zen: handle 1m context

This commit is contained in:
Frank
2026-02-06 13:57:23 -05:00
parent 89f0a447f6
commit e5b355e458

View File

@@ -20,7 +20,7 @@ export const anthropicHelper: ProviderHelper = ({ reqModel, providerModel }) =>
const isBedrockModelArn = providerModel.startsWith("arn:aws:bedrock:") const isBedrockModelArn = providerModel.startsWith("arn:aws:bedrock:")
const isBedrockModelID = providerModel.startsWith("global.anthropic.") const isBedrockModelID = providerModel.startsWith("global.anthropic.")
const isBedrock = isBedrockModelArn || isBedrockModelID const isBedrock = isBedrockModelArn || isBedrockModelID
const isSonnet = reqModel.includes("sonnet") const supports1m = reqModel.includes("sonnet") || reqModel.includes("opus-4-6")
return { return {
format: "anthropic", format: "anthropic",
modifyUrl: (providerApi: string, isStream?: boolean) => modifyUrl: (providerApi: string, isStream?: boolean) =>
@@ -33,7 +33,7 @@ export const anthropicHelper: ProviderHelper = ({ reqModel, providerModel }) =>
} else { } else {
headers.set("x-api-key", apiKey) headers.set("x-api-key", apiKey)
headers.set("anthropic-version", headers.get("anthropic-version") ?? "2023-06-01") headers.set("anthropic-version", headers.get("anthropic-version") ?? "2023-06-01")
if (body.model.startsWith("claude-sonnet-")) { if (supports1m) {
headers.set("anthropic-beta", "context-1m-2025-08-07") headers.set("anthropic-beta", "context-1m-2025-08-07")
} }
} }
@@ -43,7 +43,7 @@ export const anthropicHelper: ProviderHelper = ({ reqModel, providerModel }) =>
...(isBedrock ...(isBedrock
? { ? {
anthropic_version: "bedrock-2023-05-31", anthropic_version: "bedrock-2023-05-31",
anthropic_beta: isSonnet ? "context-1m-2025-08-07" : undefined, anthropic_beta: supports1m ? "context-1m-2025-08-07" : undefined,
model: undefined, model: undefined,
stream: undefined, stream: undefined,
} }