Add TrustedRouter as a model provider - #3135
Conversation
OpenAI-compatible, so it uses @ai-sdk/openai-compatible with an explicit baseURL. TRUSTEDROUTER_API_KEY is optional in env so existing deployments are unaffected.
|
@jperla is attempting to deploy a commit to the Onlook Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe change adds TrustedRouter as an LLM provider. It defines four TrustedRouter models, adds token limits, validates the optional API key, and initializes models through an OpenAI-compatible client. ChangesTrustedRouter support
Merge Risk: 🔵 Low · up to The PR adds TrustedRouter support, but its routing aliases and streaming configuration still need owner confirmation because upstream output limits or usage accounting could be affected. The change is mergeable with explicit follow-up on these provider-specific behaviors. Sequence Diagram(s)sequenceDiagram
participant initModel
participant getTrustedRouterProvider
participant OpenAICompatibleClient
participant TrustedRouterAPI
initModel->>getTrustedRouterProvider: requested TrustedRouter model and environment
getTrustedRouterProvider->>OpenAICompatibleClient: configure API key and TrustedRouter endpoint
OpenAICompatibleClient->>TrustedRouterAPI: send request for selected model
TrustedRouterAPI-->>OpenAICompatibleClient: return model response
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
Adds TrustedRouter as a second model provider. It's an OpenAI-compatible router — one key reaches models from OpenAI, Anthropic, Google, DeepSeek and others, with per-request routing and failover.
LLMProviderhad a single member, so this extends the existing shape rather than inventing one: aTRUSTEDROUTER_MODELSenum, aModelMappingentry,MODEL_MAX_TOKENSvalues, and aswitchcase ininitModel. TheassertNeverdefault meant the compiler required the new case, which is a nice guarantee.New dependency:
@ai-sdk/openai-compatible. TrustedRouter has no bespoke AI SDK package, andpackages/aihad no generic OpenAI-compatible provider — only@openrouter/ai-sdk-provider. This is the standard AI SDK v5 package for exactly this case. Say the word if you'd rather I route it through something already present.TRUSTEDROUTER_API_KEYis.optional()inenv.ts, unlike the requiredOPENROUTER_API_KEY, so existing deployments keep booting without setting it.Model ids are namespaced —
anthropic/claude-sonnet-4-6works, a bare id is rejected. The ids undertrustedrouter/are routing policies rather than single models:autopicks per request with failover,zdrrestricts routing to providers that retain no data.Verified:
bun installresolves the new dependency, andtsc --noEmitreports 0 errors inpackages/aiandpackages/models— the two packages this touches. Running tsc from a package directory also surfaces pre-existing path-alias errors fromapps/web/client; those are unrelated to this change and present before it.Summary by CodeRabbit