Skip to content

Add TrustedRouter as a model provider - #3135

Open
jperla wants to merge 1 commit into
onlook-dev:mainfrom
jperla:add-trustedrouter-provider
Open

Add TrustedRouter as a model provider#3135
jperla wants to merge 1 commit into
onlook-dev:mainfrom
jperla:add-trustedrouter-provider

Conversation

@jperla

@jperla jperla commented Aug 16, 2026

Copy link
Copy Markdown

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.

LLMProvider had a single member, so this extends the existing shape rather than inventing one: a TRUSTEDROUTER_MODELS enum, a ModelMapping entry, MODEL_MAX_TOKENS values, and a switch case in initModel. The assertNever default 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, and packages/ai had 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_KEY is .optional() in env.ts, unlike the required OPENROUTER_API_KEY, so existing deployments keep booting without setting it.

Model ids are namespaced — anthropic/claude-sonnet-4-6 works, a bare id is rejected. The ids under trustedrouter/ are routing policies rather than single models: auto picks per request with failover, zdr restricts routing to providers that retain no data.

Verified: bun install resolves the new dependency, and tsc --noEmit reports 0 errors in packages/ai and packages/models — the two packages this touches. Running tsc from a package directory also surfaces pre-existing path-alias errors from apps/web/client; those are unrelated to this change and present before it.

Summary by CodeRabbit

  • New Features
    • Added TrustedRouter as an available AI provider.
    • Added support for TrustedRouter routing policies and supported models.
    • Added model-specific maximum token limits for TrustedRouter options.
    • Added optional TrustedRouter API key configuration for connecting to the service.

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.
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

@jperla is attempting to deploy a commit to the Onlook Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c677c35e-571f-4d2a-8748-7bf64ad7e105

📥 Commits

Reviewing files that changed from the base of the PR and between 423e2e9 and 0084739.

📒 Files selected for processing (4)
  • apps/web/client/src/env.ts
  • packages/ai/package.json
  • packages/ai/src/chat/providers.ts
  • packages/models/src/llm/index.ts

📝 Walkthrough

Walkthrough

The 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.

Changes

TrustedRouter support

Layer / File(s) Summary
TrustedRouter model contract
packages/models/src/llm/index.ts
LLMProvider, TRUSTEDROUTER_MODELS, ModelMapping, and MODEL_MAX_TOKENS now include TrustedRouter values.
TrustedRouter provider runtime
packages/ai/src/chat/providers.ts, packages/ai/package.json, apps/web/client/src/env.ts
initModel creates TrustedRouter models through an OpenAI-compatible client. The client uses the TrustedRouter endpoint and API key. The web runtime schema exposes the optional key.
Estimated code review effort: 3 (Moderate) ~20 minutes

Merge Risk: 🔵 Low · up to 00847

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: adding TrustedRouter as a model provider.
Description check ✅ Passed The description explains the implementation, dependency, configuration, model behavior, and testing, but it omits the template's explicit sections and change-type selection.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant