feat: add OrcaRouter as a builtin OpenAI-compatible provider - #1034
feat: add OrcaRouter as a builtin OpenAI-compatible provider#1034jinhaosong-source wants to merge 1 commit into
Conversation
OrcaRouter is an OpenAI-compatible model routing gateway. This mirrors how the existing OpenRouter provider is wired so users can pick OrcaRouter models from the API mode picker and store its key like any other builtin provider. - register `orcarouter` in the builtin provider template (base URL https://api.orcarouter.ai/v1) - add the `orcaRouterApiModelKeys` group with 21 model presets, including the `orcarouter/auto`, `free`, `fusion`, `fusion-flash` and `fusion-mini` routers - map the group and the `orcaRouterApiKey` legacy secret field, resolve the provider from legacy `orcaRouter_*` model names, and reserve the provider ID for one-time secret migration - add the API key setup link and include the provider in the OpenAI-compatible session predicate - extend the config predicate, migration and thin-adapter tests
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
📝 WalkthroughWalkthroughOrcaRouter is added as a built-in OpenAI-compatible provider. The change defines its models and defaults, integrates provider detection and routing, adds API-key setup support, and extends migration and adapter tests. ChangesOrcaRouter provider
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Configuration
participant Background
participant ProviderRegistry
participant OrcaRouterAPI
Configuration->>Background: Select OrcaRouter model
Background->>Background: Detect OrcaRouter API model
Background->>ProviderRegistry: Resolve provider and endpoint
ProviderRegistry->>OrcaRouterAPI: Send chat completion request
OrcaRouterAPI-->>ProviderRegistry: Return completion response
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoAdd OrcaRouter as a built-in OpenAI-compatible provider
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/background/index.mjs`:
- Line 409: Complete the required manual browser smoke test for the OrcaRouter
API session path introduced around isUsingOrcaRouterApiModel and executeApi().
If testing cannot be performed, document the reason and the specific skipped
checks in the PR description.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c3670618-1ed0-4773-937b-1d805bbc17d4
📒 Files selected for processing (8)
src/background/index.mjssrc/config/index.mjssrc/config/openai-provider-mappings.mjssrc/popup/sections/GeneralPart.jsxsrc/services/apis/provider-registry.mjstests/unit/config/config-predicates.test.mjstests/unit/config/migrate-user-config.test.mjstests/unit/services/apis/thin-adapters.test.mjs
| isUsingNvidiaNimApiModel(session) || | ||
| isUsingOllamaApiModel(session) || | ||
| isUsingOpenRouterApiModel(session) || | ||
| isUsingOrcaRouterApiModel(session) || |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== repo files around background =="
git ls-files | rg '(^|/)(background/promise|package\.json|PR|README|README\.md|src/.*\.mjs)$' | sed -n '1,120p'
echo
echo "== src/background/index.mjs relevant section =="
if [ -f src/background/index.mjs ]; then
nl -ba src/background/index.mjs | sed -n '380,430p'
else
fd -a 'index\.mjs$' . | sed -n '1,80p'
fi
echo
echo "== references to isUsingOrcaRouterApiModel =="
rg -n "isUsingOrcaRouterApiModel|OrcaRouter|routerApiModel" . || true
echo
echo "== package scripts =="
if [ -f package.json ]; then
jq '.scripts' package.json
fi
echo
echo "== PR/objective references in tracked text files =="
rg -n "load-unpacked|manual|smoke|runtime changes|verification|ORCA|[Oo]rc[aA]|RouterApi" --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' . | sed -n '1,200p' || trueRepository: ChatGPTBox-dev/chatGPTBox
Length of output: 3654
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== src/background/index.mjs relevant section =="
awk 'NR>=380 && NR<=430 {printf "%6d\t%s\n", NR, $0}' src/background/index.mjs
echo
echo "== package scripts =="
node - <<'JS'
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
console.log(JSON.stringify(pkg.scripts || {}, null, 2));
JS
echo
echo "== references to isUsingOrcaRouterApiModel and manual verification language =="
rg -n "isUsingOrcaRouterApiModel|OrcaRouter|routerApiModel|load-unpacked|manual|smoke|runtime changes|verification|ORCA|[Oo]rc[aA]|RouterApi" --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' . | sed -n '1,240p' || trueRepository: ChatGPTBox-dev/chatGPTBox
Length of output: 17455
Complete the required manual browser smoke test.
src/background/index.mjs now routes OrcaRouter API sessions through executeApi(), which is a general runtime behavioral change. Manual browser extension testing is required; if it is skipped, document the reason and skipped checks in the PR description.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/background/index.mjs` at line 409, Complete the required manual browser
smoke test for the OrcaRouter API session path introduced around
isUsingOrcaRouterApiModel and executeApi(). If testing cannot be performed,
document the reason and the specific skipped checks in the PR description.
Source: Coding guidelines
Code Review by Qodo
Context used✅ Compliance rules (platform):
6 rules 1. Missing i18n for OrcaRouter labels
|
| orcaRouterApiModelKeys: { | ||
| value: orcaRouterApiModelKeys, | ||
| desc: 'OrcaRouter (API)', | ||
| }, |
There was a problem hiding this comment.
1. Missing i18n for orcarouter labels 📘 Rule violation ⚙ Maintainability
New user-facing desc strings for OrcaRouter models/groups were added but do not have corresponding entries in src/_locales/en/main.json. Since these desc values are passed through t(...), non-English locales cannot translate them and will fall back to raw keys.
Agent Prompt
## Issue description
New OrcaRouter UI labels (e.g., `OrcaRouter (API)`, `OrcaRouter (Auto Router)`, etc.) are introduced as translatable `desc` keys, but the corresponding English localization entries are missing.
## Issue Context
`modelNameToDesc()` calls `t(Models[...].desc)` / `t(ModelGroups[...].desc)`, so newly added `desc` strings should exist as keys in `src/_locales/en/main.json` and be propagated to other locale files.
## Fix Focus Areas
- src/config/index.mjs[298-301]
- src/config/index.mjs[635-664]
- src/utils/model-name-convert.mjs[26-49]
- src/_locales/en/main.json[69-88]
- src/_locales/fr/main.json[1-10]
- src/_locales/de/main.json[1-10]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Done — the PR description now has the results instead of a caveat. I loaded the built
For the request path specifically (the One environment note: Chrome 150 no longer honours |
Summary
Adds OrcaRouter as a builtin OpenAI-compatible provider. OrcaRouter is a model routing gateway that exposes 180+ models from OpenAI, Anthropic, Google, xAI, DeepSeek, Qwen, Moonshot, Z.ai and MiniMax behind a single endpoint and API key, plus named routers (
orcarouter/auto,free,fusion) that pick an upstream per request.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.
I'm an engineer on the OrcaRouter team.
What this changes
This mirrors the existing
openrouterprovider wiring exactly — no new mechanism, no changes to the shared request path.src/services/apis/provider-registry.mjs— registersorcarouterinBUILTIN_PROVIDER_TEMPLATE(base URLhttps://api.orcarouter.ai/v1,/chat/completions+/completions), and resolves the provider from legacyorcaRouter_*model names inresolveProviderIdFromLegacyModelName.src/config/index.mjs— addsorcaRouterApiModelKeys(22 presets) plus theirModelsentries, theorcaRouterApiModelKeys→OrcaRouter (API)group,orcaRouterApiKeyindefaultConfig,isUsingOrcaRouterApiModel,orcaRouter_auto/orcaRouter_freeindefaultApiModeIds, andorcarouterinNEWLY_RESERVED_BUILTIN_PROVIDER_IDSso a user who had already hand-rolled a custom provider with that ID gets the same one-time secret migration asxai/nvidia-nim/mistral.src/config/openai-provider-mappings.mjs—orcarouter→orcaRouterApiKeyandorcaRouterApiModelKeys→orcarouter.src/background/index.mjs— includes the provider inisUsingOpenAICompatibleApiSession.src/popup/sections/GeneralPart.jsx— API key setup link (https://www.orcarouter.ai/console; keys start withsk-orca-).newlyReservedBuiltinProvidersmigration fixture, and anorcarouter-apirow in thethin-adaptersbase-URL/auth table.Preset list (all IDs verified live against
GET /v1/modelsand a real chat completion):orcaRouter_auto/_free/_fusion/_fusion_flash/_fusion_miniorcarouter/auto,orcarouter/free,orcarouter/fusion,orcarouter/fusion-flash,orcarouter/fusion-minianthropic/claude-opus-5,anthropic/claude-sonnet-5,anthropic/claude-haiku-4.5openai/gpt-5.6-sol,openai/gpt-5.5,openai/gpt-5.5-pro,openai/gpt-5.4-minigoogle/gemini-3.6-flash,google/gemini-3.5-flash,google/gemini-3.1-pro-previewgrok/grok-4.5,kimi/kimi-k3,qwen/qwen3.7-max,z-ai/glm-5.2,deepseek/deepseek-v4-pro,deepseek/deepseek-v4-flash,minimax/minimax-m3Models outside this list are still reachable through the existing
Custom Model/ custom-provider flow, same as for OpenRouter.Verification
Ran locally on Windows (Node 22):
npm run test— 954 passed, 0 failed (948 onmasterbefore this change; the 6 new cases are the ones listed above).npm run lint— clean.npm run build— all four variants built;api.orcarouter.aipresent inbuild/chromium/background.jsandbuild/chromium/popup.js.npx prettier --checkon the changed files (LF content) — clean.Live end-to-end check against the real API, driving
generateAnswersWithOpenAICompatibleApiwith a realsk-orca-key and no fetch mocking, so the request actually left the machine through this repo's own adapter — 10/10 passed:getProviderByIdreturns nameOrcaRouter/ base URLhttps://api.orcarouter.ai/v1/builtin: trueresolveProviderIdForSessionresolves both theorcaRouterApiModelKeysgroup form and the legacyorcaRouter_openai_gpt_5_5model-name formresolveOpenAICompatibleRequestproduceshttps://api.orcarouter.ai/v1/chat/completionsand picks up the key fromproviderSecrets.orcarouterdonemessage fororcarouter/auto,anthropic/claude-opus-5,openai/gpt-5.5,google/gemini-3.5-flashandz-ai/glm-5.2Invalid token) rather than silently returning an empty answerBrowser smoke test per
AGENTS.md, driving the builtbuild/chromium/extension loaded unpacked into Chromium — 14/14 passed:popup.htmlrenders, and there are no page or console errorsOrcaRouter (Auto Router)andOrcaRouter (Free Models Router)(the two entries added todefaultApiModeIds)OpenRouter (Auto Router)/(Free Models Router)entries are still present and still precede the OrcaRouter ones, so nothing was displaced or reorderedOrcaRouter (API)in the provider-group dropdown, positioned right afterOpenRouter (API)One environment note in case you reproduce it: Chrome 150 no longer honours
--load-extension, so this ran on Edge 150 (same Chromium 150 engine, and the build under test is thebuild/chromium/MV3 variant).