feat(embeddings): add orcarouter embedding provider - #486
clementguarino06510-glitch wants to merge 1 commit into
Conversation
Add OrcaRouter as a first-class embedding provider, mirroring the existing OpenAI wiring. OrcaRouter exposes an OpenAI-compatible embeddings API on the same endpoint as its chat/agent gateway, so the OpenAI SDK path applies with ORCAROUTER_API_KEY and an optional ORCAROUTER_API_BASE override (defaults to https://api.orcarouter.ai/v1). Update the provider union and credentials check in EmbeddingFactory and EmbeddingConfig, add docs and env.example entries, and cover the new provider with unit tests.
|
Thanks for putting this together, and for the thorough writeup. However, besides the obvious merge conflicts we have now, I'm not going to merge this. OrcaRouter exposes a standard OpenAI-compatible embeddings API, and the openai provider already covers that case in full: That works today with no code changes, and dimension detection resolves Happy to take a docs-only PR adding OrcaRouter to |
Summary
Add OrcaRouter as a first-class embedding provider for the Docs MCP Server's vector search, completely parallel to the existing OpenAI provider wiring.
OrcaRouter is an OpenAI-compatible AI gateway built for both models and agents. Like OpenRouter, it exposes a provider/model namespace across many models — but it also combines adaptive routing, automatic failover, zero-markup inference, observability, guardrails, and agent-tool governance behind the same endpoint. Adding
orcarouteras a first-class provider means this project's users can use that stack directly, without treating OrcaRouter as an anonymous customOPENAI_API_BASEendpoint.It also runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes.
What's wired up
The change mirrors the existing
openaicase increateEmbeddingModelone-for-one:src/store/embeddings/EmbeddingFactory.ts"orcarouter"to theEmbeddingProviderunion, itsareCredentialsAvailablebranch (checksORCAROUTER_API_KEY), and a newcase "orcarouter"that buildsOpenAIEmbeddingsagainst the OrcaRouter endpoint — sameencodingFormat: "float"fix,batchSize, and timeout handling as the OpenAI pathsrc/store/embeddings/EmbeddingConfig.ts"orcarouter"to the provider union used for parsing/telemetry.env.exampleORCAROUTER_API_KEYand optionalORCAROUTER_API_BASEdocs/guides/embedding-models.mdsrc/store/embeddings/EmbeddingFactory.test.tsORCAROUTER_API_BASEoverride, missing-credentials errorsrc/store/embeddings/EmbeddingConfig.test.tsorcarouterto the valid-providers checkBecause OrcaRouter exposes an OpenAI-compatible embeddings endpoint on the same
https://api.orcarouter.ai/v1base URL as its chat/agent gateway, the existingOpenAIEmbeddingsSDK path applies directly — no new dependency, and the vector-dimension auto-detection already in place for OpenAI-compatible providers works unchanged. Model names follow the OrcaRouter catalog, e.g.:ORCAROUTER_API_BASEcan override the endpoint if desired.Verification
npm run lint✅ (Biome, clean)npm run typecheck✅npx vitest run src/store/embeddings✅ (59 tests pass, including the new OrcaRouter tests)npm test: the 12 failing tests (test/github-private-repo-e2e.test.tstimeouts,test/refresh-pipeline-e2e.test.tsnetwork/Invalid URLerrors) fail identically on the pristinemaintree in this environment — pre-existing and unrelated to this change.createEmbeddingModel("orcarouter:openai/text-embedding-3-small", ...): returned a 1536-dimension non-zero vector viahttps://api.orcarouter.ai/v1/embeddings.Discord: discord.gg/YEubt8enRA · X: https://x.com/OrcaRouter
I'm an engineer on the OrcaRouter team.