feat: add OrcaRouter as a built-in AI model provider#3505
Open
jinhaosong-source wants to merge 1 commit into
Open
feat: add OrcaRouter as a built-in AI model provider#3505jinhaosong-source wants to merge 1 commit into
jinhaosong-source wants to merge 1 commit into
Conversation
OrcaRouter is an OpenAI-compatible meta-router. Register it as a first-class LLMProviderType (ORCAROUTER), mirroring the OpenRouter wiring but backed by the built-in OpenAI-compatible client (no new dependency, same as qwen/zhipu): enum entry, backend provider map + includeUsage adapter, AI Settings dropdown entry + brand icon, and a unit test mirroring the OpenRouter case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
10aa77a to
4538d33
Compare
Author
|
👋 Gentle nudge — checks are passing and the PR is ready whenever you get a chance to review. Happy to address anything. Thanks for your time! |
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.
Why are these changes needed?
Disclosure: I'm an engineer on the OrcaRouter team.
OrcaRouter is an OpenAI-compatible meta-router: a single endpoint that fronts 150+ upstream
models and adds server-side routing strategies and an ordered per-request fallback list. On top
of routing it layers a security/governance product (request-level guardrails such as policy
enforcement, PII/secret redaction, and per-key access controls) and a declarative routing DSL.
Users can already connect OrcaRouter today via the generic OpenAI Compatible provider type.
This PR makes it a first-class provider so it shows up in the AI Settings provider list with
its own label, brand icon, and the correct base-URL / model placeholders — the same treatment
OpenRouter already gets — instead of asking users to know it's "OpenAI-compatible" and hand-type
the endpoint.
What changed
Mirrors the existing OpenRouter wiring, but backed by the built-in OpenAI-compatible SDK — so
there is no new dependency (same approach the
qwen/zhipu/lingyiwanwuprovider typesalready use):
packages/openapi— addORCAROUTER = 'orcarouter'to theLLMProviderTypeenum. Validationis
z.enum(LLMProviderType), so no separate string list needs updating.apps/nestjs-backend/src/features/ai/util.ts— mapORCAROUTERtocreateOpenAICompatibleWrapper(the same wrapper used byOPENAI_COMPATIBLE, which forces theChat Completions API and fixes non-standard proxy stream responses), and add
ORCAROUTERto thegetAdaptedProviderOptionscase that setsincludeUsage: true.apps/nextjs-app/.../ai-config/constant.ts— add the provider toLLM_PROVIDER_ICONSand to theLLM_PROVIDERSdropdown list (labelOrcaRouter, base URLhttps://api.orcarouter.ai/v1).packages/icons— add anOrcaRoutericon component and export it.apps/nestjs-backend/.../ai.service.spec.ts— add a unit test mirroring the OpenRouter case(verifies the new provider type flows through
getModelTagswithout spurious tag inference).Verification
pnpm --filter @teable/openapi typecheck,pnpm --filter @teable/icons typecheck, and thenestjs-backend typecheck pass with the changes.
pnpm --filter @teable/backend test-unit ai.service.spec.tspasses (including the new OrcaRoutercase).
Live-verified end-to-end against
https://api.orcarouter.ai/v1with a real key:GET /models→ 200, 172 models (orcarouter/auto,openai/gpt-5.2, etc.).POST /chat/completions(openai/gpt-4o-mini) → 200, correct content + usage.POST /chat/completions(stream:true,stream_options.include_usage:true) → 200,content streamed across chunks with usage in the final chunk — the exact path
createOpenAICompatibleWrapper+includeUsage:truehandles.modelsfallback list +route) accepted → 200.Notes
dedicated SDK package (unlike OpenRouter's
@openrouter/ai-sdk-provider).preferred.
and draft this description; I reviewed and tested the result.