File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,11 +142,15 @@ export function resolveProvider(
142142 if ( providerId === 'anthropic' && ! apiKey ) {
143143 const orKey = process . env [ 'OPENROUTER_API_KEY' ] ;
144144 if ( orKey ) {
145+ // Anthropic's native API takes dated model IDs (e.g. "claude-haiku-4-5-20251001").
146+ // OpenRouter exposes Anthropic models under dateless slugs (e.g. "anthropic/claude-haiku-4-5").
147+ // Strip a trailing -YYYYMMDD release-date suffix when remapping so the OR call resolves.
148+ const orModelId = modelId . replace ( / - \d { 8 } $ / , '' ) ;
145149 console . warn (
146- `[AgentOS] ANTHROPIC_API_KEY not set — falling back to OpenRouter for model "${ modelId } ". ` +
147- `Set ANTHROPIC_API_KEY for direct access.`
150+ `[AgentOS] ANTHROPIC_API_KEY not set — falling back to OpenRouter for model "${ modelId } " ` +
151+ `(routed as "anthropic/ ${ orModelId } "). Set ANTHROPIC_API_KEY for direct access.`
148152 ) ;
149- return { providerId : 'openrouter' , modelId : `anthropic/${ modelId } ` , apiKey : orKey } ;
153+ return { providerId : 'openrouter' , modelId : `anthropic/${ orModelId } ` , apiKey : orKey } ;
150154 }
151155 throw new Error ( `No API key for anthropic. Set ANTHROPIC_API_KEY or OPENROUTER_API_KEY.` ) ;
152156 }
You can’t perform that action at this time.
0 commit comments