Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions types/defines/ai.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,14 +521,17 @@ export type WebSearchOptions = {
search_context_size?: "low" | "medium" | "high";
user_location?: WebSearchUserLocation;
};
export type ChatTemplateKwargs = {
/** Whether to enable reasoning, enabled by default. */
enable_thinking?: boolean;
export type ChatTemplateKwargs<ThinkingEnabled extends boolean = boolean> = {
/** Whether to enable reasoning. Support and defaults depend on the model. */
enable_thinking?: ThinkingEnabled;
/** If false, preserves reasoning context between turns. */
clear_thinking?: boolean;
};
/** Shared optional properties used by both Prompt and Messages input branches. */
export type ChatCompletionsCommonOptions = {
export type ChatCompletionsCommonOptions<
Effort extends string = "low" | "medium" | "high",
ThinkingEnabled extends boolean = boolean,
> = {
model?: string;
audio?: AudioParams;
frequency_penalty?: number | null;
Expand All @@ -543,8 +546,8 @@ export type ChatCompletionsCommonOptions = {
parallel_tool_calls?: boolean;
prediction?: PredictionContent;
presence_penalty?: number | null;
reasoning_effort?: "low" | "medium" | "high" | null;
chat_template_kwargs?: ChatTemplateKwargs;
reasoning_effort?: Effort | null;
chat_template_kwargs?: ChatTemplateKwargs<ThinkingEnabled>;
response_format?: ResponseFormat;
seed?: number | null;
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
Expand Down Expand Up @@ -633,9 +636,12 @@ export type ChatCompletionChoice = {
logprobs: ChatCompletionLogprobs | null;
};

export type ChatCompletionsMessagesInput = {
export type ChatCompletionsMessagesInput<
Effort extends string = "low" | "medium" | "high",
ThinkingEnabled extends boolean = boolean,
> = {
messages: Array<ChatCompletionMessageParam>;
} & ChatCompletionsCommonOptions;
} & ChatCompletionsCommonOptions<Effort, ThinkingEnabled>;

export type ChatCompletionsOutput = {
id: string;
Expand All @@ -658,7 +664,7 @@ export type ChatCompletionsOutput = {
* It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.
* We plan to add those incrementally as model + platform capabilities evolve.
*/
export type ResponsesInput = {
export type ResponsesInput<Effort extends string | null = ReasoningEffort> = {
background?: boolean | null;
conversation?: string | ResponseConversationParam | null;
include?: Array<ResponseIncludable> | null;
Expand All @@ -668,7 +674,7 @@ export type ResponsesInput = {
parallel_tool_calls?: boolean | null;
previous_response_id?: string | null;
prompt_cache_key?: string;
reasoning?: Reasoning | null;
reasoning?: Reasoning<Effort> | null;
safety_identifier?: string;
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
stream?: boolean | null;
Expand Down Expand Up @@ -729,8 +735,8 @@ export type ResponsePrompt = {
} | null;
version?: string | null;
};
export type Reasoning = {
effort?: ReasoningEffort | null;
export type Reasoning<Effort extends string | null = ReasoningEffort> = {
effort?: Effort | null;
generate_summary?: "auto" | "concise" | "detailed" | null;
summary?: "auto" | "concise" | "detailed" | null;
};
Expand Down Expand Up @@ -4730,11 +4736,11 @@ export declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
}
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
inputs: XOR<ResponsesInput, ChatCompletionsMessagesInput>;
inputs: XOR<ResponsesInput<"low" | "medium" | "high">, ChatCompletionsInput<"low" | "medium" | "high", true>>;
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
}
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
inputs: XOR<ResponsesInput, ChatCompletionsMessagesInput>;
inputs: XOR<ResponsesInput<"low" | "medium" | "high">, ChatCompletionsInput<"low" | "medium" | "high", true>>;
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
}
export interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
Expand Down Expand Up @@ -5824,23 +5830,23 @@ export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
postProcessedOutputs: ChatCompletionsOutput;
}
export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_6 {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<"high" | "none" | "low" | "medium" | "max", boolean>;
postProcessedOutputs: ChatCompletionsOutput;
}
export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
inputs: ChatCompletionsInput;
postProcessedOutputs: ChatCompletionsOutput;
}
export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<"high" | "none" | "minimal" | "low" | "medium" | "max" | "auto", boolean>;
postProcessedOutputs: ChatCompletionsOutput;
}
export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_7_Code {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<"high" | "none" | "low" | "medium" | "max", true>;
postProcessedOutputs: ChatCompletionsOutput;
}
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_5_2 {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<"max" | "high" | "none" | "low" | "medium" | "xhigh" | "minimal", boolean>;
postProcessedOutputs: ChatCompletionsOutput;
}
export interface Ai_Cf_Moondream_Moondream3_1_9B_A2B_Input {
Expand Down Expand Up @@ -5977,19 +5983,23 @@ export declare abstract class Base_Ai_Cf_Moondream_Moondream3_1_9B_A2B {
postProcessedOutputs: Ai_Cf_Moondream_Moondream3_1_9B_A2B_Output;
}
export declare abstract class Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Flash_0731 {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<"max" | "high" | "low" | "none" | "minimal" | "medium" | "xhigh", boolean>;
postProcessedOutputs: ChatCompletionsOutput;
}
export declare abstract class Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Pro_0813 {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<"max" | "high" | "low" | "none" | "minimal" | "medium" | "xhigh", boolean>;
postProcessedOutputs: ChatCompletionsOutput;
}
export declare abstract class Base_Ai_Cf_Qwen_Qwen3_8_27B {
inputs: ChatCompletionsInput;
postProcessedOutputs: ChatCompletionsOutput;
}
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_5_3 {
inputs: ChatCompletionsInput<"max" | "high" | "low" | "none" | "medium", true>;
postProcessedOutputs: ChatCompletionsOutput;
}
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_5_3_Flash {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<"max" | "high" | "low" | "none" | "minimal" | "medium" | "xhigh", true>;
postProcessedOutputs: ChatCompletionsOutput;
}

Expand Down Expand Up @@ -6091,6 +6101,7 @@ export interface AiModels {
"@cf/deepseek-ai/deepseek-v4-flash-0731": Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Flash_0731;
"@cf/deepseek-ai/deepseek-v4-pro-0813": Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Pro_0813;
"@cf/qwen/qwen3.8-27b": Base_Ai_Cf_Qwen_Qwen3_8_27B;
"@cf/zai-org/glm-5.3": Base_Ai_Cf_Zai_Org_Glm_5_3;
"@cf/zai-org/glm-5.3-flash": Base_Ai_Cf_Zai_Org_Glm_5_3_Flash;
}
export type AiOptions = {
Expand Down Expand Up @@ -6146,7 +6157,10 @@ export type AiModelsSearchObject = {
};

export type ChatCompletionsBase = ChatCompletionsMessagesInput;
export type ChatCompletionsInput = ChatCompletionsMessagesInput;
export type ChatCompletionsInput<
Effort extends string = "low" | "medium" | "high",
ThinkingEnabled extends boolean = boolean,
> = ChatCompletionsMessagesInput<Effort, ThinkingEnabled>;

export interface InferenceUpstreamError extends Error {}
export interface AiInternalError extends Error {}
Expand Down
88 changes: 66 additions & 22 deletions types/generated-snapshot/experimental/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6483,14 +6483,17 @@ type WebSearchOptions = {
search_context_size?: "low" | "medium" | "high";
user_location?: WebSearchUserLocation;
};
type ChatTemplateKwargs = {
/** Whether to enable reasoning, enabled by default. */
enable_thinking?: boolean;
type ChatTemplateKwargs<ThinkingEnabled extends boolean = boolean> = {
/** Whether to enable reasoning. Support and defaults depend on the model. */
enable_thinking?: ThinkingEnabled;
/** If false, preserves reasoning context between turns. */
clear_thinking?: boolean;
};
/** Shared optional properties used by both Prompt and Messages input branches. */
type ChatCompletionsCommonOptions = {
type ChatCompletionsCommonOptions<
Effort extends string = "low" | "medium" | "high",
ThinkingEnabled extends boolean = boolean,
> = {
model?: string;
audio?: AudioParams;
frequency_penalty?: number | null;
Expand All @@ -6505,8 +6508,8 @@ type ChatCompletionsCommonOptions = {
parallel_tool_calls?: boolean;
prediction?: PredictionContent;
presence_penalty?: number | null;
reasoning_effort?: "low" | "medium" | "high" | null;
chat_template_kwargs?: ChatTemplateKwargs;
reasoning_effort?: Effort | null;
chat_template_kwargs?: ChatTemplateKwargs<ThinkingEnabled>;
response_format?: ResponseFormat;
seed?: number | null;
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
Expand Down Expand Up @@ -6595,9 +6598,12 @@ type ChatCompletionChoice = {
"stop" | "length" | "tool_calls" | "content_filter" | "function_call";
logprobs: ChatCompletionLogprobs | null;
};
type ChatCompletionsMessagesInput = {
type ChatCompletionsMessagesInput<
Effort extends string = "low" | "medium" | "high",
ThinkingEnabled extends boolean = boolean,
> = {
messages: Array<ChatCompletionMessageParam>;
} & ChatCompletionsCommonOptions;
} & ChatCompletionsCommonOptions<Effort, ThinkingEnabled>;
type ChatCompletionsOutput = {
id: string;
object: string;
Expand All @@ -6618,7 +6624,7 @@ type ChatCompletionsOutput = {
* It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.
* We plan to add those incrementally as model + platform capabilities evolve.
*/
type ResponsesInput = {
type ResponsesInput<Effort extends string | null = ReasoningEffort> = {
background?: boolean | null;
conversation?: string | ResponseConversationParam | null;
include?: Array<ResponseIncludable> | null;
Expand All @@ -6628,7 +6634,7 @@ type ResponsesInput = {
parallel_tool_calls?: boolean | null;
previous_response_id?: string | null;
prompt_cache_key?: string;
reasoning?: Reasoning | null;
reasoning?: Reasoning<Effort> | null;
safety_identifier?: string;
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
stream?: boolean | null;
Expand Down Expand Up @@ -6689,8 +6695,8 @@ type ResponsePrompt = {
} | null;
version?: string | null;
};
type Reasoning = {
effort?: ReasoningEffort | null;
type Reasoning<Effort extends string | null = ReasoningEffort> = {
effort?: Effort | null;
generate_summary?: "auto" | "concise" | "detailed" | null;
summary?: "auto" | "concise" | "detailed" | null;
};
Expand Down Expand Up @@ -10713,11 +10719,17 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
}
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
inputs: XOR<ResponsesInput, ChatCompletionsMessagesInput>;
inputs: XOR<
ResponsesInput<"low" | "medium" | "high">,
ChatCompletionsInput<"low" | "medium" | "high", true>
>;
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
}
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
inputs: XOR<ResponsesInput, ChatCompletionsMessagesInput>;
inputs: XOR<
ResponsesInput<"low" | "medium" | "high">,
ChatCompletionsInput<"low" | "medium" | "high", true>
>;
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
}
interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
Expand Down Expand Up @@ -11808,23 +11820,35 @@ declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
postProcessedOutputs: ChatCompletionsOutput;
}
declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_6 {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<
"high" | "none" | "low" | "medium" | "max",
boolean
>;
postProcessedOutputs: ChatCompletionsOutput;
}
declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
inputs: ChatCompletionsInput;
postProcessedOutputs: ChatCompletionsOutput;
}
declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<
"high" | "none" | "minimal" | "low" | "medium" | "max" | "auto",
boolean
>;
postProcessedOutputs: ChatCompletionsOutput;
}
declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_7_Code {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<
"high" | "none" | "low" | "medium" | "max",
true
>;
postProcessedOutputs: ChatCompletionsOutput;
}
declare abstract class Base_Ai_Cf_Zai_Org_Glm_5_2 {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<
"max" | "high" | "none" | "low" | "medium" | "xhigh" | "minimal",
boolean
>;
postProcessedOutputs: ChatCompletionsOutput;
}
interface Ai_Cf_Moondream_Moondream3_1_9B_A2B_Input {
Expand Down Expand Up @@ -11961,19 +11985,35 @@ declare abstract class Base_Ai_Cf_Moondream_Moondream3_1_9B_A2B {
postProcessedOutputs: Ai_Cf_Moondream_Moondream3_1_9B_A2B_Output;
}
declare abstract class Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Flash_0731 {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<
"max" | "high" | "low" | "none" | "minimal" | "medium" | "xhigh",
boolean
>;
postProcessedOutputs: ChatCompletionsOutput;
}
declare abstract class Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Pro_0813 {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<
"max" | "high" | "low" | "none" | "minimal" | "medium" | "xhigh",
boolean
>;
postProcessedOutputs: ChatCompletionsOutput;
}
declare abstract class Base_Ai_Cf_Qwen_Qwen3_8_27B {
inputs: ChatCompletionsInput;
postProcessedOutputs: ChatCompletionsOutput;
}
declare abstract class Base_Ai_Cf_Zai_Org_Glm_5_3 {
inputs: ChatCompletionsInput<
"max" | "high" | "low" | "none" | "medium",
true
>;
postProcessedOutputs: ChatCompletionsOutput;
}
declare abstract class Base_Ai_Cf_Zai_Org_Glm_5_3_Flash {
inputs: ChatCompletionsInput;
inputs: ChatCompletionsInput<
"max" | "high" | "low" | "none" | "minimal" | "medium" | "xhigh",
true
>;
postProcessedOutputs: ChatCompletionsOutput;
}
interface AiModels {
Expand Down Expand Up @@ -12074,6 +12114,7 @@ interface AiModels {
"@cf/deepseek-ai/deepseek-v4-flash-0731": Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Flash_0731;
"@cf/deepseek-ai/deepseek-v4-pro-0813": Base_Ai_Cf_Deepseek_Ai_Deepseek_V4_Pro_0813;
"@cf/qwen/qwen3.8-27b": Base_Ai_Cf_Qwen_Qwen3_8_27B;
"@cf/zai-org/glm-5.3": Base_Ai_Cf_Zai_Org_Glm_5_3;
"@cf/zai-org/glm-5.3-flash": Base_Ai_Cf_Zai_Org_Glm_5_3_Flash;
}
type AiOptions = {
Expand Down Expand Up @@ -12128,7 +12169,10 @@ type AiModelsSearchObject = {
}[];
};
type ChatCompletionsBase = ChatCompletionsMessagesInput;
type ChatCompletionsInput = ChatCompletionsMessagesInput;
type ChatCompletionsInput<
Effort extends string = "low" | "medium" | "high",
ThinkingEnabled extends boolean = boolean,
> = ChatCompletionsMessagesInput<Effort, ThinkingEnabled>;
interface InferenceUpstreamError extends Error {}
interface AiInternalError extends Error {}
type AiModelListType = Record<string, any>;
Expand Down
Loading
Loading