fix(ai): use dashed Claude model IDs for Cloudflare AI Gateway

The gateway's /anthropic passthrough forwards the model ID to Anthropic
unchanged. models.dev lists the gateway's Claude models with dotted
versions (claude-opus-5.5), which Anthropic rejects with a 404. Convert
dots to dashes (claude-opus-5-5) when generating the catalog.
This commit is contained in:
David Brailovsky 2026-10-02 16:10:34 +02:00
parent 1499466d85
commit c10bfb0d79
3 changed files with 7 additions and 3 deletions

View file

@ -1966,7 +1966,10 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
} else if (upstream === "anthropic") {
api = "anthropic-messages";
baseUrl = CLOUDFLARE_AI_GATEWAY_ANTHROPIC_BASE_URL;
id = nativeId;
// The /anthropic passthrough forwards the model ID to Anthropic unchanged.
// models.dev lists dotted versions (claude-opus-5.5), but Anthropic only
// accepts dashed IDs (claude-opus-5-5).
id = nativeId.replaceAll(".", "-");
} else if (upstream === "workers-ai") {
api = "openai-completions";
baseUrl = CLOUDFLARE_AI_GATEWAY_COMPAT_BASE_URL;