Skip to content

fix(embedding): forward providerOptions.openrouter in embed/embedMany - #632

Merged
mattapperson merged 2 commits into
mainfrom
claude/embedding-provider-options
Nov 4, 2026
Merged

mattapperson merged 2 commits into
mainfrom
claude/embedding-provider-options

Conversation

@mattapperson

@mattapperson mattapperson commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Related to #616.

The embedding model ignored call-time providerOptions.openrouter. doEmbed built the request body from settings and extraBody only, so embed / embedMany calls like providerOptions: { openrouter: { provider: { only: ['x'] } } } sent no provider at all. Chat and completion already forward these options.

Changes:

  • doEmbed now takes EmbeddingModelV4CallOptions, reads providerOptions.openrouter, and spreads it into the body after settings / extraBody, the same way chat and completion do. Any field the /embeddings endpoint accepts (provider, user, dimensions, input_type, session_id, trace, ...) passes through.
  • provider routing is shallow merged with precedence settings.provider < config.extraBody.provider < settings.extraBody.provider < providerOptions.openrouter.provider. Null, array and primitive values are ignored. One behavior change: an extraBody.provider used to replace settings.provider; now the two merge.
  • README: new "Embedding Provider Options" section.

Relationship to #628

#628 (still open) adds a shared src/utils/merge-provider-routing.ts helper with the same semantics for chat, completion and image. This PR doesn't depend on #628 and doesn't touch any of its files. It uses a small local mergeProviderRouting in src/embedding/index.ts, with a TODO(#628) to swap in the shared helper once that PR merges. The two can merge in either order without conflicts.

Tests

  • Unit tests (src/embedding/index.test.ts) run real embed / embedMany against a mocked fetch and check the request body for: runtime-only provider, merging with settings.provider, the full precedence chain, ignoring a null runtime provider, passthrough of other options (user, dimensions, input_type, session_id), an unchanged body when no providerOptions are given, and provider left out when nothing sets it. 6 of these fail on main.
  • E2E regression test e2e/issues/issue-616-embedding-provider-options.test.ts: a live run against OpenRouter passes here. On main, 3 of its 4 cases fail: an unknown provider.only isn't rejected, and dimensions: 256 is ignored.

Checklist

  • I have run pnpm stylecheck and pnpm typecheck
  • I have run pnpm test and all tests pass
  • I have added tests for my changes (if applicable)
  • I have updated documentation (if applicable)

Changeset

  • I have run pnpm changeset to create a changeset file

Devin Review

Merge provider routing preferences from settings, extraBody and
providerOptions (later wins), matching chat/completion. Related to #616.
devin-ai-integration[bot]

This comment was marked as resolved.

@mattapperson
mattapperson merged commit 087abdf into main Nov 4, 2026
2 checks passed
@mattapperson
mattapperson deleted the claude/embedding-provider-options branch November 4, 2026 14:29
@github-actions github-actions Bot mentioned this pull request Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant