Skip to content

Commit ebd585e

Browse files
KastanDaydanlapid
authored andcommitted
types: exact per-model Workers AI reasoning types
Regenerated from the Workers AI SDK type generator (cloudflare/ai/sdk!1778) and production ConfigAPI. Reasoning types now enforce what each model supports instead of suggesting values while accepting any string: - reasoning_effort (and Responses reasoning.effort) accepts exactly the model's supported efforts; compatibility aliases are listed in the hover docs as accepted by the API but not by the types. - Models without effort levels (Gemma 4, GLM-4.7-Flash, Kimi K2.7 Code) have no reasoning_effort; mandatory reasoning (GPT-OSS, Kimi K2.7 Code, GLM-5.3, GLM-5.3-Flash) types enable_thinking as true. - Nemotron 3 publishes its own controls: no reasoning_effort, and chat_template_kwargs with enable_thinking, low_effort and force_nonempty_content. - The shared ChatCompletionsInput and ResponsesInput keep main's types and still apply to models without reasoning metadata. - Adds GLM-5.3 and Nemotron Speech Streaming; removes stable-diffusion-v1-5-img2img, which is no longer offered. This intentionally rejects values these models do not support that the types previously accepted.
1 parent 30ed8b4 commit ebd585e

6 files changed

Lines changed: 686 additions & 419 deletions

File tree

‎types/defines/ai.d.ts‎

Lines changed: 102 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -526,18 +526,6 @@ export type WebSearchOptions = {
526526
// be turned off). The Workers AI SDK type generator (cloudflare/ai/sdk,
527527
// apps/worker-constellation-entry/scripts/build-types) turns it into the per-model
528528
// `inputs` types below; the developer docs model schemas come from the same metadata.
529-
/**
530-
* A reasoning effort. The listed values are suggestions: the efforts the model supports.
531-
* Any other string also type-checks, so new or provider-specific efforts are never blocked
532-
* by the types, but the model may reject or ignore values it does not support.
533-
*/
534-
export type AiReasoningEffortHint<Suggested extends string = never> =
535-
| Suggested
536-
| (string & NonNullable<unknown>);
537-
538-
/** Reasoning efforts suggested for models without published reasoning metadata. */
539-
export type ChatCompletionsReasoningEffort = "low" | "medium" | "high";
540-
541529
export type ChatTemplateKwargs = {
542530
/** Whether to enable reasoning. Support and defaults depend on the model. */
543531
enable_thinking?: boolean;
@@ -561,7 +549,7 @@ export type ChatCompletionsCommonOptions = {
561549
prediction?: PredictionContent;
562550
presence_penalty?: number | null;
563551
/** Reasoning effort. Supported levels depend on the model. */
564-
reasoning_effort?: AiReasoningEffortHint<ChatCompletionsReasoningEffort> | null;
552+
reasoning_effort?: "low" | "medium" | "high" | null;
565553
chat_template_kwargs?: ChatTemplateKwargs;
566554
response_format?: ResponseFormat;
567555
seed?: number | null;
@@ -686,7 +674,7 @@ export type ResponsesInput = {
686674
parallel_tool_calls?: boolean | null;
687675
previous_response_id?: string | null;
688676
prompt_cache_key?: string;
689-
reasoning?: ResponsesInputReasoning | null;
677+
reasoning?: Reasoning | null;
690678
safety_identifier?: string;
691679
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
692680
stream?: boolean | null;
@@ -747,16 +735,6 @@ export type ResponsePrompt = {
747735
} | null;
748736
version?: string | null;
749737
};
750-
/**
751-
* Reasoning options accepted in a Responses request. Unlike `Reasoning` (which responses
752-
* echo back), `effort` suggests the shared efforts but accepts any string, like
753-
* AiReasoningEffortHint (spelled out because this file cannot import it).
754-
*/
755-
export interface ResponsesInputReasoning extends Omit<Reasoning, "effort"> {
756-
/** Reasoning effort. Supported levels depend on the model. */
757-
effort?: Exclude<ReasoningEffort, null> | (string & NonNullable<unknown>) | null;
758-
}
759-
760738
export type Reasoning = {
761739
effort?: ReasoningEffort | null;
762740
generate_summary?: "auto" | "concise" | "detailed" | null;
@@ -4759,56 +4737,56 @@ export declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
47594737
}
47604738
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
47614739
inputs: XOR<Omit<ResponsesInput, "reasoning"> & {
4762-
reasoning?: (Omit<ResponsesInputReasoning, "effort"> & {
4740+
reasoning?: (Omit<Reasoning, "effort"> & {
47634741
/**
47644742
* Reasoning effort. Supported levels: low, medium, high. Reasoning cannot be disabled.
47654743
*
47664744
* @default "medium"
47674745
*/
4768-
effort?: AiReasoningEffortHint<"low" | "medium" | "high"> | null;
4746+
effort?: "low" | "medium" | "high" | null;
47694747
}) | null;
47704748
}, Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
47714749
/**
47724750
* Reasoning effort. Supported levels: low, medium, high. Reasoning cannot be disabled.
47734751
*
47744752
* @default "medium"
47754753
*/
4776-
reasoning_effort?: AiReasoningEffortHint<"low" | "medium" | "high"> | null;
4754+
reasoning_effort?: "low" | "medium" | "high" | null;
47774755
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
47784756
/**
47794757
* Reasoning is always enabled for this model and cannot be disabled.
47804758
*
47814759
* @default true
47824760
*/
4783-
enable_thinking?: boolean;
4761+
enable_thinking?: true;
47844762
};
47854763
}>;
47864764
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
47874765
}
47884766
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
47894767
inputs: XOR<Omit<ResponsesInput, "reasoning"> & {
4790-
reasoning?: (Omit<ResponsesInputReasoning, "effort"> & {
4768+
reasoning?: (Omit<Reasoning, "effort"> & {
47914769
/**
47924770
* Reasoning effort. Supported levels: low, medium, high. Reasoning cannot be disabled.
47934771
*
47944772
* @default "medium"
47954773
*/
4796-
effort?: AiReasoningEffortHint<"low" | "medium" | "high"> | null;
4774+
effort?: "low" | "medium" | "high" | null;
47974775
}) | null;
47984776
}, Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
47994777
/**
48004778
* Reasoning effort. Supported levels: low, medium, high. Reasoning cannot be disabled.
48014779
*
48024780
* @default "medium"
48034781
*/
4804-
reasoning_effort?: AiReasoningEffortHint<"low" | "medium" | "high"> | null;
4782+
reasoning_effort?: "low" | "medium" | "high" | null;
48054783
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
48064784
/**
48074785
* Reasoning is always enabled for this model and cannot be disabled.
48084786
*
48094787
* @default true
48104788
*/
4811-
enable_thinking?: boolean;
4789+
enable_thinking?: true;
48124790
};
48134791
}>;
48144792
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
@@ -5893,13 +5871,9 @@ export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
58935871
}
58945872
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
58955873
inputs: Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
5896-
/**
5897-
* This model has no reasoning effort levels. Use `chat_template_kwargs.enable_thinking` to turn reasoning on or off.
5898-
*/
5899-
reasoning_effort?: AiReasoningEffortHint | null;
59005874
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
59015875
/**
5902-
* Whether to enable reasoning for this model.
5876+
* Whether to enable reasoning for this model. This model has no reasoning effort levels.
59035877
*
59045878
* @default true
59055879
*/
@@ -5915,11 +5889,11 @@ export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
59155889
export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_6 {
59165890
inputs: Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
59175891
/**
5918-
* Reasoning effort. Supported levels: high, none. Compatibility aliases: low maps to high; medium maps to high; max maps to high.
5892+
* Reasoning effort. Supported levels: high, none. Compatibility aliases (accepted by the API, not by these types): low maps to high; medium maps to high; max maps to high.
59195893
*
59205894
* @default "high"
59215895
*/
5922-
reasoning_effort?: AiReasoningEffortHint<"high" | "none"> | null;
5896+
reasoning_effort?: "high" | "none" | null;
59235897
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
59245898
/**
59255899
* Whether to enable reasoning for this model.
@@ -5931,21 +5905,61 @@ export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_6 {
59315905
};
59325906
postProcessedOutputs: ChatCompletionsOutput;
59335907
}
5908+
export type Ai_Cf_Nvidia_Nemotron_3_120B_A12B_Input = Omit<
5909+
ChatCompletionsInput,
5910+
"model" | "max_tokens" | "metadata" | "modalities" | "chat_template_kwargs" | "store" | "reasoning_effort"
5911+
> & {
5912+
/**
5913+
* ID of the model to use (for example, '@cf/nvidia/nemotron-3-120b-a12b').
5914+
*/
5915+
model?: ChatCompletionsInput["model"];
5916+
/**
5917+
* The maximum number of tokens to generate.
5918+
*/
5919+
max_tokens?: ChatCompletionsInput["max_tokens"];
5920+
/**
5921+
* Set of key-value pairs that can be attached to the object.
5922+
*/
5923+
metadata?: ChatCompletionsInput["metadata"];
5924+
/**
5925+
* Output types requested from the model.
5926+
*/
5927+
modalities?: ChatCompletionsInput["modalities"];
5928+
/**
5929+
* Nemotron chat-template controls for normal reasoning, low-effort reasoning, and non-reasoning responses.
5930+
*/
5931+
chat_template_kwargs?: {
5932+
/**
5933+
* Whether to enable reasoning. Reasoning is enabled by default.
5934+
*/
5935+
enable_thinking?: boolean;
5936+
/**
5937+
* When reasoning is enabled, use Nemotron's low-effort reasoning mode, which uses significantly fewer reasoning tokens.
5938+
*/
5939+
low_effort?: boolean;
5940+
/**
5941+
* For coding agent use, Nvidia suggests setting force_nonempty_content=true
5942+
*/
5943+
force_nonempty_content?: boolean;
5944+
};
5945+
/**
5946+
* Whether to store the output for model distillation or evaluation.
5947+
*
5948+
* @default false
5949+
*/
5950+
store?: ChatCompletionsInput["store"];
5951+
};
59345952
export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
5935-
inputs: ChatCompletionsInput;
5953+
inputs: Ai_Cf_Nvidia_Nemotron_3_120B_A12B_Input;
59365954
postProcessedOutputs: ChatCompletionsOutput;
59375955
}
59385956
export type Ai_Cf_Google_Gemma_4_26B_A4B_It_Input = Omit<
59395957
ChatCompletionsInput,
59405958
"reasoning_effort" | "chat_template_kwargs"
59415959
> & {
5942-
/**
5943-
* This model has no reasoning effort levels. Use `chat_template_kwargs.enable_thinking` to turn reasoning on or off.
5944-
*/
5945-
reasoning_effort?: AiReasoningEffortHint | null;
59465960
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
59475961
/**
5948-
* Whether to enable reasoning for this model.
5962+
* Whether to enable reasoning for this model. This model has no reasoning effort levels.
59495963
*
59505964
* @default true
59515965
*/
@@ -5963,31 +5977,54 @@ export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_It {
59635977
}
59645978
/** @deprecated Use Base_Ai_Cf_Google_Gemma_4_26B_A4B_It. */
59655979
export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT extends Base_Ai_Cf_Google_Gemma_4_26B_A4B_It {}
5980+
export type Ai_Cf_Nvidia_Nemotron_Speech_Streaming_En_0_6B_Input =
5981+
| {
5982+
/**
5983+
* readable stream with audio data and content-type specified for that data
5984+
*/
5985+
audio: {
5986+
body: object;
5987+
contentType: string;
5988+
};
5989+
}
5990+
| {
5991+
/**
5992+
* base64 encoded audio data
5993+
*/
5994+
audio: string;
5995+
encoding?: "wav" | "flac" | "ogg" | "linear16";
5996+
sample_rate?: number;
5997+
channels?: number;
5998+
};
5999+
export interface Ai_Cf_Nvidia_Nemotron_Speech_Streaming_En_0_6B_Output {
6000+
text?: string;
6001+
duration?: number;
6002+
}
6003+
export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_Speech_Streaming_En_0_6B {
6004+
inputs: Ai_Cf_Nvidia_Nemotron_Speech_Streaming_En_0_6B_Input;
6005+
postProcessedOutputs: Ai_Cf_Nvidia_Nemotron_Speech_Streaming_En_0_6B_Output;
6006+
}
59666007
export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_7_Code {
59676008
inputs: Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
5968-
/**
5969-
* This model has no reasoning effort levels. Reasoning is always enabled.
5970-
*/
5971-
reasoning_effort?: AiReasoningEffortHint | null;
59726009
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
59736010
/**
5974-
* Reasoning is always enabled for this model and cannot be disabled.
6011+
* Reasoning is always enabled for this model and cannot be disabled. This model has no reasoning effort levels.
59756012
*
59766013
* @default true
59776014
*/
5978-
enable_thinking?: boolean;
6015+
enable_thinking?: true;
59796016
};
59806017
};
59816018
postProcessedOutputs: ChatCompletionsOutput;
59826019
}
59836020
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_5_2 {
59846021
inputs: Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
59856022
/**
5986-
* Reasoning effort. Supported levels: max, high, none. Compatibility aliases: low maps to high; medium maps to high; xhigh maps to max; minimal maps to none.
6023+
* Reasoning effort. Supported levels: max, high, none. Compatibility aliases (accepted by the API, not by these types): low maps to high; medium maps to high; xhigh maps to max; minimal maps to none.
59876024
*
59886025
* @default "max"
59896026
*/
5990-
reasoning_effort?: AiReasoningEffortHint<"max" | "high" | "none"> | null;
6027+
reasoning_effort?: "max" | "high" | "none" | null;
59916028
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
59926029
/**
59936030
* Whether to enable reasoning for this model.
@@ -6135,11 +6172,11 @@ export declare abstract class Base_Ai_Cf_Moondream_Moondream3_1_9B_A2B {
61356172
export declare abstract class Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Flash_0731 {
61366173
inputs: Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
61376174
/**
6138-
* Reasoning effort. Supported levels: max, high, low, none. Compatibility aliases: minimal maps to low; medium maps to high; xhigh maps to high.
6175+
* Reasoning effort. Supported levels: max, high, low, none. Compatibility aliases (accepted by the API, not by these types): minimal maps to low; medium maps to high; xhigh maps to high.
61396176
*
61406177
* @default "high"
61416178
*/
6142-
reasoning_effort?: AiReasoningEffortHint<"max" | "high" | "low" | "none"> | null;
6179+
reasoning_effort?: "max" | "high" | "low" | "none" | null;
61436180
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
61446181
/**
61456182
* Whether to enable reasoning for this model.
@@ -6154,11 +6191,11 @@ export declare abstract class Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Flash_0731 {
61546191
export declare abstract class Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Pro_0813 {
61556192
inputs: Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
61566193
/**
6157-
* Reasoning effort. Supported levels: max, high, low, none. Compatibility aliases: minimal maps to low; medium maps to high; xhigh maps to high.
6194+
* Reasoning effort. Supported levels: max, high, low, none. Compatibility aliases (accepted by the API, not by these types): minimal maps to low; medium maps to high; xhigh maps to high.
61586195
*
61596196
* @default "high"
61606197
*/
6161-
reasoning_effort?: AiReasoningEffortHint<"max" | "high" | "low" | "none"> | null;
6198+
reasoning_effort?: "max" | "high" | "low" | "none" | null;
61626199
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
61636200
/**
61646201
* Whether to enable reasoning for this model.
@@ -6177,7 +6214,7 @@ export declare abstract class Base_Ai_Cf_Qwen_Qwen3_8_27B {
61776214
*
61786215
* @default "xhigh"
61796216
*/
6180-
reasoning_effort?: AiReasoningEffortHint<"low" | "medium" | "xhigh"> | null;
6217+
reasoning_effort?: "low" | "medium" | "xhigh" | null;
61816218
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
61826219
/**
61836220
* Whether to enable reasoning for this model.
@@ -6192,37 +6229,37 @@ export declare abstract class Base_Ai_Cf_Qwen_Qwen3_8_27B {
61926229
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_5_3 {
61936230
inputs: Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
61946231
/**
6195-
* Reasoning effort. Supported levels: max, high, low. Reasoning cannot be disabled. Compatibility aliases: none maps to max; medium maps to max.
6232+
* Reasoning effort. Supported levels: max, high, low. Reasoning cannot be disabled. Compatibility aliases (accepted by the API, not by these types): none maps to max; minimal maps to max; medium maps to max; xhigh maps to max.
61966233
*
61976234
* @default "max"
61986235
*/
6199-
reasoning_effort?: AiReasoningEffortHint<"max" | "high" | "low"> | null;
6236+
reasoning_effort?: "max" | "high" | "low" | null;
62006237
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
62016238
/**
62026239
* Reasoning is always enabled for this model and cannot be disabled.
62036240
*
62046241
* @default true
62056242
*/
6206-
enable_thinking?: boolean;
6243+
enable_thinking?: true;
62076244
};
62086245
};
62096246
postProcessedOutputs: ChatCompletionsOutput;
62106247
}
62116248
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_5_3_Flash {
62126249
inputs: Omit<ChatCompletionsInput, "reasoning_effort" | "chat_template_kwargs"> & {
62136250
/**
6214-
* Reasoning effort. Supported levels: max, high, low. Reasoning cannot be disabled. Compatibility aliases: none maps to max; minimal maps to max; medium maps to max; xhigh maps to max.
6251+
* Reasoning effort. Supported levels: max, high, low. Reasoning cannot be disabled. Compatibility aliases (accepted by the API, not by these types): none maps to max; minimal maps to max; medium maps to max; xhigh maps to max.
62156252
*
62166253
* @default "max"
62176254
*/
6218-
reasoning_effort?: AiReasoningEffortHint<"max" | "high" | "low"> | null;
6255+
reasoning_effort?: "max" | "high" | "low" | null;
62196256
chat_template_kwargs?: Omit<ChatTemplateKwargs, "enable_thinking"> & {
62206257
/**
62216258
* Reasoning is always enabled for this model and cannot be disabled.
62226259
*
62236260
* @default true
62246261
*/
6225-
enable_thinking?: boolean;
6262+
enable_thinking?: true;
62266263
};
62276264
};
62286265
postProcessedOutputs: ChatCompletionsOutput;
@@ -6232,7 +6269,6 @@ export interface AiModels {
62326269
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
62336270
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
62346271
"@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
6235-
"@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
62366272
"@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
62376273
"@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
62386274
"@cf/myshell-ai/melotts": BaseAiTextToSpeech;
@@ -6320,6 +6356,7 @@ export interface AiModels {
63206356
"@cf/moonshotai/kimi-k2.6": Base_Ai_Cf_Moonshotai_Kimi_K2_6;
63216357
"@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
63226358
"@cf/google/gemma-4-26b-a4b-it": Base_Ai_Cf_Google_Gemma_4_26B_A4B_It;
6359+
"@cf/nvidia/nemotron-speech-streaming-en-0.6b": Base_Ai_Cf_Nvidia_Nemotron_Speech_Streaming_En_0_6B;
63236360
"@cf/moonshotai/kimi-k2.7-code": Base_Ai_Cf_Moonshotai_Kimi_K2_7_Code;
63246361
"@cf/zai-org/glm-5.2": Base_Ai_Cf_Zai_Org_Glm_5_2;
63256362
"@cf/moondream/moondream3.1-9B-A2B": Base_Ai_Cf_Moondream_Moondream3_1_9B_A2B;

0 commit comments

Comments
 (0)