Skip to content

Commit ffdbbed

Browse files
feat: add thinkingLevel and thinkingBudget config for Gemini models
Add per-model thinking configuration for Google Generative AI and Google Vertex providers. `thinkingLevel` controls reasoning depth for Gemini 3 models, and `thinkingBudget` sets the thinking token budget for Gemini 2.5 models. Deprecates the GOOGLE_VERTEX_THINKING_BUDGET_TOKENS env var in favor of the new per-model config (with fallback). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a944d5b commit ffdbbed

File tree

9 files changed

+305
-5
lines changed

9 files changed

+305
-5
lines changed

docs/snippets/schemas/v3/index.schema.mdx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,20 @@
23002300
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
23012301
"description": "Optional base URL."
23022302
},
2303+
"thinkingLevel": {
2304+
"type": "string",
2305+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
2306+
"enum": [
2307+
"minimal",
2308+
"low",
2309+
"medium",
2310+
"high"
2311+
]
2312+
},
2313+
"thinkingBudget": {
2314+
"type": "integer",
2315+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
2316+
},
23032317
"temperature": {
23042318
"type": "number",
23052319
"description": "Optional temperature setting to use with the model."
@@ -2548,6 +2562,20 @@
25482562
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
25492563
"description": "Optional base URL."
25502564
},
2565+
"thinkingLevel": {
2566+
"type": "string",
2567+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
2568+
"enum": [
2569+
"minimal",
2570+
"low",
2571+
"medium",
2572+
"high"
2573+
]
2574+
},
2575+
"thinkingBudget": {
2576+
"type": "integer",
2577+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
2578+
},
25512579
"temperature": {
25522580
"type": "number",
25532581
"description": "Optional temperature setting to use with the model."
@@ -3838,6 +3866,20 @@
38383866
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
38393867
"description": "Optional base URL."
38403868
},
3869+
"thinkingLevel": {
3870+
"type": "string",
3871+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
3872+
"enum": [
3873+
"minimal",
3874+
"low",
3875+
"medium",
3876+
"high"
3877+
]
3878+
},
3879+
"thinkingBudget": {
3880+
"type": "integer",
3881+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
3882+
},
38413883
"temperature": {
38423884
"type": "number",
38433885
"description": "Optional temperature setting to use with the model."
@@ -4086,6 +4128,20 @@
40864128
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
40874129
"description": "Optional base URL."
40884130
},
4131+
"thinkingLevel": {
4132+
"type": "string",
4133+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
4134+
"enum": [
4135+
"minimal",
4136+
"low",
4137+
"medium",
4138+
"high"
4139+
]
4140+
},
4141+
"thinkingBudget": {
4142+
"type": "integer",
4143+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
4144+
},
40894145
"temperature": {
40904146
"type": "number",
40914147
"description": "Optional temperature setting to use with the model."

docs/snippets/schemas/v3/languageModel.schema.mdx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,20 @@
614614
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
615615
"description": "Optional base URL."
616616
},
617+
"thinkingLevel": {
618+
"type": "string",
619+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
620+
"enum": [
621+
"minimal",
622+
"low",
623+
"medium",
624+
"high"
625+
]
626+
},
627+
"thinkingBudget": {
628+
"type": "integer",
629+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
630+
},
617631
"temperature": {
618632
"type": "number",
619633
"description": "Optional temperature setting to use with the model."
@@ -862,6 +876,20 @@
862876
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
863877
"description": "Optional base URL."
864878
},
879+
"thinkingLevel": {
880+
"type": "string",
881+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
882+
"enum": [
883+
"minimal",
884+
"low",
885+
"medium",
886+
"high"
887+
]
888+
},
889+
"thinkingBudget": {
890+
"type": "integer",
891+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
892+
},
865893
"temperature": {
866894
"type": "number",
867895
"description": "Optional temperature setting to use with the model."
@@ -2152,6 +2180,20 @@
21522180
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
21532181
"description": "Optional base URL."
21542182
},
2183+
"thinkingLevel": {
2184+
"type": "string",
2185+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
2186+
"enum": [
2187+
"minimal",
2188+
"low",
2189+
"medium",
2190+
"high"
2191+
]
2192+
},
2193+
"thinkingBudget": {
2194+
"type": "integer",
2195+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
2196+
},
21552197
"temperature": {
21562198
"type": "number",
21572199
"description": "Optional temperature setting to use with the model."
@@ -2400,6 +2442,20 @@
24002442
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
24012443
"description": "Optional base URL."
24022444
},
2445+
"thinkingLevel": {
2446+
"type": "string",
2447+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
2448+
"enum": [
2449+
"minimal",
2450+
"low",
2451+
"medium",
2452+
"high"
2453+
]
2454+
},
2455+
"thinkingBudget": {
2456+
"type": "integer",
2457+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
2458+
},
24032459
"temperature": {
24042460
"type": "number",
24052461
"description": "Optional temperature setting to use with the model."

packages/schemas/src/v3/index.schema.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,6 +2299,20 @@ const schema = {
22992299
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
23002300
"description": "Optional base URL."
23012301
},
2302+
"thinkingLevel": {
2303+
"type": "string",
2304+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
2305+
"enum": [
2306+
"minimal",
2307+
"low",
2308+
"medium",
2309+
"high"
2310+
]
2311+
},
2312+
"thinkingBudget": {
2313+
"type": "integer",
2314+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
2315+
},
23022316
"temperature": {
23032317
"type": "number",
23042318
"description": "Optional temperature setting to use with the model."
@@ -2547,6 +2561,20 @@ const schema = {
25472561
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
25482562
"description": "Optional base URL."
25492563
},
2564+
"thinkingLevel": {
2565+
"type": "string",
2566+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
2567+
"enum": [
2568+
"minimal",
2569+
"low",
2570+
"medium",
2571+
"high"
2572+
]
2573+
},
2574+
"thinkingBudget": {
2575+
"type": "integer",
2576+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
2577+
},
25502578
"temperature": {
25512579
"type": "number",
25522580
"description": "Optional temperature setting to use with the model."
@@ -3837,6 +3865,20 @@ const schema = {
38373865
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
38383866
"description": "Optional base URL."
38393867
},
3868+
"thinkingLevel": {
3869+
"type": "string",
3870+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
3871+
"enum": [
3872+
"minimal",
3873+
"low",
3874+
"medium",
3875+
"high"
3876+
]
3877+
},
3878+
"thinkingBudget": {
3879+
"type": "integer",
3880+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
3881+
},
38403882
"temperature": {
38413883
"type": "number",
38423884
"description": "Optional temperature setting to use with the model."
@@ -4085,6 +4127,20 @@ const schema = {
40854127
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
40864128
"description": "Optional base URL."
40874129
},
4130+
"thinkingLevel": {
4131+
"type": "string",
4132+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
4133+
"enum": [
4134+
"minimal",
4135+
"low",
4136+
"medium",
4137+
"high"
4138+
]
4139+
},
4140+
"thinkingBudget": {
4141+
"type": "integer",
4142+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
4143+
},
40884144
"temperature": {
40894145
"type": "number",
40904146
"description": "Optional temperature setting to use with the model."

packages/schemas/src/v3/index.type.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,14 @@ export interface GoogleGenerativeAILanguageModel {
962962
* Optional base URL.
963963
*/
964964
baseUrl?: string;
965+
/**
966+
* Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels
967+
*/
968+
thinkingLevel?: "minimal" | "low" | "medium" | "high";
969+
/**
970+
* Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget
971+
*/
972+
thinkingBudget?: number;
965973
/**
966974
* Optional temperature setting to use with the model.
967975
*/
@@ -1056,6 +1064,14 @@ export interface GoogleVertexLanguageModel {
10561064
* Optional base URL.
10571065
*/
10581066
baseUrl?: string;
1067+
/**
1068+
* Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels
1069+
*/
1070+
thinkingLevel?: "minimal" | "low" | "medium" | "high";
1071+
/**
1072+
* Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget
1073+
*/
1074+
thinkingBudget?: number;
10591075
/**
10601076
* Optional temperature setting to use with the model.
10611077
*/

packages/schemas/src/v3/languageModel.schema.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,20 @@ const schema = {
613613
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
614614
"description": "Optional base URL."
615615
},
616+
"thinkingLevel": {
617+
"type": "string",
618+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
619+
"enum": [
620+
"minimal",
621+
"low",
622+
"medium",
623+
"high"
624+
]
625+
},
626+
"thinkingBudget": {
627+
"type": "integer",
628+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
629+
},
616630
"temperature": {
617631
"type": "number",
618632
"description": "Optional temperature setting to use with the model."
@@ -861,6 +875,20 @@ const schema = {
861875
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
862876
"description": "Optional base URL."
863877
},
878+
"thinkingLevel": {
879+
"type": "string",
880+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
881+
"enum": [
882+
"minimal",
883+
"low",
884+
"medium",
885+
"high"
886+
]
887+
},
888+
"thinkingBudget": {
889+
"type": "integer",
890+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
891+
},
864892
"temperature": {
865893
"type": "number",
866894
"description": "Optional temperature setting to use with the model."
@@ -2151,6 +2179,20 @@ const schema = {
21512179
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
21522180
"description": "Optional base URL."
21532181
},
2182+
"thinkingLevel": {
2183+
"type": "string",
2184+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
2185+
"enum": [
2186+
"minimal",
2187+
"low",
2188+
"medium",
2189+
"high"
2190+
]
2191+
},
2192+
"thinkingBudget": {
2193+
"type": "integer",
2194+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
2195+
},
21542196
"temperature": {
21552197
"type": "number",
21562198
"description": "Optional temperature setting to use with the model."
@@ -2399,6 +2441,20 @@ const schema = {
23992441
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
24002442
"description": "Optional base URL."
24012443
},
2444+
"thinkingLevel": {
2445+
"type": "string",
2446+
"description": "Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels",
2447+
"enum": [
2448+
"minimal",
2449+
"low",
2450+
"medium",
2451+
"high"
2452+
]
2453+
},
2454+
"thinkingBudget": {
2455+
"type": "integer",
2456+
"description": "Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget"
2457+
},
24022458
"temperature": {
24032459
"type": "number",
24042460
"description": "Optional temperature setting to use with the model."

packages/schemas/src/v3/languageModel.type.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ export interface GoogleGenerativeAILanguageModel {
296296
* Optional base URL.
297297
*/
298298
baseUrl?: string;
299+
/**
300+
* Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels
301+
*/
302+
thinkingLevel?: "minimal" | "low" | "medium" | "high";
303+
/**
304+
* Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget
305+
*/
306+
thinkingBudget?: number;
299307
/**
300308
* Optional temperature setting to use with the model.
301309
*/
@@ -390,6 +398,14 @@ export interface GoogleVertexLanguageModel {
390398
* Optional base URL.
391399
*/
392400
baseUrl?: string;
401+
/**
402+
* Optional thinking level for Gemini 3 models. Controls the depth of reasoning the model performs. See https://ai.google.dev/gemini-api/docs/thinking#thinking-levels
403+
*/
404+
thinkingLevel?: "minimal" | "low" | "medium" | "high";
405+
/**
406+
* Optional thinking budget for Gemini 2.5 models. Sets the number of thinking tokens the model can use when generating a response. Set to -1 for dynamic thinking. See https://ai.google.dev/gemini-api/docs/thinking#set-budget
407+
*/
408+
thinkingBudget?: number;
393409
/**
394410
* Optional temperature setting to use with the model.
395411
*/

0 commit comments

Comments
 (0)