@@ -16,6 +16,17 @@ function mimeToModality(mime: string): Modality | undefined {
1616}
1717
1818export namespace ProviderTransform {
19+ function isAzureAnthropic ( model : Provider . Model ) : boolean {
20+ return (
21+ model . providerID === "azure-cognitive-services" &&
22+ ( model . api . id . includes ( "claude" ) || model . api . id . includes ( "anthropic" ) )
23+ )
24+ }
25+
26+ function usesAnthropicSDK ( model : Provider . Model ) : boolean {
27+ return model . api . npm === "@ai-sdk/anthropic" || isAzureAnthropic ( model )
28+ }
29+
1930 function normalizeMessages (
2031 msgs : ModelMessage [ ] ,
2132 model : Provider . Model ,
@@ -50,7 +61,7 @@ export namespace ProviderTransform {
5061
5162 // Anthropic rejects messages with empty content - filter out empty string messages
5263 // and remove empty text/reasoning parts from array content
53- if ( model . api . npm === "@ai-sdk/anthropic" ) {
64+ if ( usesAnthropicSDK ( model ) ) {
5465 msgs = msgs
5566 . map ( ( msg ) => {
5667 if ( typeof msg . content === "string" ) {
@@ -256,7 +267,7 @@ export namespace ProviderTransform {
256267 model . providerID === "anthropic" ||
257268 model . api . id . includes ( "anthropic" ) ||
258269 model . api . id . includes ( "claude" ) ||
259- model . api . npm === "@ai-sdk/anthropic"
270+ usesAnthropicSDK ( model )
260271 ) {
261272 msgs = applyCaching ( msgs , model . providerID )
262273 }
@@ -308,6 +319,23 @@ export namespace ProviderTransform {
308319 const id = model . id . toLowerCase ( )
309320 if ( id . includes ( "deepseek" ) || id . includes ( "minimax" ) || id . includes ( "glm" ) || id . includes ( "mistral" ) ) return { }
310321
322+ if ( isAzureAnthropic ( model ) ) {
323+ return {
324+ high : {
325+ thinking : {
326+ type : "enabled" ,
327+ budgetTokens : 16000 ,
328+ } ,
329+ } ,
330+ max : {
331+ thinking : {
332+ type : "enabled" ,
333+ budgetTokens : 31999 ,
334+ } ,
335+ } ,
336+ }
337+ }
338+
311339 switch ( model . api . npm ) {
312340 case "@openrouter/ai-sdk-provider" :
313341 if ( ! model . id . includes ( "gpt" ) && ! model . id . includes ( "gemini-3" ) && ! model . id . includes ( "grok-4" ) ) return { }
@@ -578,6 +606,9 @@ export namespace ProviderTransform {
578606 }
579607
580608 export function providerOptions ( model : Provider . Model , options : { [ x : string ] : any } ) {
609+ if ( isAzureAnthropic ( model ) ) {
610+ return { [ "anthropic" as string ] : options }
611+ }
581612 switch ( model . api . npm ) {
582613 case "@ai-sdk/github-copilot" :
583614 case "@ai-sdk/openai" :
@@ -613,16 +644,27 @@ export namespace ProviderTransform {
613644 }
614645 }
615646
647+ export function maxOutputTokens ( model : Provider . Model , options : Record < string , any > , globalLimit : number ) : number
616648 export function maxOutputTokens (
617649 npm : string ,
618650 options : Record < string , any > ,
619651 modelLimit : number ,
620652 globalLimit : number ,
653+ ) : number
654+ export function maxOutputTokens (
655+ arg1 : Provider . Model | string ,
656+ options : Record < string , any > ,
657+ arg3 : number ,
658+ arg4 ?: number ,
621659 ) : number {
660+ const model = typeof arg1 === "object" ? arg1 : null
661+ const npm = model ? model . api . npm : ( arg1 as string )
662+ const modelLimit = model ? model . limit . output : arg3
663+ const globalLimit = model ? arg3 : arg4 !
622664 const modelCap = modelLimit || globalLimit
623665 const standardLimit = Math . min ( modelCap , globalLimit )
624666
625- if ( npm === "@ai-sdk/anthropic" ) {
667+ if ( model ? usesAnthropicSDK ( model ) : npm === "@ai-sdk/anthropic" ) {
626668 const thinking = options ?. [ "thinking" ]
627669 const budgetTokens = typeof thinking ?. [ "budgetTokens" ] === "number" ? thinking [ "budgetTokens" ] : 0
628670 const enabled = thinking ?. [ "type" ] === "enabled"
0 commit comments