diff --git a/packages/ai/openai/src/Generated.ts b/packages/ai/openai/src/Generated.ts index c8c8e6653..73ae94ae3 100644 --- a/packages/ai/openai/src/Generated.ts +++ b/packages/ai/openai/src/Generated.ts @@ -1493,6 +1493,7 @@ export type CustomToolCall = { readonly "type": "custom_tool_call" readonly "id"?: string readonly "call_id": string + readonly "namespace"?: string readonly "name": string readonly "input": string } @@ -1506,6 +1507,9 @@ export const CustomToolCall = Schema.Struct({ "call_id": Schema.String.annotate({ "description": "An identifier used to map this custom tool call to a tool call output.\n" }), + "namespace": Schema.optionalKey( + Schema.String.annotate({ "description": "The namespace of the custom tool being called.\n" }) + ), "name": Schema.String.annotate({ "description": "The name of the custom tool being called.\n" }), "input": Schema.String.annotate({ "description": "The input for the custom tool call generated by the model.\n" }) }).annotate({ "title": "Custom tool call", "description": "A call to a custom tool created by the model.\n" }) @@ -2267,6 +2271,7 @@ export type FunctionToolCall = { readonly "id"?: string readonly "type": "function_call" readonly "call_id": string + readonly "namespace"?: string readonly "name": string readonly "arguments": string readonly "status"?: "in_progress" | "completed" | "incomplete" @@ -2279,6 +2284,7 @@ export const FunctionToolCall = Schema.Struct({ "call_id": Schema.String.annotate({ "description": "The unique ID of the function tool call generated by the model.\n" }), + "namespace": Schema.optionalKey(Schema.String.annotate({ "description": "The namespace of the function to run.\n" })), "name": Schema.String.annotate({ "description": "The name of the function to run.\n" }), "arguments": Schema.String.annotate({ "description": "A JSON string of the arguments to pass to the function.\n" }), "status": Schema.optionalKey( @@ -2296,6 +2302,7 @@ export type FunctionToolCallResource = { readonly "id": string readonly "type": "function_call" readonly "call_id": string + readonly "namespace"?: string readonly "name": string readonly "arguments": string readonly "status"?: "in_progress" | "completed" | "incomplete" @@ -2308,6 +2315,7 @@ export const FunctionToolCallResource = Schema.Struct({ "call_id": Schema.String.annotate({ "description": "The unique ID of the function tool call generated by the model.\n" }), + "namespace": Schema.optionalKey(Schema.String.annotate({ "description": "The namespace of the function to run.\n" })), "name": Schema.String.annotate({ "description": "The name of the function to run.\n" }), "arguments": Schema.String.annotate({ "description": "A JSON string of the arguments to pass to the function.\n" }), "status": Schema.optionalKey( @@ -3092,6 +3100,11 @@ export const MessageDeltaContentTextAnnotationsFilePathObject = Schema.Struct({ "description": "A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file." }) +export type MessagePhase = "commentary" | "final_answer" +export const MessagePhase = Schema.Literals(["commentary", "final_answer"]).annotate({ + "description": + "Labels an `assistant` message as intermediate commentary (`commentary`) or the final answer (`final_answer`).\nFor models like `gpt-5.3-codex` and beyond, when sending follow-up requests, preserve and resend\nphase on all assistant messages — dropping it can degrade performance. Not used for user messages.\n" +}) export type MessageRequestContentTextObject = { readonly "type": "text"; readonly "text": string } export const MessageRequestContentTextObject = Schema.Struct({ "type": Schema.Literal("text").annotate({ "description": "Always `text`." }), @@ -3126,6 +3139,8 @@ export const Model = Schema.StructWithRest( ).annotate({ "title": "Model", "description": "Describes an OpenAI model offering that can be used with the API." }) export type ModelIdsShared = | string + | "gpt-5.4" + | "gpt-5.3-chat-latest" | "gpt-5.2" | "gpt-5.2-2025-12-11" | "gpt-5.2-chat-latest" @@ -3201,6 +3216,8 @@ export type ModelIdsShared = export const ModelIdsShared = Schema.Union([ Schema.String, Schema.Literals([ + "gpt-5.4", + "gpt-5.3-chat-latest", "gpt-5.2", "gpt-5.2-2025-12-11", "gpt-5.2-chat-latest", @@ -6704,7 +6721,9 @@ export type ToolChoiceTypes = { readonly "type": | "file_search" | "web_search_preview" + | "computer" | "computer_use_preview" + | "computer_use" | "web_search_preview_2025_03_11" | "image_generation" | "code_interpreter" @@ -6713,13 +6732,15 @@ export const ToolChoiceTypes = Schema.Struct({ "type": Schema.Literals([ "file_search", "web_search_preview", + "computer", "computer_use_preview", + "computer_use", "web_search_preview_2025_03_11", "image_generation", "code_interpreter" ]).annotate({ "description": - "The type of hosted tool the model should to use. Learn more about\n[built-in tools](/docs/guides/tools).\n\nAllowed values are:\n- `file_search`\n- `web_search_preview`\n- `computer_use_preview`\n- `code_interpreter`\n- `image_generation`\n" + "The type of hosted tool the model should to use. Learn more about\n[built-in tools](/docs/guides/tools).\n\nAllowed values are:\n- `file_search`\n- `web_search_preview`\n- `computer`\n- `computer_use_preview`\n- `computer_use`\n- `code_interpreter`\n- `image_generation`\n" }) }).annotate({ "title": "Hosted tool", @@ -7954,7 +7975,7 @@ export type InputImageContent = { readonly "type": "input_image" readonly "image_url"?: string | null readonly "file_id"?: string | null - readonly "detail": "low" | "high" | "auto" + readonly "detail": "low" | "high" | "auto" | "original" } export const InputImageContent = Schema.Struct({ "type": Schema.Literal("input_image").annotate({ @@ -7975,9 +7996,9 @@ export const InputImageContent = Schema.Struct({ Schema.Null ]) ), - "detail": Schema.Literals(["low", "high", "auto"]).annotate({ + "detail": Schema.Literals(["low", "high", "auto", "original"]).annotate({ "description": - "The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`." + "The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`." }) }).annotate({ "title": "Input image", @@ -7987,6 +8008,7 @@ export type ComputerScreenshotContent = { readonly "type": "computer_screenshot" readonly "image_url": string | null readonly "file_id": string | null + readonly "detail": "low" | "high" | "auto" | "original" } export const ComputerScreenshotContent = Schema.Struct({ "type": Schema.Literal("computer_screenshot").annotate({ @@ -8000,14 +8022,19 @@ export const ComputerScreenshotContent = Schema.Struct({ "file_id": Schema.Union([ Schema.String.annotate({ "description": "The identifier of an uploaded file that contains the screenshot." }), Schema.Null - ]) + ]), + "detail": Schema.Literals(["low", "high", "auto", "original"]).annotate({ + "description": + "The detail level of the screenshot image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`." + }) }).annotate({ "title": "Computer screenshot", "description": "A screenshot of a computer." }) export type InputFileContent = { readonly "type": "input_file" readonly "file_id"?: string | null readonly "filename"?: string - readonly "file_url"?: string readonly "file_data"?: string + readonly "file_url"?: string + readonly "detail"?: "low" | "high" } export const InputFileContent = Schema.Struct({ "type": Schema.Literal("input_file").annotate({ "description": "The type of the input item. Always `input_file`." }), @@ -8020,11 +8047,16 @@ export const InputFileContent = Schema.Struct({ "filename": Schema.optionalKey( Schema.String.annotate({ "description": "The name of the file to be sent to the model." }) ), + "file_data": Schema.optionalKey( + Schema.String.annotate({ "description": "The content of the file to be sent to the model.\n" }) + ), "file_url": Schema.optionalKey( Schema.String.annotate({ "description": "The URL of the file to be sent to the model." }) ), - "file_data": Schema.optionalKey( - Schema.String.annotate({ "description": "The content of the file to be sent to the model.\n" }) + "detail": Schema.optionalKey( + Schema.Literals(["low", "high"]).annotate({ + "description": "The detail level of the file to be sent to the model. One of `high` or `low`. Defaults to `high`." + }) ) }).annotate({ "title": "Input file", "description": "A file input to the model." }) export type ClickParam = { @@ -8130,6 +8162,188 @@ export const ComputerCallSafetyCheckParam = Schema.Struct({ Schema.Union([Schema.String.annotate({ "description": "Details about the pending safety check." }), Schema.Null]) ) }).annotate({ "description": "A pending safety check for the computer call." }) +export type ToolSearchCall = { + readonly "type": "tool_search_call" + readonly "id": string + readonly "call_id": string | null + readonly "execution": "server" | "client" + readonly "arguments": unknown + readonly "status": "in_progress" | "completed" | "incomplete" + readonly "created_by"?: string +} +export const ToolSearchCall = Schema.Struct({ + "type": Schema.Literal("tool_search_call").annotate({ + "description": "The type of the item. Always `tool_search_call`." + }), + "id": Schema.String.annotate({ "description": "The unique ID of the tool search call item." }), + "call_id": Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of the tool search call generated by the model." }), + Schema.Null + ]), + "execution": Schema.Literals(["server", "client"]).annotate({ + "description": "Whether tool search was executed by the server or by the client." + }), + "arguments": Schema.Unknown.annotate({ "description": "Arguments used for the tool search call." }), + "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the tool search call item that was recorded." + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) + ) +}) +export type FunctionTool = { + readonly "type": "function" + readonly "name": string + readonly "description"?: string | null + readonly "parameters": {} | null + readonly "strict": boolean | null + readonly "defer_loading"?: boolean +} +export const FunctionTool = Schema.Struct({ + "type": Schema.Literal("function").annotate({ "description": "The type of the function tool. Always `function`." }), + "name": Schema.String.annotate({ "description": "The name of the function to call." }), + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "A description of the function. Used by the model to determine whether or not to call the function." + }), + Schema.Null + ]) + ), + "parameters": Schema.Union([ + Schema.Struct({}).annotate({ "description": "A JSON schema object describing the parameters of the function." }), + Schema.Null + ]), + "strict": Schema.Union([ + Schema.Boolean.annotate({ "description": "Whether to enforce strict parameter validation. Default `true`." }), + Schema.Null + ]), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this function is deferred and loaded via tool search." }) + ) +}).annotate({ + "title": "Function", + "description": + "Defines a function in your own code the model can choose to call. Learn more about [function calling](https://platform.openai.com/docs/guides/function-calling)." +}) +export type ComputerTool = { readonly "type": "computer" } +export const ComputerTool = Schema.Struct({ + "type": Schema.Literal("computer").annotate({ "description": "The type of the computer tool. Always `computer`." }) +}).annotate({ + "title": "Computer", + "description": + "A tool that controls a virtual computer. Learn more about the [computer tool](https://platform.openai.com/docs/guides/tools-computer-use)." +}) +export type ComputerUsePreviewTool = { + readonly "type": "computer_use_preview" + readonly "environment": "windows" | "mac" | "linux" | "ubuntu" | "browser" + readonly "display_width": number + readonly "display_height": number +} +export const ComputerUsePreviewTool = Schema.Struct({ + "type": Schema.Literal("computer_use_preview").annotate({ + "description": "The type of the computer use tool. Always `computer_use_preview`." + }), + "environment": Schema.Literals(["windows", "mac", "linux", "ubuntu", "browser"]).annotate({ + "description": "The type of computer environment to control." + }), + "display_width": Schema.Number.annotate({ "description": "The width of the computer display." }).check( + Schema.isInt() + ), + "display_height": Schema.Number.annotate({ "description": "The height of the computer display." }).check( + Schema.isInt() + ) +}).annotate({ + "title": "Computer use preview", + "description": + "A tool that controls a virtual computer. Learn more about the [computer tool](https://platform.openai.com/docs/guides/tools-computer-use)." +}) +export type InputFidelity = "high" | "low" +export const InputFidelity = Schema.Literals(["high", "low"]).annotate({ + "description": + "Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1` and `gpt-image-1.5` and later models, unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`." +}) +export type LocalShellToolParam = { readonly "type": "local_shell" } +export const LocalShellToolParam = Schema.Struct({ + "type": Schema.Literal("local_shell").annotate({ + "description": "The type of the local shell tool. Always `local_shell`." + }) +}).annotate({ + "title": "Local shell tool", + "description": "A tool that allows the model to execute shell commands in a local environment." +}) +export type LocalSkillParam = { readonly "name": string; readonly "description": string; readonly "path": string } +export const LocalSkillParam = Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the skill." }), + "description": Schema.String.annotate({ "description": "The description of the skill." }), + "path": Schema.String.annotate({ "description": "The path to the directory containing the skill." }) +}) +export type ContainerReferenceParam = { readonly "type": "container_reference"; readonly "container_id": string } +export const ContainerReferenceParam = Schema.Struct({ + "type": Schema.Literal("container_reference").annotate({ + "description": "References a container created with the /v1/containers endpoint" + }), + "container_id": Schema.String.annotate({ "description": "The ID of the referenced container." }) +}) +export type CustomTextFormatParam = { readonly "type": "text" } +export const CustomTextFormatParam = Schema.Struct({ + "type": Schema.Literal("text").annotate({ "description": "Unconstrained text format. Always `text`." }) +}).annotate({ "title": "Text format", "description": "Unconstrained free-form text." }) +export type CustomGrammarFormatParam = { + readonly "type": "grammar" + readonly "syntax": "lark" | "regex" + readonly "definition": string +} +export const CustomGrammarFormatParam = Schema.Struct({ + "type": Schema.Literal("grammar").annotate({ "description": "Grammar format. Always `grammar`." }), + "syntax": Schema.Literals(["lark", "regex"]).annotate({ + "description": "The syntax of the grammar definition. One of `lark` or `regex`." + }), + "definition": Schema.String.annotate({ "description": "The grammar definition." }) +}).annotate({ "title": "Grammar format", "description": "A grammar defined by the user." }) +export type EmptyModelParam = {} +export const EmptyModelParam = Schema.Struct({}) +export type ToolSearchToolParam = { + readonly "type": "tool_search" + readonly "execution"?: "server" | "client" + readonly "description"?: string | null + readonly "parameters"?: {} | null +} +export const ToolSearchToolParam = Schema.Struct({ + "type": Schema.Literal("tool_search").annotate({ "description": "The type of the tool. Always `tool_search`." }), + "execution": Schema.optionalKey( + Schema.Literals(["server", "client"]).annotate({ + "description": "Whether tool search is executed by the server or by the client." + }) + ), + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "Description shown to the model for a client-executed tool search tool." + }), + Schema.Null + ]) + ), + "parameters": Schema.optionalKey( + Schema.Union([ + Schema.Struct({}).annotate({ "description": "Parameter schema for a client-executed tool search tool." }), + Schema.Null + ]) + ) +}).annotate({ + "title": "Tool search tool", + "description": "Hosted or BYOT tool search configuration for deferred tools." +}) +export type SearchContentType = "text" | "image" +export const SearchContentType = Schema.Literals(["text", "image"]) +export type ApplyPatchToolParam = { readonly "type": "apply_patch" } +export const ApplyPatchToolParam = Schema.Struct({ + "type": Schema.Literal("apply_patch").annotate({ "description": "The type of the tool. Always `apply_patch`." }) +}).annotate({ + "title": "Apply patch tool", + "description": "Allows the assistant to create, delete, or update files using unified diffs." +}) export type CodeInterpreterOutputLogs = { readonly "type": "logs"; readonly "logs": string } export const CodeInterpreterOutputLogs = Schema.Struct({ "type": Schema.Literal("logs").annotate({ "description": "The type of the output. Always `logs`." }), @@ -8276,7 +8490,7 @@ export type InputImageContentParamAutoParam = { readonly "type": "input_image" readonly "image_url"?: string | null readonly "file_id"?: string | null - readonly "detail"?: "low" | "high" | "auto" | null + readonly "detail"?: "low" | "high" | "auto" | "original" | null } export const InputImageContentParamAutoParam = Schema.Struct({ "type": Schema.Literal("input_image").annotate({ @@ -8299,9 +8513,9 @@ export const InputImageContentParamAutoParam = Schema.Struct({ ), "detail": Schema.optionalKey( Schema.Union([ - Schema.Literals(["low", "high", "auto"]).annotate({ + Schema.Literals(["low", "high", "auto", "original"]).annotate({ "description": - "The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`." + "The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`." }), Schema.Null ]) @@ -8316,6 +8530,7 @@ export type InputFileContentParam = { readonly "filename"?: string | null readonly "file_data"?: string | null readonly "file_url"?: string | null + readonly "detail"?: "high" | "low" } export const InputFileContentParam = Schema.Struct({ "type": Schema.Literal("input_file").annotate({ "description": "The type of the input item. Always `input_file`." }), @@ -8344,8 +8559,49 @@ export const InputFileContentParam = Schema.Struct({ Schema.String.annotate({ "description": "The URL of the file to be sent to the model." }), Schema.Null ]) + ), + "detail": Schema.optionalKey( + Schema.Literals(["high", "low"]).annotate({ + "description": "The detail level of the file to be sent to the model. One of `high` or `low`. Defaults to `high`." + }) ) }).annotate({ "title": "Input file", "description": "A file input to the model." }) +export type ToolSearchCallItemParam = { + readonly "id"?: string | null + readonly "call_id"?: string | null + readonly "type": "tool_search_call" + readonly "execution"?: "server" | "client" + readonly "arguments": {} + readonly "status"?: "in_progress" | "completed" | "incomplete" | null +} +export const ToolSearchCallItemParam = Schema.Struct({ + "id": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The unique ID of this tool search call." }), Schema.Null]) + ), + "call_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of the tool search call generated by the model." }).check( + Schema.isMinLength(1) + ).check(Schema.isMaxLength(64)), + Schema.Null + ]) + ), + "type": Schema.Literal("tool_search_call").annotate({ "description": "The item type. Always `tool_search_call`." }), + "execution": Schema.optionalKey( + Schema.Literals(["server", "client"]).annotate({ + "description": "Whether tool search was executed by the server or by the client." + }) + ), + "arguments": Schema.Struct({}).annotate({ "description": "The arguments supplied to the tool search call." }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the tool search call." + }), + Schema.Null + ]) + ) +}) export type CompactionSummaryItemParam = { readonly "id"?: string | null readonly "type": "compaction" @@ -8363,19 +8619,6 @@ export const CompactionSummaryItemParam = Schema.Struct({ "description": "A compaction item generated by the [`v1/responses/compact` API](/docs/api-reference/responses/compact)." }) -export type LocalSkillParam = { readonly "name": string; readonly "description": string; readonly "path": string } -export const LocalSkillParam = Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the skill." }), - "description": Schema.String.annotate({ "description": "The description of the skill." }), - "path": Schema.String.annotate({ "description": "The path to the directory containing the skill." }) -}) -export type ContainerReferenceParam = { readonly "type": "container_reference"; readonly "container_id": string } -export const ContainerReferenceParam = Schema.Struct({ - "type": Schema.Literal("container_reference").annotate({ - "description": "References a container created with the /v1/containers endpoint" - }), - "container_id": Schema.String.annotate({ "description": "The ID of the referenced container." }) -}) export type FunctionShellCallOutputTimeoutOutcomeParam = { readonly "type": "timeout" } export const FunctionShellCallOutputTimeoutOutcomeParam = Schema.Struct({ "type": Schema.Literal("timeout").annotate({ "description": "The outcome type. Always `timeout`." }) @@ -8507,179 +8750,22 @@ export const ConversationResource = Schema.Struct({ "description": "The time at which the conversation was created, measured in seconds since the Unix epoch." }).check(Schema.isInt()) }) -export type FunctionTool = { - readonly "type": "function" - readonly "name": string - readonly "description"?: string | null - readonly "parameters": {} | null - readonly "strict": boolean | null -} -export const FunctionTool = Schema.Struct({ - "type": Schema.Literal("function").annotate({ "description": "The type of the function tool. Always `function`." }), - "name": Schema.String.annotate({ "description": "The name of the function to call." }), - "description": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "A description of the function. Used by the model to determine whether or not to call the function." - }), - Schema.Null - ]) - ), - "parameters": Schema.Union([ - Schema.Struct({}).annotate({ "description": "A JSON schema object describing the parameters of the function." }), - Schema.Null - ]), - "strict": Schema.Union([ - Schema.Boolean.annotate({ "description": "Whether to enforce strict parameter validation. Default `true`." }), - Schema.Null - ]) +export type ImageGenOutputTokensDetails = { readonly "image_tokens": number; readonly "text_tokens": number } +export const ImageGenOutputTokensDetails = Schema.Struct({ + "image_tokens": Schema.Number.annotate({ "description": "The number of image output tokens generated by the model." }) + .check(Schema.isInt()), + "text_tokens": Schema.Number.annotate({ "description": "The number of text output tokens generated by the model." }) + .check(Schema.isInt()) }).annotate({ - "title": "Function", - "description": - "Defines a function in your own code the model can choose to call. Learn more about [function calling](https://platform.openai.com/docs/guides/function-calling)." + "title": "Image generation output token details", + "description": "The output token details for the image generation." }) -export type ComputerUsePreviewTool = { - readonly "type": "computer_use_preview" - readonly "environment": "windows" | "mac" | "linux" | "ubuntu" | "browser" - readonly "display_width": number - readonly "display_height": number -} -export const ComputerUsePreviewTool = Schema.Struct({ - "type": Schema.Literal("computer_use_preview").annotate({ - "description": "The type of the computer use tool. Always `computer_use_preview`." - }), - "environment": Schema.Literals(["windows", "mac", "linux", "ubuntu", "browser"]).annotate({ - "description": "The type of computer environment to control." - }), - "display_width": Schema.Number.annotate({ "description": "The width of the computer display." }).check( +export type ImageGenInputUsageDetails = { readonly "text_tokens": number; readonly "image_tokens": number } +export const ImageGenInputUsageDetails = Schema.Struct({ + "text_tokens": Schema.Number.annotate({ "description": "The number of text tokens in the input prompt." }).check( Schema.isInt() ), - "display_height": Schema.Number.annotate({ "description": "The height of the computer display." }).check( - Schema.isInt() - ) -}).annotate({ - "title": "Computer use preview", - "description": - "A tool that controls a virtual computer. Learn more about the [computer tool](https://platform.openai.com/docs/guides/tools-computer-use)." -}) -export type InputFidelity = "high" | "low" -export const InputFidelity = Schema.Literals(["high", "low"]).annotate({ - "description": - "Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1` and `gpt-image-1.5` and later models, unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`." -}) -export type LocalShellToolParam = { readonly "type": "local_shell" } -export const LocalShellToolParam = Schema.Struct({ - "type": Schema.Literal("local_shell").annotate({ - "description": "The type of the local shell tool. Always `local_shell`." - }) -}).annotate({ - "title": "Local shell tool", - "description": "A tool that allows the model to execute shell commands in a local environment." -}) -export type CustomTextFormatParam = { readonly "type": "text" } -export const CustomTextFormatParam = Schema.Struct({ - "type": Schema.Literal("text").annotate({ "description": "Unconstrained text format. Always `text`." }) -}).annotate({ "title": "Text format", "description": "Unconstrained free-form text." }) -export type CustomGrammarFormatParam = { - readonly "type": "grammar" - readonly "syntax": "lark" | "regex" - readonly "definition": string -} -export const CustomGrammarFormatParam = Schema.Struct({ - "type": Schema.Literal("grammar").annotate({ "description": "Grammar format. Always `grammar`." }), - "syntax": Schema.Literals(["lark", "regex"]).annotate({ - "description": "The syntax of the grammar definition. One of `lark` or `regex`." - }), - "definition": Schema.String.annotate({ "description": "The grammar definition." }) -}).annotate({ "title": "Grammar format", "description": "A grammar defined by the user." }) -export type WebSearchPreviewTool = { - readonly "type": "web_search_preview" | "web_search_preview_2025_03_11" - readonly "user_location"?: { - readonly "type": "approximate" - readonly "country"?: string | null - readonly "region"?: string | null - readonly "city"?: string | null - readonly "timezone"?: string | null - } | null - readonly "search_context_size"?: "low" | "medium" | "high" -} -export const WebSearchPreviewTool = Schema.Struct({ - "type": Schema.Literals(["web_search_preview", "web_search_preview_2025_03_11"]).annotate({ - "description": "The type of the web search tool. One of `web_search_preview` or `web_search_preview_2025_03_11`." - }), - "user_location": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("approximate").annotate({ - "description": "The type of location approximation. Always `approximate`." - }), - "country": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`." - }), - Schema.Null - ]) - ), - "region": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "Free text input for the region of the user, e.g. `California`." }), - Schema.Null - ]) - ), - "city": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "Free text input for the city of the user, e.g. `San Francisco`." }), - Schema.Null - ]) - ), - "timezone": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`." - }), - Schema.Null - ]) - ) - }).annotate({ "description": "The user's location." }), - Schema.Null - ])), - "search_context_size": Schema.optionalKey( - Schema.Literals(["low", "medium", "high"]).annotate({ - "description": - "High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default." - }) - ) -}).annotate({ - "title": "Web search preview", - "description": - "This tool searches the web for relevant results to use in a response. Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search)." -}) -export type ApplyPatchToolParam = { readonly "type": "apply_patch" } -export const ApplyPatchToolParam = Schema.Struct({ - "type": Schema.Literal("apply_patch").annotate({ "description": "The type of the tool. Always `apply_patch`." }) -}).annotate({ - "title": "Apply patch tool", - "description": "Allows the assistant to create, delete, or update files using unified diffs." -}) -export type ImageGenOutputTokensDetails = { readonly "image_tokens": number; readonly "text_tokens": number } -export const ImageGenOutputTokensDetails = Schema.Struct({ - "image_tokens": Schema.Number.annotate({ "description": "The number of image output tokens generated by the model." }) - .check(Schema.isInt()), - "text_tokens": Schema.Number.annotate({ "description": "The number of text output tokens generated by the model." }) - .check(Schema.isInt()) -}).annotate({ - "title": "Image generation output token details", - "description": "The output token details for the image generation." -}) -export type ImageGenInputUsageDetails = { readonly "text_tokens": number; readonly "image_tokens": number } -export const ImageGenInputUsageDetails = Schema.Struct({ - "text_tokens": Schema.Number.annotate({ "description": "The number of text tokens in the input prompt." }).check( - Schema.isInt() - ), - "image_tokens": Schema.Number.annotate({ "description": "The number of image tokens in the input prompt." }).check( + "image_tokens": Schema.Number.annotate({ "description": "The number of image tokens in the input prompt." }).check( Schema.isInt() ) }).annotate({ @@ -8790,7 +8876,7 @@ export type VideoResource = { readonly "expires_at": number | null readonly "prompt": string | null readonly "size": "720x1280" | "1280x720" | "1024x1792" | "1792x1024" - readonly "seconds": "4" | "8" | "12" + readonly "seconds": string readonly "remixed_from_video_id": string | null readonly "error": { readonly "code": string; readonly "message": string } | null } @@ -8826,8 +8912,8 @@ export const VideoResource = Schema.Struct({ "size": Schema.Literals(["720x1280", "1280x720", "1024x1792", "1792x1024"]).annotate({ "description": "The resolution of the generated video." }), - "seconds": Schema.Literals(["4", "8", "12"]).annotate({ - "description": "Duration of the generated clip in seconds." + "seconds": Schema.String.annotate({ + "description": "Duration of the generated clip in seconds. For extensions, this is the stitched total duration." }), "remixed_from_video_id": Schema.Union([ Schema.String.annotate({ "description": "Identifier of the source video if this video is a remix." }), @@ -8856,6 +8942,7 @@ export type CreateVideoBody = { | "sora-2-2025-12-08" readonly "prompt": string readonly "input_reference"?: string + readonly "image_reference"?: { readonly "image_url"?: string; readonly "file_id"?: string } readonly "seconds"?: "4" | "8" | "12" readonly "size"?: "720x1280" | "1280x720" | "1024x1792" | "1792x1024" } @@ -8872,7 +8959,23 @@ export const CreateVideoBody = Schema.Struct({ Schema.isMinLength(1) ).check(Schema.isMaxLength(32000)), "input_reference": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional image reference that guides generation.", "format": "binary" }) + Schema.String.annotate({ + "description": "Optional multipart reference asset that guides generation.", + "format": "binary" + }) + ), + "image_reference": Schema.optionalKey( + Schema.Struct({ + "image_url": Schema.optionalKey( + Schema.String.annotate({ "description": "A fully qualified URL or base64-encoded data URL." }).check( + Schema.isMaxLength(20971520) + ) + ), + "file_id": Schema.optionalKey(Schema.String) + }).annotate({ + "description": + "Optional JSON-safe image reference that guides generation. Provide exactly one of `image_url` or `file_id`." + }) ), "seconds": Schema.optionalKey( Schema.Literals(["4", "8", "12"]).annotate({ @@ -10368,6 +10471,7 @@ export type MCPTool = { | "always" | "never" | null + readonly "defer_loading"?: boolean } export const MCPTool = Schema.Struct({ "type": Schema.Literal("mcp").annotate({ "description": "The type of the MCP tool. Always `mcp`." }), @@ -10440,6 +10544,9 @@ export const MCPTool = Schema.Struct({ ], { mode: "oneOf" }).annotate({ "description": "Specify which of the MCP server's tools require approval." }), Schema.Null ]) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this MCP tool is deferred and discovered via tool search.\n" }) ) }).annotate({ "title": "MCP tool", @@ -12986,86 +13093,407 @@ export const ComputerCallOutputItemParam = Schema.Struct({ ]) ) }).annotate({ "title": "Computer tool call output", "description": "The output of a computer tool call." }) -export type CodeInterpreterToolCall = { - readonly "type": "code_interpreter_call" - readonly "id": string - readonly "status": "in_progress" | "completed" | "incomplete" | "interpreting" | "failed" - readonly "container_id": string - readonly "code": string | null - readonly "outputs": ReadonlyArray | null +export type CreateImageEditRequest = { + readonly "image": string | ReadonlyArray + readonly "prompt": string + readonly "mask"?: string + readonly "background"?: "transparent" | "opaque" | "auto" | null + readonly "model"?: + | string + | "gpt-image-1.5" + | "dall-e-2" + | "gpt-image-1" + | "gpt-image-1-mini" + | "chatgpt-image-latest" + | null + readonly "n"?: number | null + readonly "size"?: "256x256" | "512x512" | "1024x1024" | "1536x1024" | "1024x1536" | "auto" | null + readonly "response_format"?: "url" | "b64_json" | null + readonly "output_format"?: "png" | "jpeg" | "webp" | null + readonly "output_compression"?: number | null + readonly "user"?: string + readonly "input_fidelity"?: InputFidelity | null + readonly "stream"?: boolean | null + readonly "partial_images"?: PartialImages + readonly "quality"?: "standard" | "low" | "medium" | "high" | "auto" | null } -export const CodeInterpreterToolCall = Schema.Struct({ - "type": Schema.Literal("code_interpreter_call").annotate({ - "description": "The type of the code interpreter tool call. Always `code_interpreter_call`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the code interpreter tool call.\n" }), - "status": Schema.Literals(["in_progress", "completed", "incomplete", "interpreting", "failed"]).annotate({ +export const CreateImageEditRequest = Schema.Struct({ + "image": Schema.Union([ + Schema.String.annotate({ "format": "binary" }), + Schema.Array(Schema.String.annotate({ "format": "binary" })).check(Schema.isMaxLength(16)) + ]).annotate({ "description": - "The status of the code interpreter tool call. Valid values are `in_progress`, `completed`, `incomplete`, `interpreting`, and `failed`.\n" - }), - "container_id": Schema.String.annotate({ "description": "The ID of the container used to run the code.\n" }), - "code": Schema.Union([ - Schema.String.annotate({ "description": "The code to run, or null if not available.\n" }), - Schema.Null - ]), - "outputs": Schema.Union([ - Schema.Array(Schema.Union([CodeInterpreterOutputLogs, CodeInterpreterOutputImage], { mode: "oneOf" })).annotate({ - "description": - "The outputs generated by the code interpreter, such as logs or images.\nCan be null if no outputs are available.\n" - }), - Schema.Null - ]) -}).annotate({ "title": "Code interpreter tool call", "description": "A tool call to run code.\n" }) -export type LocalShellToolCall = { - readonly "type": "local_shell_call" - readonly "id": string - readonly "call_id": string - readonly "action": LocalShellExecAction - readonly "status": "in_progress" | "completed" | "incomplete" -} -export const LocalShellToolCall = Schema.Struct({ - "type": Schema.Literal("local_shell_call").annotate({ - "description": "The type of the local shell call. Always `local_shell_call`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the local shell call.\n" }), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the local shell tool call generated by the model.\n" + "The image(s) to edit. Must be a supported image file or an array of images.\n\nFor the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg`\nfile less than 50MB. You can provide up to 16 images.\n`chatgpt-image-latest` follows the same input constraints as GPT image models.\n\nFor `dall-e-2`, you can only provide one image, and it should be a square\n`png` file less than 4MB.\n" }), - "action": LocalShellExecAction, - "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": "The status of the local shell call.\n" - }) -}).annotate({ "title": "Local shell call", "description": "A tool call to run a command on the local shell.\n" }) -export type FunctionShellCall = { - readonly "type": "shell_call" - readonly "id": string - readonly "call_id": string - readonly "action": { - readonly "commands": ReadonlyArray - readonly "timeout_ms": number | null - readonly "max_output_length": number | null - } - readonly "status": "in_progress" | "completed" | "incomplete" - readonly "environment": LocalEnvironmentResource | ContainerReferenceResource | null - readonly "created_by"?: string -} -export const FunctionShellCall = Schema.Struct({ - "type": Schema.Literal("shell_call").annotate({ "description": "The type of the item. Always `shell_call`." }), - "id": Schema.String.annotate({ - "description": "The unique ID of the shell tool call. Populated when this item is returned via API." + "prompt": Schema.String.annotate({ + "description": + "A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2`, and 32000 characters for the GPT image models." }), - "call_id": Schema.String.annotate({ "description": "The unique ID of the shell tool call generated by the model." }), - "action": Schema.Struct({ - "commands": Schema.Array(Schema.String.annotate({ "description": "A list of commands to run." })), - "timeout_ms": Schema.Union([ - Schema.Number.annotate({ "description": "Optional timeout in milliseconds for the commands." }).check( - Schema.isInt() - ), - Schema.Null - ]), - "max_output_length": Schema.Union([ - Schema.Number.annotate({ "description": "Optional maximum number of characters to return from each command." }) - .check(Schema.isInt()), + "mask": Schema.optionalKey(Schema.String.annotate({ + "description": + "An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. If there are multiple images provided, the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.", + "format": "binary" + })), + "background": Schema.optionalKey( + Schema.Union([Schema.Literal("transparent"), Schema.Literal("opaque"), Schema.Literal("auto"), Schema.Null]) + .annotate({ + "description": + "Allows to set transparency for the background of the generated image(s).\nThis parameter is only supported for the GPT image models. Must be one of\n`transparent`, `opaque` or `auto` (default value). When `auto` is used, the\nmodel will automatically determine the best background for the image.\n\nIf `transparent`, the output format needs to support transparency, so it\nshould be set to either `png` (default value) or `webp`.\n" + }) + ), + "model": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.String, + Schema.Literals(["gpt-image-1.5", "dall-e-2", "gpt-image-1", "gpt-image-1-mini", "chatgpt-image-latest"]) + ]).annotate({ "description": "The model to use for image generation. Defaults to `gpt-image-1.5`." }), + Schema.Null + ]) + ), + "n": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ + "description": "The number of images to generate. Must be between 1 and 10." + }) + ), + "size": Schema.optionalKey( + Schema.Union([ + Schema.Literal("256x256"), + Schema.Literal("512x512"), + Schema.Literal("1024x1024"), + Schema.Literal("1536x1024"), + Schema.Literal("1024x1536"), + Schema.Literal("auto"), + Schema.Null + ]).annotate({ + "description": + "The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`." + }) + ), + "response_format": Schema.optionalKey( + Schema.Union([Schema.Literal("url"), Schema.Literal("b64_json"), Schema.Null]).annotate({ + "description": + "The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images." + }) + ), + "output_format": Schema.optionalKey( + Schema.Union([Schema.Literal("png"), Schema.Literal("jpeg"), Schema.Literal("webp"), Schema.Null]).annotate({ + "description": + "The format in which the generated images are returned. This parameter is\nonly supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`.\nThe default value is `png`.\n" + }) + ), + "output_compression": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ + "description": + "The compression level (0-100%) for the generated images. This parameter\nis only supported for the GPT image models with the `webp` or `jpeg` output\nformats, and defaults to 100.\n" + }) + ), + "user": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).\n" + }) + ), + "input_fidelity": Schema.optionalKey(Schema.Union([InputFidelity, Schema.Null])), + "stream": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Edit the image in streaming mode. Defaults to `false`. See the\n[Image generation guide](/docs/guides/image-generation) for more information.\n" + }) + ), + "partial_images": Schema.optionalKey(PartialImages), + "quality": Schema.optionalKey( + Schema.Union([ + Schema.Literal("standard"), + Schema.Literal("low"), + Schema.Literal("medium"), + Schema.Literal("high"), + Schema.Literal("auto"), + Schema.Null + ]).annotate({ + "description": "The quality of the image that will be generated for GPT image models. Defaults to `auto`.\n" + }) + ) +}) +export type ImageGenTool = { + readonly "type": "image_generation" + readonly "model"?: string | "gpt-image-1" | "gpt-image-1-mini" | "gpt-image-1.5" + readonly "quality"?: "low" | "medium" | "high" | "auto" + readonly "size"?: "1024x1024" | "1024x1536" | "1536x1024" | "auto" + readonly "output_format"?: "png" | "webp" | "jpeg" + readonly "output_compression"?: number + readonly "moderation"?: "auto" | "low" + readonly "background"?: "transparent" | "opaque" | "auto" + readonly "input_fidelity"?: InputFidelity | null + readonly "input_image_mask"?: { readonly "image_url"?: string; readonly "file_id"?: string } + readonly "partial_images"?: number + readonly "action"?: "generate" | "edit" | "auto" +} +export const ImageGenTool = Schema.Struct({ + "type": Schema.Literal("image_generation").annotate({ + "description": "The type of the image generation tool. Always `image_generation`.\n" + }), + "model": Schema.optionalKey( + Schema.Union([ + Schema.String, + Schema.Literals(["gpt-image-1", "gpt-image-1-mini", "gpt-image-1.5"]).annotate({ + "description": "The image generation model to use. Default: `gpt-image-1`.\n" + }) + ]) + ), + "quality": Schema.optionalKey( + Schema.Literals(["low", "medium", "high", "auto"]).annotate({ + "description": + "The quality of the generated image. One of `low`, `medium`, `high`,\nor `auto`. Default: `auto`.\n" + }) + ), + "size": Schema.optionalKey( + Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"]).annotate({ + "description": + "The size of the generated image. One of `1024x1024`, `1024x1536`,\n`1536x1024`, or `auto`. Default: `auto`.\n" + }) + ), + "output_format": Schema.optionalKey( + Schema.Literals(["png", "webp", "jpeg"]).annotate({ + "description": "The output format of the generated image. One of `png`, `webp`, or\n`jpeg`. Default: `png`.\n" + }) + ), + "output_compression": Schema.optionalKey( + Schema.Number.annotate({ "description": "Compression level for the output image. Default: 100.\n" }).check( + Schema.isInt() + ).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(100)) + ), + "moderation": Schema.optionalKey( + Schema.Literals(["auto", "low"]).annotate({ + "description": "Moderation level for the generated image. Default: `auto`.\n" + }) + ), + "background": Schema.optionalKey( + Schema.Literals(["transparent", "opaque", "auto"]).annotate({ + "description": + "Background type for the generated image. One of `transparent`,\n`opaque`, or `auto`. Default: `auto`.\n" + }) + ), + "input_fidelity": Schema.optionalKey(Schema.Union([InputFidelity, Schema.Null])), + "input_image_mask": Schema.optionalKey( + Schema.Struct({ + "image_url": Schema.optionalKey(Schema.String.annotate({ "description": "Base64-encoded mask image.\n" })), + "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "File ID for the mask image.\n" })) + }).annotate({ + "description": + "Optional mask for inpainting. Contains `image_url`\n(string, optional) and `file_id` (string, optional).\n" + }) + ), + "partial_images": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Number of partial images to generate in streaming mode, from 0 (default value) to 3.\n" + }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(3)) + ), + "action": Schema.optionalKey( + Schema.Literals(["generate", "edit", "auto"]).annotate({ + "description": "Whether to generate a new image or edit an existing image. Default: `auto`.\n" + }) + ) +}).annotate({ + "title": "Image generation tool", + "description": "A tool that generates images using the GPT image models.\n" +}) +export type LocalEnvironmentParam = { readonly "type": "local"; readonly "skills"?: ReadonlyArray } +export const LocalEnvironmentParam = Schema.Struct({ + "type": Schema.Literal("local").annotate({ "description": "Use a local computer environment." }), + "skills": Schema.optionalKey( + Schema.Array(LocalSkillParam).annotate({ "description": "An optional list of skills." }).check( + Schema.isMaxLength(200) + ) + ) +}) +export type CustomToolParam = { + readonly "type": "custom" + readonly "name": string + readonly "description"?: string + readonly "format"?: CustomTextFormatParam | CustomGrammarFormatParam + readonly "defer_loading"?: boolean +} +export const CustomToolParam = Schema.Struct({ + "type": Schema.Literal("custom").annotate({ "description": "The type of the custom tool. Always `custom`." }), + "name": Schema.String.annotate({ "description": "The name of the custom tool, used to identify it in tool calls." }), + "description": Schema.optionalKey( + Schema.String.annotate({ "description": "Optional description of the custom tool, used to provide more context." }) + ), + "format": Schema.optionalKey( + Schema.Union([CustomTextFormatParam, CustomGrammarFormatParam], { mode: "oneOf" }).annotate({ + "description": "The input format for the custom tool. Default is unconstrained text." + }) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this tool should be deferred and discovered via tool search." }) + ) +}).annotate({ + "title": "Custom tool", + "description": + "A custom tool that processes input using a specified format. Learn more about [custom tools](/docs/guides/function-calling#custom-tools)" +}) +export type FunctionToolParam = { + readonly "name": string + readonly "description"?: string | null + readonly "parameters"?: EmptyModelParam | null + readonly "strict"?: boolean | null + readonly "type": "function" +} +export const FunctionToolParam = Schema.Struct({ + "name": Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(128)).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")) + ), + "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "parameters": Schema.optionalKey(Schema.Union([EmptyModelParam, Schema.Null])), + "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "type": Schema.Literal("function") +}) +export type WebSearchPreviewTool = { + readonly "type": "web_search_preview" | "web_search_preview_2025_03_11" + readonly "user_location"?: { + readonly "type": "approximate" + readonly "country"?: string | null + readonly "region"?: string | null + readonly "city"?: string | null + readonly "timezone"?: string | null + } | null + readonly "search_context_size"?: "low" | "medium" | "high" + readonly "search_content_types"?: ReadonlyArray +} +export const WebSearchPreviewTool = Schema.Struct({ + "type": Schema.Literals(["web_search_preview", "web_search_preview_2025_03_11"]).annotate({ + "description": "The type of the web search tool. One of `web_search_preview` or `web_search_preview_2025_03_11`." + }), + "user_location": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("approximate").annotate({ + "description": "The type of location approximation. Always `approximate`." + }), + "country": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`." + }), + Schema.Null + ]) + ), + "region": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "Free text input for the region of the user, e.g. `California`." }), + Schema.Null + ]) + ), + "city": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "Free text input for the city of the user, e.g. `San Francisco`." }), + Schema.Null + ]) + ), + "timezone": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`." + }), + Schema.Null + ]) + ) + }).annotate({ "description": "The user's location." }), + Schema.Null + ])), + "search_context_size": Schema.optionalKey( + Schema.Literals(["low", "medium", "high"]).annotate({ + "description": + "High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default." + }) + ), + "search_content_types": Schema.optionalKey(Schema.Array(SearchContentType)) +}).annotate({ + "title": "Web search preview", + "description": + "This tool searches the web for relevant results to use in a response. Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search)." +}) +export type CodeInterpreterToolCall = { + readonly "type": "code_interpreter_call" + readonly "id": string + readonly "status": "in_progress" | "completed" | "incomplete" | "interpreting" | "failed" + readonly "container_id": string + readonly "code": string | null + readonly "outputs": ReadonlyArray | null +} +export const CodeInterpreterToolCall = Schema.Struct({ + "type": Schema.Literal("code_interpreter_call").annotate({ + "description": "The type of the code interpreter tool call. Always `code_interpreter_call`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the code interpreter tool call.\n" }), + "status": Schema.Literals(["in_progress", "completed", "incomplete", "interpreting", "failed"]).annotate({ + "description": + "The status of the code interpreter tool call. Valid values are `in_progress`, `completed`, `incomplete`, `interpreting`, and `failed`.\n" + }), + "container_id": Schema.String.annotate({ "description": "The ID of the container used to run the code.\n" }), + "code": Schema.Union([ + Schema.String.annotate({ "description": "The code to run, or null if not available.\n" }), + Schema.Null + ]), + "outputs": Schema.Union([ + Schema.Array(Schema.Union([CodeInterpreterOutputLogs, CodeInterpreterOutputImage], { mode: "oneOf" })).annotate({ + "description": + "The outputs generated by the code interpreter, such as logs or images.\nCan be null if no outputs are available.\n" + }), + Schema.Null + ]) +}).annotate({ "title": "Code interpreter tool call", "description": "A tool call to run code.\n" }) +export type LocalShellToolCall = { + readonly "type": "local_shell_call" + readonly "id": string + readonly "call_id": string + readonly "action": LocalShellExecAction + readonly "status": "in_progress" | "completed" | "incomplete" +} +export const LocalShellToolCall = Schema.Struct({ + "type": Schema.Literal("local_shell_call").annotate({ + "description": "The type of the local shell call. Always `local_shell_call`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the local shell call.\n" }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the local shell tool call generated by the model.\n" + }), + "action": LocalShellExecAction, + "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the local shell call.\n" + }) +}).annotate({ "title": "Local shell call", "description": "A tool call to run a command on the local shell.\n" }) +export type FunctionShellCall = { + readonly "type": "shell_call" + readonly "id": string + readonly "call_id": string + readonly "action": { + readonly "commands": ReadonlyArray + readonly "timeout_ms": number | null + readonly "max_output_length": number | null + } + readonly "status": "in_progress" | "completed" | "incomplete" + readonly "environment": LocalEnvironmentResource | ContainerReferenceResource | null + readonly "created_by"?: string +} +export const FunctionShellCall = Schema.Struct({ + "type": Schema.Literal("shell_call").annotate({ "description": "The type of the item. Always `shell_call`." }), + "id": Schema.String.annotate({ + "description": "The unique ID of the shell tool call. Populated when this item is returned via API." + }), + "call_id": Schema.String.annotate({ "description": "The unique ID of the shell tool call generated by the model." }), + "action": Schema.Struct({ + "commands": Schema.Array(Schema.String.annotate({ "description": "A list of commands to run." })), + "timeout_ms": Schema.Union([ + Schema.Number.annotate({ "description": "Optional timeout in milliseconds for the commands." }).check( + Schema.isInt() + ), + Schema.Null + ]), + "max_output_length": Schema.Union([ + Schema.Number.annotate({ "description": "Optional maximum number of characters to return from each command." }) + .check(Schema.isInt()), Schema.Null ]) }).annotate({ @@ -13188,15 +13616,6 @@ export const FunctionCallOutputItemParam = Schema.Struct({ ]) ) }).annotate({ "title": "Function tool call output", "description": "The output of a function tool call." }) -export type LocalEnvironmentParam = { readonly "type": "local"; readonly "skills"?: ReadonlyArray } -export const LocalEnvironmentParam = Schema.Struct({ - "type": Schema.Literal("local").annotate({ "description": "Use a local computer environment." }), - "skills": Schema.optionalKey( - Schema.Array(LocalSkillParam).annotate({ "description": "An optional list of skills." }).check( - Schema.isMaxLength(200) - ) - ) -}) export type FunctionShellCallOutputContentParam = { readonly "stdout": string readonly "stderr": string @@ -13235,256 +13654,30 @@ export const ApplyPatchToolCallItemParam = Schema.Struct({ }), "id": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ - "description": "The unique ID of the apply patch tool call. Populated when this item is returned via API." - }), - Schema.Null - ]) - ), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the apply patch tool call generated by the model." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)), - "status": Schema.Literals(["in_progress", "completed"]).annotate({ - "title": "Apply patch call status", - "description": "The status of the apply patch tool call. One of `in_progress` or `completed`." - }), - "operation": Schema.Union([ - ApplyPatchCreateFileOperationParam, - ApplyPatchDeleteFileOperationParam, - ApplyPatchUpdateFileOperationParam - ], { mode: "oneOf" }).annotate({ - "title": "Apply patch operation", - "description": "The specific create, delete, or update instruction for the apply_patch tool call." - }) -}).annotate({ - "title": "Apply patch tool call", - "description": "A tool call representing a request to create, delete, or update files using diff patches." -}) -export type CreateImageEditRequest = { - readonly "image": string | ReadonlyArray - readonly "prompt": string - readonly "mask"?: string - readonly "background"?: "transparent" | "opaque" | "auto" | null - readonly "model"?: - | string - | "gpt-image-1.5" - | "dall-e-2" - | "gpt-image-1" - | "gpt-image-1-mini" - | "chatgpt-image-latest" - | null - readonly "n"?: number | null - readonly "size"?: "256x256" | "512x512" | "1024x1024" | "1536x1024" | "1024x1536" | "auto" | null - readonly "response_format"?: "url" | "b64_json" | null - readonly "output_format"?: "png" | "jpeg" | "webp" | null - readonly "output_compression"?: number | null - readonly "user"?: string - readonly "input_fidelity"?: InputFidelity | null - readonly "stream"?: boolean | null - readonly "partial_images"?: PartialImages - readonly "quality"?: "standard" | "low" | "medium" | "high" | "auto" | null -} -export const CreateImageEditRequest = Schema.Struct({ - "image": Schema.Union([ - Schema.String.annotate({ "format": "binary" }), - Schema.Array(Schema.String.annotate({ "format": "binary" })).check(Schema.isMaxLength(16)) - ]).annotate({ - "description": - "The image(s) to edit. Must be a supported image file or an array of images.\n\nFor the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg`\nfile less than 50MB. You can provide up to 16 images.\n`chatgpt-image-latest` follows the same input constraints as GPT image models.\n\nFor `dall-e-2`, you can only provide one image, and it should be a square\n`png` file less than 4MB.\n" - }), - "prompt": Schema.String.annotate({ - "description": - "A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2`, and 32000 characters for the GPT image models." - }), - "mask": Schema.optionalKey(Schema.String.annotate({ - "description": - "An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. If there are multiple images provided, the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.", - "format": "binary" - })), - "background": Schema.optionalKey( - Schema.Union([Schema.Literal("transparent"), Schema.Literal("opaque"), Schema.Literal("auto"), Schema.Null]) - .annotate({ - "description": - "Allows to set transparency for the background of the generated image(s).\nThis parameter is only supported for the GPT image models. Must be one of\n`transparent`, `opaque` or `auto` (default value). When `auto` is used, the\nmodel will automatically determine the best background for the image.\n\nIf `transparent`, the output format needs to support transparency, so it\nshould be set to either `png` (default value) or `webp`.\n" - }) - ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.String, - Schema.Literals(["gpt-image-1.5", "dall-e-2", "gpt-image-1", "gpt-image-1-mini", "chatgpt-image-latest"]) - ]).annotate({ "description": "The model to use for image generation. Defaults to `gpt-image-1.5`." }), - Schema.Null - ]) - ), - "n": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "description": "The number of images to generate. Must be between 1 and 10." - }) - ), - "size": Schema.optionalKey( - Schema.Union([ - Schema.Literal("256x256"), - Schema.Literal("512x512"), - Schema.Literal("1024x1024"), - Schema.Literal("1536x1024"), - Schema.Literal("1024x1536"), - Schema.Literal("auto"), - Schema.Null - ]).annotate({ - "description": - "The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`." - }) - ), - "response_format": Schema.optionalKey( - Schema.Union([Schema.Literal("url"), Schema.Literal("b64_json"), Schema.Null]).annotate({ - "description": - "The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images." - }) - ), - "output_format": Schema.optionalKey( - Schema.Union([Schema.Literal("png"), Schema.Literal("jpeg"), Schema.Literal("webp"), Schema.Null]).annotate({ - "description": - "The format in which the generated images are returned. This parameter is\nonly supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`.\nThe default value is `png`.\n" - }) - ), - "output_compression": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "description": - "The compression level (0-100%) for the generated images. This parameter\nis only supported for the GPT image models with the `webp` or `jpeg` output\nformats, and defaults to 100.\n" - }) - ), - "user": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).\n" - }) - ), - "input_fidelity": Schema.optionalKey(Schema.Union([InputFidelity, Schema.Null])), - "stream": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Edit the image in streaming mode. Defaults to `false`. See the\n[Image generation guide](/docs/guides/image-generation) for more information.\n" - }) - ), - "partial_images": Schema.optionalKey(PartialImages), - "quality": Schema.optionalKey( - Schema.Union([ - Schema.Literal("standard"), - Schema.Literal("low"), - Schema.Literal("medium"), - Schema.Literal("high"), - Schema.Literal("auto"), - Schema.Null - ]).annotate({ - "description": "The quality of the image that will be generated for GPT image models. Defaults to `auto`.\n" - }) - ) -}) -export type ImageGenTool = { - readonly "type": "image_generation" - readonly "model"?: string | "gpt-image-1" | "gpt-image-1-mini" | "gpt-image-1.5" - readonly "quality"?: "low" | "medium" | "high" | "auto" - readonly "size"?: "1024x1024" | "1024x1536" | "1536x1024" | "auto" - readonly "output_format"?: "png" | "webp" | "jpeg" - readonly "output_compression"?: number - readonly "moderation"?: "auto" | "low" - readonly "background"?: "transparent" | "opaque" | "auto" - readonly "input_fidelity"?: InputFidelity | null - readonly "input_image_mask"?: { readonly "image_url"?: string; readonly "file_id"?: string } - readonly "partial_images"?: number - readonly "action"?: "generate" | "edit" | "auto" -} -export const ImageGenTool = Schema.Struct({ - "type": Schema.Literal("image_generation").annotate({ - "description": "The type of the image generation tool. Always `image_generation`.\n" - }), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals(["gpt-image-1", "gpt-image-1-mini", "gpt-image-1.5"]).annotate({ - "description": "The image generation model to use. Default: `gpt-image-1`.\n" - }) - ]) - ), - "quality": Schema.optionalKey( - Schema.Literals(["low", "medium", "high", "auto"]).annotate({ - "description": - "The quality of the generated image. One of `low`, `medium`, `high`,\nor `auto`. Default: `auto`.\n" - }) - ), - "size": Schema.optionalKey( - Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"]).annotate({ - "description": - "The size of the generated image. One of `1024x1024`, `1024x1536`,\n`1536x1024`, or `auto`. Default: `auto`.\n" - }) - ), - "output_format": Schema.optionalKey( - Schema.Literals(["png", "webp", "jpeg"]).annotate({ - "description": "The output format of the generated image. One of `png`, `webp`, or\n`jpeg`. Default: `png`.\n" - }) - ), - "output_compression": Schema.optionalKey( - Schema.Number.annotate({ "description": "Compression level for the output image. Default: 100.\n" }).check( - Schema.isInt() - ).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(100)) - ), - "moderation": Schema.optionalKey( - Schema.Literals(["auto", "low"]).annotate({ - "description": "Moderation level for the generated image. Default: `auto`.\n" - }) - ), - "background": Schema.optionalKey( - Schema.Literals(["transparent", "opaque", "auto"]).annotate({ - "description": - "Background type for the generated image. One of `transparent`,\n`opaque`, or `auto`. Default: `auto`.\n" - }) - ), - "input_fidelity": Schema.optionalKey(Schema.Union([InputFidelity, Schema.Null])), - "input_image_mask": Schema.optionalKey( - Schema.Struct({ - "image_url": Schema.optionalKey(Schema.String.annotate({ "description": "Base64-encoded mask image.\n" })), - "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "File ID for the mask image.\n" })) - }).annotate({ - "description": - "Optional mask for inpainting. Contains `image_url`\n(string, optional) and `file_id` (string, optional).\n" - }) - ), - "partial_images": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Number of partial images to generate in streaming mode, from 0 (default value) to 3.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(3)) - ), - "action": Schema.optionalKey( - Schema.Literals(["generate", "edit", "auto"]).annotate({ - "description": "Whether to generate a new image or edit an existing image. Default: `auto`.\n" - }) - ) -}).annotate({ - "title": "Image generation tool", - "description": "A tool that generates images using the GPT image models.\n" -}) -export type CustomToolParam = { - readonly "type": "custom" - readonly "name": string - readonly "description"?: string - readonly "format"?: CustomTextFormatParam | CustomGrammarFormatParam -} -export const CustomToolParam = Schema.Struct({ - "type": Schema.Literal("custom").annotate({ "description": "The type of the custom tool. Always `custom`." }), - "name": Schema.String.annotate({ "description": "The name of the custom tool, used to identify it in tool calls." }), - "description": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional description of the custom tool, used to provide more context." }) + Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call. Populated when this item is returned via API." + }), + Schema.Null + ]) ), - "format": Schema.optionalKey( - Schema.Union([CustomTextFormatParam, CustomGrammarFormatParam], { mode: "oneOf" }).annotate({ - "description": "The input format for the custom tool. Default is unconstrained text." - }) - ) + "call_id": Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call generated by the model." + }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)), + "status": Schema.Literals(["in_progress", "completed"]).annotate({ + "title": "Apply patch call status", + "description": "The status of the apply patch tool call. One of `in_progress` or `completed`." + }), + "operation": Schema.Union([ + ApplyPatchCreateFileOperationParam, + ApplyPatchDeleteFileOperationParam, + ApplyPatchUpdateFileOperationParam + ], { mode: "oneOf" }).annotate({ + "title": "Apply patch operation", + "description": "The specific create, delete, or update instruction for the apply_patch tool call." + }) }).annotate({ - "title": "Custom tool", - "description": - "A custom tool that processes input using a specified format. Learn more about [custom tools](/docs/guides/function-calling#custom-tools)" + "title": "Apply patch tool call", + "description": "A tool call representing a request to create, delete, or update files using diff patches." }) export type ImageGenUsage = { readonly "input_tokens": number @@ -14710,6 +14903,7 @@ export type RealtimeCallCreateRequest = { readonly "model"?: | string | "gpt-realtime" + | "gpt-realtime-1.5" | "gpt-realtime-2025-08-28" | "gpt-4o-realtime-preview" | "gpt-4o-realtime-preview-2024-10-01" @@ -14720,6 +14914,7 @@ export type RealtimeCallCreateRequest = { | "gpt-realtime-mini" | "gpt-realtime-mini-2025-10-06" | "gpt-realtime-mini-2025-12-15" + | "gpt-audio-1.5" | "gpt-audio-mini" | "gpt-audio-mini-2025-10-06" | "gpt-audio-mini-2025-12-15" @@ -14796,6 +14991,7 @@ export const RealtimeCallCreateRequest = Schema.Struct({ Schema.String, Schema.Literals([ "gpt-realtime", + "gpt-realtime-1.5", "gpt-realtime-2025-08-28", "gpt-4o-realtime-preview", "gpt-4o-realtime-preview-2024-10-01", @@ -14806,6 +15002,7 @@ export const RealtimeCallCreateRequest = Schema.Struct({ "gpt-realtime-mini", "gpt-realtime-mini-2025-10-06", "gpt-realtime-mini-2025-12-15", + "gpt-audio-1.5", "gpt-audio-mini", "gpt-audio-mini-2025-10-06", "gpt-audio-mini-2025-12-15" @@ -15022,6 +15219,7 @@ export type RealtimeSession = { readonly "model"?: | string | "gpt-realtime" + | "gpt-realtime-1.5" | "gpt-realtime-2025-08-28" | "gpt-4o-realtime-preview" | "gpt-4o-realtime-preview-2024-10-01" @@ -15032,6 +15230,7 @@ export type RealtimeSession = { | "gpt-realtime-mini" | "gpt-realtime-mini-2025-10-06" | "gpt-realtime-mini-2025-12-15" + | "gpt-audio-1.5" | "gpt-audio-mini" | "gpt-audio-mini-2025-10-06" | "gpt-audio-mini-2025-12-15" @@ -15096,6 +15295,7 @@ export const RealtimeSession = Schema.Struct({ Schema.String, Schema.Literals([ "gpt-realtime", + "gpt-realtime-1.5", "gpt-realtime-2025-08-28", "gpt-4o-realtime-preview", "gpt-4o-realtime-preview-2024-10-01", @@ -15106,6 +15306,7 @@ export const RealtimeSession = Schema.Struct({ "gpt-realtime-mini", "gpt-realtime-mini-2025-10-06", "gpt-realtime-mini-2025-12-15", + "gpt-audio-1.5", "gpt-audio-mini", "gpt-audio-mini-2025-10-06", "gpt-audio-mini-2025-12-15" @@ -15455,6 +15656,7 @@ export type RealtimeSessionCreateRequestGA = { readonly "model"?: | string | "gpt-realtime" + | "gpt-realtime-1.5" | "gpt-realtime-2025-08-28" | "gpt-4o-realtime-preview" | "gpt-4o-realtime-preview-2024-10-01" @@ -15465,6 +15667,7 @@ export type RealtimeSessionCreateRequestGA = { | "gpt-realtime-mini" | "gpt-realtime-mini-2025-10-06" | "gpt-realtime-mini-2025-12-15" + | "gpt-audio-1.5" | "gpt-audio-mini" | "gpt-audio-mini-2025-10-06" | "gpt-audio-mini-2025-12-15" @@ -15535,6 +15738,7 @@ export const RealtimeSessionCreateRequestGA = Schema.Struct({ Schema.String, Schema.Literals([ "gpt-realtime", + "gpt-realtime-1.5", "gpt-realtime-2025-08-28", "gpt-4o-realtime-preview", "gpt-4o-realtime-preview-2024-10-01", @@ -15545,6 +15749,7 @@ export const RealtimeSessionCreateRequestGA = Schema.Struct({ "gpt-realtime-mini", "gpt-realtime-mini-2025-10-06", "gpt-realtime-mini-2025-12-15", + "gpt-audio-1.5", "gpt-audio-mini", "gpt-audio-mini-2025-10-06", "gpt-audio-mini-2025-12-15" @@ -15741,6 +15946,7 @@ export type RealtimeSessionCreateResponseGA = { readonly "model"?: | string | "gpt-realtime" + | "gpt-realtime-1.5" | "gpt-realtime-2025-08-28" | "gpt-4o-realtime-preview" | "gpt-4o-realtime-preview-2024-10-01" @@ -15751,6 +15957,7 @@ export type RealtimeSessionCreateResponseGA = { | "gpt-realtime-mini" | "gpt-realtime-mini-2025-10-06" | "gpt-realtime-mini-2025-12-15" + | "gpt-audio-1.5" | "gpt-audio-mini" | "gpt-audio-mini-2025-10-06" | "gpt-audio-mini-2025-12-15" @@ -15829,6 +16036,7 @@ export const RealtimeSessionCreateResponseGA = Schema.Struct({ Schema.String, Schema.Literals([ "gpt-realtime", + "gpt-realtime-1.5", "gpt-realtime-2025-08-28", "gpt-4o-realtime-preview", "gpt-4o-realtime-preview-2024-10-01", @@ -15839,6 +16047,7 @@ export const RealtimeSessionCreateResponseGA = Schema.Struct({ "gpt-realtime-mini", "gpt-realtime-mini-2025-10-06", "gpt-realtime-mini-2025-12-15", + "gpt-audio-1.5", "gpt-audio-mini", "gpt-audio-mini-2025-10-06", "gpt-audio-mini-2025-12-15" @@ -16444,40 +16653,6 @@ export const ComputerAction = Schema.Union([ TypeParam, WaitParam ], { mode: "oneOf" }) -export type FunctionShellCallOutput = { - readonly "type": "shell_call_output" - readonly "id": string - readonly "call_id": string - readonly "status": "in_progress" | "completed" | "incomplete" - readonly "output": ReadonlyArray - readonly "max_output_length": number | null - readonly "created_by"?: string -} -export const FunctionShellCallOutput = Schema.Struct({ - "type": Schema.Literal("shell_call_output").annotate({ - "description": "The type of the shell call output. Always `shell_call_output`." - }), - "id": Schema.String.annotate({ - "description": "The unique ID of the shell call output. Populated when this item is returned via API." - }), - "call_id": Schema.String.annotate({ "description": "The unique ID of the shell tool call generated by the model." }), - "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": "The status of the shell call output. One of `in_progress`, `completed`, or `incomplete`." - }), - "output": Schema.Array(FunctionShellCallOutputContent).annotate({ - "description": "An array of shell call output contents" - }), - "max_output_length": Schema.Union([ - Schema.Number.annotate({ - "description": - "The maximum length of the shell command output. This is generated by the model and should be passed back with the raw output." - }).check(Schema.isInt()), - Schema.Null - ]), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) - ) -}).annotate({ "title": "Shell call output", "description": "The output of a shell tool call that was emitted." }) export type FunctionShellCallItemParam = { readonly "id"?: string | null readonly "call_id": string @@ -16547,6 +16722,61 @@ export const FunctionShellCallItemParam = Schema.Struct({ "title": "Shell tool call", "description": "A tool representing a request to execute one or more shell commands." }) +export type NamespaceToolParam = { + readonly "type": "namespace" + readonly "name": string + readonly "description": string + readonly "tools": ReadonlyArray +} +export const NamespaceToolParam = Schema.Struct({ + "type": Schema.Literal("namespace").annotate({ "description": "The type of the tool. Always `namespace`." }), + "name": Schema.String.annotate({ "description": "The namespace name used in tool calls (for example, `crm`)." }) + .check(Schema.isMinLength(1)), + "description": Schema.String.annotate({ "description": "A description of the namespace shown to the model." }).check( + Schema.isMinLength(1) + ), + "tools": Schema.Array( + Schema.Union([FunctionToolParam, CustomToolParam], { mode: "oneOf" }).annotate({ + "description": "A function or custom tool that belongs to a namespace." + }) + ).annotate({ "description": "The function/custom tools available inside this namespace." }).check( + Schema.isMinLength(1) + ) +}).annotate({ "title": "Namespace", "description": "Groups function/custom tools under a shared namespace." }) +export type FunctionShellCallOutput = { + readonly "type": "shell_call_output" + readonly "id": string + readonly "call_id": string + readonly "status": "in_progress" | "completed" | "incomplete" + readonly "output": ReadonlyArray + readonly "max_output_length": number | null + readonly "created_by"?: string +} +export const FunctionShellCallOutput = Schema.Struct({ + "type": Schema.Literal("shell_call_output").annotate({ + "description": "The type of the shell call output. Always `shell_call_output`." + }), + "id": Schema.String.annotate({ + "description": "The unique ID of the shell call output. Populated when this item is returned via API." + }), + "call_id": Schema.String.annotate({ "description": "The unique ID of the shell tool call generated by the model." }), + "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the shell call output. One of `in_progress`, `completed`, or `incomplete`." + }), + "output": Schema.Array(FunctionShellCallOutputContent).annotate({ + "description": "An array of shell call output contents" + }), + "max_output_length": Schema.Union([ + Schema.Number.annotate({ + "description": + "The maximum length of the shell command output. This is generated by the model and should be passed back with the raw output." + }).check(Schema.isInt()), + Schema.Null + ]), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) + ) +}).annotate({ "title": "Shell call output", "description": "The output of a shell tool call that was emitted." }) export type FunctionShellCallOutputItemParam = { readonly "id"?: string | null readonly "call_id": string @@ -19437,6 +19667,7 @@ export const Message = Schema.Struct({ export type EasyInputMessage = { readonly "role": "user" | "assistant" | "system" | "developer" readonly "content": string | InputMessageContentList + readonly "phase"?: MessagePhase | null readonly "type"?: "message" } export const EasyInputMessage = Schema.Struct({ @@ -19450,6 +19681,7 @@ export const EasyInputMessage = Schema.Struct({ "description": "Text, image, or audio input to the model, used to generate a response.\nCan also contain previous assistant responses.\n" }), + "phase": Schema.optionalKey(Schema.Union([MessagePhase, Schema.Null])), "type": Schema.optionalKey( Schema.Literal("message").annotate({ "description": "The type of the message input. Always `message`.\n" }) ) @@ -19510,34 +19742,11 @@ export const InputMessageResource = Schema.Struct({ "description": "A message input to the model with a role indicating instruction following\nhierarchy. Instructions given with the `developer` or `system` role take\nprecedence over instructions given with the `user` role.\n" }) -export type ComputerToolCall = { - readonly "type": "computer_call" - readonly "id": string - readonly "call_id": string - readonly "action": ComputerAction - readonly "pending_safety_checks": ReadonlyArray - readonly "status": "in_progress" | "completed" | "incomplete" -} -export const ComputerToolCall = Schema.Struct({ - "type": Schema.Literal("computer_call").annotate({ - "description": "The type of the computer call. Always `computer_call`." - }), - "id": Schema.String.annotate({ "description": "The unique ID of the computer call." }), - "call_id": Schema.String.annotate({ - "description": "An identifier used when responding to the tool call with output.\n" - }), - "action": ComputerAction, - "pending_safety_checks": Schema.Array(ComputerCallSafetyCheckParam).annotate({ - "description": "The pending safety checks for the computer call.\n" - }), - "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" - }) -}).annotate({ - "title": "Computer tool call", +export type ComputerActionList = ReadonlyArray +export const ComputerActionList = Schema.Array(ComputerAction).annotate({ + "title": "Computer Action List", "description": - "A tool call to a computer use tool. See the\n[computer use guide](/docs/guides/tools-computer-use) for more information.\n" + "Flattened batched actions for `computer_use`. Each action includes an\n`type` discriminator and action-specific fields.\n" }) export type ThreadItem = | UserMessageItem @@ -19601,6 +19810,8 @@ export type CreateChatCompletionRequest = { readonly "messages": ReadonlyArray readonly "model": | string + | "gpt-5.4" + | "gpt-5.3-chat-latest" | "gpt-5.2" | "gpt-5.2-2025-12-11" | "gpt-5.2-chat-latest" @@ -19776,6 +19987,8 @@ export const CreateChatCompletionRequest = Schema.Struct({ "model": Schema.Union([ Schema.String, Schema.Literals([ + "gpt-5.4", + "gpt-5.3-chat-latest", "gpt-5.2", "gpt-5.2-2025-12-11", "gpt-5.2-chat-latest", @@ -20178,6 +20391,7 @@ export const RunStreamEvent = Schema.Union([ export type Tool = | FunctionTool | FileSearchTool + | ComputerTool | ComputerUsePreviewTool | WebSearchTool | MCPTool @@ -20186,11 +20400,14 @@ export type Tool = | LocalShellToolParam | FunctionShellToolParam | CustomToolParam + | NamespaceToolParam + | ToolSearchToolParam | WebSearchPreviewTool | ApplyPatchToolParam export const Tool = Schema.Union([ FunctionTool, FileSearchTool, + ComputerTool, ComputerUsePreviewTool, WebSearchTool, MCPTool, @@ -20199,6 +20416,8 @@ export const Tool = Schema.Union([ LocalShellToolParam, FunctionShellToolParam, CustomToolParam, + NamespaceToolParam, + ToolSearchToolParam, WebSearchPreviewTool, ApplyPatchToolParam ], { mode: "oneOf" }).annotate({ "description": "A tool that can be used to generate a response.\n" }) @@ -20225,6 +20444,7 @@ export type OutputMessage = { readonly "type": "message" readonly "role": "assistant" readonly "content": ReadonlyArray + readonly "phase"?: MessagePhase | null readonly "status": "in_progress" | "completed" | "incomplete" } export const OutputMessage = Schema.Struct({ @@ -20234,112 +20454,42 @@ export const OutputMessage = Schema.Struct({ "description": "The role of the output message. Always `assistant`.\n" }), "content": Schema.Array(OutputMessageContent).annotate({ "description": "The content of the output message.\n" }), + "phase": Schema.optionalKey(Schema.Union([MessagePhase, Schema.Null])), "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ "description": "The status of the message input. One of `in_progress`, `completed`, or\n`incomplete`. Populated when input items are returned via API.\n" }) }).annotate({ "title": "Output message", "description": "An output message from the model.\n" }) -export type ConversationItem = - | Message - | FunctionToolCallResource - | FunctionToolCallOutputResource - | FileSearchToolCall - | WebSearchToolCall - | ImageGenToolCall - | ComputerToolCall - | ComputerToolCallOutputResource - | ReasoningItem - | CodeInterpreterToolCall - | LocalShellToolCall - | LocalShellToolCallOutput - | FunctionShellCall - | FunctionShellCallOutput - | ApplyPatchToolCall - | ApplyPatchToolCallOutput - | MCPListTools - | MCPApprovalRequest - | MCPApprovalResponseResource - | MCPToolCall - | CustomToolCall - | CustomToolCallOutput -export const ConversationItem = Schema.Union([ - Message, - FunctionToolCallResource, - FunctionToolCallOutputResource, - FileSearchToolCall, - WebSearchToolCall, - ImageGenToolCall, - ComputerToolCall, - ComputerToolCallOutputResource, - ReasoningItem, - CodeInterpreterToolCall, - LocalShellToolCall, - LocalShellToolCallOutput, - FunctionShellCall, - FunctionShellCallOutput, - ApplyPatchToolCall, - ApplyPatchToolCallOutput, - MCPListTools, - MCPApprovalRequest, - MCPApprovalResponseResource, - MCPToolCall, - CustomToolCall, - CustomToolCallOutput -], { mode: "oneOf" }).annotate({ - "title": "Conversation item", +export type ComputerToolCall = { + readonly "type": "computer_call" + readonly "id": string + readonly "call_id": string + readonly "action"?: ComputerAction + readonly "actions"?: ComputerActionList + readonly "pending_safety_checks": ReadonlyArray + readonly "status": "in_progress" | "completed" | "incomplete" +} +export const ComputerToolCall = Schema.Struct({ + "type": Schema.Literal("computer_call").annotate({ + "description": "The type of the computer call. Always `computer_call`." + }), + "id": Schema.String.annotate({ "description": "The unique ID of the computer call." }), + "call_id": Schema.String.annotate({ + "description": "An identifier used when responding to the tool call with output.\n" + }), + "action": Schema.optionalKey(ComputerAction), + "actions": Schema.optionalKey(ComputerActionList), + "pending_safety_checks": Schema.Array(ComputerCallSafetyCheckParam).annotate({ + "description": "The pending safety checks for the computer call.\n" + }), + "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": + "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + }) +}).annotate({ + "title": "Computer tool call", "description": - "A single item within a conversation. The set of possible types are the same as the `output` type of a [Response object](/docs/api-reference/responses/object#responses/object-output)." -}) -export type ItemField = - | Message - | FunctionToolCall - | FunctionToolCallOutput - | FileSearchToolCall - | WebSearchToolCall - | ImageGenToolCall - | ComputerToolCall - | ComputerToolCallOutputResource - | ReasoningItem - | CompactionBody - | CodeInterpreterToolCall - | LocalShellToolCall - | LocalShellToolCallOutput - | FunctionShellCall - | FunctionShellCallOutput - | ApplyPatchToolCall - | ApplyPatchToolCallOutput - | MCPListTools - | MCPApprovalRequest - | MCPApprovalResponseResource - | MCPToolCall - | CustomToolCall - | CustomToolCallOutput -export const ItemField = Schema.Union([ - Message, - FunctionToolCall, - FunctionToolCallOutput, - FileSearchToolCall, - WebSearchToolCall, - ImageGenToolCall, - ComputerToolCall, - ComputerToolCallOutputResource, - ReasoningItem, - CompactionBody, - CodeInterpreterToolCall, - LocalShellToolCall, - LocalShellToolCallOutput, - FunctionShellCall, - FunctionShellCallOutput, - ApplyPatchToolCall, - ApplyPatchToolCallOutput, - MCPListTools, - MCPApprovalRequest, - MCPApprovalResponseResource, - MCPToolCall, - CustomToolCall, - CustomToolCallOutput -], { mode: "oneOf" }).annotate({ - "description": "An item representing a message, tool call, tool output, reasoning, or other response element." + "A tool call to a computer use tool. See the\n[computer use guide](/docs/guides/tools-computer-use) for more information.\n" }) export type ThreadItemListResource = { readonly "object": "list" @@ -20419,6 +20569,75 @@ export const ToolsArray = Schema.Array(Tool).annotate({ "description": "An array of tools the model may call while generating a response. You\ncan specify which tool to use by setting the `tool_choice` parameter.\n\nWe support the following categories of tools:\n- **Built-in tools**: Tools that are provided by OpenAI that extend the\n model's capabilities, like [web search](/docs/guides/tools-web-search)\n or [file search](/docs/guides/tools-file-search). Learn more about\n [built-in tools](/docs/guides/tools).\n- **MCP Tools**: Integrations with third-party systems via custom MCP servers\n or predefined connectors such as Google Drive and SharePoint. Learn more about\n [MCP Tools](/docs/guides/tools-connectors-mcp).\n- **Function calls (custom tools)**: Functions that are defined by you,\n enabling the model to call your own code with strongly typed arguments\n and outputs. Learn more about\n [function calling](/docs/guides/function-calling). You can also use\n custom tools to call your own code.\n" }) +export type ToolSearchOutput = { + readonly "type": "tool_search_output" + readonly "id": string + readonly "call_id": string | null + readonly "execution": "server" | "client" + readonly "tools": ReadonlyArray + readonly "status": "in_progress" | "completed" | "incomplete" + readonly "created_by"?: string +} +export const ToolSearchOutput = Schema.Struct({ + "type": Schema.Literal("tool_search_output").annotate({ + "description": "The type of the item. Always `tool_search_output`." + }), + "id": Schema.String.annotate({ "description": "The unique ID of the tool search output item." }), + "call_id": Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of the tool search call generated by the model." }), + Schema.Null + ]), + "execution": Schema.Literals(["server", "client"]).annotate({ + "description": "Whether tool search was executed by the server or by the client." + }), + "tools": Schema.Array(Tool).annotate({ "description": "The loaded tool definitions returned by tool search." }), + "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the tool search output item that was recorded." + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) + ) +}) +export type ToolSearchOutputItemParam = { + readonly "id"?: string | null + readonly "call_id"?: string | null + readonly "type": "tool_search_output" + readonly "execution"?: "server" | "client" + readonly "tools": ReadonlyArray + readonly "status"?: "in_progress" | "completed" | "incomplete" | null +} +export const ToolSearchOutputItemParam = Schema.Struct({ + "id": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The unique ID of this tool search output." }), Schema.Null]) + ), + "call_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of the tool search call generated by the model." }).check( + Schema.isMinLength(1) + ).check(Schema.isMaxLength(64)), + Schema.Null + ]) + ), + "type": Schema.Literal("tool_search_output").annotate({ + "description": "The item type. Always `tool_search_output`." + }), + "execution": Schema.optionalKey( + Schema.Literals(["server", "client"]).annotate({ + "description": "Whether tool search was executed by the server or by the client." + }) + ), + "tools": Schema.Array(Tool).annotate({ + "description": "The loaded tool definitions returned by the tool search output." + }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the tool search output." + }), + Schema.Null + ]) + ) +}) export type CreateEvalCompletionsRunDataSource = { readonly "type": "completions" readonly "input_messages"?: { @@ -20813,67 +21032,61 @@ export const GraderScoreModel = Schema.Struct({ "title": "ScoreModelGrader", "description": "A ScoreModelGrader object that uses a model to assign a score to the input.\n" }) -export type InputItem = - | EasyInputMessage - | InputMessage - | OutputMessage +export type ConversationItem = + | Message + | FunctionToolCallResource + | FunctionToolCallOutputResource | FileSearchToolCall - | ComputerToolCall - | ComputerCallOutputItemParam | WebSearchToolCall - | FunctionToolCall - | FunctionCallOutputItemParam - | ReasoningItem - | CompactionSummaryItemParam | ImageGenToolCall + | ComputerToolCall + | ComputerToolCallOutputResource + | ToolSearchCall + | ToolSearchOutput + | ReasoningItem | CodeInterpreterToolCall | LocalShellToolCall | LocalShellToolCallOutput - | FunctionShellCallItemParam - | FunctionShellCallOutputItemParam - | ApplyPatchToolCallItemParam - | ApplyPatchToolCallOutputItemParam + | FunctionShellCall + | FunctionShellCallOutput + | ApplyPatchToolCall + | ApplyPatchToolCallOutput | MCPListTools | MCPApprovalRequest - | MCPApprovalResponse + | MCPApprovalResponseResource | MCPToolCall - | CustomToolCallOutput | CustomToolCall - | ItemReferenceParam -export const InputItem = Schema.Union([ - EasyInputMessage, - Schema.Union([ - InputMessage, - OutputMessage, - FileSearchToolCall, - ComputerToolCall, - ComputerCallOutputItemParam, - WebSearchToolCall, - FunctionToolCall, - FunctionCallOutputItemParam, - ReasoningItem, - CompactionSummaryItemParam, - ImageGenToolCall, - CodeInterpreterToolCall, - LocalShellToolCall, - LocalShellToolCallOutput, - FunctionShellCallItemParam, - FunctionShellCallOutputItemParam, - ApplyPatchToolCallItemParam, - ApplyPatchToolCallOutputItemParam, - MCPListTools, - MCPApprovalRequest, - MCPApprovalResponse, - MCPToolCall, - CustomToolCallOutput, - CustomToolCall - ], { mode: "oneOf" }).annotate({ - "description": - "An item representing part of the context for the response to be\ngenerated by the model. Can contain text, images, and audio inputs,\nas well as previous assistant responses and tool call outputs.\n", - "title": "Item" - }), - ItemReferenceParam -], { mode: "oneOf" }) + | CustomToolCallOutput +export const ConversationItem = Schema.Union([ + Message, + FunctionToolCallResource, + FunctionToolCallOutputResource, + FileSearchToolCall, + WebSearchToolCall, + ImageGenToolCall, + ComputerToolCall, + ComputerToolCallOutputResource, + ToolSearchCall, + ToolSearchOutput, + ReasoningItem, + CodeInterpreterToolCall, + LocalShellToolCall, + LocalShellToolCallOutput, + FunctionShellCall, + FunctionShellCallOutput, + ApplyPatchToolCall, + ApplyPatchToolCallOutput, + MCPListTools, + MCPApprovalRequest, + MCPApprovalResponseResource, + MCPToolCall, + CustomToolCall, + CustomToolCallOutput +], { mode: "oneOf" }).annotate({ + "title": "Conversation item", + "description": + "A single item within a conversation. The set of possible types are the same as the `output` type of a [Response object](/docs/api-reference/responses/object#responses/object-output)." +}) export type ItemResource = | InputMessageResource | OutputMessage @@ -20883,6 +21096,8 @@ export type ItemResource = | WebSearchToolCall | FunctionToolCallResource | FunctionToolCallOutputResource + | ToolSearchCall + | ToolSearchOutput | ImageGenToolCall | CodeInterpreterToolCall | LocalShellToolCall @@ -20904,6 +21119,8 @@ export const ItemResource = Schema.Union([ WebSearchToolCall, FunctionToolCallResource, FunctionToolCallOutputResource, + ToolSearchCall, + ToolSearchOutput, ImageGenToolCall, CodeInterpreterToolCall, LocalShellToolCall, @@ -20924,6 +21141,8 @@ export type OutputItem = | WebSearchToolCall | ComputerToolCall | ReasoningItem + | ToolSearchCall + | ToolSearchOutput | CompactionBody | ImageGenToolCall | CodeInterpreterToolCall @@ -20943,6 +21162,8 @@ export const OutputItem = Schema.Union([ WebSearchToolCall, ComputerToolCall, ReasoningItem, + ToolSearchCall, + ToolSearchOutput, CompactionBody, ImageGenToolCall, CodeInterpreterToolCall, @@ -20967,6 +21188,8 @@ export type ResponseOutputItemAddedEvent = { | WebSearchToolCall | ComputerToolCall | ReasoningItem + | ToolSearchCall + | ToolSearchOutput | CompactionBody | ImageGenToolCall | CodeInterpreterToolCall @@ -20997,6 +21220,8 @@ export const ResponseOutputItemAddedEvent = Schema.Struct({ WebSearchToolCall, ComputerToolCall, ReasoningItem, + ToolSearchCall, + ToolSearchOutput, CompactionBody, ImageGenToolCall, CodeInterpreterToolCall, @@ -21022,6 +21247,8 @@ export type ResponseOutputItemDoneEvent = { | WebSearchToolCall | ComputerToolCall | ReasoningItem + | ToolSearchCall + | ToolSearchOutput | CompactionBody | ImageGenToolCall | CodeInterpreterToolCall @@ -21051,6 +21278,8 @@ export const ResponseOutputItemDoneEvent = Schema.Struct({ WebSearchToolCall, ComputerToolCall, ReasoningItem, + ToolSearchCall, + ToolSearchOutput, CompactionBody, ImageGenToolCall, CodeInterpreterToolCall, @@ -21065,61 +21294,126 @@ export const ResponseOutputItemDoneEvent = Schema.Struct({ CustomToolCall ]).annotate({ "description": "The output item that was marked done.\n" }) }).annotate({ "description": "Emitted when an output item is marked done." }) -export type ConversationItemList = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "first_id": string - readonly "last_id": string -} -export const ConversationItemList = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), - "data": Schema.Array(ConversationItem).annotate({ "description": "A list of conversation items." }), - "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }), - "first_id": Schema.String.annotate({ "description": "The ID of the first item in the list." }), - "last_id": Schema.String.annotate({ "description": "The ID of the last item in the list." }) -}).annotate({ "title": "The conversation item list", "description": "A list of Conversation items." }) -export type CompactResource = { - readonly "id": string - readonly "object": "response.compaction" - readonly "output": ReadonlyArray - readonly "created_at": number - readonly "usage": { - readonly "input_tokens": number - readonly "input_tokens_details": { readonly "cached_tokens": number } - readonly "output_tokens": number - readonly "output_tokens_details": { readonly "reasoning_tokens": number } - readonly "total_tokens": number - } -} -export const CompactResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique identifier for the compacted response." }), - "object": Schema.Literal("response.compaction").annotate({ - "description": "The object type. Always `response.compaction`." +export type ItemField = + | Message + | FunctionToolCall + | ToolSearchCall + | ToolSearchOutput + | FunctionToolCallOutput + | FileSearchToolCall + | WebSearchToolCall + | ImageGenToolCall + | ComputerToolCall + | ComputerToolCallOutputResource + | ReasoningItem + | CompactionBody + | CodeInterpreterToolCall + | LocalShellToolCall + | LocalShellToolCallOutput + | FunctionShellCall + | FunctionShellCallOutput + | ApplyPatchToolCall + | ApplyPatchToolCallOutput + | MCPListTools + | MCPApprovalRequest + | MCPApprovalResponseResource + | MCPToolCall + | CustomToolCall + | CustomToolCallOutput +export const ItemField = Schema.Union([ + Message, + FunctionToolCall, + ToolSearchCall, + ToolSearchOutput, + FunctionToolCallOutput, + FileSearchToolCall, + WebSearchToolCall, + ImageGenToolCall, + ComputerToolCall, + ComputerToolCallOutputResource, + ReasoningItem, + CompactionBody, + CodeInterpreterToolCall, + LocalShellToolCall, + LocalShellToolCallOutput, + FunctionShellCall, + FunctionShellCallOutput, + ApplyPatchToolCall, + ApplyPatchToolCallOutput, + MCPListTools, + MCPApprovalRequest, + MCPApprovalResponseResource, + MCPToolCall, + CustomToolCall, + CustomToolCallOutput +], { mode: "oneOf" }).annotate({ + "description": "An item representing a message, tool call, tool output, reasoning, or other response element." +}) +export type InputItem = + | EasyInputMessage + | InputMessage + | OutputMessage + | FileSearchToolCall + | ComputerToolCall + | ComputerCallOutputItemParam + | WebSearchToolCall + | FunctionToolCall + | FunctionCallOutputItemParam + | ToolSearchCallItemParam + | ToolSearchOutputItemParam + | ReasoningItem + | CompactionSummaryItemParam + | ImageGenToolCall + | CodeInterpreterToolCall + | LocalShellToolCall + | LocalShellToolCallOutput + | FunctionShellCallItemParam + | FunctionShellCallOutputItemParam + | ApplyPatchToolCallItemParam + | ApplyPatchToolCallOutputItemParam + | MCPListTools + | MCPApprovalRequest + | MCPApprovalResponse + | MCPToolCall + | CustomToolCallOutput + | CustomToolCall + | ItemReferenceParam +export const InputItem = Schema.Union([ + EasyInputMessage, + Schema.Union([ + InputMessage, + OutputMessage, + FileSearchToolCall, + ComputerToolCall, + ComputerCallOutputItemParam, + WebSearchToolCall, + FunctionToolCall, + FunctionCallOutputItemParam, + ToolSearchCallItemParam, + ToolSearchOutputItemParam, + ReasoningItem, + CompactionSummaryItemParam, + ImageGenToolCall, + CodeInterpreterToolCall, + LocalShellToolCall, + LocalShellToolCallOutput, + FunctionShellCallItemParam, + FunctionShellCallOutputItemParam, + ApplyPatchToolCallItemParam, + ApplyPatchToolCallOutputItemParam, + MCPListTools, + MCPApprovalRequest, + MCPApprovalResponse, + MCPToolCall, + CustomToolCallOutput, + CustomToolCall + ], { mode: "oneOf" }).annotate({ + "description": + "An item representing part of the context for the response to be\ngenerated by the model. Can contain text, images, and audio inputs,\nas well as previous assistant responses and tool call outputs.\n", + "title": "Item" }), - "output": Schema.Array(ItemField).annotate({ "description": "The compacted list of output items." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the compacted conversation was created." - }).check(Schema.isInt()), - "usage": Schema.Struct({ - "input_tokens": Schema.Number.annotate({ "description": "The number of input tokens." }).check(Schema.isInt()), - "input_tokens_details": Schema.Struct({ - "cached_tokens": Schema.Number.annotate({ - "description": - "The number of tokens that were retrieved from the cache. \n[More on prompt caching](/docs/guides/prompt-caching).\n" - }).check(Schema.isInt()) - }).annotate({ "description": "A detailed breakdown of the input tokens." }), - "output_tokens": Schema.Number.annotate({ "description": "The number of output tokens." }).check(Schema.isInt()), - "output_tokens_details": Schema.Struct({ - "reasoning_tokens": Schema.Number.annotate({ "description": "The number of reasoning tokens." }).check( - Schema.isInt() - ) - }).annotate({ "description": "A detailed breakdown of the output tokens." }), - "total_tokens": Schema.Number.annotate({ "description": "The total number of tokens used." }).check(Schema.isInt()) - }).annotate({ - "description": "Token accounting for the compaction pass, including cached, reasoning, and total tokens." - }) -}).annotate({ "title": "The compacted response object" }) + ItemReferenceParam +], { mode: "oneOf" }) export type CreateEvalLabelModelGrader = { readonly "type": "label_model" readonly "name": string @@ -21315,219 +21609,20 @@ export const GraderMulti = Schema.Struct({ "title": "MultiGrader", "description": "A MultiGrader object combines the output of multiple graders to produce a single score." }) -export type InputParam = string | ReadonlyArray -export const InputParam = Schema.Union([ - Schema.String.annotate({ - "title": "Text input", - "description": "A text input to the model, equivalent to a text input with the\n`user` role.\n" - }), - Schema.Array(InputItem).annotate({ - "title": "Input item list", - "description": "A list of one or many input items to the model, containing\ndifferent content types.\n" - }) -], { mode: "oneOf" }).annotate({ - "description": - "Text, image, or file inputs to the model, used to generate a response.\n\nLearn more:\n- [Text inputs and outputs](/docs/guides/text)\n- [Image inputs](/docs/guides/images)\n- [File inputs](/docs/guides/pdf-files)\n- [Conversation state](/docs/guides/conversation-state)\n- [Function calling](/docs/guides/function-calling)\n" -}) -export type CreateConversationBody = { - readonly "metadata"?: {} | null | null - readonly "items"?: ReadonlyArray | null -} -export const CreateConversationBody = Schema.Struct({ - "metadata": Schema.optionalKey(Schema.Union([ - Schema.Union([ - Schema.Struct({}).annotate({ - "description": - "Set of 16 key-value pairs that can be attached to an object. This can be\nuseful for storing additional information about the object in a structured\nformat, and querying for objects via API or the dashboard.\n\nKeys are strings with a maximum length of 64 characters. Values are strings\nwith a maximum length of 512 characters.\n" - }), - Schema.Null - ]).annotate({ - "description": - "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.\n Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters." - }), - Schema.Null - ])), - "items": Schema.optionalKey( - Schema.Union([ - Schema.Array(InputItem).annotate({ - "description": "Initial items to include in the conversation context. You may add up to 20 items at a time." - }).check(Schema.isMaxLength(20)), - Schema.Null - ]) - ) -}) -export type TokenCountsBody = { - readonly "model"?: string | null - readonly "input"?: string | ReadonlyArray | null - readonly "previous_response_id"?: string | null - readonly "tools"?: ReadonlyArray | null - readonly "text"?: ResponseTextParam | null - readonly "reasoning"?: { - readonly "effort"?: ReasoningEffort - readonly "summary"?: "auto" | "concise" | "detailed" | null - readonly "generate_summary"?: "auto" | "concise" | "detailed" | null - } | null - readonly "truncation"?: "auto" | "disabled" - readonly "instructions"?: string | null - readonly "conversation"?: ConversationParam | null - readonly "tool_choice"?: - | ToolChoiceOptions - | ToolChoiceAllowed - | ToolChoiceTypes - | ToolChoiceFunction - | ToolChoiceMCP - | ToolChoiceCustom - | SpecificApplyPatchParam - | SpecificFunctionShellParam - | null - readonly "parallel_tool_calls"?: boolean | null -} -export const TokenCountsBody = Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the [model guide](/docs/models) to browse and compare available models." - }), - Schema.Null - ]) - ), - "input": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.String.annotate({ - "description": "A text input to the model, equivalent to a text input with the `user` role." - }).check(Schema.isMaxLength(10485760)), - Schema.Array(InputItem).annotate({ - "description": "A list of one or many input items to the model, containing different content types." - }) - ], { mode: "oneOf" }).annotate({ - "description": "Text, image, or file inputs to the model, used to generate a response" - }), - Schema.Null - ]) - ), - "previous_response_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about [conversation state](/docs/guides/conversation-state). Cannot be used in conjunction with `conversation`." - }), - Schema.Null - ]) - ), - "tools": Schema.optionalKey( - Schema.Union([ - Schema.Array(Tool).annotate({ - "description": - "An array of tools the model may call while generating a response. You can specify which tool to use by setting the `tool_choice` parameter." - }), - Schema.Null - ]) - ), - "text": Schema.optionalKey(Schema.Union([ResponseTextParam, Schema.Null])), - "reasoning": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "effort": Schema.optionalKey(ReasoningEffort), - "summary": Schema.optionalKey(Schema.Union([ - Schema.Literals(["auto", "concise", "detailed"]).annotate({ - "description": - "A summary of the reasoning performed by the model. This can be\nuseful for debugging and understanding the model's reasoning process.\nOne of `auto`, `concise`, or `detailed`.\n\n`concise` is supported for `computer-use-preview` models and all reasoning models after `gpt-5`.\n" - }), - Schema.Null - ])), - "generate_summary": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["auto", "concise", "detailed"]).annotate({ - "description": - "**Deprecated:** use `summary` instead.\n\nA summary of the reasoning performed by the model. This can be\nuseful for debugging and understanding the model's reasoning process.\nOne of `auto`, `concise`, or `detailed`.\n" - }), - Schema.Null - ]) - ) - }).annotate({ - "title": "Reasoning", - "description": - "**gpt-5 and o-series models only** Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning)." - }), - Schema.Null - ])), - "truncation": Schema.optionalKey( - Schema.Literals(["auto", "disabled"]).annotate({ - "description": - "The truncation strategy to use for the model response. - `auto`: If the input to this Response exceeds the model's context window size, the model will truncate the response to fit the context window by dropping items from the beginning of the conversation. - `disabled` (default): If the input size will exceed the context window size for a model, the request will fail with a 400 error." - }) - ), - "instructions": Schema.optionalKey(Schema.Union([ - Schema.String.annotate({ - "description": - "A system (or developer) message inserted into the model's context.\nWhen used along with `previous_response_id`, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses." - }), - Schema.Null - ])), - "conversation": Schema.optionalKey(Schema.Union([ConversationParam, Schema.Null])), - "tool_choice": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - ToolChoiceOptions, - ToolChoiceAllowed, - ToolChoiceTypes, - ToolChoiceFunction, - ToolChoiceMCP, - ToolChoiceCustom, - SpecificApplyPatchParam, - SpecificFunctionShellParam - ], { mode: "oneOf" }).annotate({ "description": "Controls which tool the model should use, if any." }), - Schema.Null - ]) - ), - "parallel_tool_calls": Schema.optionalKey( - Schema.Union([ - Schema.Boolean.annotate({ "description": "Whether to allow the model to run tool calls in parallel." }), - Schema.Null - ]) - ) -}) -export type CompactResponseMethodPublicBody = { - readonly "model": ModelIdsCompaction - readonly "input"?: string | ReadonlyArray | null - readonly "previous_response_id"?: string | null - readonly "instructions"?: string | null -} -export const CompactResponseMethodPublicBody = Schema.Struct({ - "model": ModelIdsCompaction, - "input": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.String.annotate({ - "description": "A text input to the model, equivalent to a text input with the `user` role." - }).check(Schema.isMaxLength(10485760)), - Schema.Array(InputItem).annotate({ - "description": "A list of one or many input items to the model, containing different content types." - }) - ], { mode: "oneOf" }).annotate({ - "description": "Text, image, or file inputs to the model, used to generate a response" - }), - Schema.Null - ]) - ), - "previous_response_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about [conversation state](/docs/guides/conversation-state). Cannot be used in conjunction with `conversation`." - }), - Schema.Null - ]) - ), - "instructions": Schema.optionalKey(Schema.Union([ - Schema.String.annotate({ - "description": - "A system (or developer) message inserted into the model's context.\nWhen used along with `previous_response_id`, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses." - }), - Schema.Null - ])) -}) +export type ConversationItemList = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "first_id": string + readonly "last_id": string +} +export const ConversationItemList = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), + "data": Schema.Array(ConversationItem).annotate({ "description": "A list of conversation items." }), + "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }), + "first_id": Schema.String.annotate({ "description": "The ID of the first item in the list." }), + "last_id": Schema.String.annotate({ "description": "The ID of the last item in the list." }) +}).annotate({ "title": "The conversation item list", "description": "A list of Conversation items." }) export type ResponseItemList = { readonly "object": "list" readonly "data": ReadonlyArray @@ -21542,6 +21637,61 @@ export const ResponseItemList = Schema.Struct({ "first_id": Schema.String.annotate({ "description": "The ID of the first item in the list." }), "last_id": Schema.String.annotate({ "description": "The ID of the last item in the list." }) }).annotate({ "description": "A list of Response items." }) +export type CompactResource = { + readonly "id": string + readonly "object": "response.compaction" + readonly "output": ReadonlyArray + readonly "created_at": number + readonly "usage": { + readonly "input_tokens": number + readonly "input_tokens_details": { readonly "cached_tokens": number } + readonly "output_tokens": number + readonly "output_tokens_details": { readonly "reasoning_tokens": number } + readonly "total_tokens": number + } +} +export const CompactResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique identifier for the compacted response." }), + "object": Schema.Literal("response.compaction").annotate({ + "description": "The object type. Always `response.compaction`." + }), + "output": Schema.Array(ItemField).annotate({ "description": "The compacted list of output items." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the compacted conversation was created." + }).check(Schema.isInt()), + "usage": Schema.Struct({ + "input_tokens": Schema.Number.annotate({ "description": "The number of input tokens." }).check(Schema.isInt()), + "input_tokens_details": Schema.Struct({ + "cached_tokens": Schema.Number.annotate({ + "description": + "The number of tokens that were retrieved from the cache. \n[More on prompt caching](/docs/guides/prompt-caching).\n" + }).check(Schema.isInt()) + }).annotate({ "description": "A detailed breakdown of the input tokens." }), + "output_tokens": Schema.Number.annotate({ "description": "The number of output tokens." }).check(Schema.isInt()), + "output_tokens_details": Schema.Struct({ + "reasoning_tokens": Schema.Number.annotate({ "description": "The number of reasoning tokens." }).check( + Schema.isInt() + ) + }).annotate({ "description": "A detailed breakdown of the output tokens." }), + "total_tokens": Schema.Number.annotate({ "description": "The total number of tokens used." }).check(Schema.isInt()) + }).annotate({ + "description": "Token accounting for the compaction pass, including cached, reasoning, and total tokens." + }) +}).annotate({ "title": "The compacted response object" }) +export type InputParam = string | ReadonlyArray +export const InputParam = Schema.Union([ + Schema.String.annotate({ + "title": "Text input", + "description": "A text input to the model, equivalent to a text input with the\n`user` role.\n" + }), + Schema.Array(InputItem).annotate({ + "title": "Input item list", + "description": "A list of one or many input items to the model, containing\ndifferent content types.\n" + }) +], { mode: "oneOf" }).annotate({ + "description": + "Text, image, or file inputs to the model, used to generate a response.\n\nLearn more:\n- [Text inputs and outputs](/docs/guides/text)\n- [Image inputs](/docs/guides/images)\n- [File inputs](/docs/guides/pdf-files)\n- [Conversation state](/docs/guides/conversation-state)\n- [Function calling](/docs/guides/function-calling)\n" +}) export type Response = { readonly "metadata": {} | null readonly "top_logprobs"?: number | null @@ -23490,14 +23640,222 @@ export const ResponseQueuedEvent = Schema.Struct({ "parallel_tool_calls": Schema.Boolean.annotate({ "description": "Whether to allow the model to run tool calls in parallel.\n" }), - "conversation": Schema.optionalKey(Schema.Union([Conversation_2, Schema.Null])) - }).annotate({ "title": "The response object", "description": "The full response object that is queued." }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( - Schema.isInt() + "conversation": Schema.optionalKey(Schema.Union([Conversation_2, Schema.Null])) + }).annotate({ "title": "The response object", "description": "The full response object that is queued." }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt() + ) +}).annotate({ + "title": "ResponseQueuedEvent", + "description": "Emitted when a response is queued and waiting to be processed.\n" +}) +export type CreateConversationBody = { + readonly "metadata"?: {} | null | null + readonly "items"?: ReadonlyArray | null +} +export const CreateConversationBody = Schema.Struct({ + "metadata": Schema.optionalKey(Schema.Union([ + Schema.Union([ + Schema.Struct({}).annotate({ + "description": + "Set of 16 key-value pairs that can be attached to an object. This can be\nuseful for storing additional information about the object in a structured\nformat, and querying for objects via API or the dashboard.\n\nKeys are strings with a maximum length of 64 characters. Values are strings\nwith a maximum length of 512 characters.\n" + }), + Schema.Null + ]).annotate({ + "description": + "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.\n Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters." + }), + Schema.Null + ])), + "items": Schema.optionalKey( + Schema.Union([ + Schema.Array(InputItem).annotate({ + "description": "Initial items to include in the conversation context. You may add up to 20 items at a time." + }).check(Schema.isMaxLength(20)), + Schema.Null + ]) + ) +}) +export type TokenCountsBody = { + readonly "model"?: string | null + readonly "input"?: string | ReadonlyArray | null + readonly "previous_response_id"?: string | null + readonly "tools"?: ReadonlyArray | null + readonly "text"?: ResponseTextParam | null + readonly "reasoning"?: { + readonly "effort"?: ReasoningEffort + readonly "summary"?: "auto" | "concise" | "detailed" | null + readonly "generate_summary"?: "auto" | "concise" | "detailed" | null + } | null + readonly "truncation"?: "auto" | "disabled" + readonly "instructions"?: string | null + readonly "conversation"?: ConversationParam | null + readonly "tool_choice"?: + | ToolChoiceOptions + | ToolChoiceAllowed + | ToolChoiceTypes + | ToolChoiceFunction + | ToolChoiceMCP + | ToolChoiceCustom + | SpecificApplyPatchParam + | SpecificFunctionShellParam + | null + readonly "parallel_tool_calls"?: boolean | null +} +export const TokenCountsBody = Schema.Struct({ + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the [model guide](/docs/models) to browse and compare available models." + }), + Schema.Null + ]) + ), + "input": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.String.annotate({ + "description": "A text input to the model, equivalent to a text input with the `user` role." + }).check(Schema.isMaxLength(10485760)), + Schema.Array(InputItem).annotate({ + "description": "A list of one or many input items to the model, containing different content types." + }) + ], { mode: "oneOf" }).annotate({ + "description": "Text, image, or file inputs to the model, used to generate a response" + }), + Schema.Null + ]) + ), + "previous_response_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about [conversation state](/docs/guides/conversation-state). Cannot be used in conjunction with `conversation`." + }), + Schema.Null + ]) + ), + "tools": Schema.optionalKey( + Schema.Union([ + Schema.Array(Tool).annotate({ + "description": + "An array of tools the model may call while generating a response. You can specify which tool to use by setting the `tool_choice` parameter." + }), + Schema.Null + ]) + ), + "text": Schema.optionalKey(Schema.Union([ResponseTextParam, Schema.Null])), + "reasoning": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "effort": Schema.optionalKey(ReasoningEffort), + "summary": Schema.optionalKey(Schema.Union([ + Schema.Literals(["auto", "concise", "detailed"]).annotate({ + "description": + "A summary of the reasoning performed by the model. This can be\nuseful for debugging and understanding the model's reasoning process.\nOne of `auto`, `concise`, or `detailed`.\n\n`concise` is supported for `computer-use-preview` models and all reasoning models after `gpt-5`.\n" + }), + Schema.Null + ])), + "generate_summary": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["auto", "concise", "detailed"]).annotate({ + "description": + "**Deprecated:** use `summary` instead.\n\nA summary of the reasoning performed by the model. This can be\nuseful for debugging and understanding the model's reasoning process.\nOne of `auto`, `concise`, or `detailed`.\n" + }), + Schema.Null + ]) + ) + }).annotate({ + "title": "Reasoning", + "description": + "**gpt-5 and o-series models only** Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning)." + }), + Schema.Null + ])), + "truncation": Schema.optionalKey( + Schema.Literals(["auto", "disabled"]).annotate({ + "description": + "The truncation strategy to use for the model response. - `auto`: If the input to this Response exceeds the model's context window size, the model will truncate the response to fit the context window by dropping items from the beginning of the conversation. - `disabled` (default): If the input size will exceed the context window size for a model, the request will fail with a 400 error." + }) + ), + "instructions": Schema.optionalKey(Schema.Union([ + Schema.String.annotate({ + "description": + "A system (or developer) message inserted into the model's context.\nWhen used along with `previous_response_id`, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses." + }), + Schema.Null + ])), + "conversation": Schema.optionalKey(Schema.Union([ConversationParam, Schema.Null])), + "tool_choice": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + ToolChoiceOptions, + ToolChoiceAllowed, + ToolChoiceTypes, + ToolChoiceFunction, + ToolChoiceMCP, + ToolChoiceCustom, + SpecificApplyPatchParam, + SpecificFunctionShellParam + ], { mode: "oneOf" }).annotate({ "description": "Controls which tool the model should use, if any." }), + Schema.Null + ]) + ), + "parallel_tool_calls": Schema.optionalKey( + Schema.Union([ + Schema.Boolean.annotate({ "description": "Whether to allow the model to run tool calls in parallel." }), + Schema.Null + ]) + ) +}) +export type CompactResponseMethodPublicBody = { + readonly "model": ModelIdsCompaction + readonly "input"?: string | ReadonlyArray | null + readonly "previous_response_id"?: string | null + readonly "instructions"?: string | null + readonly "prompt_cache_key"?: string | null +} +export const CompactResponseMethodPublicBody = Schema.Struct({ + "model": ModelIdsCompaction, + "input": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.String.annotate({ + "description": "A text input to the model, equivalent to a text input with the `user` role." + }).check(Schema.isMaxLength(10485760)), + Schema.Array(InputItem).annotate({ + "description": "A list of one or many input items to the model, containing different content types." + }) + ], { mode: "oneOf" }).annotate({ + "description": "Text, image, or file inputs to the model, used to generate a response" + }), + Schema.Null + ]) + ), + "previous_response_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about [conversation state](/docs/guides/conversation-state). Cannot be used in conjunction with `conversation`." + }), + Schema.Null + ]) + ), + "instructions": Schema.optionalKey(Schema.Union([ + Schema.String.annotate({ + "description": + "A system (or developer) message inserted into the model's context.\nWhen used along with `previous_response_id`, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses." + }), + Schema.Null + ])), + "prompt_cache_key": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "A key to use when reading from or writing to the prompt cache." }).check( + Schema.isMaxLength(64) + ), + Schema.Null + ]) ) -}).annotate({ - "title": "ResponseQueuedEvent", - "description": "Emitted when a response is queued and waiting to be processed.\n" }) export type CreateEvalRequest = { readonly "name"?: string @@ -23841,6 +24199,236 @@ export const CreateResponse = Schema.Struct({ ]) ) }) +export type ResponsesClientEventResponseCreate = { + readonly "type": "response.create" + readonly "metadata"?: Metadata + readonly "top_logprobs"?: number + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "user"?: string | null + readonly "safety_identifier"?: string | null + readonly "prompt_cache_key"?: string | null + readonly "service_tier"?: ServiceTier + readonly "prompt_cache_retention"?: "in-memory" | "24h" | null + readonly "previous_response_id"?: string | null + readonly "model"?: + | ModelIdsShared + | "o1-pro" + | "o1-pro-2025-03-19" + | "o3-pro" + | "o3-pro-2025-06-10" + | "o3-deep-research" + | "o3-deep-research-2025-06-26" + | "o4-mini-deep-research" + | "o4-mini-deep-research-2025-06-26" + | "computer-use-preview" + | "computer-use-preview-2025-03-11" + | "gpt-5-codex" + | "gpt-5-pro" + | "gpt-5-pro-2025-10-06" + | "gpt-5.1-codex-max" + readonly "reasoning"?: Reasoning | null + readonly "background"?: boolean | null + readonly "max_output_tokens"?: number | null + readonly "max_tool_calls"?: number | null + readonly "text"?: ResponseTextParam + readonly "tools"?: ToolsArray + readonly "tool_choice"?: ToolChoiceParam + readonly "prompt"?: Prompt + readonly "truncation"?: "auto" | "disabled" | null + readonly "input"?: InputParam + readonly "include"?: ReadonlyArray | null + readonly "parallel_tool_calls"?: boolean | null + readonly "store"?: boolean | null + readonly "instructions"?: string | null + readonly "stream"?: boolean | null + readonly "stream_options"?: ResponseStreamOptions + readonly "conversation"?: ConversationParam | null + readonly "context_management"?: ReadonlyArray | null +} +export const ResponsesClientEventResponseCreate = Schema.Struct({ + "type": Schema.Literal("response.create").annotate({ + "description": "The type of the client event. Always `response.create`.\n" + }), + "metadata": Schema.optionalKey(Metadata), + "top_logprobs": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": + "An integer between 0 and 20 specifying the number of most likely tokens to\nreturn at each token position, each with an associated log probability.\n" + }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)).check( + Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(20)], { + "description": + "An integer between 0 and 20 specifying the number of most likely tokens to\nreturn at each token position, each with an associated log probability.\n" + }) + ) + ]) + ), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": + "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\nWe generally recommend altering this or `top_p` but not both.\n" + }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(2)), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey(Schema.Union([ + Schema.Number.annotate({ + "description": + "An alternative to sampling with temperature, called nucleus sampling,\nwhere the model considers the results of the tokens with top_p probability\nmass. So 0.1 means only the tokens comprising the top 10% probability mass\nare considered.\n\nWe generally recommend altering this or `temperature` but not both.\n" + }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)), + Schema.Null + ])), + "user": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.\nA stable identifier for your end-users.\nUsed to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. [Learn more](/docs/guides/safety-best-practices#safety-identifiers).\n" + }) + ), + "safety_identifier": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.\nThe IDs should be a string that uniquely identifies each user, with a maximum length of 64 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. [Learn more](/docs/guides/safety-best-practices#safety-identifiers).\n" + }) + ), + "prompt_cache_key": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the `user` field. [Learn more](/docs/guides/prompt-caching).\n" + }) + ), + "service_tier": Schema.optionalKey(ServiceTier), + "prompt_cache_retention": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in-memory", "24h"]).annotate({ + "description": + "The retention policy for the prompt cache. Set to `24h` to enable extended prompt caching, which keeps cached prefixes active for longer, up to a maximum of 24 hours. [Learn more](/docs/guides/prompt-caching#prompt-cache-retention).\n" + }), + Schema.Null + ]) + ), + "previous_response_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The unique ID of the previous response to the model. Use this to\ncreate multi-turn conversations. Learn more about\n[conversation state](/docs/guides/conversation-state). Cannot be used in conjunction with `conversation`.\n" + }), + Schema.Null + ]) + ), + "model": Schema.optionalKey( + Schema.Union([ + ModelIdsShared, + Schema.Literals([ + "o1-pro", + "o1-pro-2025-03-19", + "o3-pro", + "o3-pro-2025-06-10", + "o3-deep-research", + "o3-deep-research-2025-06-26", + "o4-mini-deep-research", + "o4-mini-deep-research-2025-06-26", + "computer-use-preview", + "computer-use-preview-2025-03-11", + "gpt-5-codex", + "gpt-5-pro", + "gpt-5-pro-2025-10-06", + "gpt-5.1-codex-max" + ]).annotate({ "title": "ResponsesOnlyModel" }) + ]).annotate({ + "description": + "Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI\noffers a wide range of models with different capabilities, performance\ncharacteristics, and price points. Refer to the [model guide](/docs/models)\nto browse and compare available models.\n" + }) + ), + "reasoning": Schema.optionalKey(Schema.Union([Reasoning, Schema.Null])), + "background": Schema.optionalKey( + Schema.Union([ + Schema.Boolean.annotate({ + "description": "Whether to run the model response in the background.\n[Learn more](/docs/guides/background).\n" + }), + Schema.Null + ]) + ), + "max_output_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": + "An upper bound for the number of tokens that can be generated for a response, including visible output tokens and [reasoning tokens](/docs/guides/reasoning).\n" + }).check(Schema.isInt()), + Schema.Null + ]) + ), + "max_tool_calls": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": + "The maximum number of total calls to built-in tools that can be processed in a response. This maximum number applies across all built-in tool calls, not per individual tool. Any further attempts to call a tool by the model will be ignored.\n" + }).check(Schema.isInt()), + Schema.Null + ]) + ), + "text": Schema.optionalKey(ResponseTextParam), + "tools": Schema.optionalKey(ToolsArray), + "tool_choice": Schema.optionalKey(ToolChoiceParam), + "prompt": Schema.optionalKey(Prompt), + "truncation": Schema.optionalKey(Schema.Union([ + Schema.Literals(["auto", "disabled"]).annotate({ + "description": + "The truncation strategy to use for the model response.\n- `auto`: If the input to this Response exceeds\n the model's context window size, the model will truncate the\n response to fit the context window by dropping items from the beginning of the conversation.\n- `disabled` (default): If the input size will exceed the context window\n size for a model, the request will fail with a 400 error.\n" + }), + Schema.Null + ])), + "input": Schema.optionalKey(InputParam), + "include": Schema.optionalKey(Schema.Union([ + Schema.Array(IncludeEnum).annotate({ + "description": + "Specify additional output data to include in the model response. Currently supported values are:\n- `web_search_call.action.sources`: Include the sources of the web search tool call.\n- `code_interpreter_call.outputs`: Includes the outputs of python code execution in code interpreter tool call items.\n- `computer_call_output.output.image_url`: Include image urls from the computer call output.\n- `file_search_call.results`: Include the search results of the file search tool call.\n- `message.input_image.image_url`: Include image urls from the input message.\n- `message.output_text.logprobs`: Include logprobs with assistant messages.\n- `reasoning.encrypted_content`: Includes an encrypted version of reasoning tokens in reasoning item outputs. This enables reasoning items to be used in multi-turn conversations when using the Responses API statelessly (like when the `store` parameter is set to `false`, or when an organization is enrolled in the zero data retention program)." + }), + Schema.Null + ])), + "parallel_tool_calls": Schema.optionalKey( + Schema.Union([ + Schema.Boolean.annotate({ "description": "Whether to allow the model to run tool calls in parallel.\n" }), + Schema.Null + ]) + ), + "store": Schema.optionalKey( + Schema.Union([ + Schema.Boolean.annotate({ + "description": "Whether to store the generated model response for later retrieval via\nAPI.\n" + }), + Schema.Null + ]) + ), + "instructions": Schema.optionalKey(Schema.Union([ + Schema.String.annotate({ + "description": + "A system (or developer) message inserted into the model's context.\n\nWhen using along with `previous_response_id`, the instructions from a previous\nresponse will not be carried over to the next response. This makes it simple\nto swap out system (or developer) messages in new responses.\n" + }), + Schema.Null + ])), + "stream": Schema.optionalKey(Schema.Union([ + Schema.Boolean.annotate({ + "description": + "If set to true, the model response data will be streamed to the client\nas it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).\nSee the [Streaming section below](/docs/api-reference/responses-streaming)\nfor more information.\n" + }), + Schema.Null + ])), + "stream_options": Schema.optionalKey(ResponseStreamOptions), + "conversation": Schema.optionalKey(Schema.Union([ConversationParam, Schema.Null])), + "context_management": Schema.optionalKey( + Schema.Union([ + Schema.Array(ContextManagementParam).annotate({ + "description": "Context management configuration for this request.\n" + }).check(Schema.isMinLength(1)), + Schema.Null + ]) + ) +}).annotate({ + "description": + "Client event for creating a response over a persistent WebSocket connection.\nThis payload uses the same top-level fields as `POST /v1/responses`.\n\nNotes:\n- `stream` is implicit over WebSocket and should not be sent.\n- `background` is not supported over WebSocket.\n" +}) export type ResponseStreamEvent = | ResponseAudioDeltaEvent | ResponseAudioDoneEvent @@ -30470,7 +31058,7 @@ export interface OpenAiClient { HttpClientError.HttpClientError | SchemaError > /** - * Create a vector store file batch. + * The maximum number of files in a single batch request is 2000. */ readonly "createVectorStoreFileBatch": ( vectorStoreId: string, diff --git a/packages/ai/openrouter/src/Generated.ts b/packages/ai/openrouter/src/Generated.ts index 06dadb884..24b6bb1f8 100644 --- a/packages/ai/openrouter/src/Generated.ts +++ b/packages/ai/openrouter/src/Generated.ts @@ -242,6 +242,181 @@ export const ResponsesWebSearchUserLocation = Schema.Struct({ "region": Schema.optionalKey(Schema.String), "timezone": Schema.optionalKey(Schema.String) }).annotate({ "description": "User location information for web search" }) +export type CompoundFilter = { readonly "type": "and" | "or"; readonly "filters": ReadonlyArray<{}> } +export const CompoundFilter = Schema.Struct({ + "type": Schema.Literals(["and", "or"]), + "filters": Schema.Array(Schema.Struct({})) +}).annotate({ "description": "A compound filter that combines multiple comparison or compound filters" }) +export type OpenResponsesComputerTool = { + readonly "type": "computer_use_preview" + readonly "display_height": number + readonly "display_width": number + readonly "environment": "windows" | "mac" | "linux" | "ubuntu" | "browser" +} +export const OpenResponsesComputerTool = Schema.Struct({ + "type": Schema.Literal("computer_use_preview"), + "display_height": Schema.Number.check(Schema.isFinite()), + "display_width": Schema.Number.check(Schema.isFinite()), + "environment": Schema.Literals(["windows", "mac", "linux", "ubuntu", "browser"]) +}).annotate({ "description": "Computer use preview tool configuration" }) +export type OpenResponsesCodeInterpreterTool = { + readonly "type": "code_interpreter" + readonly "container": string | { + readonly "type": "auto" + readonly "file_ids"?: ReadonlyArray + readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g" + } +} +export const OpenResponsesCodeInterpreterTool = Schema.Struct({ + "type": Schema.Literal("code_interpreter"), + "container": Schema.Union([ + Schema.String, + Schema.Struct({ + "type": Schema.Literal("auto"), + "file_ids": Schema.optionalKey(Schema.Array(Schema.String)), + "memory_limit": Schema.optionalKey(Schema.Literals(["1g", "4g", "16g", "64g"])) + }) + ]) +}).annotate({ "description": "Code interpreter tool configuration" }) +export type OpenResponsesMcpTool = { + readonly "type": "mcp" + readonly "server_label": string + readonly "allowed_tools"?: + | ReadonlyArray + | { readonly "tool_names"?: ReadonlyArray; readonly "read_only"?: boolean } + | unknown + | unknown + readonly "authorization"?: string + readonly "connector_id"?: + | "connector_dropbox" + | "connector_gmail" + | "connector_googlecalendar" + | "connector_googledrive" + | "connector_microsoftteams" + | "connector_outlookcalendar" + | "connector_outlookemail" + | "connector_sharepoint" + readonly "headers"?: {} + readonly "require_approval"?: + | { + readonly "never"?: { readonly "tool_names"?: ReadonlyArray } + readonly "always"?: { readonly "tool_names"?: ReadonlyArray } + } + | "always" + | "never" + | unknown + | unknown + readonly "server_description"?: string + readonly "server_url"?: string +} +export const OpenResponsesMcpTool = Schema.Struct({ + "type": Schema.Literal("mcp"), + "server_label": Schema.String, + "allowed_tools": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String), + Schema.Struct({ + "tool_names": Schema.optionalKey(Schema.Array(Schema.String)), + "read_only": Schema.optionalKey(Schema.Boolean) + }), + Schema.Unknown, + Schema.Unknown + ]) + ), + "authorization": Schema.optionalKey(Schema.String), + "connector_id": Schema.optionalKey( + Schema.Literals([ + "connector_dropbox", + "connector_gmail", + "connector_googlecalendar", + "connector_googledrive", + "connector_microsoftteams", + "connector_outlookcalendar", + "connector_outlookemail", + "connector_sharepoint" + ]) + ), + "headers": Schema.optionalKey(Schema.Struct({})), + "require_approval": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "never": Schema.optionalKey(Schema.Struct({ "tool_names": Schema.optionalKey(Schema.Array(Schema.String)) })), + "always": Schema.optionalKey(Schema.Struct({ "tool_names": Schema.optionalKey(Schema.Array(Schema.String)) })) + }), + Schema.Literal("always"), + Schema.Literal("never"), + Schema.Unknown, + Schema.Unknown + ]) + ), + "server_description": Schema.optionalKey(Schema.String), + "server_url": Schema.optionalKey(Schema.String) +}).annotate({ "description": "MCP (Model Context Protocol) tool configuration" }) +export type OpenResponsesImageGenerationTool = { + readonly "type": "image_generation" + readonly "background"?: "transparent" | "opaque" | "auto" + readonly "input_fidelity"?: "high" | "low" + readonly "input_image_mask"?: { readonly "image_url"?: string; readonly "file_id"?: string } + readonly "model"?: "gpt-image-1" | "gpt-image-1-mini" + readonly "moderation"?: "auto" | "low" + readonly "output_compression"?: number + readonly "output_format"?: "png" | "webp" | "jpeg" + readonly "partial_images"?: number + readonly "quality"?: "low" | "medium" | "high" | "auto" + readonly "size"?: "1024x1024" | "1024x1536" | "1536x1024" | "auto" +} +export const OpenResponsesImageGenerationTool = Schema.Struct({ + "type": Schema.Literal("image_generation"), + "background": Schema.optionalKey(Schema.Literals(["transparent", "opaque", "auto"])), + "input_fidelity": Schema.optionalKey(Schema.Literals(["high", "low"])), + "input_image_mask": Schema.optionalKey( + Schema.Struct({ "image_url": Schema.optionalKey(Schema.String), "file_id": Schema.optionalKey(Schema.String) }) + ), + "model": Schema.optionalKey(Schema.Literals(["gpt-image-1", "gpt-image-1-mini"])), + "moderation": Schema.optionalKey(Schema.Literals(["auto", "low"])), + "output_compression": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "output_format": Schema.optionalKey(Schema.Literals(["png", "webp", "jpeg"])), + "partial_images": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "quality": Schema.optionalKey(Schema.Literals(["low", "medium", "high", "auto"])), + "size": Schema.optionalKey(Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"])) +}).annotate({ "description": "Image generation tool configuration" }) +export type OpenResponsesLocalShellTool = { readonly "type": "local_shell" } +export const OpenResponsesLocalShellTool = Schema.Struct({ "type": Schema.Literal("local_shell") }).annotate({ + "description": "Local shell tool configuration" +}) +export type OpenResponsesFunctionShellTool = { readonly "type": "shell" } +export const OpenResponsesFunctionShellTool = Schema.Struct({ "type": Schema.Literal("shell") }).annotate({ + "description": "Shell tool configuration" +}) +export type OpenResponsesApplyPatchTool = { readonly "type": "apply_patch" } +export const OpenResponsesApplyPatchTool = Schema.Struct({ "type": Schema.Literal("apply_patch") }).annotate({ + "description": "Apply patch tool configuration" +}) +export type OpenResponsesCustomTool = { + readonly "type": "custom" + readonly "name": string + readonly "description"?: string + readonly "format"?: { readonly "type": "text" } | { + readonly "type": "grammar" + readonly "definition": string + readonly "syntax": "lark" | "regex" + } +} +export const OpenResponsesCustomTool = Schema.Struct({ + "type": Schema.Literal("custom"), + "name": Schema.String, + "description": Schema.optionalKey(Schema.String), + "format": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": Schema.Literal("text") }), + Schema.Struct({ + "type": Schema.Literal("grammar"), + "definition": Schema.String, + "syntax": Schema.Literals(["lark", "regex"]) + }) + ]) + ) +}).annotate({ "description": "Custom tool configuration" }) export type OpenAIResponsesToolChoice = "auto" | "none" | "required" | { readonly "type": "function" readonly "name": string @@ -270,10 +445,6 @@ export type ResponsesFormatText = { readonly "type": "text" } export const ResponsesFormatText = Schema.Struct({ "type": Schema.Literal("text") }).annotate({ "description": "Plain text response format" }) -export type ResponsesFormatJSONObject = { readonly "type": "json_object" } -export const ResponsesFormatJSONObject = Schema.Struct({ "type": Schema.Literal("json_object") }).annotate({ - "description": "JSON object response format" -}) export type ResponsesFormatTextJSONSchemaConfig = { readonly "type": "json_schema" readonly "name": string @@ -302,10 +473,15 @@ export const OpenResponsesErrorEvent = Schema.Struct({ "param": Schema.String, "sequence_number": Schema.Number.check(Schema.isFinite()) }).annotate({ "description": "Event emitted when an error occurs during streaming" }) -export type OpenResponsesTopLogprobs = { readonly "token"?: string; readonly "logprob"?: number } +export type OpenResponsesTopLogprobs = { + readonly "token"?: string + readonly "logprob"?: number + readonly "bytes"?: ReadonlyArray +} export const OpenResponsesTopLogprobs = Schema.Struct({ "token": Schema.optionalKey(Schema.String), - "logprob": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) + "logprob": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "bytes": Schema.optionalKey(Schema.Array(Schema.Number.check(Schema.isFinite()))) }).annotate({ "description": "Alternative token with its log probability" }) export type OpenResponsesRefusalDeltaEvent = { readonly "type": "response.refusal.delta" @@ -677,6 +853,7 @@ export type ProviderName = | "Inception" | "Inceptron" | "InferenceNet" + | "Ionstream" | "Infermatic" | "Io Net" | "Inflection" @@ -751,6 +928,7 @@ export const ProviderName = Schema.Literals([ "Inception", "Inceptron", "InferenceNet", + "Ionstream", "Infermatic", "Io Net", "Inflection", @@ -794,7 +972,26 @@ export const ProviderName = Schema.Literals([ export type Quantization = "int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown" export const Quantization = Schema.Literals(["int4", "int8", "fp4", "fp6", "fp8", "fp16", "bf16", "fp32", "unknown"]) export type ProviderSort = "price" | "throughput" | "latency" -export const ProviderSort = Schema.Literals(["price", "throughput", "latency"]) +export const ProviderSort = Schema.Literals(["price", "throughput", "latency"]).annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" +}) +export type ProviderSortConfig = { + readonly "by"?: "price" | "throughput" | "latency" + readonly "partition"?: "model" | "none" +} +export const ProviderSortConfig = Schema.Struct({ + "by": Schema.optionalKey( + Schema.Literals(["price", "throughput", "latency"]).annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }) + ), + "partition": Schema.optionalKey( + Schema.Literals(["model", "none"]).annotate({ + "description": + "Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model." + }) + ) +}).annotate({ "description": "The provider sorting strategy (price, throughput, latency)" }) export type BigNumberUnion = string export const BigNumberUnion = Schema.String.annotate({ "description": "Price per million prompt tokens" }) export type PercentileThroughputCutoffs = { @@ -854,6 +1051,7 @@ export type AnthropicMessagesResponse = { readonly "id": string readonly "type": "message" readonly "role": "assistant" + readonly "container": { readonly "id": string; readonly "expires_at": string } readonly "content": ReadonlyArray< | { readonly "type": "text" @@ -900,17 +1098,41 @@ export type AnthropicMessagesResponse = { } > } - | { readonly "type": "tool_use"; readonly "id": string; readonly "name": string; readonly "input"?: unknown } + | { + readonly "type": "tool_use" + readonly "id": string + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "name": string + readonly "input"?: unknown + } | { readonly "type": "thinking"; readonly "thinking": string; readonly "signature": string } | { readonly "type": "redacted_thinking"; readonly "data": string } | { readonly "type": "server_tool_use" readonly "id": string - readonly "name": "web_search" + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "name": + | "web_search" + | "web_fetch" + | "code_execution" + | "bash_code_execution" + | "text_editor_code_execution" + | "tool_search_tool_regex" + | "tool_search_tool_bm25" readonly "input"?: unknown } | { readonly "type": "web_search_tool_result" + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } readonly "tool_use_id": string readonly "content": | ReadonlyArray< @@ -930,8 +1152,127 @@ export type AnthropicMessagesResponse = { | "max_uses_exceeded" | "too_many_requests" | "query_too_long" + | "request_too_large" + } + } + | { + readonly "type": "web_fetch_tool_result" + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "content": { + readonly "type": "web_fetch_tool_result_error" + readonly "error_code": + | "invalid_tool_input" + | "url_too_long" + | "url_not_allowed" + | "url_not_accessible" + | "unsupported_content_type" + | "too_many_requests" + | "max_uses_exceeded" + | "unavailable" + } | { + readonly "content": { + readonly "citations": { readonly "enabled": boolean } + readonly "source": { + readonly "data": string + readonly "media_type": "application/pdf" + readonly "type": "base64" + } | { readonly "data": string; readonly "media_type": "text/plain"; readonly "type": "text" } + readonly "title": string + readonly "type": "document" + } + readonly "retrieved_at": string + readonly "type": "web_fetch_result" + readonly "url": string + } + readonly "tool_use_id": string + } + | { + readonly "type": "code_execution_tool_result" + readonly "content": { + readonly "error_code": "invalid_tool_input" | "unavailable" | "too_many_requests" | "execution_time_exceeded" + readonly "type": "code_execution_tool_result_error" + } | { + readonly "content": ReadonlyArray<{ readonly "file_id": string; readonly "type": "code_execution_output" }> + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "code_execution_result" + } | { + readonly "content": ReadonlyArray<{ readonly "file_id": string; readonly "type": "code_execution_output" }> + readonly "encrypted_stdout": string + readonly "return_code": number + readonly "stderr": string + readonly "type": "encrypted_code_execution_result" + } + readonly "tool_use_id": string + } + | { + readonly "type": "bash_code_execution_tool_result" + readonly "content": { + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" + | "output_file_too_large" + readonly "type": "bash_code_execution_tool_result_error" + } | { + readonly "content": ReadonlyArray<{ readonly "file_id": string; readonly "type": "bash_code_execution_output" }> + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "bash_code_execution_result" + } + readonly "tool_use_id": string + } + | { + readonly "type": "text_editor_code_execution_tool_result" + readonly "content": + | { + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" + | "file_not_found" + readonly "error_message": string + readonly "type": "text_editor_code_execution_tool_result_error" + } + | { + readonly "content": string + readonly "file_type": "text" | "image" | "pdf" + readonly "num_lines": number + readonly "start_line": number + readonly "total_lines": number + readonly "type": "text_editor_code_execution_view_result" + } + | { readonly "is_file_update": boolean; readonly "type": "text_editor_code_execution_create_result" } + | { + readonly "lines": ReadonlyArray + readonly "new_lines": number + readonly "new_start": number + readonly "old_lines": number + readonly "old_start": number + readonly "type": "text_editor_code_execution_str_replace_result" } + readonly "tool_use_id": string } + | { + readonly "type": "tool_search_tool_result" + readonly "content": { + readonly "error_code": "invalid_tool_input" | "unavailable" | "too_many_requests" | "execution_time_exceeded" + readonly "error_message": string + readonly "type": "tool_search_tool_result_error" + } | { + readonly "tool_references": ReadonlyArray<{ readonly "tool_name": string; readonly "type": "tool_reference" }> + readonly "type": "tool_search_tool_search_result" + } + readonly "tool_use_id": string + } + | { readonly "type": "container_upload"; readonly "file_id": string } > readonly "model": string readonly "stop_reason": "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "pause_turn" | "refusal" @@ -946,14 +1287,118 @@ export type AnthropicMessagesResponse = { readonly "ephemeral_1h_input_tokens": number } readonly "inference_geo": string - readonly "server_tool_use": { readonly "web_search_requests": number } + readonly "server_tool_use": { readonly "web_search_requests": number; readonly "web_fetch_requests": number } readonly "service_tier": "standard" | "priority" | "batch" } + readonly "provider"?: + | "AnyScale" + | "Atoma" + | "Cent-ML" + | "CrofAI" + | "Enfer" + | "GoPomelo" + | "HuggingFace" + | "Hyperbolic 2" + | "InoCloud" + | "Kluster" + | "Lambda" + | "Lepton" + | "Lynn 2" + | "Lynn" + | "Mancer" + | "Meta" + | "Modal" + | "Nineteen" + | "OctoAI" + | "Recursal" + | "Reflection" + | "Replicate" + | "SambaNova 2" + | "SF Compute" + | "Targon" + | "Together 2" + | "Ubicloud" + | "01.AI" + | "AI21" + | "AionLabs" + | "Alibaba" + | "Ambient" + | "Amazon Bedrock" + | "Amazon Nova" + | "Anthropic" + | "Arcee AI" + | "AtlasCloud" + | "Avian" + | "Azure" + | "BaseTen" + | "BytePlus" + | "Black Forest Labs" + | "Cerebras" + | "Chutes" + | "Cirrascale" + | "Clarifai" + | "Cloudflare" + | "Cohere" + | "Crusoe" + | "DeepInfra" + | "DeepSeek" + | "Featherless" + | "Fireworks" + | "Friendli" + | "GMICloud" + | "Google" + | "Google AI Studio" + | "Groq" + | "Hyperbolic" + | "Inception" + | "Inceptron" + | "InferenceNet" + | "Ionstream" + | "Infermatic" + | "Io Net" + | "Inflection" + | "Liquid" + | "Mara" + | "Mancer 2" + | "Minimax" + | "ModelRun" + | "Mistral" + | "Modular" + | "Moonshot AI" + | "Morph" + | "NCompass" + | "Nebius" + | "NextBit" + | "Novita" + | "Nvidia" + | "OpenAI" + | "OpenInference" + | "Parasail" + | "Perplexity" + | "Phala" + | "Relace" + | "SambaNova" + | "Seed" + | "SiliconFlow" + | "Sourceful" + | "StepFun" + | "Stealth" + | "StreamLake" + | "Switchpoint" + | "Together" + | "Upstage" + | "Venice" + | "WandB" + | "Xiaomi" + | "xAI" + | "Z.AI" + | "FakeProvider" } export const AnthropicMessagesResponse = Schema.Struct({ "id": Schema.String, "type": Schema.Literal("message"), "role": Schema.Literal("assistant"), + "container": Schema.Struct({ "id": Schema.String, "expires_at": Schema.String }), "content": Schema.Array(Schema.Union([ Schema.Struct({ "type": Schema.Literal("text"), @@ -1007,6 +1452,11 @@ export const AnthropicMessagesResponse = Schema.Struct({ Schema.Struct({ "type": Schema.Literal("tool_use"), "id": Schema.String, + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), "name": Schema.String, "input": Schema.optionalKey(Schema.Unknown) }), @@ -1015,11 +1465,29 @@ export const AnthropicMessagesResponse = Schema.Struct({ Schema.Struct({ "type": Schema.Literal("server_tool_use"), "id": Schema.String, - "name": Schema.Literal("web_search"), + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), + "name": Schema.Literals([ + "web_search", + "web_fetch", + "code_execution", + "bash_code_execution", + "text_editor_code_execution", + "tool_search_tool_regex", + "tool_search_tool_bm25" + ]), "input": Schema.optionalKey(Schema.Unknown) }), Schema.Struct({ "type": Schema.Literal("web_search_tool_result"), + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), "tool_use_id": Schema.String, "content": Schema.Union([ Schema.Array( @@ -1038,11 +1506,176 @@ export const AnthropicMessagesResponse = Schema.Struct({ "unavailable", "max_uses_exceeded", "too_many_requests", - "query_too_long" + "query_too_long", + "request_too_large" ]) }) ]) - }) + }), + Schema.Struct({ + "type": Schema.Literal("web_fetch_tool_result"), + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), + "content": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("web_fetch_tool_result_error"), + "error_code": Schema.Literals([ + "invalid_tool_input", + "url_too_long", + "url_not_allowed", + "url_not_accessible", + "unsupported_content_type", + "too_many_requests", + "max_uses_exceeded", + "unavailable" + ]) + }), + Schema.Struct({ + "content": Schema.Struct({ + "citations": Schema.Struct({ "enabled": Schema.Boolean }), + "source": Schema.Union([ + Schema.Struct({ + "data": Schema.String, + "media_type": Schema.Literal("application/pdf"), + "type": Schema.Literal("base64") + }), + Schema.Struct({ + "data": Schema.String, + "media_type": Schema.Literal("text/plain"), + "type": Schema.Literal("text") + }) + ]), + "title": Schema.String, + "type": Schema.Literal("document") + }), + "retrieved_at": Schema.String, + "type": Schema.Literal("web_fetch_result"), + "url": Schema.String + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("code_execution_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" + ]), + "type": Schema.Literal("code_execution_tool_result_error") + }), + Schema.Struct({ + "content": Schema.Array( + Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("code_execution_output") }) + ), + "return_code": Schema.Number.check(Schema.isFinite()), + "stderr": Schema.String, + "stdout": Schema.String, + "type": Schema.Literal("code_execution_result") + }), + Schema.Struct({ + "content": Schema.Array( + Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("code_execution_output") }) + ), + "encrypted_stdout": Schema.String, + "return_code": Schema.Number.check(Schema.isFinite()), + "stderr": Schema.String, + "type": Schema.Literal("encrypted_code_execution_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("bash_code_execution_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded", + "output_file_too_large" + ]), + "type": Schema.Literal("bash_code_execution_tool_result_error") + }), + Schema.Struct({ + "content": Schema.Array( + Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("bash_code_execution_output") }) + ), + "return_code": Schema.Number.check(Schema.isFinite()), + "stderr": Schema.String, + "stdout": Schema.String, + "type": Schema.Literal("bash_code_execution_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("text_editor_code_execution_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded", + "file_not_found" + ]), + "error_message": Schema.String, + "type": Schema.Literal("text_editor_code_execution_tool_result_error") + }), + Schema.Struct({ + "content": Schema.String, + "file_type": Schema.Literals(["text", "image", "pdf"]), + "num_lines": Schema.Number.check(Schema.isFinite()), + "start_line": Schema.Number.check(Schema.isFinite()), + "total_lines": Schema.Number.check(Schema.isFinite()), + "type": Schema.Literal("text_editor_code_execution_view_result") + }), + Schema.Struct({ + "is_file_update": Schema.Boolean, + "type": Schema.Literal("text_editor_code_execution_create_result") + }), + Schema.Struct({ + "lines": Schema.Array(Schema.String), + "new_lines": Schema.Number.check(Schema.isFinite()), + "new_start": Schema.Number.check(Schema.isFinite()), + "old_lines": Schema.Number.check(Schema.isFinite()), + "old_start": Schema.Number.check(Schema.isFinite()), + "type": Schema.Literal("text_editor_code_execution_str_replace_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("tool_search_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" + ]), + "error_message": Schema.String, + "type": Schema.Literal("tool_search_tool_result_error") + }), + Schema.Struct({ + "tool_references": Schema.Array( + Schema.Struct({ "tool_name": Schema.String, "type": Schema.Literal("tool_reference") }) + ), + "type": Schema.Literal("tool_search_tool_search_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ "type": Schema.Literal("container_upload"), "file_id": Schema.String }) ], { mode: "oneOf" })), "model": Schema.String, "stop_reason": Schema.Literals(["end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", "refusal"]), @@ -1057,133 +1690,127 @@ export const AnthropicMessagesResponse = Schema.Struct({ "ephemeral_1h_input_tokens": Schema.Number.check(Schema.isFinite()) }), "inference_geo": Schema.String, - "server_tool_use": Schema.Struct({ "web_search_requests": Schema.Number.check(Schema.isFinite()) }), + "server_tool_use": Schema.Struct({ + "web_search_requests": Schema.Number.check(Schema.isFinite()), + "web_fetch_requests": Schema.Number.check(Schema.isFinite()) + }), "service_tier": Schema.Literals(["standard", "priority", "batch"]) - }) + }), + "provider": Schema.optionalKey( + Schema.Literals([ + "AnyScale", + "Atoma", + "Cent-ML", + "CrofAI", + "Enfer", + "GoPomelo", + "HuggingFace", + "Hyperbolic 2", + "InoCloud", + "Kluster", + "Lambda", + "Lepton", + "Lynn 2", + "Lynn", + "Mancer", + "Meta", + "Modal", + "Nineteen", + "OctoAI", + "Recursal", + "Reflection", + "Replicate", + "SambaNova 2", + "SF Compute", + "Targon", + "Together 2", + "Ubicloud", + "01.AI", + "AI21", + "AionLabs", + "Alibaba", + "Ambient", + "Amazon Bedrock", + "Amazon Nova", + "Anthropic", + "Arcee AI", + "AtlasCloud", + "Avian", + "Azure", + "BaseTen", + "BytePlus", + "Black Forest Labs", + "Cerebras", + "Chutes", + "Cirrascale", + "Clarifai", + "Cloudflare", + "Cohere", + "Crusoe", + "DeepInfra", + "DeepSeek", + "Featherless", + "Fireworks", + "Friendli", + "GMICloud", + "Google", + "Google AI Studio", + "Groq", + "Hyperbolic", + "Inception", + "Inceptron", + "InferenceNet", + "Ionstream", + "Infermatic", + "Io Net", + "Inflection", + "Liquid", + "Mara", + "Mancer 2", + "Minimax", + "ModelRun", + "Mistral", + "Modular", + "Moonshot AI", + "Morph", + "NCompass", + "Nebius", + "NextBit", + "Novita", + "Nvidia", + "OpenAI", + "OpenInference", + "Parasail", + "Perplexity", + "Phala", + "Relace", + "SambaNova", + "Seed", + "SiliconFlow", + "Sourceful", + "StepFun", + "Stealth", + "StreamLake", + "Switchpoint", + "Together", + "Upstage", + "Venice", + "WandB", + "Xiaomi", + "xAI", + "Z.AI", + "FakeProvider" + ]) + ) }).annotate({ "description": "Non-streaming response from the Anthropic Messages API with OpenRouter extensions" }) -export type AnthropicMessagesStreamEvent = - | { - readonly "type": "message_start" - readonly "message": { - readonly "id": string - readonly "type": "message" - readonly "role": "assistant" - readonly "content": ReadonlyArray< - | { - readonly "type": "text" - readonly "text": string - readonly "citations": ReadonlyArray< - { - readonly "type": "char_location" - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string - readonly "start_char_index": number - readonly "end_char_index": number - readonly "file_id": string - } | { - readonly "type": "page_location" - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string - readonly "start_page_number": number - readonly "end_page_number": number - readonly "file_id": string - } | { - readonly "type": "content_block_location" - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string - readonly "start_block_index": number - readonly "end_block_index": number - readonly "file_id": string - } | { - readonly "type": "web_search_result_location" - readonly "cited_text": string - readonly "encrypted_index": string - readonly "title": string - readonly "url": string - } | { - readonly "type": "search_result_location" - readonly "cited_text": string - readonly "search_result_index": number - readonly "source": string - readonly "title": string - readonly "start_block_index": number - readonly "end_block_index": number - } - > - } - | { readonly "type": "tool_use"; readonly "id": string; readonly "name": string; readonly "input"?: unknown } - | { readonly "type": "thinking"; readonly "thinking": string; readonly "signature": string } - | { readonly "type": "redacted_thinking"; readonly "data": string } - | { - readonly "type": "server_tool_use" - readonly "id": string - readonly "name": "web_search" - readonly "input"?: unknown - } - | { - readonly "type": "web_search_tool_result" - readonly "tool_use_id": string - readonly "content": - | ReadonlyArray< - { - readonly "type": "web_search_result" - readonly "encrypted_content": string - readonly "page_age": string - readonly "title": string - readonly "url": string - } - > - | { - readonly "type": "web_search_tool_result_error" - readonly "error_code": - | "invalid_tool_input" - | "unavailable" - | "max_uses_exceeded" - | "too_many_requests" - | "query_too_long" - } - } - > - readonly "model": string - readonly "stop_reason": unknown - readonly "stop_sequence": unknown - readonly "usage": { - readonly "input_tokens": number - readonly "output_tokens": number - readonly "cache_creation_input_tokens": number - readonly "cache_read_input_tokens": number - readonly "cache_creation": { - readonly "ephemeral_5m_input_tokens": number - readonly "ephemeral_1h_input_tokens": number - } - readonly "inference_geo": string - readonly "server_tool_use": { readonly "web_search_requests": number } - readonly "service_tier": "standard" | "priority" | "batch" - } - } - } - | { - readonly "type": "message_delta" - readonly "delta": { - readonly "stop_reason": "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "pause_turn" | "refusal" - readonly "stop_sequence": string - } - readonly "usage": { - readonly "input_tokens": number - readonly "output_tokens": number - readonly "cache_creation_input_tokens": number - readonly "cache_read_input_tokens": number - readonly "server_tool_use": { readonly "web_search_requests": number } - } - } - | { readonly "type": "message_stop" } - | { - readonly "type": "content_block_start" - readonly "index": number - readonly "content_block": +export type AnthropicMessagesMessageStartEvent = { + readonly "type": "message_start" + readonly "message": { + readonly "id": string + readonly "type": "message" + readonly "role": "assistant" + readonly "container": { readonly "id": string; readonly "expires_at": string } + readonly "content": ReadonlyArray< | { readonly "type": "text" readonly "text": string @@ -1229,17 +1856,41 @@ export type AnthropicMessagesStreamEvent = } > } - | { readonly "type": "tool_use"; readonly "id": string; readonly "name": string; readonly "input"?: unknown } + | { + readonly "type": "tool_use" + readonly "id": string + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "name": string + readonly "input"?: unknown + } | { readonly "type": "thinking"; readonly "thinking": string; readonly "signature": string } | { readonly "type": "redacted_thinking"; readonly "data": string } | { readonly "type": "server_tool_use" readonly "id": string - readonly "name": "web_search" + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "name": + | "web_search" + | "web_fetch" + | "code_execution" + | "bash_code_execution" + | "text_editor_code_execution" + | "tool_search_tool_regex" + | "tool_search_tool_bm25" readonly "input"?: unknown } | { readonly "type": "web_search_tool_result" + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } readonly "tool_use_id": string readonly "content": | ReadonlyArray< @@ -1259,197 +1910,259 @@ export type AnthropicMessagesStreamEvent = | "max_uses_exceeded" | "too_many_requests" | "query_too_long" + | "request_too_large" } } - } - | { - readonly "type": "content_block_delta" - readonly "index": number - readonly "delta": - | { readonly "type": "text_delta"; readonly "text": string } - | { readonly "type": "input_json_delta"; readonly "partial_json": string } - | { readonly "type": "thinking_delta"; readonly "thinking": string } - | { readonly "type": "signature_delta"; readonly "signature": string } | { - readonly "type": "citations_delta" - readonly "citation": { - readonly "type": "char_location" - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string - readonly "start_char_index": number - readonly "end_char_index": number - readonly "file_id": string + readonly "type": "web_fetch_tool_result" + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "content": { + readonly "type": "web_fetch_tool_result_error" + readonly "error_code": + | "invalid_tool_input" + | "url_too_long" + | "url_not_allowed" + | "url_not_accessible" + | "unsupported_content_type" + | "too_many_requests" + | "max_uses_exceeded" + | "unavailable" } | { - readonly "type": "page_location" - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string - readonly "start_page_number": number - readonly "end_page_number": number - readonly "file_id": string + readonly "content": { + readonly "citations": { readonly "enabled": boolean } + readonly "source": { + readonly "data": string + readonly "media_type": "application/pdf" + readonly "type": "base64" + } | { readonly "data": string; readonly "media_type": "text/plain"; readonly "type": "text" } + readonly "title": string + readonly "type": "document" + } + readonly "retrieved_at": string + readonly "type": "web_fetch_result" + readonly "url": string + } + readonly "tool_use_id": string + } + | { + readonly "type": "code_execution_tool_result" + readonly "content": { + readonly "error_code": "invalid_tool_input" | "unavailable" | "too_many_requests" | "execution_time_exceeded" + readonly "type": "code_execution_tool_result_error" } | { - readonly "type": "content_block_location" - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string - readonly "start_block_index": number - readonly "end_block_index": number - readonly "file_id": string + readonly "content": ReadonlyArray<{ readonly "file_id": string; readonly "type": "code_execution_output" }> + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "code_execution_result" } | { - readonly "type": "web_search_result_location" - readonly "cited_text": string - readonly "encrypted_index": string - readonly "title": string - readonly "url": string + readonly "content": ReadonlyArray<{ readonly "file_id": string; readonly "type": "code_execution_output" }> + readonly "encrypted_stdout": string + readonly "return_code": number + readonly "stderr": string + readonly "type": "encrypted_code_execution_result" + } + readonly "tool_use_id": string + } + | { + readonly "type": "bash_code_execution_tool_result" + readonly "content": { + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" + | "output_file_too_large" + readonly "type": "bash_code_execution_tool_result_error" } | { - readonly "type": "search_result_location" - readonly "cited_text": string - readonly "search_result_index": number - readonly "source": string - readonly "title": string - readonly "start_block_index": number - readonly "end_block_index": number + readonly "content": ReadonlyArray< + { readonly "file_id": string; readonly "type": "bash_code_execution_output" } + > + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "bash_code_execution_result" + } + readonly "tool_use_id": string + } + | { + readonly "type": "text_editor_code_execution_tool_result" + readonly "content": + | { + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" + | "file_not_found" + readonly "error_message": string + readonly "type": "text_editor_code_execution_tool_result_error" + } + | { + readonly "content": string + readonly "file_type": "text" | "image" | "pdf" + readonly "num_lines": number + readonly "start_line": number + readonly "total_lines": number + readonly "type": "text_editor_code_execution_view_result" + } + | { readonly "is_file_update": boolean; readonly "type": "text_editor_code_execution_create_result" } + | { + readonly "lines": ReadonlyArray + readonly "new_lines": number + readonly "new_start": number + readonly "old_lines": number + readonly "old_start": number + readonly "type": "text_editor_code_execution_str_replace_result" + } + readonly "tool_use_id": string + } + | { + readonly "type": "tool_search_tool_result" + readonly "content": { + readonly "error_code": "invalid_tool_input" | "unavailable" | "too_many_requests" | "execution_time_exceeded" + readonly "error_message": string + readonly "type": "tool_search_tool_result_error" + } | { + readonly "tool_references": ReadonlyArray<{ readonly "tool_name": string; readonly "type": "tool_reference" }> + readonly "type": "tool_search_tool_search_result" } + readonly "tool_use_id": string + } + | { readonly "type": "container_upload"; readonly "file_id": string } + > + readonly "model": string + readonly "stop_reason": unknown + readonly "stop_sequence": unknown + readonly "usage": { + readonly "input_tokens": number + readonly "output_tokens": number + readonly "cache_creation_input_tokens": number + readonly "cache_read_input_tokens": number + readonly "cache_creation": { + readonly "ephemeral_5m_input_tokens": number + readonly "ephemeral_1h_input_tokens": number } + readonly "inference_geo": string + readonly "server_tool_use": { readonly "web_search_requests": number; readonly "web_fetch_requests": number } + readonly "service_tier": "standard" | "priority" | "batch" + } + readonly "provider"?: + | "AnyScale" + | "Atoma" + | "Cent-ML" + | "CrofAI" + | "Enfer" + | "GoPomelo" + | "HuggingFace" + | "Hyperbolic 2" + | "InoCloud" + | "Kluster" + | "Lambda" + | "Lepton" + | "Lynn 2" + | "Lynn" + | "Mancer" + | "Meta" + | "Modal" + | "Nineteen" + | "OctoAI" + | "Recursal" + | "Reflection" + | "Replicate" + | "SambaNova 2" + | "SF Compute" + | "Targon" + | "Together 2" + | "Ubicloud" + | "01.AI" + | "AI21" + | "AionLabs" + | "Alibaba" + | "Ambient" + | "Amazon Bedrock" + | "Amazon Nova" + | "Anthropic" + | "Arcee AI" + | "AtlasCloud" + | "Avian" + | "Azure" + | "BaseTen" + | "BytePlus" + | "Black Forest Labs" + | "Cerebras" + | "Chutes" + | "Cirrascale" + | "Clarifai" + | "Cloudflare" + | "Cohere" + | "Crusoe" + | "DeepInfra" + | "DeepSeek" + | "Featherless" + | "Fireworks" + | "Friendli" + | "GMICloud" + | "Google" + | "Google AI Studio" + | "Groq" + | "Hyperbolic" + | "Inception" + | "Inceptron" + | "InferenceNet" + | "Ionstream" + | "Infermatic" + | "Io Net" + | "Inflection" + | "Liquid" + | "Mara" + | "Mancer 2" + | "Minimax" + | "ModelRun" + | "Mistral" + | "Modular" + | "Moonshot AI" + | "Morph" + | "NCompass" + | "Nebius" + | "NextBit" + | "Novita" + | "Nvidia" + | "OpenAI" + | "OpenInference" + | "Parasail" + | "Perplexity" + | "Phala" + | "Relace" + | "SambaNova" + | "Seed" + | "SiliconFlow" + | "Sourceful" + | "StepFun" + | "Stealth" + | "StreamLake" + | "Switchpoint" + | "Together" + | "Upstage" + | "Venice" + | "WandB" + | "Xiaomi" + | "xAI" + | "Z.AI" + | "FakeProvider" } - | { readonly "type": "content_block_stop"; readonly "index": number } - | { readonly "type": "ping" } - | { readonly "type": "error"; readonly "error": { readonly "type": string; readonly "message": string } } -export const AnthropicMessagesStreamEvent = Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("message_start"), - "message": Schema.Struct({ - "id": Schema.String, - "type": Schema.Literal("message"), - "role": Schema.Literal("assistant"), - "content": Schema.Array(Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("text"), - "text": Schema.String, - "citations": Schema.Array(Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("char_location"), - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isFinite()), - "document_title": Schema.String, - "start_char_index": Schema.Number.check(Schema.isFinite()), - "end_char_index": Schema.Number.check(Schema.isFinite()), - "file_id": Schema.String - }), - Schema.Struct({ - "type": Schema.Literal("page_location"), - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isFinite()), - "document_title": Schema.String, - "start_page_number": Schema.Number.check(Schema.isFinite()), - "end_page_number": Schema.Number.check(Schema.isFinite()), - "file_id": Schema.String - }), - Schema.Struct({ - "type": Schema.Literal("content_block_location"), - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isFinite()), - "document_title": Schema.String, - "start_block_index": Schema.Number.check(Schema.isFinite()), - "end_block_index": Schema.Number.check(Schema.isFinite()), - "file_id": Schema.String - }), - Schema.Struct({ - "type": Schema.Literal("web_search_result_location"), - "cited_text": Schema.String, - "encrypted_index": Schema.String, - "title": Schema.String, - "url": Schema.String - }), - Schema.Struct({ - "type": Schema.Literal("search_result_location"), - "cited_text": Schema.String, - "search_result_index": Schema.Number.check(Schema.isFinite()), - "source": Schema.String, - "title": Schema.String, - "start_block_index": Schema.Number.check(Schema.isFinite()), - "end_block_index": Schema.Number.check(Schema.isFinite()) - }) - ], { mode: "oneOf" })) - }), - Schema.Struct({ - "type": Schema.Literal("tool_use"), - "id": Schema.String, - "name": Schema.String, - "input": Schema.optionalKey(Schema.Unknown) - }), - Schema.Struct({ "type": Schema.Literal("thinking"), "thinking": Schema.String, "signature": Schema.String }), - Schema.Struct({ "type": Schema.Literal("redacted_thinking"), "data": Schema.String }), - Schema.Struct({ - "type": Schema.Literal("server_tool_use"), - "id": Schema.String, - "name": Schema.Literal("web_search"), - "input": Schema.optionalKey(Schema.Unknown) - }), - Schema.Struct({ - "type": Schema.Literal("web_search_tool_result"), - "tool_use_id": Schema.String, - "content": Schema.Union([ - Schema.Array( - Schema.Struct({ - "type": Schema.Literal("web_search_result"), - "encrypted_content": Schema.String, - "page_age": Schema.String, - "title": Schema.String, - "url": Schema.String - }) - ), - Schema.Struct({ - "type": Schema.Literal("web_search_tool_result_error"), - "error_code": Schema.Literals([ - "invalid_tool_input", - "unavailable", - "max_uses_exceeded", - "too_many_requests", - "query_too_long" - ]) - }) - ]) - }) - ], { mode: "oneOf" })), - "model": Schema.String, - "stop_reason": Schema.Unknown, - "stop_sequence": Schema.Unknown, - "usage": Schema.Struct({ - "input_tokens": Schema.Number.check(Schema.isFinite()), - "output_tokens": Schema.Number.check(Schema.isFinite()), - "cache_creation_input_tokens": Schema.Number.check(Schema.isFinite()), - "cache_read_input_tokens": Schema.Number.check(Schema.isFinite()), - "cache_creation": Schema.Struct({ - "ephemeral_5m_input_tokens": Schema.Number.check(Schema.isFinite()), - "ephemeral_1h_input_tokens": Schema.Number.check(Schema.isFinite()) - }), - "inference_geo": Schema.String, - "server_tool_use": Schema.Struct({ "web_search_requests": Schema.Number.check(Schema.isFinite()) }), - "service_tier": Schema.Literals(["standard", "priority", "batch"]) - }) - }) - }), - Schema.Struct({ - "type": Schema.Literal("message_delta"), - "delta": Schema.Struct({ - "stop_reason": Schema.Literals(["end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", "refusal"]), - "stop_sequence": Schema.String - }), - "usage": Schema.Struct({ - "input_tokens": Schema.Number.check(Schema.isFinite()), - "output_tokens": Schema.Number.check(Schema.isFinite()), - "cache_creation_input_tokens": Schema.Number.check(Schema.isFinite()), - "cache_read_input_tokens": Schema.Number.check(Schema.isFinite()), - "server_tool_use": Schema.Struct({ "web_search_requests": Schema.Number.check(Schema.isFinite()) }) - }) - }), - Schema.Struct({ "type": Schema.Literal("message_stop") }), - Schema.Struct({ - "type": Schema.Literal("content_block_start"), - "index": Schema.Number.check(Schema.isFinite()), - "content_block": Schema.Union([ +} +export const AnthropicMessagesMessageStartEvent = Schema.Struct({ + "type": Schema.Literal("message_start"), + "message": Schema.Struct({ + "id": Schema.String, + "type": Schema.Literal("message"), + "role": Schema.Literal("assistant"), + "container": Schema.Struct({ "id": Schema.String, "expires_at": Schema.String }), + "content": Schema.Array(Schema.Union([ Schema.Struct({ "type": Schema.Literal("text"), "text": Schema.String, @@ -1502,6 +2215,11 @@ export const AnthropicMessagesStreamEvent = Schema.Union([ Schema.Struct({ "type": Schema.Literal("tool_use"), "id": Schema.String, + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), "name": Schema.String, "input": Schema.optionalKey(Schema.Unknown) }), @@ -1510,11 +2228,29 @@ export const AnthropicMessagesStreamEvent = Schema.Union([ Schema.Struct({ "type": Schema.Literal("server_tool_use"), "id": Schema.String, - "name": Schema.Literal("web_search"), + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), + "name": Schema.Literals([ + "web_search", + "web_fetch", + "code_execution", + "bash_code_execution", + "text_editor_code_execution", + "tool_search_tool_regex", + "tool_search_tool_bm25" + ]), "input": Schema.optionalKey(Schema.Unknown) }), Schema.Struct({ "type": Schema.Literal("web_search_tool_result"), + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), "tool_use_id": Schema.String, "content": Schema.Union([ Schema.Array( @@ -1533,78 +2269,304 @@ export const AnthropicMessagesStreamEvent = Schema.Union([ "unavailable", "max_uses_exceeded", "too_many_requests", - "query_too_long" + "query_too_long", + "request_too_large" ]) }) ]) - }) - ], { mode: "oneOf" }) - }), - Schema.Struct({ - "type": Schema.Literal("content_block_delta"), - "index": Schema.Number.check(Schema.isFinite()), - "delta": Schema.Union([ - Schema.Struct({ "type": Schema.Literal("text_delta"), "text": Schema.String }), - Schema.Struct({ "type": Schema.Literal("input_json_delta"), "partial_json": Schema.String }), - Schema.Struct({ "type": Schema.Literal("thinking_delta"), "thinking": Schema.String }), - Schema.Struct({ "type": Schema.Literal("signature_delta"), "signature": Schema.String }), + }), Schema.Struct({ - "type": Schema.Literal("citations_delta"), - "citation": Schema.Union([ + "type": Schema.Literal("web_fetch_tool_result"), + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), + "content": Schema.Union([ Schema.Struct({ - "type": Schema.Literal("char_location"), - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isFinite()), - "document_title": Schema.String, - "start_char_index": Schema.Number.check(Schema.isFinite()), - "end_char_index": Schema.Number.check(Schema.isFinite()), - "file_id": Schema.String + "type": Schema.Literal("web_fetch_tool_result_error"), + "error_code": Schema.Literals([ + "invalid_tool_input", + "url_too_long", + "url_not_allowed", + "url_not_accessible", + "unsupported_content_type", + "too_many_requests", + "max_uses_exceeded", + "unavailable" + ]) }), Schema.Struct({ - "type": Schema.Literal("page_location"), - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isFinite()), - "document_title": Schema.String, - "start_page_number": Schema.Number.check(Schema.isFinite()), - "end_page_number": Schema.Number.check(Schema.isFinite()), - "file_id": Schema.String + "content": Schema.Struct({ + "citations": Schema.Struct({ "enabled": Schema.Boolean }), + "source": Schema.Union([ + Schema.Struct({ + "data": Schema.String, + "media_type": Schema.Literal("application/pdf"), + "type": Schema.Literal("base64") + }), + Schema.Struct({ + "data": Schema.String, + "media_type": Schema.Literal("text/plain"), + "type": Schema.Literal("text") + }) + ]), + "title": Schema.String, + "type": Schema.Literal("document") + }), + "retrieved_at": Schema.String, + "type": Schema.Literal("web_fetch_result"), + "url": Schema.String + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("code_execution_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" + ]), + "type": Schema.Literal("code_execution_tool_result_error") }), Schema.Struct({ - "type": Schema.Literal("content_block_location"), - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isFinite()), - "document_title": Schema.String, - "start_block_index": Schema.Number.check(Schema.isFinite()), - "end_block_index": Schema.Number.check(Schema.isFinite()), - "file_id": Schema.String + "content": Schema.Array( + Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("code_execution_output") }) + ), + "return_code": Schema.Number.check(Schema.isFinite()), + "stderr": Schema.String, + "stdout": Schema.String, + "type": Schema.Literal("code_execution_result") }), Schema.Struct({ - "type": Schema.Literal("web_search_result_location"), - "cited_text": Schema.String, - "encrypted_index": Schema.String, - "title": Schema.String, - "url": Schema.String + "content": Schema.Array( + Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("code_execution_output") }) + ), + "encrypted_stdout": Schema.String, + "return_code": Schema.Number.check(Schema.isFinite()), + "stderr": Schema.String, + "type": Schema.Literal("encrypted_code_execution_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("bash_code_execution_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded", + "output_file_too_large" + ]), + "type": Schema.Literal("bash_code_execution_tool_result_error") }), Schema.Struct({ - "type": Schema.Literal("search_result_location"), - "cited_text": Schema.String, - "search_result_index": Schema.Number.check(Schema.isFinite()), - "source": Schema.String, - "title": Schema.String, - "start_block_index": Schema.Number.check(Schema.isFinite()), - "end_block_index": Schema.Number.check(Schema.isFinite()) + "content": Schema.Array( + Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("bash_code_execution_output") }) + ), + "return_code": Schema.Number.check(Schema.isFinite()), + "stderr": Schema.String, + "stdout": Schema.String, + "type": Schema.Literal("bash_code_execution_result") }) - ], { mode: "oneOf" }) - }) - ], { mode: "oneOf" }) - }), - Schema.Struct({ "type": Schema.Literal("content_block_stop"), "index": Schema.Number.check(Schema.isFinite()) }), - Schema.Struct({ "type": Schema.Literal("ping") }), - Schema.Struct({ - "type": Schema.Literal("error"), - "error": Schema.Struct({ "type": Schema.String, "message": Schema.String }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("text_editor_code_execution_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded", + "file_not_found" + ]), + "error_message": Schema.String, + "type": Schema.Literal("text_editor_code_execution_tool_result_error") + }), + Schema.Struct({ + "content": Schema.String, + "file_type": Schema.Literals(["text", "image", "pdf"]), + "num_lines": Schema.Number.check(Schema.isFinite()), + "start_line": Schema.Number.check(Schema.isFinite()), + "total_lines": Schema.Number.check(Schema.isFinite()), + "type": Schema.Literal("text_editor_code_execution_view_result") + }), + Schema.Struct({ + "is_file_update": Schema.Boolean, + "type": Schema.Literal("text_editor_code_execution_create_result") + }), + Schema.Struct({ + "lines": Schema.Array(Schema.String), + "new_lines": Schema.Number.check(Schema.isFinite()), + "new_start": Schema.Number.check(Schema.isFinite()), + "old_lines": Schema.Number.check(Schema.isFinite()), + "old_start": Schema.Number.check(Schema.isFinite()), + "type": Schema.Literal("text_editor_code_execution_str_replace_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("tool_search_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" + ]), + "error_message": Schema.String, + "type": Schema.Literal("tool_search_tool_result_error") + }), + Schema.Struct({ + "tool_references": Schema.Array( + Schema.Struct({ "tool_name": Schema.String, "type": Schema.Literal("tool_reference") }) + ), + "type": Schema.Literal("tool_search_tool_search_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ "type": Schema.Literal("container_upload"), "file_id": Schema.String }) + ], { mode: "oneOf" })), + "model": Schema.String, + "stop_reason": Schema.Unknown, + "stop_sequence": Schema.Unknown, + "usage": Schema.Struct({ + "input_tokens": Schema.Number.check(Schema.isFinite()), + "output_tokens": Schema.Number.check(Schema.isFinite()), + "cache_creation_input_tokens": Schema.Number.check(Schema.isFinite()), + "cache_read_input_tokens": Schema.Number.check(Schema.isFinite()), + "cache_creation": Schema.Struct({ + "ephemeral_5m_input_tokens": Schema.Number.check(Schema.isFinite()), + "ephemeral_1h_input_tokens": Schema.Number.check(Schema.isFinite()) + }), + "inference_geo": Schema.String, + "server_tool_use": Schema.Struct({ + "web_search_requests": Schema.Number.check(Schema.isFinite()), + "web_fetch_requests": Schema.Number.check(Schema.isFinite()) + }), + "service_tier": Schema.Literals(["standard", "priority", "batch"]) + }), + "provider": Schema.optionalKey( + Schema.Literals([ + "AnyScale", + "Atoma", + "Cent-ML", + "CrofAI", + "Enfer", + "GoPomelo", + "HuggingFace", + "Hyperbolic 2", + "InoCloud", + "Kluster", + "Lambda", + "Lepton", + "Lynn 2", + "Lynn", + "Mancer", + "Meta", + "Modal", + "Nineteen", + "OctoAI", + "Recursal", + "Reflection", + "Replicate", + "SambaNova 2", + "SF Compute", + "Targon", + "Together 2", + "Ubicloud", + "01.AI", + "AI21", + "AionLabs", + "Alibaba", + "Ambient", + "Amazon Bedrock", + "Amazon Nova", + "Anthropic", + "Arcee AI", + "AtlasCloud", + "Avian", + "Azure", + "BaseTen", + "BytePlus", + "Black Forest Labs", + "Cerebras", + "Chutes", + "Cirrascale", + "Clarifai", + "Cloudflare", + "Cohere", + "Crusoe", + "DeepInfra", + "DeepSeek", + "Featherless", + "Fireworks", + "Friendli", + "GMICloud", + "Google", + "Google AI Studio", + "Groq", + "Hyperbolic", + "Inception", + "Inceptron", + "InferenceNet", + "Ionstream", + "Infermatic", + "Io Net", + "Inflection", + "Liquid", + "Mara", + "Mancer 2", + "Minimax", + "ModelRun", + "Mistral", + "Modular", + "Moonshot AI", + "Morph", + "NCompass", + "Nebius", + "NextBit", + "Novita", + "Nvidia", + "OpenAI", + "OpenInference", + "Parasail", + "Perplexity", + "Phala", + "Relace", + "SambaNova", + "Seed", + "SiliconFlow", + "Sourceful", + "StepFun", + "Stealth", + "StreamLake", + "Switchpoint", + "Together", + "Upstage", + "Venice", + "WandB", + "Xiaomi", + "xAI", + "Z.AI", + "FakeProvider" + ]) + ) }) -], { mode: "oneOf" }).annotate({ "description": "Union of all possible streaming events" }) +}).annotate({ "description": "Event sent at the start of a streaming message" }) export type OpenRouterAnthropicMessageParam = { readonly "role": "user" | "assistant" readonly "content": @@ -1744,7 +2706,7 @@ export type OpenRouterAnthropicMessageParam = { readonly "content"?: | string | ReadonlyArray< - { + | { readonly "type": "text" readonly "text": string readonly "citations"?: ReadonlyArray< @@ -1786,7 +2748,8 @@ export type OpenRouterAnthropicMessageParam = { } > readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } - } | { + } + | { readonly "type": "image" readonly "source": { readonly "type": "base64" @@ -1795,6 +2758,128 @@ export type OpenRouterAnthropicMessageParam = { } | { readonly "type": "url"; readonly "url": string } readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } } + | { readonly "type": "tool_reference"; readonly "tool_name": string } + | { + readonly "type": "search_result" + readonly "source": string + readonly "title": string + readonly "content": ReadonlyArray< + { + readonly "type": "text" + readonly "text": string + readonly "citations"?: ReadonlyArray< + { + readonly "type": "char_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_char_index": number + readonly "end_char_index": number + } | { + readonly "type": "page_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_page_number": number + readonly "end_page_number": number + } | { + readonly "type": "content_block_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_block_index": number + readonly "end_block_index": number + } | { + readonly "type": "web_search_result_location" + readonly "cited_text": string + readonly "encrypted_index": string + readonly "title": string + readonly "url": string + } | { + readonly "type": "search_result_location" + readonly "cited_text": string + readonly "search_result_index": number + readonly "source": string + readonly "title": string + readonly "start_block_index": number + readonly "end_block_index": number + } + > + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } + > + readonly "citations"?: { readonly "enabled"?: boolean } + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } + | { + readonly "type": "document" + readonly "source": + | { readonly "type": "base64"; readonly "media_type": "application/pdf"; readonly "data": string } + | { readonly "type": "text"; readonly "media_type": "text/plain"; readonly "data": string } + | { + readonly "type": "content" + readonly "content": + | string + | ReadonlyArray< + { + readonly "type": "text" + readonly "text": string + readonly "citations"?: ReadonlyArray< + { + readonly "type": "char_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_char_index": number + readonly "end_char_index": number + } | { + readonly "type": "page_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_page_number": number + readonly "end_page_number": number + } | { + readonly "type": "content_block_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_block_index": number + readonly "end_block_index": number + } | { + readonly "type": "web_search_result_location" + readonly "cited_text": string + readonly "encrypted_index": string + readonly "title": string + readonly "url": string + } | { + readonly "type": "search_result_location" + readonly "cited_text": string + readonly "search_result_index": number + readonly "source": string + readonly "title": string + readonly "start_block_index": number + readonly "end_block_index": number + } + > + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } | { + readonly "type": "image" + readonly "source": { + readonly "type": "base64" + readonly "media_type": "image/jpeg" | "image/png" | "image/gif" | "image/webp" + readonly "data": string + } | { readonly "type": "url"; readonly "url": string } + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } + > + } + | { readonly "type": "url"; readonly "url": string } + readonly "citations"?: { readonly "enabled"?: boolean } + readonly "context"?: string + readonly "title"?: string + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } > readonly "is_error"?: boolean readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } @@ -1804,7 +2889,14 @@ export type OpenRouterAnthropicMessageParam = { | { readonly "type": "server_tool_use" readonly "id": string - readonly "name": "web_search" + readonly "name": + | "web_search" + | "web_fetch" + | "code_execution" + | "bash_code_execution" + | "text_editor_code_execution" + | "tool_search_tool_regex" + | "tool_search_tool_bm25" readonly "input"?: unknown readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } } @@ -2148,6 +3240,173 @@ export const OpenRouterAnthropicMessageParam = Schema.Struct({ "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) ) + }), + Schema.Struct({ "type": Schema.Literal("tool_reference"), "tool_name": Schema.String }), + Schema.Struct({ + "type": Schema.Literal("search_result"), + "source": Schema.String, + "title": Schema.String, + "content": Schema.Array(Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String, + "citations": Schema.optionalKey(Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("char_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_char_index": Schema.Number.check(Schema.isFinite()), + "end_char_index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("page_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_page_number": Schema.Number.check(Schema.isFinite()), + "end_page_number": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("content_block_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("web_search_result_location"), + "cited_text": Schema.String, + "encrypted_index": Schema.String, + "title": Schema.String, + "url": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("search_result_location"), + "cited_text": Schema.String, + "search_result_index": Schema.Number.check(Schema.isFinite()), + "source": Schema.String, + "title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()) + }) + ], { mode: "oneOf" }))), + "cache_control": Schema.optionalKey( + Schema.Struct({ + "type": Schema.Literal("ephemeral"), + "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) + }) + ) + })), + "citations": Schema.optionalKey(Schema.Struct({ "enabled": Schema.optionalKey(Schema.Boolean) })), + "cache_control": Schema.optionalKey( + Schema.Struct({ + "type": Schema.Literal("ephemeral"), + "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) + }) + ) + }), + Schema.Struct({ + "type": Schema.Literal("document"), + "source": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("base64"), + "media_type": Schema.Literal("application/pdf"), + "data": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("text"), + "media_type": Schema.Literal("text/plain"), + "data": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("content"), + "content": Schema.Union([ + Schema.String, + Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String, + "citations": Schema.optionalKey(Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("char_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_char_index": Schema.Number.check(Schema.isFinite()), + "end_char_index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("page_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_page_number": Schema.Number.check(Schema.isFinite()), + "end_page_number": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("content_block_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("web_search_result_location"), + "cited_text": Schema.String, + "encrypted_index": Schema.String, + "title": Schema.String, + "url": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("search_result_location"), + "cited_text": Schema.String, + "search_result_index": Schema.Number.check(Schema.isFinite()), + "source": Schema.String, + "title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()) + }) + ], { mode: "oneOf" }))), + "cache_control": Schema.optionalKey( + Schema.Struct({ + "type": Schema.Literal("ephemeral"), + "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) + }) + ) + }), + Schema.Struct({ + "type": Schema.Literal("image"), + "source": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("base64"), + "media_type": Schema.Literals(["image/jpeg", "image/png", "image/gif", "image/webp"]), + "data": Schema.String + }), + Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }) + ], { mode: "oneOf" }), + "cache_control": Schema.optionalKey( + Schema.Struct({ + "type": Schema.Literal("ephemeral"), + "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) + }) + ) + }) + ], { mode: "oneOf" })) + ]) + }), + Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }) + ], { mode: "oneOf" }), + "citations": Schema.optionalKey(Schema.Struct({ "enabled": Schema.optionalKey(Schema.Boolean) })), + "context": Schema.optionalKey(Schema.String), + "title": Schema.optionalKey(Schema.String), + "cache_control": Schema.optionalKey( + Schema.Struct({ + "type": Schema.Literal("ephemeral"), + "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) + }) + ) }) ])) ])), @@ -2164,7 +3423,15 @@ export const OpenRouterAnthropicMessageParam = Schema.Struct({ Schema.Struct({ "type": Schema.Literal("server_tool_use"), "id": Schema.String, - "name": Schema.Literal("web_search"), + "name": Schema.Literals([ + "web_search", + "web_fetch", + "code_execution", + "bash_code_execution", + "text_editor_code_execution", + "tool_search_tool_regex", + "tool_search_tool_bm25" + ]), "input": Schema.optionalKey(Schema.Unknown), "cache_control": Schema.optionalKey( Schema.Struct({ @@ -2271,17 +3538,26 @@ export const OpenRouterAnthropicMessageParam = Schema.Struct({ ], { mode: "oneOf" })) ]) }).annotate({ "description": "Anthropic message with OpenRouter extensions" }) -export type AnthropicOutputConfig = { readonly "effort"?: "low" | "medium" | "high" | "max" } +export type AnthropicOutputConfig = { + readonly "effort"?: "low" | "medium" | "high" | "max" + readonly "format"?: { readonly "type": "json_schema"; readonly "schema": {} } +} export const AnthropicOutputConfig = Schema.Struct({ "effort": Schema.optionalKey( Schema.Literals(["low", "medium", "high", "max"]).annotate({ "description": "How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer. Valid values are `low`, `medium`, `high`, or `max`." }) + ), + "format": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("json_schema"), "schema": Schema.Struct({}) }).annotate({ + "description": + "A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)." + }) ) }).annotate({ "description": - "Configuration for controlling output behavior. Currently supports the effort parameter for Claude Opus 4.5." + "Configuration for controlling output behavior. Supports the effort parameter and structured output format." }) export type ActivityItem = { readonly "date": string @@ -2325,17 +3601,339 @@ export const ForbiddenResponseErrorData = Schema.Struct({ "message": Schema.String, "metadata": Schema.optionalKey(Schema.Struct({})) }).annotate({ "description": "Error data for ForbiddenResponse" }) -export type CreateChargeRequest = { - readonly "amount": number - readonly "sender": string - readonly "chain_id": 1 | 137 | 8453 -} -export const CreateChargeRequest = Schema.Struct({ - "amount": Schema.Number.check(Schema.isFinite()), - "sender": Schema.String, - "chain_id": Schema.Literals([1, 137, 8453]) -}).annotate({ "description": "Create a Coinbase charge for crypto payment" }) -export type PublicPricing = { +export type ChatCompletionFinishReason = "tool_calls" | "stop" | "length" | "content_filter" | "error" +export const ChatCompletionFinishReason = Schema.Literals(["tool_calls", "stop", "length", "content_filter", "error"]) +export type ChatMessageContentItemCacheControl = { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } +export const ChatMessageContentItemCacheControl = Schema.Struct({ + "type": Schema.Literal("ephemeral"), + "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) +}).annotate({ "description": "Cache control for the content part" }) +export type ChatMessageContentItemImage = { + readonly "type": "image_url" + readonly "image_url": { readonly "url": string; readonly "detail"?: "auto" | "low" | "high" } +} +export const ChatMessageContentItemImage = Schema.Struct({ + "type": Schema.Literal("image_url"), + "image_url": Schema.Struct({ + "url": Schema.String.annotate({ "description": "URL of the image (data: URLs supported)" }), + "detail": Schema.optionalKey( + Schema.Literals(["auto", "low", "high"]).annotate({ "description": "Image detail level for vision models" }) + ) + }) +}).annotate({ "description": "Image content part for vision models" }) +export type ChatMessageContentItemAudio = { + readonly "type": "input_audio" + readonly "input_audio": { readonly "data": string; readonly "format": string } +} +export const ChatMessageContentItemAudio = Schema.Struct({ + "type": Schema.Literal("input_audio"), + "input_audio": Schema.Struct({ + "data": Schema.String.annotate({ "description": "Base64 encoded audio data" }), + "format": Schema.String.annotate({ + "description": + "Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider." + }) + }) +}).annotate({ "description": "Audio input content part. Supported audio formats vary by provider." }) +export type VideoInput = { readonly "url": string } +export const VideoInput = Schema.Struct({ + "url": Schema.String.annotate({ "description": "URL of the video (data: URLs supported)" }) +}).annotate({ "description": "Video input object" }) +export type ChatMessageContentItemFile = { + readonly "type": "file" + readonly "file": { readonly "file_data"?: string; readonly "file_id"?: string; readonly "filename"?: string } +} +export const ChatMessageContentItemFile = Schema.Struct({ + "type": Schema.Literal("file"), + "file": Schema.Struct({ + "file_data": Schema.optionalKey( + Schema.String.annotate({ "description": "File content as base64 data URL or URL" }) + ), + "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "File ID for previously uploaded files" })), + "filename": Schema.optionalKey(Schema.String.annotate({ "description": "Original filename" })) + }) +}).annotate({ "description": "File content part for document processing" }) +export type ChatMessageToolCall = { + readonly "id": string + readonly "type": "function" + readonly "function": { readonly "name": string; readonly "arguments": string } +} +export const ChatMessageToolCall = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Tool call identifier" }), + "type": Schema.Literal("function"), + "function": Schema.Struct({ + "name": Schema.String.annotate({ "description": "Function name to call" }), + "arguments": Schema.String.annotate({ "description": "Function arguments as JSON string" }) + }) +}).annotate({ "description": "Tool call made by the assistant" }) +export type ReasoningDetailSummary = { + readonly "type": "reasoning.summary" + readonly "summary": string + readonly "id"?: string + readonly "format"?: + | "unknown" + | "openai-responses-v1" + | "azure-openai-responses-v1" + | "xai-responses-v1" + | "anthropic-claude-v1" + | "google-gemini-v1" + readonly "index"?: number +} +export const ReasoningDetailSummary = Schema.Struct({ + "type": Schema.Literal("reasoning.summary"), + "summary": Schema.String, + "id": Schema.optionalKey(Schema.String), + "format": Schema.optionalKey( + Schema.Literals([ + "unknown", + "openai-responses-v1", + "azure-openai-responses-v1", + "xai-responses-v1", + "anthropic-claude-v1", + "google-gemini-v1" + ]) + ), + "index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) +}).annotate({ "description": "Reasoning detail summary schema" }) +export type ReasoningDetailEncrypted = { + readonly "type": "reasoning.encrypted" + readonly "data": string + readonly "id"?: string + readonly "format"?: + | "unknown" + | "openai-responses-v1" + | "azure-openai-responses-v1" + | "xai-responses-v1" + | "anthropic-claude-v1" + | "google-gemini-v1" + readonly "index"?: number +} +export const ReasoningDetailEncrypted = Schema.Struct({ + "type": Schema.Literal("reasoning.encrypted"), + "data": Schema.String, + "id": Schema.optionalKey(Schema.String), + "format": Schema.optionalKey( + Schema.Literals([ + "unknown", + "openai-responses-v1", + "azure-openai-responses-v1", + "xai-responses-v1", + "anthropic-claude-v1", + "google-gemini-v1" + ]) + ), + "index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) +}).annotate({ "description": "Reasoning detail encrypted schema" }) +export type ReasoningDetailText = { + readonly "type": "reasoning.text" + readonly "text"?: string + readonly "signature"?: string + readonly "id"?: string + readonly "format"?: + | "unknown" + | "openai-responses-v1" + | "azure-openai-responses-v1" + | "xai-responses-v1" + | "anthropic-claude-v1" + | "google-gemini-v1" + readonly "index"?: number +} +export const ReasoningDetailText = Schema.Struct({ + "type": Schema.Literal("reasoning.text"), + "text": Schema.optionalKey(Schema.String), + "signature": Schema.optionalKey(Schema.String), + "id": Schema.optionalKey(Schema.String), + "format": Schema.optionalKey( + Schema.Literals([ + "unknown", + "openai-responses-v1", + "azure-openai-responses-v1", + "xai-responses-v1", + "anthropic-claude-v1", + "google-gemini-v1" + ]) + ), + "index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) +}).annotate({ "description": "Reasoning detail text schema" }) +export type ChatCompletionAudioOutput = { + readonly "id"?: string + readonly "expires_at"?: number + readonly "data"?: string + readonly "transcript"?: string +} +export const ChatCompletionAudioOutput = Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "Audio output identifier" })), + "expires_at": Schema.optionalKey( + Schema.Number.annotate({ "description": "Audio expiration timestamp" }).check(Schema.isFinite()) + ), + "data": Schema.optionalKey(Schema.String.annotate({ "description": "Base64 encoded audio data" })), + "transcript": Schema.optionalKey(Schema.String.annotate({ "description": "Audio transcript" })) +}).annotate({ "description": "Audio output data or reference" }) +export type ChatMessageTokenLogprob = { + readonly "token": string + readonly "logprob": number + readonly "bytes": ReadonlyArray + readonly "top_logprobs": ReadonlyArray< + { readonly "token": string; readonly "logprob": number; readonly "bytes": ReadonlyArray } + > +} +export const ChatMessageTokenLogprob = Schema.Struct({ + "token": Schema.String.annotate({ "description": "The token" }), + "logprob": Schema.Number.annotate({ "description": "Log probability of the token" }).check(Schema.isFinite()), + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())).annotate({ "description": "UTF-8 bytes of the token" }), + "top_logprobs": Schema.Array( + Schema.Struct({ + "token": Schema.String, + "logprob": Schema.Number.check(Schema.isFinite()), + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())) + }) + ).annotate({ "description": "Top alternative tokens with probabilities" }) +}).annotate({ "description": "Token log probability information" }) +export type ChatGenerationTokenUsage = { + readonly "completion_tokens": number + readonly "prompt_tokens": number + readonly "total_tokens": number + readonly "completion_tokens_details"?: { + readonly "reasoning_tokens"?: number + readonly "audio_tokens"?: number + readonly "accepted_prediction_tokens"?: number + readonly "rejected_prediction_tokens"?: number + } + readonly "prompt_tokens_details"?: { + readonly "cached_tokens"?: number + readonly "cache_write_tokens"?: number + readonly "audio_tokens"?: number + readonly "video_tokens"?: number + } +} +export const ChatGenerationTokenUsage = Schema.Struct({ + "completion_tokens": Schema.Number.annotate({ "description": "Number of tokens in the completion" }).check( + Schema.isFinite() + ), + "prompt_tokens": Schema.Number.annotate({ "description": "Number of tokens in the prompt" }).check(Schema.isFinite()), + "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens" }).check(Schema.isFinite()), + "completion_tokens_details": Schema.optionalKey( + Schema.Struct({ + "reasoning_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Tokens used for reasoning" }).check(Schema.isFinite()) + ), + "audio_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Tokens used for audio output" }).check(Schema.isFinite()) + ), + "accepted_prediction_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Accepted prediction tokens" }).check(Schema.isFinite()) + ), + "rejected_prediction_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Rejected prediction tokens" }).check(Schema.isFinite()) + ) + }).annotate({ "description": "Detailed completion token usage" }) + ), + "prompt_tokens_details": Schema.optionalKey( + Schema.Struct({ + "cached_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Cached prompt tokens" }).check(Schema.isFinite()) + ), + "cache_write_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Tokens written to cache. Only returned for models with explicit caching and cache write pricing." + }).check(Schema.isFinite()) + ), + "audio_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Audio input tokens" }).check(Schema.isFinite()) + ), + "video_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Video input tokens" }).check(Schema.isFinite()) + ) + }).annotate({ "description": "Detailed prompt token usage" }) + ) +}).annotate({ "description": "Token usage statistics" }) +export type ChatStreamingMessageToolCall = { + readonly "index": number + readonly "id"?: string | null + readonly "type"?: "function" | null + readonly "function"?: { readonly "name"?: string | null; readonly "arguments"?: string } +} +export const ChatStreamingMessageToolCall = Schema.Struct({ + "index": Schema.Number.annotate({ "description": "Tool call index in the array" }).check(Schema.isFinite()), + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.optionalKey(Schema.Union([Schema.Literal("function"), Schema.Null])), + "function": Schema.optionalKey( + Schema.Struct({ + "name": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "arguments": Schema.optionalKey(Schema.String.annotate({ "description": "Function arguments as JSON string" })) + }).annotate({ "description": "Function call details" }) + ) +}).annotate({ "description": "Tool call delta for streaming responses" }) +export type ModelName = string +export const ModelName = Schema.String.annotate({ "description": "Model to use for completion" }) +export type ModelNames = ReadonlyArray +export const ModelNames = Schema.Array( + Schema.String.annotate({ "description": "Available OpenRouter chat completion models" }) +).annotate({ "description": "Models to use for completion" }) +export type ResponseFormatText = { readonly "type": "text" } +export const ResponseFormatText = Schema.Struct({ "type": Schema.Literal("text") }).annotate({ + "description": "Default text response format" +}) +export type ResponseFormatJSONObject = { readonly "type": "json_object" } +export const ResponseFormatJSONObject = Schema.Struct({ "type": Schema.Literal("json_object") }).annotate({ + "description": "JSON object response format" +}) +export type JSONSchemaConfig = { + readonly "name": string + readonly "description"?: string + readonly "schema"?: {} + readonly "strict"?: boolean +} +export const JSONSchemaConfig = Schema.Struct({ + "name": Schema.String.annotate({ "description": "Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)" }) + .check(Schema.isMaxLength(64)), + "description": Schema.optionalKey(Schema.String.annotate({ "description": "Schema description for the model" })), + "schema": Schema.optionalKey(Schema.Struct({}).annotate({ "description": "JSON Schema object" })), + "strict": Schema.optionalKey(Schema.Boolean.annotate({ "description": "Enable strict schema adherence" })) +}).annotate({ "description": "JSON Schema configuration object" }) +export type ResponseFormatTextGrammar = { readonly "type": "grammar"; readonly "grammar": string } +export const ResponseFormatTextGrammar = Schema.Struct({ + "type": Schema.Literal("grammar"), + "grammar": Schema.String.annotate({ "description": "Custom grammar for text generation" }) +}).annotate({ "description": "Custom grammar response format" }) +export type ResponseFormatTextPython = { readonly "type": "python" } +export const ResponseFormatTextPython = Schema.Struct({ "type": Schema.Literal("python") }).annotate({ + "description": "Python code response format" +}) +export type ChatStreamOptions = { readonly "include_usage"?: boolean } +export const ChatStreamOptions = Schema.Struct({ + "include_usage": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Deprecated: This field has no effect. Full usage details are always included." + }) + ) +}).annotate({ "description": "Streaming configuration options" }) +export type NamedToolChoice = { readonly "type": "function"; readonly "function": { readonly "name": string } } +export const NamedToolChoice = Schema.Struct({ + "type": Schema.Literal("function"), + "function": Schema.Struct({ "name": Schema.String.annotate({ "description": "Function name to call" }) }) +}).annotate({ "description": "Named tool choice for specific function" }) +export type DebugOptions = { readonly "echo_upstream_body"?: boolean } +export const DebugOptions = Schema.Struct({ + "echo_upstream_body": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "If true, includes the transformed upstream request body in a debug chunk at the start of the stream. Only works with streaming mode." + }) + ) +}).annotate({ "description": "Debug options for inspecting request transformations (streaming only)" }) +export type CreateChargeRequest = { + readonly "amount": number + readonly "sender": string + readonly "chain_id": 1 | 137 | 8453 +} +export const CreateChargeRequest = Schema.Struct({ + "amount": Schema.Number.check(Schema.isFinite()), + "sender": Schema.String, + "chain_id": Schema.Literals([1, 137, 8453]) +}).annotate({ "description": "Create a Coinbase charge for crypto payment" }) +export type PublicPricing = { readonly "prompt": string readonly "completion": string readonly "request"?: string @@ -2513,7 +4111,10 @@ export const Parameter = Schema.Literals([ export type DefaultParameters = { readonly "temperature"?: number readonly "top_p"?: number + readonly "top_k"?: number readonly "frequency_penalty"?: number + readonly "presence_penalty"?: number + readonly "repetition_penalty"?: number } export const DefaultParameters = Schema.Struct({ "temperature": Schema.optionalKey( @@ -2522,8 +4123,15 @@ export const DefaultParameters = Schema.Struct({ "top_p": Schema.optionalKey( Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) ), + "top_k": Schema.optionalKey(Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0))), "frequency_penalty": Schema.optionalKey( Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(-2)).check(Schema.isLessThanOrEqualTo(2)) + ), + "presence_penalty": Schema.optionalKey( + Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(-2)).check(Schema.isLessThanOrEqualTo(2)) + ), + "repetition_penalty": Schema.optionalKey( + Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(2)) ) }).annotate({ "description": "Default parameters for this model" }) export type ModelsCountResponse = { readonly "data": { readonly "count": number } } @@ -2549,351 +4157,6 @@ export const PercentileStats = Schema.Struct({ "description": "Latency percentiles in milliseconds over the last 30 minutes. Latency measures time to first token. Only visible when authenticated with an API key or cookie; returns null for unauthenticated requests." }) -export type __schema5 = ReadonlyArray< - | "AI21" - | "AionLabs" - | "Alibaba" - | "Ambient" - | "Amazon Bedrock" - | "Amazon Nova" - | "Anthropic" - | "Arcee AI" - | "AtlasCloud" - | "Avian" - | "Azure" - | "BaseTen" - | "BytePlus" - | "Black Forest Labs" - | "Cerebras" - | "Chutes" - | "Cirrascale" - | "Clarifai" - | "Cloudflare" - | "Cohere" - | "Crusoe" - | "DeepInfra" - | "DeepSeek" - | "Featherless" - | "Fireworks" - | "Friendli" - | "GMICloud" - | "Google" - | "Google AI Studio" - | "Groq" - | "Hyperbolic" - | "Inception" - | "Inceptron" - | "InferenceNet" - | "Infermatic" - | "Io Net" - | "Inflection" - | "Liquid" - | "Mara" - | "Mancer 2" - | "Minimax" - | "ModelRun" - | "Mistral" - | "Modular" - | "Moonshot AI" - | "Morph" - | "NCompass" - | "Nebius" - | "NextBit" - | "Novita" - | "Nvidia" - | "OpenAI" - | "OpenInference" - | "Parasail" - | "Perplexity" - | "Phala" - | "Relace" - | "SambaNova" - | "Seed" - | "SiliconFlow" - | "Sourceful" - | "StepFun" - | "Stealth" - | "StreamLake" - | "Switchpoint" - | "Together" - | "Upstage" - | "Venice" - | "WandB" - | "Xiaomi" - | "xAI" - | "Z.AI" - | "FakeProvider" - | string -> -export const __schema5 = Schema.Array( - Schema.Union([ - Schema.Literals([ - "AI21", - "AionLabs", - "Alibaba", - "Ambient", - "Amazon Bedrock", - "Amazon Nova", - "Anthropic", - "Arcee AI", - "AtlasCloud", - "Avian", - "Azure", - "BaseTen", - "BytePlus", - "Black Forest Labs", - "Cerebras", - "Chutes", - "Cirrascale", - "Clarifai", - "Cloudflare", - "Cohere", - "Crusoe", - "DeepInfra", - "DeepSeek", - "Featherless", - "Fireworks", - "Friendli", - "GMICloud", - "Google", - "Google AI Studio", - "Groq", - "Hyperbolic", - "Inception", - "Inceptron", - "InferenceNet", - "Infermatic", - "Io Net", - "Inflection", - "Liquid", - "Mara", - "Mancer 2", - "Minimax", - "ModelRun", - "Mistral", - "Modular", - "Moonshot AI", - "Morph", - "NCompass", - "Nebius", - "NextBit", - "Novita", - "Nvidia", - "OpenAI", - "OpenInference", - "Parasail", - "Perplexity", - "Phala", - "Relace", - "SambaNova", - "Seed", - "SiliconFlow", - "Sourceful", - "StepFun", - "Stealth", - "StreamLake", - "Switchpoint", - "Together", - "Upstage", - "Venice", - "WandB", - "Xiaomi", - "xAI", - "Z.AI", - "FakeProvider" - ]), - Schema.String - ]) -) -export type __schema11 = number -export const __schema11 = Schema.Number.check(Schema.isFinite()) -export type __schema13 = unknown -export const __schema13 = Schema.Unknown -export type __schema21 = string | null -export const __schema21 = Schema.Union([Schema.String, Schema.Null]) -export type __schema22 = - | "unknown" - | "openai-responses-v1" - | "azure-openai-responses-v1" - | "xai-responses-v1" - | "anthropic-claude-v1" - | "google-gemini-v1" - | null -export const __schema22 = Schema.Union([ - Schema.Literals([ - "unknown", - "openai-responses-v1", - "azure-openai-responses-v1", - "xai-responses-v1", - "anthropic-claude-v1", - "google-gemini-v1" - ]), - Schema.Null -]) -export type ModelName = string -export const ModelName = Schema.String -export type ChatMessageContentItemImage = { - readonly "type": "image_url" - readonly "image_url": { readonly "url": string; readonly "detail"?: "auto" | "low" | "high" } -} -export const ChatMessageContentItemImage = Schema.Struct({ - "type": Schema.Literal("image_url"), - "image_url": Schema.Struct({ - "url": Schema.String, - "detail": Schema.optionalKey(Schema.Literals(["auto", "low", "high"])) - }) -}) -export type ChatMessageContentItemAudio = { - readonly "type": "input_audio" - readonly "input_audio": { readonly "data": string; readonly "format": string } -} -export const ChatMessageContentItemAudio = Schema.Struct({ - "type": Schema.Literal("input_audio"), - "input_audio": Schema.Struct({ "data": Schema.String, "format": Schema.String }) -}) -export type ChatMessageContentItemVideo = { - readonly "type": "input_video" - readonly "video_url": { readonly "url": string } -} | { readonly "type": "video_url"; readonly "video_url": { readonly "url": string } } -export const ChatMessageContentItemVideo = Schema.Union([ - Schema.Struct({ "type": Schema.Literal("input_video"), "video_url": Schema.Struct({ "url": Schema.String }) }), - Schema.Struct({ "type": Schema.Literal("video_url"), "video_url": Schema.Struct({ "url": Schema.String }) }) -], { mode: "oneOf" }) -export type ChatMessageToolCall = { - readonly "id": string - readonly "type": "function" - readonly "function": { readonly "name": string; readonly "arguments": string } -} -export const ChatMessageToolCall = Schema.Struct({ - "id": Schema.String, - "type": Schema.Literal("function"), - "function": Schema.Struct({ "name": Schema.String, "arguments": Schema.String }) -}) -export type ChatMessageTokenLogprob = { - readonly "token": string - readonly "logprob": number - readonly "bytes": ReadonlyArray | null - readonly "top_logprobs": ReadonlyArray< - { readonly "token": string; readonly "logprob": number; readonly "bytes": ReadonlyArray | null } - > -} -export const ChatMessageTokenLogprob = Schema.Struct({ - "token": Schema.String, - "logprob": Schema.Number.check(Schema.isFinite()), - "bytes": Schema.Union([Schema.Array(Schema.Number.check(Schema.isFinite())), Schema.Null]), - "top_logprobs": Schema.Array( - Schema.Struct({ - "token": Schema.String, - "logprob": Schema.Number.check(Schema.isFinite()), - "bytes": Schema.Union([Schema.Array(Schema.Number.check(Schema.isFinite())), Schema.Null]) - }) - ) -}) -export type ChatGenerationTokenUsage = { - readonly "completion_tokens": number - readonly "prompt_tokens": number - readonly "total_tokens": number - readonly "completion_tokens_details"?: { - readonly "reasoning_tokens"?: number | null - readonly "audio_tokens"?: number | null - readonly "accepted_prediction_tokens"?: number | null - readonly "rejected_prediction_tokens"?: number | null - } | null - readonly "prompt_tokens_details"?: { - readonly "cached_tokens"?: number - readonly "cache_write_tokens"?: number - readonly "audio_tokens"?: number - readonly "video_tokens"?: number - } | null -} -export const ChatGenerationTokenUsage = Schema.Struct({ - "completion_tokens": Schema.Number.check(Schema.isFinite()), - "prompt_tokens": Schema.Number.check(Schema.isFinite()), - "total_tokens": Schema.Number.check(Schema.isFinite()), - "completion_tokens_details": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "reasoning_tokens": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])), - "audio_tokens": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])), - "accepted_prediction_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null]) - ), - "rejected_prediction_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null]) - ) - }), - Schema.Null - ])), - "prompt_tokens_details": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "cached_tokens": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "cache_write_tokens": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "audio_tokens": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "video_tokens": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) - }), - Schema.Null - ])) -}) -export type ChatCompletionFinishReason = "tool_calls" | "stop" | "length" | "content_filter" | "error" -export const ChatCompletionFinishReason = Schema.Literals(["tool_calls", "stop", "length", "content_filter", "error"]) -export type JSONSchemaConfig = { - readonly "name": string - readonly "description"?: string - readonly "schema"?: {} - readonly "strict"?: boolean | null -} -export const JSONSchemaConfig = Schema.Struct({ - "name": Schema.String.check(Schema.isMaxLength(64)), - "description": Schema.optionalKey(Schema.String), - "schema": Schema.optionalKey(Schema.Struct({}).check(Schema.isPropertyNames(Schema.String))), - "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])) -}) -export type ResponseFormatTextGrammar = { readonly "type": "grammar"; readonly "grammar": string } -export const ResponseFormatTextGrammar = Schema.Struct({ "type": Schema.Literal("grammar"), "grammar": Schema.String }) -export type ChatMessageContentItemCacheControl = { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } -export const ChatMessageContentItemCacheControl = Schema.Struct({ - "type": Schema.Literal("ephemeral"), - "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) -}) -export type NamedToolChoice = { readonly "type": "function"; readonly "function": { readonly "name": string } } -export const NamedToolChoice = Schema.Struct({ - "type": Schema.Literal("function"), - "function": Schema.Struct({ "name": Schema.String }) -}) -export type ChatStreamOptions = { readonly "include_usage"?: boolean } -export const ChatStreamOptions = Schema.Struct({ "include_usage": Schema.optionalKey(Schema.Boolean) }) -export type ChatStreamingMessageToolCall = { - readonly "index": number - readonly "id"?: string | null - readonly "type"?: "function" | null - readonly "function"?: { readonly "name"?: string | null; readonly "arguments"?: string } -} -export const ChatStreamingMessageToolCall = Schema.Struct({ - "index": Schema.Number.check(Schema.isFinite()), - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.optionalKey(Schema.Union([Schema.Literal("function"), Schema.Null])), - "function": Schema.optionalKey( - Schema.Struct({ - "name": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "arguments": Schema.optionalKey(Schema.String) - }) - ) -}) -export type ChatError = { - readonly "error": { - readonly "code": string | number | null - readonly "message": string - readonly "param"?: string | null - readonly "type"?: string | null - } -} -export const ChatError = Schema.Struct({ - "error": Schema.Struct({ - "code": Schema.Union([Schema.Union([Schema.String, Schema.Number.check(Schema.isFinite())]), Schema.Null]), - "message": Schema.String, - "param": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) - }) -}) export type OpenAIResponsesAnnotation = FileCitation | URLCitation | FilePath export const OpenAIResponsesAnnotation = Schema.Union([FileCitation, URLCitation, FilePath]) export type OutputItemReasoning = { @@ -2915,7 +4178,7 @@ export const OutputItemReasoning = Schema.Struct({ export type ResponsesOutputItemReasoning = { readonly "type": "reasoning" readonly "id": string - readonly "content"?: ReadonlyArray + readonly "content"?: ReadonlyArray<{ readonly "type": "reasoning_text"; readonly "text": string }> readonly "summary": ReadonlyArray readonly "encrypted_content"?: string readonly "status"?: "completed" | "incomplete" | "in_progress" @@ -2931,7 +4194,9 @@ export type ResponsesOutputItemReasoning = { export const ResponsesOutputItemReasoning = Schema.Struct({ "type": Schema.Literal("reasoning"), "id": Schema.String, - "content": Schema.optionalKey(Schema.Array(ReasoningTextContent)), + "content": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("reasoning_text"), "text": Schema.String })) + ), "summary": Schema.Array(ReasoningSummaryText), "encrypted_content": Schema.optionalKey(Schema.String), "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), @@ -2984,7 +4249,7 @@ export const OpenResponsesReasoningSummaryPartDoneEvent = Schema.Struct({ export type OpenResponsesReasoning = { readonly "type": "reasoning" readonly "id": string - readonly "content"?: ReadonlyArray + readonly "content"?: ReadonlyArray<{ readonly "type": "reasoning_text"; readonly "text": string }> readonly "summary": ReadonlyArray readonly "encrypted_content"?: string readonly "status"?: "completed" | "incomplete" | "in_progress" @@ -3000,7 +4265,9 @@ export type OpenResponsesReasoning = { export const OpenResponsesReasoning = Schema.Struct({ "type": Schema.Literal("reasoning"), "id": Schema.String, - "content": Schema.optionalKey(Schema.Array(ReasoningTextContent)), + "content": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("reasoning_text"), "text": Schema.String })) + ), "summary": Schema.Array(ReasoningSummaryText), "encrypted_content": Schema.optionalKey(Schema.String), "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), @@ -3019,21 +4286,63 @@ export const OpenResponsesReasoning = Schema.Struct({ export type OutputItemWebSearchCall = { readonly "type": "web_search_call" readonly "id": string + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } readonly "status": WebSearchStatus } export const OutputItemWebSearchCall = Schema.Struct({ "type": Schema.Literal("web_search_call"), "id": Schema.String, + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }), "status": WebSearchStatus }) export type ResponsesWebSearchCallOutput = { readonly "type": "web_search_call" readonly "id": string + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } readonly "status": WebSearchStatus } export const ResponsesWebSearchCallOutput = Schema.Struct({ "type": Schema.Literal("web_search_call"), "id": Schema.String, + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }), "status": WebSearchStatus }) export type OutputItemFileSearchCall = { @@ -3104,14 +4413,35 @@ export type OpenResponsesFunctionCallOutput = { readonly "type": "function_call_output" readonly "id"?: string readonly "call_id": string - readonly "output": string + readonly "output": + | string + | ReadonlyArray< + ResponseInputText | { + readonly "type": "input_image" + readonly "detail": "auto" | "high" | "low" + readonly "image_url"?: string + } | ResponseInputFile + > readonly "status"?: ToolCallStatus } export const OpenResponsesFunctionCallOutput = Schema.Struct({ "type": Schema.Literal("function_call_output"), "id": Schema.optionalKey(Schema.String), "call_id": Schema.String, - "output": Schema.String, + "output": Schema.Union([ + Schema.String, + Schema.Array( + Schema.Union([ + ResponseInputText, + Schema.Struct({ + "type": Schema.Literal("input_image"), + "detail": Schema.Literals(["auto", "high", "low"]), + "image_url": Schema.optionalKey(Schema.String) + }).annotate({ "description": "Image input content item" }), + ResponseInputFile + ], { mode: "oneOf" }) + ) + ]), "status": Schema.optionalKey(ToolCallStatus) }).annotate({ "description": "The output from a function call execution" }) export type OpenResponsesWebSearchPreviewTool = { @@ -3158,6 +4488,50 @@ export const OpenResponsesWebSearch20250826Tool = Schema.Struct({ "search_context_size": Schema.optionalKey(ResponsesSearchContextSize), "user_location": Schema.optionalKey(ResponsesWebSearchUserLocation) }).annotate({ "description": "Web search tool configuration (2025-08-26 version)" }) +export type OpenResponsesFileSearchTool = { + readonly "type": "file_search" + readonly "vector_store_ids": ReadonlyArray + readonly "filters"?: + | { + readonly "key": string + readonly "type": "eq" | "ne" | "gt" | "gte" | "lt" | "lte" + readonly "value": string | number | boolean | ReadonlyArray + } + | CompoundFilter + | unknown + readonly "max_num_results"?: number + readonly "ranking_options"?: { + readonly "ranker"?: "auto" | "default-2024-11-15" + readonly "score_threshold"?: number + } +} +export const OpenResponsesFileSearchTool = Schema.Struct({ + "type": Schema.Literal("file_search"), + "vector_store_ids": Schema.Array(Schema.String), + "filters": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "key": Schema.String, + "type": Schema.Literals(["eq", "ne", "gt", "gte", "lt", "lte"]), + "value": Schema.Union([ + Schema.String, + Schema.Number.check(Schema.isFinite()), + Schema.Boolean, + Schema.Array(Schema.Union([Schema.String, Schema.Number.check(Schema.isFinite())])) + ]) + }), + CompoundFilter, + Schema.Unknown + ])), + "max_num_results": Schema.optionalKey( + Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(50)) + ), + "ranking_options": Schema.optionalKey( + Schema.Struct({ + "ranker": Schema.optionalKey(Schema.Literals(["auto", "default-2024-11-15"])), + "score_threshold": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) + }) + ) +}).annotate({ "description": "File search tool configuration" }) export type OpenAIResponsesReasoningConfig = { readonly "effort"?: OpenAIResponsesReasoningEffort readonly "summary"?: ReasoningSummaryVerbosity @@ -3178,24 +4552,17 @@ export const OpenResponsesReasoningConfig = Schema.Struct({ "max_tokens": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), "enabled": Schema.optionalKey(Schema.Boolean) }).annotate({ "description": "Configuration for reasoning mode in the response" }) -export type ResponseFormatTextConfig = - | ResponsesFormatText - | ResponsesFormatJSONObject - | ResponsesFormatTextJSONSchemaConfig -export const ResponseFormatTextConfig = Schema.Union([ - ResponsesFormatText, - ResponsesFormatJSONObject, - ResponsesFormatTextJSONSchemaConfig -]).annotate({ "description": "Text response format configuration" }) export type OpenResponsesLogProbs = { readonly "logprob": number readonly "token": string readonly "top_logprobs"?: ReadonlyArray + readonly "bytes"?: ReadonlyArray } export const OpenResponsesLogProbs = Schema.Struct({ "logprob": Schema.Number.check(Schema.isFinite()), "token": Schema.String, - "top_logprobs": Schema.optionalKey(Schema.Array(OpenResponsesTopLogprobs)) + "top_logprobs": Schema.optionalKey(Schema.Array(OpenResponsesTopLogprobs)), + "bytes": Schema.optionalKey(Schema.Array(Schema.Number.check(Schema.isFinite()))) }).annotate({ "description": "Log probability information for a token" }) export type BadRequestResponse = { readonly "error": BadRequestResponseErrorData; readonly "user_id"?: string } export const BadRequestResponse = Schema.Struct({ @@ -3286,7 +4653,7 @@ export const ProviderOverloadedResponse = Schema.Struct({ export type OpenResponsesEasyInputMessage = { readonly "type"?: "message" readonly "role": "user" | "system" | "assistant" | "developer" - readonly "content": + readonly "content"?: | ReadonlyArray< | ResponseInputText | { readonly "type": "input_image"; readonly "detail": "auto" | "high" | "low"; readonly "image_url"?: string } @@ -3295,32 +4662,43 @@ export type OpenResponsesEasyInputMessage = { | ResponseInputVideo > | string + | unknown + readonly "phase"?: "commentary" | "final_answer" | unknown } export const OpenResponsesEasyInputMessage = Schema.Struct({ "type": Schema.optionalKey(Schema.Literal("message")), "role": Schema.Literals(["user", "system", "assistant", "developer"]), - "content": Schema.Union([ - Schema.Array( - Schema.Union([ - ResponseInputText, - Schema.Struct({ - "type": Schema.Literal("input_image"), - "detail": Schema.Literals(["auto", "high", "low"]), - "image_url": Schema.optionalKey(Schema.String) - }).annotate({ "description": "Image input content item" }), - ResponseInputFile, - ResponseInputAudio, - ResponseInputVideo - ], { mode: "oneOf" }) - ), - Schema.String - ]) + "content": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Union([ + ResponseInputText, + Schema.Struct({ + "type": Schema.Literal("input_image"), + "detail": Schema.Literals(["auto", "high", "low"]), + "image_url": Schema.optionalKey(Schema.String) + }).annotate({ "description": "Image input content item" }), + ResponseInputFile, + ResponseInputAudio, + ResponseInputVideo + ], { mode: "oneOf" }) + ), + Schema.String, + Schema.Unknown + ]) + ), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) }) export type OpenResponsesInputMessageItem = { readonly "id"?: string readonly "type"?: "message" readonly "role": "user" | "system" | "developer" - readonly "content": ReadonlyArray< + readonly "content"?: ReadonlyArray< | ResponseInputText | { readonly "type": "input_image"; readonly "detail": "auto" | "high" | "low"; readonly "image_url"?: string } | ResponseInputFile @@ -3332,25 +4710,22 @@ export const OpenResponsesInputMessageItem = Schema.Struct({ "id": Schema.optionalKey(Schema.String), "type": Schema.optionalKey(Schema.Literal("message")), "role": Schema.Literals(["user", "system", "developer"]), - "content": Schema.Array( - Schema.Union([ - ResponseInputText, - Schema.Struct({ - "type": Schema.Literal("input_image"), - "detail": Schema.Literals(["auto", "high", "low"]), - "image_url": Schema.optionalKey(Schema.String) - }).annotate({ "description": "Image input content item" }), - ResponseInputFile, - ResponseInputAudio, - ResponseInputVideo - ], { mode: "oneOf" }) + "content": Schema.optionalKey( + Schema.Array( + Schema.Union([ + ResponseInputText, + Schema.Struct({ + "type": Schema.Literal("input_image"), + "detail": Schema.Literals(["auto", "high", "low"]), + "image_url": Schema.optionalKey(Schema.String) + }).annotate({ "description": "Image input content item" }), + ResponseInputFile, + ResponseInputAudio, + ResponseInputVideo + ], { mode: "oneOf" }) + ) ) }) -export type ProviderSortConfig = { readonly "by"?: ProviderSort | null; readonly "partition"?: "model" | "none" | null } -export const ProviderSortConfig = Schema.Struct({ - "by": Schema.optionalKey(Schema.Union([ProviderSort, Schema.Null])), - "partition": Schema.optionalKey(Schema.Union([Schema.Literals(["model", "none"]), Schema.Null])) -}) export type PreferredMinThroughput = number | PercentileThroughputCutoffs | unknown export const PreferredMinThroughput = Schema.Union([ Schema.Number.check(Schema.isFinite()), @@ -3373,485 +4748,32 @@ export type PDFParserOptions = { readonly "engine"?: PDFParserEngine } export const PDFParserOptions = Schema.Struct({ "engine": Schema.optionalKey(PDFParserEngine) }).annotate({ "description": "Options for PDF parsing." }) -export type ForbiddenResponse = { readonly "error": ForbiddenResponseErrorData; readonly "user_id"?: string } -export const ForbiddenResponse = Schema.Struct({ - "error": ForbiddenResponseErrorData, - "user_id": Schema.optionalKey(Schema.String) -}).annotate({ "description": "Forbidden - Authentication successful but insufficient permissions" }) -export type ModelArchitecture = { - readonly "tokenizer"?: ModelGroup - readonly "instruct_type"?: - | "none" - | "airoboros" - | "alpaca" - | "alpaca-modif" - | "chatml" - | "claude" - | "code-llama" - | "gemma" - | "llama2" - | "llama3" - | "mistral" - | "nemotron" - | "neural" - | "openchat" - | "phi3" - | "rwkv" - | "vicuna" - | "zephyr" - | "deepseek-r1" - | "deepseek-v3.1" - | "qwq" - | "qwen3" - readonly "modality": string - readonly "input_modalities": ReadonlyArray - readonly "output_modalities": ReadonlyArray -} -export const ModelArchitecture = Schema.Struct({ - "tokenizer": Schema.optionalKey(ModelGroup), - "instruct_type": Schema.optionalKey( - Schema.Literals([ - "none", - "airoboros", - "alpaca", - "alpaca-modif", - "chatml", - "claude", - "code-llama", - "gemma", - "llama2", - "llama3", - "mistral", - "nemotron", - "neural", - "openchat", - "phi3", - "rwkv", - "vicuna", - "zephyr", - "deepseek-r1", - "deepseek-v3.1", - "qwq", - "qwen3" - ]).annotate({ "description": "Instruction format type" }) - ), - "modality": Schema.String.annotate({ "description": "Primary modality of the model" }), - "input_modalities": Schema.Array(InputModality).annotate({ "description": "Supported input modalities" }), - "output_modalities": Schema.Array(OutputModality).annotate({ "description": "Supported output modalities" }) -}).annotate({ "description": "Model architecture information" }) -export type PublicEndpoint = { - readonly "name": string - readonly "model_id": string - readonly "model_name": string - readonly "context_length": number - readonly "pricing": { - readonly "prompt": string - readonly "completion": string - readonly "request"?: string - readonly "image"?: string - readonly "image_token"?: string - readonly "image_output"?: string - readonly "audio"?: string - readonly "audio_output"?: string - readonly "input_audio_cache"?: string - readonly "web_search"?: string - readonly "internal_reasoning"?: string - readonly "input_cache_read"?: string - readonly "input_cache_write"?: string - readonly "discount"?: number - } - readonly "provider_name": ProviderName - readonly "tag": string - readonly "quantization": "int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown" - readonly "max_completion_tokens": number - readonly "max_prompt_tokens": number - readonly "supported_parameters": ReadonlyArray - readonly "status"?: EndpointStatus - readonly "uptime_last_30m": number - readonly "supports_implicit_caching": boolean - readonly "latency_last_30m": PercentileStats - readonly "throughput_last_30m": { - readonly "p50": number - readonly "p75": number - readonly "p90": number - readonly "p99": number +export type AnthropicMessagesStreamEvent = + | AnthropicMessagesMessageStartEvent + | { + readonly "type": "message_delta" + readonly "delta": { + readonly "container": { readonly "id": string; readonly "expires_at": string } + readonly "stop_reason": "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "pause_turn" | "refusal" + readonly "stop_sequence": string + } + readonly "usage": { + readonly "input_tokens": number + readonly "output_tokens": number + readonly "cache_creation_input_tokens": number + readonly "cache_read_input_tokens": number + readonly "server_tool_use": { readonly "web_search_requests": number; readonly "web_fetch_requests": number } + } } -} -export const PublicEndpoint = Schema.Struct({ - "name": Schema.String, - "model_id": Schema.String.annotate({ "description": "The unique identifier for the model (permaslug)" }), - "model_name": Schema.String, - "context_length": Schema.Number.check(Schema.isFinite()), - "pricing": Schema.Struct({ - "prompt": Schema.String.annotate({ "description": "A number or string value representing a large number" }), - "completion": Schema.String.annotate({ "description": "A number or string value representing a large number" }), - "request": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "image": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "image_token": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "image_output": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "audio": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "audio_output": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "input_audio_cache": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "web_search": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "internal_reasoning": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "input_cache_read": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "input_cache_write": Schema.optionalKey( - Schema.String.annotate({ "description": "A number or string value representing a large number" }) - ), - "discount": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) - }), - "provider_name": ProviderName, - "tag": Schema.String, - "quantization": Schema.Literals(["int4", "int8", "fp4", "fp6", "fp8", "fp16", "bf16", "fp32", "unknown"]), - "max_completion_tokens": Schema.Number.check(Schema.isFinite()), - "max_prompt_tokens": Schema.Number.check(Schema.isFinite()), - "supported_parameters": Schema.Array(Parameter), - "status": Schema.optionalKey(EndpointStatus), - "uptime_last_30m": Schema.Number.check(Schema.isFinite()), - "supports_implicit_caching": Schema.Boolean, - "latency_last_30m": PercentileStats, - "throughput_last_30m": Schema.Struct({ - "p50": Schema.Number.annotate({ "description": "Median (50th percentile)" }).check(Schema.isFinite()), - "p75": Schema.Number.annotate({ "description": "75th percentile" }).check(Schema.isFinite()), - "p90": Schema.Number.annotate({ "description": "90th percentile" }).check(Schema.isFinite()), - "p99": Schema.Number.annotate({ "description": "99th percentile" }).check(Schema.isFinite()) - }).annotate({ - "description": - "Throughput percentiles in tokens per second over the last 30 minutes. Throughput measures output token generation speed. Only visible when authenticated with an API key or cookie; returns null for unauthenticated requests." - }) -}).annotate({ "description": "Information about a specific model endpoint" }) -export type __schema20 = { - readonly "type": "reasoning.summary" - readonly "summary": string - readonly "id"?: __schema21 - readonly "format"?: __schema22 - readonly "index"?: __schema11 -} | { - readonly "type": "reasoning.encrypted" - readonly "data": string - readonly "id"?: __schema21 - readonly "format"?: __schema22 - readonly "index"?: __schema11 -} | { - readonly "type": "reasoning.text" - readonly "text"?: string | null - readonly "signature"?: string | null - readonly "id"?: __schema21 - readonly "format"?: __schema22 - readonly "index"?: __schema11 -} -export const __schema20 = Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("reasoning.summary"), - "summary": Schema.String, - "id": Schema.optionalKey(__schema21), - "format": Schema.optionalKey(__schema22), - "index": Schema.optionalKey(__schema11) - }), - Schema.Struct({ - "type": Schema.Literal("reasoning.encrypted"), - "data": Schema.String, - "id": Schema.optionalKey(__schema21), - "format": Schema.optionalKey(__schema22), - "index": Schema.optionalKey(__schema11) - }), - Schema.Struct({ - "type": Schema.Literal("reasoning.text"), - "text": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "signature": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "id": Schema.optionalKey(__schema21), - "format": Schema.optionalKey(__schema22), - "index": Schema.optionalKey(__schema11) - }) -], { mode: "oneOf" }) -export type __schema14 = __schema11 | ModelName | __schema13 -export const __schema14 = Schema.Union([__schema11, ModelName, __schema13]) -export type ChatMessageTokenLogprobs = { - readonly "content": ReadonlyArray | null - readonly "refusal": ReadonlyArray | null -} -export const ChatMessageTokenLogprobs = Schema.Struct({ - "content": Schema.Union([Schema.Array(ChatMessageTokenLogprob), Schema.Null]), - "refusal": Schema.Union([Schema.Array(ChatMessageTokenLogprob), Schema.Null]) -}) -export type __schema26 = ChatCompletionFinishReason | null -export const __schema26 = Schema.Union([ChatCompletionFinishReason, Schema.Null]) -export type ResponseFormatJSONSchema = { readonly "type": "json_schema"; readonly "json_schema": JSONSchemaConfig } -export const ResponseFormatJSONSchema = Schema.Struct({ - "type": Schema.Literal("json_schema"), - "json_schema": JSONSchemaConfig -}) -export type ChatMessageContentItemText = { - readonly "type": "text" - readonly "text": string - readonly "cache_control"?: ChatMessageContentItemCacheControl -} -export const ChatMessageContentItemText = Schema.Struct({ - "type": Schema.Literal("text"), - "text": Schema.String, - "cache_control": Schema.optionalKey(ChatMessageContentItemCacheControl) -}) -export type ToolDefinitionJson = { - readonly "type": "function" - readonly "function": { - readonly "name": string - readonly "description"?: string - readonly "parameters"?: {} - readonly "strict"?: boolean | null - } - readonly "cache_control"?: ChatMessageContentItemCacheControl -} -export const ToolDefinitionJson = Schema.Struct({ - "type": Schema.Literal("function"), - "function": Schema.Struct({ - "name": Schema.String.check(Schema.isMaxLength(64)), - "description": Schema.optionalKey(Schema.String), - "parameters": Schema.optionalKey(Schema.Struct({}).check(Schema.isPropertyNames(Schema.String))), - "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])) - }), - "cache_control": Schema.optionalKey(ChatMessageContentItemCacheControl) -}) -export type ToolChoiceOption = "none" | "auto" | "required" | NamedToolChoice -export const ToolChoiceOption = Schema.Union([ - Schema.Literal("none"), - Schema.Literal("auto"), - Schema.Literal("required"), - NamedToolChoice -]) -export type ResponseOutputText = { - readonly "type": "output_text" - readonly "text": string - readonly "annotations"?: ReadonlyArray - readonly "logprobs"?: ReadonlyArray< - { - readonly "token": string - readonly "bytes": ReadonlyArray - readonly "logprob": number - readonly "top_logprobs": ReadonlyArray< - { readonly "token": string; readonly "bytes": ReadonlyArray; readonly "logprob": number } - > - } - > -} -export const ResponseOutputText = Schema.Struct({ - "type": Schema.Literal("output_text"), - "text": Schema.String, - "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), - "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ - "token": Schema.String, - "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), - "logprob": Schema.Number.check(Schema.isFinite()), - "top_logprobs": Schema.Array( - Schema.Struct({ - "token": Schema.String, - "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), - "logprob": Schema.Number.check(Schema.isFinite()) - }) - ) - }))) -}) -export type OpenResponsesOutputTextAnnotationAddedEvent = { - readonly "type": "response.output_text.annotation.added" - readonly "output_index": number - readonly "item_id": string - readonly "content_index": number - readonly "sequence_number": number - readonly "annotation_index": number - readonly "annotation": OpenAIResponsesAnnotation -} -export const OpenResponsesOutputTextAnnotationAddedEvent = Schema.Struct({ - "type": Schema.Literal("response.output_text.annotation.added"), - "output_index": Schema.Number.check(Schema.isFinite()), - "item_id": Schema.String, - "content_index": Schema.Number.check(Schema.isFinite()), - "sequence_number": Schema.Number.check(Schema.isFinite()), - "annotation_index": Schema.Number.check(Schema.isFinite()), - "annotation": OpenAIResponsesAnnotation -}).annotate({ "description": "Event emitted when a text annotation is added to output" }) -export type ResponseTextConfig = { - readonly "format"?: ResponseFormatTextConfig - readonly "verbosity"?: "high" | "low" | "medium" -} -export const ResponseTextConfig = Schema.Struct({ - "format": Schema.optionalKey(ResponseFormatTextConfig), - "verbosity": Schema.optionalKey(Schema.Literals(["high", "low", "medium"])) -}).annotate({ "description": "Text output configuration including format and verbosity" }) -export type OpenResponsesResponseText = { - readonly "format"?: ResponseFormatTextConfig - readonly "verbosity"?: "high" | "low" | "medium" -} -export const OpenResponsesResponseText = Schema.Struct({ - "format": Schema.optionalKey(ResponseFormatTextConfig), - "verbosity": Schema.optionalKey(Schema.Literals(["high", "low", "medium"])) -}).annotate({ "description": "Text output configuration including format and verbosity" }) -export type OpenResponsesTextDeltaEvent = { - readonly "type": "response.output_text.delta" - readonly "logprobs": ReadonlyArray - readonly "output_index": number - readonly "item_id": string - readonly "content_index": number - readonly "delta": string - readonly "sequence_number": number -} -export const OpenResponsesTextDeltaEvent = Schema.Struct({ - "type": Schema.Literal("response.output_text.delta"), - "logprobs": Schema.Array(OpenResponsesLogProbs), - "output_index": Schema.Number.check(Schema.isFinite()), - "item_id": Schema.String, - "content_index": Schema.Number.check(Schema.isFinite()), - "delta": Schema.String, - "sequence_number": Schema.Number.check(Schema.isFinite()) -}).annotate({ "description": "Event emitted when a text delta is streamed" }) -export type OpenResponsesTextDoneEvent = { - readonly "type": "response.output_text.done" - readonly "output_index": number - readonly "item_id": string - readonly "content_index": number - readonly "text": string - readonly "sequence_number": number - readonly "logprobs": ReadonlyArray -} -export const OpenResponsesTextDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.output_text.done"), - "output_index": Schema.Number.check(Schema.isFinite()), - "item_id": Schema.String, - "content_index": Schema.Number.check(Schema.isFinite()), - "text": Schema.String, - "sequence_number": Schema.Number.check(Schema.isFinite()), - "logprobs": Schema.Array(OpenResponsesLogProbs) -}).annotate({ "description": "Event emitted when text streaming is complete" }) -export type ProviderSortUnion = ProviderSort | ProviderSortConfig -export const ProviderSortUnion = Schema.Union([ProviderSort, ProviderSortConfig]) -export type ProviderPreferences = { - readonly "allow_fallbacks"?: boolean - readonly "require_parameters"?: boolean - readonly "data_collection"?: DataCollection - readonly "zdr"?: boolean - readonly "enforce_distillable_text"?: boolean - readonly "order"?: ReadonlyArray - readonly "only"?: ReadonlyArray - readonly "ignore"?: ReadonlyArray - readonly "quantizations"?: ReadonlyArray - readonly "sort"?: "price" | "price" | "throughput" | "throughput" | "latency" | "latency" - readonly "max_price"?: { - readonly "prompt"?: BigNumberUnion - readonly "completion"?: string - readonly "image"?: string - readonly "audio"?: string - readonly "request"?: string - } - readonly "preferred_min_throughput"?: PreferredMinThroughput - readonly "preferred_max_latency"?: PreferredMaxLatency -} -export const ProviderPreferences = Schema.Struct({ - "allow_fallbacks": Schema.optionalKey(Schema.Boolean.annotate({ - "description": - "Whether to allow backup providers to serve requests\n- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.\n- false: use only the primary/custom provider, and return the upstream error if it's unavailable.\n" - })), - "require_parameters": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest." - }) - ), - "data_collection": Schema.optionalKey(DataCollection), - "zdr": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used." - }) - ), - "enforce_distillable_text": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used." - }) - ), - "order": Schema.optionalKey( - Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ - "description": - "An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message." - }) - ), - "only": Schema.optionalKey( - Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ - "description": - "List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request." - }) - ), - "ignore": Schema.optionalKey( - Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ - "description": - "List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request." - }) - ), - "quantizations": Schema.optionalKey( - Schema.Array(Quantization).annotate({ "description": "A list of quantization levels to filter the provider by." }) - ), - "sort": Schema.optionalKey( - Schema.Union([ - Schema.Union([Schema.Literal("price"), Schema.Literal("price")]).annotate({ - "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." - }), - Schema.Union([Schema.Literal("throughput"), Schema.Literal("throughput")]).annotate({ - "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." - }), - Schema.Union([Schema.Literal("latency"), Schema.Literal("latency")]).annotate({ - "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." - }) - ]) - ), - "max_price": Schema.optionalKey( - Schema.Struct({ - "prompt": Schema.optionalKey(BigNumberUnion), - "completion": Schema.optionalKey( - Schema.String.annotate({ "description": "Price per million completion tokens" }) - ), - "image": Schema.optionalKey(Schema.String.annotate({ "description": "Price per image" })), - "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Price per audio unit" })), - "request": Schema.optionalKey(Schema.String.annotate({ "description": "Price per request" })) - }).annotate({ - "description": - "The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion." - }) - ), - "preferred_min_throughput": Schema.optionalKey(PreferredMinThroughput), - "preferred_max_latency": Schema.optionalKey(PreferredMaxLatency) -}).annotate({ "description": "Provider routing preferences for the request." }) -export type AnthropicMessagesRequest = { - readonly "model": string - readonly "max_tokens": number - readonly "messages": ReadonlyArray - readonly "system"?: - | string - | ReadonlyArray< - { + | { readonly "type": "message_stop" } + | { + readonly "type": "content_block_start" + readonly "index": number + readonly "content_block": + | { readonly "type": "text" readonly "text": string - readonly "citations"?: ReadonlyArray< + readonly "citations": ReadonlyArray< { readonly "type": "char_location" readonly "cited_text": string @@ -3859,6 +4781,7 @@ export type AnthropicMessagesRequest = { readonly "document_title": string readonly "start_char_index": number readonly "end_char_index": number + readonly "file_id": string } | { readonly "type": "page_location" readonly "cited_text": string @@ -3866,6 +4789,7 @@ export type AnthropicMessagesRequest = { readonly "document_title": string readonly "start_page_number": number readonly "end_page_number": number + readonly "file_id": string } | { readonly "type": "content_block_location" readonly "cited_text": string @@ -3873,6 +4797,7 @@ export type AnthropicMessagesRequest = { readonly "document_title": string readonly "start_block_index": number readonly "end_block_index": number + readonly "file_id": string } | { readonly "type": "web_search_result_location" readonly "cited_text": string @@ -3889,1071 +4814,2947 @@ export type AnthropicMessagesRequest = { readonly "end_block_index": number } > - readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } } - > - readonly "metadata"?: { readonly "user_id"?: string } - readonly "stop_sequences"?: ReadonlyArray - readonly "stream"?: boolean - readonly "temperature"?: number - readonly "top_p"?: number - readonly "top_k"?: number - readonly "tools"?: ReadonlyArray< - { - readonly "name": string - readonly "description"?: string - readonly "input_schema": { - readonly "type": "object" - readonly "properties"?: unknown - readonly "required"?: ReadonlyArray + | { + readonly "type": "tool_use" + readonly "id": string + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "name": string + readonly "input"?: unknown } - readonly "type"?: "custom" - readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } - } | { - readonly "type": "bash_20250124" - readonly "name": "bash" - readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } - } | { - readonly "type": "text_editor_20250124" - readonly "name": "str_replace_editor" - readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } - } | { - readonly "type": "web_search_20250305" - readonly "name": "web_search" - readonly "allowed_domains"?: ReadonlyArray - readonly "blocked_domains"?: ReadonlyArray - readonly "max_uses"?: number - readonly "user_location"?: { - readonly "type": "approximate" - readonly "city"?: string - readonly "country"?: string - readonly "region"?: string - readonly "timezone"?: string + | { readonly "type": "thinking"; readonly "thinking": string; readonly "signature": string } + | { readonly "type": "redacted_thinking"; readonly "data": string } + | { + readonly "type": "server_tool_use" + readonly "id": string + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "name": + | "web_search" + | "web_fetch" + | "code_execution" + | "bash_code_execution" + | "text_editor_code_execution" + | "tool_search_tool_regex" + | "tool_search_tool_bm25" + readonly "input"?: unknown } - readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } - } - > - readonly "tool_choice"?: - | { readonly "type": "auto"; readonly "disable_parallel_tool_use"?: boolean } - | { readonly "type": "any"; readonly "disable_parallel_tool_use"?: boolean } - | { readonly "type": "none" } - | { readonly "type": "tool"; readonly "name": string; readonly "disable_parallel_tool_use"?: boolean } - readonly "thinking"?: { readonly "type": "enabled"; readonly "budget_tokens": number } | { - readonly "type": "disabled" - } | { readonly "type": "adaptive" } - readonly "service_tier"?: "auto" | "standard_only" - readonly "provider"?: { - readonly "allow_fallbacks"?: boolean - readonly "require_parameters"?: boolean - readonly "data_collection"?: DataCollection - readonly "zdr"?: boolean - readonly "enforce_distillable_text"?: boolean - readonly "order"?: ReadonlyArray - readonly "only"?: ReadonlyArray - readonly "ignore"?: ReadonlyArray - readonly "quantizations"?: ReadonlyArray - readonly "sort"?: "price" | "price" | "throughput" | "throughput" | "latency" | "latency" - readonly "max_price"?: { - readonly "prompt"?: BigNumberUnion - readonly "completion"?: string - readonly "image"?: string - readonly "audio"?: string - readonly "request"?: string - } - readonly "preferred_min_throughput"?: PreferredMinThroughput - readonly "preferred_max_latency"?: PreferredMaxLatency + | { + readonly "type": "web_search_tool_result" + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "tool_use_id": string + readonly "content": + | ReadonlyArray< + { + readonly "type": "web_search_result" + readonly "encrypted_content": string + readonly "page_age": string + readonly "title": string + readonly "url": string + } + > + | { + readonly "type": "web_search_tool_result_error" + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "max_uses_exceeded" + | "too_many_requests" + | "query_too_long" + | "request_too_large" + } + } + | { + readonly "type": "web_fetch_tool_result" + readonly "caller": { readonly "type": "direct" } | { + readonly "type": "code_execution_20250825" + readonly "tool_id": string + } | { readonly "type": "code_execution_20260120"; readonly "tool_id": string } + readonly "content": { + readonly "type": "web_fetch_tool_result_error" + readonly "error_code": + | "invalid_tool_input" + | "url_too_long" + | "url_not_allowed" + | "url_not_accessible" + | "unsupported_content_type" + | "too_many_requests" + | "max_uses_exceeded" + | "unavailable" + } | { + readonly "content": { + readonly "citations": { readonly "enabled": boolean } + readonly "source": { + readonly "data": string + readonly "media_type": "application/pdf" + readonly "type": "base64" + } | { readonly "data": string; readonly "media_type": "text/plain"; readonly "type": "text" } + readonly "title": string + readonly "type": "document" + } + readonly "retrieved_at": string + readonly "type": "web_fetch_result" + readonly "url": string + } + readonly "tool_use_id": string + } + | { + readonly "type": "code_execution_tool_result" + readonly "content": { + readonly "error_code": "invalid_tool_input" | "unavailable" | "too_many_requests" | "execution_time_exceeded" + readonly "type": "code_execution_tool_result_error" + } | { + readonly "content": ReadonlyArray<{ readonly "file_id": string; readonly "type": "code_execution_output" }> + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "code_execution_result" + } | { + readonly "content": ReadonlyArray<{ readonly "file_id": string; readonly "type": "code_execution_output" }> + readonly "encrypted_stdout": string + readonly "return_code": number + readonly "stderr": string + readonly "type": "encrypted_code_execution_result" + } + readonly "tool_use_id": string + } + | { + readonly "type": "bash_code_execution_tool_result" + readonly "content": { + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" + | "output_file_too_large" + readonly "type": "bash_code_execution_tool_result_error" + } | { + readonly "content": ReadonlyArray< + { readonly "file_id": string; readonly "type": "bash_code_execution_output" } + > + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "bash_code_execution_result" + } + readonly "tool_use_id": string + } + | { + readonly "type": "text_editor_code_execution_tool_result" + readonly "content": + | { + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" + | "file_not_found" + readonly "error_message": string + readonly "type": "text_editor_code_execution_tool_result_error" + } + | { + readonly "content": string + readonly "file_type": "text" | "image" | "pdf" + readonly "num_lines": number + readonly "start_line": number + readonly "total_lines": number + readonly "type": "text_editor_code_execution_view_result" + } + | { readonly "is_file_update": boolean; readonly "type": "text_editor_code_execution_create_result" } + | { + readonly "lines": ReadonlyArray + readonly "new_lines": number + readonly "new_start": number + readonly "old_lines": number + readonly "old_start": number + readonly "type": "text_editor_code_execution_str_replace_result" + } + readonly "tool_use_id": string + } + | { + readonly "type": "tool_search_tool_result" + readonly "content": { + readonly "error_code": "invalid_tool_input" | "unavailable" | "too_many_requests" | "execution_time_exceeded" + readonly "error_message": string + readonly "type": "tool_search_tool_result_error" + } | { + readonly "tool_references": ReadonlyArray<{ readonly "tool_name": string; readonly "type": "tool_reference" }> + readonly "type": "tool_search_tool_search_result" + } + readonly "tool_use_id": string + } + | { readonly "type": "container_upload"; readonly "file_id": string } } - readonly "plugins"?: ReadonlyArray< - | { readonly "id": "auto-router"; readonly "enabled"?: boolean; readonly "allowed_models"?: ReadonlyArray } - | { readonly "id": "moderation" } - | { - readonly "id": "web" - readonly "enabled"?: boolean - readonly "max_results"?: number - readonly "search_prompt"?: string - readonly "engine"?: WebSearchEngine - } - | { readonly "id": "file-parser"; readonly "enabled"?: boolean; readonly "pdf"?: PDFParserOptions } - | { readonly "id": "response-healing"; readonly "enabled"?: boolean } - > - readonly "route"?: "fallback" | "sort" - readonly "user"?: string - readonly "session_id"?: string - readonly "trace"?: { - readonly "trace_id"?: string - readonly "trace_name"?: string - readonly "span_name"?: string - readonly "generation_name"?: string - readonly "parent_span_id"?: string + | { + readonly "type": "content_block_delta" + readonly "index": number + readonly "delta": + | { readonly "type": "text_delta"; readonly "text": string } + | { readonly "type": "input_json_delta"; readonly "partial_json": string } + | { readonly "type": "thinking_delta"; readonly "thinking": string } + | { readonly "type": "signature_delta"; readonly "signature": string } + | { + readonly "type": "citations_delta" + readonly "citation": { + readonly "type": "char_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_char_index": number + readonly "end_char_index": number + readonly "file_id": string + } | { + readonly "type": "page_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_page_number": number + readonly "end_page_number": number + readonly "file_id": string + } | { + readonly "type": "content_block_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_block_index": number + readonly "end_block_index": number + readonly "file_id": string + } | { + readonly "type": "web_search_result_location" + readonly "cited_text": string + readonly "encrypted_index": string + readonly "title": string + readonly "url": string + } | { + readonly "type": "search_result_location" + readonly "cited_text": string + readonly "search_result_index": number + readonly "source": string + readonly "title": string + readonly "start_block_index": number + readonly "end_block_index": number + } + } } - readonly "models"?: ReadonlyArray - readonly "output_config"?: AnthropicOutputConfig -} -export const AnthropicMessagesRequest = Schema.Struct({ - "model": Schema.String, - "max_tokens": Schema.Number.check(Schema.isFinite()), - "messages": Schema.Array(OpenRouterAnthropicMessageParam), - "system": Schema.optionalKey(Schema.Union([ - Schema.String, - Schema.Array(Schema.Struct({ - "type": Schema.Literal("text"), - "text": Schema.String, - "citations": Schema.optionalKey(Schema.Array(Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("char_location"), - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isFinite()), - "document_title": Schema.String, - "start_char_index": Schema.Number.check(Schema.isFinite()), - "end_char_index": Schema.Number.check(Schema.isFinite()) - }), - Schema.Struct({ - "type": Schema.Literal("page_location"), - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isFinite()), - "document_title": Schema.String, - "start_page_number": Schema.Number.check(Schema.isFinite()), - "end_page_number": Schema.Number.check(Schema.isFinite()) - }), - Schema.Struct({ - "type": Schema.Literal("content_block_location"), - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isFinite()), - "document_title": Schema.String, - "start_block_index": Schema.Number.check(Schema.isFinite()), - "end_block_index": Schema.Number.check(Schema.isFinite()) - }), - Schema.Struct({ - "type": Schema.Literal("web_search_result_location"), - "cited_text": Schema.String, - "encrypted_index": Schema.String, - "title": Schema.String, - "url": Schema.String - }), - Schema.Struct({ - "type": Schema.Literal("search_result_location"), - "cited_text": Schema.String, - "search_result_index": Schema.Number.check(Schema.isFinite()), - "source": Schema.String, - "title": Schema.String, - "start_block_index": Schema.Number.check(Schema.isFinite()), - "end_block_index": Schema.Number.check(Schema.isFinite()) - }) - ], { mode: "oneOf" }))), - "cache_control": Schema.optionalKey( - Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) - ) - })) - ])), - "metadata": Schema.optionalKey(Schema.Struct({ "user_id": Schema.optionalKey(Schema.String) })), - "stop_sequences": Schema.optionalKey(Schema.Array(Schema.String)), - "stream": Schema.optionalKey(Schema.Boolean), - "temperature": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "top_p": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "top_k": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "tools": Schema.optionalKey(Schema.Array(Schema.Union([ - Schema.Struct({ - "name": Schema.String, - "description": Schema.optionalKey(Schema.String), - "input_schema": Schema.Struct({ - "type": Schema.Literal("object"), - "properties": Schema.optionalKey(Schema.Unknown), - "required": Schema.optionalKey(Schema.Array(Schema.String)) - }), - "type": Schema.optionalKey(Schema.Literal("custom")), - "cache_control": Schema.optionalKey( - Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) - ) - }), - Schema.Struct({ - "type": Schema.Literal("bash_20250124"), - "name": Schema.Literal("bash"), - "cache_control": Schema.optionalKey( - Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) - ) - }), - Schema.Struct({ - "type": Schema.Literal("text_editor_20250124"), - "name": Schema.Literal("str_replace_editor"), - "cache_control": Schema.optionalKey( - Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) - ) + | { readonly "type": "content_block_stop"; readonly "index": number } + | { readonly "type": "ping" } + | { readonly "type": "error"; readonly "error": { readonly "type": string; readonly "message": string } } +export const AnthropicMessagesStreamEvent = Schema.Union([ + AnthropicMessagesMessageStartEvent, + Schema.Struct({ + "type": Schema.Literal("message_delta"), + "delta": Schema.Struct({ + "container": Schema.Struct({ "id": Schema.String, "expires_at": Schema.String }), + "stop_reason": Schema.Literals(["end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", "refusal"]), + "stop_sequence": Schema.String }), - Schema.Struct({ - "type": Schema.Literal("web_search_20250305"), - "name": Schema.Literal("web_search"), - "allowed_domains": Schema.optionalKey(Schema.Array(Schema.String)), - "blocked_domains": Schema.optionalKey(Schema.Array(Schema.String)), - "max_uses": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "user_location": Schema.optionalKey( - Schema.Struct({ - "type": Schema.Literal("approximate"), - "city": Schema.optionalKey(Schema.String), - "country": Schema.optionalKey(Schema.String), - "region": Schema.optionalKey(Schema.String), - "timezone": Schema.optionalKey(Schema.String) - }) - ), - "cache_control": Schema.optionalKey( - Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) - ) + "usage": Schema.Struct({ + "input_tokens": Schema.Number.check(Schema.isFinite()), + "output_tokens": Schema.Number.check(Schema.isFinite()), + "cache_creation_input_tokens": Schema.Number.check(Schema.isFinite()), + "cache_read_input_tokens": Schema.Number.check(Schema.isFinite()), + "server_tool_use": Schema.Struct({ + "web_search_requests": Schema.Number.check(Schema.isFinite()), + "web_fetch_requests": Schema.Number.check(Schema.isFinite()) + }) }) - ], { mode: "oneOf" }))), - "tool_choice": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("auto"), - "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean) - }), - Schema.Struct({ "type": Schema.Literal("any"), "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean) }), - Schema.Struct({ "type": Schema.Literal("none") }), + }), + Schema.Struct({ "type": Schema.Literal("message_stop") }), + Schema.Struct({ + "type": Schema.Literal("content_block_start"), + "index": Schema.Number.check(Schema.isFinite()), + "content_block": Schema.Union([ Schema.Struct({ - "type": Schema.Literal("tool"), - "name": Schema.String, - "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean) - }) - ], { mode: "oneOf" }) - ), - "thinking": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": Schema.Literal("enabled"), "budget_tokens": Schema.Number.check(Schema.isFinite()) }), - Schema.Struct({ "type": Schema.Literal("disabled") }), - Schema.Struct({ "type": Schema.Literal("adaptive") }) - ], { mode: "oneOf" }) - ), - "service_tier": Schema.optionalKey(Schema.Literals(["auto", "standard_only"])), - "provider": Schema.optionalKey( - Schema.Struct({ - "allow_fallbacks": Schema.optionalKey(Schema.Boolean.annotate({ - "description": - "Whether to allow backup providers to serve requests\n- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.\n- false: use only the primary/custom provider, and return the upstream error if it's unavailable.\n" - })), - "require_parameters": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest." - }) - ), - "data_collection": Schema.optionalKey(DataCollection), - "zdr": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used." - }) - ), - "enforce_distillable_text": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used." - }) - ), - "order": Schema.optionalKey( - Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ - "description": - "An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message." - }) - ), - "only": Schema.optionalKey( - Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ - "description": - "List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request." - }) - ), - "ignore": Schema.optionalKey( - Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ - "description": - "List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request." - }) - ), - "quantizations": Schema.optionalKey( - Schema.Array(Quantization).annotate({ - "description": "A list of quantization levels to filter the provider by." - }) - ), - "sort": Schema.optionalKey( - Schema.Union([ - Schema.Union([Schema.Literal("price"), Schema.Literal("price")]).annotate({ - "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + "type": Schema.Literal("text"), + "text": Schema.String, + "citations": Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("char_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_char_index": Schema.Number.check(Schema.isFinite()), + "end_char_index": Schema.Number.check(Schema.isFinite()), + "file_id": Schema.String }), - Schema.Union([Schema.Literal("throughput"), Schema.Literal("throughput")]).annotate({ - "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + Schema.Struct({ + "type": Schema.Literal("page_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_page_number": Schema.Number.check(Schema.isFinite()), + "end_page_number": Schema.Number.check(Schema.isFinite()), + "file_id": Schema.String }), - Schema.Union([Schema.Literal("latency"), Schema.Literal("latency")]).annotate({ - "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + Schema.Struct({ + "type": Schema.Literal("content_block_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()), + "file_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("web_search_result_location"), + "cited_text": Schema.String, + "encrypted_index": Schema.String, + "title": Schema.String, + "url": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("search_result_location"), + "cited_text": Schema.String, + "search_result_index": Schema.Number.check(Schema.isFinite()), + "source": Schema.String, + "title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()) }) - ]) - ), - "max_price": Schema.optionalKey( - Schema.Struct({ - "prompt": Schema.optionalKey(BigNumberUnion), - "completion": Schema.optionalKey( - Schema.String.annotate({ "description": "Price per million completion tokens" }) - ), - "image": Schema.optionalKey(Schema.String.annotate({ "description": "Price per image" })), - "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Price per audio unit" })), - "request": Schema.optionalKey(Schema.String.annotate({ "description": "Price per request" })) - }).annotate({ - "description": - "The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion." - }) - ), - "preferred_min_throughput": Schema.optionalKey(PreferredMinThroughput), - "preferred_max_latency": Schema.optionalKey(PreferredMaxLatency) - }).annotate({ - "description": "When multiple model providers are available, optionally indicate your routing preference." - }) - ), - "plugins": Schema.optionalKey( - Schema.Array(Schema.Union([ + ], { mode: "oneOf" })) + }), Schema.Struct({ - "id": Schema.Literal("auto-router"), - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the auto-router plugin for this request. Defaults to true." - }) - ), - "allowed_models": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list." - }) - ) + "type": Schema.Literal("tool_use"), + "id": Schema.String, + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), + "name": Schema.String, + "input": Schema.optionalKey(Schema.Unknown) }), - Schema.Struct({ "id": Schema.Literal("moderation") }), + Schema.Struct({ "type": Schema.Literal("thinking"), "thinking": Schema.String, "signature": Schema.String }), + Schema.Struct({ "type": Schema.Literal("redacted_thinking"), "data": Schema.String }), Schema.Struct({ - "id": Schema.Literal("web"), - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the web-search plugin for this request. Defaults to true." + "type": Schema.Literal("server_tool_use"), + "id": Schema.String, + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), + "name": Schema.Literals([ + "web_search", + "web_fetch", + "code_execution", + "bash_code_execution", + "text_editor_code_execution", + "tool_search_tool_regex", + "tool_search_tool_bm25" + ]), + "input": Schema.optionalKey(Schema.Unknown) + }), + Schema.Struct({ + "type": Schema.Literal("web_search_tool_result"), + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String, + "content": Schema.Union([ + Schema.Array( + Schema.Struct({ + "type": Schema.Literal("web_search_result"), + "encrypted_content": Schema.String, + "page_age": Schema.String, + "title": Schema.String, + "url": Schema.String + }) + ), + Schema.Struct({ + "type": Schema.Literal("web_search_tool_result_error"), + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "max_uses_exceeded", + "too_many_requests", + "query_too_long", + "request_too_large" + ]) }) - ), - "max_results": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "search_prompt": Schema.optionalKey(Schema.String), - "engine": Schema.optionalKey(WebSearchEngine) + ]) }), Schema.Struct({ - "id": Schema.Literal("file-parser"), - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the file-parser plugin for this request. Defaults to true." + "type": Schema.Literal("web_fetch_tool_result"), + "caller": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("direct") }), + Schema.Struct({ "type": Schema.Literal("code_execution_20250825"), "tool_id": Schema.String }), + Schema.Struct({ "type": Schema.Literal("code_execution_20260120"), "tool_id": Schema.String }) + ], { mode: "oneOf" }), + "content": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("web_fetch_tool_result_error"), + "error_code": Schema.Literals([ + "invalid_tool_input", + "url_too_long", + "url_not_allowed", + "url_not_accessible", + "unsupported_content_type", + "too_many_requests", + "max_uses_exceeded", + "unavailable" + ]) + }), + Schema.Struct({ + "content": Schema.Struct({ + "citations": Schema.Struct({ "enabled": Schema.Boolean }), + "source": Schema.Union([ + Schema.Struct({ + "data": Schema.String, + "media_type": Schema.Literal("application/pdf"), + "type": Schema.Literal("base64") + }), + Schema.Struct({ + "data": Schema.String, + "media_type": Schema.Literal("text/plain"), + "type": Schema.Literal("text") + }) + ]), + "title": Schema.String, + "type": Schema.Literal("document") + }), + "retrieved_at": Schema.String, + "type": Schema.Literal("web_fetch_result"), + "url": Schema.String }) - ), - "pdf": Schema.optionalKey(PDFParserOptions) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String }), Schema.Struct({ - "id": Schema.Literal("response-healing"), - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the response-healing plugin for this request. Defaults to true." + "type": Schema.Literal("code_execution_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" + ]), + "type": Schema.Literal("code_execution_tool_result_error") + }), + Schema.Struct({ + "content": Schema.Array( + Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("code_execution_output") }) + ), + "return_code": Schema.Number.check(Schema.isFinite()), + "stderr": Schema.String, + "stdout": Schema.String, + "type": Schema.Literal("code_execution_result") + }), + Schema.Struct({ + "content": Schema.Array( + Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("code_execution_output") }) + ), + "encrypted_stdout": Schema.String, + "return_code": Schema.Number.check(Schema.isFinite()), + "stderr": Schema.String, + "type": Schema.Literal("encrypted_code_execution_result") }) - ) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("bash_code_execution_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded", + "output_file_too_large" + ]), + "type": Schema.Literal("bash_code_execution_tool_result_error") + }), + Schema.Struct({ + "content": Schema.Array( + Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("bash_code_execution_output") }) + ), + "return_code": Schema.Number.check(Schema.isFinite()), + "stderr": Schema.String, + "stdout": Schema.String, + "type": Schema.Literal("bash_code_execution_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("text_editor_code_execution_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded", + "file_not_found" + ]), + "error_message": Schema.String, + "type": Schema.Literal("text_editor_code_execution_tool_result_error") + }), + Schema.Struct({ + "content": Schema.String, + "file_type": Schema.Literals(["text", "image", "pdf"]), + "num_lines": Schema.Number.check(Schema.isFinite()), + "start_line": Schema.Number.check(Schema.isFinite()), + "total_lines": Schema.Number.check(Schema.isFinite()), + "type": Schema.Literal("text_editor_code_execution_view_result") + }), + Schema.Struct({ + "is_file_update": Schema.Boolean, + "type": Schema.Literal("text_editor_code_execution_create_result") + }), + Schema.Struct({ + "lines": Schema.Array(Schema.String), + "new_lines": Schema.Number.check(Schema.isFinite()), + "new_start": Schema.Number.check(Schema.isFinite()), + "old_lines": Schema.Number.check(Schema.isFinite()), + "old_start": Schema.Number.check(Schema.isFinite()), + "type": Schema.Literal("text_editor_code_execution_str_replace_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("tool_search_tool_result"), + "content": Schema.Union([ + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" + ]), + "error_message": Schema.String, + "type": Schema.Literal("tool_search_tool_result_error") + }), + Schema.Struct({ + "tool_references": Schema.Array( + Schema.Struct({ "tool_name": Schema.String, "type": Schema.Literal("tool_reference") }) + ), + "type": Schema.Literal("tool_search_tool_search_result") + }) + ], { mode: "oneOf" }), + "tool_use_id": Schema.String + }), + Schema.Struct({ "type": Schema.Literal("container_upload"), "file_id": Schema.String }) + ], { mode: "oneOf" }) + }), + Schema.Struct({ + "type": Schema.Literal("content_block_delta"), + "index": Schema.Number.check(Schema.isFinite()), + "delta": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("text_delta"), "text": Schema.String }), + Schema.Struct({ "type": Schema.Literal("input_json_delta"), "partial_json": Schema.String }), + Schema.Struct({ "type": Schema.Literal("thinking_delta"), "thinking": Schema.String }), + Schema.Struct({ "type": Schema.Literal("signature_delta"), "signature": Schema.String }), + Schema.Struct({ + "type": Schema.Literal("citations_delta"), + "citation": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("char_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_char_index": Schema.Number.check(Schema.isFinite()), + "end_char_index": Schema.Number.check(Schema.isFinite()), + "file_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("page_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_page_number": Schema.Number.check(Schema.isFinite()), + "end_page_number": Schema.Number.check(Schema.isFinite()), + "file_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("content_block_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()), + "file_id": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("web_search_result_location"), + "cited_text": Schema.String, + "encrypted_index": Schema.String, + "title": Schema.String, + "url": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("search_result_location"), + "cited_text": Schema.String, + "search_result_index": Schema.Number.check(Schema.isFinite()), + "source": Schema.String, + "title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()) + }) + ], { mode: "oneOf" }) }) - ], { mode: "oneOf" })).annotate({ - "description": "Plugins you want to enable for this request, including their settings." - }) + ], { mode: "oneOf" }) + }), + Schema.Struct({ "type": Schema.Literal("content_block_stop"), "index": Schema.Number.check(Schema.isFinite()) }), + Schema.Struct({ "type": Schema.Literal("ping") }), + Schema.Struct({ + "type": Schema.Literal("error"), + "error": Schema.Struct({ "type": Schema.String, "message": Schema.String }) + }) +], { mode: "oneOf" }).annotate({ "description": "Union of all possible streaming events" }) +export type ForbiddenResponse = { readonly "error": ForbiddenResponseErrorData; readonly "user_id"?: string } +export const ForbiddenResponse = Schema.Struct({ + "error": ForbiddenResponseErrorData, + "user_id": Schema.optionalKey(Schema.String) +}).annotate({ "description": "Forbidden - Authentication successful but insufficient permissions" }) +export type ChatMessageContentItemText = { + readonly "type": "text" + readonly "text": string + readonly "cache_control"?: ChatMessageContentItemCacheControl +} +export const ChatMessageContentItemText = Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String, + "cache_control": Schema.optionalKey(ChatMessageContentItemCacheControl) +}).annotate({ "description": "Text content part" }) +export type ToolDefinitionJson = { + readonly "type": "function" + readonly "function": { + readonly "name": string + readonly "description"?: string + readonly "parameters"?: {} + readonly "strict"?: boolean + } + readonly "cache_control"?: ChatMessageContentItemCacheControl +} +export const ToolDefinitionJson = Schema.Struct({ + "type": Schema.Literal("function"), + "function": Schema.Struct({ + "name": Schema.String.annotate({ + "description": "Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)" + }).check(Schema.isMaxLength(64)), + "description": Schema.optionalKey(Schema.String.annotate({ "description": "Function description for the model" })), + "parameters": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Function parameters as JSON Schema object" }) + ), + "strict": Schema.optionalKey(Schema.Boolean.annotate({ "description": "Enable strict schema adherence" })) + }).annotate({ "description": "Function definition for tool calling" }), + "cache_control": Schema.optionalKey(ChatMessageContentItemCacheControl) +}).annotate({ "description": "Tool definition for function calling" }) +export type ChatMessageContentItemVideoLegacy = { readonly "type": "input_video"; readonly "video_url": VideoInput } +export const ChatMessageContentItemVideoLegacy = Schema.Struct({ + "type": Schema.Literal("input_video"), + "video_url": VideoInput +}).annotate({ "description": "Video input content part (legacy format - deprecated)" }) +export type ChatMessageContentItemVideo = { readonly "type": "video_url"; readonly "video_url": VideoInput } +export const ChatMessageContentItemVideo = Schema.Struct({ + "type": Schema.Literal("video_url"), + "video_url": VideoInput +}).annotate({ "description": "Video input content part" }) +export type ReasoningDetailUnion = ReasoningDetailSummary | ReasoningDetailEncrypted | ReasoningDetailText +export const ReasoningDetailUnion = Schema.Union([ + ReasoningDetailSummary, + ReasoningDetailEncrypted, + ReasoningDetailText +], { mode: "oneOf" }).annotate({ "description": "Reasoning detail union schema" }) +export type ChatMessageTokenLogprobs = { + readonly "content": ReadonlyArray + readonly "refusal"?: ReadonlyArray +} +export const ChatMessageTokenLogprobs = Schema.Struct({ + "content": Schema.Array(ChatMessageTokenLogprob).annotate({ "description": "Log probabilities for content tokens" }), + "refusal": Schema.optionalKey( + Schema.Array(ChatMessageTokenLogprob).annotate({ "description": "Log probabilities for refusal tokens" }) + ) +}).annotate({ "description": "Log probabilities for the completion" }) +export type ResponseFormatTextConfig = + | ResponsesFormatText + | ResponseFormatJSONObject + | ResponsesFormatTextJSONSchemaConfig +export const ResponseFormatTextConfig = Schema.Union([ + ResponsesFormatText, + ResponseFormatJSONObject, + ResponsesFormatTextJSONSchemaConfig +]).annotate({ "description": "Text response format configuration" }) +export type ResponseFormatJSONSchema = { readonly "type": "json_schema"; readonly "json_schema": JSONSchemaConfig } +export const ResponseFormatJSONSchema = Schema.Struct({ + "type": Schema.Literal("json_schema"), + "json_schema": JSONSchemaConfig +}).annotate({ "description": "JSON Schema response format for structured outputs" }) +export type ToolChoiceOption = "none" | "auto" | "required" | NamedToolChoice +export const ToolChoiceOption = Schema.Union([ + Schema.Literal("none"), + Schema.Literal("auto"), + Schema.Literal("required"), + NamedToolChoice +]).annotate({ "description": "Tool choice configuration" }) +export type ModelArchitecture = { + readonly "tokenizer"?: ModelGroup + readonly "instruct_type"?: + | "none" + | "airoboros" + | "alpaca" + | "alpaca-modif" + | "chatml" + | "claude" + | "code-llama" + | "gemma" + | "llama2" + | "llama3" + | "mistral" + | "nemotron" + | "neural" + | "openchat" + | "phi3" + | "rwkv" + | "vicuna" + | "zephyr" + | "deepseek-r1" + | "deepseek-v3.1" + | "qwq" + | "qwen3" + readonly "modality": string + readonly "input_modalities": ReadonlyArray + readonly "output_modalities": ReadonlyArray +} +export const ModelArchitecture = Schema.Struct({ + "tokenizer": Schema.optionalKey(ModelGroup), + "instruct_type": Schema.optionalKey( + Schema.Literals([ + "none", + "airoboros", + "alpaca", + "alpaca-modif", + "chatml", + "claude", + "code-llama", + "gemma", + "llama2", + "llama3", + "mistral", + "nemotron", + "neural", + "openchat", + "phi3", + "rwkv", + "vicuna", + "zephyr", + "deepseek-r1", + "deepseek-v3.1", + "qwq", + "qwen3" + ]).annotate({ "description": "Instruction format type" }) + ), + "modality": Schema.String.annotate({ "description": "Primary modality of the model" }), + "input_modalities": Schema.Array(InputModality).annotate({ "description": "Supported input modalities" }), + "output_modalities": Schema.Array(OutputModality).annotate({ "description": "Supported output modalities" }) +}).annotate({ "description": "Model architecture information" }) +export type PublicEndpoint = { + readonly "name": string + readonly "model_id": string + readonly "model_name": string + readonly "context_length": number + readonly "pricing": { + readonly "prompt": string + readonly "completion": string + readonly "request"?: string + readonly "image"?: string + readonly "image_token"?: string + readonly "image_output"?: string + readonly "audio"?: string + readonly "audio_output"?: string + readonly "input_audio_cache"?: string + readonly "web_search"?: string + readonly "internal_reasoning"?: string + readonly "input_cache_read"?: string + readonly "input_cache_write"?: string + readonly "discount"?: number + } + readonly "provider_name": ProviderName + readonly "tag": string + readonly "quantization": "int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown" + readonly "max_completion_tokens": number + readonly "max_prompt_tokens": number + readonly "supported_parameters": ReadonlyArray + readonly "status"?: EndpointStatus + readonly "uptime_last_30m": number + readonly "supports_implicit_caching": boolean + readonly "latency_last_30m": PercentileStats + readonly "throughput_last_30m": { + readonly "p50": number + readonly "p75": number + readonly "p90": number + readonly "p99": number + } +} +export const PublicEndpoint = Schema.Struct({ + "name": Schema.String, + "model_id": Schema.String.annotate({ "description": "The unique identifier for the model (permaslug)" }), + "model_name": Schema.String, + "context_length": Schema.Number.check(Schema.isFinite()), + "pricing": Schema.Struct({ + "prompt": Schema.String.annotate({ "description": "A number or string value representing a large number" }), + "completion": Schema.String.annotate({ "description": "A number or string value representing a large number" }), + "request": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "image": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "image_token": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "image_output": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "audio": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "audio_output": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "input_audio_cache": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "web_search": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "internal_reasoning": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "input_cache_read": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "input_cache_write": Schema.optionalKey( + Schema.String.annotate({ "description": "A number or string value representing a large number" }) + ), + "discount": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) + }), + "provider_name": ProviderName, + "tag": Schema.String, + "quantization": Schema.Literals(["int4", "int8", "fp4", "fp6", "fp8", "fp16", "bf16", "fp32", "unknown"]), + "max_completion_tokens": Schema.Number.check(Schema.isFinite()), + "max_prompt_tokens": Schema.Number.check(Schema.isFinite()), + "supported_parameters": Schema.Array(Parameter), + "status": Schema.optionalKey(EndpointStatus), + "uptime_last_30m": Schema.Number.check(Schema.isFinite()), + "supports_implicit_caching": Schema.Boolean, + "latency_last_30m": PercentileStats, + "throughput_last_30m": Schema.Struct({ + "p50": Schema.Number.annotate({ "description": "Median (50th percentile)" }).check(Schema.isFinite()), + "p75": Schema.Number.annotate({ "description": "75th percentile" }).check(Schema.isFinite()), + "p90": Schema.Number.annotate({ "description": "90th percentile" }).check(Schema.isFinite()), + "p99": Schema.Number.annotate({ "description": "99th percentile" }).check(Schema.isFinite()) + }).annotate({ + "description": + "Throughput percentiles in tokens per second over the last 30 minutes. Throughput measures output token generation speed. Only visible when authenticated with an API key or cookie; returns null for unauthenticated requests." + }) +}).annotate({ "description": "Information about a specific model endpoint" }) +export type ResponseOutputText = { + readonly "type": "output_text" + readonly "text": string + readonly "annotations"?: ReadonlyArray + readonly "logprobs"?: ReadonlyArray< + { + readonly "token": string + readonly "bytes": ReadonlyArray + readonly "logprob": number + readonly "top_logprobs": ReadonlyArray< + { readonly "token": string; readonly "bytes": ReadonlyArray; readonly "logprob": number } + > + } + > +} +export const ResponseOutputText = Schema.Struct({ + "type": Schema.Literal("output_text"), + "text": Schema.String, + "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), + "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ + "token": Schema.String, + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), + "logprob": Schema.Number.check(Schema.isFinite()), + "top_logprobs": Schema.Array( + Schema.Struct({ + "token": Schema.String, + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), + "logprob": Schema.Number.check(Schema.isFinite()) + }) + ) + }))) +}) +export type OpenResponsesOutputTextAnnotationAddedEvent = { + readonly "type": "response.output_text.annotation.added" + readonly "output_index": number + readonly "item_id": string + readonly "content_index": number + readonly "sequence_number": number + readonly "annotation_index": number + readonly "annotation": OpenAIResponsesAnnotation +} +export const OpenResponsesOutputTextAnnotationAddedEvent = Schema.Struct({ + "type": Schema.Literal("response.output_text.annotation.added"), + "output_index": Schema.Number.check(Schema.isFinite()), + "item_id": Schema.String, + "content_index": Schema.Number.check(Schema.isFinite()), + "sequence_number": Schema.Number.check(Schema.isFinite()), + "annotation_index": Schema.Number.check(Schema.isFinite()), + "annotation": OpenAIResponsesAnnotation +}).annotate({ "description": "Event emitted when a text annotation is added to output" }) +export type OpenResponsesTextDeltaEvent = { + readonly "type": "response.output_text.delta" + readonly "logprobs": ReadonlyArray + readonly "output_index": number + readonly "item_id": string + readonly "content_index": number + readonly "delta": string + readonly "sequence_number": number +} +export const OpenResponsesTextDeltaEvent = Schema.Struct({ + "type": Schema.Literal("response.output_text.delta"), + "logprobs": Schema.Array(OpenResponsesLogProbs), + "output_index": Schema.Number.check(Schema.isFinite()), + "item_id": Schema.String, + "content_index": Schema.Number.check(Schema.isFinite()), + "delta": Schema.String, + "sequence_number": Schema.Number.check(Schema.isFinite()) +}).annotate({ "description": "Event emitted when a text delta is streamed" }) +export type OpenResponsesTextDoneEvent = { + readonly "type": "response.output_text.done" + readonly "output_index": number + readonly "item_id": string + readonly "content_index": number + readonly "text": string + readonly "sequence_number": number + readonly "logprobs": ReadonlyArray +} +export const OpenResponsesTextDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.output_text.done"), + "output_index": Schema.Number.check(Schema.isFinite()), + "item_id": Schema.String, + "content_index": Schema.Number.check(Schema.isFinite()), + "text": Schema.String, + "sequence_number": Schema.Number.check(Schema.isFinite()), + "logprobs": Schema.Array(OpenResponsesLogProbs) +}).annotate({ "description": "Event emitted when text streaming is complete" }) +export type ProviderPreferences = { + readonly "allow_fallbacks"?: boolean + readonly "require_parameters"?: boolean + readonly "data_collection"?: DataCollection + readonly "zdr"?: boolean + readonly "enforce_distillable_text"?: boolean + readonly "order"?: ReadonlyArray + readonly "only"?: ReadonlyArray + readonly "ignore"?: ReadonlyArray + readonly "quantizations"?: ReadonlyArray + readonly "sort"?: "price" | "price" | "throughput" | "throughput" | "latency" | "latency" + readonly "max_price"?: { + readonly "prompt"?: BigNumberUnion + readonly "completion"?: string + readonly "image"?: string + readonly "audio"?: string + readonly "request"?: string + } + readonly "preferred_min_throughput"?: PreferredMinThroughput + readonly "preferred_max_latency"?: PreferredMaxLatency +} +export const ProviderPreferences = Schema.Struct({ + "allow_fallbacks": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "Whether to allow backup providers to serve requests\n- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.\n- false: use only the primary/custom provider, and return the upstream error if it's unavailable.\n" + })), + "require_parameters": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest." + }) + ), + "data_collection": Schema.optionalKey(DataCollection), + "zdr": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used." + }) + ), + "enforce_distillable_text": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used." + }) + ), + "order": Schema.optionalKey( + Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ + "description": + "An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message." + }) + ), + "only": Schema.optionalKey( + Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ + "description": + "List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request." + }) + ), + "ignore": Schema.optionalKey( + Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ + "description": + "List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request." + }) + ), + "quantizations": Schema.optionalKey( + Schema.Array(Quantization).annotate({ "description": "A list of quantization levels to filter the provider by." }) + ), + "sort": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.Literal("price").annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }), + Schema.Literal("price") + ]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }), + Schema.Union([ + Schema.Literal("throughput").annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }), + Schema.Literal("throughput") + ]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }), + Schema.Union([ + Schema.Literal("latency").annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }), + Schema.Literal("latency") + ]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }) + ]).annotate({ "description": "The provider sorting strategy (price, throughput, latency)" }) + ), + "max_price": Schema.optionalKey( + Schema.Struct({ + "prompt": Schema.optionalKey(BigNumberUnion), + "completion": Schema.optionalKey( + Schema.String.annotate({ "description": "Price per million completion tokens" }) + ), + "image": Schema.optionalKey(Schema.String.annotate({ "description": "Price per image" })), + "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Price per audio unit" })), + "request": Schema.optionalKey(Schema.String.annotate({ "description": "Price per request" })) + }).annotate({ + "description": + "The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion." + }) + ), + "preferred_min_throughput": Schema.optionalKey(PreferredMinThroughput), + "preferred_max_latency": Schema.optionalKey(PreferredMaxLatency) +}).annotate({ "description": "Provider routing preferences for the request." }) +export type AnthropicMessagesRequest = { + readonly "model": string + readonly "max_tokens"?: number + readonly "messages": ReadonlyArray + readonly "system"?: + | string + | ReadonlyArray< + { + readonly "type": "text" + readonly "text": string + readonly "citations"?: ReadonlyArray< + { + readonly "type": "char_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_char_index": number + readonly "end_char_index": number + } | { + readonly "type": "page_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_page_number": number + readonly "end_page_number": number + } | { + readonly "type": "content_block_location" + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string + readonly "start_block_index": number + readonly "end_block_index": number + } | { + readonly "type": "web_search_result_location" + readonly "cited_text": string + readonly "encrypted_index": string + readonly "title": string + readonly "url": string + } | { + readonly "type": "search_result_location" + readonly "cited_text": string + readonly "search_result_index": number + readonly "source": string + readonly "title": string + readonly "start_block_index": number + readonly "end_block_index": number + } + > + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } + > + readonly "metadata"?: { readonly "user_id"?: string } + readonly "stop_sequences"?: ReadonlyArray + readonly "temperature"?: number + readonly "top_p"?: number + readonly "top_k"?: number + readonly "tools"?: ReadonlyArray< + { + readonly "name": string + readonly "description"?: string + readonly "input_schema": { + readonly "type"?: string + readonly "properties"?: unknown + readonly "required"?: ReadonlyArray + } + readonly "type"?: "custom" + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } | { + readonly "type": "bash_20250124" + readonly "name": "bash" + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } | { + readonly "type": "text_editor_20250124" + readonly "name": "str_replace_editor" + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } | { + readonly "type": "web_search_20250305" + readonly "name": "web_search" + readonly "allowed_domains"?: ReadonlyArray + readonly "blocked_domains"?: ReadonlyArray + readonly "max_uses"?: number + readonly "user_location"?: { + readonly "type": "approximate" + readonly "city"?: string + readonly "country"?: string + readonly "region"?: string + readonly "timezone"?: string + } + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + } + > + readonly "tool_choice"?: + | { readonly "type": "auto"; readonly "disable_parallel_tool_use"?: boolean } + | { readonly "type": "any"; readonly "disable_parallel_tool_use"?: boolean } + | { readonly "type": "none" } + | { readonly "type": "tool"; readonly "name": string; readonly "disable_parallel_tool_use"?: boolean } + readonly "thinking"?: { readonly "type": "enabled"; readonly "budget_tokens": number } | { + readonly "type": "disabled" + } | { readonly "type": "adaptive" } + readonly "service_tier"?: "auto" | "standard_only" + readonly "output_config"?: AnthropicOutputConfig + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } + readonly "stream"?: boolean + readonly "context_management"?: { + readonly "edits"?: ReadonlyArray< + { + readonly "type": "clear_tool_uses_20250919" + readonly "clear_at_least"?: { readonly "type": "input_tokens"; readonly "value": number } + readonly "clear_tool_inputs"?: boolean | ReadonlyArray | unknown + readonly "exclude_tools"?: ReadonlyArray + readonly "keep"?: { readonly "type": "tool_uses"; readonly "value": number } + readonly "trigger"?: { readonly "type": "input_tokens"; readonly "value": number } | { + readonly "type": "tool_uses" + readonly "value": number + } + } | { + readonly "type": "clear_thinking_20251015" + readonly "keep"?: + | { readonly "type": "thinking_turns"; readonly "value": number } + | { readonly "type": "all" } + | "all" + } | { + readonly "type": "compact_20260112" + readonly "instructions"?: string + readonly "pause_after_compaction"?: boolean + readonly "trigger"?: { readonly "type": "input_tokens"; readonly "value": number } + } + > + } + readonly "provider"?: { + readonly "allow_fallbacks"?: boolean + readonly "require_parameters"?: boolean + readonly "data_collection"?: DataCollection + readonly "zdr"?: boolean + readonly "enforce_distillable_text"?: boolean + readonly "order"?: ReadonlyArray + readonly "only"?: ReadonlyArray + readonly "ignore"?: ReadonlyArray + readonly "quantizations"?: ReadonlyArray + readonly "sort"?: "price" | "price" | "throughput" | "throughput" | "latency" | "latency" + readonly "max_price"?: { + readonly "prompt"?: BigNumberUnion + readonly "completion"?: string + readonly "image"?: string + readonly "audio"?: string + readonly "request"?: string + } + readonly "preferred_min_throughput"?: PreferredMinThroughput + readonly "preferred_max_latency"?: PreferredMaxLatency + } + readonly "plugins"?: ReadonlyArray< + | { readonly "id": "auto-router"; readonly "enabled"?: boolean; readonly "allowed_models"?: ReadonlyArray } + | { readonly "id": "moderation" } + | { + readonly "id": "web" + readonly "enabled"?: boolean + readonly "max_results"?: number + readonly "search_prompt"?: string + readonly "engine"?: WebSearchEngine + readonly "include_domains"?: ReadonlyArray + readonly "exclude_domains"?: ReadonlyArray + } + | { readonly "id": "file-parser"; readonly "enabled"?: boolean; readonly "pdf"?: PDFParserOptions } + | { readonly "id": "response-healing"; readonly "enabled"?: boolean } + > + readonly "route"?: "fallback" | "sort" + readonly "user"?: string + readonly "session_id"?: string + readonly "trace"?: { + readonly "trace_id"?: string + readonly "trace_name"?: string + readonly "span_name"?: string + readonly "generation_name"?: string + readonly "parent_span_id"?: string + } + readonly "models"?: ReadonlyArray +} +export const AnthropicMessagesRequest = Schema.Struct({ + "model": Schema.String, + "max_tokens": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "messages": Schema.Array(OpenRouterAnthropicMessageParam), + "system": Schema.optionalKey(Schema.Union([ + Schema.String, + Schema.Array(Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String, + "citations": Schema.optionalKey(Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("char_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_char_index": Schema.Number.check(Schema.isFinite()), + "end_char_index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("page_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_page_number": Schema.Number.check(Schema.isFinite()), + "end_page_number": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("content_block_location"), + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isFinite()), + "document_title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("web_search_result_location"), + "cited_text": Schema.String, + "encrypted_index": Schema.String, + "title": Schema.String, + "url": Schema.String + }), + Schema.Struct({ + "type": Schema.Literal("search_result_location"), + "cited_text": Schema.String, + "search_result_index": Schema.Number.check(Schema.isFinite()), + "source": Schema.String, + "title": Schema.String, + "start_block_index": Schema.Number.check(Schema.isFinite()), + "end_block_index": Schema.Number.check(Schema.isFinite()) + }) + ], { mode: "oneOf" }))), + "cache_control": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) + ) + })) + ])), + "metadata": Schema.optionalKey(Schema.Struct({ "user_id": Schema.optionalKey(Schema.String) })), + "stop_sequences": Schema.optionalKey(Schema.Array(Schema.String)), + "temperature": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "top_p": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "top_k": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "tools": Schema.optionalKey(Schema.Array(Schema.Union([ + Schema.Struct({ + "name": Schema.String, + "description": Schema.optionalKey(Schema.String), + "input_schema": Schema.Struct({ + "type": Schema.optionalKey(Schema.String), + "properties": Schema.optionalKey(Schema.Unknown), + "required": Schema.optionalKey(Schema.Array(Schema.String)) + }), + "type": Schema.optionalKey(Schema.Literal("custom")), + "cache_control": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) + ) + }), + Schema.Struct({ + "type": Schema.Literal("bash_20250124"), + "name": Schema.Literal("bash"), + "cache_control": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) + ) + }), + Schema.Struct({ + "type": Schema.Literal("text_editor_20250124"), + "name": Schema.Literal("str_replace_editor"), + "cache_control": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) + ) + }), + Schema.Struct({ + "type": Schema.Literal("web_search_20250305"), + "name": Schema.Literal("web_search"), + "allowed_domains": Schema.optionalKey(Schema.Array(Schema.String)), + "blocked_domains": Schema.optionalKey(Schema.Array(Schema.String)), + "max_uses": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "user_location": Schema.optionalKey( + Schema.Struct({ + "type": Schema.Literal("approximate"), + "city": Schema.optionalKey(Schema.String), + "country": Schema.optionalKey(Schema.String), + "region": Schema.optionalKey(Schema.String), + "timezone": Schema.optionalKey(Schema.String) + }) + ), + "cache_control": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) + ) + }) + ], { mode: "oneOf" }))), + "tool_choice": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("auto"), + "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean) + }), + Schema.Struct({ "type": Schema.Literal("any"), "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean) }), + Schema.Struct({ "type": Schema.Literal("none") }), + Schema.Struct({ + "type": Schema.Literal("tool"), + "name": Schema.String, + "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean) + }) + ], { mode: "oneOf" }) + ), + "thinking": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": Schema.Literal("enabled"), "budget_tokens": Schema.Number.check(Schema.isFinite()) }), + Schema.Struct({ "type": Schema.Literal("disabled") }), + Schema.Struct({ "type": Schema.Literal("adaptive") }) + ], { mode: "oneOf" }) + ), + "service_tier": Schema.optionalKey(Schema.Literals(["auto", "standard_only"])), + "output_config": Schema.optionalKey(AnthropicOutputConfig), + "cache_control": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) + ), + "stream": Schema.optionalKey(Schema.Boolean), + "context_management": Schema.optionalKey(Schema.Struct({ + "edits": Schema.optionalKey(Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("clear_tool_uses_20250919"), + "clear_at_least": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("input_tokens"), "value": Schema.Number.check(Schema.isFinite()) }) + ), + "clear_tool_inputs": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Array(Schema.String), Schema.Unknown]) + ), + "exclude_tools": Schema.optionalKey(Schema.Array(Schema.String)), + "keep": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("tool_uses"), "value": Schema.Number.check(Schema.isFinite()) }) + ), + "trigger": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": Schema.Literal("input_tokens"), "value": Schema.Number.check(Schema.isFinite()) }), + Schema.Struct({ "type": Schema.Literal("tool_uses"), "value": Schema.Number.check(Schema.isFinite()) }) + ], { mode: "oneOf" }) + ) + }), + Schema.Struct({ + "type": Schema.Literal("clear_thinking_20251015"), + "keep": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("thinking_turns"), + "value": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ "type": Schema.Literal("all") }), + Schema.Literal("all") + ]) + ) + }), + Schema.Struct({ + "type": Schema.Literal("compact_20260112"), + "instructions": Schema.optionalKey(Schema.String), + "pause_after_compaction": Schema.optionalKey(Schema.Boolean), + "trigger": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("input_tokens"), "value": Schema.Number.check(Schema.isFinite()) }) + ) + }) + ], { mode: "oneOf" }))) + })), + "provider": Schema.optionalKey( + Schema.Struct({ + "allow_fallbacks": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "Whether to allow backup providers to serve requests\n- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.\n- false: use only the primary/custom provider, and return the upstream error if it's unavailable.\n" + })), + "require_parameters": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest." + }) + ), + "data_collection": Schema.optionalKey(DataCollection), + "zdr": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used." + }) + ), + "enforce_distillable_text": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used." + }) + ), + "order": Schema.optionalKey( + Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ + "description": + "An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message." + }) + ), + "only": Schema.optionalKey( + Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ + "description": + "List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request." + }) + ), + "ignore": Schema.optionalKey( + Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ + "description": + "List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request." + }) + ), + "quantizations": Schema.optionalKey( + Schema.Array(Quantization).annotate({ + "description": "A list of quantization levels to filter the provider by." + }) + ), + "sort": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.Literal("price").annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }), + Schema.Literal("price") + ]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }), + Schema.Union([ + Schema.Literal("throughput").annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }), + Schema.Literal("throughput") + ]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }), + Schema.Union([ + Schema.Literal("latency").annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }), + Schema.Literal("latency") + ]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }) + ]).annotate({ "description": "The provider sorting strategy (price, throughput, latency)" }) + ), + "max_price": Schema.optionalKey( + Schema.Struct({ + "prompt": Schema.optionalKey(BigNumberUnion), + "completion": Schema.optionalKey( + Schema.String.annotate({ "description": "Price per million completion tokens" }) + ), + "image": Schema.optionalKey(Schema.String.annotate({ "description": "Price per image" })), + "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Price per audio unit" })), + "request": Schema.optionalKey(Schema.String.annotate({ "description": "Price per request" })) + }).annotate({ + "description": + "The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion." + }) + ), + "preferred_min_throughput": Schema.optionalKey(PreferredMinThroughput), + "preferred_max_latency": Schema.optionalKey(PreferredMaxLatency) + }).annotate({ + "description": "When multiple model providers are available, optionally indicate your routing preference." + }) + ), + "plugins": Schema.optionalKey( + Schema.Array(Schema.Union([ + Schema.Struct({ + "id": Schema.Literal("auto-router"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the auto-router plugin for this request. Defaults to true." + }) + ), + "allowed_models": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list." + }) + ) + }), + Schema.Struct({ "id": Schema.Literal("moderation") }), + Schema.Struct({ + "id": Schema.Literal("web"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the web-search plugin for this request. Defaults to true." + }) + ), + "max_results": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "search_prompt": Schema.optionalKey(Schema.String), + "engine": Schema.optionalKey(WebSearchEngine), + "include_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")." + }) + ), + "exclude_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")." + }) + ) + }), + Schema.Struct({ + "id": Schema.Literal("file-parser"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the file-parser plugin for this request. Defaults to true." + }) + ), + "pdf": Schema.optionalKey(PDFParserOptions) + }), + Schema.Struct({ + "id": Schema.Literal("response-healing"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the response-healing plugin for this request. Defaults to true." + }) + ) + }) + ], { mode: "oneOf" })).annotate({ + "description": "Plugins you want to enable for this request, including their settings." + }) + ), + "route": Schema.optionalKey( + Schema.Literals(["fallback", "sort"]).annotate({ + "description": + "**DEPRECATED** Use providers.sort.partition instead. Backwards-compatible alias for providers.sort.partition. Accepts legacy values: \"fallback\" (maps to \"model\"), \"sort\" (maps to \"none\")." + }) + ), + "user": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters." + }).check(Schema.isMaxLength(128)) + ), + "session_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters." + }).check(Schema.isMaxLength(128)) + ), + "trace": Schema.optionalKey( + Schema.Struct({ + "trace_id": Schema.optionalKey(Schema.String), + "trace_name": Schema.optionalKey(Schema.String), + "span_name": Schema.optionalKey(Schema.String), + "generation_name": Schema.optionalKey(Schema.String), + "parent_span_id": Schema.optionalKey(Schema.String) + }).annotate({ + "description": + "Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations." + }) + ), + "models": Schema.optionalKey(Schema.Array(Schema.String)) +}).annotate({ "description": "Request schema for Anthropic Messages API endpoint" }) +export type SystemMessage = { + readonly "role": "system" + readonly "content": string | ReadonlyArray + readonly "name"?: string +} +export const SystemMessage = Schema.Struct({ + "role": Schema.Literal("system"), + "content": Schema.Union([Schema.String, Schema.Array(ChatMessageContentItemText)]).annotate({ + "description": "System message content" + }), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the system message" })) +}).annotate({ "description": "System message for setting behavior" }) +export type DeveloperMessage = { + readonly "role": "developer" + readonly "content": string | ReadonlyArray + readonly "name"?: string +} +export const DeveloperMessage = Schema.Struct({ + "role": Schema.Literal("developer"), + "content": Schema.Union([Schema.String, Schema.Array(ChatMessageContentItemText)]).annotate({ + "description": "Developer message content" + }), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the developer message" })) +}).annotate({ "description": "Developer message" }) +export type ChatMessageContentItem = + | ChatMessageContentItemText + | ChatMessageContentItemImage + | ChatMessageContentItemAudio + | ChatMessageContentItemVideoLegacy + | ChatMessageContentItemVideo + | ChatMessageContentItemFile +export const ChatMessageContentItem = Schema.Union([ + ChatMessageContentItemText, + ChatMessageContentItemImage, + ChatMessageContentItemAudio, + Schema.Union([ChatMessageContentItemVideoLegacy, ChatMessageContentItemVideo], { mode: "oneOf" }), + ChatMessageContentItemFile +], { mode: "oneOf" }).annotate({ "description": "Content part for chat completion messages" }) +export type AssistantMessageReasoningDetails = ReadonlyArray +export const AssistantMessageReasoningDetails = Schema.Array(ReasoningDetailUnion).annotate({ + "description": "Reasoning details for extended thinking models" +}) +export type ResponseTextConfig = { + readonly "format"?: ResponseFormatTextConfig + readonly "verbosity"?: "high" | "low" | "medium" +} +export const ResponseTextConfig = Schema.Struct({ + "format": Schema.optionalKey(ResponseFormatTextConfig), + "verbosity": Schema.optionalKey(Schema.Literals(["high", "low", "medium"])) +}).annotate({ "description": "Text output configuration including format and verbosity" }) +export type OpenResponsesResponseText = { + readonly "format"?: ResponseFormatTextConfig + readonly "verbosity"?: "high" | "low" | "medium" +} +export const OpenResponsesResponseText = Schema.Struct({ + "format": Schema.optionalKey(ResponseFormatTextConfig), + "verbosity": Schema.optionalKey(Schema.Literals(["high", "low", "medium"])) +}).annotate({ "description": "Text output configuration including format and verbosity" }) +export type Model = { + readonly "id": string + readonly "canonical_slug": string + readonly "hugging_face_id"?: string + readonly "name": string + readonly "created": number + readonly "description"?: string + readonly "pricing": PublicPricing + readonly "context_length": number + readonly "architecture": ModelArchitecture + readonly "top_provider": TopProviderInfo + readonly "per_request_limits": PerRequestLimits + readonly "supported_parameters": ReadonlyArray + readonly "default_parameters": DefaultParameters + readonly "expiration_date"?: string +} +export const Model = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), + "canonical_slug": Schema.String.annotate({ "description": "Canonical slug for the model" }), + "hugging_face_id": Schema.optionalKey( + Schema.String.annotate({ "description": "Hugging Face model identifier, if applicable" }) + ), + "name": Schema.String.annotate({ "description": "Display name of the model" }), + "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( + Schema.isFinite() + ), + "description": Schema.optionalKey(Schema.String.annotate({ "description": "Description of the model" })), + "pricing": PublicPricing, + "context_length": Schema.Number.annotate({ "description": "Maximum context length in tokens" }).check( + Schema.isFinite() + ), + "architecture": ModelArchitecture, + "top_provider": TopProviderInfo, + "per_request_limits": PerRequestLimits, + "supported_parameters": Schema.Array(Parameter).annotate({ + "description": "List of supported parameters for this model" + }), + "default_parameters": DefaultParameters, + "expiration_date": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The date after which the model may be removed. ISO 8601 date string (YYYY-MM-DD) or null if no expiration." + }) + ) +}).annotate({ "description": "Information about an AI model available on OpenRouter" }) +export type ListEndpointsResponse = { + readonly "id": string + readonly "name": string + readonly "created": number + readonly "description": string + readonly "architecture": { + readonly "tokenizer": + | "Router" + | "Media" + | "Other" + | "GPT" + | "Claude" + | "Gemini" + | "Grok" + | "Cohere" + | "Nova" + | "Qwen" + | "Yi" + | "DeepSeek" + | "Mistral" + | "Llama2" + | "Llama3" + | "Llama4" + | "PaLM" + | "RWKV" + | "Qwen3" + readonly "instruct_type": + | "none" + | "airoboros" + | "alpaca" + | "alpaca-modif" + | "chatml" + | "claude" + | "code-llama" + | "gemma" + | "llama2" + | "llama3" + | "mistral" + | "nemotron" + | "neural" + | "openchat" + | "phi3" + | "rwkv" + | "vicuna" + | "zephyr" + | "deepseek-r1" + | "deepseek-v3.1" + | "qwq" + | "qwen3" + readonly "modality": string + readonly "input_modalities": ReadonlyArray<"text" | "image" | "file" | "audio" | "video"> + readonly "output_modalities": ReadonlyArray<"text" | "image" | "embeddings" | "audio"> + } + readonly "endpoints": ReadonlyArray +} +export const ListEndpointsResponse = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), + "name": Schema.String.annotate({ "description": "Display name of the model" }), + "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( + Schema.isFinite() + ), + "description": Schema.String.annotate({ "description": "Description of the model" }), + "architecture": Schema.Struct({ + "tokenizer": Schema.Union([ + Schema.Literal("Router").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Media").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Other").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("GPT").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Claude").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Gemini").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Grok").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Cohere").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Nova").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Qwen").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Yi").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("DeepSeek").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Mistral").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Llama2").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Llama3").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Llama4").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("PaLM").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("RWKV").annotate({ "description": "Tokenizer type used by the model" }), + Schema.Literal("Qwen3").annotate({ "description": "Tokenizer type used by the model" }) + ]).annotate({ "description": "Tokenizer type used by the model" }), + "instruct_type": Schema.Union([ + Schema.Literal("none").annotate({ "description": "Instruction format type" }), + Schema.Literal("airoboros").annotate({ "description": "Instruction format type" }), + Schema.Literal("alpaca").annotate({ "description": "Instruction format type" }), + Schema.Literal("alpaca-modif").annotate({ "description": "Instruction format type" }), + Schema.Literal("chatml").annotate({ "description": "Instruction format type" }), + Schema.Literal("claude").annotate({ "description": "Instruction format type" }), + Schema.Literal("code-llama").annotate({ "description": "Instruction format type" }), + Schema.Literal("gemma").annotate({ "description": "Instruction format type" }), + Schema.Literal("llama2").annotate({ "description": "Instruction format type" }), + Schema.Literal("llama3").annotate({ "description": "Instruction format type" }), + Schema.Literal("mistral").annotate({ "description": "Instruction format type" }), + Schema.Literal("nemotron").annotate({ "description": "Instruction format type" }), + Schema.Literal("neural").annotate({ "description": "Instruction format type" }), + Schema.Literal("openchat").annotate({ "description": "Instruction format type" }), + Schema.Literal("phi3").annotate({ "description": "Instruction format type" }), + Schema.Literal("rwkv").annotate({ "description": "Instruction format type" }), + Schema.Literal("vicuna").annotate({ "description": "Instruction format type" }), + Schema.Literal("zephyr").annotate({ "description": "Instruction format type" }), + Schema.Literal("deepseek-r1").annotate({ "description": "Instruction format type" }), + Schema.Literal("deepseek-v3.1").annotate({ "description": "Instruction format type" }), + Schema.Literal("qwq").annotate({ "description": "Instruction format type" }), + Schema.Literal("qwen3").annotate({ "description": "Instruction format type" }) + ]).annotate({ "description": "Instruction format type" }), + "modality": Schema.String.annotate({ "description": "Primary modality of the model" }), + "input_modalities": Schema.Array( + Schema.Union([ + Schema.Literal("text"), + Schema.Literal("image"), + Schema.Literal("file"), + Schema.Literal("audio"), + Schema.Literal("video") + ]) + ).annotate({ "description": "Supported input modalities" }), + "output_modalities": Schema.Array( + Schema.Union([ + Schema.Literal("text"), + Schema.Literal("image"), + Schema.Literal("embeddings"), + Schema.Literal("audio") + ]) + ).annotate({ "description": "Supported output modalities" }) + }).annotate({ "description": "Model architecture information" }), + "endpoints": Schema.Array(PublicEndpoint).annotate({ "description": "List of available endpoints for this model" }) +}).annotate({ "description": "List of available endpoints for a model" }) +export type OutputMessage = { + readonly "id": string + readonly "role": "assistant" + readonly "type": "message" + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown +} +export const OutputMessage = Schema.Struct({ + "id": Schema.String, + "role": Schema.Literal("assistant"), + "type": Schema.Literal("message"), + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) +}) +export type ResponsesOutputMessage = { + readonly "id": string + readonly "role": "assistant" + readonly "type": "message" + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown +} +export const ResponsesOutputMessage = Schema.Struct({ + "id": Schema.String, + "role": Schema.Literal("assistant"), + "type": Schema.Literal("message"), + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) +}).annotate({ "description": "An output message item" }) +export type OpenResponsesContentPartAddedEvent = { + readonly "type": "response.content_part.added" + readonly "output_index": number + readonly "item_id": string + readonly "content_index": number + readonly "part": ResponseOutputText | OpenAIResponsesRefusalContent + readonly "sequence_number": number +} +export const OpenResponsesContentPartAddedEvent = Schema.Struct({ + "type": Schema.Literal("response.content_part.added"), + "output_index": Schema.Number.check(Schema.isFinite()), + "item_id": Schema.String, + "content_index": Schema.Number.check(Schema.isFinite()), + "part": Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent]), + "sequence_number": Schema.Number.check(Schema.isFinite()) +}).annotate({ "description": "Event emitted when a new content part is added to an output item" }) +export type OpenResponsesContentPartDoneEvent = { + readonly "type": "response.content_part.done" + readonly "output_index": number + readonly "item_id": string + readonly "content_index": number + readonly "part": ResponseOutputText | OpenAIResponsesRefusalContent + readonly "sequence_number": number +} +export const OpenResponsesContentPartDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.content_part.done"), + "output_index": Schema.Number.check(Schema.isFinite()), + "item_id": Schema.String, + "content_index": Schema.Number.check(Schema.isFinite()), + "part": Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent]), + "sequence_number": Schema.Number.check(Schema.isFinite()) +}).annotate({ "description": "Event emitted when a content part is complete" }) +export type OpenResponsesInput = + | string + | ReadonlyArray< + | OpenResponsesReasoning + | OpenResponsesEasyInputMessage + | OpenResponsesInputMessageItem + | OpenResponsesFunctionToolCall + | OpenResponsesFunctionCallOutput + | { + readonly "id": string + readonly "role": "assistant" + readonly "type": "message" + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "content": + | ReadonlyArray< + { + readonly "type": "output_text" + readonly "text": string + readonly "annotations"?: ReadonlyArray< + { + readonly "type": "file_citation" + readonly "file_id": string + readonly "filename": string + readonly "index": number + } | { + readonly "type": never + readonly "url": string + readonly "title": string + readonly "start_index": number + readonly "end_index": number + readonly "file_id": string + readonly "filename": string + readonly "index": number + } | { + readonly "type": never + readonly "file_id": string + readonly "index": number + readonly "filename": string + } | { + readonly "type": never + readonly "file_id": string + readonly "filename": string + readonly "index": number + readonly "url": string + readonly "title": string + readonly "start_index": number + readonly "end_index": number + } | { + readonly "type": "url_citation" + readonly "url": string + readonly "title": string + readonly "start_index": number + readonly "end_index": number + } | { + readonly "type": never + readonly "file_id": string + readonly "index": number + readonly "url": string + readonly "title": string + readonly "start_index": number + readonly "end_index": number + } | { + readonly "type": never + readonly "file_id": string + readonly "filename": string + readonly "index": number + } | { + readonly "type": never + readonly "url": string + readonly "title": string + readonly "start_index": number + readonly "end_index": number + readonly "file_id": string + readonly "index": number + } | { readonly "type": "file_path"; readonly "file_id": string; readonly "index": number } + > + readonly "logprobs"?: ReadonlyArray< + { + readonly "token": string + readonly "bytes": ReadonlyArray + readonly "logprob": number + readonly "top_logprobs": ReadonlyArray< + { readonly "token": string; readonly "bytes": ReadonlyArray; readonly "logprob": number } + > + } + > + } | { + readonly "type": never + readonly "refusal": string + readonly "text": string + readonly "annotations"?: ReadonlyArray + readonly "logprobs"?: ReadonlyArray< + { + readonly "token": string + readonly "bytes": ReadonlyArray + readonly "logprob": number + readonly "top_logprobs": ReadonlyArray< + { readonly "token": string; readonly "bytes": ReadonlyArray; readonly "logprob": number } + > + } + > + } | { + readonly "type": never + readonly "text": string + readonly "annotations"?: ReadonlyArray + readonly "logprobs"?: ReadonlyArray< + { + readonly "token": string + readonly "bytes": ReadonlyArray + readonly "logprob": number + readonly "top_logprobs": ReadonlyArray< + { readonly "token": string; readonly "bytes": ReadonlyArray; readonly "logprob": number } + > + } + > + readonly "refusal": string + } | { readonly "type": "refusal"; readonly "refusal": string } + > + | ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown + } + | { + readonly "type": "reasoning" + readonly "id": string + readonly "content"?: ReadonlyArray<{ readonly "type": "reasoning_text"; readonly "text": string }> + readonly "summary": ReadonlyArray<{ readonly "type": "summary_text"; readonly "text": string }> + readonly "encrypted_content"?: string + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "signature"?: string + readonly "format"?: + | "unknown" + | "openai-responses-v1" + | "azure-openai-responses-v1" + | "xai-responses-v1" + | "anthropic-claude-v1" + | "google-gemini-v1" + } + | ResponsesOutputItemFunctionCall + | ResponsesWebSearchCallOutput + | ResponsesOutputItemFileSearchCall + | ResponsesImageGenerationCall + > +export const OpenResponsesInput = Schema.Union([ + Schema.String, + Schema.Array( + Schema.Union([ + OpenResponsesReasoning, + OpenResponsesEasyInputMessage, + OpenResponsesInputMessageItem, + OpenResponsesFunctionToolCall, + OpenResponsesFunctionCallOutput, + Schema.Struct({ + "id": Schema.String, + "role": Schema.Literal("assistant"), + "type": Schema.Literal("message"), + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "content": Schema.Union([ + Schema.Array(Schema.Union([ + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("output_text"), + "text": Schema.String, + "annotations": Schema.optionalKey( + Schema.Array( + Schema.Union([ + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("file_citation"), + "file_id": Schema.String, + "filename": Schema.String, + "index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Never, + "url": Schema.String, + "title": Schema.String, + "start_index": Schema.Number.check(Schema.isFinite()), + "end_index": Schema.Number.check(Schema.isFinite()), + "file_id": Schema.String, + "filename": Schema.String, + "index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Never, + "file_id": Schema.String, + "index": Schema.Number.check(Schema.isFinite()), + "filename": Schema.String + }) + ]), + Schema.Union([ + Schema.Struct({ + "type": Schema.Never, + "file_id": Schema.String, + "filename": Schema.String, + "index": Schema.Number.check(Schema.isFinite()), + "url": Schema.String, + "title": Schema.String, + "start_index": Schema.Number.check(Schema.isFinite()), + "end_index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("url_citation"), + "url": Schema.String, + "title": Schema.String, + "start_index": Schema.Number.check(Schema.isFinite()), + "end_index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Never, + "file_id": Schema.String, + "index": Schema.Number.check(Schema.isFinite()), + "url": Schema.String, + "title": Schema.String, + "start_index": Schema.Number.check(Schema.isFinite()), + "end_index": Schema.Number.check(Schema.isFinite()) + }) + ]), + Schema.Union([ + Schema.Struct({ + "type": Schema.Never, + "file_id": Schema.String, + "filename": Schema.String, + "index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Never, + "url": Schema.String, + "title": Schema.String, + "start_index": Schema.Number.check(Schema.isFinite()), + "end_index": Schema.Number.check(Schema.isFinite()), + "file_id": Schema.String, + "index": Schema.Number.check(Schema.isFinite()) + }), + Schema.Struct({ + "type": Schema.Literal("file_path"), + "file_id": Schema.String, + "index": Schema.Number.check(Schema.isFinite()) + }) + ]) + ]) + ) + ), + "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ + "token": Schema.String, + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), + "logprob": Schema.Number.check(Schema.isFinite()), + "top_logprobs": Schema.Array( + Schema.Struct({ + "token": Schema.String, + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), + "logprob": Schema.Number.check(Schema.isFinite()) + }) + ) + }))) + }), + Schema.Struct({ + "type": Schema.Never, + "refusal": Schema.String, + "text": Schema.String, + "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), + "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ + "token": Schema.String, + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), + "logprob": Schema.Number.check(Schema.isFinite()), + "top_logprobs": Schema.Array( + Schema.Struct({ + "token": Schema.String, + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), + "logprob": Schema.Number.check(Schema.isFinite()) + }) + ) + }))) + }) + ]), + Schema.Union([ + Schema.Struct({ + "type": Schema.Never, + "text": Schema.String, + "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), + "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ + "token": Schema.String, + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), + "logprob": Schema.Number.check(Schema.isFinite()), + "top_logprobs": Schema.Array( + Schema.Struct({ + "token": Schema.String, + "bytes": Schema.Array(Schema.Number.check(Schema.isFinite())), + "logprob": Schema.Number.check(Schema.isFinite()) + }) + ) + }))), + "refusal": Schema.String + }), + Schema.Struct({ "type": Schema.Literal("refusal"), "refusal": Schema.String }) + ]) + ])), + Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])) + ]), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) + }).annotate({ "description": "An output message item" }), + Schema.Struct({ + "type": Schema.Literal("reasoning"), + "id": Schema.String, + "content": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("reasoning_text"), "text": Schema.String })) + ), + "summary": Schema.Array(Schema.Struct({ "type": Schema.Literal("summary_text"), "text": Schema.String })), + "encrypted_content": Schema.optionalKey(Schema.String), + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "signature": Schema.optionalKey( + Schema.String.annotate({ "description": "A signature for the reasoning content, used for verification" }) + ), + "format": Schema.optionalKey( + Schema.Literals([ + "unknown", + "openai-responses-v1", + "azure-openai-responses-v1", + "xai-responses-v1", + "anthropic-claude-v1", + "google-gemini-v1" + ]).annotate({ "description": "The format of the reasoning content" }) + ) + }).annotate({ "description": "An output item containing reasoning" }), + ResponsesOutputItemFunctionCall, + ResponsesWebSearchCallOutput, + ResponsesOutputItemFileSearchCall, + ResponsesImageGenerationCall + ]) + ) +]).annotate({ "description": "Input for a response request - can be a string or array of items" }) +export type UserMessage = { + readonly "role": "user" + readonly "content": string | ReadonlyArray + readonly "name"?: string +} +export const UserMessage = Schema.Struct({ + "role": Schema.Literal("user"), + "content": Schema.Union([Schema.String, Schema.Array(ChatMessageContentItem)]).annotate({ + "description": "User message content" + }), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the user" })) +}).annotate({ "description": "User message" }) +export type ToolResponseMessage = { + readonly "role": "tool" + readonly "content": string | ReadonlyArray + readonly "tool_call_id": string +} +export const ToolResponseMessage = Schema.Struct({ + "role": Schema.Literal("tool"), + "content": Schema.Union([Schema.String, Schema.Array(ChatMessageContentItem)]).annotate({ + "description": "Tool response content" + }), + "tool_call_id": Schema.String.annotate({ + "description": "ID of the assistant message tool call this message responds to" + }) +}).annotate({ "description": "Tool response message" }) +export type AssistantMessage = { + readonly "role": "assistant" + readonly "content"?: string | ReadonlyArray | unknown + readonly "name"?: string + readonly "tool_calls"?: ReadonlyArray + readonly "refusal"?: string + readonly "reasoning"?: string + readonly "reasoning_details"?: AssistantMessageReasoningDetails + readonly "images"?: + | ReadonlyArray<{ readonly "type": "image_url"; readonly "image_url": { readonly "url": string } }> + | null + readonly "audio"?: ChatCompletionAudioOutput + readonly "annotations"?: + | ReadonlyArray< + { + readonly "type": "url_citation" + readonly "url_citation": { + readonly "url": string + readonly "title"?: string + readonly "start_index"?: number + readonly "end_index"?: number + readonly "content"?: string + } + } | { + readonly "type": "file_annotation" + readonly "file_annotation": { readonly "file_id": string; readonly "quote"?: string } + } | { + readonly "type": "file" + readonly "file": { + readonly "hash": string + readonly "name": string + readonly "content"?: ReadonlyArray<{ readonly "type": string; readonly "text"?: string }> + } + } + > + | null +} +export const AssistantMessage = Schema.Struct({ + "role": Schema.Literal("assistant"), + "content": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Array(ChatMessageContentItem), Schema.Unknown]).annotate({ + "description": "Assistant message content" + }) + ), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the assistant" })), + "tool_calls": Schema.optionalKey( + Schema.Array(ChatMessageToolCall).annotate({ "description": "Tool calls made by the assistant" }) + ), + "refusal": Schema.optionalKey(Schema.String.annotate({ "description": "Refusal message if content was refused" })), + "reasoning": Schema.optionalKey(Schema.String.annotate({ "description": "Reasoning output" })), + "reasoning_details": Schema.optionalKey(AssistantMessageReasoningDetails), + "images": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Struct({ "type": Schema.Literal("image_url"), "image_url": Schema.Struct({ "url": Schema.String }) }) + ), + Schema.Null + ]) + ), + "audio": Schema.optionalKey(ChatCompletionAudioOutput), + "annotations": Schema.optionalKey(Schema.Union([ + Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("url_citation"), + "url_citation": Schema.Struct({ + "url": Schema.String, + "title": Schema.optionalKey(Schema.String), + "start_index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "end_index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "content": Schema.optionalKey(Schema.String) + }) + }), + Schema.Struct({ + "type": Schema.Literal("file_annotation"), + "file_annotation": Schema.Struct({ "file_id": Schema.String, "quote": Schema.optionalKey(Schema.String) }) + }), + Schema.Struct({ + "type": Schema.Literal("file"), + "file": Schema.Struct({ + "hash": Schema.String, + "name": Schema.String, + "content": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.String, "text": Schema.optionalKey(Schema.String) })) + ) + }) + }) + ], { mode: "oneOf" })), + Schema.Null + ])) +}).annotate({ "description": "Assistant message for requests and responses" }) +export type ChatStreamingMessageChunk = { + readonly "role"?: "assistant" + readonly "content"?: string + readonly "reasoning"?: string + readonly "refusal"?: string + readonly "tool_calls"?: ReadonlyArray + readonly "reasoning_details"?: AssistantMessageReasoningDetails + readonly "audio"?: { + readonly "id"?: string + readonly "expires_at"?: number + readonly "data"?: string + readonly "transcript"?: string + } + readonly "images"?: + | ReadonlyArray<{ readonly "type": "image_url"; readonly "image_url": { readonly "url": string } }> + | null + readonly "annotations"?: + | ReadonlyArray< + { + readonly "type": "url_citation" + readonly "url_citation": { + readonly "url": string + readonly "title"?: string + readonly "start_index"?: number + readonly "end_index"?: number + readonly "content"?: string + } + } | { + readonly "type": "file_annotation" + readonly "file_annotation": { readonly "file_id": string; readonly "quote"?: string } + } | { + readonly "type": "file" + readonly "file": { + readonly "hash": string + readonly "name": string + readonly "content"?: ReadonlyArray<{ readonly "type": string; readonly "text"?: string }> + } + } + > + | null +} +export const ChatStreamingMessageChunk = Schema.Struct({ + "role": Schema.optionalKey(Schema.Literal("assistant").annotate({ "description": "The role of the message author" })), + "content": Schema.optionalKey(Schema.String.annotate({ "description": "Message content delta" })), + "reasoning": Schema.optionalKey(Schema.String.annotate({ "description": "Reasoning content delta" })), + "refusal": Schema.optionalKey(Schema.String.annotate({ "description": "Refusal message delta" })), + "tool_calls": Schema.optionalKey( + Schema.Array(ChatStreamingMessageToolCall).annotate({ "description": "Tool calls delta" }) + ), + "reasoning_details": Schema.optionalKey(AssistantMessageReasoningDetails), + "audio": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "Audio output identifier" })), + "expires_at": Schema.optionalKey( + Schema.Number.annotate({ "description": "Audio expiration timestamp" }).check(Schema.isFinite()) + ), + "data": Schema.optionalKey(Schema.String.annotate({ "description": "Base64 encoded audio data" })), + "transcript": Schema.optionalKey(Schema.String.annotate({ "description": "Audio transcript" })) + }).annotate({ "description": "Audio output data" }) + ), + "images": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Struct({ "type": Schema.Literal("image_url"), "image_url": Schema.Struct({ "url": Schema.String }) }) + ), + Schema.Null + ]) + ), + "annotations": Schema.optionalKey(Schema.Union([ + Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("url_citation"), + "url_citation": Schema.Struct({ + "url": Schema.String, + "title": Schema.optionalKey(Schema.String), + "start_index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "end_index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "content": Schema.optionalKey(Schema.String) + }) + }), + Schema.Struct({ + "type": Schema.Literal("file_annotation"), + "file_annotation": Schema.Struct({ "file_id": Schema.String, "quote": Schema.optionalKey(Schema.String) }) + }), + Schema.Struct({ + "type": Schema.Literal("file"), + "file": Schema.Struct({ + "hash": Schema.String, + "name": Schema.String, + "content": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.String, "text": Schema.optionalKey(Schema.String) })) + ) + }) + }) + ], { mode: "oneOf" })), + Schema.Null + ])) +}).annotate({ "description": "Delta changes in streaming response" }) +export type ModelsListResponseData = ReadonlyArray +export const ModelsListResponseData = Schema.Array(Model).annotate({ "description": "List of available models" }) +export type OpenAIResponsesInput = + | string + | ReadonlyArray< + | { + readonly "type"?: "message" + readonly "role": "user" | "system" | "assistant" | "developer" + readonly "content": + | ReadonlyArray + | string + readonly "phase"?: "commentary" | "final_answer" | unknown + } + | { + readonly "id": string + readonly "type"?: "message" + readonly "role": "user" | "system" | "developer" + readonly "content": ReadonlyArray + } + | { + readonly "type": "function_call_output" + readonly "id"?: string + readonly "call_id": string + readonly "output": string | ReadonlyArray + readonly "status"?: ToolCallStatus + } + | { + readonly "type": "function_call" + readonly "call_id": string + readonly "name": string + readonly "arguments": string + readonly "id"?: string + readonly "status"?: ToolCallStatus + } + | OutputItemImageGenerationCall + | OutputMessage + > + | unknown +export const OpenAIResponsesInput = Schema.Union([ + Schema.String, + Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.optionalKey(Schema.Literal("message")), + "role": Schema.Literals(["user", "system", "assistant", "developer"]), + "content": Schema.Union([ + Schema.Array( + Schema.Union([ResponseInputText, ResponseInputImage, ResponseInputFile, ResponseInputAudio], { + mode: "oneOf" + }) + ), + Schema.String + ]), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]) + ) + }), + Schema.Struct({ + "id": Schema.String, + "type": Schema.optionalKey(Schema.Literal("message")), + "role": Schema.Literals(["user", "system", "developer"]), + "content": Schema.Array( + Schema.Union([ResponseInputText, ResponseInputImage, ResponseInputFile, ResponseInputAudio], { mode: "oneOf" }) + ) + }), + Schema.Struct({ + "type": Schema.Literal("function_call_output"), + "id": Schema.optionalKey(Schema.String), + "call_id": Schema.String, + "output": Schema.Union([ + Schema.String, + Schema.Array(Schema.Union([ResponseInputText, ResponseInputImage, ResponseInputFile], { mode: "oneOf" })) + ]), + "status": Schema.optionalKey(ToolCallStatus) + }), + Schema.Struct({ + "type": Schema.Literal("function_call"), + "call_id": Schema.String, + "name": Schema.String, + "arguments": Schema.String, + "id": Schema.optionalKey(Schema.String), + "status": Schema.optionalKey(ToolCallStatus) + }), + OutputItemImageGenerationCall, + OutputMessage + ])), + Schema.Unknown +]) +export type OpenResponsesOutputItemAddedEvent = { + readonly "type": "response.output_item.added" + readonly "output_index": number + readonly "item": + | OutputMessage + | OutputItemReasoning + | OutputItemFunctionCall + | OutputItemWebSearchCall + | OutputItemFileSearchCall + | OutputItemImageGenerationCall + readonly "sequence_number": number +} +export const OpenResponsesOutputItemAddedEvent = Schema.Struct({ + "type": Schema.Literal("response.output_item.added"), + "output_index": Schema.Number.check(Schema.isFinite()), + "item": Schema.Union([ + OutputMessage, + OutputItemReasoning, + OutputItemFunctionCall, + OutputItemWebSearchCall, + OutputItemFileSearchCall, + OutputItemImageGenerationCall + ], { mode: "oneOf" }), + "sequence_number": Schema.Number.check(Schema.isFinite()) +}).annotate({ "description": "Event emitted when a new output item is added to the response" }) +export type OpenResponsesOutputItemDoneEvent = { + readonly "type": "response.output_item.done" + readonly "output_index": number + readonly "item": + | OutputMessage + | OutputItemReasoning + | OutputItemFunctionCall + | OutputItemWebSearchCall + | OutputItemFileSearchCall + | OutputItemImageGenerationCall + readonly "sequence_number": number +} +export const OpenResponsesOutputItemDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.output_item.done"), + "output_index": Schema.Number.check(Schema.isFinite()), + "item": Schema.Union([ + OutputMessage, + OutputItemReasoning, + OutputItemFunctionCall, + OutputItemWebSearchCall, + OutputItemFileSearchCall, + OutputItemImageGenerationCall + ], { mode: "oneOf" }), + "sequence_number": Schema.Number.check(Schema.isFinite()) +}).annotate({ "description": "Event emitted when an output item is complete" }) +export type OpenResponsesRequest = { + readonly "input"?: OpenResponsesInput + readonly "instructions"?: string + readonly "metadata"?: OpenResponsesRequestMetadata + readonly "tools"?: ReadonlyArray< + | { + readonly "type": "function" + readonly "name": string + readonly "description"?: string + readonly "strict"?: boolean + readonly "parameters": {} + } + | OpenResponsesWebSearchPreviewTool + | OpenResponsesWebSearchPreview20250311Tool + | OpenResponsesWebSearchTool + | OpenResponsesWebSearch20250826Tool + | OpenResponsesFileSearchTool + | OpenResponsesComputerTool + | OpenResponsesCodeInterpreterTool + | OpenResponsesMcpTool + | OpenResponsesImageGenerationTool + | OpenResponsesLocalShellTool + | OpenResponsesFunctionShellTool + | OpenResponsesApplyPatchTool + | OpenResponsesCustomTool + > + readonly "tool_choice"?: OpenAIResponsesToolChoice + readonly "parallel_tool_calls"?: boolean + readonly "model"?: string + readonly "models"?: ReadonlyArray + readonly "text"?: OpenResponsesResponseText + readonly "reasoning"?: OpenResponsesReasoningConfig + readonly "max_output_tokens"?: number + readonly "temperature"?: number + readonly "top_p"?: number + readonly "top_logprobs"?: number + readonly "max_tool_calls"?: number + readonly "presence_penalty"?: number + readonly "frequency_penalty"?: number + readonly "top_k"?: number + readonly "image_config"?: {} + readonly "modalities"?: ReadonlyArray + readonly "prompt_cache_key"?: string + readonly "previous_response_id"?: string + readonly "prompt"?: OpenAIResponsesPrompt + readonly "include"?: ReadonlyArray + readonly "background"?: boolean + readonly "safety_identifier"?: string + readonly "store"?: false + readonly "service_tier"?: "auto" + readonly "truncation"?: "auto" | "disabled" + readonly "stream"?: boolean + readonly "provider"?: { + readonly "allow_fallbacks"?: boolean + readonly "require_parameters"?: boolean + readonly "data_collection"?: DataCollection + readonly "zdr"?: boolean + readonly "enforce_distillable_text"?: boolean + readonly "order"?: ReadonlyArray + readonly "only"?: ReadonlyArray + readonly "ignore"?: ReadonlyArray + readonly "quantizations"?: ReadonlyArray + readonly "sort"?: ProviderSort | ProviderSortConfig | unknown + readonly "max_price"?: { + readonly "prompt"?: BigNumberUnion + readonly "completion"?: string + readonly "image"?: string + readonly "audio"?: string + readonly "request"?: string + } + readonly "preferred_min_throughput"?: PreferredMinThroughput + readonly "preferred_max_latency"?: PreferredMaxLatency + } + readonly "plugins"?: ReadonlyArray< + | { readonly "id": "auto-router"; readonly "enabled"?: boolean; readonly "allowed_models"?: ReadonlyArray } + | { readonly "id": "moderation" } + | { + readonly "id": "web" + readonly "enabled"?: boolean + readonly "max_results"?: number + readonly "search_prompt"?: string + readonly "engine"?: WebSearchEngine + readonly "include_domains"?: ReadonlyArray + readonly "exclude_domains"?: ReadonlyArray + } + | { readonly "id": "file-parser"; readonly "enabled"?: boolean; readonly "pdf"?: PDFParserOptions } + | { readonly "id": "response-healing"; readonly "enabled"?: boolean } + > + readonly "route"?: "fallback" | "sort" + readonly "user"?: string + readonly "session_id"?: string + readonly "trace"?: { + readonly "trace_id"?: string + readonly "trace_name"?: string + readonly "span_name"?: string + readonly "generation_name"?: string + readonly "parent_span_id"?: string + } +} +export const OpenResponsesRequest = Schema.Struct({ + "input": Schema.optionalKey(OpenResponsesInput), + "instructions": Schema.optionalKey(Schema.String), + "metadata": Schema.optionalKey(OpenResponsesRequestMetadata), + "tools": Schema.optionalKey( + Schema.Array( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("function"), + "name": Schema.String, + "description": Schema.optionalKey(Schema.String), + "strict": Schema.optionalKey(Schema.Boolean), + "parameters": Schema.Struct({}) + }).annotate({ "description": "Function tool definition" }), + OpenResponsesWebSearchPreviewTool, + OpenResponsesWebSearchPreview20250311Tool, + OpenResponsesWebSearchTool, + OpenResponsesWebSearch20250826Tool, + OpenResponsesFileSearchTool, + OpenResponsesComputerTool, + OpenResponsesCodeInterpreterTool, + OpenResponsesMcpTool, + OpenResponsesImageGenerationTool, + OpenResponsesLocalShellTool, + OpenResponsesFunctionShellTool, + OpenResponsesApplyPatchTool, + OpenResponsesCustomTool + ], { mode: "oneOf" }) + ) + ), + "tool_choice": Schema.optionalKey(OpenAIResponsesToolChoice), + "parallel_tool_calls": Schema.optionalKey(Schema.Boolean), + "model": Schema.optionalKey(Schema.String), + "models": Schema.optionalKey(Schema.Array(Schema.String)), + "text": Schema.optionalKey(OpenResponsesResponseText), + "reasoning": Schema.optionalKey(OpenResponsesReasoningConfig), + "max_output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "temperature": Schema.optionalKey( + Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(2)) ), - "route": Schema.optionalKey( - Schema.Literals(["fallback", "sort"]).annotate({ - "description": - "**DEPRECATED** Use providers.sort.partition instead. Backwards-compatible alias for providers.sort.partition. Accepts legacy values: \"fallback\" (maps to \"model\"), \"sort\" (maps to \"none\")." - }) + "top_p": Schema.optionalKey(Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0))), + "top_logprobs": Schema.optionalKey( + Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)) ), - "user": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters." - }).check(Schema.isMaxLength(128)) + "max_tool_calls": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "presence_penalty": Schema.optionalKey( + Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(-2)).check(Schema.isLessThanOrEqualTo(2)) ), - "session_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters." - }).check(Schema.isMaxLength(128)) + "frequency_penalty": Schema.optionalKey( + Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(-2)).check(Schema.isLessThanOrEqualTo(2)) ), - "trace": Schema.optionalKey( - Schema.Struct({ - "trace_id": Schema.optionalKey(Schema.String), - "trace_name": Schema.optionalKey(Schema.String), - "span_name": Schema.optionalKey(Schema.String), - "generation_name": Schema.optionalKey(Schema.String), - "parent_span_id": Schema.optionalKey(Schema.String) - }).annotate({ + "top_k": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "image_config": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": - "Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations." + "Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/features/multimodal/image-generation for more details." }) ), - "models": Schema.optionalKey(Schema.Array(Schema.String)), - "output_config": Schema.optionalKey(AnthropicOutputConfig) -}).annotate({ "description": "Request schema for Anthropic Messages API endpoint" }) -export type Model = { - readonly "id": string - readonly "canonical_slug": string - readonly "hugging_face_id"?: string - readonly "name": string - readonly "created": number - readonly "description"?: string - readonly "pricing": PublicPricing - readonly "context_length": number - readonly "architecture": ModelArchitecture - readonly "top_provider": TopProviderInfo - readonly "per_request_limits": PerRequestLimits - readonly "supported_parameters": ReadonlyArray - readonly "default_parameters": DefaultParameters - readonly "expiration_date"?: string -} -export const Model = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), - "canonical_slug": Schema.String.annotate({ "description": "Canonical slug for the model" }), - "hugging_face_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Hugging Face model identifier, if applicable" }) - ), - "name": Schema.String.annotate({ "description": "Display name of the model" }), - "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( - Schema.isFinite() - ), - "description": Schema.optionalKey(Schema.String.annotate({ "description": "Description of the model" })), - "pricing": PublicPricing, - "context_length": Schema.Number.annotate({ "description": "Maximum context length in tokens" }).check( - Schema.isFinite() - ), - "architecture": ModelArchitecture, - "top_provider": TopProviderInfo, - "per_request_limits": PerRequestLimits, - "supported_parameters": Schema.Array(Parameter).annotate({ - "description": "List of supported parameters for this model" - }), - "default_parameters": DefaultParameters, - "expiration_date": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The date after which the model may be removed. ISO 8601 date string (YYYY-MM-DD) or null if no expiration." + "modalities": Schema.optionalKey( + Schema.Array(ResponsesOutputModality).annotate({ + "description": "Output modalities for the response. Supported values are \"text\" and \"image\"." }) - ) -}).annotate({ "description": "Information about an AI model available on OpenRouter" }) -export type ListEndpointsResponse = { - readonly "id": string - readonly "name": string - readonly "created": number - readonly "description": string - readonly "architecture": { - readonly "tokenizer": - | "Router" - | "Media" - | "Other" - | "GPT" - | "Claude" - | "Gemini" - | "Grok" - | "Cohere" - | "Nova" - | "Qwen" - | "Yi" - | "DeepSeek" - | "Mistral" - | "Llama2" - | "Llama3" - | "Llama4" - | "PaLM" - | "RWKV" - | "Qwen3" - readonly "instruct_type": - | "none" - | "airoboros" - | "alpaca" - | "alpaca-modif" - | "chatml" - | "claude" - | "code-llama" - | "gemma" - | "llama2" - | "llama3" - | "mistral" - | "nemotron" - | "neural" - | "openchat" - | "phi3" - | "rwkv" - | "vicuna" - | "zephyr" - | "deepseek-r1" - | "deepseek-v3.1" - | "qwq" - | "qwen3" - readonly "modality": string - readonly "input_modalities": ReadonlyArray<"text" | "image" | "file" | "audio" | "video"> - readonly "output_modalities": ReadonlyArray<"text" | "image" | "embeddings" | "audio"> - } - readonly "endpoints": ReadonlyArray -} -export const ListEndpointsResponse = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), - "name": Schema.String.annotate({ "description": "Display name of the model" }), - "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( - Schema.isFinite() ), - "description": Schema.String.annotate({ "description": "Description of the model" }), - "architecture": Schema.Struct({ - "tokenizer": Schema.Union([ - Schema.Literal("Router").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Media").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Other").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("GPT").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Claude").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Gemini").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Grok").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Cohere").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Nova").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Qwen").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Yi").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("DeepSeek").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Mistral").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Llama2").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Llama3").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Llama4").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("PaLM").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("RWKV").annotate({ "description": "Tokenizer type used by the model" }), - Schema.Literal("Qwen3").annotate({ "description": "Tokenizer type used by the model" }) - ]).annotate({ "description": "Tokenizer type used by the model" }), - "instruct_type": Schema.Union([ - Schema.Literal("none").annotate({ "description": "Instruction format type" }), - Schema.Literal("airoboros").annotate({ "description": "Instruction format type" }), - Schema.Literal("alpaca").annotate({ "description": "Instruction format type" }), - Schema.Literal("alpaca-modif").annotate({ "description": "Instruction format type" }), - Schema.Literal("chatml").annotate({ "description": "Instruction format type" }), - Schema.Literal("claude").annotate({ "description": "Instruction format type" }), - Schema.Literal("code-llama").annotate({ "description": "Instruction format type" }), - Schema.Literal("gemma").annotate({ "description": "Instruction format type" }), - Schema.Literal("llama2").annotate({ "description": "Instruction format type" }), - Schema.Literal("llama3").annotate({ "description": "Instruction format type" }), - Schema.Literal("mistral").annotate({ "description": "Instruction format type" }), - Schema.Literal("nemotron").annotate({ "description": "Instruction format type" }), - Schema.Literal("neural").annotate({ "description": "Instruction format type" }), - Schema.Literal("openchat").annotate({ "description": "Instruction format type" }), - Schema.Literal("phi3").annotate({ "description": "Instruction format type" }), - Schema.Literal("rwkv").annotate({ "description": "Instruction format type" }), - Schema.Literal("vicuna").annotate({ "description": "Instruction format type" }), - Schema.Literal("zephyr").annotate({ "description": "Instruction format type" }), - Schema.Literal("deepseek-r1").annotate({ "description": "Instruction format type" }), - Schema.Literal("deepseek-v3.1").annotate({ "description": "Instruction format type" }), - Schema.Literal("qwq").annotate({ "description": "Instruction format type" }), - Schema.Literal("qwen3").annotate({ "description": "Instruction format type" }) - ]).annotate({ "description": "Instruction format type" }), - "modality": Schema.String.annotate({ "description": "Primary modality of the model" }), - "input_modalities": Schema.Array( - Schema.Union([ - Schema.Literal("text"), - Schema.Literal("image"), - Schema.Literal("file"), - Schema.Literal("audio"), - Schema.Literal("video") - ]) - ).annotate({ "description": "Supported input modalities" }), - "output_modalities": Schema.Array( - Schema.Union([ - Schema.Literal("text"), - Schema.Literal("image"), - Schema.Literal("embeddings"), - Schema.Literal("audio") - ]) - ).annotate({ "description": "Supported output modalities" }) - }).annotate({ "description": "Model architecture information" }), - "endpoints": Schema.Array(PublicEndpoint).annotate({ "description": "List of available endpoints for this model" }) -}).annotate({ "description": "List of available endpoints for a model" }) -export type ChatStreamingMessageChunk = { - readonly "role"?: "assistant" - readonly "content"?: string | null - readonly "reasoning"?: string | null - readonly "refusal"?: string | null - readonly "tool_calls"?: ReadonlyArray - readonly "reasoning_details"?: ReadonlyArray<__schema20> - readonly "images"?: - | ReadonlyArray<{ readonly "type": "image_url"; readonly "image_url": { readonly "url": string } }> - | null - readonly "annotations"?: - | ReadonlyArray< - { - readonly "type": "url_citation" - readonly "url_citation": { - readonly "url": string - readonly "title"?: string - readonly "start_index"?: number - readonly "end_index"?: number - readonly "content"?: string - } - } | { - readonly "type": "file_annotation" - readonly "file_annotation": { readonly "file_id": string; readonly "quote"?: string } - } | { - readonly "type": "file" - readonly "file": { - readonly "hash": string - readonly "name": string - readonly "content"?: ReadonlyArray<{ readonly "type": string; readonly "text"?: string }> - } - } - > - | null -} -export const ChatStreamingMessageChunk = Schema.Struct({ - "role": Schema.optionalKey(Schema.Literal("assistant")), - "content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "reasoning": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "refusal": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "tool_calls": Schema.optionalKey(Schema.Array(ChatStreamingMessageToolCall)), - "reasoning_details": Schema.optionalKey(Schema.Array(__schema20)), - "images": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Struct({ "type": Schema.Literal("image_url"), "image_url": Schema.Struct({ "url": Schema.String }) }) + "prompt_cache_key": Schema.optionalKey(Schema.String), + "previous_response_id": Schema.optionalKey(Schema.String), + "prompt": Schema.optionalKey(OpenAIResponsesPrompt), + "include": Schema.optionalKey(Schema.Array(OpenAIResponsesIncludable)), + "background": Schema.optionalKey(Schema.Boolean), + "safety_identifier": Schema.optionalKey(Schema.String), + "store": Schema.optionalKey(Schema.Literal(false)), + "service_tier": Schema.optionalKey(Schema.Literal("auto")), + "truncation": Schema.optionalKey(Schema.Literals(["auto", "disabled"])), + "stream": Schema.optionalKey(Schema.Boolean), + "provider": Schema.optionalKey( + Schema.Struct({ + "allow_fallbacks": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "Whether to allow backup providers to serve requests\n- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.\n- false: use only the primary/custom provider, and return the upstream error if it's unavailable.\n" + })), + "require_parameters": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest." + }) ), - Schema.Null - ]) - ), - "annotations": Schema.optionalKey(Schema.Union([ - Schema.Array(Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("url_citation"), - "url_citation": Schema.Struct({ - "url": Schema.String, - "title": Schema.optionalKey(Schema.String), - "start_index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "end_index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "content": Schema.optionalKey(Schema.String) + "data_collection": Schema.optionalKey(DataCollection), + "zdr": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used." }) - }), - Schema.Struct({ - "type": Schema.Literal("file_annotation"), - "file_annotation": Schema.Struct({ "file_id": Schema.String, "quote": Schema.optionalKey(Schema.String) }) - }), - Schema.Struct({ - "type": Schema.Literal("file"), - "file": Schema.Struct({ - "hash": Schema.String, - "name": Schema.String, - "content": Schema.optionalKey( - Schema.Array(Schema.Struct({ "type": Schema.String, "text": Schema.optionalKey(Schema.String) })) - ) + ), + "enforce_distillable_text": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used." }) - }) - ], { mode: "oneOf" })), - Schema.Null - ])) -}) -export type ChatMessageContentItem = - | ChatMessageContentItemText - | ChatMessageContentItemImage - | ChatMessageContentItemAudio - | ChatMessageContentItemVideo -export const ChatMessageContentItem = Schema.Union([ - ChatMessageContentItemText, - ChatMessageContentItemImage, - ChatMessageContentItemAudio, - ChatMessageContentItemVideo -], { mode: "oneOf" }) -export type SystemMessage = { - readonly "role": "system" - readonly "content": string | ReadonlyArray - readonly "name"?: string -} -export const SystemMessage = Schema.Struct({ - "role": Schema.Literal("system"), - "content": Schema.Union([Schema.String, Schema.Array(ChatMessageContentItemText)]), - "name": Schema.optionalKey(Schema.String) -}) -export type DeveloperMessage = { - readonly "role": "developer" - readonly "content": string | ReadonlyArray - readonly "name"?: string -} -export const DeveloperMessage = Schema.Struct({ - "role": Schema.Literal("developer"), - "content": Schema.Union([Schema.String, Schema.Array(ChatMessageContentItemText)]), - "name": Schema.optionalKey(Schema.String) -}) -export type OutputMessage = { - readonly "id": string - readonly "role": "assistant" - readonly "type": "message" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "content": ReadonlyArray -} -export const OutputMessage = Schema.Struct({ - "id": Schema.String, - "role": Schema.Literal("assistant"), - "type": Schema.Literal("message"), - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])) -}) -export type ResponsesOutputMessage = { - readonly "id": string - readonly "role": "assistant" - readonly "type": "message" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "content": ReadonlyArray -} -export const ResponsesOutputMessage = Schema.Struct({ - "id": Schema.String, - "role": Schema.Literal("assistant"), - "type": Schema.Literal("message"), - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])) -}).annotate({ "description": "An output message item" }) -export type OpenResponsesContentPartAddedEvent = { - readonly "type": "response.content_part.added" - readonly "output_index": number - readonly "item_id": string - readonly "content_index": number - readonly "part": ResponseOutputText | OpenAIResponsesRefusalContent - readonly "sequence_number": number -} -export const OpenResponsesContentPartAddedEvent = Schema.Struct({ - "type": Schema.Literal("response.content_part.added"), - "output_index": Schema.Number.check(Schema.isFinite()), - "item_id": Schema.String, - "content_index": Schema.Number.check(Schema.isFinite()), - "part": Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent]), - "sequence_number": Schema.Number.check(Schema.isFinite()) -}).annotate({ "description": "Event emitted when a new content part is added to an output item" }) -export type OpenResponsesContentPartDoneEvent = { - readonly "type": "response.content_part.done" - readonly "output_index": number - readonly "item_id": string - readonly "content_index": number - readonly "part": ResponseOutputText | OpenAIResponsesRefusalContent - readonly "sequence_number": number -} -export const OpenResponsesContentPartDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.content_part.done"), - "output_index": Schema.Number.check(Schema.isFinite()), - "item_id": Schema.String, - "content_index": Schema.Number.check(Schema.isFinite()), - "part": Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent]), - "sequence_number": Schema.Number.check(Schema.isFinite()) -}).annotate({ "description": "Event emitted when a content part is complete" }) -export type ModelsListResponseData = ReadonlyArray -export const ModelsListResponseData = Schema.Array(Model).annotate({ "description": "List of available models" }) -export type ChatStreamingChoice = { - readonly "delta": ChatStreamingMessageChunk - readonly "finish_reason"?: __schema26 - readonly "index": number - readonly "logprobs"?: ChatMessageTokenLogprobs | null -} -export const ChatStreamingChoice = Schema.Struct({ - "delta": ChatStreamingMessageChunk, - "finish_reason": Schema.optionalKey(__schema26), - "index": Schema.Number.check(Schema.isFinite()), - "logprobs": Schema.optionalKey(Schema.Union([ChatMessageTokenLogprobs, Schema.Null])) -}) -export type UserMessage = { - readonly "role": "user" - readonly "content": string | ReadonlyArray - readonly "name"?: string -} -export const UserMessage = Schema.Struct({ - "role": Schema.Literal("user"), - "content": Schema.Union([Schema.String, Schema.Array(ChatMessageContentItem)]), - "name": Schema.optionalKey(Schema.String) -}) -export type AssistantMessage = { - readonly "role": "assistant" - readonly "content"?: string | ReadonlyArray | null - readonly "name"?: string - readonly "tool_calls"?: ReadonlyArray - readonly "refusal"?: string | null - readonly "reasoning"?: string | null - readonly "reasoning_details"?: ReadonlyArray<__schema20> - readonly "images"?: - | ReadonlyArray<{ readonly "type": "image_url"; readonly "image_url": { readonly "url": string } }> - | null - readonly "annotations"?: - | ReadonlyArray< - { - readonly "type": "url_citation" - readonly "url_citation": { - readonly "url": string - readonly "title"?: string - readonly "start_index"?: number - readonly "end_index"?: number - readonly "content"?: string - } - } | { - readonly "type": "file_annotation" - readonly "file_annotation": { readonly "file_id": string; readonly "quote"?: string } - } | { - readonly "type": "file" - readonly "file": { - readonly "hash": string - readonly "name": string - readonly "content"?: ReadonlyArray<{ readonly "type": string; readonly "text"?: string }> - } - } - > - | null -} -export const AssistantMessage = Schema.Struct({ - "role": Schema.Literal("assistant"), - "content": Schema.optionalKey( - Schema.Union([Schema.Union([Schema.String, Schema.Array(ChatMessageContentItem)]), Schema.Null]) - ), - "name": Schema.optionalKey(Schema.String), - "tool_calls": Schema.optionalKey(Schema.Array(ChatMessageToolCall)), - "refusal": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "reasoning": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "reasoning_details": Schema.optionalKey(Schema.Array(__schema20)), - "images": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Struct({ "type": Schema.Literal("image_url"), "image_url": Schema.Struct({ "url": Schema.String }) }) ), - Schema.Null - ]) + "order": Schema.optionalKey( + Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ + "description": + "An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message." + }) + ), + "only": Schema.optionalKey( + Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ + "description": + "List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request." + }) + ), + "ignore": Schema.optionalKey( + Schema.Array(Schema.Union([ProviderName, Schema.String])).annotate({ + "description": + "List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request." + }) + ), + "quantizations": Schema.optionalKey( + Schema.Array(Quantization).annotate({ + "description": "A list of quantization levels to filter the provider by." + }) + ), + "sort": Schema.optionalKey( + Schema.Union([ProviderSort, ProviderSortConfig, Schema.Unknown]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }) + ), + "max_price": Schema.optionalKey( + Schema.Struct({ + "prompt": Schema.optionalKey(BigNumberUnion), + "completion": Schema.optionalKey( + Schema.String.annotate({ "description": "Price per million completion tokens" }) + ), + "image": Schema.optionalKey(Schema.String.annotate({ "description": "Price per image" })), + "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Price per audio unit" })), + "request": Schema.optionalKey(Schema.String.annotate({ "description": "Price per request" })) + }).annotate({ + "description": + "The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion." + }) + ), + "preferred_min_throughput": Schema.optionalKey(PreferredMinThroughput), + "preferred_max_latency": Schema.optionalKey(PreferredMaxLatency) + }).annotate({ + "description": "When multiple model providers are available, optionally indicate your routing preference." + }) ), - "annotations": Schema.optionalKey(Schema.Union([ + "plugins": Schema.optionalKey( Schema.Array(Schema.Union([ Schema.Struct({ - "type": Schema.Literal("url_citation"), - "url_citation": Schema.Struct({ - "url": Schema.String, - "title": Schema.optionalKey(Schema.String), - "start_index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "end_index": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "content": Schema.optionalKey(Schema.String) - }) + "id": Schema.Literal("auto-router"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the auto-router plugin for this request. Defaults to true." + }) + ), + "allowed_models": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list." + }) + ) }), + Schema.Struct({ "id": Schema.Literal("moderation") }), Schema.Struct({ - "type": Schema.Literal("file_annotation"), - "file_annotation": Schema.Struct({ "file_id": Schema.String, "quote": Schema.optionalKey(Schema.String) }) + "id": Schema.Literal("web"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the web-search plugin for this request. Defaults to true." + }) + ), + "max_results": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "search_prompt": Schema.optionalKey(Schema.String), + "engine": Schema.optionalKey(WebSearchEngine), + "include_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")." + }) + ), + "exclude_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")." + }) + ) }), Schema.Struct({ - "type": Schema.Literal("file"), - "file": Schema.Struct({ - "hash": Schema.String, - "name": Schema.String, - "content": Schema.optionalKey( - Schema.Array(Schema.Struct({ "type": Schema.String, "text": Schema.optionalKey(Schema.String) })) - ) - }) - }) - ], { mode: "oneOf" })), - Schema.Null - ])) -}) -export type ToolResponseMessage = { - readonly "role": "tool" - readonly "content": string | ReadonlyArray - readonly "tool_call_id": string -} -export const ToolResponseMessage = Schema.Struct({ - "role": Schema.Literal("tool"), - "content": Schema.Union([Schema.String, Schema.Array(ChatMessageContentItem)]), - "tool_call_id": Schema.String -}) -export type OpenAIResponsesInput = - | string - | ReadonlyArray< - | { - readonly "type"?: "message" - readonly "role": "user" | "system" | "assistant" | "developer" - readonly "content": - | ReadonlyArray - | string - } - | { - readonly "id": string - readonly "type"?: "message" - readonly "role": "user" | "system" | "developer" - readonly "content": ReadonlyArray - } - | { - readonly "type": "function_call_output" - readonly "id"?: string - readonly "call_id": string - readonly "output": string - readonly "status"?: ToolCallStatus - } - | { - readonly "type": "function_call" - readonly "call_id": string - readonly "name": string - readonly "arguments": string - readonly "id"?: string - readonly "status"?: ToolCallStatus - } - | OutputItemImageGenerationCall - | OutputMessage - > - | unknown -export const OpenAIResponsesInput = Schema.Union([ - Schema.String, - Schema.Array(Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey(Schema.Literal("message")), - "role": Schema.Literals(["user", "system", "assistant", "developer"]), - "content": Schema.Union([ - Schema.Array( - Schema.Union([ResponseInputText, ResponseInputImage, ResponseInputFile, ResponseInputAudio], { - mode: "oneOf" + "id": Schema.Literal("file-parser"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the file-parser plugin for this request. Defaults to true." }) ), - Schema.String - ]) - }), - Schema.Struct({ - "id": Schema.String, - "type": Schema.optionalKey(Schema.Literal("message")), - "role": Schema.Literals(["user", "system", "developer"]), - "content": Schema.Array( - Schema.Union([ResponseInputText, ResponseInputImage, ResponseInputFile, ResponseInputAudio], { mode: "oneOf" }) - ) - }), - Schema.Struct({ - "type": Schema.Literal("function_call_output"), - "id": Schema.optionalKey(Schema.String), - "call_id": Schema.String, - "output": Schema.String, - "status": Schema.optionalKey(ToolCallStatus) - }), - Schema.Struct({ - "type": Schema.Literal("function_call"), - "call_id": Schema.String, - "name": Schema.String, - "arguments": Schema.String, - "id": Schema.optionalKey(Schema.String), - "status": Schema.optionalKey(ToolCallStatus) - }), - OutputItemImageGenerationCall, - OutputMessage - ])), - Schema.Unknown -]) -export type OpenResponsesOutputItemAddedEvent = { - readonly "type": "response.output_item.added" - readonly "output_index": number - readonly "item": - | OutputMessage - | OutputItemReasoning - | OutputItemFunctionCall - | OutputItemWebSearchCall - | OutputItemFileSearchCall - | OutputItemImageGenerationCall - readonly "sequence_number": number -} -export const OpenResponsesOutputItemAddedEvent = Schema.Struct({ - "type": Schema.Literal("response.output_item.added"), - "output_index": Schema.Number.check(Schema.isFinite()), - "item": Schema.Union([ - OutputMessage, - OutputItemReasoning, - OutputItemFunctionCall, - OutputItemWebSearchCall, - OutputItemFileSearchCall, - OutputItemImageGenerationCall - ], { mode: "oneOf" }), - "sequence_number": Schema.Number.check(Schema.isFinite()) -}).annotate({ "description": "Event emitted when a new output item is added to the response" }) -export type OpenResponsesOutputItemDoneEvent = { - readonly "type": "response.output_item.done" - readonly "output_index": number - readonly "item": - | OutputMessage - | OutputItemReasoning - | OutputItemFunctionCall - | OutputItemWebSearchCall - | OutputItemFileSearchCall - | OutputItemImageGenerationCall - readonly "sequence_number": number -} -export const OpenResponsesOutputItemDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.output_item.done"), - "output_index": Schema.Number.check(Schema.isFinite()), - "item": Schema.Union([ - OutputMessage, - OutputItemReasoning, - OutputItemFunctionCall, - OutputItemWebSearchCall, - OutputItemFileSearchCall, - OutputItemImageGenerationCall - ], { mode: "oneOf" }), - "sequence_number": Schema.Number.check(Schema.isFinite()) -}).annotate({ "description": "Event emitted when an output item is complete" }) -export type OpenResponsesInput = - | string - | ReadonlyArray< - | OpenResponsesReasoning - | OpenResponsesEasyInputMessage - | OpenResponsesInputMessageItem - | OpenResponsesFunctionToolCall - | OpenResponsesFunctionCallOutput - | ResponsesOutputMessage - | ResponsesOutputItemReasoning - | ResponsesOutputItemFunctionCall - | ResponsesWebSearchCallOutput - | ResponsesOutputItemFileSearchCall - | ResponsesImageGenerationCall - > -export const OpenResponsesInput = Schema.Union([ - Schema.String, - Schema.Array( - Schema.Union([ - OpenResponsesReasoning, - OpenResponsesEasyInputMessage, - OpenResponsesInputMessageItem, - OpenResponsesFunctionToolCall, - OpenResponsesFunctionCallOutput, - ResponsesOutputMessage, - ResponsesOutputItemReasoning, - ResponsesOutputItemFunctionCall, - ResponsesWebSearchCallOutput, - ResponsesOutputItemFileSearchCall, - ResponsesImageGenerationCall - ]) - ) -]).annotate({ "description": "Input for a response request - can be a string or array of items" }) -export type ModelsListResponse = { readonly "data": ModelsListResponseData } -export const ModelsListResponse = Schema.Struct({ "data": ModelsListResponseData }).annotate({ - "description": "List of available models" -}) -export type ChatStreamingResponseChunk = { - readonly "data": { - readonly "id": string - readonly "choices": ReadonlyArray - readonly "created": number - readonly "model": string - readonly "object": "chat.completion.chunk" - readonly "system_fingerprint"?: string | null - readonly "error"?: { readonly "message": string; readonly "code": number } - readonly "usage"?: ChatGenerationTokenUsage - } -} -export const ChatStreamingResponseChunk = Schema.Struct({ - "data": Schema.Struct({ - "id": Schema.String, - "choices": Schema.Array(ChatStreamingChoice), - "created": Schema.Number.check(Schema.isFinite()), - "model": Schema.String, - "object": Schema.Literal("chat.completion.chunk"), - "system_fingerprint": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "error": Schema.optionalKey( - Schema.Struct({ "message": Schema.String, "code": Schema.Number.check(Schema.isFinite()) }) - ), - "usage": Schema.optionalKey(ChatGenerationTokenUsage) - }) -}) + "pdf": Schema.optionalKey(PDFParserOptions) + }), + Schema.Struct({ + "id": Schema.Literal("response-healing"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the response-healing plugin for this request. Defaults to true." + }) + ) + }) + ], { mode: "oneOf" })).annotate({ + "description": "Plugins you want to enable for this request, including their settings." + }) + ), + "route": Schema.optionalKey( + Schema.Literals(["fallback", "sort"]).annotate({ + "description": + "**DEPRECATED** Use providers.sort.partition instead. Backwards-compatible alias for providers.sort.partition. Accepts legacy values: \"fallback\" (maps to \"model\"), \"sort\" (maps to \"none\")." + }) + ), + "user": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters." + }).check(Schema.isMaxLength(128)) + ), + "session_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters." + }).check(Schema.isMaxLength(128)) + ), + "trace": Schema.optionalKey( + Schema.Struct({ + "trace_id": Schema.optionalKey(Schema.String), + "trace_name": Schema.optionalKey(Schema.String), + "span_name": Schema.optionalKey(Schema.String), + "generation_name": Schema.optionalKey(Schema.String), + "parent_span_id": Schema.optionalKey(Schema.String) + }).annotate({ + "description": + "Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations." + }) + ) +}).annotate({ "description": "Request schema for Responses endpoint" }) export type ChatResponseChoice = { - readonly "finish_reason": __schema26 + readonly "finish_reason": ChatCompletionFinishReason | unknown | unknown readonly "index": number readonly "message": AssistantMessage - readonly "logprobs"?: ChatMessageTokenLogprobs | null + readonly "logprobs"?: ChatMessageTokenLogprobs } export const ChatResponseChoice = Schema.Struct({ - "finish_reason": __schema26, - "index": Schema.Number.check(Schema.isFinite()), + "finish_reason": Schema.Union([ChatCompletionFinishReason, Schema.Unknown, Schema.Unknown]), + "index": Schema.Number.annotate({ "description": "Choice index" }).check(Schema.isFinite()), "message": AssistantMessage, - "logprobs": Schema.optionalKey(Schema.Union([ChatMessageTokenLogprobs, Schema.Null])) -}) + "logprobs": Schema.optionalKey(ChatMessageTokenLogprobs) +}).annotate({ "description": "Chat completion choice" }) export type Message = SystemMessage | UserMessage | DeveloperMessage | AssistantMessage | ToolResponseMessage export const Message = Schema.Union([ SystemMessage, @@ -4961,7 +7762,23 @@ export const Message = Schema.Union([ DeveloperMessage, AssistantMessage, ToolResponseMessage -], { mode: "oneOf" }) +], { mode: "oneOf" }).annotate({ "description": "Chat completion message with role-based discrimination" }) +export type ChatStreamingChoice = { + readonly "delta": ChatStreamingMessageChunk + readonly "finish_reason"?: ChatCompletionFinishReason | unknown | unknown + readonly "index": number + readonly "logprobs"?: ChatMessageTokenLogprobs +} +export const ChatStreamingChoice = Schema.Struct({ + "delta": ChatStreamingMessageChunk, + "finish_reason": Schema.optionalKey(Schema.Union([ChatCompletionFinishReason, Schema.Unknown, Schema.Unknown])), + "index": Schema.Number.annotate({ "description": "Choice index" }).check(Schema.isFinite()), + "logprobs": Schema.optionalKey(ChatMessageTokenLogprobs) +}).annotate({ "description": "Streaming completion choice chunk" }) +export type ModelsListResponse = { readonly "data": ModelsListResponseData } +export const ModelsListResponse = Schema.Struct({ "data": ModelsListResponseData }).annotate({ + "description": "List of available models" +}) export type OpenAIResponsesNonStreamingResponse = { readonly "id": string readonly "object": "response" @@ -5005,6 +7822,15 @@ export type OpenAIResponsesNonStreamingResponse = { | OpenResponsesWebSearchPreview20250311Tool | OpenResponsesWebSearchTool | OpenResponsesWebSearch20250826Tool + | OpenResponsesFileSearchTool + | OpenResponsesComputerTool + | OpenResponsesCodeInterpreterTool + | OpenResponsesMcpTool + | OpenResponsesImageGenerationTool + | OpenResponsesLocalShellTool + | OpenResponsesFunctionShellTool + | OpenResponsesApplyPatchTool + | OpenResponsesCustomTool > readonly "tool_choice": OpenAIResponsesToolChoice readonly "parallel_tool_calls": boolean @@ -5062,7 +7888,16 @@ export const OpenAIResponsesNonStreamingResponse = Schema.Struct({ OpenResponsesWebSearchPreviewTool, OpenResponsesWebSearchPreview20250311Tool, OpenResponsesWebSearchTool, - OpenResponsesWebSearch20250826Tool + OpenResponsesWebSearch20250826Tool, + OpenResponsesFileSearchTool, + OpenResponsesComputerTool, + OpenResponsesCodeInterpreterTool, + OpenResponsesMcpTool, + OpenResponsesImageGenerationTool, + OpenResponsesLocalShellTool, + OpenResponsesFunctionShellTool, + OpenResponsesApplyPatchTool, + OpenResponsesCustomTool ], { mode: "oneOf" }) ), "tool_choice": OpenAIResponsesToolChoice, @@ -5193,6 +8028,14 @@ export type OpenResponsesNonStreamingResponse = { readonly "refusal": string } | { readonly "type": "refusal"; readonly "refusal": string } > + readonly "phase"?: + | "commentary" + | "commentary" + | "final_answer" + | "final_answer" + | "commentary" + | "final_answer" + | unknown } | { readonly "type": never readonly "id": string @@ -5225,6 +8068,7 @@ export type OpenResponsesNonStreamingResponse = { | "anthropic-claude-v1" | "google-gemini-v1" readonly "role": "assistant" + readonly "phase"?: "commentary" | "final_answer" | unknown } | { readonly "type": never readonly "id": string @@ -5234,12 +8078,23 @@ export type OpenResponsesNonStreamingResponse = { readonly "status"?: "completed" | "incomplete" | "in_progress" readonly "role": "assistant" readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown } | { readonly "type": never readonly "id": string + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } readonly "status": "completed" | "in_progress" readonly "role": "assistant" readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown } | { readonly "type": never readonly "id": string @@ -5247,6 +8102,7 @@ export type OpenResponsesNonStreamingResponse = { readonly "status": "completed" | "in_progress" readonly "role": "assistant" readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown } | { readonly "type": never readonly "id": string @@ -5254,6 +8110,7 @@ export type OpenResponsesNonStreamingResponse = { readonly "status": "in_progress" | "completed" readonly "role": "assistant" readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown } | { readonly "id": string readonly "role": "assistant" @@ -5276,6 +8133,7 @@ export type OpenResponsesNonStreamingResponse = { > } | { readonly "type": never; readonly "refusal": string; readonly "text": string } > + readonly "phase"?: "commentary" | "final_answer" | unknown readonly "summary": ReadonlyArray readonly "encrypted_content"?: string } | { @@ -5306,6 +8164,15 @@ export type OpenResponsesNonStreamingResponse = { } | { readonly "type": never readonly "id": string + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } readonly "status": "completed" | "in_progress" readonly "content"?: ReadonlyArray readonly "summary": ReadonlyArray @@ -5332,13 +8199,14 @@ export type OpenResponsesNonStreamingResponse = { readonly "type": never readonly "status"?: "completed" | "incomplete" | "in_progress" readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown readonly "name": string readonly "arguments": string readonly "call_id": string } | { readonly "type": never readonly "id": string - readonly "content"?: ReadonlyArray + readonly "content"?: ReadonlyArray<{ readonly "type": "reasoning_text"; readonly "text": string }> readonly "summary": ReadonlyArray readonly "encrypted_content"?: string readonly "status"?: "completed" | "incomplete" | "in_progress" @@ -5363,6 +8231,15 @@ export type OpenResponsesNonStreamingResponse = { } | { readonly "type": never readonly "id": string + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } readonly "status": "completed" | "in_progress" readonly "name": string readonly "arguments": string @@ -5389,10 +8266,20 @@ export type OpenResponsesNonStreamingResponse = { readonly "type": never readonly "status": "completed" | "in_progress" readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } } | { readonly "type": never readonly "id": string - readonly "content"?: ReadonlyArray + readonly "content"?: ReadonlyArray<{ readonly "type": "reasoning_text"; readonly "text": string }> readonly "summary": ReadonlyArray readonly "encrypted_content"?: string readonly "status": "completed" | "in_progress" @@ -5404,6 +8291,15 @@ export type OpenResponsesNonStreamingResponse = { | "xai-responses-v1" | "anthropic-claude-v1" | "google-gemini-v1" + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } } | { readonly "type": never readonly "id": string @@ -5411,31 +8307,100 @@ export type OpenResponsesNonStreamingResponse = { readonly "arguments": string readonly "call_id": string readonly "status": "completed" | "in_progress" + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } } | { readonly "type": "web_search_call" readonly "id": string + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { + readonly "type": never + readonly "url"?: string + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { + readonly "type": never + readonly "pattern": string + readonly "url": string + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { + readonly "type": never + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + readonly "url"?: string + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": never; readonly "pattern": string; readonly "url": string } + | { + readonly "type": never + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + readonly "pattern": string + readonly "url": string + } + | { readonly "type": never; readonly "url": string; readonly "pattern": string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } readonly "status": "completed" | "searching" | "in_progress" | "failed" } | { readonly "type": never readonly "id": string readonly "queries": ReadonlyArray readonly "status": "completed" | "searching" | "in_progress" | "failed" + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } } | { readonly "type": never readonly "id": string readonly "result"?: string readonly "status": "in_progress" | "completed" | "failed" + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } } | { readonly "id": string readonly "role": "assistant" readonly "type": never readonly "status": "completed" | "in_progress" readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown readonly "queries": ReadonlyArray } | { readonly "type": never readonly "id": string - readonly "content"?: ReadonlyArray + readonly "content"?: ReadonlyArray<{ readonly "type": "reasoning_text"; readonly "text": string }> readonly "summary": ReadonlyArray readonly "encrypted_content"?: string readonly "status": "completed" | "in_progress" @@ -5459,6 +8424,15 @@ export type OpenResponsesNonStreamingResponse = { } | { readonly "type": never readonly "id": string + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } readonly "status": "completed" | "searching" | "in_progress" | "failed" readonly "queries": ReadonlyArray } | { @@ -5478,11 +8452,12 @@ export type OpenResponsesNonStreamingResponse = { readonly "type": never readonly "status": "completed" | "in_progress" readonly "content": ReadonlyArray + readonly "phase"?: "commentary" | "final_answer" | unknown readonly "result"?: string } | { readonly "type": never readonly "id": string - readonly "content"?: ReadonlyArray + readonly "content"?: ReadonlyArray<{ readonly "type": "reasoning_text"; readonly "text": string }> readonly "summary": ReadonlyArray readonly "encrypted_content"?: string readonly "status": "completed" | "in_progress" @@ -5506,6 +8481,15 @@ export type OpenResponsesNonStreamingResponse = { } | { readonly "type": never readonly "id": string + readonly "action": + | { + readonly "type": "search" + readonly "query": string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + } + | { readonly "type": "open_page"; readonly "url"?: string } + | { readonly "type": "find_in_page"; readonly "pattern": string; readonly "url": string } readonly "status": "completed" | "in_progress" | "failed" readonly "result"?: string } | { @@ -5562,6 +8546,15 @@ export type OpenResponsesNonStreamingResponse = { | OpenResponsesWebSearchPreview20250311Tool | OpenResponsesWebSearchTool | OpenResponsesWebSearch20250826Tool + | OpenResponsesFileSearchTool + | OpenResponsesComputerTool + | OpenResponsesCodeInterpreterTool + | OpenResponsesMcpTool + | OpenResponsesImageGenerationTool + | OpenResponsesLocalShellTool + | OpenResponsesFunctionShellTool + | OpenResponsesApplyPatchTool + | OpenResponsesCustomTool > readonly "tool_choice": OpenAIResponsesToolChoice readonly "parallel_tool_calls": boolean @@ -5728,7 +8721,26 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ }), Schema.Struct({ "type": Schema.Literal("refusal"), "refusal": Schema.String }) ]) - ])) + ])), + "phase": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["commentary", "commentary"]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }), + Schema.Literals(["final_answer", "final_answer"]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }), + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) }).annotate({ "description": "An output message item" }), Schema.Struct({ "type": Schema.Never, @@ -5771,7 +8783,13 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ "google-gemini-v1" ]).annotate({ "description": "The format of the reasoning content" }) ), - "role": Schema.Literal("assistant") + "role": Schema.Literal("assistant"), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) }).annotate({ "description": "An output item containing reasoning" }), Schema.Struct({ "type": Schema.Never, @@ -5783,14 +8801,38 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ Schema.Union([Schema.Literal("completed"), Schema.Literal("incomplete"), Schema.Literal("in_progress")]) ), "role": Schema.Literal("assistant"), - "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])) + "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) }), Schema.Struct({ "type": Schema.Never, "id": Schema.String, + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }), "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), "role": Schema.Literal("assistant"), - "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])) + "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) }), Schema.Struct({ "type": Schema.Never, @@ -5798,7 +8840,13 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ "queries": Schema.Array(Schema.String), "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), "role": Schema.Literal("assistant"), - "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])) + "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) }), Schema.Struct({ "type": Schema.Never, @@ -5806,7 +8854,13 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ "result": Schema.optionalKey(Schema.String), "status": Schema.Union([Schema.Literal("in_progress"), Schema.Literal("completed")]), "role": Schema.Literal("assistant"), - "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])) + "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ) }) ]).annotate({ "description": "An output item from the response" }), Schema.Union([ @@ -5837,6 +8891,12 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ }), Schema.Struct({ "type": Schema.Never, "refusal": Schema.String, "text": Schema.String }) ])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ), "summary": Schema.Array(ReasoningSummaryText), "encrypted_content": Schema.optionalKey(Schema.String) }).annotate({ "description": "An output message item" }), @@ -5881,6 +8941,18 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ Schema.Struct({ "type": Schema.Never, "id": Schema.String, + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }), "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), "content": Schema.optionalKey(Schema.Array(ReasoningTextContent)), "summary": Schema.Array(ReasoningSummaryText), @@ -5914,6 +8986,12 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ Schema.Union([Schema.Literal("completed"), Schema.Literal("incomplete"), Schema.Literal("in_progress")]) ), "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ), "name": Schema.String, "arguments": Schema.String, "call_id": Schema.String @@ -5921,7 +8999,9 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ Schema.Struct({ "type": Schema.Never, "id": Schema.String, - "content": Schema.optionalKey(Schema.Array(ReasoningTextContent)), + "content": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("reasoning_text"), "text": Schema.String })) + ), "summary": Schema.Array(ReasoningSummaryText), "encrypted_content": Schema.optionalKey(Schema.String), "status": Schema.optionalKey( @@ -5957,6 +9037,18 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ Schema.Struct({ "type": Schema.Never, "id": Schema.String, + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }), "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), "name": Schema.String, "arguments": Schema.String, @@ -5987,12 +9079,32 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ "role": Schema.Literal("assistant"), "type": Schema.Never, "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), - "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])) + "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ), + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }) }).annotate({ "description": "An output message item" }), Schema.Struct({ "type": Schema.Never, "id": Schema.String, - "content": Schema.optionalKey(Schema.Array(ReasoningTextContent)), + "content": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("reasoning_text"), "text": Schema.String })) + ), "summary": Schema.Array(ReasoningSummaryText), "encrypted_content": Schema.optionalKey(Schema.String), "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), @@ -6008,7 +9120,19 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ "anthropic-claude-v1", "google-gemini-v1" ]).annotate({ "description": "The format of the reasoning content" }) - ) + ), + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }) }).annotate({ "description": "An output item containing reasoning" }), Schema.Struct({ "type": Schema.Never, @@ -6016,11 +9140,81 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ "name": Schema.String, "arguments": Schema.String, "call_id": Schema.String, - "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]) + "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }) }), Schema.Struct({ "type": Schema.Literal("web_search_call"), "id": Schema.String, + "action": Schema.Union([ + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ + "type": Schema.Never, + "url": Schema.optionalKey(Schema.String), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ + "type": Schema.Never, + "pattern": Schema.String, + "url": Schema.String, + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }) + ]), + Schema.Union([ + Schema.Struct({ + "type": Schema.Never, + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ), + "url": Schema.optionalKey(Schema.String) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Never, "pattern": Schema.String, "url": Schema.String }) + ]), + Schema.Union([ + Schema.Struct({ + "type": Schema.Never, + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ), + "pattern": Schema.String, + "url": Schema.String + }), + Schema.Struct({ "type": Schema.Never, "url": Schema.String, "pattern": Schema.String }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ]) + ]), "status": Schema.Union([ Schema.Literal("completed"), Schema.Literal("searching"), @@ -6037,13 +9231,37 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ Schema.Literal("searching"), Schema.Literal("in_progress"), Schema.Literal("failed") - ]) + ]), + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }) }), Schema.Struct({ "type": Schema.Never, "id": Schema.String, "result": Schema.optionalKey(Schema.String), - "status": Schema.Union([Schema.Literal("in_progress"), Schema.Literal("completed"), Schema.Literal("failed")]) + "status": Schema.Union([Schema.Literal("in_progress"), Schema.Literal("completed"), Schema.Literal("failed")]), + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }) }) ]).annotate({ "description": "An output item from the response" }), Schema.Union([ @@ -6053,12 +9271,20 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ "type": Schema.Never, "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ), "queries": Schema.Array(Schema.String) }).annotate({ "description": "An output message item" }), Schema.Struct({ "type": Schema.Never, "id": Schema.String, - "content": Schema.optionalKey(Schema.Array(ReasoningTextContent)), + "content": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("reasoning_text"), "text": Schema.String })) + ), "summary": Schema.Array(ReasoningSummaryText), "encrypted_content": Schema.optionalKey(Schema.String), "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), @@ -6089,6 +9315,18 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ Schema.Struct({ "type": Schema.Never, "id": Schema.String, + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }), "status": Schema.Union([ Schema.Literal("completed"), Schema.Literal("searching"), @@ -6123,12 +9361,20 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ "type": Schema.Never, "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Unknown]).annotate({ + "description": + "The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages." + }) + ), "result": Schema.optionalKey(Schema.String) }).annotate({ "description": "An output message item" }), Schema.Struct({ "type": Schema.Never, "id": Schema.String, - "content": Schema.optionalKey(Schema.Array(ReasoningTextContent)), + "content": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("reasoning_text"), "text": Schema.String })) + ), "summary": Schema.Array(ReasoningSummaryText), "encrypted_content": Schema.optionalKey(Schema.String), "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress")]), @@ -6159,6 +9405,18 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ Schema.Struct({ "type": Schema.Never, "id": Schema.String, + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search"), + "query": Schema.String, + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ) + }), + Schema.Struct({ "type": Schema.Literal("open_page"), "url": Schema.optionalKey(Schema.String) }), + Schema.Struct({ "type": Schema.Literal("find_in_page"), "pattern": Schema.String, "url": Schema.String }) + ], { mode: "oneOf" }), "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("in_progress"), Schema.Literal("failed")]), "result": Schema.optionalKey(Schema.String) }), @@ -6229,67 +9487,52 @@ export const OpenResponsesNonStreamingResponse = Schema.Struct({ "description": Schema.optionalKey(Schema.String), "strict": Schema.optionalKey(Schema.Boolean), "parameters": Schema.Struct({}) - }).annotate({ "description": "Function tool definition" }), - OpenResponsesWebSearchPreviewTool, - OpenResponsesWebSearchPreview20250311Tool, - OpenResponsesWebSearchTool, - OpenResponsesWebSearch20250826Tool - ], { mode: "oneOf" }) - ), - "tool_choice": OpenAIResponsesToolChoice, - "parallel_tool_calls": Schema.Boolean, - "prompt": Schema.optionalKey(OpenAIResponsesPrompt), - "background": Schema.optionalKey(Schema.Boolean), - "previous_response_id": Schema.optionalKey(Schema.String), - "reasoning": Schema.optionalKey(OpenAIResponsesReasoningConfig), - "service_tier": Schema.optionalKey(OpenAIResponsesServiceTier), - "store": Schema.optionalKey(Schema.Boolean), - "truncation": Schema.optionalKey(OpenAIResponsesTruncation), - "text": Schema.optionalKey(ResponseTextConfig) -}).annotate({ "description": "Complete non-streaming response from the Responses API" }) -export type OpenResponsesRequest = { - readonly "input"?: OpenResponsesInput - readonly "instructions"?: string - readonly "metadata"?: OpenResponsesRequestMetadata - readonly "tools"?: ReadonlyArray< - | { - readonly "type": "function" - readonly "name": string - readonly "description"?: string - readonly "strict"?: boolean - readonly "parameters": {} - } - | OpenResponsesWebSearchPreviewTool - | OpenResponsesWebSearchPreview20250311Tool - | OpenResponsesWebSearchTool - | OpenResponsesWebSearch20250826Tool - > - readonly "tool_choice"?: OpenAIResponsesToolChoice - readonly "parallel_tool_calls"?: boolean - readonly "model"?: string - readonly "models"?: ReadonlyArray - readonly "text"?: OpenResponsesResponseText - readonly "reasoning"?: OpenResponsesReasoningConfig - readonly "max_output_tokens"?: number - readonly "temperature"?: number - readonly "top_p"?: number - readonly "top_logprobs"?: number - readonly "max_tool_calls"?: number - readonly "presence_penalty"?: number - readonly "frequency_penalty"?: number - readonly "top_k"?: number - readonly "image_config"?: {} - readonly "modalities"?: ReadonlyArray - readonly "prompt_cache_key"?: string - readonly "previous_response_id"?: string - readonly "prompt"?: OpenAIResponsesPrompt - readonly "include"?: ReadonlyArray - readonly "background"?: boolean - readonly "safety_identifier"?: string - readonly "store"?: false - readonly "service_tier"?: "auto" - readonly "truncation"?: "auto" | "disabled" - readonly "stream"?: boolean + }).annotate({ "description": "Function tool definition" }), + OpenResponsesWebSearchPreviewTool, + OpenResponsesWebSearchPreview20250311Tool, + OpenResponsesWebSearchTool, + OpenResponsesWebSearch20250826Tool, + OpenResponsesFileSearchTool, + OpenResponsesComputerTool, + OpenResponsesCodeInterpreterTool, + OpenResponsesMcpTool, + OpenResponsesImageGenerationTool, + OpenResponsesLocalShellTool, + OpenResponsesFunctionShellTool, + OpenResponsesApplyPatchTool, + OpenResponsesCustomTool + ], { mode: "oneOf" }) + ), + "tool_choice": OpenAIResponsesToolChoice, + "parallel_tool_calls": Schema.Boolean, + "prompt": Schema.optionalKey(OpenAIResponsesPrompt), + "background": Schema.optionalKey(Schema.Boolean), + "previous_response_id": Schema.optionalKey(Schema.String), + "reasoning": Schema.optionalKey(OpenAIResponsesReasoningConfig), + "service_tier": Schema.optionalKey(OpenAIResponsesServiceTier), + "store": Schema.optionalKey(Schema.Boolean), + "truncation": Schema.optionalKey(OpenAIResponsesTruncation), + "text": Schema.optionalKey(ResponseTextConfig) +}).annotate({ "description": "Complete non-streaming response from the Responses API" }) +export type ChatResponse = { + readonly "id": string + readonly "choices": ReadonlyArray + readonly "created": number + readonly "model": string + readonly "object": "chat.completion" + readonly "system_fingerprint": string + readonly "usage"?: ChatGenerationTokenUsage +} +export const ChatResponse = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique completion identifier" }), + "choices": Schema.Array(ChatResponseChoice).annotate({ "description": "List of completion choices" }), + "created": Schema.Number.annotate({ "description": "Unix timestamp of creation" }).check(Schema.isFinite()), + "model": Schema.String.annotate({ "description": "Model used for completion" }), + "object": Schema.Literal("chat.completion"), + "system_fingerprint": Schema.String.annotate({ "description": "System fingerprint" }), + "usage": Schema.optionalKey(ChatGenerationTokenUsage) +}).annotate({ "description": "Chat completion response" }) +export type ChatGenerationParams = { readonly "provider"?: { readonly "allow_fallbacks"?: boolean readonly "require_parameters"?: boolean @@ -6300,7 +9543,7 @@ export type OpenResponsesRequest = { readonly "only"?: ReadonlyArray readonly "ignore"?: ReadonlyArray readonly "quantizations"?: ReadonlyArray - readonly "sort"?: ProviderSort | ProviderSortConfig | unknown + readonly "sort"?: "price" | "price" | "throughput" | "throughput" | "latency" | "latency" readonly "max_price"?: { readonly "prompt"?: BigNumberUnion readonly "completion"?: string @@ -6320,6 +9563,8 @@ export type OpenResponsesRequest = { readonly "max_results"?: number readonly "search_prompt"?: string readonly "engine"?: WebSearchEngine + readonly "include_domains"?: ReadonlyArray + readonly "exclude_domains"?: ReadonlyArray } | { readonly "id": "file-parser"; readonly "enabled"?: boolean; readonly "pdf"?: PDFParserOptions } | { readonly "id": "response-healing"; readonly "enabled"?: boolean } @@ -6334,71 +9579,42 @@ export type OpenResponsesRequest = { readonly "generation_name"?: string readonly "parent_span_id"?: string } + readonly "messages": ReadonlyArray + readonly "model"?: ModelName + readonly "models"?: ModelNames + readonly "frequency_penalty"?: number + readonly "logit_bias"?: {} + readonly "logprobs"?: boolean + readonly "top_logprobs"?: number + readonly "max_completion_tokens"?: number + readonly "max_tokens"?: number + readonly "metadata"?: {} + readonly "presence_penalty"?: number + readonly "reasoning"?: { + readonly "effort"?: "xhigh" | "high" | "medium" | "low" | "minimal" | "none" + readonly "summary"?: ReasoningSummaryVerbosity | unknown | unknown + } + readonly "response_format"?: + | ResponseFormatText + | ResponseFormatJSONObject + | ResponseFormatJSONSchema + | ResponseFormatTextGrammar + | ResponseFormatTextPython + readonly "seed"?: number + readonly "stop"?: string | ReadonlyArray | unknown + readonly "stream"?: boolean + readonly "stream_options"?: ChatStreamOptions + readonly "temperature"?: number + readonly "parallel_tool_calls"?: boolean + readonly "tool_choice"?: ToolChoiceOption + readonly "tools"?: ReadonlyArray + readonly "top_p"?: number + readonly "debug"?: DebugOptions + readonly "image_config"?: {} + readonly "modalities"?: ReadonlyArray<"text" | "image" | "audio"> + readonly "cache_control"?: { readonly "type": "ephemeral"; readonly "ttl"?: "5m" | "1h" } } -export const OpenResponsesRequest = Schema.Struct({ - "input": Schema.optionalKey(OpenResponsesInput), - "instructions": Schema.optionalKey(Schema.String), - "metadata": Schema.optionalKey(OpenResponsesRequestMetadata), - "tools": Schema.optionalKey( - Schema.Array( - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("function"), - "name": Schema.String, - "description": Schema.optionalKey(Schema.String), - "strict": Schema.optionalKey(Schema.Boolean), - "parameters": Schema.Struct({}) - }).annotate({ "description": "Function tool definition" }), - OpenResponsesWebSearchPreviewTool, - OpenResponsesWebSearchPreview20250311Tool, - OpenResponsesWebSearchTool, - OpenResponsesWebSearch20250826Tool - ], { mode: "oneOf" }) - ) - ), - "tool_choice": Schema.optionalKey(OpenAIResponsesToolChoice), - "parallel_tool_calls": Schema.optionalKey(Schema.Boolean), - "model": Schema.optionalKey(Schema.String), - "models": Schema.optionalKey(Schema.Array(Schema.String)), - "text": Schema.optionalKey(OpenResponsesResponseText), - "reasoning": Schema.optionalKey(OpenResponsesReasoningConfig), - "max_output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "temperature": Schema.optionalKey( - Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(2)) - ), - "top_p": Schema.optionalKey(Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0))), - "top_logprobs": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)) - ), - "max_tool_calls": Schema.optionalKey(Schema.Number.check(Schema.isInt())), - "presence_penalty": Schema.optionalKey( - Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(-2)).check(Schema.isLessThanOrEqualTo(2)) - ), - "frequency_penalty": Schema.optionalKey( - Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(-2)).check(Schema.isLessThanOrEqualTo(2)) - ), - "top_k": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "image_config": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/features/multimodal/image-generation for more details." - }) - ), - "modalities": Schema.optionalKey( - Schema.Array(ResponsesOutputModality).annotate({ - "description": "Output modalities for the response. Supported values are \"text\" and \"image\"." - }) - ), - "prompt_cache_key": Schema.optionalKey(Schema.String), - "previous_response_id": Schema.optionalKey(Schema.String), - "prompt": Schema.optionalKey(OpenAIResponsesPrompt), - "include": Schema.optionalKey(Schema.Array(OpenAIResponsesIncludable)), - "background": Schema.optionalKey(Schema.Boolean), - "safety_identifier": Schema.optionalKey(Schema.String), - "store": Schema.optionalKey(Schema.Literal(false)), - "service_tier": Schema.optionalKey(Schema.Literal("auto")), - "truncation": Schema.optionalKey(Schema.Literals(["auto", "disabled"])), - "stream": Schema.optionalKey(Schema.Boolean), +export const ChatGenerationParams = Schema.Struct({ "provider": Schema.optionalKey( Schema.Struct({ "allow_fallbacks": Schema.optionalKey(Schema.Boolean.annotate({ @@ -6448,10 +9664,35 @@ export const OpenResponsesRequest = Schema.Struct({ }) ), "sort": Schema.optionalKey( - Schema.Union([ProviderSort, ProviderSortConfig, Schema.Unknown]).annotate({ - "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." - }) + Schema.Union([ + Schema.Union([ + Schema.Literal("price").annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }), + Schema.Literal("price") + ]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }), + Schema.Union([ + Schema.Literal("throughput").annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }), + Schema.Literal("throughput") + ]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }), + Schema.Union([ + Schema.Literal("latency").annotate({ + "description": "The provider sorting strategy (price, throughput, latency)" + }), + Schema.Literal("latency") + ]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }) + ]).annotate({ "description": "The provider sorting strategy (price, throughput, latency)" }) ), "max_price": Schema.optionalKey( Schema.Struct({ @@ -6493,296 +9734,54 @@ export const OpenResponsesRequest = Schema.Struct({ Schema.Struct({ "id": Schema.Literal("web"), "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the web-search plugin for this request. Defaults to true." - }) - ), - "max_results": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "search_prompt": Schema.optionalKey(Schema.String), - "engine": Schema.optionalKey(WebSearchEngine) - }), - Schema.Struct({ - "id": Schema.Literal("file-parser"), - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the file-parser plugin for this request. Defaults to true." - }) - ), - "pdf": Schema.optionalKey(PDFParserOptions) - }), - Schema.Struct({ - "id": Schema.Literal("response-healing"), - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the response-healing plugin for this request. Defaults to true." - }) - ) - }) - ], { mode: "oneOf" })).annotate({ - "description": "Plugins you want to enable for this request, including their settings." - }) - ), - "route": Schema.optionalKey( - Schema.Literals(["fallback", "sort"]).annotate({ - "description": - "**DEPRECATED** Use providers.sort.partition instead. Backwards-compatible alias for providers.sort.partition. Accepts legacy values: \"fallback\" (maps to \"model\"), \"sort\" (maps to \"none\")." - }) - ), - "user": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters." - }).check(Schema.isMaxLength(128)) - ), - "session_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters." - }).check(Schema.isMaxLength(128)) - ), - "trace": Schema.optionalKey( - Schema.Struct({ - "trace_id": Schema.optionalKey(Schema.String), - "trace_name": Schema.optionalKey(Schema.String), - "span_name": Schema.optionalKey(Schema.String), - "generation_name": Schema.optionalKey(Schema.String), - "parent_span_id": Schema.optionalKey(Schema.String) - }).annotate({ - "description": - "Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations." - }) - ) -}).annotate({ "description": "Request schema for Responses endpoint" }) -export type ChatGenerationParams = { - readonly "provider"?: { - readonly "allow_fallbacks"?: boolean | null - readonly "require_parameters"?: boolean | null - readonly "data_collection"?: "deny" | "allow" | null - readonly "zdr"?: boolean | null - readonly "enforce_distillable_text"?: boolean | null - readonly "order"?: __schema5 | null - readonly "only"?: __schema5 | null - readonly "ignore"?: __schema5 | null - readonly "quantizations"?: - | ReadonlyArray<"int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown"> - | null - readonly "sort"?: ProviderSortUnion | null - readonly "max_price"?: { - readonly "prompt"?: __schema11 | ModelName | __schema13 - readonly "completion"?: __schema11 | ModelName | __schema13 - readonly "image"?: __schema14 - readonly "audio"?: __schema14 - readonly "request"?: __schema14 - } - readonly "preferred_min_throughput"?: number | { - readonly "p50"?: number | null - readonly "p75"?: number | null - readonly "p90"?: number | null - readonly "p99"?: number | null - } | null - readonly "preferred_max_latency"?: number | { - readonly "p50"?: number | null - readonly "p75"?: number | null - readonly "p90"?: number | null - readonly "p99"?: number | null - } | null - } | null - readonly "plugins"?: ReadonlyArray< - | { readonly "id": "auto-router"; readonly "enabled"?: boolean; readonly "allowed_models"?: ReadonlyArray } - | { readonly "id": "moderation" } - | { - readonly "id": "web" - readonly "enabled"?: boolean - readonly "max_results"?: number - readonly "search_prompt"?: string - readonly "engine"?: "native" | "exa" - } - | { - readonly "id": "file-parser" - readonly "enabled"?: boolean - readonly "pdf"?: { readonly "engine"?: "mistral-ocr" | "pdf-text" | "native" } - } - | { readonly "id": "response-healing"; readonly "enabled"?: boolean } - > - readonly "route"?: "fallback" | "sort" | null - readonly "user"?: string - readonly "session_id"?: string - readonly "trace"?: { - readonly "trace_id"?: string - readonly "trace_name"?: string - readonly "span_name"?: string - readonly "generation_name"?: string - readonly "parent_span_id"?: string - } - readonly "messages": ReadonlyArray - readonly "model"?: ModelName - readonly "models"?: ReadonlyArray - readonly "frequency_penalty"?: number | null - readonly "logit_bias"?: {} | null - readonly "logprobs"?: boolean | null - readonly "top_logprobs"?: number | null - readonly "max_completion_tokens"?: number | null - readonly "max_tokens"?: number | null - readonly "metadata"?: {} - readonly "presence_penalty"?: number | null - readonly "reasoning"?: { - readonly "effort"?: "xhigh" | "high" | "medium" | "low" | "minimal" | "none" | null - readonly "summary"?: ReasoningSummaryVerbosity | null - } - readonly "response_format"?: - | { readonly "type": "text" } - | { readonly "type": "json_object" } - | ResponseFormatJSONSchema - | ResponseFormatTextGrammar - | { readonly "type": "python" } - readonly "seed"?: number | null - readonly "stop"?: string | ReadonlyArray | null - readonly "stream"?: boolean - readonly "stream_options"?: ChatStreamOptions | null - readonly "temperature"?: number | null - readonly "parallel_tool_calls"?: boolean | null - readonly "tool_choice"?: ToolChoiceOption - readonly "tools"?: ReadonlyArray - readonly "top_p"?: number | null - readonly "debug"?: { readonly "echo_upstream_body"?: boolean } - readonly "image_config"?: {} - readonly "modalities"?: ReadonlyArray<"text" | "image"> -} -export const ChatGenerationParams = Schema.Struct({ - "provider": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "allow_fallbacks": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to allow backup providers to serve requests\n- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.\n- false: use only the primary/custom provider, and return the upstream error if it's unavailable.\n" - }) - ), - "require_parameters": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest." - }) - ), - "data_collection": Schema.optionalKey( - Schema.Union([Schema.Literals(["deny", "allow"]), Schema.Null]).annotate({ - "description": - "Data collection setting. If no available model provider meets the requirement, your request will return an error.\n- allow: (default) allow providers which store user data non-transiently and may train on it\n\n- deny: use only providers which do not collect user data." - }) - ), - "zdr": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "enforce_distillable_text": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "order": Schema.optionalKey( - Schema.Union([__schema5, Schema.Null]).annotate({ - "description": - "An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message." - }) - ), - "only": Schema.optionalKey( - Schema.Union([__schema5, Schema.Null]).annotate({ - "description": - "List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request." - }) - ), - "ignore": Schema.optionalKey( - Schema.Union([__schema5, Schema.Null]).annotate({ - "description": - "List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request." + Schema.Boolean.annotate({ + "description": "Set to false to disable the web-search plugin for this request. Defaults to true." }) ), - "quantizations": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.Literals(["int4", "int8", "fp4", "fp6", "fp8", "fp16", "bf16", "fp32", "unknown"])), - Schema.Null - ]).annotate({ "description": "A list of quantization levels to filter the provider by." }) - ), - "sort": Schema.optionalKey( - Schema.Union([ProviderSortUnion, Schema.Null]).annotate({ + "max_results": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), + "search_prompt": Schema.optionalKey(Schema.String), + "engine": Schema.optionalKey(WebSearchEngine), + "include_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + "A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")." }) ), - "max_price": Schema.optionalKey( - Schema.Struct({ - "prompt": Schema.optionalKey(Schema.Union([__schema11, ModelName, __schema13])), - "completion": Schema.optionalKey(Schema.Union([__schema11, ModelName, __schema13])), - "image": Schema.optionalKey(__schema14), - "audio": Schema.optionalKey(__schema14), - "request": Schema.optionalKey(__schema14) - }).annotate({ + "exclude_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion." + "A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")." }) - ), - "preferred_min_throughput": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Number.check(Schema.isFinite()), - Schema.Struct({ - "p50": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])), - "p75": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])), - "p90": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])), - "p99": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])) - }) - ]), - Schema.Null - ]).annotate({ - "description": - "Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold." + ) + }), + Schema.Struct({ + "id": Schema.Literal("file-parser"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the file-parser plugin for this request. Defaults to true." }) ), - "preferred_max_latency": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Number.check(Schema.isFinite()), - Schema.Struct({ - "p50": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])), - "p75": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])), - "p90": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])), - "p99": Schema.optionalKey(Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null])) - }) - ]), - Schema.Null - ]).annotate({ - "description": - "Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold." + "pdf": Schema.optionalKey(PDFParserOptions) + }), + Schema.Struct({ + "id": Schema.Literal("response-healing"), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the response-healing plugin for this request. Defaults to true." }) ) - }), - Schema.Null - ]).annotate({ - "description": "When multiple model providers are available, optionally indicate your routing preference." + }) + ], { mode: "oneOf" })).annotate({ + "description": "Plugins you want to enable for this request, including their settings." }) ), - "plugins": Schema.optionalKey( - Schema.Array( - Schema.Union([ - Schema.Struct({ - "id": Schema.Literal("auto-router"), - "enabled": Schema.optionalKey(Schema.Boolean), - "allowed_models": Schema.optionalKey(Schema.Array(Schema.String)) - }), - Schema.Struct({ "id": Schema.Literal("moderation") }), - Schema.Struct({ - "id": Schema.Literal("web"), - "enabled": Schema.optionalKey(Schema.Boolean), - "max_results": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "search_prompt": Schema.optionalKey(Schema.String), - "engine": Schema.optionalKey(Schema.Literals(["native", "exa"])) - }), - Schema.Struct({ - "id": Schema.Literal("file-parser"), - "enabled": Schema.optionalKey(Schema.Boolean), - "pdf": Schema.optionalKey( - Schema.Struct({ "engine": Schema.optionalKey(Schema.Literals(["mistral-ocr", "pdf-text", "native"])) }) - ) - }), - Schema.Struct({ "id": Schema.Literal("response-healing"), "enabled": Schema.optionalKey(Schema.Boolean) }) - ], { mode: "oneOf" }) - ).annotate({ "description": "Plugins you want to enable for this request, including their settings." }) + "route": Schema.optionalKey( + Schema.Literals(["fallback", "sort"]).annotate({ + "description": + "**DEPRECATED** Use providers.sort.partition instead. Backwards-compatible alias for providers.sort.partition. Accepts legacy values: \"fallback\" (maps to \"model\"), \"sort\" (maps to \"none\")." + }) ), - "route": Schema.optionalKey(Schema.Union([Schema.Literals(["fallback", "sort"]), Schema.Null])), - "user": Schema.optionalKey(Schema.String), + "user": Schema.optionalKey(Schema.String.annotate({ "description": "Unique user identifier" })), "session_id": Schema.optionalKey( Schema.String.annotate({ "description": @@ -6801,97 +9800,133 @@ export const ChatGenerationParams = Schema.Struct({ "Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations." }) ), - "messages": Schema.Array(Message).check(Schema.isMinLength(1)), + "messages": Schema.Array(Message).annotate({ "description": "List of messages for the conversation" }).check( + Schema.isMinLength(1) + ), "model": Schema.optionalKey(ModelName), - "models": Schema.optionalKey(Schema.Array(ModelName)), + "models": Schema.optionalKey(ModelNames), "frequency_penalty": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(-2)).check( - Schema.isLessThanOrEqualTo(2) - ), - Schema.Null - ]) - ), - "logit_bias": Schema.optionalKey( - Schema.Union([Schema.Struct({}).check(Schema.isPropertyNames(Schema.String)), Schema.Null]) + Schema.Number.annotate({ "description": "Frequency penalty (-2.0 to 2.0)" }).check(Schema.isFinite()).check( + Schema.isGreaterThanOrEqualTo(-2) + ).check(Schema.isLessThanOrEqualTo(2)) ), - "logprobs": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "logit_bias": Schema.optionalKey(Schema.Struct({}).annotate({ "description": "Token logit bias adjustments" })), + "logprobs": Schema.optionalKey(Schema.Boolean.annotate({ "description": "Return log probabilities" })), "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check( - Schema.isLessThanOrEqualTo(20) - ), - Schema.Null - ]) + Schema.Number.annotate({ "description": "Number of top log probabilities to return (0-20)" }).check( + Schema.isFinite() + ).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)) ), "max_completion_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(1)), Schema.Null]) + Schema.Number.annotate({ "description": "Maximum tokens in completion" }).check(Schema.isFinite()).check( + Schema.isGreaterThanOrEqualTo(1) + ) ), "max_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(1)), Schema.Null]) + Schema.Number.annotate({ + "description": + "Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16." + }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(1)) + ), + "metadata": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": "Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)" + }) ), - "metadata": Schema.optionalKey(Schema.Struct({}).check(Schema.isPropertyNames(Schema.String))), "presence_penalty": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(-2)).check( - Schema.isLessThanOrEqualTo(2) - ), - Schema.Null - ]) + Schema.Number.annotate({ "description": "Presence penalty (-2.0 to 2.0)" }).check(Schema.isFinite()).check( + Schema.isGreaterThanOrEqualTo(-2) + ).check(Schema.isLessThanOrEqualTo(2)) ), "reasoning": Schema.optionalKey( Schema.Struct({ "effort": Schema.optionalKey( - Schema.Union([Schema.Literals(["xhigh", "high", "medium", "low", "minimal", "none"]), Schema.Null]) + Schema.Literals(["xhigh", "high", "medium", "low", "minimal", "none"]).annotate({ + "description": "Constrains effort on reasoning for reasoning models" + }) ), - "summary": Schema.optionalKey(Schema.Union([ReasoningSummaryVerbosity, Schema.Null])) - }) + "summary": Schema.optionalKey(Schema.Union([ReasoningSummaryVerbosity, Schema.Unknown, Schema.Unknown])) + }).annotate({ "description": "Configuration options for reasoning models" }) ), "response_format": Schema.optionalKey( Schema.Union([ - Schema.Struct({ "type": Schema.Literal("text") }), - Schema.Struct({ "type": Schema.Literal("json_object") }), + ResponseFormatText, + ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatTextGrammar, - Schema.Struct({ "type": Schema.Literal("python") }) - ], { mode: "oneOf" }) + ResponseFormatTextPython + ], { mode: "oneOf" }).annotate({ "description": "Response format configuration" }) ), "seed": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(-9007199254740991)).check( - Schema.isLessThanOrEqualTo(9007199254740991) - ), - Schema.Null - ]) + Schema.Number.annotate({ "description": "Random seed for deterministic outputs" }).check(Schema.isInt()) ), "stop": Schema.optionalKey( - Schema.Union([Schema.Union([Schema.String, Schema.Array(ModelName).check(Schema.isMaxLength(4))]), Schema.Null]) + Schema.Union([Schema.String, Schema.Array(Schema.String).check(Schema.isMaxLength(4)), Schema.Unknown]).annotate({ + "description": "Stop sequences (up to 4)" + }) ), - "stream": Schema.optionalKey(Schema.Boolean), - "stream_options": Schema.optionalKey(Schema.Union([ChatStreamOptions, Schema.Null])), + "stream": Schema.optionalKey(Schema.Boolean.annotate({ "description": "Enable streaming response" })), + "stream_options": Schema.optionalKey(ChatStreamOptions), "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check( - Schema.isLessThanOrEqualTo(2) - ), - Schema.Null - ]) + Schema.Number.annotate({ "description": "Sampling temperature (0-2)" }).check(Schema.isFinite()).check( + Schema.isGreaterThanOrEqualTo(0) + ).check(Schema.isLessThanOrEqualTo(2)) ), - "parallel_tool_calls": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "parallel_tool_calls": Schema.optionalKey(Schema.Boolean), "tool_choice": Schema.optionalKey(ToolChoiceOption), - "tools": Schema.optionalKey(Schema.Array(ToolDefinitionJson)), + "tools": Schema.optionalKey( + Schema.Array(ToolDefinitionJson).annotate({ "description": "Available tools for function calling" }) + ), "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check( - Schema.isLessThanOrEqualTo(1) - ), - Schema.Null - ]) + Schema.Number.annotate({ "description": "Nucleus sampling parameter (0-1)" }).check(Schema.isFinite()).check( + Schema.isGreaterThanOrEqualTo(0) + ).check(Schema.isLessThanOrEqualTo(1)) ), - "debug": Schema.optionalKey(Schema.Struct({ "echo_upstream_body": Schema.optionalKey(Schema.Boolean) })), - "image_config": Schema.optionalKey(Schema.Struct({}).check(Schema.isPropertyNames(Schema.String))), - "modalities": Schema.optionalKey(Schema.Array(Schema.Literals(["text", "image"]))) -}) + "debug": Schema.optionalKey(DebugOptions), + "image_config": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": + "Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details." + }) + ), + "modalities": Schema.optionalKey( + Schema.Array(Schema.Literals(["text", "image", "audio"])).annotate({ + "description": "Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\"." + }) + ), + "cache_control": Schema.optionalKey( + Schema.Struct({ "type": Schema.Literal("ephemeral"), "ttl": Schema.optionalKey(Schema.Literals(["5m", "1h"])) }) + .annotate({ + "description": + "Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models." + }) + ) +}).annotate({ "description": "Chat completion request parameters" }) +export type ChatStreamingResponseChunk = { + readonly "id": string + readonly "choices": ReadonlyArray + readonly "created": number + readonly "model": string + readonly "object": "chat.completion.chunk" + readonly "system_fingerprint"?: string + readonly "error"?: { readonly "message": string; readonly "code": number } + readonly "usage"?: ChatGenerationTokenUsage +} +export const ChatStreamingResponseChunk = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique chunk identifier" }), + "choices": Schema.Array(ChatStreamingChoice).annotate({ "description": "List of streaming chunk choices" }), + "created": Schema.Number.annotate({ "description": "Unix timestamp of creation" }).check(Schema.isFinite()), + "model": Schema.String.annotate({ "description": "Model used for completion" }), + "object": Schema.Literal("chat.completion.chunk"), + "system_fingerprint": Schema.optionalKey(Schema.String.annotate({ "description": "System fingerprint" })), + "error": Schema.optionalKey( + Schema.Struct({ + "message": Schema.String.annotate({ "description": "Error message" }), + "code": Schema.Number.annotate({ "description": "Error code" }).check(Schema.isFinite()) + }).annotate({ "description": "Error information" }) + ), + "usage": Schema.optionalKey(ChatGenerationTokenUsage) +}).annotate({ "description": "Streaming chat completion chunk" }) export type OpenResponsesCreatedEvent = { readonly "type": "response.created" readonly "response": OpenAIResponsesNonStreamingResponse @@ -7120,6 +10155,38 @@ export type GetUserActivity403 = ForbiddenResponse export const GetUserActivity403 = ForbiddenResponse export type GetUserActivity500 = InternalServerResponse export const GetUserActivity500 = InternalServerResponse +export type SendChatCompletionRequestRequestJson = ChatGenerationParams +export const SendChatCompletionRequestRequestJson = ChatGenerationParams +export type SendChatCompletionRequest200 = ChatResponse +export const SendChatCompletionRequest200 = ChatResponse +export type SendChatCompletionRequest200Sse = { readonly "data": ChatStreamingResponseChunk } +export const SendChatCompletionRequest200Sse = Schema.Struct({ "data": ChatStreamingResponseChunk }) +export type SendChatCompletionRequest400 = BadRequestResponse +export const SendChatCompletionRequest400 = BadRequestResponse +export type SendChatCompletionRequest401 = UnauthorizedResponse +export const SendChatCompletionRequest401 = UnauthorizedResponse +export type SendChatCompletionRequest402 = PaymentRequiredResponse +export const SendChatCompletionRequest402 = PaymentRequiredResponse +export type SendChatCompletionRequest404 = NotFoundResponse +export const SendChatCompletionRequest404 = NotFoundResponse +export type SendChatCompletionRequest408 = RequestTimeoutResponse +export const SendChatCompletionRequest408 = RequestTimeoutResponse +export type SendChatCompletionRequest413 = PayloadTooLargeResponse +export const SendChatCompletionRequest413 = PayloadTooLargeResponse +export type SendChatCompletionRequest422 = UnprocessableEntityResponse +export const SendChatCompletionRequest422 = UnprocessableEntityResponse +export type SendChatCompletionRequest429 = TooManyRequestsResponse +export const SendChatCompletionRequest429 = TooManyRequestsResponse +export type SendChatCompletionRequest500 = InternalServerResponse +export const SendChatCompletionRequest500 = InternalServerResponse +export type SendChatCompletionRequest502 = BadGatewayResponse +export const SendChatCompletionRequest502 = BadGatewayResponse +export type SendChatCompletionRequest503 = ServiceUnavailableResponse +export const SendChatCompletionRequest503 = ServiceUnavailableResponse +export type SendChatCompletionRequest524 = EdgeNetworkTimeoutResponse +export const SendChatCompletionRequest524 = EdgeNetworkTimeoutResponse +export type SendChatCompletionRequest529 = ProviderOverloadedResponse +export const SendChatCompletionRequest529 = ProviderOverloadedResponse export type GetCredits200 = { readonly "data": { readonly "total_credits": number; readonly "total_usage": number } } export const GetCredits200 = Schema.Struct({ "data": Schema.Struct({ @@ -7409,6 +10476,7 @@ export type GetGeneration200 = { | "Inception" | "Inceptron" | "InferenceNet" + | "Ionstream" | "Infermatic" | "Io Net" | "Inflection" @@ -7453,6 +10521,8 @@ export type GetGeneration200 = { readonly "is_byok"?: boolean } > + readonly "user_agent": string + readonly "http_referer": string } } export const GetGeneration200 = Schema.Struct({ @@ -7590,6 +10660,7 @@ export const GetGeneration200 = Schema.Struct({ "Inception", "Inceptron", "InferenceNet", + "Ionstream", "Infermatic", "Io Net", "Inflection", @@ -7634,7 +10705,9 @@ export const GetGeneration200 = Schema.Struct({ "status": Schema.Number.check(Schema.isFinite()), "latency": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), "is_byok": Schema.optionalKey(Schema.Boolean) - })).annotate({ "description": "List of provider responses for this generation, including fallback attempts" }) + })).annotate({ "description": "List of provider responses for this generation, including fallback attempts" }), + "user_agent": Schema.String.annotate({ "description": "User-Agent header from the request" }), + "http_referer": Schema.String.annotate({ "description": "Referer header from the request" }) }).annotate({ "description": "Generation data" }) }).annotate({ "description": "Generation response" }) export type GetGeneration401 = UnauthorizedResponse @@ -8153,6 +11226,7 @@ export type ListGuardrails200 = { readonly "limit_usd"?: number readonly "reset_interval"?: "daily" | "weekly" | "monthly" readonly "allowed_providers"?: ReadonlyArray + readonly "ignored_providers"?: ReadonlyArray readonly "allowed_models"?: ReadonlyArray readonly "enforce_zdr"?: boolean readonly "created_at": string @@ -8179,6 +11253,9 @@ export const ListGuardrails200 = Schema.Struct({ "allowed_providers": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "List of allowed provider IDs" }) ), + "ignored_providers": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "List of provider IDs to exclude from routing" }) + ), "allowed_models": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "Array of model canonical_slugs (immutable identifiers)" }) ), @@ -8202,6 +11279,7 @@ export type CreateGuardrailRequestJson = { readonly "limit_usd"?: number readonly "reset_interval"?: "daily" | "weekly" | "monthly" readonly "allowed_providers"?: ReadonlyArray + readonly "ignored_providers"?: ReadonlyArray readonly "allowed_models"?: ReadonlyArray readonly "enforce_zdr"?: boolean } @@ -8225,6 +11303,11 @@ export const CreateGuardrailRequestJson = Schema.Struct({ "allowed_providers": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "List of allowed provider IDs" }).check(Schema.isMinLength(1)) ), + "ignored_providers": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "List of provider IDs to exclude from routing" }).check( + Schema.isMinLength(1) + ) + ), "allowed_models": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "Array of model identifiers (slug or canonical_slug accepted)" @@ -8242,6 +11325,7 @@ export type CreateGuardrail201 = { readonly "limit_usd"?: number readonly "reset_interval"?: "daily" | "weekly" | "monthly" readonly "allowed_providers"?: ReadonlyArray + readonly "ignored_providers"?: ReadonlyArray readonly "allowed_models"?: ReadonlyArray readonly "enforce_zdr"?: boolean readonly "created_at": string @@ -8266,6 +11350,9 @@ export const CreateGuardrail201 = Schema.Struct({ "allowed_providers": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "List of allowed provider IDs" }) ), + "ignored_providers": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "List of provider IDs to exclude from routing" }) + ), "allowed_models": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "Array of model canonical_slugs (immutable identifiers)" }) ), @@ -8292,6 +11379,7 @@ export type GetGuardrail200 = { readonly "limit_usd"?: number readonly "reset_interval"?: "daily" | "weekly" | "monthly" readonly "allowed_providers"?: ReadonlyArray + readonly "ignored_providers"?: ReadonlyArray readonly "allowed_models"?: ReadonlyArray readonly "enforce_zdr"?: boolean readonly "created_at": string @@ -8316,6 +11404,9 @@ export const GetGuardrail200 = Schema.Struct({ "allowed_providers": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "List of allowed provider IDs" }) ), + "ignored_providers": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "List of provider IDs to exclude from routing" }) + ), "allowed_models": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "Array of model canonical_slugs (immutable identifiers)" }) ), @@ -8350,6 +11441,7 @@ export type UpdateGuardrailRequestJson = { readonly "limit_usd"?: number readonly "reset_interval"?: "daily" | "weekly" | "monthly" readonly "allowed_providers"?: ReadonlyArray + readonly "ignored_providers"?: ReadonlyArray readonly "allowed_models"?: ReadonlyArray readonly "enforce_zdr"?: boolean } @@ -8377,6 +11469,11 @@ export const UpdateGuardrailRequestJson = Schema.Struct({ Schema.isMinLength(1) ) ), + "ignored_providers": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "List of provider IDs to exclude from routing" }).check( + Schema.isMinLength(1) + ) + ), "allowed_models": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "Array of model identifiers (slug or canonical_slug accepted)" @@ -8394,6 +11491,7 @@ export type UpdateGuardrail200 = { readonly "limit_usd"?: number readonly "reset_interval"?: "daily" | "weekly" | "monthly" readonly "allowed_providers"?: ReadonlyArray + readonly "ignored_providers"?: ReadonlyArray readonly "allowed_models"?: ReadonlyArray readonly "enforce_zdr"?: boolean readonly "created_at": string @@ -8418,6 +11516,9 @@ export const UpdateGuardrail200 = Schema.Struct({ "allowed_providers": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "List of allowed provider IDs" }) ), + "ignored_providers": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "List of provider IDs to exclude from routing" }) + ), "allowed_models": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": "Array of model canonical_slugs (immutable identifiers)" }) ), @@ -8787,6 +11888,10 @@ export type CreateAuthKeysCodeRequestJson = { readonly "code_challenge_method"?: "S256" | "plain" readonly "limit"?: number readonly "expires_at"?: string + readonly "key_label"?: string + readonly "usage_limit_type"?: "daily" | "weekly" | "monthly" + readonly "spawn_agent"?: string + readonly "spawn_cloud"?: string } export const CreateAuthKeysCodeRequestJson = Schema.Struct({ "callback_url": Schema.String.annotate({ @@ -8808,7 +11913,19 @@ export const CreateAuthKeysCodeRequestJson = Schema.Struct({ "description": "Optional expiration time for the API key to be created", "format": "date-time" }) - ) + ), + "key_label": Schema.optionalKey( + Schema.String.annotate({ + "description": "Optional custom label for the API key. Defaults to the app name if not provided." + }).check(Schema.isMaxLength(100)) + ), + "usage_limit_type": Schema.optionalKey( + Schema.Literals(["daily", "weekly", "monthly"]).annotate({ + "description": "Optional credit limit reset interval. When set, the credit limit resets on this interval." + }) + ), + "spawn_agent": Schema.optionalKey(Schema.String.annotate({ "description": "Agent identifier for spawn telemetry" })), + "spawn_cloud": Schema.optionalKey(Schema.String.annotate({ "description": "Cloud identifier for spawn telemetry" })) }) export type CreateAuthKeysCode200 = { readonly "data": { readonly "id": string; readonly "app_id": number; readonly "created_at": string } @@ -8828,36 +11945,6 @@ export type CreateAuthKeysCode401 = UnauthorizedResponse export const CreateAuthKeysCode401 = UnauthorizedResponse export type CreateAuthKeysCode500 = InternalServerResponse export const CreateAuthKeysCode500 = InternalServerResponse -export type SendChatCompletionRequestRequestJson = ChatGenerationParams -export const SendChatCompletionRequestRequestJson = ChatGenerationParams -export type SendChatCompletionRequest200 = { - readonly "id": string - readonly "choices": ReadonlyArray - readonly "created": number - readonly "model": string - readonly "object": "chat.completion" - readonly "system_fingerprint"?: string | null - readonly "usage"?: ChatGenerationTokenUsage -} -export const SendChatCompletionRequest200 = Schema.Struct({ - "id": Schema.String, - "choices": Schema.Array(ChatResponseChoice), - "created": Schema.Number.check(Schema.isFinite()), - "model": Schema.String, - "object": Schema.Literal("chat.completion"), - "system_fingerprint": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "usage": Schema.optionalKey(ChatGenerationTokenUsage) -}).annotate({ "description": "Chat completion response" }) -export type SendChatCompletionRequest200Sse = ChatStreamingResponseChunk -export const SendChatCompletionRequest200Sse = ChatStreamingResponseChunk -export type SendChatCompletionRequest400 = ChatError -export const SendChatCompletionRequest400 = ChatError -export type SendChatCompletionRequest401 = ChatError -export const SendChatCompletionRequest401 = ChatError -export type SendChatCompletionRequest429 = ChatError -export const SendChatCompletionRequest429 = ChatError -export type SendChatCompletionRequest500 = ChatError -export const SendChatCompletionRequest500 = ChatError export interface OperationConfig { /** @@ -9009,6 +12096,32 @@ export const make = ( orElse: unexpectedStatus })) ), + "sendChatCompletionRequest": (options) => + HttpClientRequest.post(`/chat/completions`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(SendChatCompletionRequest200), + "400": decodeError("SendChatCompletionRequest400", SendChatCompletionRequest400), + "401": decodeError("SendChatCompletionRequest401", SendChatCompletionRequest401), + "402": decodeError("SendChatCompletionRequest402", SendChatCompletionRequest402), + "404": decodeError("SendChatCompletionRequest404", SendChatCompletionRequest404), + "408": decodeError("SendChatCompletionRequest408", SendChatCompletionRequest408), + "413": decodeError("SendChatCompletionRequest413", SendChatCompletionRequest413), + "422": decodeError("SendChatCompletionRequest422", SendChatCompletionRequest422), + "429": decodeError("SendChatCompletionRequest429", SendChatCompletionRequest429), + "500": decodeError("SendChatCompletionRequest500", SendChatCompletionRequest500), + "502": decodeError("SendChatCompletionRequest502", SendChatCompletionRequest502), + "503": decodeError("SendChatCompletionRequest503", SendChatCompletionRequest503), + "524": decodeError("SendChatCompletionRequest524", SendChatCompletionRequest524), + "529": decodeError("SendChatCompletionRequest529", SendChatCompletionRequest529), + orElse: unexpectedStatus + })) + ), + "sendChatCompletionRequestSse": (options) => + HttpClientRequest.post(`/chat/completions`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + sseRequest(SendChatCompletionRequest200Sse) + ), "getCredits": (options) => HttpClientRequest.get(`/credits`).pipe( withResponse(options?.config)(HttpClientResponse.matchStatus({ @@ -9384,23 +12497,6 @@ export const make = ( "500": decodeError("CreateAuthKeysCode500", CreateAuthKeysCode500), orElse: unexpectedStatus })) - ), - "sendChatCompletionRequest": (options) => - HttpClientRequest.post(`/chat/completions`).pipe( - HttpClientRequest.bodyJsonUnsafe(options.payload), - withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(SendChatCompletionRequest200), - "400": decodeError("SendChatCompletionRequest400", SendChatCompletionRequest400), - "401": decodeError("SendChatCompletionRequest401", SendChatCompletionRequest401), - "429": decodeError("SendChatCompletionRequest429", SendChatCompletionRequest429), - "500": decodeError("SendChatCompletionRequest500", SendChatCompletionRequest500), - orElse: unexpectedStatus - })) - ), - "sendChatCompletionRequestSse": (options) => - HttpClientRequest.post(`/chat/completions`).pipe( - HttpClientRequest.bodyJsonUnsafe(options.payload), - sseRequest(SendChatCompletionRequest200Sse) ) } } @@ -9485,6 +12581,46 @@ export interface OpenRouterClient { | OpenRouterClientError<"GetUserActivity403", typeof GetUserActivity403.Type> | OpenRouterClientError<"GetUserActivity500", typeof GetUserActivity500.Type> > + /** + * Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes. + */ + readonly "sendChatCompletionRequest": ( + options: { + readonly payload: typeof SendChatCompletionRequestRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenRouterClientError<"SendChatCompletionRequest400", typeof SendChatCompletionRequest400.Type> + | OpenRouterClientError<"SendChatCompletionRequest401", typeof SendChatCompletionRequest401.Type> + | OpenRouterClientError<"SendChatCompletionRequest402", typeof SendChatCompletionRequest402.Type> + | OpenRouterClientError<"SendChatCompletionRequest404", typeof SendChatCompletionRequest404.Type> + | OpenRouterClientError<"SendChatCompletionRequest408", typeof SendChatCompletionRequest408.Type> + | OpenRouterClientError<"SendChatCompletionRequest413", typeof SendChatCompletionRequest413.Type> + | OpenRouterClientError<"SendChatCompletionRequest422", typeof SendChatCompletionRequest422.Type> + | OpenRouterClientError<"SendChatCompletionRequest429", typeof SendChatCompletionRequest429.Type> + | OpenRouterClientError<"SendChatCompletionRequest500", typeof SendChatCompletionRequest500.Type> + | OpenRouterClientError<"SendChatCompletionRequest502", typeof SendChatCompletionRequest502.Type> + | OpenRouterClientError<"SendChatCompletionRequest503", typeof SendChatCompletionRequest503.Type> + | OpenRouterClientError<"SendChatCompletionRequest524", typeof SendChatCompletionRequest524.Type> + | OpenRouterClientError<"SendChatCompletionRequest529", typeof SendChatCompletionRequest529.Type> + > + /** + * Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes. + */ + readonly "sendChatCompletionRequestSse": ( + options: { readonly payload: typeof SendChatCompletionRequestRequestJson.Encoded } + ) => Stream.Stream< + { + readonly event: string + readonly id: string | undefined + readonly data: typeof SendChatCompletionRequest200Sse.Type + }, + HttpClientError.HttpClientError | SchemaError | Sse.Retry, + typeof SendChatCompletionRequest200Sse.DecodingServices + > /** * Get total credits purchased and used for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required. */ @@ -9968,37 +13104,6 @@ export interface OpenRouterClient { | OpenRouterClientError<"CreateAuthKeysCode401", typeof CreateAuthKeysCode401.Type> | OpenRouterClientError<"CreateAuthKeysCode500", typeof CreateAuthKeysCode500.Type> > - /** - * Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes. - */ - readonly "sendChatCompletionRequest": ( - options: { - readonly payload: typeof SendChatCompletionRequestRequestJson.Encoded - readonly config?: Config | undefined - } - ) => Effect.Effect< - WithOptionalResponse, - | HttpClientError.HttpClientError - | SchemaError - | OpenRouterClientError<"SendChatCompletionRequest400", typeof SendChatCompletionRequest400.Type> - | OpenRouterClientError<"SendChatCompletionRequest401", typeof SendChatCompletionRequest401.Type> - | OpenRouterClientError<"SendChatCompletionRequest429", typeof SendChatCompletionRequest429.Type> - | OpenRouterClientError<"SendChatCompletionRequest500", typeof SendChatCompletionRequest500.Type> - > - /** - * Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes. - */ - readonly "sendChatCompletionRequestSse": ( - options: { readonly payload: typeof SendChatCompletionRequestRequestJson.Encoded } - ) => Stream.Stream< - { - readonly event: string - readonly id: string | undefined - readonly data: typeof SendChatCompletionRequest200Sse.Type - }, - HttpClientError.HttpClientError | SchemaError | Sse.Retry, - typeof SendChatCompletionRequest200Sse.DecodingServices - > } export interface OpenRouterClientError {