Skip to content

Fix openrouter behavior with gemini - #1154

Merged
Erin McNulty (erin2722) merged 3 commits into
mainfrom
fix/openrouter-fallback-index
Aug 24, 2026
Merged

Fix openrouter behavior with gemini#1154
Erin McNulty (erin2722) merged 3 commits into
mainfrom
fix/openrouter-fallback-index

Conversation

@erin2722

Copy link
Copy Markdown
Contributor

openrouter should be listed as a primary provider for gemini models, so that the secret list endpoint returns openrouter as a candidate provider for these gemini models.

tested with the control plane preview link:

erinmcnulty@E-McNulty proxy % curl -i http://localhost:9090/v1/chat/completions \
    -H "Authorization: Bearer $BRAINTRUST_API_KEY" \
    -H "Content-Type: application/json" \
    -H "x-bt-endpoint-name: OPENROUTER_API_KEY" \
    -d '{
      "model": "gemini-2.5-flash",
      "messages": [{"role": "user", "content": "Say hello in one short sentence."}]
    }'
HTTP/1.1 200 OK
content-length: 812
x-bt-passthrough: false
x-bt-used-endpoint: OPENROUTER_API_KEY
...
         
{"id":"gen-1787585709-jIAHx94UTtSYlP4jIrWW","object":"chat.completion","created":1787585709,"model":"google/gemini-2.5-flash","provider":"Google","system_fingerprint":null,"service_tier":"default","choices":[{"index":0,"logprobs":null,"finish_reason":"stop","native_finish_reason":"STOP","message":{"role":"assistant","content":"Hello!","refusal":null,"reasoning":null}}],"usage":{"prompt_tokens":7,"completion_tokens":2,"total_tokens":9,"cost":0.0000071,"is_byok":false,"prompt_tokens_details":{"cached_tokens":0,"cache_write_tokens":0,"audio_tokens":0,"video_tokens":0},"cost_details":{"upstream_inference_cost":0.0000071,"upstream_inference_prompt_cost":0.0000021,"upstream_inference_completions_cost":0.000005},"completion_tokens_details":{"reasoning_tokens":0,"image_tokens":0,"audio_tokens":0}}}

Previously providersForExactModelName stripped openrouter from a model's DIRECT
index.ts endpoint types unless openrouter was the model's only provider. That
meant a native model that is also served by OpenRouter (e.g. gemini-*, gpt-5.x)
never listed openrouter in getDirectModelEndpointTypes, so it was unreachable
via OpenRouter — both as a fallback and for a customer whose only configured
provider is OpenRouter — even though model_list.json already carried openrouter
in available_providers.

Keep openrouter in the direct endpoint types, but order it LAST so native /
first-class providers stay preferred (openrouter is only selected as a fallback
or when it is the customer's only configured provider). vertex continues to be
represented via its separate publishers/ fallback id.

Regenerate the affected AvailableEndpointTypes entries (25 rewritten to append
openrouter, 4 added for previously entry-less gemini-2.5 ids; 62 already carried
openrouter). Update the getDirectModelEndpointTypes / providersForExactModelName
tests to the new fallback behavior and add direct coverage for the ordering.

NOTE: the sync's catch-all only ADDS missing mappings; a future OpenRouter union
onto a model that already has an index.ts entry still needs the same one-time
backfill (or a follow-up to make the mapping pass self-healing).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-proxy Ready Ready Preview Aug 24, 2026 3:51pm

Request Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45c5af8691

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread packages/proxy/scripts/sync_models.ts
"Qwen/Qwen3.7-Plus": ["together"],
"qwen/qwen3.6-27b": ["groq"],
"gemini-3-pro-image": ["google"],
"qwen/qwen3.6-27b": ["groq", "openrouter"],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sync-models update caught a few other cases where index.ts should've had the openrouter candidate, so added these as a driveby

@CLowbrow Alex Z (CLowbrow) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@erin2722
Erin McNulty (erin2722) merged commit c686d15 into main Aug 24, 2026
8 checks passed
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.

2 participants