@@ -3292,89 +3292,74 @@ describe("ProviderTransform.variants", () => {
32923292 } )
32933293 } )
32943294
3295- describe ( "@ai-sdk/google" , ( ) => {
3296- test ( "gemini-2.5 returns high and max with thinkingConfig and thinkingBudget" , ( ) => {
3297- const model = createMockModel ( {
3298- id : "google/gemini-2.5-pro" ,
3299- providerID : "google" ,
3300- api : {
3301- id : "gemini-2.5-pro" ,
3302- url : "https://generativelanguage.googleapis.com" ,
3303- npm : "@ai-sdk/google" ,
3304- } ,
3305- } )
3306- const result = ProviderTransform . variants ( model )
3307- expect ( Object . keys ( result ) ) . toEqual ( [ "high" , "max" ] )
3308- expect ( result . high ) . toEqual ( {
3309- thinkingConfig : {
3310- includeThoughts : true ,
3311- thinkingBudget : 16000 ,
3312- } ,
3313- } )
3314- expect ( result . max ) . toEqual ( {
3315- thinkingConfig : {
3316- includeThoughts : true ,
3317- thinkingBudget : 24576 ,
3318- } ,
3319- } )
3320- } )
3321-
3322- test ( "other gemini models return low and high with thinkingLevel" , ( ) => {
3323- const model = createMockModel ( {
3324- id : "google/gemini-2.0-pro" ,
3325- providerID : "google" ,
3326- api : {
3327- id : "gemini-2.0-pro" ,
3328- url : "https://generativelanguage.googleapis.com" ,
3329- npm : "@ai-sdk/google" ,
3330- } ,
3331- } )
3332- const result = ProviderTransform . variants ( model )
3333- expect ( Object . keys ( result ) ) . toEqual ( [ "low" , "high" ] )
3334- expect ( result . low ) . toEqual ( {
3335- thinkingConfig : {
3336- includeThoughts : true ,
3337- thinkingLevel : "low" ,
3338- } ,
3339- } )
3340- expect ( result . high ) . toEqual ( {
3341- thinkingConfig : {
3342- includeThoughts : true ,
3343- thinkingLevel : "high" ,
3344- } ,
3345- } )
3346- } )
3347- } )
3348-
3349- describe ( "@ai-sdk/google-vertex" , ( ) => {
3350- test ( "gemini-2.5 returns high and max with thinkingConfig and thinkingBudget" , ( ) => {
3351- const model = createMockModel ( {
3352- id : "google-vertex/gemini-2.5-pro" ,
3353- providerID : "google-vertex" ,
3354- api : {
3355- id : "gemini-2.5-pro" ,
3356- url : "https://vertexai.googleapis.com" ,
3357- npm : "@ai-sdk/google-vertex" ,
3358- } ,
3359- } )
3360- const result = ProviderTransform . variants ( model )
3361- expect ( Object . keys ( result ) ) . toEqual ( [ "high" , "max" ] )
3362- } )
3363-
3364- test ( "other vertex models return low and high with thinkingLevel" , ( ) => {
3365- const model = createMockModel ( {
3366- id : "google-vertex/gemini-2.0-pro" ,
3367- providerID : "google-vertex" ,
3368- api : {
3369- id : "gemini-2.0-pro" ,
3370- url : "https://vertexai.googleapis.com" ,
3371- npm : "@ai-sdk/google-vertex" ,
3372- } ,
3373- } )
3374- const result = ProviderTransform . variants ( model )
3375- expect ( Object . keys ( result ) ) . toEqual ( [ "low" , "high" ] )
3295+ for ( const provider of [
3296+ { name : "@ai-sdk/google" , providerID : "google" , url : "https://generativelanguage.googleapis.com" } ,
3297+ { name : "@ai-sdk/google-vertex" , providerID : "google-vertex" , url : "https://vertexai.googleapis.com" } ,
3298+ ] ) {
3299+ describe ( provider . name , ( ) => {
3300+ for ( const testCase of [
3301+ {
3302+ apiId : "gemini-2.5-pro" ,
3303+ efforts : [ "high" , "max" ] ,
3304+ expectedHigh : { thinkingConfig : { includeThoughts : true , thinkingBudget : 16_000 } } ,
3305+ expectedMax : { thinkingConfig : { includeThoughts : true , thinkingBudget : 32_768 } } ,
3306+ } ,
3307+ {
3308+ apiId : "gemini-2.5-flash" ,
3309+ efforts : [ "high" , "max" ] ,
3310+ expectedHigh : { thinkingConfig : { includeThoughts : true , thinkingBudget : 16_000 } } ,
3311+ expectedMax : { thinkingConfig : { includeThoughts : true , thinkingBudget : 24_576 } } ,
3312+ } ,
3313+ {
3314+ apiId : "gemini-3-pro-preview" ,
3315+ efforts : [ "low" , "medium" , "high" ] ,
3316+ expectedHigh : { thinkingConfig : { includeThoughts : true , thinkingLevel : "high" } } ,
3317+ } ,
3318+ {
3319+ apiId : "gemini-3.1-pro-preview" ,
3320+ efforts : [ "low" , "medium" , "high" ] ,
3321+ expectedHigh : { thinkingConfig : { includeThoughts : true , thinkingLevel : "high" } } ,
3322+ } ,
3323+ {
3324+ apiId : "gemini-3-flash-preview" ,
3325+ efforts : [ "minimal" , "low" , "medium" , "high" ] ,
3326+ expectedHigh : { thinkingConfig : { includeThoughts : true , thinkingLevel : "high" } } ,
3327+ } ,
3328+ {
3329+ apiId : "gemini-3.1-flash-lite" ,
3330+ efforts : [ "minimal" , "low" , "medium" , "high" ] ,
3331+ expectedHigh : { thinkingConfig : { includeThoughts : true , thinkingLevel : "high" } } ,
3332+ } ,
3333+ {
3334+ apiId : "gemini-3.1-flash-image-preview" ,
3335+ efforts : [ "minimal" , "high" ] ,
3336+ expectedHigh : { thinkingConfig : { includeThoughts : true , thinkingLevel : "high" } } ,
3337+ } ,
3338+ {
3339+ apiId : "gemini-3-pro-image-preview" ,
3340+ efforts : [ "high" ] ,
3341+ expectedHigh : { thinkingConfig : { includeThoughts : true , thinkingLevel : "high" } } ,
3342+ } ,
3343+ ] ) {
3344+ test ( `${ testCase . apiId } returns supported thinking controls` , ( ) => {
3345+ const result = ProviderTransform . variants (
3346+ createMockModel ( {
3347+ id : `${ provider . providerID } /${ testCase . apiId } ` ,
3348+ providerID : provider . providerID ,
3349+ api : {
3350+ id : testCase . apiId ,
3351+ url : provider . url ,
3352+ npm : provider . name ,
3353+ } ,
3354+ } ) ,
3355+ )
3356+ expect ( Object . keys ( result ) ) . toEqual ( testCase . efforts )
3357+ expect ( result . high ) . toEqual ( testCase . expectedHigh )
3358+ if ( testCase . expectedMax ) expect ( result . max ) . toEqual ( testCase . expectedMax )
3359+ } )
3360+ }
33763361 } )
3377- } )
3362+ }
33783363
33793364 describe ( "@ai-sdk/cohere" , ( ) => {
33803365 test ( "returns empty object" , ( ) => {
@@ -3640,6 +3625,32 @@ describe("ProviderTransform.smallOptions - gpt-5 chat/search", () => {
36403625 }
36413626} )
36423627
3628+ describe ( "ProviderTransform.smallOptions - google thinking controls" , ( ) => {
3629+ const createGoogleModel = ( apiId : string ) =>
3630+ ( {
3631+ id : `google/${ apiId } ` ,
3632+ providerID : "google" ,
3633+ api : {
3634+ id : apiId ,
3635+ url : "https://generativelanguage.googleapis.com" ,
3636+ npm : "@ai-sdk/google" ,
3637+ } ,
3638+ } ) as any
3639+
3640+ for ( const testCase of [
3641+ { id : "gemini-3-pro-preview" , options : { thinkingConfig : { thinkingLevel : "low" } } } ,
3642+ { id : "gemini-3-flash-preview" , options : { thinkingConfig : { thinkingLevel : "minimal" } } } ,
3643+ { id : "gemini-3.1-flash-image-preview" , options : { thinkingConfig : { thinkingLevel : "minimal" } } } ,
3644+ { id : "gemini-3-pro-image-preview" , options : { thinkingConfig : { thinkingLevel : "high" } } } ,
3645+ { id : "gemini-2.5-pro" , options : { thinkingConfig : { thinkingBudget : 128 } } } ,
3646+ { id : "gemini-2.5-flash" , options : { thinkingConfig : { thinkingBudget : 0 } } } ,
3647+ ] ) {
3648+ test ( `${ testCase . id } returns supported small thinking options` , ( ) => {
3649+ expect ( ProviderTransform . smallOptions ( createGoogleModel ( testCase . id ) ) ) . toEqual ( testCase . options )
3650+ } )
3651+ }
3652+ } )
3653+
36433654describe ( "ProviderTransform.providerOptions - ai-gateway-provider" , ( ) => {
36443655 const createModel = ( overrides : Partial < any > = { } ) =>
36453656 ( {
0 commit comments