fix: route Copilot Claude through Anthropic

This commit is contained in:
Peter Steinberger
2026-04-04 02:57:06 +09:00
parent e588a363f9
commit 5d20c73e05
10 changed files with 213 additions and 7 deletions

View File

@@ -11,6 +11,14 @@ const CODEX_TEMPLATE_MODEL_IDS = ["gpt-5.2-codex"] as const;
const DEFAULT_CONTEXT_WINDOW = 128_000;
const DEFAULT_MAX_TOKENS = 8192;
export function resolveCopilotTransportApi(
modelId: string,
): "anthropic-messages" | "openai-responses" {
return modelId.trim().toLowerCase().includes("claude")
? "anthropic-messages"
: "openai-responses";
}
export function resolveCopilotForwardCompatModel(
ctx: ProviderResolveDynamicModelContext,
): ProviderRuntimeModel | undefined {
@@ -56,7 +64,7 @@ export function resolveCopilotForwardCompatModel(
id: trimmedModelId,
name: trimmedModelId,
provider: PROVIDER_ID,
api: "openai-responses",
api: resolveCopilotTransportApi(trimmedModelId),
reasoning,
// Optimistic: most Copilot models support images, and the API rejects
// image payloads for text-only models rather than failing silently.