feat(provider): add OrcaRouter as a first-class provider - #153
Open
JinhaoSong322 wants to merge 1 commit into
Open
feat(provider): add OrcaRouter as a first-class provider#153JinhaoSong322 wants to merge 1 commit into
JinhaoSong322 wants to merge 1 commit into
Conversation
Adds OrcaRouter (OpenAI-compatible LLM routing gateway) alongside the other named OpenAI-compatible providers: - llm: register the orcarouter profile and export the named facade, mirroring groq/deepseek/togetherai - core: add OrcaRouterPlugin so bcode attribution headers are applied, mirroring the existing Zenmux/LLMGateway gateway plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #
Type of change
What does this PR do?
Adds OrcaRouter — an OpenAI-compatible LLM routing gateway — as a named provider, so it is selectable the same way as the other gateways rather than only through a hand-typed custom endpoint. It is already in the models.dev catalog (
providers/orcarouter,api = https://api.orcarouter.ai/v1,ORCAROUTER_API_KEY), so this PR is only the bcode-side wiring that catalog entry expects.Two small pieces, each mirroring existing precedent:
packages/llm— added theorcarouterentry toopenai-compatible-profile.tsand the matchingdefine(profiles.orcarouter)export, exactly likegroq/deepseek/togetherai. The API is plain OpenAI chat-completions, so no custom protocol module is needed (unlikeopenrouter.ts, which exists only for its extra body options).packages/core— addedOrcaRouterPlugin, modelled onZenmuxPlugin: it matches on@ai-sdk/openai-compatible+ the OrcaRouter base URL and setsHTTP-Referer/X-Titlewith??=so user-configured headers still win. Registered inProviderPlugins.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.
How did you verify your code works?
bun test test/plugin/inpackages/core→ 226 pass / 0 fail, including 5 new tests inprovider-orcarouter.test.tscovering registration, header application, merging with existing headers, user overrides, and that the guard does not leak onto theopenrouterprovider.bun run typecheck→ 17/17 tasks pass.bunx oxlinton the five touched files → 0 warnings / 0 errors. (The repo-widebun run lintreports the same 4760 warnings + 1 pre-existing error inpublish-llm-event.tson a cleanmainas it does with this branch.)baseURLand the attribution headers:POST /v1/chat/completionswithmodel: orcarouter/auto→ HTTP 200, routed togemini-3.1-flash-lite, response body returned as expected.Screenshots / recordings
Not a UI change.
Checklist
Disclosure: I'm an engineer on the OrcaRouter team.
Summary by cubic
Adds OrcaRouter as a first-class OpenAI-compatible provider and applies default attribution headers when using its base URL. Previously it required a custom endpoint; now you can select the
orcarouterprovider, and defaults do not override user-specified headers.orcarouterprofile (https://api.orcarouter.ai/v1) and exportsorcaroutervia the existing OpenAI-compatible facade; no custom protocol beyond@ai-sdk/openai-compatible.OrcaRouterPluginthat matches@ai-sdk/openai-compatible+ the OrcaRouter base URL and setsHTTP-RefererandX-Titlewith??=; registered inProviderPlugins.openrouteror other providers.orcarouterprovider to use it.Written for commit 792e77f. Summary will update on new commits.