@@ -3504,7 +3504,7 @@ describe("ProviderTransform.variants", () => {
35043504 } )
35053505
35063506 describe ( "@jerome-benoit/sap-ai-provider-v2" , ( ) => {
3507- const sapModel = ( apiId : string ) =>
3507+ const sapModel = ( apiId : string , releaseDate = "2024-01-01" ) =>
35083508 createMockModel ( {
35093509 id : `sap-ai-core/${ apiId } ` ,
35103510 providerID : "sap-ai-core" ,
@@ -3513,78 +3513,110 @@ describe("ProviderTransform.variants", () => {
35133513 url : "https://api.ai.sap" ,
35143514 npm : "@jerome-benoit/sap-ai-provider-v2" ,
35153515 } ,
3516+ release_date : releaseDate ,
35163517 } )
35173518
35183519 for ( const testCase of [
35193520 {
35203521 name : "sonnet 4.6" ,
35213522 apiIds : [ "anthropic--claude-sonnet-4-6" ] ,
35223523 efforts : [ "low" , "medium" , "high" , "max" ] ,
3523- expectedHigh : { thinking : { type : "adaptive" } , effort : "high " } ,
3524+ thinking : { type : "adaptive" } ,
35243525 } ,
35253526 {
35263527 name : "opus 4.6" ,
35273528 apiIds : [ "anthropic--claude-4.6-opus" , "anthropic--claude-4-6-opus" ] ,
35283529 efforts : [ "low" , "medium" , "high" , "max" ] ,
3529- expectedHigh : { thinking : { type : "adaptive" } , effort : "high " } ,
3530+ thinking : { type : "adaptive" } ,
35303531 } ,
35313532 {
35323533 name : "opus 4.7" ,
35333534 apiIds : [ "anthropic--claude-4.7-opus" , "anthropic--claude-4-7-opus" ] ,
35343535 efforts : [ "low" , "medium" , "high" , "xhigh" , "max" ] ,
3535- expectedHigh : { thinking : { type : "adaptive" , display : "summarized" } , effort : "high " } ,
3536+ thinking : { type : "adaptive" , display : "summarized" } ,
35363537 } ,
35373538 {
35383539 name : "opus 4.8" ,
35393540 apiIds : [ "anthropic--claude-4.8-opus" , "anthropic--claude-4-8-opus" ] ,
35403541 efforts : [ "low" , "medium" , "high" , "xhigh" , "max" ] ,
3541- expectedHigh : { thinking : { type : "adaptive" , display : "summarized" } , effort : "high " } ,
3542+ thinking : { type : "adaptive" , display : "summarized" } ,
35423543 } ,
35433544 ] ) {
35443545 for ( const apiId of testCase . apiIds ) {
3545- test ( `${ testCase . name } ${ apiId } returns adaptive thinking variants` , ( ) => {
3546+ test ( `${ testCase . name } ${ apiId } returns adaptive thinking variants under modelParams ` , ( ) => {
35463547 const result = ProviderTransform . variants ( sapModel ( apiId ) )
35473548 expect ( Object . keys ( result ) ) . toEqual ( testCase . efforts )
3548- expect ( result . high ) . toEqual ( testCase . expectedHigh )
3549- if ( testCase . efforts . includes ( "xhigh" ) ) {
3550- expect ( result . xhigh ) . toEqual ( { ...testCase . expectedHigh , effort : "xhigh" } )
3549+ for ( const effort of testCase . efforts ) {
3550+ expect ( result [ effort ] ) . toEqual ( {
3551+ modelParams : {
3552+ thinking : testCase . thinking ,
3553+ output_config : { effort } ,
3554+ } ,
3555+ } )
35513556 }
35523557 } )
35533558 }
35543559 }
35553560
3556- test ( "anthropic sonnet 4 returns budget-tokens variants" , ( ) => {
3557- const result = ProviderTransform . variants ( sapModel ( "anthropic--claude-sonnet-4" ) )
3558- expect ( Object . keys ( result ) ) . toEqual ( [ "high" , "max" ] )
3559- expect ( result . high ) . toEqual ( { thinking : { type : "enabled" , budgetTokens : 16000 } } )
3560- expect ( result . max ) . toEqual ( { thinking : { type : "enabled" , budgetTokens : 31999 } } )
3561- } )
3562-
3563- test ( "gemini 2.5 returns thinkingConfig variants" , ( ) => {
3564- const result = ProviderTransform . variants ( sapModel ( "gcp--gemini-2.5-pro" ) )
3565- expect ( Object . keys ( result ) ) . toEqual ( [ "high" , "max" ] )
3566- expect ( result . high ) . toEqual ( { thinkingConfig : { includeThoughts : true , thinkingBudget : 16000 } } )
3567- expect ( result . max ) . toEqual ( { thinkingConfig : { includeThoughts : true , thinkingBudget : 24576 } } )
3568- } )
3569-
3570- for ( const apiId of [ "azure-openai--gpt-4o" , "azure-openai--o3-mini" ] ) {
3571- test ( `${ apiId } returns reasoningEffort variants` , ( ) => {
3561+ for ( const apiId of [ "anthropic--claude-sonnet-4" , "anthropic--claude-4.5-opus" ] ) {
3562+ test ( `${ apiId } returns budget_tokens variants under modelParams` , ( ) => {
35723563 const result = ProviderTransform . variants ( sapModel ( apiId ) )
3573- expect ( Object . keys ( result ) ) . toEqual ( [ "low" , "medium" , "high" ] )
3574- expect ( result . low ) . toEqual ( { reasoningEffort : "low" } )
3575- expect ( result . high ) . toEqual ( { reasoningEffort : "high" } )
3564+ expect ( Object . keys ( result ) ) . toEqual ( [ "high" , "max" ] )
3565+ expect ( result . high ) . toEqual ( {
3566+ modelParams : { thinking : { type : "enabled" , budget_tokens : 16000 } } ,
3567+ } )
3568+ expect ( result . max ) . toEqual ( {
3569+ modelParams : { thinking : { type : "enabled" , budget_tokens : 31999 } } ,
3570+ } )
35763571 } )
35773572 }
35783573
3579- for ( const apiId of [ "perplexity--sonar-pro" , "mistral--mistral-large" ] ) {
3580- test ( `${ apiId } returns empty object` , ( ) => {
3581- expect ( ProviderTransform . variants ( sapModel ( apiId ) ) ) . toEqual ( { } )
3574+ for ( const testCase of [
3575+ { apiId : "gemini-2.5-pro" , maxBudget : 32768 } ,
3576+ { apiId : "gemini-2.5-flash" , maxBudget : 24576 } ,
3577+ ] ) {
3578+ test ( `${ testCase . apiId } returns thinkingConfig variants under modelParams` , ( ) => {
3579+ const result = ProviderTransform . variants ( sapModel ( testCase . apiId ) )
3580+ expect ( Object . keys ( result ) ) . toEqual ( [ "high" , "max" ] )
3581+ expect ( result . high ) . toEqual ( {
3582+ modelParams : { thinkingConfig : { includeThoughts : true , thinkingBudget : 16000 } } ,
3583+ } )
3584+ expect ( result . max ) . toEqual ( {
3585+ modelParams : { thinkingConfig : { includeThoughts : true , thinkingBudget : testCase . maxBudget } } ,
3586+ } )
35823587 } )
35833588 }
35843589
3585- test ( "non-anthropic models with opus-like substrings do not get adaptive thinking" , ( ) => {
3586- expect ( ProviderTransform . variants ( sapModel ( "aws--llama-opus-4.7-fake" ) ) ) . toEqual ( { } )
3587- } )
3590+ for ( const testCase of [
3591+ { apiId : "gpt-5" , releaseDate : "2025-08-07" , efforts : [ "minimal" , "low" , "medium" , "high" ] } ,
3592+ { apiId : "gpt-5-mini" , releaseDate : "2025-08-07" , efforts : [ "minimal" , "low" , "medium" , "high" ] } ,
3593+ { apiId : "gpt-5-nano" , releaseDate : "2025-08-07" , efforts : [ "minimal" , "low" , "medium" , "high" ] } ,
3594+ { apiId : "gpt-5.4" , releaseDate : "2026-01-15" , efforts : [ "none" , "low" , "medium" , "high" , "xhigh" ] } ,
3595+ { apiId : "azure-openai--o3-mini" , releaseDate : "2024-01-01" , efforts : [ "low" , "medium" , "high" ] } ,
3596+ ] ) {
3597+ test ( `${ testCase . apiId } returns reasoning_effort variants under modelParams` , ( ) => {
3598+ const result = ProviderTransform . variants ( sapModel ( testCase . apiId , testCase . releaseDate ) )
3599+ expect ( Object . keys ( result ) ) . toEqual ( testCase . efforts )
3600+ for ( const effort of testCase . efforts ) {
3601+ expect ( result [ effort ] ) . toEqual ( { modelParams : { reasoning_effort : effort } } )
3602+ }
3603+ } )
3604+ }
3605+
3606+ for ( const apiId of [
3607+ "gemini-3.1-flash-lite" ,
3608+ "cohere--command-a-reasoning" ,
3609+ "sonar-deep-research" ,
3610+ "aws--llama-opus-4.7-fake" ,
3611+ ] ) {
3612+ test ( `${ apiId } falls through to harmonized reasoning_effort fallback` , ( ) => {
3613+ const result = ProviderTransform . variants ( sapModel ( apiId ) )
3614+ expect ( Object . keys ( result ) ) . toEqual ( [ "low" , "medium" , "high" ] )
3615+ for ( const effort of [ "low" , "medium" , "high" ] ) {
3616+ expect ( result [ effort ] ) . toEqual ( { modelParams : { reasoning_effort : effort } } )
3617+ }
3618+ } )
3619+ }
35883620 } )
35893621
35903622 describe ( "ai-gateway-provider (cloudflare-ai-gateway)" , ( ) => {
0 commit comments