Skip to content

Commit 2652c67

Browse files
committed
Add thinking levels.
1 parent bc2b2cd commit 2652c67

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

packages/ai/src/types/enums.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,26 @@ export const Language = {
432432
* @beta
433433
*/
434434
export type Language = (typeof Language)[keyof typeof Language];
435+
436+
/**
437+
* A preset that controls the model's "thinking" process. Use
438+
* `ThinkingLevel.LOW` for faster responses on less complex tasks, and
439+
* `ThinkingLevel.HIGH` for better reasoning on more complex tasks.
440+
*
441+
* @public
442+
*/
443+
export const ThinkingLevel = {
444+
MINIMAL: 'MINIMAL',
445+
LOW: 'LOW',
446+
MEDIUM: 'MEDIUM',
447+
HIGH: 'HIGH'
448+
};
449+
450+
/**
451+
* A preset that controls the model's "thinking" process. Use
452+
* `ThinkingLevel.LOW` for faster responses on less complex tasks, and
453+
* `ThinkingLevel.HIGH` for better reasoning on more complex tasks.
454+
*
455+
* @public
456+
*/
457+
export type ThinkingLevel = (typeof ThinkingLevel)[keyof typeof ThinkingLevel];

packages/ai/src/types/requests.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import {
2727
HarmBlockThreshold,
2828
HarmCategory,
2929
InferenceMode,
30-
ResponseModality
30+
ResponseModality,
31+
ThinkingLevel
3132
} from './enums';
3233
import { ObjectSchemaRequest, SchemaRequest } from './schema';
3334

@@ -440,14 +441,29 @@ export interface ThinkingConfig {
440441
* "thinking" process. A higher budget may result in higher quality responses for complex tasks
441442
* but can also increase latency and cost.
442443
*
443-
* If you don't specify a budget, the model will determine the appropriate amount
444-
* of thinking based on the complexity of the prompt.
444+
* The range of supported thinking budget values depends on the model.
445+
*
446+
* - To use the default thinking budget or thinking level for a model, leave
447+
* this value undefined.
448+
*
449+
* - To disable thinking, when supported by the model, set this value to `0`.
450+
*
451+
* - To use dynamic thinking, allowing the model to decide on the thinking
452+
* budget based on the task, set this value to `-1`.
445453
*
446454
* An error will be thrown if you set a thinking budget for a model that does not support this
447455
* feature or if the specified budget is not within the model's supported range.
448456
*/
449457
thinkingBudget?: number;
450458

459+
/**
460+
* If not specified, Gemini will use the model's default dynamic thinking level.
461+
*
462+
* Important: Gemini 2.5 series models do not support thinking levels; use
463+
* `thinkingBudget` to set a thinking budget instead.
464+
*/
465+
thinkingLevel?: ThinkingLevel;
466+
451467
/**
452468
* Whether to include "thought summaries" in the model's response.
453469
*

0 commit comments

Comments
 (0)