@@ -155,11 +155,24 @@ async function getAnthropicApiKey(): Promise<string | null> {
155155 return null;
156156 }
157157
158+/**
159+ * Strip the trailing date suffix from an Anthropic model ID to produce the
160+ * short alias that the OAuth / Claude Code inference endpoint expects.
161+ * e.g. "claude-sonnet-4-6-20250725" → "claude-sonnet-4-6"
162+ * "claude-opus-4-0-20250514" → "claude-opus-4-0"
163+ * Returns null if the ID has no date suffix.
164+ */
165+function stripAnthropicDateSuffix(modelId: string): string | null {
166+ const match = modelId.match(/^(.+)-(\d{8})$/);
167+ return match?.[1] ?? null;
168+}
169+
158170 async function fetchAnthropicModels(): Promise<
159171 ProviderModelCandidate[] | null
160172 > {
161173 const key = await getAnthropicApiKey();
162174 if (!key) return null;
175+ const usingOAuth = !process.env.ANTHROPIC_API_KEY;
163176
164177 const payload = await fetchJson(
165178 `${ANTHROPIC_BASE}/v1/models`,
@@ -177,8 +190,12 @@ async function fetchAnthropicModels(): Promise<
177190 item.display_name.trim().length > 0
178191 ? item.display_name
179192 : modelId;
193+ // OAuth inference requires short aliases (no date suffix).
194+ const effectiveId = usingOAuth
195+ ? (stripAnthropicDateSuffix(modelId) ?? modelId)
196+ : modelId;
180197 return {
181- providerModelId: modelId,
198+ providerModelId: effectiveId,
182199 displayName,
183200 contextWindow: null,
184201 free: false,