@@ -254,47 +254,112 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
254254 // Helper to guess model info from custom modelId string if not in bedrockModels
255255 private guessModelInfoFromId ( modelId : string ) : Partial < ModelInfo > {
256256 // Define a mapping for model ID patterns and their configurations
257+ // Order matters - more specific patterns should come first
257258 const modelConfigMap : Record < string , Partial < ModelInfo > > = {
258- "claude-4" : {
259+ // Claude 4.5 Sonnet (most specific)
260+ "claude-sonnet-4-5" : {
259261 maxTokens : 8192 ,
260262 contextWindow : 200_000 ,
261263 supportsImages : true ,
264+ supportsComputerUse : true ,
262265 supportsPromptCache : true ,
266+ supportsReasoningBudget : true ,
263267 } ,
264- "claude-3-7" : {
268+ // Claude 4 Sonnet
269+ "claude-sonnet-4" : {
265270 maxTokens : 8192 ,
266271 contextWindow : 200_000 ,
267272 supportsImages : true ,
273+ supportsComputerUse : true ,
268274 supportsPromptCache : true ,
275+ supportsReasoningBudget : true ,
269276 } ,
270- "claude-3-5" : {
277+ // Claude 4 Opus
278+ "claude-opus-4" : {
271279 maxTokens : 8192 ,
272280 contextWindow : 200_000 ,
273281 supportsImages : true ,
282+ supportsComputerUse : true ,
274283 supportsPromptCache : true ,
284+ supportsReasoningBudget : true ,
275285 } ,
276- "claude-4-opus" : {
277- maxTokens : 4096 ,
286+ // Claude 3.7 Sonnet
287+ "claude-3-7-sonnet" : {
288+ maxTokens : 8192 ,
278289 contextWindow : 200_000 ,
279290 supportsImages : true ,
291+ supportsComputerUse : true ,
280292 supportsPromptCache : true ,
293+ supportsReasoningBudget : true ,
281294 } ,
295+ // Claude 3.5 Sonnet
296+ "claude-3-5-sonnet" : {
297+ maxTokens : 8192 ,
298+ contextWindow : 200_000 ,
299+ supportsImages : true ,
300+ supportsComputerUse : true ,
301+ supportsPromptCache : true ,
302+ } ,
303+ // Claude 3.5 Haiku
304+ "claude-3-5-haiku" : {
305+ maxTokens : 8192 ,
306+ contextWindow : 200_000 ,
307+ supportsImages : false ,
308+ supportsPromptCache : true ,
309+ } ,
310+ // Claude 3 Opus
282311 "claude-3-opus" : {
283312 maxTokens : 4096 ,
284313 contextWindow : 200_000 ,
285314 supportsImages : true ,
286- supportsPromptCache : true ,
315+ supportsPromptCache : false ,
316+ } ,
317+ // Claude 3 Sonnet
318+ "claude-3-sonnet" : {
319+ maxTokens : 4096 ,
320+ contextWindow : 200_000 ,
321+ supportsImages : true ,
322+ supportsPromptCache : false ,
287323 } ,
324+ // Claude 3 Haiku
288325 "claude-3-haiku" : {
289326 maxTokens : 4096 ,
290327 contextWindow : 200_000 ,
291328 supportsImages : true ,
329+ supportsPromptCache : false ,
330+ } ,
331+ // Generic Claude 4 (fallback for any Claude 4 variant)
332+ "claude-4" : {
333+ maxTokens : 8192 ,
334+ contextWindow : 200_000 ,
335+ supportsImages : true ,
336+ supportsComputerUse : true ,
337+ supportsPromptCache : true ,
338+ supportsReasoningBudget : true ,
339+ } ,
340+ // Generic Claude 3.7
341+ "claude-3-7" : {
342+ maxTokens : 8192 ,
343+ contextWindow : 200_000 ,
344+ supportsImages : true ,
345+ supportsComputerUse : true ,
346+ supportsPromptCache : true ,
347+ supportsReasoningBudget : true ,
348+ } ,
349+ // Generic Claude 3.5
350+ "claude-3-5" : {
351+ maxTokens : 8192 ,
352+ contextWindow : 200_000 ,
353+ supportsImages : true ,
354+ supportsComputerUse : true ,
292355 supportsPromptCache : true ,
293356 } ,
294357 }
295358
296359 // Match the model ID to a configuration
297360 const id = modelId . toLowerCase ( )
361+
362+ // Check patterns in order (more specific first)
298363 for ( const [ pattern , config ] of Object . entries ( modelConfigMap ) ) {
299364 if ( id . includes ( pattern ) ) {
300365 return config
@@ -885,6 +950,24 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
885950 }
886951 }
887952
953+ // Also handle additional regional prefixes that might not be in the mapping
954+ // These are commonly used in cross-region inference IDs
955+ const additionalRegionalPrefixes = [
956+ "au." , // Australia (e.g., au.anthropic.claude-sonnet-4-5-20250929-v1:0)
957+ "af." , // Africa
958+ "me." , // Middle East
959+ "il." , // Israel
960+ "cn." , // China
961+ "jp." , // Japan (alternative to ap-)
962+ ]
963+
964+ for ( const prefix of additionalRegionalPrefixes ) {
965+ if ( modelId . startsWith ( prefix ) ) {
966+ // Remove the regional prefix from the model ID
967+ return modelId . substring ( prefix . length )
968+ }
969+ }
970+
888971 // Return the model ID as-is for all other cases
889972 return modelId
890973 }
0 commit comments