feat: add OrcaRouter embedding provider - #923
kuswardhanietidims-svg wants to merge 2 commits into
Conversation
Adds a named OrcaRouter embedding provider (--provider orcarouter) mirroring the existing Voyage integration. OrcaRouter is an OpenAI-compatible AI gateway that serves hosted open-source and vendor embedding models behind a single API key. - OrcaRouterEmbeddingProvider with endpoint-aware identity - get_provider branch reading ORCAROUTER_API_KEY with CRG_ORCAROUTER_* overrides and a default base URL of https://api.orcarouter.ai/v1 - provider choices, docstrings, README env table, and docs updated - tests for factory resolution, env/model overrides, and structured errors Co-Authored-By: Claude <noreply@anthropic.com>
code-review-graph reviewOverall risk: 0.65 (MEDIUM) — 20 changed function(s)/class(es), 48 affected flow(s), 10 test gap(s) Risk-scored changes
Affected execution flows
Test gaps
Token savings: this graph-backed report used ~95,386 fewer tokens (~85%) than reading every changed file in full (estimated, chars/4 approximation). Powered by code-review-graph — local-first analysis; no code leaves the CI runner. |
|
Thanks for a clean, well-formed patch — it passes every gate, the key never leaves the
Everything this adds is already reachable today, with no code change: CRG_OPENAI_API_KEY=$ORCAROUTER_API_KEY \
CRG_OPENAI_BASE_URL=https://api.orcarouter.ai/v1 \
CRG_OPENAI_MODEL=openai/text-embedding-3-small \
CRG_ACCEPT_CLOUD_EMBEDDINGS=1 \
code-review-graph embed --provider openaiVector-space isolation is already handled on that path: The Voyage provider is the precedent people reach for here, and it's the one that shows the test I apply. Voyage needed its own class because it genuinely cannot ride the OpenAI wire format — it sends What I'd take instead: a one-line addition to the README's existing OpenAI-compatible section, listing OrcaRouter beside new-api, LiteLLM and vLLM, with the configuration above. Same bytes on the wire for the user, zero new code paths, and OrcaRouter becomes discoverable to anyone reading the docs. If you'd like to rework this PR into that, I'll merge it. One request if you do: keep the copy to what the code does. The PR description covers adaptive routing, failover, zero-trust prompt screening, observability and agent-tool governance — none of which relates to |
Rework per maintainer review (PR tirth8205#923): drop the dedicated OrcaRouterEmbeddingProvider and instead list OrcaRouter beside new-api/LiteLLM/vLLM as an OpenAI-compatible /v1/embeddings endpoint, reachable today via CRG_OPENAI_BASE_URL/CRG_OPENAI_API_KEY with the openai provider. Same bytes on the wire, no new code paths. Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks — that's a fair bar, and you're right on every count. The provider sent byte-identical requests to the existing openai path (only What changed:
export CRG_OPENAI_BASE_URL=https://api.orcarouter.ai/v1
export CRG_OPENAI_API_KEY=$ORCAROUTER_API_KEY
export CRG_OPENAI_MODEL=openai/text-embedding-3-small
export CRG_ACCEPT_CLOUD_EMBEDDINGS=1
code-review-graph embed --provider openai
One note so it doesn't look like a regression: If this shape works, happy to adjust wording or placement. |
|
Outside this sweep's mission of verified coding-session token savings: the current net diff is README-only endpoint documentation. The provider implementation was removed in the later commit, so there is no runtime change left to retain. |
|
This no longer merges into git fetch origin && git merge origin/staging
# resolve, then
uv run pytest tests/ -q
uv run ruff check code_review_graph/
uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional
git pushWhen resolving:
A large integration branch landed on PRs now target |
|
This no longer merges into All of it is prose, so taking staging's text and re-applying your lines on top should be the whole job. git fetch origin
git merge origin/staging
# resolve, then
uv run pytest tests/ -q
uv run ruff check code_review_graph/
uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional
git pushI have not reviewed the change itself yet. That comes once it merges and the checks run against the merged state, since staging has moved a long way and the result is what matters. |
Adds OrcaRouter as a first-class embedding provider, so code-review-graph users can switch to
--provider orcarouterand embed with any model OrcaRouter routes — no anonymousCRG_OPENAI_BASE_URLneeded.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 custom base URL. 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.This mirrors the existing Voyage AI integration: a dedicated provider class with an endpoint-aware
nameidentity, aget_providerbranch that readsORCAROUTER_API_KEY(default endpointhttps://api.orcarouter.ai/v1, default modelopenai/text-embedding-3-small), CLI provider choices, README env-var table, and docstrings. Since OrcaRouter serves OpenAI-compatible/v1/embeddings, the provider reuses the existing OpenAI-compatible wire path (retries, dimension pinning, batch size).Verified locally:
ruff check,mypy, and the full test suite pass (2991 passed, 9 skipped). Live test againsthttps://api.orcarouter.ai/v1/embeddingswith a real key returned 1536-dim vectors for bothembed()andembed_query().Discord: discord.gg/YEubt8enRA · X: https://x.com/OrcaRouter
I'm an engineer on the OrcaRouter team.