fix(provider): send Anthropic's dashed native slug through the AI Gateway - #44251
Closed
superhighfives wants to merge 1 commit into
Closed
fix(provider): send Anthropic's dashed native slug through the AI Gateway#44251superhighfives wants to merge 1 commit into
superhighfives wants to merge 1 commit into
Conversation
The Unified API forwards the model id straight to the upstream provider. models.dev lists Anthropic ids with dotted versions (claude-haiku-4.5) but Anthropic's real slugs use dashes (claude-haiku-4-5), so a dotted id 404s and unified billing / BYOK never works for any Anthropic model. Other proxied providers use dots natively, so the fix is scoped to the anthropic/ prefix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
4 tasks
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Contributor
Author
|
Ah, I think we're using the legacy endpoint here. Closing. |
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 #44252
Type of change
What does this PR do?
Every Anthropic model under
cloudflare-ai-gatewayfails withError: model: claude-haiku-4.5, so none of them are usable.The plugin already routes
anthropic/*models through Anthropic's native Messages passthrough (createAnthropic), which forwards the sliced model id to Anthropic's API unchanged. models.dev lists Cloudflare's canonical dotted ids (anthropic/claude-haiku-4.5), but Anthropic's Messages API expects dashed native slugs (claude-haiku-4-5) — so it 404s.The fix translates dots to dashes when slicing the
anthropic/prefix. OpenAI is unaffected because its native slugs already use dots (gpt-4.1), which is why only Anthropic was broken.Worth noting: Cloudflare's own catalog-aware REST endpoints (
/ai/v1/messages,/ai/run) accept the dotted id and do this exact dot→dash translation internally before calling Anthropic. The native passthrough route this plugin uses forwards the slug raw, so the plugin has to do the same translation. The dotted id in models.dev is correct — it's Cloudflare's canonical id (see https://developers.cloudflare.com/ai/models/anthropic/claude-haiku-4.5/), so this is fixed on the opencode side, not in the catalog. (Context: surfaced while testing anomalyco/models.dev#4922.)How did you verify your code works?
anthropic/claude-haiku-4.5went fromError: model: claude-haiku-4.5to a normal completion;openai/*andworkers-ai/@cf/*still work.cf-ai-gateway-e2e.test.tsasserting a dotted Anthropic id reaches the Anthropic Messages wire as a dashed slug; confirmed it fails without the fix and passes with it.bun test test/provider/inpackages/opencodepasses (one unrelated pre-existing flake inheader-timeout.test.ts, which also fails ondev).tsgo --noEmitclean.Screenshots / recordings
N/A (not a UI change).
Checklist