diff --git a/packages/ai/anthropic/src/Generated.ts b/packages/ai/anthropic/src/Generated.ts index 319aeb25cef..3d0d000831a 100644 --- a/packages/ai/anthropic/src/Generated.ts +++ b/packages/ai/anthropic/src/Generated.ts @@ -1,5 +1,5 @@ /** - * @since 4.0.0 + * @since 1.0.0 */ import * as Data from "effect/Data" @@ -12,16 +12,210 @@ import * as HttpClientError from "effect/unstable/http/HttpClientError" import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest" import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse" // non-recursive definitions -export type APIError = { readonly "message": string; readonly "type": "api_error" } -export const APIError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Internal server error" }), - "type": Schema.Literal("api_error").annotate({ "title": "Type", "default": "api_error" }) -}).annotate({ "title": "APIError" }) -export type AuthenticationError = { readonly "message": string; readonly "type": "authentication_error" } -export const AuthenticationError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Authentication error" }), - "type": Schema.Literal("authentication_error").annotate({ "title": "Type", "default": "authentication_error" }) -}).annotate({ "title": "AuthenticationError" }) +export type Model = + | string + | "claude-sonnet-5" + | "claude-fable-5" + | "claude-mythos-5" + | "claude-opus-5" + | "claude-opus-4-8" + | "claude-opus-4-7" + | "claude-mythos-preview" + | "claude-opus-4-6" + | "claude-sonnet-4-6" + | "claude-haiku-4-5" + | "claude-haiku-4-5-20251001" + | "claude-opus-4-5" + | "claude-opus-4-5-20251101" + | "claude-sonnet-4-5" + | "claude-sonnet-4-5-20250929" +export const Model = Schema.Union([ + Schema.String, + Schema.Literals([ + "claude-sonnet-5", + "claude-fable-5", + "claude-mythos-5", + "claude-opus-5", + "claude-opus-4-8", + "claude-opus-4-7", + "claude-mythos-preview", + "claude-opus-4-6", + "claude-sonnet-4-6", + "claude-haiku-4-5", + "claude-haiku-4-5-20251001", + "claude-opus-4-5", + "claude-opus-4-5-20251101", + "claude-sonnet-4-5", + "claude-sonnet-4-5-20250929" + ]) +]).annotate({ + "title": "Model", + "description": + "The model that will complete your prompt.\n\nSee [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.", + "identifier": "Model" +}) +export type CacheControlEphemeral = { readonly "ttl"?: "5m" | "1h"; readonly "type": "ephemeral" } +export const CacheControlEphemeral = Schema.Struct({ + "ttl": Schema.optionalKey( + Schema.Literals(["5m", "1h"]).annotate({ + "title": "Ttl", + "description": + "The time-to-live for the cache control breakpoint.\n\nThis may be one the following values:\n- `5m`: 5 minutes\n- `1h`: 1 hour\n\nDefaults to `5m`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details." + }) + ), + "type": Schema.Literal("ephemeral").annotate({ "title": "Type" }) +}).annotate({ "title": "CacheControlEphemeral", "identifier": "CacheControlEphemeral" }) +export type RequestCharLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_char_index": number + readonly "start_char_index": number + readonly "type": "char_location" +} +export const RequestCharLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ "title": "Document Title" }), + "end_char_index": Schema.Number.annotate({ "title": "End Char Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "start_char_index": Schema.Number.annotate({ "title": "Start Char Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "type": Schema.Literal("char_location").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestCharLocationCitation", "identifier": "RequestCharLocationCitation" }) +export type RequestPageLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_page_number": number + readonly "start_page_number": number + readonly "type": "page_location" +} +export const RequestPageLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ "title": "Document Title" }), + "end_page_number": Schema.Number.annotate({ "title": "End Page Number" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "start_page_number": Schema.Number.annotate({ "title": "Start Page Number" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })), + "type": Schema.Literal("page_location").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestPageLocationCitation", "identifier": "RequestPageLocationCitation" }) +export type RequestContentBlockLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_block_index": number + readonly "start_block_index": number + readonly "type": "content_block_location" +} +export const RequestContentBlockLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ + "title": "Cited Text", + "description": + "The full text of the cited block range, concatenated.\n\nAlways equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns." + }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ "title": "Document Title" }), + "end_block_index": Schema.Number.annotate({ + "title": "End Block Index", + "description": + "Exclusive 0-based end index of the cited block range in the source's `content` array.\n\nAlways greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_block_index": Schema.Number.annotate({ + "title": "Start Block Index", + "description": "0-based index of the first cited block in the source's `content` array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "type": Schema.Literal("content_block_location").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestContentBlockLocationCitation", "identifier": "RequestContentBlockLocationCitation" }) +export type RequestWebSearchResultLocationCitation = { + readonly "cited_text": string + readonly "encrypted_index": string + readonly "title": string | null + readonly "type": "web_search_result_location" + readonly "url": string +} +export const RequestWebSearchResultLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "encrypted_index": Schema.String.annotate({ "title": "Encrypted Index" }), + "title": Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" }) + ), + Schema.Null + ]).annotate({ "title": "Title" }), + "type": Schema.Literal("web_search_result_location").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" })) +}).annotate({ + "title": "RequestWebSearchResultLocationCitation", + "identifier": "RequestWebSearchResultLocationCitation" +}) +export type RequestSearchResultLocationCitation = { + readonly "cited_text": string + readonly "end_block_index": number + readonly "search_result_index": number + readonly "source": string + readonly "start_block_index": number + readonly "title": string | null + readonly "type": "search_result_location" +} +export const RequestSearchResultLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ + "title": "Cited Text", + "description": + "The full text of the cited block range, concatenated.\n\nAlways equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns." + }), + "end_block_index": Schema.Number.annotate({ + "title": "End Block Index", + "description": + "Exclusive 0-based end index of the cited block range in the source's `content` array.\n\nAlways greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "search_result_index": Schema.Number.annotate({ + "title": "Search Result Index", + "description": + "0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.\n\nCounted separately from `document_index`; server-side web search results are not included in this count." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "source": Schema.String.annotate({ "title": "Source" }), + "start_block_index": Schema.Number.annotate({ + "title": "Start Block Index", + "description": "0-based index of the first cited block in the source's `content` array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Title" }), + "type": Schema.Literal("search_result_location").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestSearchResultLocationCitation", "identifier": "RequestSearchResultLocationCitation" }) export type Base64ImageSource = { readonly "data": string readonly "media_type": "image/jpeg" | "image/png" | "image/gif" | "image/webp" @@ -33,7 +227,16 @@ export const Base64ImageSource = Schema.Struct({ "title": "Media Type" }), "type": Schema.Literal("base64").annotate({ "title": "Type" }) -}).annotate({ "title": "Base64ImageSource" }) +}).annotate({ "title": "Base64ImageSource", "identifier": "Base64ImageSource" }) +export type URLImageSource = { readonly "type": "url"; readonly "url": string } +export const URLImageSource = Schema.Struct({ + "type": Schema.Literal("url").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url" }) +}).annotate({ "title": "URLImageSource", "identifier": "URLImageSource" }) +export type RequestCitationsConfig = { readonly "enabled"?: boolean } +export const RequestCitationsConfig = Schema.Struct({ + "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Enabled" })) +}).annotate({ "title": "RequestCitationsConfig", "identifier": "RequestCitationsConfig" }) export type Base64PDFSource = { readonly "data": string readonly "media_type": "application/pdf" @@ -43,7 +246,138 @@ export const Base64PDFSource = Schema.Struct({ "data": Schema.String.annotate({ "title": "Data", "format": "byte" }), "media_type": Schema.Literal("application/pdf").annotate({ "title": "Media Type" }), "type": Schema.Literal("base64").annotate({ "title": "Type" }) -}).annotate({ "title": "Base64PDFSource" }) +}).annotate({ "title": "Base64PDFSource", "identifier": "Base64PDFSource" }) +export type PlainTextSource = { readonly "data": string; readonly "media_type": "text/plain"; readonly "type": "text" } +export const PlainTextSource = Schema.Struct({ + "data": Schema.String.annotate({ "title": "Data" }), + "media_type": Schema.Literal("text/plain").annotate({ "title": "Media Type" }), + "type": Schema.Literal("text").annotate({ "title": "Type" }) +}).annotate({ "title": "PlainTextSource", "identifier": "PlainTextSource" }) +export type URLPDFSource = { readonly "type": "url"; readonly "url": string } +export const URLPDFSource = Schema.Struct({ + "type": Schema.Literal("url").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url" }) +}).annotate({ "title": "URLPDFSource", "identifier": "URLPDFSource" }) +export type RequestThinkingBlock = { + readonly "signature": string + readonly "thinking": string + readonly "type": "thinking" +} +export const RequestThinkingBlock = Schema.Struct({ + "signature": Schema.String.annotate({ + "title": "Signature", + "description": + "The `signature` value of this thinking block, exactly as returned by the API in a previous response. Used to verify that the block was generated by Claude.\n\nThinking blocks must be passed back unmodified and in their original order; a modified block results in a 400 `invalid_request_error`." + }), + "thinking": Schema.String.annotate({ + "title": "Thinking", + "description": "The `thinking` text of this block as returned by the API." + }), + "type": Schema.Literal("thinking").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestThinkingBlock", "identifier": "RequestThinkingBlock" }) +export type RequestRedactedThinkingBlock = { readonly "data": string; readonly "type": "redacted_thinking" } +export const RequestRedactedThinkingBlock = Schema.Struct({ + "data": Schema.String.annotate({ + "title": "Data", + "description": + "The `data` value of this redacted thinking block, exactly as returned by the API in a previous response. Opaque and encrypted; pass it back unchanged." + }), + "type": Schema.Literal("redacted_thinking").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestRedactedThinkingBlock", "identifier": "RequestRedactedThinkingBlock" }) +export type DirectCaller = { readonly "type": "direct" } +export const DirectCaller = Schema.Struct({ "type": Schema.Literal("direct").annotate({ "title": "Type" }) }).annotate({ + "title": "DirectCaller", + "description": "Tool invocation directly from the model.", + "identifier": "DirectCaller" +}) +export type ServerToolCaller = { readonly "tool_id": string; readonly "type": "code_execution_20250825" } +export const ServerToolCaller = Schema.Struct({ + "tool_id": Schema.String.annotate({ "title": "Tool Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" + }) + ), + "type": Schema.Literal("code_execution_20250825").annotate({ "title": "Type" }) +}).annotate({ + "title": "ServerToolCaller", + "description": "Tool invocation generated by a server-side tool.", + "identifier": "ServerToolCaller" +}) +export type ServerToolCaller_20260120 = { readonly "tool_id": string; readonly "type": "code_execution_20260120" } +export const ServerToolCaller_20260120 = Schema.Struct({ + "tool_id": Schema.String.annotate({ "title": "Tool Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" + }) + ), + "type": Schema.Literal("code_execution_20260120").annotate({ "title": "Type" }) +}).annotate({ "title": "ServerToolCaller_20260120", "identifier": "ServerToolCaller_20260120" }) +export type RequestWebSearchResultBlock = { + readonly "encrypted_content": string + readonly "page_age"?: string | null + readonly "title": string + readonly "type": "web_search_result" + readonly "url": string +} +export const RequestWebSearchResultBlock = Schema.Struct({ + "encrypted_content": Schema.String.annotate({ "title": "Encrypted Content" }), + "page_age": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Page Age" })), + "title": Schema.String.annotate({ "title": "Title" }), + "type": Schema.Literal("web_search_result").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url" }) +}).annotate({ "title": "RequestWebSearchResultBlock", "identifier": "RequestWebSearchResultBlock" }) +export type WebSearchToolResultErrorCode = + | "invalid_tool_input" + | "unavailable" + | "max_uses_exceeded" + | "too_many_requests" + | "query_too_long" + | "request_too_large" +export const WebSearchToolResultErrorCode = Schema.Literals([ + "invalid_tool_input", + "unavailable", + "max_uses_exceeded", + "too_many_requests", + "query_too_long", + "request_too_large" +]).annotate({ "title": "WebSearchToolResultErrorCode", "identifier": "WebSearchToolResultErrorCode" }) +export type WebFetchToolResultErrorCode = + | "invalid_tool_input" + | "url_too_long" + | "url_not_allowed" + | "url_not_in_prior_context" + | "url_not_accessible" + | "unsupported_content_type" + | "too_many_requests" + | "max_uses_exceeded" + | "unavailable" +export const WebFetchToolResultErrorCode = Schema.Literals([ + "invalid_tool_input", + "url_too_long", + "url_not_allowed", + "url_not_in_prior_context", + "url_not_accessible", + "unsupported_content_type", + "too_many_requests", + "max_uses_exceeded", + "unavailable" +]).annotate({ "title": "WebFetchToolResultErrorCode", "identifier": "WebFetchToolResultErrorCode" }) +export type CodeExecutionToolResultErrorCode = + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" +export const CodeExecutionToolResultErrorCode = Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" +]).annotate({ "title": "CodeExecutionToolResultErrorCode", "identifier": "CodeExecutionToolResultErrorCode" }) +export type RequestCodeExecutionOutputBlock = { readonly "file_id": string; readonly "type": "code_execution_output" } +export const RequestCodeExecutionOutputBlock = Schema.Struct({ + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("code_execution_output").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestCodeExecutionOutputBlock", "identifier": "RequestCodeExecutionOutputBlock" }) export type BashCodeExecutionToolResultErrorCode = | "invalid_tool_input" | "unavailable" @@ -56,649 +390,794 @@ export const BashCodeExecutionToolResultErrorCode = Schema.Literals([ "too_many_requests", "execution_time_exceeded", "output_file_too_large" -]).annotate({ "title": "BashCodeExecutionToolResultErrorCode" }) -export type BetaAPIError = { readonly "message": string; readonly "type": "api_error" } -export const BetaAPIError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Internal server error" }), - "type": Schema.Literal("api_error").annotate({ "title": "Type", "default": "api_error" }) -}).annotate({ "title": "APIError" }) -export type BetaAllThinkingTurns = { readonly "type": "all" } -export const BetaAllThinkingTurns = Schema.Struct({ "type": Schema.Literal("all").annotate({ "title": "Type" }) }) - .annotate({ "title": "AllThinkingTurns" }) -export type BetaAuthenticationError = { readonly "message": string; readonly "type": "authentication_error" } -export const BetaAuthenticationError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Authentication error" }), - "type": Schema.Literal("authentication_error").annotate({ "title": "Type", "default": "authentication_error" }) -}).annotate({ "title": "AuthenticationError" }) -export type BetaBase64ImageSource = { - readonly "data": string - readonly "media_type": "image/jpeg" | "image/png" | "image/gif" | "image/webp" - readonly "type": "base64" -} -export const BetaBase64ImageSource = Schema.Struct({ - "data": Schema.String.annotate({ "title": "Data", "format": "byte" }), - "media_type": Schema.Literals(["image/jpeg", "image/png", "image/gif", "image/webp"]).annotate({ - "title": "Media Type" - }), - "type": Schema.Literal("base64").annotate({ "title": "Type" }) -}).annotate({ "title": "Base64ImageSource" }) -export type BetaBase64PDFSource = { - readonly "data": string - readonly "media_type": "application/pdf" - readonly "type": "base64" +]).annotate({ "title": "BashCodeExecutionToolResultErrorCode", "identifier": "BashCodeExecutionToolResultErrorCode" }) +export type RequestBashCodeExecutionOutputBlock = { + readonly "file_id": string + readonly "type": "bash_code_execution_output" } -export const BetaBase64PDFSource = Schema.Struct({ - "data": Schema.String.annotate({ "title": "Data", "format": "byte" }), - "media_type": Schema.Literal("application/pdf").annotate({ "title": "Media Type" }), - "type": Schema.Literal("base64").annotate({ "title": "Type" }) -}).annotate({ "title": "Base64PDFSource" }) -export type BetaBashCodeExecutionToolResultErrorCode = +export const RequestBashCodeExecutionOutputBlock = Schema.Struct({ + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("bash_code_execution_output").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestBashCodeExecutionOutputBlock", "identifier": "RequestBashCodeExecutionOutputBlock" }) +export type TextEditorCodeExecutionToolResultErrorCode = | "invalid_tool_input" | "unavailable" | "too_many_requests" | "execution_time_exceeded" - | "output_file_too_large" -export const BetaBashCodeExecutionToolResultErrorCode = Schema.Literals([ + | "file_not_found" +export const TextEditorCodeExecutionToolResultErrorCode = Schema.Literals([ "invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded", - "output_file_too_large" -]).annotate({ "title": "BashCodeExecutionToolResultErrorCode" }) -export type BetaBillingError = { readonly "message": string; readonly "type": "billing_error" } -export const BetaBillingError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Billing error" }), - "type": Schema.Literal("billing_error").annotate({ "title": "Type", "default": "billing_error" }) -}).annotate({ "title": "BillingError" }) -export type BetaBody_create_skill_v1_skills_post = { - readonly "display_title"?: string | null - readonly "files"?: ReadonlyArray | null + "file_not_found" +]).annotate({ + "title": "TextEditorCodeExecutionToolResultErrorCode", + "identifier": "TextEditorCodeExecutionToolResultErrorCode" +}) +export type RequestTextEditorCodeExecutionViewResultBlock = { + readonly "content": string + readonly "file_type": "text" | "image" | "pdf" + readonly "num_lines"?: number | null + readonly "start_line"?: number | null + readonly "total_lines"?: number | null + readonly "type": "text_editor_code_execution_view_result" } -export const BetaBody_create_skill_v1_skills_post = Schema.Struct({ - "display_title": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Display Title", - "description": - "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." +export const RequestTextEditorCodeExecutionViewResultBlock = Schema.Struct({ + "content": Schema.String.annotate({ "title": "Content" }), + "file_type": Schema.Literals(["text", "image", "pdf"]).annotate({ "title": "File Type" }), + "num_lines": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Num Lines" }) ), - "files": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String.annotate({ "format": "binary" })), Schema.Null]).annotate({ - "title": "Files", - "description": - "Files to upload for the skill.\n\nAll files must be in the same top-level directory and must include a SKILL.md file at the root of that directory." + "start_line": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Start Line" }) - ) -}).annotate({ "title": "Body_create_skill_v1_skills_post" }) -export type BetaBody_create_skill_version_v1_skills__skill_id__versions_post = { - readonly "files"?: ReadonlyArray | null + ), + "total_lines": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Total Lines" + }) + ), + "type": Schema.Literal("text_editor_code_execution_view_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionViewResultBlock", + "identifier": "RequestTextEditorCodeExecutionViewResultBlock" +}) +export type RequestTextEditorCodeExecutionCreateResultBlock = { + readonly "is_file_update": boolean + readonly "type": "text_editor_code_execution_create_result" } -export const BetaBody_create_skill_version_v1_skills__skill_id__versions_post = Schema.Struct({ - "files": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String.annotate({ "format": "binary" })), Schema.Null]).annotate({ - "title": "Files", - "description": - "Files to upload for the skill.\n\nAll files must be in the same top-level directory and must include a SKILL.md file at the root of that directory." +export const RequestTextEditorCodeExecutionCreateResultBlock = Schema.Struct({ + "is_file_update": Schema.Boolean.annotate({ "title": "Is File Update" }), + "type": Schema.Literal("text_editor_code_execution_create_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionCreateResultBlock", + "identifier": "RequestTextEditorCodeExecutionCreateResultBlock" +}) +export type RequestTextEditorCodeExecutionStrReplaceResultBlock = { + readonly "lines"?: ReadonlyArray | null + readonly "new_lines"?: number | null + readonly "new_start"?: number | null + readonly "old_lines"?: number | null + readonly "old_start"?: number | null + readonly "type": "text_editor_code_execution_str_replace_result" +} +export const RequestTextEditorCodeExecutionStrReplaceResultBlock = Schema.Struct({ + "lines": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Lines" })), + "new_lines": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "New Lines" }) - ) -}).annotate({ "title": "Body_create_skill_version_v1_skills__skill_id__versions_post" }) -export type BetaCacheControlEphemeral = { readonly "ttl"?: "5m" | "1h"; readonly "type": "ephemeral" } -export const BetaCacheControlEphemeral = Schema.Struct({ - "ttl": Schema.optionalKey( - Schema.Literals(["5m", "1h"]).annotate({ - "title": "Ttl", - "description": - "The time-to-live for the cache control breakpoint.\n\nThis may be one the following values:\n- `5m`: 5 minutes\n- `1h`: 1 hour\n\nDefaults to `5m`." + ), + "new_start": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "New Start" }) ), - "type": Schema.Literal("ephemeral").annotate({ "title": "Type" }) -}).annotate({ "title": "CacheControlEphemeral" }) -export type BetaCacheCreation = { - readonly "ephemeral_1h_input_tokens": number - readonly "ephemeral_5m_input_tokens": number -} -export const BetaCacheCreation = Schema.Struct({ - "ephemeral_1h_input_tokens": Schema.Number.annotate({ - "title": "Ephemeral 1H Input Tokens", - "description": "The number of input tokens used to create the 1 hour cache entry.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "ephemeral_5m_input_tokens": Schema.Number.annotate({ - "title": "Ephemeral 5M Input Tokens", - "description": "The number of input tokens used to create the 5 minute cache entry.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) -}).annotate({ "title": "CacheCreation" }) -export type BetaCanceledResult = { readonly "type": "canceled" } -export const BetaCanceledResult = Schema.Struct({ - "type": Schema.Literal("canceled").annotate({ "title": "Type", "default": "canceled" }) -}).annotate({ "title": "CanceledResult" }) -export type BetaCodeExecutionToolResultErrorCode = + "old_lines": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Old Lines" + }) + ), + "old_start": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Old Start" + }) + ), + "type": Schema.Literal("text_editor_code_execution_str_replace_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionStrReplaceResultBlock", + "identifier": "RequestTextEditorCodeExecutionStrReplaceResultBlock" +}) +export type ToolSearchToolResultErrorCode = | "invalid_tool_input" | "unavailable" | "too_many_requests" | "execution_time_exceeded" -export const BetaCodeExecutionToolResultErrorCode = Schema.Literals([ +export const ToolSearchToolResultErrorCode = Schema.Literals([ "invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded" -]).annotate({ "title": "CodeExecutionToolResultErrorCode" }) -export type BetaCompactionContentBlockDelta = { readonly "content": string | null; readonly "type": "compaction_delta" } -export const BetaCompactionContentBlockDelta = Schema.Struct({ - "content": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Content" }), - "type": Schema.Literal("compaction_delta").annotate({ "title": "Type", "default": "compaction_delta" }) -}).annotate({ "title": "CompactionContentBlockDelta" }) -export type BetaContentBlockStopEvent = { readonly "index": number; readonly "type": "content_block_stop" } -export const BetaContentBlockStopEvent = Schema.Struct({ - "index": Schema.Number.annotate({ "title": "Index" }).check(Schema.isInt()), - "type": Schema.Literal("content_block_stop").annotate({ "title": "Type", "default": "content_block_stop" }) -}).annotate({ "title": "ContentBlockStopEvent" }) -export type BetaContextManagementResponse = { readonly "original_input_tokens": number } -export const BetaContextManagementResponse = Schema.Struct({ - "original_input_tokens": Schema.Number.annotate({ - "title": "Original Input Tokens", - "description": "The original token count before context management was applied" - }).check(Schema.isInt()) -}).annotate({ "title": "ContextManagementResponse" }) -export type BetaCreateSkillResponse = { - readonly "created_at": string - readonly "display_title": string | null - readonly "id": string - readonly "latest_version": string | null - readonly "source": string - readonly "type": string - readonly "updated_at": string +]).annotate({ "title": "ToolSearchToolResultErrorCode", "identifier": "ToolSearchToolResultErrorCode" }) +export type Metadata = { readonly "user_id"?: string | null } +export const Metadata = Schema.Struct({ + "user_id": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })), + Schema.Null + ]).annotate({ + "title": "User Id", + "description": + "An external identifier for the user who is associated with the request.\n\nThis should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number." + }) + ) +}).annotate({ "title": "Metadata", "identifier": "Metadata" }) +export type EffortLevel = "low" | "medium" | "high" | "xhigh" | "max" +export const EffortLevel = Schema.Literals(["low", "medium", "high", "xhigh", "max"]).annotate({ + "title": "EffortLevel", + "description": "All possible effort levels.", + "identifier": "EffortLevel" +}) +export type JsonOutputFormat = { + readonly "schema": { readonly [x: string]: Schema.Json } + readonly "type": "json_schema" } -export const BetaCreateSkillResponse = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill was created." - }), - "display_title": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Display Title", - "description": - "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." - }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." - }), - "latest_version": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Latest Version", - "description": - "The latest version identifier for the skill.\n\nThis represents the most recent version of the skill that has been created." - }), - "source": Schema.String.annotate({ - "title": "Source", - "description": - "Source of the skill.\n\nThis may be one of the following values:\n* `\"custom\"`: the skill was created by a user\n* `\"anthropic\"`: the skill was created by Anthropic" - }), - "type": Schema.String.annotate({ - "title": "Type", - "description": "Object type.\n\nFor Skills, this is always `\"skill\"`.", - "default": "skill" +export const JsonOutputFormat = Schema.Struct({ + "schema": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Schema", + "description": "The JSON schema of the format" }), - "updated_at": Schema.String.annotate({ - "title": "Updated At", - "description": "ISO 8601 timestamp of when the skill was last updated." - }) -}).annotate({ "title": "CreateSkillResponse" }) -export type BetaCreateSkillVersionResponse = { - readonly "created_at": string - readonly "description": string - readonly "directory": string - readonly "id": string + "type": Schema.Literal("json_schema").annotate({ "title": "Type" }) +}).annotate({ "title": "JsonOutputFormat", "identifier": "JsonOutputFormat" }) +export type ThinkingDisplayMode = "summarized" | "omitted" +export const ThinkingDisplayMode = Schema.Literals(["summarized", "omitted"]).annotate({ + "title": "ThinkingDisplayMode", + "identifier": "ThinkingDisplayMode" +}) +export type ThinkingConfigDisabled = { readonly "type": "disabled" } +export const ThinkingConfigDisabled = Schema.Struct({ + "type": Schema.Literal("disabled").annotate({ "title": "Type" }) +}).annotate({ "title": "ThinkingConfigDisabled", "identifier": "ThinkingConfigDisabled" }) +export type ToolChoiceAuto = { readonly "disable_parallel_tool_use"?: boolean; readonly "type": "auto" } +export const ToolChoiceAuto = Schema.Struct({ + "disable_parallel_tool_use": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Disable Parallel Tool Use", + "description": + "Whether to disable parallel tool use.\n\nDefaults to `false`. If set to `true`, the model will output at most one tool use." + }) + ), + "type": Schema.Literal("auto").annotate({ "title": "Type" }) +}).annotate({ + "title": "ToolChoiceAuto", + "description": "The model will automatically decide whether to use tools.", + "identifier": "ToolChoiceAuto" +}) +export type ToolChoiceAny = { readonly "disable_parallel_tool_use"?: boolean; readonly "type": "any" } +export const ToolChoiceAny = Schema.Struct({ + "disable_parallel_tool_use": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Disable Parallel Tool Use", + "description": + "Whether to disable parallel tool use.\n\nDefaults to `false`. If set to `true`, the model will output exactly one tool use." + }) + ), + "type": Schema.Literal("any").annotate({ "title": "Type" }) +}).annotate({ + "title": "ToolChoiceAny", + "description": "The model will use any available tools.", + "identifier": "ToolChoiceAny" +}) +export type ToolChoiceTool = { + readonly "disable_parallel_tool_use"?: boolean readonly "name": string - readonly "skill_id": string - readonly "type": string - readonly "version": string + readonly "type": "tool" } -export const BetaCreateSkillVersionResponse = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill version was created." - }), - "description": Schema.String.annotate({ - "title": "Description", - "description": "Description of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." - }), - "directory": Schema.String.annotate({ - "title": "Directory", - "description": - "Directory name of the skill version.\n\nThis is the top-level directory name that was extracted from the uploaded files." +export const ToolChoiceTool = Schema.Struct({ + "disable_parallel_tool_use": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Disable Parallel Tool Use", + "description": + "Whether to disable parallel tool use.\n\nDefaults to `false`. If set to `true`, the model will output exactly one tool use." + }) + ), + "name": Schema.String.annotate({ "title": "Name", "description": "The name of the tool to use." }), + "type": Schema.Literal("tool").annotate({ "title": "Type" }) +}).annotate({ + "title": "ToolChoiceTool", + "description": "The model will use the specified tool with `tool_choice.name`.", + "identifier": "ToolChoiceTool" +}) +export type ToolChoiceNone = { readonly "type": "none" } +export const ToolChoiceNone = Schema.Struct({ "type": Schema.Literal("none").annotate({ "title": "Type" }) }).annotate({ + "title": "ToolChoiceNone", + "description": "The model will not be allowed to use tools.", + "identifier": "ToolChoiceNone" +}) +export type InputSchema = { + readonly "properties"?: { readonly [x: string]: Schema.Json } | null + readonly "required"?: ReadonlyArray | null + readonly "type": "object" + readonly [x: string]: Schema.Json +} +export const InputSchema = Schema.StructWithRest( + Schema.Struct({ + "properties": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + .annotate({ "title": "Properties" }) + ), + "required": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Required" }) + ), + "type": Schema.Literal("object").annotate({ "title": "Type" }) }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill version.\n\nThe format and length of IDs may change over time." - }), - "name": Schema.String.annotate({ - "title": "Name", + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ "title": "InputSchema", "identifier": "InputSchema" }) +export type AllowedCaller = "direct" | "code_execution_20250825" | "code_execution_20260120" | "code_execution_20260521" +export const AllowedCaller = Schema.Literals([ + "direct", + "code_execution_20250825", + "code_execution_20260120", + "code_execution_20260521" +]).annotate({ + "title": "AllowedCaller", + "description": + "Specifies who can invoke a tool.\n\nValues:\n direct: The model can call this tool directly.\n code_execution_20250825: The tool can be called from the code execution environment (v1).\n code_execution_20260120: The tool can be called from the code execution environment (v2 with persistence).\n code_execution_20260521: The tool can be called from the code execution environment (v2 with persistence).", + "identifier": "AllowedCaller" +}) +export type JsonValue = Schema.Json +export const JsonValue = Schema.Json.annotate({ "expected": "JSON value", "identifier": "JsonValue" }) +export type UserLocation = { + readonly "city"?: string | null + readonly "country"?: string | null + readonly "region"?: string | null + readonly "timezone"?: string | null + readonly "type": "approximate" +} +export const UserLocation = Schema.Struct({ + "city": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ "title": "City", "description": "The city of the user." }) + ), + "country": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(2).annotate({ "expected": "a value with a length of at least 2" })).check( + Schema.isMaxLength(2).annotate({ "expected": "a value with a length of at most 2" }) + ), + Schema.Null + ]).annotate({ + "title": "Country", + "description": "The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user." + }) + ), + "region": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ "title": "Region", "description": "The region of the user." }) + ), + "timezone": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ + "title": "Timezone", + "description": "The [IANA timezone](https://nodatime.org/TimeZones) of the user." + }) + ), + "type": Schema.Literal("approximate").annotate({ "title": "Type" }) +}).annotate({ "title": "UserLocation", "identifier": "UserLocation" }) +export type ResponseCharLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_char_index": number + readonly "file_id": string | null + readonly "start_char_index": number + readonly "type": "char_location" +} +export const ResponseCharLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), + "end_char_index": Schema.Number.annotate({ "title": "End Char Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), + "start_char_index": Schema.Number.annotate({ "title": "Start Char Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "type": Schema.Literal("char_location").annotate({ "title": "Type", "default": "char_location" }) +}).annotate({ "title": "ResponseCharLocationCitation", "identifier": "ResponseCharLocationCitation" }) +export type ResponsePageLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_page_number": number + readonly "file_id": string | null + readonly "start_page_number": number + readonly "type": "page_location" +} +export const ResponsePageLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), + "end_page_number": Schema.Number.annotate({ "title": "End Page Number" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), + "start_page_number": Schema.Number.annotate({ "title": "Start Page Number" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })), + "type": Schema.Literal("page_location").annotate({ "title": "Type", "default": "page_location" }) +}).annotate({ "title": "ResponsePageLocationCitation", "identifier": "ResponsePageLocationCitation" }) +export type ResponseContentBlockLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_block_index": number + readonly "file_id": string | null + readonly "start_block_index": number + readonly "type": "content_block_location" +} +export const ResponseContentBlockLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ + "title": "Cited Text", "description": - "Human-readable name of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." - }), - "skill_id": Schema.String.annotate({ - "title": "Skill Id", - "description": "Identifier for the skill that this version belongs to." - }), - "type": Schema.String.annotate({ - "title": "Type", - "description": "Object type.\n\nFor Skill Versions, this is always `\"skill_version\"`.", - "default": "skill_version" + "The full text of the cited block range, concatenated.\n\nAlways equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns." }), - "version": Schema.String.annotate({ - "title": "Version", + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), + "end_block_index": Schema.Number.annotate({ + "title": "End Block Index", "description": - "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." - }) -}).annotate({ "title": "CreateSkillVersionResponse" }) -export type BetaDeleteMessageBatchResponse = { readonly "id": string; readonly "type": "message_batch_deleted" } -export const BetaDeleteMessageBatchResponse = Schema.Struct({ - "id": Schema.String.annotate({ "title": "Id", "description": "ID of the Message Batch." }), - "type": Schema.Literal("message_batch_deleted").annotate({ - "title": "Type", - "description": "Deleted object type.\n\nFor Message Batches, this is always `\"message_batch_deleted\"`.", - "default": "message_batch_deleted" - }) -}).annotate({ "title": "DeleteMessageBatchResponse" }) -export type BetaDeleteSkillResponse = { readonly "id": string; readonly "type": string } -export const BetaDeleteSkillResponse = Schema.Struct({ - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." - }), - "type": Schema.String.annotate({ + "Exclusive 0-based end index of the cited block range in the source's `content` array.\n\nAlways greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), + "start_block_index": Schema.Number.annotate({ + "title": "Start Block Index", + "description": "0-based index of the first cited block in the source's `content` array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "type": Schema.Literal("content_block_location").annotate({ "title": "Type", "default": "content_block_location" }) +}).annotate({ "title": "ResponseContentBlockLocationCitation", "identifier": "ResponseContentBlockLocationCitation" }) +export type ResponseWebSearchResultLocationCitation = { + readonly "cited_text": string + readonly "encrypted_index": string + readonly "title": string | null + readonly "type": "web_search_result_location" + readonly "url": string +} +export const ResponseWebSearchResultLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "encrypted_index": Schema.String.annotate({ "title": "Encrypted Index" }), + "title": Schema.Union([ + Schema.String.check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })), + Schema.Null + ]).annotate({ "title": "Title" }), + "type": Schema.Literal("web_search_result_location").annotate({ "title": "Type", - "description": "Deleted object type.\n\nFor Skills, this is always `\"skill_deleted\"`.", - "default": "skill_deleted" - }) -}).annotate({ "title": "DeleteSkillResponse" }) -export type BetaDeleteSkillVersionResponse = { readonly "id": string; readonly "type": string } -export const BetaDeleteSkillVersionResponse = Schema.Struct({ - "id": Schema.String.annotate({ - "title": "Id", - "description": - "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." + "default": "web_search_result_location" }), - "type": Schema.String.annotate({ - "title": "Type", - "description": "Deleted object type.\n\nFor Skill Versions, this is always `\"skill_version_deleted\"`.", - "default": "skill_version_deleted" - }) -}).annotate({ "title": "DeleteSkillVersionResponse" }) -export type BetaDirectCaller = { readonly "type": "direct" } -export const BetaDirectCaller = Schema.Struct({ "type": Schema.Literal("direct").annotate({ "title": "Type" }) }) - .annotate({ "title": "DirectCaller", "description": "Tool invocation directly from the model." }) -export type BetaEffortLevel = "low" | "medium" | "high" | "max" -export const BetaEffortLevel = Schema.Literals(["low", "medium", "high", "max"]).annotate({ - "title": "EffortLevel", - "description": "All possible effort levels." + "url": Schema.String.annotate({ "title": "Url" }) +}).annotate({ + "title": "ResponseWebSearchResultLocationCitation", + "identifier": "ResponseWebSearchResultLocationCitation" }) -export type BetaExpiredResult = { readonly "type": "expired" } -export const BetaExpiredResult = Schema.Struct({ - "type": Schema.Literal("expired").annotate({ "title": "Type", "default": "expired" }) -}).annotate({ "title": "ExpiredResult" }) -export type BetaFileDeleteResponse = { readonly "id": string; readonly "type"?: "file_deleted" } -export const BetaFileDeleteResponse = Schema.Struct({ - "id": Schema.String.annotate({ "title": "Id", "description": "ID of the deleted file." }), - "type": Schema.optionalKey( - Schema.Literal("file_deleted").annotate({ - "title": "Type", - "description": "Deleted object type.\n\nFor file deletion, this is always `\"file_deleted\"`.", - "default": "file_deleted" - }) - ) -}).annotate({ "title": "FileDeleteResponse" }) -export type BetaFileDocumentSource = { readonly "file_id": string; readonly "type": "file" } -export const BetaFileDocumentSource = Schema.Struct({ - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("file").annotate({ "title": "Type" }) -}).annotate({ "title": "FileDocumentSource" }) -export type BetaFileImageSource = { readonly "file_id": string; readonly "type": "file" } -export const BetaFileImageSource = Schema.Struct({ - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("file").annotate({ "title": "Type" }) -}).annotate({ "title": "FileImageSource" }) -export type BetaFileMetadataSchema = { - readonly "created_at": string - readonly "downloadable"?: boolean - readonly "filename": string - readonly "id": string - readonly "mime_type": string - readonly "size_bytes": number - readonly "type": "file" +export type ResponseSearchResultLocationCitation = { + readonly "cited_text": string + readonly "end_block_index": number + readonly "search_result_index": number + readonly "source": string + readonly "start_block_index": number + readonly "title": string | null + readonly "type": "search_result_location" } -export const BetaFileMetadataSchema = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "RFC 3339 datetime string representing when the file was created.", - "format": "date-time" +export const ResponseSearchResultLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ + "title": "Cited Text", + "description": + "The full text of the cited block range, concatenated.\n\nAlways equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns." }), - "downloadable": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Downloadable", - "description": "Whether the file can be downloaded.", - "default": false - }) + "end_block_index": Schema.Number.annotate({ + "title": "End Block Index", + "description": + "Exclusive 0-based end index of the cited block range in the source's `content` array.\n\nAlways greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "search_result_index": Schema.Number.annotate({ + "title": "Search Result Index", + "description": + "0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.\n\nCounted separately from `document_index`; server-side web search results are not included in this count." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "filename": Schema.String.annotate({ "title": "Filename", "description": "Original filename of the uploaded file." }) - .check(Schema.isMinLength(1)).check(Schema.isMaxLength(500)), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." - }), - "mime_type": Schema.String.annotate({ "title": "Mime Type", "description": "MIME type of the file." }).check( - Schema.isMinLength(1) - ).check(Schema.isMaxLength(255)), - "size_bytes": Schema.Number.annotate({ "title": "Size Bytes", "description": "Size of the file in bytes." }).check( - Schema.isInt() - ).check(Schema.isGreaterThanOrEqualTo(0)), - "type": Schema.Literal("file").annotate({ - "title": "Type", - "description": "Object type.\n\nFor files, this is always `\"file\"`." - }) -}).annotate({ "title": "FileMetadataSchema" }) -export type BetaGatewayTimeoutError = { readonly "message": string; readonly "type": "timeout_error" } -export const BetaGatewayTimeoutError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Request timeout" }), - "type": Schema.Literal("timeout_error").annotate({ "title": "Type", "default": "timeout_error" }) -}).annotate({ "title": "GatewayTimeoutError" }) -export type BetaGetSkillResponse = { - readonly "created_at": string - readonly "display_title": string | null - readonly "id": string - readonly "latest_version": string | null - readonly "source": string - readonly "type": string - readonly "updated_at": string + "source": Schema.String.annotate({ "title": "Source" }), + "start_block_index": Schema.Number.annotate({ + "title": "Start Block Index", + "description": "0-based index of the first cited block in the source's `content` array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Title" }), + "type": Schema.Literal("search_result_location").annotate({ "title": "Type", "default": "search_result_location" }) +}).annotate({ "title": "ResponseSearchResultLocationCitation", "identifier": "ResponseSearchResultLocationCitation" }) +export type ResponseThinkingBlock = { + readonly "signature": string + readonly "thinking": string + readonly "type": "thinking" } -export const BetaGetSkillResponse = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill was created." - }), - "display_title": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Display Title", +export const ResponseThinkingBlock = Schema.Struct({ + "signature": Schema.String.annotate({ + "title": "Signature", "description": - "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." - }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." + "A value used to verify that this thinking block was generated by Claude when it is passed back to the API.\n\nThis is an opaque field and should not be interpreted or parsed. When passing thinking blocks back to the API (required when using tools with extended thinking), pass them back exactly as received, with this field intact.\n\nSee [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details." }), - "latest_version": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Latest Version", - "description": - "The latest version identifier for the skill.\n\nThis represents the most recent version of the skill that has been created." + "thinking": Schema.String.annotate({ + "title": "Thinking", + "description": "The text of Claude's thinking process for this block." }), - "source": Schema.String.annotate({ - "title": "Source", + "type": Schema.Literal("thinking").annotate({ "title": "Type", "default": "thinking" }) +}).annotate({ "title": "ResponseThinkingBlock", "identifier": "ResponseThinkingBlock" }) +export type ResponseRedactedThinkingBlock = { readonly "data": string; readonly "type": "redacted_thinking" } +export const ResponseRedactedThinkingBlock = Schema.Struct({ + "data": Schema.String.annotate({ + "title": "Data", "description": - "Source of the skill.\n\nThis may be one of the following values:\n* `\"custom\"`: the skill was created by a user\n* `\"anthropic\"`: the skill was created by Anthropic" + "The contents of this redacted thinking block, returned when portions of the model's thinking were safety-redacted. This field is opaque and encrypted, with no readable content.\n\nPass `redacted_thinking` blocks back to the API unchanged when continuing a multi-turn conversation.\n\nSee [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking#redacted-thinking-blocks) for details." }), - "type": Schema.String.annotate({ - "title": "Type", - "description": "Object type.\n\nFor Skills, this is always `\"skill\"`.", - "default": "skill" - }), - "updated_at": Schema.String.annotate({ - "title": "Updated At", - "description": "ISO 8601 timestamp of when the skill was last updated." - }) -}).annotate({ "title": "GetSkillResponse" }) -export type BetaGetSkillVersionResponse = { - readonly "created_at": string - readonly "description": string - readonly "directory": string - readonly "id": string - readonly "name": string - readonly "skill_id": string - readonly "type": string - readonly "version": string + "type": Schema.Literal("redacted_thinking").annotate({ "title": "Type", "default": "redacted_thinking" }) +}).annotate({ "title": "ResponseRedactedThinkingBlock", "identifier": "ResponseRedactedThinkingBlock" }) +export type ResponseWebSearchResultBlock = { + readonly "encrypted_content": string + readonly "page_age": string | null + readonly "title": string + readonly "type": "web_search_result" + readonly "url": string } -export const BetaGetSkillVersionResponse = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill version was created." - }), - "description": Schema.String.annotate({ - "title": "Description", - "description": "Description of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." - }), - "directory": Schema.String.annotate({ - "title": "Directory", - "description": - "Directory name of the skill version.\n\nThis is the top-level directory name that was extracted from the uploaded files." - }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill version.\n\nThe format and length of IDs may change over time." - }), - "name": Schema.String.annotate({ - "title": "Name", - "description": - "Human-readable name of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." - }), - "skill_id": Schema.String.annotate({ - "title": "Skill Id", - "description": "Identifier for the skill that this version belongs to." - }), - "type": Schema.String.annotate({ +export const ResponseWebSearchResultBlock = Schema.Struct({ + "encrypted_content": Schema.String.annotate({ "title": "Encrypted Content" }), + "page_age": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Page Age", "default": null }), + "title": Schema.String.annotate({ "title": "Title" }), + "type": Schema.Literal("web_search_result").annotate({ "title": "Type", "default": "web_search_result" }), + "url": Schema.String.annotate({ "title": "Url" }) +}).annotate({ "title": "ResponseWebSearchResultBlock", "identifier": "ResponseWebSearchResultBlock" }) +export type ResponseCitationsConfig = { readonly "enabled": boolean } +export const ResponseCitationsConfig = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ "title": "Enabled", "default": false }) +}).annotate({ "title": "ResponseCitationsConfig", "identifier": "ResponseCitationsConfig" }) +export type ResponseCodeExecutionOutputBlock = { readonly "file_id": string; readonly "type": "code_execution_output" } +export const ResponseCodeExecutionOutputBlock = Schema.Struct({ + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("code_execution_output").annotate({ "title": "Type", "default": "code_execution_output" }) +}).annotate({ "title": "ResponseCodeExecutionOutputBlock", "identifier": "ResponseCodeExecutionOutputBlock" }) +export type ResponseBashCodeExecutionOutputBlock = { + readonly "file_id": string + readonly "type": "bash_code_execution_output" +} +export const ResponseBashCodeExecutionOutputBlock = Schema.Struct({ + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("bash_code_execution_output").annotate({ "title": "Type", - "description": "Object type.\n\nFor Skill Versions, this is always `\"skill_version\"`.", - "default": "skill_version" - }), - "version": Schema.String.annotate({ - "title": "Version", - "description": - "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." + "default": "bash_code_execution_output" }) -}).annotate({ "title": "GetSkillVersionResponse" }) -export type BetaInputJsonContentBlockDelta = { readonly "partial_json": string; readonly "type": "input_json_delta" } -export const BetaInputJsonContentBlockDelta = Schema.Struct({ - "partial_json": Schema.String.annotate({ "title": "Partial Json" }), - "type": Schema.Literal("input_json_delta").annotate({ "title": "Type", "default": "input_json_delta" }) -}).annotate({ "title": "InputJsonContentBlockDelta" }) -export type BetaInputTokensClearAtLeast = { readonly "type": "input_tokens"; readonly "value": number } -export const BetaInputTokensClearAtLeast = Schema.Struct({ - "type": Schema.Literal("input_tokens").annotate({ "title": "Type" }), - "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) -}).annotate({ "title": "InputTokensClearAtLeast" }) -export type BetaInputTokensTrigger = { readonly "type": "input_tokens"; readonly "value": number } -export const BetaInputTokensTrigger = Schema.Struct({ - "type": Schema.Literal("input_tokens").annotate({ "title": "Type" }), - "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)) -}).annotate({ "title": "InputTokensTrigger" }) -export type BetaInvalidRequestError = { readonly "message": string; readonly "type": "invalid_request_error" } -export const BetaInvalidRequestError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Invalid request" }), - "type": Schema.Literal("invalid_request_error").annotate({ "title": "Type", "default": "invalid_request_error" }) -}).annotate({ "title": "InvalidRequestError" }) -export type BetaJsonOutputFormat = { - readonly "schema": { readonly [x: string]: Schema.Json } - readonly "type": "json_schema" -} -export const BetaJsonOutputFormat = Schema.Struct({ - "schema": Schema.Record(Schema.String, Schema.Json).annotate({ - "title": "Schema", - "description": "The JSON schema of the format" - }), - "type": Schema.Literal("json_schema").annotate({ "title": "Type" }) -}).annotate({ "title": "JsonOutputFormat" }) -export type BetaJsonValue = unknown -export const BetaJsonValue = Schema.Unknown -export type BetaMCPToolConfig = { readonly "defer_loading"?: boolean; readonly "enabled"?: boolean } -export const BetaMCPToolConfig = Schema.Struct({ - "defer_loading": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Defer Loading" })), - "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Enabled" })) -}).annotate({ "title": "MCPToolConfig", "description": "Configuration for a specific tool in an MCP toolset." }) -export type BetaMessageBatch = { - readonly "archived_at": string | null - readonly "cancel_initiated_at": string | null - readonly "created_at": string - readonly "ended_at": string | null - readonly "expires_at": string - readonly "id": string - readonly "processing_status": "in_progress" | "canceling" | "ended" - readonly "request_counts": { - readonly "canceled": number - readonly "errored": number - readonly "expired": number - readonly "processing": number - readonly "succeeded": number - } - readonly "results_url": string | null - readonly "type": "message_batch" +}).annotate({ "title": "ResponseBashCodeExecutionOutputBlock", "identifier": "ResponseBashCodeExecutionOutputBlock" }) +export type ResponseTextEditorCodeExecutionViewResultBlock = { + readonly "content": string + readonly "file_type": "text" | "image" | "pdf" + readonly "num_lines": number | null + readonly "start_line": number | null + readonly "total_lines": number | null + readonly "type": "text_editor_code_execution_view_result" } -export const BetaMessageBatch = Schema.Struct({ - "archived_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ - "title": "Archived At", - "description": - "RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable." - }), - "cancel_initiated_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ - "title": "Cancel Initiated At", - "description": - "RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated." - }), - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "RFC 3339 datetime string representing the time at which the Message Batch was created.", - "format": "date-time" - }), - "ended_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ - "title": "Ended At", - "description": - "RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.\n\nProcessing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired." - }), - "expires_at": Schema.String.annotate({ - "title": "Expires At", - "description": - "RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.", - "format": "date-time" - }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." - }), - "processing_status": Schema.Literals(["in_progress", "canceling", "ended"]).annotate({ - "title": "Processing Status", - "description": "Processing status of the Message Batch." - }), - "request_counts": Schema.Struct({ - "canceled": Schema.Number.annotate({ - "title": "Canceled", - "description": - "Number of requests in the Message Batch that have been canceled.\n\nThis is zero until processing of the entire Message Batch has ended.", - "default": 0 - }).check(Schema.isInt()), - "errored": Schema.Number.annotate({ - "title": "Errored", - "description": - "Number of requests in the Message Batch that encountered an error.\n\nThis is zero until processing of the entire Message Batch has ended.", - "default": 0 - }).check(Schema.isInt()), - "expired": Schema.Number.annotate({ - "title": "Expired", - "description": - "Number of requests in the Message Batch that have expired.\n\nThis is zero until processing of the entire Message Batch has ended.", - "default": 0 - }).check(Schema.isInt()), - "processing": Schema.Number.annotate({ - "title": "Processing", - "description": "Number of requests in the Message Batch that are processing.", - "default": 0 - }).check(Schema.isInt()), - "succeeded": Schema.Number.annotate({ - "title": "Succeeded", - "description": - "Number of requests in the Message Batch that have completed successfully.\n\nThis is zero until processing of the entire Message Batch has ended.", - "default": 0 - }).check(Schema.isInt()) - }).annotate({ - "title": "RequestCounts", - "description": - "Tallies requests within the Message Batch, categorized by their status.\n\nRequests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch." - }), - "results_url": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Results Url", - "description": - "URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.\n\nResults in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests." - }), - "type": Schema.Literal("message_batch").annotate({ +export const ResponseTextEditorCodeExecutionViewResultBlock = Schema.Struct({ + "content": Schema.String.annotate({ "title": "Content" }), + "file_type": Schema.Literals(["text", "image", "pdf"]).annotate({ "title": "File Type" }), + "num_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Num Lines", "default": null }), + "start_line": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Start Line", "default": null }), + "total_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Total Lines", "default": null }), + "type": Schema.Literal("text_editor_code_execution_view_result").annotate({ "title": "Type", - "description": "Object type.\n\nFor Message Batches, this is always `\"message_batch\"`.", - "default": "message_batch" + "default": "text_editor_code_execution_view_result" }) -}).annotate({ "title": "MessageBatch" }) -export type BetaMessageStopEvent = { readonly "type": "message_stop" } -export const BetaMessageStopEvent = Schema.Struct({ - "type": Schema.Literal("message_stop").annotate({ "title": "Type", "default": "message_stop" }) -}).annotate({ "title": "MessageStopEvent" }) -export type BetaModelInfo = { - readonly "created_at": string - readonly "display_name": string - readonly "id": string - readonly "type": "model" +}).annotate({ + "title": "ResponseTextEditorCodeExecutionViewResultBlock", + "identifier": "ResponseTextEditorCodeExecutionViewResultBlock" +}) +export type ResponseTextEditorCodeExecutionCreateResultBlock = { + readonly "is_file_update": boolean + readonly "type": "text_editor_code_execution_create_result" } -export const BetaModelInfo = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": - "RFC 3339 datetime string representing the time at which the model was released. May be set to an epoch value if the release date is unknown.", - "format": "date-time" - }), - "display_name": Schema.String.annotate({ - "title": "Display Name", - "description": "A human-readable name for the model." - }), - "id": Schema.String.annotate({ "title": "Id", "description": "Unique model identifier." }), - "type": Schema.Literal("model").annotate({ +export const ResponseTextEditorCodeExecutionCreateResultBlock = Schema.Struct({ + "is_file_update": Schema.Boolean.annotate({ "title": "Is File Update" }), + "type": Schema.Literal("text_editor_code_execution_create_result").annotate({ "title": "Type", - "description": "Object type.\n\nFor Models, this is always `\"model\"`.", - "default": "model" + "default": "text_editor_code_execution_create_result" }) -}).annotate({ "title": "ModelInfo" }) -export type BetaNotFoundError = { readonly "message": string; readonly "type": "not_found_error" } -export const BetaNotFoundError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Not found" }), - "type": Schema.Literal("not_found_error").annotate({ "title": "Type", "default": "not_found_error" }) -}).annotate({ "title": "NotFoundError" }) -export type BetaOverloadedError = { readonly "message": string; readonly "type": "overloaded_error" } -export const BetaOverloadedError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Overloaded" }), - "type": Schema.Literal("overloaded_error").annotate({ "title": "Type", "default": "overloaded_error" }) -}).annotate({ "title": "OverloadedError" }) -export type BetaPermissionError = { readonly "message": string; readonly "type": "permission_error" } -export const BetaPermissionError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Permission denied" }), - "type": Schema.Literal("permission_error").annotate({ "title": "Type", "default": "permission_error" }) -}).annotate({ "title": "PermissionError" }) -export type BetaPlainTextSource = { - readonly "data": string - readonly "media_type": "text/plain" - readonly "type": "text" -} -export const BetaPlainTextSource = Schema.Struct({ - "data": Schema.String.annotate({ "title": "Data" }), - "media_type": Schema.Literal("text/plain").annotate({ "title": "Media Type" }), - "type": Schema.Literal("text").annotate({ "title": "Type" }) -}).annotate({ "title": "PlainTextSource" }) -export type BetaRateLimitError = { readonly "message": string; readonly "type": "rate_limit_error" } -export const BetaRateLimitError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Rate limited" }), - "type": Schema.Literal("rate_limit_error").annotate({ "title": "Type", "default": "rate_limit_error" }) -}).annotate({ "title": "RateLimitError" }) -export type BetaRequestBashCodeExecutionOutputBlock = { - readonly "file_id": string - readonly "type": "bash_code_execution_output" +}).annotate({ + "title": "ResponseTextEditorCodeExecutionCreateResultBlock", + "identifier": "ResponseTextEditorCodeExecutionCreateResultBlock" +}) +export type ResponseTextEditorCodeExecutionStrReplaceResultBlock = { + readonly "lines": ReadonlyArray | null + readonly "new_lines": number | null + readonly "new_start": number | null + readonly "old_lines": number | null + readonly "old_start": number | null + readonly "type": "text_editor_code_execution_str_replace_result" } -export const BetaRequestBashCodeExecutionOutputBlock = Schema.Struct({ +export const ResponseTextEditorCodeExecutionStrReplaceResultBlock = Schema.Struct({ + "lines": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Lines", "default": null }), + "new_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "New Lines", "default": null }), + "new_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "New Start", "default": null }), + "old_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Old Lines", "default": null }), + "old_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Old Start", "default": null }), + "type": Schema.Literal("text_editor_code_execution_str_replace_result").annotate({ + "title": "Type", + "default": "text_editor_code_execution_str_replace_result" + }) +}).annotate({ + "title": "ResponseTextEditorCodeExecutionStrReplaceResultBlock", + "identifier": "ResponseTextEditorCodeExecutionStrReplaceResultBlock" +}) +export type ResponseToolReferenceBlock = { readonly "tool_name": string; readonly "type": "tool_reference" } +export const ResponseToolReferenceBlock = Schema.Struct({ + "tool_name": Schema.String.annotate({ "title": "Tool Name" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,256}$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]{1,256}$" + }) + ), + "type": Schema.Literal("tool_reference").annotate({ "title": "Type", "default": "tool_reference" }) +}).annotate({ "title": "ResponseToolReferenceBlock", "identifier": "ResponseToolReferenceBlock" }) +export type ResponseContainerUploadBlock = { readonly "file_id": string; readonly "type": "container_upload" } +export const ResponseContainerUploadBlock = Schema.Struct({ "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("bash_code_execution_output").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestBashCodeExecutionOutputBlock" }) -export type BetaRequestCharLocationCitation = { - readonly "cited_text": string + "type": Schema.Literal("container_upload").annotate({ "title": "Type", "default": "container_upload" }) +}).annotate({ + "title": "ResponseContainerUploadBlock", + "description": "Response model for a file uploaded to the container.", + "identifier": "ResponseContainerUploadBlock" +}) +export type StopReason = + | "end_turn" + | "max_tokens" + | "stop_sequence" + | "tool_use" + | "pause_turn" + | "refusal" + | "model_context_window_exceeded" +export const StopReason = Schema.Literals([ + "end_turn", + "max_tokens", + "stop_sequence", + "tool_use", + "pause_turn", + "refusal", + "model_context_window_exceeded" +]).annotate({ "identifier": "StopReason" }) +export type RefusalCategory = "cyber" | "bio" | "frontier_llm" | "reasoning_extraction" | "general_harms" +export const RefusalCategory = Schema.Literals([ + "cyber", + "bio", + "frontier_llm", + "reasoning_extraction", + "general_harms" +]).annotate({ + "title": "RefusalCategory", + "description": "The policy category that triggered a refusal.", + "identifier": "RefusalCategory" +}) +export type CacheCreation = { + readonly "ephemeral_1h_input_tokens": number + readonly "ephemeral_5m_input_tokens": number +} +export const CacheCreation = Schema.Struct({ + "ephemeral_1h_input_tokens": Schema.Number.annotate({ + "title": "Ephemeral 1H Input Tokens", + "description": "The number of input tokens used to create the 1 hour cache entry.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "ephemeral_5m_input_tokens": Schema.Number.annotate({ + "title": "Ephemeral 5M Input Tokens", + "description": "The number of input tokens used to create the 5 minute cache entry.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) +}).annotate({ "title": "CacheCreation", "identifier": "CacheCreation" }) +export type OutputTokensDetails = { readonly "thinking_tokens": number } +export const OutputTokensDetails = Schema.Struct({ + "thinking_tokens": Schema.Number.annotate({ + "title": "Thinking Tokens", + "description": + "Number of output tokens the model generated as internal reasoning, including\nthe thinking-block delimiter tokens.\n\nReflects the raw reasoning the model produced, not the (possibly shorter)\nsummarized thinking text returned in the response body. Computed by\nre-tokenizing the raw reasoning text, so it may differ from the model's exact\ngeneration count by a small number of tokens. Always ≤ `output_tokens`;\n`output_tokens - thinking_tokens` approximates the non-reasoning output.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) +}).annotate({ "title": "OutputTokensDetails", "identifier": "OutputTokensDetails" }) +export type ServerToolUsage = { readonly "web_fetch_requests": number; readonly "web_search_requests": number } +export const ServerToolUsage = Schema.Struct({ + "web_fetch_requests": Schema.Number.annotate({ + "title": "Web Fetch Requests", + "description": "The number of web fetch tool requests.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "web_search_requests": Schema.Number.annotate({ + "title": "Web Search Requests", + "description": "The number of web search tool requests.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) +}).annotate({ "title": "ServerToolUsage", "identifier": "ServerToolUsage" }) +export type Container = { readonly "expires_at": string; readonly "id": string } +export const Container = Schema.Struct({ + "expires_at": Schema.String.annotate({ + "title": "Expires At", + "description": "The time at which the container will expire.", + "format": "date-time" + }), + "id": Schema.String.annotate({ "title": "Id", "description": "Identifier for the container used in this request" }) +}).annotate({ + "title": "Container", + "description": "Information about the container used in the request (for the code execution tool)", + "identifier": "Container" +}) +export type InvalidRequestError = { readonly "message": string; readonly "type": "invalid_request_error" } +export const InvalidRequestError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Invalid request" }), + "type": Schema.Literal("invalid_request_error").annotate({ "title": "Type", "default": "invalid_request_error" }) +}).annotate({ "title": "InvalidRequestError", "identifier": "InvalidRequestError" }) +export type AuthenticationError = { readonly "message": string; readonly "type": "authentication_error" } +export const AuthenticationError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Authentication error" }), + "type": Schema.Literal("authentication_error").annotate({ "title": "Type", "default": "authentication_error" }) +}).annotate({ "title": "AuthenticationError", "identifier": "AuthenticationError" }) +export type BillingError = { readonly "message": string; readonly "type": "billing_error" } +export const BillingError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Billing error" }), + "type": Schema.Literal("billing_error").annotate({ "title": "Type", "default": "billing_error" }) +}).annotate({ "title": "BillingError", "identifier": "BillingError" }) +export type PermissionError = { readonly "message": string; readonly "type": "permission_error" } +export const PermissionError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Permission denied" }), + "type": Schema.Literal("permission_error").annotate({ "title": "Type", "default": "permission_error" }) +}).annotate({ "title": "PermissionError", "identifier": "PermissionError" }) +export type NotFoundError = { readonly "message": string; readonly "type": "not_found_error" } +export const NotFoundError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Not found" }), + "type": Schema.Literal("not_found_error").annotate({ "title": "Type", "default": "not_found_error" }) +}).annotate({ "title": "NotFoundError", "identifier": "NotFoundError" }) +export type RateLimitError = { readonly "message": string; readonly "type": "rate_limit_error" } +export const RateLimitError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Rate limited" }), + "type": Schema.Literal("rate_limit_error").annotate({ "title": "Type", "default": "rate_limit_error" }) +}).annotate({ "title": "RateLimitError", "identifier": "RateLimitError" }) +export type GatewayTimeoutError = { readonly "message": string; readonly "type": "timeout_error" } +export const GatewayTimeoutError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Request timeout" }), + "type": Schema.Literal("timeout_error").annotate({ "title": "Type", "default": "timeout_error" }) +}).annotate({ "title": "GatewayTimeoutError", "identifier": "GatewayTimeoutError" }) +export type APIError = { readonly "message": string; readonly "type": "api_error" } +export const APIError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Internal server error" }), + "type": Schema.Literal("api_error").annotate({ "title": "Type", "default": "api_error" }) +}).annotate({ "title": "APIError", "identifier": "APIError" }) +export type OverloadedError = { readonly "message": string; readonly "type": "overloaded_error" } +export const OverloadedError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Overloaded" }), + "type": Schema.Literal("overloaded_error").annotate({ "title": "Type", "default": "overloaded_error" }) +}).annotate({ "title": "OverloadedError", "identifier": "OverloadedError" }) +export type CapabilitySupport = { readonly "supported": boolean } +export const CapabilitySupport = Schema.Struct({ + "supported": Schema.Boolean.annotate({ + "title": "Supported", + "description": "Whether this capability is supported by the model." + }) +}).annotate({ + "title": "CapabilitySupport", + "description": "Indicates whether a capability is supported.", + "identifier": "CapabilitySupport" +}) +export type RequestCounts = { + readonly "canceled": number + readonly "errored": number + readonly "expired": number + readonly "processing": number + readonly "succeeded": number +} +export const RequestCounts = Schema.Struct({ + "canceled": Schema.Number.annotate({ + "title": "Canceled", + "description": + "Number of requests in the Message Batch that have been canceled.\n\nThis is zero until processing of the entire Message Batch has ended.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "errored": Schema.Number.annotate({ + "title": "Errored", + "description": + "Number of requests in the Message Batch that encountered an error.\n\nThis is zero until processing of the entire Message Batch has ended.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "expired": Schema.Number.annotate({ + "title": "Expired", + "description": + "Number of requests in the Message Batch that have expired.\n\nThis is zero until processing of the entire Message Batch has ended.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "processing": Schema.Number.annotate({ + "title": "Processing", + "description": "Number of requests in the Message Batch that are processing.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "succeeded": Schema.Number.annotate({ + "title": "Succeeded", + "description": + "Number of requests in the Message Batch that have completed successfully.\n\nThis is zero until processing of the entire Message Batch has ended.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "title": "RequestCounts", "identifier": "RequestCounts" }) +export type DeleteMessageBatchResponse = { readonly "id": string; readonly "type": "message_batch_deleted" } +export const DeleteMessageBatchResponse = Schema.Struct({ + "id": Schema.String.annotate({ "title": "Id", "description": "ID of the Message Batch." }), + "type": Schema.Literal("message_batch_deleted").annotate({ + "title": "Type", + "description": "Deleted object type.\n\nFor Message Batches, this is always `\"message_batch_deleted\"`.", + "default": "message_batch_deleted" + }) +}).annotate({ "title": "DeleteMessageBatchResponse", "identifier": "DeleteMessageBatchResponse" }) +export type CountMessageTokensResponse = { readonly "input_tokens": number } +export const CountMessageTokensResponse = Schema.Struct({ + "input_tokens": Schema.Number.annotate({ + "title": "Input Tokens", + "description": "The total number of tokens across the provided list of messages, system prompt, and tools." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "title": "CountMessageTokensResponse", "identifier": "CountMessageTokensResponse" }) +export type BetaCacheControlEphemeral = { readonly "ttl"?: "5m" | "1h"; readonly "type": "ephemeral" } +export const BetaCacheControlEphemeral = Schema.Struct({ + "ttl": Schema.optionalKey( + Schema.Literals(["5m", "1h"]).annotate({ + "title": "Ttl", + "description": + "The time-to-live for the cache control breakpoint.\n\nThis may be one the following values:\n- `5m`: 5 minutes\n- `1h`: 1 hour\n\nDefaults to `5m`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details." + }) + ), + "type": Schema.Literal("ephemeral").annotate({ "title": "Type" }) +}).annotate({ "title": "CacheControlEphemeral", "identifier": "BetaCacheControlEphemeral" }) +export type BetaRequestCharLocationCitation = { + readonly "cited_text": string readonly "document_index": number readonly "document_title": string | null readonly "end_char_index": number @@ -707,31 +1186,50 @@ export type BetaRequestCharLocationCitation = { } export const BetaRequestCharLocationCitation = Schema.Struct({ "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), "document_title": Schema.Union([ - Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), Schema.Null ]).annotate({ "title": "Document Title" }), - "end_char_index": Schema.Number.annotate({ "title": "End Char Index" }).check(Schema.isInt()), - "start_char_index": Schema.Number.annotate({ "title": "Start Char Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) + "end_char_index": Schema.Number.annotate({ "title": "End Char Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), + "start_char_index": Schema.Number.annotate({ "title": "Start Char Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), "type": Schema.Literal("char_location").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestCharLocationCitation" }) -export type BetaRequestCitationsConfig = { readonly "enabled"?: boolean } -export const BetaRequestCitationsConfig = Schema.Struct({ - "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Enabled" })) -}).annotate({ "title": "RequestCitationsConfig" }) -export type BetaRequestCodeExecutionOutputBlock = { - readonly "file_id": string - readonly "type": "code_execution_output" +}).annotate({ "title": "RequestCharLocationCitation", "identifier": "BetaRequestCharLocationCitation" }) +export type BetaRequestPageLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_page_number": number + readonly "start_page_number": number + readonly "type": "page_location" } -export const BetaRequestCodeExecutionOutputBlock = Schema.Struct({ - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("code_execution_output").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestCodeExecutionOutputBlock" }) +export const BetaRequestPageLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ "title": "Document Title" }), + "end_page_number": Schema.Number.annotate({ "title": "End Page Number" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "start_page_number": Schema.Number.annotate({ "title": "Start Page Number" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })), + "type": Schema.Literal("page_location").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestPageLocationCitation", "identifier": "BetaRequestPageLocationCitation" }) export type BetaRequestContentBlockLocationCitation = { readonly "cited_text": string readonly "document_index": number @@ -741,53 +1239,57 @@ export type BetaRequestContentBlockLocationCitation = { readonly "type": "content_block_location" } export const BetaRequestContentBlockLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), + "cited_text": Schema.String.annotate({ + "title": "Cited Text", + "description": + "The full text of the cited block range, concatenated.\n\nAlways equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns." + }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), "document_title": Schema.Union([ - Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), Schema.Null ]).annotate({ "title": "Document Title" }), - "end_block_index": Schema.Number.annotate({ "title": "End Block Index" }).check(Schema.isInt()), - "start_block_index": Schema.Number.annotate({ "title": "Start Block Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) + "end_block_index": Schema.Number.annotate({ + "title": "End Block Index", + "description": + "Exclusive 0-based end index of the cited block range in the source's `content` array.\n\nAlways greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_block_index": Schema.Number.annotate({ + "title": "Start Block Index", + "description": "0-based index of the first cited block in the source's `content` array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), "type": Schema.Literal("content_block_location").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestContentBlockLocationCitation" }) -export type BetaRequestMCPServerToolConfiguration = { - readonly "allowed_tools"?: ReadonlyArray | null - readonly "enabled"?: boolean | null -} -export const BetaRequestMCPServerToolConfiguration = Schema.Struct({ - "allowed_tools": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Allowed Tools" }) - ), - "enabled": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null]).annotate({ "title": "Enabled" })) -}).annotate({ "title": "RequestMCPServerToolConfiguration" }) -export type BetaRequestPageLocationCitation = { +}).annotate({ "title": "RequestContentBlockLocationCitation", "identifier": "BetaRequestContentBlockLocationCitation" }) +export type BetaRequestWebSearchResultLocationCitation = { readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_page_number": number - readonly "start_page_number": number - readonly "type": "page_location" + readonly "encrypted_index": string + readonly "title": string | null + readonly "type": "web_search_result_location" + readonly "url": string } -export const BetaRequestPageLocationCitation = Schema.Struct({ +export const BetaRequestWebSearchResultLocationCitation = Schema.Struct({ "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "document_title": Schema.Union([ - Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), + "encrypted_index": Schema.String.annotate({ "title": "Encrypted Index" }), + "title": Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" }) + ), Schema.Null - ]).annotate({ "title": "Document Title" }), - "end_page_number": Schema.Number.annotate({ "title": "End Page Number" }).check(Schema.isInt()), - "start_page_number": Schema.Number.annotate({ "title": "Start Page Number" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(1) - ), - "type": Schema.Literal("page_location").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestPageLocationCitation" }) + ]).annotate({ "title": "Title" }), + "type": Schema.Literal("web_search_result_location").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" })) +}).annotate({ + "title": "RequestWebSearchResultLocationCitation", + "identifier": "BetaRequestWebSearchResultLocationCitation" +}) export type BetaRequestSearchResultLocationCitation = { readonly "cited_text": string readonly "end_block_index": number @@ -798,72 +1300,144 @@ export type BetaRequestSearchResultLocationCitation = { readonly "type": "search_result_location" } export const BetaRequestSearchResultLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "end_block_index": Schema.Number.annotate({ "title": "End Block Index" }).check(Schema.isInt()), - "search_result_index": Schema.Number.annotate({ "title": "Search Result Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) + "cited_text": Schema.String.annotate({ + "title": "Cited Text", + "description": + "The full text of the cited block range, concatenated.\n\nAlways equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns." + }), + "end_block_index": Schema.Number.annotate({ + "title": "End Block Index", + "description": + "Exclusive 0-based end index of the cited block range in the source's `content` array.\n\nAlways greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "search_result_index": Schema.Number.annotate({ + "title": "Search Result Index", + "description": + "0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.\n\nCounted separately from `document_index`; server-side web search results are not included in this count." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), "source": Schema.String.annotate({ "title": "Source" }), - "start_block_index": Schema.Number.annotate({ "title": "Start Block Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) + "start_block_index": Schema.Number.annotate({ + "title": "Start Block Index", + "description": "0-based index of the first cited block in the source's `content` array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), "title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Title" }), "type": Schema.Literal("search_result_location").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestSearchResultLocationCitation" }) -export type BetaRequestTextEditorCodeExecutionCreateResultBlock = { - readonly "is_file_update": boolean - readonly "type": "text_editor_code_execution_create_result" +}).annotate({ "title": "RequestSearchResultLocationCitation", "identifier": "BetaRequestSearchResultLocationCitation" }) +export type BetaBase64ImageSource = { + readonly "data": string + readonly "media_type": "image/jpeg" | "image/png" | "image/gif" | "image/webp" + readonly "type": "base64" } -export const BetaRequestTextEditorCodeExecutionCreateResultBlock = Schema.Struct({ - "is_file_update": Schema.Boolean.annotate({ "title": "Is File Update" }), - "type": Schema.Literal("text_editor_code_execution_create_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionCreateResultBlock" }) -export type BetaRequestTextEditorCodeExecutionStrReplaceResultBlock = { - readonly "lines"?: ReadonlyArray | null - readonly "new_lines"?: number | null - readonly "new_start"?: number | null - readonly "old_lines"?: number | null - readonly "old_start"?: number | null - readonly "type": "text_editor_code_execution_str_replace_result" +export const BetaBase64ImageSource = Schema.Struct({ + "data": Schema.String.annotate({ "title": "Data", "format": "byte" }), + "media_type": Schema.Literals(["image/jpeg", "image/png", "image/gif", "image/webp"]).annotate({ + "title": "Media Type" + }), + "type": Schema.Literal("base64").annotate({ "title": "Type" }) +}).annotate({ "title": "Base64ImageSource", "identifier": "BetaBase64ImageSource" }) +export type BetaURLImageSource = { readonly "type": "url"; readonly "url": string } +export const BetaURLImageSource = Schema.Struct({ + "type": Schema.Literal("url").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url" }) +}).annotate({ "title": "URLImageSource", "identifier": "BetaURLImageSource" }) +export type BetaFileImageSource = { readonly "file_id": string; readonly "type": "file" } +export const BetaFileImageSource = Schema.Struct({ + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("file").annotate({ "title": "Type" }) +}).annotate({ "title": "FileImageSource", "identifier": "BetaFileImageSource" }) +export type BetaRequestCitationsConfig = { readonly "enabled"?: boolean } +export const BetaRequestCitationsConfig = Schema.Struct({ + "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Enabled" })) +}).annotate({ "title": "RequestCitationsConfig", "identifier": "BetaRequestCitationsConfig" }) +export type BetaBase64PDFSource = { + readonly "data": string + readonly "media_type": "application/pdf" + readonly "type": "base64" } -export const BetaRequestTextEditorCodeExecutionStrReplaceResultBlock = Schema.Struct({ - "lines": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Lines" })), - "new_lines": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "New Lines" }) - ), - "new_start": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "New Start" }) - ), - "old_lines": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Old Lines" }) - ), - "old_start": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Old Start" }) - ), - "type": Schema.Literal("text_editor_code_execution_str_replace_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionStrReplaceResultBlock" }) -export type BetaRequestTextEditorCodeExecutionViewResultBlock = { - readonly "content": string - readonly "file_type": "text" | "image" | "pdf" - readonly "num_lines"?: number | null - readonly "start_line"?: number | null - readonly "total_lines"?: number | null - readonly "type": "text_editor_code_execution_view_result" +export const BetaBase64PDFSource = Schema.Struct({ + "data": Schema.String.annotate({ "title": "Data", "format": "byte" }), + "media_type": Schema.Literal("application/pdf").annotate({ "title": "Media Type" }), + "type": Schema.Literal("base64").annotate({ "title": "Type" }) +}).annotate({ "title": "Base64PDFSource", "identifier": "BetaBase64PDFSource" }) +export type BetaPlainTextSource = { + readonly "data": string + readonly "media_type": "text/plain" + readonly "type": "text" } -export const BetaRequestTextEditorCodeExecutionViewResultBlock = Schema.Struct({ - "content": Schema.String.annotate({ "title": "Content" }), - "file_type": Schema.Literals(["text", "image", "pdf"]).annotate({ "title": "File Type" }), - "num_lines": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Num Lines" }) - ), - "start_line": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Start Line" }) +export const BetaPlainTextSource = Schema.Struct({ + "data": Schema.String.annotate({ "title": "Data" }), + "media_type": Schema.Literal("text/plain").annotate({ "title": "Media Type" }), + "type": Schema.Literal("text").annotate({ "title": "Type" }) +}).annotate({ "title": "PlainTextSource", "identifier": "BetaPlainTextSource" }) +export type BetaURLPDFSource = { readonly "type": "url"; readonly "url": string } +export const BetaURLPDFSource = Schema.Struct({ + "type": Schema.Literal("url").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url" }) +}).annotate({ "title": "URLPDFSource", "identifier": "BetaURLPDFSource" }) +export type BetaFileDocumentSource = { readonly "file_id": string; readonly "type": "file" } +export const BetaFileDocumentSource = Schema.Struct({ + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("file").annotate({ "title": "Type" }) +}).annotate({ "title": "FileDocumentSource", "identifier": "BetaFileDocumentSource" }) +export type BetaRequestThinkingBlock = { + readonly "signature": string + readonly "thinking": string + readonly "type": "thinking" +} +export const BetaRequestThinkingBlock = Schema.Struct({ + "signature": Schema.String.annotate({ + "title": "Signature", + "description": + "The `signature` value of this thinking block, exactly as returned by the API in a previous response. Used to verify that the block was generated by Claude.\n\nThinking blocks must be passed back unmodified and in their original order; a modified block results in a 400 `invalid_request_error`." + }), + "thinking": Schema.String.annotate({ + "title": "Thinking", + "description": "The `thinking` text of this block as returned by the API." + }), + "type": Schema.Literal("thinking").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestThinkingBlock", "identifier": "BetaRequestThinkingBlock" }) +export type BetaRequestRedactedThinkingBlock = { readonly "data": string; readonly "type": "redacted_thinking" } +export const BetaRequestRedactedThinkingBlock = Schema.Struct({ + "data": Schema.String.annotate({ + "title": "Data", + "description": + "The `data` value of this redacted thinking block, exactly as returned by the API in a previous response. Opaque and encrypted; pass it back unchanged." + }), + "type": Schema.Literal("redacted_thinking").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestRedactedThinkingBlock", "identifier": "BetaRequestRedactedThinkingBlock" }) +export type BetaDirectCaller = { readonly "type": "direct" } +export const BetaDirectCaller = Schema.Struct({ "type": Schema.Literal("direct").annotate({ "title": "Type" }) }) + .annotate({ + "title": "DirectCaller", + "description": "Tool invocation directly from the model.", + "identifier": "BetaDirectCaller" + }) +export type BetaServerToolCaller = { readonly "tool_id": string; readonly "type": "code_execution_20250825" } +export const BetaServerToolCaller = Schema.Struct({ + "tool_id": Schema.String.annotate({ "title": "Tool Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" + }) ), - "total_lines": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Total Lines" }) + "type": Schema.Literal("code_execution_20250825").annotate({ "title": "Type" }) +}).annotate({ + "title": "ServerToolCaller", + "description": "Tool invocation generated by a server-side tool.", + "identifier": "BetaServerToolCaller" +}) +export type BetaServerToolCaller_20260120 = { readonly "tool_id": string; readonly "type": "code_execution_20260120" } +export const BetaServerToolCaller_20260120 = Schema.Struct({ + "tool_id": Schema.String.annotate({ "title": "Tool Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" + }) ), - "type": Schema.Literal("text_editor_code_execution_view_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionViewResultBlock" }) + "type": Schema.Literal("code_execution_20260120").annotate({ "title": "Type" }) +}).annotate({ "title": "ServerToolCaller_20260120", "identifier": "BetaServerToolCaller_20260120" }) export type BetaRequestWebSearchResultBlock = { readonly "encrypted_content": string readonly "page_age"?: string | null @@ -877,505 +1451,456 @@ export const BetaRequestWebSearchResultBlock = Schema.Struct({ "title": Schema.String.annotate({ "title": "Title" }), "type": Schema.Literal("web_search_result").annotate({ "title": "Type" }), "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "RequestWebSearchResultBlock" }) -export type BetaRequestWebSearchResultLocationCitation = { - readonly "cited_text": string - readonly "encrypted_index": string - readonly "title": string | null - readonly "type": "web_search_result_location" - readonly "url": string -} -export const BetaRequestWebSearchResultLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "encrypted_index": Schema.String.annotate({ "title": "Encrypted Index" }), - "title": Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(512)), Schema.Null]) - .annotate({ "title": "Title" }), - "type": Schema.Literal("web_search_result_location").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url" }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(2048)) -}).annotate({ "title": "RequestWebSearchResultLocationCitation" }) -export type BetaResponseBashCodeExecutionOutputBlock = { - readonly "file_id": string - readonly "type": "bash_code_execution_output" -} -export const BetaResponseBashCodeExecutionOutputBlock = Schema.Struct({ - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("bash_code_execution_output").annotate({ - "title": "Type", - "default": "bash_code_execution_output" - }) -}).annotate({ "title": "ResponseBashCodeExecutionOutputBlock" }) -export type BetaResponseCharLocationCitation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_char_index": number - readonly "file_id": string | null - readonly "start_char_index": number - readonly "type": "char_location" -} -export const BetaResponseCharLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), - "end_char_index": Schema.Number.annotate({ "title": "End Char Index" }).check(Schema.isInt()), - "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), - "start_char_index": Schema.Number.annotate({ "title": "Start Char Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "type": Schema.Literal("char_location").annotate({ "title": "Type", "default": "char_location" }) -}).annotate({ "title": "ResponseCharLocationCitation" }) -export type BetaResponseCitationsConfig = { readonly "enabled": boolean } -export const BetaResponseCitationsConfig = Schema.Struct({ - "enabled": Schema.Boolean.annotate({ "title": "Enabled", "default": false }) -}).annotate({ "title": "ResponseCitationsConfig" }) -export type BetaResponseClearThinking20251015Edit = { - readonly "cleared_input_tokens": number - readonly "cleared_thinking_turns": number - readonly "type": "clear_thinking_20251015" +}).annotate({ "title": "RequestWebSearchResultBlock", "identifier": "BetaRequestWebSearchResultBlock" }) +export type BetaWebSearchToolResultErrorCode = + | "invalid_tool_input" + | "unavailable" + | "max_uses_exceeded" + | "too_many_requests" + | "query_too_long" + | "request_too_large" +export const BetaWebSearchToolResultErrorCode = Schema.Literals([ + "invalid_tool_input", + "unavailable", + "max_uses_exceeded", + "too_many_requests", + "query_too_long", + "request_too_large" +]).annotate({ "title": "WebSearchToolResultErrorCode", "identifier": "BetaWebSearchToolResultErrorCode" }) +export type BetaWebFetchToolResultErrorCode = + | "invalid_tool_input" + | "url_too_long" + | "url_not_allowed" + | "url_not_in_prior_context" + | "url_not_accessible" + | "unsupported_content_type" + | "too_many_requests" + | "max_uses_exceeded" + | "unavailable" +export const BetaWebFetchToolResultErrorCode = Schema.Literals([ + "invalid_tool_input", + "url_too_long", + "url_not_allowed", + "url_not_in_prior_context", + "url_not_accessible", + "unsupported_content_type", + "too_many_requests", + "max_uses_exceeded", + "unavailable" +]).annotate({ "title": "WebFetchToolResultErrorCode", "identifier": "BetaWebFetchToolResultErrorCode" }) +export type BetaAdvisorToolResultErrorCode = + | "max_uses_exceeded" + | "prompt_too_long" + | "too_many_requests" + | "overloaded" + | "unavailable" + | "execution_time_exceeded" + | "model_not_found" +export const BetaAdvisorToolResultErrorCode = Schema.Literals([ + "max_uses_exceeded", + "prompt_too_long", + "too_many_requests", + "overloaded", + "unavailable", + "execution_time_exceeded", + "model_not_found" +]).annotate({ "title": "AdvisorToolResultErrorCode", "identifier": "BetaAdvisorToolResultErrorCode" }) +export type BetaRequestAdvisorResultBlock = { + readonly "stop_reason"?: string | null + readonly "text": string + readonly "type": "advisor_result" } -export const BetaResponseClearThinking20251015Edit = Schema.Struct({ - "cleared_input_tokens": Schema.Number.annotate({ - "title": "Cleared Input Tokens", - "description": "Number of input tokens cleared by this edit." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "cleared_thinking_turns": Schema.Number.annotate({ - "title": "Cleared Thinking Turns", - "description": "Number of thinking turns that were cleared." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "type": Schema.Literal("clear_thinking_20251015").annotate({ - "title": "Type", - "description": "The type of context management edit applied.", - "default": "clear_thinking_20251015" - }) -}).annotate({ "title": "ResponseClearThinking20251015Edit" }) -export type BetaResponseClearToolUses20250919Edit = { - readonly "cleared_input_tokens": number - readonly "cleared_tool_uses": number - readonly "type": "clear_tool_uses_20250919" +export const BetaRequestAdvisorResultBlock = Schema.Struct({ + "stop_reason": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Stop Reason" })), + "text": Schema.String.annotate({ "title": "Text" }), + "type": Schema.Literal("advisor_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestAdvisorResultBlock", "identifier": "BetaRequestAdvisorResultBlock" }) +export type BetaRequestAdvisorRedactedResultBlock = { + readonly "encrypted_content": string + readonly "stop_reason"?: string | null + readonly "type": "advisor_redacted_result" } -export const BetaResponseClearToolUses20250919Edit = Schema.Struct({ - "cleared_input_tokens": Schema.Number.annotate({ - "title": "Cleared Input Tokens", - "description": "Number of input tokens cleared by this edit." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "cleared_tool_uses": Schema.Number.annotate({ - "title": "Cleared Tool Uses", - "description": "Number of tool uses that were cleared." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "type": Schema.Literal("clear_tool_uses_20250919").annotate({ - "title": "Type", - "description": "The type of context management edit applied.", - "default": "clear_tool_uses_20250919" - }) -}).annotate({ "title": "ResponseClearToolUses20250919Edit" }) -export type BetaResponseCodeExecutionOutputBlock = { +export const BetaRequestAdvisorRedactedResultBlock = Schema.Struct({ + "encrypted_content": Schema.String.annotate({ + "title": "Encrypted Content", + "description": "Opaque blob produced by a prior response; must be round-tripped verbatim." + }), + "stop_reason": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Stop Reason" })), + "type": Schema.Literal("advisor_redacted_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestAdvisorRedactedResultBlock", "identifier": "BetaRequestAdvisorRedactedResultBlock" }) +export type BetaCodeExecutionToolResultErrorCode = + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" +export const BetaCodeExecutionToolResultErrorCode = Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" +]).annotate({ "title": "CodeExecutionToolResultErrorCode", "identifier": "BetaCodeExecutionToolResultErrorCode" }) +export type BetaRequestCodeExecutionOutputBlock = { readonly "file_id": string readonly "type": "code_execution_output" } -export const BetaResponseCodeExecutionOutputBlock = Schema.Struct({ +export const BetaRequestCodeExecutionOutputBlock = Schema.Struct({ "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("code_execution_output").annotate({ "title": "Type", "default": "code_execution_output" }) -}).annotate({ "title": "ResponseCodeExecutionOutputBlock" }) -export type BetaResponseCompactionBlock = { readonly "content": string | null; readonly "type": "compaction" } -export const BetaResponseCompactionBlock = Schema.Struct({ - "content": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Content", - "description": "Summary of compacted content, or null if compaction failed" - }), - "type": Schema.Literal("compaction").annotate({ "title": "Type", "default": "compaction" }) -}).annotate({ - "title": "ResponseCompactionBlock", - "description": - "A compaction block returned when autocompact is triggered.\n\nWhen content is None, it indicates the compaction failed to produce a valid\nsummary (e.g., malformed output from the model). Clients may round-trip\ncompaction blocks with null content; the server treats them as no-ops." + "type": Schema.Literal("code_execution_output").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestCodeExecutionOutputBlock", "identifier": "BetaRequestCodeExecutionOutputBlock" }) +export type BetaBashCodeExecutionToolResultErrorCode = + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" + | "output_file_too_large" +export const BetaBashCodeExecutionToolResultErrorCode = Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded", + "output_file_too_large" +]).annotate({ + "title": "BashCodeExecutionToolResultErrorCode", + "identifier": "BetaBashCodeExecutionToolResultErrorCode" }) -export type BetaResponseContainerUploadBlock = { readonly "file_id": string; readonly "type": "container_upload" } -export const BetaResponseContainerUploadBlock = Schema.Struct({ +export type BetaRequestBashCodeExecutionOutputBlock = { + readonly "file_id": string + readonly "type": "bash_code_execution_output" +} +export const BetaRequestBashCodeExecutionOutputBlock = Schema.Struct({ "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("container_upload").annotate({ "title": "Type", "default": "container_upload" }) -}).annotate({ - "title": "ResponseContainerUploadBlock", - "description": "Response model for a file uploaded to the container." + "type": Schema.Literal("bash_code_execution_output").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestBashCodeExecutionOutputBlock", "identifier": "BetaRequestBashCodeExecutionOutputBlock" }) +export type BetaTextEditorCodeExecutionToolResultErrorCode = + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" + | "file_not_found" +export const BetaTextEditorCodeExecutionToolResultErrorCode = Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded", + "file_not_found" +]).annotate({ + "title": "TextEditorCodeExecutionToolResultErrorCode", + "identifier": "BetaTextEditorCodeExecutionToolResultErrorCode" }) -export type BetaResponseContentBlockLocationCitation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_block_index": number - readonly "file_id": string | null - readonly "start_block_index": number - readonly "type": "content_block_location" +export type BetaRequestTextEditorCodeExecutionViewResultBlock = { + readonly "content": string + readonly "file_type": "text" | "image" | "pdf" + readonly "num_lines"?: number | null + readonly "start_line"?: number | null + readonly "total_lines"?: number | null + readonly "type": "text_editor_code_execution_view_result" } -export const BetaResponseContentBlockLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) +export const BetaRequestTextEditorCodeExecutionViewResultBlock = Schema.Struct({ + "content": Schema.String.annotate({ "title": "Content" }), + "file_type": Schema.Literals(["text", "image", "pdf"]).annotate({ "title": "File Type" }), + "num_lines": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Num Lines" + }) ), - "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), - "end_block_index": Schema.Number.annotate({ "title": "End Block Index" }).check(Schema.isInt()), - "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), - "start_block_index": Schema.Number.annotate({ "title": "Start Block Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "type": Schema.Literal("content_block_location").annotate({ "title": "Type", "default": "content_block_location" }) -}).annotate({ "title": "ResponseContentBlockLocationCitation" }) -export type BetaResponseMCPToolUseBlock = { - readonly "id": string - readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": string - readonly "server_name": string - readonly "type": "mcp_tool_use" -} -export const BetaResponseMCPToolUseBlock = Schema.Struct({ - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.String.annotate({ "title": "Name", "description": "The name of the MCP tool" }), - "server_name": Schema.String.annotate({ "title": "Server Name", "description": "The name of the MCP server" }), - "type": Schema.Literal("mcp_tool_use").annotate({ "title": "Type", "default": "mcp_tool_use" }) -}).annotate({ "title": "ResponseMCPToolUseBlock" }) -export type BetaResponsePageLocationCitation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_page_number": number - readonly "file_id": string | null - readonly "start_page_number": number - readonly "type": "page_location" -} -export const BetaResponsePageLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), - "end_page_number": Schema.Number.annotate({ "title": "End Page Number" }).check(Schema.isInt()), - "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), - "start_page_number": Schema.Number.annotate({ "title": "Start Page Number" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(1) - ), - "type": Schema.Literal("page_location").annotate({ "title": "Type", "default": "page_location" }) -}).annotate({ "title": "ResponsePageLocationCitation" }) -export type BetaResponseRedactedThinkingBlock = { readonly "data": string; readonly "type": "redacted_thinking" } -export const BetaResponseRedactedThinkingBlock = Schema.Struct({ - "data": Schema.String.annotate({ "title": "Data" }), - "type": Schema.Literal("redacted_thinking").annotate({ "title": "Type", "default": "redacted_thinking" }) -}).annotate({ "title": "ResponseRedactedThinkingBlock" }) -export type BetaResponseSearchResultLocationCitation = { - readonly "cited_text": string - readonly "end_block_index": number - readonly "search_result_index": number - readonly "source": string - readonly "start_block_index": number - readonly "title": string | null - readonly "type": "search_result_location" -} -export const BetaResponseSearchResultLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "end_block_index": Schema.Number.annotate({ "title": "End Block Index" }).check(Schema.isInt()), - "search_result_index": Schema.Number.annotate({ "title": "Search Result Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) + "start_line": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Start Line" + }) ), - "source": Schema.String.annotate({ "title": "Source" }), - "start_block_index": Schema.Number.annotate({ "title": "Start Block Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) + "total_lines": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Total Lines" + }) ), - "title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Title" }), - "type": Schema.Literal("search_result_location").annotate({ "title": "Type", "default": "search_result_location" }) -}).annotate({ "title": "ResponseSearchResultLocationCitation" }) -export type BetaResponseTextEditorCodeExecutionCreateResultBlock = { + "type": Schema.Literal("text_editor_code_execution_view_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionViewResultBlock", + "identifier": "BetaRequestTextEditorCodeExecutionViewResultBlock" +}) +export type BetaRequestTextEditorCodeExecutionCreateResultBlock = { readonly "is_file_update": boolean readonly "type": "text_editor_code_execution_create_result" } -export const BetaResponseTextEditorCodeExecutionCreateResultBlock = Schema.Struct({ +export const BetaRequestTextEditorCodeExecutionCreateResultBlock = Schema.Struct({ "is_file_update": Schema.Boolean.annotate({ "title": "Is File Update" }), - "type": Schema.Literal("text_editor_code_execution_create_result").annotate({ - "title": "Type", - "default": "text_editor_code_execution_create_result" - }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionCreateResultBlock" }) -export type BetaResponseTextEditorCodeExecutionStrReplaceResultBlock = { - readonly "lines": ReadonlyArray | null - readonly "new_lines": number | null - readonly "new_start": number | null - readonly "old_lines": number | null - readonly "old_start": number | null + "type": Schema.Literal("text_editor_code_execution_create_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionCreateResultBlock", + "identifier": "BetaRequestTextEditorCodeExecutionCreateResultBlock" +}) +export type BetaRequestTextEditorCodeExecutionStrReplaceResultBlock = { + readonly "lines"?: ReadonlyArray | null + readonly "new_lines"?: number | null + readonly "new_start"?: number | null + readonly "old_lines"?: number | null + readonly "old_start"?: number | null readonly "type": "text_editor_code_execution_str_replace_result" } -export const BetaResponseTextEditorCodeExecutionStrReplaceResultBlock = Schema.Struct({ - "lines": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Lines", "default": null }), - "new_lines": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "New Lines", - "default": null - }), - "new_start": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "New Start", - "default": null - }), - "old_lines": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Old Lines", - "default": null - }), - "old_start": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Old Start", - "default": null - }), - "type": Schema.Literal("text_editor_code_execution_str_replace_result").annotate({ - "title": "Type", - "default": "text_editor_code_execution_str_replace_result" - }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionStrReplaceResultBlock" }) -export type BetaResponseTextEditorCodeExecutionViewResultBlock = { - readonly "content": string - readonly "file_type": "text" | "image" | "pdf" - readonly "num_lines": number | null - readonly "start_line": number | null - readonly "total_lines": number | null - readonly "type": "text_editor_code_execution_view_result" -} -export const BetaResponseTextEditorCodeExecutionViewResultBlock = Schema.Struct({ - "content": Schema.String.annotate({ "title": "Content" }), - "file_type": Schema.Literals(["text", "image", "pdf"]).annotate({ "title": "File Type" }), - "num_lines": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Num Lines", - "default": null - }), - "start_line": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Start Line", - "default": null - }), - "total_lines": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Total Lines", - "default": null - }), - "type": Schema.Literal("text_editor_code_execution_view_result").annotate({ - "title": "Type", - "default": "text_editor_code_execution_view_result" - }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionViewResultBlock" }) -export type BetaResponseThinkingBlock = { - readonly "signature": string - readonly "thinking": string - readonly "type": "thinking" -} -export const BetaResponseThinkingBlock = Schema.Struct({ - "signature": Schema.String.annotate({ "title": "Signature" }), - "thinking": Schema.String.annotate({ "title": "Thinking" }), - "type": Schema.Literal("thinking").annotate({ "title": "Type", "default": "thinking" }) -}).annotate({ "title": "ResponseThinkingBlock" }) -export type BetaResponseToolReferenceBlock = { readonly "tool_name": string; readonly "type": "tool_reference" } -export const BetaResponseToolReferenceBlock = Schema.Struct({ - "tool_name": Schema.String.annotate({ "title": "Tool Name" }).check(Schema.isMinLength(1)).check( - Schema.isMaxLength(256) - ).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,256}$"))), - "type": Schema.Literal("tool_reference").annotate({ "title": "Type", "default": "tool_reference" }) -}).annotate({ "title": "ResponseToolReferenceBlock" }) -export type BetaResponseWebSearchResultBlock = { - readonly "encrypted_content": string - readonly "page_age": string | null - readonly "title": string - readonly "type": "web_search_result" - readonly "url": string -} -export const BetaResponseWebSearchResultBlock = Schema.Struct({ - "encrypted_content": Schema.String.annotate({ "title": "Encrypted Content" }), - "page_age": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Page Age", "default": null }), - "title": Schema.String.annotate({ "title": "Title" }), - "type": Schema.Literal("web_search_result").annotate({ "title": "Type", "default": "web_search_result" }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "ResponseWebSearchResultBlock" }) -export type BetaResponseWebSearchResultLocationCitation = { - readonly "cited_text": string - readonly "encrypted_index": string - readonly "title": string | null - readonly "type": "web_search_result_location" - readonly "url": string -} -export const BetaResponseWebSearchResultLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "encrypted_index": Schema.String.annotate({ "title": "Encrypted Index" }), - "title": Schema.Union([Schema.String.check(Schema.isMaxLength(512)), Schema.Null]).annotate({ "title": "Title" }), - "type": Schema.Literal("web_search_result_location").annotate({ - "title": "Type", - "default": "web_search_result_location" - }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "ResponseWebSearchResultLocationCitation" }) -export type BetaServerToolCaller = { readonly "tool_id": string; readonly "type": "code_execution_20250825" } -export const BetaServerToolCaller = Schema.Struct({ - "tool_id": Schema.String.annotate({ "title": "Tool Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) +export const BetaRequestTextEditorCodeExecutionStrReplaceResultBlock = Schema.Struct({ + "lines": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Lines" })), + "new_lines": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "New Lines" + }) ), - "type": Schema.Literal("code_execution_20250825").annotate({ "title": "Type" }) -}).annotate({ "title": "ServerToolCaller", "description": "Tool invocation generated by a server-side tool." }) -export type BetaServerToolCaller_20260120 = { readonly "tool_id": string; readonly "type": "code_execution_20260120" } -export const BetaServerToolCaller_20260120 = Schema.Struct({ - "tool_id": Schema.String.annotate({ "title": "Tool Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "new_start": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "New Start" + }) ), - "type": Schema.Literal("code_execution_20260120").annotate({ "title": "Type" }) -}).annotate({ "title": "ServerToolCaller_20260120" }) -export type BetaServerToolUsage = { readonly "web_fetch_requests": number; readonly "web_search_requests": number } -export const BetaServerToolUsage = Schema.Struct({ - "web_fetch_requests": Schema.Number.annotate({ - "title": "Web Fetch Requests", - "description": "The number of web fetch tool requests.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "web_search_requests": Schema.Number.annotate({ - "title": "Web Search Requests", - "description": "The number of web search tool requests.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) -}).annotate({ "title": "ServerToolUsage" }) -export type BetaSignatureContentBlockDelta = { readonly "signature": string; readonly "type": "signature_delta" } -export const BetaSignatureContentBlockDelta = Schema.Struct({ - "signature": Schema.String.annotate({ "title": "Signature" }), - "type": Schema.Literal("signature_delta").annotate({ "title": "Type", "default": "signature_delta" }) -}).annotate({ "title": "SignatureContentBlockDelta" }) -export type BetaSkill = { - readonly "skill_id": string - readonly "type": "anthropic" | "custom" - readonly "version": string + "old_lines": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Old Lines" + }) + ), + "old_start": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Old Start" + }) + ), + "type": Schema.Literal("text_editor_code_execution_str_replace_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionStrReplaceResultBlock", + "identifier": "BetaRequestTextEditorCodeExecutionStrReplaceResultBlock" +}) +export type BetaToolSearchToolResultErrorCode = + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" +export const BetaToolSearchToolResultErrorCode = Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" +]).annotate({ "title": "ToolSearchToolResultErrorCode", "identifier": "BetaToolSearchToolResultErrorCode" }) +export type BetaToolChangeToolReference = { readonly "name": string; readonly "type": "tool_reference" } +export const BetaToolChangeToolReference = Schema.Struct({ + "name": Schema.String.annotate({ "title": "Name" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,128}$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]{1,128}$" + }) + ), + "type": Schema.Literal("tool_reference").annotate({ "title": "Type" }) +}).annotate({ + "title": "ToolChangeToolReference", + "description": + "Reference to a single tool the caller declared directly in\n``tools[]``. Does not accept the composed ``{server}_{name}`` form the\nserver assigns to MCP-resolved tools — use ``mcp_tool_reference`` or\n``mcp_toolset_reference`` for those.", + "identifier": "BetaToolChangeToolReference" +}) +export type BetaToolChangeMCPToolReference = { + readonly "name": string + readonly "server_name": string + readonly "type": "mcp_tool_reference" } -export const BetaSkill = Schema.Struct({ - "skill_id": Schema.String.annotate({ "title": "Skill Id", "description": "Skill ID" }).check(Schema.isMinLength(1)) - .check(Schema.isMaxLength(64)), - "type": Schema.Literals(["anthropic", "custom"]).annotate({ - "title": "Type", - "description": "Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)" - }), - "version": Schema.String.annotate({ - "title": "Version", - "description": "Skill version or 'latest' for most recent version" - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)) -}).annotate({ "title": "Skill", "description": "A skill that was loaded in a container (response model)." }) +export const BetaToolChangeMCPToolReference = Schema.Struct({ + "name": Schema.String.annotate({ "title": "Name" }), + "server_name": Schema.String.annotate({ "title": "Server Name" }), + "type": Schema.Literal("mcp_tool_reference").annotate({ "title": "Type" }) +}).annotate({ + "title": "ToolChangeMCPToolReference", + "description": + "Reference to a single MCP tool by its server and remote name — the\nsame ``server_name``/``name`` pair ``mcp_tool_use`` carries.", + "identifier": "BetaToolChangeMCPToolReference" +}) +export type BetaToolChangeMCPToolsetReference = { + readonly "server_name": string + readonly "type": "mcp_toolset_reference" +} +export const BetaToolChangeMCPToolsetReference = Schema.Struct({ + "server_name": Schema.String.annotate({ "title": "Server Name" }), + "type": Schema.Literal("mcp_toolset_reference").annotate({ "title": "Type" }) +}).annotate({ + "title": "ToolChangeMCPToolsetReference", + "description": "Reference to every tool in the named MCP server's toolset.", + "identifier": "BetaToolChangeMCPToolsetReference" +}) export type BetaSkillParams = { readonly "skill_id": string readonly "type": "anthropic" | "custom" readonly "version"?: string } export const BetaSkillParams = Schema.Struct({ - "skill_id": Schema.String.annotate({ "title": "Skill Id", "description": "Skill ID" }).check(Schema.isMinLength(1)) - .check(Schema.isMaxLength(64)), + "skill_id": Schema.String.annotate({ "title": "Skill Id", "description": "Skill ID" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), "type": Schema.Literals(["anthropic", "custom"]).annotate({ "title": "Type", "description": "Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)" }), "version": Schema.optionalKey( Schema.String.annotate({ "title": "Version", "description": "Skill version or 'latest' for most recent version" }) - .check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ) ) }).annotate({ "title": "SkillParams", - "description": "Specification for a skill to be loaded in a container (request model)." + "description": "Specification for a skill to be loaded in a container (request model).", + "identifier": "BetaSkillParams" }) -export type BetaSkillVersion = { - readonly "created_at": string - readonly "description": string - readonly "directory": string - readonly "id": string - readonly "name": string - readonly "skill_id": string - readonly "type": string - readonly "version": string -} -export const BetaSkillVersion = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill version was created." - }), - "description": Schema.String.annotate({ - "title": "Description", - "description": "Description of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." - }), - "directory": Schema.String.annotate({ - "title": "Directory", - "description": - "Directory name of the skill version.\n\nThis is the top-level directory name that was extracted from the uploaded files." - }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill version.\n\nThe format and length of IDs may change over time." - }), - "name": Schema.String.annotate({ - "title": "Name", - "description": - "Human-readable name of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." - }), - "skill_id": Schema.String.annotate({ - "title": "Skill Id", - "description": "Identifier for the skill that this version belongs to." +export type BetaInputTokensClearAtLeast = { readonly "type": "input_tokens"; readonly "value": number } +export const BetaInputTokensClearAtLeast = Schema.Struct({ + "type": Schema.Literal("input_tokens").annotate({ "title": "Type" }), + "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + .check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })) +}).annotate({ "title": "InputTokensClearAtLeast", "identifier": "BetaInputTokensClearAtLeast" }) +export type BetaToolUsesKeep = { readonly "type": "tool_uses"; readonly "value": number } +export const BetaToolUsesKeep = Schema.Struct({ + "type": Schema.Literal("tool_uses").annotate({ "title": "Type" }), + "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + .check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })) +}).annotate({ "title": "ToolUsesKeep", "identifier": "BetaToolUsesKeep" }) +export type BetaInputTokensTrigger = { readonly "type": "input_tokens"; readonly "value": number } +export const BetaInputTokensTrigger = Schema.Struct({ + "type": Schema.Literal("input_tokens").annotate({ "title": "Type" }), + "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + .check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })) +}).annotate({ "title": "InputTokensTrigger", "identifier": "BetaInputTokensTrigger" }) +export type BetaToolUsesTrigger = { readonly "type": "tool_uses"; readonly "value": number } +export const BetaToolUsesTrigger = Schema.Struct({ + "type": Schema.Literal("tool_uses").annotate({ "title": "Type" }), + "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + .check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })) +}).annotate({ "title": "ToolUsesTrigger", "identifier": "BetaToolUsesTrigger" }) +export type BetaThinkingTurns = { readonly "type": "thinking_turns"; readonly "value": number } +export const BetaThinkingTurns = Schema.Struct({ + "type": Schema.Literal("thinking_turns").annotate({ "title": "Type" }), + "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + .check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })) +}).annotate({ "title": "ThinkingTurns", "identifier": "BetaThinkingTurns" }) +export type BetaAllThinkingTurns = { readonly "type": "all" } +export const BetaAllThinkingTurns = Schema.Struct({ "type": Schema.Literal("all").annotate({ "title": "Type" }) }) + .annotate({ "title": "AllThinkingTurns", "identifier": "BetaAllThinkingTurns" }) +export type BetaDiagnosticsParam = { readonly "previous_message_id"?: string | null } +export const BetaDiagnosticsParam = Schema.Struct({ + "previous_message_id": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })), + Schema.Null + ]).annotate({ + "title": "Previous Message Id", + "description": + "The `id` (`msg_...`) from this client's previous /v1/messages response. The server compares that request's prompt fingerprint against this one and returns `diagnostics.cache_miss_reason` when the prompt-cache prefix could not be reused. Pass `null` on the first turn to opt in without a prior message to compare." + }) + ) +}).annotate({ + "title": "DiagnosticsParam", + "description": + "Request-level diagnostics. Currently carries the previous response\nid for prompt-cache divergence reporting.", + "identifier": "BetaDiagnosticsParam" +}) +export type BetaFallbackCreditTokenParam = { readonly "mode"?: "strict" | "best_effort"; readonly "token": string } +export const BetaFallbackCreditTokenParam = Schema.Struct({ + "mode": Schema.optionalKey( + Schema.Literals(["strict", "best_effort"]).annotate({ + "title": "Mode", + "description": + "How a failing token affects the retry. `strict` (the default, and the bare-string behavior): a failing redemption is a 400 and the retry is not served. `best_effort`: the retry is served either way — a token-layer failure no longer rejects the request; the retry proceeds at normal price and the outcome is reported on the response's `usage.fallback_credit`. Two failures stay hard in both modes: a malformed token, and combining `fallback_credit_token` with `fallbacks`." + }) + ), + "token": Schema.String.annotate({ + "title": "Token", + "description": + "The opaque `fallback_credit_token` from a prior refusal's `stop_details` — the same string the bare-string form carries." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" }) + ) +}).annotate({ + "title": "FallbackCreditTokenParam", + "description": + "Object form of ``fallback_credit_token``: the token plus a redemption\nmode.\n\nRequires ``anthropic-beta: fallback-credit-2026-07-01``; without that\nheader the field accepts the bare string only. The bare string and the\nmode-less object are equivalent (both select ``strict``), so wrapping\nan existing token changes nothing by itself.", + "identifier": "BetaFallbackCreditTokenParam" +}) +export type BetaEffortLevel = "low" | "medium" | "high" | "xhigh" | "max" +export const BetaEffortLevel = Schema.Literals(["low", "medium", "high", "xhigh", "max"]).annotate({ + "title": "EffortLevel", + "description": "All possible effort levels.", + "identifier": "BetaEffortLevel" +}) +export type BetaJsonOutputFormat = { + readonly "schema": { readonly [x: string]: Schema.Json } + readonly "type": "json_schema" +} +export const BetaJsonOutputFormat = Schema.Struct({ + "schema": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Schema", + "description": "The JSON schema of the format" }), - "type": Schema.String.annotate({ + "type": Schema.Literal("json_schema").annotate({ "title": "Type" }) +}).annotate({ "title": "JsonOutputFormat", "identifier": "BetaJsonOutputFormat" }) +export type BetaTokenTaskBudget = { readonly "remaining"?: number; readonly "total": number; readonly "type": "tokens" } +export const BetaTokenTaskBudget = Schema.Struct({ + "remaining": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check( + Schema.makeFilterGroup([ + Schema.isFinite().annotate({ "expected": "a finite number" }), + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ]).annotate({ + "title": "Remaining", + "description": + "Remaining tokens in the budget. Use this to track usage across contexts when implementing compaction client-side. Defaults to total if not provided." + }) + ) + ]) + ), + "total": Schema.Number.annotate({ + "title": "Total", + "description": "Total token budget across all contexts in the session." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1024).annotate({ "expected": "a value greater than or equal to 1024" }) + ), + "type": Schema.Literal("tokens").annotate({ "title": "Type", - "description": "Object type.\n\nFor Skill Versions, this is always `\"skill_version\"`.", - "default": "skill_version" - }), - "version": Schema.String.annotate({ - "title": "Version", - "description": - "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." + "description": "The budget type. Currently only 'tokens' is supported." }) -}).annotate({ "title": "SkillVersion" }) +}).annotate({ + "title": "TokenTaskBudget", + "description": "User-configurable total token budget across contexts.", + "identifier": "BetaTokenTaskBudget" +}) export type BetaSpeed = "standard" | "fast" -export const BetaSpeed = Schema.Literals(["standard", "fast"]).annotate({ "title": "Speed" }) -export type BetaTextContentBlockDelta = { readonly "text": string; readonly "type": "text_delta" } -export const BetaTextContentBlockDelta = Schema.Struct({ - "text": Schema.String.annotate({ "title": "Text" }), - "type": Schema.Literal("text_delta").annotate({ "title": "Type", "default": "text_delta" }) -}).annotate({ "title": "TextContentBlockDelta" }) -export type BetaTextEditorCodeExecutionToolResultErrorCode = - | "invalid_tool_input" - | "unavailable" - | "too_many_requests" - | "execution_time_exceeded" - | "file_not_found" -export const BetaTextEditorCodeExecutionToolResultErrorCode = Schema.Literals([ - "invalid_tool_input", - "unavailable", - "too_many_requests", - "execution_time_exceeded", - "file_not_found" -]).annotate({ "title": "TextEditorCodeExecutionToolResultErrorCode" }) -export type BetaThinkingConfigAdaptive = { readonly "type": "adaptive" } -export const BetaThinkingConfigAdaptive = Schema.Struct({ - "type": Schema.Literal("adaptive").annotate({ "title": "Type" }) -}).annotate({ "title": "ThinkingConfigAdaptive" }) +export const BetaSpeed = Schema.Literals(["standard", "fast"]).annotate({ + "description": + "Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.", + "identifier": "BetaSpeed" +}) +export type BetaThinkingDisplayMode = "summarized" | "omitted" +export const BetaThinkingDisplayMode = Schema.Literals(["summarized", "omitted"]).annotate({ + "title": "ThinkingDisplayMode", + "identifier": "BetaThinkingDisplayMode" +}) export type BetaThinkingConfigDisabled = { readonly "type": "disabled" } export const BetaThinkingConfigDisabled = Schema.Struct({ "type": Schema.Literal("disabled").annotate({ "title": "Type" }) -}).annotate({ "title": "ThinkingConfigDisabled" }) -export type BetaThinkingConfigEnabled = { readonly "budget_tokens": number; readonly "type": "enabled" } -export const BetaThinkingConfigEnabled = Schema.Struct({ - "budget_tokens": Schema.Number.annotate({ - "title": "Budget Tokens", - "description": - "Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.\n\nMust be ≥1024 and less than `max_tokens`.\n\nSee [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1024)), - "type": Schema.Literal("enabled").annotate({ "title": "Type" }) -}).annotate({ "title": "ThinkingConfigEnabled" }) -export type BetaThinkingContentBlockDelta = { readonly "thinking": string; readonly "type": "thinking_delta" } -export const BetaThinkingContentBlockDelta = Schema.Struct({ - "thinking": Schema.String.annotate({ "title": "Thinking" }), - "type": Schema.Literal("thinking_delta").annotate({ "title": "Type", "default": "thinking_delta" }) -}).annotate({ "title": "ThinkingContentBlockDelta" }) -export type BetaThinkingTurns = { readonly "type": "thinking_turns"; readonly "value": number } -export const BetaThinkingTurns = Schema.Struct({ - "type": Schema.Literal("thinking_turns").annotate({ "title": "Type" }), - "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)) -}).annotate({ "title": "ThinkingTurns" }) -export type BetaToolChoiceAny = { readonly "disable_parallel_tool_use"?: boolean; readonly "type": "any" } -export const BetaToolChoiceAny = Schema.Struct({ - "disable_parallel_tool_use": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Disable Parallel Tool Use", +}).annotate({ "title": "ThinkingConfigDisabled", "identifier": "BetaThinkingConfigDisabled" }) +export type BetaRequestMCPServerToolConfiguration = { + readonly "allowed_tools"?: ReadonlyArray | null + readonly "enabled"?: boolean | null +} +export const BetaRequestMCPServerToolConfiguration = Schema.Struct({ + "allowed_tools": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Allowed Tools" }) + ), + "enabled": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null]).annotate({ "title": "Enabled" })) +}).annotate({ "title": "RequestMCPServerToolConfiguration", "identifier": "BetaRequestMCPServerToolConfiguration" }) +export type BetaMetadata = { readonly "user_id"?: string | null } +export const BetaMetadata = Schema.Struct({ + "user_id": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })), + Schema.Null + ]).annotate({ + "title": "User Id", "description": - "Whether to disable parallel tool use.\n\nDefaults to `false`. If set to `true`, the model will output exactly one tool use." + "An external identifier for the user who is associated with the request.\n\nThis should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number." }) - ), - "type": Schema.Literal("any").annotate({ "title": "Type" }) -}).annotate({ "title": "ToolChoiceAny", "description": "The model will use any available tools." }) + ) +}).annotate({ "title": "Metadata", "identifier": "BetaMetadata" }) export type BetaToolChoiceAuto = { readonly "disable_parallel_tool_use"?: boolean; readonly "type": "auto" } export const BetaToolChoiceAuto = Schema.Struct({ "disable_parallel_tool_use": Schema.optionalKey( @@ -1386,10 +1911,26 @@ export const BetaToolChoiceAuto = Schema.Struct({ }) ), "type": Schema.Literal("auto").annotate({ "title": "Type" }) -}).annotate({ "title": "ToolChoiceAuto", "description": "The model will automatically decide whether to use tools." }) -export type BetaToolChoiceNone = { readonly "type": "none" } -export const BetaToolChoiceNone = Schema.Struct({ "type": Schema.Literal("none").annotate({ "title": "Type" }) }) - .annotate({ "title": "ToolChoiceNone", "description": "The model will not be allowed to use tools." }) +}).annotate({ + "title": "ToolChoiceAuto", + "description": "The model will automatically decide whether to use tools.", + "identifier": "BetaToolChoiceAuto" +}) +export type BetaToolChoiceAny = { readonly "disable_parallel_tool_use"?: boolean; readonly "type": "any" } +export const BetaToolChoiceAny = Schema.Struct({ + "disable_parallel_tool_use": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Disable Parallel Tool Use", + "description": + "Whether to disable parallel tool use.\n\nDefaults to `false`. If set to `true`, the model will output exactly one tool use." + }) + ), + "type": Schema.Literal("any").annotate({ "title": "Type" }) +}).annotate({ + "title": "ToolChoiceAny", + "description": "The model will use any available tools.", + "identifier": "BetaToolChoiceAny" +}) export type BetaToolChoiceTool = { readonly "disable_parallel_tool_use"?: boolean readonly "name": string @@ -1407,39 +1948,53 @@ export const BetaToolChoiceTool = Schema.Struct({ "type": Schema.Literal("tool").annotate({ "title": "Type" }) }).annotate({ "title": "ToolChoiceTool", - "description": "The model will use the specified tool with `tool_choice.name`." + "description": "The model will use the specified tool with `tool_choice.name`.", + "identifier": "BetaToolChoiceTool" }) -export type BetaToolSearchToolResultErrorCode = - | "invalid_tool_input" - | "unavailable" - | "too_many_requests" - | "execution_time_exceeded" -export const BetaToolSearchToolResultErrorCode = Schema.Literals([ - "invalid_tool_input", - "unavailable", - "too_many_requests", - "execution_time_exceeded" -]).annotate({ "title": "ToolSearchToolResultErrorCode" }) -export type BetaToolUsesKeep = { readonly "type": "tool_uses"; readonly "value": number } -export const BetaToolUsesKeep = Schema.Struct({ - "type": Schema.Literal("tool_uses").annotate({ "title": "Type" }), - "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) -}).annotate({ "title": "ToolUsesKeep" }) -export type BetaToolUsesTrigger = { readonly "type": "tool_uses"; readonly "value": number } -export const BetaToolUsesTrigger = Schema.Struct({ - "type": Schema.Literal("tool_uses").annotate({ "title": "Type" }), - "value": Schema.Number.annotate({ "title": "Value" }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)) -}).annotate({ "title": "ToolUsesTrigger" }) -export type BetaURLImageSource = { readonly "type": "url"; readonly "url": string } -export const BetaURLImageSource = Schema.Struct({ - "type": Schema.Literal("url").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "URLImageSource" }) -export type BetaURLPDFSource = { readonly "type": "url"; readonly "url": string } -export const BetaURLPDFSource = Schema.Struct({ - "type": Schema.Literal("url").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "URLPDFSource" }) +export type BetaToolChoiceNone = { readonly "type": "none" } +export const BetaToolChoiceNone = Schema.Struct({ "type": Schema.Literal("none").annotate({ "title": "Type" }) }) + .annotate({ + "title": "ToolChoiceNone", + "description": "The model will not be allowed to use tools.", + "identifier": "BetaToolChoiceNone" + }) +export type BetaInputSchema = { + readonly "properties"?: { readonly [x: string]: Schema.Json } | null + readonly "required"?: ReadonlyArray | null + readonly "type": "object" + readonly [x: string]: Schema.Json +} +export const BetaInputSchema = Schema.StructWithRest( + Schema.Struct({ + "properties": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + .annotate({ "title": "Properties" }) + ), + "required": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Required" }) + ), + "type": Schema.Literal("object").annotate({ "title": "Type" }) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ "title": "InputSchema", "identifier": "BetaInputSchema" }) +export type BetaAllowedCaller = + | "direct" + | "code_execution_20250825" + | "code_execution_20260120" + | "code_execution_20260521" +export const BetaAllowedCaller = Schema.Literals([ + "direct", + "code_execution_20250825", + "code_execution_20260120", + "code_execution_20260521" +]).annotate({ + "title": "AllowedCaller", + "description": + "Specifies who can invoke a tool.\n\nValues:\n direct: The model can call this tool directly.\n code_execution_20250825: The tool can be called from the code execution environment (v1).\n code_execution_20260120: The tool can be called from the code execution environment (v2 with persistence).\n code_execution_20260521: The tool can be called from the code execution environment (v2 with persistence).", + "identifier": "BetaAllowedCaller" +}) +export type BetaJsonValue = Schema.Json +export const BetaJsonValue = Schema.Json.annotate({ "expected": "JSON value", "identifier": "BetaJsonValue" }) export type BetaUserLocation = { readonly "city"?: string | null readonly "country"?: string | null @@ -1449,1727 +2004,2948 @@ export type BetaUserLocation = { } export const BetaUserLocation = Schema.Struct({ "city": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), Schema.Null]).annotate({ - "title": "City", - "description": "The city of the user." - }) + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ "title": "City", "description": "The city of the user." }) ), "country": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(2)).check(Schema.isMaxLength(2)), Schema.Null]).annotate({ + Schema.Union([ + Schema.String.check(Schema.isMinLength(2).annotate({ "expected": "a value with a length of at least 2" })).check( + Schema.isMaxLength(2).annotate({ "expected": "a value with a length of at most 2" }) + ), + Schema.Null + ]).annotate({ "title": "Country", "description": "The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user." }) ), "region": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), Schema.Null]).annotate({ - "title": "Region", - "description": "The region of the user." - }) + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ "title": "Region", "description": "The region of the user." }) ), "timezone": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), Schema.Null]).annotate({ + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + Schema.Null + ]).annotate({ "title": "Timezone", "description": "The [IANA timezone](https://nodatime.org/TimeZones) of the user." }) ), "type": Schema.Literal("approximate").annotate({ "title": "Type" }) -}).annotate({ "title": "UserLocation" }) -export type BetaWebFetchToolResultErrorCode = - | "invalid_tool_input" - | "url_too_long" - | "url_not_allowed" - | "url_not_accessible" - | "unsupported_content_type" - | "too_many_requests" - | "max_uses_exceeded" - | "unavailable" -export const BetaWebFetchToolResultErrorCode = Schema.Literals([ - "invalid_tool_input", - "url_too_long", - "url_not_allowed", - "url_not_accessible", - "unsupported_content_type", - "too_many_requests", - "max_uses_exceeded", - "unavailable" -]).annotate({ "title": "WebFetchToolResultErrorCode" }) -export type BetaWebSearchToolResultErrorCode = - | "invalid_tool_input" - | "unavailable" - | "max_uses_exceeded" - | "too_many_requests" - | "query_too_long" - | "request_too_large" -export const BetaWebSearchToolResultErrorCode = Schema.Literals([ - "invalid_tool_input", - "unavailable", - "max_uses_exceeded", - "too_many_requests", - "query_too_long", - "request_too_large" -]).annotate({ "title": "WebSearchToolResultErrorCode" }) -export type Betaapi__schemas__skills__Skill = { - readonly "created_at": string - readonly "display_title": string | null - readonly "id": string - readonly "latest_version": string | null - readonly "source": string - readonly "type": string - readonly "updated_at": string +}).annotate({ "title": "UserLocation", "identifier": "BetaUserLocation" }) +export type BetaMCPToolConfig = { readonly "defer_loading"?: boolean; readonly "enabled"?: boolean } +export const BetaMCPToolConfig = Schema.Struct({ + "defer_loading": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Defer Loading" })), + "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Enabled" })) +}).annotate({ + "title": "MCPToolConfig", + "description": "Configuration for a specific tool in an MCP toolset.", + "identifier": "BetaMCPToolConfig" +}) +export type BetaMCPToolDefaultConfig = { readonly "defer_loading"?: boolean; readonly "enabled"?: boolean } +export const BetaMCPToolDefaultConfig = Schema.Struct({ + "defer_loading": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Defer Loading" })), + "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Enabled" })) +}).annotate({ + "title": "MCPToolDefaultConfig", + "description": "Default configuration for tools in an MCP toolset.", + "identifier": "BetaMCPToolDefaultConfig" +}) +export type BetaResponseCharLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_char_index": number + readonly "file_id": string | null + readonly "start_char_index": number + readonly "type": "char_location" } -export const Betaapi__schemas__skills__Skill = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill was created." - }), - "display_title": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Display Title", - "description": - "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." - }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." - }), - "latest_version": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Latest Version", - "description": - "The latest version identifier for the skill.\n\nThis represents the most recent version of the skill that has been created." - }), - "source": Schema.String.annotate({ - "title": "Source", - "description": - "Source of the skill.\n\nThis may be one of the following values:\n* `\"custom\"`: the skill was created by a user\n* `\"anthropic\"`: the skill was created by Anthropic" - }), - "type": Schema.String.annotate({ - "title": "Type", - "description": "Object type.\n\nFor Skills, this is always `\"skill\"`.", - "default": "skill" - }), - "updated_at": Schema.String.annotate({ - "title": "Updated At", - "description": "ISO 8601 timestamp of when the skill was last updated." - }) -}).annotate({ "title": "Skill" }) -export type BillingError = { readonly "message": string; readonly "type": "billing_error" } -export const BillingError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Billing error" }), - "type": Schema.Literal("billing_error").annotate({ "title": "Type", "default": "billing_error" }) -}).annotate({ "title": "BillingError" }) -export type Body_create_skill_v1_skills_post = { - readonly "display_title"?: string | null - readonly "files"?: ReadonlyArray | null +export const BetaResponseCharLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), + "end_char_index": Schema.Number.annotate({ "title": "End Char Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), + "start_char_index": Schema.Number.annotate({ "title": "Start Char Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "type": Schema.Literal("char_location").annotate({ "title": "Type", "default": "char_location" }) +}).annotate({ "title": "ResponseCharLocationCitation", "identifier": "BetaResponseCharLocationCitation" }) +export type BetaResponsePageLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_page_number": number + readonly "file_id": string | null + readonly "start_page_number": number + readonly "type": "page_location" } -export const Body_create_skill_v1_skills_post = Schema.Struct({ - "display_title": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Display Title", - "description": - "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." - }) +export const BetaResponsePageLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), + "end_page_number": Schema.Number.annotate({ "title": "End Page Number" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "files": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String.annotate({ "format": "binary" })), Schema.Null]).annotate({ - "title": "Files", - "description": - "Files to upload for the skill.\n\nAll files must be in the same top-level directory and must include a SKILL.md file at the root of that directory." - }) - ) -}).annotate({ "title": "Body_create_skill_v1_skills_post" }) -export type Body_create_skill_version_v1_skills__skill_id__versions_post = { - readonly "files"?: ReadonlyArray | null + "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), + "start_page_number": Schema.Number.annotate({ "title": "Start Page Number" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })), + "type": Schema.Literal("page_location").annotate({ "title": "Type", "default": "page_location" }) +}).annotate({ "title": "ResponsePageLocationCitation", "identifier": "BetaResponsePageLocationCitation" }) +export type BetaResponseContentBlockLocationCitation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_block_index": number + readonly "file_id": string | null + readonly "start_block_index": number + readonly "type": "content_block_location" } -export const Body_create_skill_version_v1_skills__skill_id__versions_post = Schema.Struct({ - "files": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String.annotate({ "format": "binary" })), Schema.Null]).annotate({ - "title": "Files", - "description": - "Files to upload for the skill.\n\nAll files must be in the same top-level directory and must include a SKILL.md file at the root of that directory." - }) - ) -}).annotate({ "title": "Body_create_skill_version_v1_skills__skill_id__versions_post" }) -export type CacheControlEphemeral = { readonly "ttl"?: "5m" | "1h"; readonly "type": "ephemeral" } -export const CacheControlEphemeral = Schema.Struct({ - "ttl": Schema.optionalKey( - Schema.Literals(["5m", "1h"]).annotate({ - "title": "Ttl", - "description": - "The time-to-live for the cache control breakpoint.\n\nThis may be one the following values:\n- `5m`: 5 minutes\n- `1h`: 1 hour\n\nDefaults to `5m`." - }) +export const BetaResponseContentBlockLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ + "title": "Cited Text", + "description": + "The full text of the cited block range, concatenated.\n\nAlways equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns." + }), + "document_index": Schema.Number.annotate({ "title": "Document Index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), + "end_block_index": Schema.Number.annotate({ + "title": "End Block Index", + "description": + "Exclusive 0-based end index of the cited block range in the source's `content` array.\n\nAlways greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), + "start_block_index": Schema.Number.annotate({ + "title": "Start Block Index", + "description": "0-based index of the first cited block in the source's `content` array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "type": Schema.Literal("ephemeral").annotate({ "title": "Type" }) -}).annotate({ "title": "CacheControlEphemeral" }) -export type CacheCreation = { - readonly "ephemeral_1h_input_tokens": number - readonly "ephemeral_5m_input_tokens": number + "type": Schema.Literal("content_block_location").annotate({ "title": "Type", "default": "content_block_location" }) +}).annotate({ + "title": "ResponseContentBlockLocationCitation", + "identifier": "BetaResponseContentBlockLocationCitation" +}) +export type BetaResponseWebSearchResultLocationCitation = { + readonly "cited_text": string + readonly "encrypted_index": string + readonly "title": string | null + readonly "type": "web_search_result_location" + readonly "url": string } -export const CacheCreation = Schema.Struct({ - "ephemeral_1h_input_tokens": Schema.Number.annotate({ - "title": "Ephemeral 1H Input Tokens", - "description": "The number of input tokens used to create the 1 hour cache entry.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "ephemeral_5m_input_tokens": Schema.Number.annotate({ - "title": "Ephemeral 5M Input Tokens", - "description": "The number of input tokens used to create the 5 minute cache entry.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) -}).annotate({ "title": "CacheCreation" }) -export type CanceledResult = { readonly "type": "canceled" } -export const CanceledResult = Schema.Struct({ - "type": Schema.Literal("canceled").annotate({ "title": "Type", "default": "canceled" }) -}).annotate({ "title": "CanceledResult" }) -export type CodeExecutionToolResultErrorCode = - | "invalid_tool_input" - | "unavailable" - | "too_many_requests" - | "execution_time_exceeded" -export const CodeExecutionToolResultErrorCode = Schema.Literals([ - "invalid_tool_input", - "unavailable", - "too_many_requests", - "execution_time_exceeded" -]).annotate({ "title": "CodeExecutionToolResultErrorCode" }) -export type Container = { readonly "expires_at": string; readonly "id": string } -export const Container = Schema.Struct({ - "expires_at": Schema.String.annotate({ - "title": "Expires At", - "description": "The time at which the container will expire.", - "format": "date-time" +export const BetaResponseWebSearchResultLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ "title": "Cited Text" }), + "encrypted_index": Schema.String.annotate({ "title": "Encrypted Index" }), + "title": Schema.Union([ + Schema.String.check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })), + Schema.Null + ]).annotate({ "title": "Title" }), + "type": Schema.Literal("web_search_result_location").annotate({ + "title": "Type", + "default": "web_search_result_location" }), - "id": Schema.String.annotate({ "title": "Id", "description": "Identifier for the container used in this request" }) + "url": Schema.String.annotate({ "title": "Url" }) }).annotate({ - "title": "Container", - "description": "Information about the container used in the request (for the code execution tool)" + "title": "ResponseWebSearchResultLocationCitation", + "identifier": "BetaResponseWebSearchResultLocationCitation" }) -export type ContentBlockStopEvent = { readonly "index": number; readonly "type": "content_block_stop" } -export const ContentBlockStopEvent = Schema.Struct({ - "index": Schema.Number.annotate({ "title": "Index" }).check(Schema.isInt()), - "type": Schema.Literal("content_block_stop").annotate({ "title": "Type", "default": "content_block_stop" }) -}).annotate({ "title": "ContentBlockStopEvent" }) -export type CountMessageTokensResponse = { readonly "input_tokens": number } -export const CountMessageTokensResponse = Schema.Struct({ - "input_tokens": Schema.Number.annotate({ - "title": "Input Tokens", - "description": "The total number of tokens across the provided list of messages, system prompt, and tools." - }).check(Schema.isInt()) -}).annotate({ "title": "CountMessageTokensResponse" }) -export type CreateSkillResponse = { - readonly "created_at": string - readonly "display_title": string | null - readonly "id": string - readonly "latest_version": string | null +export type BetaResponseSearchResultLocationCitation = { + readonly "cited_text": string + readonly "end_block_index": number + readonly "search_result_index": number readonly "source": string - readonly "type": string - readonly "updated_at": string + readonly "start_block_index": number + readonly "title": string | null + readonly "type": "search_result_location" } -export const CreateSkillResponse = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill was created." - }), - "display_title": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Display Title", +export const BetaResponseSearchResultLocationCitation = Schema.Struct({ + "cited_text": Schema.String.annotate({ + "title": "Cited Text", "description": - "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." - }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." + "The full text of the cited block range, concatenated.\n\nAlways equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns." }), - "latest_version": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Latest Version", + "end_block_index": Schema.Number.annotate({ + "title": "End Block Index", "description": - "The latest version identifier for the skill.\n\nThis represents the most recent version of the skill that has been created." - }), - "source": Schema.String.annotate({ - "title": "Source", + "Exclusive 0-based end index of the cited block range in the source's `content` array.\n\nAlways greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "search_result_index": Schema.Number.annotate({ + "title": "Search Result Index", "description": - "Source of the skill.\n\nThis may be one of the following values:\n* `\"custom\"`: the skill was created by a user\n* `\"anthropic\"`: the skill was created by Anthropic" - }), - "type": Schema.String.annotate({ - "title": "Type", - "description": "Object type.\n\nFor Skills, this is always `\"skill\"`.", - "default": "skill" - }), - "updated_at": Schema.String.annotate({ - "title": "Updated At", - "description": "ISO 8601 timestamp of when the skill was last updated." - }) -}).annotate({ "title": "CreateSkillResponse" }) -export type CreateSkillVersionResponse = { - readonly "created_at": string - readonly "description": string - readonly "directory": string - readonly "id": string - readonly "name": string - readonly "skill_id": string - readonly "type": string - readonly "version": string + "0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.\n\nCounted separately from `document_index`; server-side web search results are not included in this count." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "source": Schema.String.annotate({ "title": "Source" }), + "start_block_index": Schema.Number.annotate({ + "title": "Start Block Index", + "description": "0-based index of the first cited block in the source's `content` array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Title" }), + "type": Schema.Literal("search_result_location").annotate({ "title": "Type", "default": "search_result_location" }) +}).annotate({ + "title": "ResponseSearchResultLocationCitation", + "identifier": "BetaResponseSearchResultLocationCitation" +}) +export type BetaResponseThinkingBlock = { + readonly "signature": string + readonly "thinking": string + readonly "type": "thinking" } -export const CreateSkillVersionResponse = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill version was created." +export const BetaResponseThinkingBlock = Schema.Struct({ + "signature": Schema.String.annotate({ + "title": "Signature", + "description": + "A value used to verify that this thinking block was generated by Claude when it is passed back to the API.\n\nThis is an opaque field and should not be interpreted or parsed. When passing thinking blocks back to the API (required when using tools with extended thinking), pass them back exactly as received, with this field intact.\n\nSee [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details." }), - "description": Schema.String.annotate({ - "title": "Description", - "description": "Description of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + "thinking": Schema.String.annotate({ + "title": "Thinking", + "description": "The text of Claude's thinking process for this block." }), - "directory": Schema.String.annotate({ - "title": "Directory", + "type": Schema.Literal("thinking").annotate({ "title": "Type", "default": "thinking" }) +}).annotate({ "title": "ResponseThinkingBlock", "identifier": "BetaResponseThinkingBlock" }) +export type BetaResponseRedactedThinkingBlock = { readonly "data": string; readonly "type": "redacted_thinking" } +export const BetaResponseRedactedThinkingBlock = Schema.Struct({ + "data": Schema.String.annotate({ + "title": "Data", "description": - "Directory name of the skill version.\n\nThis is the top-level directory name that was extracted from the uploaded files." + "The contents of this redacted thinking block, returned when portions of the model's thinking were safety-redacted. This field is opaque and encrypted, with no readable content.\n\nPass `redacted_thinking` blocks back to the API unchanged when continuing a multi-turn conversation.\n\nSee [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking#redacted-thinking-blocks) for details." }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill version.\n\nThe format and length of IDs may change over time." - }), - "name": Schema.String.annotate({ - "title": "Name", + "type": Schema.Literal("redacted_thinking").annotate({ "title": "Type", "default": "redacted_thinking" }) +}).annotate({ "title": "ResponseRedactedThinkingBlock", "identifier": "BetaResponseRedactedThinkingBlock" }) +export type BetaResponseWebSearchResultBlock = { + readonly "encrypted_content": string + readonly "page_age": string | null + readonly "title": string + readonly "type": "web_search_result" + readonly "url": string +} +export const BetaResponseWebSearchResultBlock = Schema.Struct({ + "encrypted_content": Schema.String.annotate({ "title": "Encrypted Content" }), + "page_age": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Page Age", "default": null }), + "title": Schema.String.annotate({ "title": "Title" }), + "type": Schema.Literal("web_search_result").annotate({ "title": "Type", "default": "web_search_result" }), + "url": Schema.String.annotate({ "title": "Url" }) +}).annotate({ "title": "ResponseWebSearchResultBlock", "identifier": "BetaResponseWebSearchResultBlock" }) +export type BetaResponseCitationsConfig = { readonly "enabled": boolean } +export const BetaResponseCitationsConfig = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ "title": "Enabled", "default": false }) +}).annotate({ "title": "ResponseCitationsConfig", "identifier": "BetaResponseCitationsConfig" }) +export type BetaResponseAdvisorResultBlock = { + readonly "stop_reason": string | null + readonly "text": string + readonly "type": "advisor_result" +} +export const BetaResponseAdvisorResultBlock = Schema.Struct({ + "stop_reason": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Stop Reason", "description": - "Human-readable name of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + "The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.", + "default": null }), - "skill_id": Schema.String.annotate({ - "title": "Skill Id", - "description": "Identifier for the skill that this version belongs to." + "text": Schema.String.annotate({ "title": "Text" }), + "type": Schema.Literal("advisor_result").annotate({ "title": "Type", "default": "advisor_result" }) +}).annotate({ "title": "ResponseAdvisorResultBlock", "identifier": "BetaResponseAdvisorResultBlock" }) +export type BetaResponseAdvisorRedactedResultBlock = { + readonly "encrypted_content": string + readonly "stop_reason": string | null + readonly "type": "advisor_redacted_result" +} +export const BetaResponseAdvisorRedactedResultBlock = Schema.Struct({ + "encrypted_content": Schema.String.annotate({ + "title": "Encrypted Content", + "description": "Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify." }), - "type": Schema.String.annotate({ - "title": "Type", - "description": "Object type.\n\nFor Skill Versions, this is always `\"skill_version\"`.", - "default": "skill_version" + "stop_reason": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Stop Reason", + "description": "The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).", + "default": null }), - "version": Schema.String.annotate({ - "title": "Version", - "description": - "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." - }) -}).annotate({ "title": "CreateSkillVersionResponse" }) -export type DeleteMessageBatchResponse = { readonly "id": string; readonly "type": "message_batch_deleted" } -export const DeleteMessageBatchResponse = Schema.Struct({ - "id": Schema.String.annotate({ "title": "Id", "description": "ID of the Message Batch." }), - "type": Schema.Literal("message_batch_deleted").annotate({ - "title": "Type", - "description": "Deleted object type.\n\nFor Message Batches, this is always `\"message_batch_deleted\"`.", - "default": "message_batch_deleted" + "type": Schema.Literal("advisor_redacted_result").annotate({ "title": "Type", "default": "advisor_redacted_result" }) +}).annotate({ "title": "ResponseAdvisorRedactedResultBlock", "identifier": "BetaResponseAdvisorRedactedResultBlock" }) +export type BetaResponseCodeExecutionOutputBlock = { + readonly "file_id": string + readonly "type": "code_execution_output" +} +export const BetaResponseCodeExecutionOutputBlock = Schema.Struct({ + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("code_execution_output").annotate({ "title": "Type", "default": "code_execution_output" }) +}).annotate({ "title": "ResponseCodeExecutionOutputBlock", "identifier": "BetaResponseCodeExecutionOutputBlock" }) +export type BetaResponseBashCodeExecutionOutputBlock = { + readonly "file_id": string + readonly "type": "bash_code_execution_output" +} +export const BetaResponseBashCodeExecutionOutputBlock = Schema.Struct({ + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("bash_code_execution_output").annotate({ + "title": "Type", + "default": "bash_code_execution_output" }) -}).annotate({ "title": "DeleteMessageBatchResponse" }) -export type DeleteSkillResponse = { readonly "id": string; readonly "type": string } -export const DeleteSkillResponse = Schema.Struct({ - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." - }), - "type": Schema.String.annotate({ +}).annotate({ + "title": "ResponseBashCodeExecutionOutputBlock", + "identifier": "BetaResponseBashCodeExecutionOutputBlock" +}) +export type BetaResponseTextEditorCodeExecutionViewResultBlock = { + readonly "content": string + readonly "file_type": "text" | "image" | "pdf" + readonly "num_lines": number | null + readonly "start_line": number | null + readonly "total_lines": number | null + readonly "type": "text_editor_code_execution_view_result" +} +export const BetaResponseTextEditorCodeExecutionViewResultBlock = Schema.Struct({ + "content": Schema.String.annotate({ "title": "Content" }), + "file_type": Schema.Literals(["text", "image", "pdf"]).annotate({ "title": "File Type" }), + "num_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Num Lines", "default": null }), + "start_line": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Start Line", "default": null }), + "total_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Total Lines", "default": null }), + "type": Schema.Literal("text_editor_code_execution_view_result").annotate({ "title": "Type", - "description": "Deleted object type.\n\nFor Skills, this is always `\"skill_deleted\"`.", - "default": "skill_deleted" + "default": "text_editor_code_execution_view_result" }) -}).annotate({ "title": "DeleteSkillResponse" }) -export type DeleteSkillVersionResponse = { readonly "id": string; readonly "type": string } -export const DeleteSkillVersionResponse = Schema.Struct({ - "id": Schema.String.annotate({ - "title": "Id", - "description": - "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." - }), - "type": Schema.String.annotate({ +}).annotate({ + "title": "ResponseTextEditorCodeExecutionViewResultBlock", + "identifier": "BetaResponseTextEditorCodeExecutionViewResultBlock" +}) +export type BetaResponseTextEditorCodeExecutionCreateResultBlock = { + readonly "is_file_update": boolean + readonly "type": "text_editor_code_execution_create_result" +} +export const BetaResponseTextEditorCodeExecutionCreateResultBlock = Schema.Struct({ + "is_file_update": Schema.Boolean.annotate({ "title": "Is File Update" }), + "type": Schema.Literal("text_editor_code_execution_create_result").annotate({ "title": "Type", - "description": "Deleted object type.\n\nFor Skill Versions, this is always `\"skill_version_deleted\"`.", - "default": "skill_version_deleted" + "default": "text_editor_code_execution_create_result" }) -}).annotate({ "title": "DeleteSkillVersionResponse" }) -export type DirectCaller = { readonly "type": "direct" } -export const DirectCaller = Schema.Struct({ "type": Schema.Literal("direct").annotate({ "title": "Type" }) }).annotate({ - "title": "DirectCaller", - "description": "Tool invocation directly from the model." +}).annotate({ + "title": "ResponseTextEditorCodeExecutionCreateResultBlock", + "identifier": "BetaResponseTextEditorCodeExecutionCreateResultBlock" }) -export type EffortLevel = "low" | "medium" | "high" | "max" -export const EffortLevel = Schema.Literals(["low", "medium", "high", "max"]).annotate({ - "title": "EffortLevel", - "description": "All possible effort levels." -}) -export type ExpiredResult = { readonly "type": "expired" } -export const ExpiredResult = Schema.Struct({ - "type": Schema.Literal("expired").annotate({ "title": "Type", "default": "expired" }) -}).annotate({ "title": "ExpiredResult" }) -export type FileDeleteResponse = { readonly "id": string; readonly "type"?: "file_deleted" } -export const FileDeleteResponse = Schema.Struct({ - "id": Schema.String.annotate({ "title": "Id", "description": "ID of the deleted file." }), - "type": Schema.optionalKey( - Schema.Literal("file_deleted").annotate({ - "title": "Type", - "description": "Deleted object type.\n\nFor file deletion, this is always `\"file_deleted\"`.", - "default": "file_deleted" +export type BetaResponseTextEditorCodeExecutionStrReplaceResultBlock = { + readonly "lines": ReadonlyArray | null + readonly "new_lines": number | null + readonly "new_start": number | null + readonly "old_lines": number | null + readonly "old_start": number | null + readonly "type": "text_editor_code_execution_str_replace_result" +} +export const BetaResponseTextEditorCodeExecutionStrReplaceResultBlock = Schema.Struct({ + "lines": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Lines", "default": null }), + "new_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "New Lines", "default": null }), + "new_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "New Start", "default": null }), + "old_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Old Lines", "default": null }), + "old_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "title": "Old Start", "default": null }), + "type": Schema.Literal("text_editor_code_execution_str_replace_result").annotate({ + "title": "Type", + "default": "text_editor_code_execution_str_replace_result" + }) +}).annotate({ + "title": "ResponseTextEditorCodeExecutionStrReplaceResultBlock", + "identifier": "BetaResponseTextEditorCodeExecutionStrReplaceResultBlock" +}) +export type BetaResponseToolReferenceBlock = { readonly "tool_name": string; readonly "type": "tool_reference" } +export const BetaResponseToolReferenceBlock = Schema.Struct({ + "tool_name": Schema.String.annotate({ "title": "Tool Name" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,256}$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]{1,256}$" }) - ) -}).annotate({ "title": "FileDeleteResponse" }) -export type FileMetadataSchema = { - readonly "created_at": string - readonly "downloadable"?: boolean - readonly "filename": string + ), + "type": Schema.Literal("tool_reference").annotate({ "title": "Type", "default": "tool_reference" }) +}).annotate({ "title": "ResponseToolReferenceBlock", "identifier": "BetaResponseToolReferenceBlock" }) +export type BetaResponseMCPToolUseBlock = { readonly "id": string - readonly "mime_type": string - readonly "size_bytes": number - readonly "type": "file" + readonly "input": { readonly [x: string]: Schema.Json } + readonly "name": string + readonly "server_name": string + readonly "type": "mcp_tool_use" } -export const FileMetadataSchema = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "RFC 3339 datetime string representing when the file was created.", - "format": "date-time" - }), - "downloadable": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Downloadable", - "description": "Whether the file can be downloaded.", - "default": false +export const BetaResponseMCPToolUseBlock = Schema.Struct({ + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), - "filename": Schema.String.annotate({ "title": "Filename", "description": "Original filename of the uploaded file." }) - .check(Schema.isMinLength(1)).check(Schema.isMaxLength(500)), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" }), - "mime_type": Schema.String.annotate({ "title": "Mime Type", "description": "MIME type of the file." }).check( - Schema.isMinLength(1) - ).check(Schema.isMaxLength(255)), - "size_bytes": Schema.Number.annotate({ "title": "Size Bytes", "description": "Size of the file in bytes." }).check( - Schema.isInt() - ).check(Schema.isGreaterThanOrEqualTo(0)), - "type": Schema.Literal("file").annotate({ - "title": "Type", - "description": "Object type.\n\nFor files, this is always `\"file\"`." - }) -}).annotate({ "title": "FileMetadataSchema" }) -export type GatewayTimeoutError = { readonly "message": string; readonly "type": "timeout_error" } -export const GatewayTimeoutError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Request timeout" }), - "type": Schema.Literal("timeout_error").annotate({ "title": "Type", "default": "timeout_error" }) -}).annotate({ "title": "GatewayTimeoutError" }) -export type GetSkillResponse = { - readonly "created_at": string - readonly "display_title": string | null - readonly "id": string - readonly "latest_version": string | null - readonly "source": string - readonly "type": string - readonly "updated_at": string + "name": Schema.String.annotate({ "title": "Name", "description": "The name of the MCP tool" }), + "server_name": Schema.String.annotate({ "title": "Server Name", "description": "The name of the MCP server" }), + "type": Schema.Literal("mcp_tool_use").annotate({ "title": "Type", "default": "mcp_tool_use" }) +}).annotate({ "title": "ResponseMCPToolUseBlock", "identifier": "BetaResponseMCPToolUseBlock" }) +export type BetaResponseContainerUploadBlock = { readonly "file_id": string; readonly "type": "container_upload" } +export const BetaResponseContainerUploadBlock = Schema.Struct({ + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("container_upload").annotate({ "title": "Type", "default": "container_upload" }) +}).annotate({ + "title": "ResponseContainerUploadBlock", + "description": "Response model for a file uploaded to the container.", + "identifier": "BetaResponseContainerUploadBlock" +}) +export type BetaResponseCompactionBlock = { + readonly "content": string | null + readonly "encrypted_content": string | null + readonly "type": "compaction" } -export const GetSkillResponse = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill was created." - }), - "display_title": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Display Title", - "description": - "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." +export const BetaResponseCompactionBlock = Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Content", + "description": "Summary of compacted content, or null if compaction failed" }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." + "encrypted_content": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Encrypted Content", + "description": "Opaque metadata from prior compaction, to be round-tripped verbatim", + "default": null }), - "latest_version": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Latest Version", + "type": Schema.Literal("compaction").annotate({ "title": "Type", "default": "compaction" }) +}).annotate({ + "title": "ResponseCompactionBlock", + "description": + "A compaction block returned when autocompact is triggered.\n\nWhen content is None, it indicates the compaction failed to produce a valid\nsummary (e.g., malformed output from the model). Clients may round-trip\ncompaction blocks with null content; the server treats them as no-ops.", + "identifier": "BetaResponseCompactionBlock" +}) +export type BetaRefusalCategory = "cyber" | "bio" | "frontier_llm" | "reasoning_extraction" | "general_harms" +export const BetaRefusalCategory = Schema.Literals([ + "cyber", + "bio", + "frontier_llm", + "reasoning_extraction", + "general_harms" +]).annotate({ + "title": "RefusalCategory", + "description": "The policy category that triggered a refusal.", + "identifier": "BetaRefusalCategory" +}) +export type BetaStopReason = + | "end_turn" + | "max_tokens" + | "stop_sequence" + | "tool_use" + | "pause_turn" + | "compaction" + | "refusal" + | "model_context_window_exceeded" +export const BetaStopReason = Schema.Literals([ + "end_turn", + "max_tokens", + "stop_sequence", + "tool_use", + "pause_turn", + "compaction", + "refusal", + "model_context_window_exceeded" +]).annotate({ "identifier": "BetaStopReason" }) +export type BetaCacheCreation = { + readonly "ephemeral_1h_input_tokens": number + readonly "ephemeral_5m_input_tokens": number +} +export const BetaCacheCreation = Schema.Struct({ + "ephemeral_1h_input_tokens": Schema.Number.annotate({ + "title": "Ephemeral 1H Input Tokens", + "description": "The number of input tokens used to create the 1 hour cache entry.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "ephemeral_5m_input_tokens": Schema.Number.annotate({ + "title": "Ephemeral 5M Input Tokens", + "description": "The number of input tokens used to create the 5 minute cache entry.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) +}).annotate({ "title": "CacheCreation", "identifier": "BetaCacheCreation" }) +export type BetaFallbackCreditRedeemed = { readonly "type": "redeemed" } +export const BetaFallbackCreditRedeemed = Schema.Struct({ + "type": Schema.Literal("redeemed").annotate({ "title": "Type", "default": "redeemed" }) +}).annotate({ + "title": "FallbackCreditRedeemed", + "description": + "The reprice was applied: the retry is billed as if the conversation\nhad been on the retry model all along.", + "identifier": "BetaFallbackCreditRedeemed" +}) +export type BetaFallbackCreditNotApplied = { + readonly "reason": + | "body_mismatch" + | "continuation_excluded" + | "continuation_only" + | "expired" + | "invalid_target_model" + | "not_enabled" + | "reprice_unavailable" + | "temporarily_unavailable" + | "variant_fields_present" + | "wrong_organization" + | "wrong_platform" + | "wrong_workspace" + readonly "remove_to_redeem"?: ReadonlyArray | null + readonly "type": "not_applied" +} +export const BetaFallbackCreditNotApplied = Schema.Struct({ + "reason": Schema.Literals([ + "body_mismatch", + "continuation_excluded", + "continuation_only", + "expired", + "invalid_target_model", + "not_enabled", + "reprice_unavailable", + "temporarily_unavailable", + "variant_fields_present", + "wrong_organization", + "wrong_platform", + "wrong_workspace" + ]).annotate({ + "title": "Reason", "description": - "The latest version identifier for the skill.\n\nThis represents the most recent version of the skill that has been created." + "Why the reprice was not applied.\n\nA closed enum; additions to the redemption-check vocabulary arrive as\ndeliberate schema updates." }), - "source": Schema.String.annotate({ - "title": "Source", + "remove_to_redeem": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Remove To Redeem", + "description": + "Request fields to remove before retrying, so the retry can redeem this\ntoken.\n\nPresent exactly when `reason` is `variant_fields_present` — never null,\nnever an empty array; absent otherwise. Fields are named only from your own request, and only after\nthe sealed variant hash matched. A served best-effort retry has already\nbeen billed at normal price; nothing redeems retroactively, but a corrected\nre-send inside the token's five-minute window can still redeem.", + "default": null + }) + ), + "type": Schema.Literal("not_applied").annotate({ "title": "Type", "default": "not_applied" }) +}).annotate({ + "title": "FallbackCreditNotApplied", + "description": "No reprice was applied; ``reason`` says why.", + "identifier": "BetaFallbackCreditNotApplied" +}) +export type BetaOutputTokensDetails = { readonly "thinking_tokens": number } +export const BetaOutputTokensDetails = Schema.Struct({ + "thinking_tokens": Schema.Number.annotate({ + "title": "Thinking Tokens", "description": - "Source of the skill.\n\nThis may be one of the following values:\n* `\"custom\"`: the skill was created by a user\n* `\"anthropic\"`: the skill was created by Anthropic" - }), - "type": Schema.String.annotate({ + "Number of output tokens the model generated as internal reasoning, including\nthe thinking-block delimiter tokens.\n\nReflects the raw reasoning the model produced, not the (possibly shorter)\nsummarized thinking text returned in the response body. Computed by\nre-tokenizing the raw reasoning text, so it may differ from the model's exact\ngeneration count by a small number of tokens. Always ≤ `output_tokens`;\n`output_tokens - thinking_tokens` approximates the non-reasoning output.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) +}).annotate({ "title": "OutputTokensDetails", "identifier": "BetaOutputTokensDetails" }) +export type BetaServerToolUsage = { readonly "web_fetch_requests": number; readonly "web_search_requests": number } +export const BetaServerToolUsage = Schema.Struct({ + "web_fetch_requests": Schema.Number.annotate({ + "title": "Web Fetch Requests", + "description": "The number of web fetch tool requests.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "web_search_requests": Schema.Number.annotate({ + "title": "Web Search Requests", + "description": "The number of web search tool requests.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) +}).annotate({ "title": "ServerToolUsage", "identifier": "BetaServerToolUsage" }) +export type BetaCacheMissModelChanged = { + readonly "cache_missed_input_tokens": number + readonly "type": "model_changed" +} +export const BetaCacheMissModelChanged = Schema.Struct({ + "cache_missed_input_tokens": Schema.Number.annotate({ + "title": "Cache Missed Input Tokens", + "description": + "Approximate number of input tokens that would have been read from cache had the prefix matched the previous request." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("model_changed").annotate({ "title": "Type", "default": "model_changed" }) +}).annotate({ "title": "CacheMissModelChanged", "identifier": "BetaCacheMissModelChanged" }) +export type BetaCacheMissSystemChanged = { + readonly "cache_missed_input_tokens": number + readonly "type": "system_changed" +} +export const BetaCacheMissSystemChanged = Schema.Struct({ + "cache_missed_input_tokens": Schema.Number.annotate({ + "title": "Cache Missed Input Tokens", + "description": + "Approximate number of input tokens that would have been read from cache had the prefix matched the previous request." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("system_changed").annotate({ "title": "Type", "default": "system_changed" }) +}).annotate({ "title": "CacheMissSystemChanged", "identifier": "BetaCacheMissSystemChanged" }) +export type BetaCacheMissToolsChanged = { + readonly "cache_missed_input_tokens": number + readonly "type": "tools_changed" +} +export const BetaCacheMissToolsChanged = Schema.Struct({ + "cache_missed_input_tokens": Schema.Number.annotate({ + "title": "Cache Missed Input Tokens", + "description": + "Approximate number of input tokens that would have been read from cache had the prefix matched the previous request." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("tools_changed").annotate({ "title": "Type", "default": "tools_changed" }) +}).annotate({ "title": "CacheMissToolsChanged", "identifier": "BetaCacheMissToolsChanged" }) +export type BetaCacheMissMessagesChanged = { + readonly "cache_missed_input_tokens": number + readonly "type": "messages_changed" +} +export const BetaCacheMissMessagesChanged = Schema.Struct({ + "cache_missed_input_tokens": Schema.Number.annotate({ + "title": "Cache Missed Input Tokens", + "description": + "Approximate number of input tokens that would have been read from cache had the prefix matched the previous request." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("messages_changed").annotate({ "title": "Type", "default": "messages_changed" }) +}).annotate({ "title": "CacheMissMessagesChanged", "identifier": "BetaCacheMissMessagesChanged" }) +export type BetaCacheMissPreviousMessageNotFound = { readonly "type": "previous_message_not_found" } +export const BetaCacheMissPreviousMessageNotFound = Schema.Struct({ + "type": Schema.Literal("previous_message_not_found").annotate({ "title": "Type", - "description": "Object type.\n\nFor Skills, this is always `\"skill\"`.", - "default": "skill" - }), - "updated_at": Schema.String.annotate({ - "title": "Updated At", - "description": "ISO 8601 timestamp of when the skill was last updated." + "default": "previous_message_not_found" }) -}).annotate({ "title": "GetSkillResponse" }) -export type GetSkillVersionResponse = { - readonly "created_at": string - readonly "description": string - readonly "directory": string - readonly "id": string - readonly "name": string - readonly "skill_id": string - readonly "type": string - readonly "version": string +}).annotate({ "title": "CacheMissPreviousMessageNotFound", "identifier": "BetaCacheMissPreviousMessageNotFound" }) +export type BetaCacheMissUnavailable = { readonly "type": "unavailable" } +export const BetaCacheMissUnavailable = Schema.Struct({ + "type": Schema.Literal("unavailable").annotate({ "title": "Type", "default": "unavailable" }) +}).annotate({ "title": "CacheMissUnavailable", "identifier": "BetaCacheMissUnavailable" }) +export type BetaResponseClearToolUses20250919Edit = { + readonly "cleared_input_tokens": number + readonly "cleared_tool_uses": number + readonly "type": "clear_tool_uses_20250919" } -export const GetSkillVersionResponse = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill version was created." +export const BetaResponseClearToolUses20250919Edit = Schema.Struct({ + "cleared_input_tokens": Schema.Number.annotate({ + "title": "Cleared Input Tokens", + "description": "Number of input tokens cleared by this edit." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "cleared_tool_uses": Schema.Number.annotate({ + "title": "Cleared Tool Uses", + "description": "Number of tool uses that were cleared." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "type": Schema.Literal("clear_tool_uses_20250919").annotate({ + "title": "Type", + "description": "The type of context management edit applied.", + "default": "clear_tool_uses_20250919" + }) +}).annotate({ "title": "ResponseClearToolUses20250919Edit", "identifier": "BetaResponseClearToolUses20250919Edit" }) +export type BetaResponseClearThinking20251015Edit = { + readonly "cleared_input_tokens": number + readonly "cleared_thinking_turns": number + readonly "type": "clear_thinking_20251015" +} +export const BetaResponseClearThinking20251015Edit = Schema.Struct({ + "cleared_input_tokens": Schema.Number.annotate({ + "title": "Cleared Input Tokens", + "description": "Number of input tokens cleared by this edit." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "cleared_thinking_turns": Schema.Number.annotate({ + "title": "Cleared Thinking Turns", + "description": "Number of thinking turns that were cleared." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "type": Schema.Literal("clear_thinking_20251015").annotate({ + "title": "Type", + "description": "The type of context management edit applied.", + "default": "clear_thinking_20251015" + }) +}).annotate({ "title": "ResponseClearThinking20251015Edit", "identifier": "BetaResponseClearThinking20251015Edit" }) +export type BetaSkill = { + readonly "skill_id": string + readonly "type": "anthropic" | "custom" + readonly "version": string +} +export const BetaSkill = Schema.Struct({ + "skill_id": Schema.String.annotate({ "title": "Skill Id", "description": "Skill ID" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "type": Schema.Literals(["anthropic", "custom"]).annotate({ + "title": "Type", + "description": "Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)" }), - "description": Schema.String.annotate({ - "title": "Description", - "description": "Description of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + "version": Schema.String.annotate({ + "title": "Version", + "description": "Skill version or 'latest' for most recent version" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ) +}).annotate({ + "title": "Skill", + "description": "A skill that was loaded in a container (response model).", + "identifier": "BetaSkill" +}) +export type BetaInvalidRequestError = { readonly "message": string; readonly "type": "invalid_request_error" } +export const BetaInvalidRequestError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Invalid request" }), + "type": Schema.Literal("invalid_request_error").annotate({ "title": "Type", "default": "invalid_request_error" }) +}).annotate({ "title": "InvalidRequestError", "identifier": "BetaInvalidRequestError" }) +export type BetaAuthenticationError = { readonly "message": string; readonly "type": "authentication_error" } +export const BetaAuthenticationError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Authentication error" }), + "type": Schema.Literal("authentication_error").annotate({ "title": "Type", "default": "authentication_error" }) +}).annotate({ "title": "AuthenticationError", "identifier": "BetaAuthenticationError" }) +export type BetaBillingError = { readonly "message": string; readonly "type": "billing_error" } +export const BetaBillingError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Billing error" }), + "type": Schema.Literal("billing_error").annotate({ "title": "Type", "default": "billing_error" }) +}).annotate({ "title": "BillingError", "identifier": "BetaBillingError" }) +export type BetaPermissionError = { readonly "message": string; readonly "type": "permission_error" } +export const BetaPermissionError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Permission denied" }), + "type": Schema.Literal("permission_error").annotate({ "title": "Type", "default": "permission_error" }) +}).annotate({ "title": "PermissionError", "identifier": "BetaPermissionError" }) +export type BetaNotFoundError = { readonly "message": string; readonly "type": "not_found_error" } +export const BetaNotFoundError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Not found" }), + "type": Schema.Literal("not_found_error").annotate({ "title": "Type", "default": "not_found_error" }) +}).annotate({ "title": "NotFoundError", "identifier": "BetaNotFoundError" }) +export type BetaRateLimitError = { readonly "message": string; readonly "type": "rate_limit_error" } +export const BetaRateLimitError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Rate limited" }), + "type": Schema.Literal("rate_limit_error").annotate({ "title": "Type", "default": "rate_limit_error" }) +}).annotate({ "title": "RateLimitError", "identifier": "BetaRateLimitError" }) +export type BetaGatewayTimeoutError = { readonly "message": string; readonly "type": "timeout_error" } +export const BetaGatewayTimeoutError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Request timeout" }), + "type": Schema.Literal("timeout_error").annotate({ "title": "Type", "default": "timeout_error" }) +}).annotate({ "title": "GatewayTimeoutError", "identifier": "BetaGatewayTimeoutError" }) +export type BetaAPIError = { readonly "message": string; readonly "type": "api_error" } +export const BetaAPIError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Internal server error" }), + "type": Schema.Literal("api_error").annotate({ "title": "Type", "default": "api_error" }) +}).annotate({ "title": "APIError", "identifier": "BetaAPIError" }) +export type BetaOverloadedError = { readonly "message": string; readonly "type": "overloaded_error" } +export const BetaOverloadedError = Schema.Struct({ + "message": Schema.String.annotate({ "title": "Message", "default": "Overloaded" }), + "type": Schema.Literal("overloaded_error").annotate({ "title": "Type", "default": "overloaded_error" }) +}).annotate({ "title": "OverloadedError", "identifier": "BetaOverloadedError" }) +export type BetaCapabilitySupport = { readonly "supported": boolean } +export const BetaCapabilitySupport = Schema.Struct({ + "supported": Schema.Boolean.annotate({ + "title": "Supported", + "description": "Whether this capability is supported by the model." + }) +}).annotate({ + "title": "CapabilitySupport", + "description": "Indicates whether a capability is supported.", + "identifier": "BetaCapabilitySupport" +}) +export type BetaRequestCounts = { + readonly "canceled": number + readonly "errored": number + readonly "expired": number + readonly "processing": number + readonly "succeeded": number +} +export const BetaRequestCounts = Schema.Struct({ + "canceled": Schema.Number.annotate({ + "title": "Canceled", + "description": + "Number of requests in the Message Batch that have been canceled.\n\nThis is zero until processing of the entire Message Batch has ended.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "errored": Schema.Number.annotate({ + "title": "Errored", + "description": + "Number of requests in the Message Batch that encountered an error.\n\nThis is zero until processing of the entire Message Batch has ended.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "expired": Schema.Number.annotate({ + "title": "Expired", + "description": + "Number of requests in the Message Batch that have expired.\n\nThis is zero until processing of the entire Message Batch has ended.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "processing": Schema.Number.annotate({ + "title": "Processing", + "description": "Number of requests in the Message Batch that are processing.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "succeeded": Schema.Number.annotate({ + "title": "Succeeded", + "description": + "Number of requests in the Message Batch that have completed successfully.\n\nThis is zero until processing of the entire Message Batch has ended.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "title": "RequestCounts", "identifier": "BetaRequestCounts" }) +export type BetaDeleteMessageBatchResponse = { readonly "id": string; readonly "type": "message_batch_deleted" } +export const BetaDeleteMessageBatchResponse = Schema.Struct({ + "id": Schema.String.annotate({ "title": "Id", "description": "ID of the Message Batch." }), + "type": Schema.Literal("message_batch_deleted").annotate({ + "title": "Type", + "description": "Deleted object type.\n\nFor Message Batches, this is always `\"message_batch_deleted\"`.", + "default": "message_batch_deleted" + }) +}).annotate({ "title": "DeleteMessageBatchResponse", "identifier": "BetaDeleteMessageBatchResponse" }) +export type BetaContextManagementResponse = { readonly "original_input_tokens": number } +export const BetaContextManagementResponse = Schema.Struct({ + "original_input_tokens": Schema.Number.annotate({ + "title": "Original Input Tokens", + "description": "The original token count before context management was applied" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "title": "ContextManagementResponse", "identifier": "BetaContextManagementResponse" }) +export type BetaFileScope = { readonly "id": string; readonly "type": "session" } +export const BetaFileScope = Schema.Struct({ + "id": Schema.String.annotate({ + "title": "Id", + "description": "The ID of the scoping resource (e.g., the session ID)." }), - "directory": Schema.String.annotate({ - "title": "Directory", + "type": Schema.Literal("session").annotate({ + "title": "Type", + "description": "The type of scope (e.g., `\"session\"`)." + }) +}).annotate({ "title": "FileScope", "identifier": "BetaFileScope" }) +export type BetaFileDeleteResponse = { readonly "id": string; readonly "type"?: "file_deleted" } +export const BetaFileDeleteResponse = Schema.Struct({ + "id": Schema.String.annotate({ "title": "Id", "description": "ID of the deleted file." }), + "type": Schema.optionalKey( + Schema.Literal("file_deleted").annotate({ + "title": "Type", + "description": "Deleted object type.\n\nFor file deletion, this is always `\"file_deleted\"`.", + "default": "file_deleted" + }) + ) +}).annotate({ "title": "FileDeleteResponse", "identifier": "BetaFileDeleteResponse" }) +export type Betaapi__schemas__skills__Skill = { + readonly "created_at": string + readonly "display_title": string | null + readonly "id": string + readonly "latest_version": string | null + readonly "source": string + readonly "type": string + readonly "updated_at": string +} +export const Betaapi__schemas__skills__Skill = Schema.Struct({ + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": "ISO 8601 timestamp of when the skill was created." + }), + "display_title": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Display Title", "description": - "Directory name of the skill version.\n\nThis is the top-level directory name that was extracted from the uploaded files." + "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." }), "id": Schema.String.annotate({ "title": "Id", - "description": "Unique identifier for the skill version.\n\nThe format and length of IDs may change over time." + "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." }), - "name": Schema.String.annotate({ - "title": "Name", + "latest_version": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Latest Version", "description": - "Human-readable name of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + "The latest version identifier for the skill.\n\nThis represents the most recent version of the skill that has been created." }), - "skill_id": Schema.String.annotate({ - "title": "Skill Id", - "description": "Identifier for the skill that this version belongs to." + "source": Schema.String.annotate({ + "title": "Source", + "description": + "Source of the skill.\n\nThis may be one of the following values:\n* `\"custom\"`: the skill was created by a user\n* `\"anthropic\"`: the skill was created by Anthropic" }), "type": Schema.String.annotate({ "title": "Type", - "description": "Object type.\n\nFor Skill Versions, this is always `\"skill_version\"`.", - "default": "skill_version" + "description": "Object type.\n\nFor Skills, this is always `\"skill\"`.", + "default": "skill" }), - "version": Schema.String.annotate({ - "title": "Version", - "description": - "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." + "updated_at": Schema.String.annotate({ + "title": "Updated At", + "description": "ISO 8601 timestamp of when the skill was last updated." }) -}).annotate({ "title": "GetSkillVersionResponse" }) -export type InputJsonContentBlockDelta = { readonly "partial_json": string; readonly "type": "input_json_delta" } -export const InputJsonContentBlockDelta = Schema.Struct({ - "partial_json": Schema.String.annotate({ "title": "Partial Json" }), - "type": Schema.Literal("input_json_delta").annotate({ "title": "Type", "default": "input_json_delta" }) -}).annotate({ "title": "InputJsonContentBlockDelta" }) -export type InvalidRequestError = { readonly "message": string; readonly "type": "invalid_request_error" } -export const InvalidRequestError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Invalid request" }), - "type": Schema.Literal("invalid_request_error").annotate({ "title": "Type", "default": "invalid_request_error" }) -}).annotate({ "title": "InvalidRequestError" }) -export type JsonOutputFormat = { - readonly "schema": { readonly [x: string]: Schema.Json } - readonly "type": "json_schema" +}).annotate({ "title": "Skill", "identifier": "Betaapi__schemas__skills__Skill" }) +export type BetaBody_create_skill_v1_skills_post = { + readonly "files": ReadonlyArray + readonly "display_title"?: string | null } -export const JsonOutputFormat = Schema.Struct({ - "schema": Schema.Record(Schema.String, Schema.Json).annotate({ - "title": "Schema", - "description": "The JSON schema of the format" +export const BetaBody_create_skill_v1_skills_post = Schema.Struct({ + "files": Schema.Array(Schema.String.annotate({ "format": "binary" })).annotate({ + "title": "Files", + "description": + "Files to upload for the skill.\n\nAll files must be in the same top-level directory and must include a SKILL.md file at the root of that directory." }), - "type": Schema.Literal("json_schema").annotate({ "title": "Type" }) -}).annotate({ "title": "JsonOutputFormat" }) -export type JsonValue = unknown -export const JsonValue = Schema.Unknown -export type MessageBatch = { - readonly "archived_at": string | null - readonly "cancel_initiated_at": string | null + "display_title": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Display Title", + "description": + "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." + }) + ) +}).annotate({ "title": "Body_create_skill_v1_skills_post", "identifier": "BetaBody_create_skill_v1_skills_post" }) +export type BetaCreateSkillResponse = { readonly "created_at": string - readonly "ended_at": string | null - readonly "expires_at": string + readonly "display_title": string | null readonly "id": string - readonly "processing_status": "in_progress" | "canceling" | "ended" - readonly "request_counts": { - readonly "canceled": number - readonly "errored": number - readonly "expired": number - readonly "processing": number - readonly "succeeded": number - } - readonly "results_url": string | null - readonly "type": "message_batch" + readonly "latest_version": string | null + readonly "source": string + readonly "type": string + readonly "updated_at": string } -export const MessageBatch = Schema.Struct({ - "archived_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ - "title": "Archived At", - "description": - "RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable." - }), - "cancel_initiated_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ - "title": "Cancel Initiated At", - "description": - "RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated." - }), +export const BetaCreateSkillResponse = Schema.Struct({ "created_at": Schema.String.annotate({ "title": "Created At", - "description": "RFC 3339 datetime string representing the time at which the Message Batch was created.", - "format": "date-time" - }), - "ended_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ - "title": "Ended At", - "description": - "RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.\n\nProcessing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired." + "description": "ISO 8601 timestamp of when the skill was created." }), - "expires_at": Schema.String.annotate({ - "title": "Expires At", + "display_title": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Display Title", "description": - "RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.", - "format": "date-time" + "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." }), "id": Schema.String.annotate({ "title": "Id", - "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." - }), - "processing_status": Schema.Literals(["in_progress", "canceling", "ended"]).annotate({ - "title": "Processing Status", - "description": "Processing status of the Message Batch." + "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." }), - "request_counts": Schema.Struct({ - "canceled": Schema.Number.annotate({ - "title": "Canceled", - "description": - "Number of requests in the Message Batch that have been canceled.\n\nThis is zero until processing of the entire Message Batch has ended.", - "default": 0 - }).check(Schema.isInt()), - "errored": Schema.Number.annotate({ - "title": "Errored", - "description": - "Number of requests in the Message Batch that encountered an error.\n\nThis is zero until processing of the entire Message Batch has ended.", - "default": 0 - }).check(Schema.isInt()), - "expired": Schema.Number.annotate({ - "title": "Expired", - "description": - "Number of requests in the Message Batch that have expired.\n\nThis is zero until processing of the entire Message Batch has ended.", - "default": 0 - }).check(Schema.isInt()), - "processing": Schema.Number.annotate({ - "title": "Processing", - "description": "Number of requests in the Message Batch that are processing.", - "default": 0 - }).check(Schema.isInt()), - "succeeded": Schema.Number.annotate({ - "title": "Succeeded", - "description": - "Number of requests in the Message Batch that have completed successfully.\n\nThis is zero until processing of the entire Message Batch has ended.", - "default": 0 - }).check(Schema.isInt()) - }).annotate({ - "title": "RequestCounts", + "latest_version": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Latest Version", "description": - "Tallies requests within the Message Batch, categorized by their status.\n\nRequests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch." + "The latest version identifier for the skill.\n\nThis represents the most recent version of the skill that has been created." }), - "results_url": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Results Url", + "source": Schema.String.annotate({ + "title": "Source", "description": - "URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.\n\nResults in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests." + "Source of the skill.\n\nThis may be one of the following values:\n* `\"custom\"`: the skill was created by a user\n* `\"anthropic\"`: the skill was created by Anthropic" }), - "type": Schema.Literal("message_batch").annotate({ + "type": Schema.String.annotate({ "title": "Type", - "description": "Object type.\n\nFor Message Batches, this is always `\"message_batch\"`.", - "default": "message_batch" + "description": "Object type.\n\nFor Skills, this is always `\"skill\"`.", + "default": "skill" + }), + "updated_at": Schema.String.annotate({ + "title": "Updated At", + "description": "ISO 8601 timestamp of when the skill was last updated." }) -}).annotate({ "title": "MessageBatch" }) -export type MessageStopEvent = { readonly "type": "message_stop" } -export const MessageStopEvent = Schema.Struct({ - "type": Schema.Literal("message_stop").annotate({ "title": "Type", "default": "message_stop" }) -}).annotate({ "title": "MessageStopEvent" }) -export type ModelInfo = { +}).annotate({ "title": "CreateSkillResponse", "identifier": "BetaCreateSkillResponse" }) +export type BetaGetSkillResponse = { readonly "created_at": string - readonly "display_name": string + readonly "display_title": string | null readonly "id": string - readonly "type": "model" + readonly "latest_version": string | null + readonly "source": string + readonly "type": string + readonly "updated_at": string } -export const ModelInfo = Schema.Struct({ +export const BetaGetSkillResponse = Schema.Struct({ "created_at": Schema.String.annotate({ "title": "Created At", + "description": "ISO 8601 timestamp of when the skill was created." + }), + "display_title": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Display Title", "description": - "RFC 3339 datetime string representing the time at which the model was released. May be set to an epoch value if the release date is unknown.", - "format": "date-time" + "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." }), - "display_name": Schema.String.annotate({ - "title": "Display Name", - "description": "A human-readable name for the model." + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." }), - "id": Schema.String.annotate({ "title": "Id", "description": "Unique model identifier." }), - "type": Schema.Literal("model").annotate({ + "latest_version": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Latest Version", + "description": + "The latest version identifier for the skill.\n\nThis represents the most recent version of the skill that has been created." + }), + "source": Schema.String.annotate({ + "title": "Source", + "description": + "Source of the skill.\n\nThis may be one of the following values:\n* `\"custom\"`: the skill was created by a user\n* `\"anthropic\"`: the skill was created by Anthropic" + }), + "type": Schema.String.annotate({ "title": "Type", - "description": "Object type.\n\nFor Models, this is always `\"model\"`.", - "default": "model" + "description": "Object type.\n\nFor Skills, this is always `\"skill\"`.", + "default": "skill" + }), + "updated_at": Schema.String.annotate({ + "title": "Updated At", + "description": "ISO 8601 timestamp of when the skill was last updated." }) -}).annotate({ "title": "ModelInfo" }) -export type NotFoundError = { readonly "message": string; readonly "type": "not_found_error" } -export const NotFoundError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Not found" }), - "type": Schema.Literal("not_found_error").annotate({ "title": "Type", "default": "not_found_error" }) -}).annotate({ "title": "NotFoundError" }) -export type OverloadedError = { readonly "message": string; readonly "type": "overloaded_error" } -export const OverloadedError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Overloaded" }), - "type": Schema.Literal("overloaded_error").annotate({ "title": "Type", "default": "overloaded_error" }) -}).annotate({ "title": "OverloadedError" }) -export type PermissionError = { readonly "message": string; readonly "type": "permission_error" } -export const PermissionError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Permission denied" }), - "type": Schema.Literal("permission_error").annotate({ "title": "Type", "default": "permission_error" }) -}).annotate({ "title": "PermissionError" }) -export type PlainTextSource = { readonly "data": string; readonly "media_type": "text/plain"; readonly "type": "text" } -export const PlainTextSource = Schema.Struct({ - "data": Schema.String.annotate({ "title": "Data" }), - "media_type": Schema.Literal("text/plain").annotate({ "title": "Media Type" }), - "type": Schema.Literal("text").annotate({ "title": "Type" }) -}).annotate({ "title": "PlainTextSource" }) -export type RateLimitError = { readonly "message": string; readonly "type": "rate_limit_error" } -export const RateLimitError = Schema.Struct({ - "message": Schema.String.annotate({ "title": "Message", "default": "Rate limited" }), - "type": Schema.Literal("rate_limit_error").annotate({ "title": "Type", "default": "rate_limit_error" }) -}).annotate({ "title": "RateLimitError" }) -export type RequestBashCodeExecutionOutputBlock = { - readonly "file_id": string - readonly "type": "bash_code_execution_output" +}).annotate({ "title": "GetSkillResponse", "identifier": "BetaGetSkillResponse" }) +export type BetaDeleteSkillResponse = { readonly "id": string; readonly "type": string } +export const BetaDeleteSkillResponse = Schema.Struct({ + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." + }), + "type": Schema.String.annotate({ + "title": "Type", + "description": "Deleted object type.\n\nFor Skills, this is always `\"skill_deleted\"`.", + "default": "skill_deleted" + }) +}).annotate({ "title": "DeleteSkillResponse", "identifier": "BetaDeleteSkillResponse" }) +export type BetaSkillVersion = { + readonly "created_at": string + readonly "description": string + readonly "directory": string + readonly "id": string + readonly "name": string + readonly "skill_id": string + readonly "type": string + readonly "version": string } -export const RequestBashCodeExecutionOutputBlock = Schema.Struct({ - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("bash_code_execution_output").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestBashCodeExecutionOutputBlock" }) -export type RequestCharLocationCitation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_char_index": number - readonly "start_char_index": number - readonly "type": "char_location" +export const BetaSkillVersion = Schema.Struct({ + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": "ISO 8601 timestamp of when the skill version was created." + }), + "description": Schema.String.annotate({ + "title": "Description", + "description": "Description of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + }), + "directory": Schema.String.annotate({ + "title": "Directory", + "description": + "Directory name of the skill version.\n\nThis is the top-level directory name that was extracted from the uploaded files." + }), + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique identifier for the skill version.\n\nThe format and length of IDs may change over time." + }), + "name": Schema.String.annotate({ + "title": "Name", + "description": + "Human-readable name of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + }), + "skill_id": Schema.String.annotate({ + "title": "Skill Id", + "description": "Identifier for the skill that this version belongs to." + }), + "type": Schema.String.annotate({ + "title": "Type", + "description": "Object type.\n\nFor Skill Versions, this is always `\"skill_version\"`.", + "default": "skill_version" + }), + "version": Schema.String.annotate({ + "title": "Version", + "description": + "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." + }) +}).annotate({ "title": "SkillVersion", "identifier": "BetaSkillVersion" }) +export type BetaBody_create_skill_version_v1_skills__skill_id__versions_post = { + readonly "files": ReadonlyArray } -export const RequestCharLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "document_title": Schema.Union([ - Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), - Schema.Null - ]).annotate({ "title": "Document Title" }), - "end_char_index": Schema.Number.annotate({ "title": "End Char Index" }).check(Schema.isInt()), - "start_char_index": Schema.Number.annotate({ "title": "Start Char Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "type": Schema.Literal("char_location").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestCharLocationCitation" }) -export type RequestCitationsConfig = { readonly "enabled"?: boolean } -export const RequestCitationsConfig = Schema.Struct({ - "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Enabled" })) -}).annotate({ "title": "RequestCitationsConfig" }) -export type RequestCodeExecutionOutputBlock = { readonly "file_id": string; readonly "type": "code_execution_output" } -export const RequestCodeExecutionOutputBlock = Schema.Struct({ - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("code_execution_output").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestCodeExecutionOutputBlock" }) -export type RequestContentBlockLocationCitation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_block_index": number - readonly "start_block_index": number - readonly "type": "content_block_location" +export const BetaBody_create_skill_version_v1_skills__skill_id__versions_post = Schema.Struct({ + "files": Schema.Array(Schema.String.annotate({ "format": "binary" })).annotate({ + "title": "Files", + "description": + "Files to upload for the skill.\n\nAll files must be in the same top-level directory and must include a SKILL.md file at the root of that directory." + }) +}).annotate({ + "title": "Body_create_skill_version_v1_skills__skill_id__versions_post", + "identifier": "BetaBody_create_skill_version_v1_skills__skill_id__versions_post" +}) +export type BetaCreateSkillVersionResponse = { + readonly "created_at": string + readonly "description": string + readonly "directory": string + readonly "id": string + readonly "name": string + readonly "skill_id": string + readonly "type": string + readonly "version": string } -export const RequestContentBlockLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "document_title": Schema.Union([ - Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), - Schema.Null - ]).annotate({ "title": "Document Title" }), - "end_block_index": Schema.Number.annotate({ "title": "End Block Index" }).check(Schema.isInt()), - "start_block_index": Schema.Number.annotate({ "title": "Start Block Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "type": Schema.Literal("content_block_location").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestContentBlockLocationCitation" }) -export type RequestPageLocationCitation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_page_number": number - readonly "start_page_number": number - readonly "type": "page_location" +export const BetaCreateSkillVersionResponse = Schema.Struct({ + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": "ISO 8601 timestamp of when the skill version was created." + }), + "description": Schema.String.annotate({ + "title": "Description", + "description": "Description of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + }), + "directory": Schema.String.annotate({ + "title": "Directory", + "description": + "Directory name of the skill version.\n\nThis is the top-level directory name that was extracted from the uploaded files." + }), + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique identifier for the skill version.\n\nThe format and length of IDs may change over time." + }), + "name": Schema.String.annotate({ + "title": "Name", + "description": + "Human-readable name of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + }), + "skill_id": Schema.String.annotate({ + "title": "Skill Id", + "description": "Identifier for the skill that this version belongs to." + }), + "type": Schema.String.annotate({ + "title": "Type", + "description": "Object type.\n\nFor Skill Versions, this is always `\"skill_version\"`.", + "default": "skill_version" + }), + "version": Schema.String.annotate({ + "title": "Version", + "description": + "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." + }) +}).annotate({ "title": "CreateSkillVersionResponse", "identifier": "BetaCreateSkillVersionResponse" }) +export type BetaGetSkillVersionResponse = { + readonly "created_at": string + readonly "description": string + readonly "directory": string + readonly "id": string + readonly "name": string + readonly "skill_id": string + readonly "type": string + readonly "version": string } -export const RequestPageLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "document_title": Schema.Union([ - Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), - Schema.Null - ]).annotate({ "title": "Document Title" }), - "end_page_number": Schema.Number.annotate({ "title": "End Page Number" }).check(Schema.isInt()), - "start_page_number": Schema.Number.annotate({ "title": "Start Page Number" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(1) - ), - "type": Schema.Literal("page_location").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestPageLocationCitation" }) -export type RequestSearchResultLocationCitation = { - readonly "cited_text": string - readonly "end_block_index": number - readonly "search_result_index": number - readonly "source": string - readonly "start_block_index": number - readonly "title": string | null - readonly "type": "search_result_location" -} -export const RequestSearchResultLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "end_block_index": Schema.Number.annotate({ "title": "End Block Index" }).check(Schema.isInt()), - "search_result_index": Schema.Number.annotate({ "title": "Search Result Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) +export const BetaGetSkillVersionResponse = Schema.Struct({ + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": "ISO 8601 timestamp of when the skill version was created." + }), + "description": Schema.String.annotate({ + "title": "Description", + "description": "Description of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + }), + "directory": Schema.String.annotate({ + "title": "Directory", + "description": + "Directory name of the skill version.\n\nThis is the top-level directory name that was extracted from the uploaded files." + }), + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique identifier for the skill version.\n\nThe format and length of IDs may change over time." + }), + "name": Schema.String.annotate({ + "title": "Name", + "description": + "Human-readable name of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + }), + "skill_id": Schema.String.annotate({ + "title": "Skill Id", + "description": "Identifier for the skill that this version belongs to." + }), + "type": Schema.String.annotate({ + "title": "Type", + "description": "Object type.\n\nFor Skill Versions, this is always `\"skill_version\"`.", + "default": "skill_version" + }), + "version": Schema.String.annotate({ + "title": "Version", + "description": + "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." + }) +}).annotate({ "title": "GetSkillVersionResponse", "identifier": "BetaGetSkillVersionResponse" }) +export type BetaDeleteSkillVersionResponse = { readonly "id": string; readonly "type": string } +export const BetaDeleteSkillVersionResponse = Schema.Struct({ + "id": Schema.String.annotate({ + "title": "Id", + "description": + "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." + }), + "type": Schema.String.annotate({ + "title": "Type", + "description": "Deleted object type.\n\nFor Skill Versions, this is always `\"skill_version_deleted\"`.", + "default": "skill_version_deleted" + }) +}).annotate({ "title": "DeleteSkillVersionResponse", "identifier": "BetaDeleteSkillVersionResponse" }) +export type BetaUnrestrictedNetwork = { readonly "type": "unrestricted" } +export const BetaUnrestrictedNetwork = Schema.Struct({ + "type": Schema.Literal("unrestricted").annotate({ "title": "Type", "description": "Network policy type" }) +}).annotate({ + "title": "UnrestrictedNetwork", + "description": "Unrestricted network access.", + "identifier": "BetaUnrestrictedNetwork" +}) +export type BetaLimitedNetwork = { + readonly "allow_mcp_servers": boolean + readonly "allow_package_managers": boolean + readonly "allowed_hosts": ReadonlyArray + readonly "type": "limited" +} +export const BetaLimitedNetwork = Schema.Struct({ + "allow_mcp_servers": Schema.Boolean.annotate({ + "title": "Allow Mcp Servers", + "description": + "Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array." + }), + "allow_package_managers": Schema.Boolean.annotate({ + "title": "Allow Package Managers", + "description": + "Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array." + }), + "allowed_hosts": Schema.Array(Schema.String).annotate({ + "title": "Allowed Hosts", + "description": "Specifies domains the container can reach." + }), + "type": Schema.Literal("limited").annotate({ "title": "Type", "description": "Network policy type" }) +}).annotate({ "title": "LimitedNetwork", "description": "Limited network access.", "identifier": "BetaLimitedNetwork" }) +export type BetaPackages = { + readonly "apt": ReadonlyArray + readonly "cargo": ReadonlyArray + readonly "gem": ReadonlyArray + readonly "go": ReadonlyArray + readonly "npm": ReadonlyArray + readonly "pip": ReadonlyArray + readonly "type"?: "packages" +} +export const BetaPackages = Schema.Struct({ + "apt": Schema.Array(Schema.String).annotate({ "title": "Apt", "description": "Ubuntu/Debian packages to install" }), + "cargo": Schema.Array(Schema.String).annotate({ "title": "Cargo", "description": "Rust packages to install" }), + "gem": Schema.Array(Schema.String).annotate({ "title": "Gem", "description": "Ruby packages to install" }), + "go": Schema.Array(Schema.String).annotate({ "title": "Go", "description": "Go packages to install" }), + "npm": Schema.Array(Schema.String).annotate({ "title": "Npm", "description": "Node.js packages to install" }), + "pip": Schema.Array(Schema.String).annotate({ "title": "Pip", "description": "Python packages to install" }), + "type": Schema.optionalKey( + Schema.Literal("packages").annotate({ + "title": "Type", + "description": "Package configuration type", + "default": "packages" + }) + ) +}).annotate({ + "title": "Packages", + "description": "Packages (and their versions) available in this environment.", + "identifier": "BetaPackages" +}) +export type BetaSelfHostedConfig = { readonly "type": "self_hosted" } +export const BetaSelfHostedConfig = Schema.Struct({ + "type": Schema.Literal("self_hosted").annotate({ "title": "Type", "description": "Environment type" }) +}).annotate({ + "title": "SelfHostedConfig", + "description": "Configuration for self-hosted environments.", + "identifier": "BetaSelfHostedConfig" +}) +export type BetaLimitedNetworkParams = { + readonly "allow_mcp_servers"?: boolean | null + readonly "allow_package_managers"?: boolean | null + readonly "allowed_hosts"?: ReadonlyArray | null + readonly "type": "limited" +} +export const BetaLimitedNetworkParams = Schema.Struct({ + "allow_mcp_servers": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "title": "Allow Mcp Servers", + "description": + "Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array. Defaults to `false`." + }) ), - "source": Schema.String.annotate({ "title": "Source" }), - "start_block_index": Schema.Number.annotate({ "title": "Start Block Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) + "allow_package_managers": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "title": "Allow Package Managers", + "description": + "Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array. Defaults to `false`." + }) ), - "title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Title" }), - "type": Schema.Literal("search_result_location").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestSearchResultLocationCitation" }) -export type RequestTextEditorCodeExecutionCreateResultBlock = { - readonly "is_file_update": boolean - readonly "type": "text_editor_code_execution_create_result" -} -export const RequestTextEditorCodeExecutionCreateResultBlock = Schema.Struct({ - "is_file_update": Schema.Boolean.annotate({ "title": "Is File Update" }), - "type": Schema.Literal("text_editor_code_execution_create_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionCreateResultBlock" }) -export type RequestTextEditorCodeExecutionStrReplaceResultBlock = { - readonly "lines"?: ReadonlyArray | null - readonly "new_lines"?: number | null - readonly "new_start"?: number | null - readonly "old_lines"?: number | null - readonly "old_start"?: number | null - readonly "type": "text_editor_code_execution_str_replace_result" -} -export const RequestTextEditorCodeExecutionStrReplaceResultBlock = Schema.Struct({ - "lines": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Lines" })), - "new_lines": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "New Lines" }) + "allowed_hosts": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Hosts", + "description": "Specifies domains the container can reach." + }) ), - "new_start": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "New Start" }) + "type": Schema.Literal("limited").annotate({ "title": "Type", "description": "Network policy type" }) +}).annotate({ + "title": "LimitedNetworkParams", + "description": + "Limited network request params.\n\nFields default to null; on update, omitted fields preserve the\nexisting value.", + "identifier": "BetaLimitedNetworkParams" +}) +export type BetaPackagesParams = { + readonly "apt"?: ReadonlyArray | null + readonly "cargo"?: ReadonlyArray | null + readonly "gem"?: ReadonlyArray | null + readonly "go"?: ReadonlyArray | null + readonly "npm"?: ReadonlyArray | null + readonly "pip"?: ReadonlyArray | null + readonly "type"?: "packages" +} +export const BetaPackagesParams = Schema.Struct({ + "apt": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Apt", + "description": "Ubuntu/Debian packages to install" + }) ), - "old_lines": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Old Lines" }) + "cargo": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Cargo", + "description": "Rust packages to install" + }) ), - "old_start": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Old Start" }) + "gem": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Gem", + "description": "Ruby packages to install" + }) ), - "type": Schema.Literal("text_editor_code_execution_str_replace_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionStrReplaceResultBlock" }) -export type RequestTextEditorCodeExecutionViewResultBlock = { - readonly "content": string - readonly "file_type": "text" | "image" | "pdf" - readonly "num_lines"?: number | null - readonly "start_line"?: number | null - readonly "total_lines"?: number | null - readonly "type": "text_editor_code_execution_view_result" -} -export const RequestTextEditorCodeExecutionViewResultBlock = Schema.Struct({ - "content": Schema.String.annotate({ "title": "Content" }), - "file_type": Schema.Literals(["text", "image", "pdf"]).annotate({ "title": "File Type" }), - "num_lines": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Num Lines" }) + "go": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Go", + "description": "Go packages to install" + }) ), - "start_line": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Start Line" }) + "npm": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Npm", + "description": "Node.js packages to install" + }) ), - "total_lines": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ "title": "Total Lines" }) + "pip": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Pip", + "description": "Python packages to install" + }) ), - "type": Schema.Literal("text_editor_code_execution_view_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionViewResultBlock" }) -export type RequestWebSearchResultBlock = { - readonly "encrypted_content": string - readonly "page_age"?: string | null - readonly "title": string - readonly "type": "web_search_result" - readonly "url": string -} -export const RequestWebSearchResultBlock = Schema.Struct({ - "encrypted_content": Schema.String.annotate({ "title": "Encrypted Content" }), - "page_age": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Page Age" })), - "title": Schema.String.annotate({ "title": "Title" }), - "type": Schema.Literal("web_search_result").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "RequestWebSearchResultBlock" }) -export type RequestWebSearchResultLocationCitation = { - readonly "cited_text": string - readonly "encrypted_index": string - readonly "title": string | null - readonly "type": "web_search_result_location" - readonly "url": string -} -export const RequestWebSearchResultLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "encrypted_index": Schema.String.annotate({ "title": "Encrypted Index" }), - "title": Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(512)), Schema.Null]) - .annotate({ "title": "Title" }), - "type": Schema.Literal("web_search_result_location").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url" }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(2048)) -}).annotate({ "title": "RequestWebSearchResultLocationCitation" }) -export type ResponseBashCodeExecutionOutputBlock = { - readonly "file_id": string - readonly "type": "bash_code_execution_output" -} -export const ResponseBashCodeExecutionOutputBlock = Schema.Struct({ - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("bash_code_execution_output").annotate({ + "type": Schema.optionalKey( + Schema.Literal("packages").annotate({ + "title": "Type", + "description": "Package configuration type", + "default": "packages" + }) + ) +}).annotate({ + "title": "PackagesParams", + "description": + "Specify packages (and optionally their versions) available in this environment.\n\nWhen versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest.", + "identifier": "BetaPackagesParams" +}) +export type BetaSelfHostedConfigParams = { readonly "type": "self_hosted" } +export const BetaSelfHostedConfigParams = Schema.Struct({ + "type": Schema.Literal("self_hosted").annotate({ "title": "Type", "description": "Environment type" }) +}).annotate({ + "title": "SelfHostedConfigParams", + "description": "Request params for `self_hosted` environment configuration.", + "identifier": "BetaSelfHostedConfigParams" +}) +export type BetaEnvironmentDeleteResponse = { readonly "id": string; readonly "type": "environment_deleted" } +export const BetaEnvironmentDeleteResponse = Schema.Struct({ + "id": Schema.String.annotate({ "title": "Id", "description": "Environment identifier" }), + "type": Schema.Literal("environment_deleted").annotate({ "title": "Type", - "default": "bash_code_execution_output" + "description": "The type of response", + "default": "environment_deleted" }) -}).annotate({ "title": "ResponseBashCodeExecutionOutputBlock" }) -export type ResponseCharLocationCitation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_char_index": number - readonly "file_id": string | null - readonly "start_char_index": number - readonly "type": "char_location" -} -export const ResponseCharLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), - "end_char_index": Schema.Number.annotate({ "title": "End Char Index" }).check(Schema.isInt()), - "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), - "start_char_index": Schema.Number.annotate({ "title": "Start Char Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "type": Schema.Literal("char_location").annotate({ "title": "Type", "default": "char_location" }) -}).annotate({ "title": "ResponseCharLocationCitation" }) -export type ResponseCitationsConfig = { readonly "enabled": boolean } -export const ResponseCitationsConfig = Schema.Struct({ - "enabled": Schema.Boolean.annotate({ "title": "Enabled", "default": false }) -}).annotate({ "title": "ResponseCitationsConfig" }) -export type ResponseCodeExecutionOutputBlock = { readonly "file_id": string; readonly "type": "code_execution_output" } -export const ResponseCodeExecutionOutputBlock = Schema.Struct({ - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("code_execution_output").annotate({ "title": "Type", "default": "code_execution_output" }) -}).annotate({ "title": "ResponseCodeExecutionOutputBlock" }) -export type ResponseContainerUploadBlock = { readonly "file_id": string; readonly "type": "container_upload" } -export const ResponseContainerUploadBlock = Schema.Struct({ - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("container_upload").annotate({ "title": "Type", "default": "container_upload" }) }).annotate({ - "title": "ResponseContainerUploadBlock", - "description": "Response model for a file uploaded to the container." + "title": "EnvironmentDeleteResponse", + "description": "Response after deleting an environment.", + "identifier": "BetaEnvironmentDeleteResponse" }) -export type ResponseContentBlockLocationCitation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_block_index": number - readonly "file_id": string | null - readonly "start_block_index": number - readonly "type": "content_block_location" -} -export const ResponseContentBlockLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) - ), - "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), - "end_block_index": Schema.Number.annotate({ "title": "End Block Index" }).check(Schema.isInt()), - "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), - "start_block_index": Schema.Number.annotate({ "title": "Start Block Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) +export type BetaSelfHostedWorkQueueStats = { + readonly "depth": number + readonly "oldest_queued_at": string | null + readonly "pending": number + readonly "type": "work_queue_stats" + readonly "workers_polling": number | null +} +export const BetaSelfHostedWorkQueueStats = Schema.Struct({ + "depth": Schema.Number.annotate({ + "title": "Depth", + "description": "Number of work items waiting to be picked up (lag from consumer group)" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "oldest_queued_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Oldest Queued At", + "description": + "RFC 3339 timestamp of oldest item in the work stream (includes both queued and pending items), null if stream empty" + }), + "pending": Schema.Number.annotate({ + "title": "Pending", + "description": "Number of work items being processed (polled but not acknowledged)", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("work_queue_stats").annotate({ + "title": "Type", + "description": "The type of object", + "default": "work_queue_stats" + }), + "workers_polling": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ + "title": "Workers Polling", + "description": + "Number of workers that have polled for work in the last 30 seconds. Requires worker_id to be sent with poll requests." + }) +}).annotate({ + "title": "SelfHostedWorkQueueStats", + "description": + "Statistics about the work queue for an environment.\n\nUses Redis Stream consumer group metrics for O(1) queries.", + "identifier": "BetaSelfHostedWorkQueueStats" +}) +export type BetaSessionWorkData = { readonly "id": string; readonly "type": "session" } +export const BetaSessionWorkData = Schema.Struct({ + "id": Schema.String.annotate({ "title": "Id", "description": "Session identifier (e.g., 'session_...')" }), + "type": Schema.Literal("session").annotate({ "title": "Type", "description": "Type of work data" }) +}).annotate({ + "title": "SessionWorkData", + "description": + "Work data for session work items.\n\nThis resource type is used when work represents a session that needs to be executed\nin a self-hosted environment.", + "identifier": "BetaSessionWorkData" +}) +export type BetaSelfHostedWorkHeartbeatResponse = { + readonly "last_heartbeat": string + readonly "lease_extended": boolean + readonly "state": "queued" | "starting" | "active" | "stopping" | "stopped" + readonly "ttl_seconds": number + readonly "type": "work_heartbeat" +} +export const BetaSelfHostedWorkHeartbeatResponse = Schema.Struct({ + "last_heartbeat": Schema.String.annotate({ + "title": "Last Heartbeat", + "description": "RFC 3339 timestamp of the actual heartbeat from DB" + }), + "lease_extended": Schema.Boolean.annotate({ + "title": "Lease Extended", + "description": "Whether the heartbeat succeeded in extending the lease" + }), + "state": Schema.Literals(["queued", "starting", "active", "stopping", "stopped"]).annotate({ + "title": "State", + "description": "Current state of the work item (active/stopping/stopped)" + }), + "ttl_seconds": Schema.Number.annotate({ "title": "Ttl Seconds", "description": "Effective TTL applied to the lease" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("work_heartbeat").annotate({ + "title": "Type", + "description": "The type of response", + "default": "work_heartbeat" + }) +}).annotate({ + "title": "SelfHostedWorkHeartbeatResponse", + "description": "Response after recording a heartbeat for a work item.", + "identifier": "BetaSelfHostedWorkHeartbeatResponse" +}) +export type BetaSelfHostedWorkStopRequest = { readonly "force"?: boolean } +export const BetaSelfHostedWorkStopRequest = Schema.Struct({ + "force": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Force", + "description": "If true, immediately stop work without graceful shutdown", + "default": false + }) + ) +}).annotate({ + "title": "SelfHostedWorkStopRequest", + "description": "Request to stop a work item.", + "identifier": "BetaSelfHostedWorkStopRequest" +}) +export type BetaSelfHostedWorkUpdateRequest = { readonly "metadata": { readonly [x: string]: string | null } } +export const BetaSelfHostedWorkUpdateRequest = Schema.Struct({ + "metadata": Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Null])).annotate({ + "title": "Metadata", + "description": + "Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve existing metadata." + }) +}).annotate({ + "title": "SelfHostedWorkUpdateRequest", + "description": "Request to update work item metadata.", + "identifier": "BetaSelfHostedWorkUpdateRequest" +}) +export type BetaManagedAgentsMemoryView = "basic" | "full" +export const BetaManagedAgentsMemoryView = Schema.Literals(["basic", "full"]).annotate({ + "description": + "Selects which projection of a `memory` or `memory_version` the server returns. `basic` returns the object with `content` set to `null`; `full` populates `content`. When omitted, the default is endpoint-specific: retrieve operations default to `full`; list, create, and update operations default to `basic`. Listing with `view=full` caps `limit` at 20.", + "identifier": "BetaManagedAgentsMemoryView" +}) +export type BetaTimestamp = string +export const BetaTimestamp = Schema.String.annotate({ + "description": "A timestamp in RFC 3339 format", + "format": "date-time", + "identifier": "BetaTimestamp" +}) +export type BetaManagedAgentsMemoryPreconditionFailedError = { + readonly "type": "memory_precondition_failed_error" + readonly "message"?: string +} +export const BetaManagedAgentsMemoryPreconditionFailedError = Schema.Struct({ + "type": Schema.Literal("memory_precondition_failed_error"), + "message": Schema.optionalKey(Schema.String) +}).annotate({ "identifier": "BetaManagedAgentsMemoryPreconditionFailedError" }) +export type BetaManagedAgentsMemoryPathConflictError = { + readonly "type": "memory_path_conflict_error" + readonly "message"?: string + readonly "conflicting_path"?: string + readonly "conflicting_memory_id"?: string +} +export const BetaManagedAgentsMemoryPathConflictError = Schema.Struct({ + "type": Schema.Literal("memory_path_conflict_error"), + "message": Schema.optionalKey(Schema.String), + "conflicting_path": Schema.optionalKey(Schema.String), + "conflicting_memory_id": Schema.optionalKey(Schema.String) +}).annotate({ "identifier": "BetaManagedAgentsMemoryPathConflictError" }) +export type BetaManagedAgentsConflictError = { readonly "type": "conflict_error"; readonly "message"?: string } +export const BetaManagedAgentsConflictError = Schema.Struct({ + "type": Schema.Literal("conflict_error"), + "message": Schema.optionalKey(Schema.String) +}).annotate({ "identifier": "BetaManagedAgentsConflictError" }) +export type BetaManagedAgentsCreateMemoryParams = { readonly "path": string; readonly "content": string } +export const BetaManagedAgentsCreateMemoryParams = Schema.Struct({ + "path": Schema.String.annotate({ + "description": + "Hierarchical path for the new memory, e.g. `/projects/foo/notes.md`. Must start with `/`, contain at least one non-empty segment, and be at most 1,024 bytes. Must not contain empty segments, `.` or `..` segments, control or format characters, and must be NFC-normalized. Paths are case-sensitive." + }).check(Schema.isMinLength(2).annotate({ "expected": "a value with a length of at least 2" })).check( + Schema.isMaxLength(1024).annotate({ "expected": "a value with a length of at most 1024" }) ), - "type": Schema.Literal("content_block_location").annotate({ "title": "Type", "default": "content_block_location" }) -}).annotate({ "title": "ResponseContentBlockLocationCitation" }) -export type ResponsePageLocationCitation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_page_number": number - readonly "file_id": string | null - readonly "start_page_number": number - readonly "type": "page_location" + "content": Schema.String.annotate({ + "description": + "UTF-8 text content for the new memory. Maximum 100 kB (102,400 bytes). Required; pass `\"\"` explicitly to create an empty memory." + }) +}).annotate({ + "description": + "Request parameters for [Create a memory](/en/api/beta/memory_stores/memories/create). The path must be unoccupied: if a memory already exists at the path, or the path is an ancestor or descendant of an existing memory's path, the request returns `memory_path_conflict_error` (HTTP 409). Create never overwrites; to modify an existing memory, use [Update a memory](/en/api/beta/memory_stores/memories/update).", + "identifier": "BetaManagedAgentsCreateMemoryParams" +}) +export type BetaManagedAgentsPrecondition = { readonly "type": "content_sha256"; readonly "content_sha256"?: string } +export const BetaManagedAgentsPrecondition = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("content_sha256"), + "content_sha256": Schema.optionalKey(Schema.String.annotate({ + "description": + "Expected `content_sha256` of the stored memory (64 lowercase hexadecimal characters). Typically the `content_sha256` returned by a prior read or list call. Because the server applies no content normalization, clients can also compute this locally as the SHA-256 of the UTF-8 content bytes." + })) + }).annotate({ + "description": + "Optional condition that must hold for an update to apply. When omitted, the update is unconditional. Asserts the current state of the memory being updated. When an update changes `path`, the precondition still refers to the memory's current content, not the destination path. Currently the only supported variant is `content_sha256`." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsPrecondition" }) +export type BetaManagedAgentsDeletedMemory = { readonly "type": "memory_deleted"; readonly "id": string } +export const BetaManagedAgentsDeletedMemory = Schema.Struct({ + "type": Schema.Literal("memory_deleted"), + "id": Schema.String.annotate({ "description": "ID of the deleted memory (a `mem_...` value)." }) +}).annotate({ + "description": + "Tombstone returned by [Delete a memory](/en/api/beta/memory_stores/memories/delete). The memory's version history persists and remains listable via [List memory versions](/en/api/beta/memory_stores/memory_versions/list) until the store itself is deleted.", + "identifier": "BetaManagedAgentsDeletedMemory" +}) +export type BetaManagedAgentsMemoryVersionOperation = "created" | "modified" | "deleted" +export const BetaManagedAgentsMemoryVersionOperation = Schema.Literals(["created", "modified", "deleted"]).annotate({ + "description": + "The kind of mutation a `memory_version` records. Every non-no-op mutation to a memory appends exactly one version row with one of these values.", + "identifier": "BetaManagedAgentsMemoryVersionOperation" +}) +export type BetaManagedAgentsActor = { readonly "type": "session_actor"; readonly "session_id": string } | { + readonly "type": "api_actor" + readonly "api_key_id": string +} | { readonly "type": "user_actor"; readonly "user_id": string } +export const BetaManagedAgentsActor = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("session_actor"), + "session_id": Schema.String.annotate({ + "description": + "ID of the session that performed the write (a `sesn_...` value). Look up the session via [Retrieve a session](/en/api/sessions-retrieve) for further provenance." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + }).annotate({ + "description": + "Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/en/api/sessions-retrieve)." + }), + Schema.Struct({ + "type": Schema.Literal("api_actor"), + "api_key_id": Schema.String.annotate({ + "description": "ID of the API key that performed the write. This identifies the key, not the secret." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + }).annotate({ + "description": + "Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/en/api/sessions-retrieve)." + }), + Schema.Struct({ + "type": Schema.Literal("user_actor"), + "user_id": Schema.String.annotate({ "description": "ID of the user who performed the write (a `user_...` value)." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + }).annotate({ + "description": + "Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/en/api/sessions-retrieve)." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsActor" }) +export type BetaManagedAgentsCreateMemoryStoreRequest = { + readonly "name": string + readonly "description"?: string + readonly "metadata"?: { readonly [x: string]: string } } -export const ResponsePageLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "document_index": Schema.Number.annotate({ "title": "Document Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) +export const BetaManagedAgentsCreateMemoryStoreRequest = Schema.Struct({ + "name": Schema.String.annotate({ + "description": + "Human-readable name for the store. Required; 1–255 characters; no control characters. The mount-path slug under `/mnt/memory/` is derived from this name (lowercased, non-alphanumeric runs collapsed to a hyphen). Names need not be unique within a workspace." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) ), - "document_title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Document Title" }), - "end_page_number": Schema.Number.annotate({ "title": "End Page Number" }).check(Schema.isInt()), - "file_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "File Id", "default": null }), - "start_page_number": Schema.Number.annotate({ "title": "Start Page Number" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(1) + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent." + }).check(Schema.isMaxLength(1024).annotate({ "expected": "a value with a length of at most 1024" })) ), - "type": Schema.Literal("page_location").annotate({ "title": "Type", "default": "page_location" }) -}).annotate({ "title": "ResponsePageLocationCitation" }) -export type ResponseRedactedThinkingBlock = { readonly "data": string; readonly "type": "redacted_thinking" } -export const ResponseRedactedThinkingBlock = Schema.Struct({ - "data": Schema.String.annotate({ "title": "Data" }), - "type": Schema.Literal("redacted_thinking").annotate({ "title": "Type", "default": "redacted_thinking" }) -}).annotate({ "title": "ResponseRedactedThinkingBlock" }) -export type ResponseSearchResultLocationCitation = { - readonly "cited_text": string - readonly "end_block_index": number - readonly "search_result_index": number - readonly "source": string - readonly "start_block_index": number - readonly "title": string | null - readonly "type": "search_result_location" + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Not visible to the agent." + }) + ) +}).annotate({ + "description": "Request parameters for creating a `memory_store`.", + "identifier": "BetaManagedAgentsCreateMemoryStoreRequest" +}) +export type BetaManagedAgentsUpdateMemoryStoreRequestBody = { + readonly "name"?: string + readonly "description"?: string + readonly "metadata"?: { readonly [x: string]: string } } -export const ResponseSearchResultLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "end_block_index": Schema.Number.annotate({ "title": "End Block Index" }).check(Schema.isInt()), - "search_result_index": Schema.Number.annotate({ "title": "Search Result Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) +export const BetaManagedAgentsUpdateMemoryStoreRequestBody = Schema.Struct({ + "name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "New human-readable name for the store. 1–255 characters; no control characters. Renaming changes the slug used for the store's `mount_path` in sessions created after the update." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ) ), - "source": Schema.String.annotate({ "title": "Source" }), - "start_block_index": Schema.Number.annotate({ "title": "Start Block Index" }).check(Schema.isInt()).check( - Schema.isGreaterThanOrEqualTo(0) + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": "New description for the store, up to 1024 characters. Pass an empty string to clear it." + }).check(Schema.isMaxLength(1024).annotate({ "expected": "a value with a length of at most 1024" })) ), - "title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Title" }), - "type": Schema.Literal("search_result_location").annotate({ "title": "Type", "default": "search_result_location" }) -}).annotate({ "title": "ResponseSearchResultLocationCitation" }) -export type ResponseTextEditorCodeExecutionCreateResultBlock = { - readonly "is_file_update": boolean - readonly "type": "text_editor_code_execution_create_result" + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values up to 512 chars." + }) + ) +}).annotate({ "identifier": "BetaManagedAgentsUpdateMemoryStoreRequestBody" }) +export type BetaManagedAgentsDeleteMemoryStoreResponse = { + readonly "type": "memory_store_deleted" + readonly "id": string } -export const ResponseTextEditorCodeExecutionCreateResultBlock = Schema.Struct({ - "is_file_update": Schema.Boolean.annotate({ "title": "Is File Update" }), - "type": Schema.Literal("text_editor_code_execution_create_result").annotate({ - "title": "Type", - "default": "text_editor_code_execution_create_result" +export const BetaManagedAgentsDeleteMemoryStoreResponse = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("memory_store_deleted"), + "id": Schema.String.annotate({ + "description": + "ID of the deleted memory store (a `memstore_...` identifier). The store and all its memories and versions are no longer retrievable." + }) + }).annotate({ "description": "Response from deleting a `memory_store`. Confirms the deleted ID." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsDeleteMemoryStoreResponse" }) +export type BetaUserProfileListOrder = "asc" | "desc" +export const BetaUserProfileListOrder = Schema.Literals(["asc", "desc"]).annotate({ + "description": "ListOrder enum", + "identifier": "BetaUserProfileListOrder" +}) +export type BetaUserProfileRelationship = "external" | "resold" | "internal" +export const BetaUserProfileRelationship = Schema.Literals(["external", "resold", "internal"]).annotate({ + "description": + "How the entity behind a user profile relates to the platform that owns the API key. `external`: an individual end-user of the platform. `resold`: a company the platform resells Claude access to. `internal`: the platform's own usage.", + "identifier": "BetaUserProfileRelationship" +}) +export type BetaUserProfileTrustGrant = { readonly "status": "active" | "pending" | "rejected" } +export const BetaUserProfileTrustGrant = Schema.Struct({ + "status": Schema.Literals(["active", "pending", "rejected"]).annotate({ "description": "Status of the trust grant." }) +}).annotate({ "identifier": "BetaUserProfileTrustGrant" }) +export type BetaCreateTunnelRequest = { readonly "display_name"?: string } +export const BetaCreateTunnelRequest = Schema.Struct({ + "display_name": Schema.optionalKey( + Schema.String.annotate({ "description": "Optional human-readable name for the tunnel (1-255 characters)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })) + ) +}).annotate({ "description": "Request parameters for creating a tunnel.", "identifier": "BetaCreateTunnelRequest" }) +export type BetaTunnelToken = { + readonly "type": "tunnel_token" + readonly "id": string + readonly "tunnel_token": string +} +export const BetaTunnelToken = Schema.Struct({ + "type": Schema.Literal("tunnel_token"), + "id": Schema.String.annotate({ + "description": "Stable identifier for the current token value. Changes when the token is rotated." + }), + "tunnel_token": Schema.String.annotate({ + "description": "The connector token used to run the tunnel. Treat as a credential." }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionCreateResultBlock" }) -export type ResponseTextEditorCodeExecutionStrReplaceResultBlock = { - readonly "lines": ReadonlyArray | null - readonly "new_lines": number | null - readonly "new_start": number | null - readonly "old_lines": number | null - readonly "old_start": number | null - readonly "type": "text_editor_code_execution_str_replace_result" +}).annotate({ "description": "A tunnel's connector token.", "identifier": "BetaTunnelToken" }) +export type BetaRotateTunnelTokenRequestBody = { readonly "reason"?: string } +export const BetaRotateTunnelTokenRequestBody = Schema.Struct({ + "reason": Schema.optionalKey( + Schema.String.annotate({ "description": "Optional free-text reason for the rotation, recorded for audit." }).check( + Schema.isMaxLength(1024).annotate({ "expected": "a value with a length of at most 1024" }) + ) + ) +}).annotate({ "identifier": "BetaRotateTunnelTokenRequestBody" }) +export type BetaCreateTunnelCertificateRequestBody = { readonly "ca_certificate_pem": string } +export const BetaCreateTunnelCertificateRequestBody = Schema.Struct({ + "ca_certificate_pem": Schema.String.annotate({ + "description": + "PEM-encoded X.509 CA certificate. Must contain exactly one certificate and no private-key material. Maximum 8KB." + }).check(Schema.isMaxLength(8192).annotate({ "expected": "a value with a length of at most 8192" })) +}).annotate({ "identifier": "BetaCreateTunnelCertificateRequestBody" }) +export type BetaDreamStatus = "pending" | "running" | "completed" | "failed" | "canceled" +export const BetaDreamStatus = Schema.Literals(["pending", "running", "completed", "failed", "canceled"]).annotate({ + "description": "Lifecycle status of a Dream.", + "identifier": "BetaDreamStatus" +}) +export type BetaDreamInput = { readonly "type": "memory_store"; readonly "memory_store_id": string } | { + readonly "type": "sessions" + readonly "session_ids": ReadonlyArray } -export const ResponseTextEditorCodeExecutionStrReplaceResultBlock = Schema.Struct({ - "lines": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Lines", "default": null }), - "new_lines": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "New Lines", - "default": null +export const BetaDreamInput = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("memory_store"), + "memory_store_id": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "An input memory store the dream reads from. The dream never mutates this store." }), + Schema.Struct({ "type": Schema.Literal("sessions"), "session_ids": Schema.Array(Schema.String) }).annotate({ + "description": "Input session transcripts the dream reads." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaDreamInput" }) +export type BetaDreamOutput = { readonly "type": "memory_store"; readonly "memory_store_id": string } +export const BetaDreamOutput = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("memory_store"), "memory_store_id": Schema.String }).annotate({ + "description": "An output memory store the dream writes consolidated memories into." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaDreamOutput" }) +export type BetaDreamError = { readonly "type": string; readonly "message": string } +export const BetaDreamError = Schema.Struct({ "type": Schema.String, "message": Schema.String }).annotate({ + "description": "Failure detail for a Dream whose `status` is `failed`.", + "identifier": "BetaDreamError" +}) +export type BetaDreamUsage = { + readonly "input_tokens": number + readonly "output_tokens": number + readonly "cache_read_input_tokens": number + readonly "cache_creation_input_tokens": number +} +export const BetaDreamUsage = Schema.Struct({ + "input_tokens": Schema.Number.annotate({ + "description": "Total uncached input tokens consumed across every pipeline stage.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "output_tokens": Schema.Number.annotate({ + "description": "Total output tokens generated across every pipeline stage.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "cache_read_input_tokens": Schema.Number.annotate({ + "description": "Total tokens read from prompt cache.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "cache_creation_input_tokens": Schema.Number.annotate({ + "description": "Total tokens used to create prompt-cache entries (sum of all TTL tiers).", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Cumulative token usage for the dream across every pipeline stage.", + "identifier": "BetaDreamUsage" +}) +export type BetaManagedAgentsListOrder = "asc" | "desc" +export const BetaManagedAgentsListOrder = Schema.Literals(["asc", "desc"]).annotate({ + "description": "ListOrder enum", + "identifier": "BetaManagedAgentsListOrder" +}) +export type BetaManagedAgentsSessionStatus = "rescheduling" | "running" | "idle" | "terminated" +export const BetaManagedAgentsSessionStatus = Schema.Literals(["rescheduling", "running", "idle", "terminated"]) + .annotate({ "description": "SessionStatus enum", "identifier": "BetaManagedAgentsSessionStatus" }) +export type BetaManagedAgentsModel = + | string + | "claude-sonnet-5" + | "claude-fable-5" + | "claude-opus-5" + | "claude-opus-4-8" + | "claude-opus-4-7" + | "claude-opus-4-6" + | "claude-sonnet-4-6" + | "claude-haiku-4-5" + | "claude-haiku-4-5-20251001" + | "claude-opus-4-5" + | "claude-opus-4-5-20251101" + | "claude-sonnet-4-5" + | "claude-sonnet-4-5-20250929" +export const BetaManagedAgentsModel = Schema.Union([ + Schema.String, + Schema.Literals([ + "claude-sonnet-5", + "claude-fable-5", + "claude-opus-5", + "claude-opus-4-8", + "claude-opus-4-7", + "claude-opus-4-6", + "claude-sonnet-4-6", + "claude-haiku-4-5", + "claude-haiku-4-5-20251001", + "claude-opus-4-5", + "claude-opus-4-5-20251101", + "claude-sonnet-4-5", + "claude-sonnet-4-5-20250929" + ]) +]).annotate({ + "title": "BetaManagedAgentsModel", + "description": + "The model that will power your agent.\n\nSee [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.", + "identifier": "BetaManagedAgentsModel" +}) +export type BetaManagedAgentsSpeed = "standard" | "fast" +export const BetaManagedAgentsSpeed = Schema.Literals(["standard", "fast"]).annotate({ + "description": + "Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.", + "identifier": "BetaManagedAgentsSpeed" +}) +export type BetaManagedAgentsEffort = + | { readonly "type": "low" } + | { readonly "type": "medium" } + | { readonly "type": "high" } + | { readonly "type": "xhigh" } + | { readonly "type": "max" } +export const BetaManagedAgentsEffort = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("low") }).annotate({ + "description": + "How hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes." }), - "new_start": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "New Start", - "default": null + Schema.Struct({ "type": Schema.Literal("medium") }).annotate({ + "description": + "How hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes." }), - "old_lines": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Old Lines", - "default": null + Schema.Struct({ "type": Schema.Literal("high") }).annotate({ + "description": + "How hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes." }), - "old_start": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Old Start", - "default": null + Schema.Struct({ "type": Schema.Literal("xhigh") }).annotate({ + "description": + "How hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes." }), - "type": Schema.Literal("text_editor_code_execution_str_replace_result").annotate({ - "title": "Type", - "default": "text_editor_code_execution_str_replace_result" + Schema.Struct({ "type": Schema.Literal("max") }).annotate({ + "description": + "How hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes." }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionStrReplaceResultBlock" }) -export type ResponseTextEditorCodeExecutionViewResultBlock = { - readonly "content": string - readonly "file_type": "text" | "image" | "pdf" - readonly "num_lines": number | null - readonly "start_line": number | null - readonly "total_lines": number | null - readonly "type": "text_editor_code_execution_view_result" -} -export const ResponseTextEditorCodeExecutionViewResultBlock = Schema.Struct({ - "content": Schema.String.annotate({ "title": "Content" }), - "file_type": Schema.Literals(["text", "image", "pdf"]).annotate({ "title": "File Type" }), - "num_lines": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Num Lines", - "default": null - }), - "start_line": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Start Line", - "default": null +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsEffort" }) +export type BetaManagedAgentsPermissionPolicy = { readonly "type": "always_allow" } | { readonly "type": "always_ask" } +export const BetaManagedAgentsPermissionPolicy = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("always_allow") }).annotate({ + "description": "Permission policy for tool execution." }), - "total_lines": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Total Lines", - "default": null + Schema.Struct({ "type": Schema.Literal("always_ask") }).annotate({ + "description": "Permission policy for tool execution." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsPermissionPolicy" }) +export type BetaManagedAgentsAgentToolName = + | "bash" + | "edit" + | "read" + | "write" + | "glob" + | "grep" + | "web_fetch" + | "web_search" +export const BetaManagedAgentsAgentToolName = Schema.Literals([ + "bash", + "edit", + "read", + "write", + "glob", + "grep", + "web_fetch", + "web_search" +]).annotate({ "description": "Built-in agent tool identifier.", "identifier": "BetaManagedAgentsAgentToolName" }) +export type BetaManagedAgentsCustomToolInputSchema = { + readonly "properties"?: { readonly [x: string]: Schema.Json } | null + readonly "required"?: ReadonlyArray | null + readonly "type": "object" + readonly [x: string]: Schema.Json +} +export const BetaManagedAgentsCustomToolInputSchema = Schema.StructWithRest( + Schema.Struct({ + "properties": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + .annotate({ "title": "Properties" }) + ), + "required": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Required" }) + ), + "type": Schema.Literal("object").annotate({ "title": "Type" }) }), - "type": Schema.Literal("text_editor_code_execution_view_result").annotate({ - "title": "Type", - "default": "text_editor_code_execution_view_result" + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ + "description": "JSON Schema for custom tool input parameters.", + "identifier": "BetaManagedAgentsCustomToolInputSchema" +}) +export type BetaManagedAgentsMCPServer = { readonly "type": "url"; readonly "name": string; readonly "url": string } +export const BetaManagedAgentsMCPServer = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("url"), "name": Schema.String, "url": Schema.String }).annotate({ + "description": "Union type for MCP server connection definitions returned in API responses." }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionViewResultBlock" }) -export type ResponseThinkingBlock = { - readonly "signature": string - readonly "thinking": string - readonly "type": "thinking" +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsMCPServer" }) +export type BetaManagedAgentsAnthropicSkill = { + readonly "type": "anthropic" + readonly "skill_id": string + readonly "version": string } -export const ResponseThinkingBlock = Schema.Struct({ - "signature": Schema.String.annotate({ "title": "Signature" }), - "thinking": Schema.String.annotate({ "title": "Thinking" }), - "type": Schema.Literal("thinking").annotate({ "title": "Type", "default": "thinking" }) -}).annotate({ "title": "ResponseThinkingBlock" }) -export type ResponseToolReferenceBlock = { readonly "tool_name": string; readonly "type": "tool_reference" } -export const ResponseToolReferenceBlock = Schema.Struct({ - "tool_name": Schema.String.annotate({ "title": "Tool Name" }).check(Schema.isMinLength(1)).check( - Schema.isMaxLength(256) - ).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,256}$"))), - "type": Schema.Literal("tool_reference").annotate({ "title": "Type", "default": "tool_reference" }) -}).annotate({ "title": "ResponseToolReferenceBlock" }) -export type ResponseWebSearchResultBlock = { - readonly "encrypted_content": string - readonly "page_age": string | null - readonly "title": string - readonly "type": "web_search_result" - readonly "url": string +export const BetaManagedAgentsAnthropicSkill = Schema.Struct({ + "type": Schema.Literal("anthropic"), + "skill_id": Schema.String, + "version": Schema.String +}).annotate({ "description": "A resolved Anthropic-managed skill.", "identifier": "BetaManagedAgentsAnthropicSkill" }) +export type BetaManagedAgentsCustomSkill = { + readonly "type": "custom" + readonly "skill_id": string + readonly "version": string } -export const ResponseWebSearchResultBlock = Schema.Struct({ - "encrypted_content": Schema.String.annotate({ "title": "Encrypted Content" }), - "page_age": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Page Age", "default": null }), - "title": Schema.String.annotate({ "title": "Title" }), - "type": Schema.Literal("web_search_result").annotate({ "title": "Type", "default": "web_search_result" }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "ResponseWebSearchResultBlock" }) -export type ResponseWebSearchResultLocationCitation = { - readonly "cited_text": string - readonly "encrypted_index": string - readonly "title": string | null - readonly "type": "web_search_result_location" - readonly "url": string +export const BetaManagedAgentsCustomSkill = Schema.Struct({ + "type": Schema.Literal("custom"), + "skill_id": Schema.String, + "version": Schema.String +}).annotate({ "description": "A resolved user-created custom skill.", "identifier": "BetaManagedAgentsCustomSkill" }) +export type BetaManagedAgentsAdvisor = { readonly "type": "advisor"; readonly "model": string } +export const BetaManagedAgentsAdvisor = Schema.Struct({ + "type": Schema.Literal("advisor"), + "model": Schema.String.annotate({ "description": "The advisor model id." }) +}).annotate({ + "description": "Platform advisor roster entry: a model the session's primary thread may consult mid-turn.", + "identifier": "BetaManagedAgentsAdvisor" +}) +export type BetaManagedAgentsRepositoryCheckout = { readonly "type": "branch"; readonly "name": string } | { + readonly "type": "commit" + readonly "sha": string } -export const ResponseWebSearchResultLocationCitation = Schema.Struct({ - "cited_text": Schema.String.annotate({ "title": "Cited Text" }), - "encrypted_index": Schema.String.annotate({ "title": "Encrypted Index" }), - "title": Schema.Union([Schema.String.check(Schema.isMaxLength(512)), Schema.Null]).annotate({ "title": "Title" }), - "type": Schema.Literal("web_search_result_location").annotate({ - "title": "Type", - "default": "web_search_result_location" +export const BetaManagedAgentsRepositoryCheckout = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("branch"), + "name": Schema.String.annotate({ "description": "Branch name to check out." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })) }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "ResponseWebSearchResultLocationCitation" }) -export type ServerToolCaller = { readonly "tool_id": string; readonly "type": "code_execution_20250825" } -export const ServerToolCaller = Schema.Struct({ - "tool_id": Schema.String.annotate({ "title": "Tool Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + Schema.Struct({ + "type": Schema.Literal("commit"), + "sha": Schema.String.annotate({ "description": "Full commit SHA to check out." }).check( + Schema.isMinLength(7).annotate({ "expected": "a value with a length of at least 7" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })) + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsRepositoryCheckout" }) +export type BetaManagedAgentsMountMode = "read_write" | "read_only" +export const BetaManagedAgentsMountMode = Schema.Literals(["read_write", "read_only"]).annotate({ + "description": "Access mode for an attached memory store.", + "identifier": "BetaManagedAgentsMountMode" +}) +export type BetaManagedAgentsCacheCreationUsage = { + readonly "ephemeral_1h_input_tokens"?: number + readonly "ephemeral_5m_input_tokens"?: number +} +export const BetaManagedAgentsCacheCreationUsage = Schema.Struct({ + "ephemeral_1h_input_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Tokens used to create 1-hour ephemeral cache entries.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "type": Schema.Literal("code_execution_20250825").annotate({ "title": "Type" }) -}).annotate({ "title": "ServerToolCaller", "description": "Tool invocation generated by a server-side tool." }) -export type ServerToolCaller_20260120 = { readonly "tool_id": string; readonly "type": "code_execution_20260120" } -export const ServerToolCaller_20260120 = Schema.Struct({ - "tool_id": Schema.String.annotate({ "title": "Tool Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "ephemeral_5m_input_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Tokens used to create 5-minute ephemeral cache entries.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) +}).annotate({ + "description": "Prompt-cache creation token usage broken down by cache lifetime.", + "identifier": "BetaManagedAgentsCacheCreationUsage" +}) +export type BetaCurrency = "USD" +export const BetaCurrency = Schema.Literal("USD").annotate({ "identifier": "BetaCurrency" }) +export type BetaManagedAgentsServerToolUsage = { + readonly "web_search_requests"?: number + readonly "web_fetch_requests"?: number +} +export const BetaManagedAgentsServerToolUsage = Schema.Struct({ + "web_search_requests": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of server-executed web search requests.", "format": "int32" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "web_fetch_requests": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of server-executed web fetch requests.", "format": "int32" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ) +}).annotate({ + "description": "Cumulative count of server-executed tool invocations, broken down by tool.", + "identifier": "BetaManagedAgentsServerToolUsage" +}) +export type BetaManagedAgentsSessionStats = { readonly "duration_seconds"?: number; readonly "active_seconds"?: number } +export const BetaManagedAgentsSessionStats = Schema.Struct({ + "duration_seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), - "type": Schema.Literal("code_execution_20260120").annotate({ "title": "Type" }) -}).annotate({ "title": "ServerToolCaller_20260120" }) -export type ServerToolUsage = { readonly "web_fetch_requests": number; readonly "web_search_requests": number } -export const ServerToolUsage = Schema.Struct({ - "web_fetch_requests": Schema.Number.annotate({ - "title": "Web Fetch Requests", - "description": "The number of web fetch tool requests.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "web_search_requests": Schema.Number.annotate({ - "title": "Web Search Requests", - "description": "The number of web search tool requests.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) -}).annotate({ "title": "ServerToolUsage" }) -export type SignatureContentBlockDelta = { readonly "signature": string; readonly "type": "signature_delta" } -export const SignatureContentBlockDelta = Schema.Struct({ - "signature": Schema.String.annotate({ "title": "Signature" }), - "type": Schema.Literal("signature_delta").annotate({ "title": "Type", "default": "signature_delta" }) -}).annotate({ "title": "SignatureContentBlockDelta" }) -export type Skill = { - readonly "created_at": string - readonly "display_title": string | null + "active_seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Cumulative time in seconds the session spent in running status. Excludes idle time.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) +}).annotate({ "description": "Timing statistics for a session.", "identifier": "BetaManagedAgentsSessionStats" }) +export type BetaManagedAgentsAgentParams = { + readonly "type": "agent" readonly "id": string - readonly "latest_version": string | null - readonly "source": string - readonly "type": string - readonly "updated_at": string + readonly "version"?: number } -export const Skill = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill was created." - }), - "display_title": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Display Title", +export const BetaManagedAgentsAgentParams = Schema.Struct({ + "type": Schema.Literal("agent"), + "id": Schema.String.annotate({ "description": "The `agent` ID." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })), + "version": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) +}).annotate({ + "description": + "Specification for an Agent. Provide a specific `version` or use the short-form `agent=\"agent_id\"` for the most recent version", + "identifier": "BetaManagedAgentsAgentParams" +}) +export type BetaManagedAgentsEffortLevel = "low" | "medium" | "high" | "xhigh" | "max" +export const BetaManagedAgentsEffortLevel = Schema.Literals(["low", "medium", "high", "xhigh", "max"]).annotate({ + "description": + "How hard Claude works on each turn. Higher levels favor reasoning depth over latency. Not all models accept every level; invalid combinations are rejected at create time.", + "identifier": "BetaManagedAgentsEffortLevel" +}) +export type BetaManagedAgentsMCPServerParams = { + readonly "type": "url" + readonly "name": string + readonly "url": string +} +export const BetaManagedAgentsMCPServerParams = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("url"), + "name": Schema.String.annotate({ + "description": "Unique name for this server, referenced by mcp_toolset configurations. 1-255 characters." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + "url": Schema.String.annotate({ "description": "Endpoint URL for the MCP server." }).check( + Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" }) + ) + }).annotate({ "description": "Union type for MCP server connection definitions." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsMCPServerParams" }) +export type BetaManagedAgentsAnthropicSkillParams = { + readonly "type": "anthropic" + readonly "skill_id": string + readonly "version"?: string +} +export const BetaManagedAgentsAnthropicSkillParams = Schema.Struct({ + "type": Schema.Literal("anthropic"), + "skill_id": Schema.String.annotate({ "description": "Identifier of the Anthropic skill (e.g., \"xlsx\")." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "version": Schema.optionalKey( + Schema.String.annotate({ "description": "Version to pin. Defaults to latest if omitted." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })) + ) +}).annotate({ "description": "An Anthropic-managed skill.", "identifier": "BetaManagedAgentsAnthropicSkillParams" }) +export type BetaManagedAgentsCustomSkillParams = { + readonly "type": "custom" + readonly "skill_id": string + readonly "version"?: string +} +export const BetaManagedAgentsCustomSkillParams = Schema.Struct({ + "type": Schema.Literal("custom"), + "skill_id": Schema.String.annotate({ "description": "Tagged ID of the custom skill (e.g., \"skill_01XJ5...\")." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "version": Schema.optionalKey( + Schema.String.annotate({ "description": "Version to pin. Defaults to latest if omitted." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })) + ) +}).annotate({ "description": "A user-created custom skill.", "identifier": "BetaManagedAgentsCustomSkillParams" }) +export type BetaManagedAgentsImageSource = + | { readonly "type": "base64"; readonly "media_type": string; readonly "data": string } + | { readonly "type": "url"; readonly "url": string } + | { readonly "type": "file"; readonly "file_id": string } +export const BetaManagedAgentsImageSource = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("base64"), + "media_type": Schema.String.annotate({ + "description": "MIME type of the image (e.g., \"image/png\", \"image/jpeg\", \"image/gif\", \"image/webp\")." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "data": Schema.String.annotate({ "description": "Base64-encoded image data." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Union type for image source variants." }), + Schema.Struct({ + "type": Schema.Literal("url"), + "url": Schema.String.annotate({ "description": "URL of the image to fetch." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Union type for image source variants." }), + Schema.Struct({ + "type": Schema.Literal("file"), + "file_id": Schema.String.annotate({ "description": "ID of a previously uploaded file." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Union type for image source variants." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsImageSource" }) +export type BetaManagedAgentsDocumentSource = + | { readonly "type": "base64"; readonly "media_type": string; readonly "data": string } + | { readonly "type": "text"; readonly "media_type": "text/plain"; readonly "data": string } + | { readonly "type": "url"; readonly "url": string } + | { readonly "type": "file"; readonly "file_id": string } +export const BetaManagedAgentsDocumentSource = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("base64"), + "media_type": Schema.String.annotate({ "description": "MIME type of the document (e.g., \"application/pdf\")." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "data": Schema.String.annotate({ "description": "Base64-encoded document data." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Union type for document source variants." }), + Schema.Struct({ + "type": Schema.Literal("text"), + "media_type": Schema.Literal("text/plain").annotate({ + "description": "MIME type of the text content. Must be \"text/plain\"." + }), + "data": Schema.String.annotate({ "description": "The plain text content." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Union type for document source variants." }), + Schema.Struct({ + "type": Schema.Literal("url"), + "url": Schema.String.annotate({ "description": "URL of the document to fetch." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Union type for document source variants." }), + Schema.Struct({ + "type": Schema.Literal("file"), + "file_id": Schema.String.annotate({ "description": "ID of a previously uploaded file." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Union type for document source variants." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsDocumentSource" }) +export type BetaManagedAgentsFileRubricParams = { readonly "type": "file"; readonly "file_id": string } +export const BetaManagedAgentsFileRubricParams = Schema.Struct({ + "type": Schema.Literal("file"), + "file_id": Schema.String.annotate({ "description": "ID of the rubric file." }) +}).annotate({ + "description": "Rubric referenced by a file uploaded via the Files API.", + "identifier": "BetaManagedAgentsFileRubricParams" +}) +export type BetaManagedAgentsTextRubricParams = { readonly "type": "text"; readonly "content": string } +export const BetaManagedAgentsTextRubricParams = Schema.Struct({ + "type": Schema.Literal("text"), + "content": Schema.String.annotate({ "description": - "Display title for the skill.\n\nThis is a human-readable label that is not included in the prompt sent to the model." + "Rubric content. Plain text or markdown — the grader treats it as freeform text. Maximum 262144 characters." + }).check(Schema.isMaxLength(262144).annotate({ "expected": "a value with a length of at most 262144" })) +}).annotate({ + "description": "Rubric content provided inline as text.", + "identifier": "BetaManagedAgentsTextRubricParams" +}) +export type BetaManagedAgentsDeletedSession = { readonly "type": "session_deleted"; readonly "id": string } +export const BetaManagedAgentsDeletedSession = Schema.Struct({ + "type": Schema.Literal("session_deleted"), + "id": Schema.String +}).annotate({ + "description": "Confirmation that a `session` has been permanently deleted.", + "identifier": "BetaManagedAgentsDeletedSession" +}) +export type BetaManagedAgentsUserToolConfirmationResult = "allow" | "deny" +export const BetaManagedAgentsUserToolConfirmationResult = Schema.Literals(["allow", "deny"]).annotate({ + "description": "UserToolConfirmationResult enum", + "identifier": "BetaManagedAgentsUserToolConfirmationResult" +}) +export type BetaManagedAgentsSearchResultContent = { readonly "type": "text"; readonly "text": string } +export const BetaManagedAgentsSearchResultContent = Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String.annotate({ "description": "The text content." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ + "description": "Text content within a search result.", + "identifier": "BetaManagedAgentsSearchResultContent" +}) +export type BetaManagedAgentsSearchResultCitations = { readonly "enabled": boolean } +export const BetaManagedAgentsSearchResultCitations = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ "description": "Whether citations are enabled for this search result." }) +}).annotate({ + "description": "Citation settings for a search result.", + "identifier": "BetaManagedAgentsSearchResultCitations" +}) +export type BetaManagedAgentsStruct = { readonly [x: string]: Schema.Json } +export const BetaManagedAgentsStruct = Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) + .annotate({ "identifier": "BetaManagedAgentsStruct" }) +export type BetaManagedAgentsAgentMessageContentBlock = { readonly "type": "text"; readonly "text": string } | { + readonly "type": "redacted" +} +export const BetaManagedAgentsAgentMessageContentBlock = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String.annotate({ "description": "The text content." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Content block in an agent message." }), + Schema.Struct({ "type": Schema.Literal("redacted") }).annotate({ + "description": "Content block in an agent message." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsAgentMessageContentBlock" }) +export type BetaManagedAgentsAgentEvaluatedPermission = "allow" | "ask" | "deny" +export const BetaManagedAgentsAgentEvaluatedPermission = Schema.Literals(["allow", "ask", "deny"]).annotate({ + "description": "AgentEvaluatedPermission enum", + "identifier": "BetaManagedAgentsAgentEvaluatedPermission" +}) +export type BetaManagedAgentsRetryStatus = { readonly "type": "retrying" } | { readonly "type": "exhausted" } | { + readonly "type": "terminal" +} +export const BetaManagedAgentsRetryStatus = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("retrying") }).annotate({ + "description": "What the client should do next in response to this error." }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill.\n\nThe format and length of IDs may change over time." + Schema.Struct({ "type": Schema.Literal("exhausted") }).annotate({ + "description": "What the client should do next in response to this error." }), - "latest_version": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Latest Version", - "description": - "The latest version identifier for the skill.\n\nThis represents the most recent version of the skill that has been created." + Schema.Struct({ "type": Schema.Literal("terminal") }).annotate({ + "description": "What the client should do next in response to this error." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsRetryStatus" }) +export type BetaManagedAgentsFileRubric = { readonly "type": "file"; readonly "file_id": string } +export const BetaManagedAgentsFileRubric = Schema.Struct({ + "type": Schema.Literal("file"), + "file_id": Schema.String.annotate({ "description": "ID of the rubric file." }) +}).annotate({ + "description": "Rubric referenced by a file uploaded via the Files API.", + "identifier": "BetaManagedAgentsFileRubric" +}) +export type BetaManagedAgentsTextRubric = { readonly "type": "text"; readonly "content": string } +export const BetaManagedAgentsTextRubric = Schema.Struct({ + "type": Schema.Literal("text"), + "content": Schema.String.annotate({ + "description": "Rubric content. Plain text or markdown — the grader treats it as freeform text." + }) +}).annotate({ "description": "Rubric content provided inline as text.", "identifier": "BetaManagedAgentsTextRubric" }) +export type BetaManagedAgentsSystemContentBlock = { readonly "type": "text"; readonly "text": string } +export const BetaManagedAgentsSystemContentBlock = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String.annotate({ "description": "The text content." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Content block in a mid-conversation system message. Text-only." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsSystemContentBlock" }) +export type BetaManagedAgentsEventDeltaType = "agent.message" | "agent.thinking" +export const BetaManagedAgentsEventDeltaType = Schema.Literals(["agent.message", "agent.thinking"]).annotate({ + "description": "EventDeltaType enum", + "identifier": "BetaManagedAgentsEventDeltaType" +}) +export type BetaManagedAgentsEventStartEvent_Event = { readonly "type": "agent.message"; readonly "id": string } | { + readonly "type": "agent.thinking" + readonly "id": string +} +export const BetaManagedAgentsEventStartEvent_Event = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("agent.message"), + "id": Schema.String.annotate({ + "description": + "The id the buffered agent.message will carry if it is emitted. Matches the event_id on this preview's event_delta events." + }) }), - "source": Schema.String.annotate({ - "title": "Source", + Schema.Struct({ + "type": Schema.Literal("agent.thinking"), + "id": Schema.String.annotate({ + "description": + "The id the buffered agent.thinking will carry if it is emitted. Start-only — no event_delta events follow." + }) + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsEventStartEvent_Event" }) +export type BetaManagedAgentsTextBlock = { readonly "type": "text"; readonly "text": string } +export const BetaManagedAgentsTextBlock = Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String.annotate({ "description": "The text content." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ "description": "Regular text content.", "identifier": "BetaManagedAgentsTextBlock" }) +export type BetaManagedAgentsSessionThreadStatus = "running" | "idle" | "rescheduling" | "terminated" +export const BetaManagedAgentsSessionThreadStatus = Schema.Literals(["running", "idle", "rescheduling", "terminated"]) + .annotate({ "description": "SessionThreadStatus enum", "identifier": "BetaManagedAgentsSessionThreadStatus" }) +export type BetaManagedAgentsSessionThreadStats = { + readonly "duration_seconds"?: number + readonly "startup_seconds"?: number + readonly "active_seconds"?: number +} +export const BetaManagedAgentsSessionThreadStats = Schema.Struct({ + "duration_seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Elapsed time since thread creation in seconds. For archived threads, frozen at the final update.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "startup_seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Time in seconds for the thread to begin running. Zero for child threads, which start immediately.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "active_seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Cumulative time in seconds the thread spent actively running. Excludes idle time.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) +}).annotate({ + "description": "Timing statistics for a session thread.", + "identifier": "BetaManagedAgentsSessionThreadStats" +}) +export type BetaManagedAgentsAddSessionResourceParams = { + readonly "type": "file" + readonly "file_id": string + readonly "mount_path"?: string +} +export const BetaManagedAgentsAddSessionResourceParams = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("file"), + "file_id": Schema.String.annotate({ "description": "ID of a previously uploaded file." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })), + "mount_path": Schema.optionalKey( + Schema.String.annotate({ + "description": "Mount path in the container. Defaults to `/mnt/session/uploads/`." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" }) + ) + ) + }).annotate({ "description": "Request parameters for adding a resource to a session." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsAddSessionResourceParams" }) +export type BetaManagedAgentsUpdateSessionResourceParams = { readonly "authorization_token": string } +export const BetaManagedAgentsUpdateSessionResourceParams = Schema.Struct({ + "authorization_token": Schema.String.annotate({ "description": - "Source of the skill.\n\nThis may be one of the following values:\n* `\"custom\"`: the skill was created by a user\n* `\"anthropic\"`: the skill was created by Anthropic" + "New authorization token for the resource. Currently only `github_repository` resources support token rotation." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" }) + ) +}).annotate({ + "description": "Request parameters for updating a session resource.", + "identifier": "BetaManagedAgentsUpdateSessionResourceParams" +}) +export type BetaManagedAgentsDeleteSessionResource = { + readonly "type": "session_resource_deleted" + readonly "id": string +} +export const BetaManagedAgentsDeleteSessionResource = Schema.Struct({ + "type": Schema.Literal("session_resource_deleted"), + "id": Schema.String +}).annotate({ + "description": "Confirmation of resource deletion.", + "identifier": "BetaManagedAgentsDeleteSessionResource" +}) +export type BetaManagedAgentsAgentReference = { + readonly "type": "agent" + readonly "id": string + readonly "version": number +} +export const BetaManagedAgentsAgentReference = Schema.Struct({ + "type": Schema.Literal("agent"), + "id": Schema.String, + "version": Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "A resolved agent reference with a concrete version.", + "identifier": "BetaManagedAgentsAgentReference" +}) +export type BetaManagedAgentsMultiagentSelfParams = { readonly "type": "self" } +export const BetaManagedAgentsMultiagentSelfParams = Schema.Struct({ "type": Schema.Literal("self") }).annotate({ + "description": + "Sentinel roster entry meaning \"the agent that owns this configuration\". Resolved server-side to a concrete agent reference.", + "identifier": "BetaManagedAgentsMultiagentSelfParams" +}) +export type BetaManagedAgentsAdvisorParams = { readonly "type": "advisor"; readonly "model": string } +export const BetaManagedAgentsAdvisorParams = Schema.Struct({ + "type": Schema.Literal("advisor"), + "model": Schema.String.annotate({ + "description": + "A Claude model id. The model must be permitted as an advisor for this agent's model — see the sessions/threads/advisor spec." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" }) + ) +}).annotate({ + "description": + "Platform advisor roster entry: a model the session's primary thread may consult mid-turn. At most one per roster; the entry occupies the roster name `anthropic.advisor`.", + "identifier": "BetaManagedAgentsAdvisorParams" +}) +export type BetaManagedAgentsDeploymentStatus = "active" | "paused" +export const BetaManagedAgentsDeploymentStatus = Schema.Literals(["active", "paused"]).annotate({ + "description": "Lifecycle status of a deployment.", + "identifier": "BetaManagedAgentsDeploymentStatus" +}) +export type BetaManagedAgentsDeploymentPausedReasonError = + | { readonly "type": "environment_archived_error" } + | { readonly "type": "agent_archived_error" } + | { readonly "type": "environment_not_found_error" } + | { readonly "type": "vault_not_found_error" } + | { readonly "type": "file_not_found_error" } + | { readonly "type": "session_resource_not_found_error" } + | { readonly "type": "workspace_archived_error" } + | { readonly "type": "organization_disabled_error" } + | { readonly "type": "memory_store_archived_error" } + | { readonly "type": "skill_not_found_error" } + | { readonly "type": "vault_archived_error" } + | { readonly "type": "unknown_error" } + | { readonly "type": "self_hosted_resources_unsupported_error" } + | { readonly "type": "mcp_egress_blocked_error" } +export const BetaManagedAgentsDeploymentPausedReasonError = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("environment_archived_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." }), - "type": Schema.String.annotate({ - "title": "Type", - "description": "Object type.\n\nFor Skills, this is always `\"skill\"`.", - "default": "skill" + Schema.Struct({ "type": Schema.Literal("agent_archived_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." }), - "updated_at": Schema.String.annotate({ - "title": "Updated At", - "description": "ISO 8601 timestamp of when the skill was last updated." + Schema.Struct({ "type": Schema.Literal("environment_not_found_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("vault_not_found_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("file_not_found_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("session_resource_not_found_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("workspace_archived_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("organization_disabled_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("memory_store_archived_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("skill_not_found_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("vault_archived_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("unknown_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("self_hosted_resources_unsupported_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." + }), + Schema.Struct({ "type": Schema.Literal("mcp_egress_blocked_error") }).annotate({ + "description": "The error that triggered an auto-pause. Matches the failed run's `error.type`." }) -}).annotate({ "title": "Skill" }) -export type SkillVersion = { - readonly "created_at": string - readonly "description": string - readonly "directory": string - readonly "id": string - readonly "name": string - readonly "skill_id": string - readonly "type": string - readonly "version": string +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsDeploymentPausedReasonError" }) +export type BetaManagedAgentsScheduleParams = { + readonly "type": "cron" + readonly "expression": string + readonly "timezone": string } -export const SkillVersion = Schema.Struct({ - "created_at": Schema.String.annotate({ - "title": "Created At", - "description": "ISO 8601 timestamp of when the skill version was created." +export const BetaManagedAgentsScheduleParams = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("cron"), + "expression": Schema.String.annotate({ + "description": + "5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., \"0 9 * * 1-5\" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily)." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" }) + ), + "timezone": Schema.String.annotate({ + "description": + "Required. IANA timezone identifier (e.g., \"America/Los_Angeles\", \"UTC\"). Validated against the IANA timezone database." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + }).annotate({ "description": "A recurring schedule. Discriminated union — only cron is supported currently." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsScheduleParams" }) +export type BetaManagedAgentsRunError = + | { readonly "type": "environment_archived_error"; readonly "message": string } + | { readonly "type": "agent_archived_error"; readonly "message": string } + | { readonly "type": "environment_not_found_error"; readonly "message": string } + | { readonly "type": "vault_not_found_error"; readonly "message": string } + | { readonly "type": "vault_archived_error"; readonly "message": string } + | { readonly "type": "file_not_found_error"; readonly "message": string } + | { readonly "type": "memory_store_archived_error"; readonly "message": string } + | { readonly "type": "skill_not_found_error"; readonly "message": string } + | { readonly "type": "session_resource_not_found_error"; readonly "message": string } + | { readonly "type": "workspace_archived_error"; readonly "message": string } + | { readonly "type": "organization_disabled_error"; readonly "message": string } + | { readonly "type": "session_rate_limited_error"; readonly "message": string } + | { readonly "type": "session_creation_rejected_error"; readonly "message": string } + | { readonly "type": "unknown_error"; readonly "message": string } + | { readonly "type": "self_hosted_resources_unsupported_error"; readonly "message": string } + | { readonly "type": "mcp_egress_blocked_error"; readonly "message": string } +export const BetaManagedAgentsRunError = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("environment_archived_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." }), - "description": Schema.String.annotate({ - "title": "Description", - "description": "Description of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + Schema.Struct({ + "type": Schema.Literal("agent_archived_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." }), - "directory": Schema.String.annotate({ - "title": "Directory", + Schema.Struct({ + "type": Schema.Literal("environment_not_found_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ "description": - "Directory name of the skill version.\n\nThis is the top-level directory name that was extracted from the uploaded files." + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique identifier for the skill version.\n\nThe format and length of IDs may change over time." + Schema.Struct({ + "type": Schema.Literal("vault_not_found_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." }), - "name": Schema.String.annotate({ - "title": "Name", + Schema.Struct({ + "type": Schema.Literal("vault_archived_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ "description": - "Human-readable name of the skill version.\n\nThis is extracted from the SKILL.md file in the skill upload." + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." }), - "skill_id": Schema.String.annotate({ - "title": "Skill Id", - "description": "Identifier for the skill that this version belongs to." + Schema.Struct({ + "type": Schema.Literal("file_not_found_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." }), - "type": Schema.String.annotate({ - "title": "Type", - "description": "Object type.\n\nFor Skill Versions, this is always `\"skill_version\"`.", - "default": "skill_version" + Schema.Struct({ + "type": Schema.Literal("memory_store_archived_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." }), - "version": Schema.String.annotate({ - "title": "Version", + Schema.Struct({ + "type": Schema.Literal("skill_not_found_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ "description": - "Version identifier for the skill.\n\nEach version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\")." - }) -}).annotate({ "title": "SkillVersion" }) -export type TextContentBlockDelta = { readonly "text": string; readonly "type": "text_delta" } -export const TextContentBlockDelta = Schema.Struct({ - "text": Schema.String.annotate({ "title": "Text" }), - "type": Schema.Literal("text_delta").annotate({ "title": "Type", "default": "text_delta" }) -}).annotate({ "title": "TextContentBlockDelta" }) -export type TextEditorCodeExecutionToolResultErrorCode = - | "invalid_tool_input" - | "unavailable" - | "too_many_requests" - | "execution_time_exceeded" - | "file_not_found" -export const TextEditorCodeExecutionToolResultErrorCode = Schema.Literals([ - "invalid_tool_input", - "unavailable", - "too_many_requests", - "execution_time_exceeded", - "file_not_found" -]).annotate({ "title": "TextEditorCodeExecutionToolResultErrorCode" }) -export type ThinkingConfigAdaptive = { readonly "type": "adaptive" } -export const ThinkingConfigAdaptive = Schema.Struct({ - "type": Schema.Literal("adaptive").annotate({ "title": "Type" }) -}).annotate({ "title": "ThinkingConfigAdaptive" }) -export type ThinkingConfigDisabled = { readonly "type": "disabled" } -export const ThinkingConfigDisabled = Schema.Struct({ - "type": Schema.Literal("disabled").annotate({ "title": "Type" }) -}).annotate({ "title": "ThinkingConfigDisabled" }) -export type ThinkingConfigEnabled = { readonly "budget_tokens": number; readonly "type": "enabled" } -export const ThinkingConfigEnabled = Schema.Struct({ - "budget_tokens": Schema.Number.annotate({ - "title": "Budget Tokens", + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." + }), + Schema.Struct({ + "type": Schema.Literal("session_resource_not_found_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ "description": - "Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.\n\nMust be ≥1024 and less than `max_tokens`.\n\nSee [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1024)), - "type": Schema.Literal("enabled").annotate({ "title": "Type" }) -}).annotate({ "title": "ThinkingConfigEnabled" }) -export type ThinkingContentBlockDelta = { readonly "thinking": string; readonly "type": "thinking_delta" } -export const ThinkingContentBlockDelta = Schema.Struct({ - "thinking": Schema.String.annotate({ "title": "Thinking" }), - "type": Schema.Literal("thinking_delta").annotate({ "title": "Type", "default": "thinking_delta" }) -}).annotate({ "title": "ThinkingContentBlockDelta" }) -export type ToolChoiceAny = { readonly "disable_parallel_tool_use"?: boolean; readonly "type": "any" } -export const ToolChoiceAny = Schema.Struct({ - "disable_parallel_tool_use": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Disable Parallel Tool Use", - "description": - "Whether to disable parallel tool use.\n\nDefaults to `false`. If set to `true`, the model will output exactly one tool use." - }) - ), - "type": Schema.Literal("any").annotate({ "title": "Type" }) -}).annotate({ "title": "ToolChoiceAny", "description": "The model will use any available tools." }) -export type ToolChoiceAuto = { readonly "disable_parallel_tool_use"?: boolean; readonly "type": "auto" } -export const ToolChoiceAuto = Schema.Struct({ - "disable_parallel_tool_use": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Disable Parallel Tool Use", + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." + }), + Schema.Struct({ + "type": Schema.Literal("workspace_archived_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." + }), + Schema.Struct({ + "type": Schema.Literal("organization_disabled_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." + }), + Schema.Struct({ + "type": Schema.Literal("session_rate_limited_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." + }), + Schema.Struct({ + "type": Schema.Literal("session_creation_rejected_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." + }), + Schema.Struct({ + "type": Schema.Literal("unknown_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." + }), + Schema.Struct({ + "type": Schema.Literal("self_hosted_resources_unsupported_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." + }), + Schema.Struct({ + "type": Schema.Literal("mcp_egress_blocked_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }) + }).annotate({ + "description": + "Why the run failed to create a session. The type identifies the failure; message is human-readable detail." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsRunError" }) +export type BetaManagedAgentsTriggerType = "schedule" | "manual" +export const BetaManagedAgentsTriggerType = Schema.Literals(["schedule", "manual"]).annotate({ + "description": "What triggered a deployment run.", + "identifier": "BetaManagedAgentsTriggerType" +}) +export type BetaManagedAgentsCreateVaultRequest = { + readonly "display_name": string + readonly "metadata"?: { readonly [x: string]: string } +} +export const BetaManagedAgentsCreateVaultRequest = Schema.Struct({ + "display_name": Schema.String.annotate({ "description": "Human-readable name for the vault. 1-255 characters." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ "description": - "Whether to disable parallel tool use.\n\nDefaults to `false`. If set to `true`, the model will output at most one tool use." + "Arbitrary key-value metadata to attach to the vault. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars." }) - ), - "type": Schema.Literal("auto").annotate({ "title": "Type" }) -}).annotate({ "title": "ToolChoiceAuto", "description": "The model will automatically decide whether to use tools." }) -export type ToolChoiceNone = { readonly "type": "none" } -export const ToolChoiceNone = Schema.Struct({ "type": Schema.Literal("none").annotate({ "title": "Type" }) }).annotate({ - "title": "ToolChoiceNone", - "description": "The model will not be allowed to use tools." + ) +}).annotate({ + "description": "Request parameters for creating a vault.", + "identifier": "BetaManagedAgentsCreateVaultRequest" }) -export type ToolChoiceTool = { - readonly "disable_parallel_tool_use"?: boolean - readonly "name": string - readonly "type": "tool" +export type BetaManagedAgentsUpdateVaultRequestBody = { + readonly "display_name"?: string + readonly "metadata"?: { readonly [x: string]: string } } -export const ToolChoiceTool = Schema.Struct({ - "disable_parallel_tool_use": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Disable Parallel Tool Use", +export const BetaManagedAgentsUpdateVaultRequestBody = Schema.Struct({ + "display_name": Schema.optionalKey( + Schema.String.annotate({ "description": "Updated human-readable name for the vault. 1-255 characters." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ "description": - "Whether to disable parallel tool use.\n\nDefaults to `false`. If set to `true`, the model will output exactly one tool use." + "Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omitted keys are preserved." }) - ), - "name": Schema.String.annotate({ "title": "Name", "description": "The name of the tool to use." }), - "type": Schema.Literal("tool").annotate({ "title": "Type" }) + ) +}).annotate({ "identifier": "BetaManagedAgentsUpdateVaultRequestBody" }) +export type BetaManagedAgentsDeletedVault = { readonly "type": "vault_deleted"; readonly "id": string } +export const BetaManagedAgentsDeletedVault = Schema.Struct({ + "type": Schema.Literal("vault_deleted"), + "id": Schema.String.annotate({ "description": "Unique identifier of the deleted vault." }) +}).annotate({ "description": "Confirmation of a deleted vault.", "identifier": "BetaManagedAgentsDeletedVault" }) +export type BetaManagedAgentsMcpOauthRefreshResponse = { + readonly "token_endpoint": string + readonly "client_id": string + readonly "resource"?: string + readonly "scope"?: string + readonly "token_endpoint_auth": { readonly "type": "none" } | { readonly "type": "client_secret_basic" } | { + readonly "type": "client_secret_post" + } +} +export const BetaManagedAgentsMcpOauthRefreshResponse = Schema.Struct({ + "token_endpoint": Schema.String.annotate({ "description": "Token endpoint URL used to refresh the access token." }), + "client_id": Schema.String.annotate({ "description": "OAuth client ID." }), + "resource": Schema.optionalKey(Schema.String.annotate({ "description": "OAuth resource indicator." })), + "scope": Schema.optionalKey(Schema.String.annotate({ "description": "OAuth scope for the refresh request." })), + "token_endpoint_auth": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("none") }).annotate({ + "description": "Token endpoint requires no client authentication." + }), + Schema.Struct({ "type": Schema.Literal("client_secret_basic") }).annotate({ + "description": "Token endpoint uses HTTP Basic authentication with client credentials." + }), + Schema.Struct({ "type": Schema.Literal("client_secret_post") }).annotate({ + "description": "Token endpoint uses POST body authentication with client credentials." + }) + ], { mode: "oneOf" }) }).annotate({ - "title": "ToolChoiceTool", - "description": "The model will use the specified tool with `tool_choice.name`." + "description": "OAuth refresh token configuration returned in credential responses.", + "identifier": "BetaManagedAgentsMcpOauthRefreshResponse" }) -export type ToolSearchToolResultErrorCode = - | "invalid_tool_input" - | "unavailable" - | "too_many_requests" - | "execution_time_exceeded" -export const ToolSearchToolResultErrorCode = Schema.Literals([ - "invalid_tool_input", - "unavailable", - "too_many_requests", - "execution_time_exceeded" -]).annotate({ "title": "ToolSearchToolResultErrorCode" }) -export type URLImageSource = { readonly "type": "url"; readonly "url": string } -export const URLImageSource = Schema.Struct({ - "type": Schema.Literal("url").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "URLImageSource" }) -export type URLPDFSource = { readonly "type": "url"; readonly "url": string } -export const URLPDFSource = Schema.Struct({ - "type": Schema.Literal("url").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "URLPDFSource" }) -export type UserLocation = { - readonly "city"?: string | null - readonly "country"?: string | null - readonly "region"?: string | null - readonly "timezone"?: string | null - readonly "type": "approximate" +export type BetaManagedAgentsCredentialNetworkingResponse = { readonly "type": "unrestricted" } | { + readonly "type": "limited" + readonly "allowed_hosts": ReadonlyArray } -export const UserLocation = Schema.Struct({ - "city": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), Schema.Null]).annotate({ - "title": "City", - "description": "The city of the user." - }) - ), - "country": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(2)).check(Schema.isMaxLength(2)), Schema.Null]).annotate({ - "title": "Country", - "description": "The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user." +export const BetaManagedAgentsCredentialNetworkingResponse = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("unrestricted") }).annotate({ + "description": "The secret is substituted on any host the session's Environment network policy permits egress to." + }), + Schema.Struct({ + "type": Schema.Literal("limited"), + "allowed_hosts": Schema.Array(Schema.String).annotate({ + "description": + "Hostnames on which the secret will be substituted. An entry matches the request host exactly; a `*.`-prefixed entry matches any subdomain of the named domain but not the domain itself." + }) + }).annotate({ "description": "The secret is substituted only on requests to the listed hosts." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsCredentialNetworkingResponse" }) +export type BetaManagedAgentsInjectionLocationResponse = { readonly "header": boolean; readonly "body": boolean } +export const BetaManagedAgentsInjectionLocationResponse = Schema.Struct({ + "header": Schema.Boolean.annotate({ + "description": "Whether the placeholder is substituted in request header values." + }), + "body": Schema.Boolean.annotate({ "description": "Whether the placeholder is substituted in the request body." }) +}).annotate({ + "description": "Where in the outbound request the secret value is substituted.", + "identifier": "BetaManagedAgentsInjectionLocationResponse" +}) +export type BetaManagedAgentsMcpOauthRefreshParams = { + readonly "refresh_token": string + readonly "token_endpoint": string + readonly "client_id": string + readonly "scope"?: string + readonly "resource"?: string + readonly "token_endpoint_auth": { readonly "type": "none" } | { + readonly "type": "client_secret_basic" + readonly "client_secret": string + } | { readonly "type": "client_secret_post"; readonly "client_secret": string } +} +export const BetaManagedAgentsMcpOauthRefreshParams = Schema.Struct({ + "refresh_token": Schema.String.annotate({ "description": "OAuth refresh token." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" })), + "token_endpoint": Schema.String.annotate({ "description": "Token endpoint URL used to refresh the access token." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2047).annotate({ "expected": "a value with a length of at most 2047" }) + ), + "client_id": Schema.String.annotate({ "description": "OAuth client ID." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(1024).annotate({ "expected": "a value with a length of at most 1024" })), + "scope": Schema.optionalKey( + Schema.String.annotate({ "description": "OAuth scope for the refresh request." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(8192).annotate({ "expected": "a value with a length of at most 8192" })) + ), + "resource": Schema.optionalKey( + Schema.String.annotate({ "description": "OAuth resource indicator." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(2047).annotate({ "expected": "a value with a length of at most 2047" })) + ), + "token_endpoint_auth": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("none") }).annotate({ + "description": "Token endpoint requires no client authentication." + }), + Schema.Struct({ + "type": Schema.Literal("client_secret_basic"), + "client_secret": Schema.String.annotate({ "description": "OAuth client secret." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })) + }).annotate({ "description": "Token endpoint uses HTTP Basic authentication with client credentials." }), + Schema.Struct({ + "type": Schema.Literal("client_secret_post"), + "client_secret": Schema.String.annotate({ "description": "OAuth client secret." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })) + }).annotate({ "description": "Token endpoint uses POST body authentication with client credentials." }) + ], { mode: "oneOf" }) +}).annotate({ + "description": "OAuth refresh token parameters for creating a credential with refresh support.", + "identifier": "BetaManagedAgentsMcpOauthRefreshParams" +}) +export type BetaManagedAgentsCredentialNetworkingParams = { readonly "type": "unrestricted" } | { + readonly "type": "limited" + readonly "allowed_hosts": ReadonlyArray +} +export const BetaManagedAgentsCredentialNetworkingParams = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("unrestricted") }).annotate({ + "description": + "Substitute the secret on any host the session's Environment network policy permits egress to. The Environment's network policy is the only boundary on where the secret can reach." + }), + Schema.Struct({ + "type": Schema.Literal("limited"), + "allowed_hosts": Schema.Array(Schema.String).annotate({ + "description": + "Hostnames on which the secret will be substituted. Each entry is a bare hostname (`api.example.com`), an IPv4 address (`192.0.2.1`), or a `*.`-prefixed wildcard (`*.example.com`). URLs, ports, paths, and IPv6 addresses are not accepted. At most 16 entries." }) + }).annotate({ "description": "Substitute the secret only on requests to the listed hosts." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsCredentialNetworkingParams" }) +export type BetaManagedAgentsInjectionLocationParams = { readonly "header"?: boolean; readonly "body"?: boolean } +export const BetaManagedAgentsInjectionLocationParams = Schema.Struct({ + "header": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Substitute when the placeholder appears in a request header value." }) ), - "region": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), Schema.Null]).annotate({ - "title": "Region", - "description": "The region of the user." - }) + "body": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Substitute when the placeholder appears in the request body." }) + ) +}).annotate({ + "description": "Where in the outbound request the secret value may be substituted.", + "identifier": "BetaManagedAgentsInjectionLocationParams" +}) +export type BetaManagedAgentsMcpOauthRefreshUpdateParams = { + readonly "refresh_token"?: string + readonly "scope"?: string + readonly "token_endpoint_auth"?: { readonly "type": "client_secret_basic"; readonly "client_secret"?: string } | { + readonly "type": "client_secret_post" + readonly "client_secret"?: string + } +} +export const BetaManagedAgentsMcpOauthRefreshUpdateParams = Schema.Struct({ + "refresh_token": Schema.optionalKey( + Schema.String.annotate({ "description": "Updated OAuth refresh token." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" })) ), - "timezone": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), Schema.Null]).annotate({ - "title": "Timezone", - "description": "The [IANA timezone](https://nodatime.org/TimeZones) of the user." - }) + "scope": Schema.optionalKey( + Schema.String.annotate({ "description": "Updated OAuth scope for the refresh request." }).check( + Schema.isMaxLength(8192).annotate({ "expected": "a value with a length of at most 8192" }) + ) ), - "type": Schema.Literal("approximate").annotate({ "title": "Type" }) -}).annotate({ "title": "UserLocation" }) -export type WebFetchToolResultErrorCode = - | "invalid_tool_input" - | "url_too_long" - | "url_not_allowed" - | "url_not_accessible" - | "unsupported_content_type" - | "too_many_requests" - | "max_uses_exceeded" - | "unavailable" -export const WebFetchToolResultErrorCode = Schema.Literals([ - "invalid_tool_input", - "url_too_long", - "url_not_allowed", - "url_not_accessible", - "unsupported_content_type", - "too_many_requests", - "max_uses_exceeded", - "unavailable" -]).annotate({ "title": "WebFetchToolResultErrorCode" }) -export type WebSearchToolResultErrorCode = - | "invalid_tool_input" - | "unavailable" - | "max_uses_exceeded" - | "too_many_requests" - | "query_too_long" - | "request_too_large" -export const WebSearchToolResultErrorCode = Schema.Literals([ - "invalid_tool_input", - "unavailable", - "max_uses_exceeded", - "too_many_requests", - "query_too_long", - "request_too_large" -]).annotate({ "title": "WebSearchToolResultErrorCode" }) -export type StopReason = "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "pause_turn" | "refusal" -export const StopReason = Schema.Literals([ - "end_turn", - "max_tokens", - "stop_sequence", - "tool_use", - "pause_turn", - "refusal" -]) -export type BetaStopReason = - | "end_turn" - | "max_tokens" - | "stop_sequence" - | "tool_use" - | "pause_turn" - | "compaction" - | "refusal" - | "model_context_window_exceeded" -export const BetaStopReason = Schema.Literals([ - "end_turn", - "max_tokens", - "stop_sequence", - "tool_use", - "pause_turn", - "compaction", - "refusal", - "model_context_window_exceeded" -]) -export type Model = - | string - | "claude-sonnet-5" - | "claude-fable-5" - | "claude-mythos-5" - | "claude-opus-4-8" - | "claude-opus-4-7" - | "claude-mythos-preview" - | "claude-opus-4-6" - | "claude-sonnet-4-6" - | "claude-haiku-4-5" - | "claude-haiku-4-5-20251001" - | "claude-opus-4-5" - | "claude-opus-4-5-20251101" - | "claude-sonnet-4-5" - | "claude-sonnet-4-5-20250929" - | "claude-opus-4-1" - | "claude-opus-4-1-20250805" -export const Model = Schema.Union([ - Schema.String, - Schema.Literals([ - "claude-sonnet-5", - "claude-fable-5", - "claude-mythos-5", - "claude-opus-4-8", - "claude-opus-4-7", - "claude-mythos-preview", - "claude-opus-4-6", - "claude-sonnet-4-6", - "claude-haiku-4-5", - "claude-haiku-4-5-20251001", - "claude-opus-4-5", - "claude-opus-4-5-20251101", - "claude-sonnet-4-5", - "claude-sonnet-4-5-20250929", - "claude-opus-4-1", - "claude-opus-4-1-20250805" - ]) -]).annotate({ - "title": "Model", - "description": - "The model that will complete your prompt.\n\nSee [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options." + "token_endpoint_auth": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("client_secret_basic"), + "client_secret": Schema.optionalKey( + Schema.String.annotate({ "description": "Updated OAuth client secret." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })) + ) + }).annotate({ "description": "Updated HTTP Basic authentication parameters for the token endpoint." }), + Schema.Struct({ + "type": Schema.Literal("client_secret_post"), + "client_secret": Schema.optionalKey( + Schema.String.annotate({ "description": "Updated OAuth client secret." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })) + ) + }).annotate({ "description": "Updated POST body authentication parameters for the token endpoint." }) + ], { mode: "oneOf" })) +}).annotate({ + "description": "Parameters for updating OAuth refresh token configuration.", + "identifier": "BetaManagedAgentsMcpOauthRefreshUpdateParams" }) -export type BetaMemoryTool_20250818_ViewCommand = { - readonly "command": "view" - readonly "path": string - readonly "view_range"?: ReadonlyArray -} -export const BetaMemoryTool_20250818_ViewCommand = Schema.Struct({ - "command": Schema.Literal("view").annotate({ "description": "Command type identifier", "default": "view" }), - "path": Schema.String.annotate({ "description": "Path to directory or file to view" }), - "view_range": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "description": "Optional line range for viewing specific lines" - }).check(Schema.isMinLength(2)).check(Schema.isMaxLength(2)) +export type BetaManagedAgentsInjectionLocationUpdateParams = { readonly "header"?: boolean; readonly "body"?: boolean } +export const BetaManagedAgentsInjectionLocationUpdateParams = Schema.Struct({ + "header": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Substitute when the placeholder appears in a request header value." }) + ), + "body": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Substitute when the placeholder appears in the request body." }) ) +}).annotate({ + "description": "Updated injection location.", + "identifier": "BetaManagedAgentsInjectionLocationUpdateParams" }) -export type BetaMemoryTool_20250818_CreateCommand = { - readonly "command": "create" - readonly "path": string - readonly "file_text": string -} -export const BetaMemoryTool_20250818_CreateCommand = Schema.Struct({ - "command": Schema.Literal("create").annotate({ "description": "Command type identifier", "default": "create" }), - "path": Schema.String.annotate({ "description": "Path where the file should be created" }), - "file_text": Schema.String.annotate({ "description": "Content to write to the file" }) +export type BetaManagedAgentsDeletedCredential = { readonly "type": "vault_credential_deleted"; readonly "id": string } +export const BetaManagedAgentsDeletedCredential = Schema.Struct({ + "type": Schema.Literal("vault_credential_deleted"), + "id": Schema.String.annotate({ "description": "Unique identifier of the deleted credential." }) +}).annotate({ + "description": "Confirmation of a deleted credential.", + "identifier": "BetaManagedAgentsDeletedCredential" }) -export type BetaMemoryTool_20250818_StrReplaceCommand = { - readonly "command": "str_replace" - readonly "path": string - readonly "old_str": string - readonly "new_str": string -} -export const BetaMemoryTool_20250818_StrReplaceCommand = Schema.Struct({ - "command": Schema.Literal("str_replace").annotate({ - "description": "Command type identifier", - "default": "str_replace" +export type BetaManagedAgentsCredentialValidationStatus = "valid" | "invalid" | "unknown" +export const BetaManagedAgentsCredentialValidationStatus = Schema.Literals(["valid", "invalid", "unknown"]).annotate({ + "description": "Overall verdict of a credential validation probe.", + "identifier": "BetaManagedAgentsCredentialValidationStatus" +}) +export type BetaManagedAgentsRefreshHttpResponse = { + readonly "status_code": number + readonly "content_type": string + readonly "body": string + readonly "body_truncated": boolean +} +export const BetaManagedAgentsRefreshHttpResponse = Schema.Struct({ + "status_code": Schema.Number.annotate({ "description": "HTTP status code.", "format": "int32" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "content_type": Schema.String.annotate({ "description": "Value of the `Content-Type` response header." }), + "body": Schema.String.annotate({ + "description": "Response body. May be truncated and has sensitive values scrubbed." }), - "path": Schema.String.annotate({ "description": "Path to the file where text should be replaced" }), - "old_str": Schema.String.annotate({ "description": "Text to search for and replace" }), - "new_str": Schema.String.annotate({ "description": "Text to replace with" }) + "body_truncated": Schema.Boolean.annotate({ "description": "Whether `body` was truncated." }) +}).annotate({ + "description": "An HTTP response captured during a credential validation probe.", + "identifier": "BetaManagedAgentsRefreshHttpResponse" }) -export type BetaMemoryTool_20250818_InsertCommand = { - readonly "command": "insert" - readonly "path": string - readonly "insert_line": number - readonly "insert_text": string -} -export const BetaMemoryTool_20250818_InsertCommand = Schema.Struct({ - "command": Schema.Literal("insert").annotate({ "description": "Command type identifier", "default": "insert" }), - "path": Schema.String.annotate({ "description": "Path to the file where text should be inserted" }), - "insert_line": Schema.Number.annotate({ "description": "Line number where text should be inserted" }).check( - Schema.isInt() - ).check(Schema.isGreaterThanOrEqualTo(1)), - "insert_text": Schema.String.annotate({ "description": "Text to insert at the specified line" }) -}) -export type BetaMemoryTool_20250818_DeleteCommand = { readonly "command": "delete"; readonly "path": string } -export const BetaMemoryTool_20250818_DeleteCommand = Schema.Struct({ - "command": Schema.Literal("delete").annotate({ "description": "Command type identifier", "default": "delete" }), - "path": Schema.String.annotate({ "description": "Path to the file or directory to delete" }) -}) -export type BetaMemoryTool_20250818_RenameCommand = { - readonly "command": "rename" - readonly "old_path": string - readonly "new_path": string -} -export const BetaMemoryTool_20250818_RenameCommand = Schema.Struct({ - "command": Schema.Literal("rename").annotate({ "description": "Command type identifier", "default": "rename" }), - "old_path": Schema.String.annotate({ "description": "Current path of the file or directory" }), - "new_path": Schema.String.annotate({ "description": "New path for the file or directory" }) +export type BetaManagedAgentsCredentialRefreshStatus = "succeeded" | "failed" | "connect_error" | "no_refresh_token" +export const BetaManagedAgentsCredentialRefreshStatus = Schema.Literals([ + "succeeded", + "failed", + "connect_error", + "no_refresh_token" +]).annotate({ + "description": "Outcome of a refresh-token exchange attempted during credential validation.", + "identifier": "BetaManagedAgentsCredentialRefreshStatus" }) -export type RequestBashCodeExecutionToolResultError = { - readonly "error_code": BashCodeExecutionToolResultErrorCode - readonly "type": "bash_code_execution_tool_result_error" -} -export const RequestBashCodeExecutionToolResultError = Schema.Struct({ - "error_code": BashCodeExecutionToolResultErrorCode, - "type": Schema.Literal("bash_code_execution_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestBashCodeExecutionToolResultError" }) -export type ResponseBashCodeExecutionToolResultError = { - readonly "error_code": BashCodeExecutionToolResultErrorCode - readonly "type": "bash_code_execution_tool_result_error" +export type CompletionResponse = { + readonly "completion": string + readonly "id": string + readonly "model": Model + readonly "stop_reason": string | null + readonly "type": "completion" } -export const ResponseBashCodeExecutionToolResultError = Schema.Struct({ - "error_code": BashCodeExecutionToolResultErrorCode, - "type": Schema.Literal("bash_code_execution_tool_result_error").annotate({ - "title": "Type", - "default": "bash_code_execution_tool_result_error" - }) -}).annotate({ "title": "ResponseBashCodeExecutionToolResultError" }) -export type BetaRequestBashCodeExecutionToolResultError = { - readonly "error_code": BetaBashCodeExecutionToolResultErrorCode - readonly "type": "bash_code_execution_tool_result_error" -} -export const BetaRequestBashCodeExecutionToolResultError = Schema.Struct({ - "error_code": BetaBashCodeExecutionToolResultErrorCode, - "type": Schema.Literal("bash_code_execution_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestBashCodeExecutionToolResultError" }) -export type BetaResponseBashCodeExecutionToolResultError = { - readonly "error_code": BetaBashCodeExecutionToolResultErrorCode - readonly "type": "bash_code_execution_tool_result_error" -} -export const BetaResponseBashCodeExecutionToolResultError = Schema.Struct({ - "error_code": BetaBashCodeExecutionToolResultErrorCode, - "type": Schema.Literal("bash_code_execution_tool_result_error").annotate({ - "title": "Type", - "default": "bash_code_execution_tool_result_error" - }) -}).annotate({ "title": "ResponseBashCodeExecutionToolResultError" }) -export type BetaCodeExecutionTool_20250522 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "defer_loading"?: boolean - readonly "name": "code_execution" - readonly "strict"?: boolean - readonly "type": "code_execution_20250522" -} -export const BetaCodeExecutionTool_20250522 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Defer Loading", - "description": - "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." - }) - ), - "name": Schema.Literal("code_execution").annotate({ - "title": "Name", - "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." +export const CompletionResponse = Schema.Struct({ + "completion": Schema.String.annotate({ + "title": "Completion", + "description": "The resulting completion up to and excluding the stop sequences." }), - "strict": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Strict", - "description": "When true, guarantees schema validation on tool names and inputs" - }) - ), - "type": Schema.Literal("code_execution_20250522").annotate({ "title": "Type" }) -}).annotate({ "title": "CodeExecutionTool_20250522" }) -export type BetaCodeExecutionTool_20250825 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "defer_loading"?: boolean - readonly "name": "code_execution" - readonly "strict"?: boolean - readonly "type": "code_execution_20250825" -} -export const BetaCodeExecutionTool_20250825 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Defer Loading", - "description": - "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." - }) - ), - "name": Schema.Literal("code_execution").annotate({ - "title": "Name", - "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." }), - "strict": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Strict", - "description": "When true, guarantees schema validation on tool names and inputs" - }) - ), - "type": Schema.Literal("code_execution_20250825").annotate({ "title": "Type" }) -}).annotate({ "title": "CodeExecutionTool_20250825" }) -export type BetaCodeExecutionTool_20260120 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "defer_loading"?: boolean - readonly "name": "code_execution" - readonly "strict"?: boolean - readonly "type": "code_execution_20260120" -} -export const BetaCodeExecutionTool_20260120 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Defer Loading", - "description": - "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." - }) - ), - "name": Schema.Literal("code_execution").annotate({ - "title": "Name", - "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + "model": Model, + "stop_reason": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Stop Reason", + "description": + "The reason that we stopped.\n\nThis may be one the following values:\n* `\"stop_sequence\"`: we reached a stop sequence — either provided by you via the `stop_sequences` parameter, or a stop sequence built into the model\n* `\"max_tokens\"`: we exceeded `max_tokens_to_sample` or the model's maximum" }), - "strict": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Strict", - "description": "When true, guarantees schema validation on tool names and inputs" - }) - ), - "type": Schema.Literal("code_execution_20260120").annotate({ "title": "Type" }) -}).annotate({ - "title": "CodeExecutionTool_20260120", - "description": "Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint)." + "type": Schema.Literal("completion").annotate({ + "title": "Type", + "description": "Object type.\n\nFor Text Completions, this is always `\"completion\"`.", + "default": "completion" + }) +}).annotate({ "title": "CompletionResponse", "identifier": "CompletionResponse" }) +export type BetaRequestFallbackHopInfo = { readonly "model": Model } +export const BetaRequestFallbackHopInfo = Schema.Struct({ "model": Model }).annotate({ + "title": "RequestFallbackHopInfo", + "description": "Identifies one hop of a fallback transition.", + "identifier": "BetaRequestFallbackHopInfo" }) -export type BetaRequestCompactionBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "content": string | null - readonly "type": "compaction" +export type BetaResponseFallbackHopInfo = { readonly "model": Model } +export const BetaResponseFallbackHopInfo = Schema.Struct({ "model": Model }).annotate({ + "title": "ResponseFallbackHopInfo", + "description": "Identifies one hop of a fallback transition.", + "identifier": "BetaResponseFallbackHopInfo" +}) +export type RequestToolReferenceBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "tool_name": string + readonly "type": "tool_reference" } -export const BetaRequestCompactionBlock = Schema.Struct({ +export const RequestToolReferenceBlock = Schema.Struct({ "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "content": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Content", - "description": "Summary of previously compacted content, or null if compaction failed" - }), - "type": Schema.Literal("compaction").annotate({ "title": "Type" }) + "tool_name": Schema.String.annotate({ "title": "Tool Name" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,256}$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]{1,256}$" + }) + ), + "type": Schema.Literal("tool_reference").annotate({ "title": "Type" }) }).annotate({ - "title": "RequestCompactionBlock", - "description": - "A compaction block containing summary of previous context.\n\nUsers should round-trip these blocks from responses to subsequent requests\nto maintain context across compaction boundaries.\n\nWhen content is None, the block represents a failed compaction. The server\ntreats these as no-ops. Empty string content is not allowed." + "title": "RequestToolReferenceBlock", + "description": "Tool reference block that can be included in tool_result content.", + "identifier": "RequestToolReferenceBlock" }) -export type BetaRequestContainerUploadBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null +export type RequestContainerUploadBlock = { + readonly "cache_control"?: CacheControlEphemeral | null readonly "file_id": string readonly "type": "container_upload" } -export const BetaRequestContainerUploadBlock = Schema.Struct({ +export const RequestContainerUploadBlock = Schema.Struct({ "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -3179,310 +4955,535 @@ export const BetaRequestContainerUploadBlock = Schema.Struct({ }).annotate({ "title": "RequestContainerUploadBlock", "description": - "A content block that represents a file to be uploaded to the container\nFiles uploaded via this block will be available in the container's input directory." + "A content block that represents a file to be uploaded to the container\nFiles uploaded via this block will be available in the container's input directory.", + "identifier": "RequestContainerUploadBlock" }) -export type BetaRequestMCPToolUseBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "id": string - readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": string - readonly "server_name": string - readonly "type": "mcp_tool_use" +export type RequestTextBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "citations"?: + | ReadonlyArray< + | RequestCharLocationCitation + | RequestPageLocationCitation + | RequestContentBlockLocationCitation + | RequestWebSearchResultLocationCitation + | RequestSearchResultLocationCitation + > + | null + readonly "text": string + readonly "type": "text" } -export const BetaRequestMCPToolUseBlock = Schema.Struct({ +export const RequestTextBlock = Schema.Struct({ "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.String.annotate({ "title": "Name" }), - "server_name": Schema.String.annotate({ "title": "Server Name", "description": "The name of the MCP server" }), - "type": Schema.Literal("mcp_tool_use").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestMCPToolUseBlock" }) -export type BetaRequestToolReferenceBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "tool_name": string - readonly "type": "tool_reference" + "citations": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Union([ + RequestCharLocationCitation, + RequestPageLocationCitation, + RequestContentBlockLocationCitation, + RequestWebSearchResultLocationCitation, + RequestSearchResultLocationCitation + ], { mode: "oneOf" }) + ), + Schema.Null + ]).annotate({ "title": "Citations" }) + ), + "text": Schema.String.annotate({ "title": "Text" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "type": Schema.Literal("text").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestTextBlock", "identifier": "RequestTextBlock" }) +export type RequestImageBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "source": Base64ImageSource | URLImageSource + readonly "type": "image" } -export const BetaRequestToolReferenceBlock = Schema.Struct({ +export const RequestImageBlock = Schema.Struct({ "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "tool_name": Schema.String.annotate({ "title": "Tool Name" }).check(Schema.isMinLength(1)).check( - Schema.isMaxLength(256) - ).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,256}$"))), - "type": Schema.Literal("tool_reference").annotate({ "title": "Type" }) -}).annotate({ - "title": "RequestToolReferenceBlock", - "description": "Tool reference block that can be included in tool_result content." -}) -export type BetaToolSearchToolBM25_20251119 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "defer_loading"?: boolean - readonly "name": "tool_search_tool_bm25" - readonly "strict"?: boolean - readonly "type": "tool_search_tool_bm25_20251119" | "tool_search_tool_bm25" + "source": Schema.Union([Base64ImageSource, URLImageSource], { mode: "oneOf" }).annotate({ "title": "Source" }), + "type": Schema.Literal("image").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestImageBlock", "identifier": "RequestImageBlock" }) +export type RequestToolUseBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "caller"?: DirectCaller | ServerToolCaller | ServerToolCaller_20260120 + readonly "id": string + readonly "input": { readonly [x: string]: Schema.Json } + readonly "name": string + readonly "type": "tool_use" } -export const BetaToolSearchToolBM25_20251119 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const RequestToolUseBlock = Schema.Struct({ "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Defer Loading", - "description": - "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + "caller": Schema.optionalKey( + Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "name": Schema.Literal("tool_search_tool_bm25").annotate({ - "title": "Name", - "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." - }), - "strict": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Strict", - "description": "When true, guarantees schema validation on tool names and inputs" + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), - "type": Schema.Literals(["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]).annotate({ "title": "Type" }) -}).annotate({ "title": "ToolSearchToolBM25_20251119" }) -export type BetaToolSearchToolRegex_20251119 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "defer_loading"?: boolean - readonly "name": "tool_search_tool_regex" - readonly "strict"?: boolean - readonly "type": "tool_search_tool_regex_20251119" | "tool_search_tool_regex" + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" + }), + "name": Schema.String.annotate({ "title": "Name" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(200).annotate({ "expected": "a value with a length of at most 200" })), + "type": Schema.Literal("tool_use").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestToolUseBlock", "identifier": "RequestToolUseBlock" }) +export type RequestServerToolUseBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "caller"?: DirectCaller | ServerToolCaller | ServerToolCaller_20260120 + readonly "id": string + readonly "input": { readonly [x: string]: Schema.Json } + readonly "name": + | "web_search" + | "web_fetch" + | "code_execution" + | "bash_code_execution" + | "text_editor_code_execution" + | "tool_search_tool_regex" + | "tool_search_tool_bm25" + readonly "type": "server_tool_use" } -export const BetaToolSearchToolRegex_20251119 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const RequestServerToolUseBlock = Schema.Struct({ "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Defer Loading", - "description": - "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + "caller": Schema.optionalKey( + Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "name": Schema.Literal("tool_search_tool_regex").annotate({ - "title": "Name", - "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" + }) + ), + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" }), - "strict": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Strict", - "description": "When true, guarantees schema validation on tool names and inputs" + "name": Schema.Literals([ + "web_search", + "web_fetch", + "code_execution", + "bash_code_execution", + "text_editor_code_execution", + "tool_search_tool_regex", + "tool_search_tool_bm25" + ]).annotate({ "title": "Name" }), + "type": Schema.Literal("server_tool_use").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestServerToolUseBlock", "identifier": "RequestServerToolUseBlock" }) +export type ResponseToolUseBlock = { + readonly "caller": DirectCaller | ServerToolCaller | ServerToolCaller_20260120 + readonly "id": string + readonly "input": { readonly [x: string]: Schema.Json } + readonly "name": string + readonly "type": "tool_use" +} +export const ResponseToolUseBlock = Schema.Struct({ + "caller": Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller", + "default": { "type": "direct" } + }), + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), - "type": Schema.Literals(["tool_search_tool_regex_20251119", "tool_search_tool_regex"]).annotate({ "title": "Type" }) -}).annotate({ "title": "ToolSearchToolRegex_20251119" }) -export type BetaCompactionIterationUsage = { - readonly "cache_creation": BetaCacheCreation | null - readonly "cache_creation_input_tokens": number - readonly "cache_read_input_tokens": number - readonly "input_tokens": number - readonly "output_tokens": number - readonly "type": "compaction" + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" + }), + "name": Schema.String.annotate({ "title": "Name" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "type": Schema.Literal("tool_use").annotate({ "title": "Type", "default": "tool_use" }) +}).annotate({ "title": "ResponseToolUseBlock", "identifier": "ResponseToolUseBlock" }) +export type ResponseServerToolUseBlock = { + readonly "caller": DirectCaller | ServerToolCaller | ServerToolCaller_20260120 + readonly "id": string + readonly "input": { readonly [x: string]: Schema.Json } + readonly "name": + | "web_search" + | "web_fetch" + | "code_execution" + | "bash_code_execution" + | "text_editor_code_execution" + | "tool_search_tool_regex" + | "tool_search_tool_bm25" + readonly "type": "server_tool_use" } -export const BetaCompactionIterationUsage = Schema.Struct({ - "cache_creation": Schema.Union([BetaCacheCreation, Schema.Null]).annotate({ - "description": "Breakdown of cached tokens by TTL", - "default": null +export const ResponseServerToolUseBlock = Schema.Struct({ + "caller": Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller", + "default": { "type": "direct" } }), - "cache_creation_input_tokens": Schema.Number.annotate({ - "title": "Cache Creation Input Tokens", - "description": "The number of input tokens used to create the cache entry.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "cache_read_input_tokens": Schema.Number.annotate({ - "title": "Cache Read Input Tokens", - "description": "The number of input tokens read from the cache.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "input_tokens": Schema.Number.annotate({ - "title": "Input Tokens", - "description": "The number of input tokens which were used." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "output_tokens": Schema.Number.annotate({ - "title": "Output Tokens", - "description": "The number of output tokens which were used." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "type": Schema.Literal("compaction").annotate({ + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" + }) + ), + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" + }), + "name": Schema.Literals([ + "web_search", + "web_fetch", + "code_execution", + "bash_code_execution", + "text_editor_code_execution", + "tool_search_tool_regex", + "tool_search_tool_bm25" + ]).annotate({ "title": "Name" }), + "type": Schema.Literal("server_tool_use").annotate({ "title": "Type", "default": "server_tool_use" }) +}).annotate({ "title": "ResponseServerToolUseBlock", "identifier": "ResponseServerToolUseBlock" }) +export type RequestWebSearchToolResultError = { + readonly "error_code": WebSearchToolResultErrorCode + readonly "type": "web_search_tool_result_error" +} +export const RequestWebSearchToolResultError = Schema.Struct({ + "error_code": WebSearchToolResultErrorCode, + "type": Schema.Literal("web_search_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestWebSearchToolResultError", "identifier": "RequestWebSearchToolResultError" }) +export type ResponseWebSearchToolResultError = { + readonly "error_code": WebSearchToolResultErrorCode + readonly "type": "web_search_tool_result_error" +} +export const ResponseWebSearchToolResultError = Schema.Struct({ + "error_code": WebSearchToolResultErrorCode, + "type": Schema.Literal("web_search_tool_result_error").annotate({ "title": "Type", - "description": "Usage for a compaction iteration", - "default": "compaction" + "default": "web_search_tool_result_error" }) -}).annotate({ "title": "CompactionIterationUsage", "description": "Token usage for a compaction iteration." }) -export type BetaMessageIterationUsage = { - readonly "cache_creation": BetaCacheCreation | null - readonly "cache_creation_input_tokens": number - readonly "cache_read_input_tokens": number - readonly "input_tokens": number - readonly "output_tokens": number - readonly "type": "message" +}).annotate({ "title": "ResponseWebSearchToolResultError", "identifier": "ResponseWebSearchToolResultError" }) +export type RequestWebFetchToolResultError = { + readonly "error_code": WebFetchToolResultErrorCode + readonly "type": "web_fetch_tool_result_error" } -export const BetaMessageIterationUsage = Schema.Struct({ - "cache_creation": Schema.Union([BetaCacheCreation, Schema.Null]).annotate({ - "description": "Breakdown of cached tokens by TTL", - "default": null - }), - "cache_creation_input_tokens": Schema.Number.annotate({ - "title": "Cache Creation Input Tokens", - "description": "The number of input tokens used to create the cache entry.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "cache_read_input_tokens": Schema.Number.annotate({ - "title": "Cache Read Input Tokens", - "description": "The number of input tokens read from the cache.", - "default": 0 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "input_tokens": Schema.Number.annotate({ - "title": "Input Tokens", - "description": "The number of input tokens which were used." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "output_tokens": Schema.Number.annotate({ - "title": "Output Tokens", - "description": "The number of output tokens which were used." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "type": Schema.Literal("message").annotate({ +export const RequestWebFetchToolResultError = Schema.Struct({ + "error_code": WebFetchToolResultErrorCode, + "type": Schema.Literal("web_fetch_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestWebFetchToolResultError", "identifier": "RequestWebFetchToolResultError" }) +export type ResponseWebFetchToolResultError = { + readonly "error_code": WebFetchToolResultErrorCode + readonly "type": "web_fetch_tool_result_error" +} +export const ResponseWebFetchToolResultError = Schema.Struct({ + "error_code": WebFetchToolResultErrorCode, + "type": Schema.Literal("web_fetch_tool_result_error").annotate({ "title": "Type", - "description": "Usage for a sampling iteration", - "default": "message" + "default": "web_fetch_tool_result_error" }) -}).annotate({ "title": "MessageIterationUsage", "description": "Token usage for a sampling iteration." }) -export type BetaRequestCodeExecutionToolResultError = { - readonly "error_code": BetaCodeExecutionToolResultErrorCode +}).annotate({ "title": "ResponseWebFetchToolResultError", "identifier": "ResponseWebFetchToolResultError" }) +export type RequestCodeExecutionToolResultError = { + readonly "error_code": CodeExecutionToolResultErrorCode readonly "type": "code_execution_tool_result_error" } -export const BetaRequestCodeExecutionToolResultError = Schema.Struct({ - "error_code": BetaCodeExecutionToolResultErrorCode, +export const RequestCodeExecutionToolResultError = Schema.Struct({ + "error_code": CodeExecutionToolResultErrorCode, "type": Schema.Literal("code_execution_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "Error" }) -export type BetaResponseCodeExecutionToolResultError = { - readonly "error_code": BetaCodeExecutionToolResultErrorCode +}).annotate({ "title": "RequestCodeExecutionToolResultError", "identifier": "RequestCodeExecutionToolResultError" }) +export type ResponseCodeExecutionToolResultError = { + readonly "error_code": CodeExecutionToolResultErrorCode readonly "type": "code_execution_tool_result_error" } -export const BetaResponseCodeExecutionToolResultError = Schema.Struct({ - "error_code": BetaCodeExecutionToolResultErrorCode, +export const ResponseCodeExecutionToolResultError = Schema.Struct({ + "error_code": CodeExecutionToolResultErrorCode, "type": Schema.Literal("code_execution_tool_result_error").annotate({ "title": "Type", "default": "code_execution_tool_result_error" }) -}).annotate({ "title": "ResponseCodeExecutionToolResultError" }) -export type BetaCountMessageTokensResponse = { - readonly "context_management": BetaContextManagementResponse | null - readonly "input_tokens": number -} -export const BetaCountMessageTokensResponse = Schema.Struct({ - "context_management": Schema.Union([BetaContextManagementResponse, Schema.Null]).annotate({ - "description": "Information about context management applied to the message." - }), - "input_tokens": Schema.Number.annotate({ - "title": "Input Tokens", - "description": "The total number of tokens across the provided list of messages, system prompt, and tools." - }).check(Schema.isInt()) -}).annotate({ "title": "CountMessageTokensResponse" }) -export type BetaFileListResponse = { - readonly "data": ReadonlyArray - readonly "first_id"?: string | null - readonly "has_more"?: boolean - readonly "last_id"?: string | null +}).annotate({ "title": "ResponseCodeExecutionToolResultError", "identifier": "ResponseCodeExecutionToolResultError" }) +export type RequestCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "code_execution_result" } -export const BetaFileListResponse = Schema.Struct({ - "data": Schema.Array(BetaFileMetadataSchema).annotate({ - "title": "Data", - "description": "List of file metadata objects." - }), - "first_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "First Id", - "description": "ID of the first file in this page of results." - }) - ), - "has_more": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Has More", - "description": "Whether there are more results available.", - "default": false - }) +export const RequestCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(RequestCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "last_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Last Id", - "description": "ID of the last file in this page of results." - }) - ) -}).annotate({ "title": "FileListResponse" }) -export type BetaCompact20260112 = { - readonly "instructions"?: string | null - readonly "pause_after_compaction"?: boolean - readonly "trigger"?: BetaInputTokensTrigger | null - readonly "type": "compact_20260112" + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "stdout": Schema.String.annotate({ "title": "Stdout" }), + "type": Schema.Literal("code_execution_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestCodeExecutionResultBlock", "identifier": "RequestCodeExecutionResultBlock" }) +export type RequestEncryptedCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "encrypted_stdout": string + readonly "return_code": number + readonly "stderr": string + readonly "type": "encrypted_code_execution_result" } -export const BetaCompact20260112 = Schema.Struct({ - "instructions": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Instructions", - "description": "Additional instructions for summarization." +export const RequestEncryptedCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(RequestCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "encrypted_stdout": Schema.String.annotate({ "title": "Encrypted Stdout" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "type": Schema.Literal("encrypted_code_execution_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestEncryptedCodeExecutionResultBlock", + "description": "Code execution result with encrypted stdout for PFC + web_search results.", + "identifier": "RequestEncryptedCodeExecutionResultBlock" +}) +export type RequestBashCodeExecutionToolResultError = { + readonly "error_code": BashCodeExecutionToolResultErrorCode + readonly "type": "bash_code_execution_tool_result_error" +} +export const RequestBashCodeExecutionToolResultError = Schema.Struct({ + "error_code": BashCodeExecutionToolResultErrorCode, + "type": Schema.Literal("bash_code_execution_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestBashCodeExecutionToolResultError", + "identifier": "RequestBashCodeExecutionToolResultError" +}) +export type ResponseBashCodeExecutionToolResultError = { + readonly "error_code": BashCodeExecutionToolResultErrorCode + readonly "type": "bash_code_execution_tool_result_error" +} +export const ResponseBashCodeExecutionToolResultError = Schema.Struct({ + "error_code": BashCodeExecutionToolResultErrorCode, + "type": Schema.Literal("bash_code_execution_tool_result_error").annotate({ + "title": "Type", + "default": "bash_code_execution_tool_result_error" + }) +}).annotate({ + "title": "ResponseBashCodeExecutionToolResultError", + "identifier": "ResponseBashCodeExecutionToolResultError" +}) +export type RequestBashCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "bash_code_execution_result" +} +export const RequestBashCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(RequestBashCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "stdout": Schema.String.annotate({ "title": "Stdout" }), + "type": Schema.Literal("bash_code_execution_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestBashCodeExecutionResultBlock", "identifier": "RequestBashCodeExecutionResultBlock" }) +export type RequestTextEditorCodeExecutionToolResultError = { + readonly "error_code": TextEditorCodeExecutionToolResultErrorCode + readonly "error_message"?: string | null + readonly "type": "text_editor_code_execution_tool_result_error" +} +export const RequestTextEditorCodeExecutionToolResultError = Schema.Struct({ + "error_code": TextEditorCodeExecutionToolResultErrorCode, + "error_message": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message" }) + ), + "type": Schema.Literal("text_editor_code_execution_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionToolResultError", + "identifier": "RequestTextEditorCodeExecutionToolResultError" +}) +export type ResponseTextEditorCodeExecutionToolResultError = { + readonly "error_code": TextEditorCodeExecutionToolResultErrorCode + readonly "error_message": string | null + readonly "type": "text_editor_code_execution_tool_result_error" +} +export const ResponseTextEditorCodeExecutionToolResultError = Schema.Struct({ + "error_code": TextEditorCodeExecutionToolResultErrorCode, + "error_message": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message", "default": null }), + "type": Schema.Literal("text_editor_code_execution_tool_result_error").annotate({ + "title": "Type", + "default": "text_editor_code_execution_tool_result_error" + }) +}).annotate({ + "title": "ResponseTextEditorCodeExecutionToolResultError", + "identifier": "ResponseTextEditorCodeExecutionToolResultError" +}) +export type RequestToolSearchToolResultError = { + readonly "error_code": ToolSearchToolResultErrorCode + readonly "error_message"?: string | null + readonly "type": "tool_search_tool_result_error" +} +export const RequestToolSearchToolResultError = Schema.Struct({ + "error_code": ToolSearchToolResultErrorCode, + "error_message": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message" }) + ), + "type": Schema.Literal("tool_search_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestToolSearchToolResultError", "identifier": "RequestToolSearchToolResultError" }) +export type ResponseToolSearchToolResultError = { + readonly "error_code": ToolSearchToolResultErrorCode + readonly "error_message": string | null + readonly "type": "tool_search_tool_result_error" +} +export const ResponseToolSearchToolResultError = Schema.Struct({ + "error_code": ToolSearchToolResultErrorCode, + "error_message": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message", "default": null }), + "type": Schema.Literal("tool_search_tool_result_error").annotate({ + "title": "Type", + "default": "tool_search_tool_result_error" + }) +}).annotate({ "title": "ResponseToolSearchToolResultError", "identifier": "ResponseToolSearchToolResultError" }) +export type CompletionRequest = { + readonly "model": Model + readonly "prompt": string + readonly "max_tokens_to_sample": number + readonly "stop_sequences"?: ReadonlyArray + readonly "temperature"?: number + readonly "top_p"?: number + readonly "top_k"?: number + readonly "metadata"?: Metadata + readonly "stream"?: boolean +} +export const CompletionRequest = Schema.Struct({ + "model": Model, + "prompt": Schema.String.annotate({ + "title": "Prompt", + "description": + "The prompt that you want Claude to complete.\n\nFor proper response generation you will need to format your prompt using alternating `\\n\\nHuman:` and `\\n\\nAssistant:` conversational turns. For example:\n\n```\n\"\\n\\nHuman: {userQuestion}\\n\\nAssistant:\"\n```\n\nSee [prompt validation](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) and our guide to [prompt design](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview) for more details." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "max_tokens_to_sample": Schema.Number.annotate({ + "title": "Max Tokens To Sample", + "description": + "The maximum number of tokens to generate before stopping.\n\nNote that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + "stop_sequences": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "title": "Stop Sequences", + "description": + "Sequences that will cause the model to stop generating.\n\nOur models stop on `\"\\n\\nHuman:\"`, and may include additional built-in stop sequences in the future. By providing the stop_sequences parameter, you may include additional strings that will cause the model to stop generating." }) ), - "pause_after_compaction": Schema.optionalKey( + "temperature": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Temperature", + "description": + "Amount of randomness injected into the response.\n\nDefaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.\n\nNote that even with `temperature` of `0.0`, the results will not be fully deterministic." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) + ), + "top_p": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Top P", + "description": + "Use nucleus sampling.\n\nIn nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`.\n\nRecommended for advanced use cases only." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) + ), + "top_k": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Top K", + "description": + "Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\nRecommended for advanced use cases only." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) + ), + "metadata": Schema.optionalKey( + Schema.suspend((): Schema.Codec => Metadata).annotate({ + "description": "An object describing metadata about the request." + }) + ), + "stream": Schema.optionalKey( Schema.Boolean.annotate({ - "title": "Pause After Compaction", - "description": "Whether to pause after compaction and return the compaction block to the user." + "title": "Stream", + "description": + "Whether to incrementally stream the response using server-sent events.\n\nSee [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming) for details." + }) + ) +}).annotate({ "title": "CompletionRequest", "identifier": "CompletionRequest" }) +export type OutputConfig = { readonly "effort"?: EffortLevel | null; readonly "format"?: JsonOutputFormat | null } +export const OutputConfig = Schema.Struct({ + "effort": Schema.optionalKey( + Schema.Union([EffortLevel, Schema.Null]).annotate({ + "description": + "How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.\n\nValid values are `low`, `medium`, `high`, `xhigh`, or `max`." }) ), - "trigger": Schema.optionalKey( - Schema.Union([BetaInputTokensTrigger, Schema.Null]).annotate({ - "description": "When to trigger compaction. Defaults to 150000 input tokens." + "format": Schema.optionalKey( + Schema.Union([JsonOutputFormat, Schema.Null]).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({ "title": "OutputConfig", "identifier": "OutputConfig" }) +export type ThinkingConfigEnabled = { + readonly "budget_tokens": number + readonly "display"?: ThinkingDisplayMode | null + readonly "type": "enabled" +} +export const ThinkingConfigEnabled = Schema.Struct({ + "budget_tokens": Schema.Number.annotate({ + "title": "Budget Tokens", + "description": + "Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.\n\nMust be ≥1024 and less than `max_tokens`.\n\nSee [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1024).annotate({ "expected": "a value greater than or equal to 1024" }) + ), + "display": Schema.optionalKey( + Schema.Union([ThinkingDisplayMode, Schema.Null]).annotate({ + "description": + "Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`." }) ), - "type": Schema.Literal("compact_20260112").annotate({ "title": "Type" }) + "type": Schema.Literal("enabled").annotate({ "title": "Type" }) +}).annotate({ "title": "ThinkingConfigEnabled", "identifier": "ThinkingConfigEnabled" }) +export type ThinkingConfigAdaptive = { readonly "display"?: ThinkingDisplayMode | null; readonly "type": "adaptive" } +export const ThinkingConfigAdaptive = Schema.Struct({ + "display": Schema.optionalKey( + Schema.Union([ThinkingDisplayMode, Schema.Null]).annotate({ + "description": + "Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`." + }) + ), + "type": Schema.Literal("adaptive").annotate({ "title": "Type" }) +}).annotate({ "title": "ThinkingConfigAdaptive", "identifier": "ThinkingConfigAdaptive" }) +export type ToolChoice = ToolChoiceAuto | ToolChoiceAny | ToolChoiceTool | ToolChoiceNone +export const ToolChoice = Schema.Union([ToolChoiceAuto, ToolChoiceAny, ToolChoiceTool, ToolChoiceNone], { + mode: "oneOf" }).annotate({ - "title": "Compact20260112", - "description": "Automatically compact older context when reaching the configured trigger threshold." + "title": "Tool Choice", + "description": + "How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.", + "identifier": "ToolChoice" }) -export type BetaBashTool_20241022 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null +export type CodeExecutionTool_20250522 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "name": "bash" + readonly "name": "code_execution" readonly "strict"?: boolean - readonly "type": "bash_20241022" + readonly "type": "code_execution_20250522" } -export const BetaBashTool_20241022 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const CodeExecutionTool_20250522 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -3494,10 +5495,7 @@ export const BetaBashTool_20241022 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) - ), - "name": Schema.Literal("bash").annotate({ + "name": Schema.Literal("code_execution").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -3507,25 +5505,20 @@ export const BetaBashTool_20241022 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("bash_20241022").annotate({ "title": "Type" }) -}).annotate({ "title": "BashTool_20241022" }) -export type BetaBashTool_20250124 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null + "type": Schema.Literal("code_execution_20250522").annotate({ "title": "Type" }) +}).annotate({ "title": "CodeExecutionTool_20250522", "identifier": "CodeExecutionTool_20250522" }) +export type CodeExecutionTool_20250825 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "name": "bash" + readonly "name": "code_execution" readonly "strict"?: boolean - readonly "type": "bash_20250124" + readonly "type": "code_execution_20250825" } -export const BetaBashTool_20250124 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const CodeExecutionTool_20250825 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -3537,10 +5530,7 @@ export const BetaBashTool_20250124 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) - ), - "name": Schema.Literal("bash").annotate({ + "name": Schema.Literal("code_execution").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -3550,28 +5540,20 @@ export const BetaBashTool_20250124 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("bash_20250124").annotate({ "title": "Type" }) -}).annotate({ "title": "BashTool_20250124" }) -export type BetaComputerUseTool_20241022 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null + "type": Schema.Literal("code_execution_20250825").annotate({ "title": "Type" }) +}).annotate({ "title": "CodeExecutionTool_20250825", "identifier": "CodeExecutionTool_20250825" }) +export type CodeExecutionTool_20260120 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "display_height_px": number - readonly "display_number"?: number | null - readonly "display_width_px": number - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "name": "computer" + readonly "name": "code_execution" readonly "strict"?: boolean - readonly "type": "computer_20241022" + readonly "type": "code_execution_20260120" } -export const BetaComputerUseTool_20241022 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const CodeExecutionTool_20260120 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -3583,24 +5565,7 @@ export const BetaComputerUseTool_20241022 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "display_height_px": Schema.Number.annotate({ - "title": "Display Height Px", - "description": "The height of the display in pixels." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "display_number": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), Schema.Null]).annotate({ - "title": "Display Number", - "description": "The X11 display number (e.g. 0, 1) for the display." - }) - ), - "display_width_px": Schema.Number.annotate({ - "title": "Display Width Px", - "description": "The width of the display in pixels." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) - ), - "name": Schema.Literal("computer").annotate({ + "name": Schema.Literal("code_execution").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -3610,28 +5575,24 @@ export const BetaComputerUseTool_20241022 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("computer_20241022").annotate({ "title": "Type" }) -}).annotate({ "title": "ComputerUseTool_20241022" }) -export type BetaComputerUseTool_20250124 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null + "type": Schema.Literal("code_execution_20260120").annotate({ "title": "Type" }) +}).annotate({ + "title": "CodeExecutionTool_20260120", + "description": "Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).", + "identifier": "CodeExecutionTool_20260120" +}) +export type CodeExecutionTool_20260521 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "display_height_px": number - readonly "display_number"?: number | null - readonly "display_width_px": number - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "name": "computer" + readonly "name": "code_execution" readonly "strict"?: boolean - readonly "type": "computer_20250124" + readonly "type": "code_execution_20260521" } -export const BetaComputerUseTool_20250124 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const CodeExecutionTool_20260521 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -3643,24 +5604,7 @@ export const BetaComputerUseTool_20250124 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "display_height_px": Schema.Number.annotate({ - "title": "Display Height Px", - "description": "The height of the display in pixels." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "display_number": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), Schema.Null]).annotate({ - "title": "Display Number", - "description": "The X11 display number (e.g. 0, 1) for the display." - }) - ), - "display_width_px": Schema.Number.annotate({ - "title": "Display Width Px", - "description": "The width of the display in pixels." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) - ), - "name": Schema.Literal("computer").annotate({ + "name": Schema.Literal("code_execution").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -3670,33 +5614,50 @@ export const BetaComputerUseTool_20250124 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("computer_20250124").annotate({ "title": "Type" }) -}).annotate({ "title": "ComputerUseTool_20250124" }) -export type BetaComputerUseTool_20251124 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null + "type": Schema.Literal("code_execution_20260521").annotate({ "title": "Type" }) +}).annotate({ + "title": "CodeExecutionTool_20260521", + "description": "Code execution tool with REPL state persistence.", + "identifier": "CodeExecutionTool_20260521" +}) +export type WebFetchTool_20250910 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: CacheControlEphemeral | null + readonly "citations"?: RequestCitationsConfig | null readonly "defer_loading"?: boolean - readonly "display_height_px": number - readonly "display_number"?: number | null - readonly "display_width_px": number - readonly "enable_zoom"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "name": "computer" + readonly "max_content_tokens"?: number | null + readonly "max_uses"?: number | null + readonly "name": "web_fetch" readonly "strict"?: boolean - readonly "type": "computer_20251124" + readonly "type": "web_fetch_20250910" } -export const BetaComputerUseTool_20251124 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const WebFetchTool_20250910 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": "List of domains to allow fetching from" + }) + ), + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": "List of domains to block fetching from" }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), + "citations": Schema.optionalKey( + Schema.Union([RequestCitationsConfig, Schema.Null]).annotate({ + "description": "Citations configuration for fetched documents. Citations are disabled by default." + }) + ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -3704,30 +5665,30 @@ export const BetaComputerUseTool_20251124 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "display_height_px": Schema.Number.annotate({ - "title": "Display Height Px", - "description": "The height of the display in pixels." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "display_number": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), Schema.Null]).annotate({ - "title": "Display Number", - "description": "The X11 display number (e.g. 0, 1) for the display." + "max_content_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Content Tokens", + "description": + "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." }) ), - "display_width_px": Schema.Number.annotate({ - "title": "Display Width Px", - "description": "The width of the display in pixels." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "enable_zoom": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Enable Zoom", - "description": "Whether to enable an action to take a zoomed-in screenshot of the screen." + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) - ), - "name": Schema.Literal("computer").annotate({ + "name": Schema.Literal("web_fetch").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -3737,29 +5698,46 @@ export const BetaComputerUseTool_20251124 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("computer_20251124").annotate({ "title": "Type" }) -}).annotate({ "title": "ComputerUseTool_20251124" }) -export type BetaMemoryTool_20250818 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null + "type": Schema.Literal("web_fetch_20250910").annotate({ "title": "Type" }) +}).annotate({ "title": "WebFetchTool_20250910", "identifier": "WebFetchTool_20250910" }) +export type WebFetchTool_20260209 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: CacheControlEphemeral | null + readonly "citations"?: RequestCitationsConfig | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "name": "memory" + readonly "max_content_tokens"?: number | null + readonly "max_uses"?: number | null + readonly "name": "web_fetch" readonly "strict"?: boolean - readonly "type": "memory_20250818" + readonly "type": "web_fetch_20260209" } -export const BetaMemoryTool_20250818 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const WebFetchTool_20260209 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": "List of domains to allow fetching from" + }) + ), + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": "List of domains to block fetching from" }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), + "citations": Schema.optionalKey( + Schema.Union([RequestCitationsConfig, Schema.Null]).annotate({ + "description": "Citations configuration for fetched documents. Citations are disabled by default." + }) + ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -3767,10 +5745,30 @@ export const BetaMemoryTool_20250818 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + "max_content_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Content Tokens", + "description": + "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." + }) ), - "name": Schema.Literal("memory").annotate({ + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) + ), + "name": Schema.Literal("web_fetch").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -3780,29 +5778,47 @@ export const BetaMemoryTool_20250818 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("memory_20250818").annotate({ "title": "Type" }) -}).annotate({ "title": "MemoryTool_20250818" }) -export type BetaTextEditor_20241022 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null + "type": Schema.Literal("web_fetch_20260209").annotate({ "title": "Type" }) +}).annotate({ "title": "WebFetchTool_20260209", "identifier": "WebFetchTool_20260209" }) +export type WebFetchTool_20260309 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: CacheControlEphemeral | null + readonly "citations"?: RequestCitationsConfig | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "name": "str_replace_editor" + readonly "max_content_tokens"?: number | null + readonly "max_uses"?: number | null + readonly "name": "web_fetch" readonly "strict"?: boolean - readonly "type": "text_editor_20241022" + readonly "type": "web_fetch_20260309" + readonly "use_cache"?: boolean } -export const BetaTextEditor_20241022 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const WebFetchTool_20260309 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": "List of domains to allow fetching from" + }) + ), + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": "List of domains to block fetching from" }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), + "citations": Schema.optionalKey( + Schema.Union([RequestCitationsConfig, Schema.Null]).annotate({ + "description": "Citations configuration for fetched documents. Citations are disabled by default." + }) + ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -3810,10 +5826,30 @@ export const BetaTextEditor_20241022 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + "max_content_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Content Tokens", + "description": + "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." + }) ), - "name": Schema.Literal("str_replace_editor").annotate({ + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) + ), + "name": Schema.Literal("web_fetch").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -3823,29 +5859,59 @@ export const BetaTextEditor_20241022 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("text_editor_20241022").annotate({ "title": "Type" }) -}).annotate({ "title": "TextEditor_20241022" }) -export type BetaTextEditor_20250124 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null + "type": Schema.Literal("web_fetch_20260309").annotate({ "title": "Type" }), + "use_cache": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Use Cache", + "description": + "Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources." + }) + ) +}).annotate({ + "title": "WebFetchTool_20260309", + "description": "Web fetch tool with use_cache parameter for bypassing cached content.", + "identifier": "WebFetchTool_20260309" +}) +export type WebFetchTool_20260318 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: CacheControlEphemeral | null + readonly "citations"?: RequestCitationsConfig | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "name": "str_replace_editor" + readonly "max_content_tokens"?: number | null + readonly "max_uses"?: number | null + readonly "name": "web_fetch" + readonly "response_inclusion"?: "full" | "excluded" readonly "strict"?: boolean - readonly "type": "text_editor_20250124" + readonly "type": "web_fetch_20260318" + readonly "use_cache"?: boolean } -export const BetaTextEditor_20250124 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const WebFetchTool_20260318 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": "List of domains to allow fetching from" }) ), - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": "List of domains to block fetching from" + }) + ), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), + "citations": Schema.optionalKey( + Schema.Union([RequestCitationsConfig, Schema.Null]).annotate({ + "description": "Citations configuration for fetched documents. Citations are disabled by default." + }) + ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -3853,38 +5919,67 @@ export const BetaTextEditor_20250124 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + "max_content_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Content Tokens", + "description": + "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." + }) ), - "name": Schema.Literal("str_replace_editor").annotate({ + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) + ), + "name": Schema.Literal("web_fetch").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), + "response_inclusion": Schema.optionalKey( + Schema.Literals(["full", "excluded"]).annotate({ + "title": "Response Inclusion", + "description": + "How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn." + }) + ), "strict": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Strict", "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("text_editor_20250124").annotate({ "title": "Type" }) -}).annotate({ "title": "TextEditor_20250124" }) -export type BetaTextEditor_20250429 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null + "type": Schema.Literal("web_fetch_20260318").annotate({ "title": "Type" }), + "use_cache": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Use Cache", + "description": + "Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources." + }) + ) +}).annotate({ "title": "WebFetchTool_20260318", "identifier": "WebFetchTool_20260318" }) +export type ToolSearchToolBM25_20251119 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "name": "str_replace_based_edit_tool" + readonly "name": "tool_search_tool_bm25" readonly "strict"?: boolean - readonly "type": "text_editor_20250429" + readonly "type": "tool_search_tool_bm25_20251119" | "tool_search_tool_bm25" } -export const BetaTextEditor_20250429 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const ToolSearchToolBM25_20251119 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -3896,10 +5991,7 @@ export const BetaTextEditor_20250429 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) - ), - "name": Schema.Literal("str_replace_based_edit_tool").annotate({ + "name": Schema.Literal("tool_search_tool_bm25").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -3909,26 +6001,20 @@ export const BetaTextEditor_20250429 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("text_editor_20250429").annotate({ "title": "Type" }) -}).annotate({ "title": "TextEditor_20250429" }) -export type BetaTextEditor_20250728 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: BetaCacheControlEphemeral | null + "type": Schema.Literals(["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]).annotate({ "title": "Type" }) +}).annotate({ "title": "ToolSearchToolBM25_20251119", "identifier": "ToolSearchToolBM25_20251119" }) +export type ToolSearchToolRegex_20251119 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> - readonly "max_characters"?: number | null - readonly "name": "str_replace_based_edit_tool" + readonly "name": "tool_search_tool_regex" readonly "strict"?: boolean - readonly "type": "text_editor_20250728" + readonly "type": "tool_search_tool_regex_20251119" | "tool_search_tool_regex" } -export const BetaTextEditor_20250728 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const ToolSearchToolRegex_20251119 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -3940,17 +6026,7 @@ export const BetaTextEditor_20250728 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) - ), - "max_characters": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), Schema.Null]).annotate({ - "title": "Max Characters", - "description": - "Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file." - }) - ), - "name": Schema.Literal("str_replace_based_edit_tool").annotate({ + "name": Schema.Literal("tool_search_tool_regex").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -3960,26 +6036,21 @@ export const BetaTextEditor_20250728 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("text_editor_20250728").annotate({ "title": "Type" }) -}).annotate({ "title": "TextEditor_20250728" }) -export type BetaTool = { + "type": Schema.Literals(["tool_search_tool_regex_20251119", "tool_search_tool_regex"]).annotate({ "title": "Type" }) +}).annotate({ "title": "ToolSearchToolRegex_20251119", "identifier": "ToolSearchToolRegex_20251119" }) +export type Tool = { readonly "type"?: null | "custom" readonly "description"?: string readonly "name": string - readonly "input_schema": { - readonly "properties"?: { readonly [x: string]: Schema.Json } | null - readonly "required"?: ReadonlyArray | null - readonly "type": "object" - readonly [x: string]: Schema.Json - } - readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "input_schema": InputSchema + readonly "cache_control"?: CacheControlEphemeral | null readonly "strict"?: boolean readonly "eager_input_streaming"?: boolean | null - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> + readonly "allowed_callers"?: ReadonlyArray readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> } -export const BetaTool = Schema.Struct({ +export const Tool = Schema.Struct({ "type": Schema.optionalKey(Schema.Union([Schema.Null, Schema.Literal("custom")]).annotate({ "title": "Type" })), "description": Schema.optionalKey(Schema.String.annotate({ "title": "Description", @@ -3989,27 +6060,19 @@ export const BetaTool = Schema.Struct({ "name": Schema.String.annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(128)).check( - Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,128}$")) + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" }) + ).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,128}$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]{1,128}$" + }) ), - "input_schema": Schema.StructWithRest( - Schema.Struct({ - "properties": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json), Schema.Null]).annotate({ "title": "Properties" }) - ), - "required": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Required" }) - ), - "type": Schema.Literal("object").annotate({ "title": "Type" }) - }), - [Schema.Record(Schema.String, Schema.Json)] - ).annotate({ - "title": "InputSchema", + "input_schema": Schema.suspend((): Schema.Codec => InputSchema).annotate({ "description": "[JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.\n\nThis defines the shape of the `input` that your tool accepts and that the model will produce." }), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -4027,11 +6090,7 @@ export const BetaTool = Schema.Struct({ "Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers." }) ), - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -4040,175 +6099,251 @@ export const BetaTool = Schema.Struct({ }) ), "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) ) -}).annotate({ "title": "Tool" }) -export type BetaMCPToolset = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "configs"?: { readonly [x: string]: BetaMCPToolConfig } | null - readonly "default_config"?: { readonly "defer_loading"?: boolean; readonly "enabled"?: boolean } - readonly "mcp_server_name": string - readonly "type": "mcp_toolset" +}).annotate({ "title": "Tool", "identifier": "Tool" }) +export type BashTool_20250124 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> + readonly "name": "bash" + readonly "strict"?: boolean + readonly "type": "bash_20250124" } -export const BetaMCPToolset = Schema.Struct({ +export const BashTool_20250124 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "configs": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, BetaMCPToolConfig), Schema.Null]).annotate({ - "title": "Configs", - "description": "Configuration overrides for specific tools, keyed by tool name" + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "default_config": Schema.optionalKey( - Schema.Struct({ - "defer_loading": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Defer Loading" })), - "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Enabled" })) - }).annotate({ - "title": "MCPToolDefaultConfig", - "description": "Default configuration applied to all tools from this server" + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("bash").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "mcp_server_name": Schema.String.annotate({ - "title": "Mcp Server Name", - "description": "Name of the MCP server to configure tools for" - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(255)), - "type": Schema.Literal("mcp_toolset").annotate({ "title": "Type" }) -}).annotate({ - "title": "MCPToolset", - "description": - "Configuration for a group of tools from an MCP server.\n\nAllows configuring enabled status and defer_loading for all tools\nfrom an MCP server, with optional per-tool overrides." -}) -export type BetaListResponse_MessageBatch_ = { - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "has_more": boolean - readonly "last_id": string | null + "type": Schema.Literal("bash_20250124").annotate({ "title": "Type" }) +}).annotate({ "title": "BashTool_20250124", "identifier": "BashTool_20250124" }) +export type MemoryTool_20250818 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> + readonly "name": "memory" + readonly "strict"?: boolean + readonly "type": "memory_20250818" } -export const BetaListResponse_MessageBatch_ = Schema.Struct({ - "data": Schema.Array(BetaMessageBatch).annotate({ "title": "Data" }), - "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "First Id", - "description": "First ID in the `data` list. Can be used as the `before_id` for the previous page." - }), - "has_more": Schema.Boolean.annotate({ - "title": "Has More", - "description": "Indicates if there are more results in the requested page direction." +export const MemoryTool_20250818 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) + ), + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("memory").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), - "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Last Id", - "description": "Last ID in the `data` list. Can be used as the `after_id` for the next page." - }) -}).annotate({ "title": "ListResponse[MessageBatch]" }) -export type BetaListResponse_ModelInfo_ = { - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "has_more": boolean - readonly "last_id": string | null + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) + ), + "type": Schema.Literal("memory_20250818").annotate({ "title": "Type" }) +}).annotate({ "title": "MemoryTool_20250818", "identifier": "MemoryTool_20250818" }) +export type TextEditor_20250124 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> + readonly "name": "str_replace_editor" + readonly "strict"?: boolean + readonly "type": "text_editor_20250124" } -export const BetaListResponse_ModelInfo_ = Schema.Struct({ - "data": Schema.Array(BetaModelInfo).annotate({ "title": "Data" }), - "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "First Id", - "description": "First ID in the `data` list. Can be used as the `before_id` for the previous page." - }), - "has_more": Schema.Boolean.annotate({ - "title": "Has More", - "description": "Indicates if there are more results in the requested page direction." +export const TextEditor_20250124 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) + ), + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("str_replace_editor").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), - "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Last Id", - "description": "Last ID in the `data` list. Can be used as the `after_id` for the next page." - }) -}).annotate({ "title": "ListResponse[ModelInfo]" }) -export type BetaErrorResponse = { - readonly "error": - | BetaInvalidRequestError - | BetaAuthenticationError - | BetaBillingError - | BetaPermissionError - | BetaNotFoundError - | BetaRateLimitError - | BetaGatewayTimeoutError - | BetaAPIError - | BetaOverloadedError - readonly "request_id": string | null - readonly "type": "error" + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) + ), + "type": Schema.Literal("text_editor_20250124").annotate({ "title": "Type" }) +}).annotate({ "title": "TextEditor_20250124", "identifier": "TextEditor_20250124" }) +export type TextEditor_20250429 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> + readonly "name": "str_replace_based_edit_tool" + readonly "strict"?: boolean + readonly "type": "text_editor_20250429" } -export const BetaErrorResponse = Schema.Struct({ - "error": Schema.Union([ - BetaInvalidRequestError, - BetaAuthenticationError, - BetaBillingError, - BetaPermissionError, - BetaNotFoundError, - BetaRateLimitError, - BetaGatewayTimeoutError, - BetaAPIError, - BetaOverloadedError - ], { mode: "oneOf" }).annotate({ "title": "Error" }), - "request_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Request Id", "default": null }), - "type": Schema.Literal("error").annotate({ "title": "Type", "default": "error" }) -}).annotate({ "title": "ErrorResponse" }) -export type BetaRequestBashCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "return_code": number - readonly "stderr": string - readonly "stdout": string - readonly "type": "bash_code_execution_result" +export const TextEditor_20250429 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) + ), + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("str_replace_based_edit_tool").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) + ), + "type": Schema.Literal("text_editor_20250429").annotate({ "title": "Type" }) +}).annotate({ "title": "TextEditor_20250429", "identifier": "TextEditor_20250429" }) +export type TextEditor_20250728 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> + readonly "max_characters"?: number | null + readonly "name": "str_replace_based_edit_tool" + readonly "strict"?: boolean + readonly "type": "text_editor_20250728" } -export const BetaRequestBashCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(BetaRequestBashCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "stdout": Schema.String.annotate({ "title": "Stdout" }), - "type": Schema.Literal("bash_code_execution_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestBashCodeExecutionResultBlock" }) -export type BetaWebFetchTool_20250910 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> +export const TextEditor_20250728 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) + ), + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + ), + "max_characters": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Characters", + "description": + "Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file." + }) + ), + "name": Schema.Literal("str_replace_based_edit_tool").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) + ), + "type": Schema.Literal("text_editor_20250728").annotate({ "title": "Type" }) +}).annotate({ "title": "TextEditor_20250728", "identifier": "TextEditor_20250728" }) +export type WebSearchTool_20250305 = { + readonly "allowed_callers"?: ReadonlyArray readonly "allowed_domains"?: ReadonlyArray | null readonly "blocked_domains"?: ReadonlyArray | null - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "citations"?: BetaRequestCitationsConfig | null + readonly "cache_control"?: CacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "max_content_tokens"?: number | null readonly "max_uses"?: number | null - readonly "name": "web_fetch" + readonly "name": "web_search" readonly "strict"?: boolean - readonly "type": "web_fetch_20250910" + readonly "type": "web_search_20250305" + readonly "user_location"?: UserLocation | null } -export const BetaWebFetchTool_20250910 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const WebSearchTool_20250305 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "allowed_domains": Schema.optionalKey( Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Allowed Domains", - "description": "List of domains to allow fetching from" + "description": + "If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`." }) ), "blocked_domains": Schema.optionalKey( Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Blocked Domains", - "description": "List of domains to block fetching from" + "description": + "If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`." }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "citations": Schema.optionalKey( - Schema.Union([BetaRequestCitationsConfig, Schema.Null]).annotate({ - "description": "Citations configuration for fetched documents. Citations are disabled by default." - }) - ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -4216,20 +6351,18 @@ export const BetaWebFetchTool_20250910 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "max_content_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ - "title": "Max Content Tokens", - "description": - "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." - }) - ), "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ "title": "Max Uses", "description": "Maximum number of times the tool can be used in the API request." }) ), - "name": Schema.Literal("web_fetch").annotate({ + "name": Schema.Literal("web_search").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -4239,50 +6372,47 @@ export const BetaWebFetchTool_20250910 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("web_fetch_20250910").annotate({ "title": "Type" }) -}).annotate({ "title": "WebFetchTool_20250910" }) -export type BetaWebFetchTool_20260209 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> + "type": Schema.Literal("web_search_20250305").annotate({ "title": "Type" }), + "user_location": Schema.optionalKey( + Schema.Union([UserLocation, Schema.Null]).annotate({ + "description": "Parameters for the user's location. Used to provide more relevant search results." + }) + ) +}).annotate({ "title": "WebSearchTool_20250305", "identifier": "WebSearchTool_20250305" }) +export type WebSearchTool_20260209 = { + readonly "allowed_callers"?: ReadonlyArray readonly "allowed_domains"?: ReadonlyArray | null readonly "blocked_domains"?: ReadonlyArray | null - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "citations"?: BetaRequestCitationsConfig | null + readonly "cache_control"?: CacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "max_content_tokens"?: number | null readonly "max_uses"?: number | null - readonly "name": "web_fetch" + readonly "name": "web_search" readonly "strict"?: boolean - readonly "type": "web_fetch_20260209" + readonly "type": "web_search_20260209" + readonly "user_location"?: UserLocation | null } -export const BetaWebFetchTool_20260209 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const WebSearchTool_20260209 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), "allowed_domains": Schema.optionalKey( Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Allowed Domains", - "description": "List of domains to allow fetching from" + "description": + "If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`." }) ), "blocked_domains": Schema.optionalKey( Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Blocked Domains", - "description": "List of domains to block fetching from" + "description": + "If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`." }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "citations": Schema.optionalKey( - Schema.Union([BetaRequestCitationsConfig, Schema.Null]).annotate({ - "description": "Citations configuration for fetched documents. Citations are disabled by default." - }) - ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -4290,20 +6420,18 @@ export const BetaWebFetchTool_20260209 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "max_content_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ - "title": "Max Content Tokens", - "description": - "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." - }) - ), "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ "title": "Max Uses", "description": "Maximum number of times the tool can be used in the API request." }) ), - "name": Schema.Literal("web_fetch").annotate({ + "name": Schema.Literal("web_search").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -4313,230 +6441,176 @@ export const BetaWebFetchTool_20260209 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("web_fetch_20260209").annotate({ "title": "Type" }) -}).annotate({ "title": "WebFetchTool_20260209" }) -export type BetaRequestCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "return_code": number - readonly "stderr": string - readonly "stdout": string - readonly "type": "code_execution_result" -} -export const BetaRequestCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(BetaRequestCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "stdout": Schema.String.annotate({ "title": "Stdout" }), - "type": Schema.Literal("code_execution_result").annotate({ "title": "Type" }) -}).annotate({ "title": "Result Block" }) -export type BetaRequestEncryptedCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "encrypted_stdout": string - readonly "return_code": number - readonly "stderr": string - readonly "type": "encrypted_code_execution_result" + "type": Schema.Literal("web_search_20260209").annotate({ "title": "Type" }), + "user_location": Schema.optionalKey( + Schema.Union([UserLocation, Schema.Null]).annotate({ + "description": "Parameters for the user's location. Used to provide more relevant search results." + }) + ) +}).annotate({ "title": "WebSearchTool_20260209", "identifier": "WebSearchTool_20260209" }) +export type WebSearchTool_20260318 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: CacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "max_uses"?: number | null + readonly "name": "web_search" + readonly "response_inclusion"?: "full" | "excluded" + readonly "strict"?: boolean + readonly "type": "web_search_20260318" + readonly "user_location"?: UserLocation | null } -export const BetaRequestEncryptedCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(BetaRequestCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "encrypted_stdout": Schema.String.annotate({ "title": "Encrypted Stdout" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "type": Schema.Literal("encrypted_code_execution_result").annotate({ "title": "Type" }) -}).annotate({ - "title": "RequestEncryptedCodeExecutionResultBlock", - "description": "Code execution result with encrypted stdout for PFC + web_search results." -}) -export type BetaRequestMCPServerURLDefinition = { - readonly "authorization_token"?: string | null - readonly "name": string - readonly "tool_configuration"?: BetaRequestMCPServerToolConfiguration | null - readonly "type": "url" - readonly "url": string -} -export const BetaRequestMCPServerURLDefinition = Schema.Struct({ - "authorization_token": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Authorization Token" }) +export const WebSearchTool_20260318 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(AllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": + "If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`." + }) + ), + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": + "If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`." + }) ), - "name": Schema.String.annotate({ "title": "Name" }), - "tool_configuration": Schema.optionalKey(Schema.Union([BetaRequestMCPServerToolConfiguration, Schema.Null])), - "type": Schema.Literal("url").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url" }) -}).annotate({ "title": "RequestMCPServerURLDefinition" }) -export type BetaRequestMCPToolResultBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "content"?: - | string - | ReadonlyArray< - { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "citations"?: - | ReadonlyArray< - | BetaRequestCharLocationCitation - | BetaRequestPageLocationCitation - | BetaRequestContentBlockLocationCitation - | BetaRequestWebSearchResultLocationCitation - | BetaRequestSearchResultLocationCitation - > - | null - readonly "text": string - readonly "type": "text" - } - > - readonly "is_error"?: boolean - readonly "tool_use_id": string - readonly "type": "mcp_tool_result" -} -export const BetaRequestMCPToolResultBlock = Schema.Struct({ "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "content": Schema.optionalKey( + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) + ), + "max_uses": Schema.optionalKey( Schema.Union([ - Schema.String, - Schema.Array( - Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "citations": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([ - BetaRequestCharLocationCitation, - BetaRequestPageLocationCitation, - BetaRequestContentBlockLocationCitation, - BetaRequestWebSearchResultLocationCitation, - BetaRequestSearchResultLocationCitation - ], { mode: "oneOf" }) - ), - Schema.Null - ]).annotate({ "title": "Citations" }) - ), - "text": Schema.String.annotate({ "title": "Text" }).check(Schema.isMinLength(1)), - "type": Schema.Literal("text").annotate({ "title": "Type" }) - }).annotate({ "title": "beta_mcp_tool_result_block_param_content_item" }) - ).annotate({ "title": "beta_mcp_tool_result_block_param_content" }) - ]).annotate({ "title": "Content" }) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) ), - "is_error": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Is Error" })), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")) + "name": Schema.Literal("web_search").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "response_inclusion": Schema.optionalKey( + Schema.Literals(["full", "excluded"]).annotate({ + "title": "Response Inclusion", + "description": + "How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn." + }) ), - "type": Schema.Literal("mcp_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestMCPToolResultBlock" }) -export type BetaRequestTextBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) + ), + "type": Schema.Literal("web_search_20260318").annotate({ "title": "Type" }), + "user_location": Schema.optionalKey( + Schema.Union([UserLocation, Schema.Null]).annotate({ + "description": "Parameters for the user's location. Used to provide more relevant search results." + }) + ) +}).annotate({ "title": "WebSearchTool_20260318", "identifier": "WebSearchTool_20260318" }) +export type ResponseTextBlock = { readonly "citations"?: | ReadonlyArray< - | BetaRequestCharLocationCitation - | BetaRequestPageLocationCitation - | BetaRequestContentBlockLocationCitation - | BetaRequestWebSearchResultLocationCitation - | BetaRequestSearchResultLocationCitation + | ResponseCharLocationCitation + | ResponsePageLocationCitation + | ResponseContentBlockLocationCitation + | ResponseWebSearchResultLocationCitation + | ResponseSearchResultLocationCitation > | null readonly "text": string readonly "type": "text" } -export const BetaRequestTextBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), +export const ResponseTextBlock = Schema.Struct({ "citations": Schema.optionalKey( Schema.Union([ Schema.Array( Schema.Union([ - BetaRequestCharLocationCitation, - BetaRequestPageLocationCitation, - BetaRequestContentBlockLocationCitation, - BetaRequestWebSearchResultLocationCitation, - BetaRequestSearchResultLocationCitation + ResponseCharLocationCitation, + ResponsePageLocationCitation, + ResponseContentBlockLocationCitation, + ResponseWebSearchResultLocationCitation, + ResponseSearchResultLocationCitation ], { mode: "oneOf" }) ), Schema.Null - ]).annotate({ "title": "Citations" }) + ]).annotate({ + "title": "Citations", + "description": + "Citations supporting the text block.\n\nThe type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.", + "default": null + }) ), - "text": Schema.String.annotate({ "title": "Text" }).check(Schema.isMinLength(1)), - "type": Schema.Literal("text").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextBlock" }) -export type BetaResponseBashCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "return_code": number - readonly "stderr": string - readonly "stdout": string - readonly "type": "bash_code_execution_result" -} -export const BetaResponseBashCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(BetaResponseBashCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "stdout": Schema.String.annotate({ "title": "Stdout" }), - "type": Schema.Literal("bash_code_execution_result").annotate({ - "title": "Type", - "default": "bash_code_execution_result" - }) -}).annotate({ "title": "ResponseBashCodeExecutionResultBlock" }) -export type BetaResponseDocumentBlock = { - readonly "citations": BetaResponseCitationsConfig | null - readonly "source": BetaBase64PDFSource | BetaPlainTextSource + "text": Schema.String.annotate({ "title": "Text" }).check( + Schema.isMinLength(0).annotate({ "expected": "a value with a length of at least 0" }) + ).check(Schema.isMaxLength(5000000).annotate({ "expected": "a value with a length of at most 5000000" })), + "type": Schema.Literal("text").annotate({ "title": "Type", "default": "text" }) +}).annotate({ "title": "ResponseTextBlock", "identifier": "ResponseTextBlock" }) +export type ResponseDocumentBlock = { + readonly "citations": ResponseCitationsConfig | null + readonly "source": Base64PDFSource | PlainTextSource readonly "title": string | null readonly "type": "document" } -export const BetaResponseDocumentBlock = Schema.Struct({ - "citations": Schema.Union([BetaResponseCitationsConfig, Schema.Null]).annotate({ +export const ResponseDocumentBlock = Schema.Struct({ + "citations": Schema.Union([ResponseCitationsConfig, Schema.Null]).annotate({ "description": "Citation configuration for the document", "default": null }), - "source": Schema.Union([BetaBase64PDFSource, BetaPlainTextSource], { mode: "oneOf" }).annotate({ "title": "Source" }), + "source": Schema.Union([Base64PDFSource, PlainTextSource], { mode: "oneOf" }).annotate({ "title": "Source" }), "title": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Title", "description": "The title of the document", "default": null }), "type": Schema.Literal("document").annotate({ "title": "Type", "default": "document" }) -}).annotate({ "title": "ResponseDocumentBlock" }) -export type BetaResponseContextManagement = { - readonly "applied_edits": ReadonlyArray -} -export const BetaResponseContextManagement = Schema.Struct({ - "applied_edits": Schema.Array( - Schema.Union([BetaResponseClearToolUses20250919Edit, BetaResponseClearThinking20251015Edit], { mode: "oneOf" }) - ).annotate({ "title": "Applied Edits", "description": "List of context management edits that were applied." }) -}).annotate({ "title": "ResponseContextManagement" }) -export type BetaResponseCodeExecutionResultBlock = { - readonly "content": ReadonlyArray +}).annotate({ "title": "ResponseDocumentBlock", "identifier": "ResponseDocumentBlock" }) +export type ResponseCodeExecutionResultBlock = { + readonly "content": ReadonlyArray readonly "return_code": number readonly "stderr": string readonly "stdout": string readonly "type": "code_execution_result" } -export const BetaResponseCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(BetaResponseCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), +export const ResponseCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(ResponseCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), "stderr": Schema.String.annotate({ "title": "Stderr" }), "stdout": Schema.String.annotate({ "title": "Stdout" }), "type": Schema.Literal("code_execution_result").annotate({ "title": "Type", "default": "code_execution_result" }) -}).annotate({ "title": "ResponseCodeExecutionResultBlock" }) -export type BetaResponseEncryptedCodeExecutionResultBlock = { - readonly "content": ReadonlyArray +}).annotate({ "title": "ResponseCodeExecutionResultBlock", "identifier": "ResponseCodeExecutionResultBlock" }) +export type ResponseEncryptedCodeExecutionResultBlock = { + readonly "content": ReadonlyArray readonly "encrypted_stdout": string readonly "return_code": number readonly "stderr": string readonly "type": "encrypted_code_execution_result" } -export const BetaResponseEncryptedCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(BetaResponseCodeExecutionOutputBlock).annotate({ "title": "Content" }), +export const ResponseEncryptedCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(ResponseCodeExecutionOutputBlock).annotate({ "title": "Content" }), "encrypted_stdout": Schema.String.annotate({ "title": "Encrypted Stdout" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), "stderr": Schema.String.annotate({ "title": "Stderr" }), "type": Schema.Literal("encrypted_code_execution_result").annotate({ "title": "Type", @@ -4544,400 +6618,441 @@ export const BetaResponseEncryptedCodeExecutionResultBlock = Schema.Struct({ }) }).annotate({ "title": "ResponseEncryptedCodeExecutionResultBlock", - "description": "Code execution result with encrypted stdout for PFC + web_search results." + "description": "Code execution result with encrypted stdout for PFC + web_search results.", + "identifier": "ResponseEncryptedCodeExecutionResultBlock" }) -export type BetaResponseToolSearchToolSearchResultBlock = { - readonly "tool_references": ReadonlyArray +export type ResponseBashCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "bash_code_execution_result" +} +export const ResponseBashCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(ResponseBashCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "stdout": Schema.String.annotate({ "title": "Stdout" }), + "type": Schema.Literal("bash_code_execution_result").annotate({ + "title": "Type", + "default": "bash_code_execution_result" + }) +}).annotate({ "title": "ResponseBashCodeExecutionResultBlock", "identifier": "ResponseBashCodeExecutionResultBlock" }) +export type ResponseToolSearchToolSearchResultBlock = { + readonly "tool_references": ReadonlyArray readonly "type": "tool_search_tool_search_result" } -export const BetaResponseToolSearchToolSearchResultBlock = Schema.Struct({ - "tool_references": Schema.Array(BetaResponseToolReferenceBlock).annotate({ "title": "Tool References" }), +export const ResponseToolSearchToolSearchResultBlock = Schema.Struct({ + "tool_references": Schema.Array(ResponseToolReferenceBlock).annotate({ "title": "Tool References" }), "type": Schema.Literal("tool_search_tool_search_result").annotate({ "title": "Type", "default": "tool_search_tool_search_result" }) -}).annotate({ "title": "ResponseToolSearchToolSearchResultBlock" }) -export type BetaCitationsDelta = { - readonly "citation": - | BetaResponseCharLocationCitation - | BetaResponsePageLocationCitation - | BetaResponseContentBlockLocationCitation - | BetaResponseWebSearchResultLocationCitation - | BetaResponseSearchResultLocationCitation - readonly "type": "citations_delta" -} -export const BetaCitationsDelta = Schema.Struct({ - "citation": Schema.Union([ - BetaResponseCharLocationCitation, - BetaResponsePageLocationCitation, - BetaResponseContentBlockLocationCitation, - BetaResponseWebSearchResultLocationCitation, - BetaResponseSearchResultLocationCitation - ], { mode: "oneOf" }).annotate({ "title": "Citation" }), - "type": Schema.Literal("citations_delta").annotate({ "title": "Type", "default": "citations_delta" }) -}).annotate({ "title": "CitationsDelta" }) -export type BetaResponseMCPToolResultBlock = { - readonly "content": - | string - | ReadonlyArray< - { - readonly "citations": - | ReadonlyArray< - | BetaResponseCharLocationCitation - | BetaResponsePageLocationCitation - | BetaResponseContentBlockLocationCitation - | BetaResponseWebSearchResultLocationCitation - | BetaResponseSearchResultLocationCitation - > - | null - readonly "text": string - readonly "type": "text" - } - > - readonly "is_error": boolean - readonly "tool_use_id": string - readonly "type": "mcp_tool_result" +}).annotate({ + "title": "ResponseToolSearchToolSearchResultBlock", + "identifier": "ResponseToolSearchToolSearchResultBlock" +}) +export type RefusalStopDetails = { + readonly "category": RefusalCategory | null + readonly "explanation": string | null + readonly "type": "refusal" } -export const BetaResponseMCPToolResultBlock = Schema.Struct({ - "content": Schema.Union([ - Schema.String, - Schema.Array( - Schema.Struct({ - "citations": Schema.Union([ - Schema.Array( - Schema.Union([ - BetaResponseCharLocationCitation, - BetaResponsePageLocationCitation, - BetaResponseContentBlockLocationCitation, - BetaResponseWebSearchResultLocationCitation, - BetaResponseSearchResultLocationCitation - ], { mode: "oneOf" }) - ), - Schema.Null - ]).annotate({ - "title": "Citations", - "description": - "Citations supporting the text block.\n\nThe type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.", - "default": null - }), - "text": Schema.String.annotate({ "title": "Text" }).check(Schema.isMinLength(0)).check( - Schema.isMaxLength(5000000) - ), - "type": Schema.Literal("text").annotate({ "title": "Type", "default": "text" }) - }).annotate({ "title": "beta_mcp_tool_result_block_content_item" }) - ).annotate({ "title": "beta_mcp_tool_result_block_content" }) - ]).annotate({ "title": "Content" }), - "is_error": Schema.Boolean.annotate({ "title": "Is Error", "default": false }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")) - ), - "type": Schema.Literal("mcp_tool_result").annotate({ "title": "Type", "default": "mcp_tool_result" }) -}).annotate({ "title": "ResponseMCPToolResultBlock" }) -export type BetaResponseTextBlock = { - readonly "citations"?: - | ReadonlyArray< - | BetaResponseCharLocationCitation - | BetaResponsePageLocationCitation - | BetaResponseContentBlockLocationCitation - | BetaResponseWebSearchResultLocationCitation - | BetaResponseSearchResultLocationCitation - > - | null - readonly "text": string - readonly "type": "text" +export const RefusalStopDetails = Schema.Struct({ + "category": Schema.Union([RefusalCategory, Schema.Null]).annotate({ + "description": + "The policy category that triggered the refusal.\n\n`null` when the refusal doesn't map to a named category.", + "default": null + }), + "explanation": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Explanation", + "description": + "Human-readable explanation of the refusal.\n\nThis text is not guaranteed to be stable. `null` when no explanation is available for the category.", + "default": null + }), + "type": Schema.Literal("refusal").annotate({ "title": "Type", "default": "refusal" }) +}).annotate({ + "title": "RefusalStopDetails", + "description": "Structured information about a refusal.", + "identifier": "RefusalStopDetails" +}) +export type Usage = { + readonly "cache_creation": CacheCreation | null + readonly "cache_creation_input_tokens": number | null + readonly "cache_read_input_tokens": number | null + readonly "inference_geo": string | null + readonly "input_tokens": number + readonly "output_tokens": number + readonly "output_tokens_details": OutputTokensDetails | null + readonly "server_tool_use"?: ServerToolUsage | null + readonly "service_tier": "standard" | "priority" | "batch" | null } -export const BetaResponseTextBlock = Schema.Struct({ - "citations": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([ - BetaResponseCharLocationCitation, - BetaResponsePageLocationCitation, - BetaResponseContentBlockLocationCitation, - BetaResponseWebSearchResultLocationCitation, - BetaResponseSearchResultLocationCitation - ], { mode: "oneOf" }) - ), - Schema.Null - ]).annotate({ - "title": "Citations", - "description": - "Citations supporting the text block.\n\nThe type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.", +export const Usage = Schema.Struct({ + "cache_creation": Schema.Union([CacheCreation, Schema.Null]).annotate({ + "description": "Breakdown of cached tokens by TTL", + "default": null + }), + "cache_creation_input_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Cache Creation Input Tokens", + "description": "The number of input tokens used to create the cache entry.", + "default": null + }), + "cache_read_input_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Cache Read Input Tokens", + "description": "The number of input tokens read from the cache.", + "default": null + }), + "inference_geo": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Inference Geo", + "description": "The geographic region where inference was performed for this request.", + "default": null + }), + "input_tokens": Schema.Number.annotate({ + "title": "Input Tokens", + "description": "The number of input tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "output_tokens": Schema.Number.annotate({ + "title": "Output Tokens", + "description": "The number of output tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "output_tokens_details": Schema.Union([OutputTokensDetails, Schema.Null]).annotate({ + "description": + "Breakdown of output tokens by category.\n\n`output_tokens` remains the inclusive, authoritative total used for billing.\nThis object provides a read-only decomposition for observability — for example,\nhow many of the billed output tokens were spent on internal reasoning that may\nhave been summarized before being returned to you.", + "default": null + }), + "server_tool_use": Schema.optionalKey( + Schema.Union([ServerToolUsage, Schema.Null]).annotate({ + "description": "The number of server tool requests.", "default": null }) ), - "text": Schema.String.annotate({ "title": "Text" }).check(Schema.isMinLength(0)).check(Schema.isMaxLength(5000000)), - "type": Schema.Literal("text").annotate({ "title": "Type", "default": "text" }) -}).annotate({ "title": "ResponseTextBlock" }) -export type BetaRequestServerToolUseBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + "service_tier": Schema.Union([Schema.Literals(["standard", "priority", "batch"]), Schema.Null]).annotate({ + "title": "Service Tier", + "description": "If the request used the priority, standard, or batch tier.", + "default": null + }) +}).annotate({ "title": "Usage", "identifier": "Usage" }) +export type ErrorResponse = { + readonly "error": + | InvalidRequestError + | AuthenticationError + | BillingError + | PermissionError + | NotFoundError + | RateLimitError + | GatewayTimeoutError + | APIError + | OverloadedError + readonly "request_id": string | null + readonly "type": "error" +} +export const ErrorResponse = Schema.Struct({ + "error": Schema.Union([ + InvalidRequestError, + AuthenticationError, + BillingError, + PermissionError, + NotFoundError, + RateLimitError, + GatewayTimeoutError, + APIError, + OverloadedError + ], { mode: "oneOf" }).annotate({ "title": "Error" }), + "request_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Request Id", "default": null }), + "type": Schema.Literal("error").annotate({ "title": "Type", "default": "error" }) +}).annotate({ "title": "ErrorResponse", "identifier": "ErrorResponse" }) +export type ContextManagementCapability = { + readonly "clear_thinking_20251015": CapabilitySupport | null + readonly "clear_tool_uses_20250919": CapabilitySupport | null + readonly "compact_20260112": CapabilitySupport | null + readonly "supported": boolean +} +export const ContextManagementCapability = Schema.Struct({ + "clear_thinking_20251015": Schema.Union([CapabilitySupport, Schema.Null]).annotate({ + "description": "Whether the clear_thinking_20251015 strategy is supported." + }), + "clear_tool_uses_20250919": Schema.Union([CapabilitySupport, Schema.Null]).annotate({ + "description": "Whether the clear_tool_uses_20250919 strategy is supported." + }), + "compact_20260112": Schema.Union([CapabilitySupport, Schema.Null]).annotate({ + "description": "Whether the compact_20260112 strategy is supported." + }), + "supported": Schema.Boolean.annotate({ + "title": "Supported", + "description": "Whether this capability is supported by the model." + }) +}).annotate({ + "title": "ContextManagementCapability", + "description": "Context management capability details.", + "identifier": "ContextManagementCapability" +}) +export type EffortCapability = { + readonly "high": CapabilitySupport + readonly "low": CapabilitySupport + readonly "max": CapabilitySupport + readonly "medium": CapabilitySupport + readonly "supported": boolean + readonly "xhigh": CapabilitySupport | null +} +export const EffortCapability = Schema.Struct({ + "high": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports high effort level." + }), + "low": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports low effort level." + }), + "max": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports max effort level." + }), + "medium": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports medium effort level." + }), + "supported": Schema.Boolean.annotate({ + "title": "Supported", + "description": "Whether this capability is supported by the model." + }), + "xhigh": Schema.Union([CapabilitySupport, Schema.Null]).annotate({ + "description": "Whether the model supports xhigh effort level." + }) +}).annotate({ + "title": "EffortCapability", + "description": "Effort (reasoning_effort) capability details.", + "identifier": "EffortCapability" +}) +export type ThinkingTypes = { readonly "adaptive": CapabilitySupport; readonly "enabled": CapabilitySupport } +export const ThinkingTypes = Schema.Struct({ + "adaptive": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports thinking with type 'adaptive' (auto)." + }), + "enabled": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports thinking with type 'enabled'." + }) +}).annotate({ + "title": "ThinkingTypes", + "description": "Supported thinking type configurations.", + "identifier": "ThinkingTypes" +}) +export type MessageBatch = { + readonly "archived_at": string | null + readonly "cancel_initiated_at": string | null + readonly "created_at": string + readonly "ended_at": string | null + readonly "expires_at": string readonly "id": string - readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": - | "web_search" - | "web_fetch" - | "code_execution" - | "bash_code_execution" - | "text_editor_code_execution" - | "tool_search_tool_regex" - | "tool_search_tool_bm25" - readonly "type": "server_tool_use" + readonly "processing_status": "in_progress" | "canceling" | "ended" + readonly "request_counts": RequestCounts + readonly "results_url": string | null + readonly "type": "message_batch" } -export const BetaRequestServerToolUseBlock = Schema.Struct({ +export const MessageBatch = Schema.Struct({ + "archived_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ + "title": "Archived At", + "description": + "RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable." + }), + "cancel_initiated_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ + "title": "Cancel Initiated At", + "description": + "RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated." + }), + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": "RFC 3339 datetime string representing the time at which the Message Batch was created.", + "format": "date-time" + }), + "ended_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ + "title": "Ended At", + "description": + "RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.\n\nProcessing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired." + }), + "expires_at": Schema.String.annotate({ + "title": "Expires At", + "description": + "RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.", + "format": "date-time" + }), + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." + }), + "processing_status": Schema.Literals(["in_progress", "canceling", "ended"]).annotate({ + "title": "Processing Status", + "description": "Processing status of the Message Batch." + }), + "request_counts": Schema.suspend((): Schema.Codec => RequestCounts).annotate({ + "description": + "Tallies requests within the Message Batch, categorized by their status.\n\nRequests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch." + }), + "results_url": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Results Url", + "description": + "URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.\n\nResults in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests." + }), + "type": Schema.Literal("message_batch").annotate({ + "title": "Type", + "description": "Object type.\n\nFor Message Batches, this is always `\"message_batch\"`.", + "default": "message_batch" + }) +}).annotate({ "title": "MessageBatch", "identifier": "MessageBatch" }) +export type BetaRequestToolReferenceBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "tool_name": string + readonly "type": "tool_reference" +} +export const BetaRequestToolReferenceBlock = Schema.Struct({ "cache_control": Schema.optionalKey( Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "caller": Schema.optionalKey( - Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" + "tool_name": Schema.String.annotate({ "title": "Tool Name" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,256}$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]{1,256}$" }) ), - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.Literals([ - "web_search", - "web_fetch", - "code_execution", - "bash_code_execution", - "text_editor_code_execution", - "tool_search_tool_regex", - "tool_search_tool_bm25" - ]).annotate({ "title": "Name" }), - "type": Schema.Literal("server_tool_use").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestServerToolUseBlock" }) -export type BetaResponseServerToolUseBlock = { - readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + "type": Schema.Literal("tool_reference").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestToolReferenceBlock", + "description": "Tool reference block that can be included in tool_result content.", + "identifier": "BetaRequestToolReferenceBlock" +}) +export type BetaRequestMCPToolUseBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "id": string readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": - | "web_search" - | "web_fetch" - | "code_execution" - | "bash_code_execution" - | "text_editor_code_execution" - | "tool_search_tool_regex" - | "tool_search_tool_bm25" - readonly "type": "server_tool_use" + readonly "name": string + readonly "server_name": string + readonly "type": "mcp_tool_use" } -export const BetaResponseServerToolUseBlock = Schema.Struct({ - "caller": Schema.optionalKey( - Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" +export const BetaRequestMCPToolUseBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.Literals([ - "web_search", - "web_fetch", - "code_execution", - "bash_code_execution", - "text_editor_code_execution", - "tool_search_tool_regex", - "tool_search_tool_bm25" - ]).annotate({ "title": "Name" }), - "type": Schema.Literal("server_tool_use").annotate({ "title": "Type", "default": "server_tool_use" }) -}).annotate({ "title": "ResponseServerToolUseBlock" }) -export type BetaResponseToolUseBlock = { - readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 - readonly "id": string - readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": string - readonly "type": "tool_use" -} -export const BetaResponseToolUseBlock = Schema.Struct({ - "caller": Schema.optionalKey( - Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.String.annotate({ "title": "Name" }).check(Schema.isMinLength(1)), - "type": Schema.Literal("tool_use").annotate({ "title": "Type", "default": "tool_use" }) -}).annotate({ "title": "ResponseToolUseBlock" }) -export type BetaContainer = { - readonly "expires_at": string - readonly "id": string - readonly "skills": ReadonlyArray | null -} -export const BetaContainer = Schema.Struct({ - "expires_at": Schema.String.annotate({ - "title": "Expires At", - "description": "The time at which the container will expire.", - "format": "date-time" + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" }), - "id": Schema.String.annotate({ "title": "Id", "description": "Identifier for the container used in this request" }), - "skills": Schema.Union([Schema.Array(BetaSkill), Schema.Null]).annotate({ - "title": "Skills", - "description": "Skills loaded in the container", - "default": null - }) -}).annotate({ - "title": "Container", - "description": "Information about the container used in the request (for the code execution tool)" -}) -export type BetaContainerParams = { - readonly "id"?: string | null - readonly "skills"?: ReadonlyArray | null + "name": Schema.String.annotate({ "title": "Name" }), + "server_name": Schema.String.annotate({ "title": "Server Name", "description": "The name of the MCP server" }), + "type": Schema.Literal("mcp_tool_use").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestMCPToolUseBlock", "identifier": "BetaRequestMCPToolUseBlock" }) +export type BetaRequestContainerUploadBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "file_id": string + readonly "type": "container_upload" } -export const BetaContainerParams = Schema.Struct({ - "id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Id", "description": "Container id" }) - ), - "skills": Schema.optionalKey( - Schema.Union([Schema.Array(BetaSkillParams).check(Schema.isMaxLength(8)), Schema.Null]).annotate({ - "title": "Skills", - "description": "List of skills to load in the container" +export const BetaRequestContainerUploadBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) - ) -}).annotate({ "title": "ContainerParams", "description": "Container parameters with skills to be loaded." }) -export type BetaListSkillVersionsResponse = { - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next_page": string | null -} -export const BetaListSkillVersionsResponse = Schema.Struct({ - "data": Schema.Array(BetaSkillVersion).annotate({ "title": "Data", "description": "List of skill versions." }), - "has_more": Schema.Boolean.annotate({ - "title": "Has More", - "description": "Indicates if there are more results in the requested page direction." - }), - "next_page": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Next Page", - "description": "Token to provide in as `page` in the subsequent request to retrieve the next page of data." - }) -}).annotate({ "title": "ListSkillVersionsResponse" }) -export type BetaRequestTextEditorCodeExecutionToolResultError = { - readonly "error_code": BetaTextEditorCodeExecutionToolResultErrorCode - readonly "error_message"?: string | null - readonly "type": "text_editor_code_execution_tool_result_error" -} -export const BetaRequestTextEditorCodeExecutionToolResultError = Schema.Struct({ - "error_code": BetaTextEditorCodeExecutionToolResultErrorCode, - "error_message": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message" }) - ), - "type": Schema.Literal("text_editor_code_execution_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionToolResultError" }) -export type BetaResponseTextEditorCodeExecutionToolResultError = { - readonly "error_code": BetaTextEditorCodeExecutionToolResultErrorCode - readonly "error_message": string | null - readonly "type": "text_editor_code_execution_tool_result_error" -} -export const BetaResponseTextEditorCodeExecutionToolResultError = Schema.Struct({ - "error_code": BetaTextEditorCodeExecutionToolResultErrorCode, - "error_message": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message", "default": null }), - "type": Schema.Literal("text_editor_code_execution_tool_result_error").annotate({ - "title": "Type", - "default": "text_editor_code_execution_tool_result_error" - }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionToolResultError" }) -export type BetaThinkingConfigParam = - | BetaThinkingConfigEnabled - | BetaThinkingConfigDisabled - | BetaThinkingConfigAdaptive -export const BetaThinkingConfigParam = Schema.Union([ - BetaThinkingConfigEnabled, - BetaThinkingConfigDisabled, - BetaThinkingConfigAdaptive -], { mode: "oneOf" }).annotate({ - "title": "Thinking", - "description": - "Configuration for enabling Claude's extended thinking.\n\nWhen enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.\n\nSee [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details." -}) -export type BetaClearThinking20251015 = { - readonly "keep"?: BetaThinkingTurns | BetaAllThinkingTurns | "all" - readonly "type": "clear_thinking_20251015" -} -export const BetaClearThinking20251015 = Schema.Struct({ - "keep": Schema.optionalKey( - Schema.Union([Schema.Union([BetaThinkingTurns, BetaAllThinkingTurns], { mode: "oneOf" }), Schema.Literal("all")]) - .annotate({ - "title": "Keep", - "description": - "Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed." - }) ), - "type": Schema.Literal("clear_thinking_20251015").annotate({ "title": "Type" }) -}).annotate({ "title": "ClearThinking20251015" }) -export type BetaToolChoice = BetaToolChoiceAuto | BetaToolChoiceAny | BetaToolChoiceTool | BetaToolChoiceNone -export const BetaToolChoice = Schema.Union([ - BetaToolChoiceAuto, - BetaToolChoiceAny, - BetaToolChoiceTool, - BetaToolChoiceNone -], { mode: "oneOf" }).annotate({ - "title": "Tool Choice", + "file_id": Schema.String.annotate({ "title": "File Id" }), + "type": Schema.Literal("container_upload").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestContainerUploadBlock", "description": - "How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all." + "A content block that represents a file to be uploaded to the container\nFiles uploaded via this block will be available in the container's input directory.", + "identifier": "BetaRequestContainerUploadBlock" }) -export type BetaRequestToolSearchToolResultError = { - readonly "error_code": BetaToolSearchToolResultErrorCode - readonly "type": "tool_search_tool_result_error" -} -export const BetaRequestToolSearchToolResultError = Schema.Struct({ - "error_code": BetaToolSearchToolResultErrorCode, - "type": Schema.Literal("tool_search_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestToolSearchToolResultError" }) -export type BetaResponseToolSearchToolResultError = { - readonly "error_code": BetaToolSearchToolResultErrorCode - readonly "error_message": string | null - readonly "type": "tool_search_tool_result_error" -} -export const BetaResponseToolSearchToolResultError = Schema.Struct({ - "error_code": BetaToolSearchToolResultErrorCode, - "error_message": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message", "default": null }), - "type": Schema.Literal("tool_search_tool_result_error").annotate({ - "title": "Type", - "default": "tool_search_tool_result_error" - }) -}).annotate({ "title": "ResponseToolSearchToolResultError" }) -export type BetaClearToolUses20250919 = { - readonly "clear_at_least"?: BetaInputTokensClearAtLeast | null - readonly "clear_tool_inputs"?: boolean | ReadonlyArray | null - readonly "exclude_tools"?: ReadonlyArray | null - readonly "keep"?: BetaToolUsesKeep - readonly "trigger"?: BetaInputTokensTrigger | BetaToolUsesTrigger - readonly "type": "clear_tool_uses_20250919" +export type BetaRequestCompactionBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "content"?: string | null + readonly "encrypted_content"?: string | null + readonly "type": "compaction" } -export const BetaClearToolUses20250919 = Schema.Struct({ - "clear_at_least": Schema.optionalKey( - Schema.Union([BetaInputTokensClearAtLeast, Schema.Null]).annotate({ - "description": - "Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed." +export const BetaRequestCompactionBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "clear_tool_inputs": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Clear Tool Inputs", - "description": "Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)" + "content": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Content", + "description": "Summary of previously compacted content, or null if compaction failed" }) ), - "exclude_tools": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Exclude Tools", - "description": "Tool names whose uses are preserved from clearing" + "encrypted_content": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Encrypted Content", + "description": "Opaque metadata from prior compaction, to be round-tripped verbatim" }) ), - "keep": Schema.optionalKey( - Schema.Union([BetaToolUsesKeep], { mode: "oneOf" }).annotate({ - "title": "Keep", - "description": "Number of tool uses to retain in the conversation" + "type": Schema.Literal("compaction").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestCompactionBlock", + "description": + "A compaction block containing summary of previous context.\n\nUsers should round-trip these blocks from responses to subsequent requests\nto maintain context across compaction boundaries.\n\nWhen content is None, the block represents a failed compaction. The server\ntreats these as no-ops. Empty string content is not allowed.", + "identifier": "BetaRequestCompactionBlock" +}) +export type BetaRequestTextBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "citations"?: + | ReadonlyArray< + | BetaRequestCharLocationCitation + | BetaRequestPageLocationCitation + | BetaRequestContentBlockLocationCitation + | BetaRequestWebSearchResultLocationCitation + | BetaRequestSearchResultLocationCitation + > + | null + readonly "text": string + readonly "type": "text" +} +export const BetaRequestTextBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "trigger": Schema.optionalKey( - Schema.Union([BetaInputTokensTrigger, BetaToolUsesTrigger], { mode: "oneOf" }).annotate({ - "title": "Trigger", - "description": "Condition that triggers the context management strategy" - }) + "citations": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Union([ + BetaRequestCharLocationCitation, + BetaRequestPageLocationCitation, + BetaRequestContentBlockLocationCitation, + BetaRequestWebSearchResultLocationCitation, + BetaRequestSearchResultLocationCitation + ], { mode: "oneOf" }) + ), + Schema.Null + ]).annotate({ "title": "Citations" }) ), - "type": Schema.Literal("clear_tool_uses_20250919").annotate({ "title": "Type" }) -}).annotate({ "title": "ClearToolUses20250919" }) + "text": Schema.String.annotate({ "title": "Text" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "type": Schema.Literal("text").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestTextBlock", "identifier": "BetaRequestTextBlock" }) export type BetaRequestImageBlock = { readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "source": BetaBase64ImageSource | BetaURLImageSource | BetaFileImageSource @@ -4954,143 +7069,174 @@ export const BetaRequestImageBlock = Schema.Struct({ "title": "Source" }), "type": Schema.Literal("image").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestImageBlock" }) -export type BetaWebSearchTool_20250305 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "allowed_domains"?: ReadonlyArray | null - readonly "blocked_domains"?: ReadonlyArray | null +}).annotate({ "title": "RequestImageBlock", "identifier": "BetaRequestImageBlock" }) +export type BetaRequestToolUseBlock = { readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "defer_loading"?: boolean - readonly "max_uses"?: number | null - readonly "name": "web_search" - readonly "strict"?: boolean - readonly "type": "web_search_20250305" - readonly "user_location"?: BetaUserLocation | null + readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + readonly "id": string + readonly "input": { readonly [x: string]: Schema.Json } + readonly "name": string + readonly "type": "tool_use" } -export const BetaWebSearchTool_20250305 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const BetaRequestToolUseBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "allowed_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Allowed Domains", - "description": - "If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`." + "caller": Schema.optionalKey( + Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "blocked_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Blocked Domains", - "description": - "If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`." + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" + }), + "name": Schema.String.annotate({ "title": "Name" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(200).annotate({ "expected": "a value with a length of at most 200" })), + "type": Schema.Literal("tool_use").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestToolUseBlock", "identifier": "BetaRequestToolUseBlock" }) +export type BetaRequestServerToolUseBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + readonly "id": string + readonly "input": { readonly [x: string]: Schema.Json } + readonly "name": + | "advisor" + | "web_search" + | "web_fetch" + | "code_execution" + | "bash_code_execution" + | "text_editor_code_execution" + | "tool_search_tool_regex" + | "tool_search_tool_bm25" + readonly "type": "server_tool_use" +} +export const BetaRequestServerToolUseBlock = Schema.Struct({ "cache_control": Schema.optionalKey( Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Defer Loading", - "description": - "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + "caller": Schema.optionalKey( + Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ - "title": "Max Uses", - "description": "Maximum number of times the tool can be used in the API request." + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "name": Schema.Literal("web_search").annotate({ - "title": "Name", - "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" }), - "strict": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Strict", - "description": "When true, guarantees schema validation on tool names and inputs" - }) - ), - "type": Schema.Literal("web_search_20250305").annotate({ "title": "Type" }), - "user_location": Schema.optionalKey( - Schema.Union([BetaUserLocation, Schema.Null]).annotate({ - "description": "Parameters for the user's location. Used to provide more relevant search results." - }) - ) -}).annotate({ "title": "WebSearchTool_20250305" }) -export type BetaWebSearchTool_20260209 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "allowed_domains"?: ReadonlyArray | null - readonly "blocked_domains"?: ReadonlyArray | null - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "defer_loading"?: boolean - readonly "max_uses"?: number | null - readonly "name": "web_search" - readonly "strict"?: boolean - readonly "type": "web_search_20260209" - readonly "user_location"?: BetaUserLocation | null + "name": Schema.Literals([ + "advisor", + "web_search", + "web_fetch", + "code_execution", + "bash_code_execution", + "text_editor_code_execution", + "tool_search_tool_regex", + "tool_search_tool_bm25" + ]).annotate({ "title": "Name" }), + "type": Schema.Literal("server_tool_use").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestServerToolUseBlock", "identifier": "BetaRequestServerToolUseBlock" }) +export type BetaResponseToolUseBlock = { + readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + readonly "id": string + readonly "input": { readonly [x: string]: Schema.Json } + readonly "name": string + readonly "type": "tool_use" } -export const BetaWebSearchTool_20260209 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), - "allowed_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Allowed Domains", - "description": - "If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`." +export const BetaResponseToolUseBlock = Schema.Struct({ + "caller": Schema.optionalKey( + Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "blocked_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Blocked Domains", - "description": - "If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`." + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" + }), + "name": Schema.String.annotate({ "title": "Name" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Defer Loading", - "description": - "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + "type": Schema.Literal("tool_use").annotate({ "title": "Type", "default": "tool_use" }) +}).annotate({ "title": "ResponseToolUseBlock", "identifier": "BetaResponseToolUseBlock" }) +export type BetaResponseServerToolUseBlock = { + readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + readonly "id": string + readonly "input": { readonly [x: string]: Schema.Json } + readonly "name": + | "advisor" + | "web_search" + | "web_fetch" + | "code_execution" + | "bash_code_execution" + | "text_editor_code_execution" + | "tool_search_tool_regex" + | "tool_search_tool_bm25" + readonly "type": "server_tool_use" +} +export const BetaResponseServerToolUseBlock = Schema.Struct({ + "caller": Schema.optionalKey( + Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ - "title": "Max Uses", - "description": "Maximum number of times the tool can be used in the API request." + "id": Schema.String.annotate({ "title": "Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "name": Schema.Literal("web_search").annotate({ - "title": "Name", - "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + "input": Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({ + "title": "Input" }), - "strict": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Strict", - "description": "When true, guarantees schema validation on tool names and inputs" - }) - ), - "type": Schema.Literal("web_search_20260209").annotate({ "title": "Type" }), - "user_location": Schema.optionalKey( - Schema.Union([BetaUserLocation, Schema.Null]).annotate({ - "description": "Parameters for the user's location. Used to provide more relevant search results." - }) - ) -}).annotate({ "title": "WebSearchTool_20260209" }) + "name": Schema.Literals([ + "advisor", + "web_search", + "web_fetch", + "code_execution", + "bash_code_execution", + "text_editor_code_execution", + "tool_search_tool_regex", + "tool_search_tool_bm25" + ]).annotate({ "title": "Name" }), + "type": Schema.Literal("server_tool_use").annotate({ "title": "Type", "default": "server_tool_use" }) +}).annotate({ "title": "ResponseServerToolUseBlock", "identifier": "BetaResponseServerToolUseBlock" }) +export type BetaRequestWebSearchToolResultError = { + readonly "error_code": BetaWebSearchToolResultErrorCode + readonly "type": "web_search_tool_result_error" +} +export const BetaRequestWebSearchToolResultError = Schema.Struct({ + "error_code": BetaWebSearchToolResultErrorCode, + "type": Schema.Literal("web_search_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ "title": "Error", "identifier": "BetaRequestWebSearchToolResultError" }) +export type BetaResponseWebSearchToolResultError = { + readonly "error_code": BetaWebSearchToolResultErrorCode + readonly "type": "web_search_tool_result_error" +} +export const BetaResponseWebSearchToolResultError = Schema.Struct({ + "error_code": BetaWebSearchToolResultErrorCode, + "type": Schema.Literal("web_search_tool_result_error").annotate({ + "title": "Type", + "default": "web_search_tool_result_error" + }) +}).annotate({ "title": "ResponseWebSearchToolResultError", "identifier": "BetaResponseWebSearchToolResultError" }) export type BetaRequestWebFetchToolResultError = { readonly "error_code": BetaWebFetchToolResultErrorCode readonly "type": "web_fetch_tool_result_error" @@ -5098,7 +7244,7 @@ export type BetaRequestWebFetchToolResultError = { export const BetaRequestWebFetchToolResultError = Schema.Struct({ "error_code": BetaWebFetchToolResultErrorCode, "type": Schema.Literal("web_fetch_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestWebFetchToolResultError" }) +}).annotate({ "title": "RequestWebFetchToolResultError", "identifier": "BetaRequestWebFetchToolResultError" }) export type BetaResponseWebFetchToolResultError = { readonly "error_code": BetaWebFetchToolResultErrorCode readonly "type": "web_fetch_tool_result_error" @@ -5109,99 +7255,463 @@ export const BetaResponseWebFetchToolResultError = Schema.Struct({ "title": "Type", "default": "web_fetch_tool_result_error" }) -}).annotate({ "title": "ResponseWebFetchToolResultError" }) -export type BetaRequestWebSearchToolResultError = { - readonly "error_code": BetaWebSearchToolResultErrorCode - readonly "type": "web_search_tool_result_error" +}).annotate({ "title": "ResponseWebFetchToolResultError", "identifier": "BetaResponseWebFetchToolResultError" }) +export type BetaRequestAdvisorToolResultError = { + readonly "error_code": BetaAdvisorToolResultErrorCode + readonly "type": "advisor_tool_result_error" +} +export const BetaRequestAdvisorToolResultError = Schema.Struct({ + "error_code": BetaAdvisorToolResultErrorCode, + "type": Schema.Literal("advisor_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestAdvisorToolResultError", "identifier": "BetaRequestAdvisorToolResultError" }) +export type BetaResponseAdvisorToolResultError = { + readonly "error_code": BetaAdvisorToolResultErrorCode + readonly "type": "advisor_tool_result_error" +} +export const BetaResponseAdvisorToolResultError = Schema.Struct({ + "error_code": BetaAdvisorToolResultErrorCode, + "type": Schema.Literal("advisor_tool_result_error").annotate({ + "title": "Type", + "default": "advisor_tool_result_error" + }) +}).annotate({ "title": "ResponseAdvisorToolResultError", "identifier": "BetaResponseAdvisorToolResultError" }) +export type BetaRequestCodeExecutionToolResultError = { + readonly "error_code": BetaCodeExecutionToolResultErrorCode + readonly "type": "code_execution_tool_result_error" } -export const BetaRequestWebSearchToolResultError = Schema.Struct({ - "error_code": BetaWebSearchToolResultErrorCode, - "type": Schema.Literal("web_search_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "Error" }) -export type BetaResponseWebSearchToolResultError = { - readonly "error_code": BetaWebSearchToolResultErrorCode - readonly "type": "web_search_tool_result_error" +export const BetaRequestCodeExecutionToolResultError = Schema.Struct({ + "error_code": BetaCodeExecutionToolResultErrorCode, + "type": Schema.Literal("code_execution_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ "title": "Error", "identifier": "BetaRequestCodeExecutionToolResultError" }) +export type BetaResponseCodeExecutionToolResultError = { + readonly "error_code": BetaCodeExecutionToolResultErrorCode + readonly "type": "code_execution_tool_result_error" } -export const BetaResponseWebSearchToolResultError = Schema.Struct({ - "error_code": BetaWebSearchToolResultErrorCode, - "type": Schema.Literal("web_search_tool_result_error").annotate({ +export const BetaResponseCodeExecutionToolResultError = Schema.Struct({ + "error_code": BetaCodeExecutionToolResultErrorCode, + "type": Schema.Literal("code_execution_tool_result_error").annotate({ "title": "Type", - "default": "web_search_tool_result_error" + "default": "code_execution_tool_result_error" }) -}).annotate({ "title": "ResponseWebSearchToolResultError" }) -export type BetaListSkillsResponse = { - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next_page": string | null +}).annotate({ + "title": "ResponseCodeExecutionToolResultError", + "identifier": "BetaResponseCodeExecutionToolResultError" +}) +export type BetaRequestCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "code_execution_result" } -export const BetaListSkillsResponse = Schema.Struct({ - "data": Schema.Array(Betaapi__schemas__skills__Skill).annotate({ "title": "Data", "description": "List of skills." }), - "has_more": Schema.Boolean.annotate({ - "title": "Has More", - "description": - "Whether there are more results available.\n\nIf `true`, there are additional results that can be fetched using the `next_page` token." - }), - "next_page": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Next Page", - "description": - "Token for fetching the next page of results.\n\nIf `null`, there are no more results available. Pass this value to the `page_token` parameter in the next request to get the next page." - }) -}).annotate({ "title": "ListSkillsResponse" }) -export type CodeExecutionTool_20250522 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null - readonly "defer_loading"?: boolean - readonly "name": "code_execution" - readonly "strict"?: boolean - readonly "type": "code_execution_20250522" +export const BetaRequestCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(BetaRequestCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "stdout": Schema.String.annotate({ "title": "Stdout" }), + "type": Schema.Literal("code_execution_result").annotate({ "title": "Type" }) +}).annotate({ "title": "Result Block", "identifier": "BetaRequestCodeExecutionResultBlock" }) +export type BetaRequestEncryptedCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "encrypted_stdout": string + readonly "return_code": number + readonly "stderr": string + readonly "type": "encrypted_code_execution_result" } -export const CodeExecutionTool_20250522 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) +export const BetaRequestEncryptedCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(BetaRequestCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "encrypted_stdout": Schema.String.annotate({ "title": "Encrypted Stdout" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "type": Schema.Literal("encrypted_code_execution_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestEncryptedCodeExecutionResultBlock", + "description": "Code execution result with encrypted stdout for PFC + web_search results.", + "identifier": "BetaRequestEncryptedCodeExecutionResultBlock" +}) +export type BetaRequestBashCodeExecutionToolResultError = { + readonly "error_code": BetaBashCodeExecutionToolResultErrorCode + readonly "type": "bash_code_execution_tool_result_error" +} +export const BetaRequestBashCodeExecutionToolResultError = Schema.Struct({ + "error_code": BetaBashCodeExecutionToolResultErrorCode, + "type": Schema.Literal("bash_code_execution_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestBashCodeExecutionToolResultError", + "identifier": "BetaRequestBashCodeExecutionToolResultError" +}) +export type BetaResponseBashCodeExecutionToolResultError = { + readonly "error_code": BetaBashCodeExecutionToolResultErrorCode + readonly "type": "bash_code_execution_tool_result_error" +} +export const BetaResponseBashCodeExecutionToolResultError = Schema.Struct({ + "error_code": BetaBashCodeExecutionToolResultErrorCode, + "type": Schema.Literal("bash_code_execution_tool_result_error").annotate({ + "title": "Type", + "default": "bash_code_execution_tool_result_error" + }) +}).annotate({ + "title": "ResponseBashCodeExecutionToolResultError", + "identifier": "BetaResponseBashCodeExecutionToolResultError" +}) +export type BetaRequestBashCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "bash_code_execution_result" +} +export const BetaRequestBashCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(BetaRequestBashCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Defer Loading", - "description": - "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." - }) + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "stdout": Schema.String.annotate({ "title": "Stdout" }), + "type": Schema.Literal("bash_code_execution_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestBashCodeExecutionResultBlock", "identifier": "BetaRequestBashCodeExecutionResultBlock" }) +export type BetaRequestTextEditorCodeExecutionToolResultError = { + readonly "error_code": BetaTextEditorCodeExecutionToolResultErrorCode + readonly "error_message"?: string | null + readonly "type": "text_editor_code_execution_tool_result_error" +} +export const BetaRequestTextEditorCodeExecutionToolResultError = Schema.Struct({ + "error_code": BetaTextEditorCodeExecutionToolResultErrorCode, + "error_message": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message" }) ), - "name": Schema.Literal("code_execution").annotate({ - "title": "Name", - "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." - }), - "strict": Schema.optionalKey( + "type": Schema.Literal("text_editor_code_execution_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionToolResultError", + "identifier": "BetaRequestTextEditorCodeExecutionToolResultError" +}) +export type BetaResponseTextEditorCodeExecutionToolResultError = { + readonly "error_code": BetaTextEditorCodeExecutionToolResultErrorCode + readonly "error_message": string | null + readonly "type": "text_editor_code_execution_tool_result_error" +} +export const BetaResponseTextEditorCodeExecutionToolResultError = Schema.Struct({ + "error_code": BetaTextEditorCodeExecutionToolResultErrorCode, + "error_message": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message", "default": null }), + "type": Schema.Literal("text_editor_code_execution_tool_result_error").annotate({ + "title": "Type", + "default": "text_editor_code_execution_tool_result_error" + }) +}).annotate({ + "title": "ResponseTextEditorCodeExecutionToolResultError", + "identifier": "BetaResponseTextEditorCodeExecutionToolResultError" +}) +export type BetaRequestToolSearchToolResultError = { + readonly "error_code": BetaToolSearchToolResultErrorCode + readonly "error_message"?: string | null + readonly "type": "tool_search_tool_result_error" +} +export const BetaRequestToolSearchToolResultError = Schema.Struct({ + "error_code": BetaToolSearchToolResultErrorCode, + "error_message": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message" }) + ), + "type": Schema.Literal("tool_search_tool_result_error").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestToolSearchToolResultError", "identifier": "BetaRequestToolSearchToolResultError" }) +export type BetaResponseToolSearchToolResultError = { + readonly "error_code": BetaToolSearchToolResultErrorCode + readonly "error_message": string | null + readonly "type": "tool_search_tool_result_error" +} +export const BetaResponseToolSearchToolResultError = Schema.Struct({ + "error_code": BetaToolSearchToolResultErrorCode, + "error_message": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message", "default": null }), + "type": Schema.Literal("tool_search_tool_result_error").annotate({ + "title": "Type", + "default": "tool_search_tool_result_error" + }) +}).annotate({ "title": "ResponseToolSearchToolResultError", "identifier": "BetaResponseToolSearchToolResultError" }) +export type BetaRequestToolAdditionBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "tool": BetaToolChangeToolReference | BetaToolChangeMCPToolReference | BetaToolChangeMCPToolsetReference + readonly "type": "tool_addition" +} +export const BetaRequestToolAdditionBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "tool": Schema.Union( + [BetaToolChangeToolReference, BetaToolChangeMCPToolReference, BetaToolChangeMCPToolsetReference], + { mode: "oneOf" } + ).annotate({ "title": "Tool" }), + "type": Schema.Literal("tool_addition").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestToolAdditionBlock", + "description": + "Mid-conversation directive to surface a declared tool.\n\n``tool`` references a tool (or MCP toolset) by name from the request's\n``tools``; it is offered to the model from this point in the\nconversation onward.", + "identifier": "BetaRequestToolAdditionBlock" +}) +export type BetaRequestToolRemovalBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "tool": BetaToolChangeToolReference | BetaToolChangeMCPToolReference | BetaToolChangeMCPToolsetReference + readonly "type": "tool_removal" +} +export const BetaRequestToolRemovalBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "tool": Schema.Union( + [BetaToolChangeToolReference, BetaToolChangeMCPToolReference, BetaToolChangeMCPToolsetReference], + { mode: "oneOf" } + ).annotate({ "title": "Tool" }), + "type": Schema.Literal("tool_removal").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestToolRemovalBlock", + "description": + "Mid-conversation directive to withdraw a tool.\n\n``tool`` references a tool (or MCP toolset) by name from the request's\n``tools``; it is no longer offered to the model from this point in the\nconversation onward.", + "identifier": "BetaRequestToolRemovalBlock" +}) +export type BetaContainerParams = { + readonly "id"?: string | null + readonly "skills"?: ReadonlyArray | null +} +export const BetaContainerParams = Schema.Struct({ + "id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Id", "description": "Container id" }) + ), + "skills": Schema.optionalKey( + Schema.Union([ + Schema.Array(BetaSkillParams).check( + Schema.isMaxLength(8).annotate({ "expected": "a value with a length of at most 8" }) + ), + Schema.Null + ]).annotate({ "title": "Skills", "description": "List of skills to load in the container" }) + ) +}).annotate({ + "title": "ContainerParams", + "description": "Container parameters with skills to be loaded.", + "identifier": "BetaContainerParams" +}) +export type BetaCompact20260112 = { + readonly "instructions"?: string | null + readonly "pause_after_compaction"?: boolean + readonly "trigger"?: BetaInputTokensTrigger | null + readonly "type": "compact_20260112" +} +export const BetaCompact20260112 = Schema.Struct({ + "instructions": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Instructions", + "description": "Additional instructions for summarization." + }) + ), + "pause_after_compaction": Schema.optionalKey( Schema.Boolean.annotate({ - "title": "Strict", - "description": "When true, guarantees schema validation on tool names and inputs" + "title": "Pause After Compaction", + "description": "Whether to pause after compaction and return the compaction block to the user." }) ), - "type": Schema.Literal("code_execution_20250522").annotate({ "title": "Type" }) -}).annotate({ "title": "CodeExecutionTool_20250522" }) -export type CodeExecutionTool_20250825 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null + "trigger": Schema.optionalKey( + Schema.Union([BetaInputTokensTrigger, Schema.Null]).annotate({ + "description": "When to trigger compaction. Defaults to 150000 input tokens." + }) + ), + "type": Schema.Literal("compact_20260112").annotate({ "title": "Type" }) +}).annotate({ + "title": "Compact20260112", + "description": "Automatically compact older context when reaching the configured trigger threshold.", + "identifier": "BetaCompact20260112" +}) +export type BetaClearToolUses20250919 = { + readonly "clear_at_least"?: BetaInputTokensClearAtLeast | null + readonly "clear_tool_inputs"?: boolean | ReadonlyArray | null + readonly "exclude_tools"?: ReadonlyArray | null + readonly "keep"?: BetaToolUsesKeep + readonly "trigger"?: BetaInputTokensTrigger | BetaToolUsesTrigger + readonly "type": "clear_tool_uses_20250919" +} +export const BetaClearToolUses20250919 = Schema.Struct({ + "clear_at_least": Schema.optionalKey( + Schema.Union([BetaInputTokensClearAtLeast, Schema.Null]).annotate({ + "description": + "Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed." + }) + ), + "clear_tool_inputs": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Clear Tool Inputs", + "description": "Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)" + }) + ), + "exclude_tools": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Exclude Tools", + "description": "Tool names whose uses are preserved from clearing" + }) + ), + "keep": Schema.optionalKey( + Schema.Union([BetaToolUsesKeep], { mode: "oneOf" }).annotate({ + "title": "Keep", + "description": "Number of tool uses to retain in the conversation" + }) + ), + "trigger": Schema.optionalKey( + Schema.Union([BetaInputTokensTrigger, BetaToolUsesTrigger], { mode: "oneOf" }).annotate({ + "title": "Trigger", + "description": "Condition that triggers the context management strategy" + }) + ), + "type": Schema.Literal("clear_tool_uses_20250919").annotate({ "title": "Type" }) +}).annotate({ "title": "ClearToolUses20250919", "identifier": "BetaClearToolUses20250919" }) +export type BetaClearThinking20251015 = { + readonly "keep"?: BetaThinkingTurns | BetaAllThinkingTurns | "all" + readonly "type": "clear_thinking_20251015" +} +export const BetaClearThinking20251015 = Schema.Struct({ + "keep": Schema.optionalKey( + Schema.Union([Schema.Union([BetaThinkingTurns, BetaAllThinkingTurns], { mode: "oneOf" }), Schema.Literal("all")]) + .annotate({ + "title": "Keep", + "description": + "Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed." + }) + ), + "type": Schema.Literal("clear_thinking_20251015").annotate({ "title": "Type" }) +}).annotate({ "title": "ClearThinking20251015", "identifier": "BetaClearThinking20251015" }) +export type BetaOutputConfig = { + readonly "effort"?: BetaEffortLevel | null + readonly "format"?: BetaJsonOutputFormat | null + readonly "task_budget"?: BetaTokenTaskBudget | null +} +export const BetaOutputConfig = Schema.Struct({ + "effort": Schema.optionalKey( + Schema.Union([BetaEffortLevel, Schema.Null]).annotate({ + "description": + "How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.\n\nValid values are `low`, `medium`, `high`, `xhigh`, or `max`." + }) + ), + "format": Schema.optionalKey( + Schema.Union([BetaJsonOutputFormat, Schema.Null]).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)" + }) + ), + "task_budget": Schema.optionalKey( + Schema.Union([BetaTokenTaskBudget, Schema.Null]).annotate({ + "description": "Configuration for token budget tracking across contexts." + }) + ) +}).annotate({ "title": "OutputConfig", "identifier": "BetaOutputConfig" }) +export type BetaDreamModelConfig = { readonly "id": string; readonly "speed"?: BetaSpeed } +export const BetaDreamModelConfig = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Model identifier, e.g. \"claude-opus-4-7\". 1-256 characters." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" }) + ), + "speed": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaSpeed).annotate({ + "description": "Inference speed mode. Defaults to `standard`." + }) + ) +}).annotate({ + "description": + "Model identifier and configuration applied to every pipeline stage. Same wire shape as the Agents API ModelConfig.", + "identifier": "BetaDreamModelConfig" +}) +export type BetaDreamModelConfigParams = { readonly "id": string; readonly "speed"?: BetaSpeed } +export const BetaDreamModelConfigParams = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Model identifier, e.g. \"claude-opus-4-7\". 1-256 characters." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" }) + ), + "speed": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaSpeed).annotate({ + "description": "Inference speed mode. Defaults to `standard`." + }) + ) +}).annotate({ + "description": "Model identifier and configuration applied to every pipeline stage.", + "identifier": "BetaDreamModelConfigParams" +}) +export type BetaThinkingConfigEnabled = { + readonly "budget_tokens": number + readonly "display"?: BetaThinkingDisplayMode | null + readonly "type": "enabled" +} +export const BetaThinkingConfigEnabled = Schema.Struct({ + "budget_tokens": Schema.Number.annotate({ + "title": "Budget Tokens", + "description": + "Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.\n\nMust be ≥1024 and less than `max_tokens`.\n\nSee [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1024).annotate({ "expected": "a value greater than or equal to 1024" }) + ), + "display": Schema.optionalKey( + Schema.Union([BetaThinkingDisplayMode, Schema.Null]).annotate({ + "description": + "Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`." + }) + ), + "type": Schema.Literal("enabled").annotate({ "title": "Type" }) +}).annotate({ "title": "ThinkingConfigEnabled", "identifier": "BetaThinkingConfigEnabled" }) +export type BetaThinkingConfigAdaptive = { + readonly "display"?: BetaThinkingDisplayMode | null + readonly "type": "adaptive" +} +export const BetaThinkingConfigAdaptive = Schema.Struct({ + "display": Schema.optionalKey( + Schema.Union([BetaThinkingDisplayMode, Schema.Null]).annotate({ + "description": + "Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`." + }) + ), + "type": Schema.Literal("adaptive").annotate({ "title": "Type" }) +}).annotate({ "title": "ThinkingConfigAdaptive", "identifier": "BetaThinkingConfigAdaptive" }) +export type BetaRequestMCPServerURLDefinition = { + readonly "authorization_token"?: string | null + readonly "name": string + readonly "tool_configuration"?: BetaRequestMCPServerToolConfiguration | null + readonly "type": "url" + readonly "url": string +} +export const BetaRequestMCPServerURLDefinition = Schema.Struct({ + "authorization_token": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Authorization Token" }) + ), + "name": Schema.String.annotate({ "title": "Name" }), + "tool_configuration": Schema.optionalKey(Schema.Union([BetaRequestMCPServerToolConfiguration, Schema.Null])), + "type": Schema.Literal("url").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url" }) +}).annotate({ "title": "RequestMCPServerURLDefinition", "identifier": "BetaRequestMCPServerURLDefinition" }) +export type BetaToolChoice = BetaToolChoiceAuto | BetaToolChoiceAny | BetaToolChoiceTool | BetaToolChoiceNone +export const BetaToolChoice = Schema.Union([ + BetaToolChoiceAuto, + BetaToolChoiceAny, + BetaToolChoiceTool, + BetaToolChoiceNone +], { mode: "oneOf" }).annotate({ + "title": "Tool Choice", + "description": + "How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.", + "identifier": "BetaToolChoice" +}) +export type BetaCodeExecutionTool_20250522 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "defer_loading"?: boolean readonly "name": "code_execution" readonly "strict"?: boolean - readonly "type": "code_execution_20250825" + readonly "type": "code_execution_20250522" } -export const CodeExecutionTool_20250825 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const BetaCodeExecutionTool_20250522 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -5223,24 +7733,20 @@ export const CodeExecutionTool_20250825 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("code_execution_20250825").annotate({ "title": "Type" }) -}).annotate({ "title": "CodeExecutionTool_20250825" }) -export type CodeExecutionTool_20260120 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null + "type": Schema.Literal("code_execution_20250522").annotate({ "title": "Type" }) +}).annotate({ "title": "CodeExecutionTool_20250522", "identifier": "BetaCodeExecutionTool_20250522" }) +export type BetaCodeExecutionTool_20250825 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "defer_loading"?: boolean readonly "name": "code_execution" readonly "strict"?: boolean - readonly "type": "code_execution_20260120" + readonly "type": "code_execution_20250825" } -export const CodeExecutionTool_20260120 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const BetaCodeExecutionTool_20250825 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -5262,66 +7768,20 @@ export const CodeExecutionTool_20260120 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("code_execution_20260120").annotate({ "title": "Type" }) -}).annotate({ - "title": "CodeExecutionTool_20260120", - "description": "Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint)." -}) -export type RequestContainerUploadBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "file_id": string - readonly "type": "container_upload" -} -export const RequestContainerUploadBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "file_id": Schema.String.annotate({ "title": "File Id" }), - "type": Schema.Literal("container_upload").annotate({ "title": "Type" }) -}).annotate({ - "title": "RequestContainerUploadBlock", - "description": - "A content block that represents a file to be uploaded to the container\nFiles uploaded via this block will be available in the container's input directory." -}) -export type RequestToolReferenceBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "tool_name": string - readonly "type": "tool_reference" -} -export const RequestToolReferenceBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "tool_name": Schema.String.annotate({ "title": "Tool Name" }).check(Schema.isMinLength(1)).check( - Schema.isMaxLength(256) - ).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,256}$"))), - "type": Schema.Literal("tool_reference").annotate({ "title": "Type" }) -}).annotate({ - "title": "RequestToolReferenceBlock", - "description": "Tool reference block that can be included in tool_result content." -}) -export type ToolSearchToolBM25_20251119 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null + "type": Schema.Literal("code_execution_20250825").annotate({ "title": "Type" }) +}).annotate({ "title": "CodeExecutionTool_20250825", "identifier": "BetaCodeExecutionTool_20250825" }) +export type BetaCodeExecutionTool_20260120 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "name": "tool_search_tool_bm25" + readonly "name": "code_execution" readonly "strict"?: boolean - readonly "type": "tool_search_tool_bm25_20251119" | "tool_search_tool_bm25" + readonly "type": "code_execution_20260120" } -export const ToolSearchToolBM25_20251119 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const BetaCodeExecutionTool_20260120 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -5333,7 +7793,7 @@ export const ToolSearchToolBM25_20251119 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "name": Schema.Literal("tool_search_tool_bm25").annotate({ + "name": Schema.Literal("code_execution").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -5343,24 +7803,24 @@ export const ToolSearchToolBM25_20251119 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literals(["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]).annotate({ "title": "Type" }) -}).annotate({ "title": "ToolSearchToolBM25_20251119" }) -export type ToolSearchToolRegex_20251119 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null + "type": Schema.Literal("code_execution_20260120").annotate({ "title": "Type" }) +}).annotate({ + "title": "CodeExecutionTool_20260120", + "description": "Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).", + "identifier": "BetaCodeExecutionTool_20260120" +}) +export type BetaCodeExecutionTool_20260521 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "name": "tool_search_tool_regex" + readonly "name": "code_execution" readonly "strict"?: boolean - readonly "type": "tool_search_tool_regex_20251119" | "tool_search_tool_regex" + readonly "type": "code_execution_20260521" } -export const ToolSearchToolRegex_20251119 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const BetaCodeExecutionTool_20260521 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -5372,7 +7832,7 @@ export const ToolSearchToolRegex_20251119 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "name": Schema.Literal("tool_search_tool_regex").annotate({ + "name": Schema.Literal("code_execution").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -5382,79 +7842,50 @@ export const ToolSearchToolRegex_20251119 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literals(["tool_search_tool_regex_20251119", "tool_search_tool_regex"]).annotate({ "title": "Type" }) -}).annotate({ "title": "ToolSearchToolRegex_20251119" }) -export type RequestCodeExecutionToolResultError = { - readonly "error_code": CodeExecutionToolResultErrorCode - readonly "type": "code_execution_tool_result_error" -} -export const RequestCodeExecutionToolResultError = Schema.Struct({ - "error_code": CodeExecutionToolResultErrorCode, - "type": Schema.Literal("code_execution_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestCodeExecutionToolResultError" }) -export type ResponseCodeExecutionToolResultError = { - readonly "error_code": CodeExecutionToolResultErrorCode - readonly "type": "code_execution_tool_result_error" -} -export const ResponseCodeExecutionToolResultError = Schema.Struct({ - "error_code": CodeExecutionToolResultErrorCode, - "type": Schema.Literal("code_execution_tool_result_error").annotate({ - "title": "Type", - "default": "code_execution_tool_result_error" - }) -}).annotate({ "title": "ResponseCodeExecutionToolResultError" }) -export type FileListResponse = { - readonly "data": ReadonlyArray - readonly "first_id"?: string | null - readonly "has_more"?: boolean - readonly "last_id"?: string | null -} -export const FileListResponse = Schema.Struct({ - "data": Schema.Array(FileMetadataSchema).annotate({ - "title": "Data", - "description": "List of file metadata objects." - }), - "first_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "First Id", - "description": "ID of the first file in this page of results." - }) - ), - "has_more": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Has More", - "description": "Whether there are more results available.", - "default": false - }) - ), - "last_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Last Id", - "description": "ID of the last file in this page of results." - }) - ) -}).annotate({ "title": "FileListResponse" }) -export type BashTool_20250124 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null + "type": Schema.Literal("code_execution_20260521").annotate({ "title": "Type" }) +}).annotate({ + "title": "CodeExecutionTool_20260521", + "description": "Code execution tool with REPL state persistence.", + "identifier": "BetaCodeExecutionTool_20260521" +}) +export type BetaWebFetchTool_20250910 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "citations"?: BetaRequestCitationsConfig | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> - readonly "name": "bash" + readonly "max_content_tokens"?: number | null + readonly "max_uses"?: number | null + readonly "name": "web_fetch" readonly "strict"?: boolean - readonly "type": "bash_20250124" + readonly "type": "web_fetch_20250910" } -export const BashTool_20250124 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const BetaWebFetchTool_20250910 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": "List of domains to allow fetching from" + }) + ), + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": "List of domains to block fetching from" }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), + "citations": Schema.optionalKey( + Schema.Union([BetaRequestCitationsConfig, Schema.Null]).annotate({ + "description": "Citations configuration for fetched documents. Citations are disabled by default." + }) + ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -5462,10 +7893,30 @@ export const BashTool_20250124 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + "max_content_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Content Tokens", + "description": + "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." + }) ), - "name": Schema.Literal("bash").annotate({ + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) + ), + "name": Schema.Literal("web_fetch").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -5475,29 +7926,46 @@ export const BashTool_20250124 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("bash_20250124").annotate({ "title": "Type" }) -}).annotate({ "title": "BashTool_20250124" }) -export type MemoryTool_20250818 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null + "type": Schema.Literal("web_fetch_20250910").annotate({ "title": "Type" }) +}).annotate({ "title": "WebFetchTool_20250910", "identifier": "BetaWebFetchTool_20250910" }) +export type BetaWebFetchTool_20260209 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "citations"?: BetaRequestCitationsConfig | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> - readonly "name": "memory" + readonly "max_content_tokens"?: number | null + readonly "max_uses"?: number | null + readonly "name": "web_fetch" readonly "strict"?: boolean - readonly "type": "memory_20250818" + readonly "type": "web_fetch_20260209" } -export const MemoryTool_20250818 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const BetaWebFetchTool_20260209 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": "List of domains to allow fetching from" + }) + ), + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": "List of domains to block fetching from" }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), + "citations": Schema.optionalKey( + Schema.Union([BetaRequestCitationsConfig, Schema.Null]).annotate({ + "description": "Citations configuration for fetched documents. Citations are disabled by default." + }) + ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -5505,10 +7973,30 @@ export const MemoryTool_20250818 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + "max_content_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Content Tokens", + "description": + "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." + }) ), - "name": Schema.Literal("memory").annotate({ + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) + ), + "name": Schema.Literal("web_fetch").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -5518,40 +8006,78 @@ export const MemoryTool_20250818 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("memory_20250818").annotate({ "title": "Type" }) -}).annotate({ "title": "MemoryTool_20250818" }) -export type TextEditor_20250124 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null + "type": Schema.Literal("web_fetch_20260209").annotate({ "title": "Type" }) +}).annotate({ "title": "WebFetchTool_20260209", "identifier": "BetaWebFetchTool_20260209" }) +export type BetaWebFetchTool_20260309 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "citations"?: BetaRequestCitationsConfig | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> - readonly "name": "str_replace_editor" + readonly "max_content_tokens"?: number | null + readonly "max_uses"?: number | null + readonly "name": "web_fetch" readonly "strict"?: boolean - readonly "type": "text_editor_20250124" + readonly "type": "web_fetch_20260309" + readonly "use_cache"?: boolean } -export const TextEditor_20250124 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const BetaWebFetchTool_20260309 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": "List of domains to allow fetching from" + }) + ), + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": "List of domains to block fetching from" }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Defer Loading", + "citations": Schema.optionalKey( + Schema.Union([BetaRequestCitationsConfig, Schema.Null]).annotate({ + "description": "Citations configuration for fetched documents. Citations are disabled by default." + }) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", "description": "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + "max_content_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Content Tokens", + "description": + "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." + }) ), - "name": Schema.Literal("str_replace_editor").annotate({ + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) + ), + "name": Schema.Literal("web_fetch").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -5561,29 +8087,59 @@ export const TextEditor_20250124 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("text_editor_20250124").annotate({ "title": "Type" }) -}).annotate({ "title": "TextEditor_20250124" }) -export type TextEditor_20250429 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null + "type": Schema.Literal("web_fetch_20260309").annotate({ "title": "Type" }), + "use_cache": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Use Cache", + "description": + "Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources." + }) + ) +}).annotate({ + "title": "WebFetchTool_20260309", + "description": "Web fetch tool with use_cache parameter for bypassing cached content.", + "identifier": "BetaWebFetchTool_20260309" +}) +export type BetaWebFetchTool_20260318 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "citations"?: BetaRequestCitationsConfig | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> - readonly "name": "str_replace_based_edit_tool" + readonly "max_content_tokens"?: number | null + readonly "max_uses"?: number | null + readonly "name": "web_fetch" + readonly "response_inclusion"?: "full" | "excluded" readonly "strict"?: boolean - readonly "type": "text_editor_20250429" + readonly "type": "web_fetch_20260318" + readonly "use_cache"?: boolean } -export const TextEditor_20250429 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const BetaWebFetchTool_20260318 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": "List of domains to allow fetching from" + }) + ), + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": "List of domains to block fetching from" }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), + "citations": Schema.optionalKey( + Schema.Union([BetaRequestCitationsConfig, Schema.Null]).annotate({ + "description": "Citations configuration for fetched documents. Citations are disabled by default." + }) + ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -5591,39 +8147,137 @@ export const TextEditor_20250429 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + "max_content_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Content Tokens", + "description": + "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." + }) ), - "name": Schema.Literal("str_replace_based_edit_tool").annotate({ + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) + ), + "name": Schema.Literal("web_fetch").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), + "response_inclusion": Schema.optionalKey( + Schema.Literals(["full", "excluded"]).annotate({ + "title": "Response Inclusion", + "description": + "How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn." + }) + ), "strict": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Strict", "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("text_editor_20250429").annotate({ "title": "Type" }) -}).annotate({ "title": "TextEditor_20250429" }) -export type TextEditor_20250728 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "cache_control"?: CacheControlEphemeral | null + "type": Schema.Literal("web_fetch_20260318").annotate({ "title": "Type" }), + "use_cache": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Use Cache", + "description": + "Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources." + }) + ) +}).annotate({ "title": "WebFetchTool_20260318", "identifier": "BetaWebFetchTool_20260318" }) +export type BetaAdvisorTool_20260301 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "caching"?: BetaCacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> - readonly "max_characters"?: number | null - readonly "name": "str_replace_based_edit_tool" + readonly "max_tokens"?: number | null + readonly "max_uses"?: number | null + readonly "model": Model + readonly "name": "advisor" readonly "strict"?: boolean - readonly "type": "text_editor_20250728" + readonly "type": "advisor_20260301" } -export const TextEditor_20250728 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const BetaAdvisorTool_20260301 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "caching": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Caching", + "description": + "Caching for the advisor's own prompt. When set, each advisor call writes a cache entry at the given TTL so subsequent calls in the same conversation read the stable prefix. When omitted, the advisor prompt is not cached." + }) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) + ), + "max_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1024).annotate({ "expected": "a value greater than or equal to 1024" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Tokens", + "description": + "Bounds the advisor's total output (thinking + text) per call. When the advisor hits this cap, the returned advisor_result or advisor_redacted_result block carries stop_reason='max_tokens', and a truncation note is appended to the advice text the worker model sees (inside the encrypted blob in redacted mode). When set, the server also emits a remaining-tokens budget block in the advisor's prompt so the advisor self-shapes toward the cap. When omitted, the advisor model's default output cap applies and no budget block is emitted." + }) + ), + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) + ), + "model": Model, + "name": Schema.Literal("advisor").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" }) ), + "type": Schema.Literal("advisor_20260301").annotate({ "title": "Type" }) +}).annotate({ "title": "AdvisorTool_20260301", "identifier": "BetaAdvisorTool_20260301" }) +export type BetaToolSearchToolBM25_20251119 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "name": "tool_search_tool_bm25" + readonly "strict"?: boolean + readonly "type": "tool_search_tool_bm25_20251119" | "tool_search_tool_bm25" +} +export const BetaToolSearchToolBM25_20251119 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -5635,17 +8289,42 @@ export const TextEditor_20250728 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + "name": Schema.Literal("tool_search_tool_bm25").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) ), - "max_characters": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), Schema.Null]).annotate({ - "title": "Max Characters", + "type": Schema.Literals(["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]).annotate({ "title": "Type" }) +}).annotate({ "title": "ToolSearchToolBM25_20251119", "identifier": "BetaToolSearchToolBM25_20251119" }) +export type BetaToolSearchToolRegex_20251119 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "name": "tool_search_tool_regex" + readonly "strict"?: boolean + readonly "type": "tool_search_tool_regex_20251119" | "tool_search_tool_regex" +} +export const BetaToolSearchToolRegex_20251119 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", "description": - "Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file." + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "name": Schema.Literal("str_replace_based_edit_tool").annotate({ + "name": Schema.Literal("tool_search_tool_regex").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -5655,26 +8334,21 @@ export const TextEditor_20250728 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("text_editor_20250728").annotate({ "title": "Type" }) -}).annotate({ "title": "TextEditor_20250728" }) -export type Tool = { + "type": Schema.Literals(["tool_search_tool_regex_20251119", "tool_search_tool_regex"]).annotate({ "title": "Type" }) +}).annotate({ "title": "ToolSearchToolRegex_20251119", "identifier": "BetaToolSearchToolRegex_20251119" }) +export type BetaTool = { readonly "type"?: null | "custom" readonly "description"?: string readonly "name": string - readonly "input_schema": { - readonly "properties"?: { readonly [x: string]: Schema.Json } | null - readonly "required"?: ReadonlyArray | null - readonly "type": "object" - readonly [x: string]: Schema.Json - } - readonly "cache_control"?: CacheControlEphemeral | null + readonly "input_schema": BetaInputSchema + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "strict"?: boolean readonly "eager_input_streaming"?: boolean | null - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> + readonly "allowed_callers"?: ReadonlyArray readonly "defer_loading"?: boolean - readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: JsonValue }> + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> } -export const Tool = Schema.Struct({ +export const BetaTool = Schema.Struct({ "type": Schema.optionalKey(Schema.Union([Schema.Null, Schema.Literal("custom")]).annotate({ "title": "Type" })), "description": Schema.optionalKey(Schema.String.annotate({ "title": "Description", @@ -5684,27 +8358,19 @@ export const Tool = Schema.Struct({ "name": Schema.String.annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(128)).check( - Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,128}$")) + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" }) + ).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,128}$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]{1,128}$" + }) ), - "input_schema": Schema.StructWithRest( - Schema.Struct({ - "properties": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json), Schema.Null]).annotate({ "title": "Properties" }) - ), - "required": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Required" }) - ), - "type": Schema.Literal("object").annotate({ "title": "Type" }) - }), - [Schema.Record(Schema.String, Schema.Json)] - ).annotate({ - "title": "InputSchema", + "input_schema": Schema.suspend((): Schema.Codec => BetaInputSchema).annotate({ "description": "[JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.\n\nThis defines the shape of the `input` that your tool accepts and that the model will produce." }), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -5722,11 +8388,7 @@ export const Tool = Schema.Struct({ "Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers." }) ), - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -5735,136 +8397,107 @@ export const Tool = Schema.Struct({ }) ), "input_examples": Schema.optionalKey( - Schema.Array(Schema.Record(Schema.String, JsonValue)).annotate({ "title": "Input Examples" }) + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) ) -}).annotate({ "title": "Tool" }) -export type ListResponse_MessageBatch_ = { - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "has_more": boolean - readonly "last_id": string | null +}).annotate({ "title": "Tool", "identifier": "BetaTool" }) +export type BetaBashTool_20241022 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "name": "bash" + readonly "strict"?: boolean + readonly "type": "bash_20241022" } -export const ListResponse_MessageBatch_ = Schema.Struct({ - "data": Schema.Array(MessageBatch).annotate({ "title": "Data" }), - "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "First Id", - "description": "First ID in the `data` list. Can be used as the `before_id` for the previous page." +export const BetaBashTool_20241022 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) + ), + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("bash").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), - "has_more": Schema.Boolean.annotate({ - "title": "Has More", - "description": "Indicates if there are more results in the requested page direction." - }), - "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Last Id", - "description": "Last ID in the `data` list. Can be used as the `after_id` for the next page." - }) -}).annotate({ "title": "ListResponse[MessageBatch]" }) -export type ListResponse_ModelInfo_ = { - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "has_more": boolean - readonly "last_id": string | null -} -export const ListResponse_ModelInfo_ = Schema.Struct({ - "data": Schema.Array(ModelInfo).annotate({ "title": "Data" }), - "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "First Id", - "description": "First ID in the `data` list. Can be used as the `before_id` for the previous page." - }), - "has_more": Schema.Boolean.annotate({ - "title": "Has More", - "description": "Indicates if there are more results in the requested page direction." - }), - "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Last Id", - "description": "Last ID in the `data` list. Can be used as the `after_id` for the next page." - }) -}).annotate({ "title": "ListResponse[ModelInfo]" }) -export type ErrorResponse = { - readonly "error": - | InvalidRequestError - | AuthenticationError - | BillingError - | PermissionError - | NotFoundError - | RateLimitError - | GatewayTimeoutError - | APIError - | OverloadedError - readonly "request_id": string | null - readonly "type": "error" -} -export const ErrorResponse = Schema.Struct({ - "error": Schema.Union([ - InvalidRequestError, - AuthenticationError, - BillingError, - PermissionError, - NotFoundError, - RateLimitError, - GatewayTimeoutError, - APIError, - OverloadedError - ], { mode: "oneOf" }).annotate({ "title": "Error" }), - "request_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Request Id", "default": null }), - "type": Schema.Literal("error").annotate({ "title": "Type", "default": "error" }) -}).annotate({ "title": "ErrorResponse" }) -export type RequestBashCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "return_code": number - readonly "stderr": string - readonly "stdout": string - readonly "type": "bash_code_execution_result" -} -export const RequestBashCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(RequestBashCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "stdout": Schema.String.annotate({ "title": "Stdout" }), - "type": Schema.Literal("bash_code_execution_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestBashCodeExecutionResultBlock" }) -export type WebFetchTool_20250910 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "allowed_domains"?: ReadonlyArray | null - readonly "blocked_domains"?: ReadonlyArray | null - readonly "cache_control"?: CacheControlEphemeral | null - readonly "citations"?: RequestCitationsConfig | null + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) + ), + "type": Schema.Literal("bash_20241022").annotate({ "title": "Type" }) +}).annotate({ "title": "BashTool_20241022", "identifier": "BetaBashTool_20241022" }) +export type BetaBashTool_20250124 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "max_content_tokens"?: number | null - readonly "max_uses"?: number | null - readonly "name": "web_fetch" + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "name": "bash" readonly "strict"?: boolean - readonly "type": "web_fetch_20250910" + readonly "type": "bash_20250124" } -export const WebFetchTool_20250910 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const BetaBashTool_20250124 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "allowed_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Allowed Domains", - "description": "List of domains to allow fetching from" + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "blocked_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Blocked Domains", - "description": "List of domains to block fetching from" + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("bash").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" }) ), + "type": Schema.Literal("bash_20250124").annotate({ "title": "Type" }) +}).annotate({ "title": "BashTool_20250124", "identifier": "BetaBashTool_20250124" }) +export type BetaComputerUseTool_20241022 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "display_height_px": number + readonly "display_number"?: number | null + readonly "display_width_px": number + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "name": "computer" + readonly "strict"?: boolean + readonly "type": "computer_20241022" +} +export const BetaComputerUseTool_20241022 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "citations": Schema.optionalKey( - Schema.Union([RequestCitationsConfig, Schema.Null]).annotate({ - "description": "Citations configuration for fetched documents. Citations are disabled by default." - }) - ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -5872,20 +8505,30 @@ export const WebFetchTool_20250910 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "max_content_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ - "title": "Max Content Tokens", - "description": - "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." - }) + "display_height_px": Schema.Number.annotate({ + "title": "Display Height Px", + "description": "The height of the display in pixels." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) ), - "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ - "title": "Max Uses", - "description": "Maximum number of times the tool can be used in the API request." - }) + "display_number": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]).annotate({ "title": "Display Number", "description": "The X11 display number (e.g. 0, 1) for the display." }) ), - "name": Schema.Literal("web_fetch").annotate({ + "display_width_px": Schema.Number.annotate({ + "title": "Display Width Px", + "description": "The width of the display in pixels." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("computer").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -5895,50 +8538,67 @@ export const WebFetchTool_20250910 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("web_fetch_20250910").annotate({ "title": "Type" }) -}).annotate({ "title": "WebFetchTool_20250910" }) -export type WebFetchTool_20260209 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "allowed_domains"?: ReadonlyArray | null - readonly "blocked_domains"?: ReadonlyArray | null - readonly "cache_control"?: CacheControlEphemeral | null - readonly "citations"?: RequestCitationsConfig | null + "type": Schema.Literal("computer_20241022").annotate({ "title": "Type" }) +}).annotate({ "title": "ComputerUseTool_20241022", "identifier": "BetaComputerUseTool_20241022" }) +export type BetaMemoryTool_20250818 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "max_content_tokens"?: number | null - readonly "max_uses"?: number | null - readonly "name": "web_fetch" + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "name": "memory" readonly "strict"?: boolean - readonly "type": "web_fetch_20260209" + readonly "type": "memory_20250818" } -export const WebFetchTool_20260209 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const BetaMemoryTool_20250818 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "allowed_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Allowed Domains", - "description": "List of domains to allow fetching from" + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "blocked_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Blocked Domains", - "description": "List of domains to block fetching from" + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("memory").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" }) ), + "type": Schema.Literal("memory_20250818").annotate({ "title": "Type" }) +}).annotate({ "title": "MemoryTool_20250818", "identifier": "BetaMemoryTool_20250818" }) +export type BetaComputerUseTool_20250124 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "display_height_px": number + readonly "display_number"?: number | null + readonly "display_width_px": number + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "name": "computer" + readonly "strict"?: boolean + readonly "type": "computer_20250124" +} +export const BetaComputerUseTool_20250124 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "citations": Schema.optionalKey( - Schema.Union([RequestCitationsConfig, Schema.Null]).annotate({ - "description": "Citations configuration for fetched documents. Citations are disabled by default." - }) - ), "defer_loading": Schema.optionalKey( Schema.Boolean.annotate({ "title": "Defer Loading", @@ -5946,20 +8606,30 @@ export const WebFetchTool_20260209 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "max_content_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ - "title": "Max Content Tokens", - "description": - "Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs." - }) + "display_height_px": Schema.Number.annotate({ + "title": "Display Height Px", + "description": "The height of the display in pixels." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) ), - "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ - "title": "Max Uses", - "description": "Maximum number of times the tool can be used in the API request." - }) + "display_number": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]).annotate({ "title": "Display Number", "description": "The X11 display number (e.g. 0, 1) for the display." }) ), - "name": Schema.Literal("web_fetch").annotate({ + "display_width_px": Schema.Number.annotate({ + "title": "Display Width Px", + "description": "The width of the display in pixels." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("computer").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -5969,448 +8639,208 @@ export const WebFetchTool_20260209 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("web_fetch_20260209").annotate({ "title": "Type" }) -}).annotate({ "title": "WebFetchTool_20260209" }) -export type RequestCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "return_code": number - readonly "stderr": string - readonly "stdout": string - readonly "type": "code_execution_result" -} -export const RequestCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(RequestCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "stdout": Schema.String.annotate({ "title": "Stdout" }), - "type": Schema.Literal("code_execution_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestCodeExecutionResultBlock" }) -export type RequestEncryptedCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "encrypted_stdout": string - readonly "return_code": number - readonly "stderr": string - readonly "type": "encrypted_code_execution_result" -} -export const RequestEncryptedCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(RequestCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "encrypted_stdout": Schema.String.annotate({ "title": "Encrypted Stdout" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "type": Schema.Literal("encrypted_code_execution_result").annotate({ "title": "Type" }) -}).annotate({ - "title": "RequestEncryptedCodeExecutionResultBlock", - "description": "Code execution result with encrypted stdout for PFC + web_search results." -}) -export type RequestTextBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "citations"?: - | ReadonlyArray< - | RequestCharLocationCitation - | RequestPageLocationCitation - | RequestContentBlockLocationCitation - | RequestWebSearchResultLocationCitation - | RequestSearchResultLocationCitation - > - | null - readonly "text": string - readonly "type": "text" + "type": Schema.Literal("computer_20250124").annotate({ "title": "Type" }) +}).annotate({ "title": "ComputerUseTool_20250124", "identifier": "BetaComputerUseTool_20250124" }) +export type BetaTextEditor_20241022 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "name": "str_replace_editor" + readonly "strict"?: boolean + readonly "type": "text_editor_20241022" } -export const RequestTextBlock = Schema.Struct({ +export const BetaTextEditor_20241022 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "citations": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([ - RequestCharLocationCitation, - RequestPageLocationCitation, - RequestContentBlockLocationCitation, - RequestWebSearchResultLocationCitation, - RequestSearchResultLocationCitation - ], { mode: "oneOf" }) - ), - Schema.Null - ]).annotate({ "title": "Citations" }) + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) ), - "text": Schema.String.annotate({ "title": "Text" }).check(Schema.isMinLength(1)), - "type": Schema.Literal("text").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextBlock" }) -export type ResponseBashCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "return_code": number - readonly "stderr": string - readonly "stdout": string - readonly "type": "bash_code_execution_result" -} -export const ResponseBashCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(ResponseBashCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "stdout": Schema.String.annotate({ "title": "Stdout" }), - "type": Schema.Literal("bash_code_execution_result").annotate({ - "title": "Type", - "default": "bash_code_execution_result" - }) -}).annotate({ "title": "ResponseBashCodeExecutionResultBlock" }) -export type ResponseDocumentBlock = { - readonly "citations": ResponseCitationsConfig | null - readonly "source": Base64PDFSource | PlainTextSource - readonly "title": string | null - readonly "type": "document" -} -export const ResponseDocumentBlock = Schema.Struct({ - "citations": Schema.Union([ResponseCitationsConfig, Schema.Null]).annotate({ - "description": "Citation configuration for the document", - "default": null - }), - "source": Schema.Union([Base64PDFSource, PlainTextSource], { mode: "oneOf" }).annotate({ "title": "Source" }), - "title": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Title", - "description": "The title of the document", - "default": null + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("str_replace_editor").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), - "type": Schema.Literal("document").annotate({ "title": "Type", "default": "document" }) -}).annotate({ "title": "ResponseDocumentBlock" }) -export type ResponseCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "return_code": number - readonly "stderr": string - readonly "stdout": string - readonly "type": "code_execution_result" -} -export const ResponseCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(ResponseCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "stdout": Schema.String.annotate({ "title": "Stdout" }), - "type": Schema.Literal("code_execution_result").annotate({ "title": "Type", "default": "code_execution_result" }) -}).annotate({ "title": "ResponseCodeExecutionResultBlock" }) -export type ResponseEncryptedCodeExecutionResultBlock = { - readonly "content": ReadonlyArray - readonly "encrypted_stdout": string - readonly "return_code": number - readonly "stderr": string - readonly "type": "encrypted_code_execution_result" -} -export const ResponseEncryptedCodeExecutionResultBlock = Schema.Struct({ - "content": Schema.Array(ResponseCodeExecutionOutputBlock).annotate({ "title": "Content" }), - "encrypted_stdout": Schema.String.annotate({ "title": "Encrypted Stdout" }), - "return_code": Schema.Number.annotate({ "title": "Return Code" }).check(Schema.isInt()), - "stderr": Schema.String.annotate({ "title": "Stderr" }), - "type": Schema.Literal("encrypted_code_execution_result").annotate({ - "title": "Type", - "default": "encrypted_code_execution_result" - }) -}).annotate({ - "title": "ResponseEncryptedCodeExecutionResultBlock", - "description": "Code execution result with encrypted stdout for PFC + web_search results." -}) -export type ResponseToolSearchToolSearchResultBlock = { - readonly "tool_references": ReadonlyArray - readonly "type": "tool_search_tool_search_result" -} -export const ResponseToolSearchToolSearchResultBlock = Schema.Struct({ - "tool_references": Schema.Array(ResponseToolReferenceBlock).annotate({ "title": "Tool References" }), - "type": Schema.Literal("tool_search_tool_search_result").annotate({ - "title": "Type", - "default": "tool_search_tool_search_result" - }) -}).annotate({ "title": "ResponseToolSearchToolSearchResultBlock" }) -export type CitationsDelta = { - readonly "citation": - | ResponseCharLocationCitation - | ResponsePageLocationCitation - | ResponseContentBlockLocationCitation - | ResponseWebSearchResultLocationCitation - | ResponseSearchResultLocationCitation - readonly "type": "citations_delta" -} -export const CitationsDelta = Schema.Struct({ - "citation": Schema.Union([ - ResponseCharLocationCitation, - ResponsePageLocationCitation, - ResponseContentBlockLocationCitation, - ResponseWebSearchResultLocationCitation, - ResponseSearchResultLocationCitation - ], { mode: "oneOf" }).annotate({ "title": "Citation" }), - "type": Schema.Literal("citations_delta").annotate({ "title": "Type", "default": "citations_delta" }) -}).annotate({ "title": "CitationsDelta" }) -export type ResponseTextBlock = { - readonly "citations"?: - | ReadonlyArray< - | ResponseCharLocationCitation - | ResponsePageLocationCitation - | ResponseContentBlockLocationCitation - | ResponseWebSearchResultLocationCitation - | ResponseSearchResultLocationCitation - > - | null - readonly "text": string - readonly "type": "text" -} -export const ResponseTextBlock = Schema.Struct({ - "citations": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([ - ResponseCharLocationCitation, - ResponsePageLocationCitation, - ResponseContentBlockLocationCitation, - ResponseWebSearchResultLocationCitation, - ResponseSearchResultLocationCitation - ], { mode: "oneOf" }) - ), - Schema.Null - ]).annotate({ - "title": "Citations", - "description": - "Citations supporting the text block.\n\nThe type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.", - "default": null + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "text": Schema.String.annotate({ "title": "Text" }).check(Schema.isMinLength(0)).check(Schema.isMaxLength(5000000)), - "type": Schema.Literal("text").annotate({ "title": "Type", "default": "text" }) -}).annotate({ "title": "ResponseTextBlock" }) -export type RequestServerToolUseBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "caller"?: DirectCaller | ServerToolCaller | ServerToolCaller_20260120 - readonly "id": string - readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": - | "web_search" - | "web_fetch" - | "code_execution" - | "bash_code_execution" - | "text_editor_code_execution" - | "tool_search_tool_regex" - | "tool_search_tool_bm25" - readonly "type": "server_tool_use" + "type": Schema.Literal("text_editor_20241022").annotate({ "title": "Type" }) +}).annotate({ "title": "TextEditor_20241022", "identifier": "BetaTextEditor_20241022" }) +export type BetaComputerUseTool_20251124 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "display_height_px": number + readonly "display_number"?: number | null + readonly "display_width_px": number + readonly "enable_zoom"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "name": "computer" + readonly "strict"?: boolean + readonly "type": "computer_20251124" } -export const RequestServerToolUseBlock = Schema.Struct({ +export const BetaComputerUseTool_20251124 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "caller": Schema.optionalKey( - Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.Literals([ - "web_search", - "web_fetch", - "code_execution", - "bash_code_execution", - "text_editor_code_execution", - "tool_search_tool_regex", - "tool_search_tool_bm25" - ]).annotate({ "title": "Name" }), - "type": Schema.Literal("server_tool_use").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestServerToolUseBlock" }) -export type ResponseServerToolUseBlock = { - readonly "caller": DirectCaller | ServerToolCaller | ServerToolCaller_20260120 - readonly "id": string - readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": - | "web_search" - | "web_fetch" - | "code_execution" - | "bash_code_execution" - | "text_editor_code_execution" - | "tool_search_tool_regex" - | "tool_search_tool_bm25" - readonly "type": "server_tool_use" -} -export const ResponseServerToolUseBlock = Schema.Struct({ - "caller": Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller", - "default": { "type": "direct" } - }), - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.Literals([ - "web_search", - "web_fetch", - "code_execution", - "bash_code_execution", - "text_editor_code_execution", - "tool_search_tool_regex", - "tool_search_tool_bm25" - ]).annotate({ "title": "Name" }), - "type": Schema.Literal("server_tool_use").annotate({ "title": "Type", "default": "server_tool_use" }) -}).annotate({ "title": "ResponseServerToolUseBlock" }) -export type ResponseToolUseBlock = { - readonly "caller": DirectCaller | ServerToolCaller | ServerToolCaller_20260120 - readonly "id": string - readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": string - readonly "type": "tool_use" -} -export const ResponseToolUseBlock = Schema.Struct({ - "caller": Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller", - "default": { "type": "direct" } - }), - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.String.annotate({ "title": "Name" }).check(Schema.isMinLength(1)), - "type": Schema.Literal("tool_use").annotate({ "title": "Type", "default": "tool_use" }) -}).annotate({ "title": "ResponseToolUseBlock" }) -export type ListSkillsResponse = { - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next_page": string | null -} -export const ListSkillsResponse = Schema.Struct({ - "data": Schema.Array(Skill).annotate({ "title": "Data", "description": "List of skills." }), - "has_more": Schema.Boolean.annotate({ - "title": "Has More", - "description": - "Whether there are more results available.\n\nIf `true`, there are additional results that can be fetched using the `next_page` token." - }), - "next_page": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Next Page", - "description": - "Token for fetching the next page of results.\n\nIf `null`, there are no more results available. Pass this value to the `page_token` parameter in the next request to get the next page." - }) -}).annotate({ "title": "ListSkillsResponse" }) -export type ListSkillVersionsResponse = { - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next_page": string | null -} -export const ListSkillVersionsResponse = Schema.Struct({ - "data": Schema.Array(SkillVersion).annotate({ "title": "Data", "description": "List of skill versions." }), - "has_more": Schema.Boolean.annotate({ - "title": "Has More", - "description": "Indicates if there are more results in the requested page direction." + "display_height_px": Schema.Number.annotate({ + "title": "Display Height Px", + "description": "The height of the display in pixels." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + "display_number": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]).annotate({ "title": "Display Number", "description": "The X11 display number (e.g. 0, 1) for the display." }) + ), + "display_width_px": Schema.Number.annotate({ + "title": "Display Width Px", + "description": "The width of the display in pixels." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + "enable_zoom": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Enable Zoom", + "description": "Whether to enable an action to take a zoomed-in screenshot of the screen." + }) + ), + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("computer").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), - "next_page": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Next Page", - "description": "Token to provide in as `page` in the subsequent request to retrieve the next page of data." - }) -}).annotate({ "title": "ListSkillVersionsResponse" }) -export type RequestTextEditorCodeExecutionToolResultError = { - readonly "error_code": TextEditorCodeExecutionToolResultErrorCode - readonly "error_message"?: string | null - readonly "type": "text_editor_code_execution_tool_result_error" -} -export const RequestTextEditorCodeExecutionToolResultError = Schema.Struct({ - "error_code": TextEditorCodeExecutionToolResultErrorCode, - "error_message": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message" }) + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) ), - "type": Schema.Literal("text_editor_code_execution_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionToolResultError" }) -export type ResponseTextEditorCodeExecutionToolResultError = { - readonly "error_code": TextEditorCodeExecutionToolResultErrorCode - readonly "error_message": string | null - readonly "type": "text_editor_code_execution_tool_result_error" -} -export const ResponseTextEditorCodeExecutionToolResultError = Schema.Struct({ - "error_code": TextEditorCodeExecutionToolResultErrorCode, - "error_message": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message", "default": null }), - "type": Schema.Literal("text_editor_code_execution_tool_result_error").annotate({ - "title": "Type", - "default": "text_editor_code_execution_tool_result_error" - }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionToolResultError" }) -export type ThinkingConfigParam = ThinkingConfigEnabled | ThinkingConfigDisabled | ThinkingConfigAdaptive -export const ThinkingConfigParam = Schema.Union( - [ThinkingConfigEnabled, ThinkingConfigDisabled, ThinkingConfigAdaptive], - { mode: "oneOf" } -).annotate({ - "title": "Thinking", - "description": - "Configuration for enabling Claude's extended thinking.\n\nWhen enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.\n\nSee [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details." -}) -export type ToolChoice = ToolChoiceAuto | ToolChoiceAny | ToolChoiceTool | ToolChoiceNone -export const ToolChoice = Schema.Union([ToolChoiceAuto, ToolChoiceAny, ToolChoiceTool, ToolChoiceNone], { - mode: "oneOf" -}).annotate({ - "title": "Tool Choice", - "description": - "How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all." -}) -export type RequestToolSearchToolResultError = { - readonly "error_code": ToolSearchToolResultErrorCode - readonly "type": "tool_search_tool_result_error" -} -export const RequestToolSearchToolResultError = Schema.Struct({ - "error_code": ToolSearchToolResultErrorCode, - "type": Schema.Literal("tool_search_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestToolSearchToolResultError" }) -export type ResponseToolSearchToolResultError = { - readonly "error_code": ToolSearchToolResultErrorCode - readonly "error_message": string | null - readonly "type": "tool_search_tool_result_error" -} -export const ResponseToolSearchToolResultError = Schema.Struct({ - "error_code": ToolSearchToolResultErrorCode, - "error_message": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Error Message", "default": null }), - "type": Schema.Literal("tool_search_tool_result_error").annotate({ - "title": "Type", - "default": "tool_search_tool_result_error" - }) -}).annotate({ "title": "ResponseToolSearchToolResultError" }) -export type RequestImageBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "source": Base64ImageSource | URLImageSource - readonly "type": "image" + "type": Schema.Literal("computer_20251124").annotate({ "title": "Type" }) +}).annotate({ "title": "ComputerUseTool_20251124", "identifier": "BetaComputerUseTool_20251124" }) +export type BetaTextEditor_20250124 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "name": "str_replace_editor" + readonly "strict"?: boolean + readonly "type": "text_editor_20250124" } -export const RequestImageBlock = Schema.Struct({ +export const BetaTextEditor_20250124 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "source": Schema.Union([Base64ImageSource, URLImageSource], { mode: "oneOf" }).annotate({ "title": "Source" }), - "type": Schema.Literal("image").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestImageBlock" }) -export type WebSearchTool_20250305 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> - readonly "allowed_domains"?: ReadonlyArray | null - readonly "blocked_domains"?: ReadonlyArray | null - readonly "cache_control"?: CacheControlEphemeral | null + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) + ), + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("str_replace_editor").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) + ), + "type": Schema.Literal("text_editor_20250124").annotate({ "title": "Type" }) +}).annotate({ "title": "TextEditor_20250124", "identifier": "BetaTextEditor_20250124" }) +export type BetaTextEditor_20250429 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "defer_loading"?: boolean - readonly "max_uses"?: number | null - readonly "name": "web_search" + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "name": "str_replace_based_edit_tool" readonly "strict"?: boolean - readonly "type": "web_search_20250305" - readonly "user_location"?: UserLocation | null + readonly "type": "text_editor_20250429" } -export const WebSearchTool_20250305 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" +export const BetaTextEditor_20250429 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "allowed_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Allowed Domains", + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", "description": - "If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`." + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "blocked_domains": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "title": "Blocked Domains", - "description": - "If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`." + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "name": Schema.Literal("str_replace_based_edit_tool").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" }) ), + "type": Schema.Literal("text_editor_20250429").annotate({ "title": "Type" }) +}).annotate({ "title": "TextEditor_20250429", "identifier": "BetaTextEditor_20250429" }) +export type BetaTextEditor_20250728 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "input_examples"?: ReadonlyArray<{ readonly [x: string]: BetaJsonValue }> + readonly "max_characters"?: number | null + readonly "name": "str_replace_based_edit_tool" + readonly "strict"?: boolean + readonly "type": "text_editor_20250728" +} +export const BetaTextEditor_20250728 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -6422,13 +8852,22 @@ export const WebSearchTool_20250305 = Schema.Struct({ "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ - "title": "Max Uses", - "description": "Maximum number of times the tool can be used in the API request." + "input_examples": Schema.optionalKey( + Schema.Array(Schema.Record(Schema.String, BetaJsonValue)).annotate({ "title": "Input Examples" }) + ), + "max_characters": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Characters", + "description": + "Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file." }) ), - "name": Schema.Literal("web_search").annotate({ + "name": Schema.Literal("str_replace_based_edit_tool").annotate({ "title": "Name", "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), @@ -6438,31 +8877,22 @@ export const WebSearchTool_20250305 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("web_search_20250305").annotate({ "title": "Type" }), - "user_location": Schema.optionalKey( - Schema.Union([UserLocation, Schema.Null]).annotate({ - "description": "Parameters for the user's location. Used to provide more relevant search results." - }) - ) -}).annotate({ "title": "WebSearchTool_20250305" }) -export type WebSearchTool_20260209 = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> + "type": Schema.Literal("text_editor_20250728").annotate({ "title": "Type" }) +}).annotate({ "title": "TextEditor_20250728", "identifier": "BetaTextEditor_20250728" }) +export type BetaWebSearchTool_20250305 = { + readonly "allowed_callers"?: ReadonlyArray readonly "allowed_domains"?: ReadonlyArray | null readonly "blocked_domains"?: ReadonlyArray | null - readonly "cache_control"?: CacheControlEphemeral | null + readonly "cache_control"?: BetaCacheControlEphemeral | null readonly "defer_loading"?: boolean readonly "max_uses"?: number | null readonly "name": "web_search" readonly "strict"?: boolean - readonly "type": "web_search_20260209" - readonly "user_location"?: UserLocation | null + readonly "type": "web_search_20250305" + readonly "user_location"?: BetaUserLocation | null } -export const WebSearchTool_20260209 = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Array(Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"])).annotate({ - "title": "Allowed Callers" - }) - ), +export const BetaWebSearchTool_20250305 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), "allowed_domains": Schema.optionalKey( Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "title": "Allowed Domains", @@ -6478,7 +8908,7 @@ export const WebSearchTool_20260209 = Schema.Struct({ }) ), "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) @@ -6491,7 +8921,12 @@ export const WebSearchTool_20260209 = Schema.Struct({ }) ), "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThan(0)), Schema.Null]).annotate({ + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ "title": "Max Uses", "description": "Maximum number of times the tool can be used in the API request." }) @@ -6506,5265 +8941,18601 @@ export const WebSearchTool_20260209 = Schema.Struct({ "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "type": Schema.Literal("web_search_20260209").annotate({ "title": "Type" }), + "type": Schema.Literal("web_search_20250305").annotate({ "title": "Type" }), "user_location": Schema.optionalKey( - Schema.Union([UserLocation, Schema.Null]).annotate({ + Schema.Union([BetaUserLocation, Schema.Null]).annotate({ "description": "Parameters for the user's location. Used to provide more relevant search results." }) ) -}).annotate({ "title": "WebSearchTool_20260209" }) -export type RequestWebFetchToolResultError = { - readonly "error_code": WebFetchToolResultErrorCode - readonly "type": "web_fetch_tool_result_error" -} -export const RequestWebFetchToolResultError = Schema.Struct({ - "error_code": WebFetchToolResultErrorCode, - "type": Schema.Literal("web_fetch_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestWebFetchToolResultError" }) -export type ResponseWebFetchToolResultError = { - readonly "error_code": WebFetchToolResultErrorCode - readonly "type": "web_fetch_tool_result_error" -} -export const ResponseWebFetchToolResultError = Schema.Struct({ - "error_code": WebFetchToolResultErrorCode, - "type": Schema.Literal("web_fetch_tool_result_error").annotate({ - "title": "Type", - "default": "web_fetch_tool_result_error" - }) -}).annotate({ "title": "ResponseWebFetchToolResultError" }) -export type RequestWebSearchToolResultError = { - readonly "error_code": WebSearchToolResultErrorCode - readonly "type": "web_search_tool_result_error" -} -export const RequestWebSearchToolResultError = Schema.Struct({ - "error_code": WebSearchToolResultErrorCode, - "type": Schema.Literal("web_search_tool_result_error").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestWebSearchToolResultError" }) -export type ResponseWebSearchToolResultError = { - readonly "error_code": WebSearchToolResultErrorCode - readonly "type": "web_search_tool_result_error" -} -export const ResponseWebSearchToolResultError = Schema.Struct({ - "error_code": WebSearchToolResultErrorCode, - "type": Schema.Literal("web_search_tool_result_error").annotate({ - "title": "Type", - "default": "web_search_tool_result_error" - }) -}).annotate({ "title": "ResponseWebSearchToolResultError" }) -export type MessageDelta = { - readonly "container": Container | null - readonly "stop_reason": StopReason | null - readonly "stop_sequence": string | null -} -export const MessageDelta = Schema.Struct({ - "container": Schema.Union([Container, Schema.Null]).annotate({ - "description": - "Information about the container used in this request.\n\nThis will be non-null if a container tool (e.g. code execution) was used.", - "default": null - }), - "stop_reason": Schema.Union([StopReason, Schema.Null]).annotate({ "title": "Stop Reason", "default": null }), - "stop_sequence": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Stop Sequence", "default": null }) -}).annotate({ "title": "MessageDelta" }) -export type CompletionRequest = { - readonly "model": Model - readonly "prompt": string - readonly "max_tokens_to_sample": number - readonly "stop_sequences"?: ReadonlyArray - readonly "temperature"?: number - readonly "top_p"?: number - readonly "top_k"?: number - readonly "metadata"?: { readonly "user_id"?: string | null } - readonly "stream"?: boolean +}).annotate({ "title": "WebSearchTool_20250305", "identifier": "BetaWebSearchTool_20250305" }) +export type BetaWebSearchTool_20260209 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "defer_loading"?: boolean + readonly "max_uses"?: number | null + readonly "name": "web_search" + readonly "strict"?: boolean + readonly "type": "web_search_20260209" + readonly "user_location"?: BetaUserLocation | null } -export const CompletionRequest = Schema.Struct({ - "model": Model, - "prompt": Schema.String.annotate({ - "title": "Prompt", - "description": - "The prompt that you want Claude to complete.\n\nFor proper response generation you will need to format your prompt using alternating `\\n\\nHuman:` and `\\n\\nAssistant:` conversational turns. For example:\n\n```\n\"\\n\\nHuman: {userQuestion}\\n\\nAssistant:\"\n```\n\nSee [prompt validation](https://docs.claude.com/en/api/prompt-validation) and our guide to [prompt design](https://docs.claude.com/en/docs/intro-to-prompting) for more details." - }).check(Schema.isMinLength(1)), - "max_tokens_to_sample": Schema.Number.annotate({ - "title": "Max Tokens To Sample", - "description": - "The maximum number of tokens to generate before stopping.\n\nNote that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "stop_sequences": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "title": "Stop Sequences", +export const BetaWebSearchTool_20260209 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", "description": - "Sequences that will cause the model to stop generating.\n\nOur models stop on `\"\\n\\nHuman:\"`, and may include additional built-in stop sequences in the future. By providing the stop_sequences parameter, you may include additional strings that will cause the model to stop generating." + "If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`." }) ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Temperature", + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", "description": - "Amount of randomness injected into the response.\n\nDefaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.\n\nNote that even with `temperature` of `0.0`, the results will not be fully deterministic." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) + "If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`." + }) ), - "top_p": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top P", - "description": - "Use nucleus sampling.\n\nIn nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both.\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) ), - "top_k": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top K", + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", "description": - "Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." + }) ), - "metadata": Schema.optionalKey( - Schema.Struct({ - "user_id": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMaxLength(256)), Schema.Null]).annotate({ - "title": "User Id", - "description": - "An external identifier for the user who is associated with the request.\n\nThis should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number." - }) - ) - }).annotate({ "title": "Metadata", "description": "An object describing metadata about the request." }) + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) ), - "stream": Schema.optionalKey( + "name": Schema.Literal("web_search").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." + }), + "strict": Schema.optionalKey( Schema.Boolean.annotate({ - "title": "Stream", - "description": - "Whether to incrementally stream the response using server-sent events.\n\nSee [streaming](https://docs.claude.com/en/api/streaming) for details." + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" + }) + ), + "type": Schema.Literal("web_search_20260209").annotate({ "title": "Type" }), + "user_location": Schema.optionalKey( + Schema.Union([BetaUserLocation, Schema.Null]).annotate({ + "description": "Parameters for the user's location. Used to provide more relevant search results." }) ) -}).annotate({ "title": "CompletionRequest" }) -export type CompletionResponse = { - readonly "completion": string - readonly "id": string - readonly "model": Model - readonly "stop_reason": string | null - readonly "type": "completion" -} -export const CompletionResponse = Schema.Struct({ - "completion": Schema.String.annotate({ - "title": "Completion", - "description": "The resulting completion up to and excluding the stop sequences." - }), - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." - }), - "model": Model, - "stop_reason": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Stop Reason", - "description": - "The reason that we stopped.\n\nThis may be one the following values:\n* `\"stop_sequence\"`: we reached a stop sequence — either provided by you via the `stop_sequences` parameter, or a stop sequence built into the model\n* `\"max_tokens\"`: we exceeded `max_tokens_to_sample` or the model's maximum" - }), - "type": Schema.Literal("completion").annotate({ - "title": "Type", - "description": "Object type.\n\nFor Text Completions, this is always `\"completion\"`.", - "default": "completion" - }) -}).annotate({ "title": "CompletionResponse" }) -export type BetaRequestToolSearchToolSearchResultBlock = { - readonly "tool_references": ReadonlyArray - readonly "type": "tool_search_tool_search_result" -} -export const BetaRequestToolSearchToolSearchResultBlock = Schema.Struct({ - "tool_references": Schema.Array(BetaRequestToolReferenceBlock).annotate({ "title": "Tool References" }), - "type": Schema.Literal("tool_search_tool_search_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestToolSearchToolSearchResultBlock" }) -export type BetaIterationsUsage = ReadonlyArray | null -export const BetaIterationsUsage = Schema.Union([ - Schema.Array(Schema.Union([BetaMessageIterationUsage, BetaCompactionIterationUsage])), - Schema.Null -]).annotate({ - "title": "Iterations", - "description": - "Per-iteration token usage breakdown.\n\nEach entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:\n- Determine which iterations exceeded long context thresholds (>=200k tokens)\n- Calculate the true context window size from the last iteration\n- Understand token accumulation across server-side tool use loops", - "default": null -}) -export type BetaErroredResult = { readonly "error": BetaErrorResponse; readonly "type": "errored" } -export const BetaErroredResult = Schema.Struct({ - "error": BetaErrorResponse, - "type": Schema.Literal("errored").annotate({ "title": "Type", "default": "errored" }) -}).annotate({ "title": "ErroredResult" }) -export type BetaRequestBashCodeExecutionToolResultBlock = { +}).annotate({ "title": "WebSearchTool_20260209", "identifier": "BetaWebSearchTool_20260209" }) +export type BetaWebSearchTool_20260318 = { + readonly "allowed_callers"?: ReadonlyArray + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "content": BetaRequestBashCodeExecutionToolResultError | BetaRequestBashCodeExecutionResultBlock - readonly "tool_use_id": string - readonly "type": "bash_code_execution_tool_result" + readonly "defer_loading"?: boolean + readonly "max_uses"?: number | null + readonly "name": "web_search" + readonly "response_inclusion"?: "full" | "excluded" + readonly "strict"?: boolean + readonly "type": "web_search_20260318" + readonly "user_location"?: BetaUserLocation | null } -export const BetaRequestBashCodeExecutionToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." +export const BetaWebSearchTool_20260318 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(Schema.Array(BetaAllowedCaller).annotate({ "title": "Allowed Callers" })), + "allowed_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Domains", + "description": + "If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`." }) ), - "content": Schema.Union([BetaRequestBashCodeExecutionToolResultError, BetaRequestBashCodeExecutionResultBlock]) - .annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "blocked_domains": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Blocked Domains", + "description": + "If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`." + }) ), - "type": Schema.Literal("bash_code_execution_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestBashCodeExecutionToolResultBlock" }) -export type BetaRequestCodeExecutionToolResultBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "content": - | BetaRequestCodeExecutionToolResultError - | BetaRequestCodeExecutionResultBlock - | BetaRequestEncryptedCodeExecutionResultBlock - readonly "tool_use_id": string - readonly "type": "code_execution_tool_result" -} -export const BetaRequestCodeExecutionToolResultBlock = Schema.Struct({ "cache_control": Schema.optionalKey( Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "content": Schema.Union([ - BetaRequestCodeExecutionToolResultError, - BetaRequestCodeExecutionResultBlock, - BetaRequestEncryptedCodeExecutionResultBlock - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("code_execution_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestCodeExecutionToolResultBlock" }) -export type BetaRequestSearchResultBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "citations"?: BetaRequestCitationsConfig - readonly "content": ReadonlyArray - readonly "source": string - readonly "title": string - readonly "type": "search_result" -} -export const BetaRequestSearchResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Defer Loading", + "description": + "If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search." }) ), - "citations": Schema.optionalKey(BetaRequestCitationsConfig), - "content": Schema.Array(BetaRequestTextBlock).annotate({ "title": "Content" }), - "source": Schema.String.annotate({ "title": "Source" }), - "title": Schema.String.annotate({ "title": "Title" }), - "type": Schema.Literal("search_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestSearchResultBlock" }) -export type BetaResponseBashCodeExecutionToolResultBlock = { - readonly "content": BetaResponseBashCodeExecutionToolResultError | BetaResponseBashCodeExecutionResultBlock - readonly "tool_use_id": string - readonly "type": "bash_code_execution_tool_result" -} -export const BetaResponseBashCodeExecutionToolResultBlock = Schema.Struct({ - "content": Schema.Union([BetaResponseBashCodeExecutionToolResultError, BetaResponseBashCodeExecutionResultBlock]) - .annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "max_uses": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Max Uses", + "description": "Maximum number of times the tool can be used in the API request." + }) ), - "type": Schema.Literal("bash_code_execution_tool_result").annotate({ - "title": "Type", - "default": "bash_code_execution_tool_result" - }) -}).annotate({ "title": "ResponseBashCodeExecutionToolResultBlock" }) -export type BetaResponseWebFetchResultBlock = { - readonly "content": BetaResponseDocumentBlock - readonly "retrieved_at": string | null - readonly "type": "web_fetch_result" - readonly "url": string -} -export const BetaResponseWebFetchResultBlock = Schema.Struct({ - "content": BetaResponseDocumentBlock, - "retrieved_at": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Retrieved At", - "description": "ISO 8601 timestamp when the content was retrieved", - "default": null + "name": Schema.Literal("web_search").annotate({ + "title": "Name", + "description": "Name of the tool.\n\nThis is how the tool will be called by the model and in `tool_use` blocks." }), - "type": Schema.Literal("web_fetch_result").annotate({ "title": "Type", "default": "web_fetch_result" }), - "url": Schema.String.annotate({ "title": "Url", "description": "Fetched content URL" }) -}).annotate({ "title": "ResponseWebFetchResultBlock" }) -export type BetaResponseCodeExecutionToolResultBlock = { - readonly "content": - | BetaResponseCodeExecutionToolResultError - | BetaResponseCodeExecutionResultBlock - | BetaResponseEncryptedCodeExecutionResultBlock - readonly "tool_use_id": string - readonly "type": "code_execution_tool_result" -} -export const BetaResponseCodeExecutionToolResultBlock = Schema.Struct({ - "content": Schema.Union([ - BetaResponseCodeExecutionToolResultError, - BetaResponseCodeExecutionResultBlock, - BetaResponseEncryptedCodeExecutionResultBlock - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("code_execution_tool_result").annotate({ - "title": "Type", - "default": "code_execution_tool_result" - }) -}).annotate({ "title": "ResponseCodeExecutionToolResultBlock" }) -export type BetaContentBlockDeltaEvent = { - readonly "delta": - | BetaTextContentBlockDelta - | BetaInputJsonContentBlockDelta - | BetaCitationsDelta - | BetaThinkingContentBlockDelta - | BetaSignatureContentBlockDelta - | BetaCompactionContentBlockDelta - readonly "index": number - readonly "type": "content_block_delta" -} -export const BetaContentBlockDeltaEvent = Schema.Struct({ - "delta": Schema.Union([ - BetaTextContentBlockDelta, - BetaInputJsonContentBlockDelta, - BetaCitationsDelta, - BetaThinkingContentBlockDelta, - BetaSignatureContentBlockDelta, - BetaCompactionContentBlockDelta - ], { mode: "oneOf" }).annotate({ "title": "Delta" }), - "index": Schema.Number.annotate({ "title": "Index" }).check(Schema.isInt()), - "type": Schema.Literal("content_block_delta").annotate({ "title": "Type", "default": "content_block_delta" }) -}).annotate({ "title": "ContentBlockDeltaEvent" }) -export type BetaMessageDelta = { - readonly "container"?: BetaContainer | null - readonly "stop_reason": BetaStopReason | null - readonly "stop_sequence": string | null -} -export const BetaMessageDelta = Schema.Struct({ - "container": Schema.optionalKey( - Schema.Union([BetaContainer, Schema.Null]).annotate({ + "response_inclusion": Schema.optionalKey( + Schema.Literals(["full", "excluded"]).annotate({ + "title": "Response Inclusion", "description": - "Information about the container used in this request.\n\nThis will be non-null if a container tool (e.g. code execution) was used.", - "default": null + "How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn." }) ), - "stop_reason": Schema.Union([BetaStopReason, Schema.Null]).annotate({ "title": "Stop Reason", "default": null }), - "stop_sequence": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Stop Sequence", "default": null }) -}).annotate({ "title": "MessageDelta" }) -export type BetaRequestTextEditorCodeExecutionToolResultBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "content": - | BetaRequestTextEditorCodeExecutionToolResultError - | BetaRequestTextEditorCodeExecutionViewResultBlock - | BetaRequestTextEditorCodeExecutionCreateResultBlock - | BetaRequestTextEditorCodeExecutionStrReplaceResultBlock - readonly "tool_use_id": string - readonly "type": "text_editor_code_execution_tool_result" -} -export const BetaRequestTextEditorCodeExecutionToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "strict": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Strict", + "description": "When true, guarantees schema validation on tool names and inputs" }) ), - "content": Schema.Union([ - BetaRequestTextEditorCodeExecutionToolResultError, - BetaRequestTextEditorCodeExecutionViewResultBlock, - BetaRequestTextEditorCodeExecutionCreateResultBlock, - BetaRequestTextEditorCodeExecutionStrReplaceResultBlock - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("text_editor_code_execution_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionToolResultBlock" }) -export type BetaResponseTextEditorCodeExecutionToolResultBlock = { - readonly "content": - | BetaResponseTextEditorCodeExecutionToolResultError - | BetaResponseTextEditorCodeExecutionViewResultBlock - | BetaResponseTextEditorCodeExecutionCreateResultBlock - | BetaResponseTextEditorCodeExecutionStrReplaceResultBlock - readonly "tool_use_id": string - readonly "type": "text_editor_code_execution_tool_result" -} -export const BetaResponseTextEditorCodeExecutionToolResultBlock = Schema.Struct({ - "content": Schema.Union([ - BetaResponseTextEditorCodeExecutionToolResultError, - BetaResponseTextEditorCodeExecutionViewResultBlock, - BetaResponseTextEditorCodeExecutionCreateResultBlock, - BetaResponseTextEditorCodeExecutionStrReplaceResultBlock - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("text_editor_code_execution_tool_result").annotate({ - "title": "Type", - "default": "text_editor_code_execution_tool_result" - }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionToolResultBlock" }) -export type BetaResponseToolSearchToolResultBlock = { - readonly "content": BetaResponseToolSearchToolResultError | BetaResponseToolSearchToolSearchResultBlock - readonly "tool_use_id": string - readonly "type": "tool_search_tool_result" -} -export const BetaResponseToolSearchToolResultBlock = Schema.Struct({ - "content": Schema.Union([BetaResponseToolSearchToolResultError, BetaResponseToolSearchToolSearchResultBlock]) - .annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("tool_search_tool_result").annotate({ "title": "Type", "default": "tool_search_tool_result" }) -}).annotate({ "title": "ResponseToolSearchToolResultBlock" }) -export type BetaContextManagementConfig = { - readonly "edits"?: ReadonlyArray -} -export const BetaContextManagementConfig = Schema.Struct({ - "edits": Schema.optionalKey( - Schema.Array( - Schema.Union([BetaClearToolUses20250919, BetaClearThinking20251015, BetaCompact20260112], { mode: "oneOf" }) - ).annotate({ "title": "Edits", "description": "List of context management edits to apply" }).check( - Schema.isMinLength(0) - ) + "type": Schema.Literal("web_search_20260318").annotate({ "title": "Type" }), + "user_location": Schema.optionalKey( + Schema.Union([BetaUserLocation, Schema.Null]).annotate({ + "description": "Parameters for the user's location. Used to provide more relevant search results." + }) ) -}).annotate({ "title": "ContextManagementConfig" }) -export type BetaContentBlockSource = { - readonly "content": string | ReadonlyArray - readonly "type": "content" -} -export const BetaContentBlockSource = Schema.Struct({ - "content": Schema.Union([ - Schema.String, - Schema.Array( - Schema.Union([BetaRequestTextBlock, BetaRequestImageBlock], { mode: "oneOf" }).annotate({ - "title": "beta_content_block_source_content_item" - }) - ).annotate({ "title": "beta_content_block_source_content" }) - ]).annotate({ "title": "Content" }), - "type": Schema.Literal("content").annotate({ "title": "Type" }) -}).annotate({ "title": "ContentBlockSource" }) -export type BetaRequestWebSearchToolResultBlock = { +}).annotate({ "title": "WebSearchTool_20260318", "identifier": "BetaWebSearchTool_20260318" }) +export type BetaMCPToolset = { readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 - readonly "content": ReadonlyArray | BetaRequestWebSearchToolResultError - readonly "tool_use_id": string - readonly "type": "web_search_tool_result" + readonly "configs"?: { readonly [x: string]: BetaMCPToolConfig } | null + readonly "default_config"?: BetaMCPToolDefaultConfig + readonly "mcp_server_name": string + readonly "type": "mcp_toolset" } -export const BetaRequestWebSearchToolResultBlock = Schema.Struct({ +export const BetaMCPToolset = Schema.Struct({ "cache_control": Schema.optionalKey( Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", "description": "Create a cache control breakpoint at this content block." }) ), - "caller": Schema.optionalKey( - Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" + "configs": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, BetaMCPToolConfig), Schema.Null]).annotate({ + "title": "Configs", + "description": "Configuration overrides for specific tools, keyed by tool name" }) ), - "content": Schema.Union([ - Schema.Array(BetaRequestWebSearchResultBlock).annotate({ "title": "Result Block" }), - BetaRequestWebSearchToolResultError - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("web_search_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestWebSearchToolResultBlock" }) -export type BetaResponseWebSearchToolResultBlock = { - readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 - readonly "content": BetaResponseWebSearchToolResultError | ReadonlyArray - readonly "tool_use_id": string - readonly "type": "web_search_tool_result" -} -export const BetaResponseWebSearchToolResultBlock = Schema.Struct({ - "caller": Schema.optionalKey( - Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" + "default_config": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaMCPToolDefaultConfig).annotate({ + "description": "Default configuration applied to all tools from this server" }) ), - "content": Schema.Union([BetaResponseWebSearchToolResultError, Schema.Array(BetaResponseWebSearchResultBlock)]) - .annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "mcp_server_name": Schema.String.annotate({ + "title": "Mcp Server Name", + "description": "Name of the MCP server to configure tools for" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) ), - "type": Schema.Literal("web_search_tool_result").annotate({ "title": "Type", "default": "web_search_tool_result" }) -}).annotate({ "title": "ResponseWebSearchToolResultBlock" }) -export type RequestToolSearchToolSearchResultBlock = { - readonly "tool_references": ReadonlyArray - readonly "type": "tool_search_tool_search_result" -} -export const RequestToolSearchToolSearchResultBlock = Schema.Struct({ - "tool_references": Schema.Array(RequestToolReferenceBlock).annotate({ "title": "Tool References" }), - "type": Schema.Literal("tool_search_tool_search_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestToolSearchToolSearchResultBlock" }) -export type ErroredResult = { readonly "error": ErrorResponse; readonly "type": "errored" } -export const ErroredResult = Schema.Struct({ - "error": ErrorResponse, - "type": Schema.Literal("errored").annotate({ "title": "Type", "default": "errored" }) -}).annotate({ "title": "ErroredResult" }) -export type RequestBashCodeExecutionToolResultBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "content": RequestBashCodeExecutionToolResultError | RequestBashCodeExecutionResultBlock - readonly "tool_use_id": string - readonly "type": "bash_code_execution_tool_result" + "type": Schema.Literal("mcp_toolset").annotate({ "title": "Type" }) +}).annotate({ + "title": "MCPToolset", + "description": + "Configuration for a group of tools from an MCP server.\n\nAllows configuring enabled status and defer_loading for all tools\nfrom an MCP server, with optional per-tool overrides.", + "identifier": "BetaMCPToolset" +}) +export type BetaResponseTextBlock = { + readonly "citations"?: + | ReadonlyArray< + | BetaResponseCharLocationCitation + | BetaResponsePageLocationCitation + | BetaResponseContentBlockLocationCitation + | BetaResponseWebSearchResultLocationCitation + | BetaResponseSearchResultLocationCitation + > + | null + readonly "text": string + readonly "type": "text" } -export const RequestBashCodeExecutionToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." +export const BetaResponseTextBlock = Schema.Struct({ + "citations": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Union([ + BetaResponseCharLocationCitation, + BetaResponsePageLocationCitation, + BetaResponseContentBlockLocationCitation, + BetaResponseWebSearchResultLocationCitation, + BetaResponseSearchResultLocationCitation + ], { mode: "oneOf" }) + ), + Schema.Null + ]).annotate({ + "title": "Citations", + "description": + "Citations supporting the text block.\n\nThe type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.", + "default": null }) ), - "content": Schema.Union([RequestBashCodeExecutionToolResultError, RequestBashCodeExecutionResultBlock]).annotate({ - "title": "Content" - }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("bash_code_execution_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestBashCodeExecutionToolResultBlock" }) -export type RequestCodeExecutionToolResultBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "content": - | RequestCodeExecutionToolResultError - | RequestCodeExecutionResultBlock - | RequestEncryptedCodeExecutionResultBlock - readonly "tool_use_id": string - readonly "type": "code_execution_tool_result" + "text": Schema.String.annotate({ "title": "Text" }).check( + Schema.isMinLength(0).annotate({ "expected": "a value with a length of at least 0" }) + ).check(Schema.isMaxLength(5000000).annotate({ "expected": "a value with a length of at most 5000000" })), + "type": Schema.Literal("text").annotate({ "title": "Type", "default": "text" }) +}).annotate({ "title": "ResponseTextBlock", "identifier": "BetaResponseTextBlock" }) +export type BetaResponseDocumentBlock = { + readonly "citations": BetaResponseCitationsConfig | null + readonly "source": BetaBase64PDFSource | BetaPlainTextSource + readonly "title": string | null + readonly "type": "document" } -export const RequestCodeExecutionToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "content": Schema.Union([ - RequestCodeExecutionToolResultError, - RequestCodeExecutionResultBlock, - RequestEncryptedCodeExecutionResultBlock - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) +export const BetaResponseDocumentBlock = Schema.Struct({ + "citations": Schema.Union([BetaResponseCitationsConfig, Schema.Null]).annotate({ + "description": "Citation configuration for the document", + "default": null + }), + "source": Schema.Union([BetaBase64PDFSource, BetaPlainTextSource], { mode: "oneOf" }).annotate({ "title": "Source" }), + "title": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Title", + "description": "The title of the document", + "default": null + }), + "type": Schema.Literal("document").annotate({ "title": "Type", "default": "document" }) +}).annotate({ "title": "ResponseDocumentBlock", "identifier": "BetaResponseDocumentBlock" }) +export type BetaResponseCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "code_execution_result" +} +export const BetaResponseCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(BetaResponseCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "type": Schema.Literal("code_execution_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestCodeExecutionToolResultBlock" }) -export type RequestSearchResultBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "citations"?: RequestCitationsConfig - readonly "content": ReadonlyArray - readonly "source": string - readonly "title": string - readonly "type": "search_result" + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "stdout": Schema.String.annotate({ "title": "Stdout" }), + "type": Schema.Literal("code_execution_result").annotate({ "title": "Type", "default": "code_execution_result" }) +}).annotate({ "title": "ResponseCodeExecutionResultBlock", "identifier": "BetaResponseCodeExecutionResultBlock" }) +export type BetaResponseEncryptedCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "encrypted_stdout": string + readonly "return_code": number + readonly "stderr": string + readonly "type": "encrypted_code_execution_result" } -export const RequestSearchResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) +export const BetaResponseEncryptedCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(BetaResponseCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "encrypted_stdout": Schema.String.annotate({ "title": "Encrypted Stdout" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "citations": Schema.optionalKey(RequestCitationsConfig), - "content": Schema.Array(RequestTextBlock).annotate({ "title": "Content" }), - "source": Schema.String.annotate({ "title": "Source" }), - "title": Schema.String.annotate({ "title": "Title" }), - "type": Schema.Literal("search_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestSearchResultBlock" }) -export type ResponseBashCodeExecutionToolResultBlock = { - readonly "content": ResponseBashCodeExecutionToolResultError | ResponseBashCodeExecutionResultBlock - readonly "tool_use_id": string - readonly "type": "bash_code_execution_tool_result" + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "type": Schema.Literal("encrypted_code_execution_result").annotate({ + "title": "Type", + "default": "encrypted_code_execution_result" + }) +}).annotate({ + "title": "ResponseEncryptedCodeExecutionResultBlock", + "description": "Code execution result with encrypted stdout for PFC + web_search results.", + "identifier": "BetaResponseEncryptedCodeExecutionResultBlock" +}) +export type BetaResponseBashCodeExecutionResultBlock = { + readonly "content": ReadonlyArray + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "bash_code_execution_result" } -export const ResponseBashCodeExecutionToolResultBlock = Schema.Struct({ - "content": Schema.Union([ResponseBashCodeExecutionToolResultError, ResponseBashCodeExecutionResultBlock]).annotate({ - "title": "Content" - }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) +export const BetaResponseBashCodeExecutionResultBlock = Schema.Struct({ + "content": Schema.Array(BetaResponseBashCodeExecutionOutputBlock).annotate({ "title": "Content" }), + "return_code": Schema.Number.annotate({ "title": "Return Code" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "type": Schema.Literal("bash_code_execution_tool_result").annotate({ + "stderr": Schema.String.annotate({ "title": "Stderr" }), + "stdout": Schema.String.annotate({ "title": "Stdout" }), + "type": Schema.Literal("bash_code_execution_result").annotate({ "title": "Type", - "default": "bash_code_execution_tool_result" + "default": "bash_code_execution_result" }) -}).annotate({ "title": "ResponseBashCodeExecutionToolResultBlock" }) -export type ResponseWebFetchResultBlock = { - readonly "content": ResponseDocumentBlock - readonly "retrieved_at": string | null - readonly "type": "web_fetch_result" - readonly "url": string +}).annotate({ + "title": "ResponseBashCodeExecutionResultBlock", + "identifier": "BetaResponseBashCodeExecutionResultBlock" +}) +export type BetaResponseToolSearchToolSearchResultBlock = { + readonly "tool_references": ReadonlyArray + readonly "type": "tool_search_tool_search_result" } -export const ResponseWebFetchResultBlock = Schema.Struct({ - "content": ResponseDocumentBlock, - "retrieved_at": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Retrieved At", - "description": "ISO 8601 timestamp when the content was retrieved", +export const BetaResponseToolSearchToolSearchResultBlock = Schema.Struct({ + "tool_references": Schema.Array(BetaResponseToolReferenceBlock).annotate({ "title": "Tool References" }), + "type": Schema.Literal("tool_search_tool_search_result").annotate({ + "title": "Type", + "default": "tool_search_tool_search_result" + }) +}).annotate({ + "title": "ResponseToolSearchToolSearchResultBlock", + "identifier": "BetaResponseToolSearchToolSearchResultBlock" +}) +export type BetaFallbackRefusalTrigger = { readonly "category": BetaRefusalCategory | null; readonly "type": "refusal" } +export const BetaFallbackRefusalTrigger = Schema.Struct({ + "category": Schema.Union([BetaRefusalCategory, Schema.Null]).annotate({ + "description": + "The policy category that triggered the `from` model's refusal at this hop. `null` when the refusal doesn't map to a named category. Same vocabulary as `stop_details.category`.", "default": null }), - "type": Schema.Literal("web_fetch_result").annotate({ "title": "Type", "default": "web_fetch_result" }), - "url": Schema.String.annotate({ "title": "Url", "description": "Fetched content URL" }) -}).annotate({ "title": "ResponseWebFetchResultBlock" }) -export type ResponseCodeExecutionToolResultBlock = { - readonly "content": - | ResponseCodeExecutionToolResultError - | ResponseCodeExecutionResultBlock - | ResponseEncryptedCodeExecutionResultBlock - readonly "tool_use_id": string - readonly "type": "code_execution_tool_result" + "type": Schema.Literal("refusal").annotate({ "title": "Type", "default": "refusal" }) +}).annotate({ + "title": "FallbackRefusalTrigger", + "description": "The `from` model declined for policy reasons.", + "identifier": "BetaFallbackRefusalTrigger" +}) +export type BetaRefusalStopDetails = { + readonly "category": BetaRefusalCategory | null + readonly "explanation": string | null + readonly "fallback_credit_token": string | null + readonly "fallback_has_prefill_claim": boolean | null + readonly "recommended_model": string | null + readonly "type": "refusal" +} +export const BetaRefusalStopDetails = Schema.Struct({ + "category": Schema.Union([BetaRefusalCategory, Schema.Null]).annotate({ + "description": + "The policy category that triggered the refusal.\n\n`null` when the refusal doesn't map to a named category.", + "default": null + }), + "explanation": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Explanation", + "description": + "Human-readable explanation of the refusal.\n\nThis text is not guaranteed to be stable. `null` when no explanation is available for the category.", + "default": null + }), + "fallback_credit_token": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Fallback Credit Token", + "description": + "Opaque code that refunds the cache-miss cost when retrying this refused\nrequest on the fallback model. Pass it as `fallback_credit_token` on the\nretry request. Expires 5 minutes after the refusal.\n\nThe retry is sent either with the same request body (`system`, `messages`,\n`tools`, and other render-shaping fields), or with the same body plus one\nappended `assistant` message whose content is the partial text (with any\ntrailing whitespace stripped from the final text block) and paired\nserver-tool blocks from this refusal — which also authorizes that\nappended turn as an assistant-prefill continuation on models that otherwise\ndisallow prefill. A token minted mid-server-tool-loop whose partial content\nwas continuable may only be redeemed the second way — if a same-body retry\nis rejected with a 400 saying the token must be redeemed by continuing the\npartial response, retry the second way instead. Either way: same workspace,\nsame platform; a mismatch is a 400. Resending a token for an already-warm\nprefix is permitted but yields no additional credit.\n\n`null` when the refused model isn't eligible for a fallback credit.", + "default": null + }), + "fallback_has_prefill_claim": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "title": "Fallback Has Prefill Claim", + "description": + "Whether the accompanying `fallback_credit_token` may be redeemed with the\nappended-assistant retry form. Only set when `fallback_credit_token` is\npresent.\n\n`true`: retry by resending the same request body plus one appended\n`assistant` message whose content is this response's `content` with any\ntrailing whitespace stripped from the final text block and unpaired\n`tool_use` blocks omitted (the same appended-turn shape described on\n`fallback_credit_token`), with the token attached. `false`: retry by\nresending the original request body unchanged, with the token attached —\nthe appended-assistant form is not available for this refusal (no\ncontinuable partial content, or the request uses `output_format` or a\n`tool_choice` that forces tool use). One exception: when the request used\n`output_format` or a forced `tool_choice` and the refusal arrived after\nserver tools (including MCP connector tools) had already executed, the\ntoken may not be redeemable by either retry form; if the exact-body retry\nis then rejected with a 400 saying the token must be redeemed by\ncontinuing the partial response, discard the token and retry without it.\n\nAdvisory: if an appended-assistant retry is rejected with a 400 despite\n`true`, fall back to resending the original request body with the token.", + "default": null + }), + "recommended_model": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Recommended Model", + "description": + "The server's suggested retry target for this refusal. Populated when a fallback attempt could not be made (the fallback model's rate limit was exhausted, or it was overloaded); names the fallback model the caller can retry directly. Null otherwise.", + "default": null + }), + "type": Schema.Literal("refusal").annotate({ "title": "Type", "default": "refusal" }) +}).annotate({ + "title": "RefusalStopDetails", + "description": "Structured information about a refusal.", + "identifier": "BetaRefusalStopDetails" +}) +export type BetaMessageIterationUsage = { + readonly "cache_creation": BetaCacheCreation | null + readonly "cache_creation_input_tokens": number + readonly "cache_read_input_tokens": number + readonly "input_tokens": number + readonly "model": Model + readonly "output_tokens": number + readonly "type": "message" } -export const ResponseCodeExecutionToolResultBlock = Schema.Struct({ - "content": Schema.Union([ - ResponseCodeExecutionToolResultError, - ResponseCodeExecutionResultBlock, - ResponseEncryptedCodeExecutionResultBlock - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) +export const BetaMessageIterationUsage = Schema.Struct({ + "cache_creation": Schema.Union([BetaCacheCreation, Schema.Null]).annotate({ + "description": "Breakdown of cached tokens by TTL", + "default": null + }), + "cache_creation_input_tokens": Schema.Number.annotate({ + "title": "Cache Creation Input Tokens", + "description": "The number of input tokens used to create the cache entry.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "type": Schema.Literal("code_execution_tool_result").annotate({ - "title": "Type", - "default": "code_execution_tool_result" - }) -}).annotate({ "title": "ResponseCodeExecutionToolResultBlock" }) -export type ContentBlockDeltaEvent = { - readonly "delta": - | TextContentBlockDelta - | InputJsonContentBlockDelta - | CitationsDelta - | ThinkingContentBlockDelta - | SignatureContentBlockDelta - readonly "index": number - readonly "type": "content_block_delta" -} -export const ContentBlockDeltaEvent = Schema.Struct({ - "delta": Schema.Union([ - TextContentBlockDelta, - InputJsonContentBlockDelta, - CitationsDelta, - ThinkingContentBlockDelta, - SignatureContentBlockDelta - ], { mode: "oneOf" }).annotate({ "title": "Delta" }), - "index": Schema.Number.annotate({ "title": "Index" }).check(Schema.isInt()), - "type": Schema.Literal("content_block_delta").annotate({ "title": "Type", "default": "content_block_delta" }) -}).annotate({ "title": "ContentBlockDeltaEvent" }) -export type RequestTextEditorCodeExecutionToolResultBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "content": - | RequestTextEditorCodeExecutionToolResultError - | RequestTextEditorCodeExecutionViewResultBlock - | RequestTextEditorCodeExecutionCreateResultBlock - | RequestTextEditorCodeExecutionStrReplaceResultBlock - readonly "tool_use_id": string - readonly "type": "text_editor_code_execution_tool_result" -} -export const RequestTextEditorCodeExecutionToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) + "cache_read_input_tokens": Schema.Number.annotate({ + "title": "Cache Read Input Tokens", + "description": "The number of input tokens read from the cache.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "content": Schema.Union([ - RequestTextEditorCodeExecutionToolResultError, - RequestTextEditorCodeExecutionViewResultBlock, - RequestTextEditorCodeExecutionCreateResultBlock, - RequestTextEditorCodeExecutionStrReplaceResultBlock - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "input_tokens": Schema.Number.annotate({ + "title": "Input Tokens", + "description": "The number of input tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "type": Schema.Literal("text_editor_code_execution_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestTextEditorCodeExecutionToolResultBlock" }) -export type ResponseTextEditorCodeExecutionToolResultBlock = { - readonly "content": - | ResponseTextEditorCodeExecutionToolResultError - | ResponseTextEditorCodeExecutionViewResultBlock - | ResponseTextEditorCodeExecutionCreateResultBlock - | ResponseTextEditorCodeExecutionStrReplaceResultBlock - readonly "tool_use_id": string - readonly "type": "text_editor_code_execution_tool_result" -} -export const ResponseTextEditorCodeExecutionToolResultBlock = Schema.Struct({ - "content": Schema.Union([ - ResponseTextEditorCodeExecutionToolResultError, - ResponseTextEditorCodeExecutionViewResultBlock, - ResponseTextEditorCodeExecutionCreateResultBlock, - ResponseTextEditorCodeExecutionStrReplaceResultBlock - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "model": Model, + "output_tokens": Schema.Number.annotate({ + "title": "Output Tokens", + "description": "The number of output tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "type": Schema.Literal("text_editor_code_execution_tool_result").annotate({ + "type": Schema.Literal("message").annotate({ "title": "Type", - "default": "text_editor_code_execution_tool_result" + "description": "Usage for a sampling iteration", + "default": "message" }) -}).annotate({ "title": "ResponseTextEditorCodeExecutionToolResultBlock" }) -export type ResponseToolSearchToolResultBlock = { - readonly "content": ResponseToolSearchToolResultError | ResponseToolSearchToolSearchResultBlock - readonly "tool_use_id": string - readonly "type": "tool_search_tool_result" -} -export const ResponseToolSearchToolResultBlock = Schema.Struct({ - "content": Schema.Union([ResponseToolSearchToolResultError, ResponseToolSearchToolSearchResultBlock]).annotate({ - "title": "Content" +}).annotate({ + "title": "MessageIterationUsage", + "description": "Token usage for a sampling iteration.", + "identifier": "BetaMessageIterationUsage" +}) +export type BetaCompactionIterationUsage = { + readonly "cache_creation": BetaCacheCreation | null + readonly "cache_creation_input_tokens": number + readonly "cache_read_input_tokens": number + readonly "input_tokens": number + readonly "output_tokens": number + readonly "type": "compaction" +} +export const BetaCompactionIterationUsage = Schema.Struct({ + "cache_creation": Schema.Union([BetaCacheCreation, Schema.Null]).annotate({ + "description": "Breakdown of cached tokens by TTL", + "default": null }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "cache_creation_input_tokens": Schema.Number.annotate({ + "title": "Cache Creation Input Tokens", + "description": "The number of input tokens used to create the cache entry.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "type": Schema.Literal("tool_search_tool_result").annotate({ "title": "Type", "default": "tool_search_tool_result" }) -}).annotate({ "title": "ResponseToolSearchToolResultBlock" }) -export type ContentBlockSource = { - readonly "content": string | ReadonlyArray - readonly "type": "content" -} -export const ContentBlockSource = Schema.Struct({ - "content": Schema.Union([ - Schema.String, - Schema.Array( - Schema.Union([RequestTextBlock, RequestImageBlock], { mode: "oneOf" }).annotate({ - "title": "content_block_source_content_item" - }) - ).annotate({ "title": "content_block_source_content" }) - ]).annotate({ "title": "Content" }), - "type": Schema.Literal("content").annotate({ "title": "Type" }) -}).annotate({ "title": "ContentBlockSource" }) -export type RequestWebSearchToolResultBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "caller"?: DirectCaller | ServerToolCaller | ServerToolCaller_20260120 - readonly "content": ReadonlyArray | RequestWebSearchToolResultError - readonly "tool_use_id": string - readonly "type": "web_search_tool_result" -} -export const RequestWebSearchToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) + "cache_read_input_tokens": Schema.Number.annotate({ + "title": "Cache Read Input Tokens", + "description": "The number of input tokens read from the cache.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "caller": Schema.optionalKey( - Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" - }) + "input_tokens": Schema.Number.annotate({ + "title": "Input Tokens", + "description": "The number of input tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "content": Schema.Union([ - Schema.Array(RequestWebSearchResultBlock).annotate({ "title": "web_search_tool_result_block_item" }), - RequestWebSearchToolResultError - ]).annotate({ "title": "Content" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "output_tokens": Schema.Number.annotate({ + "title": "Output Tokens", + "description": "The number of output tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "type": Schema.Literal("web_search_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestWebSearchToolResultBlock" }) -export type ResponseWebSearchToolResultBlock = { - readonly "caller": DirectCaller | ServerToolCaller | ServerToolCaller_20260120 - readonly "content": ResponseWebSearchToolResultError | ReadonlyArray - readonly "tool_use_id": string - readonly "type": "web_search_tool_result" + "type": Schema.Literal("compaction").annotate({ + "title": "Type", + "description": "Usage for a compaction iteration", + "default": "compaction" + }) +}).annotate({ + "title": "CompactionIterationUsage", + "description": "Token usage for a compaction iteration.", + "identifier": "BetaCompactionIterationUsage" +}) +export type BetaAdvisorMessageIterationUsage = { + readonly "cache_creation": BetaCacheCreation | null + readonly "cache_creation_input_tokens": number + readonly "cache_read_input_tokens": number + readonly "input_tokens": number + readonly "model": Model + readonly "output_tokens": number + readonly "type": "advisor_message" } -export const ResponseWebSearchToolResultBlock = Schema.Struct({ - "caller": Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller", - "default": { "type": "direct" } - }), - "content": Schema.Union([ResponseWebSearchToolResultError, Schema.Array(ResponseWebSearchResultBlock)]).annotate({ - "title": "Content" +export const BetaAdvisorMessageIterationUsage = Schema.Struct({ + "cache_creation": Schema.Union([BetaCacheCreation, Schema.Null]).annotate({ + "description": "Breakdown of cached tokens by TTL", + "default": null }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "cache_creation_input_tokens": Schema.Number.annotate({ + "title": "Cache Creation Input Tokens", + "description": "The number of input tokens used to create the cache entry.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "type": Schema.Literal("web_search_tool_result").annotate({ "title": "Type", "default": "web_search_tool_result" }) -}).annotate({ "title": "ResponseWebSearchToolResultBlock" }) -export type MessageDeltaEvent = { - readonly "delta": MessageDelta - readonly "type": "message_delta" - readonly "usage": { - readonly "cache_creation_input_tokens": number | null - readonly "cache_read_input_tokens": number | null - readonly "input_tokens": number | null - readonly "output_tokens": number - readonly "server_tool_use"?: ServerToolUsage | null - } -} -export const MessageDeltaEvent = Schema.Struct({ - "delta": MessageDelta, - "type": Schema.Literal("message_delta").annotate({ "title": "Type", "default": "message_delta" }), - "usage": Schema.Struct({ - "cache_creation_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Cache Creation Input Tokens", - "description": "The cumulative number of input tokens used to create the cache entry.", - "default": null - }), - "cache_read_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Cache Read Input Tokens", - "description": "The cumulative number of input tokens read from the cache.", - "default": null - }), - "input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Input Tokens", - "description": "The cumulative number of input tokens which were used.", - "default": null - }), - "output_tokens": Schema.Number.annotate({ - "title": "Output Tokens", - "description": "The cumulative number of output tokens which were used." - }).check(Schema.isInt()), - "server_tool_use": Schema.optionalKey( - Schema.Union([ServerToolUsage, Schema.Null]).annotate({ - "description": "The number of server tool requests.", - "default": null - }) - ) - }).annotate({ - "title": "MessageDeltaUsage", - "description": - "Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response from Claude.\n\nTotal input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`." + "cache_read_input_tokens": Schema.Number.annotate({ + "title": "Cache Read Input Tokens", + "description": "The number of input tokens read from the cache.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "input_tokens": Schema.Number.annotate({ + "title": "Input Tokens", + "description": "The number of input tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "model": Model, + "output_tokens": Schema.Number.annotate({ + "title": "Output Tokens", + "description": "The number of output tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "type": Schema.Literal("advisor_message").annotate({ + "title": "Type", + "description": "Usage for an advisor sub-inference iteration", + "default": "advisor_message" }) -}).annotate({ "title": "MessageDeltaEvent" }) -export type BetaRequestToolSearchToolResultBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "content": BetaRequestToolSearchToolResultError | BetaRequestToolSearchToolSearchResultBlock - readonly "tool_use_id": string - readonly "type": "tool_search_tool_result" +}).annotate({ + "title": "AdvisorMessageIterationUsage", + "description": "Token usage for an advisor sub-inference iteration.", + "identifier": "BetaAdvisorMessageIterationUsage" +}) +export type BetaFallbackMessageIterationUsage = { + readonly "cache_creation": BetaCacheCreation | null + readonly "cache_creation_input_tokens": number + readonly "cache_read_input_tokens": number + readonly "input_tokens": number + readonly "model": Model + readonly "output_tokens": number + readonly "type": "fallback_message" } -export const BetaRequestToolSearchToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "content": Schema.Union([BetaRequestToolSearchToolResultError, BetaRequestToolSearchToolSearchResultBlock]).annotate({ - "title": "Content" +export const BetaFallbackMessageIterationUsage = Schema.Struct({ + "cache_creation": Schema.Union([BetaCacheCreation, Schema.Null]).annotate({ + "description": "Breakdown of cached tokens by TTL", + "default": null }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "cache_creation_input_tokens": Schema.Number.annotate({ + "title": "Cache Creation Input Tokens", + "description": "The number of input tokens used to create the cache entry.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "type": Schema.Literal("tool_search_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestToolSearchToolResultBlock" }) -export type BetaResponseWebFetchToolResultBlock = { - readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 - readonly "content": BetaResponseWebFetchToolResultError | BetaResponseWebFetchResultBlock - readonly "tool_use_id": string - readonly "type": "web_fetch_tool_result" -} -export const BetaResponseWebFetchToolResultBlock = Schema.Struct({ - "caller": Schema.optionalKey( - Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" - }) + "cache_read_input_tokens": Schema.Number.annotate({ + "title": "Cache Read Input Tokens", + "description": "The number of input tokens read from the cache.", + "default": 0 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "content": Schema.Union([BetaResponseWebFetchToolResultError, BetaResponseWebFetchResultBlock]).annotate({ - "title": "Content" - }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) + "input_tokens": Schema.Number.annotate({ + "title": "Input Tokens", + "description": "The number of input tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "type": Schema.Literal("web_fetch_tool_result").annotate({ "title": "Type", "default": "web_fetch_tool_result" }) -}).annotate({ "title": "ResponseWebFetchToolResultBlock" }) -export type BetaMessageDeltaEvent = { - readonly "context_management"?: BetaResponseContextManagement | null - readonly "delta": BetaMessageDelta - readonly "type": "message_delta" - readonly "usage": { - readonly "cache_creation_input_tokens": number | null - readonly "cache_read_input_tokens": number | null - readonly "input_tokens": number | null - readonly "iterations"?: BetaIterationsUsage - readonly "output_tokens": number - readonly "server_tool_use"?: BetaServerToolUsage | null - } -} -export const BetaMessageDeltaEvent = Schema.Struct({ - "context_management": Schema.optionalKey( - Schema.Union([BetaResponseContextManagement, Schema.Null]).annotate({ - "description": "Information about context management strategies applied during the request", - "default": null - }) + "model": Model, + "output_tokens": Schema.Number.annotate({ + "title": "Output Tokens", + "description": "The number of output tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "delta": BetaMessageDelta, - "type": Schema.Literal("message_delta").annotate({ "title": "Type", "default": "message_delta" }), - "usage": Schema.Struct({ - "cache_creation_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Cache Creation Input Tokens", - "description": "The cumulative number of input tokens used to create the cache entry.", - "default": null - }), - "cache_read_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Cache Read Input Tokens", - "description": "The cumulative number of input tokens read from the cache.", - "default": null - }), - "input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Input Tokens", - "description": "The cumulative number of input tokens which were used.", - "default": null - }), - "iterations": Schema.optionalKey(BetaIterationsUsage), - "output_tokens": Schema.Number.annotate({ - "title": "Output Tokens", - "description": "The cumulative number of output tokens which were used." - }).check(Schema.isInt()), - "server_tool_use": Schema.optionalKey( - Schema.Union([BetaServerToolUsage, Schema.Null]).annotate({ - "description": "The number of server tool requests.", - "default": null - }) - ) - }).annotate({ - "title": "MessageDeltaUsage", + "type": Schema.Literal("fallback_message").annotate({ + "title": "Type", + "description": "Usage for the fallback-model attempt that served the response", + "default": "fallback_message" + }) +}).annotate({ + "title": "FallbackMessageIterationUsage", + "description": + "Token usage for the fallback-model attempt of a server-side fallback request.\n\nProduced in place of a `message` entry for whichever hop served the\nresponse. A declined hop produces the existing `message` entry. Whether\na fallback model served the response is signalled by the presence of this\nentry in `usage.iterations`.", + "identifier": "BetaFallbackMessageIterationUsage" +}) +export type BetaFallbackCreditUsage = { readonly "status": BetaFallbackCreditRedeemed | BetaFallbackCreditNotApplied } +export const BetaFallbackCreditUsage = Schema.Struct({ + "status": Schema.Union([BetaFallbackCreditRedeemed, BetaFallbackCreditNotApplied], { mode: "oneOf" }).annotate({ + "title": "Status", "description": - "Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response from Claude.\n\nTotal input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`." + "Whether the fallback-credit reprice was applied to this response's billing.\n\nA union discriminated on `type`. `redeemed`: the retry is billed as if\nthe conversation had been on the retry model all along — including when the\nresulting shift is zero because there was nothing to move. `not_applied`:\nno reprice was applied; the arm's `reason` says why." }) -}).annotate({ "title": "MessageDeltaEvent" }) -export type BetaRequestDocumentBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "citations"?: BetaRequestCitationsConfig | null - readonly "context"?: string | null - readonly "source": - | BetaBase64PDFSource - | BetaPlainTextSource - | BetaContentBlockSource - | BetaURLPDFSource - | BetaFileDocumentSource - readonly "title"?: string | null - readonly "type": "document" +}).annotate({ + "title": "FallbackCreditUsage", + "description": "Outcome of the ``fallback_credit_token`` presented on this request.", + "identifier": "BetaFallbackCreditUsage" +}) +export type BetaDiagnostics = { + readonly "cache_miss_reason": + | BetaCacheMissModelChanged + | BetaCacheMissSystemChanged + | BetaCacheMissToolsChanged + | BetaCacheMissMessagesChanged + | BetaCacheMissPreviousMessageNotFound + | BetaCacheMissUnavailable + | null } -export const BetaRequestDocumentBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "citations": Schema.optionalKey(Schema.Union([BetaRequestCitationsConfig, Schema.Null])), - "context": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)), Schema.Null]).annotate({ "title": "Context" }) - ), - "source": Schema.Union([ - BetaBase64PDFSource, - BetaPlainTextSource, - BetaContentBlockSource, - BetaURLPDFSource, - BetaFileDocumentSource - ], { mode: "oneOf" }).annotate({ "title": "Source" }), - "title": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(500)), Schema.Null]).annotate({ - "title": "Title" - }) - ), - "type": Schema.Literal("document").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestDocumentBlock" }) -export type RequestToolSearchToolResultBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "content": RequestToolSearchToolResultError | RequestToolSearchToolSearchResultBlock - readonly "tool_use_id": string - readonly "type": "tool_search_tool_result" +export const BetaDiagnostics = Schema.Struct({ + "cache_miss_reason": Schema.Union([ + Schema.Union([ + BetaCacheMissModelChanged, + BetaCacheMissSystemChanged, + BetaCacheMissToolsChanged, + BetaCacheMissMessagesChanged, + BetaCacheMissPreviousMessageNotFound, + BetaCacheMissUnavailable + ], { mode: "oneOf" }), + Schema.Null + ]).annotate({ + "title": "Cache Miss Reason", + "description": + "Explains why the prompt cache could not fully reuse the prefix from the request identified by `diagnostics.previous_message_id`. `null` means diagnosis is still pending — the response was serialized before the background comparison completed.", + "default": null + }) +}).annotate({ + "title": "Diagnostics", + "description": + "Response envelope for request-level diagnostics. Present (possibly\nnull) whenever the caller supplied `diagnostics` on the request.", + "identifier": "BetaDiagnostics" +}) +export type BetaResponseContextManagement = { + readonly "applied_edits": ReadonlyArray } -export const RequestToolSearchToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "content": Schema.Union([RequestToolSearchToolResultError, RequestToolSearchToolSearchResultBlock]).annotate({ - "title": "Content" +export const BetaResponseContextManagement = Schema.Struct({ + "applied_edits": Schema.Array( + Schema.Union([BetaResponseClearToolUses20250919Edit, BetaResponseClearThinking20251015Edit], { mode: "oneOf" }) + ).annotate({ "title": "Applied Edits", "description": "List of context management edits that were applied." }) +}).annotate({ "title": "ResponseContextManagement", "identifier": "BetaResponseContextManagement" }) +export type BetaContainer = { + readonly "expires_at": string + readonly "id": string + readonly "skills": ReadonlyArray | null +} +export const BetaContainer = Schema.Struct({ + "expires_at": Schema.String.annotate({ + "title": "Expires At", + "description": "The time at which the container will expire.", + "format": "date-time" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("tool_search_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestToolSearchToolResultBlock" }) -export type ResponseWebFetchToolResultBlock = { - readonly "caller": DirectCaller | ServerToolCaller | ServerToolCaller_20260120 - readonly "content": ResponseWebFetchToolResultError | ResponseWebFetchResultBlock - readonly "tool_use_id": string - readonly "type": "web_fetch_tool_result" + "id": Schema.String.annotate({ "title": "Id", "description": "Identifier for the container used in this request" }), + "skills": Schema.Union([Schema.Array(BetaSkill), Schema.Null]).annotate({ + "title": "Skills", + "description": "Skills loaded in the container", + "default": null + }) +}).annotate({ + "title": "Container", + "description": "Information about the container used in the request (for the code execution tool)", + "identifier": "BetaContainer" +}) +export type BetaErrorResponse = { + readonly "error": + | BetaInvalidRequestError + | BetaAuthenticationError + | BetaBillingError + | BetaPermissionError + | BetaNotFoundError + | BetaRateLimitError + | BetaGatewayTimeoutError + | BetaAPIError + | BetaOverloadedError + readonly "request_id": string | null + readonly "type": "error" } -export const ResponseWebFetchToolResultBlock = Schema.Struct({ - "caller": Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller", - "default": { "type": "direct" } +export const BetaErrorResponse = Schema.Struct({ + "error": Schema.Union([ + BetaInvalidRequestError, + BetaAuthenticationError, + BetaBillingError, + BetaPermissionError, + BetaNotFoundError, + BetaRateLimitError, + BetaGatewayTimeoutError, + BetaAPIError, + BetaOverloadedError + ], { mode: "oneOf" }).annotate({ "title": "Error" }), + "request_id": Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Request Id", "default": null }), + "type": Schema.Literal("error").annotate({ "title": "Type", "default": "error" }) +}).annotate({ "title": "ErrorResponse", "identifier": "BetaErrorResponse" }) +export type BetaContextManagementCapability = { + readonly "clear_thinking_20251015": BetaCapabilitySupport | null + readonly "clear_tool_uses_20250919": BetaCapabilitySupport | null + readonly "compact_20260112": BetaCapabilitySupport | null + readonly "supported": boolean +} +export const BetaContextManagementCapability = Schema.Struct({ + "clear_thinking_20251015": Schema.Union([BetaCapabilitySupport, Schema.Null]).annotate({ + "description": "Whether the clear_thinking_20251015 strategy is supported." }), - "content": Schema.Union([ResponseWebFetchToolResultError, ResponseWebFetchResultBlock]).annotate({ - "title": "Content" + "clear_tool_uses_20250919": Schema.Union([BetaCapabilitySupport, Schema.Null]).annotate({ + "description": "Whether the clear_tool_uses_20250919 strategy is supported." }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("web_fetch_tool_result").annotate({ "title": "Type", "default": "web_fetch_tool_result" }) -}).annotate({ "title": "ResponseWebFetchToolResultBlock" }) -export type RequestDocumentBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "citations"?: RequestCitationsConfig | null - readonly "context"?: string | null - readonly "source": Base64PDFSource | PlainTextSource | ContentBlockSource | URLPDFSource - readonly "title"?: string | null - readonly "type": "document" -} -export const RequestDocumentBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "citations": Schema.optionalKey(Schema.Union([RequestCitationsConfig, Schema.Null])), - "context": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)), Schema.Null]).annotate({ "title": "Context" }) - ), - "source": Schema.Union([Base64PDFSource, PlainTextSource, ContentBlockSource, URLPDFSource], { mode: "oneOf" }) - .annotate({ "title": "Source" }), - "title": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(500)), Schema.Null]).annotate({ - "title": "Title" - }) - ), - "type": Schema.Literal("document").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestDocumentBlock" }) -export type BetaContentBlockStartEvent = { - readonly "content_block": - | BetaResponseTextBlock - | BetaResponseThinkingBlock - | BetaResponseRedactedThinkingBlock - | BetaResponseToolUseBlock - | BetaResponseServerToolUseBlock - | BetaResponseWebSearchToolResultBlock - | BetaResponseWebFetchToolResultBlock - | BetaResponseCodeExecutionToolResultBlock - | BetaResponseBashCodeExecutionToolResultBlock - | BetaResponseTextEditorCodeExecutionToolResultBlock - | BetaResponseToolSearchToolResultBlock - | BetaResponseMCPToolUseBlock - | BetaResponseMCPToolResultBlock - | BetaResponseContainerUploadBlock - | BetaResponseCompactionBlock - readonly "index": number - readonly "type": "content_block_start" -} -export const BetaContentBlockStartEvent = Schema.Struct({ - "content_block": Schema.Union([ - BetaResponseTextBlock, - BetaResponseThinkingBlock, - BetaResponseRedactedThinkingBlock, - BetaResponseToolUseBlock, - BetaResponseServerToolUseBlock, - BetaResponseWebSearchToolResultBlock, - BetaResponseWebFetchToolResultBlock, - BetaResponseCodeExecutionToolResultBlock, - BetaResponseBashCodeExecutionToolResultBlock, - BetaResponseTextEditorCodeExecutionToolResultBlock, - BetaResponseToolSearchToolResultBlock, - BetaResponseMCPToolUseBlock, - BetaResponseMCPToolResultBlock, - BetaResponseContainerUploadBlock, - BetaResponseCompactionBlock - ], { mode: "oneOf" }).annotate({ "title": "Content Block" }), - "index": Schema.Number.annotate({ "title": "Index" }).check(Schema.isInt()), - "type": Schema.Literal("content_block_start").annotate({ "title": "Type", "default": "content_block_start" }) -}).annotate({ "title": "ContentBlockStartEvent" }) -export type BetaContentBlock = - | BetaResponseTextBlock - | BetaResponseThinkingBlock - | BetaResponseRedactedThinkingBlock - | BetaResponseToolUseBlock - | BetaResponseServerToolUseBlock - | BetaResponseWebSearchToolResultBlock - | BetaResponseWebFetchToolResultBlock - | BetaResponseCodeExecutionToolResultBlock - | BetaResponseBashCodeExecutionToolResultBlock - | BetaResponseTextEditorCodeExecutionToolResultBlock - | BetaResponseToolSearchToolResultBlock - | BetaResponseMCPToolUseBlock - | BetaResponseMCPToolResultBlock - | BetaResponseContainerUploadBlock - | BetaResponseCompactionBlock -export const BetaContentBlock = Schema.Union([ - BetaResponseTextBlock, - BetaResponseThinkingBlock, - BetaResponseRedactedThinkingBlock, - BetaResponseToolUseBlock, - BetaResponseServerToolUseBlock, - BetaResponseWebSearchToolResultBlock, - BetaResponseWebFetchToolResultBlock, - BetaResponseCodeExecutionToolResultBlock, - BetaResponseBashCodeExecutionToolResultBlock, - BetaResponseTextEditorCodeExecutionToolResultBlock, - BetaResponseToolSearchToolResultBlock, - BetaResponseMCPToolUseBlock, - BetaResponseMCPToolResultBlock, - BetaResponseContainerUploadBlock, - BetaResponseCompactionBlock -], { mode: "oneOf" }) -export type BetaRequestWebFetchResultBlock = { - readonly "content": BetaRequestDocumentBlock - readonly "retrieved_at"?: string | null - readonly "type": "web_fetch_result" - readonly "url": string -} -export const BetaRequestWebFetchResultBlock = Schema.Struct({ - "content": BetaRequestDocumentBlock, - "retrieved_at": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Retrieved At", - "description": "ISO 8601 timestamp when the content was retrieved" - }) - ), - "type": Schema.Literal("web_fetch_result").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url", "description": "Fetched content URL" }) -}).annotate({ "title": "RequestWebFetchResultBlock" }) -export type ContentBlockStartEvent = { - readonly "content_block": - | ResponseTextBlock - | ResponseThinkingBlock - | ResponseRedactedThinkingBlock - | ResponseToolUseBlock - | ResponseServerToolUseBlock - | ResponseWebSearchToolResultBlock - | ResponseWebFetchToolResultBlock - | ResponseCodeExecutionToolResultBlock - | ResponseBashCodeExecutionToolResultBlock - | ResponseTextEditorCodeExecutionToolResultBlock - | ResponseToolSearchToolResultBlock - | ResponseContainerUploadBlock - readonly "index": number - readonly "type": "content_block_start" -} -export const ContentBlockStartEvent = Schema.Struct({ - "content_block": Schema.Union([ - ResponseTextBlock, - ResponseThinkingBlock, - ResponseRedactedThinkingBlock, - ResponseToolUseBlock, - ResponseServerToolUseBlock, - ResponseWebSearchToolResultBlock, - ResponseWebFetchToolResultBlock, - ResponseCodeExecutionToolResultBlock, - ResponseBashCodeExecutionToolResultBlock, - ResponseTextEditorCodeExecutionToolResultBlock, - ResponseToolSearchToolResultBlock, - ResponseContainerUploadBlock - ], { mode: "oneOf" }).annotate({ "title": "Content Block" }), - "index": Schema.Number.annotate({ "title": "Index" }).check(Schema.isInt()), - "type": Schema.Literal("content_block_start").annotate({ "title": "Type", "default": "content_block_start" }) -}).annotate({ "title": "ContentBlockStartEvent" }) -export type ContentBlock = - | ResponseTextBlock - | ResponseThinkingBlock - | ResponseRedactedThinkingBlock - | ResponseToolUseBlock - | ResponseServerToolUseBlock - | ResponseWebSearchToolResultBlock - | ResponseWebFetchToolResultBlock - | ResponseCodeExecutionToolResultBlock - | ResponseBashCodeExecutionToolResultBlock - | ResponseTextEditorCodeExecutionToolResultBlock - | ResponseToolSearchToolResultBlock - | ResponseContainerUploadBlock -export const ContentBlock = Schema.Union([ - ResponseTextBlock, - ResponseThinkingBlock, - ResponseRedactedThinkingBlock, - ResponseToolUseBlock, - ResponseServerToolUseBlock, - ResponseWebSearchToolResultBlock, - ResponseWebFetchToolResultBlock, - ResponseCodeExecutionToolResultBlock, - ResponseBashCodeExecutionToolResultBlock, - ResponseTextEditorCodeExecutionToolResultBlock, - ResponseToolSearchToolResultBlock, - ResponseContainerUploadBlock -], { mode: "oneOf" }) -export type RequestWebFetchResultBlock = { - readonly "content": RequestDocumentBlock - readonly "retrieved_at"?: string | null - readonly "type": "web_fetch_result" - readonly "url": string -} -export const RequestWebFetchResultBlock = Schema.Struct({ - "content": RequestDocumentBlock, - "retrieved_at": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Retrieved At", - "description": "ISO 8601 timestamp when the content was retrieved" - }) - ), - "type": Schema.Literal("web_fetch_result").annotate({ "title": "Type" }), - "url": Schema.String.annotate({ "title": "Url", "description": "Fetched content URL" }) -}).annotate({ "title": "RequestWebFetchResultBlock" }) -export type BetaMessage = { - readonly "id": string - readonly "type": "message" - readonly "role": "assistant" - readonly "content": ReadonlyArray - readonly "model": Model - readonly "stop_reason": BetaStopReason | null - readonly "stop_sequence": string | null - readonly "usage": { - readonly "cache_creation": BetaCacheCreation | null - readonly "cache_creation_input_tokens": number | null - readonly "cache_read_input_tokens": number | null - readonly "inference_geo": string | null - readonly "input_tokens": number - readonly "iterations"?: BetaIterationsUsage - readonly "output_tokens": number - readonly "server_tool_use"?: BetaServerToolUsage | null - readonly "service_tier": "standard" | "priority" | "batch" | null - readonly "speed"?: BetaSpeed | null - } - readonly "context_management"?: BetaResponseContextManagement | null - readonly "container"?: BetaContainer | null -} -export const BetaMessage = Schema.Struct({ - "id": Schema.String.annotate({ - "title": "Id", - "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." + "compact_20260112": Schema.Union([BetaCapabilitySupport, Schema.Null]).annotate({ + "description": "Whether the compact_20260112 strategy is supported." }), - "type": Schema.Literal("message").annotate({ - "title": "Type", - "description": "Object type.\n\nFor Messages, this is always `\"message\"`.", - "default": "message" + "supported": Schema.Boolean.annotate({ + "title": "Supported", + "description": "Whether this capability is supported by the model." + }) +}).annotate({ + "title": "ContextManagementCapability", + "description": "Context management capability details.", + "identifier": "BetaContextManagementCapability" +}) +export type BetaEffortCapability = { + readonly "high": BetaCapabilitySupport + readonly "low": BetaCapabilitySupport + readonly "max": BetaCapabilitySupport + readonly "medium": BetaCapabilitySupport + readonly "supported": boolean + readonly "xhigh": BetaCapabilitySupport | null +} +export const BetaEffortCapability = Schema.Struct({ + "high": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports high effort level." }), - "role": Schema.Literal("assistant").annotate({ - "title": "Role", - "description": "Conversational role of the generated message.\n\nThis will always be `\"assistant\"`.", - "default": "assistant" + "low": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports low effort level." }), - "content": Schema.Array(BetaContentBlock).annotate({ - "title": "Content", - "description": - "Content generated by the model.\n\nThis is an array of content blocks, each of which has a `type` that determines its shape.\n\nExample:\n\n```json\n[{\"type\": \"text\", \"text\": \"Hi, I'm Claude.\"}]\n```\n\nIf the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output.\n\nFor example, if the input `messages` were:\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"}\n]\n```\n\nThen the response `content` might be:\n\n```json\n[{\"type\": \"text\", \"text\": \"B)\"}]\n```" + "max": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports max effort level." }), - "model": Model, - "stop_reason": Schema.Union([BetaStopReason, Schema.Null]).annotate({ - "title": "Stop Reason", - "description": - "The reason that we stopped.\n\nThis may be one the following values:\n* `\"end_turn\"`: the model reached a natural stopping point\n* `\"max_tokens\"`: we exceeded the requested `max_tokens` or the model's maximum\n* `\"stop_sequence\"`: one of your provided custom `stop_sequences` was generated\n* `\"tool_use\"`: the model invoked one or more tools\n* `\"pause_turn\"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.\n* `\"refusal\"`: when streaming classifiers intervene to handle potential policy violations\n\nIn non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise." + "medium": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports medium effort level." }), - "stop_sequence": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Stop Sequence", - "description": - "Which custom stop sequence was generated, if any.\n\nThis value will be a non-null string if one of your custom stop sequences was generated.", - "default": null + "supported": Schema.Boolean.annotate({ + "title": "Supported", + "description": "Whether this capability is supported by the model." }), - "usage": Schema.Struct({ - "cache_creation": Schema.Union([BetaCacheCreation, Schema.Null]).annotate({ - "description": "Breakdown of cached tokens by TTL", - "default": null - }), - "cache_creation_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Cache Creation Input Tokens", - "description": "The number of input tokens used to create the cache entry.", - "default": null - }), - "cache_read_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Cache Read Input Tokens", - "description": "The number of input tokens read from the cache.", - "default": null - }), - "inference_geo": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Inference Geo", - "description": "The geographic region where inference was performed for this request.", - "default": null - }), - "input_tokens": Schema.Number.annotate({ - "title": "Input Tokens", - "description": "The number of input tokens which were used." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "iterations": Schema.optionalKey(BetaIterationsUsage), - "output_tokens": Schema.Number.annotate({ - "title": "Output Tokens", - "description": "The number of output tokens which were used." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "server_tool_use": Schema.optionalKey( - Schema.Union([BetaServerToolUsage, Schema.Null]).annotate({ - "description": "The number of server tool requests.", - "default": null - }) - ), - "service_tier": Schema.Union([Schema.Literals(["standard", "priority", "batch"]), Schema.Null]).annotate({ - "title": "Service Tier", - "description": "If the request used the priority, standard, or batch tier.", - "default": null - }), - "speed": Schema.optionalKey( - Schema.Union([BetaSpeed, Schema.Null]).annotate({ - "description": "The inference speed mode used for this request.", - "default": null - }) - ) - }).annotate({ - "title": "Usage", - "description": - "Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response from Claude.\n\nTotal input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`." - }), - "context_management": Schema.optionalKey( - Schema.Union([BetaResponseContextManagement, Schema.Null]).annotate({ - "description": - "Context management response.\n\nInformation about context management strategies applied during the request.", - "default": null - }) - ), - "container": Schema.optionalKey( - Schema.Union([BetaContainer, Schema.Null]).annotate({ - "description": - "Information about the container used in this request.\n\nThis will be non-null if a container tool (e.g. code execution) was used.", - "default": null - }) - ) -}).annotate({ "title": "Message" }) -export type BetaRequestWebFetchToolResultBlock = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 - readonly "content": BetaRequestWebFetchToolResultError | BetaRequestWebFetchResultBlock - readonly "tool_use_id": string - readonly "type": "web_fetch_tool_result" + "xhigh": Schema.Union([BetaCapabilitySupport, Schema.Null]).annotate({ + "description": "Whether the model supports xhigh effort level." + }) +}).annotate({ + "title": "EffortCapability", + "description": "Effort (reasoning_effort) capability details.", + "identifier": "BetaEffortCapability" +}) +export type BetaThinkingTypes = { + readonly "adaptive": BetaCapabilitySupport + readonly "enabled": BetaCapabilitySupport } -export const BetaRequestWebFetchToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "caller": Schema.optionalKey( - Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" - }) - ), - "content": Schema.Union([BetaRequestWebFetchToolResultError, BetaRequestWebFetchResultBlock]).annotate({ - "title": "Content" +export const BetaThinkingTypes = Schema.Struct({ + "adaptive": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports thinking with type 'adaptive' (auto)." }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("web_fetch_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestWebFetchToolResultBlock" }) -export type Message = { + "enabled": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports thinking with type 'enabled'." + }) +}).annotate({ + "title": "ThinkingTypes", + "description": "Supported thinking type configurations.", + "identifier": "BetaThinkingTypes" +}) +export type BetaMessageBatch = { + readonly "archived_at": string | null + readonly "cancel_initiated_at": string | null + readonly "created_at": string + readonly "ended_at": string | null + readonly "expires_at": string readonly "id": string - readonly "type": "message" - readonly "role": "assistant" - readonly "content": ReadonlyArray - readonly "model": Model - readonly "stop_reason": StopReason | null - readonly "stop_sequence": string | null - readonly "usage": { - readonly "cache_creation": CacheCreation | null - readonly "cache_creation_input_tokens": number | null - readonly "cache_read_input_tokens": number | null - readonly "inference_geo": string | null - readonly "input_tokens": number - readonly "output_tokens": number - readonly "server_tool_use"?: ServerToolUsage | null - readonly "service_tier": "standard" | "priority" | "batch" | null - } - readonly "container": Container | null + readonly "processing_status": "in_progress" | "canceling" | "ended" + readonly "request_counts": BetaRequestCounts + readonly "results_url": string | null + readonly "type": "message_batch" } -export const Message = Schema.Struct({ +export const BetaMessageBatch = Schema.Struct({ + "archived_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ + "title": "Archived At", + "description": + "RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable." + }), + "cancel_initiated_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ + "title": "Cancel Initiated At", + "description": + "RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated." + }), + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": "RFC 3339 datetime string representing the time at which the Message Batch was created.", + "format": "date-time" + }), + "ended_at": Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null]).annotate({ + "title": "Ended At", + "description": + "RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.\n\nProcessing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired." + }), + "expires_at": Schema.String.annotate({ + "title": "Expires At", + "description": + "RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.", + "format": "date-time" + }), "id": Schema.String.annotate({ "title": "Id", "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." }), - "type": Schema.Literal("message").annotate({ - "title": "Type", - "description": "Object type.\n\nFor Messages, this is always `\"message\"`.", - "default": "message" - }), - "role": Schema.Literal("assistant").annotate({ - "title": "Role", - "description": "Conversational role of the generated message.\n\nThis will always be `\"assistant\"`.", - "default": "assistant" + "processing_status": Schema.Literals(["in_progress", "canceling", "ended"]).annotate({ + "title": "Processing Status", + "description": "Processing status of the Message Batch." }), - "content": Schema.Array(ContentBlock).annotate({ - "title": "Content", + "request_counts": Schema.suspend((): Schema.Codec => BetaRequestCounts).annotate({ "description": - "Content generated by the model.\n\nThis is an array of content blocks, each of which has a `type` that determines its shape.\n\nExample:\n\n```json\n[{\"type\": \"text\", \"text\": \"Hi, I'm Claude.\"}]\n```\n\nIf the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output.\n\nFor example, if the input `messages` were:\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"}\n]\n```\n\nThen the response `content` might be:\n\n```json\n[{\"type\": \"text\", \"text\": \"B)\"}]\n```" + "Tallies requests within the Message Batch, categorized by their status.\n\nRequests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch." }), - "model": Model, - "stop_reason": Schema.Union([StopReason, Schema.Null]).annotate({ - "title": "Stop Reason", + "results_url": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Results Url", "description": - "The reason that we stopped.\n\nThis may be one the following values:\n* `\"end_turn\"`: the model reached a natural stopping point\n* `\"max_tokens\"`: we exceeded the requested `max_tokens` or the model's maximum\n* `\"stop_sequence\"`: one of your provided custom `stop_sequences` was generated\n* `\"tool_use\"`: the model invoked one or more tools\n* `\"pause_turn\"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.\n* `\"refusal\"`: when streaming classifiers intervene to handle potential policy violations\n\nIn non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise." + "URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.\n\nResults in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests." }), - "stop_sequence": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Stop Sequence", - "description": - "Which custom stop sequence was generated, if any.\n\nThis value will be a non-null string if one of your custom stop sequences was generated.", - "default": null + "type": Schema.Literal("message_batch").annotate({ + "title": "Type", + "description": "Object type.\n\nFor Message Batches, this is always `\"message_batch\"`.", + "default": "message_batch" + }) +}).annotate({ "title": "MessageBatch", "identifier": "BetaMessageBatch" }) +export type BetaCountMessageTokensResponse = { + readonly "context_management": BetaContextManagementResponse | null + readonly "input_tokens": number +} +export const BetaCountMessageTokensResponse = Schema.Struct({ + "context_management": Schema.Union([BetaContextManagementResponse, Schema.Null]).annotate({ + "description": "Information about context management applied to the message." }), - "usage": Schema.Struct({ - "cache_creation": Schema.Union([CacheCreation, Schema.Null]).annotate({ - "description": "Breakdown of cached tokens by TTL", - "default": null - }), - "cache_creation_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Cache Creation Input Tokens", - "description": "The number of input tokens used to create the cache entry.", - "default": null - }), - "cache_read_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]).annotate({ - "title": "Cache Read Input Tokens", - "description": "The number of input tokens read from the cache.", - "default": null - }), - "inference_geo": Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Inference Geo", - "description": "The geographic region where inference was performed for this request.", - "default": null - }), - "input_tokens": Schema.Number.annotate({ - "title": "Input Tokens", - "description": "The number of input tokens which were used." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "output_tokens": Schema.Number.annotate({ - "title": "Output Tokens", - "description": "The number of output tokens which were used." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "server_tool_use": Schema.optionalKey( - Schema.Union([ServerToolUsage, Schema.Null]).annotate({ - "description": "The number of server tool requests.", - "default": null - }) - ), - "service_tier": Schema.Union([Schema.Literals(["standard", "priority", "batch"]), Schema.Null]).annotate({ - "title": "Service Tier", - "description": "If the request used the priority, standard, or batch tier.", - "default": null + "input_tokens": Schema.Number.annotate({ + "title": "Input Tokens", + "description": "The total number of tokens across the provided list of messages, system prompt, and tools." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "title": "CountMessageTokensResponse", "identifier": "BetaCountMessageTokensResponse" }) +export type BetaFileMetadataSchema = { + readonly "created_at": string + readonly "downloadable"?: boolean + readonly "filename": string + readonly "id": string + readonly "mime_type": string + readonly "scope"?: BetaFileScope | null + readonly "size_bytes": number + readonly "type": "file" +} +export const BetaFileMetadataSchema = Schema.Struct({ + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": "RFC 3339 datetime string representing when the file was created.", + "format": "date-time" + }), + "downloadable": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Downloadable", + "description": "Whether the file can be downloaded.", + "default": false }) - }).annotate({ - "title": "Usage", + ), + "filename": Schema.String.annotate({ "title": "Filename", "description": "Original filename of the uploaded file." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" }) + ), + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." + }), + "mime_type": Schema.String.annotate({ "title": "Mime Type", "description": "MIME type of the file." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })), + "scope": Schema.optionalKey( + Schema.Union([BetaFileScope, Schema.Null]).annotate({ + "description": "The scope of this file, indicating the context in which it was created (e.g., a session)." + }) + ), + "size_bytes": Schema.Number.annotate({ "title": "Size Bytes", "description": "Size of the file in bytes." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "type": Schema.Literal("file").annotate({ + "title": "Type", + "description": "Object type.\n\nFor files, this is always `\"file\"`." + }) +}).annotate({ "title": "FileMetadataSchema", "identifier": "BetaFileMetadataSchema" }) +export type BetaListSkillsResponse = { + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "next_page": string | null +} +export const BetaListSkillsResponse = Schema.Struct({ + "data": Schema.Array(Betaapi__schemas__skills__Skill).annotate({ "title": "Data", "description": "List of skills." }), + "has_more": Schema.Boolean.annotate({ + "title": "Has More", "description": - "Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response from Claude.\n\nTotal input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`." + "Whether there are more results available.\n\nIf `true`, there are additional results that can be fetched using the `next_page` token." }), - "container": Schema.Union([Container, Schema.Null]).annotate({ + "next_page": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Next Page", "description": - "Information about the container used in this request.\n\nThis will be non-null if a container tool (e.g. code execution) was used.", - "default": null + "Token for fetching the next page of results.\n\nIf `null`, there are no more results available. Pass this value to the `page` parameter in the next request to get the next page." }) -}).annotate({ "title": "Message" }) -export type RequestWebFetchToolResultBlock = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "caller"?: DirectCaller | ServerToolCaller | ServerToolCaller_20260120 - readonly "content": RequestWebFetchToolResultError | RequestWebFetchResultBlock - readonly "tool_use_id": string - readonly "type": "web_fetch_tool_result" +}).annotate({ "title": "ListSkillsResponse", "identifier": "BetaListSkillsResponse" }) +export type BetaListSkillVersionsResponse = { + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "next_page": string | null } -export const RequestWebFetchToolResultBlock = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) +export const BetaListSkillVersionsResponse = Schema.Struct({ + "data": Schema.Array(BetaSkillVersion).annotate({ "title": "Data", "description": "List of skill versions." }), + "has_more": Schema.Boolean.annotate({ + "title": "Has More", + "description": "Indicates if there are more results in the requested page direction." + }), + "next_page": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Next Page", + "description": "Token to provide in as `page` in the subsequent request to retrieve the next page of data." + }) +}).annotate({ "title": "ListSkillVersionsResponse", "identifier": "BetaListSkillVersionsResponse" }) +export type BetaCloudConfig = { + readonly "networking": BetaUnrestrictedNetwork | BetaLimitedNetwork + readonly "packages": BetaPackages + readonly "type": "cloud" +} +export const BetaCloudConfig = Schema.Struct({ + "networking": Schema.Union([BetaUnrestrictedNetwork, BetaLimitedNetwork], { mode: "oneOf" }).annotate({ + "title": "Networking", + "description": "Network configuration policy." + }), + "packages": Schema.suspend((): Schema.Codec => BetaPackages).annotate({ + "description": "Package manager configuration." + }), + "type": Schema.Literal("cloud").annotate({ "title": "Type", "description": "Environment type" }) +}).annotate({ + "title": "CloudConfig", + "description": "`cloud` environment configuration.", + "identifier": "BetaCloudConfig" +}) +export type BetaCloudConfigParams = { + readonly "networking"?: BetaUnrestrictedNetwork | BetaLimitedNetworkParams | null + readonly "packages"?: BetaPackagesParams | null + readonly "type": "cloud" +} +export const BetaCloudConfigParams = Schema.Struct({ + "networking": Schema.optionalKey( + Schema.Union([Schema.Union([BetaUnrestrictedNetwork, BetaLimitedNetworkParams], { mode: "oneOf" }), Schema.Null]) + .annotate({ + "title": "Networking", + "description": "Network configuration policy. Omit on update to preserve the existing value." + }) ), - "caller": Schema.optionalKey( - Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" + "packages": Schema.optionalKey( + Schema.Union([BetaPackagesParams, Schema.Null]).annotate({ + "description": "Package manager configuration. Omit on update to preserve the existing value." }) ), - "content": Schema.Union([RequestWebFetchToolResultError, RequestWebFetchResultBlock]).annotate({ - "title": "Content" + "type": Schema.Literal("cloud").annotate({ "title": "Type", "description": "Environment type" }) +}).annotate({ + "title": "CloudConfigParams", + "description": + "Request params for `cloud` environment configuration.\n\nFields default to null; on update, omitted fields preserve the\nexisting value.", + "identifier": "BetaCloudConfigParams" +}) +export type BetaSelfHostedWork = { + readonly "acknowledged_at": string | null + readonly "created_at": string + readonly "data": BetaSessionWorkData + readonly "environment_id": string + readonly "id": string + readonly "latest_heartbeat_at": string | null + readonly "metadata": { readonly [x: string]: string } + readonly "secret": string | null + readonly "started_at": string | null + readonly "state": "queued" | "starting" | "active" | "stopping" | "stopped" + readonly "stop_requested_at": string | null + readonly "stopped_at": string | null + readonly "type": "work" +} +export const BetaSelfHostedWork = Schema.Struct({ + "acknowledged_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Acknowledged At", + "description": "RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox" }), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")) - ), - "type": Schema.Literal("web_fetch_tool_result").annotate({ "title": "Type" }) -}).annotate({ "title": "RequestWebFetchToolResultBlock" }) -export type BetaMessageStartEvent = { readonly "message": BetaMessage; readonly "type": "message_start" } -export const BetaMessageStartEvent = Schema.Struct({ - "message": BetaMessage, - "type": Schema.Literal("message_start").annotate({ "title": "Type", "default": "message_start" }) -}).annotate({ "title": "MessageStartEvent" }) -export type BetaSucceededResult = { readonly "message": BetaMessage; readonly "type": "succeeded" } -export const BetaSucceededResult = Schema.Struct({ - "message": BetaMessage, - "type": Schema.Literal("succeeded").annotate({ "title": "Type", "default": "succeeded" }) -}).annotate({ "title": "SucceededResult" }) -export type BetaInputContentBlock = - | { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "citations"?: - | ReadonlyArray< - | BetaRequestCharLocationCitation - | BetaRequestPageLocationCitation - | BetaRequestContentBlockLocationCitation - | BetaRequestWebSearchResultLocationCitation - | BetaRequestSearchResultLocationCitation - > - | null - readonly "text": string - readonly "type": "text" - } - | { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "source": BetaBase64ImageSource | BetaURLImageSource | BetaFileImageSource - readonly "type": "image" - } - | { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "citations"?: BetaRequestCitationsConfig | null - readonly "context"?: string | null - readonly "source": - | BetaBase64PDFSource - | BetaPlainTextSource - | BetaContentBlockSource - | BetaURLPDFSource - | BetaFileDocumentSource - readonly "title"?: string | null - readonly "type": "document" - } - | { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "citations"?: BetaRequestCitationsConfig - readonly "content": ReadonlyArray - readonly "source": string - readonly "title": string - readonly "type": "search_result" - } - | { readonly "signature": string; readonly "thinking": string; readonly "type": "thinking" } - | { readonly "data": string; readonly "type": "redacted_thinking" } - | { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 - readonly "id": string - readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": string - readonly "type": "tool_use" - } - | { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "content"?: - | string - | ReadonlyArray< - | BetaRequestTextBlock - | BetaRequestImageBlock - | BetaRequestSearchResultBlock - | BetaRequestDocumentBlock - | BetaRequestToolReferenceBlock - > - readonly "is_error"?: boolean - readonly "tool_use_id": string - readonly "type": "tool_result" - } - | BetaRequestServerToolUseBlock - | BetaRequestWebSearchToolResultBlock - | BetaRequestWebFetchToolResultBlock - | BetaRequestCodeExecutionToolResultBlock - | BetaRequestBashCodeExecutionToolResultBlock - | BetaRequestTextEditorCodeExecutionToolResultBlock - | BetaRequestToolSearchToolResultBlock - | BetaRequestMCPToolUseBlock - | BetaRequestMCPToolResultBlock - | BetaRequestContainerUploadBlock - | BetaRequestCompactionBlock -export const BetaInputContentBlock = Schema.Union([ - Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "citations": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([ - BetaRequestCharLocationCitation, - BetaRequestPageLocationCitation, - BetaRequestContentBlockLocationCitation, - BetaRequestWebSearchResultLocationCitation, - BetaRequestSearchResultLocationCitation - ], { mode: "oneOf" }) - ), - Schema.Null - ]).annotate({ "title": "Citations" }) - ), - "text": Schema.String.annotate({ "title": "Text" }).check(Schema.isMinLength(1)), - "type": Schema.Literal("text").annotate({ "title": "Type" }) - }).annotate({ "title": "RequestTextBlock", "description": "Regular text content." }), - Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "source": Schema.Union([BetaBase64ImageSource, BetaURLImageSource, BetaFileImageSource], { mode: "oneOf" }) - .annotate({ "title": "Source" }), - "type": Schema.Literal("image").annotate({ "title": "Type" }) - }).annotate({ - "title": "RequestImageBlock", - "description": "Image content specified directly as base64 data or as a reference via a URL." + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": "RFC 3339 timestamp when work was created" }), - Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." - }) - ), - "citations": Schema.optionalKey(Schema.Union([BetaRequestCitationsConfig, Schema.Null])), - "context": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)), Schema.Null]).annotate({ "title": "Context" }) - ), - "source": Schema.Union([ - BetaBase64PDFSource, - BetaPlainTextSource, - BetaContentBlockSource, - BetaURLPDFSource, - BetaFileDocumentSource - ], { mode: "oneOf" }).annotate({ "title": "Source" }), - "title": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(500)), Schema.Null]).annotate({ - "title": "Title" - }) - ), - "type": Schema.Literal("document").annotate({ "title": "Type" }) - }).annotate({ - "title": "RequestDocumentBlock", - "description": "Document content, either specified directly as base64 data, as text, or as a reference via a URL." + "data": Schema.suspend((): Schema.Codec => BetaSessionWorkData).annotate({ + "description": "The actual work to be performed" + }), + "environment_id": Schema.String.annotate({ + "title": "Environment Id", + "description": "Environment identifier this work belongs to (e.g., `env_...`)" + }), + "id": Schema.String.annotate({ "title": "Id", "description": "Work identifier (e.g., 'work_...')" }), + "latest_heartbeat_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Latest Heartbeat At", + "description": "RFC 3339 timestamp of the most recent heartbeat" + }), + "metadata": Schema.Record(Schema.String, Schema.String).annotate({ + "title": "Metadata", + "description": "User-provided metadata key-value pairs associated with this work item" + }), + "secret": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Secret", + "description": + "Credential payload used by the environment worker to execute this work item. May be populated when polling for work; null on all other retrieval paths." }), + "started_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Started At", + "description": "RFC 3339 timestamp when work execution started" + }), + "state": Schema.Literals(["queued", "starting", "active", "stopping", "stopped"]).annotate({ + "title": "State", + "description": "Current state of the work item" + }), + "stop_requested_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Stop Requested At", + "description": "RFC 3339 timestamp when stop was requested" + }), + "stopped_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Stopped At", + "description": "RFC 3339 timestamp when work execution stopped" + }), + "type": Schema.Literal("work").annotate({ + "title": "Type", + "description": "The type of object (always 'work')", + "default": "work" + }) +}).annotate({ + "title": "SelfHostedWork", + "description": + "Work resource representing a unit of work in a self-hosted environment.\n\nWork items are queued when sessions are created or when long-dormant sessions\nreceive new messages. The environment worker polls for work to execute in a\nself-hosted sandbox.", + "identifier": "BetaSelfHostedWork" +}) +export type BetaManagedAgentsMemoryListItem = { + readonly "type": "memory" + readonly "id": string + readonly "memory_store_id": string + readonly "path": string + readonly "content"?: string + readonly "content_size_bytes": number + readonly "content_sha256": string + readonly "memory_version_id": string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp +} | { readonly "type": "memory_prefix"; readonly "path": string } +export const BetaManagedAgentsMemoryListItem = Schema.Union([ Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "type": Schema.Literal("memory"), + "id": Schema.String.annotate({ + "description": + "Unique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory." + }), + "memory_store_id": Schema.String.annotate({ + "description": "ID of the memory store this memory belongs to (a `memstore_...` value)." + }), + "path": Schema.String.annotate({ + "description": + "Hierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes." + }), + "content": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes)." }) ), - "citations": Schema.optionalKey(BetaRequestCitationsConfig), - "content": Schema.Array(BetaRequestTextBlock).annotate({ "title": "Content" }), - "source": Schema.String.annotate({ "title": "Source" }), - "title": Schema.String.annotate({ "title": "Title" }), - "type": Schema.Literal("search_result").annotate({ "title": "Type" }) + "content_size_bytes": Schema.Number.annotate({ + "description": "Size of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_sha256": Schema.String.annotate({ + "description": + "Lowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`." + }), + "memory_version_id": Schema.String.annotate({ + "description": + "ID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the full history via [List memory versions](/en/api/beta/memory_stores/memory_versions/list)." + }), + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When this memory was created, in RFC 3339 format." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "When this memory was last modified, in RFC 3339 format. Use this as a cheap freshness signal; for who made the change, look up the head version's `created_by` via [List memory versions](/en/api/beta/memory_stores/memory_versions/list)." + }) }).annotate({ - "title": "RequestSearchResultBlock", - "description": "A search result block containing source, title, and content from search operations." + "description": + "One item in a [List memories](/en/api/beta/memory_stores/memories/list) response: either a `memory` object or, when `depth` is set, a `memory_prefix` rollup marker." }), Schema.Struct({ - "signature": Schema.String.annotate({ "title": "Signature" }), - "thinking": Schema.String.annotate({ "title": "Thinking" }), - "type": Schema.Literal("thinking").annotate({ "title": "Type" }) - }).annotate({ "title": "RequestThinkingBlock", "description": "A block specifying internal thinking by the model." }), - Schema.Struct({ - "data": Schema.String.annotate({ "title": "Data" }), - "type": Schema.Literal("redacted_thinking").annotate({ "title": "Type" }) + "type": Schema.Literal("memory_prefix"), + "path": Schema.String.annotate({ + "description": + "The rolled-up path prefix, including a trailing `/` (e.g. `/projects/foo/`). Pass this value as `path_prefix` on a subsequent list call to drill into the directory." + }) }).annotate({ - "title": "RequestRedactedThinkingBlock", - "description": "A block specifying internal, redacted thinking by the model." + "description": + "One item in a [List memories](/en/api/beta/memory_stores/memories/list) response: either a `memory` object or, when `depth` is set, a `memory_prefix` rollup marker." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsMemoryListItem" }) +export type BetaManagedAgentsMemory = { + readonly "type": "memory" + readonly "id": string + readonly "memory_store_id": string + readonly "path": string + readonly "content"?: string + readonly "content_size_bytes": number + readonly "content_sha256": string + readonly "memory_version_id": string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp +} +export const BetaManagedAgentsMemory = Schema.Struct({ + "type": Schema.Literal("memory"), + "id": Schema.String.annotate({ + "description": + "Unique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory." + }), + "memory_store_id": Schema.String.annotate({ + "description": "ID of the memory store this memory belongs to (a `memstore_...` value)." + }), + "path": Schema.String.annotate({ + "description": + "Hierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes." + }), + "content": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes)." + }) + ), + "content_size_bytes": Schema.Number.annotate({ + "description": "Size of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_sha256": Schema.String.annotate({ + "description": + "Lowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`." + }), + "memory_version_id": Schema.String.annotate({ + "description": + "ID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the full history via [List memory versions](/en/api/beta/memory_stores/memory_versions/list)." + }), + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When this memory was created, in RFC 3339 format." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "When this memory was last modified, in RFC 3339 format. Use this as a cheap freshness signal; for who made the change, look up the head version's `created_by` via [List memory versions](/en/api/beta/memory_stores/memory_versions/list)." + }) +}).annotate({ + "description": + "A `memory` object: a single text document at a hierarchical path inside a memory store. The `content` field is populated when `view=full` and `null` when `view=basic`; the `content_size_bytes` and `content_sha256` fields are always populated so sync clients can diff without fetching content. Memories are addressed by their `mem_...` ID; the path is the create key and can be changed via update.", + "identifier": "BetaManagedAgentsMemory" +}) +export type BetaManagedAgentsMemoryStore = { + readonly "type": "memory_store" + readonly "id": string + readonly "name": string + readonly "description"?: string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "metadata"?: { readonly [x: string]: string } + readonly "archived_at"?: BetaTimestamp +} +export const BetaManagedAgentsMemoryStore = Schema.Struct({ + "type": Schema.Literal("memory_store"), + "id": Schema.String.annotate({ + "description": + "Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls." + }), + "name": Schema.String.annotate({ + "description": + "Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name." + }), + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset." + }) + ), + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the store was created." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store's `name`, `description`, or `metadata` was last modified. Memory writes inside the store do not advance this." }), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable." + }) + ), + "archived_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store was archived, or `null` if active. Set once and never cleared; archiving is one-way. Archived stores are read-only and cannot be attached to new sessions." + }) + ) +}).annotate({ + "description": + "A `memory_store`: a named container for agent memories, scoped to a workspace. Attach a store to a session via `resources[]` to mount it as a directory the agent can read and write.", + "identifier": "BetaManagedAgentsMemoryStore" +}) +export type BetaManagedAgentsCreateMemoryStoreResponse = { + readonly "type": "memory_store" + readonly "id": string + readonly "name": string + readonly "description"?: string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "metadata"?: { readonly [x: string]: string } + readonly "archived_at"?: BetaTimestamp +} +export const BetaManagedAgentsCreateMemoryStoreResponse = Schema.Union([ Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "type": Schema.Literal("memory_store"), + "id": Schema.String.annotate({ + "description": + "Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls." + }), + "name": Schema.String.annotate({ + "description": + "Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name." + }), + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset." }) ), - "caller": Schema.optionalKey( - Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate( - { "title": "Caller" } - ) - ), - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.String.annotate({ "title": "Name" }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(200)), - "type": Schema.Literal("tool_use").annotate({ "title": "Type" }) - }).annotate({ "title": "RequestToolUseBlock", "description": "A block indicating a tool use by the model." }), - Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the store was created." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store's `name`, `description`, or `metadata` was last modified. Memory writes inside the store do not advance this." + }), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable." }) ), - "content": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Array( - Schema.Union([ - BetaRequestTextBlock, - BetaRequestImageBlock, - BetaRequestSearchResultBlock, - BetaRequestDocumentBlock, - BetaRequestToolReferenceBlock - ], { mode: "oneOf" }).annotate({ "title": "Block" }) - ) - ]).annotate({ "title": "Content" }) - ), - "is_error": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Is Error" })), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")) - ), - "type": Schema.Literal("tool_result").annotate({ "title": "Type" }) - }).annotate({ - "title": "RequestToolResultBlock", - "description": "A block specifying the results of a tool use by the model." - }), - BetaRequestServerToolUseBlock, - BetaRequestWebSearchToolResultBlock, - BetaRequestWebFetchToolResultBlock, - BetaRequestCodeExecutionToolResultBlock, - BetaRequestBashCodeExecutionToolResultBlock, - BetaRequestTextEditorCodeExecutionToolResultBlock, - BetaRequestToolSearchToolResultBlock, - BetaRequestMCPToolUseBlock, - BetaRequestMCPToolResultBlock, - BetaRequestContainerUploadBlock, - BetaRequestCompactionBlock -], { mode: "oneOf" }) -export type MessageStartEvent = { readonly "message": Message; readonly "type": "message_start" } -export const MessageStartEvent = Schema.Struct({ - "message": Message, - "type": Schema.Literal("message_start").annotate({ "title": "Type", "default": "message_start" }) -}).annotate({ "title": "MessageStartEvent" }) -export type SucceededResult = { readonly "message": Message; readonly "type": "succeeded" } -export const SucceededResult = Schema.Struct({ - "message": Message, - "type": Schema.Literal("succeeded").annotate({ "title": "Type", "default": "succeeded" }) -}).annotate({ "title": "SucceededResult" }) -export type InputContentBlock = - | { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "citations"?: - | ReadonlyArray< - | RequestCharLocationCitation - | RequestPageLocationCitation - | RequestContentBlockLocationCitation - | RequestWebSearchResultLocationCitation - | RequestSearchResultLocationCitation - > - | null - readonly "text": string - readonly "type": "text" - } - | { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "source": Base64ImageSource | URLImageSource - readonly "type": "image" - } - | { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "citations"?: RequestCitationsConfig | null - readonly "context"?: string | null - readonly "source": Base64PDFSource | PlainTextSource | ContentBlockSource | URLPDFSource - readonly "title"?: string | null - readonly "type": "document" - } - | { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "citations"?: RequestCitationsConfig - readonly "content": ReadonlyArray - readonly "source": string - readonly "title": string - readonly "type": "search_result" - } - | { readonly "signature": string; readonly "thinking": string; readonly "type": "thinking" } - | { readonly "data": string; readonly "type": "redacted_thinking" } - | { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "caller"?: DirectCaller | ServerToolCaller | ServerToolCaller_20260120 - readonly "id": string - readonly "input": { readonly [x: string]: Schema.Json } - readonly "name": string - readonly "type": "tool_use" - } - | { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "content"?: - | string - | ReadonlyArray< - | RequestTextBlock - | RequestImageBlock - | RequestSearchResultBlock - | RequestDocumentBlock - | RequestToolReferenceBlock - > - readonly "is_error"?: boolean - readonly "tool_use_id": string - readonly "type": "tool_result" - } - | RequestServerToolUseBlock - | RequestWebSearchToolResultBlock - | RequestWebFetchToolResultBlock - | RequestCodeExecutionToolResultBlock - | RequestBashCodeExecutionToolResultBlock - | RequestTextEditorCodeExecutionToolResultBlock - | RequestToolSearchToolResultBlock - | RequestContainerUploadBlock -export const InputContentBlock = Schema.Union([ + "archived_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store was archived, or `null` if active. Set once and never cleared; archiving is one-way. Archived stores are read-only and cannot be attached to new sessions." + }) + ) + }).annotate({ "description": "Response from creating a `memory_store`. Returns the created store." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsCreateMemoryStoreResponse" }) +export type BetaManagedAgentsGetMemoryStoreResponse = { + readonly "type": "memory_store" + readonly "id": string + readonly "name": string + readonly "description"?: string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "metadata"?: { readonly [x: string]: string } + readonly "archived_at"?: BetaTimestamp +} +export const BetaManagedAgentsGetMemoryStoreResponse = Schema.Union([ Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "type": Schema.Literal("memory_store"), + "id": Schema.String.annotate({ + "description": + "Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls." + }), + "name": Schema.String.annotate({ + "description": + "Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name." + }), + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset." }) ), - "citations": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([ - RequestCharLocationCitation, - RequestPageLocationCitation, - RequestContentBlockLocationCitation, - RequestWebSearchResultLocationCitation, - RequestSearchResultLocationCitation - ], { mode: "oneOf" }) - ), - Schema.Null - ]).annotate({ "title": "Citations" }) - ), - "text": Schema.String.annotate({ "title": "Text" }).check(Schema.isMinLength(1)), - "type": Schema.Literal("text").annotate({ "title": "Type" }) - }).annotate({ "title": "RequestTextBlock", "description": "Regular text content." }), - Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the store was created." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store's `name`, `description`, or `metadata` was last modified. Memory writes inside the store do not advance this." + }), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable." }) ), - "source": Schema.Union([Base64ImageSource, URLImageSource], { mode: "oneOf" }).annotate({ "title": "Source" }), - "type": Schema.Literal("image").annotate({ "title": "Type" }) + "archived_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store was archived, or `null` if active. Set once and never cleared; archiving is one-way. Archived stores are read-only and cannot be attached to new sessions." + }) + ) }).annotate({ - "title": "RequestImageBlock", - "description": "Image content specified directly as base64 data or as a reference via a URL." - }), + "description": "Response from retrieving a `memory_store`. Returns the store, including archived stores." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsGetMemoryStoreResponse" }) +export type BetaManagedAgentsUpdateMemoryStoreResponse = { + readonly "type": "memory_store" + readonly "id": string + readonly "name": string + readonly "description"?: string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "metadata"?: { readonly [x: string]: string } + readonly "archived_at"?: BetaTimestamp +} +export const BetaManagedAgentsUpdateMemoryStoreResponse = Schema.Union([ Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "type": Schema.Literal("memory_store"), + "id": Schema.String.annotate({ + "description": + "Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls." + }), + "name": Schema.String.annotate({ + "description": + "Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name." + }), + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset." }) ), - "citations": Schema.optionalKey(Schema.Union([RequestCitationsConfig, Schema.Null])), - "context": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)), Schema.Null]).annotate({ "title": "Context" }) - ), - "source": Schema.Union([Base64PDFSource, PlainTextSource, ContentBlockSource, URLPDFSource], { mode: "oneOf" }) - .annotate({ "title": "Source" }), - "title": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMinLength(1)).check(Schema.isMaxLength(500)), Schema.Null]).annotate({ - "title": "Title" + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the store was created." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store's `name`, `description`, or `metadata` was last modified. Memory writes inside the store do not advance this." + }), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable." }) ), - "type": Schema.Literal("document").annotate({ "title": "Type" }) - }).annotate({ - "title": "RequestDocumentBlock", - "description": "Document content, either specified directly as base64 data, as text, or as a reference via a URL." - }), - Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "archived_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store was archived, or `null` if active. Set once and never cleared; archiving is one-way. Archived stores are read-only and cannot be attached to new sessions." }) - ), - "citations": Schema.optionalKey(RequestCitationsConfig), - "content": Schema.Array(RequestTextBlock).annotate({ "title": "Content" }), - "source": Schema.String.annotate({ "title": "Source" }), - "title": Schema.String.annotate({ "title": "Title" }), - "type": Schema.Literal("search_result").annotate({ "title": "Type" }) - }).annotate({ - "title": "RequestSearchResultBlock", - "description": "A search result block containing source, title, and content from search operations." - }), - Schema.Struct({ - "signature": Schema.String.annotate({ "title": "Signature" }), - "thinking": Schema.String.annotate({ "title": "Thinking" }), - "type": Schema.Literal("thinking").annotate({ "title": "Type" }) - }).annotate({ "title": "RequestThinkingBlock", "description": "A block specifying internal thinking by the model." }), - Schema.Struct({ - "data": Schema.String.annotate({ "title": "Data" }), - "type": Schema.Literal("redacted_thinking").annotate({ "title": "Type" }) - }).annotate({ - "title": "RequestRedactedThinkingBlock", - "description": "A block specifying internal, redacted thinking by the model." - }), + ) + }).annotate({ "description": "Response from updating a `memory_store`. Returns the store with the changes applied." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsUpdateMemoryStoreResponse" }) +export type BetaManagedAgentsArchiveMemoryStoreResponse = { + readonly "type": "memory_store" + readonly "id": string + readonly "name": string + readonly "description"?: string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "metadata"?: { readonly [x: string]: string } + readonly "archived_at"?: BetaTimestamp +} +export const BetaManagedAgentsArchiveMemoryStoreResponse = Schema.Union([ Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "type": Schema.Literal("memory_store"), + "id": Schema.String.annotate({ + "description": + "Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls." + }), + "name": Schema.String.annotate({ + "description": + "Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name." + }), + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset." }) ), - "caller": Schema.optionalKey( - Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ - "title": "Caller" + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the store was created." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store's `name`, `description`, or `metadata` was last modified. Memory writes inside the store do not advance this." + }), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable." }) ), - "id": Schema.String.annotate({ "title": "Id" }).check(Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$"))), - "input": Schema.Record(Schema.String, Schema.Json).annotate({ "title": "Input" }), - "name": Schema.String.annotate({ "title": "Name" }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(200)), - "type": Schema.Literal("tool_use").annotate({ "title": "Type" }) - }).annotate({ "title": "RequestToolUseBlock", "description": "A block indicating a tool use by the model." }), - Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": "Create a cache control breakpoint at this content block." + "archived_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Timestamp when the store was archived, or `null` if active. Set once and never cleared; archiving is one-way. Archived stores are read-only and cannot be attached to new sessions." }) + ) + }).annotate({ "description": "Response from archiving a `memory_store`. Returns the store with `archived_at` set." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsArchiveMemoryStoreResponse" }) +export type BetaEnrollmentUrl = { + readonly "url": string + readonly "expires_at": BetaTimestamp + readonly "type": "enrollment_url" +} +export const BetaEnrollmentUrl = Schema.Struct({ + "url": Schema.String.annotate({ "description": "Enrollment URL to send to the end user. Valid until `expires_at`." }), + "expires_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When this enrollment URL expires, in RFC 3339 format." + }), + "type": Schema.Literal("enrollment_url").annotate({ "description": "Object type. Always `enrollment_url`." }) +}).annotate({ "identifier": "BetaEnrollmentUrl" }) +export type BetaTunnel = { + readonly "type": "tunnel" + readonly "id": string + readonly "domain": string + readonly "display_name": string + readonly "created_at": BetaTimestamp + readonly "archived_at": BetaTimestamp +} +export const BetaTunnel = Schema.Struct({ + "type": Schema.Literal("tunnel"), + "id": Schema.String.annotate({ "description": "Unique identifier for the tunnel, prefixed with `tnl_`." }), + "domain": Schema.String.annotate({ + "description": + "Anthropic-assigned hostname for the tunnel. MCP server URLs whose host is a subdomain of this value are routed through the tunnel. Globally unique and never reused, even after the tunnel is archived." + }), + "display_name": Schema.String.annotate({ + "description": "Human-readable name for the tunnel (1-255 characters). Null if unset." + }), + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "RFC 3339 datetime string indicating when the tunnel was created." + }), + "archived_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "RFC 3339 datetime string indicating when the tunnel was archived. Null if it is not archived." + }) +}).annotate({ "description": "An MCP tunnel.", "identifier": "BetaTunnel" }) +export type BetaTunnelCertificate = { + readonly "type": "tunnel_certificate" + readonly "id": string + readonly "tunnel_id": string + readonly "fingerprint": string + readonly "expires_at": BetaTimestamp + readonly "created_at": BetaTimestamp + readonly "archived_at": BetaTimestamp +} +export const BetaTunnelCertificate = Schema.Struct({ + "type": Schema.Literal("tunnel_certificate"), + "id": Schema.String.annotate({ "description": "Unique identifier for the certificate, prefixed with `tcrt_`." }), + "tunnel_id": Schema.String.annotate({ "description": "ID of the tunnel the certificate is registered against." }), + "fingerprint": Schema.String.annotate({ + "description": "Lowercase hex SHA-256 fingerprint of the certificate's DER encoding." + }), + "expires_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "RFC 3339 datetime string indicating when the certificate expires, or `null` if it does not expire." + }), + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "RFC 3339 datetime string indicating when the certificate was registered." + }), + "archived_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "RFC 3339 datetime string indicating when the certificate was archived. Null if it is still in the trusted set." + }) +}).annotate({ "description": "A CA certificate attached to a tunnel.", "identifier": "BetaTunnelCertificate" }) +export type BetaManagedAgentsOutcomeEvaluationResource = { + readonly "type": "outcome_evaluation" + readonly "outcome_id": string + readonly "description": string + readonly "result": string + readonly "iteration": number + readonly "completed_at": BetaTimestamp + readonly "explanation": string +} +export const BetaManagedAgentsOutcomeEvaluationResource = Schema.Struct({ + "type": Schema.Literal("outcome_evaluation"), + "outcome_id": Schema.String.annotate({ "description": "Server-generated outc_ ID for this outcome." }), + "description": Schema.String.annotate({ "description": "What the agent should produce." }), + "result": Schema.String.annotate({ + "description": + "Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal." + }), + "iteration": Schema.Number.annotate({ + "description": "0-indexed revision cycle the outcome is currently on.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "completed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When the outcome reached a terminal result. Null while pending/running/evaluating." + }), + "explanation": Schema.String.annotate({ + "description": + "Grader's verdict text from the most recent evaluation. For satisfied, explains why criteria are met; for needs_revision (intermediate), what's missing; for failed, why unrecoverable." + }) +}).annotate({ + "description": "Evaluation state for a single outcome defined via a define_outcome event.", + "identifier": "BetaManagedAgentsOutcomeEvaluationResource" +}) +export type BetaManagedAgentsAddSessionResource = { + readonly "type": "file" + readonly "id": string + readonly "file_id": string + readonly "mount_path": string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp +} +export const BetaManagedAgentsAddSessionResource = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("file"), + "id": Schema.String, + "file_id": Schema.String, + "mount_path": Schema.String, + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp + }).annotate({ "description": "The added session resource." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsAddSessionResource" }) +export type BetaManagedAgentsSchedule = { + readonly "type": "cron" + readonly "expression": string + readonly "timezone": string + readonly "last_run_at"?: BetaTimestamp + readonly "upcoming_runs_at"?: ReadonlyArray +} +export const BetaManagedAgentsSchedule = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("cron"), + "expression": Schema.String.annotate({ + "description": + "5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., \"0 9 * * 1-5\" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily)." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" }) ), - "content": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Array( - Schema.Union([ - RequestTextBlock, - RequestImageBlock, - RequestSearchResultBlock, - RequestDocumentBlock, - RequestToolReferenceBlock - ], { mode: "oneOf" }).annotate({ "title": "Block" }) - ) - ]).annotate({ "title": "Content" }) - ), - "is_error": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Is Error" })), - "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( - Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")) + "timezone": Schema.String.annotate({ + "description": "IANA timezone identifier (e.g., \"America/Los_Angeles\", \"UTC\")." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "last_run_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "Time the most recent scheduled run actually started. Null until one completes; preserved after the deployment is archived. Manual runs do not update this." + }) ), - "type": Schema.Literal("tool_result").annotate({ "title": "Type" }) + "upcoming_runs_at": Schema.optionalKey( + Schema.Array(BetaTimestamp).annotate({ + "description": + "Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused deployments (reflects what the schedule would do if unpaused); empty once the deployment is archived (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a run will actually start at or shortly after its listed time." + }) + ) }).annotate({ - "title": "RequestToolResultBlock", - "description": "A block specifying the results of a tool use by the model." + "description": + "A recurring schedule with computed runtime timestamps. Discriminated union — only cron is supported currently." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsSchedule" }) +export type BetaManagedAgentsTriggerContext = + | { readonly "type": "schedule"; readonly "scheduled_at": BetaTimestamp } + | { readonly "type": "manual" } +export const BetaManagedAgentsTriggerContext = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("schedule"), + "scheduled_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "The UTC instant at which the cron expression matched in the configured timezone, before jitter is applied. At most one run is recorded per (deployment_id, scheduled_at) pair." + }) + }).annotate({ "description": "Describes what triggered a deployment run, with trigger-specific metadata." }), + Schema.Struct({ "type": Schema.Literal("manual") }).annotate({ + "description": "Describes what triggered a deployment run, with trigger-specific metadata." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsTriggerContext" }) +export type BetaManagedAgentsVault = { + readonly "type": "vault" + readonly "id": string + readonly "display_name": string + readonly "metadata": { readonly [x: string]: string } + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "archived_at": BetaTimestamp +} +export const BetaManagedAgentsVault = Schema.Struct({ + "type": Schema.Literal("vault"), + "id": Schema.String.annotate({ "description": "Unique identifier for the vault." }), + "display_name": Schema.String.annotate({ "description": "Human-readable name for the vault." }), + "metadata": Schema.Record(Schema.String, Schema.String).annotate({ + "description": "Arbitrary key-value metadata attached to the vault." }), - RequestServerToolUseBlock, - RequestWebSearchToolResultBlock, - RequestWebFetchToolResultBlock, - RequestCodeExecutionToolResultBlock, - RequestBashCodeExecutionToolResultBlock, - RequestTextEditorCodeExecutionToolResultBlock, - RequestToolSearchToolResultBlock, - RequestContainerUploadBlock -], { mode: "oneOf" }) -export type BetaInputMessage = { - readonly "content": string | ReadonlyArray - readonly "role": "user" | "assistant" -} -export const BetaInputMessage = Schema.Struct({ - "content": Schema.Union([Schema.String, Schema.Array(BetaInputContentBlock)]).annotate({ "title": "Content" }), - "role": Schema.Literals(["user", "assistant"]).annotate({ "title": "Role" }) -}).annotate({ "title": "InputMessage" }) -export type InputMessage = { - readonly "content": string | ReadonlyArray - readonly "role": "user" | "assistant" -} -export const InputMessage = Schema.Struct({ - "content": Schema.Union([Schema.String, Schema.Array(InputContentBlock)]).annotate({ "title": "Content" }), - "role": Schema.Literals(["user", "assistant"]).annotate({ "title": "Role" }) -}).annotate({ "title": "InputMessage" }) -export type BetaCountMessageTokensParams = { - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "context_management"?: BetaContextManagementConfig | null - readonly "mcp_servers"?: ReadonlyArray - readonly "messages": ReadonlyArray - readonly "model": Model - readonly "output_config"?: { - readonly "effort"?: BetaEffortLevel | null - readonly "format"?: BetaJsonOutputFormat | null - } - readonly "output_format"?: BetaJsonOutputFormat | null - readonly "speed"?: BetaSpeed | null - readonly "system"?: string | ReadonlyArray - readonly "thinking"?: BetaThinkingConfigParam - readonly "tool_choice"?: BetaToolChoice - readonly "tools"?: ReadonlyArray< - | BetaTool - | BetaBashTool_20241022 - | BetaBashTool_20250124 - | BetaCodeExecutionTool_20250522 - | BetaCodeExecutionTool_20250825 - | BetaCodeExecutionTool_20260120 - | BetaComputerUseTool_20241022 - | BetaMemoryTool_20250818 - | BetaComputerUseTool_20250124 - | BetaTextEditor_20241022 - | BetaComputerUseTool_20251124 - | BetaTextEditor_20250124 - | BetaTextEditor_20250429 - | BetaTextEditor_20250728 - | BetaWebSearchTool_20250305 - | BetaWebFetchTool_20250910 - | BetaWebSearchTool_20260209 - | BetaWebFetchTool_20260209 - | BetaToolSearchToolBM25_20251119 - | BetaToolSearchToolRegex_20251119 - | BetaMCPToolset - > -} -export const BetaCountMessageTokensParams = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp, + "archived_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When the vault was archived. Null if not archived." + }) +}).annotate({ + "description": "A vault that stores credentials for use by agents during sessions.", + "identifier": "BetaManagedAgentsVault" +}) +export type BetaManagedAgentsError = + | BetaInvalidRequestError + | BetaAuthenticationError + | BetaBillingError + | BetaPermissionError + | BetaNotFoundError + | BetaRateLimitError + | BetaGatewayTimeoutError + | BetaAPIError + | BetaOverloadedError + | BetaManagedAgentsMemoryPreconditionFailedError + | BetaManagedAgentsMemoryPathConflictError + | BetaManagedAgentsConflictError +export const BetaManagedAgentsError = Schema.Union([ + BetaInvalidRequestError, + BetaAuthenticationError, + BetaBillingError, + BetaPermissionError, + BetaNotFoundError, + BetaRateLimitError, + BetaGatewayTimeoutError, + BetaAPIError, + BetaOverloadedError, + BetaManagedAgentsMemoryPreconditionFailedError, + BetaManagedAgentsMemoryPathConflictError, + BetaManagedAgentsConflictError +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsError" }) +export type BetaManagedAgentsUpdateMemoryParams = { + readonly "content"?: string + readonly "path"?: string + readonly "precondition"?: BetaManagedAgentsPrecondition +} +export const BetaManagedAgentsUpdateMemoryParams = Schema.Struct({ + "content": Schema.optionalKey( + Schema.String.annotate({ "description": - "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." + "New UTF-8 text content for the memory. Maximum 100 kB (102,400 bytes). Omit to leave the content unchanged (e.g., for a rename-only update)." }) ), - "context_management": Schema.optionalKey( - Schema.Union([BetaContextManagementConfig, Schema.Null]).annotate({ + "path": Schema.optionalKey( + Schema.String.annotate({ "description": - "Context management configuration.\n\nThis allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not." + "New path for the memory (a rename). Must start with `/`, contain at least one non-empty segment, and be at most 1,024 bytes. Must not contain empty segments, `.` or `..` segments, control or format characters, and must be NFC-normalized. Paths are case-sensitive. The memory's `id` is preserved across renames. Omit to leave the path unchanged." + }).check(Schema.isMinLength(2).annotate({ "expected": "a value with a length of at least 2" })).check( + Schema.isMaxLength(1024).annotate({ "expected": "a value with a length of at most 1024" }) + ) + ), + "precondition": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsPrecondition).annotate({ + "description": + "Optional optimistic-concurrency precondition. When supplied, the update applies only if the memory's current state matches; on mismatch the request returns `memory_precondition_failed_error` (HTTP 409). When omitted, the update is unconditional." + }) + ) +}).annotate({ + "description": + "Request parameters for [Update a memory](/en/api/beta/memory_stores/memories/update). At least one of `content` or `path` must be provided. Renaming onto a path occupied by a different memory returns `memory_path_conflict_error` (HTTP 409). Rename never overwrites; delete or rename the blocking memory first. An update where every supplied field already matches the stored value is a no-op: it returns 200 with the existing memory and writes no new version.", + "identifier": "BetaManagedAgentsUpdateMemoryParams" +}) +export type BetaManagedAgentsMemoryVersion = { + readonly "type": "memory_version" + readonly "id": string + readonly "memory_store_id": string + readonly "memory_id": string + readonly "path"?: string + readonly "operation": BetaManagedAgentsMemoryVersionOperation + readonly "content"?: string + readonly "content_size_bytes"?: number + readonly "content_sha256"?: string + readonly "created_by"?: BetaManagedAgentsActor + readonly "created_at": BetaTimestamp + readonly "redacted_at"?: BetaTimestamp + readonly "redacted_by"?: BetaManagedAgentsActor +} +export const BetaManagedAgentsMemoryVersion = Schema.Struct({ + "type": Schema.Literal("memory_version"), + "id": Schema.String.annotate({ "description": "Unique identifier for this version (a `memver_...` value)." }), + "memory_store_id": Schema.String.annotate({ + "description": "ID of the memory store this version belongs to (a `memstore_...` value)." + }), + "memory_id": Schema.String.annotate({ + "description": + "ID of the memory this version snapshots (a `mem_...` value). Remains valid after the memory is deleted; pass it as `memory_id` to [List memory versions](/en/api/beta/memory_stores/memory_versions/list) to retrieve the full lineage including the `deleted` row." + }), + "path": Schema.optionalKey( + Schema.String.annotate({ + "description": "The memory's path at the time of this write. `null` if and only if `redacted_at` is set." }) ), - "mcp_servers": Schema.optionalKey( - Schema.Array(BetaRequestMCPServerURLDefinition).annotate({ - "title": "Mcp Servers", - "description": "MCP servers to be utilized in this request" - }).check(Schema.isMaxLength(20)) + "operation": Schema.suspend((): Schema.Codec => + BetaManagedAgentsMemoryVersionOperation + ).annotate({ "description": "The kind of mutation this version records: `created`, `modified`, or `deleted`." }), + "content": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The memory's UTF-8 text content as of this version. `null` when `view=basic`, when `operation` is `deleted`, or when `redacted_at` is set." + }) ), - "messages": Schema.Array(BetaInputMessage).annotate({ - "title": "Messages", - "description": - "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://docs.claude.com/en/api/messages-examples).\n\nNote that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." + "content_size_bytes": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Size of `content` in bytes as of this version. `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "content_sha256": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Lowercase hex SHA-256 digest of `content` as of this version (64 characters). `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise." + }) + ), + "created_by": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsActor).annotate({ + "description": + "Who performed this write: a `session_actor`, `api_actor`, or `user_actor`. Captured at write time and preserved through redaction." + }) + ), + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When this version was written, in RFC 3339 format." }), - "model": Model, - "output_config": Schema.optionalKey( - Schema.Struct({ - "effort": Schema.optionalKey( - Schema.Union([BetaEffortLevel, Schema.Null]).annotate({ - "description": - "How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.\n\nValid values are `low`, `medium`, `high`, or `max`." - }) - ), - "format": Schema.optionalKey( - Schema.Union([BetaJsonOutputFormat, Schema.Null]).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({ - "title": "OutputConfig", - "description": "Configuration options for the model's output, such as the output format." + "redacted_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "When this version was redacted, in RFC 3339 format, or `null` if it has not been redacted. When set, `content`, `path`, `content_size_bytes`, and `content_sha256` are all `null`. See [Redact a memory version](/en/api/beta/memory_stores/memory_versions/redact)." }) ), - "output_format": Schema.optionalKey( - Schema.Union([BetaJsonOutputFormat, Schema.Null]).annotate({ + "redacted_by": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsActor).annotate({ "description": - "Deprecated: Use `output_config.format` instead. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\nA schema to specify Claude's output format in responses. This parameter will be removed in a future release." + "Who redacted this version, or `null` if it has not been redacted. In practice always an `api_actor` or `user_actor` (agents do not have a redact capability)." }) + ) +}).annotate({ + "description": + "A `memory_version` object: one immutable, attributed row in a memory's append-only history. Every non-no-op mutation to a memory produces a new version. Versions belong to the store (not the individual memory) and persist after the memory is deleted. Retrieving a redacted version returns 200 with `content`, `path`, `content_size_bytes`, and `content_sha256` set to `null`; branch on `redacted_at`, not HTTP status.", + "identifier": "BetaManagedAgentsMemoryVersion" +}) +export type BetaCreateUserProfileRequest = { + readonly "external_id"?: string + readonly "name"?: string + readonly "relationship"?: BetaUserProfileRelationship + readonly "metadata"?: { readonly [x: string]: string } +} +export const BetaCreateUserProfileRequest = Schema.Struct({ + "external_id": Schema.optionalKey( + Schema.String.annotate({ + "description": "Platform's own identifier for this user. Not enforced unique. Maximum 255 characters." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ) ), - "speed": Schema.optionalKey( - Schema.Union([BetaSpeed, Schema.Null]).annotate({ + "name": Schema.optionalKey( + Schema.String.annotate({ "description": - "The inference speed mode for this request. `\"fast\"` enables high output-tokens-per-second inference." + "Display name of the entity this profile represents. Required when relationship is `resold` (the resold-to company's name); optional otherwise. Maximum 255 characters." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ) + ), + "relationship": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaUserProfileRelationship).annotate({ + "description": + "How the entity relates to the platform. `external` (default): an individual end-user. `resold`: a company the platform resells Claude access to. `internal`: the platform's own usage." }) ), - "system": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Array(BetaRequestTextBlock)]).annotate({ - "title": "System", + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ "description": - "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts)." + "Free-form key-value data to attach to this user profile. Maximum 16 keys, with keys up to 64 characters and values up to 512 characters. Values must be non-empty strings." }) + ) +}).annotate({ "identifier": "BetaCreateUserProfileRequest" }) +export type BetaUpdateUserProfileRequestBody = { + readonly "external_id"?: string + readonly "metadata"?: { readonly [x: string]: string } + readonly "name"?: string + readonly "relationship"?: BetaUserProfileRelationship +} +export const BetaUpdateUserProfileRequestBody = Schema.Struct({ + "external_id": Schema.optionalKey( + Schema.String.annotate({ + "description": "If present, replaces the stored external_id. Omit to leave unchanged. Maximum 255 characters." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ) ), - "thinking": Schema.optionalKey(BetaThinkingConfigParam), - "tool_choice": Schema.optionalKey(BetaToolChoice), - "tools": Schema.optionalKey( - Schema.Array( - Schema.Union([ - BetaTool, - BetaBashTool_20241022, - BetaBashTool_20250124, - BetaCodeExecutionTool_20250522, - BetaCodeExecutionTool_20250825, - BetaCodeExecutionTool_20260120, - BetaComputerUseTool_20241022, - BetaMemoryTool_20250818, - BetaComputerUseTool_20250124, - BetaTextEditor_20241022, - BetaComputerUseTool_20251124, - BetaTextEditor_20250124, - BetaTextEditor_20250429, - BetaTextEditor_20250728, - BetaWebSearchTool_20250305, - BetaWebFetchTool_20250910, - BetaWebSearchTool_20260209, - BetaWebFetchTool_20260209, - BetaToolSearchToolBM25_20251119, - BetaToolSearchToolRegex_20251119, - BetaMCPToolset - ], { mode: "oneOf" }) - ).annotate({ - "title": "Tools", + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ "description": - "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview\\#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://docs.claude.com/en/docs/tool-use) for more details." + "Key-value pairs to merge into the stored metadata. Keys provided overwrite existing values. To remove a key, set its value to an empty string. Keys not provided are left unchanged. Maximum 16 keys, with keys up to 64 characters and values up to 512 characters." + }) + ), + "name": Schema.optionalKey( + Schema.String.annotate({ + "description": "If present, replaces the stored name. Omit to leave unchanged. Maximum 255 characters." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ) + ), + "relationship": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaUserProfileRelationship).annotate({ + "description": "If present, replaces the stored relationship. Omit to leave unchanged." }) ) -}).annotate({ "title": "CountMessageTokensParams" }) -export type BetaCreateMessageParams = { - readonly "model": Model - readonly "messages": ReadonlyArray - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "container"?: BetaContainerParams | string | null - readonly "context_management"?: BetaContextManagementConfig | null - readonly "inference_geo"?: string | null - readonly "max_tokens": number - readonly "mcp_servers"?: ReadonlyArray - readonly "metadata"?: { readonly "user_id"?: string | null } - readonly "output_config"?: { - readonly "effort"?: BetaEffortLevel | null - readonly "format"?: BetaJsonOutputFormat | null - } - readonly "output_format"?: BetaJsonOutputFormat | null - readonly "service_tier"?: "auto" | "standard_only" - readonly "speed"?: BetaSpeed | null - readonly "stop_sequences"?: ReadonlyArray - readonly "stream"?: boolean - readonly "system"?: string | ReadonlyArray - readonly "temperature"?: number - readonly "thinking"?: BetaThinkingConfigParam - readonly "tool_choice"?: BetaToolChoice - readonly "tools"?: ReadonlyArray< - | BetaTool - | BetaBashTool_20241022 - | BetaBashTool_20250124 - | BetaCodeExecutionTool_20250522 - | BetaCodeExecutionTool_20250825 - | BetaCodeExecutionTool_20260120 - | BetaComputerUseTool_20241022 - | BetaMemoryTool_20250818 - | BetaComputerUseTool_20250124 - | BetaTextEditor_20241022 - | BetaComputerUseTool_20251124 - | BetaTextEditor_20250124 - | BetaTextEditor_20250429 - | BetaTextEditor_20250728 - | BetaWebSearchTool_20250305 - | BetaWebFetchTool_20250910 - | BetaWebSearchTool_20260209 - | BetaWebFetchTool_20260209 - | BetaToolSearchToolBM25_20251119 - | BetaToolSearchToolRegex_20251119 - | BetaMCPToolset - > - readonly "top_k"?: number - readonly "top_p"?: number -} -export const BetaCreateMessageParams = Schema.Struct({ - "model": Model, - "messages": Schema.Array(BetaInputMessage).annotate({ - "title": "Messages", - "description": - "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://docs.claude.com/en/api/messages-examples).\n\nNote that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." - }), - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", +}).annotate({ "identifier": "BetaUpdateUserProfileRequestBody" }) +export type BetaUserProfile = { + readonly "id": string + readonly "type": "user_profile" + readonly "external_id"?: string + readonly "name"?: string + readonly "relationship": BetaUserProfileRelationship + readonly "trust_grants": { readonly [x: string]: BetaUserProfileTrustGrant } + readonly "created_at": BetaTimestamp + readonly "metadata": { readonly [x: string]: string } + readonly "updated_at": BetaTimestamp +} +export const BetaUserProfile = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique identifier for this user profile, prefixed `uprof_`." }), + "type": Schema.Literal("user_profile").annotate({ "description": "Object type. Always `user_profile`." }), + "external_id": Schema.optionalKey( + Schema.String.annotate({ "description": "Platform's own identifier for this user. Not enforced unique." }) + ), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": - "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." + "Display name of the entity this profile represents. For `resold` this is the resold-to company's name." }) ), - "container": Schema.optionalKey( - Schema.Union([BetaContainerParams, Schema.String, Schema.Null]).annotate({ - "title": "Container", - "description": "Container identifier for reuse across requests." - }) + "relationship": Schema.suspend((): Schema.Codec => BetaUserProfileRelationship).annotate( + { "description": "How the entity relates to the platform. `external` (default), `resold`, or `internal`." } ), - "context_management": Schema.optionalKey( - Schema.Union([BetaContextManagementConfig, Schema.Null]).annotate({ + "trust_grants": Schema.Record(Schema.String, BetaUserProfileTrustGrant).annotate({ + "description": + "Trust grants for this profile, keyed by grant name. Key omitted when no grant is active or in flight." + }), + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When this user profile was created, in RFC 3339 format." + }), + "metadata": Schema.Record(Schema.String, Schema.String).annotate({ + "description": "Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": + "When this user profile was last modified, in RFC 3339 format. Trust-grant status changes also bump this timestamp." + }) +}).annotate({ "identifier": "BetaUserProfile" }) +export type BetaManagedAgentsSpanModelUsage = { + readonly "input_tokens": number + readonly "output_tokens": number + readonly "cache_creation_input_tokens": number + readonly "cache_read_input_tokens": number + readonly "speed"?: BetaManagedAgentsSpeed +} +export const BetaManagedAgentsSpanModelUsage = Schema.Struct({ + "input_tokens": Schema.Number.annotate({ "description": "Input tokens consumed by this request.", "format": "int32" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "output_tokens": Schema.Number.annotate({ + "description": "Output tokens generated by this request.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "cache_creation_input_tokens": Schema.Number.annotate({ + "description": "Tokens used to create prompt cache in this request.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "cache_read_input_tokens": Schema.Number.annotate({ + "description": "Tokens read from prompt cache in this request.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "speed": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsSpeed).annotate({ "description": - "Context management configuration.\n\nThis allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not." + "Inference speed tier this request actually ran at. Mirrors `usage.speed` on /v1/messages. Only present when the fast-mode beta is active." }) - ), - "inference_geo": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Inference Geo", + ) +}).annotate({ + "description": "Token usage for a single model request.", + "identifier": "BetaManagedAgentsSpanModelUsage" +}) +export type BetaManagedAgentsModelConfig = { + readonly "id": BetaManagedAgentsModel + readonly "speed"?: BetaManagedAgentsSpeed + readonly "effort"?: BetaManagedAgentsEffort + readonly "inference_geo"?: string +} +export const BetaManagedAgentsModelConfig = Schema.Struct({ + "id": BetaManagedAgentsModel, + "speed": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsSpeed).annotate({ "description": - "Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used." - }) - ), - "max_tokens": Schema.Number.annotate({ - "title": "Max Tokens", - "description": - "The maximum number of tokens to generate before stopping.\n\nNote that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.\n\nDifferent models have different maximum values for this parameter. See [models](https://docs.claude.com/en/docs/models-overview) for details." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "mcp_servers": Schema.optionalKey( - Schema.Array(BetaRequestMCPServerURLDefinition).annotate({ - "title": "Mcp Servers", - "description": "MCP servers to be utilized in this request" - }).check(Schema.isMaxLength(20)) - ), - "metadata": Schema.optionalKey( - Schema.Struct({ - "user_id": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMaxLength(256)), Schema.Null]).annotate({ - "title": "User Id", - "description": - "An external identifier for the user who is associated with the request.\n\nThis should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number." - }) - ) - }).annotate({ "title": "Metadata", "description": "An object describing metadata about the request." }) - ), - "output_config": Schema.optionalKey( - Schema.Struct({ - "effort": Schema.optionalKey( - Schema.Union([BetaEffortLevel, Schema.Null]).annotate({ - "description": - "How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.\n\nValid values are `low`, `medium`, `high`, or `max`." - }) - ), - "format": Schema.optionalKey( - Schema.Union([BetaJsonOutputFormat, Schema.Null]).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({ - "title": "OutputConfig", - "description": "Configuration options for the model's output, such as the output format." + "Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Defaults to `standard`. Not all models support `fast`; invalid combinations are rejected at create time." }) ), - "output_format": Schema.optionalKey( - Schema.Union([BetaJsonOutputFormat, Schema.Null]).annotate({ + "effort": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsEffort).annotate({ "description": - "Deprecated: Use `output_config.format` instead. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\nA schema to specify Claude's output format in responses. This parameter will be removed in a future release." + "How hard Claude works on each inference call. One of `low`, `medium`, `high`, `xhigh`, `max`. Always present; resolved to the per-model default at save time when not supplied." }) ), - "service_tier": Schema.optionalKey( - Schema.Literals(["auto", "standard_only"]).annotate({ - "title": "Service Tier", + "inference_geo": Schema.optionalKey( + Schema.String.annotate({ "description": - "Determines whether to use priority capacity (if available) or standard capacity for this request.\n\nAnthropic offers different levels of service for your API requests. See [service-tiers](https://docs.claude.com/en/api/service-tiers) for details." + "Geographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo." }) - ), - "speed": Schema.optionalKey( - Schema.Union([BetaSpeed, Schema.Null]).annotate({ - "description": - "The inference speed mode for this request. `\"fast\"` enables high output-tokens-per-second inference." + ) +}).annotate({ "description": "Model identifier and configuration.", "identifier": "BetaManagedAgentsModelConfig" }) +export type BetaManagedAgentsAgentToolsetDefaultConfig = { + readonly "enabled": boolean + readonly "permission_policy": BetaManagedAgentsPermissionPolicy +} +export const BetaManagedAgentsAgentToolsetDefaultConfig = Schema.Struct({ + "enabled": Schema.Boolean, + "permission_policy": BetaManagedAgentsPermissionPolicy +}).annotate({ + "description": "Resolved default configuration for agent tools.", + "identifier": "BetaManagedAgentsAgentToolsetDefaultConfig" +}) +export type BetaManagedAgentsMCPToolsetDefaultConfig = { + readonly "enabled": boolean + readonly "permission_policy": BetaManagedAgentsPermissionPolicy +} +export const BetaManagedAgentsMCPToolsetDefaultConfig = Schema.Struct({ + "enabled": Schema.Boolean, + "permission_policy": BetaManagedAgentsPermissionPolicy +}).annotate({ + "description": "Resolved default configuration for all tools from an MCP server.", + "identifier": "BetaManagedAgentsMCPToolsetDefaultConfig" +}) +export type BetaManagedAgentsMCPToolConfig = { + readonly "name": string + readonly "enabled": boolean + readonly "permission_policy": BetaManagedAgentsPermissionPolicy +} +export const BetaManagedAgentsMCPToolConfig = Schema.Struct({ + "name": Schema.String, + "enabled": Schema.Boolean, + "permission_policy": BetaManagedAgentsPermissionPolicy +}).annotate({ + "description": "Resolved configuration for a specific MCP tool.", + "identifier": "BetaManagedAgentsMCPToolConfig" +}) +export type BetaManagedAgentsAgentToolsetDefaultConfigParams = { + readonly "enabled"?: boolean + readonly "permission_policy"?: BetaManagedAgentsPermissionPolicy +} +export const BetaManagedAgentsAgentToolsetDefaultConfigParams = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Whether tools are enabled and available to Claude by default. Defaults to true if not specified." }) ), - "stop_sequences": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "title": "Stop Sequences", + "permission_policy": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsPermissionPolicy).annotate({ "description": - "Custom text sequences that will cause the model to stop generating.\n\nOur models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `\"end_turn\"`.\n\nIf you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"` and the response `stop_sequence` value will contain the matched stop sequence." + "Default permission policy for tools. Controls whether tool calls are auto-approved or require confirmation." }) - ), - "stream": Schema.optionalKey( + ) +}).annotate({ + "description": "Default configuration for all tools in a toolset.", + "identifier": "BetaManagedAgentsAgentToolsetDefaultConfigParams" +}) +export type BetaManagedAgentsMCPToolsetDefaultConfigParams = { + readonly "enabled"?: boolean + readonly "permission_policy"?: BetaManagedAgentsPermissionPolicy +} +export const BetaManagedAgentsMCPToolsetDefaultConfigParams = Schema.Struct({ + "enabled": Schema.optionalKey( Schema.Boolean.annotate({ - "title": "Stream", - "description": - "Whether to incrementally stream the response using server-sent events.\n\nSee [streaming](https://docs.claude.com/en/api/messages-streaming) for details." + "description": "Whether tools are enabled by default. Defaults to true if not specified." }) ), - "system": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Array(BetaRequestTextBlock)]).annotate({ - "title": "System", - "description": - "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts)." + "permission_policy": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsPermissionPolicy).annotate({ + "description": "Default permission policy for tools from this server." }) + ) +}).annotate({ + "description": "Default configuration for all tools from an MCP server.", + "identifier": "BetaManagedAgentsMCPToolsetDefaultConfigParams" +}) +export type BetaManagedAgentsMCPToolConfigParams = { + readonly "name": string + readonly "enabled"?: boolean + readonly "permission_policy"?: BetaManagedAgentsPermissionPolicy +} +export const BetaManagedAgentsMCPToolConfigParams = Schema.Struct({ + "name": Schema.String.annotate({ "description": "Name of the MCP tool to configure. 1-128 characters." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this tool is enabled. Overrides the `default_config` setting." }) ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Temperature", - "description": - "Amount of randomness injected into the response.\n\nDefaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.\n\nNote that even with `temperature` of `0.0`, the results will not be fully deterministic." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) - ), - "thinking": Schema.optionalKey(BetaThinkingConfigParam), - "tool_choice": Schema.optionalKey(BetaToolChoice), - "tools": Schema.optionalKey( - Schema.Array( - Schema.Union([ - BetaTool, - BetaBashTool_20241022, - BetaBashTool_20250124, - BetaCodeExecutionTool_20250522, - BetaCodeExecutionTool_20250825, - BetaCodeExecutionTool_20260120, - BetaComputerUseTool_20241022, - BetaMemoryTool_20250818, - BetaComputerUseTool_20250124, - BetaTextEditor_20241022, - BetaComputerUseTool_20251124, - BetaTextEditor_20250124, - BetaTextEditor_20250429, - BetaTextEditor_20250728, - BetaWebSearchTool_20250305, - BetaWebFetchTool_20250910, - BetaWebSearchTool_20260209, - BetaWebFetchTool_20260209, - BetaToolSearchToolBM25_20251119, - BetaToolSearchToolRegex_20251119, - BetaMCPToolset - ], { mode: "oneOf" }) - ).annotate({ - "title": "Tools", - "description": - "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview\\#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://docs.claude.com/en/docs/tool-use) for more details." + "permission_policy": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsPermissionPolicy).annotate({ + "description": "Permission policy for this tool. Overrides the `default_config` setting." + }) + ) +}).annotate({ + "description": "Configuration override for a specific MCP tool.", + "identifier": "BetaManagedAgentsMCPToolConfigParams" +}) +export type BetaManagedAgentsAgentToolConfig = { + readonly "name": BetaManagedAgentsAgentToolName + readonly "enabled": boolean + readonly "permission_policy": BetaManagedAgentsPermissionPolicy +} +export const BetaManagedAgentsAgentToolConfig = Schema.Struct({ + "name": BetaManagedAgentsAgentToolName, + "enabled": Schema.Boolean, + "permission_policy": BetaManagedAgentsPermissionPolicy +}).annotate({ + "description": "Configuration for a specific agent tool.", + "identifier": "BetaManagedAgentsAgentToolConfig" +}) +export type BetaManagedAgentsAgentToolConfigParams = { + readonly "name": BetaManagedAgentsAgentToolName + readonly "enabled"?: boolean + readonly "permission_policy"?: BetaManagedAgentsPermissionPolicy +} +export const BetaManagedAgentsAgentToolConfigParams = Schema.Struct({ + "name": BetaManagedAgentsAgentToolName, + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Whether this tool is enabled and available to Claude. Overrides the default_config setting." }) ), - "top_k": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top K", - "description": - "Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) - ), - "top_p": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top P", + "permission_policy": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsPermissionPolicy).annotate({ "description": - "Use nucleus sampling.\n\nIn nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both.\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) + "Permission policy for this tool. Controls whether tool calls are auto-approved or require confirmation." + }) ) -}).annotate({ "title": "CreateMessageParams" }) -export type BetaMessageBatchIndividualRequestParams = { - readonly "custom_id": string - readonly "params": { - readonly "model": Model - readonly "messages": ReadonlyArray - readonly "cache_control"?: BetaCacheControlEphemeral | null - readonly "container"?: BetaContainerParams | string | null - readonly "context_management"?: BetaContextManagementConfig | null - readonly "inference_geo"?: string | null - readonly "max_tokens": number - readonly "mcp_servers"?: ReadonlyArray - readonly "metadata"?: { readonly "user_id"?: string | null } - readonly "output_config"?: { - readonly "effort"?: BetaEffortLevel | null - readonly "format"?: BetaJsonOutputFormat | null - } - readonly "output_format"?: BetaJsonOutputFormat | null - readonly "service_tier"?: "auto" | "standard_only" - readonly "speed"?: BetaSpeed | null - readonly "stop_sequences"?: ReadonlyArray - readonly "stream"?: boolean - readonly "system"?: string | ReadonlyArray - readonly "temperature"?: number - readonly "thinking"?: BetaThinkingConfigParam - readonly "tool_choice"?: BetaToolChoice - readonly "tools"?: ReadonlyArray< - | BetaTool - | BetaBashTool_20241022 - | BetaBashTool_20250124 - | BetaCodeExecutionTool_20250522 - | BetaCodeExecutionTool_20250825 - | BetaCodeExecutionTool_20260120 - | BetaComputerUseTool_20241022 - | BetaMemoryTool_20250818 - | BetaComputerUseTool_20250124 - | BetaTextEditor_20241022 - | BetaComputerUseTool_20251124 - | BetaTextEditor_20250124 - | BetaTextEditor_20250429 - | BetaTextEditor_20250728 - | BetaWebSearchTool_20250305 - | BetaWebFetchTool_20250910 - | BetaWebSearchTool_20260209 - | BetaWebFetchTool_20260209 - | BetaToolSearchToolBM25_20251119 - | BetaToolSearchToolRegex_20251119 - | BetaMCPToolset - > - readonly "top_k"?: number - readonly "top_p"?: number - } +}).annotate({ + "description": "Configuration override for a specific tool within a toolset.", + "identifier": "BetaManagedAgentsAgentToolConfigParams" +}) +export type BetaManagedAgentsSkill = BetaManagedAgentsAnthropicSkill | BetaManagedAgentsCustomSkill +export const BetaManagedAgentsSkill = Schema.Union([BetaManagedAgentsAnthropicSkill, BetaManagedAgentsCustomSkill], { + mode: "oneOf" +}).annotate({ "description": "Resolved skill as returned in API responses.", "identifier": "BetaManagedAgentsSkill" }) +export type BetaManagedAgentsSessionResource = { + readonly "type": "github_repository" + readonly "id": string + readonly "url": string + readonly "mount_path": string + readonly "checkout"?: BetaManagedAgentsRepositoryCheckout + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp +} | { + readonly "type": "file" + readonly "id": string + readonly "file_id": string + readonly "mount_path": string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp +} | { + readonly "type": "memory_store" + readonly "memory_store_id": string + readonly "access"?: BetaManagedAgentsMountMode + readonly "name"?: string + readonly "description"?: string + readonly "instructions"?: string + readonly "mount_path"?: string } -export const BetaMessageBatchIndividualRequestParams = Schema.Struct({ - "custom_id": Schema.String.annotate({ - "title": "Custom Id", - "description": - "Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.\n\nMust be unique for each request within the Message Batch." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)).check( - Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$")) - ), - "params": Schema.Struct({ - "model": Model, - "messages": Schema.Array(BetaInputMessage).annotate({ - "title": "Messages", - "description": - "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://docs.claude.com/en/api/messages-examples).\n\nNote that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." +export const BetaManagedAgentsSessionResource = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("github_repository"), + "id": Schema.String, + "url": Schema.String, + "mount_path": Schema.String, + "checkout": Schema.optionalKey(BetaManagedAgentsRepositoryCheckout), + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp + }), + Schema.Struct({ + "type": Schema.Literal("file"), + "id": Schema.String, + "file_id": Schema.String, + "mount_path": Schema.String, + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp + }), + Schema.Struct({ + "type": Schema.Literal("memory_store"), + "memory_store_id": Schema.String.annotate({ + "description": "The memory store ID (memstore_...). Must belong to the caller's organization and workspace." }), - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", + "access": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsMountMode).annotate({ "description": - "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." + "Access mode for the mounted store. Defaults to read_write. read_only mounts the store as a read-only filesystem." }) ), - "container": Schema.optionalKey( - Schema.Union([BetaContainerParams, Schema.String, Schema.Null]).annotate({ - "title": "Container", - "description": "Container identifier for reuse across requests." - }) - ), - "context_management": Schema.optionalKey( - Schema.Union([BetaContextManagementConfig, Schema.Null]).annotate({ + "name": Schema.optionalKey( + Schema.String.annotate({ "description": - "Context management configuration.\n\nThis allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not." + "Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource." }) ), - "inference_geo": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Inference Geo", + "description": Schema.optionalKey( + Schema.String.annotate({ "description": - "Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used." + "Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description." }) ), - "max_tokens": Schema.Number.annotate({ - "title": "Max Tokens", - "description": - "The maximum number of tokens to generate before stopping.\n\nNote that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.\n\nDifferent models have different maximum values for this parameter. See [models](https://docs.claude.com/en/docs/models-overview) for details." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "mcp_servers": Schema.optionalKey( - Schema.Array(BetaRequestMCPServerURLDefinition).annotate({ - "title": "Mcp Servers", - "description": "MCP servers to be utilized in this request" - }).check(Schema.isMaxLength(20)) - ), - "metadata": Schema.optionalKey( - Schema.Struct({ - "user_id": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMaxLength(256)), Schema.Null]).annotate({ - "title": "User Id", - "description": - "An external identifier for the user who is associated with the request.\n\nThis should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number." - }) - ) - }).annotate({ "title": "Metadata", "description": "An object describing metadata about the request." }) - ), - "output_config": Schema.optionalKey( - Schema.Struct({ - "effort": Schema.optionalKey( - Schema.Union([BetaEffortLevel, Schema.Null]).annotate({ - "description": - "How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.\n\nValid values are `low`, `medium`, `high`, or `max`." - }) - ), - "format": Schema.optionalKey( - Schema.Union([BetaJsonOutputFormat, Schema.Null]).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({ - "title": "OutputConfig", - "description": "Configuration options for the model's output, such as the output format." - }) + "instructions": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars." + }).check(Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" })) ), - "output_format": Schema.optionalKey( - Schema.Union([BetaJsonOutputFormat, Schema.Null]).annotate({ + "mount_path": Schema.optionalKey( + Schema.String.annotate({ "description": - "Deprecated: Use `output_config.format` instead. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\nA schema to specify Claude's output format in responses. This parameter will be removed in a future release." + "Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only." }) + ) + }).annotate({ "description": "A memory store attached to an agent session." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsSessionResource" }) +export type BetaManagedAgentsSessionResourceParams = + | { + readonly "type": "github_repository" + readonly "url": string + readonly "authorization_token": string + readonly "mount_path"?: string + readonly "checkout"?: BetaManagedAgentsRepositoryCheckout + } + | { readonly "type": "file"; readonly "file_id": string; readonly "mount_path"?: string } + | { + readonly "type": "memory_store" + readonly "memory_store_id": string + readonly "access"?: BetaManagedAgentsMountMode + readonly "instructions"?: string + } +export const BetaManagedAgentsSessionResourceParams = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("github_repository"), + "url": Schema.String.annotate({ "description": "Github URL of the repository" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" })), + "authorization_token": Schema.String.annotate({ + "description": "GitHub authorization token used to clone the repository." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" }) ), - "service_tier": Schema.optionalKey( - Schema.Literals(["auto", "standard_only"]).annotate({ - "title": "Service Tier", + "mount_path": Schema.optionalKey( + Schema.String.annotate({ "description": "Mount path in the container. Defaults to `/workspace/`." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" }) + ) + ), + "checkout": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsRepositoryCheckout) + .annotate({ "description": "Branch or commit to check out. Defaults to the repository's default branch." }) + ) + }).annotate({ "description": "Union of resources that can be mounted into a session." }), + Schema.Struct({ + "type": Schema.Literal("file"), + "file_id": Schema.String.annotate({ "description": "ID of a previously uploaded file." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })), + "mount_path": Schema.optionalKey( + Schema.String.annotate({ + "description": "Mount path in the container. Defaults to `/mnt/session/uploads/`." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" }) + ) + ) + }).annotate({ "description": "Union of resources that can be mounted into a session." }), + Schema.Struct({ + "type": Schema.Literal("memory_store"), + "memory_store_id": Schema.String.annotate({ + "description": "The memory store ID (memstore_...). Must belong to the caller's organization and workspace." + }), + "access": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsMountMode).annotate({ "description": - "Determines whether to use priority capacity (if available) or standard capacity for this request.\n\nAnthropic offers different levels of service for your API requests. See [service-tiers](https://docs.claude.com/en/api/service-tiers) for details." + "Access mode for the mounted store. Defaults to read_write. read_only mounts the store as a read-only filesystem." }) ), - "speed": Schema.optionalKey( - Schema.Union([BetaSpeed, Schema.Null]).annotate({ + "instructions": Schema.optionalKey( + Schema.String.annotate({ "description": - "The inference speed mode for this request. `\"fast\"` enables high output-tokens-per-second inference." + "Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars." + }).check(Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" })) + ) + }).annotate({ "description": "Union of resources that can be mounted into a session." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsSessionResourceParams" }) +export type BetaManagedAgentsGetSessionResource = { + readonly "type": "github_repository" + readonly "id": string + readonly "url": string + readonly "mount_path": string + readonly "checkout"?: BetaManagedAgentsRepositoryCheckout + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp +} | { + readonly "type": "file" + readonly "id": string + readonly "file_id": string + readonly "mount_path": string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp +} | { + readonly "type": "memory_store" + readonly "memory_store_id": string + readonly "access"?: BetaManagedAgentsMountMode + readonly "name"?: string + readonly "description"?: string + readonly "instructions"?: string + readonly "mount_path"?: string +} +export const BetaManagedAgentsGetSessionResource = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("github_repository"), + "id": Schema.String, + "url": Schema.String, + "mount_path": Schema.String, + "checkout": Schema.optionalKey(BetaManagedAgentsRepositoryCheckout), + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp + }).annotate({ "description": "The requested session resource." }), + Schema.Struct({ + "type": Schema.Literal("file"), + "id": Schema.String, + "file_id": Schema.String, + "mount_path": Schema.String, + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp + }).annotate({ "description": "The requested session resource." }), + Schema.Struct({ + "type": Schema.Literal("memory_store"), + "memory_store_id": Schema.String.annotate({ + "description": "The memory store ID (memstore_...). Must belong to the caller's organization and workspace." + }), + "access": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsMountMode).annotate({ + "description": + "Access mode for the mounted store. Defaults to read_write. read_only mounts the store as a read-only filesystem." }) ), - "stop_sequences": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "title": "Stop Sequences", + "name": Schema.optionalKey( + Schema.String.annotate({ "description": - "Custom text sequences that will cause the model to stop generating.\n\nOur models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `\"end_turn\"`.\n\nIf you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"` and the response `stop_sequence` value will contain the matched stop sequence." + "Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource." }) ), - "stream": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Stream", + "description": Schema.optionalKey( + Schema.String.annotate({ "description": - "Whether to incrementally stream the response using server-sent events.\n\nSee [streaming](https://docs.claude.com/en/api/messages-streaming) for details." + "Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description." }) ), - "system": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Array(BetaRequestTextBlock)]).annotate({ - "title": "System", + "instructions": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars." + }).check(Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" })) + ), + "mount_path": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only." + }) + ) + }).annotate({ "description": "The requested session resource." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsGetSessionResource" }) +export type BetaManagedAgentsUpdateSessionResource = { + readonly "type": "github_repository" + readonly "id": string + readonly "url": string + readonly "mount_path": string + readonly "checkout"?: BetaManagedAgentsRepositoryCheckout + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp +} | { + readonly "type": "file" + readonly "id": string + readonly "file_id": string + readonly "mount_path": string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp +} | { + readonly "type": "memory_store" + readonly "memory_store_id": string + readonly "access"?: BetaManagedAgentsMountMode + readonly "name"?: string + readonly "description"?: string + readonly "instructions"?: string + readonly "mount_path"?: string +} +export const BetaManagedAgentsUpdateSessionResource = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("github_repository"), + "id": Schema.String, + "url": Schema.String, + "mount_path": Schema.String, + "checkout": Schema.optionalKey(BetaManagedAgentsRepositoryCheckout), + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp + }).annotate({ "description": "The updated session resource." }), + Schema.Struct({ + "type": Schema.Literal("file"), + "id": Schema.String, + "file_id": Schema.String, + "mount_path": Schema.String, + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp + }).annotate({ "description": "The updated session resource." }), + Schema.Struct({ + "type": Schema.Literal("memory_store"), + "memory_store_id": Schema.String.annotate({ + "description": "The memory store ID (memstore_...). Must belong to the caller's organization and workspace." + }), + "access": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsMountMode).annotate({ "description": - "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts)." + "Access mode for the mounted store. Defaults to read_write. read_only mounts the store as a read-only filesystem." }) ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Temperature", + "name": Schema.optionalKey( + Schema.String.annotate({ "description": - "Amount of randomness injected into the response.\n\nDefaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.\n\nNote that even with `temperature` of `0.0`, the results will not be fully deterministic." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) + "Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource." + }) ), - "thinking": Schema.optionalKey(BetaThinkingConfigParam), - "tool_choice": Schema.optionalKey(BetaToolChoice), - "tools": Schema.optionalKey( - Schema.Array( - Schema.Union([ - BetaTool, - BetaBashTool_20241022, - BetaBashTool_20250124, - BetaCodeExecutionTool_20250522, - BetaCodeExecutionTool_20250825, - BetaCodeExecutionTool_20260120, - BetaComputerUseTool_20241022, - BetaMemoryTool_20250818, - BetaComputerUseTool_20250124, - BetaTextEditor_20241022, - BetaComputerUseTool_20251124, - BetaTextEditor_20250124, - BetaTextEditor_20250429, - BetaTextEditor_20250728, - BetaWebSearchTool_20250305, - BetaWebFetchTool_20250910, - BetaWebSearchTool_20260209, - BetaWebFetchTool_20260209, - BetaToolSearchToolBM25_20251119, - BetaToolSearchToolRegex_20251119, - BetaMCPToolset - ], { mode: "oneOf" }) - ).annotate({ - "title": "Tools", + "description": Schema.optionalKey( + Schema.String.annotate({ "description": - "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview\\#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://docs.claude.com/en/docs/tool-use) for more details." + "Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description." }) ), - "top_k": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top K", + "instructions": Schema.optionalKey( + Schema.String.annotate({ "description": - "Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) + "Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars." + }).check(Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" })) ), - "top_p": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top P", + "mount_path": Schema.optionalKey( + Schema.String.annotate({ "description": - "Use nucleus sampling.\n\nIn nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both.\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) + "Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only." + }) ) - }).annotate({ - "title": "CreateMessageParams", + }).annotate({ "description": "The updated session resource." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsUpdateSessionResource" }) +export type BetaManagedAgentsSessionResourceConfig = + | { + readonly "type": "github_repository" + readonly "url": string + readonly "mount_path"?: string + readonly "checkout"?: BetaManagedAgentsRepositoryCheckout + } + | { readonly "type": "file"; readonly "file_id": string; readonly "mount_path"?: string } + | { + readonly "type": "memory_store" + readonly "memory_store_id": string + readonly "access"?: BetaManagedAgentsMountMode + readonly "instructions"?: string + } +export const BetaManagedAgentsSessionResourceConfig = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("github_repository"), + "url": Schema.String.annotate({ "description": "Github URL of the repository" }), + "mount_path": Schema.optionalKey( + Schema.String.annotate({ "description": "Mount path in the container. Defaults to `/workspace/`." }) + ), + "checkout": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsRepositoryCheckout) + .annotate({ "description": "Branch or commit to check out. Defaults to the repository's default branch." }) + ) + }).annotate({ "description": "A configured session resource. Echoes the input minus write-only credentials." }), + Schema.Struct({ + "type": Schema.Literal("file"), + "file_id": Schema.String.annotate({ "description": "ID of a previously uploaded file." }), + "mount_path": Schema.optionalKey( + Schema.String.annotate({ + "description": "Mount path in the container. Defaults to `/mnt/session/uploads/`." + }) + ) + }).annotate({ "description": "A configured session resource. Echoes the input minus write-only credentials." }), + Schema.Struct({ + "type": Schema.Literal("memory_store"), + "memory_store_id": Schema.String.annotate({ + "description": "The memory store ID (memstore_...). Must belong to the caller's organization and workspace." + }), + "access": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsMountMode).annotate({ + "description": + "Access mode for the mounted store. Defaults to read_write. read_only mounts the store as a read-only filesystem." + }) + ), + "instructions": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars." + }) + ) + }).annotate({ "description": "A configured session resource. Echoes the input minus write-only credentials." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsSessionResourceConfig" }) +export type BetaMonetaryAmount = { readonly "currency": BetaCurrency; readonly "amount": string } +export const BetaMonetaryAmount = Schema.Struct({ + "currency": Schema.suspend((): Schema.Codec => BetaCurrency).annotate({ "description": - "Messages API creation parameters for the individual request.\n\nSee the [Messages API reference](https://docs.claude.com/en/api/messages) for full documentation on available parameters." + "Uppercase ISO-4217 currency code. `USD` is the only currency currently supported; the accepted set is closed and grows only when a new currency is priced." + }), + "amount": Schema.String.annotate({ + "description": + "Amount in minor units of the currency, as an integer decimal string with no leading zeros: \"2500\" is $25.00 and \"50\" is fifty cents. A string rather than a number so no float rounding is ever applied." }) -}).annotate({ "title": "MessageBatchIndividualRequestParams" }) -export type CountMessageTokensParams = { - readonly "cache_control"?: CacheControlEphemeral | null - readonly "messages": ReadonlyArray - readonly "model": Model - readonly "output_config"?: { readonly "effort"?: EffortLevel | null; readonly "format"?: JsonOutputFormat | null } - readonly "system"?: string | ReadonlyArray - readonly "thinking"?: ThinkingConfigParam - readonly "tool_choice"?: ToolChoice - readonly "tools"?: ReadonlyArray< - | Tool - | BashTool_20250124 - | CodeExecutionTool_20250522 - | CodeExecutionTool_20250825 - | CodeExecutionTool_20260120 - | MemoryTool_20250818 - | TextEditor_20250124 - | TextEditor_20250429 - | TextEditor_20250728 - | WebSearchTool_20250305 - | WebFetchTool_20250910 - | WebSearchTool_20260209 - | WebFetchTool_20260209 - | ToolSearchToolBM25_20251119 - | ToolSearchToolRegex_20251119 - > +}).annotate({ "description": "A monetary amount in a specific currency.", "identifier": "BetaMonetaryAmount" }) +export type BetaManagedAgentsAgentUnionParams = string | BetaManagedAgentsAgentParams +export const BetaManagedAgentsAgentUnionParams = Schema.Union([ + Schema.String, + Schema.Union([BetaManagedAgentsAgentParams], { mode: "oneOf" }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsAgentUnionParams" }) +export type BetaManagedAgentsEffortParams = BetaManagedAgentsEffortLevel | BetaManagedAgentsEffort +export const BetaManagedAgentsEffortParams = Schema.Union([BetaManagedAgentsEffortLevel, BetaManagedAgentsEffort], { + mode: "oneOf" +}).annotate({ "identifier": "BetaManagedAgentsEffortParams" }) +export type BetaManagedAgentsSkillParams = BetaManagedAgentsAnthropicSkillParams | BetaManagedAgentsCustomSkillParams +export const BetaManagedAgentsSkillParams = Schema.Union([ + BetaManagedAgentsAnthropicSkillParams, + BetaManagedAgentsCustomSkillParams +], { mode: "oneOf" }).annotate({ + "description": "Skill to load in the session container.", + "identifier": "BetaManagedAgentsSkillParams" +}) +export type BetaManagedAgentsUserContentBlock = { readonly "type": "text"; readonly "text": string } | { + readonly "type": "image" + readonly "source": BetaManagedAgentsImageSource +} | { + readonly "type": "document" + readonly "source": BetaManagedAgentsDocumentSource + readonly "title"?: string + readonly "context"?: string +} | { readonly "type": "redacted" } +export const BetaManagedAgentsUserContentBlock = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String.annotate({ "description": "The text content." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ "description": "Content block in a user message. Can be `text`, `image`, or `document`." }), + Schema.Struct({ + "type": Schema.Literal("image"), + "source": Schema.suspend((): Schema.Codec => BetaManagedAgentsImageSource).annotate({ + "description": "The source of the image data." + }) + }).annotate({ "description": "Content block in a user message. Can be `text`, `image`, or `document`." }), + Schema.Struct({ + "type": Schema.Literal("document"), + "source": Schema.suspend((): Schema.Codec => BetaManagedAgentsDocumentSource) + .annotate({ "description": "The source of the document data." }), + "title": Schema.optionalKey(Schema.String.annotate({ "description": "The title of the document." })), + "context": Schema.optionalKey( + Schema.String.annotate({ "description": "Additional context about the document for the model." }) + ) + }).annotate({ "description": "Content block in a user message. Can be `text`, `image`, or `document`." }), + Schema.Struct({ "type": Schema.Literal("redacted") }).annotate({ + "description": "Content block in a user message. Can be `text`, `image`, or `document`." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsUserContentBlock" }) +export type BetaManagedAgentsRubricParams = BetaManagedAgentsFileRubricParams | BetaManagedAgentsTextRubricParams +export const BetaManagedAgentsRubricParams = Schema.Union([ + BetaManagedAgentsFileRubricParams, + BetaManagedAgentsTextRubricParams +], { mode: "oneOf" }).annotate({ + "description": "Rubric for grading the quality of an outcome.", + "identifier": "BetaManagedAgentsRubricParams" +}) +export type BetaManagedAgentsToolResultContentBlock = { readonly "type": "text"; readonly "text": string } | { + readonly "type": "image" + readonly "source": BetaManagedAgentsImageSource +} | { + readonly "type": "document" + readonly "source": BetaManagedAgentsDocumentSource + readonly "title"?: string + readonly "context"?: string +} | { + readonly "type": "search_result" + readonly "source": string + readonly "title": string + readonly "content": ReadonlyArray + readonly "citations": BetaManagedAgentsSearchResultCitations } -export const CountMessageTokensParams = Schema.Struct({ - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": - "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." +export const BetaManagedAgentsToolResultContentBlock = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("text"), + "text": Schema.String.annotate({ "description": "The text content." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }).annotate({ + "description": "Content block in a tool result. Can be `text`, `image`, `document`, or `search_result`." + }), + Schema.Struct({ + "type": Schema.Literal("image"), + "source": Schema.suspend((): Schema.Codec => BetaManagedAgentsImageSource).annotate({ + "description": "The source of the image data." }) + }).annotate({ + "description": "Content block in a tool result. Can be `text`, `image`, `document`, or `search_result`." + }), + Schema.Struct({ + "type": Schema.Literal("document"), + "source": Schema.suspend((): Schema.Codec => BetaManagedAgentsDocumentSource) + .annotate({ "description": "The source of the document data." }), + "title": Schema.optionalKey(Schema.String.annotate({ "description": "The title of the document." })), + "context": Schema.optionalKey( + Schema.String.annotate({ "description": "Additional context about the document for the model." }) + ) + }).annotate({ + "description": "Content block in a tool result. Can be `text`, `image`, `document`, or `search_result`." + }), + Schema.Struct({ + "type": Schema.Literal("search_result"), + "source": Schema.String.annotate({ "description": "The URL source of the search result." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "title": Schema.String.annotate({ "description": "The title of the search result." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "content": Schema.Array(BetaManagedAgentsSearchResultContent).annotate({ + "description": "Array of text content blocks from the search result." + }), + "citations": Schema.suspend((): Schema.Codec => + BetaManagedAgentsSearchResultCitations + ).annotate({ "description": "Citation settings for this search result." }) + }).annotate({ + "description": "Content block in a tool result. Can be `text`, `image`, `document`, or `search_result`." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsToolResultContentBlock" }) +export type BetaManagedAgentsRubric = BetaManagedAgentsFileRubric | BetaManagedAgentsTextRubric +export const BetaManagedAgentsRubric = Schema.Union([BetaManagedAgentsFileRubric, BetaManagedAgentsTextRubric], { + mode: "oneOf" +}).annotate({ "description": "Rubric for grading the quality of an outcome.", "identifier": "BetaManagedAgentsRubric" }) +export type BetaManagedAgentsEventDeltaEvent_Delta = { + readonly "type": "content_delta" + readonly "index"?: number + readonly "content": BetaManagedAgentsTextBlock +} +export const BetaManagedAgentsEventDeltaEvent_Delta = Schema.Union([Schema.Struct({ + "type": Schema.Literal("content_delta"), + "index": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Which entry in the previewed event's content array this fragment lands in. Insert content as that entry when the index is new; append to the existing entry otherwise.", + "format": "uint32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "messages": Schema.Array(InputMessage).annotate({ - "title": "Messages", + "content": Schema.suspend((): Schema.Codec => BetaManagedAgentsTextBlock).annotate({ "description": - "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://docs.claude.com/en/api/messages-examples).\n\nNote that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." + "A partial element of the content array at index, typed like the element itself — the same shape the buffered agent.message carries in content." + }) +})], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsEventDeltaEvent_Delta" }) +export type BetaManagedAgentsMultiagentRosterEntry = BetaManagedAgentsAgentReference | BetaManagedAgentsAdvisor +export const BetaManagedAgentsMultiagentRosterEntry = Schema.Union([ + BetaManagedAgentsAgentReference, + BetaManagedAgentsAdvisor +], { mode: "oneOf" }).annotate({ + "description": "A resolved multiagent roster entry.", + "identifier": "BetaManagedAgentsMultiagentRosterEntry" +}) +export type BetaManagedAgentsMultiagentRosterEntryParams = + | string + | BetaManagedAgentsAgentParams + | BetaManagedAgentsMultiagentSelfParams + | BetaManagedAgentsAdvisorParams +export const BetaManagedAgentsMultiagentRosterEntryParams = Schema.Union([ + Schema.String, + Schema.Union([BetaManagedAgentsAgentParams, BetaManagedAgentsMultiagentSelfParams, BetaManagedAgentsAdvisorParams], { + mode: "oneOf" + }) +], { mode: "oneOf" }).annotate({ + "description": "An entry in a multiagent roster: an agent ID string, a versioned agent reference, or `self`.", + "identifier": "BetaManagedAgentsMultiagentRosterEntryParams" +}) +export type BetaManagedAgentsDeploymentPausedReason = { readonly "type": "manual" } | { + readonly "type": "error" + readonly "error": BetaManagedAgentsDeploymentPausedReasonError +} +export const BetaManagedAgentsDeploymentPausedReason = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("manual") }).annotate({ + "description": "Why a deployment is paused. Non-null exactly when `status` is `paused`." }), - "model": Model, - "output_config": Schema.optionalKey( - Schema.Struct({ - "effort": Schema.optionalKey( - Schema.Union([EffortLevel, Schema.Null]).annotate({ - "description": - "How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.\n\nValid values are `low`, `medium`, `high`, or `max`." - }) - ), - "format": Schema.optionalKey( - Schema.Union([JsonOutputFormat, Schema.Null]).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({ - "title": "OutputConfig", - "description": "Configuration options for the model's output, such as the output format." + Schema.Struct({ + "type": Schema.Literal("error"), + "error": Schema.suspend((): Schema.Codec => + BetaManagedAgentsDeploymentPausedReasonError + ).annotate({ "description": "The failed run's error." }) + }).annotate({ "description": "Why a deployment is paused. Non-null exactly when `status` is `paused`." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsDeploymentPausedReason" }) +export type BetaManagedAgentsCredentialAuth = + | { + readonly "type": "mcp_oauth" + readonly "mcp_server_url": string + readonly "expires_at"?: BetaTimestamp + readonly "refresh"?: BetaManagedAgentsMcpOauthRefreshResponse + } + | { readonly "type": "static_bearer"; readonly "mcp_server_url": string } + | { + readonly "type": "environment_variable" + readonly "secret_name": string + readonly "networking": BetaManagedAgentsCredentialNetworkingResponse + readonly "injection_location": BetaManagedAgentsInjectionLocationResponse + } +export const BetaManagedAgentsCredentialAuth = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("mcp_oauth"), + "mcp_server_url": Schema.String.annotate({ + "description": "URL of the MCP server this credential authenticates against." + }), + "expires_at": Schema.optionalKey(BetaTimestamp), + "refresh": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsMcpOauthRefreshResponse + ).annotate({ "description": "Refresh token configuration, if the credential supports token refresh." }) + ) + }).annotate({ "description": "Authentication details for a credential." }), + Schema.Struct({ + "type": Schema.Literal("static_bearer"), + "mcp_server_url": Schema.String.annotate({ + "description": "URL of the MCP server this credential authenticates against." }) - ), - "system": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Array(RequestTextBlock)]).annotate({ - "title": "System", + }).annotate({ "description": "Authentication details for a credential." }), + Schema.Struct({ + "type": Schema.Literal("environment_variable"), + "secret_name": Schema.String.annotate({ "description": "Name of the environment variable." }), + "networking": Schema.suspend((): Schema.Codec => + BetaManagedAgentsCredentialNetworkingResponse + ).annotate({ "description": "Outbound hosts the secret value is substituted on." }), + "injection_location": Schema.suspend((): Schema.Codec => + BetaManagedAgentsInjectionLocationResponse + ).annotate({ "description": "Where in the outbound request the secret value is substituted." }) + }).annotate({ "description": "Authentication details for a credential." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsCredentialAuth" }) +export type BetaManagedAgentsCredentialCreateAuth = + | { + readonly "type": "mcp_oauth" + readonly "mcp_server_url": string + readonly "access_token": string + readonly "expires_at"?: BetaTimestamp + readonly "refresh"?: BetaManagedAgentsMcpOauthRefreshParams + } + | { readonly "type": "static_bearer"; readonly "token": string; readonly "mcp_server_url": string } + | { + readonly "type": "environment_variable" + readonly "secret_name": string + readonly "secret_value": string + readonly "networking": BetaManagedAgentsCredentialNetworkingParams + readonly "injection_location"?: BetaManagedAgentsInjectionLocationParams + } +export const BetaManagedAgentsCredentialCreateAuth = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("mcp_oauth"), + "mcp_server_url": Schema.String.annotate({ + "description": "URL of the MCP server this credential authenticates against." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2047).annotate({ "expected": "a value with a length of at most 2047" }) + ), + "access_token": Schema.String.annotate({ "description": "OAuth access token." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(8192).annotate({ "expected": "a value with a length of at most 8192" })), + "expires_at": Schema.optionalKey(BetaTimestamp), + "refresh": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsMcpOauthRefreshParams) + .annotate({ "description": "Refresh token configuration, if the credential supports token refresh." }) + ) + }).annotate({ "description": "Authentication details for creating a credential." }), + Schema.Struct({ + "type": Schema.Literal("static_bearer"), + "token": Schema.String.annotate({ "description": "Static bearer token value." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(8192).annotate({ "expected": "a value with a length of at most 8192" })), + "mcp_server_url": Schema.String.annotate({ + "description": "URL of the MCP server this credential authenticates against." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2047).annotate({ "expected": "a value with a length of at most 2047" }) + ) + }).annotate({ "description": "Authentication details for creating a credential." }), + Schema.Struct({ + "type": Schema.Literal("environment_variable"), + "secret_name": Schema.String.annotate({ + "description": "Name of the environment variable. Immutable after create." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + "secret_value": Schema.String.annotate({ "description": "Secret value. Write-only; never returned in responses." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" }) + ), + "networking": Schema.suspend((): Schema.Codec => + BetaManagedAgentsCredentialNetworkingParams + ).annotate({ "description": "Outbound hosts the secret value is substituted on." }), + "injection_location": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsInjectionLocationParams + ).annotate({ "description": "Where in the outbound request the secret value may be substituted." }) + ) + }).annotate({ "description": "Authentication details for creating a credential." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsCredentialCreateAuth" }) +export type BetaManagedAgentsCredentialUpdateAuth = + | { + readonly "type": "mcp_oauth" + readonly "access_token"?: string + readonly "expires_at"?: BetaTimestamp + readonly "refresh"?: BetaManagedAgentsMcpOauthRefreshUpdateParams + } + | { readonly "type": "static_bearer"; readonly "token"?: string } + | { + readonly "type": "environment_variable" + readonly "secret_value"?: string + readonly "networking"?: BetaManagedAgentsCredentialNetworkingParams + readonly "injection_location"?: BetaManagedAgentsInjectionLocationUpdateParams + } +export const BetaManagedAgentsCredentialUpdateAuth = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("mcp_oauth"), + "access_token": Schema.optionalKey( + Schema.String.annotate({ "description": "Updated OAuth access token." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(8192).annotate({ "expected": "a value with a length of at most 8192" })) + ), + "expires_at": Schema.optionalKey(BetaTimestamp), + "refresh": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsMcpOauthRefreshUpdateParams + ).annotate({ "description": "Updated refresh token configuration." }) + ) + }).annotate({ "description": "Updated authentication details for a credential." }), + Schema.Struct({ + "type": Schema.Literal("static_bearer"), + "token": Schema.optionalKey( + Schema.String.annotate({ "description": "Updated static bearer token value." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(8192).annotate({ "expected": "a value with a length of at most 8192" })) + ) + }).annotate({ "description": "Updated authentication details for a credential." }), + Schema.Struct({ + "type": Schema.Literal("environment_variable"), + "secret_value": Schema.optionalKey( + Schema.String.annotate({ "description": "Updated secret value." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" })) + ), + "networking": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsCredentialNetworkingParams + ).annotate({ "description": "Updated networking scope. Full replacement." }) + ), + "injection_location": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsInjectionLocationUpdateParams + ).annotate({ "description": "Updated injection location." }) + ) + }).annotate({ "description": "Updated authentication details for a credential." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsCredentialUpdateAuth" }) +export type BetaManagedAgentsMcpProbe = { + readonly "method": string + readonly "http_response": BetaManagedAgentsRefreshHttpResponse +} +export const BetaManagedAgentsMcpProbe = Schema.Struct({ + "method": Schema.String.annotate({ + "description": "The MCP method that failed (for example `initialize` or `tools/list`)." + }), + "http_response": Schema.suspend((): Schema.Codec => + BetaManagedAgentsRefreshHttpResponse + ).annotate({ + "description": "The captured HTTP error response. Null when no HTTP response was received (timeout, DNS, TLS)." + }) +}).annotate({ + "description": "The failing step of an MCP validation probe.", + "identifier": "BetaManagedAgentsMcpProbe" +}) +export type BetaManagedAgentsRefreshObject = { + readonly "status": BetaManagedAgentsCredentialRefreshStatus + readonly "http_response": BetaManagedAgentsRefreshHttpResponse +} +export const BetaManagedAgentsRefreshObject = Schema.Struct({ + "status": Schema.suspend((): Schema.Codec => + BetaManagedAgentsCredentialRefreshStatus + ).annotate({ "description": "Outcome of the refresh attempt." }), + "http_response": Schema.suspend((): Schema.Codec => + BetaManagedAgentsRefreshHttpResponse + ).annotate({ + "description": "The captured HTTP error response from the token endpoint. Populated only when `status` is `failed`." + }) +}).annotate({ + "description": "Outcome of a refresh-token exchange attempted during credential validation.", + "identifier": "BetaManagedAgentsRefreshObject" +}) +export type BetaRequestFallbackBlock = { + readonly "from": BetaRequestFallbackHopInfo + readonly "to": BetaRequestFallbackHopInfo + readonly "trigger"?: Schema.Json + readonly "type": "fallback" +} +export const BetaRequestFallbackBlock = Schema.Struct({ + "from": BetaRequestFallbackHopInfo, + "to": BetaRequestFallbackHopInfo, + "trigger": Schema.optionalKey( + Schema.Json.annotate({ + "expected": "JSON value", + "title": "Trigger", "description": - "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts)." + "The response block's `trigger`, echoed verbatim. Accepted and ignored by the server; any object or `null` is allowed." }) ), - "thinking": Schema.optionalKey(ThinkingConfigParam), - "tool_choice": Schema.optionalKey(ToolChoice), - "tools": Schema.optionalKey( - Schema.Array( - Schema.Union([ - Tool, - BashTool_20250124, - CodeExecutionTool_20250522, - CodeExecutionTool_20250825, - CodeExecutionTool_20260120, - MemoryTool_20250818, - TextEditor_20250124, - TextEditor_20250429, - TextEditor_20250728, - WebSearchTool_20250305, - WebFetchTool_20250910, - WebSearchTool_20260209, - WebFetchTool_20260209, - ToolSearchToolBM25_20251119, - ToolSearchToolRegex_20251119 - ], { mode: "oneOf" }) - ).annotate({ - "title": "Tools", - "description": - "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview\\#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://docs.claude.com/en/docs/tool-use) for more details." - }) - ) -}).annotate({ "title": "CountMessageTokensParams" }) -export type CreateMessageParams = { - readonly "model": Model - readonly "messages": ReadonlyArray + "type": Schema.Literal("fallback").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestFallbackBlock", + "description": + "A `fallback` block echoed back from a prior response.\n\nAccepted in `messages[].content` and not rendered into the prompt; not\nvalidated against the request's `fallbacks` chain or top-level `model`.\n\nEcho the assistant turn back verbatim, including this block in its\noriginal position. The block marks the boundary between content produced\nbefore and after a fallback hop, and the server relies on that boundary\nto validate the turn: when thinking runs flank the boundary, omitting\nthe block merges them into one span the server cannot validate (the\nrequest is rejected), and moving it into the middle of a single run is\nlikewise rejected; between non-thinking blocks the block's placement has\nno validation effect.", + "identifier": "BetaRequestFallbackBlock" +}) +export type RequestToolSearchToolSearchResultBlock = { + readonly "tool_references": ReadonlyArray + readonly "type": "tool_search_tool_search_result" +} +export const RequestToolSearchToolSearchResultBlock = Schema.Struct({ + "tool_references": Schema.Array(RequestToolReferenceBlock).annotate({ "title": "Tool References" }), + "type": Schema.Literal("tool_search_tool_search_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestToolSearchToolSearchResultBlock", + "identifier": "RequestToolSearchToolSearchResultBlock" +}) +export type RequestSearchResultBlock = { readonly "cache_control"?: CacheControlEphemeral | null - readonly "container"?: string | null - readonly "inference_geo"?: string | null - readonly "max_tokens": number - readonly "metadata"?: { readonly "user_id"?: string | null } - readonly "output_config"?: { readonly "effort"?: EffortLevel | null; readonly "format"?: JsonOutputFormat | null } - readonly "service_tier"?: "auto" | "standard_only" - readonly "stop_sequences"?: ReadonlyArray - readonly "stream"?: boolean - readonly "system"?: string | ReadonlyArray - readonly "temperature"?: number - readonly "thinking"?: ThinkingConfigParam - readonly "tool_choice"?: ToolChoice - readonly "tools"?: ReadonlyArray< - | Tool - | BashTool_20250124 - | CodeExecutionTool_20250522 - | CodeExecutionTool_20250825 - | CodeExecutionTool_20260120 - | MemoryTool_20250818 - | TextEditor_20250124 - | TextEditor_20250429 - | TextEditor_20250728 - | WebSearchTool_20250305 - | WebFetchTool_20250910 - | WebSearchTool_20260209 - | WebFetchTool_20260209 - | ToolSearchToolBM25_20251119 - | ToolSearchToolRegex_20251119 - > - readonly "top_k"?: number - readonly "top_p"?: number + readonly "citations"?: RequestCitationsConfig + readonly "content": ReadonlyArray + readonly "source": string + readonly "title": string + readonly "type": "search_result" } -export const CreateMessageParams = Schema.Struct({ - "model": Model, - "messages": Schema.Array(InputMessage).annotate({ - "title": "Messages", - "description": - "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://docs.claude.com/en/api/messages-examples).\n\nNote that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." - }), +export const RequestSearchResultBlock = Schema.Struct({ "cache_control": Schema.optionalKey( Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ "title": "Cache Control", - "description": - "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." + "description": "Create a cache control breakpoint at this content block." }) ), - "container": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Container", - "description": "Container identifier for reuse across requests." + "citations": Schema.optionalKey(RequestCitationsConfig), + "content": Schema.Array(RequestTextBlock).annotate({ "title": "Content" }), + "source": Schema.String.annotate({ "title": "Source" }), + "title": Schema.String.annotate({ "title": "Title" }), + "type": Schema.Literal("search_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestSearchResultBlock", "identifier": "RequestSearchResultBlock" }) +export type RequestMidConvSystemBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "content": ReadonlyArray + readonly "type": "mid_conv_system" +} +export const RequestMidConvSystemBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "inference_geo": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Inference Geo", - "description": - "Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used." + "content": Schema.Array(Schema.Union([RequestTextBlock], { mode: "oneOf" })).annotate({ + "title": "Content", + "description": "System instruction text blocks." + }), + "type": Schema.Literal("mid_conv_system").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestMidConvSystemBlock", + "description": + "System instructions that appear mid-conversation.\n\nUse this block to provide or update system-level instructions at a specific\npoint in the conversation, rather than only via the top-level `system` parameter.", + "identifier": "RequestMidConvSystemBlock" +}) +export type ContentBlockSource = { + readonly "content": string | ReadonlyArray + readonly "type": "content" +} +export const ContentBlockSource = Schema.Struct({ + "content": Schema.Union([ + Schema.String, + Schema.Array( + Schema.Union([RequestTextBlock, RequestImageBlock], { mode: "oneOf" }).annotate({ + "title": "content_block_source_content_item" + }) + ).annotate({ "title": "content_block_source_content" }) + ]).annotate({ "title": "Content" }), + "type": Schema.Literal("content").annotate({ "title": "Type" }) +}).annotate({ "title": "ContentBlockSource", "identifier": "ContentBlockSource" }) +export type RequestWebSearchToolResultBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "caller"?: DirectCaller | ServerToolCaller | ServerToolCaller_20260120 + readonly "content": ReadonlyArray | RequestWebSearchToolResultError + readonly "tool_use_id": string + readonly "type": "web_search_tool_result" +} +export const RequestWebSearchToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "max_tokens": Schema.Number.annotate({ - "title": "Max Tokens", - "description": - "The maximum number of tokens to generate before stopping.\n\nNote that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.\n\nDifferent models have different maximum values for this parameter. See [models](https://docs.claude.com/en/docs/models-overview) for details." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "metadata": Schema.optionalKey( - Schema.Struct({ - "user_id": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMaxLength(256)), Schema.Null]).annotate({ - "title": "User Id", - "description": - "An external identifier for the user who is associated with the request.\n\nThis should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number." - }) - ) - }).annotate({ "title": "Metadata", "description": "An object describing metadata about the request." }) - ), - "output_config": Schema.optionalKey( - Schema.Struct({ - "effort": Schema.optionalKey( - Schema.Union([EffortLevel, Schema.Null]).annotate({ - "description": - "How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.\n\nValid values are `low`, `medium`, `high`, or `max`." - }) - ), - "format": Schema.optionalKey( - Schema.Union([JsonOutputFormat, Schema.Null]).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({ - "title": "OutputConfig", - "description": "Configuration options for the model's output, such as the output format." + "caller": Schema.optionalKey( + Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "service_tier": Schema.optionalKey( - Schema.Literals(["auto", "standard_only"]).annotate({ - "title": "Service Tier", - "description": - "Determines whether to use priority capacity (if available) or standard capacity for this request.\n\nAnthropic offers different levels of service for your API requests. See [service-tiers](https://docs.claude.com/en/api/service-tiers) for details." + "content": Schema.Union([ + Schema.Array(RequestWebSearchResultBlock).annotate({ "title": "web_search_tool_result_block_item" }), + RequestWebSearchToolResultError + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "stop_sequences": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "title": "Stop Sequences", - "description": - "Custom text sequences that will cause the model to stop generating.\n\nOur models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `\"end_turn\"`.\n\nIf you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"` and the response `stop_sequence` value will contain the matched stop sequence." + "type": Schema.Literal("web_search_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestWebSearchToolResultBlock", "identifier": "RequestWebSearchToolResultBlock" }) +export type ResponseWebSearchToolResultBlock = { + readonly "caller": DirectCaller | ServerToolCaller | ServerToolCaller_20260120 + readonly "content": ResponseWebSearchToolResultError | ReadonlyArray + readonly "tool_use_id": string + readonly "type": "web_search_tool_result" +} +export const ResponseWebSearchToolResultBlock = Schema.Struct({ + "caller": Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller", + "default": { "type": "direct" } + }), + "content": Schema.Union([ResponseWebSearchToolResultError, Schema.Array(ResponseWebSearchResultBlock)]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "stream": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Stream", - "description": - "Whether to incrementally stream the response using server-sent events.\n\nSee [streaming](https://docs.claude.com/en/api/messages-streaming) for details." + "type": Schema.Literal("web_search_tool_result").annotate({ "title": "Type", "default": "web_search_tool_result" }) +}).annotate({ "title": "ResponseWebSearchToolResultBlock", "identifier": "ResponseWebSearchToolResultBlock" }) +export type RequestCodeExecutionToolResultBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "content": + | RequestCodeExecutionToolResultError + | RequestCodeExecutionResultBlock + | RequestEncryptedCodeExecutionResultBlock + readonly "tool_use_id": string + readonly "type": "code_execution_tool_result" +} +export const RequestCodeExecutionToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "system": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Array(RequestTextBlock)]).annotate({ - "title": "System", - "description": - "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts)." + "content": Schema.Union([ + RequestCodeExecutionToolResultError, + RequestCodeExecutionResultBlock, + RequestEncryptedCodeExecutionResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Temperature", - "description": - "Amount of randomness injected into the response.\n\nDefaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.\n\nNote that even with `temperature` of `0.0`, the results will not be fully deterministic." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) - ), - "thinking": Schema.optionalKey(ThinkingConfigParam), - "tool_choice": Schema.optionalKey(ToolChoice), - "tools": Schema.optionalKey( - Schema.Array( - Schema.Union([ - Tool, - BashTool_20250124, - CodeExecutionTool_20250522, - CodeExecutionTool_20250825, - CodeExecutionTool_20260120, - MemoryTool_20250818, - TextEditor_20250124, - TextEditor_20250429, - TextEditor_20250728, - WebSearchTool_20250305, - WebFetchTool_20250910, - WebSearchTool_20260209, - WebFetchTool_20260209, - ToolSearchToolBM25_20251119, - ToolSearchToolRegex_20251119 - ], { mode: "oneOf" }) - ).annotate({ - "title": "Tools", - "description": - "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview\\#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://docs.claude.com/en/docs/tool-use) for more details." + "type": Schema.Literal("code_execution_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestCodeExecutionToolResultBlock", "identifier": "RequestCodeExecutionToolResultBlock" }) +export type RequestBashCodeExecutionToolResultBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "content": RequestBashCodeExecutionToolResultError | RequestBashCodeExecutionResultBlock + readonly "tool_use_id": string + readonly "type": "bash_code_execution_tool_result" +} +export const RequestBashCodeExecutionToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "top_k": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top K", - "description": - "Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) + "content": Schema.Union([RequestBashCodeExecutionToolResultError, RequestBashCodeExecutionResultBlock]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" + }) ), - "top_p": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top P", - "description": - "Use nucleus sampling.\n\nIn nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both.\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) - ) -}).annotate({ "title": "CreateMessageParams" }) -export type MessageBatchIndividualRequestParams = { - readonly "custom_id": string - readonly "params": { - readonly "model": Model - readonly "messages": ReadonlyArray - readonly "cache_control"?: CacheControlEphemeral | null - readonly "container"?: string | null - readonly "inference_geo"?: string | null - readonly "max_tokens": number - readonly "metadata"?: { readonly "user_id"?: string | null } - readonly "output_config"?: { readonly "effort"?: EffortLevel | null; readonly "format"?: JsonOutputFormat | null } - readonly "service_tier"?: "auto" | "standard_only" - readonly "stop_sequences"?: ReadonlyArray - readonly "stream"?: boolean - readonly "system"?: string | ReadonlyArray - readonly "temperature"?: number - readonly "thinking"?: ThinkingConfigParam - readonly "tool_choice"?: ToolChoice - readonly "tools"?: ReadonlyArray< - | Tool - | BashTool_20250124 - | CodeExecutionTool_20250522 - | CodeExecutionTool_20250825 - | CodeExecutionTool_20260120 - | MemoryTool_20250818 - | TextEditor_20250124 - | TextEditor_20250429 - | TextEditor_20250728 - | WebSearchTool_20250305 - | WebFetchTool_20250910 - | WebSearchTool_20260209 - | WebFetchTool_20260209 - | ToolSearchToolBM25_20251119 - | ToolSearchToolRegex_20251119 - > - readonly "top_k"?: number - readonly "top_p"?: number - } + "type": Schema.Literal("bash_code_execution_tool_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestBashCodeExecutionToolResultBlock", + "identifier": "RequestBashCodeExecutionToolResultBlock" +}) +export type RequestTextEditorCodeExecutionToolResultBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "content": + | RequestTextEditorCodeExecutionToolResultError + | RequestTextEditorCodeExecutionViewResultBlock + | RequestTextEditorCodeExecutionCreateResultBlock + | RequestTextEditorCodeExecutionStrReplaceResultBlock + readonly "tool_use_id": string + readonly "type": "text_editor_code_execution_tool_result" } -export const MessageBatchIndividualRequestParams = Schema.Struct({ - "custom_id": Schema.String.annotate({ - "title": "Custom Id", - "description": - "Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.\n\nMust be unique for each request within the Message Batch." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)).check( - Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$")) +export const RequestTextEditorCodeExecutionToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) ), - "params": Schema.Struct({ - "model": Model, - "messages": Schema.Array(InputMessage).annotate({ - "title": "Messages", - "description": - "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://docs.claude.com/en/api/messages-examples).\n\nNote that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." - }), - "cache_control": Schema.optionalKey( - Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ - "title": "Cache Control", - "description": - "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." - }) - ), - "container": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Container", - "description": "Container identifier for reuse across requests." - }) - ), - "inference_geo": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Inference Geo", - "description": - "Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used." - }) - ), - "max_tokens": Schema.Number.annotate({ - "title": "Max Tokens", - "description": - "The maximum number of tokens to generate before stopping.\n\nNote that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.\n\nDifferent models have different maximum values for this parameter. See [models](https://docs.claude.com/en/docs/models-overview) for details." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - "metadata": Schema.optionalKey( - Schema.Struct({ - "user_id": Schema.optionalKey( - Schema.Union([Schema.String.check(Schema.isMaxLength(256)), Schema.Null]).annotate({ - "title": "User Id", - "description": - "An external identifier for the user who is associated with the request.\n\nThis should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number." - }) - ) - }).annotate({ "title": "Metadata", "description": "An object describing metadata about the request." }) - ), - "output_config": Schema.optionalKey( - Schema.Struct({ - "effort": Schema.optionalKey( - Schema.Union([EffortLevel, Schema.Null]).annotate({ - "description": - "How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.\n\nValid values are `low`, `medium`, `high`, or `max`." - }) - ), - "format": Schema.optionalKey( - Schema.Union([JsonOutputFormat, Schema.Null]).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({ - "title": "OutputConfig", - "description": "Configuration options for the model's output, such as the output format." - }) - ), - "service_tier": Schema.optionalKey( - Schema.Literals(["auto", "standard_only"]).annotate({ - "title": "Service Tier", - "description": - "Determines whether to use priority capacity (if available) or standard capacity for this request.\n\nAnthropic offers different levels of service for your API requests. See [service-tiers](https://docs.claude.com/en/api/service-tiers) for details." - }) - ), - "stop_sequences": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "title": "Stop Sequences", - "description": - "Custom text sequences that will cause the model to stop generating.\n\nOur models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `\"end_turn\"`.\n\nIf you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"` and the response `stop_sequence` value will contain the matched stop sequence." - }) - ), - "stream": Schema.optionalKey( - Schema.Boolean.annotate({ - "title": "Stream", - "description": - "Whether to incrementally stream the response using server-sent events.\n\nSee [streaming](https://docs.claude.com/en/api/messages-streaming) for details." - }) - ), - "system": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Array(RequestTextBlock)]).annotate({ - "title": "System", - "description": - "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts)." - }) - ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Temperature", - "description": - "Amount of randomness injected into the response.\n\nDefaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.\n\nNote that even with `temperature` of `0.0`, the results will not be fully deterministic." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) - ), - "thinking": Schema.optionalKey(ThinkingConfigParam), - "tool_choice": Schema.optionalKey(ToolChoice), - "tools": Schema.optionalKey( - Schema.Array( - Schema.Union([ - Tool, - BashTool_20250124, - CodeExecutionTool_20250522, - CodeExecutionTool_20250825, - CodeExecutionTool_20260120, - MemoryTool_20250818, - TextEditor_20250124, - TextEditor_20250429, - TextEditor_20250728, - WebSearchTool_20250305, - WebFetchTool_20250910, - WebSearchTool_20260209, - WebFetchTool_20260209, - ToolSearchToolBM25_20251119, - ToolSearchToolRegex_20251119 - ], { mode: "oneOf" }) - ).annotate({ - "title": "Tools", - "description": - "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview\\#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://docs.claude.com/en/docs/tool-use) for more details." - }) - ), - "top_k": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top K", - "description": - "Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) - ), - "top_p": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Top P", - "description": - "Use nucleus sampling.\n\nIn nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both.\n\nRecommended for advanced use cases only. You usually only need to use `temperature`." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) - ) - }).annotate({ - "title": "CreateMessageParams", - "description": - "Messages API creation parameters for the individual request.\n\nSee the [Messages API reference](https://docs.claude.com/en/api/messages) for full documentation on available parameters." - }) -}).annotate({ "title": "MessageBatchIndividualRequestParams" }) -export type BetaCreateMessageBatchParams = { - readonly "requests": ReadonlyArray -} -export const BetaCreateMessageBatchParams = Schema.Struct({ - "requests": Schema.Array(BetaMessageBatchIndividualRequestParams).annotate({ - "title": "Requests", - "description": "List of requests for prompt completion. Each is an individual request to create a Message." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(100000)) -}).annotate({ "title": "CreateMessageBatchParams" }) -export type CreateMessageBatchParams = { readonly "requests": ReadonlyArray } -export const CreateMessageBatchParams = Schema.Struct({ - "requests": Schema.Array(MessageBatchIndividualRequestParams).annotate({ - "title": "Requests", - "description": "List of requests for prompt completion. Each is an individual request to create a Message." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(100000)) -}).annotate({ "title": "CreateMessageBatchParams" }) -// schemas -export type MessagesPostParams = { readonly "anthropic-version"?: string } -export const MessagesPostParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) - ) -}) -export type MessagesPostRequestJson = CreateMessageParams -export const MessagesPostRequestJson = CreateMessageParams -export type MessagesPost200 = Message -export const MessagesPost200 = Message -export type MessagesPost4XX = ErrorResponse -export const MessagesPost4XX = ErrorResponse -export type CompletePostParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } -export const CompletePostParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.Union([ + RequestTextEditorCodeExecutionToolResultError, + RequestTextEditorCodeExecutionViewResultBlock, + RequestTextEditorCodeExecutionCreateResultBlock, + RequestTextEditorCodeExecutionStrReplaceResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." - }) - ) + "type": Schema.Literal("text_editor_code_execution_tool_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionToolResultBlock", + "identifier": "RequestTextEditorCodeExecutionToolResultBlock" }) -export type CompletePostRequestJson = CompletionRequest -export const CompletePostRequestJson = CompletionRequest -export type CompletePost200 = CompletionResponse -export const CompletePost200 = CompletionResponse -export type CompletePost4XX = ErrorResponse -export const CompletePost4XX = ErrorResponse -export type ModelsListParams = { - readonly "before_id"?: string - readonly "after_id"?: string - readonly "limit"?: number - readonly "anthropic-version"?: string - readonly "x-api-key"?: string - readonly "anthropic-beta"?: string +export type ResponseTextEditorCodeExecutionToolResultBlock = { + readonly "content": + | ResponseTextEditorCodeExecutionToolResultError + | ResponseTextEditorCodeExecutionViewResultBlock + | ResponseTextEditorCodeExecutionCreateResultBlock + | ResponseTextEditorCodeExecutionStrReplaceResultBlock + readonly "tool_use_id": string + readonly "type": "text_editor_code_execution_tool_result" } -export const ModelsListParams = Schema.Struct({ - "before_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "Before Id", - "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." +export const ResponseTextEditorCodeExecutionToolResultBlock = Schema.Struct({ + "content": Schema.Union([ + ResponseTextEditorCodeExecutionToolResultError, + ResponseTextEditorCodeExecutionViewResultBlock, + ResponseTextEditorCodeExecutionCreateResultBlock, + ResponseTextEditorCodeExecutionStrReplaceResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "after_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "After Id", - "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + "type": Schema.Literal("text_editor_code_execution_tool_result").annotate({ + "title": "Type", + "default": "text_editor_code_execution_tool_result" + }) +}).annotate({ + "title": "ResponseTextEditorCodeExecutionToolResultBlock", + "identifier": "ResponseTextEditorCodeExecutionToolResultBlock" +}) +export type ThinkingConfigParam = ThinkingConfigEnabled | ThinkingConfigDisabled | ThinkingConfigAdaptive +export const ThinkingConfigParam = Schema.Union( + [ThinkingConfigEnabled, ThinkingConfigDisabled, ThinkingConfigAdaptive], + { mode: "oneOf" } +).annotate({ + "title": "Thinking", + "description": + "Configuration for enabling Claude's extended thinking.\n\nWhen enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.\n\nSee [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.", + "identifier": "ThinkingConfigParam" +}) +export type ResponseWebFetchResultBlock = { + readonly "content": ResponseDocumentBlock + readonly "retrieved_at": string | null + readonly "type": "web_fetch_result" + readonly "url": string +} +export const ResponseWebFetchResultBlock = Schema.Struct({ + "content": ResponseDocumentBlock, + "retrieved_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Retrieved At", + "description": "ISO 8601 timestamp when the content was retrieved", + "default": null + }), + "type": Schema.Literal("web_fetch_result").annotate({ "title": "Type", "default": "web_fetch_result" }), + "url": Schema.String.annotate({ "title": "Url", "description": "Fetched content URL" }) +}).annotate({ "title": "ResponseWebFetchResultBlock", "identifier": "ResponseWebFetchResultBlock" }) +export type ResponseCodeExecutionToolResultBlock = { + readonly "content": + | ResponseCodeExecutionToolResultError + | ResponseCodeExecutionResultBlock + | ResponseEncryptedCodeExecutionResultBlock + readonly "tool_use_id": string + readonly "type": "code_execution_tool_result" +} +export const ResponseCodeExecutionToolResultBlock = Schema.Struct({ + "content": Schema.Union([ + ResponseCodeExecutionToolResultError, + ResponseCodeExecutionResultBlock, + ResponseEncryptedCodeExecutionResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "limit": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Limit", - "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", - "default": 20 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(1000)) - ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "type": Schema.Literal("code_execution_tool_result").annotate({ + "title": "Type", + "default": "code_execution_tool_result" + }) +}).annotate({ "title": "ResponseCodeExecutionToolResultBlock", "identifier": "ResponseCodeExecutionToolResultBlock" }) +export type ResponseBashCodeExecutionToolResultBlock = { + readonly "content": ResponseBashCodeExecutionToolResultError | ResponseBashCodeExecutionResultBlock + readonly "tool_use_id": string + readonly "type": "bash_code_execution_tool_result" +} +export const ResponseBashCodeExecutionToolResultBlock = Schema.Struct({ + "content": Schema.Union([ResponseBashCodeExecutionToolResultError, ResponseBashCodeExecutionResultBlock]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." - }) - ) + "type": Schema.Literal("bash_code_execution_tool_result").annotate({ + "title": "Type", + "default": "bash_code_execution_tool_result" + }) +}).annotate({ + "title": "ResponseBashCodeExecutionToolResultBlock", + "identifier": "ResponseBashCodeExecutionToolResultBlock" }) -export type ModelsList200 = ListResponse_ModelInfo_ -export const ModelsList200 = ListResponse_ModelInfo_ -export type ModelsList4XX = ErrorResponse -export const ModelsList4XX = ErrorResponse -export type ModelsGetParams = { - readonly "anthropic-version"?: string - readonly "x-api-key"?: string - readonly "anthropic-beta"?: string +export type ResponseToolSearchToolResultBlock = { + readonly "content": ResponseToolSearchToolResultError | ResponseToolSearchToolSearchResultBlock + readonly "tool_use_id": string + readonly "type": "tool_search_tool_result" } -export const ModelsGetParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." +export const ResponseToolSearchToolResultBlock = Schema.Struct({ + "content": Schema.Union([ResponseToolSearchToolResultError, ResponseToolSearchToolSearchResultBlock]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." - }) - ) + "type": Schema.Literal("tool_search_tool_result").annotate({ "title": "Type", "default": "tool_search_tool_result" }) +}).annotate({ "title": "ResponseToolSearchToolResultBlock", "identifier": "ResponseToolSearchToolResultBlock" }) +export type ThinkingCapability = { readonly "supported": boolean; readonly "types": ThinkingTypes } +export const ThinkingCapability = Schema.Struct({ + "supported": Schema.Boolean.annotate({ + "title": "Supported", + "description": "Whether this capability is supported by the model." + }), + "types": ThinkingTypes +}).annotate({ + "title": "ThinkingCapability", + "description": "Thinking capability details.", + "identifier": "ThinkingCapability" }) -export type ModelsGet200 = ModelInfo -export const ModelsGet200 = ModelInfo -export type ModelsGet4XX = ErrorResponse -export const ModelsGet4XX = ErrorResponse -export type MessageBatchesListParams = { - readonly "before_id"?: string - readonly "after_id"?: string - readonly "limit"?: number - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type ListResponse_MessageBatch_ = { + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "has_more": boolean + readonly "last_id": string | null } -export const MessageBatchesListParams = Schema.Struct({ - "before_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "Before Id", - "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." +export const ListResponse_MessageBatch_ = Schema.Struct({ + "data": Schema.Array(MessageBatch).annotate({ "title": "Data" }), + "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "First Id", + "description": "First ID in the `data` list. Can be used as the `before_id` for the previous page." + }), + "has_more": Schema.Boolean.annotate({ + "title": "Has More", + "description": "Indicates if there are more results in the requested page direction." + }), + "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Last Id", + "description": "Last ID in the `data` list. Can be used as the `after_id` for the next page." + }) +}).annotate({ "title": "ListResponse[MessageBatch]", "identifier": "ListResponse_MessageBatch_" }) +export type BetaRequestToolSearchToolSearchResultBlock = { + readonly "tool_references": ReadonlyArray + readonly "type": "tool_search_tool_search_result" +} +export const BetaRequestToolSearchToolSearchResultBlock = Schema.Struct({ + "tool_references": Schema.Array(BetaRequestToolReferenceBlock).annotate({ "title": "Tool References" }), + "type": Schema.Literal("tool_search_tool_search_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestToolSearchToolSearchResultBlock", + "identifier": "BetaRequestToolSearchToolSearchResultBlock" +}) +export type BetaRequestSearchResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "citations"?: BetaRequestCitationsConfig + readonly "content": ReadonlyArray + readonly "source": string + readonly "title": string + readonly "type": "search_result" +} +export const BetaRequestSearchResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "after_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "After Id", - "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + "citations": Schema.optionalKey(BetaRequestCitationsConfig), + "content": Schema.Array(BetaRequestTextBlock).annotate({ "title": "Content" }), + "source": Schema.String.annotate({ "title": "Source" }), + "title": Schema.String.annotate({ "title": "Title" }), + "type": Schema.Literal("search_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestSearchResultBlock", "identifier": "BetaRequestSearchResultBlock" }) +export type BetaRequestMCPToolResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "content"?: string | ReadonlyArray + readonly "is_error"?: boolean + readonly "tool_use_id": string + readonly "type": "mcp_tool_result" +} +export const BetaRequestMCPToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "limit": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Limit", - "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", - "default": 20 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(1000)) + "content": Schema.optionalKey( + Schema.Union([ + Schema.String, + Schema.Array( + Schema.suspend((): Schema.Codec => BetaRequestTextBlock).annotate({ + "title": "beta_mcp_tool_result_block_param_content_item" + }) + ).annotate({ "title": "beta_mcp_tool_result_block_param_content" }) + ]).annotate({ "title": "Content" }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "is_error": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Is Error" })), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type MessageBatchesList200 = ListResponse_MessageBatch_ -export const MessageBatchesList200 = ListResponse_MessageBatch_ -export type MessageBatchesList4XX = ErrorResponse -export const MessageBatchesList4XX = ErrorResponse -export type MessageBatchesPostParams = { readonly "anthropic-version"?: string } -export const MessageBatchesPostParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) - ) -}) -export type MessageBatchesPostRequestJson = CreateMessageBatchParams -export const MessageBatchesPostRequestJson = CreateMessageBatchParams -export type MessageBatchesPost200 = MessageBatch -export const MessageBatchesPost200 = MessageBatch -export type MessageBatchesPost4XX = ErrorResponse -export const MessageBatchesPost4XX = ErrorResponse -export type MessageBatchesRetrieveParams = { readonly "anthropic-version"?: string; readonly "x-api-key"?: string } -export const MessageBatchesRetrieveParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "type": Schema.Literal("mcp_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestMCPToolResultBlock", "identifier": "BetaRequestMCPToolResultBlock" }) +export type BetaContentBlockSource = { + readonly "content": string | ReadonlyArray + readonly "type": "content" +} +export const BetaContentBlockSource = Schema.Struct({ + "content": Schema.Union([ + Schema.String, + Schema.Array( + Schema.Union([BetaRequestTextBlock, BetaRequestImageBlock], { mode: "oneOf" }).annotate({ + "title": "beta_content_block_source_content_item" + }) + ).annotate({ "title": "beta_content_block_source_content" }) + ]).annotate({ "title": "Content" }), + "type": Schema.Literal("content").annotate({ "title": "Type" }) +}).annotate({ "title": "ContentBlockSource", "identifier": "BetaContentBlockSource" }) +export type BetaRequestWebSearchToolResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + readonly "content": ReadonlyArray | BetaRequestWebSearchToolResultError + readonly "tool_use_id": string + readonly "type": "web_search_tool_result" +} +export const BetaRequestWebSearchToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type MessageBatchesRetrieve200 = MessageBatch -export const MessageBatchesRetrieve200 = MessageBatch -export type MessageBatchesRetrieve4XX = ErrorResponse -export const MessageBatchesRetrieve4XX = ErrorResponse -export type MessageBatchesDeleteParams = { readonly "anthropic-version"?: string; readonly "x-api-key"?: string } -export const MessageBatchesDeleteParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "caller": Schema.optionalKey( + Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type MessageBatchesDelete200 = DeleteMessageBatchResponse -export const MessageBatchesDelete200 = DeleteMessageBatchResponse -export type MessageBatchesDelete4XX = ErrorResponse -export const MessageBatchesDelete4XX = ErrorResponse -export type MessageBatchesCancelParams = { readonly "anthropic-version"?: string } -export const MessageBatchesCancelParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) - ) -}) -export type MessageBatchesCancel200 = MessageBatch -export const MessageBatchesCancel200 = MessageBatch -export type MessageBatchesCancel4XX = ErrorResponse -export const MessageBatchesCancel4XX = ErrorResponse -export type MessageBatchesResultsParams = { readonly "anthropic-version"?: string; readonly "x-api-key"?: string } -export const MessageBatchesResultsParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.Union([ + Schema.Array(BetaRequestWebSearchResultBlock).annotate({ "title": "Result Block" }), + BetaRequestWebSearchToolResultError + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type MessageBatchesResults4XX = ErrorResponse -export const MessageBatchesResults4XX = ErrorResponse -export type MessagesCountTokensPostParams = { readonly "anthropic-version"?: string } -export const MessagesCountTokensPostParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) - ) -}) -export type MessagesCountTokensPostRequestJson = CountMessageTokensParams -export const MessagesCountTokensPostRequestJson = CountMessageTokensParams -export type MessagesCountTokensPost200 = CountMessageTokensResponse -export const MessagesCountTokensPost200 = CountMessageTokensResponse -export type MessagesCountTokensPost4XX = ErrorResponse -export const MessagesCountTokensPost4XX = ErrorResponse -export type ListFilesV1FilesGetParams = { - readonly "before_id"?: string - readonly "after_id"?: string - readonly "limit"?: number - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string + "type": Schema.Literal("web_search_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestWebSearchToolResultBlock", "identifier": "BetaRequestWebSearchToolResultBlock" }) +export type BetaResponseWebSearchToolResultBlock = { + readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + readonly "content": BetaResponseWebSearchToolResultError | ReadonlyArray + readonly "tool_use_id": string + readonly "type": "web_search_tool_result" } -export const ListFilesV1FilesGetParams = Schema.Struct({ - "before_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "Before Id", - "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." +export const BetaResponseWebSearchToolResultBlock = Schema.Struct({ + "caller": Schema.optionalKey( + Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "after_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "After Id", - "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + "content": Schema.Union([BetaResponseWebSearchToolResultError, Schema.Array(BetaResponseWebSearchResultBlock)]) + .annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "limit": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Limit", - "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", - "default": 20 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(1000)) - ), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "type": Schema.Literal("web_search_tool_result").annotate({ "title": "Type", "default": "web_search_tool_result" }) +}).annotate({ "title": "ResponseWebSearchToolResultBlock", "identifier": "BetaResponseWebSearchToolResultBlock" }) +export type BetaRequestAdvisorToolResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "content": + | BetaRequestAdvisorToolResultError + | BetaRequestAdvisorResultBlock + | BetaRequestAdvisorRedactedResultBlock + readonly "tool_use_id": string + readonly "type": "advisor_tool_result" +} +export const BetaRequestAdvisorToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.Union([ + BetaRequestAdvisorToolResultError, + BetaRequestAdvisorResultBlock, + BetaRequestAdvisorRedactedResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type ListFilesV1FilesGet200 = FileListResponse -export const ListFilesV1FilesGet200 = FileListResponse -export type ListFilesV1FilesGet4XX = ErrorResponse -export const ListFilesV1FilesGet4XX = ErrorResponse -export type UploadFileV1FilesPostParams = { readonly "anthropic-beta"?: string; readonly "anthropic-version"?: string } -export const UploadFileV1FilesPostParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "type": Schema.Literal("advisor_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestAdvisorToolResultBlock", "identifier": "BetaRequestAdvisorToolResultBlock" }) +export type BetaResponseAdvisorToolResultBlock = { + readonly "content": + | BetaResponseAdvisorToolResultError + | BetaResponseAdvisorResultBlock + | BetaResponseAdvisorRedactedResultBlock + readonly "tool_use_id": string + readonly "type": "advisor_tool_result" +} +export const BetaResponseAdvisorToolResultBlock = Schema.Struct({ + "content": Schema.Union([ + BetaResponseAdvisorToolResultError, + BetaResponseAdvisorResultBlock, + BetaResponseAdvisorRedactedResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) - ) -}) -export type UploadFileV1FilesPostRequestFormData = { readonly "file": string } -export const UploadFileV1FilesPostRequestFormData = Schema.Struct({ - "file": Schema.String.annotate({ "description": "The file to upload", "format": "binary" }) -}) -export type UploadFileV1FilesPost200 = FileMetadataSchema -export const UploadFileV1FilesPost200 = FileMetadataSchema -export type UploadFileV1FilesPost4XX = ErrorResponse -export const UploadFileV1FilesPost4XX = ErrorResponse -export type GetFileMetadataV1FilesFileIdGetParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string + "type": Schema.Literal("advisor_tool_result").annotate({ "title": "Type", "default": "advisor_tool_result" }) +}).annotate({ "title": "ResponseAdvisorToolResultBlock", "identifier": "BetaResponseAdvisorToolResultBlock" }) +export type BetaRequestCodeExecutionToolResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "content": + | BetaRequestCodeExecutionToolResultError + | BetaRequestCodeExecutionResultBlock + | BetaRequestEncryptedCodeExecutionResultBlock + readonly "tool_use_id": string + readonly "type": "code_execution_tool_result" } -export const GetFileMetadataV1FilesFileIdGetParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaRequestCodeExecutionToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.Union([ + BetaRequestCodeExecutionToolResultError, + BetaRequestCodeExecutionResultBlock, + BetaRequestEncryptedCodeExecutionResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type GetFileMetadataV1FilesFileIdGet200 = FileMetadataSchema -export const GetFileMetadataV1FilesFileIdGet200 = FileMetadataSchema -export type GetFileMetadataV1FilesFileIdGet4XX = ErrorResponse -export const GetFileMetadataV1FilesFileIdGet4XX = ErrorResponse -export type DeleteFileV1FilesFileIdDeleteParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string + "type": Schema.Literal("code_execution_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestCodeExecutionToolResultBlock", "identifier": "BetaRequestCodeExecutionToolResultBlock" }) +export type BetaRequestBashCodeExecutionToolResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "content": BetaRequestBashCodeExecutionToolResultError | BetaRequestBashCodeExecutionResultBlock + readonly "tool_use_id": string + readonly "type": "bash_code_execution_tool_result" } -export const DeleteFileV1FilesFileIdDeleteParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaRequestBashCodeExecutionToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.Union([BetaRequestBashCodeExecutionToolResultError, BetaRequestBashCodeExecutionResultBlock]) + .annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + "type": Schema.Literal("bash_code_execution_tool_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestBashCodeExecutionToolResultBlock", + "identifier": "BetaRequestBashCodeExecutionToolResultBlock" }) -export type DeleteFileV1FilesFileIdDelete200 = FileDeleteResponse -export const DeleteFileV1FilesFileIdDelete200 = FileDeleteResponse -export type DeleteFileV1FilesFileIdDelete4XX = ErrorResponse -export const DeleteFileV1FilesFileIdDelete4XX = ErrorResponse -export type DownloadFileV1FilesFileIdContentGetParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type BetaRequestTextEditorCodeExecutionToolResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "content": + | BetaRequestTextEditorCodeExecutionToolResultError + | BetaRequestTextEditorCodeExecutionViewResultBlock + | BetaRequestTextEditorCodeExecutionCreateResultBlock + | BetaRequestTextEditorCodeExecutionStrReplaceResultBlock + readonly "tool_use_id": string + readonly "type": "text_editor_code_execution_tool_result" } -export const DownloadFileV1FilesFileIdContentGetParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaRequestTextEditorCodeExecutionToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.Union([ + BetaRequestTextEditorCodeExecutionToolResultError, + BetaRequestTextEditorCodeExecutionViewResultBlock, + BetaRequestTextEditorCodeExecutionCreateResultBlock, + BetaRequestTextEditorCodeExecutionStrReplaceResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + "type": Schema.Literal("text_editor_code_execution_tool_result").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestTextEditorCodeExecutionToolResultBlock", + "identifier": "BetaRequestTextEditorCodeExecutionToolResultBlock" }) -export type ListSkillsV1SkillsGetParams = { - readonly "page"?: string | null - readonly "limit"?: number - readonly "source"?: string | null - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type BetaResponseTextEditorCodeExecutionToolResultBlock = { + readonly "content": + | BetaResponseTextEditorCodeExecutionToolResultError + | BetaResponseTextEditorCodeExecutionViewResultBlock + | BetaResponseTextEditorCodeExecutionCreateResultBlock + | BetaResponseTextEditorCodeExecutionStrReplaceResultBlock + readonly "tool_use_id": string + readonly "type": "text_editor_code_execution_tool_result" } -export const ListSkillsV1SkillsGetParams = Schema.Struct({ - "page": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Page", - "description": - "Pagination token for fetching a specific page of results.\n\nPass the value from a previous response's `next_page` field to get the next page of results." - }) - ), - "limit": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Limit", - "description": "Number of results to return per page.\n\nMaximum value is 100. Defaults to 20.", - "default": 20 - }).check(Schema.isInt()) - ), - "source": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Source", - "description": - "Filter skills by source.\n\nIf provided, only skills from the specified source will be returned:\n* `\"custom\"`: only return user-created skills\n* `\"anthropic\"`: only return Anthropic-created skills" - }) - ), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." - }) - ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." +export const BetaResponseTextEditorCodeExecutionToolResultBlock = Schema.Struct({ + "content": Schema.Union([ + BetaResponseTextEditorCodeExecutionToolResultError, + BetaResponseTextEditorCodeExecutionViewResultBlock, + BetaResponseTextEditorCodeExecutionCreateResultBlock, + BetaResponseTextEditorCodeExecutionStrReplaceResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + "type": Schema.Literal("text_editor_code_execution_tool_result").annotate({ + "title": "Type", + "default": "text_editor_code_execution_tool_result" + }) +}).annotate({ + "title": "ResponseTextEditorCodeExecutionToolResultBlock", + "identifier": "BetaResponseTextEditorCodeExecutionToolResultBlock" }) -export type ListSkillsV1SkillsGet200 = ListSkillsResponse -export const ListSkillsV1SkillsGet200 = ListSkillsResponse -export type ListSkillsV1SkillsGet4XX = ErrorResponse -export const ListSkillsV1SkillsGet4XX = ErrorResponse -export type CreateSkillV1SkillsPostParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string +export type BetaRequestMidConvSystemBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "content": ReadonlyArray + readonly "type": "mid_conv_system" } -export const CreateSkillV1SkillsPostParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaRequestMidConvSystemBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) - ) + "content": Schema.Array( + Schema.Union([BetaRequestTextBlock, BetaRequestToolAdditionBlock, BetaRequestToolRemovalBlock], { mode: "oneOf" }) + ).annotate({ "title": "Content", "description": "System instruction text blocks." }), + "type": Schema.Literal("mid_conv_system").annotate({ "title": "Type" }) +}).annotate({ + "title": "RequestMidConvSystemBlock", + "description": + "System instructions that appear mid-conversation.\n\nUse this block to provide or update system-level instructions at a specific\npoint in the conversation, rather than only via the top-level `system` parameter.", + "identifier": "BetaRequestMidConvSystemBlock" }) -export type CreateSkillV1SkillsPostRequestFormData = Body_create_skill_v1_skills_post -export const CreateSkillV1SkillsPostRequestFormData = Body_create_skill_v1_skills_post -export type CreateSkillV1SkillsPost200 = CreateSkillResponse -export const CreateSkillV1SkillsPost200 = CreateSkillResponse -export type CreateSkillV1SkillsPost4XX = ErrorResponse -export const CreateSkillV1SkillsPost4XX = ErrorResponse -export type GetSkillV1SkillsSkillIdGetParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type BetaContextManagementConfig = { + readonly "edits"?: ReadonlyArray } -export const GetSkillV1SkillsSkillIdGetParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaContextManagementConfig = Schema.Struct({ + "edits": Schema.optionalKey( + Schema.Array( + Schema.Union([BetaClearToolUses20250919, BetaClearThinking20251015, BetaCompact20260112], { mode: "oneOf" }) + ).annotate({ "title": "Edits", "description": "List of context management edits to apply" }).check( + Schema.isMinLength(0).annotate({ "expected": "a value with a length of at least 0" }) + ) + ) +}).annotate({ "title": "ContextManagementConfig", "identifier": "BetaContextManagementConfig" }) +export type BetaDream = { + readonly "type": "dream" + readonly "id": string + readonly "inputs": ReadonlyArray + readonly "outputs": ReadonlyArray + readonly "status": BetaDreamStatus + readonly "created_at": BetaTimestamp + readonly "ended_at": BetaTimestamp + readonly "archived_at": BetaTimestamp + readonly "error": BetaDreamError + readonly "model": BetaDreamModelConfig + readonly "instructions": string + readonly "session_id": string + readonly "usage": BetaDreamUsage +} +export const BetaDream = Schema.Struct({ + "type": Schema.Literal("dream"), + "id": Schema.String, + "inputs": Schema.Array(BetaDreamInput), + "outputs": Schema.Array(BetaDreamOutput), + "status": BetaDreamStatus, + "created_at": BetaTimestamp, + "ended_at": BetaTimestamp, + "archived_at": BetaTimestamp, + "error": BetaDreamError, + "model": BetaDreamModelConfig, + "instructions": Schema.String, + "session_id": Schema.String, + "usage": BetaDreamUsage +}).annotate({ + "description": + "An asynchronous memory-consolidation job that reads a memory store plus a set of session transcripts and writes consolidated memories into a new output memory store. The Dreams API is in research preview: the request and response shapes are volatile and may change without the deprecation period that applies to generally-available endpoints.", + "identifier": "BetaDream" +}) +export type BetaDreamModelParams = string | BetaDreamModelConfigParams +export const BetaDreamModelParams = Schema.Union([Schema.String, BetaDreamModelConfigParams], { mode: "oneOf" }) + .annotate({ "identifier": "BetaDreamModelParams" }) +export type BetaFallbackConfigV2 = { + readonly "max_tokens"?: number | null + readonly "model": Model + readonly "output_config"?: BetaOutputConfig | null + readonly "speed"?: BetaSpeed | null + readonly "thinking"?: BetaThinkingConfigEnabled | BetaThinkingConfigDisabled | BetaThinkingConfigAdaptive | null + readonly [x: string]: Schema.Json +} +export const BetaFallbackConfigV2 = Schema.StructWithRest( + Schema.Struct({ + "max_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Max Tokens" + }) + ), + "model": Model, + "output_config": Schema.optionalKey(Schema.Union([BetaOutputConfig, Schema.Null])), + "speed": Schema.optionalKey(Schema.Union([BetaSpeed, Schema.Null])), + "thinking": Schema.optionalKey( + Schema.Union([ + Schema.Union([BetaThinkingConfigEnabled, BetaThinkingConfigDisabled, BetaThinkingConfigAdaptive], { + mode: "oneOf" + }), + Schema.Null + ]).annotate({ "title": "Thinking" }) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ + "title": "FallbackConfigV2", + "description": + "One entry in the `fallbacks` chain on a `/v1/messages` request.\n\n`model` is required. The override fields (`max_tokens`, `thinking`,\n`output_config`, and `speed`) set the corresponding parameter for this\nattempt only and are validated as if the request were made to `model`.\nAny other key is rejected at parse time.", + "identifier": "BetaFallbackConfigV2" +}) +export type BetaThinkingConfigParam = + | BetaThinkingConfigEnabled + | BetaThinkingConfigDisabled + | BetaThinkingConfigAdaptive +export const BetaThinkingConfigParam = Schema.Union([ + BetaThinkingConfigEnabled, + BetaThinkingConfigDisabled, + BetaThinkingConfigAdaptive +], { mode: "oneOf" }).annotate({ + "title": "Thinking", + "description": + "Configuration for enabling Claude's extended thinking.\n\nWhen enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.\n\nSee [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.", + "identifier": "BetaThinkingConfigParam" +}) +export type BetaResponseMCPToolResultBlock = { + readonly "content": string | ReadonlyArray + readonly "is_error": boolean + readonly "tool_use_id": string + readonly "type": "mcp_tool_result" +} +export const BetaResponseMCPToolResultBlock = Schema.Struct({ + "content": Schema.Union([ + Schema.String, + Schema.Array( + Schema.suspend((): Schema.Codec => BetaResponseTextBlock).annotate({ + "title": "beta_mcp_tool_result_block_content_item" + }) + ).annotate({ "title": "beta_mcp_tool_result_block_content" }) + ]).annotate({ "title": "Content" }), + "is_error": Schema.Boolean.annotate({ "title": "Is Error", "default": false }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "type": Schema.Literal("mcp_tool_result").annotate({ "title": "Type", "default": "mcp_tool_result" }) +}).annotate({ "title": "ResponseMCPToolResultBlock", "identifier": "BetaResponseMCPToolResultBlock" }) +export type BetaResponseWebFetchResultBlock = { + readonly "content": BetaResponseDocumentBlock + readonly "retrieved_at": string | null + readonly "type": "web_fetch_result" + readonly "url": string +} +export const BetaResponseWebFetchResultBlock = Schema.Struct({ + "content": BetaResponseDocumentBlock, + "retrieved_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Retrieved At", + "description": "ISO 8601 timestamp when the content was retrieved", + "default": null + }), + "type": Schema.Literal("web_fetch_result").annotate({ "title": "Type", "default": "web_fetch_result" }), + "url": Schema.String.annotate({ "title": "Url", "description": "Fetched content URL" }) +}).annotate({ "title": "ResponseWebFetchResultBlock", "identifier": "BetaResponseWebFetchResultBlock" }) +export type BetaResponseCodeExecutionToolResultBlock = { + readonly "content": + | BetaResponseCodeExecutionToolResultError + | BetaResponseCodeExecutionResultBlock + | BetaResponseEncryptedCodeExecutionResultBlock + readonly "tool_use_id": string + readonly "type": "code_execution_tool_result" +} +export const BetaResponseCodeExecutionToolResultBlock = Schema.Struct({ + "content": Schema.Union([ + BetaResponseCodeExecutionToolResultError, + BetaResponseCodeExecutionResultBlock, + BetaResponseEncryptedCodeExecutionResultBlock + ]).annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + "type": Schema.Literal("code_execution_tool_result").annotate({ + "title": "Type", + "default": "code_execution_tool_result" + }) +}).annotate({ + "title": "ResponseCodeExecutionToolResultBlock", + "identifier": "BetaResponseCodeExecutionToolResultBlock" }) -export type GetSkillV1SkillsSkillIdGet200 = GetSkillResponse -export const GetSkillV1SkillsSkillIdGet200 = GetSkillResponse -export type GetSkillV1SkillsSkillIdGet4XX = ErrorResponse -export const GetSkillV1SkillsSkillIdGet4XX = ErrorResponse -export type DeleteSkillV1SkillsSkillIdDeleteParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type BetaResponseBashCodeExecutionToolResultBlock = { + readonly "content": BetaResponseBashCodeExecutionToolResultError | BetaResponseBashCodeExecutionResultBlock + readonly "tool_use_id": string + readonly "type": "bash_code_execution_tool_result" } -export const DeleteSkillV1SkillsSkillIdDeleteParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaResponseBashCodeExecutionToolResultBlock = Schema.Struct({ + "content": Schema.Union([BetaResponseBashCodeExecutionToolResultError, BetaResponseBashCodeExecutionResultBlock]) + .annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "type": Schema.Literal("bash_code_execution_tool_result").annotate({ + "title": "Type", + "default": "bash_code_execution_tool_result" + }) +}).annotate({ + "title": "ResponseBashCodeExecutionToolResultBlock", + "identifier": "BetaResponseBashCodeExecutionToolResultBlock" +}) +export type BetaResponseToolSearchToolResultBlock = { + readonly "content": BetaResponseToolSearchToolResultError | BetaResponseToolSearchToolSearchResultBlock + readonly "tool_use_id": string + readonly "type": "tool_search_tool_result" +} +export const BetaResponseToolSearchToolResultBlock = Schema.Struct({ + "content": Schema.Union([BetaResponseToolSearchToolResultError, BetaResponseToolSearchToolSearchResultBlock]) + .annotate({ "title": "Content" }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", + "type": Schema.Literal("tool_search_tool_result").annotate({ "title": "Type", "default": "tool_search_tool_result" }) +}).annotate({ "title": "ResponseToolSearchToolResultBlock", "identifier": "BetaResponseToolSearchToolResultBlock" }) +export type BetaResponseFallbackBlock = { + readonly "from": BetaResponseFallbackHopInfo + readonly "to": BetaResponseFallbackHopInfo + readonly "trigger": BetaFallbackRefusalTrigger + readonly "type": "fallback" +} +export const BetaResponseFallbackBlock = Schema.Struct({ + "from": Schema.suspend((): Schema.Codec => BetaResponseFallbackHopInfo).annotate({ "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + "The model whose output ends at this point — the model that declined at this hop. When the declining hop is the requested model, its `model` echoes the top-level `model` string the caller sent (alias or canonical); when the declining hop is a fallback model, its `model` is that model's canonical id." + }), + "to": Schema.suspend((): Schema.Codec => BetaResponseFallbackHopInfo).annotate({ + "description": + "The fallback model producing the content that follows this block. Its `model` is always the canonical id." + }), + "trigger": Schema.suspend((): Schema.Codec => BetaFallbackRefusalTrigger).annotate({ + "description": "What caused the `from` model to hand over at this hop." + }), + "type": Schema.Literal("fallback").annotate({ "title": "Type", "default": "fallback" }) +}).annotate({ + "title": "ResponseFallbackBlock", + "description": + "Marks the point in `content` where one model's output gives way to the next.\n\nOne block appears per hop where a preceding model actually ran this turn and\ndeclined. A turn where no preceding model ran and declined has no such\nboundary and carries no block — the signal for whether a fallback model\nserved the response is the presence of a `fallback_message` entry in\n`usage.iterations`, not this block.\n\nThe block is treated like a server-tool content block for streaming: it\narrives via the standard `content_block_start` / `content_block_stop`\npair and carries no deltas.", + "identifier": "BetaResponseFallbackBlock" }) -export type DeleteSkillV1SkillsSkillIdDelete200 = DeleteSkillResponse -export const DeleteSkillV1SkillsSkillIdDelete200 = DeleteSkillResponse -export type DeleteSkillV1SkillsSkillIdDelete4XX = ErrorResponse -export const DeleteSkillV1SkillsSkillIdDelete4XX = ErrorResponse -export type ListSkillVersionsV1SkillsSkillIdVersionsGetParams = { - readonly "page"?: string | null - readonly "limit"?: number | null - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type BetaIterationsUsage = + | ReadonlyArray< + | BetaMessageIterationUsage + | BetaCompactionIterationUsage + | BetaAdvisorMessageIterationUsage + | BetaFallbackMessageIterationUsage + > + | null +export const BetaIterationsUsage = Schema.Union([ + Schema.Array( + Schema.Union([ + BetaMessageIterationUsage, + BetaCompactionIterationUsage, + BetaAdvisorMessageIterationUsage, + BetaFallbackMessageIterationUsage + ], { mode: "oneOf" }) + ), + Schema.Null +]).annotate({ + "title": "Iterations", + "description": + "Per-iteration token usage breakdown.\n\nEach entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:\n- Determine which iterations exceeded long context thresholds (>=200k tokens)\n- Calculate the true context window size from the last iteration\n- Understand token accumulation across server-side tool use loops", + "default": null, + "identifier": "BetaIterationsUsage" +}) +export type BetaThinkingCapability = { readonly "supported": boolean; readonly "types": BetaThinkingTypes } +export const BetaThinkingCapability = Schema.Struct({ + "supported": Schema.Boolean.annotate({ + "title": "Supported", + "description": "Whether this capability is supported by the model." + }), + "types": BetaThinkingTypes +}).annotate({ + "title": "ThinkingCapability", + "description": "Thinking capability details.", + "identifier": "BetaThinkingCapability" +}) +export type BetaListResponse_MessageBatch_ = { + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "has_more": boolean + readonly "last_id": string | null } -export const ListSkillVersionsV1SkillsSkillIdVersionsGetParams = Schema.Struct({ - "page": Schema.optionalKey( +export const BetaListResponse_MessageBatch_ = Schema.Struct({ + "data": Schema.Array(BetaMessageBatch).annotate({ "title": "Data" }), + "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "First Id", + "description": "First ID in the `data` list. Can be used as the `before_id` for the previous page." + }), + "has_more": Schema.Boolean.annotate({ + "title": "Has More", + "description": "Indicates if there are more results in the requested page direction." + }), + "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Last Id", + "description": "Last ID in the `data` list. Can be used as the `after_id` for the next page." + }) +}).annotate({ "title": "ListResponse[MessageBatch]", "identifier": "BetaListResponse_MessageBatch_" }) +export type BetaFileListResponse = { + readonly "data": ReadonlyArray + readonly "first_id"?: string | null + readonly "has_more"?: boolean + readonly "last_id"?: string | null +} +export const BetaFileListResponse = Schema.Struct({ + "data": Schema.Array(BetaFileMetadataSchema).annotate({ + "title": "Data", + "description": "List of file metadata objects." + }), + "first_id": Schema.optionalKey( Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Page", - "description": "Optionally set to the `next_page` token from the previous response." + "title": "First Id", + "description": "ID of the first file in this page of results." }) ), - "limit": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Limit", - "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`." + "has_more": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Has More", + "description": "Whether there are more results available.", + "default": false }) ), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "last_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Last Id", + "description": "ID of the last file in this page of results." }) - ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + ) +}).annotate({ "title": "FileListResponse", "identifier": "BetaFileListResponse" }) +export type BetaEnvironment = { + readonly "archived_at": string | null + readonly "config": BetaCloudConfig | BetaSelfHostedConfig + readonly "created_at": string + readonly "description": string + readonly "id": string + readonly "metadata": { readonly [x: string]: string } + readonly "name": string + readonly "scope"?: "organization" | "account" + readonly "type": "environment" + readonly "updated_at": string +} +export const BetaEnvironment = Schema.Struct({ + "archived_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Archived At", + "description": "RFC 3339 timestamp when environment was archived, or null if not archived" + }), + "config": Schema.Union([BetaCloudConfig, BetaSelfHostedConfig], { mode: "oneOf" }).annotate({ + "title": "Config", + "description": "Environment configuration (either Anthropic Cloud or self-hosted)" + }), + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": "RFC 3339 timestamp when environment was created" + }), + "description": Schema.String.annotate({ + "title": "Description", + "description": "User-provided description for the environment" + }), + "id": Schema.String.annotate({ "title": "Id", "description": "Environment identifier (e.g., 'env_...')" }), + "metadata": Schema.Record(Schema.String, Schema.String).annotate({ + "title": "Metadata", + "description": "User-provided metadata key-value pairs" + }), + "name": Schema.String.annotate({ "title": "Name", "description": "Human-readable name for the environment" }), + "scope": Schema.optionalKey( + Schema.Literals(["organization", "account"]).annotate({ + "title": "Scope", "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account." }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + "type": Schema.Literal("environment").annotate({ + "title": "Type", + "description": "The type of object (always 'environment')", + "default": "environment" + }), + "updated_at": Schema.String.annotate({ + "title": "Updated At", + "description": "RFC 3339 timestamp when environment was last updated" + }) +}).annotate({ + "title": "Environment", + "description": "Unified Environment resource for both cloud and self-hosted environments.", + "identifier": "BetaEnvironment" }) -export type ListSkillVersionsV1SkillsSkillIdVersionsGet200 = ListSkillVersionsResponse -export const ListSkillVersionsV1SkillsSkillIdVersionsGet200 = ListSkillVersionsResponse -export type ListSkillVersionsV1SkillsSkillIdVersionsGet4XX = ErrorResponse -export const ListSkillVersionsV1SkillsSkillIdVersionsGet4XX = ErrorResponse -export type CreateSkillVersionV1SkillsSkillIdVersionsPostParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string +export type BetaPublicEnvironmentCreateRequest = { + readonly "config"?: BetaCloudConfigParams | BetaSelfHostedConfigParams | null + readonly "description"?: string | null + readonly "metadata"?: { readonly [x: string]: string } + readonly "name": string + readonly "scope"?: "organization" | "account" | null } -export const CreateSkillVersionV1SkillsSkillIdVersionsPostParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaPublicEnvironmentCreateRequest = Schema.Struct({ + "config": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCloudConfigParams, BetaSelfHostedConfigParams], { mode: "oneOf" }), Schema.Null]) + .annotate({ "title": "Config", "description": "Environment configuration" }) + ), + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(1024).annotate({ "expected": "a value with a length of at most 1024" })), + Schema.Null + ]).annotate({ "title": "Description", "description": "Optional description of the environment" }) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "title": "Metadata", + "description": "User-provided metadata key-value pairs" }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + "name": Schema.String.annotate({ "title": "Name", "description": "Human-readable name for the environment" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })), + "scope": Schema.optionalKey( + Schema.Union([Schema.Literals(["organization", "account"]), Schema.Null]).annotate({ + "title": "Scope", "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only. Only applicable for self-hosted environments. If not specified, defaults based on organization type." }) ) +}).annotate({ + "title": "PublicEnvironmentCreateRequest", + "description": "Public API request to create a new environment (without org/account fields).", + "identifier": "BetaPublicEnvironmentCreateRequest" }) -export type CreateSkillVersionV1SkillsSkillIdVersionsPostRequestFormData = - Body_create_skill_version_v1_skills__skill_id__versions_post -export const CreateSkillVersionV1SkillsSkillIdVersionsPostRequestFormData = - Body_create_skill_version_v1_skills__skill_id__versions_post -export type CreateSkillVersionV1SkillsSkillIdVersionsPost200 = CreateSkillVersionResponse -export const CreateSkillVersionV1SkillsSkillIdVersionsPost200 = CreateSkillVersionResponse -export type CreateSkillVersionV1SkillsSkillIdVersionsPost4XX = ErrorResponse -export const CreateSkillVersionV1SkillsSkillIdVersionsPost4XX = ErrorResponse -export type GetSkillVersionV1SkillsSkillIdVersionsVersionGetParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string -} -export const GetSkillVersionV1SkillsSkillIdVersionsVersionGetParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export type BetaPublicEnvironmentUpdateRequest = { + readonly "config"?: BetaCloudConfigParams | BetaSelfHostedConfigParams | null + readonly "description"?: string | null + readonly "metadata"?: { readonly [x: string]: string | null } + readonly "name"?: string | null + readonly "scope"?: "organization" | "account" | null +} +export const BetaPublicEnvironmentUpdateRequest = Schema.Struct({ + "config": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCloudConfigParams, BetaSelfHostedConfigParams], { mode: "oneOf" }), Schema.Null]) + .annotate({ "title": "Config", "description": "Updated environment configuration" }) + ), + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(1024).annotate({ "expected": "a value with a length of at most 1024" })), + Schema.Null + ]).annotate({ "title": "Description", "description": "Updated description of the environment" }) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Null])).annotate({ + "title": "Metadata", + "description": "User-provided metadata key-value pairs. Set a value to null or empty string to delete the key." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + "name": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" }) + ), + Schema.Null + ]).annotate({ "title": "Name", "description": "Updated name for the environment" }) + ), + "scope": Schema.optionalKey( + Schema.Union([Schema.Literals(["organization", "account"]), Schema.Null]).annotate({ + "title": "Scope", "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only." }) - ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + ) +}).annotate({ + "title": "PublicEnvironmentUpdateRequest", + "description": "Public API request to update an environment (without org/account fields).", + "identifier": "BetaPublicEnvironmentUpdateRequest" }) -export type GetSkillVersionV1SkillsSkillIdVersionsVersionGet200 = GetSkillVersionResponse -export const GetSkillVersionV1SkillsSkillIdVersionsVersionGet200 = GetSkillVersionResponse -export type GetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX = ErrorResponse -export const GetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX = ErrorResponse -export type DeleteSkillVersionV1SkillsSkillIdVersionsVersionDeleteParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type BetaSelfHostedWorkListResponse = { + readonly "data": ReadonlyArray + readonly "next_page": string | null } -export const DeleteSkillVersionV1SkillsSkillIdVersionsVersionDeleteParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", +export const BetaSelfHostedWorkListResponse = Schema.Struct({ + "data": Schema.Array(BetaSelfHostedWork).annotate({ "title": "Data", "description": "List of work items" }), + "next_page": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Next Page", + "description": "Opaque cursor for fetching the next page of results" + }) +}).annotate({ + "title": "SelfHostedWorkListResponse", + "description": "Response when listing work items with cursor-based pagination.", + "identifier": "BetaSelfHostedWorkListResponse" +}) +export type BetaManagedAgentsListMemoriesResult = { + readonly "data"?: ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListMemoriesResult = Schema.Struct({ + "data": Schema.optionalKey( + Schema.Array(BetaManagedAgentsMemoryListItem).annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "One page of results. Each item is either a `memory` object or, when `depth` was set, a `memory_prefix` rollup marker. Items are returned in a stable, server-defined order." }) ), - "anthropic-version": Schema.optionalKey( + "next_page": Schema.optionalKey( Schema.String.annotate({ - "title": "Anthropic-Version", "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Opaque cursor for the next page (a `page_...` value), or `null` if there are no more results. Pass as `page` on the next request." }) - ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + ) +}).annotate({ + "description": "Response payload for [List memories](/en/api/beta/memory_stores/memories/list).", + "identifier": "BetaManagedAgentsListMemoriesResult" }) -export type DeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete200 = DeleteSkillVersionResponse -export const DeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete200 = DeleteSkillVersionResponse -export type DeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX = ErrorResponse -export const DeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX = ErrorResponse -export type BetaMessagesPostParams = { readonly "anthropic-beta"?: string; readonly "anthropic-version"?: string } -export const BetaMessagesPostParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export type BetaManagedAgentsListMemoryStoresResponse = { + readonly "data"?: ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListMemoryStoresResponse = Schema.Struct({ + "data": Schema.optionalKey( + Schema.Array(BetaManagedAgentsMemoryStore).annotate({ + "description": "Memory stores on this page, newest first. Empty when there are no stores matching the filters." }) ), - "anthropic-version": Schema.optionalKey( + "next_page": Schema.optionalKey( Schema.String.annotate({ - "title": "Anthropic-Version", "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Opaque cursor for the next page (a `page_...` value). Pass as `page` on the next request. `null` when there are no more results." }) ) +}).annotate({ + "description": "A page of `memory_store` results, ordered by `created_at` descending (newest first).", + "identifier": "BetaManagedAgentsListMemoryStoresResponse" }) -export type BetaMessagesPostRequestJson = BetaCreateMessageParams -export const BetaMessagesPostRequestJson = BetaCreateMessageParams -export type BetaMessagesPost200 = BetaMessage -export const BetaMessagesPost200 = BetaMessage -export type BetaMessagesPost4XX = BetaErrorResponse -export const BetaMessagesPost4XX = BetaErrorResponse -export type BetaModelsListParams = { - readonly "before_id"?: string - readonly "after_id"?: string - readonly "limit"?: number - readonly "anthropic-version"?: string - readonly "x-api-key"?: string - readonly "anthropic-beta"?: string -} -export const BetaModelsListParams = Schema.Struct({ - "before_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "Before Id", +export type BetaListTunnelsResponse = { readonly "data": ReadonlyArray; readonly "next_page": string } +export const BetaListTunnelsResponse = Schema.Struct({ + "data": Schema.Array(BetaTunnel).annotate({ "description": "List of tunnels, ordered by created_at descending." }), + "next_page": Schema.String.annotate({ + "description": "Pagination cursor for the next page, or null if no more results." + }) +}).annotate({ "description": "A paginated list of tunnels.", "identifier": "BetaListTunnelsResponse" }) +export type BetaListTunnelCertificatesResponse = { + readonly "data": ReadonlyArray + readonly "next_page": string +} +export const BetaListTunnelCertificatesResponse = Schema.Struct({ + "data": Schema.Array(BetaTunnelCertificate).annotate({ + "description": "List of certificates, ordered by created_at descending." + }), + "next_page": Schema.String.annotate({ + "description": "Pagination cursor for the next page, or null if no more results." + }) +}).annotate({ "description": "The tunnel's certificates.", "identifier": "BetaListTunnelCertificatesResponse" }) +export type BetaManagedAgentsDeploymentRun = { + readonly "type": "deployment_run" + readonly "id": string + readonly "deployment_id": string + readonly "trigger_context": BetaManagedAgentsTriggerContext + readonly "session_id": string + readonly "error": BetaManagedAgentsRunError + readonly "agent": BetaManagedAgentsAgentReference + readonly "created_at": BetaTimestamp +} +export const BetaManagedAgentsDeploymentRun = Schema.Struct({ + "type": Schema.Literal("deployment_run"), + "id": Schema.String.annotate({ "description": "Unique identifier for this run (`drun_...`)." }), + "deployment_id": Schema.String.annotate({ "description": "ID of the deployment that produced this run." }), + "trigger_context": Schema.suspend((): Schema.Codec => + BetaManagedAgentsTriggerContext + ).annotate({ "description": "What triggered this run and trigger-specific metadata." }), + "session_id": Schema.String.annotate({ + "description": "Populated on success. Null on creation failure. Exactly one of session_id or error is non-null." + }), + "error": Schema.suspend((): Schema.Codec => BetaManagedAgentsRunError).annotate({ + "description": "Populated on creation failure. Null on success. Exactly one of session_id or error is non-null." + }), + "agent": Schema.suspend((): Schema.Codec => BetaManagedAgentsAgentReference) + .annotate({ + "description": "Snapshot of the agent at fire time. Always fully resolved — deployments pin agent + version." + }), + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Time this run record was persisted." + }) +}).annotate({ + "description": + "A persistent, append-only record of a single deployment execution. Records session creation success or failure — no session lifecycle tracking.", + "identifier": "BetaManagedAgentsDeploymentRun" +}) +export type BetaManagedAgentsListVaultsResponse = { + readonly "data"?: ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListVaultsResponse = Schema.Struct({ + "data": Schema.optionalKey(Schema.Array(BetaManagedAgentsVault).annotate({ "description": "List of vaults." })), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Pagination token for the next page, or null if no more results." }) + ) +}).annotate({ + "description": "Response containing a paginated list of vaults.", + "identifier": "BetaManagedAgentsListVaultsResponse" +}) +export type BetaManagedAgentsErrorResponse = { readonly "type": "error"; readonly "error": BetaManagedAgentsError } +export const BetaManagedAgentsErrorResponse = Schema.Struct({ + "type": Schema.Literal("error").annotate({ "description": "Always \"error\" for error responses" }), + "error": BetaManagedAgentsError +}).annotate({ "identifier": "BetaManagedAgentsErrorResponse" }) +export type BetaManagedAgentsListMemoryVersionsResult = { + readonly "data"?: ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListMemoryVersionsResult = Schema.Struct({ + "data": Schema.optionalKey( + Schema.Array(BetaManagedAgentsMemoryVersion).annotate({ "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." + "One page of `memory_version` objects, ordered by `created_at` descending (newest first), with `id` as tiebreak." }) ), - "after_id": Schema.optionalKey( + "next_page": Schema.optionalKey( Schema.String.annotate({ - "title": "After Id", "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + "Opaque cursor for the next page (a `page_...` value), or `null` if there are no more results. Pass as `page` on the next request." }) + ) +}).annotate({ + "description": "Response payload for [List memory versions](/en/api/beta/memory_stores/memory_versions/list).", + "identifier": "BetaManagedAgentsListMemoryVersionsResult" +}) +export type BetaListUserProfilesResponse = { + readonly "data": ReadonlyArray + readonly "next_page": string +} +export const BetaListUserProfilesResponse = Schema.Struct({ + "data": Schema.Array(BetaUserProfile).annotate({ "description": "User profiles on this page." }), + "next_page": Schema.String.annotate({ + "description": "Cursor for the next page, or `null` when there are no more results." + }) +}).annotate({ "identifier": "BetaListUserProfilesResponse" }) +export type BetaManagedAgentsAgentTool = { + readonly "type": "agent_toolset_20260401" + readonly "default_config": BetaManagedAgentsAgentToolsetDefaultConfig + readonly "configs": ReadonlyArray +} | { + readonly "type": "mcp_toolset" + readonly "mcp_server_name": string + readonly "default_config": BetaManagedAgentsMCPToolsetDefaultConfig + readonly "configs": ReadonlyArray +} | { + readonly "type": "custom" + readonly "name": string + readonly "description": string + readonly "input_schema": BetaManagedAgentsCustomToolInputSchema +} +export const BetaManagedAgentsAgentTool = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("agent_toolset_20260401"), + "default_config": BetaManagedAgentsAgentToolsetDefaultConfig, + "configs": Schema.Array(BetaManagedAgentsAgentToolConfig) + }).annotate({ "description": "Union type for tool configurations returned in API responses." }), + Schema.Struct({ + "type": Schema.Literal("mcp_toolset"), + "mcp_server_name": Schema.String, + "default_config": BetaManagedAgentsMCPToolsetDefaultConfig, + "configs": Schema.Array(BetaManagedAgentsMCPToolConfig) + }).annotate({ "description": "Union type for tool configurations returned in API responses." }), + Schema.Struct({ + "type": Schema.Literal("custom"), + "name": Schema.String, + "description": Schema.String, + "input_schema": BetaManagedAgentsCustomToolInputSchema + }).annotate({ "description": "Union type for tool configurations returned in API responses." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsAgentTool" }) +export type BetaManagedAgentsAgentToolParams = { + readonly "type": "agent_toolset_20260401" + readonly "default_config"?: BetaManagedAgentsAgentToolsetDefaultConfigParams + readonly "configs"?: ReadonlyArray +} | { + readonly "type": "mcp_toolset" + readonly "mcp_server_name": string + readonly "default_config"?: BetaManagedAgentsMCPToolsetDefaultConfigParams + readonly "configs"?: ReadonlyArray +} | { + readonly "type": "custom" + readonly "name": string + readonly "description": string + readonly "input_schema": BetaManagedAgentsCustomToolInputSchema +} +export const BetaManagedAgentsAgentToolParams = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("agent_toolset_20260401"), + "default_config": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsAgentToolsetDefaultConfigParams + ).annotate({ "description": "Default configuration applied to all tools in this set." }) + ), + "configs": Schema.optionalKey( + Schema.Array(BetaManagedAgentsAgentToolConfigParams).annotate({ + "description": "Per-tool configuration overrides." + }) + ) + }).annotate({ "description": "Union type for tool configurations in the tools array." }), + Schema.Struct({ + "type": Schema.Literal("mcp_toolset"), + "mcp_server_name": Schema.String.annotate({ + "description": "Name of the MCP server. Must match a server name from the mcp_servers array. 1-255 characters." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ), + "default_config": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsMCPToolsetDefaultConfigParams + ).annotate({ "description": "Default configuration for all tools from this server." }) + ), + "configs": Schema.optionalKey( + Schema.Array(BetaManagedAgentsMCPToolConfigParams).annotate({ + "description": "Per-tool configuration overrides." + }) + ) + }).annotate({ "description": "Union type for tool configurations in the tools array." }), + Schema.Struct({ + "type": Schema.Literal("custom"), + "name": Schema.String.annotate({ + "description": "Unique name for the tool. 1-128 characters; letters, digits, underscores, and hyphens." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" }) + ), + "description": Schema.String.annotate({ + "description": "Description of what the tool does, shown to the agent to help it decide when to use the tool." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "input_schema": Schema.suspend((): Schema.Codec => + BetaManagedAgentsCustomToolInputSchema + ).annotate({ "description": "JSON Schema defining the expected input parameters for the tool." }) + }).annotate({ "description": "Union type for tool configurations in the tools array." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsAgentToolParams" }) +export type BetaManagedAgentsListSessionResources = { + readonly "data": ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListSessionResources = Schema.Struct({ + "data": Schema.Array(BetaManagedAgentsSessionResource).annotate({ + "description": "Resources for the session, ordered by `created_at`." + }), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Opaque cursor for the next page. Null when no more results." }) + ) +}).annotate({ + "description": "Paginated list of resources attached to a session.", + "identifier": "BetaManagedAgentsListSessionResources" +}) +export type BetaManagedAgentsSessionUsage = { + readonly "input_tokens"?: number + readonly "output_tokens"?: number + readonly "cache_read_input_tokens"?: number + readonly "cache_creation"?: BetaManagedAgentsCacheCreationUsage + readonly "list_cost"?: BetaMonetaryAmount + readonly "server_tool_use"?: BetaManagedAgentsServerToolUsage + readonly "active_seconds"?: number +} +export const BetaManagedAgentsSessionUsage = Schema.Struct({ + "input_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total input tokens consumed across all turns.", "format": "int32" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ), - "limit": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Limit", - "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", - "default": 20 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(1000)) + "output_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total output tokens generated across all turns.", "format": "int32" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + "cache_read_input_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total tokens read from prompt cache.", "format": "int32" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "cache_creation": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsCacheCreationUsage) + .annotate({ "description": "Tokens used to create prompt cache entries, broken down by cache TTL." }) + ), + "list_cost": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaMonetaryAmount).annotate({ "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Cumulative list cost of the session across all turns, priced at public list rates. Absent until cost tracking is available for the session." }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", + "server_tool_use": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsServerToolUsage).annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "Cumulative server-executed tool usage across all turns. Absent until server-tool tracking is available for the session." }) + ), + "active_seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Cumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ) +}).annotate({ + "description": "Cumulative token usage for a session across all turns.", + "identifier": "BetaManagedAgentsSessionUsage" }) -export type BetaModelsList200 = BetaListResponse_ModelInfo_ -export const BetaModelsList200 = BetaListResponse_ModelInfo_ -export type BetaModelsList4XX = BetaErrorResponse -export const BetaModelsList4XX = BetaErrorResponse -export type BetaModelsGetParams = { - readonly "anthropic-version"?: string - readonly "x-api-key"?: string - readonly "anthropic-beta"?: string -} -export const BetaModelsGetParams = Schema.Struct({ - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", +export type BetaManagedAgentsBudget = { readonly "type": "limit"; readonly "max_list_cost": BetaMonetaryAmount } +export const BetaManagedAgentsBudget = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("limit"), + "max_list_cost": Schema.suspend((): Schema.Codec => BetaMonetaryAmount).annotate({ "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Maximum list cost the session may accrue. List price is used regardless of any negotiated discount, so the cap fires at or before the actual charge." }) - ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", + }).annotate({ "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "An enforced spend ceiling on a session. Discriminated on `type`; `limit` is the only kind currently supported." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsBudget" }) +export type BetaManagedAgentsSessionUsageSnapshot = { + readonly "input_tokens"?: number + readonly "output_tokens"?: number + readonly "cache_read_input_tokens"?: number + readonly "cache_creation"?: BetaManagedAgentsCacheCreationUsage + readonly "list_cost"?: BetaMonetaryAmount + readonly "server_tool_use"?: BetaManagedAgentsServerToolUsage + readonly "active_seconds"?: number +} +export const BetaManagedAgentsSessionUsageSnapshot = Schema.Struct({ + "input_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total input tokens consumed across all turns.", "format": "int32" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "output_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total output tokens generated across all turns.", "format": "int32" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "cache_read_input_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total tokens read from prompt cache.", "format": "int32" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "cache_creation": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsCacheCreationUsage) + .annotate({ "description": "Tokens used to create prompt cache entries, broken down by cache TTL." }) + ), + "list_cost": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaMonetaryAmount).annotate({ + "description": "Cumulative list cost of the session across all turns, priced at public list rates." + }) + ), + "server_tool_use": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsServerToolUsage).annotate({ + "description": "Cumulative server-executed tool usage across all turns." }) + ), + "active_seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Cumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once. This is the duration the session's runtime cost is priced on.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ) +}).annotate({ + "description": "Point-in-time snapshot of a session's cumulative usage.", + "identifier": "BetaManagedAgentsSessionUsageSnapshot" }) -export type BetaModelsGet200 = BetaModelInfo -export const BetaModelsGet200 = BetaModelInfo -export type BetaModelsGet4XX = BetaErrorResponse -export const BetaModelsGet4XX = BetaErrorResponse -export type BetaMessageBatchesListParams = { - readonly "before_id"?: string - readonly "after_id"?: string - readonly "limit"?: number - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string -} -export const BetaMessageBatchesListParams = Schema.Struct({ - "before_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "Before Id", - "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." - }) +export type BetaManagedAgentsSessionThreadUsage = { + readonly "input_tokens"?: number + readonly "output_tokens"?: number + readonly "cache_read_input_tokens"?: number + readonly "cache_creation"?: BetaManagedAgentsCacheCreationUsage + readonly "list_cost"?: BetaMonetaryAmount + readonly "active_seconds"?: number + readonly "server_tool_use"?: BetaManagedAgentsServerToolUsage +} +export const BetaManagedAgentsSessionThreadUsage = Schema.Struct({ + "input_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total input tokens consumed across all turns.", "format": "int32" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ), - "after_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "After Id", + "output_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total output tokens generated across all turns.", "format": "int32" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "cache_read_input_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total tokens read from prompt cache.", "format": "int32" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "cache_creation": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsCacheCreationUsage) + .annotate({ "description": "Tokens used to create prompt cache entries, broken down by cache TTL." }) + ), + "list_cost": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaMonetaryAmount).annotate({ "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + "Cumulative list cost of this thread across all turns, priced at public list rates. Absent until cost tracking is available for the thread. Each figure is rounded to the nearest cent independently and the session's aggregate `usage.list_cost` additionally includes session runtime, so per-thread costs do not sum exactly to the session figure; the session figure is authoritative and is what a budget is enforced against." }) ), - "limit": Schema.optionalKey( + "active_seconds": Schema.optionalKey( Schema.Number.annotate({ - "title": "Limit", - "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", - "default": 20 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(1000)) + "description": + "Cumulative time in seconds this thread spent in running status. Equal to `stats.active_seconds`; surfaced here so a thread's usage carries every quantity its cost is priced on.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", + "server_tool_use": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsServerToolUsage).annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "Cumulative server-executed tool usage across all turns of this thread. Absent until server-tool tracking is available for the thread." + }) + ) +}).annotate({ + "description": "Cumulative token usage for a session thread across all turns.", + "identifier": "BetaManagedAgentsSessionThreadUsage" +}) +export type BetaManagedAgentsModelConfigParams = { + readonly "id": BetaManagedAgentsModel + readonly "speed"?: BetaManagedAgentsSpeed + readonly "effort"?: BetaManagedAgentsEffortParams + readonly "inference_geo"?: string +} +export const BetaManagedAgentsModelConfigParams = Schema.Struct({ + "id": BetaManagedAgentsModel, + "speed": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsSpeed).annotate({ + "description": "Inference speed mode. Defaults to `standard`." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + "effort": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsEffortParams).annotate({ "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "How hard Claude works on each inference call. Accepts a bare level string (`\"high\"`) or `{\"type\": \"high\"}`. On create, omitting it resolves the per-model default; on update, omitting it leaves the stored value unchanged." }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaMessageBatchesList200 = BetaListResponse_MessageBatch_ -export const BetaMessageBatchesList200 = BetaListResponse_MessageBatch_ -export type BetaMessageBatchesList4XX = BetaErrorResponse -export const BetaMessageBatchesList4XX = BetaErrorResponse -export type BetaMessageBatchesPostParams = { readonly "anthropic-beta"?: string; readonly "anthropic-version"?: string } -export const BetaMessageBatchesPostParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." - }) - ), - "anthropic-version": Schema.optionalKey( + "inference_geo": Schema.optionalKey( Schema.String.annotate({ - "title": "Anthropic-Version", "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Geographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo. On update, `model` is whole-object replacement — omitting inference_geo clears it." }) ) +}).annotate({ + "description": "An object that defines additional configuration control over model use", + "identifier": "BetaManagedAgentsModelConfigParams" }) -export type BetaMessageBatchesPostRequestJson = BetaCreateMessageBatchParams -export const BetaMessageBatchesPostRequestJson = BetaCreateMessageBatchParams -export type BetaMessageBatchesPost200 = BetaMessageBatch -export const BetaMessageBatchesPost200 = BetaMessageBatch -export type BetaMessageBatchesPost4XX = BetaErrorResponse -export const BetaMessageBatchesPost4XX = BetaErrorResponse -export type BetaMessageBatchesRetrieveParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type BetaManagedAgentsSessionInitialEventParams = { + readonly "type": "user.message" + readonly "content": ReadonlyArray +} | { + readonly "type": "user.define_outcome" + readonly "description": string + readonly "rubric": BetaManagedAgentsRubricParams + readonly "max_iterations"?: number } -export const BetaMessageBatchesRetrieveParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaManagedAgentsSessionInitialEventParams = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("user.message"), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ + "description": "Array of content blocks for the user message." }) - ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + }).annotate({ + "description": + "An event sent to the `session` immediately after it is created. Supports `user.message` and `user.define_outcome`." + }), + Schema.Struct({ + "type": Schema.Literal("user.define_outcome"), + "description": Schema.String.annotate({ + "description": "What the agent should produce. This is the task specification." + }), + "rubric": Schema.suspend((): Schema.Codec => BetaManagedAgentsRubricParams).annotate( + { "description": "How to grade the outcome. Text or file reference." } + ), + "max_iterations": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Eval→revision cycles before giving up. Default 3, max 20.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).annotate({ + "description": + "An event sent to the `session` immediately after it is created. Supports `user.message` and `user.define_outcome`." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsSessionInitialEventParams" }) +export type BetaManagedAgentsDeploymentInitialEventParams = { + readonly "type": "user.message" + readonly "content": ReadonlyArray +} | { + readonly "type": "user.define_outcome" + readonly "description": string + readonly "rubric": BetaManagedAgentsRubricParams + readonly "max_iterations"?: number +} | { readonly "type": "system.message"; readonly "content": ReadonlyArray } +export const BetaManagedAgentsDeploymentInitialEventParams = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("user.message"), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ + "description": "Array of content blocks for the user message." }) - ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", + }).annotate({ "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaMessageBatchesRetrieve200 = BetaMessageBatch -export const BetaMessageBatchesRetrieve200 = BetaMessageBatch -export type BetaMessageBatchesRetrieve4XX = BetaErrorResponse -export const BetaMessageBatchesRetrieve4XX = BetaErrorResponse -export type BetaMessageBatchesDeleteParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string + "An event sent to a session immediately after it is created. Supports `user.message`, `user.define_outcome`, and `system.message`." + }), + Schema.Struct({ + "type": Schema.Literal("user.define_outcome"), + "description": Schema.String.annotate({ + "description": "What the agent should produce. This is the task specification." + }), + "rubric": Schema.suspend((): Schema.Codec => BetaManagedAgentsRubricParams).annotate( + { "description": "How to grade the outcome. Text or file reference." } + ), + "max_iterations": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Eval→revision cycles before giving up. Default 3, max 20.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).annotate({ + "description": + "An event sent to a session immediately after it is created. Supports `user.message`, `user.define_outcome`, and `system.message`." + }), + Schema.Struct({ + "type": Schema.Literal("system.message"), + "content": Schema.Array(BetaManagedAgentsSystemContentBlock).annotate({ + "description": "System content blocks to append. Text-only." + }) + }).annotate({ + "description": + "An event sent to a session immediately after it is created. Supports `user.message`, `user.define_outcome`, and `system.message`." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsDeploymentInitialEventParams" }) +export type BetaManagedAgentsEventParams = + | { readonly "type": "user.message"; readonly "content": ReadonlyArray } + | { readonly "type": "user.interrupt"; readonly "session_thread_id"?: string } + | { + readonly "type": "user.tool_confirmation" + readonly "tool_use_id": string + readonly "result": BetaManagedAgentsUserToolConfirmationResult + readonly "deny_message"?: string + } + | { + readonly "type": "user.custom_tool_result" + readonly "custom_tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + } + | { + readonly "type": "user.define_outcome" + readonly "description": string + readonly "rubric": BetaManagedAgentsRubricParams + readonly "max_iterations"?: number + } + | { + readonly "type": "user.tool_result" + readonly "tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + } + | { readonly "type": "system.message"; readonly "content": ReadonlyArray } +export const BetaManagedAgentsEventParams = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("user.message"), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ + "description": "Array of content blocks for the user message." + }) + }).annotate({ "description": "Union type for event parameters that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.interrupt"), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread." + }) + ) + }).annotate({ "description": "Union type for event parameters that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_confirmation"), + "tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" }) + ), + "result": Schema.suspend((): Schema.Codec => + BetaManagedAgentsUserToolConfirmationResult + ).annotate({ "description": "The confirmation result: 'allow' or 'deny'." }), + "deny_message": Schema.optionalKey( + Schema.String.annotate({ + "description": "Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'." + }).check(Schema.isMaxLength(10000).annotate({ "expected": "a value with a length of at most 10000" })) + ) + }).annotate({ "description": "Union type for event parameters that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.custom_tool_result"), + "custom_tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" }) + ), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ) + }).annotate({ "description": "Union type for event parameters that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.define_outcome"), + "description": Schema.String.annotate({ + "description": "What the agent should produce. This is the task specification." + }), + "rubric": Schema.suspend((): Schema.Codec => BetaManagedAgentsRubricParams).annotate( + { "description": "How to grade the outcome. Text or file reference." } + ), + "max_iterations": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Eval→revision cycles before giving up. Default 3, max 20.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).annotate({ "description": "Union type for event parameters that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_result"), + "tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" }) + ), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ) + }).annotate({ "description": "Union type for event parameters that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("system.message"), + "content": Schema.Array(BetaManagedAgentsSystemContentBlock).annotate({ + "description": "System content blocks to append. Text-only." + }) + }).annotate({ "description": "Union type for event parameters that can be sent to a session." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsEventParams" }) +export type BetaManagedAgentsInputEvent = { + readonly "type": "user.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at"?: BetaTimestamp +} | { + readonly "type": "user.interrupt" + readonly "id": string + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string +} | { + readonly "type": "user.tool_confirmation" + readonly "id": string + readonly "tool_use_id": string + readonly "result": BetaManagedAgentsUserToolConfirmationResult + readonly "deny_message"?: string + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string +} | { + readonly "type": "user.custom_tool_result" + readonly "id": string + readonly "custom_tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string +} | { + readonly "type": "user.define_outcome" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "outcome_id": string + readonly "description": string + readonly "max_iterations": number + readonly "rubric": BetaManagedAgentsRubric +} | { + readonly "type": "user.tool_result" + readonly "id": string + readonly "tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string +} | { + readonly "type": "system.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at"?: BetaTimestamp } -export const BetaMessageBatchesDeleteParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", +export const BetaManagedAgentsInputEvent = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("user.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ + "description": "Array of content blocks comprising the user message." + }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the agent finished processing this message." + }) + ) + }).annotate({ "description": "Union type for events that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.interrupt"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the interrupt was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread." + }) + ) + }).annotate({ "description": "Union type for events that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_confirmation"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "result": Schema.suspend((): Schema.Codec => + BetaManagedAgentsUserToolConfirmationResult + ).annotate({ "description": "The confirmation result: 'allow' or 'deny'." }), + "deny_message": Schema.optionalKey( + Schema.String.annotate({ + "description": "Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'." + }).check(Schema.isMaxLength(10000).annotate({ "expected": "a value with a length of at most 10000" })) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the confirmation was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval." + }) + ) + }).annotate({ "description": "Union type for events that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.custom_tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "custom_tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this result was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`." + }) + ) + }).annotate({ "description": "Union type for events that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.define_outcome"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the outcome was accepted." + }), + "outcome_id": Schema.String.annotate({ + "description": + "Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list." + }), + "description": Schema.String.annotate({ + "description": "What the agent should produce. Copied from the input event." + }), + "max_iterations": Schema.Number.annotate({ + "description": "Evaluate-then-revise cycles before giving up. Default 3, max 20.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "rubric": Schema.suspend((): Schema.Codec => BetaManagedAgentsRubric).annotate({ + "description": + "How to grade the outcome. File rubrics are currently resolved to their text content; clients should handle both variants." }) - ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + }).annotate({ "description": "Union type for events that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this result was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`." + }) + ) + }).annotate({ "description": "Union type for events that can be sent to a session." }), + Schema.Struct({ + "type": Schema.Literal("system.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsSystemContentBlock).annotate({ + "description": "System content blocks. Text-only." + }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this system message was processed." + }) + ) + }).annotate({ "description": "Union type for events that can be sent to a session." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsInputEvent" }) +export type BetaManagedAgentsDeploymentInitialEvent = { + readonly "type": "user.message" + readonly "content": ReadonlyArray +} | { + readonly "type": "user.define_outcome" + readonly "description": string + readonly "rubric": BetaManagedAgentsRubric + readonly "max_iterations"?: number +} | { readonly "type": "system.message"; readonly "content": ReadonlyArray } +export const BetaManagedAgentsDeploymentInitialEvent = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("user.message"), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ + "description": "Array of content blocks for the user message." }) - ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", + }).annotate({ "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + "An event sent to a session immediately after it is created. Supports `user.message`, `user.define_outcome`, and `system.message`." + }), + Schema.Struct({ + "type": Schema.Literal("user.define_outcome"), + "description": Schema.String.annotate({ + "description": "What the agent should produce. This is the task specification." + }), + "rubric": Schema.suspend((): Schema.Codec => BetaManagedAgentsRubric).annotate({ + "description": "How to grade the outcome. Text or file reference." + }), + "max_iterations": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Eval→revision cycles before giving up. Default 3, max 20.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).annotate({ + "description": + "An event sent to a session immediately after it is created. Supports `user.message`, `user.define_outcome`, and `system.message`." + }), + Schema.Struct({ + "type": Schema.Literal("system.message"), + "content": Schema.Array(BetaManagedAgentsSystemContentBlock).annotate({ + "description": "System content blocks to append. Text-only." + }) + }).annotate({ + "description": + "An event sent to a session immediately after it is created. Supports `user.message`, `user.define_outcome`, and `system.message`." + }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsDeploymentInitialEvent" }) +export type BetaManagedAgentsMultiagentCoordinator = { + readonly "type": "coordinator" + readonly "agents": ReadonlyArray +} +export const BetaManagedAgentsMultiagentCoordinator = Schema.Struct({ + "type": Schema.Literal("coordinator"), + "agents": Schema.Array(BetaManagedAgentsMultiagentRosterEntry).annotate({ + "description": "Agents the coordinator may spawn as session threads, each resolved to a specific version." + }) +}).annotate({ + "description": "Resolved coordinator topology with a concrete agent roster.", + "identifier": "BetaManagedAgentsMultiagentCoordinator" }) -export type BetaMessageBatchesDelete200 = BetaDeleteMessageBatchResponse -export const BetaMessageBatchesDelete200 = BetaDeleteMessageBatchResponse -export type BetaMessageBatchesDelete4XX = BetaErrorResponse -export const BetaMessageBatchesDelete4XX = BetaErrorResponse -export type BetaMessageBatchesCancelParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string +export type BetaManagedAgentsMultiagentCoordinatorParams = { + readonly "type": "coordinator" + readonly "agents": ReadonlyArray } -export const BetaMessageBatchesCancelParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", +export const BetaManagedAgentsMultiagentCoordinatorParams = Schema.Struct({ + "type": Schema.Literal("coordinator"), + "agents": Schema.Array(BetaManagedAgentsMultiagentRosterEntryParams).annotate({ + "description": + "Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is an agent ID string, a versioned `{\"type\":\"agent\",\"id\",\"version\"}` reference, or `{\"type\":\"self\"}` to allow recursive self-invocation. Entries must reference distinct agents (after resolving `self` and string forms); at most one `self`. Referenced agents must exist, must not be archived, and must not themselves have `multiagent` set (depth limit 1)." + }) +}).annotate({ + "description": + "A coordinator topology: the session's primary thread orchestrates work by spawning session threads, each running an agent drawn from the `agents` roster.", + "identifier": "BetaManagedAgentsMultiagentCoordinatorParams" +}) +export type BetaManagedAgentsCredential = { + readonly "type": "vault_credential" + readonly "id": string + readonly "vault_id": string + readonly "display_name"?: string + readonly "metadata": { readonly [x: string]: string } + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "archived_at": BetaTimestamp + readonly "auth": BetaManagedAgentsCredentialAuth +} +export const BetaManagedAgentsCredential = Schema.Struct({ + "type": Schema.Literal("vault_credential"), + "id": Schema.String.annotate({ "description": "Unique identifier for the credential." }), + "vault_id": Schema.String.annotate({ "description": "Identifier of the vault this credential belongs to." }), + "display_name": Schema.optionalKey( + Schema.String.annotate({ "description": "Human-readable name for the credential." }) + ), + "metadata": Schema.Record(Schema.String, Schema.String).annotate({ + "description": "Arbitrary key-value metadata attached to the credential." + }), + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp, + "archived_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When the credential was archived. Null if not archived." + }), + "auth": Schema.suspend((): Schema.Codec => BetaManagedAgentsCredentialAuth).annotate( + { "description": "Authentication configuration for this credential." } + ) +}).annotate({ + "description": "A credential stored in a vault. Sensitive fields are never returned in responses.", + "identifier": "BetaManagedAgentsCredential" +}) +export type BetaManagedAgentsCreateCredentialRequestBody = { + readonly "auth": BetaManagedAgentsCredentialCreateAuth + readonly "display_name"?: string + readonly "metadata"?: { readonly [x: string]: string } +} +export const BetaManagedAgentsCreateCredentialRequestBody = Schema.Struct({ + "auth": Schema.suspend((): Schema.Codec => + BetaManagedAgentsCredentialCreateAuth + ).annotate({ "description": "Authentication configuration for the credential." }), + "display_name": Schema.optionalKey( + Schema.String.annotate({ "description": "Human-readable name for the credential. Up to 255 characters." }).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "Arbitrary key-value metadata to attach to the credential. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars." }) + ) +}).annotate({ "identifier": "BetaManagedAgentsCreateCredentialRequestBody" }) +export type BetaManagedAgentsUpdateCredentialRequestBody = { + readonly "display_name"?: string + readonly "metadata"?: { readonly [x: string]: string } + readonly "auth"?: BetaManagedAgentsCredentialUpdateAuth +} +export const BetaManagedAgentsUpdateCredentialRequestBody = Schema.Struct({ + "display_name": Schema.optionalKey( + Schema.String.annotate({ "description": "Updated human-readable name for the credential. 1-255 characters." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" }) + ) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omitted keys are preserved." }) + ), + "auth": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsCredentialUpdateAuth) + .annotate({ + "description": + "Updated authentication configuration. The `type` is immutable; the variant sent must match the stored credential's type." + }) ) -}) -export type BetaMessageBatchesCancel200 = BetaMessageBatch -export const BetaMessageBatchesCancel200 = BetaMessageBatch -export type BetaMessageBatchesCancel4XX = BetaErrorResponse -export const BetaMessageBatchesCancel4XX = BetaErrorResponse -export type BetaMessageBatchesResultsParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string -} -export const BetaMessageBatchesResultsParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." - }) - ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." +}).annotate({ "identifier": "BetaManagedAgentsUpdateCredentialRequestBody" }) +export type BetaManagedAgentsCredentialValidation = { + readonly "type": "vault_credential_validation" + readonly "credential_id": string + readonly "vault_id": string + readonly "status": BetaManagedAgentsCredentialValidationStatus + readonly "validated_at": BetaTimestamp + readonly "has_refresh_token": boolean + readonly "mcp_probe": BetaManagedAgentsMcpProbe + readonly "refresh": BetaManagedAgentsRefreshObject +} +export const BetaManagedAgentsCredentialValidation = Schema.Struct({ + "type": Schema.Literal("vault_credential_validation"), + "credential_id": Schema.String.annotate({ "description": "Unique identifier of the credential that was validated." }), + "vault_id": Schema.String.annotate({ "description": "Identifier of the vault containing the credential." }), + "status": Schema.suspend((): Schema.Codec => + BetaManagedAgentsCredentialValidationStatus + ).annotate({ "description": "Overall verdict of the validation probe." }), + "validated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When the validation probe was performed." + }), + "has_refresh_token": Schema.Boolean.annotate({ + "description": "Whether the credential has a refresh token configured." + }), + "mcp_probe": Schema.suspend((): Schema.Codec => BetaManagedAgentsMcpProbe).annotate({ + "description": "Details of the failing MCP probe step. Null when the probe succeeded." + }), + "refresh": Schema.suspend((): Schema.Codec => BetaManagedAgentsRefreshObject) + .annotate({ + "description": "Details of the refresh-token exchange attempted on a 401. Null when no refresh was attempted." }) - ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) +}).annotate({ + "description": "Result of live-probing a credential against its configured MCP server.", + "identifier": "BetaManagedAgentsCredentialValidation" }) -export type BetaMessageBatchesResults4XX = BetaErrorResponse -export const BetaMessageBatchesResults4XX = BetaErrorResponse -export type BetaMessagesCountTokensPostParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string +export type RequestToolSearchToolResultBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "content": RequestToolSearchToolResultError | RequestToolSearchToolSearchResultBlock + readonly "tool_use_id": string + readonly "type": "tool_search_tool_result" } -export const BetaMessagesCountTokensPostParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const RequestToolSearchToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) - ) -}) -export type BetaMessagesCountTokensPostRequestJson = BetaCountMessageTokensParams -export const BetaMessagesCountTokensPostRequestJson = BetaCountMessageTokensParams -export type BetaMessagesCountTokensPost200 = BetaCountMessageTokensResponse -export const BetaMessagesCountTokensPost200 = BetaCountMessageTokensResponse -export type BetaMessagesCountTokensPost4XX = BetaErrorResponse -export const BetaMessagesCountTokensPost4XX = BetaErrorResponse -export type BetaListFilesV1FilesGetParams = { - readonly "before_id"?: string - readonly "after_id"?: string - readonly "limit"?: number - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string -} -export const BetaListFilesV1FilesGetParams = Schema.Struct({ - "before_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "Before Id", - "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." + "content": Schema.Union([RequestToolSearchToolResultError, RequestToolSearchToolSearchResultBlock]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "after_id": Schema.optionalKey( - Schema.String.annotate({ - "title": "After Id", - "description": - "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + "type": Schema.Literal("tool_search_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestToolSearchToolResultBlock", "identifier": "RequestToolSearchToolResultBlock" }) +export type RequestDocumentBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "citations"?: RequestCitationsConfig | null + readonly "context"?: string | null + readonly "source": Base64PDFSource | PlainTextSource | ContentBlockSource | URLPDFSource + readonly "title"?: string | null + readonly "type": "document" +} +export const RequestDocumentBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "limit": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Limit", - "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", - "default": 20 - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(1000)) - ), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." - }) + "citations": Schema.optionalKey(Schema.Union([RequestCitationsConfig, Schema.Null])), + "context": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + Schema.Null + ]).annotate({ "title": "Context" }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) + "source": Schema.Union([Base64PDFSource, PlainTextSource, ContentBlockSource, URLPDFSource], { mode: "oneOf" }) + .annotate({ "title": "Source" }), + "title": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" }) + ), + Schema.Null + ]).annotate({ "title": "Title" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaListFilesV1FilesGet200 = BetaFileListResponse -export const BetaListFilesV1FilesGet200 = BetaFileListResponse -export type BetaListFilesV1FilesGet4XX = BetaErrorResponse -export const BetaListFilesV1FilesGet4XX = BetaErrorResponse -export type BetaUploadFileV1FilesPostParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string + "type": Schema.Literal("document").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestDocumentBlock", "identifier": "RequestDocumentBlock" }) +export type ResponseWebFetchToolResultBlock = { + readonly "caller": DirectCaller | ServerToolCaller | ServerToolCaller_20260120 + readonly "content": ResponseWebFetchToolResultError | ResponseWebFetchResultBlock + readonly "tool_use_id": string + readonly "type": "web_fetch_tool_result" } -export const BetaUploadFileV1FilesPostParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const ResponseWebFetchToolResultBlock = Schema.Struct({ + "caller": Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller", + "default": { "type": "direct" } + }), + "content": Schema.Union([ResponseWebFetchToolResultError, ResponseWebFetchResultBlock]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) - ) -}) -export type BetaUploadFileV1FilesPostRequestFormData = { readonly "file": string } -export const BetaUploadFileV1FilesPostRequestFormData = Schema.Struct({ - "file": Schema.String.annotate({ "description": "The file to upload", "format": "binary" }) + "type": Schema.Literal("web_fetch_tool_result").annotate({ "title": "Type", "default": "web_fetch_tool_result" }) +}).annotate({ "title": "ResponseWebFetchToolResultBlock", "identifier": "ResponseWebFetchToolResultBlock" }) +export type ModelCapabilities = { + readonly "batch": CapabilitySupport + readonly "citations": CapabilitySupport + readonly "code_execution": CapabilitySupport + readonly "context_management": ContextManagementCapability + readonly "effort": EffortCapability + readonly "image_input": CapabilitySupport + readonly "pdf_input": CapabilitySupport + readonly "structured_outputs": CapabilitySupport + readonly "thinking": ThinkingCapability +} +export const ModelCapabilities = Schema.Struct({ + "batch": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports the Batch API." + }), + "citations": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports citation generation." + }), + "code_execution": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports code execution tools." + }), + "context_management": Schema.suspend((): Schema.Codec => ContextManagementCapability) + .annotate({ "description": "Context management support and available strategies." }), + "effort": Schema.suspend((): Schema.Codec => EffortCapability).annotate({ + "description": "Effort (reasoning_effort) support and available levels." + }), + "image_input": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model accepts image content blocks." + }), + "pdf_input": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model accepts PDF content blocks." + }), + "structured_outputs": Schema.suspend((): Schema.Codec => CapabilitySupport).annotate({ + "description": "Whether the model supports structured output / JSON mode / strict tool schemas." + }), + "thinking": Schema.suspend((): Schema.Codec => ThinkingCapability).annotate({ + "description": "Thinking capability and supported type configurations." + }) +}).annotate({ + "title": "ModelCapabilities", + "description": "Model capability information.", + "identifier": "ModelCapabilities" }) -export type BetaUploadFileV1FilesPost200 = BetaFileMetadataSchema -export const BetaUploadFileV1FilesPost200 = BetaFileMetadataSchema -export type BetaUploadFileV1FilesPost4XX = BetaErrorResponse -export const BetaUploadFileV1FilesPost4XX = BetaErrorResponse -export type BetaGetFileMetadataV1FilesFileIdGetParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type BetaRequestToolSearchToolResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "content": BetaRequestToolSearchToolResultError | BetaRequestToolSearchToolSearchResultBlock + readonly "tool_use_id": string + readonly "type": "tool_search_tool_result" } -export const BetaGetFileMetadataV1FilesFileIdGetParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaRequestToolSearchToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.Union([BetaRequestToolSearchToolResultError, BetaRequestToolSearchToolSearchResultBlock]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaGetFileMetadataV1FilesFileIdGet200 = BetaFileMetadataSchema -export const BetaGetFileMetadataV1FilesFileIdGet200 = BetaFileMetadataSchema -export type BetaGetFileMetadataV1FilesFileIdGet4XX = BetaErrorResponse -export const BetaGetFileMetadataV1FilesFileIdGet4XX = BetaErrorResponse -export type BetaDeleteFileV1FilesFileIdDeleteParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string + "type": Schema.Literal("tool_search_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestToolSearchToolResultBlock", "identifier": "BetaRequestToolSearchToolResultBlock" }) +export type BetaRequestDocumentBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "citations"?: BetaRequestCitationsConfig | null + readonly "context"?: string | null + readonly "source": + | BetaBase64PDFSource + | BetaPlainTextSource + | BetaContentBlockSource + | BetaURLPDFSource + | BetaFileDocumentSource + readonly "title"?: string | null + readonly "type": "document" } -export const BetaDeleteFileV1FilesFileIdDeleteParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaRequestDocumentBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) + "citations": Schema.optionalKey(Schema.Union([BetaRequestCitationsConfig, Schema.Null])), + "context": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + Schema.Null + ]).annotate({ "title": "Context" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaDeleteFileV1FilesFileIdDelete200 = BetaFileDeleteResponse -export const BetaDeleteFileV1FilesFileIdDelete200 = BetaFileDeleteResponse -export type BetaDeleteFileV1FilesFileIdDelete4XX = BetaErrorResponse -export const BetaDeleteFileV1FilesFileIdDelete4XX = BetaErrorResponse -export type BetaDownloadFileV1FilesFileIdContentGetParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string + "source": Schema.Union([ + BetaBase64PDFSource, + BetaPlainTextSource, + BetaContentBlockSource, + BetaURLPDFSource, + BetaFileDocumentSource + ], { mode: "oneOf" }).annotate({ "title": "Source" }), + "title": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" }) + ), + Schema.Null + ]).annotate({ "title": "Title" }) + ), + "type": Schema.Literal("document").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestDocumentBlock", "identifier": "BetaRequestDocumentBlock" }) +export type BetaListDreamsResponse = { readonly "data": ReadonlyArray; readonly "next_page": string } +export const BetaListDreamsResponse = Schema.Struct({ "data": Schema.Array(BetaDream), "next_page": Schema.String }) + .annotate({ "identifier": "BetaListDreamsResponse" }) +export type BetaCreateDreamRequest = { + readonly "inputs": ReadonlyArray + readonly "model": BetaDreamModelParams + readonly "instructions"?: string +} +export const BetaCreateDreamRequest = Schema.Struct({ + "inputs": Schema.Array(BetaDreamInput), + "model": BetaDreamModelParams, + "instructions": Schema.optionalKey( + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" }) + ) + ) +}).annotate({ "identifier": "BetaCreateDreamRequest" }) +export type BetaResponseWebFetchToolResultBlock = { + readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + readonly "content": BetaResponseWebFetchToolResultError | BetaResponseWebFetchResultBlock + readonly "tool_use_id": string + readonly "type": "web_fetch_tool_result" } -export const BetaDownloadFileV1FilesFileIdContentGetParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaResponseWebFetchToolResultBlock = Schema.Struct({ + "caller": Schema.optionalKey( + Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.Union([BetaResponseWebFetchToolResultError, BetaResponseWebFetchResultBlock]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", + "type": Schema.Literal("web_fetch_tool_result").annotate({ "title": "Type", "default": "web_fetch_tool_result" }) +}).annotate({ "title": "ResponseWebFetchToolResultBlock", "identifier": "BetaResponseWebFetchToolResultBlock" }) +export type BetaUsage = { + readonly "cache_creation": BetaCacheCreation | null + readonly "cache_creation_input_tokens": number | null + readonly "cache_read_input_tokens": number | null + readonly "fallback_credit": BetaFallbackCreditUsage | null + readonly "inference_geo": string | null + readonly "input_tokens"?: number + readonly "iterations": BetaIterationsUsage + readonly "output_tokens": number + readonly "output_tokens_details": BetaOutputTokensDetails | null + readonly "server_tool_use"?: BetaServerToolUsage | null + readonly "service_tier": "standard" | "priority" | "batch" | null + readonly "speed": BetaSpeed | null +} +export const BetaUsage = Schema.Struct({ + "cache_creation": Schema.Union([BetaCacheCreation, Schema.Null]).annotate({ + "description": "Breakdown of cached tokens by TTL", + "default": null + }), + "cache_creation_input_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Cache Creation Input Tokens", + "description": "The number of input tokens used to create the cache entry.", + "default": null + }), + "cache_read_input_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]).annotate({ + "title": "Cache Read Input Tokens", + "description": "The number of input tokens read from the cache.", + "default": null + }), + "fallback_credit": Schema.Union([BetaFallbackCreditUsage, Schema.Null]).annotate({ "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + "Outcome of the `fallback_credit_token` presented on this request.\n\nPresent on every response to a non-batch request that carried a\n`fallback_credit_token`, in either redemption mode; absent otherwise (batch\nitems accept and ignore the token and carry no outcome object).", + "default": null + }), + "inference_geo": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Inference Geo", + "description": "The geographic region where inference was performed for this request.", + "default": null + }), + "input_tokens": Schema.optionalKey( + Schema.Number.annotate({ "title": "Input Tokens", "description": "The number of input tokens which were used." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) + ), + "iterations": BetaIterationsUsage, + "output_tokens": Schema.Number.annotate({ + "title": "Output Tokens", + "description": "The number of output tokens which were used." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "output_tokens_details": Schema.Union([BetaOutputTokensDetails, Schema.Null]).annotate({ + "description": + "Breakdown of output tokens by category.\n\n`output_tokens` remains the inclusive, authoritative total used for billing.\nThis object provides a read-only decomposition for observability — for example,\nhow many of the billed output tokens were spent on internal reasoning that may\nhave been summarized before being returned to you.", + "default": null + }), + "server_tool_use": Schema.optionalKey( + Schema.Union([BetaServerToolUsage, Schema.Null]).annotate({ + "description": "The number of server tool requests.", + "default": null + }) + ), + "service_tier": Schema.Union([Schema.Literals(["standard", "priority", "batch"]), Schema.Null]).annotate({ + "title": "Service Tier", + "description": "If the request used the priority, standard, or batch tier.", + "default": null + }), + "speed": Schema.Union([BetaSpeed, Schema.Null]).annotate({ + "description": "The inference speed mode used for this request.", + "default": null + }) +}).annotate({ "title": "Usage", "identifier": "BetaUsage" }) +export type BetaModelCapabilities = { + readonly "batch": BetaCapabilitySupport + readonly "citations": BetaCapabilitySupport + readonly "code_execution": BetaCapabilitySupport + readonly "context_management": BetaContextManagementCapability + readonly "effort": BetaEffortCapability + readonly "image_input": BetaCapabilitySupport + readonly "pdf_input": BetaCapabilitySupport + readonly "structured_outputs": BetaCapabilitySupport + readonly "thinking": BetaThinkingCapability +} +export const BetaModelCapabilities = Schema.Struct({ + "batch": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports the Batch API." + }), + "citations": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports citation generation." + }), + "code_execution": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports code execution tools." + }), + "context_management": Schema.suspend((): Schema.Codec => + BetaContextManagementCapability + ).annotate({ "description": "Context management support and available strategies." }), + "effort": Schema.suspend((): Schema.Codec => BetaEffortCapability).annotate({ + "description": "Effort (reasoning_effort) support and available levels." + }), + "image_input": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model accepts image content blocks." + }), + "pdf_input": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model accepts PDF content blocks." + }), + "structured_outputs": Schema.suspend((): Schema.Codec => BetaCapabilitySupport).annotate({ + "description": "Whether the model supports structured output / JSON mode / strict tool schemas." + }), + "thinking": Schema.suspend((): Schema.Codec => BetaThinkingCapability).annotate({ + "description": "Thinking capability and supported type configurations." + }) +}).annotate({ + "title": "ModelCapabilities", + "description": "Model capability information.", + "identifier": "BetaModelCapabilities" }) -export type BetaListSkillsV1SkillsGetParams = { - readonly "page"?: string | null - readonly "limit"?: number - readonly "source"?: string | null - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type BetaEnvironmentListResponse = { + readonly "data": ReadonlyArray + readonly "next_page": string | null } -export const BetaListSkillsV1SkillsGetParams = Schema.Struct({ - "page": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Page", +export const BetaEnvironmentListResponse = Schema.Struct({ + "data": Schema.Array(BetaEnvironment).annotate({ "title": "Data", "description": "List of environments." }), + "next_page": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Next Page", + "description": + "Token for fetching the next page of results. If `null`, there are no more results available. Pass this value to the `page` parameter in the next request." + }) +}).annotate({ + "title": "EnvironmentListResponse", + "description": + "Response when listing environments.\n\nThis response model uses opaque cursor-based pagination. Use the `page`\nquery parameter with the value from `next_page` to fetch the next page.", + "identifier": "BetaEnvironmentListResponse" +}) +export type BetaManagedAgentsListDeploymentRunsData = { + readonly "data": ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListDeploymentRunsData = Schema.Struct({ + "data": Schema.Array(BetaManagedAgentsDeploymentRun).annotate({ "description": "List of deployment runs." }), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Opaque cursor for the next page. Null when no more results." }) + ) +}).annotate({ + "description": "Paginated list of deployment runs. Sorted by created_at descending (most recent first).", + "identifier": "BetaManagedAgentsListDeploymentRunsData" +}) +export type BetaManagedAgentsSessionThreadAgent = { + readonly "type": "agent" + readonly "id": string + readonly "version": number + readonly "name": string + readonly "description": string + readonly "model": BetaManagedAgentsModelConfig + readonly "system": string + readonly "tools": ReadonlyArray + readonly "mcp_servers": ReadonlyArray + readonly "skills": ReadonlyArray +} +export const BetaManagedAgentsSessionThreadAgent = Schema.Struct({ + "type": Schema.Literal("agent"), + "id": Schema.String, + "version": Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "name": Schema.String, + "description": Schema.String, + "model": BetaManagedAgentsModelConfig, + "system": Schema.String, + "tools": Schema.Array(BetaManagedAgentsAgentTool), + "mcp_servers": Schema.Array(BetaManagedAgentsMCPServer), + "skills": Schema.Array(BetaManagedAgentsSkill) +}).annotate({ + "description": + "Resolved `agent` definition for a single `session_thread`. Snapshot of the agent at thread creation time. The multiagent roster is not repeated here; read it from `Session.agent`.", + "identifier": "BetaManagedAgentsSessionThreadAgent" +}) +export type BetaManagedAgentsSessionAgentUpdate = { + readonly "tools"?: ReadonlyArray + readonly "mcp_servers"?: ReadonlyArray +} +export const BetaManagedAgentsSessionAgentUpdate = Schema.Struct({ + "tools": Schema.optionalKey( + Schema.Array(BetaManagedAgentsAgentToolParams).annotate({ "description": - "Pagination token for fetching a specific page of results.\n\nPass the value from a previous response's `next_page` field to get the next page of results." + "Replacement tool list. Full replacement: the provided array becomes the new value. Send an empty array to clear; omit to preserve." }) ), - "limit": Schema.optionalKey( - Schema.Number.annotate({ - "title": "Limit", - "description": "Number of results to return per page.\n\nMaximum value is 100. Defaults to 20.", - "default": 20 - }).check(Schema.isInt()) - ), - "source": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Source", + "mcp_servers": Schema.optionalKey( + Schema.Array(BetaManagedAgentsMCPServerParams).annotate({ "description": - "Filter skills by source.\n\nIf provided, only skills from the specified source will be returned:\n* `\"custom\"`: only return user-created skills\n* `\"anthropic\"`: only return Anthropic-created skills" + "Replacement MCP server list. Full replacement: the provided array becomes the new value. Send an empty array to clear; omit to preserve." }) + ) +}).annotate({ + "description": + "Mid-session agent configuration update. Only `tools` and `mcp_servers` are updatable. Full replacement: the provided array becomes the new value. To preserve existing entries, GET the session, modify the array, and POST it back.", + "identifier": "BetaManagedAgentsSessionAgentUpdate" +}) +export type BetaManagedAgentsModelParams = BetaManagedAgentsModel | BetaManagedAgentsModelConfigParams +export const BetaManagedAgentsModelParams = Schema.Union([ + Schema.suspend((): Schema.Codec => BetaManagedAgentsModel).annotate({ + "title": "BetaManagedAgentsModel" + }), + BetaManagedAgentsModelConfigParams +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsModelParams" }) +export type BetaManagedAgentsCreateDeploymentParams = { + readonly "name": string + readonly "description"?: string + readonly "agent": BetaManagedAgentsAgentUnionParams + readonly "environment_id": string + readonly "vault_ids"?: ReadonlyArray + readonly "initial_events": ReadonlyArray + readonly "resources"?: ReadonlyArray + readonly "metadata"?: { readonly [x: string]: string } + readonly "schedule"?: BetaManagedAgentsScheduleParams + readonly "budget"?: BetaManagedAgentsBudget +} +export const BetaManagedAgentsCreateDeploymentParams = Schema.Struct({ + "name": Schema.String.annotate({ "description": "Human-readable name for the deployment." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })), + "description": Schema.optionalKey( + Schema.String.annotate({ "description": "Description of what the deployment does." }).check( + Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" }) + ) ), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", + "agent": Schema.suspend((): Schema.Codec => BetaManagedAgentsAgentUnionParams) + .annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." - }) + "Agent to deploy. Accepts the `agent` ID string, which pins the latest version, or an `agent` object with both id and version specified. The agent must exist and not be archived." + }), + "environment_id": Schema.String.annotate({ + "description": + "ID of the `environment` defining the container configuration for sessions created from this deployment." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + "vault_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Vault IDs for stored credentials the agent can use during sessions created from this deployment. Maximum 50." }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaListSkillsV1SkillsGet200 = BetaListSkillsResponse -export const BetaListSkillsV1SkillsGet200 = BetaListSkillsResponse -export type BetaListSkillsV1SkillsGet4XX = BetaErrorResponse -export const BetaListSkillsV1SkillsGet4XX = BetaErrorResponse -export type BetaCreateSkillV1SkillsPostParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string -} -export const BetaCreateSkillV1SkillsPostParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", + "initial_events": Schema.Array(BetaManagedAgentsDeploymentInitialEventParams).annotate({ + "description": "Events to send to each session immediately after creation. At least 1, maximum 50." + }), + "resources": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSessionResourceParams).annotate({ + "description": "Resources (e.g. repositories, files) to mount into each session's container. Maximum 500." + }) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": "Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars." + }) + ), + "schedule": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsScheduleParams).annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "Optional recurring cron schedule. When present, the deployment fires automatically. Both expression and timezone are required when schedule is set." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Enforced spend ceiling stamped onto each session created from this deployment, copied at session-creation time. Omit to leave sessions uncapped. The deployment agent's model must have a public list price, or the request is rejected; a multiagent roster is re-validated in full when each fire copies the cap, which fails closed the same way." }) ) +}).annotate({ + "description": "Request parameters for creating a `deployment`.", + "identifier": "BetaManagedAgentsCreateDeploymentParams" }) -export type BetaCreateSkillV1SkillsPostRequestFormData = BetaBody_create_skill_v1_skills_post -export const BetaCreateSkillV1SkillsPostRequestFormData = BetaBody_create_skill_v1_skills_post -export type BetaCreateSkillV1SkillsPost200 = BetaCreateSkillResponse -export const BetaCreateSkillV1SkillsPost200 = BetaCreateSkillResponse -export type BetaCreateSkillV1SkillsPost4XX = BetaErrorResponse -export const BetaCreateSkillV1SkillsPost4XX = BetaErrorResponse -export type BetaGetSkillV1SkillsSkillIdGetParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string -} -export const BetaGetSkillV1SkillsSkillIdGetParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( +export type BetaManagedAgentsUpdateDeploymentParams = { + readonly "name"?: string + readonly "description"?: string + readonly "agent"?: BetaManagedAgentsAgentUnionParams + readonly "environment_id"?: string + readonly "vault_ids"?: ReadonlyArray + readonly "initial_events"?: ReadonlyArray + readonly "resources"?: ReadonlyArray + readonly "metadata"?: { readonly [x: string]: string } + readonly "schedule"?: BetaManagedAgentsScheduleParams + readonly "budget"?: BetaManagedAgentsBudget +} +export const BetaManagedAgentsUpdateDeploymentParams = Schema.Struct({ + "name": Schema.optionalKey( Schema.String.annotate({ - "title": "Anthropic-Beta", + "description": "Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared." + }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) + ), + "description": Schema.optionalKey( + Schema.String.annotate({ "description": "Description. Omit to preserve; send empty string or null to clear." }) + .check(Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" })) + ), + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsAgentUnionParams).annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest version, or an `agent` object with both id and version specified. Omit to preserve. Cannot be cleared." }) ), - "anthropic-version": Schema.optionalKey( + "environment_id": Schema.optionalKey( Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "description": "ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared." + }).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })) + ), + "vault_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "Vault IDs. Full replacement. Omit to preserve; send empty array or null to clear. Maximum 50." }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaGetSkillV1SkillsSkillIdGet200 = BetaGetSkillResponse -export const BetaGetSkillV1SkillsSkillIdGet200 = BetaGetSkillResponse -export type BetaGetSkillV1SkillsSkillIdGet4XX = BetaErrorResponse -export const BetaGetSkillV1SkillsSkillIdGet4XX = BetaErrorResponse -export type BetaDeleteSkillV1SkillsSkillIdDeleteParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string -} -export const BetaDeleteSkillV1SkillsSkillIdDeleteParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", + "initial_events": Schema.optionalKey( + Schema.Array(BetaManagedAgentsDeploymentInitialEventParams).annotate({ + "description": "Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least 1, maximum 50." + }) + ), + "resources": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSessionResourceParams).annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "Session resources. Full replacement. Omit to preserve; send empty array or null to clear. Maximum 500." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values up to 512 chars." }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaDeleteSkillV1SkillsSkillIdDelete200 = BetaDeleteSkillResponse -export const BetaDeleteSkillV1SkillsSkillIdDelete200 = BetaDeleteSkillResponse -export type BetaDeleteSkillV1SkillsSkillIdDelete4XX = BetaErrorResponse -export const BetaDeleteSkillV1SkillsSkillIdDelete4XX = BetaErrorResponse -export type BetaListSkillVersionsV1SkillsSkillIdVersionsGetParams = { - readonly "page"?: string | null - readonly "limit"?: number | null - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string -} -export const BetaListSkillVersionsV1SkillsSkillIdVersionsGetParams = Schema.Struct({ - "page": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "title": "Page", - "description": "Optionally set to the `next_page` token from the previous response." - }) - ), - "limit": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "title": "Limit", - "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`." + "schedule": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsScheduleParams).annotate({ + "description": "Cron schedule. Full replacement. Omit to preserve; send null to clear (revert to manual-only)." }) ), - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + "Spend ceiling for future sessions. Full replacement. Omit to preserve; send null to clear (sessions created afterwards are uncapped). The deployment agent's model must have a public list price, or the request is rejected; a multiagent roster is re-validated in full when each fire copies the cap, which fails closed the same way." }) - ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", + ) +}).annotate({ + "description": "Request parameters for updating a `deployment`. Omit a field to preserve its current value.", + "identifier": "BetaManagedAgentsUpdateDeploymentParams" +}) +export type BetaManagedAgentsSendSessionEventsParams = { + readonly "events": ReadonlyArray +} +export const BetaManagedAgentsSendSessionEventsParams = Schema.Struct({ + "events": Schema.Array(BetaManagedAgentsEventParams).annotate({ "description": "Events to send to the `session`." }) +}).annotate({ + "description": "Request parameters for sending events to a `session`.", + "identifier": "BetaManagedAgentsSendSessionEventsParams" +}) +export type BetaManagedAgentsSendSessionEvents = { readonly "data"?: ReadonlyArray } +export const BetaManagedAgentsSendSessionEvents = Schema.Struct({ + "data": Schema.optionalKey(Schema.Array(BetaManagedAgentsInputEvent).annotate({ "description": "Sent events" })) +}).annotate({ + "description": "Events that were successfully sent to the session.", + "identifier": "BetaManagedAgentsSendSessionEvents" +}) +export type BetaManagedAgentsDeployment = { + readonly "type": "deployment" + readonly "id": string + readonly "name": string + readonly "description": string + readonly "agent": BetaManagedAgentsAgentReference + readonly "environment_id": string + readonly "vault_ids": ReadonlyArray + readonly "initial_events": ReadonlyArray + readonly "resources": ReadonlyArray + readonly "metadata": { readonly [x: string]: string } + readonly "schedule": BetaManagedAgentsSchedule + readonly "status": BetaManagedAgentsDeploymentStatus + readonly "paused_reason": BetaManagedAgentsDeploymentPausedReason + readonly "budget"?: BetaManagedAgentsBudget + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "archived_at": BetaTimestamp +} +export const BetaManagedAgentsDeployment = Schema.Struct({ + "type": Schema.Literal("deployment"), + "id": Schema.String.annotate({ "description": "Unique identifier for this deployment." }), + "name": Schema.String.annotate({ "description": "Human-readable name." }), + "description": Schema.String.annotate({ "description": "Description of what the deployment does." }), + "agent": Schema.suspend((): Schema.Codec => BetaManagedAgentsAgentReference) + .annotate({ "description": "Reference to the agent this deployment runs, resolved to a concrete version." }), + "environment_id": Schema.String.annotate({ "description": "ID of the `environment` where sessions run." }), + "vault_ids": Schema.Array(Schema.String).annotate({ + "description": "Vault IDs supplying stored credentials for sessions created from this deployment." + }), + "initial_events": Schema.Array(BetaManagedAgentsDeploymentInitialEvent).annotate({ + "description": "Events sent to each session immediately after creation." + }), + "resources": Schema.Array(BetaManagedAgentsSessionResourceConfig).annotate({ + "description": + "Resources attached to sessions created from this deployment. Echoes the input minus write-only credentials." + }), + "metadata": Schema.Record(Schema.String, Schema.String).annotate({ + "description": "Arbitrary key-value metadata. Maximum 16 pairs." + }), + "schedule": Schema.suspend((): Schema.Codec => BetaManagedAgentsSchedule).annotate({ + "description": + "Recurring cron schedule. Presence enables scheduled execution; null means manual-only. Includes computed timestamps (next fire times, last run) on the cron variant." + }), + "status": Schema.suspend((): Schema.Codec => BetaManagedAgentsDeploymentStatus) + .annotate({ "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "Computed status of the deployment: `active` or `paused`. Archived deployments report `active` with `archived_at` set." + }), + "paused_reason": Schema.suspend((): Schema.Codec => + BetaManagedAgentsDeploymentPausedReason + ).annotate({ + "description": "Why the deployment is paused. Non-null exactly when status is paused; null otherwise." + }), + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": + "Spend ceiling stamped onto each session created from this deployment. Absent when no budget is set." }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Time the deployment was created." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Time the deployment was last updated." + }), + "archived_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Time the deployment was archived. Null if not archived." + }) +}).annotate({ + "description": + "A deployment is a configured instance of an agent — it binds the agent to everything needed to run it autonomously: an environment, credentials, initial events, and an optional schedule.", + "identifier": "BetaManagedAgentsDeployment" }) -export type BetaListSkillVersionsV1SkillsSkillIdVersionsGet200 = BetaListSkillVersionsResponse -export const BetaListSkillVersionsV1SkillsSkillIdVersionsGet200 = BetaListSkillVersionsResponse -export type BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX = BetaErrorResponse -export const BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX = BetaErrorResponse -export type BetaCreateSkillVersionV1SkillsSkillIdVersionsPostParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string +export type BetaManagedAgentsMultiagent = BetaManagedAgentsMultiagentCoordinator +export const BetaManagedAgentsMultiagent = Schema.Union([BetaManagedAgentsMultiagentCoordinator], { mode: "oneOf" }) + .annotate({ + "description": "Resolved multiagent orchestration configuration as returned in API responses.", + "identifier": "BetaManagedAgentsMultiagent" + }) +export type BetaManagedAgentsMultiagentParams = BetaManagedAgentsMultiagentCoordinatorParams +export const BetaManagedAgentsMultiagentParams = Schema.Union([BetaManagedAgentsMultiagentCoordinatorParams], { + mode: "oneOf" +}).annotate({ + "description": "Multiagent orchestration configuration. Currently supports the `coordinator` topology.", + "identifier": "BetaManagedAgentsMultiagentParams" +}) +export type BetaManagedAgentsListCredentialsResponse = { + readonly "data"?: ReadonlyArray + readonly "next_page"?: string } -export const BetaCreateSkillVersionV1SkillsSkillIdVersionsPostParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." - }) +export const BetaManagedAgentsListCredentialsResponse = Schema.Struct({ + "data": Schema.optionalKey( + Schema.Array(BetaManagedAgentsCredential).annotate({ "description": "List of credentials." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." - }) + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Pagination token for the next page, or null if no more results." }) ) +}).annotate({ + "description": "Response containing a paginated list of credentials.", + "identifier": "BetaManagedAgentsListCredentialsResponse" }) -export type BetaCreateSkillVersionV1SkillsSkillIdVersionsPostRequestFormData = - BetaBody_create_skill_version_v1_skills__skill_id__versions_post -export const BetaCreateSkillVersionV1SkillsSkillIdVersionsPostRequestFormData = - BetaBody_create_skill_version_v1_skills__skill_id__versions_post -export type BetaCreateSkillVersionV1SkillsSkillIdVersionsPost200 = BetaCreateSkillVersionResponse -export const BetaCreateSkillVersionV1SkillsSkillIdVersionsPost200 = BetaCreateSkillVersionResponse -export type BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX = BetaErrorResponse -export const BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX = BetaErrorResponse -export type BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGetParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string +export type RequestToolResultBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "content"?: + | string + | ReadonlyArray< + RequestTextBlock | RequestImageBlock | RequestSearchResultBlock | RequestDocumentBlock | RequestToolReferenceBlock + > + readonly "is_error"?: boolean + readonly "tool_use_id": string + readonly "type": "tool_result" } -export const BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGetParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const RequestToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.optionalKey( + Schema.Union([ + Schema.String, + Schema.Array( + Schema.Union([ + RequestTextBlock, + RequestImageBlock, + RequestSearchResultBlock, + RequestDocumentBlock, + RequestToolReferenceBlock + ], { mode: "oneOf" }).annotate({ "title": "Block" }) + ) + ]).annotate({ "title": "Content" }) + ), + "is_error": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Is Error" })), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", + "type": Schema.Literal("tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestToolResultBlock", "identifier": "RequestToolResultBlock" }) +export type RequestWebFetchResultBlock = { + readonly "content": RequestDocumentBlock + readonly "retrieved_at"?: string | null + readonly "type": "web_fetch_result" + readonly "url": string +} +export const RequestWebFetchResultBlock = Schema.Struct({ + "content": RequestDocumentBlock, + "retrieved_at": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Retrieved At", + "description": "ISO 8601 timestamp when the content was retrieved" + }) + ), + "type": Schema.Literal("web_fetch_result").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url", "description": "Fetched content URL" }) +}).annotate({ "title": "RequestWebFetchResultBlock", "identifier": "RequestWebFetchResultBlock" }) +export type ContentBlock = + | ResponseTextBlock + | ResponseThinkingBlock + | ResponseRedactedThinkingBlock + | ResponseToolUseBlock + | ResponseServerToolUseBlock + | ResponseWebSearchToolResultBlock + | ResponseWebFetchToolResultBlock + | ResponseCodeExecutionToolResultBlock + | ResponseBashCodeExecutionToolResultBlock + | ResponseTextEditorCodeExecutionToolResultBlock + | ResponseToolSearchToolResultBlock + | ResponseContainerUploadBlock +export const ContentBlock = Schema.Union([ + ResponseTextBlock, + ResponseThinkingBlock, + ResponseRedactedThinkingBlock, + ResponseToolUseBlock, + ResponseServerToolUseBlock, + ResponseWebSearchToolResultBlock, + ResponseWebFetchToolResultBlock, + ResponseCodeExecutionToolResultBlock, + ResponseBashCodeExecutionToolResultBlock, + ResponseTextEditorCodeExecutionToolResultBlock, + ResponseToolSearchToolResultBlock, + ResponseContainerUploadBlock +], { mode: "oneOf" }).annotate({ "identifier": "ContentBlock" }) +export type ModelInfo = { + readonly "capabilities": ModelCapabilities | null + readonly "created_at": string + readonly "display_name": string + readonly "id": string + readonly "max_input_tokens": number | null + readonly "max_tokens": number | null + readonly "type": "model" +} +export const ModelInfo = Schema.Struct({ + "capabilities": Schema.Union([ModelCapabilities, Schema.Null]).annotate({ "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet200 = BetaGetSkillVersionResponse -export const BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet200 = BetaGetSkillVersionResponse -export type BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX = BetaErrorResponse -export const BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX = BetaErrorResponse -export type BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDeleteParams = { - readonly "anthropic-beta"?: string - readonly "anthropic-version"?: string - readonly "x-api-key"?: string + "Object mapping capability names to their support details. Keys are always present for all known capabilities." + }), + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": + "RFC 3339 datetime string representing the time at which the model was released. May be set to an epoch value if the release date is unknown.", + "format": "date-time" + }), + "display_name": Schema.String.annotate({ + "title": "Display Name", + "description": "A human-readable name for the model." + }), + "id": Schema.String.annotate({ "title": "Id", "description": "Unique model identifier." }), + "max_input_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ + "title": "Max Input Tokens", + "description": "Maximum input context window size in tokens for this model." + }), + "max_tokens": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ + "title": "Max Tokens", + "description": "Maximum value for the `max_tokens` parameter when using this model." + }), + "type": Schema.Literal("model").annotate({ + "title": "Type", + "description": "Object type.\n\nFor Models, this is always `\"model\"`.", + "default": "model" + }) +}).annotate({ "title": "ModelInfo", "identifier": "ModelInfo" }) +export type BetaRequestToolResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "content"?: + | string + | ReadonlyArray< + | BetaRequestTextBlock + | BetaRequestImageBlock + | BetaRequestSearchResultBlock + | BetaRequestDocumentBlock + | BetaRequestToolReferenceBlock + > + readonly "is_error"?: boolean + readonly "tool_use_id": string + readonly "type": "tool_result" } -export const BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDeleteParams = Schema.Struct({ - "anthropic-beta": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Beta", - "description": - "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." +export const BetaRequestToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." }) ), - "anthropic-version": Schema.optionalKey( - Schema.String.annotate({ - "title": "Anthropic-Version", - "description": - "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://docs.claude.com/en/api/versioning)." + "content": Schema.optionalKey( + Schema.Union([ + Schema.String, + Schema.Array( + Schema.Union([ + BetaRequestTextBlock, + BetaRequestImageBlock, + BetaRequestSearchResultBlock, + BetaRequestDocumentBlock, + BetaRequestToolReferenceBlock + ], { mode: "oneOf" }).annotate({ "title": "Block" }) + ) + ]).annotate({ "title": "Content" }) + ), + "is_error": Schema.optionalKey(Schema.Boolean.annotate({ "title": "Is Error" })), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" }) ), - "x-api-key": Schema.optionalKey(Schema.String.annotate({ - "title": "X-Api-Key", - "description": - "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." - })) -}) -export type BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete200 = BetaDeleteSkillVersionResponse -export const BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete200 = BetaDeleteSkillVersionResponse -export type BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX = BetaErrorResponse -export const BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX = BetaErrorResponse - -export interface OperationConfig { - /** - * Whether or not the response should be included in the value returned from - * an operation. - * - * If set to `true`, a tuple of `[A, HttpClientResponse]` will be returned, - * where `A` is the success type of the operation. - * - * If set to `false`, only the success type of the operation will be returned. - */ - readonly includeResponse?: boolean | undefined + "type": Schema.Literal("tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestToolResultBlock", "identifier": "BetaRequestToolResultBlock" }) +export type BetaRequestWebFetchResultBlock = { + readonly "content": BetaRequestDocumentBlock + readonly "retrieved_at"?: string | null + readonly "type": "web_fetch_result" + readonly "url": string } - -/** - * A utility type which optionally includes the response in the return result - * of an operation based upon the value of the `includeResponse` configuration - * option. - */ -export type WithOptionalResponse = Config extends { - readonly includeResponse: true -} ? [A, HttpClientResponse.HttpClientResponse] : - A - -export const make = ( - httpClient: HttpClient.HttpClient, - options: { - readonly transformClient?: ((client: HttpClient.HttpClient) => Effect.Effect) | undefined - } = {} -): AnthropicClient => { - const unexpectedStatus = (response: HttpClientResponse.HttpClientResponse) => - Effect.flatMap( - Effect.orElseSucceed(response.json, () => "Unexpected status code"), - (description) => - Effect.fail( - new HttpClientError.HttpClientError({ - reason: new HttpClientError.StatusCodeError({ - request: response.request, - response, - description: typeof description === "string" ? description : JSON.stringify(description) - }) - }) - ) +export const BetaRequestWebFetchResultBlock = Schema.Struct({ + "content": BetaRequestDocumentBlock, + "retrieved_at": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Retrieved At", + "description": "ISO 8601 timestamp when the content was retrieved" + }) + ), + "type": Schema.Literal("web_fetch_result").annotate({ "title": "Type" }), + "url": Schema.String.annotate({ "title": "Url", "description": "Fetched content URL" }) +}).annotate({ "title": "RequestWebFetchResultBlock", "identifier": "BetaRequestWebFetchResultBlock" }) +export type BetaContentBlock = + | BetaResponseTextBlock + | BetaResponseThinkingBlock + | BetaResponseRedactedThinkingBlock + | BetaResponseToolUseBlock + | BetaResponseServerToolUseBlock + | BetaResponseWebSearchToolResultBlock + | BetaResponseWebFetchToolResultBlock + | BetaResponseAdvisorToolResultBlock + | BetaResponseCodeExecutionToolResultBlock + | BetaResponseBashCodeExecutionToolResultBlock + | BetaResponseTextEditorCodeExecutionToolResultBlock + | BetaResponseToolSearchToolResultBlock + | BetaResponseMCPToolUseBlock + | BetaResponseMCPToolResultBlock + | BetaResponseContainerUploadBlock + | BetaResponseCompactionBlock + | BetaResponseFallbackBlock +export const BetaContentBlock = Schema.Union([ + BetaResponseTextBlock, + BetaResponseThinkingBlock, + BetaResponseRedactedThinkingBlock, + BetaResponseToolUseBlock, + BetaResponseServerToolUseBlock, + BetaResponseWebSearchToolResultBlock, + BetaResponseWebFetchToolResultBlock, + BetaResponseAdvisorToolResultBlock, + BetaResponseCodeExecutionToolResultBlock, + BetaResponseBashCodeExecutionToolResultBlock, + BetaResponseTextEditorCodeExecutionToolResultBlock, + BetaResponseToolSearchToolResultBlock, + BetaResponseMCPToolUseBlock, + BetaResponseMCPToolResultBlock, + BetaResponseContainerUploadBlock, + BetaResponseCompactionBlock, + BetaResponseFallbackBlock +], { mode: "oneOf" }).annotate({ "identifier": "BetaContentBlock" }) +export type BetaModelInfo = { + readonly "allowed_fallback_models": ReadonlyArray | null + readonly "capabilities": BetaModelCapabilities | null + readonly "created_at": string + readonly "display_name": string + readonly "id": string + readonly "max_input_tokens": number | null + readonly "max_tokens": number | null + readonly "type": "model" +} +export const BetaModelInfo = Schema.Struct({ + "allowed_fallback_models": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "title": "Allowed Fallback Models", + "description": + "Model IDs this model accepts as `fallbacks[i].model` on the Messages API. An empty list means the `fallbacks` parameter is not supported for this model as primary." + }), + "capabilities": Schema.Union([BetaModelCapabilities, Schema.Null]).annotate({ + "description": + "Object mapping capability names to their support details. Keys are always present for all known capabilities." + }), + "created_at": Schema.String.annotate({ + "title": "Created At", + "description": + "RFC 3339 datetime string representing the time at which the model was released. May be set to an epoch value if the release date is unknown.", + "format": "date-time" + }), + "display_name": Schema.String.annotate({ + "title": "Display Name", + "description": "A human-readable name for the model." + }), + "id": Schema.String.annotate({ "title": "Id", "description": "Unique model identifier." }), + "max_input_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ + "title": "Max Input Tokens", + "description": "Maximum input context window size in tokens for this model." + }), + "max_tokens": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ + "title": "Max Tokens", + "description": "Maximum value for the `max_tokens` parameter when using this model." + }), + "type": Schema.Literal("model").annotate({ + "title": "Type", + "description": "Object type.\n\nFor Models, this is always `\"model\"`.", + "default": "model" + }) +}).annotate({ "title": "ModelInfo", "identifier": "BetaModelInfo" }) +export type BetaManagedAgentsSessionRosterEntry = BetaManagedAgentsSessionThreadAgent | BetaManagedAgentsAdvisor +export const BetaManagedAgentsSessionRosterEntry = Schema.Union([ + BetaManagedAgentsSessionThreadAgent, + BetaManagedAgentsAdvisor +], { mode: "oneOf" }).annotate({ + "description": "A session-resolved multiagent roster entry.", + "identifier": "BetaManagedAgentsSessionRosterEntry" +}) +export type BetaManagedAgentsUpdateSessionParams = { + readonly "title"?: string + readonly "metadata"?: { readonly [x: string]: string } + readonly "vault_ids"?: ReadonlyArray + readonly "agent"?: BetaManagedAgentsSessionAgentUpdate + readonly "budget"?: BetaManagedAgentsBudget +} +export const BetaManagedAgentsUpdateSessionParams = Schema.Struct({ + "title": Schema.optionalKey( + Schema.String.annotate({ "description": "Human-readable session title." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" })) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve." + }) + ), + "vault_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Vault IDs (`vlt_*`) to attach to the session. Not yet supported; requests setting this field are rejected. Reserved for future use." + }) + ), + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsSessionAgentUpdate) + .annotate({ + "description": + "Agent configuration update. Only `tools` and `mcp_servers` are updatable mid-session. Only valid for sessions created from an agent or deployment reference. The session must not be running." + }) + ), + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": + "Enforced spend ceiling for the session. Set an object to replace the budget of a session that was created with one, or `null` to remove it; omit to preserve. A budget cannot be added to a session created without one (rejected with reason `budget_create_only`), and a removed budget cannot be re-added. Allowed in any non-terminated status. Lowering `max_list_cost` to at or below the session's consumed list cost is rejected with reason `budget_not_raised`, and every model the session can run must have a public list price or the request is rejected with reason `model_not_budgetable`." + }) + ) +}).annotate({ + "description": "Request parameters for updating a `session`. Omit a field to preserve its current value.", + "identifier": "BetaManagedAgentsUpdateSessionParams" +}) +export type BetaManagedAgentsAgentWithOverridesParams = { + readonly "type": "agent_with_overrides" + readonly "id": string + readonly "version"?: number + readonly "model"?: BetaManagedAgentsModelParams + readonly "system"?: string + readonly "tools"?: ReadonlyArray + readonly "mcp_servers"?: ReadonlyArray + readonly "skills"?: ReadonlyArray +} +export const BetaManagedAgentsAgentWithOverridesParams = Schema.Struct({ + "type": Schema.Literal("agent_with_overrides"), + "id": Schema.String.annotate({ "description": "The `agent` ID." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })), + "version": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The specific `agent` version to use. Omit to use the latest version.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "model": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsModelParams).annotate({ + "description": + "Replacement model. Accepts the model string, e.g. `claude-opus-4-6`, or a `model_config` object. Omit to use the agent's model." + }) + ), + "system": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Replacement system prompt. Up to 100,000 characters. Set to null to clear the agent's system prompt; omit to preserve it." + }).check(Schema.isMaxLength(100000).annotate({ "expected": "a value with a length of at most 100000" })) + ), + "tools": Schema.optionalKey( + Schema.Array(BetaManagedAgentsAgentToolParams).annotate({ + "description": + "Replacement tool list. Full replacement: the provided array becomes the tool configuration. Send an empty array to clear; omit to preserve the agent's tools." + }) + ), + "mcp_servers": Schema.optionalKey( + Schema.Array(BetaManagedAgentsMCPServerParams).annotate({ + "description": + "Replacement MCP server list. Full replacement: the provided array becomes the MCP servers. Send an empty array to clear; omit to preserve the agent's servers." + }) + ), + "skills": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSkillParams).annotate({ + "description": + "Replacement skill list. Full replacement: the provided array becomes the skills. Send an empty array to clear; omit to preserve the agent's skills." + }) + ) +}).annotate({ + "description": + "Reference to an `agent` plus optional configuration overrides. Each provided field replaces the agent's value for the caller's use; the agent resource is unchanged.", + "identifier": "BetaManagedAgentsAgentWithOverridesParams" +}) +export type BetaManagedAgentsListDeploymentsData = { + readonly "data": ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListDeploymentsData = Schema.Struct({ + "data": Schema.Array(BetaManagedAgentsDeployment).annotate({ "description": "List of deployments." }), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Opaque cursor for the next page. Null when no more results." }) + ) +}).annotate({ "description": "Paginated list of deployments.", "identifier": "BetaManagedAgentsListDeploymentsData" }) +export type BetaManagedAgentsAgent = { + readonly "type": "agent" + readonly "id": string + readonly "version": number + readonly "name": string + readonly "description": string + readonly "model": BetaManagedAgentsModelConfig + readonly "system": string + readonly "tools": ReadonlyArray + readonly "mcp_servers": ReadonlyArray + readonly "skills": ReadonlyArray + readonly "metadata": { readonly [x: string]: string } + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "archived_at": BetaTimestamp + readonly "multiagent": BetaManagedAgentsMultiagent +} +export const BetaManagedAgentsAgent = Schema.Struct({ + "type": Schema.Literal("agent"), + "id": Schema.String, + "version": Schema.Number.annotate({ + "description": "The agent's current version. Starts at 1 and increments when the agent is modified.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "name": Schema.String, + "description": Schema.String, + "model": BetaManagedAgentsModelConfig, + "system": Schema.String, + "tools": Schema.Array(BetaManagedAgentsAgentTool), + "mcp_servers": Schema.Array(BetaManagedAgentsMCPServer), + "skills": Schema.Array(BetaManagedAgentsSkill), + "metadata": Schema.Record(Schema.String, Schema.String), + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp, + "archived_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When the agent was archived. Null if not archived." + }), + "multiagent": Schema.suspend((): Schema.Codec => BetaManagedAgentsMultiagent).annotate({ + "description": "Multiagent orchestration configuration. Null when the agent is single-threaded." + }) +}).annotate({ "description": "A Managed Agents `agent`.", "identifier": "BetaManagedAgentsAgent" }) +export type BetaManagedAgentsCreateAgentParams = { + readonly "name": string + readonly "model": BetaManagedAgentsModelParams + readonly "description"?: string + readonly "system"?: string + readonly "tools"?: ReadonlyArray + readonly "mcp_servers"?: ReadonlyArray + readonly "skills"?: ReadonlyArray + readonly "metadata"?: { readonly [x: string]: string } + readonly "multiagent"?: BetaManagedAgentsMultiagentParams +} +export const BetaManagedAgentsCreateAgentParams = Schema.Struct({ + "name": Schema.String.annotate({ "description": "Human-readable name for the agent." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })), + "model": Schema.suspend((): Schema.Codec => BetaManagedAgentsModelParams).annotate({ + "description": + "Model identifier. Accepts the [model string](https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison), e.g. `claude-opus-4-6`, or a `model_config` object for additional configuration control" + }), + "description": Schema.optionalKey( + Schema.String.annotate({ "description": "Description of what the agent does." }).check( + Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" }) ) - const withResponse = (config: Config | undefined) => - ( - f: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect - ): (request: HttpClientRequest.HttpClientRequest) => Effect.Effect => { - const withOptionalResponse = ( - config?.includeResponse - ? (response: HttpClientResponse.HttpClientResponse) => Effect.map(f(response), (a) => [a, response]) - : (response: HttpClientResponse.HttpClientResponse) => f(response) - ) as any - return options?.transformClient - ? (request) => - Effect.flatMap( - Effect.flatMap(options.transformClient!(httpClient), (client) => client.execute(request)), - withOptionalResponse - ) - : (request) => Effect.flatMap(httpClient.execute(request), withOptionalResponse) - } - const binaryRequest = ( - request: HttpClientRequest.HttpClientRequest - ): Stream.Stream => - HttpClient.filterStatusOk(httpClient).execute(request).pipe( - Effect.map((response) => response.stream), - Stream.unwrap + ), + "system": Schema.optionalKey( + Schema.String.annotate({ "description": "System prompt for the agent." }).check( + Schema.isMaxLength(100000).annotate({ "expected": "a value with a length of at most 100000" }) ) - const decodeSuccess = - (schema: Schema) => (response: HttpClientResponse.HttpClientResponse) => - HttpClientResponse.schemaBodyJson(schema)(response) - const decodeError = - (tag: Tag, schema: Schema) => - (response: HttpClientResponse.HttpClientResponse) => - Effect.flatMap( - HttpClientResponse.schemaBodyJson(schema)(response), - (cause) => Effect.fail(AnthropicClientError(tag, cause, response)) - ) - return { - httpClient, - "messagesPost": (options) => - HttpClientRequest.post(`/v1/messages`).pipe( - HttpClientRequest.setHeaders({ "anthropic-version": options.params?.["anthropic-version"] ?? undefined }), - HttpClientRequest.bodyJsonUnsafe(options.payload), - withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(MessagesPost200), - "4xx": decodeError("MessagesPost4XX", MessagesPost4XX), - orElse: unexpectedStatus - })) - ), - "completePost": (options) => - HttpClientRequest.post(`/v1/complete`).pipe( - HttpClientRequest.setHeaders({ - "anthropic-version": options.params?.["anthropic-version"] ?? undefined, - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined - }), - HttpClientRequest.bodyJsonUnsafe(options.payload), - withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(CompletePost200), - "4xx": decodeError("CompletePost4XX", CompletePost4XX), - orElse: unexpectedStatus - })) - ), - "modelsList": (options) => - HttpClientRequest.get(`/v1/models`).pipe( - HttpClientRequest.setUrlParams({ - "before_id": options?.params?.["before_id"] as any, - "after_id": options?.params?.["after_id"] as any, - "limit": options?.params?.["limit"] as any - }), - HttpClientRequest.setHeaders({ - "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined, - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined - }), - withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(ModelsList200), - "4xx": decodeError("ModelsList4XX", ModelsList4XX), - orElse: unexpectedStatus - })) - ), - "modelsGet": (modelId, options) => - HttpClientRequest.get(`/v1/models/${modelId}`).pipe( - HttpClientRequest.setHeaders({ - "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined, - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + ), + "tools": Schema.optionalKey( + Schema.Array(BetaManagedAgentsAgentToolParams).annotate({ + "description": "Tool configurations available to the agent. Maximum of 128 tools across all toolsets allowed." + }) + ), + "mcp_servers": Schema.optionalKey( + Schema.Array(BetaManagedAgentsMCPServerParams).annotate({ + "description": + "MCP servers this agent connects to. Maximum 20. Names must be unique within the array. Every server must be referenced by an `mcp_toolset` in `tools`; unreferenced servers are rejected. See the [MCP connector guide](https://platform.claude.com/docs/en/managed-agents/mcp-connector)." + }) + ), + "skills": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSkillParams).annotate({ "description": "Skills available to the agent." }) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": "Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars." + }) + ), + "multiagent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsMultiagentParams).annotate({ + "description": + "Multiagent orchestration configuration. Currently supports the `coordinator` topology with a roster of 1-20 agents." + }) + ) +}).annotate({ + "description": "Request parameters for creating an `agent`.", + "identifier": "BetaManagedAgentsCreateAgentParams" +}) +export type BetaManagedAgentsUpdateAgentParams = { + readonly "version"?: number + readonly "name"?: string + readonly "description"?: string + readonly "model"?: BetaManagedAgentsModelParams + readonly "system"?: string + readonly "tools"?: ReadonlyArray + readonly "mcp_servers"?: ReadonlyArray + readonly "skills"?: ReadonlyArray + readonly "metadata"?: { readonly [x: string]: string } + readonly "multiagent"?: BetaManagedAgentsMultiagentParams +} +export const BetaManagedAgentsUpdateAgentParams = Schema.Struct({ + "version": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The agent's current version, used to prevent concurrent overwrites. Obtain this value from a create or retrieve response. Must be at least 1 if specified. When supplied, the request fails if it does not match the server's current version; omit to apply the update unconditionally.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "name": Schema.optionalKey( + Schema.String.annotate({ + "description": "Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared." + }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) + ), + "description": Schema.optionalKey( + Schema.String.annotate({ "description": "Description. Omit to preserve; send empty string or null to clear." }) + .check(Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" })) + ), + "model": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsModelParams).annotate({ + "description": + "Model identifier. Accepts the [model string](https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison), e.g. `claude-opus-4-6`, or a `model_config` object for additional configuration control. Omit to preserve. Cannot be cleared." + }) + ), + "system": Schema.optionalKey( + Schema.String.annotate({ "description": "System prompt. Omit to preserve; send empty string or null to clear." }) + .check(Schema.isMaxLength(100000).annotate({ "expected": "a value with a length of at most 100000" })) + ), + "tools": Schema.optionalKey( + Schema.Array(BetaManagedAgentsAgentToolParams).annotate({ + "description": + "Tool configurations available to the agent. Full replacement. Omit to preserve; send empty array or null to clear. Maximum of 128 tools across all toolsets allowed." + }) + ), + "mcp_servers": Schema.optionalKey( + Schema.Array(BetaManagedAgentsMCPServerParams).annotate({ + "description": + "MCP servers. Full replacement. Omit to preserve; send empty array or `null` to clear. Names must be unique. Maximum 20. Every server must be referenced by an `mcp_toolset` in the agent's resulting `tools`; unreferenced servers are rejected. See the [MCP connector guide](https://platform.claude.com/docs/en/managed-agents/mcp-connector)." + }) + ), + "skills": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSkillParams).annotate({ + "description": "Skills. Full replacement. Omit to preserve; send empty array or null to clear." + }) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values up to 512 chars." + }) + ), + "multiagent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsMultiagentParams).annotate({ + "description": "Multiagent orchestration configuration. Full replacement. Omit to preserve; send null to clear." + }) + ) +}).annotate({ + "description": "Request parameters for updating an `agent`. Omit a field to preserve its current value.", + "identifier": "BetaManagedAgentsUpdateAgentParams" +}) +export type RequestWebFetchToolResultBlock = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "caller"?: DirectCaller | ServerToolCaller | ServerToolCaller_20260120 + readonly "content": RequestWebFetchToolResultError | RequestWebFetchResultBlock + readonly "tool_use_id": string + readonly "type": "web_fetch_tool_result" +} +export const RequestWebFetchToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "caller": Schema.optionalKey( + Schema.Union([DirectCaller, ServerToolCaller, ServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" + }) + ), + "content": Schema.Union([RequestWebFetchToolResultError, RequestWebFetchResultBlock]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" + }) + ), + "type": Schema.Literal("web_fetch_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestWebFetchToolResultBlock", "identifier": "RequestWebFetchToolResultBlock" }) +export type Message = { + readonly "id": string + readonly "type": "message" + readonly "role": "assistant" + readonly "content": ReadonlyArray + readonly "model": Model + readonly "stop_reason": StopReason | null + readonly "stop_sequence": string | null + readonly "stop_details": RefusalStopDetails | null + readonly "usage": Usage + readonly "container": Container | null +} +export const Message = Schema.Struct({ + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." + }), + "type": Schema.Literal("message").annotate({ + "title": "Type", + "description": "Object type.\n\nFor Messages, this is always `\"message\"`.", + "default": "message" + }), + "role": Schema.Literal("assistant").annotate({ + "title": "Role", + "description": "Conversational role of the generated message.\n\nThis will always be `\"assistant\"`.", + "default": "assistant" + }), + "content": Schema.Array(ContentBlock).annotate({ + "title": "Content", + "description": + "Content generated by the model.\n\nThis is an array of content blocks, each of which has a `type` that determines its shape.\n\nExample:\n\n```json\n[{\"type\": \"text\", \"text\": \"Hi, I'm Claude.\"}]\n```\n\nIf the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output.\n\nFor example, if the input `messages` were:\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"}\n]\n```\n\nThen the response `content` might be:\n\n```json\n[{\"type\": \"text\", \"text\": \"B)\"}]\n```" + }), + "model": Model, + "stop_reason": Schema.Union([StopReason, Schema.Null]).annotate({ + "title": "Stop Reason", + "description": + "The reason that we stopped.\n\nThis may be one the following values:\n* `\"end_turn\"`: the model reached a natural stopping point\n* `\"max_tokens\"`: we exceeded the requested `max_tokens` or the model's maximum\n* `\"stop_sequence\"`: one of your provided custom `stop_sequences` was generated\n* `\"tool_use\"`: the model invoked one or more tools\n* `\"pause_turn\"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.\n* `\"refusal\"`: when streaming classifiers intervene to handle potential policy violations\n* `\"model_context_window_exceeded\"`: we exceeded the model's context window\n\nIn non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise." + }), + "stop_sequence": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Stop Sequence", + "description": + "Which custom stop sequence was generated, if any.\n\nThis value will be a non-null string if one of your custom stop sequences was generated.", + "default": null + }), + "stop_details": Schema.Union([RefusalStopDetails, Schema.Null]).annotate({ + "description": + "Structured information about why model output stopped.\n\nThis is `null` when the `stop_reason` has no additional detail to report.", + "default": null + }), + "usage": Schema.suspend((): Schema.Codec => Usage).annotate({ + "description": + "Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response from Claude.\n\nTotal input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`." + }), + "container": Schema.Union([Container, Schema.Null]).annotate({ + "description": + "Information about the container used in this request.\n\nThis will be non-null if a container tool (e.g. code execution) was used.", + "default": null + }) +}).annotate({ "title": "Message", "identifier": "Message" }) +export type ListResponse_ModelInfo_ = { + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "has_more": boolean + readonly "last_id": string | null +} +export const ListResponse_ModelInfo_ = Schema.Struct({ + "data": Schema.Array(ModelInfo).annotate({ "title": "Data" }), + "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "First Id", + "description": "First ID in the `data` list. Can be used as the `before_id` for the previous page." + }), + "has_more": Schema.Boolean.annotate({ + "title": "Has More", + "description": "Indicates if there are more results in the requested page direction." + }), + "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Last Id", + "description": "Last ID in the `data` list. Can be used as the `after_id` for the next page." + }) +}).annotate({ "title": "ListResponse[ModelInfo]", "identifier": "ListResponse_ModelInfo_" }) +export type BetaRequestWebFetchToolResultBlock = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "caller"?: BetaDirectCaller | BetaServerToolCaller | BetaServerToolCaller_20260120 + readonly "content": BetaRequestWebFetchToolResultError | BetaRequestWebFetchResultBlock + readonly "tool_use_id": string + readonly "type": "web_fetch_tool_result" +} +export const BetaRequestWebFetchToolResultBlock = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": "Create a cache control breakpoint at this content block." + }) + ), + "caller": Schema.optionalKey( + Schema.Union([BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller_20260120], { mode: "oneOf" }).annotate({ + "title": "Caller" + }) + ), + "content": Schema.Union([BetaRequestWebFetchToolResultError, BetaRequestWebFetchResultBlock]).annotate({ + "title": "Content" + }), + "tool_use_id": Schema.String.annotate({ "title": "Tool Use Id" }).check( + Schema.isPattern(new RegExp("^srvtoolu_[a-zA-Z0-9_]+$")).annotate({ + "expected": "a string matching the RegExp ^srvtoolu_[a-zA-Z0-9_]+$" + }) + ), + "type": Schema.Literal("web_fetch_tool_result").annotate({ "title": "Type" }) +}).annotate({ "title": "RequestWebFetchToolResultBlock", "identifier": "BetaRequestWebFetchToolResultBlock" }) +export type BetaMessage = { + readonly "id": string + readonly "type": "message" + readonly "role": "assistant" + readonly "content": ReadonlyArray + readonly "model": Model + readonly "stop_reason": BetaStopReason | null + readonly "stop_sequence": string | null + readonly "stop_details": BetaRefusalStopDetails | null + readonly "usage": BetaUsage + readonly "diagnostics": BetaDiagnostics | null + readonly "context_management"?: BetaResponseContextManagement | null + readonly "container"?: BetaContainer | null +} +export const BetaMessage = Schema.Struct({ + "id": Schema.String.annotate({ + "title": "Id", + "description": "Unique object identifier.\n\nThe format and length of IDs may change over time." + }), + "type": Schema.Literal("message").annotate({ + "title": "Type", + "description": "Object type.\n\nFor Messages, this is always `\"message\"`.", + "default": "message" + }), + "role": Schema.Literal("assistant").annotate({ + "title": "Role", + "description": "Conversational role of the generated message.\n\nThis will always be `\"assistant\"`.", + "default": "assistant" + }), + "content": Schema.Array(BetaContentBlock).annotate({ + "title": "Content", + "description": + "Content generated by the model.\n\nThis is an array of content blocks, each of which has a `type` that determines its shape.\n\nExample:\n\n```json\n[{\"type\": \"text\", \"text\": \"Hi, I'm Claude.\"}]\n```\n\nIf the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output.\n\nFor example, if the input `messages` were:\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"}\n]\n```\n\nThen the response `content` might be:\n\n```json\n[{\"type\": \"text\", \"text\": \"B)\"}]\n```" + }), + "model": Model, + "stop_reason": Schema.Union([BetaStopReason, Schema.Null]).annotate({ + "title": "Stop Reason", + "description": + "The reason that we stopped.\n\nThis may be one the following values:\n* `\"end_turn\"`: the model reached a natural stopping point\n* `\"max_tokens\"`: we exceeded the requested `max_tokens` or the model's maximum\n* `\"stop_sequence\"`: one of your provided custom `stop_sequences` was generated\n* `\"tool_use\"`: the model invoked one or more tools\n* `\"pause_turn\"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.\n* `\"refusal\"`: when streaming classifiers intervene to handle potential policy violations\n* `\"model_context_window_exceeded\"`: we exceeded the model's context window\n\nIn non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise." + }), + "stop_sequence": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Stop Sequence", + "description": + "Which custom stop sequence was generated, if any.\n\nThis value will be a non-null string if one of your custom stop sequences was generated.", + "default": null + }), + "stop_details": Schema.Union([BetaRefusalStopDetails, Schema.Null]).annotate({ + "description": + "Structured information about why model output stopped.\n\nThis is `null` when the `stop_reason` has no additional detail to report.", + "default": null + }), + "usage": Schema.suspend((): Schema.Codec => BetaUsage).annotate({ + "description": + "Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response from Claude.\n\nTotal input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`." + }), + "diagnostics": Schema.Union([BetaDiagnostics, Schema.Null]).annotate({ + "description": + "Request-level diagnostics. Present only when `diagnostics` was supplied on the request; `null` when no prompt-cache divergence was detected.", + "default": null + }), + "context_management": Schema.optionalKey( + Schema.Union([BetaResponseContextManagement, Schema.Null]).annotate({ + "description": + "Context management response.\n\nInformation about context management strategies applied during the request.", + "default": null + }) + ), + "container": Schema.optionalKey( + Schema.Union([BetaContainer, Schema.Null]).annotate({ + "description": + "Information about the container used in this request.\n\nThis will be non-null if a container tool (e.g. code execution) was used.", + "default": null + }) + ) +}).annotate({ "title": "Message", "identifier": "BetaMessage" }) +export type BetaListResponse_ModelInfo_ = { + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "has_more": boolean + readonly "last_id": string | null +} +export const BetaListResponse_ModelInfo_ = Schema.Struct({ + "data": Schema.Array(BetaModelInfo).annotate({ "title": "Data" }), + "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "First Id", + "description": "First ID in the `data` list. Can be used as the `before_id` for the previous page." + }), + "has_more": Schema.Boolean.annotate({ + "title": "Has More", + "description": "Indicates if there are more results in the requested page direction." + }), + "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Last Id", + "description": "Last ID in the `data` list. Can be used as the `after_id` for the next page." + }) +}).annotate({ "title": "ListResponse[ModelInfo]", "identifier": "BetaListResponse_ModelInfo_" }) +export type BetaManagedAgentsSessionMultiagentCoordinator = { + readonly "type": "coordinator" + readonly "agents": ReadonlyArray +} +export const BetaManagedAgentsSessionMultiagentCoordinator = Schema.Struct({ + "type": Schema.Literal("coordinator"), + "agents": Schema.Array(BetaManagedAgentsSessionRosterEntry).annotate({ + "description": "Full `agent` definitions the coordinator may spawn as session threads." + }) +}).annotate({ + "description": "Resolved coordinator topology with full agent definitions for each roster member.", + "identifier": "BetaManagedAgentsSessionMultiagentCoordinator" +}) +export type BetaManagedAgentsSessionThread = { + readonly "type": "session_thread" + readonly "id": string + readonly "session_id": string + readonly "status": BetaManagedAgentsSessionThreadStatus + readonly "agent": BetaManagedAgentsSessionRosterEntry + readonly "parent_thread_id": string + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "archived_at": BetaTimestamp + readonly "usage": BetaManagedAgentsSessionThreadUsage + readonly "stats": BetaManagedAgentsSessionThreadStats +} +export const BetaManagedAgentsSessionThread = Schema.Struct({ + "type": Schema.Literal("session_thread"), + "id": Schema.String.annotate({ "description": "Unique identifier for this thread." }), + "session_id": Schema.String.annotate({ "description": "The session this thread belongs to." }), + "status": Schema.suspend((): Schema.Codec => + BetaManagedAgentsSessionThreadStatus + ).annotate({ "description": "Current execution status of the thread." }), + "agent": Schema.suspend((): Schema.Codec => BetaManagedAgentsSessionRosterEntry) + .annotate({ + "description": "Resolved agent definition for this thread. Snapshot of the agent at thread creation time." + }), + "parent_thread_id": Schema.String.annotate({ + "description": "Parent thread that spawned this thread. Null for the primary thread." + }), + "created_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When the thread was created." + }), + "updated_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When the thread was last updated." + }), + "archived_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When the thread was archived. Null if not archived." + }), + "usage": Schema.suspend((): Schema.Codec => BetaManagedAgentsSessionThreadUsage) + .annotate({ + "description": "Cumulative token usage for this thread. Null until the thread's first idle transition." + }), + "stats": Schema.suspend((): Schema.Codec => BetaManagedAgentsSessionThreadStats) + .annotate({ "description": "Timing statistics for this thread. Null until the thread's first status transition." }) +}).annotate({ + "description": + "An execution thread within a `session`. Each session has one primary thread plus zero or more child threads spawned by the coordinator.", + "identifier": "BetaManagedAgentsSessionThread" +}) +export type BetaManagedAgentsCreateSessionAgentUnionParams = + | string + | BetaManagedAgentsAgentParams + | BetaManagedAgentsAgentWithOverridesParams +export const BetaManagedAgentsCreateSessionAgentUnionParams = Schema.Union([ + Schema.String, + Schema.Union([BetaManagedAgentsAgentParams, BetaManagedAgentsAgentWithOverridesParams], { mode: "oneOf" }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsCreateSessionAgentUnionParams" }) +export type BetaManagedAgentsListAgents = { + readonly "data": ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListAgents = Schema.Struct({ + "data": Schema.Array(BetaManagedAgentsAgent).annotate({ "description": "List of agents." }), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Opaque cursor for the next page. Null when no more results." }) + ) +}).annotate({ "description": "Paginated list of agents.", "identifier": "BetaManagedAgentsListAgents" }) +export type BetaManagedAgentsListAgentVersions = { + readonly "data": ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListAgentVersions = Schema.Struct({ + "data": Schema.Array(BetaManagedAgentsAgent).annotate({ "description": "Agent versions." }), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Opaque cursor for the next page. Null when no more results." }) + ) +}).annotate({ "description": "Paginated list of agent versions.", "identifier": "BetaManagedAgentsListAgentVersions" }) +export type InputContentBlock = + | RequestTextBlock + | RequestImageBlock + | RequestDocumentBlock + | RequestSearchResultBlock + | RequestThinkingBlock + | RequestRedactedThinkingBlock + | RequestToolUseBlock + | RequestToolResultBlock + | RequestServerToolUseBlock + | RequestWebSearchToolResultBlock + | RequestWebFetchToolResultBlock + | RequestCodeExecutionToolResultBlock + | RequestBashCodeExecutionToolResultBlock + | RequestTextEditorCodeExecutionToolResultBlock + | RequestToolSearchToolResultBlock + | RequestContainerUploadBlock + | RequestMidConvSystemBlock +export const InputContentBlock = Schema.Union([ + Schema.suspend((): Schema.Codec => RequestTextBlock).annotate({ + "description": "Regular text content." + }), + Schema.suspend((): Schema.Codec => RequestImageBlock).annotate({ + "description": "Image content specified directly as base64 data or as a reference via a URL." + }), + Schema.suspend((): Schema.Codec => RequestDocumentBlock).annotate({ + "description": "Document content, either specified directly as base64 data, as text, or as a reference via a URL." + }), + Schema.suspend((): Schema.Codec => RequestSearchResultBlock).annotate({ + "description": "A search result block containing source, title, and content from search operations." + }), + Schema.suspend((): Schema.Codec => RequestThinkingBlock).annotate({ + "description": "A block specifying internal thinking by the model." + }), + Schema.suspend((): Schema.Codec => RequestRedactedThinkingBlock).annotate({ + "description": "A block specifying internal, redacted thinking by the model." + }), + Schema.suspend((): Schema.Codec => RequestToolUseBlock).annotate({ + "description": "A block indicating a tool use by the model." + }), + Schema.suspend((): Schema.Codec => RequestToolResultBlock).annotate({ + "description": "A block specifying the results of a tool use by the model." + }), + RequestServerToolUseBlock, + RequestWebSearchToolResultBlock, + RequestWebFetchToolResultBlock, + RequestCodeExecutionToolResultBlock, + RequestBashCodeExecutionToolResultBlock, + RequestTextEditorCodeExecutionToolResultBlock, + RequestToolSearchToolResultBlock, + RequestContainerUploadBlock, + RequestMidConvSystemBlock +], { mode: "oneOf" }).annotate({ "identifier": "InputContentBlock" }) +export type BetaInputContentBlock = + | BetaRequestTextBlock + | BetaRequestImageBlock + | BetaRequestDocumentBlock + | BetaRequestSearchResultBlock + | BetaRequestThinkingBlock + | BetaRequestRedactedThinkingBlock + | BetaRequestToolUseBlock + | BetaRequestToolResultBlock + | BetaRequestServerToolUseBlock + | BetaRequestWebSearchToolResultBlock + | BetaRequestWebFetchToolResultBlock + | BetaRequestAdvisorToolResultBlock + | BetaRequestCodeExecutionToolResultBlock + | BetaRequestBashCodeExecutionToolResultBlock + | BetaRequestTextEditorCodeExecutionToolResultBlock + | BetaRequestToolSearchToolResultBlock + | BetaRequestMCPToolUseBlock + | BetaRequestMCPToolResultBlock + | BetaRequestContainerUploadBlock + | BetaRequestCompactionBlock + | BetaRequestMidConvSystemBlock + | BetaRequestToolAdditionBlock + | BetaRequestToolRemovalBlock + | BetaRequestFallbackBlock +export const BetaInputContentBlock = Schema.Union([ + Schema.suspend((): Schema.Codec => BetaRequestTextBlock).annotate({ + "description": "Regular text content." + }), + Schema.suspend((): Schema.Codec => BetaRequestImageBlock).annotate({ + "description": "Image content specified directly as base64 data or as a reference via a URL." + }), + Schema.suspend((): Schema.Codec => BetaRequestDocumentBlock).annotate({ + "description": "Document content, either specified directly as base64 data, as text, or as a reference via a URL." + }), + Schema.suspend((): Schema.Codec => BetaRequestSearchResultBlock).annotate({ + "description": "A search result block containing source, title, and content from search operations." + }), + Schema.suspend((): Schema.Codec => BetaRequestThinkingBlock).annotate({ + "description": "A block specifying internal thinking by the model." + }), + Schema.suspend((): Schema.Codec => BetaRequestRedactedThinkingBlock).annotate({ + "description": "A block specifying internal, redacted thinking by the model." + }), + Schema.suspend((): Schema.Codec => BetaRequestToolUseBlock).annotate({ + "description": "A block indicating a tool use by the model." + }), + Schema.suspend((): Schema.Codec => BetaRequestToolResultBlock).annotate({ + "description": "A block specifying the results of a tool use by the model." + }), + BetaRequestServerToolUseBlock, + BetaRequestWebSearchToolResultBlock, + BetaRequestWebFetchToolResultBlock, + BetaRequestAdvisorToolResultBlock, + BetaRequestCodeExecutionToolResultBlock, + BetaRequestBashCodeExecutionToolResultBlock, + BetaRequestTextEditorCodeExecutionToolResultBlock, + BetaRequestToolSearchToolResultBlock, + BetaRequestMCPToolUseBlock, + BetaRequestMCPToolResultBlock, + BetaRequestContainerUploadBlock, + BetaRequestCompactionBlock, + BetaRequestMidConvSystemBlock, + BetaRequestToolAdditionBlock, + BetaRequestToolRemovalBlock, + BetaRequestFallbackBlock +], { mode: "oneOf" }).annotate({ "identifier": "BetaInputContentBlock" }) +export type BetaManagedAgentsSessionMultiagent = BetaManagedAgentsSessionMultiagentCoordinator +export const BetaManagedAgentsSessionMultiagent = Schema.Union([BetaManagedAgentsSessionMultiagentCoordinator], { + mode: "oneOf" +}).annotate({ + "description": "Resolved multiagent orchestration configuration as returned on a `session`.", + "identifier": "BetaManagedAgentsSessionMultiagent" +}) +export type BetaManagedAgentsListSessionThreads = { + readonly "data"?: ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListSessionThreads = Schema.Struct({ + "data": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSessionThread).annotate({ + "description": "Threads in the session, primary first then children in spawn order." + }) + ), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Opaque cursor for the next page. Null when no more results." }) + ) +}).annotate({ + "description": "Paginated list of threads within a `session`.", + "identifier": "BetaManagedAgentsListSessionThreads" +}) +export type BetaManagedAgentsCreateSessionParams = { + readonly "agent": BetaManagedAgentsCreateSessionAgentUnionParams + readonly "environment_id": string + readonly "title"?: string + readonly "metadata"?: { readonly [x: string]: string } + readonly "resources"?: ReadonlyArray + readonly "vault_ids"?: ReadonlyArray + readonly "initial_events"?: ReadonlyArray + readonly "budget"?: BetaManagedAgentsBudget +} +export const BetaManagedAgentsCreateSessionParams = Schema.Struct({ + "agent": Schema.suspend((): Schema.Codec => + BetaManagedAgentsCreateSessionAgentUnionParams + ).annotate({ + "description": + "Agent identifier. Accepts the `agent` ID string, which pins the latest version for the session, or an `agent` object with both id and version specified." + }), + "environment_id": Schema.String.annotate({ + "description": "ID of the `environment` defining the container configuration for this session." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" }) + ), + "title": Schema.optionalKey( + Schema.String.annotate({ "description": "Human-readable session title." }).check( + Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" }) + ) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "Arbitrary key-value metadata attached to the session. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars." + }) + ), + "resources": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSessionResourceParams).annotate({ + "description": "Resources (e.g. repositories, files) to mount into the session's container." + }) + ), + "vault_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "Vault IDs for stored credentials the agent can use during the session." + }) + ), + "initial_events": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSessionInitialEventParams).annotate({ + "description": + "Initial events to send to the `session` at creation, processed in order. Supports `user.message` and `user.define_outcome` events. Maximum 50 events." + }) + ), + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": + "Enforced spend ceiling for the session. Omit to create an uncapped session. Every model the session can run — the agent's model and each callable agent's model — must have a public list price, or the request is rejected with reason `model_not_budgetable`." + }) + ) +}).annotate({ + "description": "Request parameters for creating a `session`.", + "identifier": "BetaManagedAgentsCreateSessionParams" +}) +export type InputMessage = { + readonly "content": string | ReadonlyArray + readonly "role": "user" | "assistant" | "system" +} +export const InputMessage = Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Array(InputContentBlock)]).annotate({ "title": "Content" }), + "role": Schema.Literals(["user", "assistant", "system"]).annotate({ "title": "Role" }) +}).annotate({ "title": "InputMessage", "identifier": "InputMessage" }) +export type BetaInputMessage = { + readonly "content": string | ReadonlyArray + readonly "role": "user" | "assistant" | "system" +} +export const BetaInputMessage = Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Array(BetaInputContentBlock)]).annotate({ "title": "Content" }), + "role": Schema.Literals(["user", "assistant", "system"]).annotate({ "title": "Role" }) +}).annotate({ "title": "InputMessage", "identifier": "BetaInputMessage" }) +export type BetaManagedAgentsSessionAgent = { + readonly "type": "agent" + readonly "id": string + readonly "version": number + readonly "name": string + readonly "description": string + readonly "model": BetaManagedAgentsModelConfig + readonly "system": string + readonly "tools": ReadonlyArray + readonly "mcp_servers": ReadonlyArray + readonly "skills": ReadonlyArray + readonly "multiagent": BetaManagedAgentsSessionMultiagent +} +export const BetaManagedAgentsSessionAgent = Schema.Struct({ + "type": Schema.Literal("agent"), + "id": Schema.String, + "version": Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "name": Schema.String, + "description": Schema.String, + "model": BetaManagedAgentsModelConfig, + "system": Schema.String, + "tools": Schema.Array(BetaManagedAgentsAgentTool), + "mcp_servers": Schema.Array(BetaManagedAgentsMCPServer), + "skills": Schema.Array(BetaManagedAgentsSkill), + "multiagent": Schema.suspend((): Schema.Codec => + BetaManagedAgentsSessionMultiagent + ).annotate({ + "description": "Resolved multiagent orchestration configuration. Null when the agent is single-threaded." + }) +}).annotate({ + "description": "Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.", + "identifier": "BetaManagedAgentsSessionAgent" +}) +export type CreateMessageParams = { + readonly "model": Model + readonly "messages": ReadonlyArray + readonly "cache_control"?: CacheControlEphemeral | null + readonly "container"?: string | null + readonly "inference_geo"?: string | null + readonly "max_tokens": number + readonly "metadata"?: Metadata + readonly "output_config"?: OutputConfig + readonly "service_tier"?: "auto" | "standard_only" + readonly "stop_sequences"?: ReadonlyArray + readonly "stream"?: boolean + readonly "system"?: string | ReadonlyArray + readonly "temperature"?: number + readonly "thinking"?: ThinkingConfigParam + readonly "tool_choice"?: ToolChoice + readonly "tools"?: ReadonlyArray< + | Tool + | BashTool_20250124 + | CodeExecutionTool_20250522 + | CodeExecutionTool_20250825 + | CodeExecutionTool_20260120 + | CodeExecutionTool_20260521 + | MemoryTool_20250818 + | TextEditor_20250124 + | TextEditor_20250429 + | TextEditor_20250728 + | WebSearchTool_20250305 + | WebFetchTool_20250910 + | WebSearchTool_20260209 + | WebFetchTool_20260209 + | WebFetchTool_20260309 + | WebSearchTool_20260318 + | WebFetchTool_20260318 + | ToolSearchToolBM25_20251119 + | ToolSearchToolRegex_20251119 + > + readonly "top_k"?: number + readonly "top_p"?: number +} +export const CreateMessageParams = Schema.Struct({ + "model": Model, + "messages": Schema.Array(InputMessage).annotate({ + "title": "Messages", + "description": + "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).\n\nNote that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." + }), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": + "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." + }) + ), + "container": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Container", + "description": "Container identifier for reuse across requests." + }) + ), + "inference_geo": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Inference Geo", + "description": + "Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used." + }) + ), + "max_tokens": Schema.Number.annotate({ + "title": "Max Tokens", + "description": + "The maximum number of tokens to generate before stopping.\n\nNote that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.\n\nSet to `0` to populate the [prompt cache](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pre-warming-the-cache) without generating a response.\n\nDifferent models have different maximum values for this parameter. See [models](https://platform.claude.com/docs/en/about-claude/models/overview) for details." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "metadata": Schema.optionalKey( + Schema.suspend((): Schema.Codec => Metadata).annotate({ + "description": "An object describing metadata about the request." + }) + ), + "output_config": Schema.optionalKey( + Schema.suspend((): Schema.Codec => OutputConfig).annotate({ + "description": "Configuration options for the model's output, such as the output format." + }) + ), + "service_tier": Schema.optionalKey( + Schema.Literals(["auto", "standard_only"]).annotate({ + "title": "Service Tier", + "description": + "Determines whether to use priority capacity (if available) or standard capacity for this request.\n\nAnthropic offers different levels of service for your API requests. See [service-tiers](https://platform.claude.com/docs/en/api/service-tiers) for details." + }) + ), + "stop_sequences": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "title": "Stop Sequences", + "description": + "Custom text sequences that will cause the model to stop generating.\n\nOur models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `\"end_turn\"`.\n\nIf you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"` and the response `stop_sequence` value will contain the matched stop sequence." + }) + ), + "stream": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Stream", + "description": + "Whether to incrementally stream the response using server-sent events.\n\nSee [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming) for details." + }) + ), + "system": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Array(RequestTextBlock)]).annotate({ + "title": "System", + "description": + "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role)." + }) + ), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Temperature", + "description": + "Amount of randomness injected into the response.\n\nDefaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.\n\nNote that even with `temperature` of `0.0`, the results will not be fully deterministic." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) + ), + "thinking": Schema.optionalKey(ThinkingConfigParam), + "tool_choice": Schema.optionalKey(ToolChoice), + "tools": Schema.optionalKey( + Schema.Array( + Schema.Union([ + Tool, + BashTool_20250124, + CodeExecutionTool_20250522, + CodeExecutionTool_20250825, + CodeExecutionTool_20260120, + CodeExecutionTool_20260521, + MemoryTool_20250818, + TextEditor_20250124, + TextEditor_20250429, + TextEditor_20250728, + WebSearchTool_20250305, + WebFetchTool_20250910, + WebSearchTool_20260209, + WebFetchTool_20260209, + WebFetchTool_20260309, + WebSearchTool_20260318, + WebFetchTool_20260318, + ToolSearchToolBM25_20251119, + ToolSearchToolRegex_20251119 + ], { mode: "oneOf" }) + ).annotate({ + "title": "Tools", + "description": + "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details." + }) + ), + "top_k": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Top K", + "description": + "Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\nRecommended for advanced use cases only." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) + ), + "top_p": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Top P", + "description": + "Use nucleus sampling.\n\nIn nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`.\n\nRecommended for advanced use cases only." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) + ) +}).annotate({ "title": "CreateMessageParams", "identifier": "CreateMessageParams" }) +export type CountMessageTokensParams = { + readonly "cache_control"?: CacheControlEphemeral | null + readonly "messages": ReadonlyArray + readonly "model": Model + readonly "output_config"?: OutputConfig + readonly "system"?: string | ReadonlyArray + readonly "thinking"?: ThinkingConfigParam + readonly "tool_choice"?: ToolChoice + readonly "tools"?: ReadonlyArray< + | Tool + | BashTool_20250124 + | CodeExecutionTool_20250522 + | CodeExecutionTool_20250825 + | CodeExecutionTool_20260120 + | CodeExecutionTool_20260521 + | MemoryTool_20250818 + | TextEditor_20250124 + | TextEditor_20250429 + | TextEditor_20250728 + | WebSearchTool_20250305 + | WebFetchTool_20250910 + | WebSearchTool_20260209 + | WebFetchTool_20260209 + | WebFetchTool_20260309 + | WebSearchTool_20260318 + | WebFetchTool_20260318 + | ToolSearchToolBM25_20251119 + | ToolSearchToolRegex_20251119 + > +} +export const CountMessageTokensParams = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([CacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": + "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." + }) + ), + "messages": Schema.Array(InputMessage).annotate({ + "title": "Messages", + "description": + "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).\n\nNote that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." + }), + "model": Model, + "output_config": Schema.optionalKey( + Schema.suspend((): Schema.Codec => OutputConfig).annotate({ + "description": "Configuration options for the model's output, such as the output format." + }) + ), + "system": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Array(RequestTextBlock)]).annotate({ + "title": "System", + "description": + "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role)." + }) + ), + "thinking": Schema.optionalKey(ThinkingConfigParam), + "tool_choice": Schema.optionalKey(ToolChoice), + "tools": Schema.optionalKey( + Schema.Array( + Schema.Union([ + Tool, + BashTool_20250124, + CodeExecutionTool_20250522, + CodeExecutionTool_20250825, + CodeExecutionTool_20260120, + CodeExecutionTool_20260521, + MemoryTool_20250818, + TextEditor_20250124, + TextEditor_20250429, + TextEditor_20250728, + WebSearchTool_20250305, + WebFetchTool_20250910, + WebSearchTool_20260209, + WebFetchTool_20260209, + WebFetchTool_20260309, + WebSearchTool_20260318, + WebFetchTool_20260318, + ToolSearchToolBM25_20251119, + ToolSearchToolRegex_20251119 + ], { mode: "oneOf" }) + ).annotate({ + "title": "Tools", + "description": + "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details." + }) + ) +}).annotate({ "title": "CountMessageTokensParams", "identifier": "CountMessageTokensParams" }) +export type BetaCreateMessageParams = { + readonly "model": Model + readonly "messages": ReadonlyArray + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "container"?: BetaContainerParams | string | null + readonly "context_management"?: BetaContextManagementConfig | null + readonly "diagnostics"?: BetaDiagnosticsParam | null + readonly "fallback_credit_token"?: string | BetaFallbackCreditTokenParam | null + readonly "fallbacks"?: ReadonlyArray | "default" | null + readonly "inference_geo"?: string | null + readonly "max_tokens": number + readonly "mcp_servers"?: ReadonlyArray + readonly "metadata"?: BetaMetadata + readonly "output_config"?: BetaOutputConfig + readonly "output_format"?: BetaJsonOutputFormat | null + readonly "service_tier"?: "auto" | "standard_only" + readonly "speed"?: BetaSpeed | null + readonly "stop_sequences"?: ReadonlyArray + readonly "stream"?: boolean + readonly "system"?: string | ReadonlyArray + readonly "temperature"?: number + readonly "thinking"?: BetaThinkingConfigParam + readonly "tool_choice"?: BetaToolChoice + readonly "tools"?: ReadonlyArray< + | BetaTool + | BetaBashTool_20241022 + | BetaBashTool_20250124 + | BetaCodeExecutionTool_20250522 + | BetaCodeExecutionTool_20250825 + | BetaCodeExecutionTool_20260120 + | BetaCodeExecutionTool_20260521 + | BetaComputerUseTool_20241022 + | BetaMemoryTool_20250818 + | BetaComputerUseTool_20250124 + | BetaTextEditor_20241022 + | BetaComputerUseTool_20251124 + | BetaTextEditor_20250124 + | BetaTextEditor_20250429 + | BetaTextEditor_20250728 + | BetaWebSearchTool_20250305 + | BetaWebFetchTool_20250910 + | BetaWebSearchTool_20260209 + | BetaWebFetchTool_20260209 + | BetaWebFetchTool_20260309 + | BetaWebSearchTool_20260318 + | BetaWebFetchTool_20260318 + | BetaAdvisorTool_20260301 + | BetaToolSearchToolBM25_20251119 + | BetaToolSearchToolRegex_20251119 + | BetaMCPToolset + > + readonly "top_k"?: number + readonly "top_p"?: number +} +export const BetaCreateMessageParams = Schema.Struct({ + "model": Model, + "messages": Schema.Array(BetaInputMessage).annotate({ + "title": "Messages", + "description": + "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).\n\nNote that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." + }), + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": + "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." + }) + ), + "container": Schema.optionalKey( + Schema.Union([BetaContainerParams, Schema.String, Schema.Null]).annotate({ + "title": "Container", + "description": "Container identifier for reuse across requests." + }) + ), + "context_management": Schema.optionalKey( + Schema.Union([BetaContextManagementConfig, Schema.Null]).annotate({ + "description": + "Context management configuration.\n\nThis allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not." + }) + ), + "diagnostics": Schema.optionalKey( + Schema.Union([BetaDiagnosticsParam, Schema.Null]).annotate({ + "description": + "Request-level diagnostics. Supply `previous_message_id` to have the response include `diagnostics.cache_miss_reason` explaining any prompt-cache divergence from that prior request." + }) + ), + "fallback_credit_token": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" }) + ), + BetaFallbackCreditTokenParam, + Schema.Null + ]).annotate({ + "title": "Fallback Credit Token", + "description": + "The `fallback_credit_token` from a prior refusal's `stop_details`.\n\nWhen a preceding request was refused and returned a `fallback_credit_token`,\npass that code here on the retry to have the retry's cache-creation tokens\nfor the prefix that was warm on the refused model billed at the cache-read\nrate. Must be redeemed by the same organization and workspace, with the same\nrequest body (optionally extended by one appended `assistant` message whose\ncontent is the partial text — with any trailing whitespace stripped from\nthe final text block — and paired server-tool blocks streamed before the\nrefusal; the appended-assistant form is not available for requests with\n`output_format` set or forced `tool_choice`), on an eligible fallback\nmodel, on the same platform,\nand within 5 minutes of the refusal; a mismatch is a 400. A token minted\nmid-server-tool-loop whose partial content was continuable may only be\nredeemed with the appended-assistant form — if an exact-body retry is\nrejected with a 400 saying the token must be redeemed by continuing the\npartial response, retry with the appended-assistant form instead.\n\nWhen the appended-assistant form is used on a model that otherwise disallows\nassistant-turn prefill, this token also authorizes that one prefill." + }) + ), + "fallbacks": Schema.optionalKey( + Schema.Union([ + Schema.Array(BetaFallbackConfigV2).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(3).annotate({ "expected": "a value with a length of at most 3" })), + Schema.Literal("default").annotate({ "title": "FallbacksDefault" }), + Schema.Null + ]).annotate({ + "title": "Fallbacks", + "description": + "Opt-in server-side retry on one or more substitute models when the requested model declines for policy reasons. Tried in order: if the first entry also declines, the second is tried, and so on. The string \"default\" requests the requested model's server-defined default fallback configuration." + }) + ), + "inference_geo": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Inference Geo", + "description": + "Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used." + }) + ), + "max_tokens": Schema.Number.annotate({ + "title": "Max Tokens", + "description": + "The maximum number of tokens to generate before stopping.\n\nNote that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.\n\nSet to `0` to populate the [prompt cache](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pre-warming-the-cache) without generating a response.\n\nDifferent models have different maximum values for this parameter. See [models](https://platform.claude.com/docs/en/about-claude/models/overview) for details." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "mcp_servers": Schema.optionalKey( + Schema.Array(BetaRequestMCPServerURLDefinition).annotate({ + "title": "Mcp Servers", + "description": "MCP servers to be utilized in this request" + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) + ), + "metadata": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaMetadata).annotate({ + "description": "An object describing metadata about the request." + }) + ), + "output_config": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaOutputConfig).annotate({ + "description": "Configuration options for the model's output, such as the output format." + }) + ), + "output_format": Schema.optionalKey( + Schema.Union([BetaJsonOutputFormat, Schema.Null]).annotate({ + "description": + "Deprecated: Use `output_config.format` instead. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\nA schema to specify Claude's output format in responses. This parameter will be removed in a future release." + }) + ), + "service_tier": Schema.optionalKey( + Schema.Literals(["auto", "standard_only"]).annotate({ + "title": "Service Tier", + "description": + "Determines whether to use priority capacity (if available) or standard capacity for this request.\n\nAnthropic offers different levels of service for your API requests. See [service-tiers](https://platform.claude.com/docs/en/api/service-tiers) for details." + }) + ), + "speed": Schema.optionalKey( + Schema.Union([BetaSpeed, Schema.Null]).annotate({ + "description": + "The inference speed mode for this request. `\"fast\"` enables high output-tokens-per-second inference." + }) + ), + "stop_sequences": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "title": "Stop Sequences", + "description": + "Custom text sequences that will cause the model to stop generating.\n\nOur models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `\"end_turn\"`.\n\nIf you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"` and the response `stop_sequence` value will contain the matched stop sequence." + }) + ), + "stream": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Stream", + "description": + "Whether to incrementally stream the response using server-sent events.\n\nSee [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming) for details." + }) + ), + "system": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Array(BetaRequestTextBlock)]).annotate({ + "title": "System", + "description": + "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role)." + }) + ), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Temperature", + "description": + "Amount of randomness injected into the response.\n\nDefaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.\n\nNote that even with `temperature` of `0.0`, the results will not be fully deterministic." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) + ), + "thinking": Schema.optionalKey(BetaThinkingConfigParam), + "tool_choice": Schema.optionalKey(BetaToolChoice), + "tools": Schema.optionalKey( + Schema.Array( + Schema.Union([ + BetaTool, + BetaBashTool_20241022, + BetaBashTool_20250124, + BetaCodeExecutionTool_20250522, + BetaCodeExecutionTool_20250825, + BetaCodeExecutionTool_20260120, + BetaCodeExecutionTool_20260521, + BetaComputerUseTool_20241022, + BetaMemoryTool_20250818, + BetaComputerUseTool_20250124, + BetaTextEditor_20241022, + BetaComputerUseTool_20251124, + BetaTextEditor_20250124, + BetaTextEditor_20250429, + BetaTextEditor_20250728, + BetaWebSearchTool_20250305, + BetaWebFetchTool_20250910, + BetaWebSearchTool_20260209, + BetaWebFetchTool_20260209, + BetaWebFetchTool_20260309, + BetaWebSearchTool_20260318, + BetaWebFetchTool_20260318, + BetaAdvisorTool_20260301, + BetaToolSearchToolBM25_20251119, + BetaToolSearchToolRegex_20251119, + BetaMCPToolset + ], { mode: "oneOf" }) + ).annotate({ + "title": "Tools", + "description": + "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details." + }) + ), + "top_k": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Top K", + "description": + "Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\nRecommended for advanced use cases only." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) + ), + "top_p": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Top P", + "description": + "Use nucleus sampling.\n\nIn nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`.\n\nRecommended for advanced use cases only." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) + ) +}).annotate({ "title": "CreateMessageParams", "identifier": "BetaCreateMessageParams" }) +export type BetaCountMessageTokensParams = { + readonly "cache_control"?: BetaCacheControlEphemeral | null + readonly "context_management"?: BetaContextManagementConfig | null + readonly "mcp_servers"?: ReadonlyArray + readonly "messages": ReadonlyArray + readonly "model": Model + readonly "output_config"?: BetaOutputConfig + readonly "output_format"?: BetaJsonOutputFormat | null + readonly "speed"?: BetaSpeed | null + readonly "system"?: string | ReadonlyArray + readonly "thinking"?: BetaThinkingConfigParam + readonly "tool_choice"?: BetaToolChoice + readonly "tools"?: ReadonlyArray< + | BetaTool + | BetaBashTool_20241022 + | BetaBashTool_20250124 + | BetaCodeExecutionTool_20250522 + | BetaCodeExecutionTool_20250825 + | BetaCodeExecutionTool_20260120 + | BetaCodeExecutionTool_20260521 + | BetaComputerUseTool_20241022 + | BetaMemoryTool_20250818 + | BetaComputerUseTool_20250124 + | BetaTextEditor_20241022 + | BetaComputerUseTool_20251124 + | BetaTextEditor_20250124 + | BetaTextEditor_20250429 + | BetaTextEditor_20250728 + | BetaWebSearchTool_20250305 + | BetaWebFetchTool_20250910 + | BetaWebSearchTool_20260209 + | BetaWebFetchTool_20260209 + | BetaWebFetchTool_20260309 + | BetaWebSearchTool_20260318 + | BetaWebFetchTool_20260318 + | BetaAdvisorTool_20260301 + | BetaToolSearchToolBM25_20251119 + | BetaToolSearchToolRegex_20251119 + | BetaMCPToolset + > +} +export const BetaCountMessageTokensParams = Schema.Struct({ + "cache_control": Schema.optionalKey( + Schema.Union([Schema.Union([BetaCacheControlEphemeral], { mode: "oneOf" }), Schema.Null]).annotate({ + "title": "Cache Control", + "description": + "Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request." + }) + ), + "context_management": Schema.optionalKey( + Schema.Union([BetaContextManagementConfig, Schema.Null]).annotate({ + "description": + "Context management configuration.\n\nThis allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not." + }) + ), + "mcp_servers": Schema.optionalKey( + Schema.Array(BetaRequestMCPServerURLDefinition).annotate({ + "title": "Mcp Servers", + "description": "MCP servers to be utilized in this request" + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) + ), + "messages": Schema.Array(BetaInputMessage).annotate({ + "title": "Messages", + "description": + "Input messages.\n\nOur models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.\n\nEach input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.\n\nIf the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.\n\nExample with a single `user` message:\n\n```json\n[{\"role\": \"user\", \"content\": \"Hello, Claude\"}]\n```\n\nExample with multiple conversational turns:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"Hello there.\"},\n {\"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\"},\n {\"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\"},\n]\n```\n\nExample with a partially-filled response from Claude:\n\n```json\n[\n {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n {\"role\": \"assistant\", \"content\": \"The best answer is (\"},\n]\n```\n\nEach input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `\"text\"`. The following input messages are equivalent:\n\n```json\n{\"role\": \"user\", \"content\": \"Hello, Claude\"}\n```\n\n```json\n{\"role\": \"user\", \"content\": [{\"type\": \"text\", \"text\": \"Hello, Claude\"}]}\n```\n\nSee [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).\n\nNote that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), you can use the top-level `system` parameter — there is no `\"system\"` role for input messages in the Messages API.\n\nThere is a limit of 100,000 messages in a single request." + }), + "model": Model, + "output_config": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaOutputConfig).annotate({ + "description": "Configuration options for the model's output, such as the output format." + }) + ), + "output_format": Schema.optionalKey( + Schema.Union([BetaJsonOutputFormat, Schema.Null]).annotate({ + "description": + "Deprecated: Use `output_config.format` instead. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\nA schema to specify Claude's output format in responses. This parameter will be removed in a future release." + }) + ), + "speed": Schema.optionalKey( + Schema.Union([BetaSpeed, Schema.Null]).annotate({ + "description": + "The inference speed mode for this request. `\"fast\"` enables high output-tokens-per-second inference." + }) + ), + "system": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Array(BetaRequestTextBlock)]).annotate({ + "title": "System", + "description": + "System prompt.\n\nA system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role)." + }) + ), + "thinking": Schema.optionalKey(BetaThinkingConfigParam), + "tool_choice": Schema.optionalKey(BetaToolChoice), + "tools": Schema.optionalKey( + Schema.Array( + Schema.Union([ + BetaTool, + BetaBashTool_20241022, + BetaBashTool_20250124, + BetaCodeExecutionTool_20250522, + BetaCodeExecutionTool_20250825, + BetaCodeExecutionTool_20260120, + BetaCodeExecutionTool_20260521, + BetaComputerUseTool_20241022, + BetaMemoryTool_20250818, + BetaComputerUseTool_20250124, + BetaTextEditor_20241022, + BetaComputerUseTool_20251124, + BetaTextEditor_20250124, + BetaTextEditor_20250429, + BetaTextEditor_20250728, + BetaWebSearchTool_20250305, + BetaWebFetchTool_20250910, + BetaWebSearchTool_20260209, + BetaWebFetchTool_20260209, + BetaWebFetchTool_20260309, + BetaWebSearchTool_20260318, + BetaWebFetchTool_20260318, + BetaAdvisorTool_20260301, + BetaToolSearchToolBM25_20251119, + BetaToolSearchToolRegex_20251119, + BetaMCPToolset + ], { mode: "oneOf" }) + ).annotate({ + "title": "Tools", + "description": + "Definitions of tools that the model may use.\n\nIf you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.\n\nThere are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)).\n\nEach tool definition includes:\n\n* `name`: Name of the tool.\n* `description`: Optional, but strongly-recommended description of the tool.\n* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.\n\nFor example, if you defined `tools` as:\n\n```json\n[\n {\n \"name\": \"get_stock_price\",\n \"description\": \"Get the current stock price for a given ticker symbol.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"ticker\": {\n \"type\": \"string\",\n \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n }\n },\n \"required\": [\"ticker\"]\n }\n }\n]\n```\n\nAnd then asked the model \"What's the S&P 500 at today?\", the model might produce `tool_use` content blocks in the response like this:\n\n```json\n[\n {\n \"type\": \"tool_use\",\n \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"name\": \"get_stock_price\",\n \"input\": { \"ticker\": \"^GSPC\" }\n }\n]\n```\n\nYou might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an input, and return the following back to the model in a subsequent `user` message:\n\n```json\n[\n {\n \"type\": \"tool_result\",\n \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n \"content\": \"259.75 USD\"\n }\n]\n```\n\nTools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.\n\nSee our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details." + }) + ) +}).annotate({ "title": "CountMessageTokensParams", "identifier": "BetaCountMessageTokensParams" }) +export type BetaManagedAgentsSession = { + readonly "type": "session" + readonly "id": string + readonly "status": BetaManagedAgentsSessionStatus + readonly "created_at": BetaTimestamp + readonly "updated_at": BetaTimestamp + readonly "environment_id": string + readonly "title": string + readonly "metadata": { readonly [x: string]: string } + readonly "agent": BetaManagedAgentsSessionAgent + readonly "resources": ReadonlyArray + readonly "vault_ids": ReadonlyArray + readonly "outcome_evaluations": ReadonlyArray + readonly "usage": BetaManagedAgentsSessionUsage + readonly "stats": BetaManagedAgentsSessionStats + readonly "archived_at": BetaTimestamp + readonly "deployment_id"?: string + readonly "budget": BetaManagedAgentsBudget +} +export const BetaManagedAgentsSession = Schema.Struct({ + "type": Schema.Literal("session"), + "id": Schema.String, + "status": BetaManagedAgentsSessionStatus, + "created_at": BetaTimestamp, + "updated_at": BetaTimestamp, + "environment_id": Schema.String, + "title": Schema.String, + "metadata": Schema.Record(Schema.String, Schema.String), + "agent": BetaManagedAgentsSessionAgent, + "resources": Schema.Array(BetaManagedAgentsSessionResource), + "vault_ids": Schema.Array(Schema.String).annotate({ + "description": "Vault IDs attached to the session at creation. Empty when no vaults were supplied." + }), + "outcome_evaluations": Schema.Array(BetaManagedAgentsOutcomeEvaluationResource).annotate({ + "description": "Per-outcome evaluation state. One entry per define_outcome event sent to the session." + }), + "usage": Schema.suspend((): Schema.Codec => BetaManagedAgentsSessionUsage).annotate({ + "description": "Cumulative token usage for the session." + }), + "stats": Schema.suspend((): Schema.Codec => BetaManagedAgentsSessionStats).annotate({ + "description": "Timing statistics for the session." + }), + "archived_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "When the session was archived. Null if not archived." + }), + "deployment_id": Schema.optionalKey( + Schema.String.annotate({ + "description": "Deployment ID when the session was created from a deployment reference. Null otherwise." + }) + ), + "budget": Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": "The session's enforced spend ceiling, or null when no budget is set." + }) +}).annotate({ "description": "A Managed Agents `session`.", "identifier": "BetaManagedAgentsSession" }) +export type BetaManagedAgentsSessionEvent = + | { + readonly "type": "user.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at"?: BetaTimestamp + } + | { + readonly "type": "user.interrupt" + readonly "id": string + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "user.tool_confirmation" + readonly "id": string + readonly "tool_use_id": string + readonly "result": BetaManagedAgentsUserToolConfirmationResult + readonly "deny_message"?: string + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "user.custom_tool_result" + readonly "id": string + readonly "custom_tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.custom_tool_use" + readonly "id": string + readonly "name": string + readonly "input": BetaManagedAgentsStruct + readonly "processed_at": BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at": BetaTimestamp + } + | { readonly "type": "agent.thinking"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "agent.mcp_tool_use" + readonly "id": string + readonly "name": string + readonly "mcp_server_name": string + readonly "input": BetaManagedAgentsStruct + readonly "processed_at": BetaTimestamp + readonly "evaluated_permission"?: BetaManagedAgentsAgentEvaluatedPermission + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.mcp_tool_result" + readonly "id": string + readonly "mcp_tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at": BetaTimestamp + } + | { + readonly "type": "agent.tool_use" + readonly "id": string + readonly "name": string + readonly "input": BetaManagedAgentsStruct + readonly "processed_at": BetaTimestamp + readonly "evaluated_permission"?: BetaManagedAgentsAgentEvaluatedPermission + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.tool_result" + readonly "id": string + readonly "tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at": BetaTimestamp + } + | { + readonly "type": "agent.thread_message_received" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "from_agent_name"?: string + readonly "content": ReadonlyArray + readonly "from_session_thread_id": string + } + | { + readonly "type": "agent.thread_message_sent" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "to_agent_name"?: string + readonly "content": ReadonlyArray + readonly "to_session_thread_id": string + } + | { readonly "type": "agent.thread_context_compacted"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.error" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "error": { + readonly "type": "unknown_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "model_overloaded_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "model_rate_limited_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "model_request_failed_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "mcp_connection_failed_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + readonly "mcp_server_name": string + } | { + readonly "type": "mcp_authentication_failed_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + readonly "mcp_server_name": string + } | { + readonly "type": "billing_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "credential_host_unreachable_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + readonly "vault_id": string + readonly "credential_id": string + } + } + | { readonly "type": "session.status_rescheduled"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { readonly "type": "session.status_running"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.status_idle" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "stop_reason": + | { readonly "type": "end_turn" } + | { readonly "type": "requires_action"; readonly "event_ids": ReadonlyArray } + | { readonly "type": "retries_exhausted" } + | { readonly "type": "budget_reached" } + } + | { readonly "type": "session.status_terminated"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.thread_created" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + readonly "session_thread_id": string + } + | { + readonly "type": "span.outcome_evaluation_start" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "iteration": number + readonly "outcome_id": string + } + | { + readonly "type": "span.outcome_evaluation_end" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "outcome_evaluation_start_id": string + readonly "iteration": number + readonly "result": string + readonly "explanation": string + readonly "usage": BetaManagedAgentsSpanModelUsage + readonly "outcome_id": string + } + | { readonly "type": "span.model_request_start"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "span.model_request_end" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "is_error": boolean + readonly "model_usage": BetaManagedAgentsSpanModelUsage + readonly "model_request_start_id": string + } + | { + readonly "type": "span.outcome_evaluation_ongoing" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "iteration": number + readonly "outcome_id": string + } + | { + readonly "type": "user.define_outcome" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "outcome_id": string + readonly "description": string + readonly "max_iterations": number + readonly "rubric": BetaManagedAgentsRubric + } + | { readonly "type": "session.deleted"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.thread_status_running" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + } + | { + readonly "type": "session.thread_status_idle" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + readonly "stop_reason": + | { readonly "type": "end_turn" } + | { readonly "type": "requires_action"; readonly "event_ids": ReadonlyArray } + | { readonly "type": "retries_exhausted" } + | { readonly "type": "budget_reached" } + } + | { + readonly "type": "session.thread_status_terminated" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + } + | { + readonly "type": "user.tool_result" + readonly "id": string + readonly "tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "session.thread_status_rescheduled" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + } + | { + readonly "type": "session.updated" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "title"?: string + readonly "metadata"?: { readonly [x: string]: string } + readonly "agent"?: BetaManagedAgentsSessionAgent + readonly "budget"?: BetaManagedAgentsBudget + } + | { + readonly "type": "system.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at"?: BetaTimestamp + } + | { + readonly "type": "session.usage" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "usage": BetaManagedAgentsSessionUsageSnapshot + readonly "budget"?: BetaManagedAgentsBudget + } +export const BetaManagedAgentsSessionEvent = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("user.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ + "description": "Array of content blocks comprising the user message." + }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the agent finished processing this message." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("user.interrupt"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the interrupt was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_confirmation"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "result": Schema.suspend((): Schema.Codec => + BetaManagedAgentsUserToolConfirmationResult + ).annotate({ "description": "The confirmation result: 'allow' or 'deny'." }), + "deny_message": Schema.optionalKey( + Schema.String.annotate({ + "description": "Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'." + }).check(Schema.isMaxLength(10000).annotate({ "expected": "a value with a length of at most 10000" })) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the confirmation was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("user.custom_tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "custom_tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this result was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.custom_tool_use"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "name": Schema.String.annotate({ "description": "Name of the custom tool being called." }), + "input": Schema.suspend((): Schema.Codec => BetaManagedAgentsStruct).annotate({ + "description": "Input parameters for the tool call." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this tool use was processed." + }), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsAgentMessageContentBlock).annotate({ + "description": "Array of text blocks comprising the agent response." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this response was generated." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.thinking"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this thinking was produced." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.mcp_tool_use"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "name": Schema.String.annotate({ "description": "Name of the MCP tool being used." }), + "mcp_server_name": Schema.String.annotate({ "description": "Name of the MCP server providing the tool." }), + "input": Schema.suspend((): Schema.Codec => BetaManagedAgentsStruct).annotate({ + "description": "Input parameters for the tool call." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }), + "evaluated_permission": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsAgentEvaluatedPermission + ).annotate({ "description": "The evaluated permission policy for this tool invocation." }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.mcp_tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "mcp_tool_use_id": Schema.String.annotate({ + "description": "The id of the `agent.mcp_tool_use` event this result corresponds to." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.tool_use"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "name": Schema.String.annotate({ "description": "Name of the agent tool being used." }), + "input": Schema.suspend((): Schema.Codec => BetaManagedAgentsStruct).annotate({ + "description": "Input parameters for the tool call." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }), + "evaluated_permission": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsAgentEvaluatedPermission + ).annotate({ "description": "The evaluated permission policy for this tool invocation." }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ + "description": "The id of the `agent.tool_use` event this result corresponds to." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.thread_message_received"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the message was received." + }), + "from_agent_name": Schema.optionalKey( + Schema.String.annotate({ + "description": "Name of the callable agent this message came from. Absent when received from the primary agent." + }) + ), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ "description": "Message content blocks." }), + "from_session_thread_id": Schema.String.annotate({ + "description": "Public `sthr_` ID of the thread that sent the message." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.thread_message_sent"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the message was sent." + }), + "to_agent_name": Schema.optionalKey( + Schema.String.annotate({ + "description": "Name of the callable agent this message was sent to. Absent when sent to the primary agent." + }) + ), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ "description": "Message content blocks." }), + "to_session_thread_id": Schema.String.annotate({ + "description": "Public `sthr_` ID of the thread the message was sent to." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("agent.thread_context_compacted"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when compaction was processed." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.error"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the error occurred." + }), + "error": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("unknown_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ + "description": + "An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone." + }), + Schema.Struct({ + "type": Schema.Literal("model_overloaded_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ + "description": "The model is currently overloaded. Emitted after automatic retries are exhausted." + }), + Schema.Struct({ + "type": Schema.Literal("model_rate_limited_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ "description": "The model request was rate-limited." }), + Schema.Struct({ + "type": Schema.Literal("model_request_failed_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ "description": "A model request failed for a reason other than overload or rate-limiting." }), + Schema.Struct({ + "type": Schema.Literal("mcp_connection_failed_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }), + "mcp_server_name": Schema.String.annotate({ "description": "Name of the MCP server that failed to connect." }) + }).annotate({ "description": "Failed to connect to an MCP server." }), + Schema.Struct({ + "type": Schema.Literal("mcp_authentication_failed_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }), + "mcp_server_name": Schema.String.annotate({ + "description": "Name of the MCP server that failed authentication." + }) + }).annotate({ "description": "Authentication to an MCP server failed." }), + Schema.Struct({ + "type": Schema.Literal("billing_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ + "description": + "The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state." + }), + Schema.Struct({ + "type": Schema.Literal("credential_host_unreachable_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }), + "vault_id": Schema.String.annotate({ "description": "ID of the vault containing the affected credential." }), + "credential_id": Schema.String.annotate({ "description": "ID of the affected credential." }) + }).annotate({ + "description": + "An `environment_variable` credential's `auth.networking.allowed_hosts` includes a host the environment's network policy does not permit." + }) + ], { mode: "oneOf" }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.status_rescheduled"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.status_running"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.status_idle"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }), + "stop_reason": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("end_turn") }).annotate({ + "description": "The agent completed its turn naturally and is ready for the next user message." + }), + Schema.Struct({ + "type": Schema.Literal("requires_action"), + "event_ids": Schema.Array(Schema.String).annotate({ + "description": + "The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder." + }) + }).annotate({ + "description": + "The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running." + }), + Schema.Struct({ "type": Schema.Literal("retries_exhausted") }).annotate({ + "description": + "The turn ended because repeated errors exhausted the retry budget or an error escalated to `retry_status: 'exhausted'`." + }), + Schema.Struct({ "type": Schema.Literal("budget_reached") }).annotate({ + "description": + "The agent stopped because the session's tracked list cost reached its budget, or because its usage includes a model with no list price (which the budget cannot measure). Raise the budget to continue — or, if raising is rejected because a model has no list price, remove the budget." + }) + ], { mode: "oneOf" }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.status_terminated"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_created"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the thread was created." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the callable agent the thread runs." }), + "session_thread_id": Schema.String.annotate({ "description": "Public `sthr_` ID of the newly created thread." }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("span.outcome_evaluation_start"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when outcome evaluation started." + }), + "iteration": Schema.Number.annotate({ + "description": + "0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "outcome_id": Schema.String.annotate({ "description": "The `outc_` ID of the outcome being evaluated." }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("span.outcome_evaluation_end"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when outcome evaluation ended." + }), + "outcome_evaluation_start_id": Schema.String.annotate({ + "description": "The id of the corresponding `span.outcome_evaluation_start` event." + }), + "iteration": Schema.Number.annotate({ + "description": "0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "result": Schema.String.annotate({ + "description": + "Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress." + }), + "explanation": Schema.String.annotate({ + "description": + "Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why." + }), + "usage": Schema.suspend((): Schema.Codec => BetaManagedAgentsSpanModelUsage) + .annotate({ + "description": + "Aggregate token usage for this evaluation cycle. Sums across all grader model requests within the cycle." + }), + "outcome_id": Schema.String.annotate({ "description": "The `outc_` ID of the outcome being evaluated." }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("span.model_request_start"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the model request started." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("span.model_request_end"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the model request completed." + }), + "is_error": Schema.Boolean.annotate({ "description": "Whether the model request resulted in an error." }), + "model_usage": Schema.suspend((): Schema.Codec => BetaManagedAgentsSpanModelUsage) + .annotate({ "description": "Token usage for this model request." }), + "model_request_start_id": Schema.String.annotate({ + "description": "The id of the corresponding `span.model_request_start` event." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("span.outcome_evaluation_ongoing"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this heartbeat was emitted." + }), + "iteration": Schema.Number.annotate({ + "description": "0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "outcome_id": Schema.String.annotate({ "description": "The `outc_` ID of the outcome being evaluated." }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("user.define_outcome"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the outcome was accepted." + }), + "outcome_id": Schema.String.annotate({ + "description": + "Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list." + }), + "description": Schema.String.annotate({ + "description": "What the agent should produce. Copied from the input event." + }), + "max_iterations": Schema.Number.annotate({ + "description": "Evaluate-then-revise cycles before giving up. Default 3, max 20.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "rubric": Schema.suspend((): Schema.Codec => BetaManagedAgentsRubric).annotate({ + "description": + "How to grade the outcome. File rubrics are currently resolved to their text content; clients should handle both variants." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.deleted"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the session was deleted." + }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_running"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ + "description": "Public sthr_ ID of the thread that started running." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_idle"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ "description": "Public sthr_ ID of the thread that went idle." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }), + "stop_reason": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("end_turn") }).annotate({ + "description": "The agent completed its turn naturally and is ready for the next user message." + }), + Schema.Struct({ + "type": Schema.Literal("requires_action"), + "event_ids": Schema.Array(Schema.String).annotate({ + "description": + "The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder." + }) + }).annotate({ + "description": + "The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running." + }), + Schema.Struct({ "type": Schema.Literal("retries_exhausted") }).annotate({ + "description": + "The turn ended because repeated errors exhausted the retry budget or an error escalated to `retry_status: 'exhausted'`." + }), + Schema.Struct({ "type": Schema.Literal("budget_reached") }).annotate({ + "description": + "The agent stopped because the session's tracked list cost reached its budget, or because its usage includes a model with no list price (which the budget cannot measure). Raise the budget to continue — or, if raising is rejected because a model has no list price, remove the budget." + }) + ], { mode: "oneOf" }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_terminated"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ "description": "Public sthr_ ID of the thread that terminated." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this result was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_rescheduled"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ "description": "Public sthr_ ID of the thread that is retrying." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.updated"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the update was applied." + }), + "title": Schema.optionalKey( + Schema.String.annotate({ "description": "The session's new title. Present only when the update changed it." }) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty." + }) + ), + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsSessionAgent).annotate({ + "description": + "The session's effective agent configuration after the update. Present only when the update changed `agent` (tools or mcp_servers); when present it is the full materialised snapshot, not a diff." + }) + ), + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": + "The session's budget after the update: the new budget when set or replaced, or null when the update removed it. Present only when the update changed the budget." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("system.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsSystemContentBlock).annotate({ + "description": "System content blocks. Text-only." + }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this system message was processed." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }), + Schema.Struct({ + "type": Schema.Literal("session.usage"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the snapshot was taken." + }), + "usage": Schema.suspend((): Schema.Codec => + BetaManagedAgentsSessionUsageSnapshot + ).annotate({ "description": "The session's cumulative usage at the snapshot time." }), + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": "The session's configured budget at the snapshot time, or null when the session has no budget." + }) + ) + }).annotate({ "description": "Union type for all event types in a session." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsSessionEvent" }) +export type BetaManagedAgentsStreamSessionEvents = + | { + readonly "type": "user.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at"?: BetaTimestamp + } + | { + readonly "type": "user.interrupt" + readonly "id": string + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "user.tool_confirmation" + readonly "id": string + readonly "tool_use_id": string + readonly "result": BetaManagedAgentsUserToolConfirmationResult + readonly "deny_message"?: string + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "user.custom_tool_result" + readonly "id": string + readonly "custom_tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.custom_tool_use" + readonly "id": string + readonly "name": string + readonly "input": BetaManagedAgentsStruct + readonly "processed_at": BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at": BetaTimestamp + } + | { readonly "type": "agent.thinking"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "agent.mcp_tool_use" + readonly "id": string + readonly "name": string + readonly "mcp_server_name": string + readonly "input": BetaManagedAgentsStruct + readonly "processed_at": BetaTimestamp + readonly "evaluated_permission"?: BetaManagedAgentsAgentEvaluatedPermission + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.mcp_tool_result" + readonly "id": string + readonly "mcp_tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at": BetaTimestamp + } + | { + readonly "type": "agent.tool_use" + readonly "id": string + readonly "name": string + readonly "input": BetaManagedAgentsStruct + readonly "processed_at": BetaTimestamp + readonly "evaluated_permission"?: BetaManagedAgentsAgentEvaluatedPermission + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.tool_result" + readonly "id": string + readonly "tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at": BetaTimestamp + } + | { + readonly "type": "agent.thread_message_received" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "from_agent_name"?: string + readonly "content": ReadonlyArray + readonly "from_session_thread_id": string + } + | { + readonly "type": "agent.thread_message_sent" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "to_agent_name"?: string + readonly "content": ReadonlyArray + readonly "to_session_thread_id": string + } + | { readonly "type": "agent.thread_context_compacted"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.error" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "error": { + readonly "type": "unknown_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "model_overloaded_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "model_rate_limited_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "model_request_failed_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "mcp_connection_failed_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + readonly "mcp_server_name": string + } | { + readonly "type": "mcp_authentication_failed_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + readonly "mcp_server_name": string + } | { + readonly "type": "billing_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "credential_host_unreachable_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + readonly "vault_id": string + readonly "credential_id": string + } + } + | { readonly "type": "session.status_rescheduled"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { readonly "type": "session.status_running"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.status_idle" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "stop_reason": + | { readonly "type": "end_turn" } + | { readonly "type": "requires_action"; readonly "event_ids": ReadonlyArray } + | { readonly "type": "retries_exhausted" } + | { readonly "type": "budget_reached" } + } + | { readonly "type": "session.status_terminated"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.thread_created" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + readonly "session_thread_id": string + } + | { + readonly "type": "span.outcome_evaluation_start" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "iteration": number + readonly "outcome_id": string + } + | { + readonly "type": "span.outcome_evaluation_end" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "outcome_evaluation_start_id": string + readonly "iteration": number + readonly "result": string + readonly "explanation": string + readonly "usage": BetaManagedAgentsSpanModelUsage + readonly "outcome_id": string + } + | { readonly "type": "span.model_request_start"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "span.model_request_end" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "is_error": boolean + readonly "model_usage": BetaManagedAgentsSpanModelUsage + readonly "model_request_start_id": string + } + | { + readonly "type": "span.outcome_evaluation_ongoing" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "iteration": number + readonly "outcome_id": string + } + | { + readonly "type": "user.define_outcome" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "outcome_id": string + readonly "description": string + readonly "max_iterations": number + readonly "rubric": BetaManagedAgentsRubric + } + | { readonly "type": "session.deleted"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.thread_status_running" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + } + | { + readonly "type": "session.thread_status_idle" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + readonly "stop_reason": + | { readonly "type": "end_turn" } + | { readonly "type": "requires_action"; readonly "event_ids": ReadonlyArray } + | { readonly "type": "retries_exhausted" } + | { readonly "type": "budget_reached" } + } + | { + readonly "type": "session.thread_status_terminated" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + } + | { + readonly "type": "user.tool_result" + readonly "id": string + readonly "tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "session.thread_status_rescheduled" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + } + | { + readonly "type": "session.updated" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "title"?: string + readonly "metadata"?: { readonly [x: string]: string } + readonly "agent"?: BetaManagedAgentsSessionAgent + readonly "budget"?: BetaManagedAgentsBudget + } + | { readonly "type": "event_start"; readonly "event": BetaManagedAgentsEventStartEvent_Event } + | { + readonly "type": "event_delta" + readonly "event_id": string + readonly "delta": BetaManagedAgentsEventDeltaEvent_Delta + } + | { + readonly "type": "system.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at"?: BetaTimestamp + } + | { + readonly "type": "session.usage" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "usage": BetaManagedAgentsSessionUsageSnapshot + readonly "budget"?: BetaManagedAgentsBudget + } +export const BetaManagedAgentsStreamSessionEvents = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("user.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ + "description": "Array of content blocks comprising the user message." + }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the agent finished processing this message." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("user.interrupt"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the interrupt was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_confirmation"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "result": Schema.suspend((): Schema.Codec => + BetaManagedAgentsUserToolConfirmationResult + ).annotate({ "description": "The confirmation result: 'allow' or 'deny'." }), + "deny_message": Schema.optionalKey( + Schema.String.annotate({ + "description": "Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'." + }).check(Schema.isMaxLength(10000).annotate({ "expected": "a value with a length of at most 10000" })) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the confirmation was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("user.custom_tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "custom_tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this result was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.custom_tool_use"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "name": Schema.String.annotate({ "description": "Name of the custom tool being called." }), + "input": Schema.suspend((): Schema.Codec => BetaManagedAgentsStruct).annotate({ + "description": "Input parameters for the tool call." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this tool use was processed." + }), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsAgentMessageContentBlock).annotate({ + "description": "Array of text blocks comprising the agent response." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this response was generated." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.thinking"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this thinking was produced." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.mcp_tool_use"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "name": Schema.String.annotate({ "description": "Name of the MCP tool being used." }), + "mcp_server_name": Schema.String.annotate({ "description": "Name of the MCP server providing the tool." }), + "input": Schema.suspend((): Schema.Codec => BetaManagedAgentsStruct).annotate({ + "description": "Input parameters for the tool call." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }), + "evaluated_permission": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsAgentEvaluatedPermission + ).annotate({ "description": "The evaluated permission policy for this tool invocation." }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.mcp_tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "mcp_tool_use_id": Schema.String.annotate({ + "description": "The id of the `agent.mcp_tool_use` event this result corresponds to." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.tool_use"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "name": Schema.String.annotate({ "description": "Name of the agent tool being used." }), + "input": Schema.suspend((): Schema.Codec => BetaManagedAgentsStruct).annotate({ + "description": "Input parameters for the tool call." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }), + "evaluated_permission": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsAgentEvaluatedPermission + ).annotate({ "description": "The evaluated permission policy for this tool invocation." }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ + "description": "The id of the `agent.tool_use` event this result corresponds to." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.thread_message_received"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the message was received." + }), + "from_agent_name": Schema.optionalKey( + Schema.String.annotate({ + "description": "Name of the callable agent this message came from. Absent when received from the primary agent." + }) + ), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ "description": "Message content blocks." }), + "from_session_thread_id": Schema.String.annotate({ + "description": "Public `sthr_` ID of the thread that sent the message." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.thread_message_sent"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the message was sent." + }), + "to_agent_name": Schema.optionalKey( + Schema.String.annotate({ + "description": "Name of the callable agent this message was sent to. Absent when sent to the primary agent." + }) + ), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ "description": "Message content blocks." }), + "to_session_thread_id": Schema.String.annotate({ + "description": "Public `sthr_` ID of the thread the message was sent to." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.thread_context_compacted"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when compaction was processed." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.error"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the error occurred." + }), + "error": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("unknown_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ + "description": + "An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone." + }), + Schema.Struct({ + "type": Schema.Literal("model_overloaded_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ + "description": "The model is currently overloaded. Emitted after automatic retries are exhausted." + }), + Schema.Struct({ + "type": Schema.Literal("model_rate_limited_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ "description": "The model request was rate-limited." }), + Schema.Struct({ + "type": Schema.Literal("model_request_failed_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ "description": "A model request failed for a reason other than overload or rate-limiting." }), + Schema.Struct({ + "type": Schema.Literal("mcp_connection_failed_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }), + "mcp_server_name": Schema.String.annotate({ "description": "Name of the MCP server that failed to connect." }) + }).annotate({ "description": "Failed to connect to an MCP server." }), + Schema.Struct({ + "type": Schema.Literal("mcp_authentication_failed_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }), + "mcp_server_name": Schema.String.annotate({ + "description": "Name of the MCP server that failed authentication." + }) + }).annotate({ "description": "Authentication to an MCP server failed." }), + Schema.Struct({ + "type": Schema.Literal("billing_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ + "description": + "The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state." + }), + Schema.Struct({ + "type": Schema.Literal("credential_host_unreachable_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }), + "vault_id": Schema.String.annotate({ "description": "ID of the vault containing the affected credential." }), + "credential_id": Schema.String.annotate({ "description": "ID of the affected credential." }) + }).annotate({ + "description": + "An `environment_variable` credential's `auth.networking.allowed_hosts` includes a host the environment's network policy does not permit." + }) + ], { mode: "oneOf" }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.status_rescheduled"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.status_running"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.status_idle"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }), + "stop_reason": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("end_turn") }).annotate({ + "description": "The agent completed its turn naturally and is ready for the next user message." + }), + Schema.Struct({ + "type": Schema.Literal("requires_action"), + "event_ids": Schema.Array(Schema.String).annotate({ + "description": + "The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder." + }) + }).annotate({ + "description": + "The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running." + }), + Schema.Struct({ "type": Schema.Literal("retries_exhausted") }).annotate({ + "description": + "The turn ended because repeated errors exhausted the retry budget or an error escalated to `retry_status: 'exhausted'`." + }), + Schema.Struct({ "type": Schema.Literal("budget_reached") }).annotate({ + "description": + "The agent stopped because the session's tracked list cost reached its budget, or because its usage includes a model with no list price (which the budget cannot measure). Raise the budget to continue — or, if raising is rejected because a model has no list price, remove the budget." + }) + ], { mode: "oneOf" }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.status_terminated"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_created"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the thread was created." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the callable agent the thread runs." }), + "session_thread_id": Schema.String.annotate({ "description": "Public `sthr_` ID of the newly created thread." }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("span.outcome_evaluation_start"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when outcome evaluation started." + }), + "iteration": Schema.Number.annotate({ + "description": + "0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "outcome_id": Schema.String.annotate({ "description": "The `outc_` ID of the outcome being evaluated." }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("span.outcome_evaluation_end"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when outcome evaluation ended." + }), + "outcome_evaluation_start_id": Schema.String.annotate({ + "description": "The id of the corresponding `span.outcome_evaluation_start` event." + }), + "iteration": Schema.Number.annotate({ + "description": "0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "result": Schema.String.annotate({ + "description": + "Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress." + }), + "explanation": Schema.String.annotate({ + "description": + "Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why." + }), + "usage": Schema.suspend((): Schema.Codec => BetaManagedAgentsSpanModelUsage) + .annotate({ + "description": + "Aggregate token usage for this evaluation cycle. Sums across all grader model requests within the cycle." + }), + "outcome_id": Schema.String.annotate({ "description": "The `outc_` ID of the outcome being evaluated." }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("span.model_request_start"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the model request started." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("span.model_request_end"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the model request completed." + }), + "is_error": Schema.Boolean.annotate({ "description": "Whether the model request resulted in an error." }), + "model_usage": Schema.suspend((): Schema.Codec => BetaManagedAgentsSpanModelUsage) + .annotate({ "description": "Token usage for this model request." }), + "model_request_start_id": Schema.String.annotate({ + "description": "The id of the corresponding `span.model_request_start` event." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("span.outcome_evaluation_ongoing"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this heartbeat was emitted." + }), + "iteration": Schema.Number.annotate({ + "description": "0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "outcome_id": Schema.String.annotate({ "description": "The `outc_` ID of the outcome being evaluated." }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("user.define_outcome"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the outcome was accepted." + }), + "outcome_id": Schema.String.annotate({ + "description": + "Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list." + }), + "description": Schema.String.annotate({ + "description": "What the agent should produce. Copied from the input event." + }), + "max_iterations": Schema.Number.annotate({ + "description": "Evaluate-then-revise cycles before giving up. Default 3, max 20.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "rubric": Schema.suspend((): Schema.Codec => BetaManagedAgentsRubric).annotate({ + "description": + "How to grade the outcome. File rubrics are currently resolved to their text content; clients should handle both variants." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.deleted"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the session was deleted." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_running"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ + "description": "Public sthr_ ID of the thread that started running." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_idle"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ "description": "Public sthr_ ID of the thread that went idle." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }), + "stop_reason": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("end_turn") }).annotate({ + "description": "The agent completed its turn naturally and is ready for the next user message." + }), + Schema.Struct({ + "type": Schema.Literal("requires_action"), + "event_ids": Schema.Array(Schema.String).annotate({ + "description": + "The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder." + }) + }).annotate({ + "description": + "The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running." + }), + Schema.Struct({ "type": Schema.Literal("retries_exhausted") }).annotate({ + "description": + "The turn ended because repeated errors exhausted the retry budget or an error escalated to `retry_status: 'exhausted'`." + }), + Schema.Struct({ "type": Schema.Literal("budget_reached") }).annotate({ + "description": + "The agent stopped because the session's tracked list cost reached its budget, or because its usage includes a model with no list price (which the budget cannot measure). Raise the budget to continue — or, if raising is rejected because a model has no list price, remove the budget." + }) + ], { mode: "oneOf" }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_terminated"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ "description": "Public sthr_ ID of the thread that terminated." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this result was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_rescheduled"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ "description": "Public sthr_ ID of the thread that is retrying." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.updated"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the update was applied." + }), + "title": Schema.optionalKey( + Schema.String.annotate({ "description": "The session's new title. Present only when the update changed it." }) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty." + }) + ), + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsSessionAgent).annotate({ + "description": + "The session's effective agent configuration after the update. Present only when the update changed `agent` (tools or mcp_servers); when present it is the full materialised snapshot, not a diff." + }) + ), + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": + "The session's budget after the update: the new budget when set or replaced, or null when the update removed it. Present only when the update changed the budget." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("event_start"), + "event": Schema.suspend((): Schema.Codec => + BetaManagedAgentsEventStartEvent_Event + ).annotate({ + "description": + "The previewed event's type and id. The event type determines which delta types the preview's event_delta events carry: agent.message events stream content_delta fragments; agent.thinking previews are start-only — no deltas follow, and the buffered agent.thinking with the same id concludes them." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("event_delta"), + "event_id": Schema.String.annotate({ + "description": + "The id of the event being previewed. Matches event.id on the corresponding event_start and the buffered event that reconciles the preview." + }), + "delta": Schema.suspend((): Schema.Codec => + BetaManagedAgentsEventDeltaEvent_Delta + ).annotate({ + "description": + "One fragment of the previewed event. The delta type is named for the previewed event's field it streams into: agent.message events stream content_delta fragments, each a partial element of the content array." + }) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("system.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsSystemContentBlock).annotate({ + "description": "System content blocks. Text-only." + }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this system message was processed." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }), + Schema.Struct({ + "type": Schema.Literal("session.usage"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the snapshot was taken." + }), + "usage": Schema.suspend((): Schema.Codec => + BetaManagedAgentsSessionUsageSnapshot + ).annotate({ "description": "The session's cumulative usage at the snapshot time." }), + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": "The session's configured budget at the snapshot time, or null when the session has no budget." + }) + ) + }).annotate({ "description": "Server-sent event in the session stream." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsStreamSessionEvents" }) +export type BetaManagedAgentsStreamSessionThreadEvents = + | { + readonly "type": "user.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at"?: BetaTimestamp + } + | { + readonly "type": "user.interrupt" + readonly "id": string + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "user.tool_confirmation" + readonly "id": string + readonly "tool_use_id": string + readonly "result": BetaManagedAgentsUserToolConfirmationResult + readonly "deny_message"?: string + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "user.custom_tool_result" + readonly "id": string + readonly "custom_tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.custom_tool_use" + readonly "id": string + readonly "name": string + readonly "input": BetaManagedAgentsStruct + readonly "processed_at": BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at": BetaTimestamp + } + | { readonly "type": "agent.thinking"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "agent.mcp_tool_use" + readonly "id": string + readonly "name": string + readonly "mcp_server_name": string + readonly "input": BetaManagedAgentsStruct + readonly "processed_at": BetaTimestamp + readonly "evaluated_permission"?: BetaManagedAgentsAgentEvaluatedPermission + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.mcp_tool_result" + readonly "id": string + readonly "mcp_tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at": BetaTimestamp + } + | { + readonly "type": "agent.tool_use" + readonly "id": string + readonly "name": string + readonly "input": BetaManagedAgentsStruct + readonly "processed_at": BetaTimestamp + readonly "evaluated_permission"?: BetaManagedAgentsAgentEvaluatedPermission + readonly "session_thread_id"?: string + } + | { + readonly "type": "agent.tool_result" + readonly "id": string + readonly "tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at": BetaTimestamp + } + | { + readonly "type": "agent.thread_message_received" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "from_agent_name"?: string + readonly "content": ReadonlyArray + readonly "from_session_thread_id": string + } + | { + readonly "type": "agent.thread_message_sent" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "to_agent_name"?: string + readonly "content": ReadonlyArray + readonly "to_session_thread_id": string + } + | { readonly "type": "agent.thread_context_compacted"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.error" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "error": { + readonly "type": "unknown_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "model_overloaded_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "model_rate_limited_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "model_request_failed_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "mcp_connection_failed_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + readonly "mcp_server_name": string + } | { + readonly "type": "mcp_authentication_failed_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + readonly "mcp_server_name": string + } | { + readonly "type": "billing_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + } | { + readonly "type": "credential_host_unreachable_error" + readonly "message": string + readonly "retry_status": BetaManagedAgentsRetryStatus + readonly "vault_id": string + readonly "credential_id": string + } + } + | { readonly "type": "session.status_rescheduled"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { readonly "type": "session.status_running"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.status_idle" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "stop_reason": + | { readonly "type": "end_turn" } + | { readonly "type": "requires_action"; readonly "event_ids": ReadonlyArray } + | { readonly "type": "retries_exhausted" } + | { readonly "type": "budget_reached" } + } + | { readonly "type": "session.status_terminated"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.thread_created" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + readonly "session_thread_id": string + } + | { + readonly "type": "span.outcome_evaluation_start" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "iteration": number + readonly "outcome_id": string + } + | { + readonly "type": "span.outcome_evaluation_end" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "outcome_evaluation_start_id": string + readonly "iteration": number + readonly "result": string + readonly "explanation": string + readonly "usage": BetaManagedAgentsSpanModelUsage + readonly "outcome_id": string + } + | { readonly "type": "span.model_request_start"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "span.model_request_end" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "is_error": boolean + readonly "model_usage": BetaManagedAgentsSpanModelUsage + readonly "model_request_start_id": string + } + | { + readonly "type": "span.outcome_evaluation_ongoing" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "iteration": number + readonly "outcome_id": string + } + | { + readonly "type": "user.define_outcome" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "outcome_id": string + readonly "description": string + readonly "max_iterations": number + readonly "rubric": BetaManagedAgentsRubric + } + | { readonly "type": "session.deleted"; readonly "id": string; readonly "processed_at": BetaTimestamp } + | { + readonly "type": "session.thread_status_running" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + } + | { + readonly "type": "session.thread_status_idle" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + readonly "stop_reason": + | { readonly "type": "end_turn" } + | { readonly "type": "requires_action"; readonly "event_ids": ReadonlyArray } + | { readonly "type": "retries_exhausted" } + | { readonly "type": "budget_reached" } + } + | { + readonly "type": "session.thread_status_terminated" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + } + | { + readonly "type": "user.tool_result" + readonly "id": string + readonly "tool_use_id": string + readonly "content"?: ReadonlyArray + readonly "is_error"?: boolean + readonly "processed_at"?: BetaTimestamp + readonly "session_thread_id"?: string + } + | { + readonly "type": "session.thread_status_rescheduled" + readonly "id": string + readonly "session_thread_id": string + readonly "processed_at": BetaTimestamp + readonly "agent_name": string + } + | { + readonly "type": "session.updated" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "title"?: string + readonly "metadata"?: { readonly [x: string]: string } + readonly "agent"?: BetaManagedAgentsSessionAgent + readonly "budget"?: BetaManagedAgentsBudget + } + | { readonly "type": "event_start"; readonly "event": BetaManagedAgentsEventStartEvent_Event } + | { + readonly "type": "event_delta" + readonly "event_id": string + readonly "delta": BetaManagedAgentsEventDeltaEvent_Delta + } + | { + readonly "type": "system.message" + readonly "id": string + readonly "content": ReadonlyArray + readonly "processed_at"?: BetaTimestamp + } + | { + readonly "type": "session.usage" + readonly "id": string + readonly "processed_at": BetaTimestamp + readonly "usage": BetaManagedAgentsSessionUsageSnapshot + readonly "budget"?: BetaManagedAgentsBudget + } +export const BetaManagedAgentsStreamSessionThreadEvents = Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("user.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ + "description": "Array of content blocks comprising the user message." + }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the agent finished processing this message." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("user.interrupt"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the interrupt was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_confirmation"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "result": Schema.suspend((): Schema.Codec => + BetaManagedAgentsUserToolConfirmationResult + ).annotate({ "description": "The confirmation result: 'allow' or 'deny'." }), + "deny_message": Schema.optionalKey( + Schema.String.annotate({ + "description": "Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'." + }).check(Schema.isMaxLength(10000).annotate({ "expected": "a value with a length of at most 10000" })) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the confirmation was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("user.custom_tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "custom_tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this result was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.custom_tool_use"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "name": Schema.String.annotate({ "description": "Name of the custom tool being called." }), + "input": Schema.suspend((): Schema.Codec => BetaManagedAgentsStruct).annotate({ + "description": "Input parameters for the tool call." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this tool use was processed." + }), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsAgentMessageContentBlock).annotate({ + "description": "Array of text blocks comprising the agent response." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this response was generated." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.thinking"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this thinking was produced." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.mcp_tool_use"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "name": Schema.String.annotate({ "description": "Name of the MCP tool being used." }), + "mcp_server_name": Schema.String.annotate({ "description": "Name of the MCP server providing the tool." }), + "input": Schema.suspend((): Schema.Codec => BetaManagedAgentsStruct).annotate({ + "description": "Input parameters for the tool call." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }), + "evaluated_permission": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsAgentEvaluatedPermission + ).annotate({ "description": "The evaluated permission policy for this tool invocation." }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.mcp_tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "mcp_tool_use_id": Schema.String.annotate({ + "description": "The id of the `agent.mcp_tool_use` event this result corresponds to." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.tool_use"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "name": Schema.String.annotate({ "description": "Name of the agent tool being used." }), + "input": Schema.suspend((): Schema.Codec => BetaManagedAgentsStruct).annotate({ + "description": "Input parameters for the tool call." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }), + "evaluated_permission": Schema.optionalKey( + Schema.suspend((): Schema.Codec => + BetaManagedAgentsAgentEvaluatedPermission + ).annotate({ "description": "The evaluated permission policy for this tool invocation." }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ + "description": "The id of the `agent.tool_use` event this result corresponds to." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this event was processed." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.thread_message_received"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the message was received." + }), + "from_agent_name": Schema.optionalKey( + Schema.String.annotate({ + "description": "Name of the callable agent this message came from. Absent when received from the primary agent." + }) + ), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ "description": "Message content blocks." }), + "from_session_thread_id": Schema.String.annotate({ + "description": "Public `sthr_` ID of the thread that sent the message." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.thread_message_sent"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the message was sent." + }), + "to_agent_name": Schema.optionalKey( + Schema.String.annotate({ + "description": "Name of the callable agent this message was sent to. Absent when sent to the primary agent." + }) + ), + "content": Schema.Array(BetaManagedAgentsUserContentBlock).annotate({ "description": "Message content blocks." }), + "to_session_thread_id": Schema.String.annotate({ + "description": "Public `sthr_` ID of the thread the message was sent to." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("agent.thread_context_compacted"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when compaction was processed." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.error"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the error occurred." + }), + "error": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("unknown_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ + "description": + "An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone." + }), + Schema.Struct({ + "type": Schema.Literal("model_overloaded_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ + "description": "The model is currently overloaded. Emitted after automatic retries are exhausted." + }), + Schema.Struct({ + "type": Schema.Literal("model_rate_limited_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ "description": "The model request was rate-limited." }), + Schema.Struct({ + "type": Schema.Literal("model_request_failed_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ "description": "A model request failed for a reason other than overload or rate-limiting." }), + Schema.Struct({ + "type": Schema.Literal("mcp_connection_failed_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }), + "mcp_server_name": Schema.String.annotate({ "description": "Name of the MCP server that failed to connect." }) + }).annotate({ "description": "Failed to connect to an MCP server." }), + Schema.Struct({ + "type": Schema.Literal("mcp_authentication_failed_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }), + "mcp_server_name": Schema.String.annotate({ + "description": "Name of the MCP server that failed authentication." + }) + }).annotate({ "description": "Authentication to an MCP server failed." }), + Schema.Struct({ + "type": Schema.Literal("billing_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }) + }).annotate({ + "description": + "The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state." + }), + Schema.Struct({ + "type": Schema.Literal("credential_host_unreachable_error"), + "message": Schema.String.annotate({ "description": "Human-readable error description." }), + "retry_status": Schema.suspend((): Schema.Codec => BetaManagedAgentsRetryStatus) + .annotate({ "description": "What the client should do next." }), + "vault_id": Schema.String.annotate({ "description": "ID of the vault containing the affected credential." }), + "credential_id": Schema.String.annotate({ "description": "ID of the affected credential." }) + }).annotate({ + "description": + "An `environment_variable` credential's `auth.networking.allowed_hosts` includes a host the environment's network policy does not permit." + }) + ], { mode: "oneOf" }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.status_rescheduled"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.status_running"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.status_idle"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }), + "stop_reason": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("end_turn") }).annotate({ + "description": "The agent completed its turn naturally and is ready for the next user message." + }), + Schema.Struct({ + "type": Schema.Literal("requires_action"), + "event_ids": Schema.Array(Schema.String).annotate({ + "description": + "The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder." + }) + }).annotate({ + "description": + "The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running." + }), + Schema.Struct({ "type": Schema.Literal("retries_exhausted") }).annotate({ + "description": + "The turn ended because repeated errors exhausted the retry budget or an error escalated to `retry_status: 'exhausted'`." + }), + Schema.Struct({ "type": Schema.Literal("budget_reached") }).annotate({ + "description": + "The agent stopped because the session's tracked list cost reached its budget, or because its usage includes a model with no list price (which the budget cannot measure). Raise the budget to continue — or, if raising is rejected because a model has no list price, remove the budget." + }) + ], { mode: "oneOf" }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.status_terminated"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of status change." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_created"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the thread was created." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the callable agent the thread runs." }), + "session_thread_id": Schema.String.annotate({ "description": "Public `sthr_` ID of the newly created thread." }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("span.outcome_evaluation_start"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when outcome evaluation started." + }), + "iteration": Schema.Number.annotate({ + "description": + "0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "outcome_id": Schema.String.annotate({ "description": "The `outc_` ID of the outcome being evaluated." }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("span.outcome_evaluation_end"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when outcome evaluation ended." + }), + "outcome_evaluation_start_id": Schema.String.annotate({ + "description": "The id of the corresponding `span.outcome_evaluation_start` event." + }), + "iteration": Schema.Number.annotate({ + "description": "0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "result": Schema.String.annotate({ + "description": + "Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress." + }), + "explanation": Schema.String.annotate({ + "description": + "Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why." + }), + "usage": Schema.suspend((): Schema.Codec => BetaManagedAgentsSpanModelUsage) + .annotate({ + "description": + "Aggregate token usage for this evaluation cycle. Sums across all grader model requests within the cycle." + }), + "outcome_id": Schema.String.annotate({ "description": "The `outc_` ID of the outcome being evaluated." }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("span.model_request_start"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the model request started." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("span.model_request_end"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the model request completed." + }), + "is_error": Schema.Boolean.annotate({ "description": "Whether the model request resulted in an error." }), + "model_usage": Schema.suspend((): Schema.Codec => BetaManagedAgentsSpanModelUsage) + .annotate({ "description": "Token usage for this model request." }), + "model_request_start_id": Schema.String.annotate({ + "description": "The id of the corresponding `span.model_request_start` event." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("span.outcome_evaluation_ongoing"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this heartbeat was emitted." + }), + "iteration": Schema.Number.annotate({ + "description": "0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "outcome_id": Schema.String.annotate({ "description": "The `outc_` ID of the outcome being evaluated." }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("user.define_outcome"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the outcome was accepted." + }), + "outcome_id": Schema.String.annotate({ + "description": + "Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list." + }), + "description": Schema.String.annotate({ + "description": "What the agent should produce. Copied from the input event." + }), + "max_iterations": Schema.Number.annotate({ + "description": "Evaluate-then-revise cycles before giving up. Default 3, max 20.", + "format": "int32" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "rubric": Schema.suspend((): Schema.Codec => BetaManagedAgentsRubric).annotate({ + "description": + "How to grade the outcome. File rubrics are currently resolved to their text content; clients should handle both variants." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.deleted"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the session was deleted." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_running"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ + "description": "Public sthr_ ID of the thread that started running." + }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_idle"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ "description": "Public sthr_ ID of the thread that went idle." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }), + "stop_reason": Schema.Union([ + Schema.Struct({ "type": Schema.Literal("end_turn") }).annotate({ + "description": "The agent completed its turn naturally and is ready for the next user message." + }), + Schema.Struct({ + "type": Schema.Literal("requires_action"), + "event_ids": Schema.Array(Schema.String).annotate({ + "description": + "The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder." + }) + }).annotate({ + "description": + "The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running." + }), + Schema.Struct({ "type": Schema.Literal("retries_exhausted") }).annotate({ + "description": + "The turn ended because repeated errors exhausted the retry budget or an error escalated to `retry_status: 'exhausted'`." + }), + Schema.Struct({ "type": Schema.Literal("budget_reached") }).annotate({ + "description": + "The agent stopped because the session's tracked list cost reached its budget, or because its usage includes a model with no list price (which the budget cannot measure). Raise the budget to continue — or, if raising is rejected because a model has no list price, remove the budget." + }) + ], { mode: "oneOf" }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_terminated"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ "description": "Public sthr_ ID of the thread that terminated." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("user.tool_result"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "tool_use_id": Schema.String.annotate({ + "description": + "The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field." + }), + "content": Schema.optionalKey( + Schema.Array(BetaManagedAgentsToolResultContentBlock).annotate({ + "description": "The result content returned by the tool." + }) + ), + "is_error": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the tool execution resulted in an error." }) + ), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this result was processed." + }) + ), + "session_thread_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.thread_status_rescheduled"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "session_thread_id": Schema.String.annotate({ "description": "Public sthr_ ID of the thread that is retrying." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp of the status transition." + }), + "agent_name": Schema.String.annotate({ "description": "Name of the agent the thread runs." }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.updated"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the update was applied." + }), + "title": Schema.optionalKey( + Schema.String.annotate({ "description": "The session's new title. Present only when the update changed it." }) + ), + "metadata": Schema.optionalKey( + Schema.Record(Schema.String, Schema.String).annotate({ + "description": + "The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty." + }) + ), + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsSessionAgent).annotate({ + "description": + "The session's effective agent configuration after the update. Present only when the update changed `agent` (tools or mcp_servers); when present it is the full materialised snapshot, not a diff." + }) + ), + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": + "The session's budget after the update: the new budget when set or replaced, or null when the update removed it. Present only when the update changed the budget." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("event_start"), + "event": Schema.suspend((): Schema.Codec => + BetaManagedAgentsEventStartEvent_Event + ).annotate({ + "description": + "The previewed event's type and id. The event type determines which delta types the preview's event_delta events carry: agent.message events stream content_delta fragments; agent.thinking previews are start-only — no deltas follow, and the buffered agent.thinking with the same id concludes them." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("event_delta"), + "event_id": Schema.String.annotate({ + "description": + "The id of the event being previewed. Matches event.id on the corresponding event_start and the buffered event that reconciles the preview." + }), + "delta": Schema.suspend((): Schema.Codec => + BetaManagedAgentsEventDeltaEvent_Delta + ).annotate({ + "description": + "One fragment of the previewed event. The delta type is named for the previewed event's field it streams into: agent.message events stream content_delta fragments, each a partial element of the content array." + }) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("system.message"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "content": Schema.Array(BetaManagedAgentsSystemContentBlock).annotate({ + "description": "System content blocks. Text-only." + }), + "processed_at": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when this system message was processed." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }), + Schema.Struct({ + "type": Schema.Literal("session.usage"), + "id": Schema.String.annotate({ "description": "Unique identifier for this event." }), + "processed_at": Schema.suspend((): Schema.Codec => BetaTimestamp).annotate({ + "description": "Timestamp when the snapshot was taken." + }), + "usage": Schema.suspend((): Schema.Codec => + BetaManagedAgentsSessionUsageSnapshot + ).annotate({ "description": "The session's cumulative usage at the snapshot time." }), + "budget": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaManagedAgentsBudget).annotate({ + "description": "The session's configured budget at the snapshot time, or null when the session has no budget." + }) + ) + }).annotate({ "description": "Server-sent event in a single thread's stream." }) +], { mode: "oneOf" }).annotate({ "identifier": "BetaManagedAgentsStreamSessionThreadEvents" }) +export type MessageBatchIndividualRequestParams = { + readonly "custom_id": string + readonly "params": CreateMessageParams +} +export const MessageBatchIndividualRequestParams = Schema.Struct({ + "custom_id": Schema.String.annotate({ + "title": "Custom Id", + "description": + "Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.\n\nMust be unique for each request within the Message Batch." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]{1,64}$" + }) + ), + "params": Schema.suspend((): Schema.Codec => CreateMessageParams).annotate({ + "description": + "Messages API creation parameters for the individual request.\n\nSee the [Messages API reference](https://platform.claude.com/docs/en/api/messages) for full documentation on available parameters." + }) +}).annotate({ "title": "MessageBatchIndividualRequestParams", "identifier": "MessageBatchIndividualRequestParams" }) +export type BetaMessageBatchIndividualRequestParams = { + readonly "custom_id": string + readonly "params": BetaCreateMessageParams +} +export const BetaMessageBatchIndividualRequestParams = Schema.Struct({ + "custom_id": Schema.String.annotate({ + "title": "Custom Id", + "description": + "Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.\n\nMust be unique for each request within the Message Batch." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]{1,64}$" + }) + ), + "params": Schema.suspend((): Schema.Codec => BetaCreateMessageParams).annotate({ + "description": + "Messages API creation parameters for the individual request.\n\nSee the [Messages API reference](https://platform.claude.com/docs/en/api/messages) for full documentation on available parameters." + }) +}).annotate({ "title": "MessageBatchIndividualRequestParams", "identifier": "BetaMessageBatchIndividualRequestParams" }) +export type BetaManagedAgentsListSessions = { + readonly "data"?: ReadonlyArray + readonly "next_page"?: string + readonly "prev_page"?: string +} +export const BetaManagedAgentsListSessions = Schema.Struct({ + "data": Schema.optionalKey(Schema.Array(BetaManagedAgentsSession).annotate({ "description": "List of sessions." })), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Opaque cursor for the next page. Null when no more results." }) + ), + "prev_page": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Opaque cursor for the previous page. Null when on the first page. Pass as the `page` parameter to navigate backward." + }) + ) +}).annotate({ "description": "Paginated list of sessions.", "identifier": "BetaManagedAgentsListSessions" }) +export type BetaManagedAgentsListSessionEvents = { + readonly "data"?: ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListSessionEvents = Schema.Struct({ + "data": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSessionEvent).annotate({ + "description": "Events for the session, ordered by `processed_at`." + }) + ), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Opaque cursor for the next page. Null when no more results." }) + ) +}).annotate({ + "description": "Paginated list of events for a `session`.", + "identifier": "BetaManagedAgentsListSessionEvents" +}) +export type BetaManagedAgentsListSessionThreadEvents = { + readonly "data"?: ReadonlyArray + readonly "next_page"?: string +} +export const BetaManagedAgentsListSessionThreadEvents = Schema.Struct({ + "data": Schema.optionalKey( + Schema.Array(BetaManagedAgentsSessionEvent).annotate({ + "description": "Events for the thread, ordered by `processed_at`." + }) + ), + "next_page": Schema.optionalKey( + Schema.String.annotate({ "description": "Opaque cursor for the next page. Null when no more results." }) + ) +}).annotate({ + "description": "Paginated list of events for a single thread within a `session`.", + "identifier": "BetaManagedAgentsListSessionThreadEvents" +}) +export type CreateMessageBatchParams = { readonly "requests": ReadonlyArray } +export const CreateMessageBatchParams = Schema.Struct({ + "requests": Schema.Array(MessageBatchIndividualRequestParams).annotate({ + "title": "Requests", + "description": "List of requests for prompt completion. Each is an individual request to create a Message." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(100000).annotate({ "expected": "a value with a length of at most 100000" }) + ) +}).annotate({ "title": "CreateMessageBatchParams", "identifier": "CreateMessageBatchParams" }) +export type BetaCreateMessageBatchParams = { + readonly "requests": ReadonlyArray +} +export const BetaCreateMessageBatchParams = Schema.Struct({ + "requests": Schema.Array(BetaMessageBatchIndividualRequestParams).annotate({ + "title": "Requests", + "description": "List of requests for prompt completion. Each is an individual request to create a Message." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(100000).annotate({ "expected": "a value with a length of at most 100000" }) + ) +}).annotate({ "title": "CreateMessageBatchParams", "identifier": "BetaCreateMessageBatchParams" }) +// schemas +export type MessagesPostParams = { + readonly "anthropic-version"?: string + readonly "anthropic-user-profile-id"?: string +} +export const MessagesPostParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-user-profile-id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-User-Profile-Id", + "description": + "The user profile ID to attribute this request to. Use when acting on behalf of a party other than your organization. Requires the `user-profiles` beta header." + }) + ) +}) +export type MessagesPostRequestJson = CreateMessageParams +export const MessagesPostRequestJson = CreateMessageParams +export type MessagesPost200 = Message +export const MessagesPost200 = Message +export type MessagesPost4XX = ErrorResponse +export const MessagesPost4XX = ErrorResponse +export type CompletePostParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const CompletePostParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ) +}) +export type CompletePostRequestJson = CompletionRequest +export const CompletePostRequestJson = CompletionRequest +export type CompletePost200 = CompletionResponse +export const CompletePost200 = CompletionResponse +export type CompletePost4XX = ErrorResponse +export const CompletePost4XX = ErrorResponse +export type ModelsListParams = { + readonly "before_id"?: string + readonly "after_id"?: string + readonly "limit"?: number + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "x-api-key"?: string +} +export const ModelsListParams = Schema.Struct({ + "before_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Before Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." + }) + ), + "after_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "After Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + }) + ), + "limit": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Limit", + "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", + "default": 20 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type ModelsList200 = ListResponse_ModelInfo_ +export const ModelsList200 = ListResponse_ModelInfo_ +export type ModelsList4XX = ErrorResponse +export const ModelsList4XX = ErrorResponse +export type ModelsGetParams = { + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "x-api-key"?: string +} +export const ModelsGetParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type ModelsGet200 = ModelInfo +export const ModelsGet200 = ModelInfo +export type ModelsGet4XX = ErrorResponse +export const ModelsGet4XX = ErrorResponse +export type MessageBatchesListParams = { + readonly "before_id"?: string + readonly "after_id"?: string + readonly "limit"?: number + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const MessageBatchesListParams = Schema.Struct({ + "before_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Before Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." + }) + ), + "after_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "After Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + }) + ), + "limit": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Limit", + "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", + "default": 20 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type MessageBatchesList200 = ListResponse_MessageBatch_ +export const MessageBatchesList200 = ListResponse_MessageBatch_ +export type MessageBatchesList4XX = ErrorResponse +export const MessageBatchesList4XX = ErrorResponse +export type MessageBatchesPostParams = { + readonly "anthropic-version"?: string + readonly "anthropic-user-profile-id"?: string +} +export const MessageBatchesPostParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-user-profile-id": Schema.optionalKey(Schema.String.annotate({ + "title": "Anthropic-User-Profile-Id", + "description": + "The user profile ID to attribute the requests in this batch to. Use when acting on behalf of a party other than your organization. Requires the `user-profiles` beta header. Applies to every request in the batch; an individual request whose `user_profile_id` body field conflicts with this header is errored." + })) +}) +export type MessageBatchesPostRequestJson = CreateMessageBatchParams +export const MessageBatchesPostRequestJson = CreateMessageBatchParams +export type MessageBatchesPost200 = MessageBatch +export const MessageBatchesPost200 = MessageBatch +export type MessageBatchesPost4XX = ErrorResponse +export const MessageBatchesPost4XX = ErrorResponse +export type MessageBatchesRetrieveParams = { readonly "anthropic-version"?: string; readonly "x-api-key"?: string } +export const MessageBatchesRetrieveParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type MessageBatchesRetrieve200 = MessageBatch +export const MessageBatchesRetrieve200 = MessageBatch +export type MessageBatchesRetrieve4XX = ErrorResponse +export const MessageBatchesRetrieve4XX = ErrorResponse +export type MessageBatchesDeleteParams = { readonly "anthropic-version"?: string; readonly "x-api-key"?: string } +export const MessageBatchesDeleteParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type MessageBatchesDelete200 = DeleteMessageBatchResponse +export const MessageBatchesDelete200 = DeleteMessageBatchResponse +export type MessageBatchesDelete4XX = ErrorResponse +export const MessageBatchesDelete4XX = ErrorResponse +export type MessageBatchesCancelParams = { readonly "anthropic-version"?: string } +export const MessageBatchesCancelParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ) +}) +export type MessageBatchesCancel200 = MessageBatch +export const MessageBatchesCancel200 = MessageBatch +export type MessageBatchesCancel4XX = ErrorResponse +export const MessageBatchesCancel4XX = ErrorResponse +export type MessageBatchesResultsParams = { readonly "anthropic-version"?: string; readonly "x-api-key"?: string } +export const MessageBatchesResultsParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type MessageBatchesResults4XX = ErrorResponse +export const MessageBatchesResults4XX = ErrorResponse +export type MessagesCountTokensPostParams = { + readonly "anthropic-version"?: string + readonly "anthropic-user-profile-id"?: string +} +export const MessagesCountTokensPostParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-user-profile-id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-User-Profile-Id", + "description": + "The user profile ID to attribute this request to. Use when acting on behalf of a party other than your organization. Requires the `user-profiles` beta header." + }) + ) +}) +export type MessagesCountTokensPostRequestJson = CountMessageTokensParams +export const MessagesCountTokensPostRequestJson = CountMessageTokensParams +export type MessagesCountTokensPost200 = CountMessageTokensResponse +export const MessagesCountTokensPost200 = CountMessageTokensResponse +export type MessagesCountTokensPost4XX = ErrorResponse +export const MessagesCountTokensPost4XX = ErrorResponse +export type BetaMessagesPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "anthropic-user-profile-id"?: string +} +export const BetaMessagesPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-user-profile-id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-User-Profile-Id", + "description": + "The user profile ID to attribute this request to. Use when acting on behalf of a party other than your organization. Requires the `user-profiles` beta header." + }) + ) +}) +export type BetaMessagesPostRequestJson = BetaCreateMessageParams +export const BetaMessagesPostRequestJson = BetaCreateMessageParams +export type BetaMessagesPost200 = BetaMessage +export const BetaMessagesPost200 = BetaMessage +export type BetaMessagesPost4XX = BetaErrorResponse +export const BetaMessagesPost4XX = BetaErrorResponse +export type BetaModelsListParams = { + readonly "before_id"?: string + readonly "after_id"?: string + readonly "limit"?: number + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "x-api-key"?: string +} +export const BetaModelsListParams = Schema.Struct({ + "before_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Before Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." + }) + ), + "after_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "After Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + }) + ), + "limit": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Limit", + "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", + "default": 20 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaModelsList200 = BetaListResponse_ModelInfo_ +export const BetaModelsList200 = BetaListResponse_ModelInfo_ +export type BetaModelsList4XX = BetaErrorResponse +export const BetaModelsList4XX = BetaErrorResponse +export type BetaModelsGetParams = { + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "x-api-key"?: string +} +export const BetaModelsGetParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaModelsGet200 = BetaModelInfo +export const BetaModelsGet200 = BetaModelInfo +export type BetaModelsGet4XX = BetaErrorResponse +export const BetaModelsGet4XX = BetaErrorResponse +export type BetaMessageBatchesListParams = { + readonly "before_id"?: string + readonly "after_id"?: string + readonly "limit"?: number + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaMessageBatchesListParams = Schema.Struct({ + "before_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Before Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." + }) + ), + "after_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "After Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + }) + ), + "limit": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Limit", + "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", + "default": 20 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaMessageBatchesList200 = BetaListResponse_MessageBatch_ +export const BetaMessageBatchesList200 = BetaListResponse_MessageBatch_ +export type BetaMessageBatchesList4XX = BetaErrorResponse +export const BetaMessageBatchesList4XX = BetaErrorResponse +export type BetaMessageBatchesPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "anthropic-user-profile-id"?: string +} +export const BetaMessageBatchesPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-user-profile-id": Schema.optionalKey(Schema.String.annotate({ + "title": "Anthropic-User-Profile-Id", + "description": + "The user profile ID to attribute the requests in this batch to. Use when acting on behalf of a party other than your organization. Requires the `user-profiles` beta header. Applies to every request in the batch; an individual request whose `user_profile_id` body field conflicts with this header is errored." + })) +}) +export type BetaMessageBatchesPostRequestJson = BetaCreateMessageBatchParams +export const BetaMessageBatchesPostRequestJson = BetaCreateMessageBatchParams +export type BetaMessageBatchesPost200 = BetaMessageBatch +export const BetaMessageBatchesPost200 = BetaMessageBatch +export type BetaMessageBatchesPost4XX = BetaErrorResponse +export const BetaMessageBatchesPost4XX = BetaErrorResponse +export type BetaMessageBatchesRetrieveParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaMessageBatchesRetrieveParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaMessageBatchesRetrieve200 = BetaMessageBatch +export const BetaMessageBatchesRetrieve200 = BetaMessageBatch +export type BetaMessageBatchesRetrieve4XX = BetaErrorResponse +export const BetaMessageBatchesRetrieve4XX = BetaErrorResponse +export type BetaMessageBatchesDeleteParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaMessageBatchesDeleteParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaMessageBatchesDelete200 = BetaDeleteMessageBatchResponse +export const BetaMessageBatchesDelete200 = BetaDeleteMessageBatchResponse +export type BetaMessageBatchesDelete4XX = BetaErrorResponse +export const BetaMessageBatchesDelete4XX = BetaErrorResponse +export type BetaMessageBatchesCancelParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string +} +export const BetaMessageBatchesCancelParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ) +}) +export type BetaMessageBatchesCancel200 = BetaMessageBatch +export const BetaMessageBatchesCancel200 = BetaMessageBatch +export type BetaMessageBatchesCancel4XX = BetaErrorResponse +export const BetaMessageBatchesCancel4XX = BetaErrorResponse +export type BetaMessageBatchesResultsParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaMessageBatchesResultsParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaMessageBatchesResults4XX = BetaErrorResponse +export const BetaMessageBatchesResults4XX = BetaErrorResponse +export type BetaMessagesCountTokensPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "anthropic-user-profile-id"?: string +} +export const BetaMessagesCountTokensPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "anthropic-user-profile-id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-User-Profile-Id", + "description": + "The user profile ID to attribute this request to. Use when acting on behalf of a party other than your organization. Requires the `user-profiles` beta header." + }) + ) +}) +export type BetaMessagesCountTokensPostRequestJson = BetaCountMessageTokensParams +export const BetaMessagesCountTokensPostRequestJson = BetaCountMessageTokensParams +export type BetaMessagesCountTokensPost200 = BetaCountMessageTokensResponse +export const BetaMessagesCountTokensPost200 = BetaCountMessageTokensResponse +export type BetaMessagesCountTokensPost4XX = BetaErrorResponse +export const BetaMessagesCountTokensPost4XX = BetaErrorResponse +export type BetaListFilesV1FilesGetParams = { + readonly "before_id"?: string + readonly "after_id"?: string + readonly "limit"?: number + readonly "scope_id"?: string + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaListFilesV1FilesGetParams = Schema.Struct({ + "before_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Before Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object." + }) + ), + "after_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "After Id", + "description": + "ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object." + }) + ), + "limit": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Limit", + "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`.", + "default": 20 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) + ), + "scope_id": Schema.optionalKey( + Schema.String.annotate({ + "title": "Scope Id", + "description": "Filter by scope ID. Only returns files associated with the specified scope (e.g., a session ID)." + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaListFilesV1FilesGet200 = BetaFileListResponse +export const BetaListFilesV1FilesGet200 = BetaFileListResponse +export type BetaListFilesV1FilesGet4XX = BetaErrorResponse +export const BetaListFilesV1FilesGet4XX = BetaErrorResponse +export type BetaUploadFileV1FilesPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string +} +export const BetaUploadFileV1FilesPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ) +}) +export type BetaUploadFileV1FilesPostRequestFormData = { readonly "file": string } +export const BetaUploadFileV1FilesPostRequestFormData = Schema.Struct({ + "file": Schema.String.annotate({ "description": "The file to upload", "format": "binary" }) +}) +export type BetaUploadFileV1FilesPost200 = BetaFileMetadataSchema +export const BetaUploadFileV1FilesPost200 = BetaFileMetadataSchema +export type BetaUploadFileV1FilesPost4XX = BetaErrorResponse +export const BetaUploadFileV1FilesPost4XX = BetaErrorResponse +export type BetaGetFileMetadataV1FilesFileIdGetParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaGetFileMetadataV1FilesFileIdGetParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaGetFileMetadataV1FilesFileIdGet200 = BetaFileMetadataSchema +export const BetaGetFileMetadataV1FilesFileIdGet200 = BetaFileMetadataSchema +export type BetaGetFileMetadataV1FilesFileIdGet4XX = BetaErrorResponse +export const BetaGetFileMetadataV1FilesFileIdGet4XX = BetaErrorResponse +export type BetaDeleteFileV1FilesFileIdDeleteParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaDeleteFileV1FilesFileIdDeleteParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaDeleteFileV1FilesFileIdDelete200 = BetaFileDeleteResponse +export const BetaDeleteFileV1FilesFileIdDelete200 = BetaFileDeleteResponse +export type BetaDeleteFileV1FilesFileIdDelete4XX = BetaErrorResponse +export const BetaDeleteFileV1FilesFileIdDelete4XX = BetaErrorResponse +export type BetaDownloadFileV1FilesFileIdContentGetParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaDownloadFileV1FilesFileIdContentGetParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaListSkillsV1SkillsGetParams = { + readonly "page"?: string | null + readonly "limit"?: number + readonly "source"?: string | null + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaListSkillsV1SkillsGetParams = Schema.Struct({ + "page": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Page", + "description": + "Pagination token for fetching a specific page of results.\n\nPass the value from a previous response's `next_page` field to get the next page of results." + }) + ), + "limit": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Limit", + "description": "Number of results to return per page.\n\nMaximum value is 100. Defaults to 20.", + "default": 20 + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "source": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Source", + "description": + "Filter skills by source.\n\nIf provided, only skills from the specified source will be returned:\n* `\"custom\"`: only return user-created skills\n* `\"anthropic\"`: only return Anthropic-created skills" + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaListSkillsV1SkillsGet200 = BetaListSkillsResponse +export const BetaListSkillsV1SkillsGet200 = BetaListSkillsResponse +export type BetaListSkillsV1SkillsGet4XX = BetaErrorResponse +export const BetaListSkillsV1SkillsGet4XX = BetaErrorResponse +export type BetaCreateSkillV1SkillsPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string +} +export const BetaCreateSkillV1SkillsPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ) +}) +export type BetaCreateSkillV1SkillsPostRequestFormData = BetaBody_create_skill_v1_skills_post +export const BetaCreateSkillV1SkillsPostRequestFormData = BetaBody_create_skill_v1_skills_post +export type BetaCreateSkillV1SkillsPost200 = BetaCreateSkillResponse +export const BetaCreateSkillV1SkillsPost200 = BetaCreateSkillResponse +export type BetaCreateSkillV1SkillsPost4XX = BetaErrorResponse +export const BetaCreateSkillV1SkillsPost4XX = BetaErrorResponse +export type BetaGetSkillV1SkillsSkillIdGetParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaGetSkillV1SkillsSkillIdGetParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaGetSkillV1SkillsSkillIdGet200 = BetaGetSkillResponse +export const BetaGetSkillV1SkillsSkillIdGet200 = BetaGetSkillResponse +export type BetaGetSkillV1SkillsSkillIdGet4XX = BetaErrorResponse +export const BetaGetSkillV1SkillsSkillIdGet4XX = BetaErrorResponse +export type BetaDeleteSkillV1SkillsSkillIdDeleteParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaDeleteSkillV1SkillsSkillIdDeleteParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaDeleteSkillV1SkillsSkillIdDelete200 = BetaDeleteSkillResponse +export const BetaDeleteSkillV1SkillsSkillIdDelete200 = BetaDeleteSkillResponse +export type BetaDeleteSkillV1SkillsSkillIdDelete4XX = BetaErrorResponse +export const BetaDeleteSkillV1SkillsSkillIdDelete4XX = BetaErrorResponse +export type BetaListSkillVersionsV1SkillsSkillIdVersionsGetParams = { + readonly "page"?: string | null + readonly "limit"?: number | null + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaListSkillVersionsV1SkillsSkillIdVersionsGetParams = Schema.Struct({ + "page": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Page", + "description": "Optionally set to the `next_page` token from the previous response." + }) + ), + "limit": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Limit", + "description": "Number of items to return per page.\n\nDefaults to `20`. Ranges from `1` to `1000`." + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaListSkillVersionsV1SkillsSkillIdVersionsGet200 = BetaListSkillVersionsResponse +export const BetaListSkillVersionsV1SkillsSkillIdVersionsGet200 = BetaListSkillVersionsResponse +export type BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX = BetaErrorResponse +export const BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX = BetaErrorResponse +export type BetaCreateSkillVersionV1SkillsSkillIdVersionsPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string +} +export const BetaCreateSkillVersionV1SkillsSkillIdVersionsPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ) +}) +export type BetaCreateSkillVersionV1SkillsSkillIdVersionsPostRequestFormData = + BetaBody_create_skill_version_v1_skills__skill_id__versions_post +export const BetaCreateSkillVersionV1SkillsSkillIdVersionsPostRequestFormData = + BetaBody_create_skill_version_v1_skills__skill_id__versions_post +export type BetaCreateSkillVersionV1SkillsSkillIdVersionsPost200 = BetaCreateSkillVersionResponse +export const BetaCreateSkillVersionV1SkillsSkillIdVersionsPost200 = BetaCreateSkillVersionResponse +export type BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX = BetaErrorResponse +export const BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX = BetaErrorResponse +export type BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGetParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGetParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet200 = BetaGetSkillVersionResponse +export const BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet200 = BetaGetSkillVersionResponse +export type BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX = BetaErrorResponse +export const BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX = BetaErrorResponse +export type BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDeleteParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDeleteParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete200 = BetaDeleteSkillVersionResponse +export const BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete200 = BetaDeleteSkillVersionResponse +export type BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX = BetaErrorResponse +export const BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX = BetaErrorResponse +export type BetaDownloadSkillVersionContentV1SkillsSkillIdVersionsVersionContentGetParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string +} +export const BetaDownloadSkillVersionContentV1SkillsSkillIdVersionsVersionContentGetParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.String.annotate({ + "title": "X-Api-Key", + "description": + "Your unique API key for authentication.\n\nThis key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace." + })) +}) +export type BetaListEnvironmentsV1EnvironmentsGetParams = { + readonly "limit"?: number + readonly "page"?: string | null + readonly "include_archived"?: boolean + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string | null +} +export const BetaListEnvironmentsV1EnvironmentsGetParams = Schema.Struct({ + "limit": Schema.optionalKey( + Schema.Number.annotate({ + "title": "Limit", + "description": "Maximum number of environments to return", + "default": 20 + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) + ), + "page": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Page", + "description": + "Opaque cursor from previous response for pagination. Pass the `next_page` value from the previous response." + }) + ), + "include_archived": Schema.optionalKey( + Schema.Boolean.annotate({ + "title": "Include Archived", + "description": "Include archived environments in the response", + "default": false + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "X-Api-Key" })) +}) +export type BetaListEnvironmentsV1EnvironmentsGet200 = BetaEnvironmentListResponse +export const BetaListEnvironmentsV1EnvironmentsGet200 = BetaEnvironmentListResponse +export type BetaListEnvironmentsV1EnvironmentsGet4XX = BetaErrorResponse +export const BetaListEnvironmentsV1EnvironmentsGet4XX = BetaErrorResponse +export type BetaCreateEnvironmentV1EnvironmentsPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string +} +export const BetaCreateEnvironmentV1EnvironmentsPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ) +}) +export type BetaCreateEnvironmentV1EnvironmentsPostRequestJson = BetaPublicEnvironmentCreateRequest +export const BetaCreateEnvironmentV1EnvironmentsPostRequestJson = BetaPublicEnvironmentCreateRequest +export type BetaCreateEnvironmentV1EnvironmentsPost200 = BetaEnvironment +export const BetaCreateEnvironmentV1EnvironmentsPost200 = BetaEnvironment +export type BetaCreateEnvironmentV1EnvironmentsPost4XX = BetaErrorResponse +export const BetaCreateEnvironmentV1EnvironmentsPost4XX = BetaErrorResponse +export type BetaGetEnvironmentV1EnvironmentsEnvironmentIdGetParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string | null +} +export const BetaGetEnvironmentV1EnvironmentsEnvironmentIdGetParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "X-Api-Key" })) +}) +export type BetaGetEnvironmentV1EnvironmentsEnvironmentIdGet200 = BetaEnvironment +export const BetaGetEnvironmentV1EnvironmentsEnvironmentIdGet200 = BetaEnvironment +export type BetaGetEnvironmentV1EnvironmentsEnvironmentIdGet4XX = BetaErrorResponse +export const BetaGetEnvironmentV1EnvironmentsEnvironmentIdGet4XX = BetaErrorResponse +export type BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string +} +export const BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ) +}) +export type BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPostRequestJson = BetaPublicEnvironmentUpdateRequest +export const BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPostRequestJson = BetaPublicEnvironmentUpdateRequest +export type BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost200 = BetaEnvironment +export const BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost200 = BetaEnvironment +export type BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost4XX = BetaErrorResponse +export const BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost4XX = BetaErrorResponse +export type BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDeleteParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string | null +} +export const BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDeleteParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "X-Api-Key" })) +}) +export type BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete200 = BetaEnvironmentDeleteResponse +export const BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete200 = BetaEnvironmentDeleteResponse +export type BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete4XX = BetaErrorResponse +export const BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete4XX = BetaErrorResponse +export type BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string +} +export const BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ) +}) +export type BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost200 = BetaEnvironment +export const BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost200 = BetaEnvironment +export type BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost4XX = BetaErrorResponse +export const BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost4XX = BetaErrorResponse +export type BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGetParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string | null + readonly "authorization"?: string | null +} +export const BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGetParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "X-Api-Key" })), + "authorization": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Authorization" })) +}) +export type BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet200 = BetaSelfHostedWorkQueueStats +export const BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet200 = BetaSelfHostedWorkQueueStats +export type BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet4XX = BetaErrorResponse +export const BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet4XX = BetaErrorResponse +export type BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGetParams = { + readonly "block_ms"?: number | null + readonly "reclaim_older_than_ms"?: number | null + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "Anthropic-Worker-ID"?: string | null + readonly "authorization"?: string | null +} +export const BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGetParams = Schema.Struct({ + "block_ms": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]).annotate({ + "title": "Block Ms", + "description": + "How long to wait for work to arrive before returning. Must be 1-999 in milliseconds. Defaults to non-blocking (returns immediately if no work is available)." + }) + ), + "reclaim_older_than_ms": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]).annotate({ + "title": "Reclaim Older Than Ms", + "description": + "Reclaim unacknowledged work items older than this many milliseconds. If omitted, uses the default (5000ms)." + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "Anthropic-Worker-ID": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Anthropic-Worker-Id", + "description": + "Unique identifier for the specific worker polling, used to track aggregated environment-level work metrics in Console" + }) + ), + "authorization": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Authorization" })) +}) +export type BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet200 = BetaSelfHostedWork | null +export const BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet200 = Schema.Union([BetaSelfHostedWork, Schema.Null]) + .annotate({ "title": "Response Poll Work V1 Environments Environment Id Work Poll Get" }) +export type BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet4XX = BetaErrorResponse +export const BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet4XX = BetaErrorResponse +export type BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "authorization"?: string | null +} +export const BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "authorization": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Authorization" })) +}) +export type BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost200 = BetaSelfHostedWork +export const BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost200 = BetaSelfHostedWork +export type BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost4XX = BetaErrorResponse +export const BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost4XX = BetaErrorResponse +export type BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPostParams = { + readonly "desired_ttl_seconds"?: number | null + readonly "expected_last_heartbeat"?: string | null + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "authorization"?: string | null +} +export const BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPostParams = Schema.Struct({ + "desired_ttl_seconds": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "title": "Desired Ttl Seconds", + "description": "Desired TTL in seconds" + }) + ), + "expected_last_heartbeat": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Expected Last Heartbeat", + "description": + "Expected last_heartbeat for conditional update (optimistic concurrency). Use literal 'NO_HEARTBEAT' to claim an unclaimed lease (first heartbeat). For subsequent heartbeats, echo the server's previous last_heartbeat value exactly. Returns 412 Precondition Failed if the actual value doesn't match." + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "authorization": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Authorization" })) +}) +export type BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost200 = + BetaSelfHostedWorkHeartbeatResponse +export const BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost200 = + BetaSelfHostedWorkHeartbeatResponse +export type BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost4XX = BetaErrorResponse +export const BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost4XX = BetaErrorResponse +export type BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "authorization"?: string | null +} +export const BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "authorization": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Authorization" })) +}) +export type BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPostRequestJson = BetaSelfHostedWorkStopRequest +export const BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPostRequestJson = BetaSelfHostedWorkStopRequest +export type BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost200 = BetaSelfHostedWork +export const BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost200 = BetaSelfHostedWork +export type BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost4XX = BetaErrorResponse +export const BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost4XX = BetaErrorResponse +export type BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGetParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "x-api-key"?: string | null +} +export const BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGetParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "x-api-key": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "X-Api-Key" })) +}) +export type BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet200 = BetaSelfHostedWork +export const BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet200 = BetaSelfHostedWork +export type BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet4XX = BetaErrorResponse +export const BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet4XX = BetaErrorResponse +export type BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPostParams = { + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string +} +export const BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPostParams = Schema.Struct({ + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ) +}) +export type BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPostRequestJson = BetaSelfHostedWorkUpdateRequest +export const BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPostRequestJson = BetaSelfHostedWorkUpdateRequest +export type BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost200 = BetaSelfHostedWork +export const BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost200 = BetaSelfHostedWork +export type BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost4XX = BetaErrorResponse +export const BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost4XX = BetaErrorResponse +export type BetaListWorkV1EnvironmentsEnvironmentIdWorkGetParams = { + readonly "limit"?: number + readonly "page"?: string | null + readonly "anthropic-beta"?: string + readonly "anthropic-version"?: string + readonly "authorization"?: string | null +} +export const BetaListWorkV1EnvironmentsEnvironmentIdWorkGetParams = Schema.Struct({ + "limit": Schema.optionalKey( + Schema.Number.annotate({ "title": "Limit", "description": "Maximum number of work items to return", "default": 20 }) + .check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) + ), + "page": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "title": "Page", + "description": "Opaque cursor from previous response for pagination" + }) + ), + "anthropic-beta": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Beta", + "description": + "Optional header to specify the beta version(s) you want to use.\n\nTo use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta." + }) + ), + "anthropic-version": Schema.optionalKey( + Schema.String.annotate({ + "title": "Anthropic-Version", + "description": + "The version of the Claude API you want to use.\n\nRead more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning)." + }) + ), + "authorization": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]).annotate({ "title": "Authorization" })) +}) +export type BetaListWorkV1EnvironmentsEnvironmentIdWorkGet200 = BetaSelfHostedWorkListResponse +export const BetaListWorkV1EnvironmentsEnvironmentIdWorkGet200 = BetaSelfHostedWorkListResponse +export type BetaListWorkV1EnvironmentsEnvironmentIdWorkGet4XX = BetaErrorResponse +export const BetaListWorkV1EnvironmentsEnvironmentIdWorkGet4XX = BetaErrorResponse +export type BetaListMemoriesParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "path_prefix"?: string + readonly "depth"?: number + readonly "limit"?: number + readonly "page"?: string + readonly "view"?: BetaManagedAgentsMemoryView +} +export const BetaListMemoriesParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "path_prefix": Schema.optionalKey(Schema.String), + "depth": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "view": Schema.optionalKey(BetaManagedAgentsMemoryView) +}) +export type BetaListMemories200 = BetaManagedAgentsListMemoriesResult +export const BetaListMemories200 = BetaManagedAgentsListMemoriesResult +export type BetaListMemories400 = BetaManagedAgentsErrorResponse +export const BetaListMemories400 = BetaManagedAgentsErrorResponse +export type BetaListMemories401 = BetaManagedAgentsErrorResponse +export const BetaListMemories401 = BetaManagedAgentsErrorResponse +export type BetaListMemories403 = BetaManagedAgentsErrorResponse +export const BetaListMemories403 = BetaManagedAgentsErrorResponse +export type BetaListMemories404 = BetaManagedAgentsErrorResponse +export const BetaListMemories404 = BetaManagedAgentsErrorResponse +export type BetaListMemories408 = BetaManagedAgentsErrorResponse +export const BetaListMemories408 = BetaManagedAgentsErrorResponse +export type BetaListMemories409 = BetaManagedAgentsErrorResponse +export const BetaListMemories409 = BetaManagedAgentsErrorResponse +export type BetaListMemories412 = BetaManagedAgentsErrorResponse +export const BetaListMemories412 = BetaManagedAgentsErrorResponse +export type BetaListMemories413 = BetaManagedAgentsErrorResponse +export const BetaListMemories413 = BetaManagedAgentsErrorResponse +export type BetaListMemories429 = BetaManagedAgentsErrorResponse +export const BetaListMemories429 = BetaManagedAgentsErrorResponse +export type BetaListMemories431 = BetaManagedAgentsErrorResponse +export const BetaListMemories431 = BetaManagedAgentsErrorResponse +export type BetaListMemories499 = BetaManagedAgentsErrorResponse +export const BetaListMemories499 = BetaManagedAgentsErrorResponse +export type BetaListMemories500 = BetaManagedAgentsErrorResponse +export const BetaListMemories500 = BetaManagedAgentsErrorResponse +export type BetaListMemories501 = BetaManagedAgentsErrorResponse +export const BetaListMemories501 = BetaManagedAgentsErrorResponse +export type BetaListMemories503 = BetaManagedAgentsErrorResponse +export const BetaListMemories503 = BetaManagedAgentsErrorResponse +export type BetaListMemories504 = BetaManagedAgentsErrorResponse +export const BetaListMemories504 = BetaManagedAgentsErrorResponse +export type BetaCreateMemoryParams = { + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "view"?: BetaManagedAgentsMemoryView +} +export const BetaCreateMemoryParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "view": Schema.optionalKey(BetaManagedAgentsMemoryView) +}) +export type BetaCreateMemoryRequestJson = BetaManagedAgentsCreateMemoryParams +export const BetaCreateMemoryRequestJson = BetaManagedAgentsCreateMemoryParams +export type BetaCreateMemory200 = BetaManagedAgentsMemory +export const BetaCreateMemory200 = BetaManagedAgentsMemory +export type BetaCreateMemory400 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory400 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory401 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory401 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory403 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory403 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory404 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory404 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory408 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory408 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory409 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory409 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory412 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory412 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory413 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory413 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory429 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory429 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory431 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory431 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory499 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory499 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory500 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory500 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory501 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory501 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory503 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory503 = BetaManagedAgentsErrorResponse +export type BetaCreateMemory504 = BetaManagedAgentsErrorResponse +export const BetaCreateMemory504 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "view"?: BetaManagedAgentsMemoryView +} +export const BetaGetMemoryParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "view": Schema.optionalKey(BetaManagedAgentsMemoryView) +}) +export type BetaGetMemory200 = BetaManagedAgentsMemory +export const BetaGetMemory200 = BetaManagedAgentsMemory +export type BetaGetMemory400 = BetaManagedAgentsErrorResponse +export const BetaGetMemory400 = BetaManagedAgentsErrorResponse +export type BetaGetMemory401 = BetaManagedAgentsErrorResponse +export const BetaGetMemory401 = BetaManagedAgentsErrorResponse +export type BetaGetMemory403 = BetaManagedAgentsErrorResponse +export const BetaGetMemory403 = BetaManagedAgentsErrorResponse +export type BetaGetMemory404 = BetaManagedAgentsErrorResponse +export const BetaGetMemory404 = BetaManagedAgentsErrorResponse +export type BetaGetMemory408 = BetaManagedAgentsErrorResponse +export const BetaGetMemory408 = BetaManagedAgentsErrorResponse +export type BetaGetMemory409 = BetaManagedAgentsErrorResponse +export const BetaGetMemory409 = BetaManagedAgentsErrorResponse +export type BetaGetMemory412 = BetaManagedAgentsErrorResponse +export const BetaGetMemory412 = BetaManagedAgentsErrorResponse +export type BetaGetMemory413 = BetaManagedAgentsErrorResponse +export const BetaGetMemory413 = BetaManagedAgentsErrorResponse +export type BetaGetMemory429 = BetaManagedAgentsErrorResponse +export const BetaGetMemory429 = BetaManagedAgentsErrorResponse +export type BetaGetMemory431 = BetaManagedAgentsErrorResponse +export const BetaGetMemory431 = BetaManagedAgentsErrorResponse +export type BetaGetMemory499 = BetaManagedAgentsErrorResponse +export const BetaGetMemory499 = BetaManagedAgentsErrorResponse +export type BetaGetMemory500 = BetaManagedAgentsErrorResponse +export const BetaGetMemory500 = BetaManagedAgentsErrorResponse +export type BetaGetMemory501 = BetaManagedAgentsErrorResponse +export const BetaGetMemory501 = BetaManagedAgentsErrorResponse +export type BetaGetMemory503 = BetaManagedAgentsErrorResponse +export const BetaGetMemory503 = BetaManagedAgentsErrorResponse +export type BetaGetMemory504 = BetaManagedAgentsErrorResponse +export const BetaGetMemory504 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemoryParams = { + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "view"?: BetaManagedAgentsMemoryView +} +export const BetaUpdateMemoryParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "view": Schema.optionalKey(BetaManagedAgentsMemoryView) +}) +export type BetaUpdateMemoryRequestJson = BetaManagedAgentsUpdateMemoryParams +export const BetaUpdateMemoryRequestJson = BetaManagedAgentsUpdateMemoryParams +export type BetaUpdateMemory200 = BetaManagedAgentsMemory +export const BetaUpdateMemory200 = BetaManagedAgentsMemory +export type BetaUpdateMemory400 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory400 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory401 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory401 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory403 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory403 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory404 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory404 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory408 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory408 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory409 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory409 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory412 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory412 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory413 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory413 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory429 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory429 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory431 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory431 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory499 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory499 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory500 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory500 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory501 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory501 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory503 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory503 = BetaManagedAgentsErrorResponse +export type BetaUpdateMemory504 = BetaManagedAgentsErrorResponse +export const BetaUpdateMemory504 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemoryParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "expected_content_sha256"?: string +} +export const BetaDeleteMemoryParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "expected_content_sha256": Schema.optionalKey(Schema.String) +}) +export type BetaDeleteMemory200 = BetaManagedAgentsDeletedMemory +export const BetaDeleteMemory200 = BetaManagedAgentsDeletedMemory +export type BetaDeleteMemory400 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory400 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory401 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory401 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory403 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory403 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory404 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory404 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory408 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory408 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory409 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory409 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory412 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory412 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory413 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory413 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory429 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory429 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory431 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory431 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory499 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory499 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory500 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory500 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory501 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory501 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory503 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory503 = BetaManagedAgentsErrorResponse +export type BetaDeleteMemory504 = BetaManagedAgentsErrorResponse +export const BetaDeleteMemory504 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersionsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "memory_id"?: string + readonly "session_id"?: string + readonly "api_key_id"?: string + readonly "operation"?: BetaManagedAgentsMemoryVersionOperation + readonly "created_at[gte]"?: BetaTimestamp + readonly "created_at[lte]"?: BetaTimestamp + readonly "limit"?: number + readonly "page"?: string + readonly "view"?: BetaManagedAgentsMemoryView +} +export const BetaListMemoryVersionsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "memory_id": Schema.optionalKey(Schema.String), + "session_id": Schema.optionalKey(Schema.String), + "api_key_id": Schema.optionalKey(Schema.String), + "operation": Schema.optionalKey(BetaManagedAgentsMemoryVersionOperation), + "created_at[gte]": Schema.optionalKey(BetaTimestamp), + "created_at[lte]": Schema.optionalKey(BetaTimestamp), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "view": Schema.optionalKey(BetaManagedAgentsMemoryView) +}) +export type BetaListMemoryVersions200 = BetaManagedAgentsListMemoryVersionsResult +export const BetaListMemoryVersions200 = BetaManagedAgentsListMemoryVersionsResult +export type BetaListMemoryVersions400 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions400 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions401 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions401 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions403 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions403 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions404 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions404 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions408 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions408 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions409 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions409 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions412 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions412 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions413 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions413 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions429 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions429 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions431 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions431 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions499 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions499 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions500 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions500 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions501 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions501 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions503 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions503 = BetaManagedAgentsErrorResponse +export type BetaListMemoryVersions504 = BetaManagedAgentsErrorResponse +export const BetaListMemoryVersions504 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersionParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "view"?: BetaManagedAgentsMemoryView +} +export const BetaGetMemoryVersionParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "view": Schema.optionalKey(BetaManagedAgentsMemoryView) +}) +export type BetaGetMemoryVersion200 = BetaManagedAgentsMemoryVersion +export const BetaGetMemoryVersion200 = BetaManagedAgentsMemoryVersion +export type BetaGetMemoryVersion400 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion400 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion401 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion401 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion403 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion403 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion404 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion404 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion408 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion408 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion409 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion409 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion412 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion412 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion413 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion413 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion429 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion429 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion431 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion431 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion499 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion499 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion500 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion500 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion501 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion501 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion503 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion503 = BetaManagedAgentsErrorResponse +export type BetaGetMemoryVersion504 = BetaManagedAgentsErrorResponse +export const BetaGetMemoryVersion504 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersionParams = { + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaRedactMemoryVersionParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaRedactMemoryVersion200 = BetaManagedAgentsMemoryVersion +export const BetaRedactMemoryVersion200 = BetaManagedAgentsMemoryVersion +export type BetaRedactMemoryVersion400 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion400 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion401 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion401 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion403 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion403 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion404 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion404 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion408 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion408 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion409 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion409 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion412 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion412 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion413 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion413 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion429 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion429 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion431 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion431 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion499 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion499 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion500 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion500 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion501 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion501 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion503 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion503 = BetaManagedAgentsErrorResponse +export type BetaRedactMemoryVersion504 = BetaManagedAgentsErrorResponse +export const BetaRedactMemoryVersion504 = BetaManagedAgentsErrorResponse +export type BetaListMemoryStoresParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "include_archived"?: boolean + readonly "created_at[gte]"?: BetaTimestamp + readonly "created_at[lte]"?: BetaTimestamp +} +export const BetaListMemoryStoresParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "include_archived": Schema.optionalKey(Schema.Boolean), + "created_at[gte]": Schema.optionalKey(BetaTimestamp), + "created_at[lte]": Schema.optionalKey(BetaTimestamp) +}) +export type BetaListMemoryStores200 = BetaManagedAgentsListMemoryStoresResponse +export const BetaListMemoryStores200 = BetaManagedAgentsListMemoryStoresResponse +export type BetaListMemoryStores400 = BetaErrorResponse +export const BetaListMemoryStores400 = BetaErrorResponse +export type BetaListMemoryStores401 = BetaErrorResponse +export const BetaListMemoryStores401 = BetaErrorResponse +export type BetaListMemoryStores403 = BetaErrorResponse +export const BetaListMemoryStores403 = BetaErrorResponse +export type BetaListMemoryStores404 = BetaErrorResponse +export const BetaListMemoryStores404 = BetaErrorResponse +export type BetaListMemoryStores408 = BetaErrorResponse +export const BetaListMemoryStores408 = BetaErrorResponse +export type BetaListMemoryStores409 = BetaErrorResponse +export const BetaListMemoryStores409 = BetaErrorResponse +export type BetaListMemoryStores412 = BetaErrorResponse +export const BetaListMemoryStores412 = BetaErrorResponse +export type BetaListMemoryStores413 = BetaErrorResponse +export const BetaListMemoryStores413 = BetaErrorResponse +export type BetaListMemoryStores429 = BetaErrorResponse +export const BetaListMemoryStores429 = BetaErrorResponse +export type BetaListMemoryStores431 = BetaErrorResponse +export const BetaListMemoryStores431 = BetaErrorResponse +export type BetaListMemoryStores499 = BetaErrorResponse +export const BetaListMemoryStores499 = BetaErrorResponse +export type BetaListMemoryStores500 = BetaErrorResponse +export const BetaListMemoryStores500 = BetaErrorResponse +export type BetaListMemoryStores501 = BetaErrorResponse +export const BetaListMemoryStores501 = BetaErrorResponse +export type BetaListMemoryStores503 = BetaErrorResponse +export const BetaListMemoryStores503 = BetaErrorResponse +export type BetaListMemoryStores504 = BetaErrorResponse +export const BetaListMemoryStores504 = BetaErrorResponse +export type BetaCreateMemoryStoreParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCreateMemoryStoreParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateMemoryStoreRequestJson = BetaManagedAgentsCreateMemoryStoreRequest +export const BetaCreateMemoryStoreRequestJson = BetaManagedAgentsCreateMemoryStoreRequest +export type BetaCreateMemoryStore200 = BetaManagedAgentsCreateMemoryStoreResponse +export const BetaCreateMemoryStore200 = BetaManagedAgentsCreateMemoryStoreResponse +export type BetaCreateMemoryStore400 = BetaErrorResponse +export const BetaCreateMemoryStore400 = BetaErrorResponse +export type BetaCreateMemoryStore401 = BetaErrorResponse +export const BetaCreateMemoryStore401 = BetaErrorResponse +export type BetaCreateMemoryStore403 = BetaErrorResponse +export const BetaCreateMemoryStore403 = BetaErrorResponse +export type BetaCreateMemoryStore404 = BetaErrorResponse +export const BetaCreateMemoryStore404 = BetaErrorResponse +export type BetaCreateMemoryStore408 = BetaErrorResponse +export const BetaCreateMemoryStore408 = BetaErrorResponse +export type BetaCreateMemoryStore409 = BetaErrorResponse +export const BetaCreateMemoryStore409 = BetaErrorResponse +export type BetaCreateMemoryStore412 = BetaErrorResponse +export const BetaCreateMemoryStore412 = BetaErrorResponse +export type BetaCreateMemoryStore413 = BetaErrorResponse +export const BetaCreateMemoryStore413 = BetaErrorResponse +export type BetaCreateMemoryStore429 = BetaErrorResponse +export const BetaCreateMemoryStore429 = BetaErrorResponse +export type BetaCreateMemoryStore431 = BetaErrorResponse +export const BetaCreateMemoryStore431 = BetaErrorResponse +export type BetaCreateMemoryStore499 = BetaErrorResponse +export const BetaCreateMemoryStore499 = BetaErrorResponse +export type BetaCreateMemoryStore500 = BetaErrorResponse +export const BetaCreateMemoryStore500 = BetaErrorResponse +export type BetaCreateMemoryStore501 = BetaErrorResponse +export const BetaCreateMemoryStore501 = BetaErrorResponse +export type BetaCreateMemoryStore503 = BetaErrorResponse +export const BetaCreateMemoryStore503 = BetaErrorResponse +export type BetaCreateMemoryStore504 = BetaErrorResponse +export const BetaCreateMemoryStore504 = BetaErrorResponse +export type BetaGetMemoryStoreParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetMemoryStoreParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetMemoryStore200 = BetaManagedAgentsGetMemoryStoreResponse +export const BetaGetMemoryStore200 = BetaManagedAgentsGetMemoryStoreResponse +export type BetaGetMemoryStore400 = BetaErrorResponse +export const BetaGetMemoryStore400 = BetaErrorResponse +export type BetaGetMemoryStore401 = BetaErrorResponse +export const BetaGetMemoryStore401 = BetaErrorResponse +export type BetaGetMemoryStore403 = BetaErrorResponse +export const BetaGetMemoryStore403 = BetaErrorResponse +export type BetaGetMemoryStore404 = BetaErrorResponse +export const BetaGetMemoryStore404 = BetaErrorResponse +export type BetaGetMemoryStore408 = BetaErrorResponse +export const BetaGetMemoryStore408 = BetaErrorResponse +export type BetaGetMemoryStore409 = BetaErrorResponse +export const BetaGetMemoryStore409 = BetaErrorResponse +export type BetaGetMemoryStore412 = BetaErrorResponse +export const BetaGetMemoryStore412 = BetaErrorResponse +export type BetaGetMemoryStore413 = BetaErrorResponse +export const BetaGetMemoryStore413 = BetaErrorResponse +export type BetaGetMemoryStore429 = BetaErrorResponse +export const BetaGetMemoryStore429 = BetaErrorResponse +export type BetaGetMemoryStore431 = BetaErrorResponse +export const BetaGetMemoryStore431 = BetaErrorResponse +export type BetaGetMemoryStore499 = BetaErrorResponse +export const BetaGetMemoryStore499 = BetaErrorResponse +export type BetaGetMemoryStore500 = BetaErrorResponse +export const BetaGetMemoryStore500 = BetaErrorResponse +export type BetaGetMemoryStore501 = BetaErrorResponse +export const BetaGetMemoryStore501 = BetaErrorResponse +export type BetaGetMemoryStore503 = BetaErrorResponse +export const BetaGetMemoryStore503 = BetaErrorResponse +export type BetaGetMemoryStore504 = BetaErrorResponse +export const BetaGetMemoryStore504 = BetaErrorResponse +export type BetaUpdateMemoryStoreParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaUpdateMemoryStoreParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaUpdateMemoryStoreRequestJson = BetaManagedAgentsUpdateMemoryStoreRequestBody +export const BetaUpdateMemoryStoreRequestJson = BetaManagedAgentsUpdateMemoryStoreRequestBody +export type BetaUpdateMemoryStore200 = BetaManagedAgentsUpdateMemoryStoreResponse +export const BetaUpdateMemoryStore200 = BetaManagedAgentsUpdateMemoryStoreResponse +export type BetaUpdateMemoryStore400 = BetaErrorResponse +export const BetaUpdateMemoryStore400 = BetaErrorResponse +export type BetaUpdateMemoryStore401 = BetaErrorResponse +export const BetaUpdateMemoryStore401 = BetaErrorResponse +export type BetaUpdateMemoryStore403 = BetaErrorResponse +export const BetaUpdateMemoryStore403 = BetaErrorResponse +export type BetaUpdateMemoryStore404 = BetaErrorResponse +export const BetaUpdateMemoryStore404 = BetaErrorResponse +export type BetaUpdateMemoryStore408 = BetaErrorResponse +export const BetaUpdateMemoryStore408 = BetaErrorResponse +export type BetaUpdateMemoryStore409 = BetaErrorResponse +export const BetaUpdateMemoryStore409 = BetaErrorResponse +export type BetaUpdateMemoryStore412 = BetaErrorResponse +export const BetaUpdateMemoryStore412 = BetaErrorResponse +export type BetaUpdateMemoryStore413 = BetaErrorResponse +export const BetaUpdateMemoryStore413 = BetaErrorResponse +export type BetaUpdateMemoryStore429 = BetaErrorResponse +export const BetaUpdateMemoryStore429 = BetaErrorResponse +export type BetaUpdateMemoryStore431 = BetaErrorResponse +export const BetaUpdateMemoryStore431 = BetaErrorResponse +export type BetaUpdateMemoryStore499 = BetaErrorResponse +export const BetaUpdateMemoryStore499 = BetaErrorResponse +export type BetaUpdateMemoryStore500 = BetaErrorResponse +export const BetaUpdateMemoryStore500 = BetaErrorResponse +export type BetaUpdateMemoryStore501 = BetaErrorResponse +export const BetaUpdateMemoryStore501 = BetaErrorResponse +export type BetaUpdateMemoryStore503 = BetaErrorResponse +export const BetaUpdateMemoryStore503 = BetaErrorResponse +export type BetaUpdateMemoryStore504 = BetaErrorResponse +export const BetaUpdateMemoryStore504 = BetaErrorResponse +export type BetaDeleteMemoryStoreParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaDeleteMemoryStoreParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaDeleteMemoryStore200 = BetaManagedAgentsDeleteMemoryStoreResponse +export const BetaDeleteMemoryStore200 = BetaManagedAgentsDeleteMemoryStoreResponse +export type BetaDeleteMemoryStore400 = BetaErrorResponse +export const BetaDeleteMemoryStore400 = BetaErrorResponse +export type BetaDeleteMemoryStore401 = BetaErrorResponse +export const BetaDeleteMemoryStore401 = BetaErrorResponse +export type BetaDeleteMemoryStore403 = BetaErrorResponse +export const BetaDeleteMemoryStore403 = BetaErrorResponse +export type BetaDeleteMemoryStore404 = BetaErrorResponse +export const BetaDeleteMemoryStore404 = BetaErrorResponse +export type BetaDeleteMemoryStore408 = BetaErrorResponse +export const BetaDeleteMemoryStore408 = BetaErrorResponse +export type BetaDeleteMemoryStore409 = BetaErrorResponse +export const BetaDeleteMemoryStore409 = BetaErrorResponse +export type BetaDeleteMemoryStore412 = BetaErrorResponse +export const BetaDeleteMemoryStore412 = BetaErrorResponse +export type BetaDeleteMemoryStore413 = BetaErrorResponse +export const BetaDeleteMemoryStore413 = BetaErrorResponse +export type BetaDeleteMemoryStore429 = BetaErrorResponse +export const BetaDeleteMemoryStore429 = BetaErrorResponse +export type BetaDeleteMemoryStore431 = BetaErrorResponse +export const BetaDeleteMemoryStore431 = BetaErrorResponse +export type BetaDeleteMemoryStore499 = BetaErrorResponse +export const BetaDeleteMemoryStore499 = BetaErrorResponse +export type BetaDeleteMemoryStore500 = BetaErrorResponse +export const BetaDeleteMemoryStore500 = BetaErrorResponse +export type BetaDeleteMemoryStore501 = BetaErrorResponse +export const BetaDeleteMemoryStore501 = BetaErrorResponse +export type BetaDeleteMemoryStore503 = BetaErrorResponse +export const BetaDeleteMemoryStore503 = BetaErrorResponse +export type BetaDeleteMemoryStore504 = BetaErrorResponse +export const BetaDeleteMemoryStore504 = BetaErrorResponse +export type BetaArchiveMemoryStoreParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaArchiveMemoryStoreParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveMemoryStore200 = BetaManagedAgentsArchiveMemoryStoreResponse +export const BetaArchiveMemoryStore200 = BetaManagedAgentsArchiveMemoryStoreResponse +export type BetaArchiveMemoryStore400 = BetaErrorResponse +export const BetaArchiveMemoryStore400 = BetaErrorResponse +export type BetaArchiveMemoryStore401 = BetaErrorResponse +export const BetaArchiveMemoryStore401 = BetaErrorResponse +export type BetaArchiveMemoryStore403 = BetaErrorResponse +export const BetaArchiveMemoryStore403 = BetaErrorResponse +export type BetaArchiveMemoryStore404 = BetaErrorResponse +export const BetaArchiveMemoryStore404 = BetaErrorResponse +export type BetaArchiveMemoryStore408 = BetaErrorResponse +export const BetaArchiveMemoryStore408 = BetaErrorResponse +export type BetaArchiveMemoryStore409 = BetaErrorResponse +export const BetaArchiveMemoryStore409 = BetaErrorResponse +export type BetaArchiveMemoryStore412 = BetaErrorResponse +export const BetaArchiveMemoryStore412 = BetaErrorResponse +export type BetaArchiveMemoryStore413 = BetaErrorResponse +export const BetaArchiveMemoryStore413 = BetaErrorResponse +export type BetaArchiveMemoryStore429 = BetaErrorResponse +export const BetaArchiveMemoryStore429 = BetaErrorResponse +export type BetaArchiveMemoryStore431 = BetaErrorResponse +export const BetaArchiveMemoryStore431 = BetaErrorResponse +export type BetaArchiveMemoryStore499 = BetaErrorResponse +export const BetaArchiveMemoryStore499 = BetaErrorResponse +export type BetaArchiveMemoryStore500 = BetaErrorResponse +export const BetaArchiveMemoryStore500 = BetaErrorResponse +export type BetaArchiveMemoryStore501 = BetaErrorResponse +export const BetaArchiveMemoryStore501 = BetaErrorResponse +export type BetaArchiveMemoryStore503 = BetaErrorResponse +export const BetaArchiveMemoryStore503 = BetaErrorResponse +export type BetaArchiveMemoryStore504 = BetaErrorResponse +export const BetaArchiveMemoryStore504 = BetaErrorResponse +export type BetaListUserProfilesParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "order"?: BetaUserProfileListOrder +} +export const BetaListUserProfilesParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "order": Schema.optionalKey(BetaUserProfileListOrder) +}) +export type BetaListUserProfiles200 = BetaListUserProfilesResponse +export const BetaListUserProfiles200 = BetaListUserProfilesResponse +export type BetaListUserProfiles400 = BetaErrorResponse +export const BetaListUserProfiles400 = BetaErrorResponse +export type BetaListUserProfiles401 = BetaErrorResponse +export const BetaListUserProfiles401 = BetaErrorResponse +export type BetaListUserProfiles403 = BetaErrorResponse +export const BetaListUserProfiles403 = BetaErrorResponse +export type BetaListUserProfiles404 = BetaErrorResponse +export const BetaListUserProfiles404 = BetaErrorResponse +export type BetaListUserProfiles408 = BetaErrorResponse +export const BetaListUserProfiles408 = BetaErrorResponse +export type BetaListUserProfiles409 = BetaErrorResponse +export const BetaListUserProfiles409 = BetaErrorResponse +export type BetaListUserProfiles412 = BetaErrorResponse +export const BetaListUserProfiles412 = BetaErrorResponse +export type BetaListUserProfiles413 = BetaErrorResponse +export const BetaListUserProfiles413 = BetaErrorResponse +export type BetaListUserProfiles429 = BetaErrorResponse +export const BetaListUserProfiles429 = BetaErrorResponse +export type BetaListUserProfiles431 = BetaErrorResponse +export const BetaListUserProfiles431 = BetaErrorResponse +export type BetaListUserProfiles499 = BetaErrorResponse +export const BetaListUserProfiles499 = BetaErrorResponse +export type BetaListUserProfiles500 = BetaErrorResponse +export const BetaListUserProfiles500 = BetaErrorResponse +export type BetaListUserProfiles501 = BetaErrorResponse +export const BetaListUserProfiles501 = BetaErrorResponse +export type BetaListUserProfiles503 = BetaErrorResponse +export const BetaListUserProfiles503 = BetaErrorResponse +export type BetaListUserProfiles504 = BetaErrorResponse +export const BetaListUserProfiles504 = BetaErrorResponse +export type BetaCreateUserProfileParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCreateUserProfileParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateUserProfileRequestJson = BetaCreateUserProfileRequest +export const BetaCreateUserProfileRequestJson = BetaCreateUserProfileRequest +export type BetaCreateUserProfile200 = BetaUserProfile +export const BetaCreateUserProfile200 = BetaUserProfile +export type BetaCreateUserProfile400 = BetaErrorResponse +export const BetaCreateUserProfile400 = BetaErrorResponse +export type BetaCreateUserProfile401 = BetaErrorResponse +export const BetaCreateUserProfile401 = BetaErrorResponse +export type BetaCreateUserProfile403 = BetaErrorResponse +export const BetaCreateUserProfile403 = BetaErrorResponse +export type BetaCreateUserProfile404 = BetaErrorResponse +export const BetaCreateUserProfile404 = BetaErrorResponse +export type BetaCreateUserProfile408 = BetaErrorResponse +export const BetaCreateUserProfile408 = BetaErrorResponse +export type BetaCreateUserProfile409 = BetaErrorResponse +export const BetaCreateUserProfile409 = BetaErrorResponse +export type BetaCreateUserProfile412 = BetaErrorResponse +export const BetaCreateUserProfile412 = BetaErrorResponse +export type BetaCreateUserProfile413 = BetaErrorResponse +export const BetaCreateUserProfile413 = BetaErrorResponse +export type BetaCreateUserProfile429 = BetaErrorResponse +export const BetaCreateUserProfile429 = BetaErrorResponse +export type BetaCreateUserProfile431 = BetaErrorResponse +export const BetaCreateUserProfile431 = BetaErrorResponse +export type BetaCreateUserProfile499 = BetaErrorResponse +export const BetaCreateUserProfile499 = BetaErrorResponse +export type BetaCreateUserProfile500 = BetaErrorResponse +export const BetaCreateUserProfile500 = BetaErrorResponse +export type BetaCreateUserProfile501 = BetaErrorResponse +export const BetaCreateUserProfile501 = BetaErrorResponse +export type BetaCreateUserProfile503 = BetaErrorResponse +export const BetaCreateUserProfile503 = BetaErrorResponse +export type BetaCreateUserProfile504 = BetaErrorResponse +export const BetaCreateUserProfile504 = BetaErrorResponse +export type BetaGetUserProfileParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetUserProfileParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetUserProfile200 = BetaUserProfile +export const BetaGetUserProfile200 = BetaUserProfile +export type BetaGetUserProfile400 = BetaErrorResponse +export const BetaGetUserProfile400 = BetaErrorResponse +export type BetaGetUserProfile401 = BetaErrorResponse +export const BetaGetUserProfile401 = BetaErrorResponse +export type BetaGetUserProfile403 = BetaErrorResponse +export const BetaGetUserProfile403 = BetaErrorResponse +export type BetaGetUserProfile404 = BetaErrorResponse +export const BetaGetUserProfile404 = BetaErrorResponse +export type BetaGetUserProfile408 = BetaErrorResponse +export const BetaGetUserProfile408 = BetaErrorResponse +export type BetaGetUserProfile409 = BetaErrorResponse +export const BetaGetUserProfile409 = BetaErrorResponse +export type BetaGetUserProfile412 = BetaErrorResponse +export const BetaGetUserProfile412 = BetaErrorResponse +export type BetaGetUserProfile413 = BetaErrorResponse +export const BetaGetUserProfile413 = BetaErrorResponse +export type BetaGetUserProfile429 = BetaErrorResponse +export const BetaGetUserProfile429 = BetaErrorResponse +export type BetaGetUserProfile431 = BetaErrorResponse +export const BetaGetUserProfile431 = BetaErrorResponse +export type BetaGetUserProfile499 = BetaErrorResponse +export const BetaGetUserProfile499 = BetaErrorResponse +export type BetaGetUserProfile500 = BetaErrorResponse +export const BetaGetUserProfile500 = BetaErrorResponse +export type BetaGetUserProfile501 = BetaErrorResponse +export const BetaGetUserProfile501 = BetaErrorResponse +export type BetaGetUserProfile503 = BetaErrorResponse +export const BetaGetUserProfile503 = BetaErrorResponse +export type BetaGetUserProfile504 = BetaErrorResponse +export const BetaGetUserProfile504 = BetaErrorResponse +export type BetaUpdateUserProfileParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaUpdateUserProfileParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaUpdateUserProfileRequestJson = BetaUpdateUserProfileRequestBody +export const BetaUpdateUserProfileRequestJson = BetaUpdateUserProfileRequestBody +export type BetaUpdateUserProfile200 = BetaUserProfile +export const BetaUpdateUserProfile200 = BetaUserProfile +export type BetaUpdateUserProfile400 = BetaErrorResponse +export const BetaUpdateUserProfile400 = BetaErrorResponse +export type BetaUpdateUserProfile401 = BetaErrorResponse +export const BetaUpdateUserProfile401 = BetaErrorResponse +export type BetaUpdateUserProfile403 = BetaErrorResponse +export const BetaUpdateUserProfile403 = BetaErrorResponse +export type BetaUpdateUserProfile404 = BetaErrorResponse +export const BetaUpdateUserProfile404 = BetaErrorResponse +export type BetaUpdateUserProfile408 = BetaErrorResponse +export const BetaUpdateUserProfile408 = BetaErrorResponse +export type BetaUpdateUserProfile409 = BetaErrorResponse +export const BetaUpdateUserProfile409 = BetaErrorResponse +export type BetaUpdateUserProfile412 = BetaErrorResponse +export const BetaUpdateUserProfile412 = BetaErrorResponse +export type BetaUpdateUserProfile413 = BetaErrorResponse +export const BetaUpdateUserProfile413 = BetaErrorResponse +export type BetaUpdateUserProfile429 = BetaErrorResponse +export const BetaUpdateUserProfile429 = BetaErrorResponse +export type BetaUpdateUserProfile431 = BetaErrorResponse +export const BetaUpdateUserProfile431 = BetaErrorResponse +export type BetaUpdateUserProfile499 = BetaErrorResponse +export const BetaUpdateUserProfile499 = BetaErrorResponse +export type BetaUpdateUserProfile500 = BetaErrorResponse +export const BetaUpdateUserProfile500 = BetaErrorResponse +export type BetaUpdateUserProfile501 = BetaErrorResponse +export const BetaUpdateUserProfile501 = BetaErrorResponse +export type BetaUpdateUserProfile503 = BetaErrorResponse +export const BetaUpdateUserProfile503 = BetaErrorResponse +export type BetaUpdateUserProfile504 = BetaErrorResponse +export const BetaUpdateUserProfile504 = BetaErrorResponse +export type BetaCreateEnrollmentUrlParams = { + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaCreateEnrollmentUrlParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateEnrollmentUrl200 = BetaEnrollmentUrl +export const BetaCreateEnrollmentUrl200 = BetaEnrollmentUrl +export type BetaCreateEnrollmentUrl400 = BetaErrorResponse +export const BetaCreateEnrollmentUrl400 = BetaErrorResponse +export type BetaCreateEnrollmentUrl401 = BetaErrorResponse +export const BetaCreateEnrollmentUrl401 = BetaErrorResponse +export type BetaCreateEnrollmentUrl403 = BetaErrorResponse +export const BetaCreateEnrollmentUrl403 = BetaErrorResponse +export type BetaCreateEnrollmentUrl404 = BetaErrorResponse +export const BetaCreateEnrollmentUrl404 = BetaErrorResponse +export type BetaCreateEnrollmentUrl408 = BetaErrorResponse +export const BetaCreateEnrollmentUrl408 = BetaErrorResponse +export type BetaCreateEnrollmentUrl409 = BetaErrorResponse +export const BetaCreateEnrollmentUrl409 = BetaErrorResponse +export type BetaCreateEnrollmentUrl412 = BetaErrorResponse +export const BetaCreateEnrollmentUrl412 = BetaErrorResponse +export type BetaCreateEnrollmentUrl413 = BetaErrorResponse +export const BetaCreateEnrollmentUrl413 = BetaErrorResponse +export type BetaCreateEnrollmentUrl429 = BetaErrorResponse +export const BetaCreateEnrollmentUrl429 = BetaErrorResponse +export type BetaCreateEnrollmentUrl431 = BetaErrorResponse +export const BetaCreateEnrollmentUrl431 = BetaErrorResponse +export type BetaCreateEnrollmentUrl499 = BetaErrorResponse +export const BetaCreateEnrollmentUrl499 = BetaErrorResponse +export type BetaCreateEnrollmentUrl500 = BetaErrorResponse +export const BetaCreateEnrollmentUrl500 = BetaErrorResponse +export type BetaCreateEnrollmentUrl501 = BetaErrorResponse +export const BetaCreateEnrollmentUrl501 = BetaErrorResponse +export type BetaCreateEnrollmentUrl503 = BetaErrorResponse +export const BetaCreateEnrollmentUrl503 = BetaErrorResponse +export type BetaCreateEnrollmentUrl504 = BetaErrorResponse +export const BetaCreateEnrollmentUrl504 = BetaErrorResponse +export type BetaListTunnelsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "include_archived"?: boolean +} +export const BetaListTunnelsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "include_archived": Schema.optionalKey(Schema.Boolean) +}) +export type BetaListTunnels200 = BetaListTunnelsResponse +export const BetaListTunnels200 = BetaListTunnelsResponse +export type BetaListTunnels400 = BetaErrorResponse +export const BetaListTunnels400 = BetaErrorResponse +export type BetaListTunnels401 = BetaErrorResponse +export const BetaListTunnels401 = BetaErrorResponse +export type BetaListTunnels403 = BetaErrorResponse +export const BetaListTunnels403 = BetaErrorResponse +export type BetaListTunnels404 = BetaErrorResponse +export const BetaListTunnels404 = BetaErrorResponse +export type BetaListTunnels408 = BetaErrorResponse +export const BetaListTunnels408 = BetaErrorResponse +export type BetaListTunnels409 = BetaErrorResponse +export const BetaListTunnels409 = BetaErrorResponse +export type BetaListTunnels412 = BetaErrorResponse +export const BetaListTunnels412 = BetaErrorResponse +export type BetaListTunnels413 = BetaErrorResponse +export const BetaListTunnels413 = BetaErrorResponse +export type BetaListTunnels429 = BetaErrorResponse +export const BetaListTunnels429 = BetaErrorResponse +export type BetaListTunnels431 = BetaErrorResponse +export const BetaListTunnels431 = BetaErrorResponse +export type BetaListTunnels499 = BetaErrorResponse +export const BetaListTunnels499 = BetaErrorResponse +export type BetaListTunnels500 = BetaErrorResponse +export const BetaListTunnels500 = BetaErrorResponse +export type BetaListTunnels501 = BetaErrorResponse +export const BetaListTunnels501 = BetaErrorResponse +export type BetaListTunnels503 = BetaErrorResponse +export const BetaListTunnels503 = BetaErrorResponse +export type BetaListTunnels504 = BetaErrorResponse +export const BetaListTunnels504 = BetaErrorResponse +export type BetaCreateTunnelParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCreateTunnelParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateTunnelRequestJson = BetaCreateTunnelRequest +export const BetaCreateTunnelRequestJson = BetaCreateTunnelRequest +export type BetaCreateTunnel200 = BetaTunnel +export const BetaCreateTunnel200 = BetaTunnel +export type BetaCreateTunnel400 = BetaErrorResponse +export const BetaCreateTunnel400 = BetaErrorResponse +export type BetaCreateTunnel401 = BetaErrorResponse +export const BetaCreateTunnel401 = BetaErrorResponse +export type BetaCreateTunnel403 = BetaErrorResponse +export const BetaCreateTunnel403 = BetaErrorResponse +export type BetaCreateTunnel404 = BetaErrorResponse +export const BetaCreateTunnel404 = BetaErrorResponse +export type BetaCreateTunnel408 = BetaErrorResponse +export const BetaCreateTunnel408 = BetaErrorResponse +export type BetaCreateTunnel409 = BetaErrorResponse +export const BetaCreateTunnel409 = BetaErrorResponse +export type BetaCreateTunnel412 = BetaErrorResponse +export const BetaCreateTunnel412 = BetaErrorResponse +export type BetaCreateTunnel413 = BetaErrorResponse +export const BetaCreateTunnel413 = BetaErrorResponse +export type BetaCreateTunnel429 = BetaErrorResponse +export const BetaCreateTunnel429 = BetaErrorResponse +export type BetaCreateTunnel431 = BetaErrorResponse +export const BetaCreateTunnel431 = BetaErrorResponse +export type BetaCreateTunnel499 = BetaErrorResponse +export const BetaCreateTunnel499 = BetaErrorResponse +export type BetaCreateTunnel500 = BetaErrorResponse +export const BetaCreateTunnel500 = BetaErrorResponse +export type BetaCreateTunnel501 = BetaErrorResponse +export const BetaCreateTunnel501 = BetaErrorResponse +export type BetaCreateTunnel503 = BetaErrorResponse +export const BetaCreateTunnel503 = BetaErrorResponse +export type BetaCreateTunnel504 = BetaErrorResponse +export const BetaCreateTunnel504 = BetaErrorResponse +export type BetaGetTunnelParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetTunnelParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetTunnel200 = BetaTunnel +export const BetaGetTunnel200 = BetaTunnel +export type BetaGetTunnel400 = BetaErrorResponse +export const BetaGetTunnel400 = BetaErrorResponse +export type BetaGetTunnel401 = BetaErrorResponse +export const BetaGetTunnel401 = BetaErrorResponse +export type BetaGetTunnel403 = BetaErrorResponse +export const BetaGetTunnel403 = BetaErrorResponse +export type BetaGetTunnel404 = BetaErrorResponse +export const BetaGetTunnel404 = BetaErrorResponse +export type BetaGetTunnel408 = BetaErrorResponse +export const BetaGetTunnel408 = BetaErrorResponse +export type BetaGetTunnel409 = BetaErrorResponse +export const BetaGetTunnel409 = BetaErrorResponse +export type BetaGetTunnel412 = BetaErrorResponse +export const BetaGetTunnel412 = BetaErrorResponse +export type BetaGetTunnel413 = BetaErrorResponse +export const BetaGetTunnel413 = BetaErrorResponse +export type BetaGetTunnel429 = BetaErrorResponse +export const BetaGetTunnel429 = BetaErrorResponse +export type BetaGetTunnel431 = BetaErrorResponse +export const BetaGetTunnel431 = BetaErrorResponse +export type BetaGetTunnel499 = BetaErrorResponse +export const BetaGetTunnel499 = BetaErrorResponse +export type BetaGetTunnel500 = BetaErrorResponse +export const BetaGetTunnel500 = BetaErrorResponse +export type BetaGetTunnel501 = BetaErrorResponse +export const BetaGetTunnel501 = BetaErrorResponse +export type BetaGetTunnel503 = BetaErrorResponse +export const BetaGetTunnel503 = BetaErrorResponse +export type BetaGetTunnel504 = BetaErrorResponse +export const BetaGetTunnel504 = BetaErrorResponse +export type BetaArchiveTunnelParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaArchiveTunnelParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveTunnel200 = BetaTunnel +export const BetaArchiveTunnel200 = BetaTunnel +export type BetaArchiveTunnel400 = BetaErrorResponse +export const BetaArchiveTunnel400 = BetaErrorResponse +export type BetaArchiveTunnel401 = BetaErrorResponse +export const BetaArchiveTunnel401 = BetaErrorResponse +export type BetaArchiveTunnel403 = BetaErrorResponse +export const BetaArchiveTunnel403 = BetaErrorResponse +export type BetaArchiveTunnel404 = BetaErrorResponse +export const BetaArchiveTunnel404 = BetaErrorResponse +export type BetaArchiveTunnel408 = BetaErrorResponse +export const BetaArchiveTunnel408 = BetaErrorResponse +export type BetaArchiveTunnel409 = BetaErrorResponse +export const BetaArchiveTunnel409 = BetaErrorResponse +export type BetaArchiveTunnel412 = BetaErrorResponse +export const BetaArchiveTunnel412 = BetaErrorResponse +export type BetaArchiveTunnel413 = BetaErrorResponse +export const BetaArchiveTunnel413 = BetaErrorResponse +export type BetaArchiveTunnel429 = BetaErrorResponse +export const BetaArchiveTunnel429 = BetaErrorResponse +export type BetaArchiveTunnel431 = BetaErrorResponse +export const BetaArchiveTunnel431 = BetaErrorResponse +export type BetaArchiveTunnel499 = BetaErrorResponse +export const BetaArchiveTunnel499 = BetaErrorResponse +export type BetaArchiveTunnel500 = BetaErrorResponse +export const BetaArchiveTunnel500 = BetaErrorResponse +export type BetaArchiveTunnel501 = BetaErrorResponse +export const BetaArchiveTunnel501 = BetaErrorResponse +export type BetaArchiveTunnel503 = BetaErrorResponse +export const BetaArchiveTunnel503 = BetaErrorResponse +export type BetaArchiveTunnel504 = BetaErrorResponse +export const BetaArchiveTunnel504 = BetaErrorResponse +export type BetaRevealTunnelTokenParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaRevealTunnelTokenParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaRevealTunnelToken200 = BetaTunnelToken +export const BetaRevealTunnelToken200 = BetaTunnelToken +export type BetaRevealTunnelToken400 = BetaErrorResponse +export const BetaRevealTunnelToken400 = BetaErrorResponse +export type BetaRevealTunnelToken401 = BetaErrorResponse +export const BetaRevealTunnelToken401 = BetaErrorResponse +export type BetaRevealTunnelToken403 = BetaErrorResponse +export const BetaRevealTunnelToken403 = BetaErrorResponse +export type BetaRevealTunnelToken404 = BetaErrorResponse +export const BetaRevealTunnelToken404 = BetaErrorResponse +export type BetaRevealTunnelToken408 = BetaErrorResponse +export const BetaRevealTunnelToken408 = BetaErrorResponse +export type BetaRevealTunnelToken409 = BetaErrorResponse +export const BetaRevealTunnelToken409 = BetaErrorResponse +export type BetaRevealTunnelToken412 = BetaErrorResponse +export const BetaRevealTunnelToken412 = BetaErrorResponse +export type BetaRevealTunnelToken413 = BetaErrorResponse +export const BetaRevealTunnelToken413 = BetaErrorResponse +export type BetaRevealTunnelToken429 = BetaErrorResponse +export const BetaRevealTunnelToken429 = BetaErrorResponse +export type BetaRevealTunnelToken431 = BetaErrorResponse +export const BetaRevealTunnelToken431 = BetaErrorResponse +export type BetaRevealTunnelToken499 = BetaErrorResponse +export const BetaRevealTunnelToken499 = BetaErrorResponse +export type BetaRevealTunnelToken500 = BetaErrorResponse +export const BetaRevealTunnelToken500 = BetaErrorResponse +export type BetaRevealTunnelToken501 = BetaErrorResponse +export const BetaRevealTunnelToken501 = BetaErrorResponse +export type BetaRevealTunnelToken503 = BetaErrorResponse +export const BetaRevealTunnelToken503 = BetaErrorResponse +export type BetaRevealTunnelToken504 = BetaErrorResponse +export const BetaRevealTunnelToken504 = BetaErrorResponse +export type BetaRotateTunnelTokenParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaRotateTunnelTokenParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaRotateTunnelTokenRequestJson = BetaRotateTunnelTokenRequestBody +export const BetaRotateTunnelTokenRequestJson = BetaRotateTunnelTokenRequestBody +export type BetaRotateTunnelToken200 = BetaTunnelToken +export const BetaRotateTunnelToken200 = BetaTunnelToken +export type BetaRotateTunnelToken400 = BetaErrorResponse +export const BetaRotateTunnelToken400 = BetaErrorResponse +export type BetaRotateTunnelToken401 = BetaErrorResponse +export const BetaRotateTunnelToken401 = BetaErrorResponse +export type BetaRotateTunnelToken403 = BetaErrorResponse +export const BetaRotateTunnelToken403 = BetaErrorResponse +export type BetaRotateTunnelToken404 = BetaErrorResponse +export const BetaRotateTunnelToken404 = BetaErrorResponse +export type BetaRotateTunnelToken408 = BetaErrorResponse +export const BetaRotateTunnelToken408 = BetaErrorResponse +export type BetaRotateTunnelToken409 = BetaErrorResponse +export const BetaRotateTunnelToken409 = BetaErrorResponse +export type BetaRotateTunnelToken412 = BetaErrorResponse +export const BetaRotateTunnelToken412 = BetaErrorResponse +export type BetaRotateTunnelToken413 = BetaErrorResponse +export const BetaRotateTunnelToken413 = BetaErrorResponse +export type BetaRotateTunnelToken429 = BetaErrorResponse +export const BetaRotateTunnelToken429 = BetaErrorResponse +export type BetaRotateTunnelToken431 = BetaErrorResponse +export const BetaRotateTunnelToken431 = BetaErrorResponse +export type BetaRotateTunnelToken499 = BetaErrorResponse +export const BetaRotateTunnelToken499 = BetaErrorResponse +export type BetaRotateTunnelToken500 = BetaErrorResponse +export const BetaRotateTunnelToken500 = BetaErrorResponse +export type BetaRotateTunnelToken501 = BetaErrorResponse +export const BetaRotateTunnelToken501 = BetaErrorResponse +export type BetaRotateTunnelToken503 = BetaErrorResponse +export const BetaRotateTunnelToken503 = BetaErrorResponse +export type BetaRotateTunnelToken504 = BetaErrorResponse +export const BetaRotateTunnelToken504 = BetaErrorResponse +export type BetaListTunnelCertificatesParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "include_archived"?: boolean +} +export const BetaListTunnelCertificatesParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "include_archived": Schema.optionalKey(Schema.Boolean) +}) +export type BetaListTunnelCertificates200 = BetaListTunnelCertificatesResponse +export const BetaListTunnelCertificates200 = BetaListTunnelCertificatesResponse +export type BetaListTunnelCertificates400 = BetaErrorResponse +export const BetaListTunnelCertificates400 = BetaErrorResponse +export type BetaListTunnelCertificates401 = BetaErrorResponse +export const BetaListTunnelCertificates401 = BetaErrorResponse +export type BetaListTunnelCertificates403 = BetaErrorResponse +export const BetaListTunnelCertificates403 = BetaErrorResponse +export type BetaListTunnelCertificates404 = BetaErrorResponse +export const BetaListTunnelCertificates404 = BetaErrorResponse +export type BetaListTunnelCertificates408 = BetaErrorResponse +export const BetaListTunnelCertificates408 = BetaErrorResponse +export type BetaListTunnelCertificates409 = BetaErrorResponse +export const BetaListTunnelCertificates409 = BetaErrorResponse +export type BetaListTunnelCertificates412 = BetaErrorResponse +export const BetaListTunnelCertificates412 = BetaErrorResponse +export type BetaListTunnelCertificates413 = BetaErrorResponse +export const BetaListTunnelCertificates413 = BetaErrorResponse +export type BetaListTunnelCertificates429 = BetaErrorResponse +export const BetaListTunnelCertificates429 = BetaErrorResponse +export type BetaListTunnelCertificates431 = BetaErrorResponse +export const BetaListTunnelCertificates431 = BetaErrorResponse +export type BetaListTunnelCertificates499 = BetaErrorResponse +export const BetaListTunnelCertificates499 = BetaErrorResponse +export type BetaListTunnelCertificates500 = BetaErrorResponse +export const BetaListTunnelCertificates500 = BetaErrorResponse +export type BetaListTunnelCertificates501 = BetaErrorResponse +export const BetaListTunnelCertificates501 = BetaErrorResponse +export type BetaListTunnelCertificates503 = BetaErrorResponse +export const BetaListTunnelCertificates503 = BetaErrorResponse +export type BetaListTunnelCertificates504 = BetaErrorResponse +export const BetaListTunnelCertificates504 = BetaErrorResponse +export type BetaCreateTunnelCertificateParams = { + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaCreateTunnelCertificateParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateTunnelCertificateRequestJson = BetaCreateTunnelCertificateRequestBody +export const BetaCreateTunnelCertificateRequestJson = BetaCreateTunnelCertificateRequestBody +export type BetaCreateTunnelCertificate200 = BetaTunnelCertificate +export const BetaCreateTunnelCertificate200 = BetaTunnelCertificate +export type BetaCreateTunnelCertificate400 = BetaErrorResponse +export const BetaCreateTunnelCertificate400 = BetaErrorResponse +export type BetaCreateTunnelCertificate401 = BetaErrorResponse +export const BetaCreateTunnelCertificate401 = BetaErrorResponse +export type BetaCreateTunnelCertificate403 = BetaErrorResponse +export const BetaCreateTunnelCertificate403 = BetaErrorResponse +export type BetaCreateTunnelCertificate404 = BetaErrorResponse +export const BetaCreateTunnelCertificate404 = BetaErrorResponse +export type BetaCreateTunnelCertificate408 = BetaErrorResponse +export const BetaCreateTunnelCertificate408 = BetaErrorResponse +export type BetaCreateTunnelCertificate409 = BetaErrorResponse +export const BetaCreateTunnelCertificate409 = BetaErrorResponse +export type BetaCreateTunnelCertificate412 = BetaErrorResponse +export const BetaCreateTunnelCertificate412 = BetaErrorResponse +export type BetaCreateTunnelCertificate413 = BetaErrorResponse +export const BetaCreateTunnelCertificate413 = BetaErrorResponse +export type BetaCreateTunnelCertificate429 = BetaErrorResponse +export const BetaCreateTunnelCertificate429 = BetaErrorResponse +export type BetaCreateTunnelCertificate431 = BetaErrorResponse +export const BetaCreateTunnelCertificate431 = BetaErrorResponse +export type BetaCreateTunnelCertificate499 = BetaErrorResponse +export const BetaCreateTunnelCertificate499 = BetaErrorResponse +export type BetaCreateTunnelCertificate500 = BetaErrorResponse +export const BetaCreateTunnelCertificate500 = BetaErrorResponse +export type BetaCreateTunnelCertificate501 = BetaErrorResponse +export const BetaCreateTunnelCertificate501 = BetaErrorResponse +export type BetaCreateTunnelCertificate503 = BetaErrorResponse +export const BetaCreateTunnelCertificate503 = BetaErrorResponse +export type BetaCreateTunnelCertificate504 = BetaErrorResponse +export const BetaCreateTunnelCertificate504 = BetaErrorResponse +export type BetaGetTunnelCertificateParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetTunnelCertificateParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetTunnelCertificate200 = BetaTunnelCertificate +export const BetaGetTunnelCertificate200 = BetaTunnelCertificate +export type BetaGetTunnelCertificate400 = BetaErrorResponse +export const BetaGetTunnelCertificate400 = BetaErrorResponse +export type BetaGetTunnelCertificate401 = BetaErrorResponse +export const BetaGetTunnelCertificate401 = BetaErrorResponse +export type BetaGetTunnelCertificate403 = BetaErrorResponse +export const BetaGetTunnelCertificate403 = BetaErrorResponse +export type BetaGetTunnelCertificate404 = BetaErrorResponse +export const BetaGetTunnelCertificate404 = BetaErrorResponse +export type BetaGetTunnelCertificate408 = BetaErrorResponse +export const BetaGetTunnelCertificate408 = BetaErrorResponse +export type BetaGetTunnelCertificate409 = BetaErrorResponse +export const BetaGetTunnelCertificate409 = BetaErrorResponse +export type BetaGetTunnelCertificate412 = BetaErrorResponse +export const BetaGetTunnelCertificate412 = BetaErrorResponse +export type BetaGetTunnelCertificate413 = BetaErrorResponse +export const BetaGetTunnelCertificate413 = BetaErrorResponse +export type BetaGetTunnelCertificate429 = BetaErrorResponse +export const BetaGetTunnelCertificate429 = BetaErrorResponse +export type BetaGetTunnelCertificate431 = BetaErrorResponse +export const BetaGetTunnelCertificate431 = BetaErrorResponse +export type BetaGetTunnelCertificate499 = BetaErrorResponse +export const BetaGetTunnelCertificate499 = BetaErrorResponse +export type BetaGetTunnelCertificate500 = BetaErrorResponse +export const BetaGetTunnelCertificate500 = BetaErrorResponse +export type BetaGetTunnelCertificate501 = BetaErrorResponse +export const BetaGetTunnelCertificate501 = BetaErrorResponse +export type BetaGetTunnelCertificate503 = BetaErrorResponse +export const BetaGetTunnelCertificate503 = BetaErrorResponse +export type BetaGetTunnelCertificate504 = BetaErrorResponse +export const BetaGetTunnelCertificate504 = BetaErrorResponse +export type BetaArchiveTunnelCertificateParams = { + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaArchiveTunnelCertificateParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveTunnelCertificate200 = BetaTunnelCertificate +export const BetaArchiveTunnelCertificate200 = BetaTunnelCertificate +export type BetaArchiveTunnelCertificate400 = BetaErrorResponse +export const BetaArchiveTunnelCertificate400 = BetaErrorResponse +export type BetaArchiveTunnelCertificate401 = BetaErrorResponse +export const BetaArchiveTunnelCertificate401 = BetaErrorResponse +export type BetaArchiveTunnelCertificate403 = BetaErrorResponse +export const BetaArchiveTunnelCertificate403 = BetaErrorResponse +export type BetaArchiveTunnelCertificate404 = BetaErrorResponse +export const BetaArchiveTunnelCertificate404 = BetaErrorResponse +export type BetaArchiveTunnelCertificate408 = BetaErrorResponse +export const BetaArchiveTunnelCertificate408 = BetaErrorResponse +export type BetaArchiveTunnelCertificate409 = BetaErrorResponse +export const BetaArchiveTunnelCertificate409 = BetaErrorResponse +export type BetaArchiveTunnelCertificate412 = BetaErrorResponse +export const BetaArchiveTunnelCertificate412 = BetaErrorResponse +export type BetaArchiveTunnelCertificate413 = BetaErrorResponse +export const BetaArchiveTunnelCertificate413 = BetaErrorResponse +export type BetaArchiveTunnelCertificate429 = BetaErrorResponse +export const BetaArchiveTunnelCertificate429 = BetaErrorResponse +export type BetaArchiveTunnelCertificate431 = BetaErrorResponse +export const BetaArchiveTunnelCertificate431 = BetaErrorResponse +export type BetaArchiveTunnelCertificate499 = BetaErrorResponse +export const BetaArchiveTunnelCertificate499 = BetaErrorResponse +export type BetaArchiveTunnelCertificate500 = BetaErrorResponse +export const BetaArchiveTunnelCertificate500 = BetaErrorResponse +export type BetaArchiveTunnelCertificate501 = BetaErrorResponse +export const BetaArchiveTunnelCertificate501 = BetaErrorResponse +export type BetaArchiveTunnelCertificate503 = BetaErrorResponse +export const BetaArchiveTunnelCertificate503 = BetaErrorResponse +export type BetaArchiveTunnelCertificate504 = BetaErrorResponse +export const BetaArchiveTunnelCertificate504 = BetaErrorResponse +export type BetaListDreamsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "include_archived"?: boolean + readonly "statuses[]"?: ReadonlyArray + readonly "created_at[gt]"?: BetaTimestamp + readonly "created_at[lt]"?: BetaTimestamp +} +export const BetaListDreamsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "include_archived": Schema.optionalKey(Schema.Boolean), + "statuses[]": Schema.optionalKey(Schema.Array(BetaDreamStatus)), + "created_at[gt]": Schema.optionalKey(BetaTimestamp), + "created_at[lt]": Schema.optionalKey(BetaTimestamp) +}) +export type BetaListDreams200 = BetaListDreamsResponse +export const BetaListDreams200 = BetaListDreamsResponse +export type BetaListDreams400 = BetaErrorResponse +export const BetaListDreams400 = BetaErrorResponse +export type BetaListDreams401 = BetaErrorResponse +export const BetaListDreams401 = BetaErrorResponse +export type BetaListDreams403 = BetaErrorResponse +export const BetaListDreams403 = BetaErrorResponse +export type BetaListDreams404 = BetaErrorResponse +export const BetaListDreams404 = BetaErrorResponse +export type BetaListDreams408 = BetaErrorResponse +export const BetaListDreams408 = BetaErrorResponse +export type BetaListDreams409 = BetaErrorResponse +export const BetaListDreams409 = BetaErrorResponse +export type BetaListDreams412 = BetaErrorResponse +export const BetaListDreams412 = BetaErrorResponse +export type BetaListDreams413 = BetaErrorResponse +export const BetaListDreams413 = BetaErrorResponse +export type BetaListDreams429 = BetaErrorResponse +export const BetaListDreams429 = BetaErrorResponse +export type BetaListDreams431 = BetaErrorResponse +export const BetaListDreams431 = BetaErrorResponse +export type BetaListDreams499 = BetaErrorResponse +export const BetaListDreams499 = BetaErrorResponse +export type BetaListDreams500 = BetaErrorResponse +export const BetaListDreams500 = BetaErrorResponse +export type BetaListDreams501 = BetaErrorResponse +export const BetaListDreams501 = BetaErrorResponse +export type BetaListDreams503 = BetaErrorResponse +export const BetaListDreams503 = BetaErrorResponse +export type BetaListDreams504 = BetaErrorResponse +export const BetaListDreams504 = BetaErrorResponse +export type BetaCreateDreamParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCreateDreamParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateDreamRequestJson = BetaCreateDreamRequest +export const BetaCreateDreamRequestJson = BetaCreateDreamRequest +export type BetaCreateDream200 = BetaDream +export const BetaCreateDream200 = BetaDream +export type BetaCreateDream400 = BetaErrorResponse +export const BetaCreateDream400 = BetaErrorResponse +export type BetaCreateDream401 = BetaErrorResponse +export const BetaCreateDream401 = BetaErrorResponse +export type BetaCreateDream403 = BetaErrorResponse +export const BetaCreateDream403 = BetaErrorResponse +export type BetaCreateDream404 = BetaErrorResponse +export const BetaCreateDream404 = BetaErrorResponse +export type BetaCreateDream408 = BetaErrorResponse +export const BetaCreateDream408 = BetaErrorResponse +export type BetaCreateDream409 = BetaErrorResponse +export const BetaCreateDream409 = BetaErrorResponse +export type BetaCreateDream412 = BetaErrorResponse +export const BetaCreateDream412 = BetaErrorResponse +export type BetaCreateDream413 = BetaErrorResponse +export const BetaCreateDream413 = BetaErrorResponse +export type BetaCreateDream429 = BetaErrorResponse +export const BetaCreateDream429 = BetaErrorResponse +export type BetaCreateDream431 = BetaErrorResponse +export const BetaCreateDream431 = BetaErrorResponse +export type BetaCreateDream499 = BetaErrorResponse +export const BetaCreateDream499 = BetaErrorResponse +export type BetaCreateDream500 = BetaErrorResponse +export const BetaCreateDream500 = BetaErrorResponse +export type BetaCreateDream501 = BetaErrorResponse +export const BetaCreateDream501 = BetaErrorResponse +export type BetaCreateDream503 = BetaErrorResponse +export const BetaCreateDream503 = BetaErrorResponse +export type BetaCreateDream504 = BetaErrorResponse +export const BetaCreateDream504 = BetaErrorResponse +export type BetaGetDreamParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetDreamParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetDream200 = BetaDream +export const BetaGetDream200 = BetaDream +export type BetaGetDream400 = BetaErrorResponse +export const BetaGetDream400 = BetaErrorResponse +export type BetaGetDream401 = BetaErrorResponse +export const BetaGetDream401 = BetaErrorResponse +export type BetaGetDream403 = BetaErrorResponse +export const BetaGetDream403 = BetaErrorResponse +export type BetaGetDream404 = BetaErrorResponse +export const BetaGetDream404 = BetaErrorResponse +export type BetaGetDream408 = BetaErrorResponse +export const BetaGetDream408 = BetaErrorResponse +export type BetaGetDream409 = BetaErrorResponse +export const BetaGetDream409 = BetaErrorResponse +export type BetaGetDream412 = BetaErrorResponse +export const BetaGetDream412 = BetaErrorResponse +export type BetaGetDream413 = BetaErrorResponse +export const BetaGetDream413 = BetaErrorResponse +export type BetaGetDream429 = BetaErrorResponse +export const BetaGetDream429 = BetaErrorResponse +export type BetaGetDream431 = BetaErrorResponse +export const BetaGetDream431 = BetaErrorResponse +export type BetaGetDream499 = BetaErrorResponse +export const BetaGetDream499 = BetaErrorResponse +export type BetaGetDream500 = BetaErrorResponse +export const BetaGetDream500 = BetaErrorResponse +export type BetaGetDream501 = BetaErrorResponse +export const BetaGetDream501 = BetaErrorResponse +export type BetaGetDream503 = BetaErrorResponse +export const BetaGetDream503 = BetaErrorResponse +export type BetaGetDream504 = BetaErrorResponse +export const BetaGetDream504 = BetaErrorResponse +export type BetaCancelDreamParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCancelDreamParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCancelDream200 = BetaDream +export const BetaCancelDream200 = BetaDream +export type BetaCancelDream400 = BetaErrorResponse +export const BetaCancelDream400 = BetaErrorResponse +export type BetaCancelDream401 = BetaErrorResponse +export const BetaCancelDream401 = BetaErrorResponse +export type BetaCancelDream403 = BetaErrorResponse +export const BetaCancelDream403 = BetaErrorResponse +export type BetaCancelDream404 = BetaErrorResponse +export const BetaCancelDream404 = BetaErrorResponse +export type BetaCancelDream408 = BetaErrorResponse +export const BetaCancelDream408 = BetaErrorResponse +export type BetaCancelDream409 = BetaErrorResponse +export const BetaCancelDream409 = BetaErrorResponse +export type BetaCancelDream412 = BetaErrorResponse +export const BetaCancelDream412 = BetaErrorResponse +export type BetaCancelDream413 = BetaErrorResponse +export const BetaCancelDream413 = BetaErrorResponse +export type BetaCancelDream429 = BetaErrorResponse +export const BetaCancelDream429 = BetaErrorResponse +export type BetaCancelDream431 = BetaErrorResponse +export const BetaCancelDream431 = BetaErrorResponse +export type BetaCancelDream499 = BetaErrorResponse +export const BetaCancelDream499 = BetaErrorResponse +export type BetaCancelDream500 = BetaErrorResponse +export const BetaCancelDream500 = BetaErrorResponse +export type BetaCancelDream501 = BetaErrorResponse +export const BetaCancelDream501 = BetaErrorResponse +export type BetaCancelDream503 = BetaErrorResponse +export const BetaCancelDream503 = BetaErrorResponse +export type BetaCancelDream504 = BetaErrorResponse +export const BetaCancelDream504 = BetaErrorResponse +export type BetaArchiveDreamParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaArchiveDreamParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveDream200 = BetaDream +export const BetaArchiveDream200 = BetaDream +export type BetaArchiveDream400 = BetaErrorResponse +export const BetaArchiveDream400 = BetaErrorResponse +export type BetaArchiveDream401 = BetaErrorResponse +export const BetaArchiveDream401 = BetaErrorResponse +export type BetaArchiveDream403 = BetaErrorResponse +export const BetaArchiveDream403 = BetaErrorResponse +export type BetaArchiveDream404 = BetaErrorResponse +export const BetaArchiveDream404 = BetaErrorResponse +export type BetaArchiveDream408 = BetaErrorResponse +export const BetaArchiveDream408 = BetaErrorResponse +export type BetaArchiveDream409 = BetaErrorResponse +export const BetaArchiveDream409 = BetaErrorResponse +export type BetaArchiveDream412 = BetaErrorResponse +export const BetaArchiveDream412 = BetaErrorResponse +export type BetaArchiveDream413 = BetaErrorResponse +export const BetaArchiveDream413 = BetaErrorResponse +export type BetaArchiveDream429 = BetaErrorResponse +export const BetaArchiveDream429 = BetaErrorResponse +export type BetaArchiveDream431 = BetaErrorResponse +export const BetaArchiveDream431 = BetaErrorResponse +export type BetaArchiveDream499 = BetaErrorResponse +export const BetaArchiveDream499 = BetaErrorResponse +export type BetaArchiveDream500 = BetaErrorResponse +export const BetaArchiveDream500 = BetaErrorResponse +export type BetaArchiveDream501 = BetaErrorResponse +export const BetaArchiveDream501 = BetaErrorResponse +export type BetaArchiveDream503 = BetaErrorResponse +export const BetaArchiveDream503 = BetaErrorResponse +export type BetaArchiveDream504 = BetaErrorResponse +export const BetaArchiveDream504 = BetaErrorResponse +export type BetaListSessionsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "include_archived"?: boolean + readonly "created_at[gte]"?: BetaTimestamp + readonly "created_at[gt]"?: BetaTimestamp + readonly "created_at[lte]"?: BetaTimestamp + readonly "created_at[lt]"?: BetaTimestamp + readonly "agent_id"?: string + readonly "agent_version"?: number + readonly "order"?: BetaManagedAgentsListOrder + readonly "memory_store_id"?: string + readonly "deployment_id"?: string + readonly "statuses[]"?: ReadonlyArray +} +export const BetaListSessionsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "include_archived": Schema.optionalKey(Schema.Boolean), + "created_at[gte]": Schema.optionalKey(BetaTimestamp), + "created_at[gt]": Schema.optionalKey(BetaTimestamp), + "created_at[lte]": Schema.optionalKey(BetaTimestamp), + "created_at[lt]": Schema.optionalKey(BetaTimestamp), + "agent_id": Schema.optionalKey(Schema.String), + "agent_version": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "order": Schema.optionalKey(BetaManagedAgentsListOrder), + "memory_store_id": Schema.optionalKey(Schema.String), + "deployment_id": Schema.optionalKey(Schema.String), + "statuses[]": Schema.optionalKey(Schema.Array(BetaManagedAgentsSessionStatus)) +}) +export type BetaListSessions200 = BetaManagedAgentsListSessions +export const BetaListSessions200 = BetaManagedAgentsListSessions +export type BetaListSessions400 = BetaErrorResponse +export const BetaListSessions400 = BetaErrorResponse +export type BetaListSessions401 = BetaErrorResponse +export const BetaListSessions401 = BetaErrorResponse +export type BetaListSessions403 = BetaErrorResponse +export const BetaListSessions403 = BetaErrorResponse +export type BetaListSessions404 = BetaErrorResponse +export const BetaListSessions404 = BetaErrorResponse +export type BetaListSessions408 = BetaErrorResponse +export const BetaListSessions408 = BetaErrorResponse +export type BetaListSessions409 = BetaErrorResponse +export const BetaListSessions409 = BetaErrorResponse +export type BetaListSessions412 = BetaErrorResponse +export const BetaListSessions412 = BetaErrorResponse +export type BetaListSessions413 = BetaErrorResponse +export const BetaListSessions413 = BetaErrorResponse +export type BetaListSessions429 = BetaErrorResponse +export const BetaListSessions429 = BetaErrorResponse +export type BetaListSessions431 = BetaErrorResponse +export const BetaListSessions431 = BetaErrorResponse +export type BetaListSessions499 = BetaErrorResponse +export const BetaListSessions499 = BetaErrorResponse +export type BetaListSessions500 = BetaErrorResponse +export const BetaListSessions500 = BetaErrorResponse +export type BetaListSessions501 = BetaErrorResponse +export const BetaListSessions501 = BetaErrorResponse +export type BetaListSessions503 = BetaErrorResponse +export const BetaListSessions503 = BetaErrorResponse +export type BetaListSessions504 = BetaErrorResponse +export const BetaListSessions504 = BetaErrorResponse +export type BetaCreateSessionParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCreateSessionParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateSessionRequestJson = BetaManagedAgentsCreateSessionParams +export const BetaCreateSessionRequestJson = BetaManagedAgentsCreateSessionParams +export type BetaCreateSession200 = BetaManagedAgentsSession +export const BetaCreateSession200 = BetaManagedAgentsSession +export type BetaCreateSession400 = BetaErrorResponse +export const BetaCreateSession400 = BetaErrorResponse +export type BetaCreateSession401 = BetaErrorResponse +export const BetaCreateSession401 = BetaErrorResponse +export type BetaCreateSession403 = BetaErrorResponse +export const BetaCreateSession403 = BetaErrorResponse +export type BetaCreateSession404 = BetaErrorResponse +export const BetaCreateSession404 = BetaErrorResponse +export type BetaCreateSession408 = BetaErrorResponse +export const BetaCreateSession408 = BetaErrorResponse +export type BetaCreateSession409 = BetaErrorResponse +export const BetaCreateSession409 = BetaErrorResponse +export type BetaCreateSession412 = BetaErrorResponse +export const BetaCreateSession412 = BetaErrorResponse +export type BetaCreateSession413 = BetaErrorResponse +export const BetaCreateSession413 = BetaErrorResponse +export type BetaCreateSession429 = BetaErrorResponse +export const BetaCreateSession429 = BetaErrorResponse +export type BetaCreateSession431 = BetaErrorResponse +export const BetaCreateSession431 = BetaErrorResponse +export type BetaCreateSession499 = BetaErrorResponse +export const BetaCreateSession499 = BetaErrorResponse +export type BetaCreateSession500 = BetaErrorResponse +export const BetaCreateSession500 = BetaErrorResponse +export type BetaCreateSession501 = BetaErrorResponse +export const BetaCreateSession501 = BetaErrorResponse +export type BetaCreateSession503 = BetaErrorResponse +export const BetaCreateSession503 = BetaErrorResponse +export type BetaCreateSession504 = BetaErrorResponse +export const BetaCreateSession504 = BetaErrorResponse +export type BetaGetSessionParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetSessionParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetSession200 = BetaManagedAgentsSession +export const BetaGetSession200 = BetaManagedAgentsSession +export type BetaGetSession400 = BetaErrorResponse +export const BetaGetSession400 = BetaErrorResponse +export type BetaGetSession401 = BetaErrorResponse +export const BetaGetSession401 = BetaErrorResponse +export type BetaGetSession403 = BetaErrorResponse +export const BetaGetSession403 = BetaErrorResponse +export type BetaGetSession404 = BetaErrorResponse +export const BetaGetSession404 = BetaErrorResponse +export type BetaGetSession408 = BetaErrorResponse +export const BetaGetSession408 = BetaErrorResponse +export type BetaGetSession409 = BetaErrorResponse +export const BetaGetSession409 = BetaErrorResponse +export type BetaGetSession412 = BetaErrorResponse +export const BetaGetSession412 = BetaErrorResponse +export type BetaGetSession413 = BetaErrorResponse +export const BetaGetSession413 = BetaErrorResponse +export type BetaGetSession429 = BetaErrorResponse +export const BetaGetSession429 = BetaErrorResponse +export type BetaGetSession431 = BetaErrorResponse +export const BetaGetSession431 = BetaErrorResponse +export type BetaGetSession499 = BetaErrorResponse +export const BetaGetSession499 = BetaErrorResponse +export type BetaGetSession500 = BetaErrorResponse +export const BetaGetSession500 = BetaErrorResponse +export type BetaGetSession501 = BetaErrorResponse +export const BetaGetSession501 = BetaErrorResponse +export type BetaGetSession503 = BetaErrorResponse +export const BetaGetSession503 = BetaErrorResponse +export type BetaGetSession504 = BetaErrorResponse +export const BetaGetSession504 = BetaErrorResponse +export type BetaUpdateSessionParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaUpdateSessionParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaUpdateSessionRequestJson = BetaManagedAgentsUpdateSessionParams +export const BetaUpdateSessionRequestJson = BetaManagedAgentsUpdateSessionParams +export type BetaUpdateSession200 = BetaManagedAgentsSession +export const BetaUpdateSession200 = BetaManagedAgentsSession +export type BetaUpdateSession400 = BetaErrorResponse +export const BetaUpdateSession400 = BetaErrorResponse +export type BetaUpdateSession401 = BetaErrorResponse +export const BetaUpdateSession401 = BetaErrorResponse +export type BetaUpdateSession403 = BetaErrorResponse +export const BetaUpdateSession403 = BetaErrorResponse +export type BetaUpdateSession404 = BetaErrorResponse +export const BetaUpdateSession404 = BetaErrorResponse +export type BetaUpdateSession408 = BetaErrorResponse +export const BetaUpdateSession408 = BetaErrorResponse +export type BetaUpdateSession409 = BetaErrorResponse +export const BetaUpdateSession409 = BetaErrorResponse +export type BetaUpdateSession412 = BetaErrorResponse +export const BetaUpdateSession412 = BetaErrorResponse +export type BetaUpdateSession413 = BetaErrorResponse +export const BetaUpdateSession413 = BetaErrorResponse +export type BetaUpdateSession429 = BetaErrorResponse +export const BetaUpdateSession429 = BetaErrorResponse +export type BetaUpdateSession431 = BetaErrorResponse +export const BetaUpdateSession431 = BetaErrorResponse +export type BetaUpdateSession499 = BetaErrorResponse +export const BetaUpdateSession499 = BetaErrorResponse +export type BetaUpdateSession500 = BetaErrorResponse +export const BetaUpdateSession500 = BetaErrorResponse +export type BetaUpdateSession501 = BetaErrorResponse +export const BetaUpdateSession501 = BetaErrorResponse +export type BetaUpdateSession503 = BetaErrorResponse +export const BetaUpdateSession503 = BetaErrorResponse +export type BetaUpdateSession504 = BetaErrorResponse +export const BetaUpdateSession504 = BetaErrorResponse +export type BetaDeleteSessionParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaDeleteSessionParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaDeleteSession200 = BetaManagedAgentsDeletedSession +export const BetaDeleteSession200 = BetaManagedAgentsDeletedSession +export type BetaDeleteSession400 = BetaErrorResponse +export const BetaDeleteSession400 = BetaErrorResponse +export type BetaDeleteSession401 = BetaErrorResponse +export const BetaDeleteSession401 = BetaErrorResponse +export type BetaDeleteSession403 = BetaErrorResponse +export const BetaDeleteSession403 = BetaErrorResponse +export type BetaDeleteSession404 = BetaErrorResponse +export const BetaDeleteSession404 = BetaErrorResponse +export type BetaDeleteSession408 = BetaErrorResponse +export const BetaDeleteSession408 = BetaErrorResponse +export type BetaDeleteSession409 = BetaErrorResponse +export const BetaDeleteSession409 = BetaErrorResponse +export type BetaDeleteSession412 = BetaErrorResponse +export const BetaDeleteSession412 = BetaErrorResponse +export type BetaDeleteSession413 = BetaErrorResponse +export const BetaDeleteSession413 = BetaErrorResponse +export type BetaDeleteSession429 = BetaErrorResponse +export const BetaDeleteSession429 = BetaErrorResponse +export type BetaDeleteSession431 = BetaErrorResponse +export const BetaDeleteSession431 = BetaErrorResponse +export type BetaDeleteSession499 = BetaErrorResponse +export const BetaDeleteSession499 = BetaErrorResponse +export type BetaDeleteSession500 = BetaErrorResponse +export const BetaDeleteSession500 = BetaErrorResponse +export type BetaDeleteSession501 = BetaErrorResponse +export const BetaDeleteSession501 = BetaErrorResponse +export type BetaDeleteSession503 = BetaErrorResponse +export const BetaDeleteSession503 = BetaErrorResponse +export type BetaDeleteSession504 = BetaErrorResponse +export const BetaDeleteSession504 = BetaErrorResponse +export type BetaListEventsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "order"?: BetaManagedAgentsListOrder + readonly "types[]"?: ReadonlyArray + readonly "created_at[gte]"?: BetaTimestamp + readonly "created_at[gt]"?: BetaTimestamp + readonly "created_at[lte]"?: BetaTimestamp + readonly "created_at[lt]"?: BetaTimestamp +} +export const BetaListEventsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "order": Schema.optionalKey(BetaManagedAgentsListOrder), + "types[]": Schema.optionalKey(Schema.Array(Schema.String)), + "created_at[gte]": Schema.optionalKey(BetaTimestamp), + "created_at[gt]": Schema.optionalKey(BetaTimestamp), + "created_at[lte]": Schema.optionalKey(BetaTimestamp), + "created_at[lt]": Schema.optionalKey(BetaTimestamp) +}) +export type BetaListEvents200 = BetaManagedAgentsListSessionEvents +export const BetaListEvents200 = BetaManagedAgentsListSessionEvents +export type BetaListEvents400 = BetaErrorResponse +export const BetaListEvents400 = BetaErrorResponse +export type BetaListEvents401 = BetaErrorResponse +export const BetaListEvents401 = BetaErrorResponse +export type BetaListEvents403 = BetaErrorResponse +export const BetaListEvents403 = BetaErrorResponse +export type BetaListEvents404 = BetaErrorResponse +export const BetaListEvents404 = BetaErrorResponse +export type BetaListEvents408 = BetaErrorResponse +export const BetaListEvents408 = BetaErrorResponse +export type BetaListEvents409 = BetaErrorResponse +export const BetaListEvents409 = BetaErrorResponse +export type BetaListEvents412 = BetaErrorResponse +export const BetaListEvents412 = BetaErrorResponse +export type BetaListEvents413 = BetaErrorResponse +export const BetaListEvents413 = BetaErrorResponse +export type BetaListEvents429 = BetaErrorResponse +export const BetaListEvents429 = BetaErrorResponse +export type BetaListEvents431 = BetaErrorResponse +export const BetaListEvents431 = BetaErrorResponse +export type BetaListEvents499 = BetaErrorResponse +export const BetaListEvents499 = BetaErrorResponse +export type BetaListEvents500 = BetaErrorResponse +export const BetaListEvents500 = BetaErrorResponse +export type BetaListEvents501 = BetaErrorResponse +export const BetaListEvents501 = BetaErrorResponse +export type BetaListEvents503 = BetaErrorResponse +export const BetaListEvents503 = BetaErrorResponse +export type BetaListEvents504 = BetaErrorResponse +export const BetaListEvents504 = BetaErrorResponse +export type BetaSendEventsParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaSendEventsParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaSendEventsRequestJson = BetaManagedAgentsSendSessionEventsParams +export const BetaSendEventsRequestJson = BetaManagedAgentsSendSessionEventsParams +export type BetaSendEvents200 = BetaManagedAgentsSendSessionEvents +export const BetaSendEvents200 = BetaManagedAgentsSendSessionEvents +export type BetaSendEvents400 = BetaErrorResponse +export const BetaSendEvents400 = BetaErrorResponse +export type BetaSendEvents401 = BetaErrorResponse +export const BetaSendEvents401 = BetaErrorResponse +export type BetaSendEvents403 = BetaErrorResponse +export const BetaSendEvents403 = BetaErrorResponse +export type BetaSendEvents404 = BetaErrorResponse +export const BetaSendEvents404 = BetaErrorResponse +export type BetaSendEvents408 = BetaErrorResponse +export const BetaSendEvents408 = BetaErrorResponse +export type BetaSendEvents409 = BetaErrorResponse +export const BetaSendEvents409 = BetaErrorResponse +export type BetaSendEvents412 = BetaErrorResponse +export const BetaSendEvents412 = BetaErrorResponse +export type BetaSendEvents413 = BetaErrorResponse +export const BetaSendEvents413 = BetaErrorResponse +export type BetaSendEvents429 = BetaErrorResponse +export const BetaSendEvents429 = BetaErrorResponse +export type BetaSendEvents431 = BetaErrorResponse +export const BetaSendEvents431 = BetaErrorResponse +export type BetaSendEvents499 = BetaErrorResponse +export const BetaSendEvents499 = BetaErrorResponse +export type BetaSendEvents500 = BetaErrorResponse +export const BetaSendEvents500 = BetaErrorResponse +export type BetaSendEvents501 = BetaErrorResponse +export const BetaSendEvents501 = BetaErrorResponse +export type BetaSendEvents503 = BetaErrorResponse +export const BetaSendEvents503 = BetaErrorResponse +export type BetaSendEvents504 = BetaErrorResponse +export const BetaSendEvents504 = BetaErrorResponse +export type BetaStreamSessionEventsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "event_deltas[]"?: ReadonlyArray +} +export const BetaStreamSessionEventsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "event_deltas[]": Schema.optionalKey(Schema.Array(BetaManagedAgentsEventDeltaType)) +}) +export type BetaStreamSessionEvents200 = BetaManagedAgentsStreamSessionEvents +export const BetaStreamSessionEvents200 = BetaManagedAgentsStreamSessionEvents +export type BetaStreamSessionEvents400 = BetaErrorResponse +export const BetaStreamSessionEvents400 = BetaErrorResponse +export type BetaStreamSessionEvents401 = BetaErrorResponse +export const BetaStreamSessionEvents401 = BetaErrorResponse +export type BetaStreamSessionEvents403 = BetaErrorResponse +export const BetaStreamSessionEvents403 = BetaErrorResponse +export type BetaStreamSessionEvents404 = BetaErrorResponse +export const BetaStreamSessionEvents404 = BetaErrorResponse +export type BetaStreamSessionEvents408 = BetaErrorResponse +export const BetaStreamSessionEvents408 = BetaErrorResponse +export type BetaStreamSessionEvents409 = BetaErrorResponse +export const BetaStreamSessionEvents409 = BetaErrorResponse +export type BetaStreamSessionEvents412 = BetaErrorResponse +export const BetaStreamSessionEvents412 = BetaErrorResponse +export type BetaStreamSessionEvents413 = BetaErrorResponse +export const BetaStreamSessionEvents413 = BetaErrorResponse +export type BetaStreamSessionEvents429 = BetaErrorResponse +export const BetaStreamSessionEvents429 = BetaErrorResponse +export type BetaStreamSessionEvents431 = BetaErrorResponse +export const BetaStreamSessionEvents431 = BetaErrorResponse +export type BetaStreamSessionEvents499 = BetaErrorResponse +export const BetaStreamSessionEvents499 = BetaErrorResponse +export type BetaStreamSessionEvents500 = BetaErrorResponse +export const BetaStreamSessionEvents500 = BetaErrorResponse +export type BetaStreamSessionEvents501 = BetaErrorResponse +export const BetaStreamSessionEvents501 = BetaErrorResponse +export type BetaStreamSessionEvents503 = BetaErrorResponse +export const BetaStreamSessionEvents503 = BetaErrorResponse +export type BetaStreamSessionEvents504 = BetaErrorResponse +export const BetaStreamSessionEvents504 = BetaErrorResponse +export type BetaArchiveSessionParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaArchiveSessionParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveSession200 = BetaManagedAgentsSession +export const BetaArchiveSession200 = BetaManagedAgentsSession +export type BetaArchiveSession400 = BetaErrorResponse +export const BetaArchiveSession400 = BetaErrorResponse +export type BetaArchiveSession401 = BetaErrorResponse +export const BetaArchiveSession401 = BetaErrorResponse +export type BetaArchiveSession403 = BetaErrorResponse +export const BetaArchiveSession403 = BetaErrorResponse +export type BetaArchiveSession404 = BetaErrorResponse +export const BetaArchiveSession404 = BetaErrorResponse +export type BetaArchiveSession408 = BetaErrorResponse +export const BetaArchiveSession408 = BetaErrorResponse +export type BetaArchiveSession409 = BetaErrorResponse +export const BetaArchiveSession409 = BetaErrorResponse +export type BetaArchiveSession412 = BetaErrorResponse +export const BetaArchiveSession412 = BetaErrorResponse +export type BetaArchiveSession413 = BetaErrorResponse +export const BetaArchiveSession413 = BetaErrorResponse +export type BetaArchiveSession429 = BetaErrorResponse +export const BetaArchiveSession429 = BetaErrorResponse +export type BetaArchiveSession431 = BetaErrorResponse +export const BetaArchiveSession431 = BetaErrorResponse +export type BetaArchiveSession499 = BetaErrorResponse +export const BetaArchiveSession499 = BetaErrorResponse +export type BetaArchiveSession500 = BetaErrorResponse +export const BetaArchiveSession500 = BetaErrorResponse +export type BetaArchiveSession501 = BetaErrorResponse +export const BetaArchiveSession501 = BetaErrorResponse +export type BetaArchiveSession503 = BetaErrorResponse +export const BetaArchiveSession503 = BetaErrorResponse +export type BetaArchiveSession504 = BetaErrorResponse +export const BetaArchiveSession504 = BetaErrorResponse +export type BetaListSessionThreadsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string +} +export const BetaListSessionThreadsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String) +}) +export type BetaListSessionThreads200 = BetaManagedAgentsListSessionThreads +export const BetaListSessionThreads200 = BetaManagedAgentsListSessionThreads +export type BetaListSessionThreads400 = BetaErrorResponse +export const BetaListSessionThreads400 = BetaErrorResponse +export type BetaListSessionThreads401 = BetaErrorResponse +export const BetaListSessionThreads401 = BetaErrorResponse +export type BetaListSessionThreads403 = BetaErrorResponse +export const BetaListSessionThreads403 = BetaErrorResponse +export type BetaListSessionThreads404 = BetaErrorResponse +export const BetaListSessionThreads404 = BetaErrorResponse +export type BetaListSessionThreads408 = BetaErrorResponse +export const BetaListSessionThreads408 = BetaErrorResponse +export type BetaListSessionThreads409 = BetaErrorResponse +export const BetaListSessionThreads409 = BetaErrorResponse +export type BetaListSessionThreads412 = BetaErrorResponse +export const BetaListSessionThreads412 = BetaErrorResponse +export type BetaListSessionThreads413 = BetaErrorResponse +export const BetaListSessionThreads413 = BetaErrorResponse +export type BetaListSessionThreads429 = BetaErrorResponse +export const BetaListSessionThreads429 = BetaErrorResponse +export type BetaListSessionThreads431 = BetaErrorResponse +export const BetaListSessionThreads431 = BetaErrorResponse +export type BetaListSessionThreads499 = BetaErrorResponse +export const BetaListSessionThreads499 = BetaErrorResponse +export type BetaListSessionThreads500 = BetaErrorResponse +export const BetaListSessionThreads500 = BetaErrorResponse +export type BetaListSessionThreads501 = BetaErrorResponse +export const BetaListSessionThreads501 = BetaErrorResponse +export type BetaListSessionThreads503 = BetaErrorResponse +export const BetaListSessionThreads503 = BetaErrorResponse +export type BetaListSessionThreads504 = BetaErrorResponse +export const BetaListSessionThreads504 = BetaErrorResponse +export type BetaGetSessionThreadParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetSessionThreadParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetSessionThread200 = BetaManagedAgentsSessionThread +export const BetaGetSessionThread200 = BetaManagedAgentsSessionThread +export type BetaGetSessionThread400 = BetaErrorResponse +export const BetaGetSessionThread400 = BetaErrorResponse +export type BetaGetSessionThread401 = BetaErrorResponse +export const BetaGetSessionThread401 = BetaErrorResponse +export type BetaGetSessionThread403 = BetaErrorResponse +export const BetaGetSessionThread403 = BetaErrorResponse +export type BetaGetSessionThread404 = BetaErrorResponse +export const BetaGetSessionThread404 = BetaErrorResponse +export type BetaGetSessionThread408 = BetaErrorResponse +export const BetaGetSessionThread408 = BetaErrorResponse +export type BetaGetSessionThread409 = BetaErrorResponse +export const BetaGetSessionThread409 = BetaErrorResponse +export type BetaGetSessionThread412 = BetaErrorResponse +export const BetaGetSessionThread412 = BetaErrorResponse +export type BetaGetSessionThread413 = BetaErrorResponse +export const BetaGetSessionThread413 = BetaErrorResponse +export type BetaGetSessionThread429 = BetaErrorResponse +export const BetaGetSessionThread429 = BetaErrorResponse +export type BetaGetSessionThread431 = BetaErrorResponse +export const BetaGetSessionThread431 = BetaErrorResponse +export type BetaGetSessionThread499 = BetaErrorResponse +export const BetaGetSessionThread499 = BetaErrorResponse +export type BetaGetSessionThread500 = BetaErrorResponse +export const BetaGetSessionThread500 = BetaErrorResponse +export type BetaGetSessionThread501 = BetaErrorResponse +export const BetaGetSessionThread501 = BetaErrorResponse +export type BetaGetSessionThread503 = BetaErrorResponse +export const BetaGetSessionThread503 = BetaErrorResponse +export type BetaGetSessionThread504 = BetaErrorResponse +export const BetaGetSessionThread504 = BetaErrorResponse +export type BetaListSessionThreadEventsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string +} +export const BetaListSessionThreadEventsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String) +}) +export type BetaListSessionThreadEvents200 = BetaManagedAgentsListSessionThreadEvents +export const BetaListSessionThreadEvents200 = BetaManagedAgentsListSessionThreadEvents +export type BetaListSessionThreadEvents400 = BetaErrorResponse +export const BetaListSessionThreadEvents400 = BetaErrorResponse +export type BetaListSessionThreadEvents401 = BetaErrorResponse +export const BetaListSessionThreadEvents401 = BetaErrorResponse +export type BetaListSessionThreadEvents403 = BetaErrorResponse +export const BetaListSessionThreadEvents403 = BetaErrorResponse +export type BetaListSessionThreadEvents404 = BetaErrorResponse +export const BetaListSessionThreadEvents404 = BetaErrorResponse +export type BetaListSessionThreadEvents408 = BetaErrorResponse +export const BetaListSessionThreadEvents408 = BetaErrorResponse +export type BetaListSessionThreadEvents409 = BetaErrorResponse +export const BetaListSessionThreadEvents409 = BetaErrorResponse +export type BetaListSessionThreadEvents412 = BetaErrorResponse +export const BetaListSessionThreadEvents412 = BetaErrorResponse +export type BetaListSessionThreadEvents413 = BetaErrorResponse +export const BetaListSessionThreadEvents413 = BetaErrorResponse +export type BetaListSessionThreadEvents429 = BetaErrorResponse +export const BetaListSessionThreadEvents429 = BetaErrorResponse +export type BetaListSessionThreadEvents431 = BetaErrorResponse +export const BetaListSessionThreadEvents431 = BetaErrorResponse +export type BetaListSessionThreadEvents499 = BetaErrorResponse +export const BetaListSessionThreadEvents499 = BetaErrorResponse +export type BetaListSessionThreadEvents500 = BetaErrorResponse +export const BetaListSessionThreadEvents500 = BetaErrorResponse +export type BetaListSessionThreadEvents501 = BetaErrorResponse +export const BetaListSessionThreadEvents501 = BetaErrorResponse +export type BetaListSessionThreadEvents503 = BetaErrorResponse +export const BetaListSessionThreadEvents503 = BetaErrorResponse +export type BetaListSessionThreadEvents504 = BetaErrorResponse +export const BetaListSessionThreadEvents504 = BetaErrorResponse +export type BetaStreamSessionThreadEventsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "event_deltas[]"?: ReadonlyArray +} +export const BetaStreamSessionThreadEventsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "event_deltas[]": Schema.optionalKey(Schema.Array(BetaManagedAgentsEventDeltaType)) +}) +export type BetaStreamSessionThreadEvents200 = BetaManagedAgentsStreamSessionThreadEvents +export const BetaStreamSessionThreadEvents200 = BetaManagedAgentsStreamSessionThreadEvents +export type BetaStreamSessionThreadEvents400 = BetaErrorResponse +export const BetaStreamSessionThreadEvents400 = BetaErrorResponse +export type BetaStreamSessionThreadEvents401 = BetaErrorResponse +export const BetaStreamSessionThreadEvents401 = BetaErrorResponse +export type BetaStreamSessionThreadEvents403 = BetaErrorResponse +export const BetaStreamSessionThreadEvents403 = BetaErrorResponse +export type BetaStreamSessionThreadEvents404 = BetaErrorResponse +export const BetaStreamSessionThreadEvents404 = BetaErrorResponse +export type BetaStreamSessionThreadEvents408 = BetaErrorResponse +export const BetaStreamSessionThreadEvents408 = BetaErrorResponse +export type BetaStreamSessionThreadEvents409 = BetaErrorResponse +export const BetaStreamSessionThreadEvents409 = BetaErrorResponse +export type BetaStreamSessionThreadEvents412 = BetaErrorResponse +export const BetaStreamSessionThreadEvents412 = BetaErrorResponse +export type BetaStreamSessionThreadEvents413 = BetaErrorResponse +export const BetaStreamSessionThreadEvents413 = BetaErrorResponse +export type BetaStreamSessionThreadEvents429 = BetaErrorResponse +export const BetaStreamSessionThreadEvents429 = BetaErrorResponse +export type BetaStreamSessionThreadEvents431 = BetaErrorResponse +export const BetaStreamSessionThreadEvents431 = BetaErrorResponse +export type BetaStreamSessionThreadEvents499 = BetaErrorResponse +export const BetaStreamSessionThreadEvents499 = BetaErrorResponse +export type BetaStreamSessionThreadEvents500 = BetaErrorResponse +export const BetaStreamSessionThreadEvents500 = BetaErrorResponse +export type BetaStreamSessionThreadEvents501 = BetaErrorResponse +export const BetaStreamSessionThreadEvents501 = BetaErrorResponse +export type BetaStreamSessionThreadEvents503 = BetaErrorResponse +export const BetaStreamSessionThreadEvents503 = BetaErrorResponse +export type BetaStreamSessionThreadEvents504 = BetaErrorResponse +export const BetaStreamSessionThreadEvents504 = BetaErrorResponse +export type BetaArchiveSessionThreadParams = { + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaArchiveSessionThreadParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveSessionThread200 = BetaManagedAgentsSessionThread +export const BetaArchiveSessionThread200 = BetaManagedAgentsSessionThread +export type BetaArchiveSessionThread400 = BetaErrorResponse +export const BetaArchiveSessionThread400 = BetaErrorResponse +export type BetaArchiveSessionThread401 = BetaErrorResponse +export const BetaArchiveSessionThread401 = BetaErrorResponse +export type BetaArchiveSessionThread403 = BetaErrorResponse +export const BetaArchiveSessionThread403 = BetaErrorResponse +export type BetaArchiveSessionThread404 = BetaErrorResponse +export const BetaArchiveSessionThread404 = BetaErrorResponse +export type BetaArchiveSessionThread408 = BetaErrorResponse +export const BetaArchiveSessionThread408 = BetaErrorResponse +export type BetaArchiveSessionThread409 = BetaErrorResponse +export const BetaArchiveSessionThread409 = BetaErrorResponse +export type BetaArchiveSessionThread412 = BetaErrorResponse +export const BetaArchiveSessionThread412 = BetaErrorResponse +export type BetaArchiveSessionThread413 = BetaErrorResponse +export const BetaArchiveSessionThread413 = BetaErrorResponse +export type BetaArchiveSessionThread429 = BetaErrorResponse +export const BetaArchiveSessionThread429 = BetaErrorResponse +export type BetaArchiveSessionThread431 = BetaErrorResponse +export const BetaArchiveSessionThread431 = BetaErrorResponse +export type BetaArchiveSessionThread499 = BetaErrorResponse +export const BetaArchiveSessionThread499 = BetaErrorResponse +export type BetaArchiveSessionThread500 = BetaErrorResponse +export const BetaArchiveSessionThread500 = BetaErrorResponse +export type BetaArchiveSessionThread501 = BetaErrorResponse +export const BetaArchiveSessionThread501 = BetaErrorResponse +export type BetaArchiveSessionThread503 = BetaErrorResponse +export const BetaArchiveSessionThread503 = BetaErrorResponse +export type BetaArchiveSessionThread504 = BetaErrorResponse +export const BetaArchiveSessionThread504 = BetaErrorResponse +export type BetaListResourcesParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string +} +export const BetaListResourcesParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String) +}) +export type BetaListResources200 = BetaManagedAgentsListSessionResources +export const BetaListResources200 = BetaManagedAgentsListSessionResources +export type BetaListResources400 = BetaErrorResponse +export const BetaListResources400 = BetaErrorResponse +export type BetaListResources401 = BetaErrorResponse +export const BetaListResources401 = BetaErrorResponse +export type BetaListResources403 = BetaErrorResponse +export const BetaListResources403 = BetaErrorResponse +export type BetaListResources404 = BetaErrorResponse +export const BetaListResources404 = BetaErrorResponse +export type BetaListResources408 = BetaErrorResponse +export const BetaListResources408 = BetaErrorResponse +export type BetaListResources409 = BetaErrorResponse +export const BetaListResources409 = BetaErrorResponse +export type BetaListResources412 = BetaErrorResponse +export const BetaListResources412 = BetaErrorResponse +export type BetaListResources413 = BetaErrorResponse +export const BetaListResources413 = BetaErrorResponse +export type BetaListResources429 = BetaErrorResponse +export const BetaListResources429 = BetaErrorResponse +export type BetaListResources431 = BetaErrorResponse +export const BetaListResources431 = BetaErrorResponse +export type BetaListResources499 = BetaErrorResponse +export const BetaListResources499 = BetaErrorResponse +export type BetaListResources500 = BetaErrorResponse +export const BetaListResources500 = BetaErrorResponse +export type BetaListResources501 = BetaErrorResponse +export const BetaListResources501 = BetaErrorResponse +export type BetaListResources503 = BetaErrorResponse +export const BetaListResources503 = BetaErrorResponse +export type BetaListResources504 = BetaErrorResponse +export const BetaListResources504 = BetaErrorResponse +export type BetaAddResourceParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaAddResourceParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaAddResourceRequestJson = BetaManagedAgentsAddSessionResourceParams +export const BetaAddResourceRequestJson = BetaManagedAgentsAddSessionResourceParams +export type BetaAddResource200 = BetaManagedAgentsAddSessionResource +export const BetaAddResource200 = BetaManagedAgentsAddSessionResource +export type BetaAddResource400 = BetaErrorResponse +export const BetaAddResource400 = BetaErrorResponse +export type BetaAddResource401 = BetaErrorResponse +export const BetaAddResource401 = BetaErrorResponse +export type BetaAddResource403 = BetaErrorResponse +export const BetaAddResource403 = BetaErrorResponse +export type BetaAddResource404 = BetaErrorResponse +export const BetaAddResource404 = BetaErrorResponse +export type BetaAddResource408 = BetaErrorResponse +export const BetaAddResource408 = BetaErrorResponse +export type BetaAddResource409 = BetaErrorResponse +export const BetaAddResource409 = BetaErrorResponse +export type BetaAddResource412 = BetaErrorResponse +export const BetaAddResource412 = BetaErrorResponse +export type BetaAddResource413 = BetaErrorResponse +export const BetaAddResource413 = BetaErrorResponse +export type BetaAddResource429 = BetaErrorResponse +export const BetaAddResource429 = BetaErrorResponse +export type BetaAddResource431 = BetaErrorResponse +export const BetaAddResource431 = BetaErrorResponse +export type BetaAddResource499 = BetaErrorResponse +export const BetaAddResource499 = BetaErrorResponse +export type BetaAddResource500 = BetaErrorResponse +export const BetaAddResource500 = BetaErrorResponse +export type BetaAddResource501 = BetaErrorResponse +export const BetaAddResource501 = BetaErrorResponse +export type BetaAddResource503 = BetaErrorResponse +export const BetaAddResource503 = BetaErrorResponse +export type BetaAddResource504 = BetaErrorResponse +export const BetaAddResource504 = BetaErrorResponse +export type BetaGetResourceParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetResourceParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetResource200 = BetaManagedAgentsGetSessionResource +export const BetaGetResource200 = BetaManagedAgentsGetSessionResource +export type BetaGetResource400 = BetaErrorResponse +export const BetaGetResource400 = BetaErrorResponse +export type BetaGetResource401 = BetaErrorResponse +export const BetaGetResource401 = BetaErrorResponse +export type BetaGetResource403 = BetaErrorResponse +export const BetaGetResource403 = BetaErrorResponse +export type BetaGetResource404 = BetaErrorResponse +export const BetaGetResource404 = BetaErrorResponse +export type BetaGetResource408 = BetaErrorResponse +export const BetaGetResource408 = BetaErrorResponse +export type BetaGetResource409 = BetaErrorResponse +export const BetaGetResource409 = BetaErrorResponse +export type BetaGetResource412 = BetaErrorResponse +export const BetaGetResource412 = BetaErrorResponse +export type BetaGetResource413 = BetaErrorResponse +export const BetaGetResource413 = BetaErrorResponse +export type BetaGetResource429 = BetaErrorResponse +export const BetaGetResource429 = BetaErrorResponse +export type BetaGetResource431 = BetaErrorResponse +export const BetaGetResource431 = BetaErrorResponse +export type BetaGetResource499 = BetaErrorResponse +export const BetaGetResource499 = BetaErrorResponse +export type BetaGetResource500 = BetaErrorResponse +export const BetaGetResource500 = BetaErrorResponse +export type BetaGetResource501 = BetaErrorResponse +export const BetaGetResource501 = BetaErrorResponse +export type BetaGetResource503 = BetaErrorResponse +export const BetaGetResource503 = BetaErrorResponse +export type BetaGetResource504 = BetaErrorResponse +export const BetaGetResource504 = BetaErrorResponse +export type BetaUpdateResourceParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaUpdateResourceParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaUpdateResourceRequestJson = BetaManagedAgentsUpdateSessionResourceParams +export const BetaUpdateResourceRequestJson = BetaManagedAgentsUpdateSessionResourceParams +export type BetaUpdateResource200 = BetaManagedAgentsUpdateSessionResource +export const BetaUpdateResource200 = BetaManagedAgentsUpdateSessionResource +export type BetaUpdateResource400 = BetaErrorResponse +export const BetaUpdateResource400 = BetaErrorResponse +export type BetaUpdateResource401 = BetaErrorResponse +export const BetaUpdateResource401 = BetaErrorResponse +export type BetaUpdateResource403 = BetaErrorResponse +export const BetaUpdateResource403 = BetaErrorResponse +export type BetaUpdateResource404 = BetaErrorResponse +export const BetaUpdateResource404 = BetaErrorResponse +export type BetaUpdateResource408 = BetaErrorResponse +export const BetaUpdateResource408 = BetaErrorResponse +export type BetaUpdateResource409 = BetaErrorResponse +export const BetaUpdateResource409 = BetaErrorResponse +export type BetaUpdateResource412 = BetaErrorResponse +export const BetaUpdateResource412 = BetaErrorResponse +export type BetaUpdateResource413 = BetaErrorResponse +export const BetaUpdateResource413 = BetaErrorResponse +export type BetaUpdateResource429 = BetaErrorResponse +export const BetaUpdateResource429 = BetaErrorResponse +export type BetaUpdateResource431 = BetaErrorResponse +export const BetaUpdateResource431 = BetaErrorResponse +export type BetaUpdateResource499 = BetaErrorResponse +export const BetaUpdateResource499 = BetaErrorResponse +export type BetaUpdateResource500 = BetaErrorResponse +export const BetaUpdateResource500 = BetaErrorResponse +export type BetaUpdateResource501 = BetaErrorResponse +export const BetaUpdateResource501 = BetaErrorResponse +export type BetaUpdateResource503 = BetaErrorResponse +export const BetaUpdateResource503 = BetaErrorResponse +export type BetaUpdateResource504 = BetaErrorResponse +export const BetaUpdateResource504 = BetaErrorResponse +export type BetaDeleteResourceParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaDeleteResourceParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaDeleteResource200 = BetaManagedAgentsDeleteSessionResource +export const BetaDeleteResource200 = BetaManagedAgentsDeleteSessionResource +export type BetaDeleteResource400 = BetaErrorResponse +export const BetaDeleteResource400 = BetaErrorResponse +export type BetaDeleteResource401 = BetaErrorResponse +export const BetaDeleteResource401 = BetaErrorResponse +export type BetaDeleteResource403 = BetaErrorResponse +export const BetaDeleteResource403 = BetaErrorResponse +export type BetaDeleteResource404 = BetaErrorResponse +export const BetaDeleteResource404 = BetaErrorResponse +export type BetaDeleteResource408 = BetaErrorResponse +export const BetaDeleteResource408 = BetaErrorResponse +export type BetaDeleteResource409 = BetaErrorResponse +export const BetaDeleteResource409 = BetaErrorResponse +export type BetaDeleteResource412 = BetaErrorResponse +export const BetaDeleteResource412 = BetaErrorResponse +export type BetaDeleteResource413 = BetaErrorResponse +export const BetaDeleteResource413 = BetaErrorResponse +export type BetaDeleteResource429 = BetaErrorResponse +export const BetaDeleteResource429 = BetaErrorResponse +export type BetaDeleteResource431 = BetaErrorResponse +export const BetaDeleteResource431 = BetaErrorResponse +export type BetaDeleteResource499 = BetaErrorResponse +export const BetaDeleteResource499 = BetaErrorResponse +export type BetaDeleteResource500 = BetaErrorResponse +export const BetaDeleteResource500 = BetaErrorResponse +export type BetaDeleteResource501 = BetaErrorResponse +export const BetaDeleteResource501 = BetaErrorResponse +export type BetaDeleteResource503 = BetaErrorResponse +export const BetaDeleteResource503 = BetaErrorResponse +export type BetaDeleteResource504 = BetaErrorResponse +export const BetaDeleteResource504 = BetaErrorResponse +export type BetaListAgentsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "created_at[gte]"?: BetaTimestamp + readonly "created_at[lte]"?: BetaTimestamp + readonly "include_archived"?: boolean +} +export const BetaListAgentsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "created_at[gte]": Schema.optionalKey(BetaTimestamp), + "created_at[lte]": Schema.optionalKey(BetaTimestamp), + "include_archived": Schema.optionalKey(Schema.Boolean) +}) +export type BetaListAgents200 = BetaManagedAgentsListAgents +export const BetaListAgents200 = BetaManagedAgentsListAgents +export type BetaListAgents400 = BetaErrorResponse +export const BetaListAgents400 = BetaErrorResponse +export type BetaListAgents401 = BetaErrorResponse +export const BetaListAgents401 = BetaErrorResponse +export type BetaListAgents403 = BetaErrorResponse +export const BetaListAgents403 = BetaErrorResponse +export type BetaListAgents404 = BetaErrorResponse +export const BetaListAgents404 = BetaErrorResponse +export type BetaListAgents408 = BetaErrorResponse +export const BetaListAgents408 = BetaErrorResponse +export type BetaListAgents409 = BetaErrorResponse +export const BetaListAgents409 = BetaErrorResponse +export type BetaListAgents412 = BetaErrorResponse +export const BetaListAgents412 = BetaErrorResponse +export type BetaListAgents413 = BetaErrorResponse +export const BetaListAgents413 = BetaErrorResponse +export type BetaListAgents429 = BetaErrorResponse +export const BetaListAgents429 = BetaErrorResponse +export type BetaListAgents431 = BetaErrorResponse +export const BetaListAgents431 = BetaErrorResponse +export type BetaListAgents499 = BetaErrorResponse +export const BetaListAgents499 = BetaErrorResponse +export type BetaListAgents500 = BetaErrorResponse +export const BetaListAgents500 = BetaErrorResponse +export type BetaListAgents501 = BetaErrorResponse +export const BetaListAgents501 = BetaErrorResponse +export type BetaListAgents503 = BetaErrorResponse +export const BetaListAgents503 = BetaErrorResponse +export type BetaListAgents504 = BetaErrorResponse +export const BetaListAgents504 = BetaErrorResponse +export type BetaCreateAgentParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCreateAgentParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateAgentRequestJson = BetaManagedAgentsCreateAgentParams +export const BetaCreateAgentRequestJson = BetaManagedAgentsCreateAgentParams +export type BetaCreateAgent200 = BetaManagedAgentsAgent +export const BetaCreateAgent200 = BetaManagedAgentsAgent +export type BetaCreateAgent400 = BetaErrorResponse +export const BetaCreateAgent400 = BetaErrorResponse +export type BetaCreateAgent401 = BetaErrorResponse +export const BetaCreateAgent401 = BetaErrorResponse +export type BetaCreateAgent403 = BetaErrorResponse +export const BetaCreateAgent403 = BetaErrorResponse +export type BetaCreateAgent404 = BetaErrorResponse +export const BetaCreateAgent404 = BetaErrorResponse +export type BetaCreateAgent408 = BetaErrorResponse +export const BetaCreateAgent408 = BetaErrorResponse +export type BetaCreateAgent409 = BetaErrorResponse +export const BetaCreateAgent409 = BetaErrorResponse +export type BetaCreateAgent412 = BetaErrorResponse +export const BetaCreateAgent412 = BetaErrorResponse +export type BetaCreateAgent413 = BetaErrorResponse +export const BetaCreateAgent413 = BetaErrorResponse +export type BetaCreateAgent429 = BetaErrorResponse +export const BetaCreateAgent429 = BetaErrorResponse +export type BetaCreateAgent431 = BetaErrorResponse +export const BetaCreateAgent431 = BetaErrorResponse +export type BetaCreateAgent499 = BetaErrorResponse +export const BetaCreateAgent499 = BetaErrorResponse +export type BetaCreateAgent500 = BetaErrorResponse +export const BetaCreateAgent500 = BetaErrorResponse +export type BetaCreateAgent501 = BetaErrorResponse +export const BetaCreateAgent501 = BetaErrorResponse +export type BetaCreateAgent503 = BetaErrorResponse +export const BetaCreateAgent503 = BetaErrorResponse +export type BetaCreateAgent504 = BetaErrorResponse +export const BetaCreateAgent504 = BetaErrorResponse +export type BetaGetAgentParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "version"?: number +} +export const BetaGetAgentParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "version": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) +}) +export type BetaGetAgent200 = BetaManagedAgentsAgent +export const BetaGetAgent200 = BetaManagedAgentsAgent +export type BetaGetAgent400 = BetaErrorResponse +export const BetaGetAgent400 = BetaErrorResponse +export type BetaGetAgent401 = BetaErrorResponse +export const BetaGetAgent401 = BetaErrorResponse +export type BetaGetAgent403 = BetaErrorResponse +export const BetaGetAgent403 = BetaErrorResponse +export type BetaGetAgent404 = BetaErrorResponse +export const BetaGetAgent404 = BetaErrorResponse +export type BetaGetAgent408 = BetaErrorResponse +export const BetaGetAgent408 = BetaErrorResponse +export type BetaGetAgent409 = BetaErrorResponse +export const BetaGetAgent409 = BetaErrorResponse +export type BetaGetAgent412 = BetaErrorResponse +export const BetaGetAgent412 = BetaErrorResponse +export type BetaGetAgent413 = BetaErrorResponse +export const BetaGetAgent413 = BetaErrorResponse +export type BetaGetAgent429 = BetaErrorResponse +export const BetaGetAgent429 = BetaErrorResponse +export type BetaGetAgent431 = BetaErrorResponse +export const BetaGetAgent431 = BetaErrorResponse +export type BetaGetAgent499 = BetaErrorResponse +export const BetaGetAgent499 = BetaErrorResponse +export type BetaGetAgent500 = BetaErrorResponse +export const BetaGetAgent500 = BetaErrorResponse +export type BetaGetAgent501 = BetaErrorResponse +export const BetaGetAgent501 = BetaErrorResponse +export type BetaGetAgent503 = BetaErrorResponse +export const BetaGetAgent503 = BetaErrorResponse +export type BetaGetAgent504 = BetaErrorResponse +export const BetaGetAgent504 = BetaErrorResponse +export type BetaUpdateAgentParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaUpdateAgentParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaUpdateAgentRequestJson = BetaManagedAgentsUpdateAgentParams +export const BetaUpdateAgentRequestJson = BetaManagedAgentsUpdateAgentParams +export type BetaUpdateAgent200 = BetaManagedAgentsAgent +export const BetaUpdateAgent200 = BetaManagedAgentsAgent +export type BetaUpdateAgent400 = BetaErrorResponse +export const BetaUpdateAgent400 = BetaErrorResponse +export type BetaUpdateAgent401 = BetaErrorResponse +export const BetaUpdateAgent401 = BetaErrorResponse +export type BetaUpdateAgent403 = BetaErrorResponse +export const BetaUpdateAgent403 = BetaErrorResponse +export type BetaUpdateAgent404 = BetaErrorResponse +export const BetaUpdateAgent404 = BetaErrorResponse +export type BetaUpdateAgent408 = BetaErrorResponse +export const BetaUpdateAgent408 = BetaErrorResponse +export type BetaUpdateAgent409 = BetaErrorResponse +export const BetaUpdateAgent409 = BetaErrorResponse +export type BetaUpdateAgent412 = BetaErrorResponse +export const BetaUpdateAgent412 = BetaErrorResponse +export type BetaUpdateAgent413 = BetaErrorResponse +export const BetaUpdateAgent413 = BetaErrorResponse +export type BetaUpdateAgent429 = BetaErrorResponse +export const BetaUpdateAgent429 = BetaErrorResponse +export type BetaUpdateAgent431 = BetaErrorResponse +export const BetaUpdateAgent431 = BetaErrorResponse +export type BetaUpdateAgent499 = BetaErrorResponse +export const BetaUpdateAgent499 = BetaErrorResponse +export type BetaUpdateAgent500 = BetaErrorResponse +export const BetaUpdateAgent500 = BetaErrorResponse +export type BetaUpdateAgent501 = BetaErrorResponse +export const BetaUpdateAgent501 = BetaErrorResponse +export type BetaUpdateAgent503 = BetaErrorResponse +export const BetaUpdateAgent503 = BetaErrorResponse +export type BetaUpdateAgent504 = BetaErrorResponse +export const BetaUpdateAgent504 = BetaErrorResponse +export type BetaArchiveAgentParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaArchiveAgentParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveAgent200 = BetaManagedAgentsAgent +export const BetaArchiveAgent200 = BetaManagedAgentsAgent +export type BetaArchiveAgent400 = BetaErrorResponse +export const BetaArchiveAgent400 = BetaErrorResponse +export type BetaArchiveAgent401 = BetaErrorResponse +export const BetaArchiveAgent401 = BetaErrorResponse +export type BetaArchiveAgent403 = BetaErrorResponse +export const BetaArchiveAgent403 = BetaErrorResponse +export type BetaArchiveAgent404 = BetaErrorResponse +export const BetaArchiveAgent404 = BetaErrorResponse +export type BetaArchiveAgent408 = BetaErrorResponse +export const BetaArchiveAgent408 = BetaErrorResponse +export type BetaArchiveAgent409 = BetaErrorResponse +export const BetaArchiveAgent409 = BetaErrorResponse +export type BetaArchiveAgent412 = BetaErrorResponse +export const BetaArchiveAgent412 = BetaErrorResponse +export type BetaArchiveAgent413 = BetaErrorResponse +export const BetaArchiveAgent413 = BetaErrorResponse +export type BetaArchiveAgent429 = BetaErrorResponse +export const BetaArchiveAgent429 = BetaErrorResponse +export type BetaArchiveAgent431 = BetaErrorResponse +export const BetaArchiveAgent431 = BetaErrorResponse +export type BetaArchiveAgent499 = BetaErrorResponse +export const BetaArchiveAgent499 = BetaErrorResponse +export type BetaArchiveAgent500 = BetaErrorResponse +export const BetaArchiveAgent500 = BetaErrorResponse +export type BetaArchiveAgent501 = BetaErrorResponse +export const BetaArchiveAgent501 = BetaErrorResponse +export type BetaArchiveAgent503 = BetaErrorResponse +export const BetaArchiveAgent503 = BetaErrorResponse +export type BetaArchiveAgent504 = BetaErrorResponse +export const BetaArchiveAgent504 = BetaErrorResponse +export type BetaListAgentVersionsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string +} +export const BetaListAgentVersionsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String) +}) +export type BetaListAgentVersions200 = BetaManagedAgentsListAgentVersions +export const BetaListAgentVersions200 = BetaManagedAgentsListAgentVersions +export type BetaListAgentVersions400 = BetaErrorResponse +export const BetaListAgentVersions400 = BetaErrorResponse +export type BetaListAgentVersions401 = BetaErrorResponse +export const BetaListAgentVersions401 = BetaErrorResponse +export type BetaListAgentVersions403 = BetaErrorResponse +export const BetaListAgentVersions403 = BetaErrorResponse +export type BetaListAgentVersions404 = BetaErrorResponse +export const BetaListAgentVersions404 = BetaErrorResponse +export type BetaListAgentVersions408 = BetaErrorResponse +export const BetaListAgentVersions408 = BetaErrorResponse +export type BetaListAgentVersions409 = BetaErrorResponse +export const BetaListAgentVersions409 = BetaErrorResponse +export type BetaListAgentVersions412 = BetaErrorResponse +export const BetaListAgentVersions412 = BetaErrorResponse +export type BetaListAgentVersions413 = BetaErrorResponse +export const BetaListAgentVersions413 = BetaErrorResponse +export type BetaListAgentVersions429 = BetaErrorResponse +export const BetaListAgentVersions429 = BetaErrorResponse +export type BetaListAgentVersions431 = BetaErrorResponse +export const BetaListAgentVersions431 = BetaErrorResponse +export type BetaListAgentVersions499 = BetaErrorResponse +export const BetaListAgentVersions499 = BetaErrorResponse +export type BetaListAgentVersions500 = BetaErrorResponse +export const BetaListAgentVersions500 = BetaErrorResponse +export type BetaListAgentVersions501 = BetaErrorResponse +export const BetaListAgentVersions501 = BetaErrorResponse +export type BetaListAgentVersions503 = BetaErrorResponse +export const BetaListAgentVersions503 = BetaErrorResponse +export type BetaListAgentVersions504 = BetaErrorResponse +export const BetaListAgentVersions504 = BetaErrorResponse +export type BetaListDeploymentsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "agent_id"?: string + readonly "status"?: BetaManagedAgentsDeploymentStatus + readonly "created_at[gte]"?: BetaTimestamp + readonly "created_at[lte]"?: BetaTimestamp + readonly "include_archived"?: boolean +} +export const BetaListDeploymentsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "agent_id": Schema.optionalKey(Schema.String), + "status": Schema.optionalKey(BetaManagedAgentsDeploymentStatus), + "created_at[gte]": Schema.optionalKey(BetaTimestamp), + "created_at[lte]": Schema.optionalKey(BetaTimestamp), + "include_archived": Schema.optionalKey(Schema.Boolean) +}) +export type BetaListDeployments200 = BetaManagedAgentsListDeploymentsData +export const BetaListDeployments200 = BetaManagedAgentsListDeploymentsData +export type BetaListDeployments400 = BetaErrorResponse +export const BetaListDeployments400 = BetaErrorResponse +export type BetaListDeployments401 = BetaErrorResponse +export const BetaListDeployments401 = BetaErrorResponse +export type BetaListDeployments403 = BetaErrorResponse +export const BetaListDeployments403 = BetaErrorResponse +export type BetaListDeployments404 = BetaErrorResponse +export const BetaListDeployments404 = BetaErrorResponse +export type BetaListDeployments408 = BetaErrorResponse +export const BetaListDeployments408 = BetaErrorResponse +export type BetaListDeployments409 = BetaErrorResponse +export const BetaListDeployments409 = BetaErrorResponse +export type BetaListDeployments412 = BetaErrorResponse +export const BetaListDeployments412 = BetaErrorResponse +export type BetaListDeployments413 = BetaErrorResponse +export const BetaListDeployments413 = BetaErrorResponse +export type BetaListDeployments429 = BetaErrorResponse +export const BetaListDeployments429 = BetaErrorResponse +export type BetaListDeployments431 = BetaErrorResponse +export const BetaListDeployments431 = BetaErrorResponse +export type BetaListDeployments499 = BetaErrorResponse +export const BetaListDeployments499 = BetaErrorResponse +export type BetaListDeployments500 = BetaErrorResponse +export const BetaListDeployments500 = BetaErrorResponse +export type BetaListDeployments501 = BetaErrorResponse +export const BetaListDeployments501 = BetaErrorResponse +export type BetaListDeployments503 = BetaErrorResponse +export const BetaListDeployments503 = BetaErrorResponse +export type BetaListDeployments504 = BetaErrorResponse +export const BetaListDeployments504 = BetaErrorResponse +export type BetaCreateDeploymentParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCreateDeploymentParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateDeploymentRequestJson = BetaManagedAgentsCreateDeploymentParams +export const BetaCreateDeploymentRequestJson = BetaManagedAgentsCreateDeploymentParams +export type BetaCreateDeployment200 = BetaManagedAgentsDeployment +export const BetaCreateDeployment200 = BetaManagedAgentsDeployment +export type BetaCreateDeployment400 = BetaErrorResponse +export const BetaCreateDeployment400 = BetaErrorResponse +export type BetaCreateDeployment401 = BetaErrorResponse +export const BetaCreateDeployment401 = BetaErrorResponse +export type BetaCreateDeployment403 = BetaErrorResponse +export const BetaCreateDeployment403 = BetaErrorResponse +export type BetaCreateDeployment404 = BetaErrorResponse +export const BetaCreateDeployment404 = BetaErrorResponse +export type BetaCreateDeployment408 = BetaErrorResponse +export const BetaCreateDeployment408 = BetaErrorResponse +export type BetaCreateDeployment409 = BetaErrorResponse +export const BetaCreateDeployment409 = BetaErrorResponse +export type BetaCreateDeployment412 = BetaErrorResponse +export const BetaCreateDeployment412 = BetaErrorResponse +export type BetaCreateDeployment413 = BetaErrorResponse +export const BetaCreateDeployment413 = BetaErrorResponse +export type BetaCreateDeployment429 = BetaErrorResponse +export const BetaCreateDeployment429 = BetaErrorResponse +export type BetaCreateDeployment431 = BetaErrorResponse +export const BetaCreateDeployment431 = BetaErrorResponse +export type BetaCreateDeployment499 = BetaErrorResponse +export const BetaCreateDeployment499 = BetaErrorResponse +export type BetaCreateDeployment500 = BetaErrorResponse +export const BetaCreateDeployment500 = BetaErrorResponse +export type BetaCreateDeployment501 = BetaErrorResponse +export const BetaCreateDeployment501 = BetaErrorResponse +export type BetaCreateDeployment503 = BetaErrorResponse +export const BetaCreateDeployment503 = BetaErrorResponse +export type BetaCreateDeployment504 = BetaErrorResponse +export const BetaCreateDeployment504 = BetaErrorResponse +export type BetaGetDeploymentParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetDeploymentParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetDeployment200 = BetaManagedAgentsDeployment +export const BetaGetDeployment200 = BetaManagedAgentsDeployment +export type BetaGetDeployment400 = BetaErrorResponse +export const BetaGetDeployment400 = BetaErrorResponse +export type BetaGetDeployment401 = BetaErrorResponse +export const BetaGetDeployment401 = BetaErrorResponse +export type BetaGetDeployment403 = BetaErrorResponse +export const BetaGetDeployment403 = BetaErrorResponse +export type BetaGetDeployment404 = BetaErrorResponse +export const BetaGetDeployment404 = BetaErrorResponse +export type BetaGetDeployment408 = BetaErrorResponse +export const BetaGetDeployment408 = BetaErrorResponse +export type BetaGetDeployment409 = BetaErrorResponse +export const BetaGetDeployment409 = BetaErrorResponse +export type BetaGetDeployment412 = BetaErrorResponse +export const BetaGetDeployment412 = BetaErrorResponse +export type BetaGetDeployment413 = BetaErrorResponse +export const BetaGetDeployment413 = BetaErrorResponse +export type BetaGetDeployment429 = BetaErrorResponse +export const BetaGetDeployment429 = BetaErrorResponse +export type BetaGetDeployment431 = BetaErrorResponse +export const BetaGetDeployment431 = BetaErrorResponse +export type BetaGetDeployment499 = BetaErrorResponse +export const BetaGetDeployment499 = BetaErrorResponse +export type BetaGetDeployment500 = BetaErrorResponse +export const BetaGetDeployment500 = BetaErrorResponse +export type BetaGetDeployment501 = BetaErrorResponse +export const BetaGetDeployment501 = BetaErrorResponse +export type BetaGetDeployment503 = BetaErrorResponse +export const BetaGetDeployment503 = BetaErrorResponse +export type BetaGetDeployment504 = BetaErrorResponse +export const BetaGetDeployment504 = BetaErrorResponse +export type BetaUpdateDeploymentParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaUpdateDeploymentParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaUpdateDeploymentRequestJson = BetaManagedAgentsUpdateDeploymentParams +export const BetaUpdateDeploymentRequestJson = BetaManagedAgentsUpdateDeploymentParams +export type BetaUpdateDeployment200 = BetaManagedAgentsDeployment +export const BetaUpdateDeployment200 = BetaManagedAgentsDeployment +export type BetaUpdateDeployment400 = BetaErrorResponse +export const BetaUpdateDeployment400 = BetaErrorResponse +export type BetaUpdateDeployment401 = BetaErrorResponse +export const BetaUpdateDeployment401 = BetaErrorResponse +export type BetaUpdateDeployment403 = BetaErrorResponse +export const BetaUpdateDeployment403 = BetaErrorResponse +export type BetaUpdateDeployment404 = BetaErrorResponse +export const BetaUpdateDeployment404 = BetaErrorResponse +export type BetaUpdateDeployment408 = BetaErrorResponse +export const BetaUpdateDeployment408 = BetaErrorResponse +export type BetaUpdateDeployment409 = BetaErrorResponse +export const BetaUpdateDeployment409 = BetaErrorResponse +export type BetaUpdateDeployment412 = BetaErrorResponse +export const BetaUpdateDeployment412 = BetaErrorResponse +export type BetaUpdateDeployment413 = BetaErrorResponse +export const BetaUpdateDeployment413 = BetaErrorResponse +export type BetaUpdateDeployment429 = BetaErrorResponse +export const BetaUpdateDeployment429 = BetaErrorResponse +export type BetaUpdateDeployment431 = BetaErrorResponse +export const BetaUpdateDeployment431 = BetaErrorResponse +export type BetaUpdateDeployment499 = BetaErrorResponse +export const BetaUpdateDeployment499 = BetaErrorResponse +export type BetaUpdateDeployment500 = BetaErrorResponse +export const BetaUpdateDeployment500 = BetaErrorResponse +export type BetaUpdateDeployment501 = BetaErrorResponse +export const BetaUpdateDeployment501 = BetaErrorResponse +export type BetaUpdateDeployment503 = BetaErrorResponse +export const BetaUpdateDeployment503 = BetaErrorResponse +export type BetaUpdateDeployment504 = BetaErrorResponse +export const BetaUpdateDeployment504 = BetaErrorResponse +export type BetaArchiveDeploymentParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaArchiveDeploymentParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveDeployment200 = BetaManagedAgentsDeployment +export const BetaArchiveDeployment200 = BetaManagedAgentsDeployment +export type BetaArchiveDeployment400 = BetaErrorResponse +export const BetaArchiveDeployment400 = BetaErrorResponse +export type BetaArchiveDeployment401 = BetaErrorResponse +export const BetaArchiveDeployment401 = BetaErrorResponse +export type BetaArchiveDeployment403 = BetaErrorResponse +export const BetaArchiveDeployment403 = BetaErrorResponse +export type BetaArchiveDeployment404 = BetaErrorResponse +export const BetaArchiveDeployment404 = BetaErrorResponse +export type BetaArchiveDeployment408 = BetaErrorResponse +export const BetaArchiveDeployment408 = BetaErrorResponse +export type BetaArchiveDeployment409 = BetaErrorResponse +export const BetaArchiveDeployment409 = BetaErrorResponse +export type BetaArchiveDeployment412 = BetaErrorResponse +export const BetaArchiveDeployment412 = BetaErrorResponse +export type BetaArchiveDeployment413 = BetaErrorResponse +export const BetaArchiveDeployment413 = BetaErrorResponse +export type BetaArchiveDeployment429 = BetaErrorResponse +export const BetaArchiveDeployment429 = BetaErrorResponse +export type BetaArchiveDeployment431 = BetaErrorResponse +export const BetaArchiveDeployment431 = BetaErrorResponse +export type BetaArchiveDeployment499 = BetaErrorResponse +export const BetaArchiveDeployment499 = BetaErrorResponse +export type BetaArchiveDeployment500 = BetaErrorResponse +export const BetaArchiveDeployment500 = BetaErrorResponse +export type BetaArchiveDeployment501 = BetaErrorResponse +export const BetaArchiveDeployment501 = BetaErrorResponse +export type BetaArchiveDeployment503 = BetaErrorResponse +export const BetaArchiveDeployment503 = BetaErrorResponse +export type BetaArchiveDeployment504 = BetaErrorResponse +export const BetaArchiveDeployment504 = BetaErrorResponse +export type BetaPauseDeploymentParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaPauseDeploymentParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaPauseDeployment200 = BetaManagedAgentsDeployment +export const BetaPauseDeployment200 = BetaManagedAgentsDeployment +export type BetaPauseDeployment400 = BetaErrorResponse +export const BetaPauseDeployment400 = BetaErrorResponse +export type BetaPauseDeployment401 = BetaErrorResponse +export const BetaPauseDeployment401 = BetaErrorResponse +export type BetaPauseDeployment403 = BetaErrorResponse +export const BetaPauseDeployment403 = BetaErrorResponse +export type BetaPauseDeployment404 = BetaErrorResponse +export const BetaPauseDeployment404 = BetaErrorResponse +export type BetaPauseDeployment408 = BetaErrorResponse +export const BetaPauseDeployment408 = BetaErrorResponse +export type BetaPauseDeployment409 = BetaErrorResponse +export const BetaPauseDeployment409 = BetaErrorResponse +export type BetaPauseDeployment412 = BetaErrorResponse +export const BetaPauseDeployment412 = BetaErrorResponse +export type BetaPauseDeployment413 = BetaErrorResponse +export const BetaPauseDeployment413 = BetaErrorResponse +export type BetaPauseDeployment429 = BetaErrorResponse +export const BetaPauseDeployment429 = BetaErrorResponse +export type BetaPauseDeployment431 = BetaErrorResponse +export const BetaPauseDeployment431 = BetaErrorResponse +export type BetaPauseDeployment499 = BetaErrorResponse +export const BetaPauseDeployment499 = BetaErrorResponse +export type BetaPauseDeployment500 = BetaErrorResponse +export const BetaPauseDeployment500 = BetaErrorResponse +export type BetaPauseDeployment501 = BetaErrorResponse +export const BetaPauseDeployment501 = BetaErrorResponse +export type BetaPauseDeployment503 = BetaErrorResponse +export const BetaPauseDeployment503 = BetaErrorResponse +export type BetaPauseDeployment504 = BetaErrorResponse +export const BetaPauseDeployment504 = BetaErrorResponse +export type BetaUnpauseDeploymentParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaUnpauseDeploymentParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaUnpauseDeployment200 = BetaManagedAgentsDeployment +export const BetaUnpauseDeployment200 = BetaManagedAgentsDeployment +export type BetaUnpauseDeployment400 = BetaErrorResponse +export const BetaUnpauseDeployment400 = BetaErrorResponse +export type BetaUnpauseDeployment401 = BetaErrorResponse +export const BetaUnpauseDeployment401 = BetaErrorResponse +export type BetaUnpauseDeployment403 = BetaErrorResponse +export const BetaUnpauseDeployment403 = BetaErrorResponse +export type BetaUnpauseDeployment404 = BetaErrorResponse +export const BetaUnpauseDeployment404 = BetaErrorResponse +export type BetaUnpauseDeployment408 = BetaErrorResponse +export const BetaUnpauseDeployment408 = BetaErrorResponse +export type BetaUnpauseDeployment409 = BetaErrorResponse +export const BetaUnpauseDeployment409 = BetaErrorResponse +export type BetaUnpauseDeployment412 = BetaErrorResponse +export const BetaUnpauseDeployment412 = BetaErrorResponse +export type BetaUnpauseDeployment413 = BetaErrorResponse +export const BetaUnpauseDeployment413 = BetaErrorResponse +export type BetaUnpauseDeployment429 = BetaErrorResponse +export const BetaUnpauseDeployment429 = BetaErrorResponse +export type BetaUnpauseDeployment431 = BetaErrorResponse +export const BetaUnpauseDeployment431 = BetaErrorResponse +export type BetaUnpauseDeployment499 = BetaErrorResponse +export const BetaUnpauseDeployment499 = BetaErrorResponse +export type BetaUnpauseDeployment500 = BetaErrorResponse +export const BetaUnpauseDeployment500 = BetaErrorResponse +export type BetaUnpauseDeployment501 = BetaErrorResponse +export const BetaUnpauseDeployment501 = BetaErrorResponse +export type BetaUnpauseDeployment503 = BetaErrorResponse +export const BetaUnpauseDeployment503 = BetaErrorResponse +export type BetaUnpauseDeployment504 = BetaErrorResponse +export const BetaUnpauseDeployment504 = BetaErrorResponse +export type BetaRunDeploymentNowParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaRunDeploymentNowParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaRunDeploymentNow200 = BetaManagedAgentsDeploymentRun +export const BetaRunDeploymentNow200 = BetaManagedAgentsDeploymentRun +export type BetaRunDeploymentNow400 = BetaErrorResponse +export const BetaRunDeploymentNow400 = BetaErrorResponse +export type BetaRunDeploymentNow401 = BetaErrorResponse +export const BetaRunDeploymentNow401 = BetaErrorResponse +export type BetaRunDeploymentNow403 = BetaErrorResponse +export const BetaRunDeploymentNow403 = BetaErrorResponse +export type BetaRunDeploymentNow404 = BetaErrorResponse +export const BetaRunDeploymentNow404 = BetaErrorResponse +export type BetaRunDeploymentNow408 = BetaErrorResponse +export const BetaRunDeploymentNow408 = BetaErrorResponse +export type BetaRunDeploymentNow409 = BetaErrorResponse +export const BetaRunDeploymentNow409 = BetaErrorResponse +export type BetaRunDeploymentNow412 = BetaErrorResponse +export const BetaRunDeploymentNow412 = BetaErrorResponse +export type BetaRunDeploymentNow413 = BetaErrorResponse +export const BetaRunDeploymentNow413 = BetaErrorResponse +export type BetaRunDeploymentNow429 = BetaErrorResponse +export const BetaRunDeploymentNow429 = BetaErrorResponse +export type BetaRunDeploymentNow431 = BetaErrorResponse +export const BetaRunDeploymentNow431 = BetaErrorResponse +export type BetaRunDeploymentNow499 = BetaErrorResponse +export const BetaRunDeploymentNow499 = BetaErrorResponse +export type BetaRunDeploymentNow500 = BetaErrorResponse +export const BetaRunDeploymentNow500 = BetaErrorResponse +export type BetaRunDeploymentNow501 = BetaErrorResponse +export const BetaRunDeploymentNow501 = BetaErrorResponse +export type BetaRunDeploymentNow503 = BetaErrorResponse +export const BetaRunDeploymentNow503 = BetaErrorResponse +export type BetaRunDeploymentNow504 = BetaErrorResponse +export const BetaRunDeploymentNow504 = BetaErrorResponse +export type BetaListDeploymentRunsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "deployment_id"?: string + readonly "trigger_type"?: BetaManagedAgentsTriggerType + readonly "has_error"?: boolean + readonly "created_at[gte]"?: BetaTimestamp + readonly "created_at[lte]"?: BetaTimestamp + readonly "created_at[gt]"?: BetaTimestamp + readonly "created_at[lt]"?: BetaTimestamp +} +export const BetaListDeploymentRunsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "deployment_id": Schema.optionalKey(Schema.String), + "trigger_type": Schema.optionalKey(BetaManagedAgentsTriggerType), + "has_error": Schema.optionalKey(Schema.Boolean), + "created_at[gte]": Schema.optionalKey(BetaTimestamp), + "created_at[lte]": Schema.optionalKey(BetaTimestamp), + "created_at[gt]": Schema.optionalKey(BetaTimestamp), + "created_at[lt]": Schema.optionalKey(BetaTimestamp) +}) +export type BetaListDeploymentRuns200 = BetaManagedAgentsListDeploymentRunsData +export const BetaListDeploymentRuns200 = BetaManagedAgentsListDeploymentRunsData +export type BetaListDeploymentRuns400 = BetaErrorResponse +export const BetaListDeploymentRuns400 = BetaErrorResponse +export type BetaListDeploymentRuns401 = BetaErrorResponse +export const BetaListDeploymentRuns401 = BetaErrorResponse +export type BetaListDeploymentRuns403 = BetaErrorResponse +export const BetaListDeploymentRuns403 = BetaErrorResponse +export type BetaListDeploymentRuns404 = BetaErrorResponse +export const BetaListDeploymentRuns404 = BetaErrorResponse +export type BetaListDeploymentRuns408 = BetaErrorResponse +export const BetaListDeploymentRuns408 = BetaErrorResponse +export type BetaListDeploymentRuns409 = BetaErrorResponse +export const BetaListDeploymentRuns409 = BetaErrorResponse +export type BetaListDeploymentRuns412 = BetaErrorResponse +export const BetaListDeploymentRuns412 = BetaErrorResponse +export type BetaListDeploymentRuns413 = BetaErrorResponse +export const BetaListDeploymentRuns413 = BetaErrorResponse +export type BetaListDeploymentRuns429 = BetaErrorResponse +export const BetaListDeploymentRuns429 = BetaErrorResponse +export type BetaListDeploymentRuns431 = BetaErrorResponse +export const BetaListDeploymentRuns431 = BetaErrorResponse +export type BetaListDeploymentRuns499 = BetaErrorResponse +export const BetaListDeploymentRuns499 = BetaErrorResponse +export type BetaListDeploymentRuns500 = BetaErrorResponse +export const BetaListDeploymentRuns500 = BetaErrorResponse +export type BetaListDeploymentRuns501 = BetaErrorResponse +export const BetaListDeploymentRuns501 = BetaErrorResponse +export type BetaListDeploymentRuns503 = BetaErrorResponse +export const BetaListDeploymentRuns503 = BetaErrorResponse +export type BetaListDeploymentRuns504 = BetaErrorResponse +export const BetaListDeploymentRuns504 = BetaErrorResponse +export type BetaGetDeploymentRunParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetDeploymentRunParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetDeploymentRun200 = BetaManagedAgentsDeploymentRun +export const BetaGetDeploymentRun200 = BetaManagedAgentsDeploymentRun +export type BetaGetDeploymentRun400 = BetaErrorResponse +export const BetaGetDeploymentRun400 = BetaErrorResponse +export type BetaGetDeploymentRun401 = BetaErrorResponse +export const BetaGetDeploymentRun401 = BetaErrorResponse +export type BetaGetDeploymentRun403 = BetaErrorResponse +export const BetaGetDeploymentRun403 = BetaErrorResponse +export type BetaGetDeploymentRun404 = BetaErrorResponse +export const BetaGetDeploymentRun404 = BetaErrorResponse +export type BetaGetDeploymentRun408 = BetaErrorResponse +export const BetaGetDeploymentRun408 = BetaErrorResponse +export type BetaGetDeploymentRun409 = BetaErrorResponse +export const BetaGetDeploymentRun409 = BetaErrorResponse +export type BetaGetDeploymentRun412 = BetaErrorResponse +export const BetaGetDeploymentRun412 = BetaErrorResponse +export type BetaGetDeploymentRun413 = BetaErrorResponse +export const BetaGetDeploymentRun413 = BetaErrorResponse +export type BetaGetDeploymentRun429 = BetaErrorResponse +export const BetaGetDeploymentRun429 = BetaErrorResponse +export type BetaGetDeploymentRun431 = BetaErrorResponse +export const BetaGetDeploymentRun431 = BetaErrorResponse +export type BetaGetDeploymentRun499 = BetaErrorResponse +export const BetaGetDeploymentRun499 = BetaErrorResponse +export type BetaGetDeploymentRun500 = BetaErrorResponse +export const BetaGetDeploymentRun500 = BetaErrorResponse +export type BetaGetDeploymentRun501 = BetaErrorResponse +export const BetaGetDeploymentRun501 = BetaErrorResponse +export type BetaGetDeploymentRun503 = BetaErrorResponse +export const BetaGetDeploymentRun503 = BetaErrorResponse +export type BetaGetDeploymentRun504 = BetaErrorResponse +export const BetaGetDeploymentRun504 = BetaErrorResponse +export type BetaListVaultsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "include_archived"?: boolean +} +export const BetaListVaultsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "include_archived": Schema.optionalKey(Schema.Boolean) +}) +export type BetaListVaults200 = BetaManagedAgentsListVaultsResponse +export const BetaListVaults200 = BetaManagedAgentsListVaultsResponse +export type BetaListVaults400 = BetaErrorResponse +export const BetaListVaults400 = BetaErrorResponse +export type BetaListVaults401 = BetaErrorResponse +export const BetaListVaults401 = BetaErrorResponse +export type BetaListVaults403 = BetaErrorResponse +export const BetaListVaults403 = BetaErrorResponse +export type BetaListVaults404 = BetaErrorResponse +export const BetaListVaults404 = BetaErrorResponse +export type BetaListVaults408 = BetaErrorResponse +export const BetaListVaults408 = BetaErrorResponse +export type BetaListVaults409 = BetaErrorResponse +export const BetaListVaults409 = BetaErrorResponse +export type BetaListVaults412 = BetaErrorResponse +export const BetaListVaults412 = BetaErrorResponse +export type BetaListVaults413 = BetaErrorResponse +export const BetaListVaults413 = BetaErrorResponse +export type BetaListVaults429 = BetaErrorResponse +export const BetaListVaults429 = BetaErrorResponse +export type BetaListVaults431 = BetaErrorResponse +export const BetaListVaults431 = BetaErrorResponse +export type BetaListVaults499 = BetaErrorResponse +export const BetaListVaults499 = BetaErrorResponse +export type BetaListVaults500 = BetaErrorResponse +export const BetaListVaults500 = BetaErrorResponse +export type BetaListVaults501 = BetaErrorResponse +export const BetaListVaults501 = BetaErrorResponse +export type BetaListVaults503 = BetaErrorResponse +export const BetaListVaults503 = BetaErrorResponse +export type BetaListVaults504 = BetaErrorResponse +export const BetaListVaults504 = BetaErrorResponse +export type BetaCreateVaultParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCreateVaultParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateVaultRequestJson = BetaManagedAgentsCreateVaultRequest +export const BetaCreateVaultRequestJson = BetaManagedAgentsCreateVaultRequest +export type BetaCreateVault200 = BetaManagedAgentsVault +export const BetaCreateVault200 = BetaManagedAgentsVault +export type BetaCreateVault400 = BetaErrorResponse +export const BetaCreateVault400 = BetaErrorResponse +export type BetaCreateVault401 = BetaErrorResponse +export const BetaCreateVault401 = BetaErrorResponse +export type BetaCreateVault403 = BetaErrorResponse +export const BetaCreateVault403 = BetaErrorResponse +export type BetaCreateVault404 = BetaErrorResponse +export const BetaCreateVault404 = BetaErrorResponse +export type BetaCreateVault408 = BetaErrorResponse +export const BetaCreateVault408 = BetaErrorResponse +export type BetaCreateVault409 = BetaErrorResponse +export const BetaCreateVault409 = BetaErrorResponse +export type BetaCreateVault412 = BetaErrorResponse +export const BetaCreateVault412 = BetaErrorResponse +export type BetaCreateVault413 = BetaErrorResponse +export const BetaCreateVault413 = BetaErrorResponse +export type BetaCreateVault429 = BetaErrorResponse +export const BetaCreateVault429 = BetaErrorResponse +export type BetaCreateVault431 = BetaErrorResponse +export const BetaCreateVault431 = BetaErrorResponse +export type BetaCreateVault499 = BetaErrorResponse +export const BetaCreateVault499 = BetaErrorResponse +export type BetaCreateVault500 = BetaErrorResponse +export const BetaCreateVault500 = BetaErrorResponse +export type BetaCreateVault501 = BetaErrorResponse +export const BetaCreateVault501 = BetaErrorResponse +export type BetaCreateVault503 = BetaErrorResponse +export const BetaCreateVault503 = BetaErrorResponse +export type BetaCreateVault504 = BetaErrorResponse +export const BetaCreateVault504 = BetaErrorResponse +export type BetaGetVaultParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetVaultParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetVault200 = BetaManagedAgentsVault +export const BetaGetVault200 = BetaManagedAgentsVault +export type BetaGetVault400 = BetaErrorResponse +export const BetaGetVault400 = BetaErrorResponse +export type BetaGetVault401 = BetaErrorResponse +export const BetaGetVault401 = BetaErrorResponse +export type BetaGetVault403 = BetaErrorResponse +export const BetaGetVault403 = BetaErrorResponse +export type BetaGetVault404 = BetaErrorResponse +export const BetaGetVault404 = BetaErrorResponse +export type BetaGetVault408 = BetaErrorResponse +export const BetaGetVault408 = BetaErrorResponse +export type BetaGetVault409 = BetaErrorResponse +export const BetaGetVault409 = BetaErrorResponse +export type BetaGetVault412 = BetaErrorResponse +export const BetaGetVault412 = BetaErrorResponse +export type BetaGetVault413 = BetaErrorResponse +export const BetaGetVault413 = BetaErrorResponse +export type BetaGetVault429 = BetaErrorResponse +export const BetaGetVault429 = BetaErrorResponse +export type BetaGetVault431 = BetaErrorResponse +export const BetaGetVault431 = BetaErrorResponse +export type BetaGetVault499 = BetaErrorResponse +export const BetaGetVault499 = BetaErrorResponse +export type BetaGetVault500 = BetaErrorResponse +export const BetaGetVault500 = BetaErrorResponse +export type BetaGetVault501 = BetaErrorResponse +export const BetaGetVault501 = BetaErrorResponse +export type BetaGetVault503 = BetaErrorResponse +export const BetaGetVault503 = BetaErrorResponse +export type BetaGetVault504 = BetaErrorResponse +export const BetaGetVault504 = BetaErrorResponse +export type BetaUpdateVaultParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaUpdateVaultParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaUpdateVaultRequestJson = BetaManagedAgentsUpdateVaultRequestBody +export const BetaUpdateVaultRequestJson = BetaManagedAgentsUpdateVaultRequestBody +export type BetaUpdateVault200 = BetaManagedAgentsVault +export const BetaUpdateVault200 = BetaManagedAgentsVault +export type BetaUpdateVault400 = BetaErrorResponse +export const BetaUpdateVault400 = BetaErrorResponse +export type BetaUpdateVault401 = BetaErrorResponse +export const BetaUpdateVault401 = BetaErrorResponse +export type BetaUpdateVault403 = BetaErrorResponse +export const BetaUpdateVault403 = BetaErrorResponse +export type BetaUpdateVault404 = BetaErrorResponse +export const BetaUpdateVault404 = BetaErrorResponse +export type BetaUpdateVault408 = BetaErrorResponse +export const BetaUpdateVault408 = BetaErrorResponse +export type BetaUpdateVault409 = BetaErrorResponse +export const BetaUpdateVault409 = BetaErrorResponse +export type BetaUpdateVault412 = BetaErrorResponse +export const BetaUpdateVault412 = BetaErrorResponse +export type BetaUpdateVault413 = BetaErrorResponse +export const BetaUpdateVault413 = BetaErrorResponse +export type BetaUpdateVault429 = BetaErrorResponse +export const BetaUpdateVault429 = BetaErrorResponse +export type BetaUpdateVault431 = BetaErrorResponse +export const BetaUpdateVault431 = BetaErrorResponse +export type BetaUpdateVault499 = BetaErrorResponse +export const BetaUpdateVault499 = BetaErrorResponse +export type BetaUpdateVault500 = BetaErrorResponse +export const BetaUpdateVault500 = BetaErrorResponse +export type BetaUpdateVault501 = BetaErrorResponse +export const BetaUpdateVault501 = BetaErrorResponse +export type BetaUpdateVault503 = BetaErrorResponse +export const BetaUpdateVault503 = BetaErrorResponse +export type BetaUpdateVault504 = BetaErrorResponse +export const BetaUpdateVault504 = BetaErrorResponse +export type BetaDeleteVaultParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaDeleteVaultParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaDeleteVault200 = BetaManagedAgentsDeletedVault +export const BetaDeleteVault200 = BetaManagedAgentsDeletedVault +export type BetaDeleteVault400 = BetaErrorResponse +export const BetaDeleteVault400 = BetaErrorResponse +export type BetaDeleteVault401 = BetaErrorResponse +export const BetaDeleteVault401 = BetaErrorResponse +export type BetaDeleteVault403 = BetaErrorResponse +export const BetaDeleteVault403 = BetaErrorResponse +export type BetaDeleteVault404 = BetaErrorResponse +export const BetaDeleteVault404 = BetaErrorResponse +export type BetaDeleteVault408 = BetaErrorResponse +export const BetaDeleteVault408 = BetaErrorResponse +export type BetaDeleteVault409 = BetaErrorResponse +export const BetaDeleteVault409 = BetaErrorResponse +export type BetaDeleteVault412 = BetaErrorResponse +export const BetaDeleteVault412 = BetaErrorResponse +export type BetaDeleteVault413 = BetaErrorResponse +export const BetaDeleteVault413 = BetaErrorResponse +export type BetaDeleteVault429 = BetaErrorResponse +export const BetaDeleteVault429 = BetaErrorResponse +export type BetaDeleteVault431 = BetaErrorResponse +export const BetaDeleteVault431 = BetaErrorResponse +export type BetaDeleteVault499 = BetaErrorResponse +export const BetaDeleteVault499 = BetaErrorResponse +export type BetaDeleteVault500 = BetaErrorResponse +export const BetaDeleteVault500 = BetaErrorResponse +export type BetaDeleteVault501 = BetaErrorResponse +export const BetaDeleteVault501 = BetaErrorResponse +export type BetaDeleteVault503 = BetaErrorResponse +export const BetaDeleteVault503 = BetaErrorResponse +export type BetaDeleteVault504 = BetaErrorResponse +export const BetaDeleteVault504 = BetaErrorResponse +export type BetaArchiveVaultParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaArchiveVaultParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveVault200 = BetaManagedAgentsVault +export const BetaArchiveVault200 = BetaManagedAgentsVault +export type BetaArchiveVault400 = BetaErrorResponse +export const BetaArchiveVault400 = BetaErrorResponse +export type BetaArchiveVault401 = BetaErrorResponse +export const BetaArchiveVault401 = BetaErrorResponse +export type BetaArchiveVault403 = BetaErrorResponse +export const BetaArchiveVault403 = BetaErrorResponse +export type BetaArchiveVault404 = BetaErrorResponse +export const BetaArchiveVault404 = BetaErrorResponse +export type BetaArchiveVault408 = BetaErrorResponse +export const BetaArchiveVault408 = BetaErrorResponse +export type BetaArchiveVault409 = BetaErrorResponse +export const BetaArchiveVault409 = BetaErrorResponse +export type BetaArchiveVault412 = BetaErrorResponse +export const BetaArchiveVault412 = BetaErrorResponse +export type BetaArchiveVault413 = BetaErrorResponse +export const BetaArchiveVault413 = BetaErrorResponse +export type BetaArchiveVault429 = BetaErrorResponse +export const BetaArchiveVault429 = BetaErrorResponse +export type BetaArchiveVault431 = BetaErrorResponse +export const BetaArchiveVault431 = BetaErrorResponse +export type BetaArchiveVault499 = BetaErrorResponse +export const BetaArchiveVault499 = BetaErrorResponse +export type BetaArchiveVault500 = BetaErrorResponse +export const BetaArchiveVault500 = BetaErrorResponse +export type BetaArchiveVault501 = BetaErrorResponse +export const BetaArchiveVault501 = BetaErrorResponse +export type BetaArchiveVault503 = BetaErrorResponse +export const BetaArchiveVault503 = BetaErrorResponse +export type BetaArchiveVault504 = BetaErrorResponse +export const BetaArchiveVault504 = BetaErrorResponse +export type BetaListCredentialsParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string + readonly "limit"?: number + readonly "page"?: string + readonly "include_archived"?: boolean +} +export const BetaListCredentialsParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "format": "int32" }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "page": Schema.optionalKey(Schema.String), + "include_archived": Schema.optionalKey(Schema.Boolean) +}) +export type BetaListCredentials200 = BetaManagedAgentsListCredentialsResponse +export const BetaListCredentials200 = BetaManagedAgentsListCredentialsResponse +export type BetaListCredentials400 = BetaErrorResponse +export const BetaListCredentials400 = BetaErrorResponse +export type BetaListCredentials401 = BetaErrorResponse +export const BetaListCredentials401 = BetaErrorResponse +export type BetaListCredentials403 = BetaErrorResponse +export const BetaListCredentials403 = BetaErrorResponse +export type BetaListCredentials404 = BetaErrorResponse +export const BetaListCredentials404 = BetaErrorResponse +export type BetaListCredentials408 = BetaErrorResponse +export const BetaListCredentials408 = BetaErrorResponse +export type BetaListCredentials409 = BetaErrorResponse +export const BetaListCredentials409 = BetaErrorResponse +export type BetaListCredentials412 = BetaErrorResponse +export const BetaListCredentials412 = BetaErrorResponse +export type BetaListCredentials413 = BetaErrorResponse +export const BetaListCredentials413 = BetaErrorResponse +export type BetaListCredentials429 = BetaErrorResponse +export const BetaListCredentials429 = BetaErrorResponse +export type BetaListCredentials431 = BetaErrorResponse +export const BetaListCredentials431 = BetaErrorResponse +export type BetaListCredentials499 = BetaErrorResponse +export const BetaListCredentials499 = BetaErrorResponse +export type BetaListCredentials500 = BetaErrorResponse +export const BetaListCredentials500 = BetaErrorResponse +export type BetaListCredentials501 = BetaErrorResponse +export const BetaListCredentials501 = BetaErrorResponse +export type BetaListCredentials503 = BetaErrorResponse +export const BetaListCredentials503 = BetaErrorResponse +export type BetaListCredentials504 = BetaErrorResponse +export const BetaListCredentials504 = BetaErrorResponse +export type BetaCreateCredentialParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaCreateCredentialParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaCreateCredentialRequestJson = BetaManagedAgentsCreateCredentialRequestBody +export const BetaCreateCredentialRequestJson = BetaManagedAgentsCreateCredentialRequestBody +export type BetaCreateCredential200 = BetaManagedAgentsCredential +export const BetaCreateCredential200 = BetaManagedAgentsCredential +export type BetaCreateCredential400 = BetaErrorResponse +export const BetaCreateCredential400 = BetaErrorResponse +export type BetaCreateCredential401 = BetaErrorResponse +export const BetaCreateCredential401 = BetaErrorResponse +export type BetaCreateCredential403 = BetaErrorResponse +export const BetaCreateCredential403 = BetaErrorResponse +export type BetaCreateCredential404 = BetaErrorResponse +export const BetaCreateCredential404 = BetaErrorResponse +export type BetaCreateCredential408 = BetaErrorResponse +export const BetaCreateCredential408 = BetaErrorResponse +export type BetaCreateCredential409 = BetaErrorResponse +export const BetaCreateCredential409 = BetaErrorResponse +export type BetaCreateCredential412 = BetaErrorResponse +export const BetaCreateCredential412 = BetaErrorResponse +export type BetaCreateCredential413 = BetaErrorResponse +export const BetaCreateCredential413 = BetaErrorResponse +export type BetaCreateCredential429 = BetaErrorResponse +export const BetaCreateCredential429 = BetaErrorResponse +export type BetaCreateCredential431 = BetaErrorResponse +export const BetaCreateCredential431 = BetaErrorResponse +export type BetaCreateCredential499 = BetaErrorResponse +export const BetaCreateCredential499 = BetaErrorResponse +export type BetaCreateCredential500 = BetaErrorResponse +export const BetaCreateCredential500 = BetaErrorResponse +export type BetaCreateCredential501 = BetaErrorResponse +export const BetaCreateCredential501 = BetaErrorResponse +export type BetaCreateCredential503 = BetaErrorResponse +export const BetaCreateCredential503 = BetaErrorResponse +export type BetaCreateCredential504 = BetaErrorResponse +export const BetaCreateCredential504 = BetaErrorResponse +export type BetaGetCredentialParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaGetCredentialParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaGetCredential200 = BetaManagedAgentsCredential +export const BetaGetCredential200 = BetaManagedAgentsCredential +export type BetaGetCredential400 = BetaErrorResponse +export const BetaGetCredential400 = BetaErrorResponse +export type BetaGetCredential401 = BetaErrorResponse +export const BetaGetCredential401 = BetaErrorResponse +export type BetaGetCredential403 = BetaErrorResponse +export const BetaGetCredential403 = BetaErrorResponse +export type BetaGetCredential404 = BetaErrorResponse +export const BetaGetCredential404 = BetaErrorResponse +export type BetaGetCredential408 = BetaErrorResponse +export const BetaGetCredential408 = BetaErrorResponse +export type BetaGetCredential409 = BetaErrorResponse +export const BetaGetCredential409 = BetaErrorResponse +export type BetaGetCredential412 = BetaErrorResponse +export const BetaGetCredential412 = BetaErrorResponse +export type BetaGetCredential413 = BetaErrorResponse +export const BetaGetCredential413 = BetaErrorResponse +export type BetaGetCredential429 = BetaErrorResponse +export const BetaGetCredential429 = BetaErrorResponse +export type BetaGetCredential431 = BetaErrorResponse +export const BetaGetCredential431 = BetaErrorResponse +export type BetaGetCredential499 = BetaErrorResponse +export const BetaGetCredential499 = BetaErrorResponse +export type BetaGetCredential500 = BetaErrorResponse +export const BetaGetCredential500 = BetaErrorResponse +export type BetaGetCredential501 = BetaErrorResponse +export const BetaGetCredential501 = BetaErrorResponse +export type BetaGetCredential503 = BetaErrorResponse +export const BetaGetCredential503 = BetaErrorResponse +export type BetaGetCredential504 = BetaErrorResponse +export const BetaGetCredential504 = BetaErrorResponse +export type BetaUpdateCredentialParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaUpdateCredentialParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaUpdateCredentialRequestJson = BetaManagedAgentsUpdateCredentialRequestBody +export const BetaUpdateCredentialRequestJson = BetaManagedAgentsUpdateCredentialRequestBody +export type BetaUpdateCredential200 = BetaManagedAgentsCredential +export const BetaUpdateCredential200 = BetaManagedAgentsCredential +export type BetaUpdateCredential400 = BetaErrorResponse +export const BetaUpdateCredential400 = BetaErrorResponse +export type BetaUpdateCredential401 = BetaErrorResponse +export const BetaUpdateCredential401 = BetaErrorResponse +export type BetaUpdateCredential403 = BetaErrorResponse +export const BetaUpdateCredential403 = BetaErrorResponse +export type BetaUpdateCredential404 = BetaErrorResponse +export const BetaUpdateCredential404 = BetaErrorResponse +export type BetaUpdateCredential408 = BetaErrorResponse +export const BetaUpdateCredential408 = BetaErrorResponse +export type BetaUpdateCredential409 = BetaErrorResponse +export const BetaUpdateCredential409 = BetaErrorResponse +export type BetaUpdateCredential412 = BetaErrorResponse +export const BetaUpdateCredential412 = BetaErrorResponse +export type BetaUpdateCredential413 = BetaErrorResponse +export const BetaUpdateCredential413 = BetaErrorResponse +export type BetaUpdateCredential429 = BetaErrorResponse +export const BetaUpdateCredential429 = BetaErrorResponse +export type BetaUpdateCredential431 = BetaErrorResponse +export const BetaUpdateCredential431 = BetaErrorResponse +export type BetaUpdateCredential499 = BetaErrorResponse +export const BetaUpdateCredential499 = BetaErrorResponse +export type BetaUpdateCredential500 = BetaErrorResponse +export const BetaUpdateCredential500 = BetaErrorResponse +export type BetaUpdateCredential501 = BetaErrorResponse +export const BetaUpdateCredential501 = BetaErrorResponse +export type BetaUpdateCredential503 = BetaErrorResponse +export const BetaUpdateCredential503 = BetaErrorResponse +export type BetaUpdateCredential504 = BetaErrorResponse +export const BetaUpdateCredential504 = BetaErrorResponse +export type BetaDeleteCredentialParams = { + readonly "x-api-key"?: string + readonly "anthropic-version"?: string + readonly "anthropic-beta"?: string +} +export const BetaDeleteCredentialParams = Schema.Struct({ + "x-api-key": Schema.optionalKey(Schema.String), + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaDeleteCredential200 = BetaManagedAgentsDeletedCredential +export const BetaDeleteCredential200 = BetaManagedAgentsDeletedCredential +export type BetaDeleteCredential400 = BetaErrorResponse +export const BetaDeleteCredential400 = BetaErrorResponse +export type BetaDeleteCredential401 = BetaErrorResponse +export const BetaDeleteCredential401 = BetaErrorResponse +export type BetaDeleteCredential403 = BetaErrorResponse +export const BetaDeleteCredential403 = BetaErrorResponse +export type BetaDeleteCredential404 = BetaErrorResponse +export const BetaDeleteCredential404 = BetaErrorResponse +export type BetaDeleteCredential408 = BetaErrorResponse +export const BetaDeleteCredential408 = BetaErrorResponse +export type BetaDeleteCredential409 = BetaErrorResponse +export const BetaDeleteCredential409 = BetaErrorResponse +export type BetaDeleteCredential412 = BetaErrorResponse +export const BetaDeleteCredential412 = BetaErrorResponse +export type BetaDeleteCredential413 = BetaErrorResponse +export const BetaDeleteCredential413 = BetaErrorResponse +export type BetaDeleteCredential429 = BetaErrorResponse +export const BetaDeleteCredential429 = BetaErrorResponse +export type BetaDeleteCredential431 = BetaErrorResponse +export const BetaDeleteCredential431 = BetaErrorResponse +export type BetaDeleteCredential499 = BetaErrorResponse +export const BetaDeleteCredential499 = BetaErrorResponse +export type BetaDeleteCredential500 = BetaErrorResponse +export const BetaDeleteCredential500 = BetaErrorResponse +export type BetaDeleteCredential501 = BetaErrorResponse +export const BetaDeleteCredential501 = BetaErrorResponse +export type BetaDeleteCredential503 = BetaErrorResponse +export const BetaDeleteCredential503 = BetaErrorResponse +export type BetaDeleteCredential504 = BetaErrorResponse +export const BetaDeleteCredential504 = BetaErrorResponse +export type BetaArchiveCredentialParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaArchiveCredentialParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaArchiveCredential200 = BetaManagedAgentsCredential +export const BetaArchiveCredential200 = BetaManagedAgentsCredential +export type BetaArchiveCredential400 = BetaErrorResponse +export const BetaArchiveCredential400 = BetaErrorResponse +export type BetaArchiveCredential401 = BetaErrorResponse +export const BetaArchiveCredential401 = BetaErrorResponse +export type BetaArchiveCredential403 = BetaErrorResponse +export const BetaArchiveCredential403 = BetaErrorResponse +export type BetaArchiveCredential404 = BetaErrorResponse +export const BetaArchiveCredential404 = BetaErrorResponse +export type BetaArchiveCredential408 = BetaErrorResponse +export const BetaArchiveCredential408 = BetaErrorResponse +export type BetaArchiveCredential409 = BetaErrorResponse +export const BetaArchiveCredential409 = BetaErrorResponse +export type BetaArchiveCredential412 = BetaErrorResponse +export const BetaArchiveCredential412 = BetaErrorResponse +export type BetaArchiveCredential413 = BetaErrorResponse +export const BetaArchiveCredential413 = BetaErrorResponse +export type BetaArchiveCredential429 = BetaErrorResponse +export const BetaArchiveCredential429 = BetaErrorResponse +export type BetaArchiveCredential431 = BetaErrorResponse +export const BetaArchiveCredential431 = BetaErrorResponse +export type BetaArchiveCredential499 = BetaErrorResponse +export const BetaArchiveCredential499 = BetaErrorResponse +export type BetaArchiveCredential500 = BetaErrorResponse +export const BetaArchiveCredential500 = BetaErrorResponse +export type BetaArchiveCredential501 = BetaErrorResponse +export const BetaArchiveCredential501 = BetaErrorResponse +export type BetaArchiveCredential503 = BetaErrorResponse +export const BetaArchiveCredential503 = BetaErrorResponse +export type BetaArchiveCredential504 = BetaErrorResponse +export const BetaArchiveCredential504 = BetaErrorResponse +export type BetaValidateCredentialParams = { readonly "anthropic-version"?: string; readonly "anthropic-beta"?: string } +export const BetaValidateCredentialParams = Schema.Struct({ + "anthropic-version": Schema.optionalKey(Schema.String), + "anthropic-beta": Schema.optionalKey(Schema.String) +}) +export type BetaValidateCredential200 = BetaManagedAgentsCredentialValidation +export const BetaValidateCredential200 = BetaManagedAgentsCredentialValidation +export type BetaValidateCredential400 = BetaErrorResponse +export const BetaValidateCredential400 = BetaErrorResponse +export type BetaValidateCredential401 = BetaErrorResponse +export const BetaValidateCredential401 = BetaErrorResponse +export type BetaValidateCredential403 = BetaErrorResponse +export const BetaValidateCredential403 = BetaErrorResponse +export type BetaValidateCredential404 = BetaErrorResponse +export const BetaValidateCredential404 = BetaErrorResponse +export type BetaValidateCredential408 = BetaErrorResponse +export const BetaValidateCredential408 = BetaErrorResponse +export type BetaValidateCredential409 = BetaErrorResponse +export const BetaValidateCredential409 = BetaErrorResponse +export type BetaValidateCredential412 = BetaErrorResponse +export const BetaValidateCredential412 = BetaErrorResponse +export type BetaValidateCredential413 = BetaErrorResponse +export const BetaValidateCredential413 = BetaErrorResponse +export type BetaValidateCredential429 = BetaErrorResponse +export const BetaValidateCredential429 = BetaErrorResponse +export type BetaValidateCredential431 = BetaErrorResponse +export const BetaValidateCredential431 = BetaErrorResponse +export type BetaValidateCredential499 = BetaErrorResponse +export const BetaValidateCredential499 = BetaErrorResponse +export type BetaValidateCredential500 = BetaErrorResponse +export const BetaValidateCredential500 = BetaErrorResponse +export type BetaValidateCredential501 = BetaErrorResponse +export const BetaValidateCredential501 = BetaErrorResponse +export type BetaValidateCredential503 = BetaErrorResponse +export const BetaValidateCredential503 = BetaErrorResponse +export type BetaValidateCredential504 = BetaErrorResponse +export const BetaValidateCredential504 = BetaErrorResponse + +export interface OperationConfig { + /** + * Whether or not the response should be included in the value returned from + * an operation. + * + * If set to `true`, a tuple of `[A, HttpClientResponse]` will be returned, + * where `A` is the success type of the operation. + * + * If set to `false`, only the success type of the operation will be returned. + */ + readonly includeResponse?: boolean | undefined +} + +/** + * A utility type which optionally includes the response in the return result + * of an operation based upon the value of the `includeResponse` configuration + * option. + */ +export type WithOptionalResponse = Config extends { + readonly includeResponse: true +} ? [A, HttpClientResponse.HttpClientResponse] : + A + +export const make = ( + httpClient: HttpClient.HttpClient, + options: { + readonly transformClient?: ((client: HttpClient.HttpClient) => Effect.Effect) | undefined + } = {} +): AnthropicClient => { + const unexpectedStatus = (response: HttpClientResponse.HttpClientResponse) => + Effect.flatMap( + Effect.orElseSucceed(response.json, () => "Unexpected status code"), + (description) => + Effect.fail( + new HttpClientError.HttpClientError({ + reason: new HttpClientError.StatusCodeError({ + request: response.request, + response, + description: typeof description === "string" ? description : JSON.stringify(description) + }) + }) + ) + ) + const withResponse = (config: Config | undefined) => + ( + f: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect + ): (request: HttpClientRequest.HttpClientRequest) => Effect.Effect => { + const withOptionalResponse = ( + config?.includeResponse + ? (response: HttpClientResponse.HttpClientResponse) => Effect.map(f(response), (a) => [a, response]) + : (response: HttpClientResponse.HttpClientResponse) => f(response) + ) as any + return options?.transformClient + ? (request) => + Effect.flatMap( + Effect.flatMap(options.transformClient!(httpClient), (client) => client.execute(request)), + withOptionalResponse + ) + : (request) => Effect.flatMap(httpClient.execute(request), withOptionalResponse) + } + const binaryRequest = ( + request: HttpClientRequest.HttpClientRequest + ): Stream.Stream => + HttpClient.filterStatusOk(httpClient).execute(request).pipe( + Effect.map((response) => response.stream), + Stream.unwrap + ) + const decodeSuccess = + (schema: Schema) => (response: HttpClientResponse.HttpClientResponse) => + HttpClientResponse.schemaBodyJson(schema)(response) + const decodeError = + (tag: Tag, schema: Schema) => + (response: HttpClientResponse.HttpClientResponse) => + Effect.flatMap( + HttpClientResponse.schemaBodyJson(schema)(response), + (cause) => Effect.fail(AnthropicClientError(tag, cause, response)) + ) + return { + httpClient, + "messagesPost": (options) => + HttpClientRequest.post(`/v1/messages`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-user-profile-id": options.params?.["anthropic-user-profile-id"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(MessagesPost200), + "4xx": decodeError("MessagesPost4XX", MessagesPost4XX), + orElse: unexpectedStatus + })) + ), + "completePost": (options) => + HttpClientRequest.post(`/v1/complete`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(CompletePost200), + "4xx": decodeError("CompletePost4XX", CompletePost4XX), + orElse: unexpectedStatus + })) + ), + "modelsList": (options) => + HttpClientRequest.get(`/v1/models`).pipe( + HttpClientRequest.setUrlParams({ + "before_id": options?.params?.["before_id"] as any, + "after_id": options?.params?.["after_id"] as any, + "limit": options?.params?.["limit"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(ModelsList200), + "4xx": decodeError("ModelsList4XX", ModelsList4XX), + orElse: unexpectedStatus + })) + ), + "modelsGet": (modelId, options) => + HttpClientRequest.get(`/v1/models/${modelId}`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(ModelsGet200), + "4xx": decodeError("ModelsGet4XX", ModelsGet4XX), + orElse: unexpectedStatus + })) + ), + "messageBatchesList": (options) => + HttpClientRequest.get(`/v1/messages/batches`).pipe( + HttpClientRequest.setUrlParams({ + "before_id": options?.params?.["before_id"] as any, + "after_id": options?.params?.["after_id"] as any, + "limit": options?.params?.["limit"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(MessageBatchesList200), + "4xx": decodeError("MessageBatchesList4XX", MessageBatchesList4XX), + orElse: unexpectedStatus + })) + ), + "messageBatchesPost": (options) => + HttpClientRequest.post(`/v1/messages/batches`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-user-profile-id": options.params?.["anthropic-user-profile-id"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(MessageBatchesPost200), + "4xx": decodeError("MessageBatchesPost4XX", MessageBatchesPost4XX), + orElse: unexpectedStatus + })) + ), + "messageBatchesRetrieve": (messageBatchId, options) => + HttpClientRequest.get(`/v1/messages/batches/${messageBatchId}`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(MessageBatchesRetrieve200), + "4xx": decodeError("MessageBatchesRetrieve4XX", MessageBatchesRetrieve4XX), + orElse: unexpectedStatus + })) + ), + "messageBatchesDelete": (messageBatchId, options) => + HttpClientRequest.delete(`/v1/messages/batches/${messageBatchId}`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(MessageBatchesDelete200), + "4xx": decodeError("MessageBatchesDelete4XX", MessageBatchesDelete4XX), + orElse: unexpectedStatus + })) + ), + "messageBatchesCancel": (messageBatchId, options) => + HttpClientRequest.post(`/v1/messages/batches/${messageBatchId}/cancel`).pipe( + HttpClientRequest.setHeaders({ "anthropic-version": options?.params?.["anthropic-version"] ?? undefined }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(MessageBatchesCancel200), + "4xx": decodeError("MessageBatchesCancel4XX", MessageBatchesCancel4XX), + orElse: unexpectedStatus + })) + ), + "messageBatchesResults": (messageBatchId, options) => + HttpClientRequest.get(`/v1/messages/batches/${messageBatchId}/results`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "4xx": decodeError("MessageBatchesResults4XX", MessageBatchesResults4XX), + orElse: unexpectedStatus + })) + ), + "messagesCountTokensPost": (options) => + HttpClientRequest.post(`/v1/messages/count_tokens`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-user-profile-id": options.params?.["anthropic-user-profile-id"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(MessagesCountTokensPost200), + "4xx": decodeError("MessagesCountTokensPost4XX", MessagesCountTokensPost4XX), + orElse: unexpectedStatus + })) + ), + "betaMessagesPost": (options) => + HttpClientRequest.post(`/v1/messages?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-user-profile-id": options.params?.["anthropic-user-profile-id"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaMessagesPost200), + "4xx": decodeError("BetaMessagesPost4XX", BetaMessagesPost4XX), + orElse: unexpectedStatus + })) + ), + "betaModelsList": (options) => + HttpClientRequest.get(`/v1/models?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "before_id": options?.params?.["before_id"] as any, + "after_id": options?.params?.["after_id"] as any, + "limit": options?.params?.["limit"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaModelsList200), + "4xx": decodeError("BetaModelsList4XX", BetaModelsList4XX), + orElse: unexpectedStatus + })) + ), + "betaModelsGet": (modelId, options) => + HttpClientRequest.get(`/v1/models/${modelId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaModelsGet200), + "4xx": decodeError("BetaModelsGet4XX", BetaModelsGet4XX), + orElse: unexpectedStatus + })) + ), + "betaMessageBatchesList": (options) => + HttpClientRequest.get(`/v1/messages/batches?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "before_id": options?.params?.["before_id"] as any, + "after_id": options?.params?.["after_id"] as any, + "limit": options?.params?.["limit"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaMessageBatchesList200), + "4xx": decodeError("BetaMessageBatchesList4XX", BetaMessageBatchesList4XX), + orElse: unexpectedStatus + })) + ), + "betaMessageBatchesPost": (options) => + HttpClientRequest.post(`/v1/messages/batches?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-user-profile-id": options.params?.["anthropic-user-profile-id"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaMessageBatchesPost200), + "4xx": decodeError("BetaMessageBatchesPost4XX", BetaMessageBatchesPost4XX), + orElse: unexpectedStatus + })) + ), + "betaMessageBatchesRetrieve": (messageBatchId, options) => + HttpClientRequest.get(`/v1/messages/batches/${messageBatchId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaMessageBatchesRetrieve200), + "4xx": decodeError("BetaMessageBatchesRetrieve4XX", BetaMessageBatchesRetrieve4XX), + orElse: unexpectedStatus + })) + ), + "betaMessageBatchesDelete": (messageBatchId, options) => + HttpClientRequest.delete(`/v1/messages/batches/${messageBatchId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaMessageBatchesDelete200), + "4xx": decodeError("BetaMessageBatchesDelete4XX", BetaMessageBatchesDelete4XX), + orElse: unexpectedStatus + })) + ), + "betaMessageBatchesCancel": (messageBatchId, options) => + HttpClientRequest.post(`/v1/messages/batches/${messageBatchId}/cancel?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaMessageBatchesCancel200), + "4xx": decodeError("BetaMessageBatchesCancel4XX", BetaMessageBatchesCancel4XX), + orElse: unexpectedStatus + })) + ), + "betaMessageBatchesResults": (messageBatchId, options) => + HttpClientRequest.get(`/v1/messages/batches/${messageBatchId}/results?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "4xx": decodeError("BetaMessageBatchesResults4XX", BetaMessageBatchesResults4XX), + orElse: unexpectedStatus + })) + ), + "betaMessagesCountTokensPost": (options) => + HttpClientRequest.post(`/v1/messages/count_tokens?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-user-profile-id": options.params?.["anthropic-user-profile-id"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaMessagesCountTokensPost200), + "4xx": decodeError("BetaMessagesCountTokensPost4XX", BetaMessagesCountTokensPost4XX), + orElse: unexpectedStatus + })) + ), + "betaListFilesV1FilesGet": (options) => + HttpClientRequest.get(`/v1/files?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "before_id": options?.params?.["before_id"] as any, + "after_id": options?.params?.["after_id"] as any, + "limit": options?.params?.["limit"] as any, + "scope_id": options?.params?.["scope_id"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListFilesV1FilesGet200), + "4xx": decodeError("BetaListFilesV1FilesGet4XX", BetaListFilesV1FilesGet4XX), + orElse: unexpectedStatus + })) + ), + "betaUploadFileV1FilesPost": (options) => + HttpClientRequest.post(`/v1/files?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined + }), + HttpClientRequest.bodyFormData(options.payload as any), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUploadFileV1FilesPost200), + "4xx": decodeError("BetaUploadFileV1FilesPost4XX", BetaUploadFileV1FilesPost4XX), + orElse: unexpectedStatus + })) + ), + "betaGetFileMetadataV1FilesFileIdGet": (fileId, options) => + HttpClientRequest.get(`/v1/files/${fileId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetFileMetadataV1FilesFileIdGet200), + "4xx": decodeError("BetaGetFileMetadataV1FilesFileIdGet4XX", BetaGetFileMetadataV1FilesFileIdGet4XX), + orElse: unexpectedStatus + })) + ), + "betaDeleteFileV1FilesFileIdDelete": (fileId, options) => + HttpClientRequest.delete(`/v1/files/${fileId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaDeleteFileV1FilesFileIdDelete200), + "4xx": decodeError("BetaDeleteFileV1FilesFileIdDelete4XX", BetaDeleteFileV1FilesFileIdDelete4XX), + orElse: unexpectedStatus + })) + ), + "betaDownloadFileV1FilesFileIdContentGet": (fileId, options) => + HttpClientRequest.get(`/v1/files/${fileId}/content?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + orElse: unexpectedStatus + })) + ), + "betaDownloadFileV1FilesFileIdContentGetStream": (fileId, options) => + HttpClientRequest.get(`/v1/files/${fileId}/content?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + binaryRequest + ), + "betaListSkillsV1SkillsGet": (options) => + HttpClientRequest.get(`/v1/skills?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "page": options?.params?.["page"] as any, + "limit": options?.params?.["limit"] as any, + "source": options?.params?.["source"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListSkillsV1SkillsGet200), + "4xx": decodeError("BetaListSkillsV1SkillsGet4XX", BetaListSkillsV1SkillsGet4XX), + orElse: unexpectedStatus + })) + ), + "betaCreateSkillV1SkillsPost": (options) => + HttpClientRequest.post(`/v1/skills?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined + }), + HttpClientRequest.bodyFormData(options.payload as any), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateSkillV1SkillsPost200), + "4xx": decodeError("BetaCreateSkillV1SkillsPost4XX", BetaCreateSkillV1SkillsPost4XX), + orElse: unexpectedStatus + })) + ), + "betaGetSkillV1SkillsSkillIdGet": (skillId, options) => + HttpClientRequest.get(`/v1/skills/${skillId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetSkillV1SkillsSkillIdGet200), + "4xx": decodeError("BetaGetSkillV1SkillsSkillIdGet4XX", BetaGetSkillV1SkillsSkillIdGet4XX), + orElse: unexpectedStatus + })) + ), + "betaDeleteSkillV1SkillsSkillIdDelete": (skillId, options) => + HttpClientRequest.delete(`/v1/skills/${skillId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaDeleteSkillV1SkillsSkillIdDelete200), + "4xx": decodeError("BetaDeleteSkillV1SkillsSkillIdDelete4XX", BetaDeleteSkillV1SkillsSkillIdDelete4XX), + orElse: unexpectedStatus + })) + ), + "betaListSkillVersionsV1SkillsSkillIdVersionsGet": (skillId, options) => + HttpClientRequest.get(`/v1/skills/${skillId}/versions?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "page": options?.params?.["page"] as any, + "limit": options?.params?.["limit"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListSkillVersionsV1SkillsSkillIdVersionsGet200), + "4xx": decodeError( + "BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX", + BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX + ), + orElse: unexpectedStatus + })) + ), + "betaCreateSkillVersionV1SkillsSkillIdVersionsPost": (skillId, options) => + HttpClientRequest.post(`/v1/skills/${skillId}/versions?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined + }), + HttpClientRequest.bodyFormData(options.payload as any), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateSkillVersionV1SkillsSkillIdVersionsPost200), + "4xx": decodeError( + "BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX", + BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX + ), + orElse: unexpectedStatus + })) + ), + "betaGetSkillVersionV1SkillsSkillIdVersionsVersionGet": (skillId, version, options) => + HttpClientRequest.get(`/v1/skills/${skillId}/versions/${version}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet200), + "4xx": decodeError( + "BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX", + BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX + ), + orElse: unexpectedStatus + })) + ), + "betaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete": (skillId, version, options) => + HttpClientRequest.delete(`/v1/skills/${skillId}/versions/${version}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete200), + "4xx": decodeError( + "BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX", + BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX + ), + orElse: unexpectedStatus + })) + ), + "betaDownloadSkillVersionContentV1SkillsSkillIdVersionsVersionContentGet": (skillId, version, options) => + HttpClientRequest.get(`/v1/skills/${skillId}/versions/${version}/content?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + orElse: unexpectedStatus + })) + ), + "betaListEnvironmentsV1EnvironmentsGet": (options) => + HttpClientRequest.get(`/v1/environments?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "include_archived": options?.params?.["include_archived"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListEnvironmentsV1EnvironmentsGet200), + "4xx": decodeError("BetaListEnvironmentsV1EnvironmentsGet4XX", BetaListEnvironmentsV1EnvironmentsGet4XX), + orElse: unexpectedStatus + })) + ), + "betaCreateEnvironmentV1EnvironmentsPost": (options) => + HttpClientRequest.post(`/v1/environments?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateEnvironmentV1EnvironmentsPost200), + "4xx": decodeError("BetaCreateEnvironmentV1EnvironmentsPost4XX", BetaCreateEnvironmentV1EnvironmentsPost4XX), + orElse: unexpectedStatus + })) + ), + "betaGetEnvironmentV1EnvironmentsEnvironmentIdGet": (environmentId, options) => + HttpClientRequest.get(`/v1/environments/${environmentId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetEnvironmentV1EnvironmentsEnvironmentIdGet200), + "4xx": decodeError( + "BetaGetEnvironmentV1EnvironmentsEnvironmentIdGet4XX", + BetaGetEnvironmentV1EnvironmentsEnvironmentIdGet4XX + ), + orElse: unexpectedStatus + })) + ), + "betaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost": (environmentId, options) => + HttpClientRequest.post(`/v1/environments/${environmentId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost200), + "4xx": decodeError( + "BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost4XX", + BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost4XX + ), + orElse: unexpectedStatus + })) + ), + "betaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete": (environmentId, options) => + HttpClientRequest.delete(`/v1/environments/${environmentId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete200), + "4xx": decodeError( + "BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete4XX", + BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete4XX + ), + orElse: unexpectedStatus + })) + ), + "betaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost": (environmentId, options) => + HttpClientRequest.post(`/v1/environments/${environmentId}/archive?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost200), + "4xx": decodeError( + "BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost4XX", + BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost4XX + ), + orElse: unexpectedStatus + })) + ), + "betaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet": (environmentId, options) => + HttpClientRequest.get(`/v1/environments/${environmentId}/work/stats?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "authorization": options?.params?.["authorization"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet200), + "4xx": decodeError( + "BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet4XX", + BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet4XX + ), + orElse: unexpectedStatus + })) + ), + "betaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet": (environmentId, options) => + HttpClientRequest.get(`/v1/environments/${environmentId}/work/poll?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "block_ms": options?.params?.["block_ms"] as any, + "reclaim_older_than_ms": options?.params?.["reclaim_older_than_ms"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "Anthropic-Worker-ID": options?.params?.["Anthropic-Worker-ID"] ?? undefined, + "authorization": options?.params?.["authorization"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet200), + "4xx": decodeError( + "BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet4XX", + BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet4XX + ), + orElse: unexpectedStatus + })) + ), + "betaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost": (environmentId, workId, options) => + HttpClientRequest.post(`/v1/environments/${environmentId}/work/${workId}/ack?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "authorization": options?.params?.["authorization"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost200), + "4xx": decodeError( + "BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost4XX", + BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost4XX + ), + orElse: unexpectedStatus + })) + ), + "betaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost": (environmentId, workId, options) => + HttpClientRequest.post(`/v1/environments/${environmentId}/work/${workId}/heartbeat?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "desired_ttl_seconds": options?.params?.["desired_ttl_seconds"] as any, + "expected_last_heartbeat": options?.params?.["expected_last_heartbeat"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "authorization": options?.params?.["authorization"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost200), + "4xx": decodeError( + "BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost4XX", + BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost4XX + ), + orElse: unexpectedStatus + })) + ), + "betaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost": (environmentId, workId, options) => + HttpClientRequest.post(`/v1/environments/${environmentId}/work/${workId}/stop?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "authorization": options.params?.["authorization"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost200), + "4xx": decodeError( + "BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost4XX", + BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost4XX + ), + orElse: unexpectedStatus + })) + ), + "betaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet": (environmentId, workId, options) => + HttpClientRequest.get(`/v1/environments/${environmentId}/work/${workId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet200), + "4xx": decodeError( + "BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet4XX", + BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet4XX + ), + orElse: unexpectedStatus + })) + ), + "betaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost": (environmentId, workId, options) => + HttpClientRequest.post(`/v1/environments/${environmentId}/work/${workId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost200), + "4xx": decodeError( + "BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost4XX", + BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost4XX + ), + orElse: unexpectedStatus + })) + ), + "betaListWorkV1EnvironmentsEnvironmentIdWorkGet": (environmentId, options) => + HttpClientRequest.get(`/v1/environments/${environmentId}/work?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any + }), + HttpClientRequest.setHeaders({ + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "authorization": options?.params?.["authorization"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListWorkV1EnvironmentsEnvironmentIdWorkGet200), + "4xx": decodeError( + "BetaListWorkV1EnvironmentsEnvironmentIdWorkGet4XX", + BetaListWorkV1EnvironmentsEnvironmentIdWorkGet4XX + ), + orElse: unexpectedStatus + })) + ), + "BetaListMemories": (memoryStoreId, options) => + HttpClientRequest.get(`/v1/memory_stores/${memoryStoreId}/memories?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "path_prefix": options?.params?.["path_prefix"] as any, + "depth": options?.params?.["depth"] as any, + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "view": options?.params?.["view"] as any + }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListMemories200), + "400": decodeError("BetaListMemories400", BetaListMemories400), + "401": decodeError("BetaListMemories401", BetaListMemories401), + "403": decodeError("BetaListMemories403", BetaListMemories403), + "404": decodeError("BetaListMemories404", BetaListMemories404), + "408": decodeError("BetaListMemories408", BetaListMemories408), + "409": decodeError("BetaListMemories409", BetaListMemories409), + "412": decodeError("BetaListMemories412", BetaListMemories412), + "413": decodeError("BetaListMemories413", BetaListMemories413), + "429": decodeError("BetaListMemories429", BetaListMemories429), + "431": decodeError("BetaListMemories431", BetaListMemories431), + "499": decodeError("BetaListMemories499", BetaListMemories499), + "500": decodeError("BetaListMemories500", BetaListMemories500), + "501": decodeError("BetaListMemories501", BetaListMemories501), + "503": decodeError("BetaListMemories503", BetaListMemories503), + "504": decodeError("BetaListMemories504", BetaListMemories504), + orElse: unexpectedStatus + })) + ), + "BetaCreateMemory": (memoryStoreId, options) => + HttpClientRequest.post(`/v1/memory_stores/${memoryStoreId}/memories?beta=true`).pipe( + HttpClientRequest.setUrlParams({ "view": options.params?.["view"] as any }), + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateMemory200), + "400": decodeError("BetaCreateMemory400", BetaCreateMemory400), + "401": decodeError("BetaCreateMemory401", BetaCreateMemory401), + "403": decodeError("BetaCreateMemory403", BetaCreateMemory403), + "404": decodeError("BetaCreateMemory404", BetaCreateMemory404), + "408": decodeError("BetaCreateMemory408", BetaCreateMemory408), + "409": decodeError("BetaCreateMemory409", BetaCreateMemory409), + "412": decodeError("BetaCreateMemory412", BetaCreateMemory412), + "413": decodeError("BetaCreateMemory413", BetaCreateMemory413), + "429": decodeError("BetaCreateMemory429", BetaCreateMemory429), + "431": decodeError("BetaCreateMemory431", BetaCreateMemory431), + "499": decodeError("BetaCreateMemory499", BetaCreateMemory499), + "500": decodeError("BetaCreateMemory500", BetaCreateMemory500), + "501": decodeError("BetaCreateMemory501", BetaCreateMemory501), + "503": decodeError("BetaCreateMemory503", BetaCreateMemory503), + "504": decodeError("BetaCreateMemory504", BetaCreateMemory504), + orElse: unexpectedStatus + })) + ), + "BetaGetMemory": (memoryStoreId, memoryId, options) => + HttpClientRequest.get(`/v1/memory_stores/${memoryStoreId}/memories/${memoryId}?beta=true`).pipe( + HttpClientRequest.setUrlParams({ "view": options?.params?.["view"] as any }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetMemory200), + "400": decodeError("BetaGetMemory400", BetaGetMemory400), + "401": decodeError("BetaGetMemory401", BetaGetMemory401), + "403": decodeError("BetaGetMemory403", BetaGetMemory403), + "404": decodeError("BetaGetMemory404", BetaGetMemory404), + "408": decodeError("BetaGetMemory408", BetaGetMemory408), + "409": decodeError("BetaGetMemory409", BetaGetMemory409), + "412": decodeError("BetaGetMemory412", BetaGetMemory412), + "413": decodeError("BetaGetMemory413", BetaGetMemory413), + "429": decodeError("BetaGetMemory429", BetaGetMemory429), + "431": decodeError("BetaGetMemory431", BetaGetMemory431), + "499": decodeError("BetaGetMemory499", BetaGetMemory499), + "500": decodeError("BetaGetMemory500", BetaGetMemory500), + "501": decodeError("BetaGetMemory501", BetaGetMemory501), + "503": decodeError("BetaGetMemory503", BetaGetMemory503), + "504": decodeError("BetaGetMemory504", BetaGetMemory504), + orElse: unexpectedStatus + })) + ), + "BetaUpdateMemory": (memoryStoreId, memoryId, options) => + HttpClientRequest.post(`/v1/memory_stores/${memoryStoreId}/memories/${memoryId}?beta=true`).pipe( + HttpClientRequest.setUrlParams({ "view": options.params?.["view"] as any }), + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateMemory200), + "400": decodeError("BetaUpdateMemory400", BetaUpdateMemory400), + "401": decodeError("BetaUpdateMemory401", BetaUpdateMemory401), + "403": decodeError("BetaUpdateMemory403", BetaUpdateMemory403), + "404": decodeError("BetaUpdateMemory404", BetaUpdateMemory404), + "408": decodeError("BetaUpdateMemory408", BetaUpdateMemory408), + "409": decodeError("BetaUpdateMemory409", BetaUpdateMemory409), + "412": decodeError("BetaUpdateMemory412", BetaUpdateMemory412), + "413": decodeError("BetaUpdateMemory413", BetaUpdateMemory413), + "429": decodeError("BetaUpdateMemory429", BetaUpdateMemory429), + "431": decodeError("BetaUpdateMemory431", BetaUpdateMemory431), + "499": decodeError("BetaUpdateMemory499", BetaUpdateMemory499), + "500": decodeError("BetaUpdateMemory500", BetaUpdateMemory500), + "501": decodeError("BetaUpdateMemory501", BetaUpdateMemory501), + "503": decodeError("BetaUpdateMemory503", BetaUpdateMemory503), + "504": decodeError("BetaUpdateMemory504", BetaUpdateMemory504), + orElse: unexpectedStatus + })) + ), + "BetaDeleteMemory": (memoryStoreId, memoryId, options) => + HttpClientRequest.delete(`/v1/memory_stores/${memoryStoreId}/memories/${memoryId}?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "expected_content_sha256": options?.params?.["expected_content_sha256"] as any + }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaDeleteMemory200), + "400": decodeError("BetaDeleteMemory400", BetaDeleteMemory400), + "401": decodeError("BetaDeleteMemory401", BetaDeleteMemory401), + "403": decodeError("BetaDeleteMemory403", BetaDeleteMemory403), + "404": decodeError("BetaDeleteMemory404", BetaDeleteMemory404), + "408": decodeError("BetaDeleteMemory408", BetaDeleteMemory408), + "409": decodeError("BetaDeleteMemory409", BetaDeleteMemory409), + "412": decodeError("BetaDeleteMemory412", BetaDeleteMemory412), + "413": decodeError("BetaDeleteMemory413", BetaDeleteMemory413), + "429": decodeError("BetaDeleteMemory429", BetaDeleteMemory429), + "431": decodeError("BetaDeleteMemory431", BetaDeleteMemory431), + "499": decodeError("BetaDeleteMemory499", BetaDeleteMemory499), + "500": decodeError("BetaDeleteMemory500", BetaDeleteMemory500), + "501": decodeError("BetaDeleteMemory501", BetaDeleteMemory501), + "503": decodeError("BetaDeleteMemory503", BetaDeleteMemory503), + "504": decodeError("BetaDeleteMemory504", BetaDeleteMemory504), + orElse: unexpectedStatus + })) + ), + "BetaListMemoryVersions": (memoryStoreId, options) => + HttpClientRequest.get(`/v1/memory_stores/${memoryStoreId}/memory_versions?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "memory_id": options?.params?.["memory_id"] as any, + "session_id": options?.params?.["session_id"] as any, + "api_key_id": options?.params?.["api_key_id"] as any, + "operation": options?.params?.["operation"] as any, + "created_at[gte]": options?.params?.["created_at[gte]"] as any, + "created_at[lte]": options?.params?.["created_at[lte]"] as any, + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "view": options?.params?.["view"] as any + }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListMemoryVersions200), + "400": decodeError("BetaListMemoryVersions400", BetaListMemoryVersions400), + "401": decodeError("BetaListMemoryVersions401", BetaListMemoryVersions401), + "403": decodeError("BetaListMemoryVersions403", BetaListMemoryVersions403), + "404": decodeError("BetaListMemoryVersions404", BetaListMemoryVersions404), + "408": decodeError("BetaListMemoryVersions408", BetaListMemoryVersions408), + "409": decodeError("BetaListMemoryVersions409", BetaListMemoryVersions409), + "412": decodeError("BetaListMemoryVersions412", BetaListMemoryVersions412), + "413": decodeError("BetaListMemoryVersions413", BetaListMemoryVersions413), + "429": decodeError("BetaListMemoryVersions429", BetaListMemoryVersions429), + "431": decodeError("BetaListMemoryVersions431", BetaListMemoryVersions431), + "499": decodeError("BetaListMemoryVersions499", BetaListMemoryVersions499), + "500": decodeError("BetaListMemoryVersions500", BetaListMemoryVersions500), + "501": decodeError("BetaListMemoryVersions501", BetaListMemoryVersions501), + "503": decodeError("BetaListMemoryVersions503", BetaListMemoryVersions503), + "504": decodeError("BetaListMemoryVersions504", BetaListMemoryVersions504), + orElse: unexpectedStatus + })) + ), + "BetaGetMemoryVersion": (memoryStoreId, memoryVersionId, options) => + HttpClientRequest.get(`/v1/memory_stores/${memoryStoreId}/memory_versions/${memoryVersionId}?beta=true`).pipe( + HttpClientRequest.setUrlParams({ "view": options?.params?.["view"] as any }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetMemoryVersion200), + "400": decodeError("BetaGetMemoryVersion400", BetaGetMemoryVersion400), + "401": decodeError("BetaGetMemoryVersion401", BetaGetMemoryVersion401), + "403": decodeError("BetaGetMemoryVersion403", BetaGetMemoryVersion403), + "404": decodeError("BetaGetMemoryVersion404", BetaGetMemoryVersion404), + "408": decodeError("BetaGetMemoryVersion408", BetaGetMemoryVersion408), + "409": decodeError("BetaGetMemoryVersion409", BetaGetMemoryVersion409), + "412": decodeError("BetaGetMemoryVersion412", BetaGetMemoryVersion412), + "413": decodeError("BetaGetMemoryVersion413", BetaGetMemoryVersion413), + "429": decodeError("BetaGetMemoryVersion429", BetaGetMemoryVersion429), + "431": decodeError("BetaGetMemoryVersion431", BetaGetMemoryVersion431), + "499": decodeError("BetaGetMemoryVersion499", BetaGetMemoryVersion499), + "500": decodeError("BetaGetMemoryVersion500", BetaGetMemoryVersion500), + "501": decodeError("BetaGetMemoryVersion501", BetaGetMemoryVersion501), + "503": decodeError("BetaGetMemoryVersion503", BetaGetMemoryVersion503), + "504": decodeError("BetaGetMemoryVersion504", BetaGetMemoryVersion504), + orElse: unexpectedStatus + })) + ), + "BetaRedactMemoryVersion": (memoryStoreId, memoryVersionId, options) => + HttpClientRequest.post(`/v1/memory_stores/${memoryStoreId}/memory_versions/${memoryVersionId}/redact?beta=true`) + .pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaRedactMemoryVersion200), + "400": decodeError("BetaRedactMemoryVersion400", BetaRedactMemoryVersion400), + "401": decodeError("BetaRedactMemoryVersion401", BetaRedactMemoryVersion401), + "403": decodeError("BetaRedactMemoryVersion403", BetaRedactMemoryVersion403), + "404": decodeError("BetaRedactMemoryVersion404", BetaRedactMemoryVersion404), + "408": decodeError("BetaRedactMemoryVersion408", BetaRedactMemoryVersion408), + "409": decodeError("BetaRedactMemoryVersion409", BetaRedactMemoryVersion409), + "412": decodeError("BetaRedactMemoryVersion412", BetaRedactMemoryVersion412), + "413": decodeError("BetaRedactMemoryVersion413", BetaRedactMemoryVersion413), + "429": decodeError("BetaRedactMemoryVersion429", BetaRedactMemoryVersion429), + "431": decodeError("BetaRedactMemoryVersion431", BetaRedactMemoryVersion431), + "499": decodeError("BetaRedactMemoryVersion499", BetaRedactMemoryVersion499), + "500": decodeError("BetaRedactMemoryVersion500", BetaRedactMemoryVersion500), + "501": decodeError("BetaRedactMemoryVersion501", BetaRedactMemoryVersion501), + "503": decodeError("BetaRedactMemoryVersion503", BetaRedactMemoryVersion503), + "504": decodeError("BetaRedactMemoryVersion504", BetaRedactMemoryVersion504), + orElse: unexpectedStatus + })) + ), + "BetaListMemoryStores": (options) => + HttpClientRequest.get(`/v1/memory_stores?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "include_archived": options?.params?.["include_archived"] as any, + "created_at[gte]": options?.params?.["created_at[gte]"] as any, + "created_at[lte]": options?.params?.["created_at[lte]"] as any + }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListMemoryStores200), + "400": decodeError("BetaListMemoryStores400", BetaListMemoryStores400), + "401": decodeError("BetaListMemoryStores401", BetaListMemoryStores401), + "403": decodeError("BetaListMemoryStores403", BetaListMemoryStores403), + "404": decodeError("BetaListMemoryStores404", BetaListMemoryStores404), + "408": decodeError("BetaListMemoryStores408", BetaListMemoryStores408), + "409": decodeError("BetaListMemoryStores409", BetaListMemoryStores409), + "412": decodeError("BetaListMemoryStores412", BetaListMemoryStores412), + "413": decodeError("BetaListMemoryStores413", BetaListMemoryStores413), + "429": decodeError("BetaListMemoryStores429", BetaListMemoryStores429), + "431": decodeError("BetaListMemoryStores431", BetaListMemoryStores431), + "499": decodeError("BetaListMemoryStores499", BetaListMemoryStores499), + "500": decodeError("BetaListMemoryStores500", BetaListMemoryStores500), + "501": decodeError("BetaListMemoryStores501", BetaListMemoryStores501), + "503": decodeError("BetaListMemoryStores503", BetaListMemoryStores503), + "504": decodeError("BetaListMemoryStores504", BetaListMemoryStores504), + orElse: unexpectedStatus + })) + ), + "BetaCreateMemoryStore": (options) => + HttpClientRequest.post(`/v1/memory_stores?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateMemoryStore200), + "400": decodeError("BetaCreateMemoryStore400", BetaCreateMemoryStore400), + "401": decodeError("BetaCreateMemoryStore401", BetaCreateMemoryStore401), + "403": decodeError("BetaCreateMemoryStore403", BetaCreateMemoryStore403), + "404": decodeError("BetaCreateMemoryStore404", BetaCreateMemoryStore404), + "408": decodeError("BetaCreateMemoryStore408", BetaCreateMemoryStore408), + "409": decodeError("BetaCreateMemoryStore409", BetaCreateMemoryStore409), + "412": decodeError("BetaCreateMemoryStore412", BetaCreateMemoryStore412), + "413": decodeError("BetaCreateMemoryStore413", BetaCreateMemoryStore413), + "429": decodeError("BetaCreateMemoryStore429", BetaCreateMemoryStore429), + "431": decodeError("BetaCreateMemoryStore431", BetaCreateMemoryStore431), + "499": decodeError("BetaCreateMemoryStore499", BetaCreateMemoryStore499), + "500": decodeError("BetaCreateMemoryStore500", BetaCreateMemoryStore500), + "501": decodeError("BetaCreateMemoryStore501", BetaCreateMemoryStore501), + "503": decodeError("BetaCreateMemoryStore503", BetaCreateMemoryStore503), + "504": decodeError("BetaCreateMemoryStore504", BetaCreateMemoryStore504), + orElse: unexpectedStatus + })) + ), + "BetaGetMemoryStore": (memoryStoreId, options) => + HttpClientRequest.get(`/v1/memory_stores/${memoryStoreId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetMemoryStore200), + "400": decodeError("BetaGetMemoryStore400", BetaGetMemoryStore400), + "401": decodeError("BetaGetMemoryStore401", BetaGetMemoryStore401), + "403": decodeError("BetaGetMemoryStore403", BetaGetMemoryStore403), + "404": decodeError("BetaGetMemoryStore404", BetaGetMemoryStore404), + "408": decodeError("BetaGetMemoryStore408", BetaGetMemoryStore408), + "409": decodeError("BetaGetMemoryStore409", BetaGetMemoryStore409), + "412": decodeError("BetaGetMemoryStore412", BetaGetMemoryStore412), + "413": decodeError("BetaGetMemoryStore413", BetaGetMemoryStore413), + "429": decodeError("BetaGetMemoryStore429", BetaGetMemoryStore429), + "431": decodeError("BetaGetMemoryStore431", BetaGetMemoryStore431), + "499": decodeError("BetaGetMemoryStore499", BetaGetMemoryStore499), + "500": decodeError("BetaGetMemoryStore500", BetaGetMemoryStore500), + "501": decodeError("BetaGetMemoryStore501", BetaGetMemoryStore501), + "503": decodeError("BetaGetMemoryStore503", BetaGetMemoryStore503), + "504": decodeError("BetaGetMemoryStore504", BetaGetMemoryStore504), + orElse: unexpectedStatus + })) + ), + "BetaUpdateMemoryStore": (memoryStoreId, options) => + HttpClientRequest.post(`/v1/memory_stores/${memoryStoreId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateMemoryStore200), + "400": decodeError("BetaUpdateMemoryStore400", BetaUpdateMemoryStore400), + "401": decodeError("BetaUpdateMemoryStore401", BetaUpdateMemoryStore401), + "403": decodeError("BetaUpdateMemoryStore403", BetaUpdateMemoryStore403), + "404": decodeError("BetaUpdateMemoryStore404", BetaUpdateMemoryStore404), + "408": decodeError("BetaUpdateMemoryStore408", BetaUpdateMemoryStore408), + "409": decodeError("BetaUpdateMemoryStore409", BetaUpdateMemoryStore409), + "412": decodeError("BetaUpdateMemoryStore412", BetaUpdateMemoryStore412), + "413": decodeError("BetaUpdateMemoryStore413", BetaUpdateMemoryStore413), + "429": decodeError("BetaUpdateMemoryStore429", BetaUpdateMemoryStore429), + "431": decodeError("BetaUpdateMemoryStore431", BetaUpdateMemoryStore431), + "499": decodeError("BetaUpdateMemoryStore499", BetaUpdateMemoryStore499), + "500": decodeError("BetaUpdateMemoryStore500", BetaUpdateMemoryStore500), + "501": decodeError("BetaUpdateMemoryStore501", BetaUpdateMemoryStore501), + "503": decodeError("BetaUpdateMemoryStore503", BetaUpdateMemoryStore503), + "504": decodeError("BetaUpdateMemoryStore504", BetaUpdateMemoryStore504), + orElse: unexpectedStatus + })) + ), + "BetaDeleteMemoryStore": (memoryStoreId, options) => + HttpClientRequest.delete(`/v1/memory_stores/${memoryStoreId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaDeleteMemoryStore200), + "400": decodeError("BetaDeleteMemoryStore400", BetaDeleteMemoryStore400), + "401": decodeError("BetaDeleteMemoryStore401", BetaDeleteMemoryStore401), + "403": decodeError("BetaDeleteMemoryStore403", BetaDeleteMemoryStore403), + "404": decodeError("BetaDeleteMemoryStore404", BetaDeleteMemoryStore404), + "408": decodeError("BetaDeleteMemoryStore408", BetaDeleteMemoryStore408), + "409": decodeError("BetaDeleteMemoryStore409", BetaDeleteMemoryStore409), + "412": decodeError("BetaDeleteMemoryStore412", BetaDeleteMemoryStore412), + "413": decodeError("BetaDeleteMemoryStore413", BetaDeleteMemoryStore413), + "429": decodeError("BetaDeleteMemoryStore429", BetaDeleteMemoryStore429), + "431": decodeError("BetaDeleteMemoryStore431", BetaDeleteMemoryStore431), + "499": decodeError("BetaDeleteMemoryStore499", BetaDeleteMemoryStore499), + "500": decodeError("BetaDeleteMemoryStore500", BetaDeleteMemoryStore500), + "501": decodeError("BetaDeleteMemoryStore501", BetaDeleteMemoryStore501), + "503": decodeError("BetaDeleteMemoryStore503", BetaDeleteMemoryStore503), + "504": decodeError("BetaDeleteMemoryStore504", BetaDeleteMemoryStore504), + orElse: unexpectedStatus + })) + ), + "BetaArchiveMemoryStore": (memoryStoreId, options) => + HttpClientRequest.post(`/v1/memory_stores/${memoryStoreId}/archive?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaArchiveMemoryStore200), + "400": decodeError("BetaArchiveMemoryStore400", BetaArchiveMemoryStore400), + "401": decodeError("BetaArchiveMemoryStore401", BetaArchiveMemoryStore401), + "403": decodeError("BetaArchiveMemoryStore403", BetaArchiveMemoryStore403), + "404": decodeError("BetaArchiveMemoryStore404", BetaArchiveMemoryStore404), + "408": decodeError("BetaArchiveMemoryStore408", BetaArchiveMemoryStore408), + "409": decodeError("BetaArchiveMemoryStore409", BetaArchiveMemoryStore409), + "412": decodeError("BetaArchiveMemoryStore412", BetaArchiveMemoryStore412), + "413": decodeError("BetaArchiveMemoryStore413", BetaArchiveMemoryStore413), + "429": decodeError("BetaArchiveMemoryStore429", BetaArchiveMemoryStore429), + "431": decodeError("BetaArchiveMemoryStore431", BetaArchiveMemoryStore431), + "499": decodeError("BetaArchiveMemoryStore499", BetaArchiveMemoryStore499), + "500": decodeError("BetaArchiveMemoryStore500", BetaArchiveMemoryStore500), + "501": decodeError("BetaArchiveMemoryStore501", BetaArchiveMemoryStore501), + "503": decodeError("BetaArchiveMemoryStore503", BetaArchiveMemoryStore503), + "504": decodeError("BetaArchiveMemoryStore504", BetaArchiveMemoryStore504), + orElse: unexpectedStatus + })) + ), + "BetaListUserProfiles": (options) => + HttpClientRequest.get(`/v1/user_profiles?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "order": options?.params?.["order"] as any + }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListUserProfiles200), + "400": decodeError("BetaListUserProfiles400", BetaListUserProfiles400), + "401": decodeError("BetaListUserProfiles401", BetaListUserProfiles401), + "403": decodeError("BetaListUserProfiles403", BetaListUserProfiles403), + "404": decodeError("BetaListUserProfiles404", BetaListUserProfiles404), + "408": decodeError("BetaListUserProfiles408", BetaListUserProfiles408), + "409": decodeError("BetaListUserProfiles409", BetaListUserProfiles409), + "412": decodeError("BetaListUserProfiles412", BetaListUserProfiles412), + "413": decodeError("BetaListUserProfiles413", BetaListUserProfiles413), + "429": decodeError("BetaListUserProfiles429", BetaListUserProfiles429), + "431": decodeError("BetaListUserProfiles431", BetaListUserProfiles431), + "499": decodeError("BetaListUserProfiles499", BetaListUserProfiles499), + "500": decodeError("BetaListUserProfiles500", BetaListUserProfiles500), + "501": decodeError("BetaListUserProfiles501", BetaListUserProfiles501), + "503": decodeError("BetaListUserProfiles503", BetaListUserProfiles503), + "504": decodeError("BetaListUserProfiles504", BetaListUserProfiles504), + orElse: unexpectedStatus + })) + ), + "BetaCreateUserProfile": (options) => + HttpClientRequest.post(`/v1/user_profiles?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateUserProfile200), + "400": decodeError("BetaCreateUserProfile400", BetaCreateUserProfile400), + "401": decodeError("BetaCreateUserProfile401", BetaCreateUserProfile401), + "403": decodeError("BetaCreateUserProfile403", BetaCreateUserProfile403), + "404": decodeError("BetaCreateUserProfile404", BetaCreateUserProfile404), + "408": decodeError("BetaCreateUserProfile408", BetaCreateUserProfile408), + "409": decodeError("BetaCreateUserProfile409", BetaCreateUserProfile409), + "412": decodeError("BetaCreateUserProfile412", BetaCreateUserProfile412), + "413": decodeError("BetaCreateUserProfile413", BetaCreateUserProfile413), + "429": decodeError("BetaCreateUserProfile429", BetaCreateUserProfile429), + "431": decodeError("BetaCreateUserProfile431", BetaCreateUserProfile431), + "499": decodeError("BetaCreateUserProfile499", BetaCreateUserProfile499), + "500": decodeError("BetaCreateUserProfile500", BetaCreateUserProfile500), + "501": decodeError("BetaCreateUserProfile501", BetaCreateUserProfile501), + "503": decodeError("BetaCreateUserProfile503", BetaCreateUserProfile503), + "504": decodeError("BetaCreateUserProfile504", BetaCreateUserProfile504), + orElse: unexpectedStatus + })) + ), + "BetaGetUserProfile": (userProfileId, options) => + HttpClientRequest.get(`/v1/user_profiles/${userProfileId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(ModelsGet200), - "4xx": decodeError("ModelsGet4XX", ModelsGet4XX), + "2xx": decodeSuccess(BetaGetUserProfile200), + "400": decodeError("BetaGetUserProfile400", BetaGetUserProfile400), + "401": decodeError("BetaGetUserProfile401", BetaGetUserProfile401), + "403": decodeError("BetaGetUserProfile403", BetaGetUserProfile403), + "404": decodeError("BetaGetUserProfile404", BetaGetUserProfile404), + "408": decodeError("BetaGetUserProfile408", BetaGetUserProfile408), + "409": decodeError("BetaGetUserProfile409", BetaGetUserProfile409), + "412": decodeError("BetaGetUserProfile412", BetaGetUserProfile412), + "413": decodeError("BetaGetUserProfile413", BetaGetUserProfile413), + "429": decodeError("BetaGetUserProfile429", BetaGetUserProfile429), + "431": decodeError("BetaGetUserProfile431", BetaGetUserProfile431), + "499": decodeError("BetaGetUserProfile499", BetaGetUserProfile499), + "500": decodeError("BetaGetUserProfile500", BetaGetUserProfile500), + "501": decodeError("BetaGetUserProfile501", BetaGetUserProfile501), + "503": decodeError("BetaGetUserProfile503", BetaGetUserProfile503), + "504": decodeError("BetaGetUserProfile504", BetaGetUserProfile504), orElse: unexpectedStatus })) ), - "messageBatchesList": (options) => - HttpClientRequest.get(`/v1/messages/batches`).pipe( + "BetaUpdateUserProfile": (userProfileId, options) => + HttpClientRequest.post(`/v1/user_profiles/${userProfileId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateUserProfile200), + "400": decodeError("BetaUpdateUserProfile400", BetaUpdateUserProfile400), + "401": decodeError("BetaUpdateUserProfile401", BetaUpdateUserProfile401), + "403": decodeError("BetaUpdateUserProfile403", BetaUpdateUserProfile403), + "404": decodeError("BetaUpdateUserProfile404", BetaUpdateUserProfile404), + "408": decodeError("BetaUpdateUserProfile408", BetaUpdateUserProfile408), + "409": decodeError("BetaUpdateUserProfile409", BetaUpdateUserProfile409), + "412": decodeError("BetaUpdateUserProfile412", BetaUpdateUserProfile412), + "413": decodeError("BetaUpdateUserProfile413", BetaUpdateUserProfile413), + "429": decodeError("BetaUpdateUserProfile429", BetaUpdateUserProfile429), + "431": decodeError("BetaUpdateUserProfile431", BetaUpdateUserProfile431), + "499": decodeError("BetaUpdateUserProfile499", BetaUpdateUserProfile499), + "500": decodeError("BetaUpdateUserProfile500", BetaUpdateUserProfile500), + "501": decodeError("BetaUpdateUserProfile501", BetaUpdateUserProfile501), + "503": decodeError("BetaUpdateUserProfile503", BetaUpdateUserProfile503), + "504": decodeError("BetaUpdateUserProfile504", BetaUpdateUserProfile504), + orElse: unexpectedStatus + })) + ), + "BetaCreateEnrollmentUrl": (userProfileId, options) => + HttpClientRequest.post(`/v1/user_profiles/${userProfileId}/enrollment_url?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateEnrollmentUrl200), + "400": decodeError("BetaCreateEnrollmentUrl400", BetaCreateEnrollmentUrl400), + "401": decodeError("BetaCreateEnrollmentUrl401", BetaCreateEnrollmentUrl401), + "403": decodeError("BetaCreateEnrollmentUrl403", BetaCreateEnrollmentUrl403), + "404": decodeError("BetaCreateEnrollmentUrl404", BetaCreateEnrollmentUrl404), + "408": decodeError("BetaCreateEnrollmentUrl408", BetaCreateEnrollmentUrl408), + "409": decodeError("BetaCreateEnrollmentUrl409", BetaCreateEnrollmentUrl409), + "412": decodeError("BetaCreateEnrollmentUrl412", BetaCreateEnrollmentUrl412), + "413": decodeError("BetaCreateEnrollmentUrl413", BetaCreateEnrollmentUrl413), + "429": decodeError("BetaCreateEnrollmentUrl429", BetaCreateEnrollmentUrl429), + "431": decodeError("BetaCreateEnrollmentUrl431", BetaCreateEnrollmentUrl431), + "499": decodeError("BetaCreateEnrollmentUrl499", BetaCreateEnrollmentUrl499), + "500": decodeError("BetaCreateEnrollmentUrl500", BetaCreateEnrollmentUrl500), + "501": decodeError("BetaCreateEnrollmentUrl501", BetaCreateEnrollmentUrl501), + "503": decodeError("BetaCreateEnrollmentUrl503", BetaCreateEnrollmentUrl503), + "504": decodeError("BetaCreateEnrollmentUrl504", BetaCreateEnrollmentUrl504), + orElse: unexpectedStatus + })) + ), + "BetaListTunnels": (options) => + HttpClientRequest.get(`/v1/tunnels?beta=true`).pipe( HttpClientRequest.setUrlParams({ - "before_id": options?.params?.["before_id"] as any, - "after_id": options?.params?.["after_id"] as any, - "limit": options?.params?.["limit"] as any + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "include_archived": options?.params?.["include_archived"] as any }), HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(MessageBatchesList200), - "4xx": decodeError("MessageBatchesList4XX", MessageBatchesList4XX), + "2xx": decodeSuccess(BetaListTunnels200), + "400": decodeError("BetaListTunnels400", BetaListTunnels400), + "401": decodeError("BetaListTunnels401", BetaListTunnels401), + "403": decodeError("BetaListTunnels403", BetaListTunnels403), + "404": decodeError("BetaListTunnels404", BetaListTunnels404), + "408": decodeError("BetaListTunnels408", BetaListTunnels408), + "409": decodeError("BetaListTunnels409", BetaListTunnels409), + "412": decodeError("BetaListTunnels412", BetaListTunnels412), + "413": decodeError("BetaListTunnels413", BetaListTunnels413), + "429": decodeError("BetaListTunnels429", BetaListTunnels429), + "431": decodeError("BetaListTunnels431", BetaListTunnels431), + "499": decodeError("BetaListTunnels499", BetaListTunnels499), + "500": decodeError("BetaListTunnels500", BetaListTunnels500), + "501": decodeError("BetaListTunnels501", BetaListTunnels501), + "503": decodeError("BetaListTunnels503", BetaListTunnels503), + "504": decodeError("BetaListTunnels504", BetaListTunnels504), orElse: unexpectedStatus })) ), - "messageBatchesPost": (options) => - HttpClientRequest.post(`/v1/messages/batches`).pipe( - HttpClientRequest.setHeaders({ "anthropic-version": options.params?.["anthropic-version"] ?? undefined }), + "BetaCreateTunnel": (options) => + HttpClientRequest.post(`/v1/tunnels?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(MessageBatchesPost200), - "4xx": decodeError("MessageBatchesPost4XX", MessageBatchesPost4XX), + "2xx": decodeSuccess(BetaCreateTunnel200), + "400": decodeError("BetaCreateTunnel400", BetaCreateTunnel400), + "401": decodeError("BetaCreateTunnel401", BetaCreateTunnel401), + "403": decodeError("BetaCreateTunnel403", BetaCreateTunnel403), + "404": decodeError("BetaCreateTunnel404", BetaCreateTunnel404), + "408": decodeError("BetaCreateTunnel408", BetaCreateTunnel408), + "409": decodeError("BetaCreateTunnel409", BetaCreateTunnel409), + "412": decodeError("BetaCreateTunnel412", BetaCreateTunnel412), + "413": decodeError("BetaCreateTunnel413", BetaCreateTunnel413), + "429": decodeError("BetaCreateTunnel429", BetaCreateTunnel429), + "431": decodeError("BetaCreateTunnel431", BetaCreateTunnel431), + "499": decodeError("BetaCreateTunnel499", BetaCreateTunnel499), + "500": decodeError("BetaCreateTunnel500", BetaCreateTunnel500), + "501": decodeError("BetaCreateTunnel501", BetaCreateTunnel501), + "503": decodeError("BetaCreateTunnel503", BetaCreateTunnel503), + "504": decodeError("BetaCreateTunnel504", BetaCreateTunnel504), orElse: unexpectedStatus })) ), - "messageBatchesRetrieve": (messageBatchId, options) => - HttpClientRequest.get(`/v1/messages/batches/${messageBatchId}`).pipe( + "BetaGetTunnel": (tunnelId, options) => + HttpClientRequest.get(`/v1/tunnels/${tunnelId}?beta=true`).pipe( HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(MessageBatchesRetrieve200), - "4xx": decodeError("MessageBatchesRetrieve4XX", MessageBatchesRetrieve4XX), + "2xx": decodeSuccess(BetaGetTunnel200), + "400": decodeError("BetaGetTunnel400", BetaGetTunnel400), + "401": decodeError("BetaGetTunnel401", BetaGetTunnel401), + "403": decodeError("BetaGetTunnel403", BetaGetTunnel403), + "404": decodeError("BetaGetTunnel404", BetaGetTunnel404), + "408": decodeError("BetaGetTunnel408", BetaGetTunnel408), + "409": decodeError("BetaGetTunnel409", BetaGetTunnel409), + "412": decodeError("BetaGetTunnel412", BetaGetTunnel412), + "413": decodeError("BetaGetTunnel413", BetaGetTunnel413), + "429": decodeError("BetaGetTunnel429", BetaGetTunnel429), + "431": decodeError("BetaGetTunnel431", BetaGetTunnel431), + "499": decodeError("BetaGetTunnel499", BetaGetTunnel499), + "500": decodeError("BetaGetTunnel500", BetaGetTunnel500), + "501": decodeError("BetaGetTunnel501", BetaGetTunnel501), + "503": decodeError("BetaGetTunnel503", BetaGetTunnel503), + "504": decodeError("BetaGetTunnel504", BetaGetTunnel504), orElse: unexpectedStatus })) ), - "messageBatchesDelete": (messageBatchId, options) => - HttpClientRequest.delete(`/v1/messages/batches/${messageBatchId}`).pipe( + "BetaArchiveTunnel": (tunnelId, options) => + HttpClientRequest.post(`/v1/tunnels/${tunnelId}/archive?beta=true`).pipe( HttpClientRequest.setHeaders({ "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(MessageBatchesDelete200), - "4xx": decodeError("MessageBatchesDelete4XX", MessageBatchesDelete4XX), + "2xx": decodeSuccess(BetaArchiveTunnel200), + "400": decodeError("BetaArchiveTunnel400", BetaArchiveTunnel400), + "401": decodeError("BetaArchiveTunnel401", BetaArchiveTunnel401), + "403": decodeError("BetaArchiveTunnel403", BetaArchiveTunnel403), + "404": decodeError("BetaArchiveTunnel404", BetaArchiveTunnel404), + "408": decodeError("BetaArchiveTunnel408", BetaArchiveTunnel408), + "409": decodeError("BetaArchiveTunnel409", BetaArchiveTunnel409), + "412": decodeError("BetaArchiveTunnel412", BetaArchiveTunnel412), + "413": decodeError("BetaArchiveTunnel413", BetaArchiveTunnel413), + "429": decodeError("BetaArchiveTunnel429", BetaArchiveTunnel429), + "431": decodeError("BetaArchiveTunnel431", BetaArchiveTunnel431), + "499": decodeError("BetaArchiveTunnel499", BetaArchiveTunnel499), + "500": decodeError("BetaArchiveTunnel500", BetaArchiveTunnel500), + "501": decodeError("BetaArchiveTunnel501", BetaArchiveTunnel501), + "503": decodeError("BetaArchiveTunnel503", BetaArchiveTunnel503), + "504": decodeError("BetaArchiveTunnel504", BetaArchiveTunnel504), orElse: unexpectedStatus })) ), - "messageBatchesCancel": (messageBatchId, options) => - HttpClientRequest.post(`/v1/messages/batches/${messageBatchId}/cancel`).pipe( - HttpClientRequest.setHeaders({ "anthropic-version": options?.params?.["anthropic-version"] ?? undefined }), + "BetaRevealTunnelToken": (tunnelId, options) => + HttpClientRequest.post(`/v1/tunnels/${tunnelId}/reveal_token?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(MessageBatchesCancel200), - "4xx": decodeError("MessageBatchesCancel4XX", MessageBatchesCancel4XX), + "2xx": decodeSuccess(BetaRevealTunnelToken200), + "400": decodeError("BetaRevealTunnelToken400", BetaRevealTunnelToken400), + "401": decodeError("BetaRevealTunnelToken401", BetaRevealTunnelToken401), + "403": decodeError("BetaRevealTunnelToken403", BetaRevealTunnelToken403), + "404": decodeError("BetaRevealTunnelToken404", BetaRevealTunnelToken404), + "408": decodeError("BetaRevealTunnelToken408", BetaRevealTunnelToken408), + "409": decodeError("BetaRevealTunnelToken409", BetaRevealTunnelToken409), + "412": decodeError("BetaRevealTunnelToken412", BetaRevealTunnelToken412), + "413": decodeError("BetaRevealTunnelToken413", BetaRevealTunnelToken413), + "429": decodeError("BetaRevealTunnelToken429", BetaRevealTunnelToken429), + "431": decodeError("BetaRevealTunnelToken431", BetaRevealTunnelToken431), + "499": decodeError("BetaRevealTunnelToken499", BetaRevealTunnelToken499), + "500": decodeError("BetaRevealTunnelToken500", BetaRevealTunnelToken500), + "501": decodeError("BetaRevealTunnelToken501", BetaRevealTunnelToken501), + "503": decodeError("BetaRevealTunnelToken503", BetaRevealTunnelToken503), + "504": decodeError("BetaRevealTunnelToken504", BetaRevealTunnelToken504), orElse: unexpectedStatus })) ), - "messageBatchesResults": (messageBatchId, options) => - HttpClientRequest.get(`/v1/messages/batches/${messageBatchId}/results`).pipe( + "BetaRotateTunnelToken": (tunnelId, options) => + HttpClientRequest.post(`/v1/tunnels/${tunnelId}/rotate_token?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaRotateTunnelToken200), + "400": decodeError("BetaRotateTunnelToken400", BetaRotateTunnelToken400), + "401": decodeError("BetaRotateTunnelToken401", BetaRotateTunnelToken401), + "403": decodeError("BetaRotateTunnelToken403", BetaRotateTunnelToken403), + "404": decodeError("BetaRotateTunnelToken404", BetaRotateTunnelToken404), + "408": decodeError("BetaRotateTunnelToken408", BetaRotateTunnelToken408), + "409": decodeError("BetaRotateTunnelToken409", BetaRotateTunnelToken409), + "412": decodeError("BetaRotateTunnelToken412", BetaRotateTunnelToken412), + "413": decodeError("BetaRotateTunnelToken413", BetaRotateTunnelToken413), + "429": decodeError("BetaRotateTunnelToken429", BetaRotateTunnelToken429), + "431": decodeError("BetaRotateTunnelToken431", BetaRotateTunnelToken431), + "499": decodeError("BetaRotateTunnelToken499", BetaRotateTunnelToken499), + "500": decodeError("BetaRotateTunnelToken500", BetaRotateTunnelToken500), + "501": decodeError("BetaRotateTunnelToken501", BetaRotateTunnelToken501), + "503": decodeError("BetaRotateTunnelToken503", BetaRotateTunnelToken503), + "504": decodeError("BetaRotateTunnelToken504", BetaRotateTunnelToken504), + orElse: unexpectedStatus + })) + ), + "BetaListTunnelCertificates": (tunnelId, options) => + HttpClientRequest.get(`/v1/tunnels/${tunnelId}/certificates?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "include_archived": options?.params?.["include_archived"] as any + }), HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "4xx": decodeError("MessageBatchesResults4XX", MessageBatchesResults4XX), + "2xx": decodeSuccess(BetaListTunnelCertificates200), + "400": decodeError("BetaListTunnelCertificates400", BetaListTunnelCertificates400), + "401": decodeError("BetaListTunnelCertificates401", BetaListTunnelCertificates401), + "403": decodeError("BetaListTunnelCertificates403", BetaListTunnelCertificates403), + "404": decodeError("BetaListTunnelCertificates404", BetaListTunnelCertificates404), + "408": decodeError("BetaListTunnelCertificates408", BetaListTunnelCertificates408), + "409": decodeError("BetaListTunnelCertificates409", BetaListTunnelCertificates409), + "412": decodeError("BetaListTunnelCertificates412", BetaListTunnelCertificates412), + "413": decodeError("BetaListTunnelCertificates413", BetaListTunnelCertificates413), + "429": decodeError("BetaListTunnelCertificates429", BetaListTunnelCertificates429), + "431": decodeError("BetaListTunnelCertificates431", BetaListTunnelCertificates431), + "499": decodeError("BetaListTunnelCertificates499", BetaListTunnelCertificates499), + "500": decodeError("BetaListTunnelCertificates500", BetaListTunnelCertificates500), + "501": decodeError("BetaListTunnelCertificates501", BetaListTunnelCertificates501), + "503": decodeError("BetaListTunnelCertificates503", BetaListTunnelCertificates503), + "504": decodeError("BetaListTunnelCertificates504", BetaListTunnelCertificates504), orElse: unexpectedStatus })) ), - "messagesCountTokensPost": (options) => - HttpClientRequest.post(`/v1/messages/count_tokens`).pipe( - HttpClientRequest.setHeaders({ "anthropic-version": options.params?.["anthropic-version"] ?? undefined }), + "BetaCreateTunnelCertificate": (tunnelId, options) => + HttpClientRequest.post(`/v1/tunnels/${tunnelId}/certificates?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(MessagesCountTokensPost200), - "4xx": decodeError("MessagesCountTokensPost4XX", MessagesCountTokensPost4XX), + "2xx": decodeSuccess(BetaCreateTunnelCertificate200), + "400": decodeError("BetaCreateTunnelCertificate400", BetaCreateTunnelCertificate400), + "401": decodeError("BetaCreateTunnelCertificate401", BetaCreateTunnelCertificate401), + "403": decodeError("BetaCreateTunnelCertificate403", BetaCreateTunnelCertificate403), + "404": decodeError("BetaCreateTunnelCertificate404", BetaCreateTunnelCertificate404), + "408": decodeError("BetaCreateTunnelCertificate408", BetaCreateTunnelCertificate408), + "409": decodeError("BetaCreateTunnelCertificate409", BetaCreateTunnelCertificate409), + "412": decodeError("BetaCreateTunnelCertificate412", BetaCreateTunnelCertificate412), + "413": decodeError("BetaCreateTunnelCertificate413", BetaCreateTunnelCertificate413), + "429": decodeError("BetaCreateTunnelCertificate429", BetaCreateTunnelCertificate429), + "431": decodeError("BetaCreateTunnelCertificate431", BetaCreateTunnelCertificate431), + "499": decodeError("BetaCreateTunnelCertificate499", BetaCreateTunnelCertificate499), + "500": decodeError("BetaCreateTunnelCertificate500", BetaCreateTunnelCertificate500), + "501": decodeError("BetaCreateTunnelCertificate501", BetaCreateTunnelCertificate501), + "503": decodeError("BetaCreateTunnelCertificate503", BetaCreateTunnelCertificate503), + "504": decodeError("BetaCreateTunnelCertificate504", BetaCreateTunnelCertificate504), + orElse: unexpectedStatus + })) + ), + "BetaGetTunnelCertificate": (tunnelId, certificateId, options) => + HttpClientRequest.get(`/v1/tunnels/${tunnelId}/certificates/${certificateId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetTunnelCertificate200), + "400": decodeError("BetaGetTunnelCertificate400", BetaGetTunnelCertificate400), + "401": decodeError("BetaGetTunnelCertificate401", BetaGetTunnelCertificate401), + "403": decodeError("BetaGetTunnelCertificate403", BetaGetTunnelCertificate403), + "404": decodeError("BetaGetTunnelCertificate404", BetaGetTunnelCertificate404), + "408": decodeError("BetaGetTunnelCertificate408", BetaGetTunnelCertificate408), + "409": decodeError("BetaGetTunnelCertificate409", BetaGetTunnelCertificate409), + "412": decodeError("BetaGetTunnelCertificate412", BetaGetTunnelCertificate412), + "413": decodeError("BetaGetTunnelCertificate413", BetaGetTunnelCertificate413), + "429": decodeError("BetaGetTunnelCertificate429", BetaGetTunnelCertificate429), + "431": decodeError("BetaGetTunnelCertificate431", BetaGetTunnelCertificate431), + "499": decodeError("BetaGetTunnelCertificate499", BetaGetTunnelCertificate499), + "500": decodeError("BetaGetTunnelCertificate500", BetaGetTunnelCertificate500), + "501": decodeError("BetaGetTunnelCertificate501", BetaGetTunnelCertificate501), + "503": decodeError("BetaGetTunnelCertificate503", BetaGetTunnelCertificate503), + "504": decodeError("BetaGetTunnelCertificate504", BetaGetTunnelCertificate504), + orElse: unexpectedStatus + })) + ), + "BetaArchiveTunnelCertificate": (tunnelId, certificateId, options) => + HttpClientRequest.post(`/v1/tunnels/${tunnelId}/certificates/${certificateId}/archive?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaArchiveTunnelCertificate200), + "400": decodeError("BetaArchiveTunnelCertificate400", BetaArchiveTunnelCertificate400), + "401": decodeError("BetaArchiveTunnelCertificate401", BetaArchiveTunnelCertificate401), + "403": decodeError("BetaArchiveTunnelCertificate403", BetaArchiveTunnelCertificate403), + "404": decodeError("BetaArchiveTunnelCertificate404", BetaArchiveTunnelCertificate404), + "408": decodeError("BetaArchiveTunnelCertificate408", BetaArchiveTunnelCertificate408), + "409": decodeError("BetaArchiveTunnelCertificate409", BetaArchiveTunnelCertificate409), + "412": decodeError("BetaArchiveTunnelCertificate412", BetaArchiveTunnelCertificate412), + "413": decodeError("BetaArchiveTunnelCertificate413", BetaArchiveTunnelCertificate413), + "429": decodeError("BetaArchiveTunnelCertificate429", BetaArchiveTunnelCertificate429), + "431": decodeError("BetaArchiveTunnelCertificate431", BetaArchiveTunnelCertificate431), + "499": decodeError("BetaArchiveTunnelCertificate499", BetaArchiveTunnelCertificate499), + "500": decodeError("BetaArchiveTunnelCertificate500", BetaArchiveTunnelCertificate500), + "501": decodeError("BetaArchiveTunnelCertificate501", BetaArchiveTunnelCertificate501), + "503": decodeError("BetaArchiveTunnelCertificate503", BetaArchiveTunnelCertificate503), + "504": decodeError("BetaArchiveTunnelCertificate504", BetaArchiveTunnelCertificate504), + orElse: unexpectedStatus + })) + ), + "BetaListDreams": (options) => + HttpClientRequest.get(`/v1/dreams?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "include_archived": options?.params?.["include_archived"] as any, + "statuses[]": options?.params?.["statuses[]"] as any, + "created_at[gt]": options?.params?.["created_at[gt]"] as any, + "created_at[lt]": options?.params?.["created_at[lt]"] as any + }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListDreams200), + "400": decodeError("BetaListDreams400", BetaListDreams400), + "401": decodeError("BetaListDreams401", BetaListDreams401), + "403": decodeError("BetaListDreams403", BetaListDreams403), + "404": decodeError("BetaListDreams404", BetaListDreams404), + "408": decodeError("BetaListDreams408", BetaListDreams408), + "409": decodeError("BetaListDreams409", BetaListDreams409), + "412": decodeError("BetaListDreams412", BetaListDreams412), + "413": decodeError("BetaListDreams413", BetaListDreams413), + "429": decodeError("BetaListDreams429", BetaListDreams429), + "431": decodeError("BetaListDreams431", BetaListDreams431), + "499": decodeError("BetaListDreams499", BetaListDreams499), + "500": decodeError("BetaListDreams500", BetaListDreams500), + "501": decodeError("BetaListDreams501", BetaListDreams501), + "503": decodeError("BetaListDreams503", BetaListDreams503), + "504": decodeError("BetaListDreams504", BetaListDreams504), + orElse: unexpectedStatus + })) + ), + "BetaCreateDream": (options) => + HttpClientRequest.post(`/v1/dreams?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateDream200), + "400": decodeError("BetaCreateDream400", BetaCreateDream400), + "401": decodeError("BetaCreateDream401", BetaCreateDream401), + "403": decodeError("BetaCreateDream403", BetaCreateDream403), + "404": decodeError("BetaCreateDream404", BetaCreateDream404), + "408": decodeError("BetaCreateDream408", BetaCreateDream408), + "409": decodeError("BetaCreateDream409", BetaCreateDream409), + "412": decodeError("BetaCreateDream412", BetaCreateDream412), + "413": decodeError("BetaCreateDream413", BetaCreateDream413), + "429": decodeError("BetaCreateDream429", BetaCreateDream429), + "431": decodeError("BetaCreateDream431", BetaCreateDream431), + "499": decodeError("BetaCreateDream499", BetaCreateDream499), + "500": decodeError("BetaCreateDream500", BetaCreateDream500), + "501": decodeError("BetaCreateDream501", BetaCreateDream501), + "503": decodeError("BetaCreateDream503", BetaCreateDream503), + "504": decodeError("BetaCreateDream504", BetaCreateDream504), + orElse: unexpectedStatus + })) + ), + "BetaGetDream": (dreamId, options) => + HttpClientRequest.get(`/v1/dreams/${dreamId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetDream200), + "400": decodeError("BetaGetDream400", BetaGetDream400), + "401": decodeError("BetaGetDream401", BetaGetDream401), + "403": decodeError("BetaGetDream403", BetaGetDream403), + "404": decodeError("BetaGetDream404", BetaGetDream404), + "408": decodeError("BetaGetDream408", BetaGetDream408), + "409": decodeError("BetaGetDream409", BetaGetDream409), + "412": decodeError("BetaGetDream412", BetaGetDream412), + "413": decodeError("BetaGetDream413", BetaGetDream413), + "429": decodeError("BetaGetDream429", BetaGetDream429), + "431": decodeError("BetaGetDream431", BetaGetDream431), + "499": decodeError("BetaGetDream499", BetaGetDream499), + "500": decodeError("BetaGetDream500", BetaGetDream500), + "501": decodeError("BetaGetDream501", BetaGetDream501), + "503": decodeError("BetaGetDream503", BetaGetDream503), + "504": decodeError("BetaGetDream504", BetaGetDream504), + orElse: unexpectedStatus + })) + ), + "BetaCancelDream": (dreamId, options) => + HttpClientRequest.post(`/v1/dreams/${dreamId}/cancel?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCancelDream200), + "400": decodeError("BetaCancelDream400", BetaCancelDream400), + "401": decodeError("BetaCancelDream401", BetaCancelDream401), + "403": decodeError("BetaCancelDream403", BetaCancelDream403), + "404": decodeError("BetaCancelDream404", BetaCancelDream404), + "408": decodeError("BetaCancelDream408", BetaCancelDream408), + "409": decodeError("BetaCancelDream409", BetaCancelDream409), + "412": decodeError("BetaCancelDream412", BetaCancelDream412), + "413": decodeError("BetaCancelDream413", BetaCancelDream413), + "429": decodeError("BetaCancelDream429", BetaCancelDream429), + "431": decodeError("BetaCancelDream431", BetaCancelDream431), + "499": decodeError("BetaCancelDream499", BetaCancelDream499), + "500": decodeError("BetaCancelDream500", BetaCancelDream500), + "501": decodeError("BetaCancelDream501", BetaCancelDream501), + "503": decodeError("BetaCancelDream503", BetaCancelDream503), + "504": decodeError("BetaCancelDream504", BetaCancelDream504), + orElse: unexpectedStatus + })) + ), + "BetaArchiveDream": (dreamId, options) => + HttpClientRequest.post(`/v1/dreams/${dreamId}/archive?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaArchiveDream200), + "400": decodeError("BetaArchiveDream400", BetaArchiveDream400), + "401": decodeError("BetaArchiveDream401", BetaArchiveDream401), + "403": decodeError("BetaArchiveDream403", BetaArchiveDream403), + "404": decodeError("BetaArchiveDream404", BetaArchiveDream404), + "408": decodeError("BetaArchiveDream408", BetaArchiveDream408), + "409": decodeError("BetaArchiveDream409", BetaArchiveDream409), + "412": decodeError("BetaArchiveDream412", BetaArchiveDream412), + "413": decodeError("BetaArchiveDream413", BetaArchiveDream413), + "429": decodeError("BetaArchiveDream429", BetaArchiveDream429), + "431": decodeError("BetaArchiveDream431", BetaArchiveDream431), + "499": decodeError("BetaArchiveDream499", BetaArchiveDream499), + "500": decodeError("BetaArchiveDream500", BetaArchiveDream500), + "501": decodeError("BetaArchiveDream501", BetaArchiveDream501), + "503": decodeError("BetaArchiveDream503", BetaArchiveDream503), + "504": decodeError("BetaArchiveDream504", BetaArchiveDream504), + orElse: unexpectedStatus + })) + ), + "BetaListSessions": (options) => + HttpClientRequest.get(`/v1/sessions?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "include_archived": options?.params?.["include_archived"] as any, + "created_at[gte]": options?.params?.["created_at[gte]"] as any, + "created_at[gt]": options?.params?.["created_at[gt]"] as any, + "created_at[lte]": options?.params?.["created_at[lte]"] as any, + "created_at[lt]": options?.params?.["created_at[lt]"] as any, + "agent_id": options?.params?.["agent_id"] as any, + "agent_version": options?.params?.["agent_version"] as any, + "order": options?.params?.["order"] as any, + "memory_store_id": options?.params?.["memory_store_id"] as any, + "deployment_id": options?.params?.["deployment_id"] as any, + "statuses[]": options?.params?.["statuses[]"] as any + }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListSessions200), + "400": decodeError("BetaListSessions400", BetaListSessions400), + "401": decodeError("BetaListSessions401", BetaListSessions401), + "403": decodeError("BetaListSessions403", BetaListSessions403), + "404": decodeError("BetaListSessions404", BetaListSessions404), + "408": decodeError("BetaListSessions408", BetaListSessions408), + "409": decodeError("BetaListSessions409", BetaListSessions409), + "412": decodeError("BetaListSessions412", BetaListSessions412), + "413": decodeError("BetaListSessions413", BetaListSessions413), + "429": decodeError("BetaListSessions429", BetaListSessions429), + "431": decodeError("BetaListSessions431", BetaListSessions431), + "499": decodeError("BetaListSessions499", BetaListSessions499), + "500": decodeError("BetaListSessions500", BetaListSessions500), + "501": decodeError("BetaListSessions501", BetaListSessions501), + "503": decodeError("BetaListSessions503", BetaListSessions503), + "504": decodeError("BetaListSessions504", BetaListSessions504), + orElse: unexpectedStatus + })) + ), + "BetaCreateSession": (options) => + HttpClientRequest.post(`/v1/sessions?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateSession200), + "400": decodeError("BetaCreateSession400", BetaCreateSession400), + "401": decodeError("BetaCreateSession401", BetaCreateSession401), + "403": decodeError("BetaCreateSession403", BetaCreateSession403), + "404": decodeError("BetaCreateSession404", BetaCreateSession404), + "408": decodeError("BetaCreateSession408", BetaCreateSession408), + "409": decodeError("BetaCreateSession409", BetaCreateSession409), + "412": decodeError("BetaCreateSession412", BetaCreateSession412), + "413": decodeError("BetaCreateSession413", BetaCreateSession413), + "429": decodeError("BetaCreateSession429", BetaCreateSession429), + "431": decodeError("BetaCreateSession431", BetaCreateSession431), + "499": decodeError("BetaCreateSession499", BetaCreateSession499), + "500": decodeError("BetaCreateSession500", BetaCreateSession500), + "501": decodeError("BetaCreateSession501", BetaCreateSession501), + "503": decodeError("BetaCreateSession503", BetaCreateSession503), + "504": decodeError("BetaCreateSession504", BetaCreateSession504), + orElse: unexpectedStatus + })) + ), + "BetaGetSession": (sessionId, options) => + HttpClientRequest.get(`/v1/sessions/${sessionId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetSession200), + "400": decodeError("BetaGetSession400", BetaGetSession400), + "401": decodeError("BetaGetSession401", BetaGetSession401), + "403": decodeError("BetaGetSession403", BetaGetSession403), + "404": decodeError("BetaGetSession404", BetaGetSession404), + "408": decodeError("BetaGetSession408", BetaGetSession408), + "409": decodeError("BetaGetSession409", BetaGetSession409), + "412": decodeError("BetaGetSession412", BetaGetSession412), + "413": decodeError("BetaGetSession413", BetaGetSession413), + "429": decodeError("BetaGetSession429", BetaGetSession429), + "431": decodeError("BetaGetSession431", BetaGetSession431), + "499": decodeError("BetaGetSession499", BetaGetSession499), + "500": decodeError("BetaGetSession500", BetaGetSession500), + "501": decodeError("BetaGetSession501", BetaGetSession501), + "503": decodeError("BetaGetSession503", BetaGetSession503), + "504": decodeError("BetaGetSession504", BetaGetSession504), + orElse: unexpectedStatus + })) + ), + "BetaUpdateSession": (sessionId, options) => + HttpClientRequest.post(`/v1/sessions/${sessionId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateSession200), + "400": decodeError("BetaUpdateSession400", BetaUpdateSession400), + "401": decodeError("BetaUpdateSession401", BetaUpdateSession401), + "403": decodeError("BetaUpdateSession403", BetaUpdateSession403), + "404": decodeError("BetaUpdateSession404", BetaUpdateSession404), + "408": decodeError("BetaUpdateSession408", BetaUpdateSession408), + "409": decodeError("BetaUpdateSession409", BetaUpdateSession409), + "412": decodeError("BetaUpdateSession412", BetaUpdateSession412), + "413": decodeError("BetaUpdateSession413", BetaUpdateSession413), + "429": decodeError("BetaUpdateSession429", BetaUpdateSession429), + "431": decodeError("BetaUpdateSession431", BetaUpdateSession431), + "499": decodeError("BetaUpdateSession499", BetaUpdateSession499), + "500": decodeError("BetaUpdateSession500", BetaUpdateSession500), + "501": decodeError("BetaUpdateSession501", BetaUpdateSession501), + "503": decodeError("BetaUpdateSession503", BetaUpdateSession503), + "504": decodeError("BetaUpdateSession504", BetaUpdateSession504), + orElse: unexpectedStatus + })) + ), + "BetaDeleteSession": (sessionId, options) => + HttpClientRequest.delete(`/v1/sessions/${sessionId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaDeleteSession200), + "400": decodeError("BetaDeleteSession400", BetaDeleteSession400), + "401": decodeError("BetaDeleteSession401", BetaDeleteSession401), + "403": decodeError("BetaDeleteSession403", BetaDeleteSession403), + "404": decodeError("BetaDeleteSession404", BetaDeleteSession404), + "408": decodeError("BetaDeleteSession408", BetaDeleteSession408), + "409": decodeError("BetaDeleteSession409", BetaDeleteSession409), + "412": decodeError("BetaDeleteSession412", BetaDeleteSession412), + "413": decodeError("BetaDeleteSession413", BetaDeleteSession413), + "429": decodeError("BetaDeleteSession429", BetaDeleteSession429), + "431": decodeError("BetaDeleteSession431", BetaDeleteSession431), + "499": decodeError("BetaDeleteSession499", BetaDeleteSession499), + "500": decodeError("BetaDeleteSession500", BetaDeleteSession500), + "501": decodeError("BetaDeleteSession501", BetaDeleteSession501), + "503": decodeError("BetaDeleteSession503", BetaDeleteSession503), + "504": decodeError("BetaDeleteSession504", BetaDeleteSession504), + orElse: unexpectedStatus + })) + ), + "BetaListEvents": (sessionId, options) => + HttpClientRequest.get(`/v1/sessions/${sessionId}/events?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "order": options?.params?.["order"] as any, + "types[]": options?.params?.["types[]"] as any, + "created_at[gte]": options?.params?.["created_at[gte]"] as any, + "created_at[gt]": options?.params?.["created_at[gt]"] as any, + "created_at[lte]": options?.params?.["created_at[lte]"] as any, + "created_at[lt]": options?.params?.["created_at[lt]"] as any + }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListEvents200), + "400": decodeError("BetaListEvents400", BetaListEvents400), + "401": decodeError("BetaListEvents401", BetaListEvents401), + "403": decodeError("BetaListEvents403", BetaListEvents403), + "404": decodeError("BetaListEvents404", BetaListEvents404), + "408": decodeError("BetaListEvents408", BetaListEvents408), + "409": decodeError("BetaListEvents409", BetaListEvents409), + "412": decodeError("BetaListEvents412", BetaListEvents412), + "413": decodeError("BetaListEvents413", BetaListEvents413), + "429": decodeError("BetaListEvents429", BetaListEvents429), + "431": decodeError("BetaListEvents431", BetaListEvents431), + "499": decodeError("BetaListEvents499", BetaListEvents499), + "500": decodeError("BetaListEvents500", BetaListEvents500), + "501": decodeError("BetaListEvents501", BetaListEvents501), + "503": decodeError("BetaListEvents503", BetaListEvents503), + "504": decodeError("BetaListEvents504", BetaListEvents504), + orElse: unexpectedStatus + })) + ), + "BetaSendEvents": (sessionId, options) => + HttpClientRequest.post(`/v1/sessions/${sessionId}/events?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaSendEvents200), + "400": decodeError("BetaSendEvents400", BetaSendEvents400), + "401": decodeError("BetaSendEvents401", BetaSendEvents401), + "403": decodeError("BetaSendEvents403", BetaSendEvents403), + "404": decodeError("BetaSendEvents404", BetaSendEvents404), + "408": decodeError("BetaSendEvents408", BetaSendEvents408), + "409": decodeError("BetaSendEvents409", BetaSendEvents409), + "412": decodeError("BetaSendEvents412", BetaSendEvents412), + "413": decodeError("BetaSendEvents413", BetaSendEvents413), + "429": decodeError("BetaSendEvents429", BetaSendEvents429), + "431": decodeError("BetaSendEvents431", BetaSendEvents431), + "499": decodeError("BetaSendEvents499", BetaSendEvents499), + "500": decodeError("BetaSendEvents500", BetaSendEvents500), + "501": decodeError("BetaSendEvents501", BetaSendEvents501), + "503": decodeError("BetaSendEvents503", BetaSendEvents503), + "504": decodeError("BetaSendEvents504", BetaSendEvents504), + orElse: unexpectedStatus + })) + ), + "BetaStreamSessionEvents": (sessionId, options) => + HttpClientRequest.get(`/v1/sessions/${sessionId}/events/stream?beta=true`).pipe( + HttpClientRequest.setUrlParams({ "event_deltas[]": options?.params?.["event_deltas[]"] as any }), + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaStreamSessionEvents200), + "400": decodeError("BetaStreamSessionEvents400", BetaStreamSessionEvents400), + "401": decodeError("BetaStreamSessionEvents401", BetaStreamSessionEvents401), + "403": decodeError("BetaStreamSessionEvents403", BetaStreamSessionEvents403), + "404": decodeError("BetaStreamSessionEvents404", BetaStreamSessionEvents404), + "408": decodeError("BetaStreamSessionEvents408", BetaStreamSessionEvents408), + "409": decodeError("BetaStreamSessionEvents409", BetaStreamSessionEvents409), + "412": decodeError("BetaStreamSessionEvents412", BetaStreamSessionEvents412), + "413": decodeError("BetaStreamSessionEvents413", BetaStreamSessionEvents413), + "429": decodeError("BetaStreamSessionEvents429", BetaStreamSessionEvents429), + "431": decodeError("BetaStreamSessionEvents431", BetaStreamSessionEvents431), + "499": decodeError("BetaStreamSessionEvents499", BetaStreamSessionEvents499), + "500": decodeError("BetaStreamSessionEvents500", BetaStreamSessionEvents500), + "501": decodeError("BetaStreamSessionEvents501", BetaStreamSessionEvents501), + "503": decodeError("BetaStreamSessionEvents503", BetaStreamSessionEvents503), + "504": decodeError("BetaStreamSessionEvents504", BetaStreamSessionEvents504), + orElse: unexpectedStatus + })) + ), + "BetaArchiveSession": (sessionId, options) => + HttpClientRequest.post(`/v1/sessions/${sessionId}/archive?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaArchiveSession200), + "400": decodeError("BetaArchiveSession400", BetaArchiveSession400), + "401": decodeError("BetaArchiveSession401", BetaArchiveSession401), + "403": decodeError("BetaArchiveSession403", BetaArchiveSession403), + "404": decodeError("BetaArchiveSession404", BetaArchiveSession404), + "408": decodeError("BetaArchiveSession408", BetaArchiveSession408), + "409": decodeError("BetaArchiveSession409", BetaArchiveSession409), + "412": decodeError("BetaArchiveSession412", BetaArchiveSession412), + "413": decodeError("BetaArchiveSession413", BetaArchiveSession413), + "429": decodeError("BetaArchiveSession429", BetaArchiveSession429), + "431": decodeError("BetaArchiveSession431", BetaArchiveSession431), + "499": decodeError("BetaArchiveSession499", BetaArchiveSession499), + "500": decodeError("BetaArchiveSession500", BetaArchiveSession500), + "501": decodeError("BetaArchiveSession501", BetaArchiveSession501), + "503": decodeError("BetaArchiveSession503", BetaArchiveSession503), + "504": decodeError("BetaArchiveSession504", BetaArchiveSession504), orElse: unexpectedStatus })) ), - "listFilesV1FilesGet": (options) => - HttpClientRequest.get(`/v1/files`).pipe( + "BetaListSessionThreads": (sessionId, options) => + HttpClientRequest.get(`/v1/sessions/${sessionId}/threads?beta=true`).pipe( HttpClientRequest.setUrlParams({ - "before_id": options?.params?.["before_id"] as any, - "after_id": options?.params?.["after_id"] as any, - "limit": options?.params?.["limit"] as any + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any }), HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(ListFilesV1FilesGet200), - "4xx": decodeError("ListFilesV1FilesGet4XX", ListFilesV1FilesGet4XX), + "2xx": decodeSuccess(BetaListSessionThreads200), + "400": decodeError("BetaListSessionThreads400", BetaListSessionThreads400), + "401": decodeError("BetaListSessionThreads401", BetaListSessionThreads401), + "403": decodeError("BetaListSessionThreads403", BetaListSessionThreads403), + "404": decodeError("BetaListSessionThreads404", BetaListSessionThreads404), + "408": decodeError("BetaListSessionThreads408", BetaListSessionThreads408), + "409": decodeError("BetaListSessionThreads409", BetaListSessionThreads409), + "412": decodeError("BetaListSessionThreads412", BetaListSessionThreads412), + "413": decodeError("BetaListSessionThreads413", BetaListSessionThreads413), + "429": decodeError("BetaListSessionThreads429", BetaListSessionThreads429), + "431": decodeError("BetaListSessionThreads431", BetaListSessionThreads431), + "499": decodeError("BetaListSessionThreads499", BetaListSessionThreads499), + "500": decodeError("BetaListSessionThreads500", BetaListSessionThreads500), + "501": decodeError("BetaListSessionThreads501", BetaListSessionThreads501), + "503": decodeError("BetaListSessionThreads503", BetaListSessionThreads503), + "504": decodeError("BetaListSessionThreads504", BetaListSessionThreads504), orElse: unexpectedStatus })) ), - "uploadFileV1FilesPost": (options) => - HttpClientRequest.post(`/v1/files`).pipe( + "BetaGetSessionThread": (sessionId, threadId, options) => + HttpClientRequest.get(`/v1/sessions/${sessionId}/threads/${threadId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options.params?.["anthropic-version"] ?? undefined + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), - HttpClientRequest.bodyFormData(options.payload as any), - withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(UploadFileV1FilesPost200), - "4xx": decodeError("UploadFileV1FilesPost4XX", UploadFileV1FilesPost4XX), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetSessionThread200), + "400": decodeError("BetaGetSessionThread400", BetaGetSessionThread400), + "401": decodeError("BetaGetSessionThread401", BetaGetSessionThread401), + "403": decodeError("BetaGetSessionThread403", BetaGetSessionThread403), + "404": decodeError("BetaGetSessionThread404", BetaGetSessionThread404), + "408": decodeError("BetaGetSessionThread408", BetaGetSessionThread408), + "409": decodeError("BetaGetSessionThread409", BetaGetSessionThread409), + "412": decodeError("BetaGetSessionThread412", BetaGetSessionThread412), + "413": decodeError("BetaGetSessionThread413", BetaGetSessionThread413), + "429": decodeError("BetaGetSessionThread429", BetaGetSessionThread429), + "431": decodeError("BetaGetSessionThread431", BetaGetSessionThread431), + "499": decodeError("BetaGetSessionThread499", BetaGetSessionThread499), + "500": decodeError("BetaGetSessionThread500", BetaGetSessionThread500), + "501": decodeError("BetaGetSessionThread501", BetaGetSessionThread501), + "503": decodeError("BetaGetSessionThread503", BetaGetSessionThread503), + "504": decodeError("BetaGetSessionThread504", BetaGetSessionThread504), orElse: unexpectedStatus })) ), - "getFileMetadataV1FilesFileIdGet": (fileId, options) => - HttpClientRequest.get(`/v1/files/${fileId}`).pipe( + "BetaListSessionThreadEvents": (sessionId, threadId, options) => + HttpClientRequest.get(`/v1/sessions/${sessionId}/threads/${threadId}/events?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any + }), HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(GetFileMetadataV1FilesFileIdGet200), - "4xx": decodeError("GetFileMetadataV1FilesFileIdGet4XX", GetFileMetadataV1FilesFileIdGet4XX), + "2xx": decodeSuccess(BetaListSessionThreadEvents200), + "400": decodeError("BetaListSessionThreadEvents400", BetaListSessionThreadEvents400), + "401": decodeError("BetaListSessionThreadEvents401", BetaListSessionThreadEvents401), + "403": decodeError("BetaListSessionThreadEvents403", BetaListSessionThreadEvents403), + "404": decodeError("BetaListSessionThreadEvents404", BetaListSessionThreadEvents404), + "408": decodeError("BetaListSessionThreadEvents408", BetaListSessionThreadEvents408), + "409": decodeError("BetaListSessionThreadEvents409", BetaListSessionThreadEvents409), + "412": decodeError("BetaListSessionThreadEvents412", BetaListSessionThreadEvents412), + "413": decodeError("BetaListSessionThreadEvents413", BetaListSessionThreadEvents413), + "429": decodeError("BetaListSessionThreadEvents429", BetaListSessionThreadEvents429), + "431": decodeError("BetaListSessionThreadEvents431", BetaListSessionThreadEvents431), + "499": decodeError("BetaListSessionThreadEvents499", BetaListSessionThreadEvents499), + "500": decodeError("BetaListSessionThreadEvents500", BetaListSessionThreadEvents500), + "501": decodeError("BetaListSessionThreadEvents501", BetaListSessionThreadEvents501), + "503": decodeError("BetaListSessionThreadEvents503", BetaListSessionThreadEvents503), + "504": decodeError("BetaListSessionThreadEvents504", BetaListSessionThreadEvents504), orElse: unexpectedStatus })) ), - "deleteFileV1FilesFileIdDelete": (fileId, options) => - HttpClientRequest.delete(`/v1/files/${fileId}`).pipe( + "BetaStreamSessionThreadEvents": (sessionId, threadId, options) => + HttpClientRequest.get(`/v1/sessions/${sessionId}/threads/${threadId}/stream?beta=true`).pipe( + HttpClientRequest.setUrlParams({ "event_deltas[]": options?.params?.["event_deltas[]"] as any }), HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(DeleteFileV1FilesFileIdDelete200), - "4xx": decodeError("DeleteFileV1FilesFileIdDelete4XX", DeleteFileV1FilesFileIdDelete4XX), + "2xx": decodeSuccess(BetaStreamSessionThreadEvents200), + "400": decodeError("BetaStreamSessionThreadEvents400", BetaStreamSessionThreadEvents400), + "401": decodeError("BetaStreamSessionThreadEvents401", BetaStreamSessionThreadEvents401), + "403": decodeError("BetaStreamSessionThreadEvents403", BetaStreamSessionThreadEvents403), + "404": decodeError("BetaStreamSessionThreadEvents404", BetaStreamSessionThreadEvents404), + "408": decodeError("BetaStreamSessionThreadEvents408", BetaStreamSessionThreadEvents408), + "409": decodeError("BetaStreamSessionThreadEvents409", BetaStreamSessionThreadEvents409), + "412": decodeError("BetaStreamSessionThreadEvents412", BetaStreamSessionThreadEvents412), + "413": decodeError("BetaStreamSessionThreadEvents413", BetaStreamSessionThreadEvents413), + "429": decodeError("BetaStreamSessionThreadEvents429", BetaStreamSessionThreadEvents429), + "431": decodeError("BetaStreamSessionThreadEvents431", BetaStreamSessionThreadEvents431), + "499": decodeError("BetaStreamSessionThreadEvents499", BetaStreamSessionThreadEvents499), + "500": decodeError("BetaStreamSessionThreadEvents500", BetaStreamSessionThreadEvents500), + "501": decodeError("BetaStreamSessionThreadEvents501", BetaStreamSessionThreadEvents501), + "503": decodeError("BetaStreamSessionThreadEvents503", BetaStreamSessionThreadEvents503), + "504": decodeError("BetaStreamSessionThreadEvents504", BetaStreamSessionThreadEvents504), orElse: unexpectedStatus })) ), - "downloadFileV1FilesFileIdContentGet": (fileId, options) => - HttpClientRequest.get(`/v1/files/${fileId}/content`).pipe( + "BetaArchiveSessionThread": (sessionId, threadId, options) => + HttpClientRequest.post(`/v1/sessions/${sessionId}/threads/${threadId}/archive?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaArchiveSessionThread200), + "400": decodeError("BetaArchiveSessionThread400", BetaArchiveSessionThread400), + "401": decodeError("BetaArchiveSessionThread401", BetaArchiveSessionThread401), + "403": decodeError("BetaArchiveSessionThread403", BetaArchiveSessionThread403), + "404": decodeError("BetaArchiveSessionThread404", BetaArchiveSessionThread404), + "408": decodeError("BetaArchiveSessionThread408", BetaArchiveSessionThread408), + "409": decodeError("BetaArchiveSessionThread409", BetaArchiveSessionThread409), + "412": decodeError("BetaArchiveSessionThread412", BetaArchiveSessionThread412), + "413": decodeError("BetaArchiveSessionThread413", BetaArchiveSessionThread413), + "429": decodeError("BetaArchiveSessionThread429", BetaArchiveSessionThread429), + "431": decodeError("BetaArchiveSessionThread431", BetaArchiveSessionThread431), + "499": decodeError("BetaArchiveSessionThread499", BetaArchiveSessionThread499), + "500": decodeError("BetaArchiveSessionThread500", BetaArchiveSessionThread500), + "501": decodeError("BetaArchiveSessionThread501", BetaArchiveSessionThread501), + "503": decodeError("BetaArchiveSessionThread503", BetaArchiveSessionThread503), + "504": decodeError("BetaArchiveSessionThread504", BetaArchiveSessionThread504), orElse: unexpectedStatus })) ), - "downloadFileV1FilesFileIdContentGetStream": (fileId, options) => - HttpClientRequest.get(`/v1/files/${fileId}/content`).pipe( - HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined - }), - binaryRequest - ), - "listSkillsV1SkillsGet": (options) => - HttpClientRequest.get(`/v1/skills`).pipe( + "BetaListResources": (sessionId, options) => + HttpClientRequest.get(`/v1/sessions/${sessionId}/resources?beta=true`).pipe( HttpClientRequest.setUrlParams({ - "page": options?.params?.["page"] as any, "limit": options?.params?.["limit"] as any, - "source": options?.params?.["source"] as any + "page": options?.params?.["page"] as any }), HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(ListSkillsV1SkillsGet200), - "4xx": decodeError("ListSkillsV1SkillsGet4XX", ListSkillsV1SkillsGet4XX), + "2xx": decodeSuccess(BetaListResources200), + "400": decodeError("BetaListResources400", BetaListResources400), + "401": decodeError("BetaListResources401", BetaListResources401), + "403": decodeError("BetaListResources403", BetaListResources403), + "404": decodeError("BetaListResources404", BetaListResources404), + "408": decodeError("BetaListResources408", BetaListResources408), + "409": decodeError("BetaListResources409", BetaListResources409), + "412": decodeError("BetaListResources412", BetaListResources412), + "413": decodeError("BetaListResources413", BetaListResources413), + "429": decodeError("BetaListResources429", BetaListResources429), + "431": decodeError("BetaListResources431", BetaListResources431), + "499": decodeError("BetaListResources499", BetaListResources499), + "500": decodeError("BetaListResources500", BetaListResources500), + "501": decodeError("BetaListResources501", BetaListResources501), + "503": decodeError("BetaListResources503", BetaListResources503), + "504": decodeError("BetaListResources504", BetaListResources504), orElse: unexpectedStatus })) ), - "createSkillV1SkillsPost": (options) => - HttpClientRequest.post(`/v1/skills`).pipe( + "BetaAddResource": (sessionId, options) => + HttpClientRequest.post(`/v1/sessions/${sessionId}/resources?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options.params?.["anthropic-version"] ?? undefined + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined }), - HttpClientRequest.bodyFormData(options.payload as any), + HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(CreateSkillV1SkillsPost200), - "4xx": decodeError("CreateSkillV1SkillsPost4XX", CreateSkillV1SkillsPost4XX), + "2xx": decodeSuccess(BetaAddResource200), + "400": decodeError("BetaAddResource400", BetaAddResource400), + "401": decodeError("BetaAddResource401", BetaAddResource401), + "403": decodeError("BetaAddResource403", BetaAddResource403), + "404": decodeError("BetaAddResource404", BetaAddResource404), + "408": decodeError("BetaAddResource408", BetaAddResource408), + "409": decodeError("BetaAddResource409", BetaAddResource409), + "412": decodeError("BetaAddResource412", BetaAddResource412), + "413": decodeError("BetaAddResource413", BetaAddResource413), + "429": decodeError("BetaAddResource429", BetaAddResource429), + "431": decodeError("BetaAddResource431", BetaAddResource431), + "499": decodeError("BetaAddResource499", BetaAddResource499), + "500": decodeError("BetaAddResource500", BetaAddResource500), + "501": decodeError("BetaAddResource501", BetaAddResource501), + "503": decodeError("BetaAddResource503", BetaAddResource503), + "504": decodeError("BetaAddResource504", BetaAddResource504), orElse: unexpectedStatus })) ), - "getSkillV1SkillsSkillIdGet": (skillId, options) => - HttpClientRequest.get(`/v1/skills/${skillId}`).pipe( + "BetaGetResource": (sessionId, resourceId, options) => + HttpClientRequest.get(`/v1/sessions/${sessionId}/resources/${resourceId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(GetSkillV1SkillsSkillIdGet200), - "4xx": decodeError("GetSkillV1SkillsSkillIdGet4XX", GetSkillV1SkillsSkillIdGet4XX), + "2xx": decodeSuccess(BetaGetResource200), + "400": decodeError("BetaGetResource400", BetaGetResource400), + "401": decodeError("BetaGetResource401", BetaGetResource401), + "403": decodeError("BetaGetResource403", BetaGetResource403), + "404": decodeError("BetaGetResource404", BetaGetResource404), + "408": decodeError("BetaGetResource408", BetaGetResource408), + "409": decodeError("BetaGetResource409", BetaGetResource409), + "412": decodeError("BetaGetResource412", BetaGetResource412), + "413": decodeError("BetaGetResource413", BetaGetResource413), + "429": decodeError("BetaGetResource429", BetaGetResource429), + "431": decodeError("BetaGetResource431", BetaGetResource431), + "499": decodeError("BetaGetResource499", BetaGetResource499), + "500": decodeError("BetaGetResource500", BetaGetResource500), + "501": decodeError("BetaGetResource501", BetaGetResource501), + "503": decodeError("BetaGetResource503", BetaGetResource503), + "504": decodeError("BetaGetResource504", BetaGetResource504), orElse: unexpectedStatus })) ), - "deleteSkillV1SkillsSkillIdDelete": (skillId, options) => - HttpClientRequest.delete(`/v1/skills/${skillId}`).pipe( + "BetaUpdateResource": (sessionId, resourceId, options) => + HttpClientRequest.post(`/v1/sessions/${sessionId}/resources/${resourceId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateResource200), + "400": decodeError("BetaUpdateResource400", BetaUpdateResource400), + "401": decodeError("BetaUpdateResource401", BetaUpdateResource401), + "403": decodeError("BetaUpdateResource403", BetaUpdateResource403), + "404": decodeError("BetaUpdateResource404", BetaUpdateResource404), + "408": decodeError("BetaUpdateResource408", BetaUpdateResource408), + "409": decodeError("BetaUpdateResource409", BetaUpdateResource409), + "412": decodeError("BetaUpdateResource412", BetaUpdateResource412), + "413": decodeError("BetaUpdateResource413", BetaUpdateResource413), + "429": decodeError("BetaUpdateResource429", BetaUpdateResource429), + "431": decodeError("BetaUpdateResource431", BetaUpdateResource431), + "499": decodeError("BetaUpdateResource499", BetaUpdateResource499), + "500": decodeError("BetaUpdateResource500", BetaUpdateResource500), + "501": decodeError("BetaUpdateResource501", BetaUpdateResource501), + "503": decodeError("BetaUpdateResource503", BetaUpdateResource503), + "504": decodeError("BetaUpdateResource504", BetaUpdateResource504), + orElse: unexpectedStatus + })) + ), + "BetaDeleteResource": (sessionId, resourceId, options) => + HttpClientRequest.delete(`/v1/sessions/${sessionId}/resources/${resourceId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(DeleteSkillV1SkillsSkillIdDelete200), - "4xx": decodeError("DeleteSkillV1SkillsSkillIdDelete4XX", DeleteSkillV1SkillsSkillIdDelete4XX), + "2xx": decodeSuccess(BetaDeleteResource200), + "400": decodeError("BetaDeleteResource400", BetaDeleteResource400), + "401": decodeError("BetaDeleteResource401", BetaDeleteResource401), + "403": decodeError("BetaDeleteResource403", BetaDeleteResource403), + "404": decodeError("BetaDeleteResource404", BetaDeleteResource404), + "408": decodeError("BetaDeleteResource408", BetaDeleteResource408), + "409": decodeError("BetaDeleteResource409", BetaDeleteResource409), + "412": decodeError("BetaDeleteResource412", BetaDeleteResource412), + "413": decodeError("BetaDeleteResource413", BetaDeleteResource413), + "429": decodeError("BetaDeleteResource429", BetaDeleteResource429), + "431": decodeError("BetaDeleteResource431", BetaDeleteResource431), + "499": decodeError("BetaDeleteResource499", BetaDeleteResource499), + "500": decodeError("BetaDeleteResource500", BetaDeleteResource500), + "501": decodeError("BetaDeleteResource501", BetaDeleteResource501), + "503": decodeError("BetaDeleteResource503", BetaDeleteResource503), + "504": decodeError("BetaDeleteResource504", BetaDeleteResource504), orElse: unexpectedStatus })) ), - "listSkillVersionsV1SkillsSkillIdVersionsGet": (skillId, options) => - HttpClientRequest.get(`/v1/skills/${skillId}/versions`).pipe( + "BetaListAgents": (options) => + HttpClientRequest.get(`/v1/agents?beta=true`).pipe( HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, "page": options?.params?.["page"] as any, - "limit": options?.params?.["limit"] as any + "created_at[gte]": options?.params?.["created_at[gte]"] as any, + "created_at[lte]": options?.params?.["created_at[lte]"] as any, + "include_archived": options?.params?.["include_archived"] as any }), HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(ListSkillVersionsV1SkillsSkillIdVersionsGet200), - "4xx": decodeError( - "ListSkillVersionsV1SkillsSkillIdVersionsGet4XX", - ListSkillVersionsV1SkillsSkillIdVersionsGet4XX - ), + "2xx": decodeSuccess(BetaListAgents200), + "400": decodeError("BetaListAgents400", BetaListAgents400), + "401": decodeError("BetaListAgents401", BetaListAgents401), + "403": decodeError("BetaListAgents403", BetaListAgents403), + "404": decodeError("BetaListAgents404", BetaListAgents404), + "408": decodeError("BetaListAgents408", BetaListAgents408), + "409": decodeError("BetaListAgents409", BetaListAgents409), + "412": decodeError("BetaListAgents412", BetaListAgents412), + "413": decodeError("BetaListAgents413", BetaListAgents413), + "429": decodeError("BetaListAgents429", BetaListAgents429), + "431": decodeError("BetaListAgents431", BetaListAgents431), + "499": decodeError("BetaListAgents499", BetaListAgents499), + "500": decodeError("BetaListAgents500", BetaListAgents500), + "501": decodeError("BetaListAgents501", BetaListAgents501), + "503": decodeError("BetaListAgents503", BetaListAgents503), + "504": decodeError("BetaListAgents504", BetaListAgents504), orElse: unexpectedStatus })) ), - "createSkillVersionV1SkillsSkillIdVersionsPost": (skillId, options) => - HttpClientRequest.post(`/v1/skills/${skillId}/versions`).pipe( + "BetaCreateAgent": (options) => + HttpClientRequest.post(`/v1/agents?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options.params?.["anthropic-version"] ?? undefined + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined }), - HttpClientRequest.bodyFormData(options.payload as any), + HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(CreateSkillVersionV1SkillsSkillIdVersionsPost200), - "4xx": decodeError( - "CreateSkillVersionV1SkillsSkillIdVersionsPost4XX", - CreateSkillVersionV1SkillsSkillIdVersionsPost4XX - ), + "2xx": decodeSuccess(BetaCreateAgent200), + "400": decodeError("BetaCreateAgent400", BetaCreateAgent400), + "401": decodeError("BetaCreateAgent401", BetaCreateAgent401), + "403": decodeError("BetaCreateAgent403", BetaCreateAgent403), + "404": decodeError("BetaCreateAgent404", BetaCreateAgent404), + "408": decodeError("BetaCreateAgent408", BetaCreateAgent408), + "409": decodeError("BetaCreateAgent409", BetaCreateAgent409), + "412": decodeError("BetaCreateAgent412", BetaCreateAgent412), + "413": decodeError("BetaCreateAgent413", BetaCreateAgent413), + "429": decodeError("BetaCreateAgent429", BetaCreateAgent429), + "431": decodeError("BetaCreateAgent431", BetaCreateAgent431), + "499": decodeError("BetaCreateAgent499", BetaCreateAgent499), + "500": decodeError("BetaCreateAgent500", BetaCreateAgent500), + "501": decodeError("BetaCreateAgent501", BetaCreateAgent501), + "503": decodeError("BetaCreateAgent503", BetaCreateAgent503), + "504": decodeError("BetaCreateAgent504", BetaCreateAgent504), orElse: unexpectedStatus })) ), - "getSkillVersionV1SkillsSkillIdVersionsVersionGet": (skillId, version, options) => - HttpClientRequest.get(`/v1/skills/${skillId}/versions/${version}`).pipe( + "BetaGetAgent": (agentId, options) => + HttpClientRequest.get(`/v1/agents/${agentId}?beta=true`).pipe( + HttpClientRequest.setUrlParams({ "version": options?.params?.["version"] as any }), HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(GetSkillVersionV1SkillsSkillIdVersionsVersionGet200), - "4xx": decodeError( - "GetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX", - GetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX - ), + "2xx": decodeSuccess(BetaGetAgent200), + "400": decodeError("BetaGetAgent400", BetaGetAgent400), + "401": decodeError("BetaGetAgent401", BetaGetAgent401), + "403": decodeError("BetaGetAgent403", BetaGetAgent403), + "404": decodeError("BetaGetAgent404", BetaGetAgent404), + "408": decodeError("BetaGetAgent408", BetaGetAgent408), + "409": decodeError("BetaGetAgent409", BetaGetAgent409), + "412": decodeError("BetaGetAgent412", BetaGetAgent412), + "413": decodeError("BetaGetAgent413", BetaGetAgent413), + "429": decodeError("BetaGetAgent429", BetaGetAgent429), + "431": decodeError("BetaGetAgent431", BetaGetAgent431), + "499": decodeError("BetaGetAgent499", BetaGetAgent499), + "500": decodeError("BetaGetAgent500", BetaGetAgent500), + "501": decodeError("BetaGetAgent501", BetaGetAgent501), + "503": decodeError("BetaGetAgent503", BetaGetAgent503), + "504": decodeError("BetaGetAgent504", BetaGetAgent504), orElse: unexpectedStatus })) ), - "deleteSkillVersionV1SkillsSkillIdVersionsVersionDelete": (skillId, version, options) => - HttpClientRequest.delete(`/v1/skills/${skillId}/versions/${version}`).pipe( + "BetaUpdateAgent": (agentId, options) => + HttpClientRequest.post(`/v1/agents/${agentId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined }), - withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(DeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete200), - "4xx": decodeError( - "DeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX", - DeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX - ), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateAgent200), + "400": decodeError("BetaUpdateAgent400", BetaUpdateAgent400), + "401": decodeError("BetaUpdateAgent401", BetaUpdateAgent401), + "403": decodeError("BetaUpdateAgent403", BetaUpdateAgent403), + "404": decodeError("BetaUpdateAgent404", BetaUpdateAgent404), + "408": decodeError("BetaUpdateAgent408", BetaUpdateAgent408), + "409": decodeError("BetaUpdateAgent409", BetaUpdateAgent409), + "412": decodeError("BetaUpdateAgent412", BetaUpdateAgent412), + "413": decodeError("BetaUpdateAgent413", BetaUpdateAgent413), + "429": decodeError("BetaUpdateAgent429", BetaUpdateAgent429), + "431": decodeError("BetaUpdateAgent431", BetaUpdateAgent431), + "499": decodeError("BetaUpdateAgent499", BetaUpdateAgent499), + "500": decodeError("BetaUpdateAgent500", BetaUpdateAgent500), + "501": decodeError("BetaUpdateAgent501", BetaUpdateAgent501), + "503": decodeError("BetaUpdateAgent503", BetaUpdateAgent503), + "504": decodeError("BetaUpdateAgent504", BetaUpdateAgent504), orElse: unexpectedStatus })) ), - "betaMessagesPost": (options) => - HttpClientRequest.post(`/v1/messages?beta=true`).pipe( + "BetaArchiveAgent": (agentId, options) => + HttpClientRequest.post(`/v1/agents/${agentId}/archive?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options.params?.["anthropic-version"] ?? undefined + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), - HttpClientRequest.bodyJsonUnsafe(options.payload), - withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaMessagesPost200), - "4xx": decodeError("BetaMessagesPost4XX", BetaMessagesPost4XX), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaArchiveAgent200), + "400": decodeError("BetaArchiveAgent400", BetaArchiveAgent400), + "401": decodeError("BetaArchiveAgent401", BetaArchiveAgent401), + "403": decodeError("BetaArchiveAgent403", BetaArchiveAgent403), + "404": decodeError("BetaArchiveAgent404", BetaArchiveAgent404), + "408": decodeError("BetaArchiveAgent408", BetaArchiveAgent408), + "409": decodeError("BetaArchiveAgent409", BetaArchiveAgent409), + "412": decodeError("BetaArchiveAgent412", BetaArchiveAgent412), + "413": decodeError("BetaArchiveAgent413", BetaArchiveAgent413), + "429": decodeError("BetaArchiveAgent429", BetaArchiveAgent429), + "431": decodeError("BetaArchiveAgent431", BetaArchiveAgent431), + "499": decodeError("BetaArchiveAgent499", BetaArchiveAgent499), + "500": decodeError("BetaArchiveAgent500", BetaArchiveAgent500), + "501": decodeError("BetaArchiveAgent501", BetaArchiveAgent501), + "503": decodeError("BetaArchiveAgent503", BetaArchiveAgent503), + "504": decodeError("BetaArchiveAgent504", BetaArchiveAgent504), orElse: unexpectedStatus })) ), - "betaModelsList": (options) => - HttpClientRequest.get(`/v1/models?beta=true`).pipe( + "BetaListAgentVersions": (agentId, options) => + HttpClientRequest.get(`/v1/agents/${agentId}/versions?beta=true`).pipe( HttpClientRequest.setUrlParams({ - "before_id": options?.params?.["before_id"] as any, - "after_id": options?.params?.["after_id"] as any, - "limit": options?.params?.["limit"] as any + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any }), HttpClientRequest.setHeaders({ - "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaModelsList200), - "4xx": decodeError("BetaModelsList4XX", BetaModelsList4XX), + "2xx": decodeSuccess(BetaListAgentVersions200), + "400": decodeError("BetaListAgentVersions400", BetaListAgentVersions400), + "401": decodeError("BetaListAgentVersions401", BetaListAgentVersions401), + "403": decodeError("BetaListAgentVersions403", BetaListAgentVersions403), + "404": decodeError("BetaListAgentVersions404", BetaListAgentVersions404), + "408": decodeError("BetaListAgentVersions408", BetaListAgentVersions408), + "409": decodeError("BetaListAgentVersions409", BetaListAgentVersions409), + "412": decodeError("BetaListAgentVersions412", BetaListAgentVersions412), + "413": decodeError("BetaListAgentVersions413", BetaListAgentVersions413), + "429": decodeError("BetaListAgentVersions429", BetaListAgentVersions429), + "431": decodeError("BetaListAgentVersions431", BetaListAgentVersions431), + "499": decodeError("BetaListAgentVersions499", BetaListAgentVersions499), + "500": decodeError("BetaListAgentVersions500", BetaListAgentVersions500), + "501": decodeError("BetaListAgentVersions501", BetaListAgentVersions501), + "503": decodeError("BetaListAgentVersions503", BetaListAgentVersions503), + "504": decodeError("BetaListAgentVersions504", BetaListAgentVersions504), orElse: unexpectedStatus })) ), - "betaModelsGet": (modelId, options) => - HttpClientRequest.get(`/v1/models/${modelId}?beta=true`).pipe( + "BetaListDeployments": (options) => + HttpClientRequest.get(`/v1/deployments?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "agent_id": options?.params?.["agent_id"] as any, + "status": options?.params?.["status"] as any, + "created_at[gte]": options?.params?.["created_at[gte]"] as any, + "created_at[lte]": options?.params?.["created_at[lte]"] as any, + "include_archived": options?.params?.["include_archived"] as any + }), HttpClientRequest.setHeaders({ - "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaModelsGet200), - "4xx": decodeError("BetaModelsGet4XX", BetaModelsGet4XX), + "2xx": decodeSuccess(BetaListDeployments200), + "400": decodeError("BetaListDeployments400", BetaListDeployments400), + "401": decodeError("BetaListDeployments401", BetaListDeployments401), + "403": decodeError("BetaListDeployments403", BetaListDeployments403), + "404": decodeError("BetaListDeployments404", BetaListDeployments404), + "408": decodeError("BetaListDeployments408", BetaListDeployments408), + "409": decodeError("BetaListDeployments409", BetaListDeployments409), + "412": decodeError("BetaListDeployments412", BetaListDeployments412), + "413": decodeError("BetaListDeployments413", BetaListDeployments413), + "429": decodeError("BetaListDeployments429", BetaListDeployments429), + "431": decodeError("BetaListDeployments431", BetaListDeployments431), + "499": decodeError("BetaListDeployments499", BetaListDeployments499), + "500": decodeError("BetaListDeployments500", BetaListDeployments500), + "501": decodeError("BetaListDeployments501", BetaListDeployments501), + "503": decodeError("BetaListDeployments503", BetaListDeployments503), + "504": decodeError("BetaListDeployments504", BetaListDeployments504), orElse: unexpectedStatus })) ), - "betaMessageBatchesList": (options) => - HttpClientRequest.get(`/v1/messages/batches?beta=true`).pipe( - HttpClientRequest.setUrlParams({ - "before_id": options?.params?.["before_id"] as any, - "after_id": options?.params?.["after_id"] as any, - "limit": options?.params?.["limit"] as any + "BetaCreateDeployment": (options) => + HttpClientRequest.post(`/v1/deployments?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateDeployment200), + "400": decodeError("BetaCreateDeployment400", BetaCreateDeployment400), + "401": decodeError("BetaCreateDeployment401", BetaCreateDeployment401), + "403": decodeError("BetaCreateDeployment403", BetaCreateDeployment403), + "404": decodeError("BetaCreateDeployment404", BetaCreateDeployment404), + "408": decodeError("BetaCreateDeployment408", BetaCreateDeployment408), + "409": decodeError("BetaCreateDeployment409", BetaCreateDeployment409), + "412": decodeError("BetaCreateDeployment412", BetaCreateDeployment412), + "413": decodeError("BetaCreateDeployment413", BetaCreateDeployment413), + "429": decodeError("BetaCreateDeployment429", BetaCreateDeployment429), + "431": decodeError("BetaCreateDeployment431", BetaCreateDeployment431), + "499": decodeError("BetaCreateDeployment499", BetaCreateDeployment499), + "500": decodeError("BetaCreateDeployment500", BetaCreateDeployment500), + "501": decodeError("BetaCreateDeployment501", BetaCreateDeployment501), + "503": decodeError("BetaCreateDeployment503", BetaCreateDeployment503), + "504": decodeError("BetaCreateDeployment504", BetaCreateDeployment504), + orElse: unexpectedStatus + })) + ), + "BetaGetDeployment": (deploymentId, options) => + HttpClientRequest.get(`/v1/deployments/${deploymentId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaMessageBatchesList200), - "4xx": decodeError("BetaMessageBatchesList4XX", BetaMessageBatchesList4XX), + "2xx": decodeSuccess(BetaGetDeployment200), + "400": decodeError("BetaGetDeployment400", BetaGetDeployment400), + "401": decodeError("BetaGetDeployment401", BetaGetDeployment401), + "403": decodeError("BetaGetDeployment403", BetaGetDeployment403), + "404": decodeError("BetaGetDeployment404", BetaGetDeployment404), + "408": decodeError("BetaGetDeployment408", BetaGetDeployment408), + "409": decodeError("BetaGetDeployment409", BetaGetDeployment409), + "412": decodeError("BetaGetDeployment412", BetaGetDeployment412), + "413": decodeError("BetaGetDeployment413", BetaGetDeployment413), + "429": decodeError("BetaGetDeployment429", BetaGetDeployment429), + "431": decodeError("BetaGetDeployment431", BetaGetDeployment431), + "499": decodeError("BetaGetDeployment499", BetaGetDeployment499), + "500": decodeError("BetaGetDeployment500", BetaGetDeployment500), + "501": decodeError("BetaGetDeployment501", BetaGetDeployment501), + "503": decodeError("BetaGetDeployment503", BetaGetDeployment503), + "504": decodeError("BetaGetDeployment504", BetaGetDeployment504), orElse: unexpectedStatus })) ), - "betaMessageBatchesPost": (options) => - HttpClientRequest.post(`/v1/messages/batches?beta=true`).pipe( + "BetaUpdateDeployment": (deploymentId, options) => + HttpClientRequest.post(`/v1/deployments/${deploymentId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options.params?.["anthropic-version"] ?? undefined + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined }), HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaMessageBatchesPost200), - "4xx": decodeError("BetaMessageBatchesPost4XX", BetaMessageBatchesPost4XX), + "2xx": decodeSuccess(BetaUpdateDeployment200), + "400": decodeError("BetaUpdateDeployment400", BetaUpdateDeployment400), + "401": decodeError("BetaUpdateDeployment401", BetaUpdateDeployment401), + "403": decodeError("BetaUpdateDeployment403", BetaUpdateDeployment403), + "404": decodeError("BetaUpdateDeployment404", BetaUpdateDeployment404), + "408": decodeError("BetaUpdateDeployment408", BetaUpdateDeployment408), + "409": decodeError("BetaUpdateDeployment409", BetaUpdateDeployment409), + "412": decodeError("BetaUpdateDeployment412", BetaUpdateDeployment412), + "413": decodeError("BetaUpdateDeployment413", BetaUpdateDeployment413), + "429": decodeError("BetaUpdateDeployment429", BetaUpdateDeployment429), + "431": decodeError("BetaUpdateDeployment431", BetaUpdateDeployment431), + "499": decodeError("BetaUpdateDeployment499", BetaUpdateDeployment499), + "500": decodeError("BetaUpdateDeployment500", BetaUpdateDeployment500), + "501": decodeError("BetaUpdateDeployment501", BetaUpdateDeployment501), + "503": decodeError("BetaUpdateDeployment503", BetaUpdateDeployment503), + "504": decodeError("BetaUpdateDeployment504", BetaUpdateDeployment504), orElse: unexpectedStatus })) ), - "betaMessageBatchesRetrieve": (messageBatchId, options) => - HttpClientRequest.get(`/v1/messages/batches/${messageBatchId}?beta=true`).pipe( + "BetaArchiveDeployment": (deploymentId, options) => + HttpClientRequest.post(`/v1/deployments/${deploymentId}/archive?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaMessageBatchesRetrieve200), - "4xx": decodeError("BetaMessageBatchesRetrieve4XX", BetaMessageBatchesRetrieve4XX), + "2xx": decodeSuccess(BetaArchiveDeployment200), + "400": decodeError("BetaArchiveDeployment400", BetaArchiveDeployment400), + "401": decodeError("BetaArchiveDeployment401", BetaArchiveDeployment401), + "403": decodeError("BetaArchiveDeployment403", BetaArchiveDeployment403), + "404": decodeError("BetaArchiveDeployment404", BetaArchiveDeployment404), + "408": decodeError("BetaArchiveDeployment408", BetaArchiveDeployment408), + "409": decodeError("BetaArchiveDeployment409", BetaArchiveDeployment409), + "412": decodeError("BetaArchiveDeployment412", BetaArchiveDeployment412), + "413": decodeError("BetaArchiveDeployment413", BetaArchiveDeployment413), + "429": decodeError("BetaArchiveDeployment429", BetaArchiveDeployment429), + "431": decodeError("BetaArchiveDeployment431", BetaArchiveDeployment431), + "499": decodeError("BetaArchiveDeployment499", BetaArchiveDeployment499), + "500": decodeError("BetaArchiveDeployment500", BetaArchiveDeployment500), + "501": decodeError("BetaArchiveDeployment501", BetaArchiveDeployment501), + "503": decodeError("BetaArchiveDeployment503", BetaArchiveDeployment503), + "504": decodeError("BetaArchiveDeployment504", BetaArchiveDeployment504), orElse: unexpectedStatus })) ), - "betaMessageBatchesDelete": (messageBatchId, options) => - HttpClientRequest.delete(`/v1/messages/batches/${messageBatchId}?beta=true`).pipe( + "BetaPauseDeployment": (deploymentId, options) => + HttpClientRequest.post(`/v1/deployments/${deploymentId}/pause?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaMessageBatchesDelete200), - "4xx": decodeError("BetaMessageBatchesDelete4XX", BetaMessageBatchesDelete4XX), + "2xx": decodeSuccess(BetaPauseDeployment200), + "400": decodeError("BetaPauseDeployment400", BetaPauseDeployment400), + "401": decodeError("BetaPauseDeployment401", BetaPauseDeployment401), + "403": decodeError("BetaPauseDeployment403", BetaPauseDeployment403), + "404": decodeError("BetaPauseDeployment404", BetaPauseDeployment404), + "408": decodeError("BetaPauseDeployment408", BetaPauseDeployment408), + "409": decodeError("BetaPauseDeployment409", BetaPauseDeployment409), + "412": decodeError("BetaPauseDeployment412", BetaPauseDeployment412), + "413": decodeError("BetaPauseDeployment413", BetaPauseDeployment413), + "429": decodeError("BetaPauseDeployment429", BetaPauseDeployment429), + "431": decodeError("BetaPauseDeployment431", BetaPauseDeployment431), + "499": decodeError("BetaPauseDeployment499", BetaPauseDeployment499), + "500": decodeError("BetaPauseDeployment500", BetaPauseDeployment500), + "501": decodeError("BetaPauseDeployment501", BetaPauseDeployment501), + "503": decodeError("BetaPauseDeployment503", BetaPauseDeployment503), + "504": decodeError("BetaPauseDeployment504", BetaPauseDeployment504), orElse: unexpectedStatus })) ), - "betaMessageBatchesCancel": (messageBatchId, options) => - HttpClientRequest.post(`/v1/messages/batches/${messageBatchId}/cancel?beta=true`).pipe( + "BetaUnpauseDeployment": (deploymentId, options) => + HttpClientRequest.post(`/v1/deployments/${deploymentId}/unpause?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options?.params?.["anthropic-version"] ?? undefined + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaMessageBatchesCancel200), - "4xx": decodeError("BetaMessageBatchesCancel4XX", BetaMessageBatchesCancel4XX), + "2xx": decodeSuccess(BetaUnpauseDeployment200), + "400": decodeError("BetaUnpauseDeployment400", BetaUnpauseDeployment400), + "401": decodeError("BetaUnpauseDeployment401", BetaUnpauseDeployment401), + "403": decodeError("BetaUnpauseDeployment403", BetaUnpauseDeployment403), + "404": decodeError("BetaUnpauseDeployment404", BetaUnpauseDeployment404), + "408": decodeError("BetaUnpauseDeployment408", BetaUnpauseDeployment408), + "409": decodeError("BetaUnpauseDeployment409", BetaUnpauseDeployment409), + "412": decodeError("BetaUnpauseDeployment412", BetaUnpauseDeployment412), + "413": decodeError("BetaUnpauseDeployment413", BetaUnpauseDeployment413), + "429": decodeError("BetaUnpauseDeployment429", BetaUnpauseDeployment429), + "431": decodeError("BetaUnpauseDeployment431", BetaUnpauseDeployment431), + "499": decodeError("BetaUnpauseDeployment499", BetaUnpauseDeployment499), + "500": decodeError("BetaUnpauseDeployment500", BetaUnpauseDeployment500), + "501": decodeError("BetaUnpauseDeployment501", BetaUnpauseDeployment501), + "503": decodeError("BetaUnpauseDeployment503", BetaUnpauseDeployment503), + "504": decodeError("BetaUnpauseDeployment504", BetaUnpauseDeployment504), orElse: unexpectedStatus })) ), - "betaMessageBatchesResults": (messageBatchId, options) => - HttpClientRequest.get(`/v1/messages/batches/${messageBatchId}/results?beta=true`).pipe( + "BetaRunDeploymentNow": (deploymentId, options) => + HttpClientRequest.post(`/v1/deployments/${deploymentId}/run?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "4xx": decodeError("BetaMessageBatchesResults4XX", BetaMessageBatchesResults4XX), + "2xx": decodeSuccess(BetaRunDeploymentNow200), + "400": decodeError("BetaRunDeploymentNow400", BetaRunDeploymentNow400), + "401": decodeError("BetaRunDeploymentNow401", BetaRunDeploymentNow401), + "403": decodeError("BetaRunDeploymentNow403", BetaRunDeploymentNow403), + "404": decodeError("BetaRunDeploymentNow404", BetaRunDeploymentNow404), + "408": decodeError("BetaRunDeploymentNow408", BetaRunDeploymentNow408), + "409": decodeError("BetaRunDeploymentNow409", BetaRunDeploymentNow409), + "412": decodeError("BetaRunDeploymentNow412", BetaRunDeploymentNow412), + "413": decodeError("BetaRunDeploymentNow413", BetaRunDeploymentNow413), + "429": decodeError("BetaRunDeploymentNow429", BetaRunDeploymentNow429), + "431": decodeError("BetaRunDeploymentNow431", BetaRunDeploymentNow431), + "499": decodeError("BetaRunDeploymentNow499", BetaRunDeploymentNow499), + "500": decodeError("BetaRunDeploymentNow500", BetaRunDeploymentNow500), + "501": decodeError("BetaRunDeploymentNow501", BetaRunDeploymentNow501), + "503": decodeError("BetaRunDeploymentNow503", BetaRunDeploymentNow503), + "504": decodeError("BetaRunDeploymentNow504", BetaRunDeploymentNow504), orElse: unexpectedStatus })) ), - "betaMessagesCountTokensPost": (options) => - HttpClientRequest.post(`/v1/messages/count_tokens?beta=true`).pipe( + "BetaListDeploymentRuns": (options) => + HttpClientRequest.get(`/v1/deployment_runs?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "deployment_id": options?.params?.["deployment_id"] as any, + "trigger_type": options?.params?.["trigger_type"] as any, + "has_error": options?.params?.["has_error"] as any, + "created_at[gte]": options?.params?.["created_at[gte]"] as any, + "created_at[lte]": options?.params?.["created_at[lte]"] as any, + "created_at[gt]": options?.params?.["created_at[gt]"] as any, + "created_at[lt]": options?.params?.["created_at[lt]"] as any + }), HttpClientRequest.setHeaders({ - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options.params?.["anthropic-version"] ?? undefined + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), - HttpClientRequest.bodyJsonUnsafe(options.payload), - withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaMessagesCountTokensPost200), - "4xx": decodeError("BetaMessagesCountTokensPost4XX", BetaMessagesCountTokensPost4XX), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListDeploymentRuns200), + "400": decodeError("BetaListDeploymentRuns400", BetaListDeploymentRuns400), + "401": decodeError("BetaListDeploymentRuns401", BetaListDeploymentRuns401), + "403": decodeError("BetaListDeploymentRuns403", BetaListDeploymentRuns403), + "404": decodeError("BetaListDeploymentRuns404", BetaListDeploymentRuns404), + "408": decodeError("BetaListDeploymentRuns408", BetaListDeploymentRuns408), + "409": decodeError("BetaListDeploymentRuns409", BetaListDeploymentRuns409), + "412": decodeError("BetaListDeploymentRuns412", BetaListDeploymentRuns412), + "413": decodeError("BetaListDeploymentRuns413", BetaListDeploymentRuns413), + "429": decodeError("BetaListDeploymentRuns429", BetaListDeploymentRuns429), + "431": decodeError("BetaListDeploymentRuns431", BetaListDeploymentRuns431), + "499": decodeError("BetaListDeploymentRuns499", BetaListDeploymentRuns499), + "500": decodeError("BetaListDeploymentRuns500", BetaListDeploymentRuns500), + "501": decodeError("BetaListDeploymentRuns501", BetaListDeploymentRuns501), + "503": decodeError("BetaListDeploymentRuns503", BetaListDeploymentRuns503), + "504": decodeError("BetaListDeploymentRuns504", BetaListDeploymentRuns504), orElse: unexpectedStatus })) ), - "betaListFilesV1FilesGet": (options) => - HttpClientRequest.get(`/v1/files?beta=true`).pipe( + "BetaGetDeploymentRun": (deploymentRunId, options) => + HttpClientRequest.get(`/v1/deployment_runs/${deploymentRunId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ + "x-api-key": options?.params?.["x-api-key"] ?? undefined, + "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetDeploymentRun200), + "400": decodeError("BetaGetDeploymentRun400", BetaGetDeploymentRun400), + "401": decodeError("BetaGetDeploymentRun401", BetaGetDeploymentRun401), + "403": decodeError("BetaGetDeploymentRun403", BetaGetDeploymentRun403), + "404": decodeError("BetaGetDeploymentRun404", BetaGetDeploymentRun404), + "408": decodeError("BetaGetDeploymentRun408", BetaGetDeploymentRun408), + "409": decodeError("BetaGetDeploymentRun409", BetaGetDeploymentRun409), + "412": decodeError("BetaGetDeploymentRun412", BetaGetDeploymentRun412), + "413": decodeError("BetaGetDeploymentRun413", BetaGetDeploymentRun413), + "429": decodeError("BetaGetDeploymentRun429", BetaGetDeploymentRun429), + "431": decodeError("BetaGetDeploymentRun431", BetaGetDeploymentRun431), + "499": decodeError("BetaGetDeploymentRun499", BetaGetDeploymentRun499), + "500": decodeError("BetaGetDeploymentRun500", BetaGetDeploymentRun500), + "501": decodeError("BetaGetDeploymentRun501", BetaGetDeploymentRun501), + "503": decodeError("BetaGetDeploymentRun503", BetaGetDeploymentRun503), + "504": decodeError("BetaGetDeploymentRun504", BetaGetDeploymentRun504), + orElse: unexpectedStatus + })) + ), + "BetaListVaults": (options) => + HttpClientRequest.get(`/v1/vaults?beta=true`).pipe( HttpClientRequest.setUrlParams({ - "before_id": options?.params?.["before_id"] as any, - "after_id": options?.params?.["after_id"] as any, - "limit": options?.params?.["limit"] as any + "limit": options?.params?.["limit"] as any, + "page": options?.params?.["page"] as any, + "include_archived": options?.params?.["include_archived"] as any }), HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaListFilesV1FilesGet200), - "4xx": decodeError("BetaListFilesV1FilesGet4XX", BetaListFilesV1FilesGet4XX), + "2xx": decodeSuccess(BetaListVaults200), + "400": decodeError("BetaListVaults400", BetaListVaults400), + "401": decodeError("BetaListVaults401", BetaListVaults401), + "403": decodeError("BetaListVaults403", BetaListVaults403), + "404": decodeError("BetaListVaults404", BetaListVaults404), + "408": decodeError("BetaListVaults408", BetaListVaults408), + "409": decodeError("BetaListVaults409", BetaListVaults409), + "412": decodeError("BetaListVaults412", BetaListVaults412), + "413": decodeError("BetaListVaults413", BetaListVaults413), + "429": decodeError("BetaListVaults429", BetaListVaults429), + "431": decodeError("BetaListVaults431", BetaListVaults431), + "499": decodeError("BetaListVaults499", BetaListVaults499), + "500": decodeError("BetaListVaults500", BetaListVaults500), + "501": decodeError("BetaListVaults501", BetaListVaults501), + "503": decodeError("BetaListVaults503", BetaListVaults503), + "504": decodeError("BetaListVaults504", BetaListVaults504), orElse: unexpectedStatus })) ), - "betaUploadFileV1FilesPost": (options) => - HttpClientRequest.post(`/v1/files?beta=true`).pipe( + "BetaCreateVault": (options) => + HttpClientRequest.post(`/v1/vaults?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options.params?.["anthropic-version"] ?? undefined + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined }), - HttpClientRequest.bodyFormData(options.payload as any), + HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaUploadFileV1FilesPost200), - "4xx": decodeError("BetaUploadFileV1FilesPost4XX", BetaUploadFileV1FilesPost4XX), + "2xx": decodeSuccess(BetaCreateVault200), + "400": decodeError("BetaCreateVault400", BetaCreateVault400), + "401": decodeError("BetaCreateVault401", BetaCreateVault401), + "403": decodeError("BetaCreateVault403", BetaCreateVault403), + "404": decodeError("BetaCreateVault404", BetaCreateVault404), + "408": decodeError("BetaCreateVault408", BetaCreateVault408), + "409": decodeError("BetaCreateVault409", BetaCreateVault409), + "412": decodeError("BetaCreateVault412", BetaCreateVault412), + "413": decodeError("BetaCreateVault413", BetaCreateVault413), + "429": decodeError("BetaCreateVault429", BetaCreateVault429), + "431": decodeError("BetaCreateVault431", BetaCreateVault431), + "499": decodeError("BetaCreateVault499", BetaCreateVault499), + "500": decodeError("BetaCreateVault500", BetaCreateVault500), + "501": decodeError("BetaCreateVault501", BetaCreateVault501), + "503": decodeError("BetaCreateVault503", BetaCreateVault503), + "504": decodeError("BetaCreateVault504", BetaCreateVault504), orElse: unexpectedStatus })) ), - "betaGetFileMetadataV1FilesFileIdGet": (fileId, options) => - HttpClientRequest.get(`/v1/files/${fileId}?beta=true`).pipe( + "BetaGetVault": (vaultId, options) => + HttpClientRequest.get(`/v1/vaults/${vaultId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaGetFileMetadataV1FilesFileIdGet200), - "4xx": decodeError("BetaGetFileMetadataV1FilesFileIdGet4XX", BetaGetFileMetadataV1FilesFileIdGet4XX), + "2xx": decodeSuccess(BetaGetVault200), + "400": decodeError("BetaGetVault400", BetaGetVault400), + "401": decodeError("BetaGetVault401", BetaGetVault401), + "403": decodeError("BetaGetVault403", BetaGetVault403), + "404": decodeError("BetaGetVault404", BetaGetVault404), + "408": decodeError("BetaGetVault408", BetaGetVault408), + "409": decodeError("BetaGetVault409", BetaGetVault409), + "412": decodeError("BetaGetVault412", BetaGetVault412), + "413": decodeError("BetaGetVault413", BetaGetVault413), + "429": decodeError("BetaGetVault429", BetaGetVault429), + "431": decodeError("BetaGetVault431", BetaGetVault431), + "499": decodeError("BetaGetVault499", BetaGetVault499), + "500": decodeError("BetaGetVault500", BetaGetVault500), + "501": decodeError("BetaGetVault501", BetaGetVault501), + "503": decodeError("BetaGetVault503", BetaGetVault503), + "504": decodeError("BetaGetVault504", BetaGetVault504), orElse: unexpectedStatus })) ), - "betaDeleteFileV1FilesFileIdDelete": (fileId, options) => - HttpClientRequest.delete(`/v1/files/${fileId}?beta=true`).pipe( + "BetaUpdateVault": (vaultId, options) => + HttpClientRequest.post(`/v1/vaults/${vaultId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined }), - withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaDeleteFileV1FilesFileIdDelete200), - "4xx": decodeError("BetaDeleteFileV1FilesFileIdDelete4XX", BetaDeleteFileV1FilesFileIdDelete4XX), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateVault200), + "400": decodeError("BetaUpdateVault400", BetaUpdateVault400), + "401": decodeError("BetaUpdateVault401", BetaUpdateVault401), + "403": decodeError("BetaUpdateVault403", BetaUpdateVault403), + "404": decodeError("BetaUpdateVault404", BetaUpdateVault404), + "408": decodeError("BetaUpdateVault408", BetaUpdateVault408), + "409": decodeError("BetaUpdateVault409", BetaUpdateVault409), + "412": decodeError("BetaUpdateVault412", BetaUpdateVault412), + "413": decodeError("BetaUpdateVault413", BetaUpdateVault413), + "429": decodeError("BetaUpdateVault429", BetaUpdateVault429), + "431": decodeError("BetaUpdateVault431", BetaUpdateVault431), + "499": decodeError("BetaUpdateVault499", BetaUpdateVault499), + "500": decodeError("BetaUpdateVault500", BetaUpdateVault500), + "501": decodeError("BetaUpdateVault501", BetaUpdateVault501), + "503": decodeError("BetaUpdateVault503", BetaUpdateVault503), + "504": decodeError("BetaUpdateVault504", BetaUpdateVault504), orElse: unexpectedStatus })) ), - "betaDownloadFileV1FilesFileIdContentGet": (fileId, options) => - HttpClientRequest.get(`/v1/files/${fileId}/content?beta=true`).pipe( + "BetaDeleteVault": (vaultId, options) => + HttpClientRequest.delete(`/v1/vaults/${vaultId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaDeleteVault200), + "400": decodeError("BetaDeleteVault400", BetaDeleteVault400), + "401": decodeError("BetaDeleteVault401", BetaDeleteVault401), + "403": decodeError("BetaDeleteVault403", BetaDeleteVault403), + "404": decodeError("BetaDeleteVault404", BetaDeleteVault404), + "408": decodeError("BetaDeleteVault408", BetaDeleteVault408), + "409": decodeError("BetaDeleteVault409", BetaDeleteVault409), + "412": decodeError("BetaDeleteVault412", BetaDeleteVault412), + "413": decodeError("BetaDeleteVault413", BetaDeleteVault413), + "429": decodeError("BetaDeleteVault429", BetaDeleteVault429), + "431": decodeError("BetaDeleteVault431", BetaDeleteVault431), + "499": decodeError("BetaDeleteVault499", BetaDeleteVault499), + "500": decodeError("BetaDeleteVault500", BetaDeleteVault500), + "501": decodeError("BetaDeleteVault501", BetaDeleteVault501), + "503": decodeError("BetaDeleteVault503", BetaDeleteVault503), + "504": decodeError("BetaDeleteVault504", BetaDeleteVault504), orElse: unexpectedStatus })) ), - "betaDownloadFileV1FilesFileIdContentGetStream": (fileId, options) => - HttpClientRequest.get(`/v1/files/${fileId}/content?beta=true`).pipe( + "BetaArchiveVault": (vaultId, options) => + HttpClientRequest.post(`/v1/vaults/${vaultId}/archive?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), - binaryRequest + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaArchiveVault200), + "400": decodeError("BetaArchiveVault400", BetaArchiveVault400), + "401": decodeError("BetaArchiveVault401", BetaArchiveVault401), + "403": decodeError("BetaArchiveVault403", BetaArchiveVault403), + "404": decodeError("BetaArchiveVault404", BetaArchiveVault404), + "408": decodeError("BetaArchiveVault408", BetaArchiveVault408), + "409": decodeError("BetaArchiveVault409", BetaArchiveVault409), + "412": decodeError("BetaArchiveVault412", BetaArchiveVault412), + "413": decodeError("BetaArchiveVault413", BetaArchiveVault413), + "429": decodeError("BetaArchiveVault429", BetaArchiveVault429), + "431": decodeError("BetaArchiveVault431", BetaArchiveVault431), + "499": decodeError("BetaArchiveVault499", BetaArchiveVault499), + "500": decodeError("BetaArchiveVault500", BetaArchiveVault500), + "501": decodeError("BetaArchiveVault501", BetaArchiveVault501), + "503": decodeError("BetaArchiveVault503", BetaArchiveVault503), + "504": decodeError("BetaArchiveVault504", BetaArchiveVault504), + orElse: unexpectedStatus + })) ), - "betaListSkillsV1SkillsGet": (options) => - HttpClientRequest.get(`/v1/skills?beta=true`).pipe( + "BetaListCredentials": (vaultId, options) => + HttpClientRequest.get(`/v1/vaults/${vaultId}/credentials?beta=true`).pipe( HttpClientRequest.setUrlParams({ - "page": options?.params?.["page"] as any, "limit": options?.params?.["limit"] as any, - "source": options?.params?.["source"] as any + "page": options?.params?.["page"] as any, + "include_archived": options?.params?.["include_archived"] as any }), HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaListSkillsV1SkillsGet200), - "4xx": decodeError("BetaListSkillsV1SkillsGet4XX", BetaListSkillsV1SkillsGet4XX), + "2xx": decodeSuccess(BetaListCredentials200), + "400": decodeError("BetaListCredentials400", BetaListCredentials400), + "401": decodeError("BetaListCredentials401", BetaListCredentials401), + "403": decodeError("BetaListCredentials403", BetaListCredentials403), + "404": decodeError("BetaListCredentials404", BetaListCredentials404), + "408": decodeError("BetaListCredentials408", BetaListCredentials408), + "409": decodeError("BetaListCredentials409", BetaListCredentials409), + "412": decodeError("BetaListCredentials412", BetaListCredentials412), + "413": decodeError("BetaListCredentials413", BetaListCredentials413), + "429": decodeError("BetaListCredentials429", BetaListCredentials429), + "431": decodeError("BetaListCredentials431", BetaListCredentials431), + "499": decodeError("BetaListCredentials499", BetaListCredentials499), + "500": decodeError("BetaListCredentials500", BetaListCredentials500), + "501": decodeError("BetaListCredentials501", BetaListCredentials501), + "503": decodeError("BetaListCredentials503", BetaListCredentials503), + "504": decodeError("BetaListCredentials504", BetaListCredentials504), orElse: unexpectedStatus })) ), - "betaCreateSkillV1SkillsPost": (options) => - HttpClientRequest.post(`/v1/skills?beta=true`).pipe( + "BetaCreateCredential": (vaultId, options) => + HttpClientRequest.post(`/v1/vaults/${vaultId}/credentials?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options.params?.["anthropic-version"] ?? undefined + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined }), - HttpClientRequest.bodyFormData(options.payload as any), + HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaCreateSkillV1SkillsPost200), - "4xx": decodeError("BetaCreateSkillV1SkillsPost4XX", BetaCreateSkillV1SkillsPost4XX), + "2xx": decodeSuccess(BetaCreateCredential200), + "400": decodeError("BetaCreateCredential400", BetaCreateCredential400), + "401": decodeError("BetaCreateCredential401", BetaCreateCredential401), + "403": decodeError("BetaCreateCredential403", BetaCreateCredential403), + "404": decodeError("BetaCreateCredential404", BetaCreateCredential404), + "408": decodeError("BetaCreateCredential408", BetaCreateCredential408), + "409": decodeError("BetaCreateCredential409", BetaCreateCredential409), + "412": decodeError("BetaCreateCredential412", BetaCreateCredential412), + "413": decodeError("BetaCreateCredential413", BetaCreateCredential413), + "429": decodeError("BetaCreateCredential429", BetaCreateCredential429), + "431": decodeError("BetaCreateCredential431", BetaCreateCredential431), + "499": decodeError("BetaCreateCredential499", BetaCreateCredential499), + "500": decodeError("BetaCreateCredential500", BetaCreateCredential500), + "501": decodeError("BetaCreateCredential501", BetaCreateCredential501), + "503": decodeError("BetaCreateCredential503", BetaCreateCredential503), + "504": decodeError("BetaCreateCredential504", BetaCreateCredential504), orElse: unexpectedStatus })) ), - "betaGetSkillV1SkillsSkillIdGet": (skillId, options) => - HttpClientRequest.get(`/v1/skills/${skillId}?beta=true`).pipe( + "BetaGetCredential": (vaultId, credentialId, options) => + HttpClientRequest.get(`/v1/vaults/${vaultId}/credentials/${credentialId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaGetSkillV1SkillsSkillIdGet200), - "4xx": decodeError("BetaGetSkillV1SkillsSkillIdGet4XX", BetaGetSkillV1SkillsSkillIdGet4XX), + "2xx": decodeSuccess(BetaGetCredential200), + "400": decodeError("BetaGetCredential400", BetaGetCredential400), + "401": decodeError("BetaGetCredential401", BetaGetCredential401), + "403": decodeError("BetaGetCredential403", BetaGetCredential403), + "404": decodeError("BetaGetCredential404", BetaGetCredential404), + "408": decodeError("BetaGetCredential408", BetaGetCredential408), + "409": decodeError("BetaGetCredential409", BetaGetCredential409), + "412": decodeError("BetaGetCredential412", BetaGetCredential412), + "413": decodeError("BetaGetCredential413", BetaGetCredential413), + "429": decodeError("BetaGetCredential429", BetaGetCredential429), + "431": decodeError("BetaGetCredential431", BetaGetCredential431), + "499": decodeError("BetaGetCredential499", BetaGetCredential499), + "500": decodeError("BetaGetCredential500", BetaGetCredential500), + "501": decodeError("BetaGetCredential501", BetaGetCredential501), + "503": decodeError("BetaGetCredential503", BetaGetCredential503), + "504": decodeError("BetaGetCredential504", BetaGetCredential504), orElse: unexpectedStatus })) ), - "betaDeleteSkillV1SkillsSkillIdDelete": (skillId, options) => - HttpClientRequest.delete(`/v1/skills/${skillId}?beta=true`).pipe( + "BetaUpdateCredential": (vaultId, credentialId, options) => + HttpClientRequest.post(`/v1/vaults/${vaultId}/credentials/${credentialId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-version": options.params?.["anthropic-version"] ?? undefined, + "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined }), - withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaDeleteSkillV1SkillsSkillIdDelete200), - "4xx": decodeError("BetaDeleteSkillV1SkillsSkillIdDelete4XX", BetaDeleteSkillV1SkillsSkillIdDelete4XX), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaUpdateCredential200), + "400": decodeError("BetaUpdateCredential400", BetaUpdateCredential400), + "401": decodeError("BetaUpdateCredential401", BetaUpdateCredential401), + "403": decodeError("BetaUpdateCredential403", BetaUpdateCredential403), + "404": decodeError("BetaUpdateCredential404", BetaUpdateCredential404), + "408": decodeError("BetaUpdateCredential408", BetaUpdateCredential408), + "409": decodeError("BetaUpdateCredential409", BetaUpdateCredential409), + "412": decodeError("BetaUpdateCredential412", BetaUpdateCredential412), + "413": decodeError("BetaUpdateCredential413", BetaUpdateCredential413), + "429": decodeError("BetaUpdateCredential429", BetaUpdateCredential429), + "431": decodeError("BetaUpdateCredential431", BetaUpdateCredential431), + "499": decodeError("BetaUpdateCredential499", BetaUpdateCredential499), + "500": decodeError("BetaUpdateCredential500", BetaUpdateCredential500), + "501": decodeError("BetaUpdateCredential501", BetaUpdateCredential501), + "503": decodeError("BetaUpdateCredential503", BetaUpdateCredential503), + "504": decodeError("BetaUpdateCredential504", BetaUpdateCredential504), orElse: unexpectedStatus })) ), - "betaListSkillVersionsV1SkillsSkillIdVersionsGet": (skillId, options) => - HttpClientRequest.get(`/v1/skills/${skillId}/versions?beta=true`).pipe( - HttpClientRequest.setUrlParams({ - "page": options?.params?.["page"] as any, - "limit": options?.params?.["limit"] as any - }), + "BetaDeleteCredential": (vaultId, credentialId, options) => + HttpClientRequest.delete(`/v1/vaults/${vaultId}/credentials/${credentialId}?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, + "x-api-key": options?.params?.["x-api-key"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaListSkillVersionsV1SkillsSkillIdVersionsGet200), - "4xx": decodeError( - "BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX", - BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX - ), - orElse: unexpectedStatus - })) - ), - "betaCreateSkillVersionV1SkillsSkillIdVersionsPost": (skillId, options) => - HttpClientRequest.post(`/v1/skills/${skillId}/versions?beta=true`).pipe( - HttpClientRequest.setHeaders({ - "anthropic-beta": options.params?.["anthropic-beta"] ?? undefined, - "anthropic-version": options.params?.["anthropic-version"] ?? undefined - }), - HttpClientRequest.bodyFormData(options.payload as any), - withResponse(options.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaCreateSkillVersionV1SkillsSkillIdVersionsPost200), - "4xx": decodeError( - "BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX", - BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX - ), + "2xx": decodeSuccess(BetaDeleteCredential200), + "400": decodeError("BetaDeleteCredential400", BetaDeleteCredential400), + "401": decodeError("BetaDeleteCredential401", BetaDeleteCredential401), + "403": decodeError("BetaDeleteCredential403", BetaDeleteCredential403), + "404": decodeError("BetaDeleteCredential404", BetaDeleteCredential404), + "408": decodeError("BetaDeleteCredential408", BetaDeleteCredential408), + "409": decodeError("BetaDeleteCredential409", BetaDeleteCredential409), + "412": decodeError("BetaDeleteCredential412", BetaDeleteCredential412), + "413": decodeError("BetaDeleteCredential413", BetaDeleteCredential413), + "429": decodeError("BetaDeleteCredential429", BetaDeleteCredential429), + "431": decodeError("BetaDeleteCredential431", BetaDeleteCredential431), + "499": decodeError("BetaDeleteCredential499", BetaDeleteCredential499), + "500": decodeError("BetaDeleteCredential500", BetaDeleteCredential500), + "501": decodeError("BetaDeleteCredential501", BetaDeleteCredential501), + "503": decodeError("BetaDeleteCredential503", BetaDeleteCredential503), + "504": decodeError("BetaDeleteCredential504", BetaDeleteCredential504), orElse: unexpectedStatus })) ), - "betaGetSkillVersionV1SkillsSkillIdVersionsVersionGet": (skillId, version, options) => - HttpClientRequest.get(`/v1/skills/${skillId}/versions/${version}?beta=true`).pipe( + "BetaArchiveCredential": (vaultId, credentialId, options) => + HttpClientRequest.post(`/v1/vaults/${vaultId}/credentials/${credentialId}/archive?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet200), - "4xx": decodeError( - "BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX", - BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX - ), + "2xx": decodeSuccess(BetaArchiveCredential200), + "400": decodeError("BetaArchiveCredential400", BetaArchiveCredential400), + "401": decodeError("BetaArchiveCredential401", BetaArchiveCredential401), + "403": decodeError("BetaArchiveCredential403", BetaArchiveCredential403), + "404": decodeError("BetaArchiveCredential404", BetaArchiveCredential404), + "408": decodeError("BetaArchiveCredential408", BetaArchiveCredential408), + "409": decodeError("BetaArchiveCredential409", BetaArchiveCredential409), + "412": decodeError("BetaArchiveCredential412", BetaArchiveCredential412), + "413": decodeError("BetaArchiveCredential413", BetaArchiveCredential413), + "429": decodeError("BetaArchiveCredential429", BetaArchiveCredential429), + "431": decodeError("BetaArchiveCredential431", BetaArchiveCredential431), + "499": decodeError("BetaArchiveCredential499", BetaArchiveCredential499), + "500": decodeError("BetaArchiveCredential500", BetaArchiveCredential500), + "501": decodeError("BetaArchiveCredential501", BetaArchiveCredential501), + "503": decodeError("BetaArchiveCredential503", BetaArchiveCredential503), + "504": decodeError("BetaArchiveCredential504", BetaArchiveCredential504), orElse: unexpectedStatus })) ), - "betaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete": (skillId, version, options) => - HttpClientRequest.delete(`/v1/skills/${skillId}/versions/${version}?beta=true`).pipe( + "BetaValidateCredential": (vaultId, credentialId, options) => + HttpClientRequest.post(`/v1/vaults/${vaultId}/credentials/${credentialId}/mcp_oauth_validate?beta=true`).pipe( HttpClientRequest.setHeaders({ - "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined, "anthropic-version": options?.params?.["anthropic-version"] ?? undefined, - "x-api-key": options?.params?.["x-api-key"] ?? undefined + "anthropic-beta": options?.params?.["anthropic-beta"] ?? undefined }), withResponse(options?.config)(HttpClientResponse.matchStatus({ - "2xx": decodeSuccess(BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete200), - "4xx": decodeError( - "BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX", - BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX - ), + "2xx": decodeSuccess(BetaValidateCredential200), + "400": decodeError("BetaValidateCredential400", BetaValidateCredential400), + "401": decodeError("BetaValidateCredential401", BetaValidateCredential401), + "403": decodeError("BetaValidateCredential403", BetaValidateCredential403), + "404": decodeError("BetaValidateCredential404", BetaValidateCredential404), + "408": decodeError("BetaValidateCredential408", BetaValidateCredential408), + "409": decodeError("BetaValidateCredential409", BetaValidateCredential409), + "412": decodeError("BetaValidateCredential412", BetaValidateCredential412), + "413": decodeError("BetaValidateCredential413", BetaValidateCredential413), + "429": decodeError("BetaValidateCredential429", BetaValidateCredential429), + "431": decodeError("BetaValidateCredential431", BetaValidateCredential431), + "499": decodeError("BetaValidateCredential499", BetaValidateCredential499), + "500": decodeError("BetaValidateCredential500", BetaValidateCredential500), + "501": decodeError("BetaValidateCredential501", BetaValidateCredential501), + "503": decodeError("BetaValidateCredential503", BetaValidateCredential503), + "504": decodeError("BetaValidateCredential504", BetaValidateCredential504), orElse: unexpectedStatus })) ) @@ -11774,794 +27545,3285 @@ export const make = ( export interface AnthropicClient { readonly httpClient: HttpClient.HttpClient /** - * Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation. + * Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation. + * + * The Messages API can be used for either single queries or stateless multi-turn conversations. + * + * Learn more about the Messages API in our [user guide](https://platform.claude.com/docs/en/get-started) + */ + readonly "messagesPost": ( + options: { + readonly params?: typeof MessagesPostParams.Encoded | undefined + readonly payload: typeof MessagesPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError | AnthropicClientError<"MessagesPost4XX", typeof MessagesPost4XX.Type> + > + /** + * [Legacy] Create a Text Completion. + * + * The Text Completions API is a legacy API. We recommend using the [Messages API](https://platform.claude.com/docs/en/api/messages) going forward. + * + * Future models and features will not be compatible with Text Completions. See our [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) for guidance in migrating from Text Completions to Messages. + */ + readonly "completePost": ( + options: { + readonly params?: typeof CompletePostParams.Encoded | undefined + readonly payload: typeof CompletePostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError | AnthropicClientError<"CompletePost4XX", typeof CompletePost4XX.Type> + > + /** + * List available models. + * + * The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first. + */ + readonly "modelsList": ( + options: + | { readonly params?: typeof ModelsListParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError | AnthropicClientError<"ModelsList4XX", typeof ModelsList4XX.Type> + > + /** + * Get a specific model. + * + * The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID. + */ + readonly "modelsGet": ( + modelId: string, + options: + | { readonly params?: typeof ModelsGetParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError | AnthropicClientError<"ModelsGet4XX", typeof ModelsGet4XX.Type> + > + /** + * List all Message Batches within a Workspace. Most recently created batches are returned first. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "messageBatchesList": ( + options: { + readonly params?: typeof MessageBatchesListParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"MessageBatchesList4XX", typeof MessageBatchesList4XX.Type> + > + /** + * Send a batch of Message creation requests. + * + * The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "messageBatchesPost": ( + options: { + readonly params?: typeof MessageBatchesPostParams.Encoded | undefined + readonly payload: typeof MessageBatchesPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"MessageBatchesPost4XX", typeof MessageBatchesPost4XX.Type> + > + /** + * This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "messageBatchesRetrieve": ( + messageBatchId: string, + options: { + readonly params?: typeof MessageBatchesRetrieveParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"MessageBatchesRetrieve4XX", typeof MessageBatchesRetrieve4XX.Type> + > + /** + * Delete a Message Batch. + * + * Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "messageBatchesDelete": ( + messageBatchId: string, + options: { + readonly params?: typeof MessageBatchesDeleteParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"MessageBatchesDelete4XX", typeof MessageBatchesDelete4XX.Type> + > + /** + * Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation. + * + * The number of canceled requests is specified in `request_counts`. To determine which requests were canceled, check the individual results within the batch. Note that cancellation may not result in any canceled requests if they were non-interruptible. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "messageBatchesCancel": ( + messageBatchId: string, + options: { + readonly params?: typeof MessageBatchesCancelParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"MessageBatchesCancel4XX", typeof MessageBatchesCancel4XX.Type> + > + /** + * Streams the results of a Message Batch as a `.jsonl` file. + * + * Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "messageBatchesResults": ( + messageBatchId: string, + options: { + readonly params?: typeof MessageBatchesResultsParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"MessageBatchesResults4XX", typeof MessageBatchesResults4XX.Type> + > + /** + * Count the number of tokens in a Message. + * + * The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it. + * + * Learn more about token counting in our [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting) + */ + readonly "messagesCountTokensPost": ( + options: { + readonly params?: typeof MessagesCountTokensPostParams.Encoded | undefined + readonly payload: typeof MessagesCountTokensPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"MessagesCountTokensPost4XX", typeof MessagesCountTokensPost4XX.Type> + > + /** + * Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation. + * + * The Messages API can be used for either single queries or stateless multi-turn conversations. + * + * Learn more about the Messages API in our [user guide](https://platform.claude.com/docs/en/get-started) + */ + readonly "betaMessagesPost": ( + options: { + readonly params?: typeof BetaMessagesPostParams.Encoded | undefined + readonly payload: typeof BetaMessagesPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaMessagesPost4XX", typeof BetaMessagesPost4XX.Type> + > + /** + * List available models. + * + * The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first. + */ + readonly "betaModelsList": ( + options: + | { readonly params?: typeof BetaModelsListParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaModelsList4XX", typeof BetaModelsList4XX.Type> + > + /** + * Get a specific model. + * + * The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID. + */ + readonly "betaModelsGet": ( + modelId: string, + options: + | { readonly params?: typeof BetaModelsGetParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaModelsGet4XX", typeof BetaModelsGet4XX.Type> + > + /** + * List all Message Batches within a Workspace. Most recently created batches are returned first. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "betaMessageBatchesList": ( + options: { + readonly params?: typeof BetaMessageBatchesListParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaMessageBatchesList4XX", typeof BetaMessageBatchesList4XX.Type> + > + /** + * Send a batch of Message creation requests. + * + * The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "betaMessageBatchesPost": ( + options: { + readonly params?: typeof BetaMessageBatchesPostParams.Encoded | undefined + readonly payload: typeof BetaMessageBatchesPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaMessageBatchesPost4XX", typeof BetaMessageBatchesPost4XX.Type> + > + /** + * This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "betaMessageBatchesRetrieve": ( + messageBatchId: string, + options: { + readonly params?: typeof BetaMessageBatchesRetrieveParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaMessageBatchesRetrieve4XX", typeof BetaMessageBatchesRetrieve4XX.Type> + > + /** + * Delete a Message Batch. + * + * Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "betaMessageBatchesDelete": ( + messageBatchId: string, + options: { + readonly params?: typeof BetaMessageBatchesDeleteParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaMessageBatchesDelete4XX", typeof BetaMessageBatchesDelete4XX.Type> + > + /** + * Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation. + * + * The number of canceled requests is specified in `request_counts`. To determine which requests were canceled, check the individual results within the batch. Note that cancellation may not result in any canceled requests if they were non-interruptible. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "betaMessageBatchesCancel": ( + messageBatchId: string, + options: { + readonly params?: typeof BetaMessageBatchesCancelParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaMessageBatchesCancel4XX", typeof BetaMessageBatchesCancel4XX.Type> + > + /** + * Streams the results of a Message Batch as a `.jsonl` file. + * + * Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests. + * + * Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing) + */ + readonly "betaMessageBatchesResults": ( + messageBatchId: string, + options: { + readonly params?: typeof BetaMessageBatchesResultsParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaMessageBatchesResults4XX", typeof BetaMessageBatchesResults4XX.Type> + > + /** + * Count the number of tokens in a Message. + * + * The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it. + * + * Learn more about token counting in our [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting) + */ + readonly "betaMessagesCountTokensPost": ( + options: { + readonly params?: typeof BetaMessagesCountTokensPostParams.Encoded | undefined + readonly payload: typeof BetaMessagesCountTokensPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaMessagesCountTokensPost4XX", typeof BetaMessagesCountTokensPost4XX.Type> + > + /** + * List Files + */ + readonly "betaListFilesV1FilesGet": ( + options: { + readonly params?: typeof BetaListFilesV1FilesGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListFilesV1FilesGet4XX", typeof BetaListFilesV1FilesGet4XX.Type> + > + /** + * Upload File + */ + readonly "betaUploadFileV1FilesPost": ( + options: { + readonly params?: typeof BetaUploadFileV1FilesPostParams.Encoded | undefined + readonly payload: typeof BetaUploadFileV1FilesPostRequestFormData.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaUploadFileV1FilesPost4XX", typeof BetaUploadFileV1FilesPost4XX.Type> + > + /** + * Get File Metadata + */ + readonly "betaGetFileMetadataV1FilesFileIdGet": ( + fileId: string, + options: { + readonly params?: typeof BetaGetFileMetadataV1FilesFileIdGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetFileMetadataV1FilesFileIdGet4XX", typeof BetaGetFileMetadataV1FilesFileIdGet4XX.Type> + > + /** + * Delete File + */ + readonly "betaDeleteFileV1FilesFileIdDelete": ( + fileId: string, + options: { + readonly params?: typeof BetaDeleteFileV1FilesFileIdDeleteParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaDeleteFileV1FilesFileIdDelete4XX", typeof BetaDeleteFileV1FilesFileIdDelete4XX.Type> + > + /** + * Download File + */ + readonly "betaDownloadFileV1FilesFileIdContentGet": ( + fileId: string, + options: { + readonly params?: typeof BetaDownloadFileV1FilesFileIdContentGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect, HttpClientError.HttpClientError | SchemaError> + /** + * Download File + */ + readonly "betaDownloadFileV1FilesFileIdContentGetStream": ( + fileId: string, + options: { readonly params?: typeof BetaDownloadFileV1FilesFileIdContentGetParams.Encoded | undefined } | undefined + ) => Stream.Stream + /** + * List Skills + */ + readonly "betaListSkillsV1SkillsGet": ( + options: { + readonly params?: typeof BetaListSkillsV1SkillsGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListSkillsV1SkillsGet4XX", typeof BetaListSkillsV1SkillsGet4XX.Type> + > + /** + * Create Skill + */ + readonly "betaCreateSkillV1SkillsPost": ( + options: { + readonly params?: typeof BetaCreateSkillV1SkillsPostParams.Encoded | undefined + readonly payload: typeof BetaCreateSkillV1SkillsPostRequestFormData.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaCreateSkillV1SkillsPost4XX", typeof BetaCreateSkillV1SkillsPost4XX.Type> + > + /** + * Get Skill + */ + readonly "betaGetSkillV1SkillsSkillIdGet": ( + skillId: string, + options: { + readonly params?: typeof BetaGetSkillV1SkillsSkillIdGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetSkillV1SkillsSkillIdGet4XX", typeof BetaGetSkillV1SkillsSkillIdGet4XX.Type> + > + /** + * Delete Skill + */ + readonly "betaDeleteSkillV1SkillsSkillIdDelete": ( + skillId: string, + options: { + readonly params?: typeof BetaDeleteSkillV1SkillsSkillIdDeleteParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaDeleteSkillV1SkillsSkillIdDelete4XX", + typeof BetaDeleteSkillV1SkillsSkillIdDelete4XX.Type + > + > + /** + * List Skill Versions + */ + readonly "betaListSkillVersionsV1SkillsSkillIdVersionsGet": ( + skillId: string, + options: { + readonly params?: typeof BetaListSkillVersionsV1SkillsSkillIdVersionsGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX", + typeof BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX.Type + > + > + /** + * Create Skill Version + */ + readonly "betaCreateSkillVersionV1SkillsSkillIdVersionsPost": ( + skillId: string, + options: { + readonly params?: typeof BetaCreateSkillVersionV1SkillsSkillIdVersionsPostParams.Encoded | undefined + readonly payload: typeof BetaCreateSkillVersionV1SkillsSkillIdVersionsPostRequestFormData.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX", + typeof BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX.Type + > + > + /** + * Get Skill Version + */ + readonly "betaGetSkillVersionV1SkillsSkillIdVersionsVersionGet": ( + skillId: string, + version: string, + options: { + readonly params?: typeof BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX", + typeof BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX.Type + > + > + /** + * Delete Skill Version + */ + readonly "betaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete": ( + skillId: string, + version: string, + options: { + readonly params?: typeof BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDeleteParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX", + typeof BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX.Type + > + > + /** + * Download a skill version's content as a zip archive. + */ + readonly "betaDownloadSkillVersionContentV1SkillsSkillIdVersionsVersionContentGet": ( + skillId: string, + version: string, + options: { + readonly params?: + | typeof BetaDownloadSkillVersionContentV1SkillsSkillIdVersionsVersionContentGetParams.Encoded + | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect, HttpClientError.HttpClientError | SchemaError> + /** + * List environments with pagination support. + */ + readonly "betaListEnvironmentsV1EnvironmentsGet": ( + options: { + readonly params?: typeof BetaListEnvironmentsV1EnvironmentsGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaListEnvironmentsV1EnvironmentsGet4XX", + typeof BetaListEnvironmentsV1EnvironmentsGet4XX.Type + > + > + /** + * Create a new environment with the specified configuration. + */ + readonly "betaCreateEnvironmentV1EnvironmentsPost": ( + options: { + readonly params?: typeof BetaCreateEnvironmentV1EnvironmentsPostParams.Encoded | undefined + readonly payload: typeof BetaCreateEnvironmentV1EnvironmentsPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaCreateEnvironmentV1EnvironmentsPost4XX", + typeof BetaCreateEnvironmentV1EnvironmentsPost4XX.Type + > + > + /** + * Retrieve a specific environment by ID. + */ + readonly "betaGetEnvironmentV1EnvironmentsEnvironmentIdGet": ( + environmentId: string, + options: { + readonly params?: typeof BetaGetEnvironmentV1EnvironmentsEnvironmentIdGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaGetEnvironmentV1EnvironmentsEnvironmentIdGet4XX", + typeof BetaGetEnvironmentV1EnvironmentsEnvironmentIdGet4XX.Type + > + > + /** + * Update an existing environment's configuration. + */ + readonly "betaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost": ( + environmentId: string, + options: { + readonly params?: typeof BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPostParams.Encoded | undefined + readonly payload: typeof BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost4XX", + typeof BetaUpdateEnvironmentV1EnvironmentsEnvironmentIdPost4XX.Type + > + > + /** + * Delete an environment by ID. Returns a confirmation of the deletion. + */ + readonly "betaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete": ( + environmentId: string, + options: { + readonly params?: typeof BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDeleteParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete4XX", + typeof BetaDeleteEnvironmentV1EnvironmentsEnvironmentIdDelete4XX.Type + > + > + /** + * Archive an environment by ID. Archived environments cannot be used to create new sessions. + */ + readonly "betaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost": ( + environmentId: string, + options: { + readonly params?: typeof BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePostParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost4XX", + typeof BetaArchiveEnvironmentV1EnvironmentsEnvironmentIdArchivePost4XX.Type + > + > + /** + * Get statistics about the work queue for an environment. + */ + readonly "betaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet": ( + environmentId: string, + options: { + readonly params?: typeof BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet4XX", + typeof BetaGetEnvironmentStatsV1EnvironmentsEnvironmentIdWorkStatsGet4XX.Type + > + > + /** + * Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. + * + * Long poll for work items in the queue. + */ + readonly "betaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet": ( + environmentId: string, + options: { + readonly params?: typeof BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet4XX", + typeof BetaPollWorkV1EnvironmentsEnvironmentIdWorkPollGet4XX.Type + > + > + /** + * Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. + * + * Acknowledge receipt of a work item, transitioning it from 'queued' to 'starting' and removing it from the queue. + */ + readonly "betaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost": ( + environmentId: string, + workId: string, + options: { + readonly params?: typeof BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPostParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost4XX", + typeof BetaAcknowledgeWorkV1EnvironmentsEnvironmentIdWorkWorkIdAckPost4XX.Type + > + > + /** + * Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. + * + * Record a heartbeat for a work item to maintain the lease. + */ + readonly "betaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost": ( + environmentId: string, + workId: string, + options: { + readonly params?: + | typeof BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPostParams.Encoded + | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost4XX", + typeof BetaRecordHeartbeatV1EnvironmentsEnvironmentIdWorkWorkIdHeartbeatPost4XX.Type + > + > + /** + * Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. + * + * Stop a work item, initiating graceful or forced shutdown. + */ + readonly "betaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost": ( + environmentId: string, + workId: string, + options: { + readonly params?: typeof BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPostParams.Encoded | undefined + readonly payload: typeof BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost4XX", + typeof BetaStopWorkV1EnvironmentsEnvironmentIdWorkWorkIdStopPost4XX.Type + > + > + /** + * Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. + * + * Retrieve detailed information about a specific work item. + */ + readonly "betaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet": ( + environmentId: string, + workId: string, + options: { + readonly params?: typeof BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet4XX", + typeof BetaGetWorkV1EnvironmentsEnvironmentIdWorkWorkIdGet4XX.Type + > + > + /** + * Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. + * + * Update work item metadata with merge semantics. + */ + readonly "betaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost": ( + environmentId: string, + workId: string, + options: { + readonly params?: typeof BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPostParams.Encoded | undefined + readonly payload: typeof BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPostRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost4XX", + typeof BetaUpdateWorkV1EnvironmentsEnvironmentIdWorkWorkIdPost4XX.Type + > + > + /** + * Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. + * + * List work items in an environment. + */ + readonly "betaListWorkV1EnvironmentsEnvironmentIdWorkGet": ( + environmentId: string, + options: { + readonly params?: typeof BetaListWorkV1EnvironmentsEnvironmentIdWorkGetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError< + "BetaListWorkV1EnvironmentsEnvironmentIdWorkGet4XX", + typeof BetaListWorkV1EnvironmentsEnvironmentIdWorkGet4XX.Type + > + > + /** + * List memories + */ + readonly "BetaListMemories": ( + memoryStoreId: string, + options: { + readonly params?: typeof BetaListMemoriesParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListMemories400", typeof BetaListMemories400.Type> + | AnthropicClientError<"BetaListMemories401", typeof BetaListMemories401.Type> + | AnthropicClientError<"BetaListMemories403", typeof BetaListMemories403.Type> + | AnthropicClientError<"BetaListMemories404", typeof BetaListMemories404.Type> + | AnthropicClientError<"BetaListMemories408", typeof BetaListMemories408.Type> + | AnthropicClientError<"BetaListMemories409", typeof BetaListMemories409.Type> + | AnthropicClientError<"BetaListMemories412", typeof BetaListMemories412.Type> + | AnthropicClientError<"BetaListMemories413", typeof BetaListMemories413.Type> + | AnthropicClientError<"BetaListMemories429", typeof BetaListMemories429.Type> + | AnthropicClientError<"BetaListMemories431", typeof BetaListMemories431.Type> + | AnthropicClientError<"BetaListMemories499", typeof BetaListMemories499.Type> + | AnthropicClientError<"BetaListMemories500", typeof BetaListMemories500.Type> + | AnthropicClientError<"BetaListMemories501", typeof BetaListMemories501.Type> + | AnthropicClientError<"BetaListMemories503", typeof BetaListMemories503.Type> + | AnthropicClientError<"BetaListMemories504", typeof BetaListMemories504.Type> + > + /** + * Create a memory + */ + readonly "BetaCreateMemory": ( + memoryStoreId: string, + options: { + readonly params?: typeof BetaCreateMemoryParams.Encoded | undefined + readonly payload: typeof BetaCreateMemoryRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaCreateMemory400", typeof BetaCreateMemory400.Type> + | AnthropicClientError<"BetaCreateMemory401", typeof BetaCreateMemory401.Type> + | AnthropicClientError<"BetaCreateMemory403", typeof BetaCreateMemory403.Type> + | AnthropicClientError<"BetaCreateMemory404", typeof BetaCreateMemory404.Type> + | AnthropicClientError<"BetaCreateMemory408", typeof BetaCreateMemory408.Type> + | AnthropicClientError<"BetaCreateMemory409", typeof BetaCreateMemory409.Type> + | AnthropicClientError<"BetaCreateMemory412", typeof BetaCreateMemory412.Type> + | AnthropicClientError<"BetaCreateMemory413", typeof BetaCreateMemory413.Type> + | AnthropicClientError<"BetaCreateMemory429", typeof BetaCreateMemory429.Type> + | AnthropicClientError<"BetaCreateMemory431", typeof BetaCreateMemory431.Type> + | AnthropicClientError<"BetaCreateMemory499", typeof BetaCreateMemory499.Type> + | AnthropicClientError<"BetaCreateMemory500", typeof BetaCreateMemory500.Type> + | AnthropicClientError<"BetaCreateMemory501", typeof BetaCreateMemory501.Type> + | AnthropicClientError<"BetaCreateMemory503", typeof BetaCreateMemory503.Type> + | AnthropicClientError<"BetaCreateMemory504", typeof BetaCreateMemory504.Type> + > + /** + * Retrieve a memory + */ + readonly "BetaGetMemory": ( + memoryStoreId: string, + memoryId: string, + options: + | { readonly params?: typeof BetaGetMemoryParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetMemory400", typeof BetaGetMemory400.Type> + | AnthropicClientError<"BetaGetMemory401", typeof BetaGetMemory401.Type> + | AnthropicClientError<"BetaGetMemory403", typeof BetaGetMemory403.Type> + | AnthropicClientError<"BetaGetMemory404", typeof BetaGetMemory404.Type> + | AnthropicClientError<"BetaGetMemory408", typeof BetaGetMemory408.Type> + | AnthropicClientError<"BetaGetMemory409", typeof BetaGetMemory409.Type> + | AnthropicClientError<"BetaGetMemory412", typeof BetaGetMemory412.Type> + | AnthropicClientError<"BetaGetMemory413", typeof BetaGetMemory413.Type> + | AnthropicClientError<"BetaGetMemory429", typeof BetaGetMemory429.Type> + | AnthropicClientError<"BetaGetMemory431", typeof BetaGetMemory431.Type> + | AnthropicClientError<"BetaGetMemory499", typeof BetaGetMemory499.Type> + | AnthropicClientError<"BetaGetMemory500", typeof BetaGetMemory500.Type> + | AnthropicClientError<"BetaGetMemory501", typeof BetaGetMemory501.Type> + | AnthropicClientError<"BetaGetMemory503", typeof BetaGetMemory503.Type> + | AnthropicClientError<"BetaGetMemory504", typeof BetaGetMemory504.Type> + > + /** + * Update a memory + */ + readonly "BetaUpdateMemory": ( + memoryStoreId: string, + memoryId: string, + options: { + readonly params?: typeof BetaUpdateMemoryParams.Encoded | undefined + readonly payload: typeof BetaUpdateMemoryRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaUpdateMemory400", typeof BetaUpdateMemory400.Type> + | AnthropicClientError<"BetaUpdateMemory401", typeof BetaUpdateMemory401.Type> + | AnthropicClientError<"BetaUpdateMemory403", typeof BetaUpdateMemory403.Type> + | AnthropicClientError<"BetaUpdateMemory404", typeof BetaUpdateMemory404.Type> + | AnthropicClientError<"BetaUpdateMemory408", typeof BetaUpdateMemory408.Type> + | AnthropicClientError<"BetaUpdateMemory409", typeof BetaUpdateMemory409.Type> + | AnthropicClientError<"BetaUpdateMemory412", typeof BetaUpdateMemory412.Type> + | AnthropicClientError<"BetaUpdateMemory413", typeof BetaUpdateMemory413.Type> + | AnthropicClientError<"BetaUpdateMemory429", typeof BetaUpdateMemory429.Type> + | AnthropicClientError<"BetaUpdateMemory431", typeof BetaUpdateMemory431.Type> + | AnthropicClientError<"BetaUpdateMemory499", typeof BetaUpdateMemory499.Type> + | AnthropicClientError<"BetaUpdateMemory500", typeof BetaUpdateMemory500.Type> + | AnthropicClientError<"BetaUpdateMemory501", typeof BetaUpdateMemory501.Type> + | AnthropicClientError<"BetaUpdateMemory503", typeof BetaUpdateMemory503.Type> + | AnthropicClientError<"BetaUpdateMemory504", typeof BetaUpdateMemory504.Type> + > + /** + * Delete a memory + */ + readonly "BetaDeleteMemory": ( + memoryStoreId: string, + memoryId: string, + options: { + readonly params?: typeof BetaDeleteMemoryParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaDeleteMemory400", typeof BetaDeleteMemory400.Type> + | AnthropicClientError<"BetaDeleteMemory401", typeof BetaDeleteMemory401.Type> + | AnthropicClientError<"BetaDeleteMemory403", typeof BetaDeleteMemory403.Type> + | AnthropicClientError<"BetaDeleteMemory404", typeof BetaDeleteMemory404.Type> + | AnthropicClientError<"BetaDeleteMemory408", typeof BetaDeleteMemory408.Type> + | AnthropicClientError<"BetaDeleteMemory409", typeof BetaDeleteMemory409.Type> + | AnthropicClientError<"BetaDeleteMemory412", typeof BetaDeleteMemory412.Type> + | AnthropicClientError<"BetaDeleteMemory413", typeof BetaDeleteMemory413.Type> + | AnthropicClientError<"BetaDeleteMemory429", typeof BetaDeleteMemory429.Type> + | AnthropicClientError<"BetaDeleteMemory431", typeof BetaDeleteMemory431.Type> + | AnthropicClientError<"BetaDeleteMemory499", typeof BetaDeleteMemory499.Type> + | AnthropicClientError<"BetaDeleteMemory500", typeof BetaDeleteMemory500.Type> + | AnthropicClientError<"BetaDeleteMemory501", typeof BetaDeleteMemory501.Type> + | AnthropicClientError<"BetaDeleteMemory503", typeof BetaDeleteMemory503.Type> + | AnthropicClientError<"BetaDeleteMemory504", typeof BetaDeleteMemory504.Type> + > + /** + * List memory versions + */ + readonly "BetaListMemoryVersions": ( + memoryStoreId: string, + options: { + readonly params?: typeof BetaListMemoryVersionsParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListMemoryVersions400", typeof BetaListMemoryVersions400.Type> + | AnthropicClientError<"BetaListMemoryVersions401", typeof BetaListMemoryVersions401.Type> + | AnthropicClientError<"BetaListMemoryVersions403", typeof BetaListMemoryVersions403.Type> + | AnthropicClientError<"BetaListMemoryVersions404", typeof BetaListMemoryVersions404.Type> + | AnthropicClientError<"BetaListMemoryVersions408", typeof BetaListMemoryVersions408.Type> + | AnthropicClientError<"BetaListMemoryVersions409", typeof BetaListMemoryVersions409.Type> + | AnthropicClientError<"BetaListMemoryVersions412", typeof BetaListMemoryVersions412.Type> + | AnthropicClientError<"BetaListMemoryVersions413", typeof BetaListMemoryVersions413.Type> + | AnthropicClientError<"BetaListMemoryVersions429", typeof BetaListMemoryVersions429.Type> + | AnthropicClientError<"BetaListMemoryVersions431", typeof BetaListMemoryVersions431.Type> + | AnthropicClientError<"BetaListMemoryVersions499", typeof BetaListMemoryVersions499.Type> + | AnthropicClientError<"BetaListMemoryVersions500", typeof BetaListMemoryVersions500.Type> + | AnthropicClientError<"BetaListMemoryVersions501", typeof BetaListMemoryVersions501.Type> + | AnthropicClientError<"BetaListMemoryVersions503", typeof BetaListMemoryVersions503.Type> + | AnthropicClientError<"BetaListMemoryVersions504", typeof BetaListMemoryVersions504.Type> + > + /** + * Retrieve a memory version + */ + readonly "BetaGetMemoryVersion": ( + memoryStoreId: string, + memoryVersionId: string, + options: { + readonly params?: typeof BetaGetMemoryVersionParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetMemoryVersion400", typeof BetaGetMemoryVersion400.Type> + | AnthropicClientError<"BetaGetMemoryVersion401", typeof BetaGetMemoryVersion401.Type> + | AnthropicClientError<"BetaGetMemoryVersion403", typeof BetaGetMemoryVersion403.Type> + | AnthropicClientError<"BetaGetMemoryVersion404", typeof BetaGetMemoryVersion404.Type> + | AnthropicClientError<"BetaGetMemoryVersion408", typeof BetaGetMemoryVersion408.Type> + | AnthropicClientError<"BetaGetMemoryVersion409", typeof BetaGetMemoryVersion409.Type> + | AnthropicClientError<"BetaGetMemoryVersion412", typeof BetaGetMemoryVersion412.Type> + | AnthropicClientError<"BetaGetMemoryVersion413", typeof BetaGetMemoryVersion413.Type> + | AnthropicClientError<"BetaGetMemoryVersion429", typeof BetaGetMemoryVersion429.Type> + | AnthropicClientError<"BetaGetMemoryVersion431", typeof BetaGetMemoryVersion431.Type> + | AnthropicClientError<"BetaGetMemoryVersion499", typeof BetaGetMemoryVersion499.Type> + | AnthropicClientError<"BetaGetMemoryVersion500", typeof BetaGetMemoryVersion500.Type> + | AnthropicClientError<"BetaGetMemoryVersion501", typeof BetaGetMemoryVersion501.Type> + | AnthropicClientError<"BetaGetMemoryVersion503", typeof BetaGetMemoryVersion503.Type> + | AnthropicClientError<"BetaGetMemoryVersion504", typeof BetaGetMemoryVersion504.Type> + > + /** + * Redact a memory version + */ + readonly "BetaRedactMemoryVersion": ( + memoryStoreId: string, + memoryVersionId: string, + options: { + readonly params?: typeof BetaRedactMemoryVersionParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaRedactMemoryVersion400", typeof BetaRedactMemoryVersion400.Type> + | AnthropicClientError<"BetaRedactMemoryVersion401", typeof BetaRedactMemoryVersion401.Type> + | AnthropicClientError<"BetaRedactMemoryVersion403", typeof BetaRedactMemoryVersion403.Type> + | AnthropicClientError<"BetaRedactMemoryVersion404", typeof BetaRedactMemoryVersion404.Type> + | AnthropicClientError<"BetaRedactMemoryVersion408", typeof BetaRedactMemoryVersion408.Type> + | AnthropicClientError<"BetaRedactMemoryVersion409", typeof BetaRedactMemoryVersion409.Type> + | AnthropicClientError<"BetaRedactMemoryVersion412", typeof BetaRedactMemoryVersion412.Type> + | AnthropicClientError<"BetaRedactMemoryVersion413", typeof BetaRedactMemoryVersion413.Type> + | AnthropicClientError<"BetaRedactMemoryVersion429", typeof BetaRedactMemoryVersion429.Type> + | AnthropicClientError<"BetaRedactMemoryVersion431", typeof BetaRedactMemoryVersion431.Type> + | AnthropicClientError<"BetaRedactMemoryVersion499", typeof BetaRedactMemoryVersion499.Type> + | AnthropicClientError<"BetaRedactMemoryVersion500", typeof BetaRedactMemoryVersion500.Type> + | AnthropicClientError<"BetaRedactMemoryVersion501", typeof BetaRedactMemoryVersion501.Type> + | AnthropicClientError<"BetaRedactMemoryVersion503", typeof BetaRedactMemoryVersion503.Type> + | AnthropicClientError<"BetaRedactMemoryVersion504", typeof BetaRedactMemoryVersion504.Type> + > + /** + * List memory stores + */ + readonly "BetaListMemoryStores": ( + options: { + readonly params?: typeof BetaListMemoryStoresParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListMemoryStores400", typeof BetaListMemoryStores400.Type> + | AnthropicClientError<"BetaListMemoryStores401", typeof BetaListMemoryStores401.Type> + | AnthropicClientError<"BetaListMemoryStores403", typeof BetaListMemoryStores403.Type> + | AnthropicClientError<"BetaListMemoryStores404", typeof BetaListMemoryStores404.Type> + | AnthropicClientError<"BetaListMemoryStores408", typeof BetaListMemoryStores408.Type> + | AnthropicClientError<"BetaListMemoryStores409", typeof BetaListMemoryStores409.Type> + | AnthropicClientError<"BetaListMemoryStores412", typeof BetaListMemoryStores412.Type> + | AnthropicClientError<"BetaListMemoryStores413", typeof BetaListMemoryStores413.Type> + | AnthropicClientError<"BetaListMemoryStores429", typeof BetaListMemoryStores429.Type> + | AnthropicClientError<"BetaListMemoryStores431", typeof BetaListMemoryStores431.Type> + | AnthropicClientError<"BetaListMemoryStores499", typeof BetaListMemoryStores499.Type> + | AnthropicClientError<"BetaListMemoryStores500", typeof BetaListMemoryStores500.Type> + | AnthropicClientError<"BetaListMemoryStores501", typeof BetaListMemoryStores501.Type> + | AnthropicClientError<"BetaListMemoryStores503", typeof BetaListMemoryStores503.Type> + | AnthropicClientError<"BetaListMemoryStores504", typeof BetaListMemoryStores504.Type> + > + /** + * Create a memory store + */ + readonly "BetaCreateMemoryStore": ( + options: { + readonly params?: typeof BetaCreateMemoryStoreParams.Encoded | undefined + readonly payload: typeof BetaCreateMemoryStoreRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaCreateMemoryStore400", typeof BetaCreateMemoryStore400.Type> + | AnthropicClientError<"BetaCreateMemoryStore401", typeof BetaCreateMemoryStore401.Type> + | AnthropicClientError<"BetaCreateMemoryStore403", typeof BetaCreateMemoryStore403.Type> + | AnthropicClientError<"BetaCreateMemoryStore404", typeof BetaCreateMemoryStore404.Type> + | AnthropicClientError<"BetaCreateMemoryStore408", typeof BetaCreateMemoryStore408.Type> + | AnthropicClientError<"BetaCreateMemoryStore409", typeof BetaCreateMemoryStore409.Type> + | AnthropicClientError<"BetaCreateMemoryStore412", typeof BetaCreateMemoryStore412.Type> + | AnthropicClientError<"BetaCreateMemoryStore413", typeof BetaCreateMemoryStore413.Type> + | AnthropicClientError<"BetaCreateMemoryStore429", typeof BetaCreateMemoryStore429.Type> + | AnthropicClientError<"BetaCreateMemoryStore431", typeof BetaCreateMemoryStore431.Type> + | AnthropicClientError<"BetaCreateMemoryStore499", typeof BetaCreateMemoryStore499.Type> + | AnthropicClientError<"BetaCreateMemoryStore500", typeof BetaCreateMemoryStore500.Type> + | AnthropicClientError<"BetaCreateMemoryStore501", typeof BetaCreateMemoryStore501.Type> + | AnthropicClientError<"BetaCreateMemoryStore503", typeof BetaCreateMemoryStore503.Type> + | AnthropicClientError<"BetaCreateMemoryStore504", typeof BetaCreateMemoryStore504.Type> + > + /** + * Retrieve a memory store + */ + readonly "BetaGetMemoryStore": ( + memoryStoreId: string, + options: { + readonly params?: typeof BetaGetMemoryStoreParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetMemoryStore400", typeof BetaGetMemoryStore400.Type> + | AnthropicClientError<"BetaGetMemoryStore401", typeof BetaGetMemoryStore401.Type> + | AnthropicClientError<"BetaGetMemoryStore403", typeof BetaGetMemoryStore403.Type> + | AnthropicClientError<"BetaGetMemoryStore404", typeof BetaGetMemoryStore404.Type> + | AnthropicClientError<"BetaGetMemoryStore408", typeof BetaGetMemoryStore408.Type> + | AnthropicClientError<"BetaGetMemoryStore409", typeof BetaGetMemoryStore409.Type> + | AnthropicClientError<"BetaGetMemoryStore412", typeof BetaGetMemoryStore412.Type> + | AnthropicClientError<"BetaGetMemoryStore413", typeof BetaGetMemoryStore413.Type> + | AnthropicClientError<"BetaGetMemoryStore429", typeof BetaGetMemoryStore429.Type> + | AnthropicClientError<"BetaGetMemoryStore431", typeof BetaGetMemoryStore431.Type> + | AnthropicClientError<"BetaGetMemoryStore499", typeof BetaGetMemoryStore499.Type> + | AnthropicClientError<"BetaGetMemoryStore500", typeof BetaGetMemoryStore500.Type> + | AnthropicClientError<"BetaGetMemoryStore501", typeof BetaGetMemoryStore501.Type> + | AnthropicClientError<"BetaGetMemoryStore503", typeof BetaGetMemoryStore503.Type> + | AnthropicClientError<"BetaGetMemoryStore504", typeof BetaGetMemoryStore504.Type> + > + /** + * Update a memory store + */ + readonly "BetaUpdateMemoryStore": ( + memoryStoreId: string, + options: { + readonly params?: typeof BetaUpdateMemoryStoreParams.Encoded | undefined + readonly payload: typeof BetaUpdateMemoryStoreRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaUpdateMemoryStore400", typeof BetaUpdateMemoryStore400.Type> + | AnthropicClientError<"BetaUpdateMemoryStore401", typeof BetaUpdateMemoryStore401.Type> + | AnthropicClientError<"BetaUpdateMemoryStore403", typeof BetaUpdateMemoryStore403.Type> + | AnthropicClientError<"BetaUpdateMemoryStore404", typeof BetaUpdateMemoryStore404.Type> + | AnthropicClientError<"BetaUpdateMemoryStore408", typeof BetaUpdateMemoryStore408.Type> + | AnthropicClientError<"BetaUpdateMemoryStore409", typeof BetaUpdateMemoryStore409.Type> + | AnthropicClientError<"BetaUpdateMemoryStore412", typeof BetaUpdateMemoryStore412.Type> + | AnthropicClientError<"BetaUpdateMemoryStore413", typeof BetaUpdateMemoryStore413.Type> + | AnthropicClientError<"BetaUpdateMemoryStore429", typeof BetaUpdateMemoryStore429.Type> + | AnthropicClientError<"BetaUpdateMemoryStore431", typeof BetaUpdateMemoryStore431.Type> + | AnthropicClientError<"BetaUpdateMemoryStore499", typeof BetaUpdateMemoryStore499.Type> + | AnthropicClientError<"BetaUpdateMemoryStore500", typeof BetaUpdateMemoryStore500.Type> + | AnthropicClientError<"BetaUpdateMemoryStore501", typeof BetaUpdateMemoryStore501.Type> + | AnthropicClientError<"BetaUpdateMemoryStore503", typeof BetaUpdateMemoryStore503.Type> + | AnthropicClientError<"BetaUpdateMemoryStore504", typeof BetaUpdateMemoryStore504.Type> + > + /** + * Delete a memory store + */ + readonly "BetaDeleteMemoryStore": ( + memoryStoreId: string, + options: { + readonly params?: typeof BetaDeleteMemoryStoreParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaDeleteMemoryStore400", typeof BetaDeleteMemoryStore400.Type> + | AnthropicClientError<"BetaDeleteMemoryStore401", typeof BetaDeleteMemoryStore401.Type> + | AnthropicClientError<"BetaDeleteMemoryStore403", typeof BetaDeleteMemoryStore403.Type> + | AnthropicClientError<"BetaDeleteMemoryStore404", typeof BetaDeleteMemoryStore404.Type> + | AnthropicClientError<"BetaDeleteMemoryStore408", typeof BetaDeleteMemoryStore408.Type> + | AnthropicClientError<"BetaDeleteMemoryStore409", typeof BetaDeleteMemoryStore409.Type> + | AnthropicClientError<"BetaDeleteMemoryStore412", typeof BetaDeleteMemoryStore412.Type> + | AnthropicClientError<"BetaDeleteMemoryStore413", typeof BetaDeleteMemoryStore413.Type> + | AnthropicClientError<"BetaDeleteMemoryStore429", typeof BetaDeleteMemoryStore429.Type> + | AnthropicClientError<"BetaDeleteMemoryStore431", typeof BetaDeleteMemoryStore431.Type> + | AnthropicClientError<"BetaDeleteMemoryStore499", typeof BetaDeleteMemoryStore499.Type> + | AnthropicClientError<"BetaDeleteMemoryStore500", typeof BetaDeleteMemoryStore500.Type> + | AnthropicClientError<"BetaDeleteMemoryStore501", typeof BetaDeleteMemoryStore501.Type> + | AnthropicClientError<"BetaDeleteMemoryStore503", typeof BetaDeleteMemoryStore503.Type> + | AnthropicClientError<"BetaDeleteMemoryStore504", typeof BetaDeleteMemoryStore504.Type> + > + /** + * Archive a memory store + */ + readonly "BetaArchiveMemoryStore": ( + memoryStoreId: string, + options: { + readonly params?: typeof BetaArchiveMemoryStoreParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaArchiveMemoryStore400", typeof BetaArchiveMemoryStore400.Type> + | AnthropicClientError<"BetaArchiveMemoryStore401", typeof BetaArchiveMemoryStore401.Type> + | AnthropicClientError<"BetaArchiveMemoryStore403", typeof BetaArchiveMemoryStore403.Type> + | AnthropicClientError<"BetaArchiveMemoryStore404", typeof BetaArchiveMemoryStore404.Type> + | AnthropicClientError<"BetaArchiveMemoryStore408", typeof BetaArchiveMemoryStore408.Type> + | AnthropicClientError<"BetaArchiveMemoryStore409", typeof BetaArchiveMemoryStore409.Type> + | AnthropicClientError<"BetaArchiveMemoryStore412", typeof BetaArchiveMemoryStore412.Type> + | AnthropicClientError<"BetaArchiveMemoryStore413", typeof BetaArchiveMemoryStore413.Type> + | AnthropicClientError<"BetaArchiveMemoryStore429", typeof BetaArchiveMemoryStore429.Type> + | AnthropicClientError<"BetaArchiveMemoryStore431", typeof BetaArchiveMemoryStore431.Type> + | AnthropicClientError<"BetaArchiveMemoryStore499", typeof BetaArchiveMemoryStore499.Type> + | AnthropicClientError<"BetaArchiveMemoryStore500", typeof BetaArchiveMemoryStore500.Type> + | AnthropicClientError<"BetaArchiveMemoryStore501", typeof BetaArchiveMemoryStore501.Type> + | AnthropicClientError<"BetaArchiveMemoryStore503", typeof BetaArchiveMemoryStore503.Type> + | AnthropicClientError<"BetaArchiveMemoryStore504", typeof BetaArchiveMemoryStore504.Type> + > + /** + * List User Profiles + */ + readonly "BetaListUserProfiles": ( + options: { + readonly params?: typeof BetaListUserProfilesParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListUserProfiles400", typeof BetaListUserProfiles400.Type> + | AnthropicClientError<"BetaListUserProfiles401", typeof BetaListUserProfiles401.Type> + | AnthropicClientError<"BetaListUserProfiles403", typeof BetaListUserProfiles403.Type> + | AnthropicClientError<"BetaListUserProfiles404", typeof BetaListUserProfiles404.Type> + | AnthropicClientError<"BetaListUserProfiles408", typeof BetaListUserProfiles408.Type> + | AnthropicClientError<"BetaListUserProfiles409", typeof BetaListUserProfiles409.Type> + | AnthropicClientError<"BetaListUserProfiles412", typeof BetaListUserProfiles412.Type> + | AnthropicClientError<"BetaListUserProfiles413", typeof BetaListUserProfiles413.Type> + | AnthropicClientError<"BetaListUserProfiles429", typeof BetaListUserProfiles429.Type> + | AnthropicClientError<"BetaListUserProfiles431", typeof BetaListUserProfiles431.Type> + | AnthropicClientError<"BetaListUserProfiles499", typeof BetaListUserProfiles499.Type> + | AnthropicClientError<"BetaListUserProfiles500", typeof BetaListUserProfiles500.Type> + | AnthropicClientError<"BetaListUserProfiles501", typeof BetaListUserProfiles501.Type> + | AnthropicClientError<"BetaListUserProfiles503", typeof BetaListUserProfiles503.Type> + | AnthropicClientError<"BetaListUserProfiles504", typeof BetaListUserProfiles504.Type> + > + /** + * Create User Profile + */ + readonly "BetaCreateUserProfile": ( + options: { + readonly params?: typeof BetaCreateUserProfileParams.Encoded | undefined + readonly payload: typeof BetaCreateUserProfileRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaCreateUserProfile400", typeof BetaCreateUserProfile400.Type> + | AnthropicClientError<"BetaCreateUserProfile401", typeof BetaCreateUserProfile401.Type> + | AnthropicClientError<"BetaCreateUserProfile403", typeof BetaCreateUserProfile403.Type> + | AnthropicClientError<"BetaCreateUserProfile404", typeof BetaCreateUserProfile404.Type> + | AnthropicClientError<"BetaCreateUserProfile408", typeof BetaCreateUserProfile408.Type> + | AnthropicClientError<"BetaCreateUserProfile409", typeof BetaCreateUserProfile409.Type> + | AnthropicClientError<"BetaCreateUserProfile412", typeof BetaCreateUserProfile412.Type> + | AnthropicClientError<"BetaCreateUserProfile413", typeof BetaCreateUserProfile413.Type> + | AnthropicClientError<"BetaCreateUserProfile429", typeof BetaCreateUserProfile429.Type> + | AnthropicClientError<"BetaCreateUserProfile431", typeof BetaCreateUserProfile431.Type> + | AnthropicClientError<"BetaCreateUserProfile499", typeof BetaCreateUserProfile499.Type> + | AnthropicClientError<"BetaCreateUserProfile500", typeof BetaCreateUserProfile500.Type> + | AnthropicClientError<"BetaCreateUserProfile501", typeof BetaCreateUserProfile501.Type> + | AnthropicClientError<"BetaCreateUserProfile503", typeof BetaCreateUserProfile503.Type> + | AnthropicClientError<"BetaCreateUserProfile504", typeof BetaCreateUserProfile504.Type> + > + /** + * Get User Profile + */ + readonly "BetaGetUserProfile": ( + userProfileId: string, + options: { + readonly params?: typeof BetaGetUserProfileParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetUserProfile400", typeof BetaGetUserProfile400.Type> + | AnthropicClientError<"BetaGetUserProfile401", typeof BetaGetUserProfile401.Type> + | AnthropicClientError<"BetaGetUserProfile403", typeof BetaGetUserProfile403.Type> + | AnthropicClientError<"BetaGetUserProfile404", typeof BetaGetUserProfile404.Type> + | AnthropicClientError<"BetaGetUserProfile408", typeof BetaGetUserProfile408.Type> + | AnthropicClientError<"BetaGetUserProfile409", typeof BetaGetUserProfile409.Type> + | AnthropicClientError<"BetaGetUserProfile412", typeof BetaGetUserProfile412.Type> + | AnthropicClientError<"BetaGetUserProfile413", typeof BetaGetUserProfile413.Type> + | AnthropicClientError<"BetaGetUserProfile429", typeof BetaGetUserProfile429.Type> + | AnthropicClientError<"BetaGetUserProfile431", typeof BetaGetUserProfile431.Type> + | AnthropicClientError<"BetaGetUserProfile499", typeof BetaGetUserProfile499.Type> + | AnthropicClientError<"BetaGetUserProfile500", typeof BetaGetUserProfile500.Type> + | AnthropicClientError<"BetaGetUserProfile501", typeof BetaGetUserProfile501.Type> + | AnthropicClientError<"BetaGetUserProfile503", typeof BetaGetUserProfile503.Type> + | AnthropicClientError<"BetaGetUserProfile504", typeof BetaGetUserProfile504.Type> + > + /** + * Update User Profile + */ + readonly "BetaUpdateUserProfile": ( + userProfileId: string, + options: { + readonly params?: typeof BetaUpdateUserProfileParams.Encoded | undefined + readonly payload: typeof BetaUpdateUserProfileRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaUpdateUserProfile400", typeof BetaUpdateUserProfile400.Type> + | AnthropicClientError<"BetaUpdateUserProfile401", typeof BetaUpdateUserProfile401.Type> + | AnthropicClientError<"BetaUpdateUserProfile403", typeof BetaUpdateUserProfile403.Type> + | AnthropicClientError<"BetaUpdateUserProfile404", typeof BetaUpdateUserProfile404.Type> + | AnthropicClientError<"BetaUpdateUserProfile408", typeof BetaUpdateUserProfile408.Type> + | AnthropicClientError<"BetaUpdateUserProfile409", typeof BetaUpdateUserProfile409.Type> + | AnthropicClientError<"BetaUpdateUserProfile412", typeof BetaUpdateUserProfile412.Type> + | AnthropicClientError<"BetaUpdateUserProfile413", typeof BetaUpdateUserProfile413.Type> + | AnthropicClientError<"BetaUpdateUserProfile429", typeof BetaUpdateUserProfile429.Type> + | AnthropicClientError<"BetaUpdateUserProfile431", typeof BetaUpdateUserProfile431.Type> + | AnthropicClientError<"BetaUpdateUserProfile499", typeof BetaUpdateUserProfile499.Type> + | AnthropicClientError<"BetaUpdateUserProfile500", typeof BetaUpdateUserProfile500.Type> + | AnthropicClientError<"BetaUpdateUserProfile501", typeof BetaUpdateUserProfile501.Type> + | AnthropicClientError<"BetaUpdateUserProfile503", typeof BetaUpdateUserProfile503.Type> + | AnthropicClientError<"BetaUpdateUserProfile504", typeof BetaUpdateUserProfile504.Type> + > + /** + * Create Enrollment URL + */ + readonly "BetaCreateEnrollmentUrl": ( + userProfileId: string, + options: { + readonly params?: typeof BetaCreateEnrollmentUrlParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaCreateEnrollmentUrl400", typeof BetaCreateEnrollmentUrl400.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl401", typeof BetaCreateEnrollmentUrl401.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl403", typeof BetaCreateEnrollmentUrl403.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl404", typeof BetaCreateEnrollmentUrl404.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl408", typeof BetaCreateEnrollmentUrl408.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl409", typeof BetaCreateEnrollmentUrl409.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl412", typeof BetaCreateEnrollmentUrl412.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl413", typeof BetaCreateEnrollmentUrl413.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl429", typeof BetaCreateEnrollmentUrl429.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl431", typeof BetaCreateEnrollmentUrl431.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl499", typeof BetaCreateEnrollmentUrl499.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl500", typeof BetaCreateEnrollmentUrl500.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl501", typeof BetaCreateEnrollmentUrl501.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl503", typeof BetaCreateEnrollmentUrl503.Type> + | AnthropicClientError<"BetaCreateEnrollmentUrl504", typeof BetaCreateEnrollmentUrl504.Type> + > + /** + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. + * + * Lists tunnels. Results are ordered by creation time, newest first; archived tunnels are excluded unless include_archived is set. + */ + readonly "BetaListTunnels": ( + options: { + readonly params?: typeof BetaListTunnelsParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListTunnels400", typeof BetaListTunnels400.Type> + | AnthropicClientError<"BetaListTunnels401", typeof BetaListTunnels401.Type> + | AnthropicClientError<"BetaListTunnels403", typeof BetaListTunnels403.Type> + | AnthropicClientError<"BetaListTunnels404", typeof BetaListTunnels404.Type> + | AnthropicClientError<"BetaListTunnels408", typeof BetaListTunnels408.Type> + | AnthropicClientError<"BetaListTunnels409", typeof BetaListTunnels409.Type> + | AnthropicClientError<"BetaListTunnels412", typeof BetaListTunnels412.Type> + | AnthropicClientError<"BetaListTunnels413", typeof BetaListTunnels413.Type> + | AnthropicClientError<"BetaListTunnels429", typeof BetaListTunnels429.Type> + | AnthropicClientError<"BetaListTunnels431", typeof BetaListTunnels431.Type> + | AnthropicClientError<"BetaListTunnels499", typeof BetaListTunnels499.Type> + | AnthropicClientError<"BetaListTunnels500", typeof BetaListTunnels500.Type> + | AnthropicClientError<"BetaListTunnels501", typeof BetaListTunnels501.Type> + | AnthropicClientError<"BetaListTunnels503", typeof BetaListTunnels503.Type> + | AnthropicClientError<"BetaListTunnels504", typeof BetaListTunnels504.Type> + > + /** + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. + * + * Creates a tunnel. Creation allocates a fresh hostname and provisions the tunnel; it is not idempotent. The new tunnel rejects MCP traffic until at least one CA certificate is added. + */ + readonly "BetaCreateTunnel": ( + options: { + readonly params?: typeof BetaCreateTunnelParams.Encoded | undefined + readonly payload: typeof BetaCreateTunnelRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaCreateTunnel400", typeof BetaCreateTunnel400.Type> + | AnthropicClientError<"BetaCreateTunnel401", typeof BetaCreateTunnel401.Type> + | AnthropicClientError<"BetaCreateTunnel403", typeof BetaCreateTunnel403.Type> + | AnthropicClientError<"BetaCreateTunnel404", typeof BetaCreateTunnel404.Type> + | AnthropicClientError<"BetaCreateTunnel408", typeof BetaCreateTunnel408.Type> + | AnthropicClientError<"BetaCreateTunnel409", typeof BetaCreateTunnel409.Type> + | AnthropicClientError<"BetaCreateTunnel412", typeof BetaCreateTunnel412.Type> + | AnthropicClientError<"BetaCreateTunnel413", typeof BetaCreateTunnel413.Type> + | AnthropicClientError<"BetaCreateTunnel429", typeof BetaCreateTunnel429.Type> + | AnthropicClientError<"BetaCreateTunnel431", typeof BetaCreateTunnel431.Type> + | AnthropicClientError<"BetaCreateTunnel499", typeof BetaCreateTunnel499.Type> + | AnthropicClientError<"BetaCreateTunnel500", typeof BetaCreateTunnel500.Type> + | AnthropicClientError<"BetaCreateTunnel501", typeof BetaCreateTunnel501.Type> + | AnthropicClientError<"BetaCreateTunnel503", typeof BetaCreateTunnel503.Type> + | AnthropicClientError<"BetaCreateTunnel504", typeof BetaCreateTunnel504.Type> + > + /** + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. * - * The Messages API can be used for either single queries or stateless multi-turn conversations. + * Fetches a tunnel by ID. + */ + readonly "BetaGetTunnel": ( + tunnelId: string, + options: + | { readonly params?: typeof BetaGetTunnelParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetTunnel400", typeof BetaGetTunnel400.Type> + | AnthropicClientError<"BetaGetTunnel401", typeof BetaGetTunnel401.Type> + | AnthropicClientError<"BetaGetTunnel403", typeof BetaGetTunnel403.Type> + | AnthropicClientError<"BetaGetTunnel404", typeof BetaGetTunnel404.Type> + | AnthropicClientError<"BetaGetTunnel408", typeof BetaGetTunnel408.Type> + | AnthropicClientError<"BetaGetTunnel409", typeof BetaGetTunnel409.Type> + | AnthropicClientError<"BetaGetTunnel412", typeof BetaGetTunnel412.Type> + | AnthropicClientError<"BetaGetTunnel413", typeof BetaGetTunnel413.Type> + | AnthropicClientError<"BetaGetTunnel429", typeof BetaGetTunnel429.Type> + | AnthropicClientError<"BetaGetTunnel431", typeof BetaGetTunnel431.Type> + | AnthropicClientError<"BetaGetTunnel499", typeof BetaGetTunnel499.Type> + | AnthropicClientError<"BetaGetTunnel500", typeof BetaGetTunnel500.Type> + | AnthropicClientError<"BetaGetTunnel501", typeof BetaGetTunnel501.Type> + | AnthropicClientError<"BetaGetTunnel503", typeof BetaGetTunnel503.Type> + | AnthropicClientError<"BetaGetTunnel504", typeof BetaGetTunnel504.Type> + > + /** + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. * - * Learn more about the Messages API in our [user guide](https://docs.claude.com/en/docs/initial-setup) + * Archives a tunnel. Archival is irreversible: every non-archived certificate on the tunnel is archived in the same operation, the hostname is retired and never re-allocated, and the tunnel token is invalidated. Retrying against an already-archived tunnel returns the existing record unchanged. */ - readonly "messagesPost": ( + readonly "BetaArchiveTunnel": ( + tunnelId: string, options: { - readonly params?: typeof MessagesPostParams.Encoded | undefined - readonly payload: typeof MessagesPostRequestJson.Encoded + readonly params?: typeof BetaArchiveTunnelParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaArchiveTunnel400", typeof BetaArchiveTunnel400.Type> + | AnthropicClientError<"BetaArchiveTunnel401", typeof BetaArchiveTunnel401.Type> + | AnthropicClientError<"BetaArchiveTunnel403", typeof BetaArchiveTunnel403.Type> + | AnthropicClientError<"BetaArchiveTunnel404", typeof BetaArchiveTunnel404.Type> + | AnthropicClientError<"BetaArchiveTunnel408", typeof BetaArchiveTunnel408.Type> + | AnthropicClientError<"BetaArchiveTunnel409", typeof BetaArchiveTunnel409.Type> + | AnthropicClientError<"BetaArchiveTunnel412", typeof BetaArchiveTunnel412.Type> + | AnthropicClientError<"BetaArchiveTunnel413", typeof BetaArchiveTunnel413.Type> + | AnthropicClientError<"BetaArchiveTunnel429", typeof BetaArchiveTunnel429.Type> + | AnthropicClientError<"BetaArchiveTunnel431", typeof BetaArchiveTunnel431.Type> + | AnthropicClientError<"BetaArchiveTunnel499", typeof BetaArchiveTunnel499.Type> + | AnthropicClientError<"BetaArchiveTunnel500", typeof BetaArchiveTunnel500.Type> + | AnthropicClientError<"BetaArchiveTunnel501", typeof BetaArchiveTunnel501.Type> + | AnthropicClientError<"BetaArchiveTunnel503", typeof BetaArchiveTunnel503.Type> + | AnthropicClientError<"BetaArchiveTunnel504", typeof BetaArchiveTunnel504.Type> + > + /** + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. + * + * Reveals a tunnel's connector token. The value is fetched live on each call; Anthropic does not store it. Repeated calls return the same value until the token is rotated. Exposed as POST so the token does not appear in intermediary access logs. + */ + readonly "BetaRevealTunnelToken": ( + tunnelId: string, + options: { + readonly params?: typeof BetaRevealTunnelTokenParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaRevealTunnelToken400", typeof BetaRevealTunnelToken400.Type> + | AnthropicClientError<"BetaRevealTunnelToken401", typeof BetaRevealTunnelToken401.Type> + | AnthropicClientError<"BetaRevealTunnelToken403", typeof BetaRevealTunnelToken403.Type> + | AnthropicClientError<"BetaRevealTunnelToken404", typeof BetaRevealTunnelToken404.Type> + | AnthropicClientError<"BetaRevealTunnelToken408", typeof BetaRevealTunnelToken408.Type> + | AnthropicClientError<"BetaRevealTunnelToken409", typeof BetaRevealTunnelToken409.Type> + | AnthropicClientError<"BetaRevealTunnelToken412", typeof BetaRevealTunnelToken412.Type> + | AnthropicClientError<"BetaRevealTunnelToken413", typeof BetaRevealTunnelToken413.Type> + | AnthropicClientError<"BetaRevealTunnelToken429", typeof BetaRevealTunnelToken429.Type> + | AnthropicClientError<"BetaRevealTunnelToken431", typeof BetaRevealTunnelToken431.Type> + | AnthropicClientError<"BetaRevealTunnelToken499", typeof BetaRevealTunnelToken499.Type> + | AnthropicClientError<"BetaRevealTunnelToken500", typeof BetaRevealTunnelToken500.Type> + | AnthropicClientError<"BetaRevealTunnelToken501", typeof BetaRevealTunnelToken501.Type> + | AnthropicClientError<"BetaRevealTunnelToken503", typeof BetaRevealTunnelToken503.Type> + | AnthropicClientError<"BetaRevealTunnelToken504", typeof BetaRevealTunnelToken504.Type> + > + /** + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. + * + * Rotates a tunnel's connector token. Rotation invalidates the current token for new connections and returns a fresh value; established connections are not severed. A connector restarted after rotation must use the new value. + */ + readonly "BetaRotateTunnelToken": ( + tunnelId: string, + options: { + readonly params?: typeof BetaRotateTunnelTokenParams.Encoded | undefined + readonly payload: typeof BetaRotateTunnelTokenRequestJson.Encoded readonly config?: Config | undefined } ) => Effect.Effect< - WithOptionalResponse, - HttpClientError.HttpClientError | SchemaError | AnthropicClientError<"MessagesPost4XX", typeof MessagesPost4XX.Type> + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaRotateTunnelToken400", typeof BetaRotateTunnelToken400.Type> + | AnthropicClientError<"BetaRotateTunnelToken401", typeof BetaRotateTunnelToken401.Type> + | AnthropicClientError<"BetaRotateTunnelToken403", typeof BetaRotateTunnelToken403.Type> + | AnthropicClientError<"BetaRotateTunnelToken404", typeof BetaRotateTunnelToken404.Type> + | AnthropicClientError<"BetaRotateTunnelToken408", typeof BetaRotateTunnelToken408.Type> + | AnthropicClientError<"BetaRotateTunnelToken409", typeof BetaRotateTunnelToken409.Type> + | AnthropicClientError<"BetaRotateTunnelToken412", typeof BetaRotateTunnelToken412.Type> + | AnthropicClientError<"BetaRotateTunnelToken413", typeof BetaRotateTunnelToken413.Type> + | AnthropicClientError<"BetaRotateTunnelToken429", typeof BetaRotateTunnelToken429.Type> + | AnthropicClientError<"BetaRotateTunnelToken431", typeof BetaRotateTunnelToken431.Type> + | AnthropicClientError<"BetaRotateTunnelToken499", typeof BetaRotateTunnelToken499.Type> + | AnthropicClientError<"BetaRotateTunnelToken500", typeof BetaRotateTunnelToken500.Type> + | AnthropicClientError<"BetaRotateTunnelToken501", typeof BetaRotateTunnelToken501.Type> + | AnthropicClientError<"BetaRotateTunnelToken503", typeof BetaRotateTunnelToken503.Type> + | AnthropicClientError<"BetaRotateTunnelToken504", typeof BetaRotateTunnelToken504.Type> > /** - * [Legacy] Create a Text Completion. + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. * - * The Text Completions API is a legacy API. We recommend using the [Messages API](https://docs.claude.com/en/api/messages) going forward. + * Lists the certificates registered on a tunnel. Archived certificates are excluded unless include_archived is set. + */ + readonly "BetaListTunnelCertificates": ( + tunnelId: string, + options: { + readonly params?: typeof BetaListTunnelCertificatesParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListTunnelCertificates400", typeof BetaListTunnelCertificates400.Type> + | AnthropicClientError<"BetaListTunnelCertificates401", typeof BetaListTunnelCertificates401.Type> + | AnthropicClientError<"BetaListTunnelCertificates403", typeof BetaListTunnelCertificates403.Type> + | AnthropicClientError<"BetaListTunnelCertificates404", typeof BetaListTunnelCertificates404.Type> + | AnthropicClientError<"BetaListTunnelCertificates408", typeof BetaListTunnelCertificates408.Type> + | AnthropicClientError<"BetaListTunnelCertificates409", typeof BetaListTunnelCertificates409.Type> + | AnthropicClientError<"BetaListTunnelCertificates412", typeof BetaListTunnelCertificates412.Type> + | AnthropicClientError<"BetaListTunnelCertificates413", typeof BetaListTunnelCertificates413.Type> + | AnthropicClientError<"BetaListTunnelCertificates429", typeof BetaListTunnelCertificates429.Type> + | AnthropicClientError<"BetaListTunnelCertificates431", typeof BetaListTunnelCertificates431.Type> + | AnthropicClientError<"BetaListTunnelCertificates499", typeof BetaListTunnelCertificates499.Type> + | AnthropicClientError<"BetaListTunnelCertificates500", typeof BetaListTunnelCertificates500.Type> + | AnthropicClientError<"BetaListTunnelCertificates501", typeof BetaListTunnelCertificates501.Type> + | AnthropicClientError<"BetaListTunnelCertificates503", typeof BetaListTunnelCertificates503.Type> + | AnthropicClientError<"BetaListTunnelCertificates504", typeof BetaListTunnelCertificates504.Type> + > + /** + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. * - * Future models and features will not be compatible with Text Completions. See our [migration guide](https://docs.claude.com/en/api/migrating-from-text-completions-to-messages) for guidance in migrating from Text Completions to Messages. + * Registers a public CA certificate on a tunnel. Anthropic verifies the gateway's server certificate against this CA when it terminates the inner TLS session. A tunnel holds at most two non-archived certificates. */ - readonly "completePost": ( + readonly "BetaCreateTunnelCertificate": ( + tunnelId: string, options: { - readonly params?: typeof CompletePostParams.Encoded | undefined - readonly payload: typeof CompletePostRequestJson.Encoded + readonly params?: typeof BetaCreateTunnelCertificateParams.Encoded | undefined + readonly payload: typeof BetaCreateTunnelCertificateRequestJson.Encoded readonly config?: Config | undefined } ) => Effect.Effect< - WithOptionalResponse, - HttpClientError.HttpClientError | SchemaError | AnthropicClientError<"CompletePost4XX", typeof CompletePost4XX.Type> + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaCreateTunnelCertificate400", typeof BetaCreateTunnelCertificate400.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate401", typeof BetaCreateTunnelCertificate401.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate403", typeof BetaCreateTunnelCertificate403.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate404", typeof BetaCreateTunnelCertificate404.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate408", typeof BetaCreateTunnelCertificate408.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate409", typeof BetaCreateTunnelCertificate409.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate412", typeof BetaCreateTunnelCertificate412.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate413", typeof BetaCreateTunnelCertificate413.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate429", typeof BetaCreateTunnelCertificate429.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate431", typeof BetaCreateTunnelCertificate431.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate499", typeof BetaCreateTunnelCertificate499.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate500", typeof BetaCreateTunnelCertificate500.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate501", typeof BetaCreateTunnelCertificate501.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate503", typeof BetaCreateTunnelCertificate503.Type> + | AnthropicClientError<"BetaCreateTunnelCertificate504", typeof BetaCreateTunnelCertificate504.Type> > /** - * List available models. + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. * - * The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first. + * Fetches a tunnel certificate by ID. */ - readonly "modelsList": ( + readonly "BetaGetTunnelCertificate": ( + tunnelId: string, + certificateId: string, + options: { + readonly params?: typeof BetaGetTunnelCertificateParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetTunnelCertificate400", typeof BetaGetTunnelCertificate400.Type> + | AnthropicClientError<"BetaGetTunnelCertificate401", typeof BetaGetTunnelCertificate401.Type> + | AnthropicClientError<"BetaGetTunnelCertificate403", typeof BetaGetTunnelCertificate403.Type> + | AnthropicClientError<"BetaGetTunnelCertificate404", typeof BetaGetTunnelCertificate404.Type> + | AnthropicClientError<"BetaGetTunnelCertificate408", typeof BetaGetTunnelCertificate408.Type> + | AnthropicClientError<"BetaGetTunnelCertificate409", typeof BetaGetTunnelCertificate409.Type> + | AnthropicClientError<"BetaGetTunnelCertificate412", typeof BetaGetTunnelCertificate412.Type> + | AnthropicClientError<"BetaGetTunnelCertificate413", typeof BetaGetTunnelCertificate413.Type> + | AnthropicClientError<"BetaGetTunnelCertificate429", typeof BetaGetTunnelCertificate429.Type> + | AnthropicClientError<"BetaGetTunnelCertificate431", typeof BetaGetTunnelCertificate431.Type> + | AnthropicClientError<"BetaGetTunnelCertificate499", typeof BetaGetTunnelCertificate499.Type> + | AnthropicClientError<"BetaGetTunnelCertificate500", typeof BetaGetTunnelCertificate500.Type> + | AnthropicClientError<"BetaGetTunnelCertificate501", typeof BetaGetTunnelCertificate501.Type> + | AnthropicClientError<"BetaGetTunnelCertificate503", typeof BetaGetTunnelCertificate503.Type> + | AnthropicClientError<"BetaGetTunnelCertificate504", typeof BetaGetTunnelCertificate504.Type> + > + /** + * The Tunnels API is in research preview. It requires the `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a deprecation period. It supersedes the Admin API endpoints at `/v1/organizations/tunnels`, which remain available during a migration window. + * + * Archives a tunnel certificate, removing it from the set Anthropic trusts for the tunnel. The certificate record is retained. Archiving the last non-archived certificate is permitted; the tunnel rejects MCP traffic until a new certificate is added. + */ + readonly "BetaArchiveTunnelCertificate": ( + tunnelId: string, + certificateId: string, + options: { + readonly params?: typeof BetaArchiveTunnelCertificateParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaArchiveTunnelCertificate400", typeof BetaArchiveTunnelCertificate400.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate401", typeof BetaArchiveTunnelCertificate401.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate403", typeof BetaArchiveTunnelCertificate403.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate404", typeof BetaArchiveTunnelCertificate404.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate408", typeof BetaArchiveTunnelCertificate408.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate409", typeof BetaArchiveTunnelCertificate409.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate412", typeof BetaArchiveTunnelCertificate412.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate413", typeof BetaArchiveTunnelCertificate413.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate429", typeof BetaArchiveTunnelCertificate429.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate431", typeof BetaArchiveTunnelCertificate431.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate499", typeof BetaArchiveTunnelCertificate499.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate500", typeof BetaArchiveTunnelCertificate500.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate501", typeof BetaArchiveTunnelCertificate501.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate503", typeof BetaArchiveTunnelCertificate503.Type> + | AnthropicClientError<"BetaArchiveTunnelCertificate504", typeof BetaArchiveTunnelCertificate504.Type> + > + /** + * List Dreams + */ + readonly "BetaListDreams": ( options: - | { readonly params?: typeof ModelsListParams.Encoded | undefined; readonly config?: Config | undefined } + | { readonly params?: typeof BetaListDreamsParams.Encoded | undefined; readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, - HttpClientError.HttpClientError | SchemaError | AnthropicClientError<"ModelsList4XX", typeof ModelsList4XX.Type> + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListDreams400", typeof BetaListDreams400.Type> + | AnthropicClientError<"BetaListDreams401", typeof BetaListDreams401.Type> + | AnthropicClientError<"BetaListDreams403", typeof BetaListDreams403.Type> + | AnthropicClientError<"BetaListDreams404", typeof BetaListDreams404.Type> + | AnthropicClientError<"BetaListDreams408", typeof BetaListDreams408.Type> + | AnthropicClientError<"BetaListDreams409", typeof BetaListDreams409.Type> + | AnthropicClientError<"BetaListDreams412", typeof BetaListDreams412.Type> + | AnthropicClientError<"BetaListDreams413", typeof BetaListDreams413.Type> + | AnthropicClientError<"BetaListDreams429", typeof BetaListDreams429.Type> + | AnthropicClientError<"BetaListDreams431", typeof BetaListDreams431.Type> + | AnthropicClientError<"BetaListDreams499", typeof BetaListDreams499.Type> + | AnthropicClientError<"BetaListDreams500", typeof BetaListDreams500.Type> + | AnthropicClientError<"BetaListDreams501", typeof BetaListDreams501.Type> + | AnthropicClientError<"BetaListDreams503", typeof BetaListDreams503.Type> + | AnthropicClientError<"BetaListDreams504", typeof BetaListDreams504.Type> > /** - * Get a specific model. - * - * The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID. + * Create a Dream */ - readonly "modelsGet": ( - modelId: string, + readonly "BetaCreateDream": ( + options: { + readonly params?: typeof BetaCreateDreamParams.Encoded | undefined + readonly payload: typeof BetaCreateDreamRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaCreateDream400", typeof BetaCreateDream400.Type> + | AnthropicClientError<"BetaCreateDream401", typeof BetaCreateDream401.Type> + | AnthropicClientError<"BetaCreateDream403", typeof BetaCreateDream403.Type> + | AnthropicClientError<"BetaCreateDream404", typeof BetaCreateDream404.Type> + | AnthropicClientError<"BetaCreateDream408", typeof BetaCreateDream408.Type> + | AnthropicClientError<"BetaCreateDream409", typeof BetaCreateDream409.Type> + | AnthropicClientError<"BetaCreateDream412", typeof BetaCreateDream412.Type> + | AnthropicClientError<"BetaCreateDream413", typeof BetaCreateDream413.Type> + | AnthropicClientError<"BetaCreateDream429", typeof BetaCreateDream429.Type> + | AnthropicClientError<"BetaCreateDream431", typeof BetaCreateDream431.Type> + | AnthropicClientError<"BetaCreateDream499", typeof BetaCreateDream499.Type> + | AnthropicClientError<"BetaCreateDream500", typeof BetaCreateDream500.Type> + | AnthropicClientError<"BetaCreateDream501", typeof BetaCreateDream501.Type> + | AnthropicClientError<"BetaCreateDream503", typeof BetaCreateDream503.Type> + | AnthropicClientError<"BetaCreateDream504", typeof BetaCreateDream504.Type> + > + /** + * Get a Dream + */ + readonly "BetaGetDream": ( + dreamId: string, options: - | { readonly params?: typeof ModelsGetParams.Encoded | undefined; readonly config?: Config | undefined } + | { readonly params?: typeof BetaGetDreamParams.Encoded | undefined; readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, - HttpClientError.HttpClientError | SchemaError | AnthropicClientError<"ModelsGet4XX", typeof ModelsGet4XX.Type> + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetDream400", typeof BetaGetDream400.Type> + | AnthropicClientError<"BetaGetDream401", typeof BetaGetDream401.Type> + | AnthropicClientError<"BetaGetDream403", typeof BetaGetDream403.Type> + | AnthropicClientError<"BetaGetDream404", typeof BetaGetDream404.Type> + | AnthropicClientError<"BetaGetDream408", typeof BetaGetDream408.Type> + | AnthropicClientError<"BetaGetDream409", typeof BetaGetDream409.Type> + | AnthropicClientError<"BetaGetDream412", typeof BetaGetDream412.Type> + | AnthropicClientError<"BetaGetDream413", typeof BetaGetDream413.Type> + | AnthropicClientError<"BetaGetDream429", typeof BetaGetDream429.Type> + | AnthropicClientError<"BetaGetDream431", typeof BetaGetDream431.Type> + | AnthropicClientError<"BetaGetDream499", typeof BetaGetDream499.Type> + | AnthropicClientError<"BetaGetDream500", typeof BetaGetDream500.Type> + | AnthropicClientError<"BetaGetDream501", typeof BetaGetDream501.Type> + | AnthropicClientError<"BetaGetDream503", typeof BetaGetDream503.Type> + | AnthropicClientError<"BetaGetDream504", typeof BetaGetDream504.Type> > /** - * List all Message Batches within a Workspace. Most recently created batches are returned first. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * Cancel a Dream */ - readonly "messageBatchesList": ( + readonly "BetaCancelDream": ( + dreamId: string, options: { - readonly params?: typeof MessageBatchesListParams.Encoded | undefined + readonly params?: typeof BetaCancelDreamParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"MessageBatchesList4XX", typeof MessageBatchesList4XX.Type> + | AnthropicClientError<"BetaCancelDream400", typeof BetaCancelDream400.Type> + | AnthropicClientError<"BetaCancelDream401", typeof BetaCancelDream401.Type> + | AnthropicClientError<"BetaCancelDream403", typeof BetaCancelDream403.Type> + | AnthropicClientError<"BetaCancelDream404", typeof BetaCancelDream404.Type> + | AnthropicClientError<"BetaCancelDream408", typeof BetaCancelDream408.Type> + | AnthropicClientError<"BetaCancelDream409", typeof BetaCancelDream409.Type> + | AnthropicClientError<"BetaCancelDream412", typeof BetaCancelDream412.Type> + | AnthropicClientError<"BetaCancelDream413", typeof BetaCancelDream413.Type> + | AnthropicClientError<"BetaCancelDream429", typeof BetaCancelDream429.Type> + | AnthropicClientError<"BetaCancelDream431", typeof BetaCancelDream431.Type> + | AnthropicClientError<"BetaCancelDream499", typeof BetaCancelDream499.Type> + | AnthropicClientError<"BetaCancelDream500", typeof BetaCancelDream500.Type> + | AnthropicClientError<"BetaCancelDream501", typeof BetaCancelDream501.Type> + | AnthropicClientError<"BetaCancelDream503", typeof BetaCancelDream503.Type> + | AnthropicClientError<"BetaCancelDream504", typeof BetaCancelDream504.Type> > /** - * Send a batch of Message creation requests. - * - * The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * Archive a Dream */ - readonly "messageBatchesPost": ( + readonly "BetaArchiveDream": ( + dreamId: string, options: { - readonly params?: typeof MessageBatchesPostParams.Encoded | undefined - readonly payload: typeof MessageBatchesPostRequestJson.Encoded + readonly params?: typeof BetaArchiveDreamParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaArchiveDream400", typeof BetaArchiveDream400.Type> + | AnthropicClientError<"BetaArchiveDream401", typeof BetaArchiveDream401.Type> + | AnthropicClientError<"BetaArchiveDream403", typeof BetaArchiveDream403.Type> + | AnthropicClientError<"BetaArchiveDream404", typeof BetaArchiveDream404.Type> + | AnthropicClientError<"BetaArchiveDream408", typeof BetaArchiveDream408.Type> + | AnthropicClientError<"BetaArchiveDream409", typeof BetaArchiveDream409.Type> + | AnthropicClientError<"BetaArchiveDream412", typeof BetaArchiveDream412.Type> + | AnthropicClientError<"BetaArchiveDream413", typeof BetaArchiveDream413.Type> + | AnthropicClientError<"BetaArchiveDream429", typeof BetaArchiveDream429.Type> + | AnthropicClientError<"BetaArchiveDream431", typeof BetaArchiveDream431.Type> + | AnthropicClientError<"BetaArchiveDream499", typeof BetaArchiveDream499.Type> + | AnthropicClientError<"BetaArchiveDream500", typeof BetaArchiveDream500.Type> + | AnthropicClientError<"BetaArchiveDream501", typeof BetaArchiveDream501.Type> + | AnthropicClientError<"BetaArchiveDream503", typeof BetaArchiveDream503.Type> + | AnthropicClientError<"BetaArchiveDream504", typeof BetaArchiveDream504.Type> + > + /** + * List Sessions + */ + readonly "BetaListSessions": ( + options: { + readonly params?: typeof BetaListSessionsParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListSessions400", typeof BetaListSessions400.Type> + | AnthropicClientError<"BetaListSessions401", typeof BetaListSessions401.Type> + | AnthropicClientError<"BetaListSessions403", typeof BetaListSessions403.Type> + | AnthropicClientError<"BetaListSessions404", typeof BetaListSessions404.Type> + | AnthropicClientError<"BetaListSessions408", typeof BetaListSessions408.Type> + | AnthropicClientError<"BetaListSessions409", typeof BetaListSessions409.Type> + | AnthropicClientError<"BetaListSessions412", typeof BetaListSessions412.Type> + | AnthropicClientError<"BetaListSessions413", typeof BetaListSessions413.Type> + | AnthropicClientError<"BetaListSessions429", typeof BetaListSessions429.Type> + | AnthropicClientError<"BetaListSessions431", typeof BetaListSessions431.Type> + | AnthropicClientError<"BetaListSessions499", typeof BetaListSessions499.Type> + | AnthropicClientError<"BetaListSessions500", typeof BetaListSessions500.Type> + | AnthropicClientError<"BetaListSessions501", typeof BetaListSessions501.Type> + | AnthropicClientError<"BetaListSessions503", typeof BetaListSessions503.Type> + | AnthropicClientError<"BetaListSessions504", typeof BetaListSessions504.Type> + > + /** + * Create Session + */ + readonly "BetaCreateSession": ( + options: { + readonly params?: typeof BetaCreateSessionParams.Encoded | undefined + readonly payload: typeof BetaCreateSessionRequestJson.Encoded readonly config?: Config | undefined } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"MessageBatchesPost4XX", typeof MessageBatchesPost4XX.Type> + | AnthropicClientError<"BetaCreateSession400", typeof BetaCreateSession400.Type> + | AnthropicClientError<"BetaCreateSession401", typeof BetaCreateSession401.Type> + | AnthropicClientError<"BetaCreateSession403", typeof BetaCreateSession403.Type> + | AnthropicClientError<"BetaCreateSession404", typeof BetaCreateSession404.Type> + | AnthropicClientError<"BetaCreateSession408", typeof BetaCreateSession408.Type> + | AnthropicClientError<"BetaCreateSession409", typeof BetaCreateSession409.Type> + | AnthropicClientError<"BetaCreateSession412", typeof BetaCreateSession412.Type> + | AnthropicClientError<"BetaCreateSession413", typeof BetaCreateSession413.Type> + | AnthropicClientError<"BetaCreateSession429", typeof BetaCreateSession429.Type> + | AnthropicClientError<"BetaCreateSession431", typeof BetaCreateSession431.Type> + | AnthropicClientError<"BetaCreateSession499", typeof BetaCreateSession499.Type> + | AnthropicClientError<"BetaCreateSession500", typeof BetaCreateSession500.Type> + | AnthropicClientError<"BetaCreateSession501", typeof BetaCreateSession501.Type> + | AnthropicClientError<"BetaCreateSession503", typeof BetaCreateSession503.Type> + | AnthropicClientError<"BetaCreateSession504", typeof BetaCreateSession504.Type> > /** - * This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * Get Session */ - readonly "messageBatchesRetrieve": ( - messageBatchId: string, + readonly "BetaGetSession": ( + sessionId: string, + options: + | { readonly params?: typeof BetaGetSessionParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetSession400", typeof BetaGetSession400.Type> + | AnthropicClientError<"BetaGetSession401", typeof BetaGetSession401.Type> + | AnthropicClientError<"BetaGetSession403", typeof BetaGetSession403.Type> + | AnthropicClientError<"BetaGetSession404", typeof BetaGetSession404.Type> + | AnthropicClientError<"BetaGetSession408", typeof BetaGetSession408.Type> + | AnthropicClientError<"BetaGetSession409", typeof BetaGetSession409.Type> + | AnthropicClientError<"BetaGetSession412", typeof BetaGetSession412.Type> + | AnthropicClientError<"BetaGetSession413", typeof BetaGetSession413.Type> + | AnthropicClientError<"BetaGetSession429", typeof BetaGetSession429.Type> + | AnthropicClientError<"BetaGetSession431", typeof BetaGetSession431.Type> + | AnthropicClientError<"BetaGetSession499", typeof BetaGetSession499.Type> + | AnthropicClientError<"BetaGetSession500", typeof BetaGetSession500.Type> + | AnthropicClientError<"BetaGetSession501", typeof BetaGetSession501.Type> + | AnthropicClientError<"BetaGetSession503", typeof BetaGetSession503.Type> + | AnthropicClientError<"BetaGetSession504", typeof BetaGetSession504.Type> + > + /** + * Update Session + */ + readonly "BetaUpdateSession": ( + sessionId: string, options: { - readonly params?: typeof MessageBatchesRetrieveParams.Encoded | undefined + readonly params?: typeof BetaUpdateSessionParams.Encoded | undefined + readonly payload: typeof BetaUpdateSessionRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaUpdateSession400", typeof BetaUpdateSession400.Type> + | AnthropicClientError<"BetaUpdateSession401", typeof BetaUpdateSession401.Type> + | AnthropicClientError<"BetaUpdateSession403", typeof BetaUpdateSession403.Type> + | AnthropicClientError<"BetaUpdateSession404", typeof BetaUpdateSession404.Type> + | AnthropicClientError<"BetaUpdateSession408", typeof BetaUpdateSession408.Type> + | AnthropicClientError<"BetaUpdateSession409", typeof BetaUpdateSession409.Type> + | AnthropicClientError<"BetaUpdateSession412", typeof BetaUpdateSession412.Type> + | AnthropicClientError<"BetaUpdateSession413", typeof BetaUpdateSession413.Type> + | AnthropicClientError<"BetaUpdateSession429", typeof BetaUpdateSession429.Type> + | AnthropicClientError<"BetaUpdateSession431", typeof BetaUpdateSession431.Type> + | AnthropicClientError<"BetaUpdateSession499", typeof BetaUpdateSession499.Type> + | AnthropicClientError<"BetaUpdateSession500", typeof BetaUpdateSession500.Type> + | AnthropicClientError<"BetaUpdateSession501", typeof BetaUpdateSession501.Type> + | AnthropicClientError<"BetaUpdateSession503", typeof BetaUpdateSession503.Type> + | AnthropicClientError<"BetaUpdateSession504", typeof BetaUpdateSession504.Type> + > + /** + * Delete Session + */ + readonly "BetaDeleteSession": ( + sessionId: string, + options: { + readonly params?: typeof BetaDeleteSessionParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"MessageBatchesRetrieve4XX", typeof MessageBatchesRetrieve4XX.Type> + | AnthropicClientError<"BetaDeleteSession400", typeof BetaDeleteSession400.Type> + | AnthropicClientError<"BetaDeleteSession401", typeof BetaDeleteSession401.Type> + | AnthropicClientError<"BetaDeleteSession403", typeof BetaDeleteSession403.Type> + | AnthropicClientError<"BetaDeleteSession404", typeof BetaDeleteSession404.Type> + | AnthropicClientError<"BetaDeleteSession408", typeof BetaDeleteSession408.Type> + | AnthropicClientError<"BetaDeleteSession409", typeof BetaDeleteSession409.Type> + | AnthropicClientError<"BetaDeleteSession412", typeof BetaDeleteSession412.Type> + | AnthropicClientError<"BetaDeleteSession413", typeof BetaDeleteSession413.Type> + | AnthropicClientError<"BetaDeleteSession429", typeof BetaDeleteSession429.Type> + | AnthropicClientError<"BetaDeleteSession431", typeof BetaDeleteSession431.Type> + | AnthropicClientError<"BetaDeleteSession499", typeof BetaDeleteSession499.Type> + | AnthropicClientError<"BetaDeleteSession500", typeof BetaDeleteSession500.Type> + | AnthropicClientError<"BetaDeleteSession501", typeof BetaDeleteSession501.Type> + | AnthropicClientError<"BetaDeleteSession503", typeof BetaDeleteSession503.Type> + | AnthropicClientError<"BetaDeleteSession504", typeof BetaDeleteSession504.Type> > /** - * Delete a Message Batch. - * - * Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * List Events */ - readonly "messageBatchesDelete": ( - messageBatchId: string, + readonly "BetaListEvents": ( + sessionId: string, + options: + | { readonly params?: typeof BetaListEventsParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaListEvents400", typeof BetaListEvents400.Type> + | AnthropicClientError<"BetaListEvents401", typeof BetaListEvents401.Type> + | AnthropicClientError<"BetaListEvents403", typeof BetaListEvents403.Type> + | AnthropicClientError<"BetaListEvents404", typeof BetaListEvents404.Type> + | AnthropicClientError<"BetaListEvents408", typeof BetaListEvents408.Type> + | AnthropicClientError<"BetaListEvents409", typeof BetaListEvents409.Type> + | AnthropicClientError<"BetaListEvents412", typeof BetaListEvents412.Type> + | AnthropicClientError<"BetaListEvents413", typeof BetaListEvents413.Type> + | AnthropicClientError<"BetaListEvents429", typeof BetaListEvents429.Type> + | AnthropicClientError<"BetaListEvents431", typeof BetaListEvents431.Type> + | AnthropicClientError<"BetaListEvents499", typeof BetaListEvents499.Type> + | AnthropicClientError<"BetaListEvents500", typeof BetaListEvents500.Type> + | AnthropicClientError<"BetaListEvents501", typeof BetaListEvents501.Type> + | AnthropicClientError<"BetaListEvents503", typeof BetaListEvents503.Type> + | AnthropicClientError<"BetaListEvents504", typeof BetaListEvents504.Type> + > + /** + * Send Events + */ + readonly "BetaSendEvents": ( + sessionId: string, options: { - readonly params?: typeof MessageBatchesDeleteParams.Encoded | undefined + readonly params?: typeof BetaSendEventsParams.Encoded | undefined + readonly payload: typeof BetaSendEventsRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaSendEvents400", typeof BetaSendEvents400.Type> + | AnthropicClientError<"BetaSendEvents401", typeof BetaSendEvents401.Type> + | AnthropicClientError<"BetaSendEvents403", typeof BetaSendEvents403.Type> + | AnthropicClientError<"BetaSendEvents404", typeof BetaSendEvents404.Type> + | AnthropicClientError<"BetaSendEvents408", typeof BetaSendEvents408.Type> + | AnthropicClientError<"BetaSendEvents409", typeof BetaSendEvents409.Type> + | AnthropicClientError<"BetaSendEvents412", typeof BetaSendEvents412.Type> + | AnthropicClientError<"BetaSendEvents413", typeof BetaSendEvents413.Type> + | AnthropicClientError<"BetaSendEvents429", typeof BetaSendEvents429.Type> + | AnthropicClientError<"BetaSendEvents431", typeof BetaSendEvents431.Type> + | AnthropicClientError<"BetaSendEvents499", typeof BetaSendEvents499.Type> + | AnthropicClientError<"BetaSendEvents500", typeof BetaSendEvents500.Type> + | AnthropicClientError<"BetaSendEvents501", typeof BetaSendEvents501.Type> + | AnthropicClientError<"BetaSendEvents503", typeof BetaSendEvents503.Type> + | AnthropicClientError<"BetaSendEvents504", typeof BetaSendEvents504.Type> + > + /** + * Stream Events + */ + readonly "BetaStreamSessionEvents": ( + sessionId: string, + options: { + readonly params?: typeof BetaStreamSessionEventsParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"MessageBatchesDelete4XX", typeof MessageBatchesDelete4XX.Type> + | AnthropicClientError<"BetaStreamSessionEvents400", typeof BetaStreamSessionEvents400.Type> + | AnthropicClientError<"BetaStreamSessionEvents401", typeof BetaStreamSessionEvents401.Type> + | AnthropicClientError<"BetaStreamSessionEvents403", typeof BetaStreamSessionEvents403.Type> + | AnthropicClientError<"BetaStreamSessionEvents404", typeof BetaStreamSessionEvents404.Type> + | AnthropicClientError<"BetaStreamSessionEvents408", typeof BetaStreamSessionEvents408.Type> + | AnthropicClientError<"BetaStreamSessionEvents409", typeof BetaStreamSessionEvents409.Type> + | AnthropicClientError<"BetaStreamSessionEvents412", typeof BetaStreamSessionEvents412.Type> + | AnthropicClientError<"BetaStreamSessionEvents413", typeof BetaStreamSessionEvents413.Type> + | AnthropicClientError<"BetaStreamSessionEvents429", typeof BetaStreamSessionEvents429.Type> + | AnthropicClientError<"BetaStreamSessionEvents431", typeof BetaStreamSessionEvents431.Type> + | AnthropicClientError<"BetaStreamSessionEvents499", typeof BetaStreamSessionEvents499.Type> + | AnthropicClientError<"BetaStreamSessionEvents500", typeof BetaStreamSessionEvents500.Type> + | AnthropicClientError<"BetaStreamSessionEvents501", typeof BetaStreamSessionEvents501.Type> + | AnthropicClientError<"BetaStreamSessionEvents503", typeof BetaStreamSessionEvents503.Type> + | AnthropicClientError<"BetaStreamSessionEvents504", typeof BetaStreamSessionEvents504.Type> > /** - * Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation. - * - * The number of canceled requests is specified in `request_counts`. To determine which requests were canceled, check the individual results within the batch. Note that cancellation may not result in any canceled requests if they were non-interruptible. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * Archive Session */ - readonly "messageBatchesCancel": ( - messageBatchId: string, + readonly "BetaArchiveSession": ( + sessionId: string, options: { - readonly params?: typeof MessageBatchesCancelParams.Encoded | undefined + readonly params?: typeof BetaArchiveSessionParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"MessageBatchesCancel4XX", typeof MessageBatchesCancel4XX.Type> + | AnthropicClientError<"BetaArchiveSession400", typeof BetaArchiveSession400.Type> + | AnthropicClientError<"BetaArchiveSession401", typeof BetaArchiveSession401.Type> + | AnthropicClientError<"BetaArchiveSession403", typeof BetaArchiveSession403.Type> + | AnthropicClientError<"BetaArchiveSession404", typeof BetaArchiveSession404.Type> + | AnthropicClientError<"BetaArchiveSession408", typeof BetaArchiveSession408.Type> + | AnthropicClientError<"BetaArchiveSession409", typeof BetaArchiveSession409.Type> + | AnthropicClientError<"BetaArchiveSession412", typeof BetaArchiveSession412.Type> + | AnthropicClientError<"BetaArchiveSession413", typeof BetaArchiveSession413.Type> + | AnthropicClientError<"BetaArchiveSession429", typeof BetaArchiveSession429.Type> + | AnthropicClientError<"BetaArchiveSession431", typeof BetaArchiveSession431.Type> + | AnthropicClientError<"BetaArchiveSession499", typeof BetaArchiveSession499.Type> + | AnthropicClientError<"BetaArchiveSession500", typeof BetaArchiveSession500.Type> + | AnthropicClientError<"BetaArchiveSession501", typeof BetaArchiveSession501.Type> + | AnthropicClientError<"BetaArchiveSession503", typeof BetaArchiveSession503.Type> + | AnthropicClientError<"BetaArchiveSession504", typeof BetaArchiveSession504.Type> > /** - * Streams the results of a Message Batch as a `.jsonl` file. - * - * Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * List Session Threads */ - readonly "messageBatchesResults": ( - messageBatchId: string, + readonly "BetaListSessionThreads": ( + sessionId: string, options: { - readonly params?: typeof MessageBatchesResultsParams.Encoded | undefined + readonly params?: typeof BetaListSessionThreadsParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"MessageBatchesResults4XX", typeof MessageBatchesResults4XX.Type> + | AnthropicClientError<"BetaListSessionThreads400", typeof BetaListSessionThreads400.Type> + | AnthropicClientError<"BetaListSessionThreads401", typeof BetaListSessionThreads401.Type> + | AnthropicClientError<"BetaListSessionThreads403", typeof BetaListSessionThreads403.Type> + | AnthropicClientError<"BetaListSessionThreads404", typeof BetaListSessionThreads404.Type> + | AnthropicClientError<"BetaListSessionThreads408", typeof BetaListSessionThreads408.Type> + | AnthropicClientError<"BetaListSessionThreads409", typeof BetaListSessionThreads409.Type> + | AnthropicClientError<"BetaListSessionThreads412", typeof BetaListSessionThreads412.Type> + | AnthropicClientError<"BetaListSessionThreads413", typeof BetaListSessionThreads413.Type> + | AnthropicClientError<"BetaListSessionThreads429", typeof BetaListSessionThreads429.Type> + | AnthropicClientError<"BetaListSessionThreads431", typeof BetaListSessionThreads431.Type> + | AnthropicClientError<"BetaListSessionThreads499", typeof BetaListSessionThreads499.Type> + | AnthropicClientError<"BetaListSessionThreads500", typeof BetaListSessionThreads500.Type> + | AnthropicClientError<"BetaListSessionThreads501", typeof BetaListSessionThreads501.Type> + | AnthropicClientError<"BetaListSessionThreads503", typeof BetaListSessionThreads503.Type> + | AnthropicClientError<"BetaListSessionThreads504", typeof BetaListSessionThreads504.Type> > /** - * Count the number of tokens in a Message. - * - * The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it. - * - * Learn more about token counting in our [user guide](https://docs.claude.com/en/docs/build-with-claude/token-counting) + * Get Session Thread */ - readonly "messagesCountTokensPost": ( + readonly "BetaGetSessionThread": ( + sessionId: string, + threadId: string, options: { - readonly params?: typeof MessagesCountTokensPostParams.Encoded | undefined - readonly payload: typeof MessagesCountTokensPostRequestJson.Encoded + readonly params?: typeof BetaGetSessionThreadParams.Encoded | undefined readonly config?: Config | undefined - } + } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"MessagesCountTokensPost4XX", typeof MessagesCountTokensPost4XX.Type> + | AnthropicClientError<"BetaGetSessionThread400", typeof BetaGetSessionThread400.Type> + | AnthropicClientError<"BetaGetSessionThread401", typeof BetaGetSessionThread401.Type> + | AnthropicClientError<"BetaGetSessionThread403", typeof BetaGetSessionThread403.Type> + | AnthropicClientError<"BetaGetSessionThread404", typeof BetaGetSessionThread404.Type> + | AnthropicClientError<"BetaGetSessionThread408", typeof BetaGetSessionThread408.Type> + | AnthropicClientError<"BetaGetSessionThread409", typeof BetaGetSessionThread409.Type> + | AnthropicClientError<"BetaGetSessionThread412", typeof BetaGetSessionThread412.Type> + | AnthropicClientError<"BetaGetSessionThread413", typeof BetaGetSessionThread413.Type> + | AnthropicClientError<"BetaGetSessionThread429", typeof BetaGetSessionThread429.Type> + | AnthropicClientError<"BetaGetSessionThread431", typeof BetaGetSessionThread431.Type> + | AnthropicClientError<"BetaGetSessionThread499", typeof BetaGetSessionThread499.Type> + | AnthropicClientError<"BetaGetSessionThread500", typeof BetaGetSessionThread500.Type> + | AnthropicClientError<"BetaGetSessionThread501", typeof BetaGetSessionThread501.Type> + | AnthropicClientError<"BetaGetSessionThread503", typeof BetaGetSessionThread503.Type> + | AnthropicClientError<"BetaGetSessionThread504", typeof BetaGetSessionThread504.Type> > /** - * List Files + * List Session Thread Events */ - readonly "listFilesV1FilesGet": ( + readonly "BetaListSessionThreadEvents": ( + sessionId: string, + threadId: string, options: { - readonly params?: typeof ListFilesV1FilesGetParams.Encoded | undefined + readonly params?: typeof BetaListSessionThreadEventsParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"ListFilesV1FilesGet4XX", typeof ListFilesV1FilesGet4XX.Type> + | AnthropicClientError<"BetaListSessionThreadEvents400", typeof BetaListSessionThreadEvents400.Type> + | AnthropicClientError<"BetaListSessionThreadEvents401", typeof BetaListSessionThreadEvents401.Type> + | AnthropicClientError<"BetaListSessionThreadEvents403", typeof BetaListSessionThreadEvents403.Type> + | AnthropicClientError<"BetaListSessionThreadEvents404", typeof BetaListSessionThreadEvents404.Type> + | AnthropicClientError<"BetaListSessionThreadEvents408", typeof BetaListSessionThreadEvents408.Type> + | AnthropicClientError<"BetaListSessionThreadEvents409", typeof BetaListSessionThreadEvents409.Type> + | AnthropicClientError<"BetaListSessionThreadEvents412", typeof BetaListSessionThreadEvents412.Type> + | AnthropicClientError<"BetaListSessionThreadEvents413", typeof BetaListSessionThreadEvents413.Type> + | AnthropicClientError<"BetaListSessionThreadEvents429", typeof BetaListSessionThreadEvents429.Type> + | AnthropicClientError<"BetaListSessionThreadEvents431", typeof BetaListSessionThreadEvents431.Type> + | AnthropicClientError<"BetaListSessionThreadEvents499", typeof BetaListSessionThreadEvents499.Type> + | AnthropicClientError<"BetaListSessionThreadEvents500", typeof BetaListSessionThreadEvents500.Type> + | AnthropicClientError<"BetaListSessionThreadEvents501", typeof BetaListSessionThreadEvents501.Type> + | AnthropicClientError<"BetaListSessionThreadEvents503", typeof BetaListSessionThreadEvents503.Type> + | AnthropicClientError<"BetaListSessionThreadEvents504", typeof BetaListSessionThreadEvents504.Type> > /** - * Upload File + * Stream Session Thread Events */ - readonly "uploadFileV1FilesPost": ( + readonly "BetaStreamSessionThreadEvents": ( + sessionId: string, + threadId: string, options: { - readonly params?: typeof UploadFileV1FilesPostParams.Encoded | undefined - readonly payload: typeof UploadFileV1FilesPostRequestFormData.Encoded + readonly params?: typeof BetaStreamSessionThreadEventsParams.Encoded | undefined readonly config?: Config | undefined - } + } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"UploadFileV1FilesPost4XX", typeof UploadFileV1FilesPost4XX.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents400", typeof BetaStreamSessionThreadEvents400.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents401", typeof BetaStreamSessionThreadEvents401.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents403", typeof BetaStreamSessionThreadEvents403.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents404", typeof BetaStreamSessionThreadEvents404.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents408", typeof BetaStreamSessionThreadEvents408.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents409", typeof BetaStreamSessionThreadEvents409.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents412", typeof BetaStreamSessionThreadEvents412.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents413", typeof BetaStreamSessionThreadEvents413.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents429", typeof BetaStreamSessionThreadEvents429.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents431", typeof BetaStreamSessionThreadEvents431.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents499", typeof BetaStreamSessionThreadEvents499.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents500", typeof BetaStreamSessionThreadEvents500.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents501", typeof BetaStreamSessionThreadEvents501.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents503", typeof BetaStreamSessionThreadEvents503.Type> + | AnthropicClientError<"BetaStreamSessionThreadEvents504", typeof BetaStreamSessionThreadEvents504.Type> > /** - * Get File Metadata + * Archive Session Thread */ - readonly "getFileMetadataV1FilesFileIdGet": ( - fileId: string, + readonly "BetaArchiveSessionThread": ( + sessionId: string, + threadId: string, options: { - readonly params?: typeof GetFileMetadataV1FilesFileIdGetParams.Encoded | undefined + readonly params?: typeof BetaArchiveSessionThreadParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"GetFileMetadataV1FilesFileIdGet4XX", typeof GetFileMetadataV1FilesFileIdGet4XX.Type> + | AnthropicClientError<"BetaArchiveSessionThread400", typeof BetaArchiveSessionThread400.Type> + | AnthropicClientError<"BetaArchiveSessionThread401", typeof BetaArchiveSessionThread401.Type> + | AnthropicClientError<"BetaArchiveSessionThread403", typeof BetaArchiveSessionThread403.Type> + | AnthropicClientError<"BetaArchiveSessionThread404", typeof BetaArchiveSessionThread404.Type> + | AnthropicClientError<"BetaArchiveSessionThread408", typeof BetaArchiveSessionThread408.Type> + | AnthropicClientError<"BetaArchiveSessionThread409", typeof BetaArchiveSessionThread409.Type> + | AnthropicClientError<"BetaArchiveSessionThread412", typeof BetaArchiveSessionThread412.Type> + | AnthropicClientError<"BetaArchiveSessionThread413", typeof BetaArchiveSessionThread413.Type> + | AnthropicClientError<"BetaArchiveSessionThread429", typeof BetaArchiveSessionThread429.Type> + | AnthropicClientError<"BetaArchiveSessionThread431", typeof BetaArchiveSessionThread431.Type> + | AnthropicClientError<"BetaArchiveSessionThread499", typeof BetaArchiveSessionThread499.Type> + | AnthropicClientError<"BetaArchiveSessionThread500", typeof BetaArchiveSessionThread500.Type> + | AnthropicClientError<"BetaArchiveSessionThread501", typeof BetaArchiveSessionThread501.Type> + | AnthropicClientError<"BetaArchiveSessionThread503", typeof BetaArchiveSessionThread503.Type> + | AnthropicClientError<"BetaArchiveSessionThread504", typeof BetaArchiveSessionThread504.Type> > /** - * Delete File + * List Session Resources */ - readonly "deleteFileV1FilesFileIdDelete": ( - fileId: string, + readonly "BetaListResources": ( + sessionId: string, options: { - readonly params?: typeof DeleteFileV1FilesFileIdDeleteParams.Encoded | undefined + readonly params?: typeof BetaListResourcesParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"DeleteFileV1FilesFileIdDelete4XX", typeof DeleteFileV1FilesFileIdDelete4XX.Type> + | AnthropicClientError<"BetaListResources400", typeof BetaListResources400.Type> + | AnthropicClientError<"BetaListResources401", typeof BetaListResources401.Type> + | AnthropicClientError<"BetaListResources403", typeof BetaListResources403.Type> + | AnthropicClientError<"BetaListResources404", typeof BetaListResources404.Type> + | AnthropicClientError<"BetaListResources408", typeof BetaListResources408.Type> + | AnthropicClientError<"BetaListResources409", typeof BetaListResources409.Type> + | AnthropicClientError<"BetaListResources412", typeof BetaListResources412.Type> + | AnthropicClientError<"BetaListResources413", typeof BetaListResources413.Type> + | AnthropicClientError<"BetaListResources429", typeof BetaListResources429.Type> + | AnthropicClientError<"BetaListResources431", typeof BetaListResources431.Type> + | AnthropicClientError<"BetaListResources499", typeof BetaListResources499.Type> + | AnthropicClientError<"BetaListResources500", typeof BetaListResources500.Type> + | AnthropicClientError<"BetaListResources501", typeof BetaListResources501.Type> + | AnthropicClientError<"BetaListResources503", typeof BetaListResources503.Type> + | AnthropicClientError<"BetaListResources504", typeof BetaListResources504.Type> > /** - * Download File + * Add Session Resource */ - readonly "downloadFileV1FilesFileIdContentGet": ( - fileId: string, + readonly "BetaAddResource": ( + sessionId: string, + options: { + readonly params?: typeof BetaAddResourceParams.Encoded | undefined + readonly payload: typeof BetaAddResourceRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaAddResource400", typeof BetaAddResource400.Type> + | AnthropicClientError<"BetaAddResource401", typeof BetaAddResource401.Type> + | AnthropicClientError<"BetaAddResource403", typeof BetaAddResource403.Type> + | AnthropicClientError<"BetaAddResource404", typeof BetaAddResource404.Type> + | AnthropicClientError<"BetaAddResource408", typeof BetaAddResource408.Type> + | AnthropicClientError<"BetaAddResource409", typeof BetaAddResource409.Type> + | AnthropicClientError<"BetaAddResource412", typeof BetaAddResource412.Type> + | AnthropicClientError<"BetaAddResource413", typeof BetaAddResource413.Type> + | AnthropicClientError<"BetaAddResource429", typeof BetaAddResource429.Type> + | AnthropicClientError<"BetaAddResource431", typeof BetaAddResource431.Type> + | AnthropicClientError<"BetaAddResource499", typeof BetaAddResource499.Type> + | AnthropicClientError<"BetaAddResource500", typeof BetaAddResource500.Type> + | AnthropicClientError<"BetaAddResource501", typeof BetaAddResource501.Type> + | AnthropicClientError<"BetaAddResource503", typeof BetaAddResource503.Type> + | AnthropicClientError<"BetaAddResource504", typeof BetaAddResource504.Type> + > + /** + * Get Session Resource + */ + readonly "BetaGetResource": ( + sessionId: string, + resourceId: string, options: { - readonly params?: typeof DownloadFileV1FilesFileIdContentGetParams.Encoded | undefined + readonly params?: typeof BetaGetResourceParams.Encoded | undefined readonly config?: Config | undefined } | undefined - ) => Effect.Effect, HttpClientError.HttpClientError | SchemaError> + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaGetResource400", typeof BetaGetResource400.Type> + | AnthropicClientError<"BetaGetResource401", typeof BetaGetResource401.Type> + | AnthropicClientError<"BetaGetResource403", typeof BetaGetResource403.Type> + | AnthropicClientError<"BetaGetResource404", typeof BetaGetResource404.Type> + | AnthropicClientError<"BetaGetResource408", typeof BetaGetResource408.Type> + | AnthropicClientError<"BetaGetResource409", typeof BetaGetResource409.Type> + | AnthropicClientError<"BetaGetResource412", typeof BetaGetResource412.Type> + | AnthropicClientError<"BetaGetResource413", typeof BetaGetResource413.Type> + | AnthropicClientError<"BetaGetResource429", typeof BetaGetResource429.Type> + | AnthropicClientError<"BetaGetResource431", typeof BetaGetResource431.Type> + | AnthropicClientError<"BetaGetResource499", typeof BetaGetResource499.Type> + | AnthropicClientError<"BetaGetResource500", typeof BetaGetResource500.Type> + | AnthropicClientError<"BetaGetResource501", typeof BetaGetResource501.Type> + | AnthropicClientError<"BetaGetResource503", typeof BetaGetResource503.Type> + | AnthropicClientError<"BetaGetResource504", typeof BetaGetResource504.Type> + > /** - * Download File + * Update Session Resource */ - readonly "downloadFileV1FilesFileIdContentGetStream": ( - fileId: string, - options: { readonly params?: typeof DownloadFileV1FilesFileIdContentGetParams.Encoded | undefined } | undefined - ) => Stream.Stream + readonly "BetaUpdateResource": ( + sessionId: string, + resourceId: string, + options: { + readonly params?: typeof BetaUpdateResourceParams.Encoded | undefined + readonly payload: typeof BetaUpdateResourceRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaUpdateResource400", typeof BetaUpdateResource400.Type> + | AnthropicClientError<"BetaUpdateResource401", typeof BetaUpdateResource401.Type> + | AnthropicClientError<"BetaUpdateResource403", typeof BetaUpdateResource403.Type> + | AnthropicClientError<"BetaUpdateResource404", typeof BetaUpdateResource404.Type> + | AnthropicClientError<"BetaUpdateResource408", typeof BetaUpdateResource408.Type> + | AnthropicClientError<"BetaUpdateResource409", typeof BetaUpdateResource409.Type> + | AnthropicClientError<"BetaUpdateResource412", typeof BetaUpdateResource412.Type> + | AnthropicClientError<"BetaUpdateResource413", typeof BetaUpdateResource413.Type> + | AnthropicClientError<"BetaUpdateResource429", typeof BetaUpdateResource429.Type> + | AnthropicClientError<"BetaUpdateResource431", typeof BetaUpdateResource431.Type> + | AnthropicClientError<"BetaUpdateResource499", typeof BetaUpdateResource499.Type> + | AnthropicClientError<"BetaUpdateResource500", typeof BetaUpdateResource500.Type> + | AnthropicClientError<"BetaUpdateResource501", typeof BetaUpdateResource501.Type> + | AnthropicClientError<"BetaUpdateResource503", typeof BetaUpdateResource503.Type> + | AnthropicClientError<"BetaUpdateResource504", typeof BetaUpdateResource504.Type> + > /** - * List Skills + * Delete Session Resource */ - readonly "listSkillsV1SkillsGet": ( + readonly "BetaDeleteResource": ( + sessionId: string, + resourceId: string, options: { - readonly params?: typeof ListSkillsV1SkillsGetParams.Encoded | undefined + readonly params?: typeof BetaDeleteResourceParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | AnthropicClientError<"BetaDeleteResource400", typeof BetaDeleteResource400.Type> + | AnthropicClientError<"BetaDeleteResource401", typeof BetaDeleteResource401.Type> + | AnthropicClientError<"BetaDeleteResource403", typeof BetaDeleteResource403.Type> + | AnthropicClientError<"BetaDeleteResource404", typeof BetaDeleteResource404.Type> + | AnthropicClientError<"BetaDeleteResource408", typeof BetaDeleteResource408.Type> + | AnthropicClientError<"BetaDeleteResource409", typeof BetaDeleteResource409.Type> + | AnthropicClientError<"BetaDeleteResource412", typeof BetaDeleteResource412.Type> + | AnthropicClientError<"BetaDeleteResource413", typeof BetaDeleteResource413.Type> + | AnthropicClientError<"BetaDeleteResource429", typeof BetaDeleteResource429.Type> + | AnthropicClientError<"BetaDeleteResource431", typeof BetaDeleteResource431.Type> + | AnthropicClientError<"BetaDeleteResource499", typeof BetaDeleteResource499.Type> + | AnthropicClientError<"BetaDeleteResource500", typeof BetaDeleteResource500.Type> + | AnthropicClientError<"BetaDeleteResource501", typeof BetaDeleteResource501.Type> + | AnthropicClientError<"BetaDeleteResource503", typeof BetaDeleteResource503.Type> + | AnthropicClientError<"BetaDeleteResource504", typeof BetaDeleteResource504.Type> + > + /** + * List Agents + */ + readonly "BetaListAgents": ( + options: + | { readonly params?: typeof BetaListAgentsParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"ListSkillsV1SkillsGet4XX", typeof ListSkillsV1SkillsGet4XX.Type> + | AnthropicClientError<"BetaListAgents400", typeof BetaListAgents400.Type> + | AnthropicClientError<"BetaListAgents401", typeof BetaListAgents401.Type> + | AnthropicClientError<"BetaListAgents403", typeof BetaListAgents403.Type> + | AnthropicClientError<"BetaListAgents404", typeof BetaListAgents404.Type> + | AnthropicClientError<"BetaListAgents408", typeof BetaListAgents408.Type> + | AnthropicClientError<"BetaListAgents409", typeof BetaListAgents409.Type> + | AnthropicClientError<"BetaListAgents412", typeof BetaListAgents412.Type> + | AnthropicClientError<"BetaListAgents413", typeof BetaListAgents413.Type> + | AnthropicClientError<"BetaListAgents429", typeof BetaListAgents429.Type> + | AnthropicClientError<"BetaListAgents431", typeof BetaListAgents431.Type> + | AnthropicClientError<"BetaListAgents499", typeof BetaListAgents499.Type> + | AnthropicClientError<"BetaListAgents500", typeof BetaListAgents500.Type> + | AnthropicClientError<"BetaListAgents501", typeof BetaListAgents501.Type> + | AnthropicClientError<"BetaListAgents503", typeof BetaListAgents503.Type> + | AnthropicClientError<"BetaListAgents504", typeof BetaListAgents504.Type> > /** - * Create Skill + * Create Agent */ - readonly "createSkillV1SkillsPost": ( + readonly "BetaCreateAgent": ( options: { - readonly params?: typeof CreateSkillV1SkillsPostParams.Encoded | undefined - readonly payload: typeof CreateSkillV1SkillsPostRequestFormData.Encoded + readonly params?: typeof BetaCreateAgentParams.Encoded | undefined + readonly payload: typeof BetaCreateAgentRequestJson.Encoded readonly config?: Config | undefined } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"CreateSkillV1SkillsPost4XX", typeof CreateSkillV1SkillsPost4XX.Type> + | AnthropicClientError<"BetaCreateAgent400", typeof BetaCreateAgent400.Type> + | AnthropicClientError<"BetaCreateAgent401", typeof BetaCreateAgent401.Type> + | AnthropicClientError<"BetaCreateAgent403", typeof BetaCreateAgent403.Type> + | AnthropicClientError<"BetaCreateAgent404", typeof BetaCreateAgent404.Type> + | AnthropicClientError<"BetaCreateAgent408", typeof BetaCreateAgent408.Type> + | AnthropicClientError<"BetaCreateAgent409", typeof BetaCreateAgent409.Type> + | AnthropicClientError<"BetaCreateAgent412", typeof BetaCreateAgent412.Type> + | AnthropicClientError<"BetaCreateAgent413", typeof BetaCreateAgent413.Type> + | AnthropicClientError<"BetaCreateAgent429", typeof BetaCreateAgent429.Type> + | AnthropicClientError<"BetaCreateAgent431", typeof BetaCreateAgent431.Type> + | AnthropicClientError<"BetaCreateAgent499", typeof BetaCreateAgent499.Type> + | AnthropicClientError<"BetaCreateAgent500", typeof BetaCreateAgent500.Type> + | AnthropicClientError<"BetaCreateAgent501", typeof BetaCreateAgent501.Type> + | AnthropicClientError<"BetaCreateAgent503", typeof BetaCreateAgent503.Type> + | AnthropicClientError<"BetaCreateAgent504", typeof BetaCreateAgent504.Type> > /** - * Get Skill + * Get Agent */ - readonly "getSkillV1SkillsSkillIdGet": ( - skillId: string, - options: { - readonly params?: typeof GetSkillV1SkillsSkillIdGetParams.Encoded | undefined - readonly config?: Config | undefined - } | undefined + readonly "BetaGetAgent": ( + agentId: string, + options: + | { readonly params?: typeof BetaGetAgentParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"GetSkillV1SkillsSkillIdGet4XX", typeof GetSkillV1SkillsSkillIdGet4XX.Type> + | AnthropicClientError<"BetaGetAgent400", typeof BetaGetAgent400.Type> + | AnthropicClientError<"BetaGetAgent401", typeof BetaGetAgent401.Type> + | AnthropicClientError<"BetaGetAgent403", typeof BetaGetAgent403.Type> + | AnthropicClientError<"BetaGetAgent404", typeof BetaGetAgent404.Type> + | AnthropicClientError<"BetaGetAgent408", typeof BetaGetAgent408.Type> + | AnthropicClientError<"BetaGetAgent409", typeof BetaGetAgent409.Type> + | AnthropicClientError<"BetaGetAgent412", typeof BetaGetAgent412.Type> + | AnthropicClientError<"BetaGetAgent413", typeof BetaGetAgent413.Type> + | AnthropicClientError<"BetaGetAgent429", typeof BetaGetAgent429.Type> + | AnthropicClientError<"BetaGetAgent431", typeof BetaGetAgent431.Type> + | AnthropicClientError<"BetaGetAgent499", typeof BetaGetAgent499.Type> + | AnthropicClientError<"BetaGetAgent500", typeof BetaGetAgent500.Type> + | AnthropicClientError<"BetaGetAgent501", typeof BetaGetAgent501.Type> + | AnthropicClientError<"BetaGetAgent503", typeof BetaGetAgent503.Type> + | AnthropicClientError<"BetaGetAgent504", typeof BetaGetAgent504.Type> > /** - * Delete Skill + * Update Agent */ - readonly "deleteSkillV1SkillsSkillIdDelete": ( - skillId: string, + readonly "BetaUpdateAgent": ( + agentId: string, options: { - readonly params?: typeof DeleteSkillV1SkillsSkillIdDeleteParams.Encoded | undefined + readonly params?: typeof BetaUpdateAgentParams.Encoded | undefined + readonly payload: typeof BetaUpdateAgentRequestJson.Encoded readonly config?: Config | undefined - } | undefined + } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"DeleteSkillV1SkillsSkillIdDelete4XX", typeof DeleteSkillV1SkillsSkillIdDelete4XX.Type> + | AnthropicClientError<"BetaUpdateAgent400", typeof BetaUpdateAgent400.Type> + | AnthropicClientError<"BetaUpdateAgent401", typeof BetaUpdateAgent401.Type> + | AnthropicClientError<"BetaUpdateAgent403", typeof BetaUpdateAgent403.Type> + | AnthropicClientError<"BetaUpdateAgent404", typeof BetaUpdateAgent404.Type> + | AnthropicClientError<"BetaUpdateAgent408", typeof BetaUpdateAgent408.Type> + | AnthropicClientError<"BetaUpdateAgent409", typeof BetaUpdateAgent409.Type> + | AnthropicClientError<"BetaUpdateAgent412", typeof BetaUpdateAgent412.Type> + | AnthropicClientError<"BetaUpdateAgent413", typeof BetaUpdateAgent413.Type> + | AnthropicClientError<"BetaUpdateAgent429", typeof BetaUpdateAgent429.Type> + | AnthropicClientError<"BetaUpdateAgent431", typeof BetaUpdateAgent431.Type> + | AnthropicClientError<"BetaUpdateAgent499", typeof BetaUpdateAgent499.Type> + | AnthropicClientError<"BetaUpdateAgent500", typeof BetaUpdateAgent500.Type> + | AnthropicClientError<"BetaUpdateAgent501", typeof BetaUpdateAgent501.Type> + | AnthropicClientError<"BetaUpdateAgent503", typeof BetaUpdateAgent503.Type> + | AnthropicClientError<"BetaUpdateAgent504", typeof BetaUpdateAgent504.Type> > /** - * List Skill Versions + * Archive Agent */ - readonly "listSkillVersionsV1SkillsSkillIdVersionsGet": ( - skillId: string, + readonly "BetaArchiveAgent": ( + agentId: string, options: { - readonly params?: typeof ListSkillVersionsV1SkillsSkillIdVersionsGetParams.Encoded | undefined + readonly params?: typeof BetaArchiveAgentParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError< - "ListSkillVersionsV1SkillsSkillIdVersionsGet4XX", - typeof ListSkillVersionsV1SkillsSkillIdVersionsGet4XX.Type - > + | AnthropicClientError<"BetaArchiveAgent400", typeof BetaArchiveAgent400.Type> + | AnthropicClientError<"BetaArchiveAgent401", typeof BetaArchiveAgent401.Type> + | AnthropicClientError<"BetaArchiveAgent403", typeof BetaArchiveAgent403.Type> + | AnthropicClientError<"BetaArchiveAgent404", typeof BetaArchiveAgent404.Type> + | AnthropicClientError<"BetaArchiveAgent408", typeof BetaArchiveAgent408.Type> + | AnthropicClientError<"BetaArchiveAgent409", typeof BetaArchiveAgent409.Type> + | AnthropicClientError<"BetaArchiveAgent412", typeof BetaArchiveAgent412.Type> + | AnthropicClientError<"BetaArchiveAgent413", typeof BetaArchiveAgent413.Type> + | AnthropicClientError<"BetaArchiveAgent429", typeof BetaArchiveAgent429.Type> + | AnthropicClientError<"BetaArchiveAgent431", typeof BetaArchiveAgent431.Type> + | AnthropicClientError<"BetaArchiveAgent499", typeof BetaArchiveAgent499.Type> + | AnthropicClientError<"BetaArchiveAgent500", typeof BetaArchiveAgent500.Type> + | AnthropicClientError<"BetaArchiveAgent501", typeof BetaArchiveAgent501.Type> + | AnthropicClientError<"BetaArchiveAgent503", typeof BetaArchiveAgent503.Type> + | AnthropicClientError<"BetaArchiveAgent504", typeof BetaArchiveAgent504.Type> > /** - * Create Skill Version + * List Agent Versions */ - readonly "createSkillVersionV1SkillsSkillIdVersionsPost": ( - skillId: string, + readonly "BetaListAgentVersions": ( + agentId: string, options: { - readonly params?: typeof CreateSkillVersionV1SkillsSkillIdVersionsPostParams.Encoded | undefined - readonly payload: typeof CreateSkillVersionV1SkillsSkillIdVersionsPostRequestFormData.Encoded + readonly params?: typeof BetaListAgentVersionsParams.Encoded | undefined readonly config?: Config | undefined - } + } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError< - "CreateSkillVersionV1SkillsSkillIdVersionsPost4XX", - typeof CreateSkillVersionV1SkillsSkillIdVersionsPost4XX.Type - > + | AnthropicClientError<"BetaListAgentVersions400", typeof BetaListAgentVersions400.Type> + | AnthropicClientError<"BetaListAgentVersions401", typeof BetaListAgentVersions401.Type> + | AnthropicClientError<"BetaListAgentVersions403", typeof BetaListAgentVersions403.Type> + | AnthropicClientError<"BetaListAgentVersions404", typeof BetaListAgentVersions404.Type> + | AnthropicClientError<"BetaListAgentVersions408", typeof BetaListAgentVersions408.Type> + | AnthropicClientError<"BetaListAgentVersions409", typeof BetaListAgentVersions409.Type> + | AnthropicClientError<"BetaListAgentVersions412", typeof BetaListAgentVersions412.Type> + | AnthropicClientError<"BetaListAgentVersions413", typeof BetaListAgentVersions413.Type> + | AnthropicClientError<"BetaListAgentVersions429", typeof BetaListAgentVersions429.Type> + | AnthropicClientError<"BetaListAgentVersions431", typeof BetaListAgentVersions431.Type> + | AnthropicClientError<"BetaListAgentVersions499", typeof BetaListAgentVersions499.Type> + | AnthropicClientError<"BetaListAgentVersions500", typeof BetaListAgentVersions500.Type> + | AnthropicClientError<"BetaListAgentVersions501", typeof BetaListAgentVersions501.Type> + | AnthropicClientError<"BetaListAgentVersions503", typeof BetaListAgentVersions503.Type> + | AnthropicClientError<"BetaListAgentVersions504", typeof BetaListAgentVersions504.Type> > /** - * Get Skill Version + * List Deployments */ - readonly "getSkillVersionV1SkillsSkillIdVersionsVersionGet": ( - skillId: string, - version: string, + readonly "BetaListDeployments": ( options: { - readonly params?: typeof GetSkillVersionV1SkillsSkillIdVersionsVersionGetParams.Encoded | undefined + readonly params?: typeof BetaListDeploymentsParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError< - "GetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX", - typeof GetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX.Type - > + | AnthropicClientError<"BetaListDeployments400", typeof BetaListDeployments400.Type> + | AnthropicClientError<"BetaListDeployments401", typeof BetaListDeployments401.Type> + | AnthropicClientError<"BetaListDeployments403", typeof BetaListDeployments403.Type> + | AnthropicClientError<"BetaListDeployments404", typeof BetaListDeployments404.Type> + | AnthropicClientError<"BetaListDeployments408", typeof BetaListDeployments408.Type> + | AnthropicClientError<"BetaListDeployments409", typeof BetaListDeployments409.Type> + | AnthropicClientError<"BetaListDeployments412", typeof BetaListDeployments412.Type> + | AnthropicClientError<"BetaListDeployments413", typeof BetaListDeployments413.Type> + | AnthropicClientError<"BetaListDeployments429", typeof BetaListDeployments429.Type> + | AnthropicClientError<"BetaListDeployments431", typeof BetaListDeployments431.Type> + | AnthropicClientError<"BetaListDeployments499", typeof BetaListDeployments499.Type> + | AnthropicClientError<"BetaListDeployments500", typeof BetaListDeployments500.Type> + | AnthropicClientError<"BetaListDeployments501", typeof BetaListDeployments501.Type> + | AnthropicClientError<"BetaListDeployments503", typeof BetaListDeployments503.Type> + | AnthropicClientError<"BetaListDeployments504", typeof BetaListDeployments504.Type> > /** - * Delete Skill Version + * Create Deployment */ - readonly "deleteSkillVersionV1SkillsSkillIdVersionsVersionDelete": ( - skillId: string, - version: string, + readonly "BetaCreateDeployment": ( options: { - readonly params?: typeof DeleteSkillVersionV1SkillsSkillIdVersionsVersionDeleteParams.Encoded | undefined + readonly params?: typeof BetaCreateDeploymentParams.Encoded | undefined + readonly payload: typeof BetaCreateDeploymentRequestJson.Encoded readonly config?: Config | undefined - } | undefined + } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError< - "DeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX", - typeof DeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX.Type - > + | AnthropicClientError<"BetaCreateDeployment400", typeof BetaCreateDeployment400.Type> + | AnthropicClientError<"BetaCreateDeployment401", typeof BetaCreateDeployment401.Type> + | AnthropicClientError<"BetaCreateDeployment403", typeof BetaCreateDeployment403.Type> + | AnthropicClientError<"BetaCreateDeployment404", typeof BetaCreateDeployment404.Type> + | AnthropicClientError<"BetaCreateDeployment408", typeof BetaCreateDeployment408.Type> + | AnthropicClientError<"BetaCreateDeployment409", typeof BetaCreateDeployment409.Type> + | AnthropicClientError<"BetaCreateDeployment412", typeof BetaCreateDeployment412.Type> + | AnthropicClientError<"BetaCreateDeployment413", typeof BetaCreateDeployment413.Type> + | AnthropicClientError<"BetaCreateDeployment429", typeof BetaCreateDeployment429.Type> + | AnthropicClientError<"BetaCreateDeployment431", typeof BetaCreateDeployment431.Type> + | AnthropicClientError<"BetaCreateDeployment499", typeof BetaCreateDeployment499.Type> + | AnthropicClientError<"BetaCreateDeployment500", typeof BetaCreateDeployment500.Type> + | AnthropicClientError<"BetaCreateDeployment501", typeof BetaCreateDeployment501.Type> + | AnthropicClientError<"BetaCreateDeployment503", typeof BetaCreateDeployment503.Type> + | AnthropicClientError<"BetaCreateDeployment504", typeof BetaCreateDeployment504.Type> > /** - * Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation. - * - * The Messages API can be used for either single queries or stateless multi-turn conversations. - * - * Learn more about the Messages API in our [user guide](https://docs.claude.com/en/docs/initial-setup) + * Get Deployment */ - readonly "betaMessagesPost": ( + readonly "BetaGetDeployment": ( + deploymentId: string, options: { - readonly params?: typeof BetaMessagesPostParams.Encoded | undefined - readonly payload: typeof BetaMessagesPostRequestJson.Encoded + readonly params?: typeof BetaGetDeploymentParams.Encoded | undefined readonly config?: Config | undefined - } + } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaMessagesPost4XX", typeof BetaMessagesPost4XX.Type> + | AnthropicClientError<"BetaGetDeployment400", typeof BetaGetDeployment400.Type> + | AnthropicClientError<"BetaGetDeployment401", typeof BetaGetDeployment401.Type> + | AnthropicClientError<"BetaGetDeployment403", typeof BetaGetDeployment403.Type> + | AnthropicClientError<"BetaGetDeployment404", typeof BetaGetDeployment404.Type> + | AnthropicClientError<"BetaGetDeployment408", typeof BetaGetDeployment408.Type> + | AnthropicClientError<"BetaGetDeployment409", typeof BetaGetDeployment409.Type> + | AnthropicClientError<"BetaGetDeployment412", typeof BetaGetDeployment412.Type> + | AnthropicClientError<"BetaGetDeployment413", typeof BetaGetDeployment413.Type> + | AnthropicClientError<"BetaGetDeployment429", typeof BetaGetDeployment429.Type> + | AnthropicClientError<"BetaGetDeployment431", typeof BetaGetDeployment431.Type> + | AnthropicClientError<"BetaGetDeployment499", typeof BetaGetDeployment499.Type> + | AnthropicClientError<"BetaGetDeployment500", typeof BetaGetDeployment500.Type> + | AnthropicClientError<"BetaGetDeployment501", typeof BetaGetDeployment501.Type> + | AnthropicClientError<"BetaGetDeployment503", typeof BetaGetDeployment503.Type> + | AnthropicClientError<"BetaGetDeployment504", typeof BetaGetDeployment504.Type> > /** - * List available models. - * - * The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first. + * Update Deployment */ - readonly "betaModelsList": ( - options: - | { readonly params?: typeof BetaModelsListParams.Encoded | undefined; readonly config?: Config | undefined } - | undefined + readonly "BetaUpdateDeployment": ( + deploymentId: string, + options: { + readonly params?: typeof BetaUpdateDeploymentParams.Encoded | undefined + readonly payload: typeof BetaUpdateDeploymentRequestJson.Encoded + readonly config?: Config | undefined + } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaModelsList4XX", typeof BetaModelsList4XX.Type> + | AnthropicClientError<"BetaUpdateDeployment400", typeof BetaUpdateDeployment400.Type> + | AnthropicClientError<"BetaUpdateDeployment401", typeof BetaUpdateDeployment401.Type> + | AnthropicClientError<"BetaUpdateDeployment403", typeof BetaUpdateDeployment403.Type> + | AnthropicClientError<"BetaUpdateDeployment404", typeof BetaUpdateDeployment404.Type> + | AnthropicClientError<"BetaUpdateDeployment408", typeof BetaUpdateDeployment408.Type> + | AnthropicClientError<"BetaUpdateDeployment409", typeof BetaUpdateDeployment409.Type> + | AnthropicClientError<"BetaUpdateDeployment412", typeof BetaUpdateDeployment412.Type> + | AnthropicClientError<"BetaUpdateDeployment413", typeof BetaUpdateDeployment413.Type> + | AnthropicClientError<"BetaUpdateDeployment429", typeof BetaUpdateDeployment429.Type> + | AnthropicClientError<"BetaUpdateDeployment431", typeof BetaUpdateDeployment431.Type> + | AnthropicClientError<"BetaUpdateDeployment499", typeof BetaUpdateDeployment499.Type> + | AnthropicClientError<"BetaUpdateDeployment500", typeof BetaUpdateDeployment500.Type> + | AnthropicClientError<"BetaUpdateDeployment501", typeof BetaUpdateDeployment501.Type> + | AnthropicClientError<"BetaUpdateDeployment503", typeof BetaUpdateDeployment503.Type> + | AnthropicClientError<"BetaUpdateDeployment504", typeof BetaUpdateDeployment504.Type> > /** - * Get a specific model. - * - * The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID. + * Archive Deployment */ - readonly "betaModelsGet": ( - modelId: string, - options: - | { readonly params?: typeof BetaModelsGetParams.Encoded | undefined; readonly config?: Config | undefined } - | undefined + readonly "BetaArchiveDeployment": ( + deploymentId: string, + options: { + readonly params?: typeof BetaArchiveDeploymentParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaModelsGet4XX", typeof BetaModelsGet4XX.Type> + | AnthropicClientError<"BetaArchiveDeployment400", typeof BetaArchiveDeployment400.Type> + | AnthropicClientError<"BetaArchiveDeployment401", typeof BetaArchiveDeployment401.Type> + | AnthropicClientError<"BetaArchiveDeployment403", typeof BetaArchiveDeployment403.Type> + | AnthropicClientError<"BetaArchiveDeployment404", typeof BetaArchiveDeployment404.Type> + | AnthropicClientError<"BetaArchiveDeployment408", typeof BetaArchiveDeployment408.Type> + | AnthropicClientError<"BetaArchiveDeployment409", typeof BetaArchiveDeployment409.Type> + | AnthropicClientError<"BetaArchiveDeployment412", typeof BetaArchiveDeployment412.Type> + | AnthropicClientError<"BetaArchiveDeployment413", typeof BetaArchiveDeployment413.Type> + | AnthropicClientError<"BetaArchiveDeployment429", typeof BetaArchiveDeployment429.Type> + | AnthropicClientError<"BetaArchiveDeployment431", typeof BetaArchiveDeployment431.Type> + | AnthropicClientError<"BetaArchiveDeployment499", typeof BetaArchiveDeployment499.Type> + | AnthropicClientError<"BetaArchiveDeployment500", typeof BetaArchiveDeployment500.Type> + | AnthropicClientError<"BetaArchiveDeployment501", typeof BetaArchiveDeployment501.Type> + | AnthropicClientError<"BetaArchiveDeployment503", typeof BetaArchiveDeployment503.Type> + | AnthropicClientError<"BetaArchiveDeployment504", typeof BetaArchiveDeployment504.Type> > /** - * List all Message Batches within a Workspace. Most recently created batches are returned first. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * Pause Deployment */ - readonly "betaMessageBatchesList": ( + readonly "BetaPauseDeployment": ( + deploymentId: string, options: { - readonly params?: typeof BetaMessageBatchesListParams.Encoded | undefined + readonly params?: typeof BetaPauseDeploymentParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaMessageBatchesList4XX", typeof BetaMessageBatchesList4XX.Type> + | AnthropicClientError<"BetaPauseDeployment400", typeof BetaPauseDeployment400.Type> + | AnthropicClientError<"BetaPauseDeployment401", typeof BetaPauseDeployment401.Type> + | AnthropicClientError<"BetaPauseDeployment403", typeof BetaPauseDeployment403.Type> + | AnthropicClientError<"BetaPauseDeployment404", typeof BetaPauseDeployment404.Type> + | AnthropicClientError<"BetaPauseDeployment408", typeof BetaPauseDeployment408.Type> + | AnthropicClientError<"BetaPauseDeployment409", typeof BetaPauseDeployment409.Type> + | AnthropicClientError<"BetaPauseDeployment412", typeof BetaPauseDeployment412.Type> + | AnthropicClientError<"BetaPauseDeployment413", typeof BetaPauseDeployment413.Type> + | AnthropicClientError<"BetaPauseDeployment429", typeof BetaPauseDeployment429.Type> + | AnthropicClientError<"BetaPauseDeployment431", typeof BetaPauseDeployment431.Type> + | AnthropicClientError<"BetaPauseDeployment499", typeof BetaPauseDeployment499.Type> + | AnthropicClientError<"BetaPauseDeployment500", typeof BetaPauseDeployment500.Type> + | AnthropicClientError<"BetaPauseDeployment501", typeof BetaPauseDeployment501.Type> + | AnthropicClientError<"BetaPauseDeployment503", typeof BetaPauseDeployment503.Type> + | AnthropicClientError<"BetaPauseDeployment504", typeof BetaPauseDeployment504.Type> > /** - * Send a batch of Message creation requests. - * - * The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * Unpause Deployment */ - readonly "betaMessageBatchesPost": ( + readonly "BetaUnpauseDeployment": ( + deploymentId: string, options: { - readonly params?: typeof BetaMessageBatchesPostParams.Encoded | undefined - readonly payload: typeof BetaMessageBatchesPostRequestJson.Encoded + readonly params?: typeof BetaUnpauseDeploymentParams.Encoded | undefined readonly config?: Config | undefined - } + } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaMessageBatchesPost4XX", typeof BetaMessageBatchesPost4XX.Type> + | AnthropicClientError<"BetaUnpauseDeployment400", typeof BetaUnpauseDeployment400.Type> + | AnthropicClientError<"BetaUnpauseDeployment401", typeof BetaUnpauseDeployment401.Type> + | AnthropicClientError<"BetaUnpauseDeployment403", typeof BetaUnpauseDeployment403.Type> + | AnthropicClientError<"BetaUnpauseDeployment404", typeof BetaUnpauseDeployment404.Type> + | AnthropicClientError<"BetaUnpauseDeployment408", typeof BetaUnpauseDeployment408.Type> + | AnthropicClientError<"BetaUnpauseDeployment409", typeof BetaUnpauseDeployment409.Type> + | AnthropicClientError<"BetaUnpauseDeployment412", typeof BetaUnpauseDeployment412.Type> + | AnthropicClientError<"BetaUnpauseDeployment413", typeof BetaUnpauseDeployment413.Type> + | AnthropicClientError<"BetaUnpauseDeployment429", typeof BetaUnpauseDeployment429.Type> + | AnthropicClientError<"BetaUnpauseDeployment431", typeof BetaUnpauseDeployment431.Type> + | AnthropicClientError<"BetaUnpauseDeployment499", typeof BetaUnpauseDeployment499.Type> + | AnthropicClientError<"BetaUnpauseDeployment500", typeof BetaUnpauseDeployment500.Type> + | AnthropicClientError<"BetaUnpauseDeployment501", typeof BetaUnpauseDeployment501.Type> + | AnthropicClientError<"BetaUnpauseDeployment503", typeof BetaUnpauseDeployment503.Type> + | AnthropicClientError<"BetaUnpauseDeployment504", typeof BetaUnpauseDeployment504.Type> > /** - * This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * Run Deployment Now */ - readonly "betaMessageBatchesRetrieve": ( - messageBatchId: string, + readonly "BetaRunDeploymentNow": ( + deploymentId: string, options: { - readonly params?: typeof BetaMessageBatchesRetrieveParams.Encoded | undefined + readonly params?: typeof BetaRunDeploymentNowParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaMessageBatchesRetrieve4XX", typeof BetaMessageBatchesRetrieve4XX.Type> + | AnthropicClientError<"BetaRunDeploymentNow400", typeof BetaRunDeploymentNow400.Type> + | AnthropicClientError<"BetaRunDeploymentNow401", typeof BetaRunDeploymentNow401.Type> + | AnthropicClientError<"BetaRunDeploymentNow403", typeof BetaRunDeploymentNow403.Type> + | AnthropicClientError<"BetaRunDeploymentNow404", typeof BetaRunDeploymentNow404.Type> + | AnthropicClientError<"BetaRunDeploymentNow408", typeof BetaRunDeploymentNow408.Type> + | AnthropicClientError<"BetaRunDeploymentNow409", typeof BetaRunDeploymentNow409.Type> + | AnthropicClientError<"BetaRunDeploymentNow412", typeof BetaRunDeploymentNow412.Type> + | AnthropicClientError<"BetaRunDeploymentNow413", typeof BetaRunDeploymentNow413.Type> + | AnthropicClientError<"BetaRunDeploymentNow429", typeof BetaRunDeploymentNow429.Type> + | AnthropicClientError<"BetaRunDeploymentNow431", typeof BetaRunDeploymentNow431.Type> + | AnthropicClientError<"BetaRunDeploymentNow499", typeof BetaRunDeploymentNow499.Type> + | AnthropicClientError<"BetaRunDeploymentNow500", typeof BetaRunDeploymentNow500.Type> + | AnthropicClientError<"BetaRunDeploymentNow501", typeof BetaRunDeploymentNow501.Type> + | AnthropicClientError<"BetaRunDeploymentNow503", typeof BetaRunDeploymentNow503.Type> + | AnthropicClientError<"BetaRunDeploymentNow504", typeof BetaRunDeploymentNow504.Type> > /** - * Delete a Message Batch. - * - * Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * List Deployment Runs */ - readonly "betaMessageBatchesDelete": ( - messageBatchId: string, + readonly "BetaListDeploymentRuns": ( options: { - readonly params?: typeof BetaMessageBatchesDeleteParams.Encoded | undefined + readonly params?: typeof BetaListDeploymentRunsParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaMessageBatchesDelete4XX", typeof BetaMessageBatchesDelete4XX.Type> + | AnthropicClientError<"BetaListDeploymentRuns400", typeof BetaListDeploymentRuns400.Type> + | AnthropicClientError<"BetaListDeploymentRuns401", typeof BetaListDeploymentRuns401.Type> + | AnthropicClientError<"BetaListDeploymentRuns403", typeof BetaListDeploymentRuns403.Type> + | AnthropicClientError<"BetaListDeploymentRuns404", typeof BetaListDeploymentRuns404.Type> + | AnthropicClientError<"BetaListDeploymentRuns408", typeof BetaListDeploymentRuns408.Type> + | AnthropicClientError<"BetaListDeploymentRuns409", typeof BetaListDeploymentRuns409.Type> + | AnthropicClientError<"BetaListDeploymentRuns412", typeof BetaListDeploymentRuns412.Type> + | AnthropicClientError<"BetaListDeploymentRuns413", typeof BetaListDeploymentRuns413.Type> + | AnthropicClientError<"BetaListDeploymentRuns429", typeof BetaListDeploymentRuns429.Type> + | AnthropicClientError<"BetaListDeploymentRuns431", typeof BetaListDeploymentRuns431.Type> + | AnthropicClientError<"BetaListDeploymentRuns499", typeof BetaListDeploymentRuns499.Type> + | AnthropicClientError<"BetaListDeploymentRuns500", typeof BetaListDeploymentRuns500.Type> + | AnthropicClientError<"BetaListDeploymentRuns501", typeof BetaListDeploymentRuns501.Type> + | AnthropicClientError<"BetaListDeploymentRuns503", typeof BetaListDeploymentRuns503.Type> + | AnthropicClientError<"BetaListDeploymentRuns504", typeof BetaListDeploymentRuns504.Type> > /** - * Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation. - * - * The number of canceled requests is specified in `request_counts`. To determine which requests were canceled, check the individual results within the batch. Note that cancellation may not result in any canceled requests if they were non-interruptible. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * Get Deployment Run */ - readonly "betaMessageBatchesCancel": ( - messageBatchId: string, + readonly "BetaGetDeploymentRun": ( + deploymentRunId: string, options: { - readonly params?: typeof BetaMessageBatchesCancelParams.Encoded | undefined + readonly params?: typeof BetaGetDeploymentRunParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaMessageBatchesCancel4XX", typeof BetaMessageBatchesCancel4XX.Type> + | AnthropicClientError<"BetaGetDeploymentRun400", typeof BetaGetDeploymentRun400.Type> + | AnthropicClientError<"BetaGetDeploymentRun401", typeof BetaGetDeploymentRun401.Type> + | AnthropicClientError<"BetaGetDeploymentRun403", typeof BetaGetDeploymentRun403.Type> + | AnthropicClientError<"BetaGetDeploymentRun404", typeof BetaGetDeploymentRun404.Type> + | AnthropicClientError<"BetaGetDeploymentRun408", typeof BetaGetDeploymentRun408.Type> + | AnthropicClientError<"BetaGetDeploymentRun409", typeof BetaGetDeploymentRun409.Type> + | AnthropicClientError<"BetaGetDeploymentRun412", typeof BetaGetDeploymentRun412.Type> + | AnthropicClientError<"BetaGetDeploymentRun413", typeof BetaGetDeploymentRun413.Type> + | AnthropicClientError<"BetaGetDeploymentRun429", typeof BetaGetDeploymentRun429.Type> + | AnthropicClientError<"BetaGetDeploymentRun431", typeof BetaGetDeploymentRun431.Type> + | AnthropicClientError<"BetaGetDeploymentRun499", typeof BetaGetDeploymentRun499.Type> + | AnthropicClientError<"BetaGetDeploymentRun500", typeof BetaGetDeploymentRun500.Type> + | AnthropicClientError<"BetaGetDeploymentRun501", typeof BetaGetDeploymentRun501.Type> + | AnthropicClientError<"BetaGetDeploymentRun503", typeof BetaGetDeploymentRun503.Type> + | AnthropicClientError<"BetaGetDeploymentRun504", typeof BetaGetDeploymentRun504.Type> > /** - * Streams the results of a Message Batch as a `.jsonl` file. - * - * Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests. - * - * Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing) + * List Vaults */ - readonly "betaMessageBatchesResults": ( - messageBatchId: string, - options: { - readonly params?: typeof BetaMessageBatchesResultsParams.Encoded | undefined - readonly config?: Config | undefined - } | undefined + readonly "BetaListVaults": ( + options: + | { readonly params?: typeof BetaListVaultsParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaMessageBatchesResults4XX", typeof BetaMessageBatchesResults4XX.Type> + | AnthropicClientError<"BetaListVaults400", typeof BetaListVaults400.Type> + | AnthropicClientError<"BetaListVaults401", typeof BetaListVaults401.Type> + | AnthropicClientError<"BetaListVaults403", typeof BetaListVaults403.Type> + | AnthropicClientError<"BetaListVaults404", typeof BetaListVaults404.Type> + | AnthropicClientError<"BetaListVaults408", typeof BetaListVaults408.Type> + | AnthropicClientError<"BetaListVaults409", typeof BetaListVaults409.Type> + | AnthropicClientError<"BetaListVaults412", typeof BetaListVaults412.Type> + | AnthropicClientError<"BetaListVaults413", typeof BetaListVaults413.Type> + | AnthropicClientError<"BetaListVaults429", typeof BetaListVaults429.Type> + | AnthropicClientError<"BetaListVaults431", typeof BetaListVaults431.Type> + | AnthropicClientError<"BetaListVaults499", typeof BetaListVaults499.Type> + | AnthropicClientError<"BetaListVaults500", typeof BetaListVaults500.Type> + | AnthropicClientError<"BetaListVaults501", typeof BetaListVaults501.Type> + | AnthropicClientError<"BetaListVaults503", typeof BetaListVaults503.Type> + | AnthropicClientError<"BetaListVaults504", typeof BetaListVaults504.Type> > /** - * Count the number of tokens in a Message. - * - * The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it. - * - * Learn more about token counting in our [user guide](https://docs.claude.com/en/docs/build-with-claude/token-counting) + * Create Vault */ - readonly "betaMessagesCountTokensPost": ( + readonly "BetaCreateVault": ( options: { - readonly params?: typeof BetaMessagesCountTokensPostParams.Encoded | undefined - readonly payload: typeof BetaMessagesCountTokensPostRequestJson.Encoded + readonly params?: typeof BetaCreateVaultParams.Encoded | undefined + readonly payload: typeof BetaCreateVaultRequestJson.Encoded readonly config?: Config | undefined } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaMessagesCountTokensPost4XX", typeof BetaMessagesCountTokensPost4XX.Type> + | AnthropicClientError<"BetaCreateVault400", typeof BetaCreateVault400.Type> + | AnthropicClientError<"BetaCreateVault401", typeof BetaCreateVault401.Type> + | AnthropicClientError<"BetaCreateVault403", typeof BetaCreateVault403.Type> + | AnthropicClientError<"BetaCreateVault404", typeof BetaCreateVault404.Type> + | AnthropicClientError<"BetaCreateVault408", typeof BetaCreateVault408.Type> + | AnthropicClientError<"BetaCreateVault409", typeof BetaCreateVault409.Type> + | AnthropicClientError<"BetaCreateVault412", typeof BetaCreateVault412.Type> + | AnthropicClientError<"BetaCreateVault413", typeof BetaCreateVault413.Type> + | AnthropicClientError<"BetaCreateVault429", typeof BetaCreateVault429.Type> + | AnthropicClientError<"BetaCreateVault431", typeof BetaCreateVault431.Type> + | AnthropicClientError<"BetaCreateVault499", typeof BetaCreateVault499.Type> + | AnthropicClientError<"BetaCreateVault500", typeof BetaCreateVault500.Type> + | AnthropicClientError<"BetaCreateVault501", typeof BetaCreateVault501.Type> + | AnthropicClientError<"BetaCreateVault503", typeof BetaCreateVault503.Type> + | AnthropicClientError<"BetaCreateVault504", typeof BetaCreateVault504.Type> > /** - * List Files + * Get Vault */ - readonly "betaListFilesV1FilesGet": ( - options: { - readonly params?: typeof BetaListFilesV1FilesGetParams.Encoded | undefined - readonly config?: Config | undefined - } | undefined + readonly "BetaGetVault": ( + vaultId: string, + options: + | { readonly params?: typeof BetaGetVaultParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaListFilesV1FilesGet4XX", typeof BetaListFilesV1FilesGet4XX.Type> + | AnthropicClientError<"BetaGetVault400", typeof BetaGetVault400.Type> + | AnthropicClientError<"BetaGetVault401", typeof BetaGetVault401.Type> + | AnthropicClientError<"BetaGetVault403", typeof BetaGetVault403.Type> + | AnthropicClientError<"BetaGetVault404", typeof BetaGetVault404.Type> + | AnthropicClientError<"BetaGetVault408", typeof BetaGetVault408.Type> + | AnthropicClientError<"BetaGetVault409", typeof BetaGetVault409.Type> + | AnthropicClientError<"BetaGetVault412", typeof BetaGetVault412.Type> + | AnthropicClientError<"BetaGetVault413", typeof BetaGetVault413.Type> + | AnthropicClientError<"BetaGetVault429", typeof BetaGetVault429.Type> + | AnthropicClientError<"BetaGetVault431", typeof BetaGetVault431.Type> + | AnthropicClientError<"BetaGetVault499", typeof BetaGetVault499.Type> + | AnthropicClientError<"BetaGetVault500", typeof BetaGetVault500.Type> + | AnthropicClientError<"BetaGetVault501", typeof BetaGetVault501.Type> + | AnthropicClientError<"BetaGetVault503", typeof BetaGetVault503.Type> + | AnthropicClientError<"BetaGetVault504", typeof BetaGetVault504.Type> > /** - * Upload File + * Update Vault */ - readonly "betaUploadFileV1FilesPost": ( + readonly "BetaUpdateVault": ( + vaultId: string, options: { - readonly params?: typeof BetaUploadFileV1FilesPostParams.Encoded | undefined - readonly payload: typeof BetaUploadFileV1FilesPostRequestFormData.Encoded + readonly params?: typeof BetaUpdateVaultParams.Encoded | undefined + readonly payload: typeof BetaUpdateVaultRequestJson.Encoded readonly config?: Config | undefined } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaUploadFileV1FilesPost4XX", typeof BetaUploadFileV1FilesPost4XX.Type> + | AnthropicClientError<"BetaUpdateVault400", typeof BetaUpdateVault400.Type> + | AnthropicClientError<"BetaUpdateVault401", typeof BetaUpdateVault401.Type> + | AnthropicClientError<"BetaUpdateVault403", typeof BetaUpdateVault403.Type> + | AnthropicClientError<"BetaUpdateVault404", typeof BetaUpdateVault404.Type> + | AnthropicClientError<"BetaUpdateVault408", typeof BetaUpdateVault408.Type> + | AnthropicClientError<"BetaUpdateVault409", typeof BetaUpdateVault409.Type> + | AnthropicClientError<"BetaUpdateVault412", typeof BetaUpdateVault412.Type> + | AnthropicClientError<"BetaUpdateVault413", typeof BetaUpdateVault413.Type> + | AnthropicClientError<"BetaUpdateVault429", typeof BetaUpdateVault429.Type> + | AnthropicClientError<"BetaUpdateVault431", typeof BetaUpdateVault431.Type> + | AnthropicClientError<"BetaUpdateVault499", typeof BetaUpdateVault499.Type> + | AnthropicClientError<"BetaUpdateVault500", typeof BetaUpdateVault500.Type> + | AnthropicClientError<"BetaUpdateVault501", typeof BetaUpdateVault501.Type> + | AnthropicClientError<"BetaUpdateVault503", typeof BetaUpdateVault503.Type> + | AnthropicClientError<"BetaUpdateVault504", typeof BetaUpdateVault504.Type> > /** - * Get File Metadata + * Delete Vault */ - readonly "betaGetFileMetadataV1FilesFileIdGet": ( - fileId: string, + readonly "BetaDeleteVault": ( + vaultId: string, options: { - readonly params?: typeof BetaGetFileMetadataV1FilesFileIdGetParams.Encoded | undefined + readonly params?: typeof BetaDeleteVaultParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaGetFileMetadataV1FilesFileIdGet4XX", typeof BetaGetFileMetadataV1FilesFileIdGet4XX.Type> + | AnthropicClientError<"BetaDeleteVault400", typeof BetaDeleteVault400.Type> + | AnthropicClientError<"BetaDeleteVault401", typeof BetaDeleteVault401.Type> + | AnthropicClientError<"BetaDeleteVault403", typeof BetaDeleteVault403.Type> + | AnthropicClientError<"BetaDeleteVault404", typeof BetaDeleteVault404.Type> + | AnthropicClientError<"BetaDeleteVault408", typeof BetaDeleteVault408.Type> + | AnthropicClientError<"BetaDeleteVault409", typeof BetaDeleteVault409.Type> + | AnthropicClientError<"BetaDeleteVault412", typeof BetaDeleteVault412.Type> + | AnthropicClientError<"BetaDeleteVault413", typeof BetaDeleteVault413.Type> + | AnthropicClientError<"BetaDeleteVault429", typeof BetaDeleteVault429.Type> + | AnthropicClientError<"BetaDeleteVault431", typeof BetaDeleteVault431.Type> + | AnthropicClientError<"BetaDeleteVault499", typeof BetaDeleteVault499.Type> + | AnthropicClientError<"BetaDeleteVault500", typeof BetaDeleteVault500.Type> + | AnthropicClientError<"BetaDeleteVault501", typeof BetaDeleteVault501.Type> + | AnthropicClientError<"BetaDeleteVault503", typeof BetaDeleteVault503.Type> + | AnthropicClientError<"BetaDeleteVault504", typeof BetaDeleteVault504.Type> > /** - * Delete File + * Archive Vault */ - readonly "betaDeleteFileV1FilesFileIdDelete": ( - fileId: string, + readonly "BetaArchiveVault": ( + vaultId: string, options: { - readonly params?: typeof BetaDeleteFileV1FilesFileIdDeleteParams.Encoded | undefined + readonly params?: typeof BetaArchiveVaultParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaDeleteFileV1FilesFileIdDelete4XX", typeof BetaDeleteFileV1FilesFileIdDelete4XX.Type> + | AnthropicClientError<"BetaArchiveVault400", typeof BetaArchiveVault400.Type> + | AnthropicClientError<"BetaArchiveVault401", typeof BetaArchiveVault401.Type> + | AnthropicClientError<"BetaArchiveVault403", typeof BetaArchiveVault403.Type> + | AnthropicClientError<"BetaArchiveVault404", typeof BetaArchiveVault404.Type> + | AnthropicClientError<"BetaArchiveVault408", typeof BetaArchiveVault408.Type> + | AnthropicClientError<"BetaArchiveVault409", typeof BetaArchiveVault409.Type> + | AnthropicClientError<"BetaArchiveVault412", typeof BetaArchiveVault412.Type> + | AnthropicClientError<"BetaArchiveVault413", typeof BetaArchiveVault413.Type> + | AnthropicClientError<"BetaArchiveVault429", typeof BetaArchiveVault429.Type> + | AnthropicClientError<"BetaArchiveVault431", typeof BetaArchiveVault431.Type> + | AnthropicClientError<"BetaArchiveVault499", typeof BetaArchiveVault499.Type> + | AnthropicClientError<"BetaArchiveVault500", typeof BetaArchiveVault500.Type> + | AnthropicClientError<"BetaArchiveVault501", typeof BetaArchiveVault501.Type> + | AnthropicClientError<"BetaArchiveVault503", typeof BetaArchiveVault503.Type> + | AnthropicClientError<"BetaArchiveVault504", typeof BetaArchiveVault504.Type> > /** - * Download File - */ - readonly "betaDownloadFileV1FilesFileIdContentGet": ( - fileId: string, - options: { - readonly params?: typeof BetaDownloadFileV1FilesFileIdContentGetParams.Encoded | undefined - readonly config?: Config | undefined - } | undefined - ) => Effect.Effect, HttpClientError.HttpClientError | SchemaError> - /** - * Download File - */ - readonly "betaDownloadFileV1FilesFileIdContentGetStream": ( - fileId: string, - options: { readonly params?: typeof BetaDownloadFileV1FilesFileIdContentGetParams.Encoded | undefined } | undefined - ) => Stream.Stream - /** - * List Skills + * List Credentials */ - readonly "betaListSkillsV1SkillsGet": ( + readonly "BetaListCredentials": ( + vaultId: string, options: { - readonly params?: typeof BetaListSkillsV1SkillsGetParams.Encoded | undefined + readonly params?: typeof BetaListCredentialsParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaListSkillsV1SkillsGet4XX", typeof BetaListSkillsV1SkillsGet4XX.Type> + | AnthropicClientError<"BetaListCredentials400", typeof BetaListCredentials400.Type> + | AnthropicClientError<"BetaListCredentials401", typeof BetaListCredentials401.Type> + | AnthropicClientError<"BetaListCredentials403", typeof BetaListCredentials403.Type> + | AnthropicClientError<"BetaListCredentials404", typeof BetaListCredentials404.Type> + | AnthropicClientError<"BetaListCredentials408", typeof BetaListCredentials408.Type> + | AnthropicClientError<"BetaListCredentials409", typeof BetaListCredentials409.Type> + | AnthropicClientError<"BetaListCredentials412", typeof BetaListCredentials412.Type> + | AnthropicClientError<"BetaListCredentials413", typeof BetaListCredentials413.Type> + | AnthropicClientError<"BetaListCredentials429", typeof BetaListCredentials429.Type> + | AnthropicClientError<"BetaListCredentials431", typeof BetaListCredentials431.Type> + | AnthropicClientError<"BetaListCredentials499", typeof BetaListCredentials499.Type> + | AnthropicClientError<"BetaListCredentials500", typeof BetaListCredentials500.Type> + | AnthropicClientError<"BetaListCredentials501", typeof BetaListCredentials501.Type> + | AnthropicClientError<"BetaListCredentials503", typeof BetaListCredentials503.Type> + | AnthropicClientError<"BetaListCredentials504", typeof BetaListCredentials504.Type> > /** - * Create Skill + * Create Credential */ - readonly "betaCreateSkillV1SkillsPost": ( + readonly "BetaCreateCredential": ( + vaultId: string, options: { - readonly params?: typeof BetaCreateSkillV1SkillsPostParams.Encoded | undefined - readonly payload: typeof BetaCreateSkillV1SkillsPostRequestFormData.Encoded + readonly params?: typeof BetaCreateCredentialParams.Encoded | undefined + readonly payload: typeof BetaCreateCredentialRequestJson.Encoded readonly config?: Config | undefined } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaCreateSkillV1SkillsPost4XX", typeof BetaCreateSkillV1SkillsPost4XX.Type> + | AnthropicClientError<"BetaCreateCredential400", typeof BetaCreateCredential400.Type> + | AnthropicClientError<"BetaCreateCredential401", typeof BetaCreateCredential401.Type> + | AnthropicClientError<"BetaCreateCredential403", typeof BetaCreateCredential403.Type> + | AnthropicClientError<"BetaCreateCredential404", typeof BetaCreateCredential404.Type> + | AnthropicClientError<"BetaCreateCredential408", typeof BetaCreateCredential408.Type> + | AnthropicClientError<"BetaCreateCredential409", typeof BetaCreateCredential409.Type> + | AnthropicClientError<"BetaCreateCredential412", typeof BetaCreateCredential412.Type> + | AnthropicClientError<"BetaCreateCredential413", typeof BetaCreateCredential413.Type> + | AnthropicClientError<"BetaCreateCredential429", typeof BetaCreateCredential429.Type> + | AnthropicClientError<"BetaCreateCredential431", typeof BetaCreateCredential431.Type> + | AnthropicClientError<"BetaCreateCredential499", typeof BetaCreateCredential499.Type> + | AnthropicClientError<"BetaCreateCredential500", typeof BetaCreateCredential500.Type> + | AnthropicClientError<"BetaCreateCredential501", typeof BetaCreateCredential501.Type> + | AnthropicClientError<"BetaCreateCredential503", typeof BetaCreateCredential503.Type> + | AnthropicClientError<"BetaCreateCredential504", typeof BetaCreateCredential504.Type> > /** - * Get Skill + * Get Credential */ - readonly "betaGetSkillV1SkillsSkillIdGet": ( - skillId: string, + readonly "BetaGetCredential": ( + vaultId: string, + credentialId: string, options: { - readonly params?: typeof BetaGetSkillV1SkillsSkillIdGetParams.Encoded | undefined + readonly params?: typeof BetaGetCredentialParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError<"BetaGetSkillV1SkillsSkillIdGet4XX", typeof BetaGetSkillV1SkillsSkillIdGet4XX.Type> + | AnthropicClientError<"BetaGetCredential400", typeof BetaGetCredential400.Type> + | AnthropicClientError<"BetaGetCredential401", typeof BetaGetCredential401.Type> + | AnthropicClientError<"BetaGetCredential403", typeof BetaGetCredential403.Type> + | AnthropicClientError<"BetaGetCredential404", typeof BetaGetCredential404.Type> + | AnthropicClientError<"BetaGetCredential408", typeof BetaGetCredential408.Type> + | AnthropicClientError<"BetaGetCredential409", typeof BetaGetCredential409.Type> + | AnthropicClientError<"BetaGetCredential412", typeof BetaGetCredential412.Type> + | AnthropicClientError<"BetaGetCredential413", typeof BetaGetCredential413.Type> + | AnthropicClientError<"BetaGetCredential429", typeof BetaGetCredential429.Type> + | AnthropicClientError<"BetaGetCredential431", typeof BetaGetCredential431.Type> + | AnthropicClientError<"BetaGetCredential499", typeof BetaGetCredential499.Type> + | AnthropicClientError<"BetaGetCredential500", typeof BetaGetCredential500.Type> + | AnthropicClientError<"BetaGetCredential501", typeof BetaGetCredential501.Type> + | AnthropicClientError<"BetaGetCredential503", typeof BetaGetCredential503.Type> + | AnthropicClientError<"BetaGetCredential504", typeof BetaGetCredential504.Type> > /** - * Delete Skill + * Update Credential */ - readonly "betaDeleteSkillV1SkillsSkillIdDelete": ( - skillId: string, + readonly "BetaUpdateCredential": ( + vaultId: string, + credentialId: string, options: { - readonly params?: typeof BetaDeleteSkillV1SkillsSkillIdDeleteParams.Encoded | undefined + readonly params?: typeof BetaUpdateCredentialParams.Encoded | undefined + readonly payload: typeof BetaUpdateCredentialRequestJson.Encoded readonly config?: Config | undefined - } | undefined + } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError< - "BetaDeleteSkillV1SkillsSkillIdDelete4XX", - typeof BetaDeleteSkillV1SkillsSkillIdDelete4XX.Type - > + | AnthropicClientError<"BetaUpdateCredential400", typeof BetaUpdateCredential400.Type> + | AnthropicClientError<"BetaUpdateCredential401", typeof BetaUpdateCredential401.Type> + | AnthropicClientError<"BetaUpdateCredential403", typeof BetaUpdateCredential403.Type> + | AnthropicClientError<"BetaUpdateCredential404", typeof BetaUpdateCredential404.Type> + | AnthropicClientError<"BetaUpdateCredential408", typeof BetaUpdateCredential408.Type> + | AnthropicClientError<"BetaUpdateCredential409", typeof BetaUpdateCredential409.Type> + | AnthropicClientError<"BetaUpdateCredential412", typeof BetaUpdateCredential412.Type> + | AnthropicClientError<"BetaUpdateCredential413", typeof BetaUpdateCredential413.Type> + | AnthropicClientError<"BetaUpdateCredential429", typeof BetaUpdateCredential429.Type> + | AnthropicClientError<"BetaUpdateCredential431", typeof BetaUpdateCredential431.Type> + | AnthropicClientError<"BetaUpdateCredential499", typeof BetaUpdateCredential499.Type> + | AnthropicClientError<"BetaUpdateCredential500", typeof BetaUpdateCredential500.Type> + | AnthropicClientError<"BetaUpdateCredential501", typeof BetaUpdateCredential501.Type> + | AnthropicClientError<"BetaUpdateCredential503", typeof BetaUpdateCredential503.Type> + | AnthropicClientError<"BetaUpdateCredential504", typeof BetaUpdateCredential504.Type> > /** - * List Skill Versions + * Delete Credential */ - readonly "betaListSkillVersionsV1SkillsSkillIdVersionsGet": ( - skillId: string, + readonly "BetaDeleteCredential": ( + vaultId: string, + credentialId: string, options: { - readonly params?: typeof BetaListSkillVersionsV1SkillsSkillIdVersionsGetParams.Encoded | undefined + readonly params?: typeof BetaDeleteCredentialParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, - | HttpClientError.HttpClientError - | SchemaError - | AnthropicClientError< - "BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX", - typeof BetaListSkillVersionsV1SkillsSkillIdVersionsGet4XX.Type - > - > - /** - * Create Skill Version - */ - readonly "betaCreateSkillVersionV1SkillsSkillIdVersionsPost": ( - skillId: string, - options: { - readonly params?: typeof BetaCreateSkillVersionV1SkillsSkillIdVersionsPostParams.Encoded | undefined - readonly payload: typeof BetaCreateSkillVersionV1SkillsSkillIdVersionsPostRequestFormData.Encoded - readonly config?: Config | undefined - } - ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError< - "BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX", - typeof BetaCreateSkillVersionV1SkillsSkillIdVersionsPost4XX.Type - > + | AnthropicClientError<"BetaDeleteCredential400", typeof BetaDeleteCredential400.Type> + | AnthropicClientError<"BetaDeleteCredential401", typeof BetaDeleteCredential401.Type> + | AnthropicClientError<"BetaDeleteCredential403", typeof BetaDeleteCredential403.Type> + | AnthropicClientError<"BetaDeleteCredential404", typeof BetaDeleteCredential404.Type> + | AnthropicClientError<"BetaDeleteCredential408", typeof BetaDeleteCredential408.Type> + | AnthropicClientError<"BetaDeleteCredential409", typeof BetaDeleteCredential409.Type> + | AnthropicClientError<"BetaDeleteCredential412", typeof BetaDeleteCredential412.Type> + | AnthropicClientError<"BetaDeleteCredential413", typeof BetaDeleteCredential413.Type> + | AnthropicClientError<"BetaDeleteCredential429", typeof BetaDeleteCredential429.Type> + | AnthropicClientError<"BetaDeleteCredential431", typeof BetaDeleteCredential431.Type> + | AnthropicClientError<"BetaDeleteCredential499", typeof BetaDeleteCredential499.Type> + | AnthropicClientError<"BetaDeleteCredential500", typeof BetaDeleteCredential500.Type> + | AnthropicClientError<"BetaDeleteCredential501", typeof BetaDeleteCredential501.Type> + | AnthropicClientError<"BetaDeleteCredential503", typeof BetaDeleteCredential503.Type> + | AnthropicClientError<"BetaDeleteCredential504", typeof BetaDeleteCredential504.Type> > /** - * Get Skill Version + * Archive Credential */ - readonly "betaGetSkillVersionV1SkillsSkillIdVersionsVersionGet": ( - skillId: string, - version: string, + readonly "BetaArchiveCredential": ( + vaultId: string, + credentialId: string, options: { - readonly params?: typeof BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGetParams.Encoded | undefined + readonly params?: typeof BetaArchiveCredentialParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError< - "BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX", - typeof BetaGetSkillVersionV1SkillsSkillIdVersionsVersionGet4XX.Type - > + | AnthropicClientError<"BetaArchiveCredential400", typeof BetaArchiveCredential400.Type> + | AnthropicClientError<"BetaArchiveCredential401", typeof BetaArchiveCredential401.Type> + | AnthropicClientError<"BetaArchiveCredential403", typeof BetaArchiveCredential403.Type> + | AnthropicClientError<"BetaArchiveCredential404", typeof BetaArchiveCredential404.Type> + | AnthropicClientError<"BetaArchiveCredential408", typeof BetaArchiveCredential408.Type> + | AnthropicClientError<"BetaArchiveCredential409", typeof BetaArchiveCredential409.Type> + | AnthropicClientError<"BetaArchiveCredential412", typeof BetaArchiveCredential412.Type> + | AnthropicClientError<"BetaArchiveCredential413", typeof BetaArchiveCredential413.Type> + | AnthropicClientError<"BetaArchiveCredential429", typeof BetaArchiveCredential429.Type> + | AnthropicClientError<"BetaArchiveCredential431", typeof BetaArchiveCredential431.Type> + | AnthropicClientError<"BetaArchiveCredential499", typeof BetaArchiveCredential499.Type> + | AnthropicClientError<"BetaArchiveCredential500", typeof BetaArchiveCredential500.Type> + | AnthropicClientError<"BetaArchiveCredential501", typeof BetaArchiveCredential501.Type> + | AnthropicClientError<"BetaArchiveCredential503", typeof BetaArchiveCredential503.Type> + | AnthropicClientError<"BetaArchiveCredential504", typeof BetaArchiveCredential504.Type> > /** - * Delete Skill Version + * Validate Credential */ - readonly "betaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete": ( - skillId: string, - version: string, + readonly "BetaValidateCredential": ( + vaultId: string, + credentialId: string, options: { - readonly params?: typeof BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDeleteParams.Encoded | undefined + readonly params?: typeof BetaValidateCredentialParams.Encoded | undefined readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError - | AnthropicClientError< - "BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX", - typeof BetaDeleteSkillVersionV1SkillsSkillIdVersionsVersionDelete4XX.Type - > + | AnthropicClientError<"BetaValidateCredential400", typeof BetaValidateCredential400.Type> + | AnthropicClientError<"BetaValidateCredential401", typeof BetaValidateCredential401.Type> + | AnthropicClientError<"BetaValidateCredential403", typeof BetaValidateCredential403.Type> + | AnthropicClientError<"BetaValidateCredential404", typeof BetaValidateCredential404.Type> + | AnthropicClientError<"BetaValidateCredential408", typeof BetaValidateCredential408.Type> + | AnthropicClientError<"BetaValidateCredential409", typeof BetaValidateCredential409.Type> + | AnthropicClientError<"BetaValidateCredential412", typeof BetaValidateCredential412.Type> + | AnthropicClientError<"BetaValidateCredential413", typeof BetaValidateCredential413.Type> + | AnthropicClientError<"BetaValidateCredential429", typeof BetaValidateCredential429.Type> + | AnthropicClientError<"BetaValidateCredential431", typeof BetaValidateCredential431.Type> + | AnthropicClientError<"BetaValidateCredential499", typeof BetaValidateCredential499.Type> + | AnthropicClientError<"BetaValidateCredential500", typeof BetaValidateCredential500.Type> + | AnthropicClientError<"BetaValidateCredential501", typeof BetaValidateCredential501.Type> + | AnthropicClientError<"BetaValidateCredential503", typeof BetaValidateCredential503.Type> + | AnthropicClientError<"BetaValidateCredential504", typeof BetaValidateCredential504.Type> > } diff --git a/packages/ai/openai/src/Generated.ts b/packages/ai/openai/src/Generated.ts index d51b3124402..c5affdda5f7 100644 --- a/packages/ai/openai/src/Generated.ts +++ b/packages/ai/openai/src/Generated.ts @@ -13,160 +13,59 @@ import * as HttpClientError from "effect/unstable/http/HttpClientError" import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest" import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse" // non-recursive definitions -export type AddUploadPartRequest = { readonly "data": string } -export const AddUploadPartRequest = Schema.Struct({ - "data": Schema.String.annotate({ "description": "The chunk of bytes for this Part.\n", "format": "binary" }) +export type AssistantToolsCode = { readonly "type": "code_interpreter" } +export const AssistantToolsCode = Schema.Struct({ + "type": Schema.Literal("code_interpreter").annotate({ + "description": "The type of tool being defined: `code_interpreter`" + }) +}).annotate({ "title": "Code interpreter tool", "identifier": "AssistantToolsCode" }) +export type FileSearchRanker = "auto" | "default_2024_08_21" +export const FileSearchRanker = Schema.Literals(["auto", "default_2024_08_21"]).annotate({ + "description": "The ranker to use for the file search. If not specified will use the `auto` ranker.", + "identifier": "FileSearchRanker" }) -export type AdminApiKey = { - readonly "object": "organization.admin_api_key" - readonly "id": string - readonly "name"?: string | null - readonly "redacted_value": string - readonly "created_at": number - readonly "last_used_at"?: number | null - readonly "owner": { - readonly "type"?: string - readonly "object"?: string - readonly "id"?: string - readonly "name"?: string - readonly "created_at"?: number - readonly "role"?: string - } -} -export const AdminApiKey = Schema.Struct({ - "object": Schema.Literal("organization.admin_api_key").annotate({ - "description": "The object type, which is always `organization.admin_api_key`" +export type FunctionParameters = {} +export const FunctionParameters = Schema.Struct({}).annotate({ + "description": + "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. \n\nOmitting `parameters` defines a function with an empty parameter list.", + "identifier": "FunctionParameters" +}) +export type Metadata = {} | null +export const Metadata = 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" }), - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the API key" }) - ), - "redacted_value": Schema.String.annotate({ "description": "The redacted value of the API key" }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the API key was created", - "format": "unixtime" - }).check(Schema.isInt()), - "last_used_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the API key was last used", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]) - ), - "owner": Schema.Struct({ - "type": Schema.optionalKey(Schema.String.annotate({ "description": "Always `user`" })), - "object": Schema.optionalKey( - Schema.String.annotate({ "description": "The object type, which is always organization.user" }) - ), - "id": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }) - ), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the user" })), - "created_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the user was created", - "format": "unixtime" - }).check(Schema.isInt()) - ), - "role": Schema.optionalKey(Schema.String.annotate({ "description": "Always `owner`" })) + Schema.Null +]).annotate({ "identifier": "Metadata" }) +export type ResponseFormatText = { readonly "type": "text" } +export const ResponseFormatText = Schema.Struct({ + "type": Schema.Literal("text").annotate({ + "description": "The type of response format being defined. Always `text`." }) -}).annotate({ "description": "Represents an individual Admin API key in an org." }) -export type AdminApiKeyCreateResponse = { - readonly "object": "organization.admin_api_key" - readonly "id": string - readonly "name"?: string | null - readonly "redacted_value": string - readonly "created_at": number - readonly "last_used_at"?: number | null - readonly "owner": { - readonly "type"?: string - readonly "object"?: string - readonly "id"?: string - readonly "name"?: string - readonly "created_at"?: number - readonly "role"?: string - } - readonly "value": string -} -export const AdminApiKeyCreateResponse = Schema.Struct({ - "object": Schema.Literal("organization.admin_api_key").annotate({ - "description": "The object type, which is always `organization.admin_api_key`" - }), - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the API key" }) - ), - "redacted_value": Schema.String.annotate({ "description": "The redacted value of the API key" }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the API key was created", - "format": "unixtime" - }).check(Schema.isInt()), - "last_used_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the API key was last used", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]) - ), - "owner": Schema.Struct({ - "type": Schema.optionalKey(Schema.String.annotate({ "description": "Always `user`" })), - "object": Schema.optionalKey( - Schema.String.annotate({ "description": "The object type, which is always organization.user" }) - ), - "id": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }) - ), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the user" })), - "created_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the user was created", - "format": "unixtime" - }).check(Schema.isInt()) - ), - "role": Schema.optionalKey(Schema.String.annotate({ "description": "Always `owner`" })) - }), - "value": Schema.String.annotate({ "description": "The value of the API key. Only shown on create." }) }).annotate({ - "description": "The newly created admin API key. The `value` field is only returned once, when the key is created." + "title": "Text", + "description": "Default response format. Used to generate text responses.\n", + "identifier": "ResponseFormatText" }) -export type AssignedRoleDetails = { - readonly "id": string - readonly "name": string - readonly "permissions": ReadonlyArray - readonly "resource_type": string - readonly "predefined_role": boolean - readonly "description": string | null - readonly "created_at": number | null - readonly "updated_at": number | null - readonly "created_by": string | null - readonly "created_by_user_obj": {} | null - readonly "metadata": {} | null -} -export const AssignedRoleDetails = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier for the role." }), - "name": Schema.String.annotate({ "description": "Name of the role." }), - "permissions": Schema.Array(Schema.String).annotate({ "description": "Permissions associated with the role." }), - "resource_type": Schema.String.annotate({ "description": "Resource type the role applies to." }), - "predefined_role": Schema.Boolean.annotate({ "description": "Whether the role is predefined by OpenAI." }), - "description": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Description of the role." }), - "created_at": Schema.Union([Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt()), Schema.Null]) - .annotate({ "description": "When the role was created." }), - "updated_at": Schema.Union([Schema.Number.annotate({ "format": "int64" }).check(Schema.isInt()), Schema.Null]) - .annotate({ "description": "When the role was last updated." }), - "created_by": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Identifier of the actor who created the role." - }), - "created_by_user_obj": Schema.Union([Schema.Struct({}), Schema.Null]).annotate({ - "description": "User details for the actor that created the role, when available." - }), - "metadata": Schema.Union([Schema.Struct({}), Schema.Null]).annotate({ - "description": "Arbitrary metadata stored on the role." +export type ResponseFormatJsonObject = { readonly "type": "json_object" } +export const ResponseFormatJsonObject = Schema.Struct({ + "type": Schema.Literal("json_object").annotate({ + "description": "The type of response format being defined. Always `json_object`." }) -}).annotate({ "description": "Detailed information about a role assignment entry returned when listing assignments." }) +}).annotate({ + "title": "JSON object", + "description": + "JSON object response format. An older method of generating JSON responses.\nUsing `json_schema` is recommended for models that support it. Note that the\nmodel will not generate JSON without a system or user message instructing it\nto do so.\n", + "identifier": "ResponseFormatJsonObject" +}) +export type ResponseFormatJsonSchemaSchema = {} +export const ResponseFormatJsonSchemaSchema = Schema.Struct({}).annotate({ + "title": "JSON schema", + "description": + "The schema for the response format, described as a JSON Schema object.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n", + "identifier": "ResponseFormatJsonSchemaSchema" +}) export type AssistantSupportedModels = | "gpt-5" | "gpt-5-mini" @@ -253,427 +152,549 @@ export const AssistantSupportedModels = Schema.Literals([ "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613" -]) -export type AssistantToolsCode = { readonly "type": "code_interpreter" } -export const AssistantToolsCode = Schema.Struct({ - "type": Schema.Literal("code_interpreter").annotate({ - "description": "The type of tool being defined: `code_interpreter`" - }) -}).annotate({ "title": "Code interpreter tool" }) -export type AssistantToolsFileSearchTypeOnly = { readonly "type": "file_search" } -export const AssistantToolsFileSearchTypeOnly = Schema.Struct({ - "type": Schema.Literal("file_search").annotate({ "description": "The type of tool being defined: `file_search`" }) -}).annotate({ "title": "FileSearch tool" }) -export type AssistantsNamedToolChoice = { - readonly "type": "function" | "code_interpreter" | "file_search" - readonly "function"?: { readonly "name": string } +]).annotate({ "identifier": "AssistantSupportedModels" }) +export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | null +export const ReasoningEffort = Schema.Union([ + Schema.Literals(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).annotate({ + "description": + "Constrains effort on reasoning for reasoning models. Currently supported\nvalues are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.\nReducing reasoning effort can result in faster responses and fewer tokens\nused on reasoning in a response. Not all reasoning models support every\nvalue. See the\n[reasoning guide](https://platform.openai.com/docs/guides/reasoning)\nfor model-specific support.\n" + }), + Schema.Null +]).annotate({ "identifier": "ReasoningEffort" }) +export type DeleteAssistantResponse = { + readonly "id": string + readonly "deleted": boolean + readonly "object": "assistant.deleted" +} +export const DeleteAssistantResponse = Schema.Struct({ + "id": Schema.String, + "deleted": Schema.Boolean, + "object": Schema.Literal("assistant.deleted") +}).annotate({ "identifier": "DeleteAssistantResponse" }) +export type VoiceIdsShared = + | string + | "alloy" + | "ash" + | "ballad" + | "coral" + | "echo" + | "sage" + | "shimmer" + | "verse" + | "marin" + | "cedar" +export const VoiceIdsShared = Schema.Union([ + Schema.String, + Schema.Literals(["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse", "marin", "cedar"]) +]).annotate({ "identifier": "VoiceIdsShared" }) +export type SpeechAudioDeltaEvent = { readonly "type": "speech.audio.delta"; readonly "audio": string } +export const SpeechAudioDeltaEvent = Schema.Struct({ + "type": Schema.Literal("speech.audio.delta").annotate({ + "description": "The type of the event. Always `speech.audio.delta`.\n" + }), + "audio": Schema.String.annotate({ "description": "A chunk of Base64-encoded audio data.\n" }) +}).annotate({ + "description": "Emitted for each chunk of audio data generated during speech synthesis.", + "identifier": "SpeechAudioDeltaEvent" +}) +export type SpeechAudioDoneEvent = { + readonly "type": "speech.audio.done" + readonly "usage": { + readonly "input_tokens": number + readonly "output_tokens": number + readonly "total_tokens": number + } } -export const AssistantsNamedToolChoice = Schema.Struct({ - "type": Schema.Literals(["function", "code_interpreter", "file_search"]).annotate({ - "description": "The type of the tool. If type is `function`, the function name must be set" +export const SpeechAudioDoneEvent = Schema.Struct({ + "type": Schema.Literal("speech.audio.done").annotate({ + "description": "The type of the event. Always `speech.audio.done`.\n" }), - "function": Schema.optionalKey( - Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) }) - ) -}).annotate({ "description": "Specifies a tool the model should use. Use to force the model to call a specific tool." }) + "usage": Schema.Struct({ + "input_tokens": Schema.Number.annotate({ "description": "Number of input tokens in the prompt." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).annotate({ "description": "Token usage statistics for the request.\n" }) +}).annotate({ + "description": "Emitted when the speech synthesis is complete and all audio has been streamed.", + "identifier": "SpeechAudioDoneEvent" +}) export type AudioResponseFormat = "json" | "text" | "srt" | "verbose_json" | "vtt" | "diarized_json" export const AudioResponseFormat = Schema.Literals(["json", "text", "srt", "verbose_json", "vtt", "diarized_json"]) .annotate({ "description": - "The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.\n" + "The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.\n", + "identifier": "AudioResponseFormat" }) -export type AuditLogActorServiceAccount = { readonly "id"?: string } -export const AuditLogActorServiceAccount = Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The service account id." })) -}).annotate({ "description": "The service account that performed the audit logged action." }) -export type AuditLogActorUser = { readonly "id"?: string; readonly "email"?: string } -export const AuditLogActorUser = Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The user id." })), - "email": Schema.optionalKey(Schema.String.annotate({ "description": "The user email." })) -}).annotate({ "description": "The user who performed the audit logged action." }) -export type AuditLogEventType = - | "api_key.created" - | "api_key.updated" - | "api_key.deleted" - | "certificate.created" - | "certificate.updated" - | "certificate.deleted" - | "certificates.activated" - | "certificates.deactivated" - | "checkpoint.permission.created" - | "checkpoint.permission.deleted" - | "external_key.registered" - | "external_key.removed" - | "group.created" - | "group.updated" - | "group.deleted" - | "invite.sent" - | "invite.accepted" - | "invite.deleted" - | "ip_allowlist.created" - | "ip_allowlist.updated" - | "ip_allowlist.deleted" - | "ip_allowlist.config.activated" - | "ip_allowlist.config.deactivated" - | "login.succeeded" - | "login.failed" - | "logout.succeeded" - | "logout.failed" - | "organization.updated" - | "project.created" - | "project.updated" - | "project.archived" - | "project.deleted" - | "rate_limit.updated" - | "rate_limit.deleted" - | "resource.deleted" - | "tunnel.created" - | "tunnel.updated" - | "tunnel.deleted" - | "role.created" - | "role.updated" - | "role.deleted" - | "role.assignment.created" - | "role.assignment.deleted" - | "scim.enabled" - | "scim.disabled" - | "service_account.created" - | "service_account.updated" - | "service_account.deleted" - | "user.added" - | "user.updated" - | "user.deleted" -export const AuditLogEventType = Schema.Literals([ - "api_key.created", - "api_key.updated", - "api_key.deleted", - "certificate.created", - "certificate.updated", - "certificate.deleted", - "certificates.activated", - "certificates.deactivated", - "checkpoint.permission.created", - "checkpoint.permission.deleted", - "external_key.registered", - "external_key.removed", - "group.created", - "group.updated", - "group.deleted", - "invite.sent", - "invite.accepted", - "invite.deleted", - "ip_allowlist.created", - "ip_allowlist.updated", - "ip_allowlist.deleted", - "ip_allowlist.config.activated", - "ip_allowlist.config.deactivated", - "login.succeeded", - "login.failed", - "logout.succeeded", - "logout.failed", - "organization.updated", - "project.created", - "project.updated", - "project.archived", - "project.deleted", - "rate_limit.updated", - "rate_limit.deleted", - "resource.deleted", - "tunnel.created", - "tunnel.updated", - "tunnel.deleted", - "role.created", - "role.updated", - "role.deleted", - "role.assignment.created", - "role.assignment.deleted", - "scim.enabled", - "scim.disabled", - "service_account.created", - "service_account.updated", - "service_account.deleted", - "user.added", - "user.updated", - "user.deleted" -]).annotate({ "description": "The event type." }) -export type BatchFileExpirationAfter = { readonly "anchor": "created_at"; readonly "seconds": number } -export const BatchFileExpirationAfter = Schema.Struct({ - "anchor": Schema.Literal("created_at").annotate({ - "description": - "Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`. Note that the anchor is the file creation time, not the time the batch is created." - }), - "seconds": Schema.Number.annotate({ - "description": - "The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).", - "format": "int64" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(3600)).check(Schema.isLessThanOrEqualTo(2592000)) -}).annotate({ - "title": "File expiration policy", - "description": "The expiration policy for the output and/or error file that are generated for a batch." -}) -export type Certificate = { - readonly "object": "certificate" | "organization.certificate" | "organization.project.certificate" - readonly "id": string - readonly "name": string | null - readonly "created_at": number - readonly "certificate_details": { - readonly "valid_at"?: number - readonly "expires_at"?: number - readonly "content"?: string - } - readonly "active"?: boolean +export type TranscriptionInclude = "logprobs" +export const TranscriptionInclude = Schema.Literal("logprobs").annotate({ "identifier": "TranscriptionInclude" }) +export type VadConfig = { + readonly "type": "server_vad" + readonly "prefix_padding_ms"?: number + readonly "silence_duration_ms"?: number + readonly "threshold"?: number } -export const Certificate = Schema.Struct({ - "object": Schema.Literals(["certificate", "organization.certificate", "organization.project.certificate"]).annotate({ - "description": - "The object type.\n\n- If creating, updating, or getting a specific certificate, the object type is `certificate`.\n- If listing, activating, or deactivating certificates for the organization, the object type is `organization.certificate`.\n- If listing, activating, or deactivating certificates for a project, the object type is `organization.project.certificate`.\n" - }), - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the certificate." }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the certificate was uploaded.", - "format": "unixtime" - }).check(Schema.isInt()), - "certificate_details": Schema.Struct({ - "valid_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the certificate becomes valid.", - "format": "unixtime" - }).check(Schema.isInt()) - ), - "expires_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the certificate expires.", - "format": "unixtime" - }).check(Schema.isInt()) - ), - "content": Schema.optionalKey( - Schema.String.annotate({ "description": "The content of the certificate in PEM format." }) - ) +export const VadConfig = Schema.Struct({ + "type": Schema.Literal("server_vad").annotate({ + "description": "Must be set to `server_vad` to enable manual chunking using server side VAD." }), - "active": Schema.optionalKey( - Schema.Boolean.annotate({ + "prefix_padding_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Amount of audio to include before the VAD detected speech (in \nmilliseconds).\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "silence_duration_ms": Schema.optionalKey( + Schema.Number.annotate({ "description": - "Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate." - }) + "Duration of silence to detect speech stop (in milliseconds).\nWith shorter values the model will respond more quickly, \nbut may jump in on short pauses from the user.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "threshold": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Sensitivity threshold (0.0 to 1.0) for voice activity detection. A \nhigher threshold will require louder audio to activate the model, and \nthus might perform better in noisy environments.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ) -}).annotate({ "description": "Represents an individual `certificate` uploaded to the organization." }) -export type ChatCompletionAllowedTools = { readonly "mode": "auto" | "required"; readonly "tools": ReadonlyArray<{}> } -export const ChatCompletionAllowedTools = Schema.Struct({ - "mode": Schema.Literals(["auto", "required"]).annotate({ - "description": - "Constrains the tools available to the model to a pre-defined set.\n\n`auto` allows the model to pick from among the allowed tools and generate a\nmessage.\n\n`required` requires the model to call one or more of the allowed tools.\n" +}).annotate({ "identifier": "VadConfig" }) +export type TranscriptionLanguage = { readonly "code": string } +export const TranscriptionLanguage = Schema.Struct({ + "code": Schema.String.annotate({ "description": "The code of a language detected in the audio." }) +}).annotate({ "description": "A language detected in transcribed audio.", "identifier": "TranscriptionLanguage" }) +export type TranscriptionDiarizedSegment = { + readonly "type": "transcript.text.segment" + readonly "id": string + readonly "start": number + readonly "end": number + readonly "text": string + readonly "speaker": string +} +export const TranscriptionDiarizedSegment = Schema.Struct({ + "type": Schema.Literal("transcript.text.segment").annotate({ + "description": "The type of the segment. Always `transcript.text.segment`.\n" }), - "tools": Schema.Array( - Schema.Struct({}).annotate({ "description": "A tool definition that the model should be allowed to call.\n" }) - ).annotate({ + "id": Schema.String.annotate({ "description": "Unique identifier for the segment." }), + "start": Schema.Number.annotate({ "description": "Start timestamp of the segment in seconds.", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "end": Schema.Number.annotate({ "description": "End timestamp of the segment in seconds.", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "text": Schema.String.annotate({ "description": "Transcript text for this segment." }), + "speaker": Schema.String.annotate({ "description": - "A list of tool definitions that the model should be allowed to call.\n\nFor the Chat Completions API, the list of tool definitions might look like:\n```json\n[\n { \"type\": \"function\", \"function\": { \"name\": \"get_weather\" } },\n { \"type\": \"function\", \"function\": { \"name\": \"get_time\" } }\n]\n```\n" + "Speaker label for this segment. When known speakers are provided, the label matches `known_speaker_names[]`. Otherwise speakers are labeled sequentially using capital letters (`A`, `B`, ...).\n" }) }).annotate({ - "title": "Allowed tools", - "description": "Constrains the tools available to the model to a pre-defined set.\n" + "description": "A segment of diarized transcript text with speaker metadata.", + "identifier": "TranscriptionDiarizedSegment" }) -export type ChatCompletionDeleted = { - readonly "object": "chat.completion.deleted" - readonly "id": string - readonly "deleted": boolean +export type TranscriptionWord = { readonly "word": string; readonly "start": number; readonly "end": number } +export const TranscriptionWord = Schema.Struct({ + "word": Schema.String.annotate({ "description": "The text content of the word." }), + "start": Schema.Number.annotate({ "description": "Start time of the word in seconds.", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "end": Schema.Number.annotate({ "description": "End time of the word in seconds.", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) +}).annotate({ "identifier": "TranscriptionWord" }) +export type TranscriptionSegment = { + readonly "id": number + readonly "seek": number + readonly "start": number + readonly "end": number + readonly "text": string + readonly "tokens": ReadonlyArray + readonly "temperature": number + readonly "avg_logprob": number + readonly "compression_ratio": number + readonly "no_speech_prob": number } -export const ChatCompletionDeleted = Schema.Struct({ - "object": Schema.Literal("chat.completion.deleted").annotate({ "description": "The type of object being deleted." }), - "id": Schema.String.annotate({ "description": "The ID of the chat completion that was deleted." }), - "deleted": Schema.Boolean.annotate({ "description": "Whether the chat completion was deleted." }) -}) -export type ChatCompletionFunctionCallOption = { readonly "name": string } -export const ChatCompletionFunctionCallOption = Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the function to call." }) +export const TranscriptionSegment = Schema.Struct({ + "id": Schema.Number.annotate({ "description": "Unique identifier of the segment." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "seek": Schema.Number.annotate({ "description": "Seek offset of the segment." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "start": Schema.Number.annotate({ "description": "Start time of the segment in seconds.", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "end": Schema.Number.annotate({ "description": "End time of the segment in seconds.", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "text": Schema.String.annotate({ "description": "Text content of the segment." }), + "tokens": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({ + "description": "Array of token IDs for the text content." + }), + "temperature": Schema.Number.annotate({ + "description": "Temperature parameter used for generating the segment.", + "format": "float" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "avg_logprob": Schema.Number.annotate({ + "description": "Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.", + "format": "float" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "compression_ratio": Schema.Number.annotate({ + "description": + "Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.", + "format": "float" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "no_speech_prob": Schema.Number.annotate({ + "description": + "Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.", + "format": "float" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) +}).annotate({ "identifier": "TranscriptionSegment" }) +export type TranscriptTextUsageDuration = { readonly "type": "duration"; readonly "seconds": number } +export const TranscriptTextUsageDuration = Schema.Struct({ + "type": Schema.Literal("duration").annotate({ + "description": "The type of the usage object. Always `duration` for this variant." + }), + "seconds": Schema.Number.annotate({ "description": "Duration of the input audio in seconds.", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })) }).annotate({ - "description": - "Specifying a particular function via `{\"name\": \"my_function\"}` forces the model to call that function.\n" + "title": "Duration Usage", + "description": "Usage statistics for models billed by audio input duration.", + "identifier": "TranscriptTextUsageDuration" }) -export type ChatCompletionMessageCustomToolCall = { +export type TranscriptTextSegmentEvent = { + readonly "type": "transcript.text.segment" readonly "id": string - readonly "type": "custom" - readonly "custom": { readonly "name": string; readonly "input": string } -} -export const ChatCompletionMessageCustomToolCall = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The ID of the tool call." }), - "type": Schema.Literal("custom").annotate({ "description": "The type of the tool. Always `custom`." }), - "custom": Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the custom tool to call." }), - "input": Schema.String.annotate({ "description": "The input for the custom tool call generated by the model." }) - }).annotate({ "description": "The custom tool that the model called." }) -}).annotate({ "title": "Custom tool call", "description": "A call to a custom tool created by the model.\n" }) -export type ChatCompletionMessageToolCall = { - readonly "id": string - readonly "type": "function" - readonly "function": { readonly "name": string; readonly "arguments": string } + readonly "start": number + readonly "end": number + readonly "text": string + readonly "speaker": string } -export const ChatCompletionMessageToolCall = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The ID of the tool call." }), - "type": Schema.Literal("function").annotate({ - "description": "The type of the tool. Currently, only `function` is supported." +export const TranscriptTextSegmentEvent = Schema.Struct({ + "type": Schema.Literal("transcript.text.segment").annotate({ + "description": "The type of the event. Always `transcript.text.segment`." }), - "function": Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the function to call." }), - "arguments": Schema.String.annotate({ - "description": - "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." - }) - }).annotate({ "description": "The function that the model called." }) -}).annotate({ "title": "Function tool call", "description": "A call to a function tool created by the model.\n" }) -export type ChatCompletionMessageToolCallChunk = { - readonly "index": number - readonly "id"?: string - readonly "type"?: "function" - readonly "function"?: { readonly "name"?: string; readonly "arguments"?: string } + "id": Schema.String.annotate({ "description": "Unique identifier for the segment." }), + "start": Schema.Number.annotate({ "description": "Start timestamp of the segment in seconds.", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "end": Schema.Number.annotate({ "description": "End timestamp of the segment in seconds.", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "text": Schema.String.annotate({ "description": "Transcript text for this segment." }), + "speaker": Schema.String.annotate({ "description": "Speaker label for this segment." }) +}).annotate({ + "description": + "Emitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you [create a transcription](/docs/api-reference/audio/create-transcription) with `stream` set to `true` and `response_format` set to `diarized_json`.\n", + "identifier": "TranscriptTextSegmentEvent" +}) +export type TranscriptTextDeltaEvent = { + readonly "type": "transcript.text.delta" + readonly "delta": string + readonly "logprobs"?: ReadonlyArray< + { readonly "token"?: string; readonly "logprob"?: number; readonly "bytes"?: ReadonlyArray } + > + readonly "segment_id"?: string } -export const ChatCompletionMessageToolCallChunk = Schema.Struct({ - "index": Schema.Number.check(Schema.isInt()), - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the tool call." })), - "type": Schema.optionalKey( - Schema.Literal("function").annotate({ - "description": "The type of the tool. Currently, only `function` is supported." +export const TranscriptTextDeltaEvent = Schema.Struct({ + "type": Schema.Literal("transcript.text.delta").annotate({ + "description": "The type of the event. Always `transcript.text.delta`.\n" + }), + "delta": Schema.String.annotate({ "description": "The text delta that was additionally transcribed.\n" }), + "logprobs": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "token": Schema.optionalKey( + Schema.String.annotate({ "description": "The token that was used to generate the log probability.\n" }) + ), + "logprob": Schema.optionalKey( + Schema.Number.annotate({ "description": "The log probability of the token.\n" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "bytes": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({ + "description": "The bytes that were used to generate the log probability.\n" + }) + ) + })).annotate({ + "description": + "The log probabilities of the delta. Only included if you [create a transcription](/docs/api-reference/audio/create-transcription) with the `include[]` parameter set to `logprobs`.\n" }) ), - "function": Schema.optionalKey(Schema.Struct({ - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function to call." })), - "arguments": Schema.optionalKey(Schema.String.annotate({ + "segment_id": Schema.optionalKey( + Schema.String.annotate({ "description": - "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." - })) - })) + "Identifier of the diarized segment that this delta belongs to. Only present when using `gpt-4o-transcribe-diarize`.\n" + }) + ) +}).annotate({ + "description": + "Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.", + "identifier": "TranscriptTextDeltaEvent" }) -export type ChatCompletionNamedToolChoice = { - readonly "type": "function" - readonly "function": { readonly "name": string } +export type TranscriptTextUsageTokens = { + readonly "type": "tokens" + readonly "input_tokens": number + readonly "input_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number } + readonly "output_tokens": number + readonly "total_tokens": number } -export const ChatCompletionNamedToolChoice = Schema.Struct({ - "type": Schema.Literal("function").annotate({ - "description": "For function calling, the type is always `function`." +export const TranscriptTextUsageTokens = Schema.Struct({ + "type": Schema.Literal("tokens").annotate({ + "description": "The type of the usage object. Always `tokens` for this variant." }), - "function": Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) }) + "input_tokens": Schema.Number.annotate({ "description": "Number of input tokens billed for this request." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "input_token_details": Schema.optionalKey( + Schema.Struct({ + "text_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of text tokens billed for this request." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "audio_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of audio tokens billed for this request." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ) + }).annotate({ "description": "Details about the input tokens billed for this request." }) + ), + "output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) }).annotate({ - "title": "Function tool choice", - "description": "Specifies a tool the model should use. Use to force the model to call a specific function." + "title": "Token Usage", + "description": "Usage statistics for models billed by token usage.", + "identifier": "TranscriptTextUsageTokens" }) -export type ChatCompletionNamedToolChoiceCustom = { - readonly "type": "custom" - readonly "custom": { readonly "name": string } +export type CreateTranslationRequest = { + readonly "file": string + readonly "model": string | "whisper-1" + readonly "prompt"?: string + readonly "response_format"?: "json" | "text" | "srt" | "verbose_json" | "vtt" + readonly "temperature"?: number } -export const ChatCompletionNamedToolChoiceCustom = Schema.Struct({ - "type": Schema.Literal("custom").annotate({ "description": "For custom tool calling, the type is always `custom`." }), - "custom": Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the custom tool to call." }) - }) -}).annotate({ - "title": "Custom tool choice", - "description": "Specifies a tool the model should use. Use to force the model to call a specific custom tool." +export const CreateTranslationRequest = Schema.Struct({ + "file": Schema.String.annotate({ + "description": + "The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.\n", + "format": "binary" + }), + "model": Schema.Union([Schema.String, Schema.Literal("whisper-1")]).annotate({ + "description": + "ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.\n" + }), + "prompt": Schema.optionalKey( + Schema.String.annotate({ + "description": + "An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should be in English.\n" + }) + ), + "response_format": Schema.optionalKey( + Schema.Literals(["json", "text", "srt", "verbose_json", "vtt"]).annotate({ + "description": + "The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.\n" + }) + ), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) +}).annotate({ "identifier": "CreateTranslationRequest" }) +export type CreateTranslationResponseJson = { readonly "text": string } +export const CreateTranslationResponseJson = Schema.Struct({ "text": Schema.String }).annotate({ + "identifier": "CreateTranslationResponseJson" }) -export type ChatCompletionRequestFunctionMessage = { - readonly "role": "function" - readonly "content": string | null +export type VoiceConsentResource = { + readonly "object": "audio.voice_consent" + readonly "id": string readonly "name": string + readonly "language": string + readonly "created_at": number } -export const ChatCompletionRequestFunctionMessage = Schema.Struct({ - "role": Schema.Literal("function").annotate({ - "description": "The role of the messages author, in this case `function`." +export const VoiceConsentResource = Schema.Struct({ + "object": Schema.Literal("audio.voice_consent").annotate({ + "description": "The object type, which is always `audio.voice_consent`." }), - "content": Schema.Union([ - Schema.String.annotate({ "description": "The contents of the function message." }), - Schema.Null - ]), - "name": Schema.String.annotate({ "description": "The name of the function to call." }) -}).annotate({ "title": "Function message" }) -export type ChatCompletionRequestMessageContentPartAudio = { - readonly "type": "input_audio" - readonly "input_audio": { readonly "data": string; readonly "format": "wav" | "mp3" } -} -export const ChatCompletionRequestMessageContentPartAudio = Schema.Struct({ - "type": Schema.Literal("input_audio").annotate({ - "description": "The type of the content part. Always `input_audio`." + "id": Schema.String.annotate({ "description": "The consent recording identifier." }), + "name": Schema.String.annotate({ "description": "The label provided when the consent recording was uploaded." }), + "language": Schema.String.annotate({ + "description": "The BCP 47 language tag for the consent phrase (for example, `en-US`)." }), - "input_audio": Schema.Struct({ - "data": Schema.String.annotate({ "description": "Base64 encoded audio data." }), - "format": Schema.Literals(["wav", "mp3"]).annotate({ - "description": "The format of the encoded audio data. Currently supports \"wav\" and \"mp3\".\n" - }) - }) -}).annotate({ "title": "Audio content part", "description": "Learn about [audio inputs](/docs/guides/audio).\n" }) -export type ChatCompletionRequestMessageContentPartFile = { - readonly "type": "file" - readonly "file": { readonly "filename"?: string; readonly "file_data"?: string; readonly "file_id"?: string } -} -export const ChatCompletionRequestMessageContentPartFile = Schema.Struct({ - "type": Schema.Literal("file").annotate({ "description": "The type of the content part. Always `file`." }), - "file": Schema.Struct({ - "filename": Schema.optionalKey( - Schema.String.annotate({ - "description": "The name of the file, used when passing the file to the model as a \nstring.\n" - }) - ), - "file_data": Schema.optionalKey( - Schema.String.annotate({ - "description": "The base64 encoded file data, used when passing the file to the model \nas a string.\n" - }) - ), - "file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of an uploaded file to use as input.\n" }) - ) - }) + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the consent recording was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) }).annotate({ - "title": "File content part", - "description": "Learn about [file inputs](/docs/guides/text) for text generation.\n" + "title": "Voice consent", + "description": "A consent recording used to authorize creation of a custom voice.", + "identifier": "VoiceConsentResource" }) -export type ChatCompletionRequestMessageContentPartImage = { - readonly "type": "image_url" - readonly "image_url": { readonly "url": string; readonly "detail"?: "auto" | "low" | "high" } +export type CreateVoiceConsentRequest = { + readonly "name": string + readonly "recording": string + readonly "language": string } -export const ChatCompletionRequestMessageContentPartImage = Schema.Struct({ - "type": Schema.Literal("image_url").annotate({ "description": "The type of the content part." }), - "image_url": Schema.Struct({ - "url": Schema.String.annotate({ - "description": "Either a URL of the image or the base64 encoded image data.", - "format": "uri" - }), - "detail": Schema.optionalKey( - Schema.Literals(["auto", "low", "high"]).annotate({ - "description": - "Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding)." - }) - ) +export const CreateVoiceConsentRequest = Schema.Struct({ + "name": Schema.String.annotate({ "description": "The label to use for this consent recording." }), + "recording": Schema.String.annotate({ + "description": + "The consent audio recording file. Maximum size is 10 MiB.\n\nSupported MIME types:\n`audio/mpeg`, `audio/wav`, `audio/x-wav`, `audio/ogg`, `audio/aac`, `audio/flac`, `audio/webm`, `audio/mp4`.\n", + "format": "binary" + }), + "language": Schema.String.annotate({ + "description": "The BCP 47 language tag for the consent phrase (for example, `en-US`)." }) -}).annotate({ "title": "Image content part", "description": "Learn about [image inputs](/docs/guides/vision).\n" }) -export type ChatCompletionRequestMessageContentPartRefusal = { readonly "type": "refusal"; readonly "refusal": string } -export const ChatCompletionRequestMessageContentPartRefusal = Schema.Struct({ - "type": Schema.Literal("refusal").annotate({ "description": "The type of the content part." }), - "refusal": Schema.String.annotate({ "description": "The refusal message generated by the model." }) -}).annotate({ "title": "Refusal content part" }) -export type ChatCompletionRequestMessageContentPartText = { readonly "type": "text"; readonly "text": string } -export const ChatCompletionRequestMessageContentPartText = Schema.Struct({ - "type": Schema.Literal("text").annotate({ "description": "The type of the content part." }), - "text": Schema.String.annotate({ "description": "The text content." }) +}).annotate({ "identifier": "CreateVoiceConsentRequest" }) +export type UpdateVoiceConsentRequest = { readonly "name": string } +export const UpdateVoiceConsentRequest = Schema.Struct({ + "name": Schema.String.annotate({ "description": "The updated label for this consent recording." }) +}).annotate({ "identifier": "UpdateVoiceConsentRequest" }) +export type VoiceConsentDeletedResource = { + readonly "id": string + readonly "object": "audio.voice_consent" + readonly "deleted": boolean +} +export const VoiceConsentDeletedResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The consent recording identifier." }), + "object": Schema.Literal("audio.voice_consent"), + "deleted": Schema.Boolean +}).annotate({ "identifier": "VoiceConsentDeletedResource" }) +export type CreateVoiceRequest = { + readonly "name": string + readonly "audio_sample": string + readonly "consent": string +} +export const CreateVoiceRequest = Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the new voice." }), + "audio_sample": Schema.String.annotate({ + "description": + "The sample audio recording file. Maximum size is 10 MiB.\n\nSupported MIME types:\n`audio/mpeg`, `audio/wav`, `audio/x-wav`, `audio/ogg`, `audio/aac`, `audio/flac`, `audio/webm`, `audio/mp4`.\n", + "format": "binary" + }), + "consent": Schema.String.annotate({ "description": "The consent recording ID (for example, `cons_1234`)." }) +}).annotate({ "identifier": "CreateVoiceRequest" }) +export type VoiceResource = { + readonly "object": "audio.voice" + readonly "id": string + readonly "name": string + readonly "created_at": number +} +export const VoiceResource = Schema.Struct({ + "object": Schema.Literal("audio.voice").annotate({ + "description": "The object type, which is always `audio.voice`." + }), + "id": Schema.String.annotate({ "description": "The voice identifier, which can be referenced in API endpoints." }), + "name": Schema.String.annotate({ "description": "The name of the voice." }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the voice was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) }).annotate({ - "title": "Text content part", - "description": "Learn about [text inputs](/docs/guides/text-generation).\n" + "title": "Voice", + "description": "A custom voice that can be used for audio output.", + "identifier": "VoiceResource" +}) +export type BatchError = { + readonly "code"?: string + readonly "message"?: string + readonly "param"?: string | null + readonly "line"?: number | null +} +export const BatchError = Schema.Struct({ + "code": Schema.optionalKey(Schema.String.annotate({ "description": "An error code identifying the error type." })), + "message": Schema.optionalKey( + Schema.String.annotate({ "description": "A human-readable message providing more details about the error." }) + ), + "param": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The name of the parameter that caused the error, if applicable." }), + Schema.Null + ]) + ), + "line": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The line number of the input file where the error occurred, if applicable." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ) +}).annotate({ "identifier": "BatchError" }) +export type BatchRequestCounts = { readonly "total": number; readonly "completed": number; readonly "failed": number } +export const BatchRequestCounts = Schema.Struct({ + "total": Schema.Number.annotate({ "description": "Total number of requests in the batch." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "completed": Schema.Number.annotate({ "description": "Number of requests that have been completed successfully." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "failed": Schema.Number.annotate({ "description": "Number of requests that have failed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "The request counts for different statuses within the batch.", + "identifier": "BatchRequestCounts" }) -export type ChatCompletionStreamOptions = { - readonly "include_usage"?: boolean - readonly "include_obfuscation"?: boolean -} | null -export const ChatCompletionStreamOptions = Schema.Union([ - Schema.Struct({ - "include_usage": Schema.optionalKey(Schema.Boolean.annotate({ - "description": - "If set, an additional chunk will be streamed before the `data: [DONE]`\nmessage. The `usage` field on this chunk shows the token usage statistics\nfor the entire request, and the `choices` field will always be an empty\narray.\n\nAll other chunks will also include a `usage` field, but with a null\nvalue. **NOTE:** If the stream is interrupted, you may not receive the\nfinal usage chunk which contains the total token usage for the request.\n" - })), - "include_obfuscation": Schema.optionalKey(Schema.Boolean.annotate({ +export type BatchFileExpirationAfter = { readonly "anchor": "created_at"; readonly "seconds": number } +export const BatchFileExpirationAfter = Schema.Struct({ + "anchor": Schema.Literal("created_at").annotate({ + "description": + "Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`. Note that the anchor is the file creation time, not the time the batch is created." + }), + "seconds": Schema.Number.annotate({ + "description": + "The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).", + "format": "int64" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(3600).annotate({ "expected": "a value greater than or equal to 3600" }) + ).check(Schema.isLessThanOrEqualTo(2592000).annotate({ "expected": "a value less than or equal to 2592000" })) +}).annotate({ + "title": "File expiration policy", + "description": "The expiration policy for the output and/or error file that are generated for a batch.", + "identifier": "BatchFileExpirationAfter" +}) +export type ChatCompletionMessageToolCall = { + readonly "id": string + readonly "type": "function" + readonly "function": { readonly "name": string; readonly "arguments": string } +} +export const ChatCompletionMessageToolCall = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The ID of the tool call." }), + "type": Schema.Literal("function").annotate({ + "description": "The type of the tool. Currently, only `function` is supported." + }), + "function": Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the function to call." }), + "arguments": Schema.String.annotate({ "description": - "When true, stream obfuscation will be enabled. Stream obfuscation adds\nrandom characters to an `obfuscation` field on streaming delta events to\nnormalize payload sizes as a mitigation to certain side-channel attacks.\nThese obfuscation fields are included by default, but add a small amount\nof overhead to the data stream. You can set `include_obfuscation` to\nfalse to optimize for bandwidth if you trust the network links between\nyour application and the OpenAI API.\n" - })) - }).annotate({ "description": "Options for streaming response. Only set this when you set `stream: true`.\n" }), - Schema.Null -]) + "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + }) + }).annotate({ "description": "The function that the model called." }) +}).annotate({ + "title": "Function tool call", + "description": "A call to a function tool created by the model.\n", + "identifier": "ChatCompletionMessageToolCall" +}) +export type ChatCompletionMessageCustomToolCall = { + readonly "id": string + readonly "type": "custom" + readonly "custom": { readonly "name": string; readonly "input": string } +} +export const ChatCompletionMessageCustomToolCall = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The ID of the tool call." }), + "type": Schema.Literal("custom").annotate({ "description": "The type of the tool. Always `custom`." }), + "custom": Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the custom tool to call." }), + "input": Schema.String.annotate({ "description": "The input for the custom tool call generated by the model." }) + }).annotate({ "description": "The custom tool that the model called." }) +}).annotate({ + "title": "Custom tool call", + "description": "A call to a custom tool created by the model.\n", + "identifier": "ChatCompletionMessageCustomToolCall" +}) export type ChatCompletionTokenLogprob = { readonly "token": string readonly "logprob": number @@ -687,9 +708,9 @@ export const ChatCompletionTokenLogprob = Schema.Struct({ "logprob": Schema.Number.annotate({ "description": "The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely." - }).check(Schema.isFinite()), + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), "bytes": Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({ "description": "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token." }), @@ -700,9 +721,9 @@ export const ChatCompletionTokenLogprob = Schema.Struct({ "logprob": Schema.Number.annotate({ "description": "The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely." - }).check(Schema.isFinite()), + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), "bytes": Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({ "description": "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token." }), @@ -712,41 +733,15 @@ export const ChatCompletionTokenLogprob = Schema.Struct({ "description": "List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`." }) -}) -export type ComparisonFilter = { - readonly "type": "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" - readonly "key": string - readonly "value": string | number | boolean | ReadonlyArray -} -export const ComparisonFilter = Schema.Struct({ - "type": Schema.Literals(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]).annotate({ +}).annotate({ "identifier": "ChatCompletionTokenLogprob" }) +export type ServiceTier = "auto" | "default" | "flex" | "scale" | "priority" | "fast" | null +export const ServiceTier = Schema.Union([ + Schema.Literals(["auto", "default", "flex", "scale", "priority", "fast"]).annotate({ "description": - "Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`.\n- `eq`: equals\n- `ne`: not equal\n- `gt`: greater than\n- `gte`: greater than or equal\n- `lt`: less than\n- `lte`: less than or equal\n- `in`: in\n- `nin`: not in\n" + "Specifies the processing type used for serving the request.\n - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.\n - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.\n - If set to '[flex](/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.\n - To opt-in to [Fast mode](/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request.\n - When not set, the default behavior is 'auto'.\n\n When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.\n" }), - "key": Schema.String.annotate({ "description": "The key to compare against the value." }), - "value": Schema.Union([ - Schema.String, - Schema.Number.check(Schema.isFinite()), - Schema.Boolean, - Schema.Array(Schema.Union([Schema.String, Schema.Number.check(Schema.isFinite())], { mode: "oneOf" })) - ], { mode: "oneOf" }).annotate({ - "description": "The value to compare against the attribute key; supports string, number, or boolean types." - }) -}).annotate({ - "title": "Comparison Filter", - "description": - "A filter used to compare a specified attribute key to a given value using a defined comparison operation.\n" -}) -export type CompleteUploadRequest = { readonly "part_ids": ReadonlyArray; readonly "md5"?: string } -export const CompleteUploadRequest = Schema.Struct({ - "part_ids": Schema.Array(Schema.String).annotate({ "description": "The ordered list of Part IDs.\n" }), - "md5": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The optional md5 checksum for the file contents to verify if the bytes uploaded matches what you expect.\n" - }) - ) -}) + Schema.Null +]).annotate({ "identifier": "ServiceTier" }) export type CompletionUsage = { readonly "completion_tokens": number readonly "prompt_tokens": number @@ -757,1025 +752,1995 @@ export type CompletionUsage = { readonly "reasoning_tokens"?: number readonly "rejected_prediction_tokens"?: number } - readonly "prompt_tokens_details"?: { readonly "audio_tokens"?: number; readonly "cached_tokens"?: number } + readonly "prompt_tokens_details"?: { + readonly "audio_tokens"?: number + readonly "cached_tokens"?: number + readonly "cache_write_tokens"?: number + } } export const CompletionUsage = Schema.Struct({ "completion_tokens": Schema.Number.annotate({ "description": "Number of tokens in the generated completion." }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "prompt_tokens": Schema.Number.annotate({ "description": "Number of tokens in the prompt." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "prompt_tokens": Schema.Number.annotate({ "description": "Number of tokens in the prompt." }).check(Schema.isInt()), "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used in the request (prompt + completion)." - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "completion_tokens_details": Schema.optionalKey( Schema.Struct({ "accepted_prediction_tokens": Schema.optionalKey( Schema.Number.annotate({ "description": "When using Predicted Outputs, the number of tokens in the\nprediction that appeared in the completion.\n" - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Audio input tokens generated by the model." }).check(Schema.isInt()) + Schema.Number.annotate({ "description": "Audio input tokens generated by the model." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ), "reasoning_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Tokens generated by the model for reasoning." }).check(Schema.isInt()) + Schema.Number.annotate({ "description": "Tokens generated by the model for reasoning." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ), "rejected_prediction_tokens": Schema.optionalKey( Schema.Number.annotate({ "description": "When using Predicted Outputs, the number of tokens in the\nprediction that did not appear in the completion. However, like\nreasoning tokens, these tokens are still counted in the total\ncompletion tokens for purposes of billing, output, and context window\nlimits.\n" - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ) }).annotate({ "description": "Breakdown of tokens used in a completion." }) ), "prompt_tokens_details": Schema.optionalKey( Schema.Struct({ "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Audio input tokens present in the prompt." }).check(Schema.isInt()) + Schema.Number.annotate({ "description": "Audio input tokens present in the prompt." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ), "cached_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Cached tokens present in the prompt." }).check(Schema.isInt()) + Schema.Number.annotate({ "description": "Cached tokens present in the prompt." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "cache_write_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The unadjusted number of prompt tokens written to cache." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ) }).annotate({ "description": "Breakdown of tokens used in the prompt." }) ) -}).annotate({ "description": "Usage statistics for the completion request." }) -export type ComputerScreenshotImage = { - readonly "type": "computer_screenshot" - readonly "image_url"?: string - readonly "file_id"?: string +}).annotate({ "description": "Usage statistics for the completion request.", "identifier": "CompletionUsage" }) +export type ModerationResultBody = { + readonly "type": "moderation_result" + readonly "model": string + readonly "flagged": boolean + readonly "categories": {} + readonly "category_scores": {} + readonly "category_applied_input_types": {} } -export const ComputerScreenshotImage = Schema.Struct({ - "type": Schema.Literal("computer_screenshot").annotate({ +export const ModerationResultBody = Schema.Struct({ + "type": Schema.Literal("moderation_result").annotate({ + "description": "The object type, which was always `moderation_result` for successful moderation results." + }), + "model": Schema.String.annotate({ "description": "The moderation model that produced this result." }), + "flagged": Schema.Boolean.annotate({ + "description": "A boolean indicating whether the content was flagged by any category." + }), + "categories": Schema.Struct({}).annotate({ "description": - "Specifies the event type. For a computer screenshot, this property is \nalways set to `computer_screenshot`.\n" + "A dictionary of moderation categories to booleans, True if the input is flagged under this category." }), - "image_url": Schema.optionalKey( - Schema.String.annotate({ "description": "The URL of the screenshot image.", "format": "uri" }) - ), - "file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier of an uploaded file that contains the screenshot." }) - ) -}).annotate({ "description": "A computer screenshot image used with the computer use tool.\n" }) -export type ContainerFileResource = { - readonly "id": string - readonly "object": string - readonly "container_id": string - readonly "created_at": number - readonly "bytes": number - readonly "path": string - readonly "source": string + "category_scores": Schema.Struct({}).annotate({ "description": "A dictionary of moderation categories to scores." }), + "category_applied_input_types": Schema.Struct({}).annotate({ + "description": "Which modalities of input are reflected by the score for each category." + }) +}).annotate({ + "title": "Moderation result", + "description": "A moderation result produced for the response input or output.", + "identifier": "ModerationResultBody" +}) +export type ChatCompletionModerationError = { + readonly "type": "error" + readonly "code": string + readonly "message": string } -export const ContainerFileResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Unique identifier for the file." }), - "object": Schema.String.annotate({ "description": "The type of this object (`container.file`)." }), - "container_id": Schema.String.annotate({ "description": "The container this file belongs to." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the file was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "bytes": Schema.Number.annotate({ "description": "Size of the file in bytes." }).check(Schema.isInt()), - "path": Schema.String.annotate({ "description": "Path of the file in the container." }), - "source": Schema.String.annotate({ "description": "Source of the file (e.g., `user`, `assistant`)." }) -}).annotate({ "title": "The container file object" }) -export type ContainerResource = { - readonly "id": string - readonly "object": string +export const ChatCompletionModerationError = Schema.Struct({ + "type": Schema.Literal("error").annotate({ "description": "The object type, which is always `error`." }), + "code": Schema.String.annotate({ "description": "The error code." }), + "message": Schema.String.annotate({ "description": "The error message." }) +}).annotate({ + "description": "An error produced while attempting moderation.", + "identifier": "ChatCompletionModerationError" +}) +export type PromptCacheTTLEnum = "30m" +export const PromptCacheTTLEnum = Schema.Literal("30m").annotate({ "identifier": "PromptCacheTTLEnum" }) +export type PromptCacheModeEnum = "implicit" | "explicit" +export const PromptCacheModeEnum = Schema.Literals(["implicit", "explicit"]).annotate({ + "identifier": "PromptCacheModeEnum" +}) +export type PromptCacheBreakpointParam = { readonly "mode": "explicit" } +export const PromptCacheBreakpointParam = Schema.Struct({ + "mode": Schema.Literal("explicit").annotate({ "description": "The breakpoint mode. Always `explicit`." }) +}).annotate({ + "title": "Prompt cache breakpoint", + "description": + "Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.", + "identifier": "PromptCacheBreakpointParam" +}) +export type ChatCompletionRequestMessageContentPartRefusal = { readonly "type": "refusal"; readonly "refusal": string } +export const ChatCompletionRequestMessageContentPartRefusal = Schema.Struct({ + "type": Schema.Literal("refusal").annotate({ "description": "The type of the content part." }), + "refusal": Schema.String.annotate({ "description": "The refusal message generated by the model." }) +}).annotate({ "title": "Refusal content part", "identifier": "ChatCompletionRequestMessageContentPartRefusal" }) +export type ChatCompletionRequestFunctionMessage = { + readonly "role": "function" + readonly "content": string | null readonly "name": string - readonly "created_at": number - readonly "status": string - readonly "last_active_at"?: number - readonly "expires_after"?: { readonly "anchor"?: "last_active_at"; readonly "minutes"?: number } - readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g" - readonly "network_policy"?: { - readonly "type": "allowlist" | "disabled" - readonly "allowed_domains"?: ReadonlyArray - } } -export const ContainerResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Unique identifier for the container." }), - "object": Schema.String.annotate({ "description": "The type of this object." }), - "name": Schema.String.annotate({ "description": "Name of the container." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the container was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "status": Schema.String.annotate({ "description": "Status of the container (e.g., active, deleted)." }), - "last_active_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the container was last active.", - "format": "unixtime" - }).check(Schema.isInt()) - ), - "expires_after": Schema.optionalKey( - Schema.Struct({ - "anchor": Schema.optionalKey( - Schema.Literal("last_active_at").annotate({ "description": "The reference point for the expiration." }) - ), - "minutes": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of minutes after the anchor before the container expires." - }).check(Schema.isInt()) - ) - }).annotate({ - "description": - "The container will expire after this time period.\nThe anchor is the reference point for the expiration.\nThe minutes is the number of minutes after the anchor before the container expires.\n" - }) - ), - "memory_limit": Schema.optionalKey( - Schema.Literals(["1g", "4g", "16g", "64g"]).annotate({ - "description": "The memory limit configured for the container." - }) - ), - "network_policy": Schema.optionalKey( - Schema.Struct({ - "type": Schema.Literals(["allowlist", "disabled"]).annotate({ "description": "The network policy mode." }), - "allowed_domains": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ "description": "Allowed outbound domains when `type` is `allowlist`." }) - ) - }).annotate({ "description": "Network access policy for the container." }) - ) -}).annotate({ "title": "The container object" }) -export type CostsResult = { - readonly "object": "organization.costs.result" - readonly "amount"?: { readonly "value"?: number; readonly "currency"?: string } - readonly "line_item"?: string | null - readonly "project_id"?: string | null - readonly "api_key_id"?: string | null - readonly "quantity"?: number | null +export const ChatCompletionRequestFunctionMessage = Schema.Struct({ + "role": Schema.Literal("function").annotate({ + "description": "The role of the messages author, in this case `function`." + }), + "content": Schema.Union([ + Schema.String.annotate({ "description": "The contents of the function message." }), + Schema.Null + ]), + "name": Schema.String.annotate({ "description": "The name of the function to call." }) +}).annotate({ "title": "Function message", "identifier": "ChatCompletionRequestFunctionMessage" }) +export type ModelIdsShared = + | string + | "gpt-5.6-sol" + | "gpt-5.6-terra" + | "gpt-5.6-luna" + | "gpt-5.5" + | "gpt-5.4" + | "gpt-5.4-mini" + | "gpt-5.4-nano" + | "gpt-5.4-mini-2026-03-17" + | "gpt-5.4-nano-2026-03-17" + | "gpt-5.3-chat-latest" + | "gpt-5.2" + | "gpt-5.2-2025-12-11" + | "gpt-5.2-chat-latest" + | "gpt-5.2-pro" + | "gpt-5.2-pro-2025-12-11" + | "gpt-5.1" + | "gpt-5.1-2025-11-13" + | "gpt-5.1-codex" + | "gpt-5.1-mini" + | "gpt-5.1-chat-latest" + | "gpt-5" + | "gpt-5-mini" + | "gpt-5-nano" + | "gpt-5-2025-08-07" + | "gpt-5-mini-2025-08-07" + | "gpt-5-nano-2025-08-07" + | "gpt-5-chat-latest" + | "gpt-4.1" + | "gpt-4.1-mini" + | "gpt-4.1-nano" + | "gpt-4.1-2025-04-14" + | "gpt-4.1-mini-2025-04-14" + | "gpt-4.1-nano-2025-04-14" + | "o4-mini" + | "o4-mini-2025-04-16" + | "o3" + | "o3-2025-04-16" + | "o3-mini" + | "o3-mini-2025-01-31" + | "o1" + | "o1-2024-12-17" + | "o1-preview" + | "o1-preview-2024-09-12" + | "o1-mini" + | "o1-mini-2024-09-12" + | "gpt-4o" + | "gpt-4o-2024-11-20" + | "gpt-4o-2024-08-06" + | "gpt-4o-2024-05-13" + | "gpt-4o-audio-preview" + | "gpt-4o-audio-preview-2024-10-01" + | "gpt-4o-audio-preview-2024-12-17" + | "gpt-4o-audio-preview-2025-06-03" + | "gpt-4o-mini-audio-preview" + | "gpt-4o-mini-audio-preview-2024-12-17" + | "gpt-4o-search-preview" + | "gpt-4o-mini-search-preview" + | "gpt-4o-search-preview-2025-03-11" + | "gpt-4o-mini-search-preview-2025-03-11" + | "chatgpt-4o-latest" + | "codex-mini-latest" + | "gpt-4o-mini" + | "gpt-4o-mini-2024-07-18" + | "gpt-4-turbo" + | "gpt-4-turbo-2024-04-09" + | "gpt-4-0125-preview" + | "gpt-4-turbo-preview" + | "gpt-4-1106-preview" + | "gpt-4-vision-preview" + | "gpt-4" + | "gpt-4-0314" + | "gpt-4-0613" + | "gpt-4-32k" + | "gpt-4-32k-0314" + | "gpt-4-32k-0613" + | "gpt-3.5-turbo" + | "gpt-3.5-turbo-16k" + | "gpt-3.5-turbo-0301" + | "gpt-3.5-turbo-0613" + | "gpt-3.5-turbo-1106" + | "gpt-3.5-turbo-0125" + | "gpt-3.5-turbo-16k-0613" +export const ModelIdsShared = Schema.Union([ + Schema.String, + Schema.Literals([ + "gpt-5.6-sol", + "gpt-5.6-terra", + "gpt-5.6-luna", + "gpt-5.5", + "gpt-5.4", + "gpt-5.4-mini", + "gpt-5.4-nano", + "gpt-5.4-mini-2026-03-17", + "gpt-5.4-nano-2026-03-17", + "gpt-5.3-chat-latest", + "gpt-5.2", + "gpt-5.2-2025-12-11", + "gpt-5.2-chat-latest", + "gpt-5.2-pro", + "gpt-5.2-pro-2025-12-11", + "gpt-5.1", + "gpt-5.1-2025-11-13", + "gpt-5.1-codex", + "gpt-5.1-mini", + "gpt-5.1-chat-latest", + "gpt-5", + "gpt-5-mini", + "gpt-5-nano", + "gpt-5-2025-08-07", + "gpt-5-mini-2025-08-07", + "gpt-5-nano-2025-08-07", + "gpt-5-chat-latest", + "gpt-4.1", + "gpt-4.1-mini", + "gpt-4.1-nano", + "gpt-4.1-2025-04-14", + "gpt-4.1-mini-2025-04-14", + "gpt-4.1-nano-2025-04-14", + "o4-mini", + "o4-mini-2025-04-16", + "o3", + "o3-2025-04-16", + "o3-mini", + "o3-mini-2025-01-31", + "o1", + "o1-2024-12-17", + "o1-preview", + "o1-preview-2024-09-12", + "o1-mini", + "o1-mini-2024-09-12", + "gpt-4o", + "gpt-4o-2024-11-20", + "gpt-4o-2024-08-06", + "gpt-4o-2024-05-13", + "gpt-4o-audio-preview", + "gpt-4o-audio-preview-2024-10-01", + "gpt-4o-audio-preview-2024-12-17", + "gpt-4o-audio-preview-2025-06-03", + "gpt-4o-mini-audio-preview", + "gpt-4o-mini-audio-preview-2024-12-17", + "gpt-4o-search-preview", + "gpt-4o-mini-search-preview", + "gpt-4o-search-preview-2025-03-11", + "gpt-4o-mini-search-preview-2025-03-11", + "chatgpt-4o-latest", + "codex-mini-latest", + "gpt-4o-mini", + "gpt-4o-mini-2024-07-18", + "gpt-4-turbo", + "gpt-4-turbo-2024-04-09", + "gpt-4-0125-preview", + "gpt-4-turbo-preview", + "gpt-4-1106-preview", + "gpt-4-vision-preview", + "gpt-4", + "gpt-4-0314", + "gpt-4-0613", + "gpt-4-32k", + "gpt-4-32k-0314", + "gpt-4-32k-0613", + "gpt-3.5-turbo", + "gpt-3.5-turbo-16k", + "gpt-3.5-turbo-0301", + "gpt-3.5-turbo-0613", + "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", + "gpt-3.5-turbo-16k-0613" + ]) +]).annotate({ "identifier": "ModelIdsShared" }) +export type ResponseModalities = ReadonlyArray<"text" | "audio"> | null +export const ResponseModalities = Schema.Union([ + Schema.Array(Schema.Literals(["text", "audio"])).annotate({ + "description": + "Output types that you would like the model to generate.\nMost models are capable of generating text, which is the default:\n\n`[\"text\"]`\n\nThe `gpt-4o-audio-preview` model can also be used to\n[generate audio](/docs/guides/audio). To request that this model generate\nboth text and audio responses, you can use:\n\n`[\"text\", \"audio\"]`\n" + }), + Schema.Null +]).annotate({ "identifier": "ResponseModalities" }) +export type Verbosity = "low" | "medium" | "high" | null +export const Verbosity = Schema.Union([ + Schema.Literals(["low", "medium", "high"]).annotate({ + "description": + "Constrains the verbosity of the model's response. Lower values will result in\nmore concise responses, while higher values will result in more verbose responses.\nCurrently supported values are `low`, `medium`, and `high`. The default is\n`medium`.\n" + }), + Schema.Null +]).annotate({ "identifier": "Verbosity" }) +export type WebSearchLocation = { + readonly "country"?: string + readonly "region"?: string + readonly "city"?: string + readonly "timezone"?: string } -export const CostsResult = Schema.Struct({ - "object": Schema.Literal("organization.costs.result"), - "amount": Schema.optionalKey( - Schema.Struct({ - "value": Schema.optionalKey( - Schema.Number.annotate({ "description": "The numeric value of the cost." }).check(Schema.isFinite()) - ), - "currency": Schema.optionalKey( - Schema.String.annotate({ "description": "Lowercase ISO-4217 currency e.g. \"usd\"" }) - ) - }).annotate({ "description": "The monetary value in its associated currency." }) - ), - "line_item": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=line_item`, this field provides the line item of the grouped costs result." - }), - Schema.Null - ]) +export const WebSearchLocation = Schema.Struct({ + "country": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The two-letter \n[ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user,\ne.g. `US`.\n" + }) ), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped costs result." - }), - Schema.Null - ]) + "region": Schema.optionalKey( + Schema.String.annotate({ "description": "Free text input for the region of the user, e.g. `California`.\n" }) ), - "api_key_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result." - }), - Schema.Null - ]) + "city": Schema.optionalKey( + Schema.String.annotate({ "description": "Free text input for the city of the user, e.g. `San Francisco`.\n" }) ), - "quantity": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "When `group_by=line_item`, this field provides the quantity of the grouped costs result." - }).check(Schema.isFinite()), - Schema.Null - ]) - ) -}).annotate({ "description": "The aggregated costs details of the specific time bucket." }) -export type CreateContainerFileBody = { readonly "file_id"?: string; readonly "file"?: string } -export const CreateContainerFileBody = Schema.Struct({ - "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "Name of the file to create." })), - "file": Schema.optionalKey( - Schema.String.annotate({ "description": "The File object (not file name) to be uploaded.\n", "format": "binary" }) + "timezone": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The [IANA timezone](https://timeapi.io/documentation/iana-timezones) \nof the user, e.g. `America/Los_Angeles`.\n" + }) ) +}).annotate({ + "title": "Web search location", + "description": "Approximate location parameters for the search.", + "identifier": "WebSearchLocation" }) -export type CreateEmbeddingRequest = { - readonly "input": string | ReadonlyArray | ReadonlyArray | ReadonlyArray> - readonly "model": string | "text-embedding-ada-002" | "text-embedding-3-small" | "text-embedding-3-large" - readonly "encoding_format"?: "float" | "base64" - readonly "dimensions"?: number - readonly "user"?: string -} -export const CreateEmbeddingRequest = Schema.Struct({ - "input": Schema.Union([ - Schema.String.annotate({ "title": "string", "description": "The string that will be turned into an embedding." }), - Schema.Array(Schema.String).annotate({ - "title": "array", - "description": "The array of strings that will be turned into an embedding." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(2048)), - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "title": "array", - "description": "The array of integers that will be turned into an embedding." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(2048)), - Schema.Array(Schema.Array(Schema.Number.check(Schema.isInt())).check(Schema.isMinLength(1))).annotate({ - "title": "array", - "description": "The array of arrays containing integers that will be turned into an embedding." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(2048)) +export type WebSearchContextSize = "low" | "medium" | "high" +export const WebSearchContextSize = Schema.Literals(["low", "medium", "high"]).annotate({ + "description": + "High level guidance for the amount of context window space to use for the \nsearch. One of `low`, `medium`, or `high`. `medium` is the default.\n", + "identifier": "WebSearchContextSize" +}) +export type ModerationMode = "score" | "block" +export const ModerationMode = Schema.Literals(["score", "block"]).annotate({ "identifier": "ModerationMode" }) +export type StopConfiguration = string | null | ReadonlyArray | null +export const StopConfiguration = Schema.Union([ + Schema.Union([ + Schema.Union([Schema.String, Schema.Null]), + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(4).annotate({ "expected": "a value with a length of at most 4" })) ], { mode: "oneOf" }).annotate({ "description": - "Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for all embedding models), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. In addition to the per-input token limit, all embedding models enforce a maximum of 300,000 tokens summed across all inputs in a single request.\n" + "Not supported with latest reasoning models `o3` and `o4-mini`.\n\nUp to 4 sequences where the API will stop generating further tokens. The\nreturned text will not contain the stop sequence.\n" }), - "model": Schema.Union([ - Schema.String, - Schema.Literals(["text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large"]) - ]).annotate({ + Schema.Null +]).annotate({ "identifier": "StopConfiguration" }) +export type ChatCompletionStreamOptions = { + readonly "include_usage"?: boolean + readonly "include_obfuscation"?: boolean +} | null +export const ChatCompletionStreamOptions = Schema.Union([ + Schema.Struct({ + "include_usage": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "If set, an additional chunk will be streamed before the `data: [DONE]`\nmessage. The `usage` field on this chunk shows the token usage statistics\nfor the entire request, and the `choices` field will always be an empty\narray.\n\nAll other chunks will also include a `usage` field, but with a null\nvalue. **NOTE:** If the stream is interrupted, you may not receive the\nfinal usage chunk which contains the total token usage for the request.\n" + })), + "include_obfuscation": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "When true, stream obfuscation will be enabled. Stream obfuscation adds\nrandom characters to an `obfuscation` field on streaming delta events to\nnormalize payload sizes as a mitigation to certain side-channel attacks.\nThese obfuscation fields are included by default, but add a small amount\nof overhead to the data stream. You can set `include_obfuscation` to\nfalse to optimize for bandwidth if you trust the network links between\nyour application and the OpenAI API.\n" + })) + }).annotate({ "description": "Options for streaming response. Only set this when you set `stream: true`.\n" }), + Schema.Null +]).annotate({ "identifier": "ChatCompletionStreamOptions" }) +export type CustomToolChatCompletions = { + readonly "type": "custom" + readonly "custom": { + readonly "name": string + readonly "description"?: string + readonly "format"?: { readonly "type": "text" } | { + readonly "type": "grammar" + readonly "grammar": { readonly "definition": string; readonly "syntax": "lark" | "regex" } + } + } +} +export const CustomToolChatCompletions = Schema.Struct({ + "type": Schema.Literal("custom").annotate({ "description": "The type of the custom tool. Always `custom`." }), + "custom": Schema.Struct({ + "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.\n" + }) + ), + "format": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("text").annotate({ "description": "Unconstrained text format. Always `text`." }) + }).annotate({ "title": "Text format", "description": "Unconstrained free-form text." }), + Schema.Struct({ + "type": Schema.Literal("grammar").annotate({ "description": "Grammar format. Always `grammar`." }), + "grammar": Schema.Struct({ + "definition": Schema.String.annotate({ "description": "The grammar definition." }), + "syntax": Schema.Literals(["lark", "regex"]).annotate({ + "description": "The syntax of the grammar definition. One of `lark` or `regex`." + }) + }).annotate({ "title": "Grammar format", "description": "Your chosen grammar." }) + }).annotate({ "title": "Grammar format", "description": "A grammar defined by the user." }) + ], { mode: "oneOf" }).annotate({ + "description": "The input format for the custom tool. Default is unconstrained text.\n" + }) + ) + }).annotate({ "title": "Custom tool properties", "description": "Properties of the custom tool.\n" }) +}).annotate({ + "title": "Custom tool", + "description": "A custom tool that processes input using a specified format.\n", + "identifier": "CustomToolChatCompletions" +}) +export type ChatCompletionAllowedTools = { readonly "mode": "auto" | "required"; readonly "tools": ReadonlyArray<{}> } +export const ChatCompletionAllowedTools = Schema.Struct({ + "mode": Schema.Literals(["auto", "required"]).annotate({ "description": - "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" + "Constrains the tools available to the model to a pre-defined set.\n\n`auto` allows the model to pick from among the allowed tools and generate a\nmessage.\n\n`required` requires the model to call one or more of the allowed tools.\n" }), - "encoding_format": Schema.optionalKey( - Schema.Literals(["float", "base64"]).annotate({ - "description": - "The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/)." + "tools": Schema.Array( + Schema.Struct({}).annotate({ "description": "A tool definition that the model should be allowed to call.\n" }) + ).annotate({ + "description": + "A list of tool definitions that the model should be allowed to call.\n\nFor the Chat Completions API, the list of tool definitions might look like:\n```json\n[\n { \"type\": \"function\", \"function\": { \"name\": \"get_weather\" } },\n { \"type\": \"function\", \"function\": { \"name\": \"get_time\" } }\n]\n```\n" + }) +}).annotate({ + "title": "Allowed tools", + "description": "Constrains the tools available to the model to a pre-defined set.\n", + "identifier": "ChatCompletionAllowedTools" +}) +export type ChatCompletionNamedToolChoice = { + readonly "type": "function" + readonly "function": { readonly "name": string } +} +export const ChatCompletionNamedToolChoice = Schema.Struct({ + "type": Schema.Literal("function").annotate({ + "description": "For function calling, the type is always `function`." + }), + "function": Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) }) +}).annotate({ + "title": "Function tool choice", + "description": "Specifies a tool the model should use. Use to force the model to call a specific function.", + "identifier": "ChatCompletionNamedToolChoice" +}) +export type ChatCompletionNamedToolChoiceCustom = { + readonly "type": "custom" + readonly "custom": { readonly "name": string } +} +export const ChatCompletionNamedToolChoiceCustom = Schema.Struct({ + "type": Schema.Literal("custom").annotate({ "description": "For custom tool calling, the type is always `custom`." }), + "custom": Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the custom tool to call." }) + }) +}).annotate({ + "title": "Custom tool choice", + "description": "Specifies a tool the model should use. Use to force the model to call a specific custom tool.", + "identifier": "ChatCompletionNamedToolChoiceCustom" +}) +export type ParallelToolCalls = boolean +export const ParallelToolCalls = Schema.Boolean.annotate({ + "description": + "Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.", + "identifier": "ParallelToolCalls" +}) +export type ChatCompletionFunctionCallOption = { readonly "name": string } +export const ChatCompletionFunctionCallOption = Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the function to call." }) +}).annotate({ + "description": + "Specifying a particular function via `{\"name\": \"my_function\"}` forces the model to call that function.\n", + "identifier": "ChatCompletionFunctionCallOption" +}) +export type ChatCompletionMessageToolCallChunk = { + readonly "index": number + readonly "id"?: string + readonly "type"?: "function" + readonly "function"?: { readonly "name"?: string; readonly "arguments"?: string } +} +export const ChatCompletionMessageToolCallChunk = Schema.Struct({ + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the tool call." })), + "type": Schema.optionalKey( + Schema.Literal("function").annotate({ + "description": "The type of the tool. Currently, only `function` is supported." }) ), - "dimensions": Schema.optionalKey( - Schema.Number.annotate({ + "function": Schema.optionalKey(Schema.Struct({ + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function to call." })), + "arguments": Schema.optionalKey(Schema.String.annotate({ "description": - "The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)) + "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + })) + })) +}).annotate({ "identifier": "ChatCompletionMessageToolCallChunk" }) +export type ChatCompletionDeleted = { + readonly "object": "chat.completion.deleted" + readonly "id": string + readonly "deleted": boolean +} +export const ChatCompletionDeleted = Schema.Struct({ + "object": Schema.Literal("chat.completion.deleted").annotate({ "description": "The type of object being deleted." }), + "id": Schema.String.annotate({ "description": "The ID of the chat completion that was deleted." }), + "deleted": Schema.Boolean.annotate({ "description": "Whether the chat completion was deleted." }) +}).annotate({ "identifier": "ChatCompletionDeleted" }) +export type ContainerResource = { + readonly "id": string + readonly "object": string + readonly "name": string + readonly "created_at": number + readonly "status": string + readonly "last_active_at"?: number + readonly "expires_after"?: { readonly "anchor"?: "last_active_at"; readonly "minutes"?: number } + readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g" + readonly "network_policy"?: { + readonly "type": "allowlist" | "disabled" + readonly "allowed_domains"?: ReadonlyArray + } +} +export const ContainerResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique identifier for the container." }), + "object": Schema.String.annotate({ "description": "The type of this object." }), + "name": Schema.String.annotate({ "description": "Name of the container." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the container was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "status": Schema.String.annotate({ "description": "Status of the container (e.g., active, deleted)." }), + "last_active_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the container was last active.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "user": Schema.optionalKey( - Schema.String.annotate({ + "expires_after": Schema.optionalKey( + Schema.Struct({ + "anchor": Schema.optionalKey( + Schema.Literal("last_active_at").annotate({ "description": "The reference point for the expiration." }) + ), + "minutes": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The number of minutes after the anchor before the container expires." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).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" + "The container will expire after this time period.\nThe anchor is the reference point for the expiration.\nThe minutes is the number of minutes after the anchor before the container expires.\n" + }) + ), + "memory_limit": Schema.optionalKey( + Schema.Literals(["1g", "4g", "16g", "64g"]).annotate({ + "description": "The memory limit configured for the container." }) + ), + "network_policy": Schema.optionalKey( + Schema.Struct({ + "type": Schema.Literals(["allowlist", "disabled"]).annotate({ "description": "The network policy mode." }), + "allowed_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "Allowed outbound domains when `type` is `allowlist`." }) + ) + }).annotate({ "description": "Network access policy for the container." }) ) -}) -export type CreateFineTuningCheckpointPermissionRequest = { readonly "project_ids": ReadonlyArray } -export const CreateFineTuningCheckpointPermissionRequest = Schema.Struct({ - "project_ids": Schema.Array(Schema.String).annotate({ "description": "The project identifiers to grant access to." }) -}) -export type CreateGroupBody = { readonly "name": string } -export const CreateGroupBody = Schema.Struct({ - "name": Schema.String.annotate({ "description": "Human readable name for the group." }).check(Schema.isMinLength(1)) - .check(Schema.isMaxLength(255)) -}).annotate({ "description": "Request payload for creating a new group in the organization." }) -export type CreateGroupUserBody = { readonly "user_id": string } -export const CreateGroupUserBody = Schema.Struct({ - "user_id": Schema.String.annotate({ "description": "Identifier of the user to add to the group." }) -}).annotate({ "description": "Request payload for adding a user to a group." }) -export type CreateImageVariationRequest = { - readonly "image": string - readonly "model"?: string | "dall-e-2" | null - readonly "n"?: number - readonly "response_format"?: "url" | "b64_json" | null - readonly "size"?: "256x256" | "512x512" | "1024x1024" | null - readonly "user"?: string +}).annotate({ "title": "The container object", "identifier": "ContainerResource" }) +export type SkillReferenceParam = { + readonly "type": "skill_reference" + readonly "skill_id": string + readonly "version"?: string } -export const CreateImageVariationRequest = Schema.Struct({ - "image": Schema.String.annotate({ - "description": - "The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.", - "format": "binary" +export const SkillReferenceParam = Schema.Struct({ + "type": Schema.Literal("skill_reference").annotate({ + "description": "References a skill created with the /v1/skills endpoint." }), - "model": Schema.optionalKey( - Schema.Union([ - Schema.Union([Schema.String, Schema.Literal("dall-e-2")]).annotate({ - "description": "The model to use for image generation. Only `dall-e-2` is supported at this time." - }), - Schema.Null - ]) - ), - "n": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(10)], { - "description": "The number of images to generate. Must be between 1 and 10." - }) - ) - ]) + "skill_id": Schema.String.annotate({ "description": "The ID of the referenced skill." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "version": Schema.optionalKey( + Schema.String.annotate({ + "description": "Optional skill version. Use a positive integer or 'latest'. Omit for default." + }) + ) +}).annotate({ "identifier": "SkillReferenceParam" }) +export type InlineSkillSourceParam = { + readonly "type": "base64" + readonly "media_type": "application/zip" + readonly "data": string +} +export const InlineSkillSourceParam = Schema.Struct({ + "type": Schema.Literal("base64").annotate({ + "description": "The type of the inline skill source. Must be `base64`." + }), + "media_type": Schema.Literal("application/zip").annotate({ + "description": "The media type of the inline skill payload. Must be `application/zip`." + }), + "data": Schema.String.annotate({ "description": "Base64-encoded skill zip bundle." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(70254592).annotate({ "expected": "a value with a length of at most 70254592" })) +}).annotate({ "description": "Inline skill payload", "identifier": "InlineSkillSourceParam" }) +export type ContainerNetworkPolicyDisabledParam = { readonly "type": "disabled" } +export const ContainerNetworkPolicyDisabledParam = Schema.Struct({ + "type": Schema.Literal("disabled").annotate({ "description": "Disable outbound network access. Always `disabled`." }) +}).annotate({ "identifier": "ContainerNetworkPolicyDisabledParam" }) +export type ContainerNetworkPolicyDomainSecretParam = { + readonly "domain": string + readonly "name": string + readonly "value": string +} +export const ContainerNetworkPolicyDomainSecretParam = Schema.Struct({ + "domain": Schema.String.annotate({ "description": "The domain associated with the secret." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), - "response_format": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["url", "b64_json"]).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." - }), - Schema.Union([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." - }) - ]) + "name": Schema.String.annotate({ "description": "The name of the secret to inject for the domain." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), - "size": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["256x256", "512x512", "1024x1024"]).annotate({ - "description": "The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`." - }), - Schema.Union([Schema.Null]).annotate({ - "description": "The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`." - }) - ]) + "value": Schema.String.annotate({ "description": "The secret value to inject for the domain." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })) +}).annotate({ "identifier": "ContainerNetworkPolicyDomainSecretParam" }) +export type ContainerFileResource = { + readonly "id": string + readonly "object": string + readonly "container_id": string + readonly "created_at": number + readonly "bytes": number + readonly "path": string + readonly "source": string +} +export const ContainerFileResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique identifier for the file." }), + "object": Schema.String.annotate({ "description": "The type of this object (`container.file`)." }), + "container_id": Schema.String.annotate({ "description": "The container this file belongs to." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the file was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "bytes": Schema.Number.annotate({ "description": "Size of the file in bytes." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "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" - }) + "path": Schema.String.annotate({ "description": "Path of the file in the container." }), + "source": Schema.String.annotate({ "description": "Source of the file (e.g., `user`, `assistant`)." }) +}).annotate({ "title": "The container file object", "identifier": "ContainerFileResource" }) +export type CreateContainerFileBody = { readonly "file_id"?: string; readonly "file"?: string } +export const CreateContainerFileBody = Schema.Struct({ + "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "Name of the file to create." })), + "file": Schema.optionalKey( + Schema.String.annotate({ "description": "The File object (not file name) to be uploaded.\n", "format": "binary" }) ) +}).annotate({ "identifier": "CreateContainerFileBody" }) +export type IncludeEnum = + | "file_search_call.results" + | "web_search_call.results" + | "web_search_call.action.sources" + | "message.input_image.image_url" + | "computer_call_output.output.image_url" + | "code_interpreter_call.outputs" + | "reasoning.encrypted_content" + | "message.output_text.logprobs" +export const IncludeEnum = Schema.Literals([ + "file_search_call.results", + "web_search_call.results", + "web_search_call.action.sources", + "message.input_image.image_url", + "computer_call_output.output.image_url", + "code_interpreter_call.outputs", + "reasoning.encrypted_content", + "message.output_text.logprobs" +]).annotate({ + "description": + "Specify additional output data to include in the model response. Currently supported values are:\n- `web_search_call.results`: Include the search results of the web search tool call.\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).", + "identifier": "IncludeEnum" +}) +export type MessageStatus = "in_progress" | "completed" | "incomplete" +export const MessageStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "MessageStatus" +}) +export type MessageRole = + | "unknown" + | "user" + | "assistant" + | "system" + | "critic" + | "discriminator" + | "developer" + | "tool" +export const MessageRole = Schema.Literals([ + "unknown", + "user", + "assistant", + "system", + "critic", + "discriminator", + "developer", + "tool" +]).annotate({ "identifier": "MessageRole" }) +export type PromptCacheBreakpointConfig = { readonly "mode": "explicit" } +export const PromptCacheBreakpointConfig = Schema.Struct({ + "mode": Schema.Literal("explicit").annotate({ "description": "The breakpoint mode. Always `explicit`." }) +}).annotate({ + "title": "Prompt cache breakpoint", + "description": + "Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.", + "identifier": "PromptCacheBreakpointConfig" }) -export type CreateModerationRequest = { - readonly "input": - | string - | ReadonlyArray - | ReadonlyArray< - { readonly "type": "image_url"; readonly "image_url": { readonly "url": string } } | { - readonly "type": "text" - readonly "text": string - } - > - readonly "model"?: - | string - | "omni-moderation-latest" - | "omni-moderation-2024-09-26" - | "text-moderation-latest" - | "text-moderation-stable" +export type FileCitationBody = { + readonly "type": "file_citation" + readonly "file_id": string + readonly "index": number + readonly "filename": string } -export const CreateModerationRequest = Schema.Struct({ - "input": Schema.Union([ - Schema.String.annotate({ "description": "A string of text to classify for moderation." }), - Schema.Array(Schema.String).annotate({ "description": "An array of strings to classify for moderation." }), - Schema.Array(Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("image_url").annotate({ "description": "Always `image_url`." }), - "image_url": Schema.Struct({ - "url": Schema.String.annotate({ - "description": "Either a URL of the image or the base64 encoded image data.", - "format": "uri" - }) - }).annotate({ "description": "Contains either an image URL or a data URL for a base64 encoded image." }) - }).annotate({ "description": "An object describing an image to classify." }), - Schema.Struct({ - "type": Schema.Literal("text").annotate({ "description": "Always `text`." }), - "text": Schema.String.annotate({ "description": "A string of text to classify." }) - }).annotate({ "description": "An object describing text to classify." }) - ], { mode: "oneOf" })).annotate({ "description": "An array of multi-modal inputs to the moderation model." }) - ], { mode: "oneOf" }).annotate({ - "description": - "Input (or inputs) to classify. Can be a single string, an array of strings, or\nan array of multi-modal input objects similar to other models.\n" +export const FileCitationBody = Schema.Struct({ + "type": Schema.Literal("file_citation").annotate({ + "description": "The type of the file citation. Always `file_citation`." }), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "omni-moderation-latest", - "omni-moderation-2024-09-26", - "text-moderation-latest", - "text-moderation-stable" - ]) - ]).annotate({ - "description": - "The content moderation model you would like to use. Learn more in\n[the moderation guide](/docs/guides/moderation), and learn about\navailable models [here](/docs/models#moderation).\n" - }) + "file_id": Schema.String.annotate({ "description": "The ID of the file." }), + "index": Schema.Number.annotate({ "description": "The index of the file in the list of files." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "filename": Schema.String.annotate({ "description": "The filename of the file cited." }) +}).annotate({ "title": "File citation", "description": "A citation to a file.", "identifier": "FileCitationBody" }) +export type UrlCitationBody = { + readonly "type": "url_citation" + readonly "url": string + readonly "start_index": number + readonly "end_index": number + readonly "title": string +} +export const UrlCitationBody = Schema.Struct({ + "type": Schema.Literal("url_citation").annotate({ + "description": "The type of the URL citation. Always `url_citation`." + }), + "url": Schema.String.annotate({ "description": "The URL of the web resource.", "format": "uri" }), + "start_index": Schema.Number.annotate({ + "description": "The index of the first character of the URL citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_index": Schema.Number.annotate({ + "description": "The index of the last character of the URL citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "title": Schema.String.annotate({ "description": "The title of the web resource." }) +}).annotate({ + "title": "URL citation", + "description": "A citation for a web resource used to generate a model response.", + "identifier": "UrlCitationBody" +}) +export type ContainerFileCitationBody = { + readonly "type": "container_file_citation" + readonly "container_id": string + readonly "file_id": string + readonly "start_index": number + readonly "end_index": number + readonly "filename": string +} +export const ContainerFileCitationBody = Schema.Struct({ + "type": Schema.Literal("container_file_citation").annotate({ + "description": "The type of the container file citation. Always `container_file_citation`." + }), + "container_id": Schema.String.annotate({ "description": "The ID of the container file." }), + "file_id": Schema.String.annotate({ "description": "The ID of the file." }), + "start_index": Schema.Number.annotate({ + "description": "The index of the first character of the container file citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_index": Schema.Number.annotate({ + "description": "The index of the last character of the container file citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "filename": Schema.String.annotate({ "description": "The filename of the container file cited." }) +}).annotate({ + "title": "Container file citation", + "description": "A citation for a container file used to generate a model response.", + "identifier": "ContainerFileCitationBody" +}) +export type FilePath = { readonly "type": "file_path"; readonly "file_id": string; readonly "index": number } +export const FilePath = Schema.Struct({ + "type": Schema.Literal("file_path").annotate({ "description": "The type of the file path. Always `file_path`.\n" }), + "file_id": Schema.String.annotate({ "description": "The ID of the file.\n" }), + "index": Schema.Number.annotate({ "description": "The index of the file in the list of files.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) +}).annotate({ "title": "File path", "description": "A path to a file.\n", "identifier": "FilePath" }) +export type TopLogProb = { + readonly "token": string + readonly "logprob": number + readonly "bytes": ReadonlyArray +} +export const TopLogProb = Schema.Struct({ + "token": Schema.String, + "logprob": Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) +}).annotate({ + "title": "Top log probability", + "description": "The top log probability of a token.", + "identifier": "TopLogProb" }) -export type CreateModerationResponse = { +export type TextContent = { readonly "type": "text"; readonly "text": string } +export const TextContent = Schema.Struct({ "type": Schema.Literal("text"), "text": Schema.String }).annotate({ + "title": "Text Content", + "description": "A text content.", + "identifier": "TextContent" +}) +export type SummaryTextContent = { readonly "type": "summary_text"; readonly "text": string } +export const SummaryTextContent = Schema.Struct({ + "type": Schema.Literal("summary_text").annotate({ "description": "The type of the object. Always `summary_text`." }), + "text": Schema.String.annotate({ "description": "A summary of the reasoning output from the model so far." }) +}).annotate({ + "title": "Summary text", + "description": "A summary text from the model.", + "identifier": "SummaryTextContent" +}) +export type ReasoningTextContent = { readonly "type": "reasoning_text"; readonly "text": string } +export const ReasoningTextContent = Schema.Struct({ + "type": Schema.Literal("reasoning_text").annotate({ + "description": "The type of the reasoning text. Always `reasoning_text`." + }), + "text": Schema.String.annotate({ "description": "The reasoning text from the model." }) +}).annotate({ + "title": "Reasoning text", + "description": "Reasoning text from the model.", + "identifier": "ReasoningTextContent" +}) +export type RefusalContent = { readonly "type": "refusal"; readonly "refusal": string } +export const RefusalContent = Schema.Struct({ + "type": Schema.Literal("refusal").annotate({ "description": "The type of the refusal. Always `refusal`." }), + "refusal": Schema.String.annotate({ "description": "The refusal explanation from the model." }) +}).annotate({ "title": "Refusal", "description": "A refusal from the model.", "identifier": "RefusalContent" }) +export type ImageDetail = "low" | "high" | "auto" | "original" +export const ImageDetail = Schema.Literals(["low", "high", "auto", "original"]).annotate({ + "identifier": "ImageDetail" +}) +export type FileInputDetail = "auto" | "low" | "high" +export const FileInputDetail = Schema.Literals(["auto", "low", "high"]).annotate({ "identifier": "FileInputDetail" }) +export type MessagePhase_2 = "commentary" | "final_answer" +export const MessagePhase_2 = Schema.Literals(["commentary", "final_answer"]).annotate({ + "identifier": "MessagePhase-2" +}) +export type DirectToolCallCaller = { readonly "type": "direct" } +export const DirectToolCallCaller = Schema.Struct({ "type": Schema.Literal("direct") }).annotate({ + "identifier": "DirectToolCallCaller" +}) +export type ProgramToolCallCaller = { readonly "type": "program"; readonly "caller_id": string } +export const ProgramToolCallCaller = Schema.Struct({ + "type": Schema.Literal("program"), + "caller_id": Schema.String.annotate({ + "description": "The call ID of the program item that produced this tool call." + }) +}).annotate({ "identifier": "ProgramToolCallCaller" }) +export type DirectToolCallCallerParam = { readonly "type": "direct" } +export const DirectToolCallCallerParam = Schema.Struct({ + "type": Schema.Literal("direct").annotate({ "description": "The caller type. Always `direct`." }) +}).annotate({ "identifier": "DirectToolCallCallerParam" }) +export type ProgramToolCallCallerParam = { readonly "type": "program"; readonly "caller_id": string } +export const ProgramToolCallCallerParam = Schema.Struct({ + "type": Schema.Literal("program").annotate({ "description": "The caller type. Always `program`." }), + "caller_id": Schema.String.annotate({ + "description": "The call ID of the program item that produced this tool call." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ) +}).annotate({ "identifier": "ProgramToolCallCallerParam" }) +export type VectorStoreFileAttributes = {} | null +export const VectorStoreFileAttributes = 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. Keys are strings\nwith a maximum length of 64 characters. Values are strings with a maximum\nlength of 512 characters, booleans, or numbers.\n" + }).check(Schema.isMaxProperties(16).annotate({ "expected": "a value with at most 16 entries" })).check( + Schema.isPropertyNames( + Schema.String.check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })) + ).annotate({ "expected": "an object with property names matching the schema" }) + ), + Schema.Null +]).annotate({ "identifier": "VectorStoreFileAttributes" }) +export type WebSearchToolCall = { readonly "id": string - readonly "model": string - readonly "results": ReadonlyArray< - { - readonly "flagged": boolean - readonly "categories": { - readonly "hate": boolean - readonly "hate/threatening": boolean - readonly "harassment": boolean - readonly "harassment/threatening": boolean - readonly "illicit": boolean | null - readonly "illicit/violent": boolean | null - readonly "self-harm": boolean - readonly "self-harm/intent": boolean - readonly "self-harm/instructions": boolean - readonly "sexual": boolean - readonly "sexual/minors": boolean - readonly "violence": boolean - readonly "violence/graphic": boolean - } - readonly "category_scores": { - readonly "hate": number - readonly "hate/threatening": number - readonly "harassment": number - readonly "harassment/threatening": number - readonly "illicit": number - readonly "illicit/violent": number - readonly "self-harm": number - readonly "self-harm/intent": number - readonly "self-harm/instructions": number - readonly "sexual": number - readonly "sexual/minors": number - readonly "violence": number - readonly "violence/graphic": number - } - readonly "category_applied_input_types": { - readonly "hate": ReadonlyArray<"text"> - readonly "hate/threatening": ReadonlyArray<"text"> - readonly "harassment": ReadonlyArray<"text"> - readonly "harassment/threatening": ReadonlyArray<"text"> - readonly "illicit": ReadonlyArray<"text"> - readonly "illicit/violent": ReadonlyArray<"text"> - readonly "self-harm": ReadonlyArray<"text" | "image"> - readonly "self-harm/intent": ReadonlyArray<"text" | "image"> - readonly "self-harm/instructions": ReadonlyArray<"text" | "image"> - readonly "sexual": ReadonlyArray<"text" | "image"> - readonly "sexual/minors": ReadonlyArray<"text"> - readonly "violence": ReadonlyArray<"text" | "image"> - readonly "violence/graphic": ReadonlyArray<"text" | "image"> - } + readonly "type": "web_search_call" + readonly "status": "in_progress" | "searching" | "completed" | "failed" + readonly "action": + | { + readonly "type": "search" + readonly "query"?: string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> } - > -} -export const CreateModerationResponse = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique identifier for the moderation request." }), - "model": Schema.String.annotate({ "description": "The model used to generate the moderation results." }), - "results": Schema.Array(Schema.Struct({ - "flagged": Schema.Boolean.annotate({ "description": "Whether any of the below categories are flagged." }), - "categories": Schema.Struct({ - "hate": Schema.Boolean.annotate({ - "description": - "Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment." - }), - "hate/threatening": Schema.Boolean.annotate({ - "description": - "Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste." - }), - "harassment": Schema.Boolean.annotate({ - "description": "Content that expresses, incites, or promotes harassing language towards any target." - }), - "harassment/threatening": Schema.Boolean.annotate({ - "description": "Harassment content that also includes violence or serious harm towards any target." - }), - "illicit": Schema.Union([ - Schema.Boolean.annotate({ - "description": - "Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, \"how to shoplift\" would fit this category." - }), - Schema.Null - ]), - "illicit/violent": Schema.Union([ - Schema.Boolean.annotate({ - "description": - "Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon." - }), - Schema.Null - ]), - "self-harm": Schema.Boolean.annotate({ - "description": - "Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders." - }), - "self-harm/intent": Schema.Boolean.annotate({ - "description": - "Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders." - }), - "self-harm/instructions": Schema.Boolean.annotate({ - "description": - "Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts." - }), - "sexual": Schema.Boolean.annotate({ - "description": - "Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness)." - }), - "sexual/minors": Schema.Boolean.annotate({ - "description": "Sexual content that includes an individual who is under 18 years old." - }), - "violence": Schema.Boolean.annotate({ - "description": "Content that depicts death, violence, or physical injury." - }), - "violence/graphic": Schema.Boolean.annotate({ - "description": "Content that depicts death, violence, or physical injury in graphic detail." - }) - }).annotate({ "description": "A list of the categories, and whether they are flagged or not." }), - "category_scores": Schema.Struct({ - "hate": Schema.Number.annotate({ "description": "The score for the category 'hate'." }).check(Schema.isFinite()), - "hate/threatening": Schema.Number.annotate({ "description": "The score for the category 'hate/threatening'." }) - .check(Schema.isFinite()), - "harassment": Schema.Number.annotate({ "description": "The score for the category 'harassment'." }).check( - Schema.isFinite() - ), - "harassment/threatening": Schema.Number.annotate({ - "description": "The score for the category 'harassment/threatening'." - }).check(Schema.isFinite()), - "illicit": Schema.Number.annotate({ "description": "The score for the category 'illicit'." }).check( - Schema.isFinite() - ), - "illicit/violent": Schema.Number.annotate({ "description": "The score for the category 'illicit/violent'." }) - .check(Schema.isFinite()), - "self-harm": Schema.Number.annotate({ "description": "The score for the category 'self-harm'." }).check( - Schema.isFinite() - ), - "self-harm/intent": Schema.Number.annotate({ "description": "The score for the category 'self-harm/intent'." }) - .check(Schema.isFinite()), - "self-harm/instructions": Schema.Number.annotate({ - "description": "The score for the category 'self-harm/instructions'." - }).check(Schema.isFinite()), - "sexual": Schema.Number.annotate({ "description": "The score for the category 'sexual'." }).check( - Schema.isFinite() - ), - "sexual/minors": Schema.Number.annotate({ "description": "The score for the category 'sexual/minors'." }).check( - Schema.isFinite() - ), - "violence": Schema.Number.annotate({ "description": "The score for the category 'violence'." }).check( - Schema.isFinite() - ), - "violence/graphic": Schema.Number.annotate({ "description": "The score for the category 'violence/graphic'." }) - .check(Schema.isFinite()) - }).annotate({ "description": "A list of the categories along with their scores as predicted by model." }), - "category_applied_input_types": Schema.Struct({ - "hate": Schema.Array(Schema.Literal("text")).annotate({ - "description": "The applied input type(s) for the category 'hate'." - }), - "hate/threatening": Schema.Array(Schema.Literal("text")).annotate({ - "description": "The applied input type(s) for the category 'hate/threatening'." - }), - "harassment": Schema.Array(Schema.Literal("text")).annotate({ - "description": "The applied input type(s) for the category 'harassment'." - }), - "harassment/threatening": Schema.Array(Schema.Literal("text")).annotate({ - "description": "The applied input type(s) for the category 'harassment/threatening'." - }), - "illicit": Schema.Array(Schema.Literal("text")).annotate({ - "description": "The applied input type(s) for the category 'illicit'." - }), - "illicit/violent": Schema.Array(Schema.Literal("text")).annotate({ - "description": "The applied input type(s) for the category 'illicit/violent'." - }), - "self-harm": Schema.Array(Schema.Literals(["text", "image"])).annotate({ - "description": "The applied input type(s) for the category 'self-harm'." - }), - "self-harm/intent": Schema.Array(Schema.Literals(["text", "image"])).annotate({ - "description": "The applied input type(s) for the category 'self-harm/intent'." - }), - "self-harm/instructions": Schema.Array(Schema.Literals(["text", "image"])).annotate({ - "description": "The applied input type(s) for the category 'self-harm/instructions'." - }), - "sexual": Schema.Array(Schema.Literals(["text", "image"])).annotate({ - "description": "The applied input type(s) for the category 'sexual'." - }), - "sexual/minors": Schema.Array(Schema.Literal("text")).annotate({ - "description": "The applied input type(s) for the category 'sexual/minors'." - }), - "violence": Schema.Array(Schema.Literals(["text", "image"])).annotate({ - "description": "The applied input type(s) for the category 'violence'." - }), - "violence/graphic": Schema.Array(Schema.Literals(["text", "image"])).annotate({ - "description": "The applied input type(s) for the category 'violence/graphic'." - }) - }).annotate({ "description": "A list of the categories along with the input type(s) that the score applies to." }) - })).annotate({ "description": "A list of moderation objects." }) -}).annotate({ "description": "Represents if a given text input is potentially harmful." }) -export type CreateTranscriptionResponseJson = { - readonly "text": string - readonly "logprobs"?: ReadonlyArray< - { readonly "token"?: string; readonly "logprob"?: number; readonly "bytes"?: ReadonlyArray } - > - readonly "usage"?: { - readonly "type": "tokens" - readonly "input_tokens": number - readonly "input_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number } - readonly "output_tokens": number - readonly "total_tokens": number - } | { readonly "type": "duration"; readonly "seconds": number } + | { readonly "type": "open_page"; readonly "url"?: string | null } + | { readonly "type": "find_in_page"; readonly "url": string; readonly "pattern": string } } -export const CreateTranscriptionResponseJson = Schema.Struct({ - "text": Schema.String.annotate({ "description": "The transcribed text." }), - "logprobs": Schema.optionalKey( - Schema.Array(Schema.Struct({ - "token": Schema.optionalKey(Schema.String.annotate({ "description": "The token in the transcription." })), - "logprob": Schema.optionalKey( - Schema.Number.annotate({ "description": "The log probability of the token." }).check(Schema.isFinite()) +export const WebSearchToolCall = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the web search tool call.\n" }), + "type": Schema.Literal("web_search_call").annotate({ + "description": "The type of the web search tool call. Always `web_search_call`.\n" + }), + "status": Schema.Literals(["in_progress", "searching", "completed", "failed"]).annotate({ + "description": "The status of the web search tool call.\n" + }), + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search").annotate({ "description": "The action type.\n" }), + "query": Schema.optionalKey(Schema.String.annotate({ "description": "The search query.\n" })), + "queries": Schema.optionalKey( + Schema.Array(Schema.String.annotate({ "description": "A search query.\n" })).annotate({ + "title": "Search queries", + "description": "The search queries.\n" + }) ), - "bytes": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isFinite())).annotate({ "description": "The bytes of the token." }) + "sources": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "type": Schema.Literal("url").annotate({ "description": "The type of source. Always `url`.\n" }), + "url": Schema.String.annotate({ "description": "The URL of the source.\n", "format": "uri" }) + }).annotate({ "title": "Web search source", "description": "A source used in the search.\n" }) + ).annotate({ "title": "Web search sources", "description": "The sources used in the search.\n" }) ) - })).annotate({ + }).annotate({ + "title": "Search action", "description": - "The log probabilities of the tokens in the transcription. Only returned with the models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added to the `include` array.\n" - }) - ), - "usage": Schema.optionalKey(Schema.Union([ + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }), Schema.Struct({ - "type": Schema.Literal("tokens").annotate({ - "description": "The type of the usage object. Always `tokens` for this variant." - }), - "input_tokens": Schema.Number.annotate({ "description": "Number of input tokens billed for this request." }) - .check(Schema.isInt()), - "input_token_details": Schema.optionalKey( - Schema.Struct({ - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of text tokens billed for this request." }).check( - Schema.isInt() - ) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of audio tokens billed for this request." }).check( - Schema.isInt() - ) - ) - }).annotate({ "description": "Details about the input tokens billed for this request." }) - ), - "output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check( - Schema.isInt() - ), - "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check( - Schema.isInt() + "type": Schema.Literal("open_page").annotate({ "description": "The action type.\n" }), + "url": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "format": "uri" }), Schema.Null]).annotate({ + "description": "The URL opened by the model.\n" + }) ) - }).annotate({ "title": "Token Usage", "description": "Token usage statistics for the request." }), + }).annotate({ + "title": "Open page action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }), Schema.Struct({ - "type": Schema.Literal("duration").annotate({ - "description": "The type of the usage object. Always `duration` for this variant." + "type": Schema.Literal("find_in_page").annotate({ "description": "The action type.\n" }), + "url": Schema.String.annotate({ + "description": "The URL of the page searched for the pattern.\n", + "format": "uri" }), - "seconds": Schema.Number.annotate({ - "description": "Duration of the input audio in seconds.", - "format": "double" - }).check(Schema.isFinite()) - }).annotate({ "title": "Duration Usage", "description": "Token usage statistics for the request." }) - ], { mode: "oneOf" })) -}).annotate({ "description": "Represents a transcription response returned by model, based on the provided input." }) -export type CreateTranslationRequest = { - readonly "file": string - readonly "model": string | "whisper-1" - readonly "prompt"?: string - readonly "response_format"?: "json" | "text" | "srt" | "verbose_json" | "vtt" - readonly "temperature"?: number + "pattern": Schema.String.annotate({ "description": "The pattern or text to search for within the page.\n" }) + }).annotate({ + "title": "Find action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }) + ], { mode: "oneOf" }) +}).annotate({ + "title": "Web search tool call", + "description": + "The results of a web search tool call. See the\n[web search guide](/docs/guides/tools-web-search) for more information.\n", + "identifier": "WebSearchToolCall" +}) +export type ImageGenToolCall = { + readonly "type": "image_generation_call" + readonly "id": string + readonly "status": "in_progress" | "completed" | "generating" | "failed" + readonly "result": string | null } -export const CreateTranslationRequest = Schema.Struct({ - "file": Schema.String.annotate({ - "description": - "The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.\n", - "format": "binary" +export const ImageGenToolCall = Schema.Struct({ + "type": Schema.Literal("image_generation_call").annotate({ + "description": "The type of the image generation call. Always `image_generation_call`.\n" }), - "model": Schema.Union([Schema.String, Schema.Literal("whisper-1")]).annotate({ - "description": - "ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.\n" + "id": Schema.String.annotate({ "description": "The unique ID of the image generation call.\n" }), + "status": Schema.Literals(["in_progress", "completed", "generating", "failed"]).annotate({ + "description": "The status of the image generation call.\n" }), - "prompt": Schema.optionalKey( - Schema.String.annotate({ - "description": - "An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should be in English.\n" - }) + "result": Schema.Union([ + Schema.String.annotate({ "description": "The generated image encoded in base64.\n" }), + Schema.Null + ]) +}).annotate({ + "title": "Image generation call", + "description": "An image generation request made by the model.\n", + "identifier": "ImageGenToolCall" +}) +export type ClickButtonType = "left" | "right" | "wheel" | "back" | "forward" +export const ClickButtonType = Schema.Literals(["left", "right", "wheel", "back", "forward"]).annotate({ + "identifier": "ClickButtonType" +}) +export type DoubleClickAction = { + readonly "type": "double_click" + readonly "x": number + readonly "y": number + readonly "keys": ReadonlyArray | null +} +export const DoubleClickAction = Schema.Struct({ + "type": Schema.Literal("double_click").annotate({ + "description": "Specifies the event type. For a double click action, this property is always set to `double_click`." + }), + "x": Schema.Number.annotate({ "description": "The x-coordinate where the double click occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "response_format": Schema.optionalKey( - Schema.Literals(["json", "text", "srt", "verbose_json", "vtt"]).annotate({ - "description": - "The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.\n" - }) + "y": Schema.Number.annotate({ "description": "The y-coordinate where the double click occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.\n" - }).check(Schema.isFinite()) + "keys": Schema.Union([ + Schema.Array(Schema.String).annotate({ "description": "The keys being held while double-clicking." }), + Schema.Null + ]) +}).annotate({ "title": "DoubleClick", "description": "A double click action.", "identifier": "DoubleClickAction" }) +export type CoordParam = { readonly "x": number; readonly "y": number } +export const CoordParam = Schema.Struct({ + "x": Schema.Number.annotate({ "description": "The x-coordinate." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "y": Schema.Number.annotate({ "description": "The y-coordinate." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) +}).annotate({ + "title": "Coordinate", + "description": "An x/y coordinate pair, e.g. `{ x: 100, y: 200 }`.", + "identifier": "CoordParam" }) -export type CreateTranslationResponseJson = { readonly "text": string } -export const CreateTranslationResponseJson = Schema.Struct({ "text": Schema.String }) -export type CreateVoiceConsentRequest = { - readonly "name": string - readonly "recording": string - readonly "language": string -} -export const CreateVoiceConsentRequest = Schema.Struct({ - "name": Schema.String.annotate({ "description": "The label to use for this consent recording." }), - "recording": Schema.String.annotate({ - "description": - "The consent audio recording file. Maximum size is 10 MiB.\n\nSupported MIME types:\n`audio/mpeg`, `audio/wav`, `audio/x-wav`, `audio/ogg`, `audio/aac`, `audio/flac`, `audio/webm`, `audio/mp4`.\n", - "format": "binary" +export type KeyPressAction = { readonly "type": "keypress"; readonly "keys": ReadonlyArray } +export const KeyPressAction = Schema.Struct({ + "type": Schema.Literal("keypress").annotate({ + "description": "Specifies the event type. For a keypress action, this property is always set to `keypress`." }), - "language": Schema.String.annotate({ - "description": "The BCP 47 language tag for the consent phrase (for example, `en-US`)." + "keys": Schema.Array( + Schema.String.annotate({ "description": "One of the keys the model is requesting to be pressed." }) + ).annotate({ + "description": + "The combination of keys the model is requesting to be pressed. This is an array of strings, each representing a key." }) +}).annotate({ + "title": "KeyPress", + "description": "A collection of keypresses the model would like to perform.", + "identifier": "KeyPressAction" }) -export type CreateVoiceRequest = { - readonly "name": string - readonly "audio_sample": string - readonly "consent": string +export type MoveParam = { + readonly "type": "move" + readonly "x": number + readonly "y": number + readonly "keys"?: ReadonlyArray | null } -export const CreateVoiceRequest = Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the new voice." }), - "audio_sample": Schema.String.annotate({ - "description": - "The sample audio recording file. Maximum size is 10 MiB.\n\nSupported MIME types:\n`audio/mpeg`, `audio/wav`, `audio/x-wav`, `audio/ogg`, `audio/aac`, `audio/flac`, `audio/webm`, `audio/mp4`.\n", - "format": "binary" +export const MoveParam = Schema.Struct({ + "type": Schema.Literal("move").annotate({ + "description": "Specifies the event type. For a move action, this property is always set to `move`." }), - "consent": Schema.String.annotate({ "description": "The consent recording ID (for example, `cons_1234`)." }) -}) -export type CustomToolCall = { - readonly "type": "custom_tool_call" - readonly "id"?: string - readonly "call_id": string - readonly "namespace"?: string - readonly "name": string - readonly "input": string + "x": Schema.Number.annotate({ "description": "The x-coordinate to move to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "y": Schema.Number.annotate({ "description": "The y-coordinate to move to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "keys": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).annotate({ "description": "The keys being held while moving the mouse." }), + Schema.Null + ]) + ) +}).annotate({ "title": "Move", "description": "A mouse move action.", "identifier": "MoveParam" }) +export type ScreenshotParam = { readonly "type": "screenshot" } +export const ScreenshotParam = Schema.Struct({ + "type": Schema.Literal("screenshot").annotate({ + "description": "Specifies the event type. For a screenshot action, this property is always set to `screenshot`." + }) +}).annotate({ "title": "Screenshot", "description": "A screenshot action.", "identifier": "ScreenshotParam" }) +export type ScrollParam = { + readonly "type": "scroll" + readonly "x": number + readonly "y": number + readonly "scroll_x": number + readonly "scroll_y": number + readonly "keys"?: ReadonlyArray | null } -export const CustomToolCall = Schema.Struct({ - "type": Schema.Literal("custom_tool_call").annotate({ - "description": "The type of the custom tool call. Always `custom_tool_call`.\n" +export const ScrollParam = Schema.Struct({ + "type": Schema.Literal("scroll").annotate({ + "description": "Specifies the event type. For a scroll action, this property is always set to `scroll`." }), - "id": Schema.optionalKey( - Schema.String.annotate({ "description": "The unique ID of the custom tool call in the OpenAI platform.\n" }) + "x": Schema.Number.annotate({ "description": "The x-coordinate where the scroll occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "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" }) + "y": Schema.Number.annotate({ "description": "The y-coordinate where the scroll occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "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" }) -export type CustomToolCallResource = { - readonly "type": "custom_tool_call" + "scroll_x": Schema.Number.annotate({ "description": "The horizontal scroll distance." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "scroll_y": Schema.Number.annotate({ "description": "The vertical scroll distance." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "keys": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).annotate({ "description": "The keys being held while scrolling." }), + Schema.Null + ]) + ) +}).annotate({ "title": "Scroll", "description": "A scroll action.", "identifier": "ScrollParam" }) +export type TypeParam = { readonly "type": "type"; readonly "text": string } +export const TypeParam = Schema.Struct({ + "type": Schema.Literal("type").annotate({ + "description": "Specifies the event type. For a type action, this property is always set to `type`." + }), + "text": Schema.String.annotate({ "description": "The text to type." }) +}).annotate({ "title": "Type", "description": "An action to type in text.", "identifier": "TypeParam" }) +export type WaitParam = { readonly "type": "wait" } +export const WaitParam = Schema.Struct({ + "type": Schema.Literal("wait").annotate({ + "description": "Specifies the event type. For a wait action, this property is always set to `wait`." + }) +}).annotate({ "title": "Wait", "description": "A wait action.", "identifier": "WaitParam" }) +export type ComputerCallSafetyCheckParam = { readonly "id": string - readonly "call_id": string - readonly "namespace"?: string - readonly "name": string - readonly "input": string - readonly "status": "in_progress" | "completed" | "incomplete" - readonly "created_by"?: string + readonly "code"?: string | null + readonly "message"?: string | null } -export const CustomToolCallResource = Schema.Struct({ - "type": Schema.Literal("custom_tool_call").annotate({ - "description": "The type of the custom tool call. Always `custom_tool_call`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the custom tool call item.\n" }), - "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" }) +export const ComputerCallSafetyCheckParam = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The ID of the pending safety check." }), + "code": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The type of the pending safety check." }), Schema.Null]) ), - "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" }), - "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "message": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "Details about the pending safety check." }), Schema.Null]) + ) +}).annotate({ + "description": "A pending safety check for the computer call.", + "identifier": "ComputerCallSafetyCheckParam" +}) +export type ComputerScreenshotImage = { + readonly "type": "computer_screenshot" + readonly "image_url"?: string + readonly "file_id"?: string +} +export const ComputerScreenshotImage = Schema.Struct({ + "type": Schema.Literal("computer_screenshot").annotate({ "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + "Specifies the event type. For a computer screenshot, this property is \nalways set to `computer_screenshot`.\n" }), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + "image_url": Schema.optionalKey( + Schema.String.annotate({ "description": "The URL of the screenshot image.", "format": "uri" }) + ), + "file_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of an uploaded file that contains the screenshot." }) ) -}).annotate({ "title": "Custom tool call", "description": "A call to a custom tool created by the model.\n" }) -export type CustomToolChatCompletions = { - readonly "type": "custom" - readonly "custom": { - readonly "name": string - readonly "description"?: string - readonly "format"?: { readonly "type": "text" } | { - readonly "type": "grammar" - readonly "grammar": { readonly "definition": string; readonly "syntax": "lark" | "regex" } - } - } +}).annotate({ + "description": "A computer screenshot image used with the computer use tool.\n", + "identifier": "ComputerScreenshotImage" +}) +export type ToolSearchExecutionType = "server" | "client" +export const ToolSearchExecutionType = Schema.Literals(["server", "client"]).annotate({ + "identifier": "ToolSearchExecutionType" +}) +export type FunctionCallStatus = "in_progress" | "completed" | "incomplete" +export const FunctionCallStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "FunctionCallStatus" +}) +export type CallableToolAllowedCaller = "direct" | "programmatic" +export const CallableToolAllowedCaller = Schema.Literals(["direct", "programmatic"]).annotate({ + "identifier": "CallableToolAllowedCaller" +}) +export type RankerVersionType = "auto" | "default-2024-11-15" +export const RankerVersionType = Schema.Literals(["auto", "default-2024-11-15"]).annotate({ + "identifier": "RankerVersionType" +}) +export type HybridSearchOptions = { readonly "embedding_weight": number; readonly "text_weight": number } +export const HybridSearchOptions = Schema.Struct({ + "embedding_weight": Schema.Number.annotate({ + "description": "The weight of the embedding in the reciprocal ranking fusion." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "text_weight": Schema.Number.annotate({ "description": "The weight of the text in the reciprocal ranking fusion." }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })) +}).annotate({ "identifier": "HybridSearchOptions" }) +export type ComparisonFilter = { + readonly "type": "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" + readonly "key": string + readonly "value": string | number | boolean | ReadonlyArray } -export const CustomToolChatCompletions = Schema.Struct({ - "type": Schema.Literal("custom").annotate({ "description": "The type of the custom tool. Always `custom`." }), - "custom": Schema.Struct({ - "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.\n" +export const ComparisonFilter = Schema.Struct({ + "type": Schema.Literals(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]).annotate({ + "description": + "Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`.\n- `eq`: equals\n- `ne`: not equal\n- `gt`: greater than\n- `gte`: greater than or equal\n- `lt`: less than\n- `lte`: less than or equal\n- `in`: in\n- `nin`: not in\n" + }), + "key": Schema.String.annotate({ "description": "The key to compare against the value." }), + "value": Schema.Union([ + Schema.String, + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Boolean, + Schema.Array( + Schema.Union( + [Schema.String, Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))], + { mode: "oneOf" } + ) + ) + ], { mode: "oneOf" }).annotate({ + "description": "The value to compare against the attribute key; supports string, number, or boolean types." + }) +}).annotate({ + "title": "Comparison Filter", + "description": + "A filter used to compare a specified attribute key to a given value using a defined comparison operation.\n", + "identifier": "ComparisonFilter" +}) +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).", + "identifier": "ComputerTool" +}) +export type ComputerEnvironment = "windows" | "mac" | "linux" | "ubuntu" | "browser" +export const ComputerEnvironment = Schema.Literals(["windows", "mac", "linux", "ubuntu", "browser"]).annotate({ + "identifier": "ComputerEnvironment" +}) +export type WebSearchApproximateLocation = { + readonly "type"?: "approximate" + readonly "country"?: string | null + readonly "region"?: string | null + readonly "city"?: string | null + readonly "timezone"?: string | null +} | null +export const WebSearchApproximateLocation = Schema.Union([ + Schema.Struct({ + "type": Schema.optionalKey( + Schema.Literal("approximate").annotate({ + "description": "The type of location approximation. Always `approximate`." }) ), - "format": Schema.optionalKey( + "country": Schema.optionalKey( Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("text").annotate({ "description": "Unconstrained text format. Always `text`." }) - }).annotate({ "title": "Text format", "description": "Unconstrained free-form text." }), - Schema.Struct({ - "type": Schema.Literal("grammar").annotate({ "description": "Grammar format. Always `grammar`." }), - "grammar": Schema.Struct({ - "definition": Schema.String.annotate({ "description": "The grammar definition." }), - "syntax": Schema.Literals(["lark", "regex"]).annotate({ - "description": "The syntax of the grammar definition. One of `lark` or `regex`." - }) - }).annotate({ "title": "Grammar format", "description": "Your chosen grammar." }) - }).annotate({ "title": "Grammar format", "description": "A grammar defined by the user." }) - ], { mode: "oneOf" }).annotate({ - "description": "The input format for the custom tool. Default is unconstrained text.\n" - }) + 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({ "title": "Custom tool properties", "description": "Properties of the custom tool.\n" }) -}).annotate({ "title": "Custom tool", "description": "A custom tool that processes input using a specified format.\n" }) -export type DeleteAssistantResponse = { - readonly "id": string - readonly "deleted": boolean - readonly "object": "assistant.deleted" -} -export const DeleteAssistantResponse = Schema.Struct({ - "id": Schema.String, - "deleted": Schema.Boolean, - "object": Schema.Literal("assistant.deleted") + }).annotate({ "title": "Web search approximate location", "description": "The approximate location of the user.\n" }), + Schema.Null +]).annotate({ "identifier": "WebSearchApproximateLocation" }) +export type MCPToolFilter = { readonly "tool_names"?: ReadonlyArray; readonly "read_only"?: boolean } +export const MCPToolFilter = Schema.Struct({ + "tool_names": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "title": "MCP allowed tools", "description": "List of allowed tool names." }) + ), + "read_only": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Indicates whether or not a tool modifies data or is read-only. If an\nMCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),\nit will match this filter.\n" + }) + ) +}).annotate({ + "title": "MCP tool filter", + "description": "A filter object to specify which tools are allowed.\n", + "identifier": "MCPToolFilter" +}) +export type ContainerMemoryLimit = "1g" | "4g" | "16g" | "64g" +export const ContainerMemoryLimit = Schema.Literals(["1g", "4g", "16g", "64g"]).annotate({ + "identifier": "ContainerMemoryLimit" +}) +export type ProgrammaticToolCallingParam = { readonly "type": "programmatic_tool_calling" } +export const ProgrammaticToolCallingParam = Schema.Struct({ + "type": Schema.Literal("programmatic_tool_calling").annotate({ + "description": "The type of the tool. Always `programmatic_tool_calling`." + }) +}).annotate({ "identifier": "ProgrammaticToolCallingParam" }) +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`.", + "identifier": "InputFidelity" }) -export type DeleteCertificateResponse = { readonly "object": "certificate.deleted"; readonly "id": string } -export const DeleteCertificateResponse = Schema.Struct({ - "object": Schema.Literal("certificate.deleted").annotate({ - "description": "The object type, must be `certificate.deleted`." - }), - "id": Schema.String.annotate({ "description": "The ID of the certificate that was deleted." }) +export type ImageGenActionEnum = "generate" | "edit" | "auto" +export const ImageGenActionEnum = Schema.Literals(["generate", "edit", "auto"]).annotate({ + "identifier": "ImageGenActionEnum" }) -export type DeleteFileResponse = { readonly "id": string; readonly "object": "file"; readonly "deleted": boolean } -export const DeleteFileResponse = Schema.Struct({ - "id": Schema.String, - "object": Schema.Literal("file"), - "deleted": Schema.Boolean +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.", + "identifier": "LocalShellToolParam" }) -export type DeleteFineTuningCheckpointPermissionResponse = { - readonly "id": string - readonly "object": "checkpoint.permission" - readonly "deleted": boolean -} -export const DeleteFineTuningCheckpointPermissionResponse = Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The ID of the fine-tuned model checkpoint permission that was deleted." - }), - "object": Schema.Literal("checkpoint.permission").annotate({ - "description": "The object type, which is always \"checkpoint.permission\"." +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." }) +}).annotate({ "identifier": "LocalSkillParam" }) +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" }), - "deleted": Schema.Boolean.annotate({ - "description": "Whether the fine-tuned model checkpoint permission was successfully deleted." - }) + "container_id": Schema.String.annotate({ "description": "The ID of the referenced container." }) +}).annotate({ "identifier": "ContainerReferenceParam" }) +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.", + "identifier": "CustomTextFormatParam" }) -export type DeleteMessageResponse = { - readonly "id": string - readonly "deleted": boolean - readonly "object": "thread.message.deleted" +export type GrammarSyntax1 = "lark" | "regex" +export const GrammarSyntax1 = Schema.Literals(["lark", "regex"]).annotate({ "identifier": "GrammarSyntax1" }) +export type EmptyModelParam = {} +export const EmptyModelParam = Schema.Struct({}).annotate({ "identifier": "EmptyModelParam" }) +export type ApproximateLocation = { + readonly "type": "approximate" + readonly "country"?: string | null + readonly "region"?: string | null + readonly "city"?: string | null + readonly "timezone"?: string | null } -export const DeleteMessageResponse = Schema.Struct({ - "id": Schema.String, - "deleted": Schema.Boolean, - "object": Schema.Literal("thread.message.deleted") +export const ApproximateLocation = 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({ "identifier": "ApproximateLocation" }) +export type SearchContextSize = "low" | "medium" | "high" +export const SearchContextSize = Schema.Literals(["low", "medium", "high"]).annotate({ + "identifier": "SearchContextSize" }) -export type DeleteModelResponse = { readonly "id": string; readonly "deleted": boolean; readonly "object": string } -export const DeleteModelResponse = Schema.Struct({ - "id": Schema.String, - "deleted": Schema.Boolean, - "object": Schema.String +export type SearchContentType = "text" | "image" +export const SearchContentType = Schema.Literals(["text", "image"]).annotate({ "identifier": "SearchContentType" }) +export type FunctionCallOutputStatusEnum = "in_progress" | "completed" | "incomplete" +export const FunctionCallOutputStatusEnum = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "FunctionCallOutputStatusEnum" }) -export type DeleteThreadResponse = { +export type Program = { + readonly "type": "program" readonly "id": string - readonly "deleted": boolean - readonly "object": "thread.deleted" -} -export const DeleteThreadResponse = Schema.Struct({ - "id": Schema.String, - "deleted": Schema.Boolean, - "object": Schema.Literal("thread.deleted") + readonly "call_id": string + readonly "code": string + readonly "fingerprint": string +} +export const Program = Schema.Struct({ + "type": Schema.Literal("program").annotate({ "description": "The type of the item. Always `program`." }), + "id": Schema.String.annotate({ "description": "The unique ID of the program item." }), + "call_id": Schema.String.annotate({ "description": "The stable call ID of the program item." }), + "code": Schema.String.annotate({ "description": "The JavaScript source executed by programmatic tool calling." }), + "fingerprint": Schema.String.annotate({ + "description": "Opaque program replay fingerprint that must be round-tripped." + }) +}).annotate({ "identifier": "Program" }) +export type ProgramOutputStatus = "completed" | "incomplete" +export const ProgramOutputStatus = Schema.Literals(["completed", "incomplete"]).annotate({ + "identifier": "ProgramOutputStatus" }) -export type DeleteVectorStoreFileResponse = { +export type CompactionBody = { + readonly "type": "compaction" readonly "id": string - readonly "deleted": boolean - readonly "object": "vector_store.file.deleted" + readonly "encrypted_content": string + readonly "created_by"?: string } -export const DeleteVectorStoreFileResponse = Schema.Struct({ - "id": Schema.String, - "deleted": Schema.Boolean, - "object": Schema.Literal("vector_store.file.deleted") +export const CompactionBody = Schema.Struct({ + "type": Schema.Literal("compaction").annotate({ "description": "The type of the item. Always `compaction`." }), + "id": Schema.String.annotate({ "description": "The unique ID of the compaction item." }), + "encrypted_content": Schema.String.annotate({ + "description": "The encrypted content that was produced by compaction." + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) + ) +}).annotate({ + "title": "Compaction item", + "description": + "A compaction item generated by the [`v1/responses/compact` API](/docs/api-reference/responses/compact).", + "identifier": "CompactionBody" }) -export type DeleteVectorStoreResponse = { - readonly "id": string - readonly "deleted": boolean - readonly "object": "vector_store.deleted" +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`." }), + "logs": Schema.String.annotate({ "description": "The logs output from the code interpreter." }) +}).annotate({ + "title": "Code interpreter output logs", + "description": "The logs output from the code interpreter.", + "identifier": "CodeInterpreterOutputLogs" +}) +export type CodeInterpreterOutputImage = { readonly "type": "image"; readonly "url": string } +export const CodeInterpreterOutputImage = Schema.Struct({ + "type": Schema.Literal("image").annotate({ "description": "The type of the output. Always `image`." }), + "url": Schema.String.annotate({ + "description": "The URL of the image output from the code interpreter.", + "format": "uri" + }) +}).annotate({ + "title": "Code interpreter output image", + "description": "The image output from the code interpreter.", + "identifier": "CodeInterpreterOutputImage" +}) +export type LocalShellExecAction = { + readonly "type": "exec" + readonly "command": ReadonlyArray + readonly "timeout_ms"?: number | null + readonly "working_directory"?: string | null + readonly "env": {} + readonly "user"?: string | null } -export const DeleteVectorStoreResponse = Schema.Struct({ - "id": Schema.String, - "deleted": Schema.Boolean, - "object": Schema.Literal("vector_store.deleted") +export const LocalShellExecAction = Schema.Struct({ + "type": Schema.Literal("exec").annotate({ "description": "The type of the local shell action. Always `exec`." }), + "command": Schema.Array(Schema.String).annotate({ "description": "The command to run." }), + "timeout_ms": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "Optional timeout in milliseconds for the command." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + Schema.Null + ]) + ), + "working_directory": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "Optional working directory to run the command in." }), + Schema.Null + ]) + ), + "env": Schema.Struct({}).annotate({ "description": "Environment variables to set for the command." }), + "user": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "Optional user to run the command as." }), Schema.Null]) + ) +}).annotate({ + "title": "Local shell exec action", + "description": "Execute a shell command on the server.", + "identifier": "LocalShellExecAction" }) -export type DeletedRoleAssignmentResource = { readonly "object": string; readonly "deleted": boolean } -export const DeletedRoleAssignmentResource = Schema.Struct({ - "object": Schema.String.annotate({ - "description": "Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`." +export type LocalShellToolCallOutput = { + readonly "type": "local_shell_call_output" + readonly "id": string + readonly "output": string + readonly "status"?: "in_progress" | "completed" | "incomplete" | null + readonly "call_id": Schema.Json +} +export const LocalShellToolCallOutput = Schema.Struct({ + "type": Schema.Literal("local_shell_call_output").annotate({ + "description": "The type of the local shell tool call output. Always `local_shell_call_output`.\n" }), - "deleted": Schema.Boolean.annotate({ "description": "Whether the assignment was removed." }) -}).annotate({ "description": "Confirmation payload returned after unassigning a role." }) -export type DoneEvent = { readonly "event": "done"; readonly "data": "[DONE]" } -export const DoneEvent = Schema.Struct({ "event": Schema.Literal("done"), "data": Schema.Literal("[DONE]") }).annotate({ - "description": "Occurs when a stream ends." + "id": Schema.String.annotate({ + "description": "The unique ID of the local shell tool call generated by the model.\n" + }), + "output": Schema.String.annotate({ "description": "A JSON string of the output of the local shell tool call.\n" }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the item. One of `in_progress`, `completed`, or `incomplete`.\n" + }), + Schema.Null + ]) + ), + "call_id": Schema.Json.annotate({ "expected": "JSON value" }) +}).annotate({ + "title": "Local shell call output", + "description": "The output of a local shell tool call.\n", + "identifier": "LocalShellToolCallOutput" }) -export type Embedding = { - readonly "index": number - readonly "embedding": ReadonlyArray - readonly "object": "embedding" +export type FunctionShellAction = { + readonly "commands": ReadonlyArray + readonly "timeout_ms": number | null + readonly "max_output_length": number | null } -export const Embedding = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the embedding in the list of embeddings." }).check( - Schema.isInt() - ), - "embedding": Schema.Array(Schema.Number.annotate({ "format": "float" }).check(Schema.isFinite())).annotate({ - "description": - "The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](/docs/guides/embeddings).\n" +export const FunctionShellAction = 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().annotate({ "expected": "an integer" }) + ), + Schema.Null + ]), + "max_output_length": Schema.Union([ + Schema.Number.annotate({ "description": "Optional maximum number of characters to return from each command." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) +}).annotate({ + "title": "Shell exec action", + "description": "Execute a shell command.", + "identifier": "FunctionShellAction" +}) +export type FunctionShellCallStatus = "in_progress" | "completed" | "incomplete" +export const FunctionShellCallStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "FunctionShellCallStatus" +}) +export type LocalEnvironmentResource = { readonly "type": "local" } +export const LocalEnvironmentResource = Schema.Struct({ + "type": Schema.Literal("local").annotate({ "description": "The environment type. Always `local`." }) +}).annotate({ + "title": "Local Environment", + "description": "Represents the use of a local environment to perform shell actions.", + "identifier": "LocalEnvironmentResource" +}) +export type ContainerReferenceResource = { readonly "type": "container_reference"; readonly "container_id": string } +export const ContainerReferenceResource = Schema.Struct({ + "type": Schema.Literal("container_reference").annotate({ + "description": "The environment type. Always `container_reference`." }), - "object": Schema.Literal("embedding").annotate({ "description": "The object type, which is always \"embedding\"." }) -}).annotate({ "description": "Represents an embedding vector returned by embedding endpoint.\n" }) -export type Error = { - readonly "code": string | null - readonly "message": string - readonly "param": string | null - readonly "type": string + "container_id": Schema.String +}).annotate({ + "title": "Container Reference", + "description": "Represents a container created with /v1/containers.", + "identifier": "ContainerReferenceResource" +}) +export type FunctionShellCallOutputStatusEnum = "in_progress" | "completed" | "incomplete" +export const FunctionShellCallOutputStatusEnum = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "FunctionShellCallOutputStatusEnum" +}) +export type FunctionShellCallOutputTimeoutOutcome = { readonly "type": "timeout" } +export const FunctionShellCallOutputTimeoutOutcome = Schema.Struct({ + "type": Schema.Literal("timeout").annotate({ "description": "The outcome type. Always `timeout`." }) +}).annotate({ + "title": "Shell call timeout outcome", + "description": "Indicates that the shell call exceeded its configured time limit.", + "identifier": "FunctionShellCallOutputTimeoutOutcome" +}) +export type FunctionShellCallOutputExitOutcome = { readonly "type": "exit"; readonly "exit_code": number } +export const FunctionShellCallOutputExitOutcome = Schema.Struct({ + "type": Schema.Literal("exit").annotate({ "description": "The outcome type. Always `exit`." }), + "exit_code": Schema.Number.annotate({ "description": "Exit code from the shell process." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "Shell call exit outcome", + "description": "Indicates that the shell commands finished and returned an exit code.", + "identifier": "FunctionShellCallOutputExitOutcome" +}) +export type ApplyPatchCallStatus = "in_progress" | "completed" +export const ApplyPatchCallStatus = Schema.Literals(["in_progress", "completed"]).annotate({ + "identifier": "ApplyPatchCallStatus" +}) +export type ApplyPatchCreateFileOperation = { + readonly "type": "create_file" + readonly "path": string + readonly "diff": string } -export const Error = Schema.Struct({ - "code": Schema.Union([Schema.String, Schema.Null]), - "message": Schema.String, - "param": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.String +export const ApplyPatchCreateFileOperation = Schema.Struct({ + "type": Schema.Literal("create_file").annotate({ "description": "Create a new file with the provided diff." }), + "path": Schema.String.annotate({ "description": "Path of the file to create." }), + "diff": Schema.String.annotate({ "description": "Diff to apply." }) +}).annotate({ + "title": "Apply patch create file operation", + "description": "Instruction describing how to create a file via the apply_patch tool.", + "identifier": "ApplyPatchCreateFileOperation" }) -export type EvalApiError = { readonly "code": string; readonly "message": string } -export const EvalApiError = Schema.Struct({ - "code": Schema.String.annotate({ "description": "The error code." }), - "message": Schema.String.annotate({ "description": "The error message." }) -}).annotate({ "title": "EvalApiError", "description": "An object representing an error response from the Eval API.\n" }) -export type EvalGraderPython = { - readonly "type": "python" +export type ApplyPatchDeleteFileOperation = { readonly "type": "delete_file"; readonly "path": string } +export const ApplyPatchDeleteFileOperation = Schema.Struct({ + "type": Schema.Literal("delete_file").annotate({ "description": "Delete the specified file." }), + "path": Schema.String.annotate({ "description": "Path of the file to delete." }) +}).annotate({ + "title": "Apply patch delete file operation", + "description": "Instruction describing how to delete a file via the apply_patch tool.", + "identifier": "ApplyPatchDeleteFileOperation" +}) +export type ApplyPatchUpdateFileOperation = { + readonly "type": "update_file" + readonly "path": string + readonly "diff": string +} +export const ApplyPatchUpdateFileOperation = Schema.Struct({ + "type": Schema.Literal("update_file").annotate({ "description": "Update an existing file with the provided diff." }), + "path": Schema.String.annotate({ "description": "Path of the file to update." }), + "diff": Schema.String.annotate({ "description": "Diff to apply." }) +}).annotate({ + "title": "Apply patch update file operation", + "description": "Instruction describing how to update a file via the apply_patch tool.", + "identifier": "ApplyPatchUpdateFileOperation" +}) +export type ApplyPatchCallOutputStatus = "completed" | "failed" +export const ApplyPatchCallOutputStatus = Schema.Literals(["completed", "failed"]).annotate({ + "identifier": "ApplyPatchCallOutputStatus" +}) +export type MCPListToolsTool = { readonly "name": string - readonly "source": string - readonly "image_tag"?: string - readonly "pass_threshold"?: number + readonly "description"?: string | null + readonly "input_schema": {} + readonly "annotations"?: {} | null } -export const EvalGraderPython = Schema.Struct({ - "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "source": Schema.String.annotate({ "description": "The source code of the python script." }), - "image_tag": Schema.optionalKey( - Schema.String.annotate({ "description": "The image tag to use for the python script." }) +export const MCPListToolsTool = Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the tool.\n" }), + "description": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The description of the tool.\n" }), Schema.Null]) ), - "pass_threshold": Schema.optionalKey( - Schema.Number.annotate({ "description": "The threshold for the score." }).check(Schema.isFinite()) + "input_schema": Schema.Struct({}).annotate({ "description": "The JSON schema describing the tool's input.\n" }), + "annotations": Schema.optionalKey( + Schema.Union([ + Schema.Struct({}).annotate({ "description": "Additional annotations about the tool.\n" }), + Schema.Null + ]) ) }).annotate({ - "title": "PythonGrader", - "description": "A PythonGrader object that runs a python script on the input.\n" + "title": "MCP list tools tool", + "description": "A tool available on an MCP server.\n", + "identifier": "MCPListToolsTool" }) -export type EvalGraderStringCheck = { - readonly "type": "string_check" +export type MCPApprovalRequest = { + readonly "type": "mcp_approval_request" + readonly "id": string + readonly "server_label": string readonly "name": string - readonly "input": string - readonly "reference": string - readonly "operation": "eq" | "ne" | "like" | "ilike" + readonly "arguments": string } -export const EvalGraderStringCheck = Schema.Struct({ - "type": Schema.Literal("string_check").annotate({ - "description": "The object type, which is always `string_check`." +export const MCPApprovalRequest = Schema.Struct({ + "type": Schema.Literal("mcp_approval_request").annotate({ + "description": "The type of the item. Always `mcp_approval_request`.\n" }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), - "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), - "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ - "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." - }) + "id": Schema.String.annotate({ "description": "The unique ID of the approval request.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server making the request.\n" }), + "name": Schema.String.annotate({ "description": "The name of the tool to run.\n" }), + "arguments": Schema.String.annotate({ "description": "A JSON string of arguments for the tool.\n" }) }).annotate({ - "title": "StringCheckGrader", - "description": - "A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.\n" + "title": "MCP approval request", + "description": "A request for human approval of a tool invocation.\n", + "identifier": "MCPApprovalRequest" }) -export type EvalGraderTextSimilarity = { - readonly "type": "text_similarity" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "evaluation_metric": - | "cosine" - | "fuzzy_match" - | "bleu" - | "gleu" - | "meteor" - | "rouge_1" - | "rouge_2" - | "rouge_3" - | "rouge_4" - | "rouge_5" - | "rouge_l" - readonly "pass_threshold": number +export type MCPApprovalResponseResource = { + readonly "type": "mcp_approval_response" + readonly "id": string + readonly "approval_request_id": string + readonly "approve": boolean + readonly "reason"?: string | null + readonly "request_id": Schema.Json } -export const EvalGraderTextSimilarity = Schema.Struct({ - "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The text being graded." }), - "reference": Schema.String.annotate({ "description": "The text being graded against." }), - "evaluation_metric": Schema.Literals([ - "cosine", - "fuzzy_match", - "bleu", - "gleu", - "meteor", - "rouge_1", - "rouge_2", - "rouge_3", - "rouge_4", - "rouge_5", - "rouge_l" +export const MCPApprovalResponseResource = Schema.Struct({ + "type": Schema.Literal("mcp_approval_response").annotate({ + "description": "The type of the item. Always `mcp_approval_response`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the approval response\n" }), + "approval_request_id": Schema.String.annotate({ "description": "The ID of the approval request being answered.\n" }), + "approve": Schema.Boolean.annotate({ "description": "Whether the request was approved.\n" }), + "reason": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "Optional reason for the decision.\n" }), Schema.Null]) + ), + "request_id": Schema.Json.annotate({ "expected": "JSON value" }) +}).annotate({ + "title": "MCP approval response", + "description": "A response to an MCP approval request.\n", + "identifier": "MCPApprovalResponseResource" +}) +export type MCPToolCallStatus = "in_progress" | "completed" | "incomplete" | "calling" | "failed" +export const MCPToolCallStatus = Schema.Literals(["in_progress", "completed", "incomplete", "calling", "failed"]) + .annotate({ "identifier": "MCPToolCallStatus" }) +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", + "identifier": "MessagePhase" +}) +export type FunctionCallItemStatus = "in_progress" | "completed" | "incomplete" +export const FunctionCallItemStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "FunctionCallItemStatus" +}) +export type DetailEnum = "low" | "high" | "auto" | "original" +export const DetailEnum = Schema.Literals(["low", "high", "auto", "original"]).annotate({ "identifier": "DetailEnum" }) +export type FileDetailEnum = "auto" | "low" | "high" +export const FileDetailEnum = Schema.Literals(["auto", "low", "high"]).annotate({ "identifier": "FileDetailEnum" }) +export type FunctionShellActionParam = { + readonly "commands": ReadonlyArray + readonly "timeout_ms"?: number | null + readonly "max_output_length"?: number | null +} +export const FunctionShellActionParam = Schema.Struct({ + "commands": Schema.Array(Schema.String).annotate({ + "description": "Ordered shell commands for the execution environment to run." + }), + "timeout_ms": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "Maximum wall-clock time in milliseconds to allow the shell commands to run." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "max_output_length": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "Maximum number of UTF-8 characters to capture from combined stdout and stderr output." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ) +}).annotate({ + "title": "Shell action", + "description": "Commands and limits describing how to run the shell tool call.", + "identifier": "FunctionShellActionParam" +}) +export type FunctionShellCallItemStatus = "in_progress" | "completed" | "incomplete" +export const FunctionShellCallItemStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "title": "Shell call status", + "description": "Status values reported for shell tool calls.", + "identifier": "FunctionShellCallItemStatus" +}) +export type FunctionShellCallOutputTimeoutOutcomeParam = { readonly "type": "timeout" } +export const FunctionShellCallOutputTimeoutOutcomeParam = Schema.Struct({ + "type": Schema.Literal("timeout").annotate({ "description": "The outcome type. Always `timeout`." }) +}).annotate({ + "title": "Shell call timeout outcome", + "description": "Indicates that the shell call exceeded its configured time limit.", + "identifier": "FunctionShellCallOutputTimeoutOutcomeParam" +}) +export type FunctionShellCallOutputExitOutcomeParam = { readonly "type": "exit"; readonly "exit_code": number } +export const FunctionShellCallOutputExitOutcomeParam = Schema.Struct({ + "type": Schema.Literal("exit").annotate({ "description": "The outcome type. Always `exit`." }), + "exit_code": Schema.Number.annotate({ "description": "The exit code returned by the shell process." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "Shell call exit outcome", + "description": "Indicates that the shell commands finished and returned an exit code.", + "identifier": "FunctionShellCallOutputExitOutcomeParam" +}) +export type ApplyPatchCallStatusParam = "in_progress" | "completed" +export const ApplyPatchCallStatusParam = Schema.Literals(["in_progress", "completed"]).annotate({ + "title": "Apply patch call status", + "description": "Status values reported for apply_patch tool calls.", + "identifier": "ApplyPatchCallStatusParam" +}) +export type ApplyPatchCreateFileOperationParam = { + readonly "type": "create_file" + readonly "path": string + readonly "diff": string +} +export const ApplyPatchCreateFileOperationParam = Schema.Struct({ + "type": Schema.Literal("create_file").annotate({ "description": "The operation type. Always `create_file`." }), + "path": Schema.String.annotate({ "description": "Path of the file to create relative to the workspace root." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "diff": Schema.String.annotate({ "description": "Unified diff content to apply when creating the file." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ) +}).annotate({ + "title": "Apply patch create file operation", + "description": "Instruction for creating a new file via the apply_patch tool.", + "identifier": "ApplyPatchCreateFileOperationParam" +}) +export type ApplyPatchDeleteFileOperationParam = { readonly "type": "delete_file"; readonly "path": string } +export const ApplyPatchDeleteFileOperationParam = Schema.Struct({ + "type": Schema.Literal("delete_file").annotate({ "description": "The operation type. Always `delete_file`." }), + "path": Schema.String.annotate({ "description": "Path of the file to delete relative to the workspace root." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ + "title": "Apply patch delete file operation", + "description": "Instruction for deleting an existing file via the apply_patch tool.", + "identifier": "ApplyPatchDeleteFileOperationParam" +}) +export type ApplyPatchUpdateFileOperationParam = { + readonly "type": "update_file" + readonly "path": string + readonly "diff": string +} +export const ApplyPatchUpdateFileOperationParam = Schema.Struct({ + "type": Schema.Literal("update_file").annotate({ "description": "The operation type. Always `update_file`." }), + "path": Schema.String.annotate({ "description": "Path of the file to update relative to the workspace root." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "diff": Schema.String.annotate({ "description": "Unified diff content to apply to the existing file." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ) +}).annotate({ + "title": "Apply patch update file operation", + "description": "Instruction for updating an existing file via the apply_patch tool.", + "identifier": "ApplyPatchUpdateFileOperationParam" +}) +export type ApplyPatchCallOutputStatusParam = "completed" | "failed" +export const ApplyPatchCallOutputStatusParam = Schema.Literals(["completed", "failed"]).annotate({ + "title": "Apply patch call output status", + "description": "Outcome values reported for apply_patch tool call outputs.", + "identifier": "ApplyPatchCallOutputStatusParam" +}) +export type CompactionTriggerItemParam = { readonly "type": "compaction_trigger" } +export const CompactionTriggerItemParam = Schema.Struct({ + "type": Schema.Literal("compaction_trigger").annotate({ + "description": "The type of the item. Always `compaction_trigger`." + }) +}).annotate({ + "title": "Compaction trigger", + "description": "Compacts the current context. Must be the final input item.", + "identifier": "CompactionTriggerItemParam" +}) +export type ItemReferenceParam = { readonly "type"?: "item_reference" | null; readonly "id": string } +export const ItemReferenceParam = Schema.Struct({ + "type": Schema.optionalKey( + Schema.Union([ + Schema.Literal("item_reference").annotate({ + "description": "The type of item to reference. Always `item_reference`." + }), + Schema.Null + ]) + ), + "id": Schema.String.annotate({ "description": "The ID of the item to reference." }) +}).annotate({ + "title": "Item reference", + "description": "An internal identifier for an item to reference.", + "identifier": "ItemReferenceParam" +}) +export type ProgramItemParam = { + readonly "id": string + readonly "type": "program" + readonly "call_id": string + readonly "code": string + readonly "fingerprint": string +} +export const ProgramItemParam = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of this program item." }), + "type": Schema.Literal("program").annotate({ "description": "The item type. Always `program`." }), + "call_id": Schema.String.annotate({ "description": "The stable call ID of the program item." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "code": Schema.String.annotate({ "description": "The JavaScript source executed by programmatic tool calling." }) + .check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })), + "fingerprint": Schema.String.annotate({ + "description": "Opaque program replay fingerprint that must be round-tripped." + }).check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })) +}).annotate({ "identifier": "ProgramItemParam" }) +export type ProgramOutputItemStatus = "completed" | "incomplete" +export const ProgramOutputItemStatus = Schema.Literals(["completed", "incomplete"]).annotate({ + "identifier": "ProgramOutputItemStatus" +}) +export type ConversationResource = { + readonly "id": string + readonly "object": "conversation" + readonly "metadata": Schema.Json + readonly "created_at": number +} +export const ConversationResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the conversation." }), + "object": Schema.Literal("conversation").annotate({ + "description": "The object type, which is always `conversation`." + }), + "metadata": Schema.Json.annotate({ + "expected": "JSON value", + "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." + }), + "created_at": Schema.Number.annotate({ + "description": "The time at which the conversation was created, measured in seconds since the Unix epoch.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "ConversationResource" }) +export type CreateEmbeddingRequest = { + readonly "input": string | ReadonlyArray | ReadonlyArray | ReadonlyArray> + readonly "model": string | "text-embedding-ada-002" | "text-embedding-3-small" | "text-embedding-3-large" + readonly "encoding_format"?: "float" | "base64" + readonly "dimensions"?: number + readonly "user"?: string +} +export const CreateEmbeddingRequest = Schema.Struct({ + "input": Schema.Union([ + Schema.String.annotate({ "title": "string", "description": "The string that will be turned into an embedding." }), + Schema.Array(Schema.String).annotate({ + "title": "array", + "description": "The array of strings that will be turned into an embedding." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" }) + ), + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({ + "title": "array", + "description": "The array of integers that will be turned into an embedding." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" }) + ), + Schema.Array( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + ).annotate({ + "title": "array", + "description": "The array of arrays containing integers that will be turned into an embedding." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2048).annotate({ "expected": "a value with a length of at most 2048" }) + ) + ], { mode: "oneOf" }).annotate({ + "description": + "Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for all embedding models), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. In addition to the per-input token limit, all embedding models enforce a maximum of 300,000 tokens summed across all inputs in a single request.\n" + }), + "model": Schema.Union([ + Schema.String, + Schema.Literals(["text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large"]) ]).annotate({ "description": - "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" + "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" + }), + "encoding_format": Schema.optionalKey( + Schema.Literals(["float", "base64"]).annotate({ + "description": + "The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/)." + }) + ), + "dimensions": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ) + ), + "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" + }) + ) +}).annotate({ "identifier": "CreateEmbeddingRequest" }) +export type Embedding = { + readonly "index": number + readonly "embedding": ReadonlyArray + readonly "object": "embedding" +} +export const Embedding = Schema.Struct({ + "index": Schema.Number.annotate({ "description": "The index of the embedding in the list of embeddings." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "embedding": Schema.Array( + Schema.Number.annotate({ "format": "float" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ).annotate({ + "description": + "The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](/docs/guides/embeddings).\n" }), - "pass_threshold": Schema.Number.annotate({ "description": "The threshold for the score." }).check(Schema.isFinite()) + "object": Schema.Literal("embedding").annotate({ "description": "The object type, which is always \"embedding\"." }) }).annotate({ - "title": "TextSimilarityGrader", - "description": "A TextSimilarityGrader object which grades text based on similarity metrics.\n" + "description": "Represents an embedding vector returned by embedding endpoint.\n", + "identifier": "Embedding" +}) +export type EvalItemContentText = string +export const EvalItemContentText = Schema.String.annotate({ + "title": "Text input", + "description": "A text input to the model.\n", + "identifier": "EvalItemContentText" }) export type EvalItemContentOutputText = { readonly "type": "output_text"; readonly "text": string } export const EvalItemContentOutputText = Schema.Struct({ @@ -1783,11 +2748,10 @@ export const EvalItemContentOutputText = Schema.Struct({ "description": "The type of the output text. Always `output_text`.\n" }), "text": Schema.String.annotate({ "description": "The text output from the model.\n" }) -}).annotate({ "title": "Output text", "description": "A text output from the model.\n" }) -export type EvalItemContentText = string -export const EvalItemContentText = Schema.String.annotate({ - "title": "Text input", - "description": "A text input to the model.\n" +}).annotate({ + "title": "Output text", + "description": "A text output from the model.\n", + "identifier": "EvalItemContentOutputText" }) export type EvalItemInputImage = { readonly "type": "input_image" @@ -1805,131 +2769,157 @@ export const EvalItemInputImage = Schema.Struct({ "The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.\n" }) ) -}).annotate({ "title": "Input image", "description": "An image input block used within EvalItem content arrays." }) -export type EvalJsonlFileContentSource = { - readonly "type": "file_content" - readonly "content": ReadonlyArray<{ readonly "item": {}; readonly "sample"?: {} }> +}).annotate({ + "title": "Input image", + "description": "An image input block used within EvalItem content arrays.", + "identifier": "EvalItemInputImage" +}) +export type InputAudio = { + readonly "type": "input_audio" + readonly "input_audio": { readonly "data": string; readonly "format": "mp3" | "wav" } } -export const EvalJsonlFileContentSource = Schema.Struct({ - "type": Schema.Literal("file_content").annotate({ - "description": "The type of jsonl source. Always `file_content`." +export const InputAudio = Schema.Struct({ + "type": Schema.Literal("input_audio").annotate({ + "description": "The type of the input item. Always `input_audio`.\n" }), - "content": Schema.Array(Schema.Struct({ "item": Schema.Struct({}), "sample": Schema.optionalKey(Schema.Struct({})) })) - .annotate({ "description": "The content of the jsonl file." }) -}).annotate({ "title": "EvalJsonlFileContentSource" }) -export type EvalJsonlFileIdSource = { readonly "type": "file_id"; readonly "id": string } -export const EvalJsonlFileIdSource = Schema.Struct({ - "type": Schema.Literal("file_id").annotate({ "description": "The type of jsonl source. Always `file_id`." }), - "id": Schema.String.annotate({ "description": "The identifier of the file." }) -}).annotate({ "title": "EvalJsonlFileIdSource" }) -export type EvalResponsesSource = { - readonly "type": "responses" - readonly "metadata"?: {} | null - readonly "model"?: string | null - readonly "instructions_search"?: string | null - readonly "created_after"?: number | null - readonly "created_before"?: number | null - readonly "reasoning_effort"?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | null | null - readonly "temperature"?: number | null - readonly "top_p"?: number | null - readonly "users"?: ReadonlyArray | null - readonly "tools"?: ReadonlyArray | null + "input_audio": Schema.Struct({ + "data": Schema.String.annotate({ "description": "Base64-encoded audio data.\n" }), + "format": Schema.Literals(["mp3", "wav"]).annotate({ + "description": "The format of the audio data. Currently supported formats are `mp3` and\n`wav`.\n" + }) + }) +}).annotate({ "title": "Input audio", "description": "An audio input to the model.\n", "identifier": "InputAudio" }) +export type EvalGraderStringCheck = { + readonly "type": "string_check" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "operation": "eq" | "ne" | "like" | "ilike" } -export const EvalResponsesSource = Schema.Struct({ - "type": Schema.Literal("responses").annotate({ "description": "The type of run data source. Always `responses`." }), - "metadata": Schema.optionalKey( - Schema.Union([ - Schema.Struct({}).annotate({ - "description": "Metadata filter for the responses. This is a query parameter used to select responses." - }), - Schema.Null - ]) - ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The name of the model to find responses for. This is a query parameter used to select responses." - }), - Schema.Null - ]) - ), - "instructions_search": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "Optional string to search the 'instructions' field. This is a query parameter used to select responses." - }), - Schema.Null - ]) - ), - "created_after": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "Only include items created after this timestamp (inclusive). This is a query parameter used to select responses." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]) - ), - "created_before": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "Only include items created before this timestamp (inclusive). This is a query parameter used to select responses." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - Schema.Null - ]) - ), - "reasoning_effort": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Literals(["none", "minimal", "low", "medium", "high", "xhigh"]).annotate({ - "description": - "Constrains effort on reasoning for\n[reasoning models](https://platform.openai.com/docs/guides/reasoning).\nCurrently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing\nreasoning effort can result in faster responses and fewer tokens used\non reasoning in a response.\n\n- `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all reasoning values in gpt-5.1.\n- All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.\n- The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.\n- `xhigh` is supported for all models after `gpt-5.1-codex-max`.\n" - }), - Schema.Null - ]).annotate({ - "description": "Optional reasoning effort parameter. This is a query parameter used to select responses." - }), - Schema.Null - ]) - ), - "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "Sampling temperature. This is a query parameter used to select responses." - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "Nucleus sampling parameter. This is a query parameter used to select responses." - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "users": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).annotate({ - "description": "List of user identifiers. This is a query parameter used to select responses." - }), - Schema.Null - ]) +export const EvalGraderStringCheck = Schema.Struct({ + "type": Schema.Literal("string_check").annotate({ + "description": "The object type, which is always `string_check`." + }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), + "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), + "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ + "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." + }) +}).annotate({ + "title": "StringCheckGrader", + "description": + "A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.\n", + "identifier": "EvalGraderStringCheck" +}) +export type EvalGraderTextSimilarity = { + readonly "type": "text_similarity" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "evaluation_metric": + | "cosine" + | "fuzzy_match" + | "bleu" + | "gleu" + | "meteor" + | "rouge_1" + | "rouge_2" + | "rouge_3" + | "rouge_4" + | "rouge_5" + | "rouge_l" + readonly "pass_threshold": number +} +export const EvalGraderTextSimilarity = Schema.Struct({ + "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The text being graded." }), + "reference": Schema.String.annotate({ "description": "The text being graded against." }), + "evaluation_metric": Schema.Literals([ + "cosine", + "fuzzy_match", + "bleu", + "gleu", + "meteor", + "rouge_1", + "rouge_2", + "rouge_3", + "rouge_4", + "rouge_5", + "rouge_l" + ]).annotate({ + "description": + "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" + }), + "pass_threshold": Schema.Number.annotate({ "description": "The threshold for the score." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) +}).annotate({ + "title": "TextSimilarityGrader", + "description": "A TextSimilarityGrader object which grades text based on similarity metrics.\n", + "identifier": "EvalGraderTextSimilarity" +}) +export type EvalGraderPython = { + readonly "type": "python" + readonly "name": string + readonly "source": string + readonly "image_tag"?: string + readonly "pass_threshold"?: number +} +export const EvalGraderPython = Schema.Struct({ + "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "source": Schema.String.annotate({ "description": "The source code of the python script." }), + "image_tag": Schema.optionalKey( + Schema.String.annotate({ "description": "The image tag to use for the python script." }) ), - "tools": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).annotate({ - "description": "List of tool names. This is a query parameter used to select responses." - }), - Schema.Null - ]) + "pass_threshold": Schema.optionalKey( + Schema.Number.annotate({ "description": "The threshold for the score." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) ) }).annotate({ - "title": "EvalResponsesSource", - "description": "A EvalResponsesSource object describing a run data source configuration.\n" + "title": "PythonGrader", + "description": "A PythonGrader object that runs a python script on the input.\n", + "identifier": "EvalGraderPython" +}) +export type Error = { + readonly "code": string | null + readonly "message": string + readonly "param": string | null + readonly "type": string +} +export const Error = Schema.Struct({ + "code": Schema.Union([Schema.String, Schema.Null]), + "message": Schema.String, + "param": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.String +}).annotate({ "identifier": "Error" }) +export type EvalJsonlFileContentSource = { + readonly "type": "file_content" + readonly "content": ReadonlyArray<{ readonly "item": {}; readonly "sample"?: {} }> +} +export const EvalJsonlFileContentSource = Schema.Struct({ + "type": Schema.Literal("file_content").annotate({ + "description": "The type of jsonl source. Always `file_content`." + }), + "content": Schema.Array(Schema.Struct({ "item": Schema.Struct({}), "sample": Schema.optionalKey(Schema.Struct({})) })) + .annotate({ "description": "The content of the jsonl file." }) +}).annotate({ "title": "EvalJsonlFileContentSource", "identifier": "EvalJsonlFileContentSource" }) +export type EvalJsonlFileIdSource = { readonly "type": "file_id"; readonly "id": string } +export const EvalJsonlFileIdSource = Schema.Struct({ + "type": Schema.Literal("file_id").annotate({ "description": "The type of jsonl source. Always `file_id`." }), + "id": Schema.String.annotate({ "description": "The identifier of the file." }) +}).annotate({ "title": "EvalJsonlFileIdSource", "identifier": "EvalJsonlFileIdSource" }) +export type EvalApiError = { readonly "code": string; readonly "message": string } +export const EvalApiError = Schema.Struct({ + "code": Schema.String.annotate({ "description": "The error code." }), + "message": Schema.String.annotate({ "description": "The error message." }) +}).annotate({ + "title": "EvalApiError", + "description": "An object representing an error response from the Eval API.\n", + "identifier": "EvalApiError" }) export type EvalRunOutputItemResult = { readonly "name": string @@ -1944,7 +2934,7 @@ export const EvalRunOutputItemResult = Schema.Struct({ Schema.String.annotate({ "description": "The grader type (for example, \"string-check-grader\")." }) ), "score": Schema.Number.annotate({ "description": "The numeric score produced by the grader." }).check( - Schema.isFinite() + Schema.isFinite().annotate({ "expected": "a finite number" }) ), "passed": Schema.Boolean.annotate({ "description": "Whether the grader considered the output a pass." }), "sample": Schema.optionalKey( @@ -1954,7 +2944,81 @@ export const EvalRunOutputItemResult = Schema.Struct({ ) }).annotate({ "title": "EvalRunOutputItemResult", - "description": "A single grader result for an evaluation run output item.\n" + "description": "A single grader result for an evaluation run output item.\n", + "identifier": "EvalRunOutputItemResult" +}) +export type OpenAIFile = { + readonly "id": string + readonly "bytes": number + readonly "created_at": number + readonly "expires_at"?: number | null + readonly "filename": string + readonly "object": "file" + readonly "purpose": + | "assistants" + | "assistants_output" + | "batch" + | "batch_output" + | "fine-tune" + | "fine-tune-results" + | "vision" + | "user_data" + readonly "status": "uploaded" | "processed" | "error" + readonly "status_details"?: string | null + readonly [x: string]: Schema.Json +} +export const OpenAIFile = Schema.StructWithRest( + Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The file identifier, which can be referenced in the API endpoints." + }), + "bytes": Schema.Number.annotate({ "description": "The size of the file, in bytes." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the file was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "expires_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the file will expire.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "filename": Schema.String.annotate({ "description": "The name of the file." }), + "object": Schema.Literal("file").annotate({ "description": "The object type, which is always `file`." }), + "purpose": Schema.Literals([ + "assistants", + "assistants_output", + "batch", + "batch_output", + "fine-tune", + "fine-tune-results", + "vision", + "user_data" + ]).annotate({ + "description": + "The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`." + }), + "status": Schema.Literals(["uploaded", "processed", "error"]).annotate({ + "description": + "Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`." + }), + "status_details": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`." + }) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ + "title": "OpenAIFile", + "description": "The `File` object represents a document that has been uploaded to OpenAI.", + "identifier": "OpenAIFile" }) export type FileExpirationAfter = { readonly "anchor": "created_at"; readonly "seconds": number } export const FileExpirationAfter = Schema.Struct({ @@ -1965,53 +3029,279 @@ export const FileExpirationAfter = Schema.Struct({ "description": "The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).", "format": "int64" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(3600)).check(Schema.isLessThanOrEqualTo(2592000)) + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(3600).annotate({ "expected": "a value greater than or equal to 3600" }) + ).check(Schema.isLessThanOrEqualTo(2592000).annotate({ "expected": "a value less than or equal to 2592000" })) }).annotate({ "title": "File expiration policy", "description": - "The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted." -}) -export type FilePath = { readonly "type": "file_path"; readonly "file_id": string; readonly "index": number } -export const FilePath = Schema.Struct({ - "type": Schema.Literal("file_path").annotate({ "description": "The type of the file path. Always `file_path`.\n" }), - "file_id": Schema.String.annotate({ "description": "The ID of the file.\n" }), - "index": Schema.Number.annotate({ "description": "The index of the file in the list of files.\n" }).check( - Schema.isInt() - ) -}).annotate({ "title": "File path", "description": "A path to a file.\n" }) -export type FileSearchRanker = "auto" | "default_2024_08_21" -export const FileSearchRanker = Schema.Literals(["auto", "default_2024_08_21"]).annotate({ - "description": "The ranker to use for the file search. If not specified will use the `auto` ranker." + "The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted.", + "identifier": "FileExpirationAfter" }) -export type FineTuneDPOHyperparameters = { - readonly "beta"?: "auto" | number +export type DeleteFileResponse = { readonly "id": string; readonly "object": "file"; readonly "deleted": boolean } +export const DeleteFileResponse = Schema.Struct({ + "id": Schema.String, + "object": Schema.Literal("file"), + "deleted": Schema.Boolean +}).annotate({ "identifier": "DeleteFileResponse" }) +export type GraderStringCheck = { + readonly "type": "string_check" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "operation": "eq" | "ne" | "like" | "ilike" +} +export const GraderStringCheck = Schema.Struct({ + "type": Schema.Literal("string_check").annotate({ + "description": "The object type, which is always `string_check`." + }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), + "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), + "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ + "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." + }) +}).annotate({ + "title": "StringCheckGrader", + "description": + "A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.\n", + "identifier": "GraderStringCheck" +}) +export type GraderTextSimilarity = { + readonly "type": "text_similarity" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "evaluation_metric": + | "cosine" + | "fuzzy_match" + | "bleu" + | "gleu" + | "meteor" + | "rouge_1" + | "rouge_2" + | "rouge_3" + | "rouge_4" + | "rouge_5" + | "rouge_l" +} +export const GraderTextSimilarity = Schema.Struct({ + "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The text being graded." }), + "reference": Schema.String.annotate({ "description": "The text being graded against." }), + "evaluation_metric": Schema.Literals([ + "cosine", + "fuzzy_match", + "bleu", + "gleu", + "meteor", + "rouge_1", + "rouge_2", + "rouge_3", + "rouge_4", + "rouge_5", + "rouge_l" + ]).annotate({ + "description": + "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" + }) +}).annotate({ + "title": "TextSimilarityGrader", + "description": "A TextSimilarityGrader object which grades text based on similarity metrics.\n", + "identifier": "GraderTextSimilarity" +}) +export type GraderPython = { + readonly "type": "python" + readonly "name": string + readonly "source": string + readonly "image_tag"?: string +} +export const GraderPython = Schema.Struct({ + "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "source": Schema.String.annotate({ "description": "The source code of the python script." }), + "image_tag": Schema.optionalKey( + Schema.String.annotate({ "description": "The image tag to use for the python script." }) + ) +}).annotate({ + "title": "PythonGrader", + "description": "A PythonGrader object that runs a python script on the input.\n", + "identifier": "GraderPython" +}) +export type RunGraderResponse = { + readonly "reward": number + readonly "metadata": { + readonly "name": string + readonly "type": string + readonly "errors": { + readonly "formula_parse_error": boolean + readonly "sample_parse_error": boolean + readonly "truncated_observation_error": boolean + readonly "unresponsive_reward_error": boolean + readonly "invalid_variable_error": boolean + readonly "other_error": boolean + readonly "python_grader_server_error": boolean + readonly "python_grader_server_error_type": string | null + readonly "python_grader_runtime_error": boolean + readonly "python_grader_runtime_error_details": string | null + readonly "model_grader_server_error": boolean + readonly "model_grader_refusal_error": boolean + readonly "model_grader_parse_error": boolean + readonly "model_grader_server_error_details": string | null + } + readonly "execution_time": number + readonly "scores": {} + readonly "token_usage": number | null + readonly "sampled_model_name": string | null + } + readonly "sub_rewards": {} + readonly "model_grader_token_usage_per_model": {} +} +export const RunGraderResponse = Schema.Struct({ + "reward": Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "metadata": Schema.Struct({ + "name": Schema.String, + "type": Schema.String, + "errors": Schema.Struct({ + "formula_parse_error": Schema.Boolean, + "sample_parse_error": Schema.Boolean, + "truncated_observation_error": Schema.Boolean, + "unresponsive_reward_error": Schema.Boolean, + "invalid_variable_error": Schema.Boolean, + "other_error": Schema.Boolean, + "python_grader_server_error": Schema.Boolean, + "python_grader_server_error_type": Schema.Union([Schema.String, Schema.Null]), + "python_grader_runtime_error": Schema.Boolean, + "python_grader_runtime_error_details": Schema.Union([Schema.String, Schema.Null]), + "model_grader_server_error": Schema.Boolean, + "model_grader_refusal_error": Schema.Boolean, + "model_grader_parse_error": Schema.Boolean, + "model_grader_server_error_details": Schema.Union([Schema.String, Schema.Null]) + }), + "execution_time": Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "scores": Schema.Struct({}), + "token_usage": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "sampled_model_name": Schema.Union([Schema.String, Schema.Null]) + }), + "sub_rewards": Schema.Struct({}), + "model_grader_token_usage_per_model": Schema.Struct({}) +}).annotate({ "identifier": "RunGraderResponse" }) +export type FineTuningCheckpointPermission = { + readonly "id": string + readonly "created_at": number + readonly "project_id": string + readonly "object": "checkpoint.permission" +} +export const FineTuningCheckpointPermission = Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The permission identifier, which can be referenced in the API endpoints." + }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the permission was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "project_id": Schema.String.annotate({ "description": "The project identifier that the permission is for." }), + "object": Schema.Literal("checkpoint.permission").annotate({ + "description": "The object type, which is always \"checkpoint.permission\"." + }) +}).annotate({ + "title": "FineTuningCheckpointPermission", + "description": "The `checkpoint.permission` object represents a permission for a fine-tuned model checkpoint.\n", + "identifier": "FineTuningCheckpointPermission" +}) +export type CreateFineTuningCheckpointPermissionRequest = { readonly "project_ids": ReadonlyArray } +export const CreateFineTuningCheckpointPermissionRequest = Schema.Struct({ + "project_ids": Schema.Array(Schema.String).annotate({ "description": "The project identifiers to grant access to." }) +}).annotate({ "identifier": "CreateFineTuningCheckpointPermissionRequest" }) +export type DeleteFineTuningCheckpointPermissionResponse = { + readonly "id": string + readonly "object": "checkpoint.permission" + readonly "deleted": boolean +} +export const DeleteFineTuningCheckpointPermissionResponse = Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The ID of the fine-tuned model checkpoint permission that was deleted." + }), + "object": Schema.Literal("checkpoint.permission").annotate({ + "description": "The object type, which is always \"checkpoint.permission\"." + }), + "deleted": Schema.Boolean.annotate({ + "description": "Whether the fine-tuned model checkpoint permission was successfully deleted." + }) +}).annotate({ "identifier": "DeleteFineTuningCheckpointPermissionResponse" }) +export type FineTuningIntegration = { + readonly "type": "wandb" + readonly "wandb": { + readonly "project": string + readonly "name"?: string | null + readonly "entity"?: string | null + readonly "tags"?: ReadonlyArray + } +} +export const FineTuningIntegration = Schema.Struct({ + "type": Schema.Literal("wandb").annotate({ + "description": "The type of the integration being enabled for the fine-tuning job" + }), + "wandb": Schema.Struct({ + "project": Schema.String.annotate({ + "description": "The name of the project that the new run will be created under.\n" + }), + "name": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "A display name to set for the run. If not set, we will use the Job ID as the name.\n" + }), + Schema.Null + ]) + ), + "entity": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The entity to use for the run. This allows you to set the team or username of the WandB user that you would\nlike associated with the run. If not set, the default entity for the registered WandB API key is used.\n" + }), + Schema.Null + ]) + ), + "tags": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some\ndefault tags are generated by OpenAI: \"openai/finetune\", \"openai/{base-model}\", \"openai/{ftjob-abcdef}\".\n" + }) + ) + }).annotate({ + "description": + "The settings for your integration with Weights and Biases. This payload specifies the project that\nmetrics will be sent to. Optionally, you can set an explicit display name for your run, add tags\nto your run, and set a default entity (team, username, etc) to be associated with your run.\n" + }) +}).annotate({ "title": "Fine-Tuning Job Integration", "identifier": "FineTuningIntegration" }) +export type FineTuneSupervisedHyperparameters = { readonly "batch_size"?: "auto" | number readonly "learning_rate_multiplier"?: "auto" | number readonly "n_epochs"?: "auto" | number } -export const FineTuneDPOHyperparameters = Schema.Struct({ - "beta": Schema.optionalKey( - Schema.Union([ - Schema.Literal("auto"), - Schema.Number.check(Schema.isFinite()).check(Schema.isLessThanOrEqualTo(2)).check(Schema.isGreaterThan(0)) - ], { mode: "oneOf" }).annotate({ - "description": - "The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.\n" - }) - ), +export const FineTuneSupervisedHyperparameters = Schema.Struct({ "batch_size": Schema.optionalKey( Schema.Union([ Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(256)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(256).annotate({ "expected": "a value less than or equal to 256" })) ], { mode: "oneOf" }).annotate({ "description": "Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.\n" }) ), "learning_rate_multiplier": Schema.optionalKey( - Schema.Union([Schema.Literal("auto"), Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThan(0))], { - mode: "oneOf" - }).annotate({ + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ) + ], { mode: "oneOf" }).annotate({ "description": "Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.\n" }) @@ -2019,92 +3309,101 @@ export const FineTuneDPOHyperparameters = Schema.Struct({ "n_epochs": Schema.optionalKey( Schema.Union([ Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(50)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(50).annotate({ "expected": "a value less than or equal to 50" })) ], { mode: "oneOf" }).annotate({ "description": "The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.\n" }) ) -}).annotate({ "description": "The hyperparameters used for the DPO fine-tuning job." }) -export type FineTuneReinforcementHyperparameters = { +}).annotate({ + "description": "The hyperparameters used for the fine-tuning job.", + "identifier": "FineTuneSupervisedHyperparameters" +}) +export type FineTuneDPOHyperparameters = { + readonly "beta"?: "auto" | number readonly "batch_size"?: "auto" | number readonly "learning_rate_multiplier"?: "auto" | number readonly "n_epochs"?: "auto" | number - readonly "reasoning_effort"?: "default" | "low" | "medium" | "high" - readonly "compute_multiplier"?: "auto" | number - readonly "eval_interval"?: "auto" | number - readonly "eval_samples"?: "auto" | number } -export const FineTuneReinforcementHyperparameters = Schema.Struct({ - "batch_size": Schema.optionalKey( +export const FineTuneDPOHyperparameters = Schema.Struct({ + "beta": Schema.optionalKey( Schema.Union([ Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(256)) + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" }) + ).check(Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" })) ], { mode: "oneOf" }).annotate({ "description": - "Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.\n" + "The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.\n" }) ), - "learning_rate_multiplier": Schema.optionalKey( - Schema.Union([Schema.Literal("auto"), Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThan(0))], { - mode: "oneOf" - }).annotate({ + "batch_size": Schema.optionalKey( + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(256).annotate({ "expected": "a value less than or equal to 256" })) + ], { mode: "oneOf" }).annotate({ "description": - "Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.\n" + "Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.\n" }) ), - "n_epochs": Schema.optionalKey( + "learning_rate_multiplier": Schema.optionalKey( Schema.Union([ Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(50)) + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ) ], { mode: "oneOf" }).annotate({ "description": - "The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.\n" + "Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.\n" }) ), - "reasoning_effort": Schema.optionalKey( - Schema.Literals(["default", "low", "medium", "high"]).annotate({ "description": "Level of reasoning effort.\n" }) - ), - "compute_multiplier": Schema.optionalKey( + "n_epochs": Schema.optionalKey( Schema.Union([ Schema.Literal("auto"), - Schema.Number.check(Schema.isFinite()).check(Schema.isLessThanOrEqualTo(10)).check(Schema.isGreaterThan(0.00001)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(50).annotate({ "expected": "a value less than or equal to 50" })) ], { mode: "oneOf" }).annotate({ - "description": "Multiplier on amount of compute used for exploring search space during training.\n" + "description": + "The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.\n" }) - ), - "eval_interval": Schema.optionalKey( - Schema.Union( - [Schema.Literal("auto"), Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1))], - { mode: "oneOf" } - ).annotate({ "description": "The number of training steps between evaluation runs.\n" }) - ), - "eval_samples": Schema.optionalKey( - Schema.Union( - [Schema.Literal("auto"), Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1))], - { mode: "oneOf" } - ).annotate({ "description": "Number of evaluation samples to generate per training step.\n" }) ) -}).annotate({ "description": "The hyperparameters used for the reinforcement fine-tuning job." }) -export type FineTuneSupervisedHyperparameters = { +}).annotate({ + "description": "The hyperparameters used for the DPO fine-tuning job.", + "identifier": "FineTuneDPOHyperparameters" +}) +export type FineTuneReinforcementHyperparameters = { readonly "batch_size"?: "auto" | number readonly "learning_rate_multiplier"?: "auto" | number readonly "n_epochs"?: "auto" | number + readonly "reasoning_effort"?: "default" | "low" | "medium" | "high" + readonly "compute_multiplier"?: "auto" | number + readonly "eval_interval"?: "auto" | number + readonly "eval_samples"?: "auto" | number } -export const FineTuneSupervisedHyperparameters = Schema.Struct({ +export const FineTuneReinforcementHyperparameters = Schema.Struct({ "batch_size": Schema.optionalKey( Schema.Union([ Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(256)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(256).annotate({ "expected": "a value less than or equal to 256" })) ], { mode: "oneOf" }).annotate({ "description": "Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.\n" }) ), "learning_rate_multiplier": Schema.optionalKey( - Schema.Union([Schema.Literal("auto"), Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThan(0))], { - mode: "oneOf" - }).annotate({ + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ) + ], { mode: "oneOf" }).annotate({ "description": "Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.\n" }) @@ -2112,80 +3411,47 @@ export const FineTuneSupervisedHyperparameters = Schema.Struct({ "n_epochs": Schema.optionalKey( Schema.Union([ Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(50)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(50).annotate({ "expected": "a value less than or equal to 50" })) ], { mode: "oneOf" }).annotate({ "description": "The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.\n" }) + ), + "reasoning_effort": Schema.optionalKey( + Schema.Literals(["default", "low", "medium", "high"]).annotate({ "description": "Level of reasoning effort.\n" }) + ), + "compute_multiplier": Schema.optionalKey( + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isLessThanOrEqualTo(10).annotate({ "expected": "a value less than or equal to 10" }) + ).check(Schema.isGreaterThan(0.00001).annotate({ "expected": "a value greater than 0.00001" })) + ], { mode: "oneOf" }).annotate({ + "description": "Multiplier on amount of compute used for exploring search space during training.\n" + }) + ), + "eval_interval": Schema.optionalKey( + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ) + ], { mode: "oneOf" }).annotate({ "description": "The number of training steps between evaluation runs.\n" }) + ), + "eval_samples": Schema.optionalKey( + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ) + ], { mode: "oneOf" }).annotate({ "description": "Number of evaluation samples to generate per training step.\n" }) ) -}).annotate({ "description": "The hyperparameters used for the fine-tuning job." }) -export type FineTuningCheckpointPermission = { - readonly "id": string - readonly "created_at": number - readonly "project_id": string - readonly "object": "checkpoint.permission" -} -export const FineTuningCheckpointPermission = Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The permission identifier, which can be referenced in the API endpoints." - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the permission was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "project_id": Schema.String.annotate({ "description": "The project identifier that the permission is for." }), - "object": Schema.Literal("checkpoint.permission").annotate({ - "description": "The object type, which is always \"checkpoint.permission\"." - }) }).annotate({ - "title": "FineTuningCheckpointPermission", - "description": "The `checkpoint.permission` object represents a permission for a fine-tuned model checkpoint.\n" + "description": "The hyperparameters used for the reinforcement fine-tuning job.", + "identifier": "FineTuneReinforcementHyperparameters" }) -export type FineTuningIntegration = { - readonly "type": "wandb" - readonly "wandb": { - readonly "project": string - readonly "name"?: string | null - readonly "entity"?: string | null - readonly "tags"?: ReadonlyArray - } -} -export const FineTuningIntegration = Schema.Struct({ - "type": Schema.Literal("wandb").annotate({ - "description": "The type of the integration being enabled for the fine-tuning job" - }), - "wandb": Schema.Struct({ - "project": Schema.String.annotate({ - "description": "The name of the project that the new run will be created under.\n" - }), - "name": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "A display name to set for the run. If not set, we will use the Job ID as the name.\n" - }), - Schema.Null - ]) - ), - "entity": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The entity to use for the run. This allows you to set the team or username of the WandB user that you would\nlike associated with the run. If not set, the default entity for the registered WandB API key is used.\n" - }), - Schema.Null - ]) - ), - "tags": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some\ndefault tags are generated by OpenAI: \"openai/finetune\", \"openai/{base-model}\", \"openai/{ftjob-abcdef}\".\n" - }) - ) - }).annotate({ - "description": - "The settings for your integration with Weights and Biases. This payload specifies the project that\nmetrics will be sent to. Optionally, you can set an explicit display name for your run, add tags\nto your run, and set a default entity (team, username, etc) to be associated with your run.\n" - }) -}).annotate({ "title": "Fine-Tuning Job Integration" }) export type FineTuningJobCheckpoint = { readonly "id": string readonly "created_at": number @@ -2210,21 +3476,33 @@ export const FineTuningJobCheckpoint = Schema.Struct({ "created_at": Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) for when the checkpoint was created.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "fine_tuned_model_checkpoint": Schema.String.annotate({ "description": "The name of the fine-tuned checkpoint model that is created." }), "step_number": Schema.Number.annotate({ "description": "The step number that the checkpoint was created at." }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ), "metrics": Schema.Struct({ - "step": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "train_loss": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "train_mean_token_accuracy": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "valid_loss": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "valid_mean_token_accuracy": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "full_valid_loss": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "full_valid_mean_token_accuracy": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) + "step": Schema.optionalKey(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))), + "train_loss": Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "train_mean_token_accuracy": Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "valid_loss": Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "valid_mean_token_accuracy": Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "full_valid_loss": Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "full_valid_mean_token_accuracy": Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) }).annotate({ "description": "Metrics at the step number during the fine-tuning job." }), "fine_tuning_job_id": Schema.String.annotate({ "description": "The name of the fine-tuning job that this checkpoint was created from." @@ -2235,7 +3513,8 @@ export const FineTuningJobCheckpoint = Schema.Struct({ }).annotate({ "title": "FineTuningJobCheckpoint", "description": - "The `fine_tuning.job.checkpoint` object represents a model checkpoint for a fine-tuning job that is ready to use.\n" + "The `fine_tuning.job.checkpoint` object represents a model checkpoint for a fine-tuning job that is ready to use.\n", + "identifier": "FineTuningJobCheckpoint" }) export type FineTuningJobEvent = { readonly "object": "fine_tuning.job.event" @@ -2254,289 +3533,98 @@ export const FineTuningJobEvent = Schema.Struct({ "created_at": Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) for when the fine-tuning job was created.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "level": Schema.Literals(["info", "warn", "error"]).annotate({ "description": "The log level of the event." }), "message": Schema.String.annotate({ "description": "The message of the event." }), "type": Schema.optionalKey(Schema.Literals(["message", "metrics"]).annotate({ "description": "The type of event." })), "data": Schema.optionalKey(Schema.Struct({}).annotate({ "description": "The data associated with the event." })) -}).annotate({ "description": "Fine-tuning job event object" }) -export type FunctionParameters = {} -export const FunctionParameters = Schema.Struct({}).annotate({ - "description": - "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. \n\nOmitting `parameters` defines a function with an empty parameter list." -}) -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" +}).annotate({ "description": "Fine-tuning job event object", "identifier": "FineTuningJobEvent" }) +export type ImageRefParam = { readonly "image_url": string; readonly "file_id"?: string } | { + readonly "file_id": string + readonly "image_url"?: string } -export const FunctionToolCall = Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the function tool call.\n" })), - "type": Schema.Literal("function_call").annotate({ - "description": "The type of the function tool call. Always `function_call`.\n" - }), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the function tool call generated by the model.\n" +export const ImageRefParam = Schema.Union([ + Schema.Struct({ + "image_url": Schema.String.annotate({ + "description": "A fully qualified URL or base64-encoded data URL.", + "format": "uri" + }).check(Schema.isMaxLength(20971520).annotate({ "expected": "a value with a length of at most 20971520" })), + "file_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The File API ID of an uploaded image to use as input." }) + ) + }).annotate({ + "description": + "Reference an input image by either URL or uploaded file ID.\nProvide exactly one of `image_url` or `file_id`.\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( - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + Schema.Struct({ + "file_id": Schema.String.annotate({ "description": "The File API ID of an uploaded image to use as input." }), + "image_url": Schema.optionalKey( + Schema.String.annotate({ "description": "A fully qualified URL or base64-encoded data URL.", "format": "uri" }) + .check(Schema.isMaxLength(20971520).annotate({ "expected": "a value with a length of at most 20971520" })) + ) + }).annotate({ + "description": + "Reference an input image by either URL or uploaded file ID.\nProvide exactly one of `image_url` or `file_id`.\n" + }) +]).annotate({ "identifier": "ImageRefParam" }) +export type PartialImages = number | null +export const PartialImages = Schema.Union([ + Schema.Number.annotate({ + "description": + "The number of partial images to generate. This parameter is used for\nstreaming responses that return partial images. Value must be between 0 and 3.\nWhen set to 0, the response will be a single image sent in one streaming event.\n\nNote that the final image may be sent before the full number of partial images\nare generated if the full image is generated more quickly.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(3).annotate({ "expected": "a value less than or equal to 3" })), + Schema.Null +]).annotate({ "identifier": "PartialImages" }) +export type Image = { readonly "b64_json"?: string; readonly "url"?: string; readonly "revised_prompt"?: string } +export const Image = Schema.Struct({ + "b64_json": Schema.optionalKey( + Schema.String.annotate({ "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + "The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if `response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`." + }) + ), + "url": Schema.optionalKey( + Schema.String.annotate({ + "description": + "When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response_format` is set to `url` (default value). Unsupported for the GPT image models.", + "format": "uri" + }) + ), + "revised_prompt": Schema.optionalKey( + Schema.String.annotate({ + "description": "For `dall-e-3` only, the revised prompt that was used to generate the image." }) ) }).annotate({ - "title": "Function tool call", - "description": - "A tool call to run a function. See the \n[function calling guide](/docs/guides/function-calling) for more information.\n" + "description": "Represents the content or the URL of an image generated by the OpenAI API.", + "identifier": "Image" }) -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" - readonly "created_by"?: string -} -export const FunctionToolCallResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the function tool call.\n" }), - "type": Schema.Literal("function_call").annotate({ - "description": "The type of the function tool call. Always `function_call`.\n" - }), - "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.Union([ - Schema.Literal("in_progress").annotate({ - "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" - }), - Schema.Literal("completed").annotate({ - "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" - }), - Schema.Literal("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({ - "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" - }), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) +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().annotate({ "expected": "an integer" })), + "text_tokens": Schema.Number.annotate({ "description": "The number of text output tokens generated by the model." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "title": "Image generation output token details", + "description": "The output token details for the image generation.", + "identifier": "ImageGenOutputTokensDetails" +}) +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().annotate({ "expected": "an integer" }) + ), + "image_tokens": Schema.Number.annotate({ "description": "The number of image tokens in the input prompt." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) }).annotate({ - "title": "Function tool call", - "description": - "A tool call to run a function. See the \n[function calling guide](/docs/guides/function-calling) for more information.\n" + "title": "Input usage details", + "description": "The input tokens detailed information for the image generation.", + "identifier": "ImageGenInputUsageDetails" }) -export type GraderPython = { - readonly "type": "python" - readonly "name": string - readonly "source": string - readonly "image_tag"?: string -} -export const GraderPython = Schema.Struct({ - "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "source": Schema.String.annotate({ "description": "The source code of the python script." }), - "image_tag": Schema.optionalKey( - Schema.String.annotate({ "description": "The image tag to use for the python script." }) - ) -}).annotate({ - "title": "PythonGrader", - "description": "A PythonGrader object that runs a python script on the input.\n" -}) -export type GraderStringCheck = { - readonly "type": "string_check" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "operation": "eq" | "ne" | "like" | "ilike" -} -export const GraderStringCheck = Schema.Struct({ - "type": Schema.Literal("string_check").annotate({ - "description": "The object type, which is always `string_check`." - }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), - "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), - "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ - "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." - }) -}).annotate({ - "title": "StringCheckGrader", - "description": - "A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.\n" -}) -export type GraderTextSimilarity = { - readonly "type": "text_similarity" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "evaluation_metric": - | "cosine" - | "fuzzy_match" - | "bleu" - | "gleu" - | "meteor" - | "rouge_1" - | "rouge_2" - | "rouge_3" - | "rouge_4" - | "rouge_5" - | "rouge_l" -} -export const GraderTextSimilarity = Schema.Struct({ - "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The text being graded." }), - "reference": Schema.String.annotate({ "description": "The text being graded against." }), - "evaluation_metric": Schema.Literals([ - "cosine", - "fuzzy_match", - "bleu", - "gleu", - "meteor", - "rouge_1", - "rouge_2", - "rouge_3", - "rouge_4", - "rouge_5", - "rouge_l" - ]).annotate({ - "description": - "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" - }) -}).annotate({ - "title": "TextSimilarityGrader", - "description": "A TextSimilarityGrader object which grades text based on similarity metrics.\n" -}) -export type Group = { - readonly "object": "group" - readonly "id": string - readonly "name": string - readonly "created_at": number - readonly "scim_managed": boolean -} -export const Group = Schema.Struct({ - "object": Schema.Literal("group").annotate({ "description": "Always `group`." }), - "id": Schema.String.annotate({ "description": "Identifier for the group." }), - "name": Schema.String.annotate({ "description": "Display name of the group." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the group was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "scim_managed": Schema.Boolean.annotate({ "description": "Whether the group is managed through SCIM." }) -}).annotate({ "description": "Summary information about a group returned in role assignment responses." }) -export type GroupDeletedResource = { - readonly "object": "group.deleted" - readonly "id": string - readonly "deleted": boolean -} -export const GroupDeletedResource = Schema.Struct({ - "object": Schema.Literal("group.deleted").annotate({ "description": "Always `group.deleted`." }), - "id": Schema.String.annotate({ "description": "Identifier of the deleted group." }), - "deleted": Schema.Boolean.annotate({ "description": "Whether the group was deleted." }) -}).annotate({ "description": "Confirmation payload returned after deleting a group." }) -export type GroupResourceWithSuccess = { - readonly "id": string - readonly "name": string - readonly "created_at": number - readonly "is_scim_managed": boolean -} -export const GroupResourceWithSuccess = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier for the group." }), - "name": Schema.String.annotate({ "description": "Updated display name for the group." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the group was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "is_scim_managed": Schema.Boolean.annotate({ - "description": "Whether the group is managed through SCIM and controlled by your identity provider." - }) -}).annotate({ "description": "Response returned after updating a group." }) -export type GroupResponse = { - readonly "id": string - readonly "name": string - readonly "created_at": number - readonly "is_scim_managed": boolean - readonly "group_type": string -} -export const GroupResponse = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier for the group." }), - "name": Schema.String.annotate({ "description": "Display name of the group." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the group was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "is_scim_managed": Schema.Boolean.annotate({ - "description": "Whether the group is managed through SCIM and controlled by your identity provider." - }), - "group_type": Schema.String.annotate({ "description": "The type of the group." }) -}).annotate({ "description": "Details about an organization group." }) -export type GroupUser = { readonly "id": string; readonly "name": string; readonly "email": string | null } -export const GroupUser = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "name": Schema.String.annotate({ "description": "The name of the user." }), - "email": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The email address of the user." }) -}).annotate({ "description": "Represents an individual user returned when inspecting group membership." }) -export type GroupUserAssignment = { - readonly "object": "group.user" - readonly "user_id": string - readonly "group_id": string -} -export const GroupUserAssignment = Schema.Struct({ - "object": Schema.Literal("group.user").annotate({ "description": "Always `group.user`." }), - "user_id": Schema.String.annotate({ "description": "Identifier of the user that was added." }), - "group_id": Schema.String.annotate({ "description": "Identifier of the group the user was added to." }) -}).annotate({ "description": "Confirmation payload returned after adding a user to a group." }) -export type GroupUserDeletedResource = { readonly "object": "group.user.deleted"; readonly "deleted": boolean } -export const GroupUserDeletedResource = Schema.Struct({ - "object": Schema.Literal("group.user.deleted").annotate({ "description": "Always `group.user.deleted`." }), - "deleted": Schema.Boolean.annotate({ "description": "Whether the group membership was removed." }) -}).annotate({ "description": "Confirmation payload returned after removing a user from a group." }) -export type HostedToolPermission = { readonly "enabled": boolean } -export const HostedToolPermission = Schema.Struct({ - "enabled": Schema.Boolean.annotate({ "description": "Whether the hosted tool is enabled for the project." }) -}).annotate({ "description": "Permission state for a single hosted tool on a project." }) -export type HostedToolPermissionUpdate = { readonly "enabled": boolean } -export const HostedToolPermissionUpdate = Schema.Struct({ - "enabled": Schema.Boolean.annotate({ "description": "Whether to enable the hosted tool for the project." }) -}) -export type Image = { readonly "b64_json"?: string; readonly "url"?: string; readonly "revised_prompt"?: string } -export const Image = Schema.Struct({ - "b64_json": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if `response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`." - }) - ), - "url": Schema.optionalKey( - Schema.String.annotate({ - "description": - "When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response_format` is set to `url` (default value). Unsupported for the GPT image models.", - "format": "uri" - }) - ), - "revised_prompt": Schema.optionalKey( - Schema.String.annotate({ - "description": "For `dall-e-3` only, the revised prompt that was used to generate the image." - }) - ) -}).annotate({ "description": "Represents the content or the URL of an image generated by the OpenAI API." }) export type ImageEditPartialImageEvent = { readonly "type": "image_edit.partial_image" readonly "b64_json": string @@ -2557,7 +3645,7 @@ export const ImageEditPartialImageEvent = Schema.Struct({ "created_at": Schema.Number.annotate({ "description": "The Unix timestamp when the event was created.\n", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "size": Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"]).annotate({ "description": "The size of the requested edited image.\n" }), @@ -2571,8 +3659,39 @@ export const ImageEditPartialImageEvent = Schema.Struct({ "description": "The output format for the requested edited image.\n" }), "partial_image_index": Schema.Number.annotate({ "description": "0-based index for the partial image (streaming).\n" }) - .check(Schema.isInt()) -}).annotate({ "description": "Emitted when a partial image is available during image editing streaming.\n" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a partial image is available during image editing streaming.\n", + "identifier": "ImageEditPartialImageEvent" +}) +export type ImagesUsage = { + readonly "total_tokens": number + readonly "input_tokens": number + readonly "output_tokens": number + readonly "input_tokens_details": { readonly "text_tokens": number; readonly "image_tokens": number } +} +export const ImagesUsage = Schema.Struct({ + "total_tokens": Schema.Number.annotate({ + "description": "The total number of tokens (images and text) used for the image generation.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "input_tokens": Schema.Number.annotate({ + "description": "The number of tokens (images and text) in the input prompt." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "output_tokens": Schema.Number.annotate({ "description": "The number of image tokens in the output image." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "input_tokens_details": Schema.Struct({ + "text_tokens": Schema.Number.annotate({ "description": "The number of text tokens in the input prompt." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "image_tokens": Schema.Number.annotate({ "description": "The number of image tokens in the input prompt." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).annotate({ "description": "The input tokens detailed information for the image generation." }) +}).annotate({ + "description": "For the GPT image models only, the token usage information for the image generation.\n", + "identifier": "ImagesUsage" +}) export type ImageGenPartialImageEvent = { readonly "type": "image_generation.partial_image" readonly "b64_json": string @@ -2593,7 +3712,7 @@ export const ImageGenPartialImageEvent = Schema.Struct({ "created_at": Schema.Number.annotate({ "description": "The Unix timestamp when the event was created.\n", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "size": Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"]).annotate({ "description": "The size of the requested image.\n" }), @@ -2607,812 +3726,781 @@ export const ImageGenPartialImageEvent = Schema.Struct({ "description": "The output format for the requested image.\n" }), "partial_image_index": Schema.Number.annotate({ "description": "0-based index for the partial image (streaming).\n" }) - .check(Schema.isInt()) -}).annotate({ "description": "Emitted when a partial image is available during image generation streaming.\n" }) -export type ImageGenToolCall = { - readonly "type": "image_generation_call" - readonly "id": string - readonly "status": "in_progress" | "completed" | "generating" | "failed" - readonly "result": string | null -} -export const ImageGenToolCall = Schema.Struct({ - "type": Schema.Literal("image_generation_call").annotate({ - "description": "The type of the image generation call. Always `image_generation_call`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the image generation call.\n" }), - "status": Schema.Literals(["in_progress", "completed", "generating", "failed"]).annotate({ - "description": "The status of the image generation call.\n" - }), - "result": Schema.Union([ - Schema.String.annotate({ "description": "The generated image encoded in base64.\n" }), - Schema.Null - ]) -}).annotate({ "title": "Image generation call", "description": "An image generation request made by the model.\n" }) -export type ImageRefParam = { readonly "image_url": string; readonly "file_id"?: string } | { - readonly "file_id": string - readonly "image_url"?: string + .check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a partial image is available during image generation streaming.\n", + "identifier": "ImageGenPartialImageEvent" +}) +export type CreateImageVariationRequest = { + readonly "image": string + readonly "model"?: string | "dall-e-2" | null + readonly "n"?: number | null + readonly "response_format"?: "url" | "b64_json" | null + readonly "size"?: "256x256" | "512x512" | "1024x1024" | null + readonly "user"?: string } -export const ImageRefParam = Schema.Union([ - Schema.Struct({ - "image_url": Schema.String.annotate({ - "description": "A fully qualified URL or base64-encoded data URL.", - "format": "uri" - }).check(Schema.isMaxLength(20971520)), - "file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The File API ID of an uploaded image to use as input." }) - ) - }).annotate({ +export const CreateImageVariationRequest = Schema.Struct({ + "image": Schema.String.annotate({ "description": - "Reference an input image by either URL or uploaded file ID.\nProvide exactly one of `image_url` or `file_id`.\n" + "The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.", + "format": "binary" }), - Schema.Struct({ - "file_id": Schema.String.annotate({ "description": "The File API ID of an uploaded image to use as input." }), - "image_url": Schema.optionalKey( - Schema.String.annotate({ "description": "A fully qualified URL or base64-encoded data URL.", "format": "uri" }) - .check(Schema.isMaxLength(20971520)) - ) - }).annotate({ - "description": - "Reference an input image by either URL or uploaded file ID.\nProvide exactly one of `image_url` or `file_id`.\n" - }) -]) -export type ImagesUsage = { - readonly "total_tokens": number - readonly "input_tokens": number - readonly "output_tokens": number - readonly "input_tokens_details": { readonly "text_tokens": number; readonly "image_tokens": number } -} -export const ImagesUsage = Schema.Struct({ - "total_tokens": Schema.Number.annotate({ - "description": "The total number of tokens (images and text) used for the image generation.\n" - }).check(Schema.isInt()), - "input_tokens": Schema.Number.annotate({ - "description": "The number of tokens (images and text) in the input prompt." - }).check(Schema.isInt()), - "output_tokens": Schema.Number.annotate({ "description": "The number of image tokens in the output image." }).check( - Schema.isInt() - ), - "input_tokens_details": 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( - Schema.isInt() - ) - }).annotate({ "description": "The input tokens detailed information for the image generation." }) -}).annotate({ "description": "For the GPT image models only, the token usage information for the image generation.\n" }) -export type InputAudio = { - readonly "type": "input_audio" - readonly "input_audio": { readonly "data": string; readonly "format": "mp3" | "wav" } -} -export const InputAudio = Schema.Struct({ - "type": Schema.Literal("input_audio").annotate({ - "description": "The type of the input item. Always `input_audio`.\n" - }), - "input_audio": Schema.Struct({ - "data": Schema.String.annotate({ "description": "Base64-encoded audio data.\n" }), - "format": Schema.Literals(["mp3", "wav"]).annotate({ - "description": "The format of the audio data. Currently supported formats are `mp3` and\n`wav`.\n" - }) - }) -}).annotate({ "title": "Input audio", "description": "An audio input to the model.\n" }) -export type Invite = { - readonly "object": "organization.invite" - readonly "id": string - readonly "email": string - readonly "role": "owner" | "reader" - readonly "status": "accepted" | "expired" | "pending" - readonly "created_at": number - readonly "expires_at"?: number | null - readonly "accepted_at"?: number | null - readonly "projects": ReadonlyArray<{ readonly "id": string; readonly "role": "member" | "owner" }> -} -export const Invite = Schema.Struct({ - "object": Schema.Literal("organization.invite").annotate({ - "description": "The object type, which is always `organization.invite`" - }), - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "email": Schema.String.annotate({ "description": "The email address of the individual to whom the invite was sent" }), - "role": Schema.Literals(["owner", "reader"]).annotate({ "description": "`owner` or `reader`" }), - "status": Schema.Literals(["accepted", "expired", "pending"]).annotate({ - "description": "`accepted`,`expired`, or `pending`" - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the invite was sent.", - "format": "unixtime" - }).check(Schema.isInt()), - "expires_at": Schema.optionalKey( - Schema.Union([Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt()), Schema.Null]).annotate({ - "description": "The Unix timestamp (in seconds) of when the invite expires." - }) - ), - "accepted_at": Schema.optionalKey( - Schema.Union([Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt()), Schema.Null]).annotate({ - "description": "The Unix timestamp (in seconds) of when the invite was accepted." - }) - ), - "projects": Schema.Array( - Schema.Struct({ - "id": Schema.String.annotate({ "description": "Project's public ID" }), - "role": Schema.Literals(["member", "owner"]).annotate({ "description": "Project membership role" }) - }) - ).annotate({ "description": "The projects that were granted membership upon acceptance of the invite." }) -}).annotate({ "description": "Represents an individual `invite` to the organization." }) -export type InviteDeleteResponse = { - readonly "object": "organization.invite.deleted" - readonly "id": string - readonly "deleted": boolean -} -export const InviteDeleteResponse = Schema.Struct({ - "object": Schema.Literal("organization.invite.deleted").annotate({ - "description": "The object type, which is always `organization.invite.deleted`" - }), - "id": Schema.String, - "deleted": Schema.Boolean -}) -export type InviteProjectGroupBody = { readonly "group_id": string; readonly "role": string } -export const InviteProjectGroupBody = Schema.Struct({ - "group_id": Schema.String.annotate({ "description": "Identifier of the group to add to the project." }), - "role": Schema.String.annotate({ "description": "Identifier of the project role to grant to the group." }) -}).annotate({ "description": "Request payload for granting a group access to a project." }) -export type InviteRequest = { - readonly "email": string - readonly "role": "reader" | "owner" - readonly "projects"?: ReadonlyArray<{ readonly "id": string; readonly "role": "member" | "owner" }> -} -export const InviteRequest = Schema.Struct({ - "email": Schema.String.annotate({ "description": "Send an email to this address" }), - "role": Schema.Literals(["reader", "owner"]).annotate({ "description": "`owner` or `reader`" }), - "projects": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "id": Schema.String.annotate({ "description": "Project's public ID" }), - "role": Schema.Literals(["member", "owner"]).annotate({ "description": "Project membership role" }) - }) - ).annotate({ - "description": - "An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. If empty list is passed, the user will not be invited to any projects, including the default one." - }) - ) -}) -export type LocalShellToolCallOutput = { - readonly "type": "local_shell_call_output" - readonly "id": string - readonly "output": string - readonly "status"?: "in_progress" | "completed" | "incomplete" | null - readonly "call_id": unknown -} -export const LocalShellToolCallOutput = Schema.Struct({ - "type": Schema.Literal("local_shell_call_output").annotate({ - "description": "The type of the local shell tool call output. Always `local_shell_call_output`.\n" - }), - "id": Schema.String.annotate({ - "description": "The unique ID of the local shell tool call generated by the model.\n" - }), - "output": Schema.String.annotate({ "description": "A JSON string of the output of the local shell tool call.\n" }), - "status": Schema.optionalKey( + "model": Schema.optionalKey( Schema.Union([ - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": "The status of the item. One of `in_progress`, `completed`, or `incomplete`.\n" + Schema.Union([Schema.String, Schema.Literal("dall-e-2")]).annotate({ + "description": "The model to use for image generation. Only `dall-e-2` is supported at this time." }), Schema.Null ]) ), - "call_id": Schema.Unknown -}).annotate({ "title": "Local shell call output", "description": "The output of a local shell tool call.\n" }) -export type LogProbProperties = { - readonly "token": string - readonly "logprob": number - readonly "bytes": ReadonlyArray -} -export const LogProbProperties = Schema.Struct({ - "token": Schema.String.annotate({ "description": "The token that was used to generate the log probability.\n" }), - "logprob": Schema.Number.annotate({ "description": "The log probability of the token.\n" }).check(Schema.isFinite()), - "bytes": Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "description": "The bytes that were used to generate the log probability.\n" - }) -}).annotate({ "description": "A log probability object.\n" }) -export type MCPApprovalRequest = { - readonly "type": "mcp_approval_request" - readonly "id": string - readonly "server_label": string - readonly "name": string - readonly "arguments": string -} -export const MCPApprovalRequest = Schema.Struct({ - "type": Schema.Literal("mcp_approval_request").annotate({ - "description": "The type of the item. Always `mcp_approval_request`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the approval request.\n" }), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server making the request.\n" }), - "name": Schema.String.annotate({ "description": "The name of the tool to run.\n" }), - "arguments": Schema.String.annotate({ "description": "A JSON string of arguments for the tool.\n" }) -}).annotate({ "title": "MCP approval request", "description": "A request for human approval of a tool invocation.\n" }) -export type MCPApprovalResponseResource = { - readonly "type": "mcp_approval_response" - readonly "id": string - readonly "approval_request_id": string - readonly "approve": boolean - readonly "reason"?: string | null - readonly "request_id": unknown -} -export const MCPApprovalResponseResource = Schema.Struct({ - "type": Schema.Literal("mcp_approval_response").annotate({ - "description": "The type of the item. Always `mcp_approval_response`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the approval response\n" }), - "approval_request_id": Schema.String.annotate({ "description": "The ID of the approval request being answered.\n" }), - "approve": Schema.Boolean.annotate({ "description": "Whether the request was approved.\n" }), - "reason": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "Optional reason for the decision.\n" }), Schema.Null]) - ), - "request_id": Schema.Unknown -}).annotate({ "title": "MCP approval response", "description": "A response to an MCP approval request.\n" }) -export type MCPListToolsTool = { - readonly "name": string - readonly "description"?: string | null - readonly "input_schema": {} - readonly "annotations"?: {} | null -} -export const MCPListToolsTool = Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the tool.\n" }), - "description": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "The description of the tool.\n" }), Schema.Null]) - ), - "input_schema": Schema.Struct({}).annotate({ "description": "The JSON schema describing the tool's input.\n" }), - "annotations": Schema.optionalKey( + "n": Schema.optionalKey( Schema.Union([ - Schema.Struct({}).annotate({ "description": "Additional annotations about the tool.\n" }), + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(10).annotate({ "expected": "a value less than or equal to 10" })), Schema.Null - ]) - ) -}).annotate({ "title": "MCP list tools tool", "description": "A tool available on an MCP server.\n" }) -export type MCPToolCall = { - readonly "type": "mcp_call" - readonly "id": string - readonly "server_label": string - readonly "name": string - readonly "arguments": string - readonly "output"?: string | null - readonly "error"?: string | null - readonly "status"?: "in_progress" | "completed" | "incomplete" | "calling" | "failed" - readonly "approval_request_id"?: string | null -} -export const MCPToolCall = Schema.Struct({ - "type": Schema.Literal("mcp_call").annotate({ "description": "The type of the item. Always `mcp_call`.\n" }), - "id": Schema.String.annotate({ "description": "The unique ID of the tool call.\n" }), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server running the tool.\n" }), - "name": Schema.String.annotate({ "description": "The name of the tool that was run.\n" }), - "arguments": Schema.String.annotate({ "description": "A JSON string of the arguments passed to the tool.\n" }), - "output": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "The output from the tool call.\n" }), Schema.Null]) - ), - "error": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "The error from the tool call, if any.\n" }), Schema.Null]) + ]).annotate({ "description": "The number of images to generate. Must be between 1 and 10." }) ), - "status": Schema.optionalKey( - Schema.Literals(["in_progress", "completed", "incomplete", "calling", "failed"]).annotate({ + "response_format": Schema.optionalKey( + Schema.Union([Schema.Literal("url"), Schema.Literal("b64_json"), Schema.Null]).annotate({ "description": - "The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`, or `failed`.\n" + "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." }) ), - "approval_request_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "Unique identifier for the MCP tool call approval request.\nInclude this value in a subsequent `mcp_approval_response` input to approve or reject the corresponding tool call.\n" - }), - Schema.Null - ]) - ) -}).annotate({ "title": "MCP tool call", "description": "An invocation of a tool on an MCP server.\n" }) -export type MCPToolFilter = { readonly "tool_names"?: ReadonlyArray; readonly "read_only"?: boolean } -export const MCPToolFilter = Schema.Struct({ - "tool_names": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ "title": "MCP allowed tools", "description": "List of allowed tool names." }) + "size": Schema.optionalKey( + Schema.Union([Schema.Literal("256x256"), Schema.Literal("512x512"), Schema.Literal("1024x1024"), Schema.Null]) + .annotate({ + "description": "The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`." + }) ), - "read_only": Schema.optionalKey( - Schema.Boolean.annotate({ + "user": Schema.optionalKey( + Schema.String.annotate({ "description": - "Indicates whether or not a tool modifies data or is read-only. If an\nMCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),\nit will match this filter.\n" + "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" }) ) -}).annotate({ "title": "MCP tool filter", "description": "A filter object to specify which tools are allowed.\n" }) -export type MessageContentImageFileObject = { - readonly "type": "image_file" - readonly "image_file": { readonly "file_id": string; readonly "detail"?: "auto" | "low" | "high" } +}).annotate({ "identifier": "CreateImageVariationRequest" }) +export type Model = { + readonly "id": string + readonly "created": number + readonly "object": "model" + readonly "owned_by": string + readonly [x: string]: Schema.Json } -export const MessageContentImageFileObject = Schema.Struct({ - "type": Schema.Literal("image_file").annotate({ "description": "Always `image_file`." }), - "image_file": Schema.Struct({ - "file_id": Schema.String.annotate({ - "description": - "The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose=\"vision\"` when uploading the File if you need to later display the file content." +export const Model = Schema.StructWithRest( + Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The model identifier, which can be referenced in the API endpoints." }), - "detail": Schema.optionalKey( - Schema.Literals(["auto", "low", "high"]).annotate({ - "description": - "Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`." - }) - ) - }) -}).annotate({ - "title": "Image file", - "description": "References an image [File](/docs/api-reference/files) in the content of a message." -}) -export type MessageContentImageUrlObject = { - readonly "type": "image_url" - readonly "image_url": { readonly "url": string; readonly "detail"?: "auto" | "low" | "high" } -} -export const MessageContentImageUrlObject = Schema.Struct({ - "type": Schema.Literal("image_url").annotate({ "description": "The type of the content part." }), - "image_url": Schema.Struct({ - "url": Schema.String.annotate({ - "description": "The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.", - "format": "uri" - }), - "detail": Schema.optionalKey( - Schema.Literals(["auto", "low", "high"]).annotate({ - "description": - "Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`" - }) - ) - }) -}).annotate({ "title": "Image URL", "description": "References an image URL in the content of a message." }) -export type MessageContentRefusalObject = { readonly "type": "refusal"; readonly "refusal": string } -export const MessageContentRefusalObject = Schema.Struct({ - "type": Schema.Literal("refusal").annotate({ "description": "Always `refusal`." }), - "refusal": Schema.String -}).annotate({ "title": "Refusal", "description": "The refusal content generated by the assistant." }) -export type MessageContentTextAnnotationsFileCitationObject = { - readonly "type": "file_citation" - readonly "text": string - readonly "file_citation": { readonly "file_id": string } - readonly "start_index": number - readonly "end_index": number -} -export const MessageContentTextAnnotationsFileCitationObject = Schema.Struct({ - "type": Schema.Literal("file_citation").annotate({ "description": "Always `file_citation`." }), - "text": Schema.String.annotate({ "description": "The text in the message content that needs to be replaced." }), - "file_citation": Schema.Struct({ - "file_id": Schema.String.annotate({ "description": "The ID of the specific File the citation is from." }) + "created": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) when the model was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "object": Schema.Literal("model").annotate({ "description": "The object type, which is always \"model\"." }), + "owned_by": Schema.String.annotate({ "description": "The organization that owns the model." }) }), - "start_index": Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "end_index": Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) -}).annotate({ - "title": "File citation", - "description": - "A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the \"file_search\" tool to search files." + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ + "title": "Model", + "description": "Describes an OpenAI model offering that can be used with the API.", + "identifier": "Model" }) -export type MessageContentTextAnnotationsFilePathObject = { - readonly "type": "file_path" - readonly "text": string - readonly "file_path": { readonly "file_id": string } - readonly "start_index": number - readonly "end_index": number +export type DeleteModelResponse = { readonly "id": string; readonly "deleted": boolean; readonly "object": string } +export const DeleteModelResponse = Schema.Struct({ + "id": Schema.String, + "deleted": Schema.Boolean, + "object": Schema.String +}).annotate({ "identifier": "DeleteModelResponse" }) +export type CreateModerationRequest = { + readonly "input": + | string + | ReadonlyArray + | ReadonlyArray< + { readonly "type": "image_url"; readonly "image_url": { readonly "url": string } } | { + readonly "type": "text" + readonly "text": string + } + > + readonly "model"?: + | string + | "omni-moderation-latest" + | "omni-moderation-2024-09-26" + | "text-moderation-latest" + | "text-moderation-stable" } -export const MessageContentTextAnnotationsFilePathObject = Schema.Struct({ - "type": Schema.Literal("file_path").annotate({ "description": "Always `file_path`." }), - "text": Schema.String.annotate({ "description": "The text in the message content that needs to be replaced." }), - "file_path": Schema.Struct({ - "file_id": Schema.String.annotate({ "description": "The ID of the file that was generated." }) +export const CreateModerationRequest = Schema.Struct({ + "input": Schema.Union([ + Schema.String.annotate({ "description": "A string of text to classify for moderation." }), + Schema.Array(Schema.String).annotate({ "description": "An array of strings to classify for moderation." }), + Schema.Array(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("image_url").annotate({ "description": "Always `image_url`." }), + "image_url": Schema.Struct({ + "url": Schema.String.annotate({ + "description": "Either a URL of the image or the base64 encoded image data.", + "format": "uri" + }) + }).annotate({ "description": "Contains either an image URL or a data URL for a base64 encoded image." }) + }).annotate({ "description": "An object describing an image to classify." }), + Schema.Struct({ + "type": Schema.Literal("text").annotate({ "description": "Always `text`." }), + "text": Schema.String.annotate({ "description": "A string of text to classify." }) + }).annotate({ "description": "An object describing text to classify." }) + ], { mode: "oneOf" })).annotate({ "description": "An array of multi-modal inputs to the moderation model." }) + ], { mode: "oneOf" }).annotate({ + "description": + "Input (or inputs) to classify. Can be a single string, an array of strings, or\nan array of multi-modal input objects similar to other models.\n" }), - "start_index": Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)), - "end_index": Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) -}).annotate({ - "title": "File path", - "description": - "A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file." -}) -export type MessageDeltaContentImageFileObject = { - readonly "index": number - readonly "type": "image_file" - readonly "image_file"?: { readonly "file_id"?: string; readonly "detail"?: "auto" | "low" | "high" } + "model": Schema.optionalKey( + Schema.Union([ + Schema.String, + Schema.Literals([ + "omni-moderation-latest", + "omni-moderation-2024-09-26", + "text-moderation-latest", + "text-moderation-stable" + ]) + ]).annotate({ + "description": + "The content moderation model you would like to use. Learn more in\n[the moderation guide](/docs/guides/moderation), and learn about\navailable models [here](/docs/models#moderation).\n" + }) + ) +}).annotate({ "identifier": "CreateModerationRequest" }) +export type CreateModerationResponse = { + readonly "id": string + readonly "model": string + readonly "results": ReadonlyArray< + { + readonly "flagged": boolean + readonly "categories": { + readonly "hate": boolean + readonly "hate/threatening": boolean + readonly "harassment": boolean + readonly "harassment/threatening": boolean + readonly "illicit": boolean | null + readonly "illicit/violent": boolean | null + readonly "self-harm": boolean + readonly "self-harm/intent": boolean + readonly "self-harm/instructions": boolean + readonly "sexual": boolean + readonly "sexual/minors": boolean + readonly "violence": boolean + readonly "violence/graphic": boolean + } + readonly "category_scores": { + readonly "hate": number + readonly "hate/threatening": number + readonly "harassment": number + readonly "harassment/threatening": number + readonly "illicit": number + readonly "illicit/violent": number + readonly "self-harm": number + readonly "self-harm/intent": number + readonly "self-harm/instructions": number + readonly "sexual": number + readonly "sexual/minors": number + readonly "violence": number + readonly "violence/graphic": number + } + readonly "category_applied_input_types": { + readonly "hate": ReadonlyArray<"text"> + readonly "hate/threatening": ReadonlyArray<"text"> + readonly "harassment": ReadonlyArray<"text"> + readonly "harassment/threatening": ReadonlyArray<"text"> + readonly "illicit": ReadonlyArray<"text"> + readonly "illicit/violent": ReadonlyArray<"text"> + readonly "self-harm": ReadonlyArray<"text" | "image"> + readonly "self-harm/intent": ReadonlyArray<"text" | "image"> + readonly "self-harm/instructions": ReadonlyArray<"text" | "image"> + readonly "sexual": ReadonlyArray<"text" | "image"> + readonly "sexual/minors": ReadonlyArray<"text"> + readonly "violence": ReadonlyArray<"text" | "image"> + readonly "violence/graphic": ReadonlyArray<"text" | "image"> + } + } + > } -export const MessageDeltaContentImageFileObject = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the content part in the message." }).check( - Schema.isInt() - ), - "type": Schema.Literal("image_file").annotate({ "description": "Always `image_file`." }), - "image_file": Schema.optionalKey(Schema.Struct({ - "file_id": Schema.optionalKey( - Schema.String.annotate({ +export const CreateModerationResponse = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique identifier for the moderation request." }), + "model": Schema.String.annotate({ "description": "The model used to generate the moderation results." }), + "results": Schema.Array(Schema.Struct({ + "flagged": Schema.Boolean.annotate({ "description": "Whether any of the below categories are flagged." }), + "categories": Schema.Struct({ + "hate": Schema.Boolean.annotate({ "description": - "The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose=\"vision\"` when uploading the File if you need to later display the file content." - }) - ), - "detail": Schema.optionalKey( - Schema.Literals(["auto", "low", "high"]).annotate({ + "Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment." + }), + "hate/threatening": Schema.Boolean.annotate({ "description": - "Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`." - }) - ) - })) -}).annotate({ - "title": "Image file", - "description": "References an image [File](/docs/api-reference/files) in the content of a message." -}) -export type MessageDeltaContentImageUrlObject = { - readonly "index": number - readonly "type": "image_url" - readonly "image_url"?: { readonly "url"?: string; readonly "detail"?: "auto" | "low" | "high" } -} -export const MessageDeltaContentImageUrlObject = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the content part in the message." }).check( - Schema.isInt() - ), - "type": Schema.Literal("image_url").annotate({ "description": "Always `image_url`." }), - "image_url": Schema.optionalKey(Schema.Struct({ - "url": Schema.optionalKey( - Schema.String.annotate({ - "description": "The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.", - "format": "uri" - }) - ), - "detail": Schema.optionalKey( - Schema.Literals(["auto", "low", "high"]).annotate({ + "Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste." + }), + "harassment": Schema.Boolean.annotate({ + "description": "Content that expresses, incites, or promotes harassing language towards any target." + }), + "harassment/threatening": Schema.Boolean.annotate({ + "description": "Harassment content that also includes violence or serious harm towards any target." + }), + "illicit": Schema.Union([ + Schema.Boolean.annotate({ + "description": + "Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, \"how to shoplift\" would fit this category." + }), + Schema.Null + ]), + "illicit/violent": Schema.Union([ + Schema.Boolean.annotate({ + "description": + "Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon." + }), + Schema.Null + ]), + "self-harm": Schema.Boolean.annotate({ + "description": + "Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders." + }), + "self-harm/intent": Schema.Boolean.annotate({ + "description": + "Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders." + }), + "self-harm/instructions": Schema.Boolean.annotate({ + "description": + "Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts." + }), + "sexual": Schema.Boolean.annotate({ "description": - "Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`." + "Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness)." + }), + "sexual/minors": Schema.Boolean.annotate({ + "description": "Sexual content that includes an individual who is under 18 years old." + }), + "violence": Schema.Boolean.annotate({ + "description": "Content that depicts death, violence, or physical injury." + }), + "violence/graphic": Schema.Boolean.annotate({ + "description": "Content that depicts death, violence, or physical injury in graphic detail." }) - ) - })) -}).annotate({ "title": "Image URL", "description": "References an image URL in the content of a message." }) -export type MessageDeltaContentRefusalObject = { - readonly "index": number - readonly "type": "refusal" - readonly "refusal"?: string -} -export const MessageDeltaContentRefusalObject = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the refusal part in the message." }).check( - Schema.isInt() - ), - "type": Schema.Literal("refusal").annotate({ "description": "Always `refusal`." }), - "refusal": Schema.optionalKey(Schema.String) -}).annotate({ "title": "Refusal", "description": "The refusal content that is part of a message." }) -export type MessageDeltaContentTextAnnotationsFileCitationObject = { - readonly "index": number - readonly "type": "file_citation" - readonly "text"?: string - readonly "file_citation"?: { readonly "file_id"?: string; readonly "quote"?: string } - readonly "start_index"?: number - readonly "end_index"?: number -} -export const MessageDeltaContentTextAnnotationsFileCitationObject = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the annotation in the text content part." }).check( - Schema.isInt() - ), - "type": Schema.Literal("file_citation").annotate({ "description": "Always `file_citation`." }), - "text": Schema.optionalKey( - Schema.String.annotate({ "description": "The text in the message content that needs to be replaced." }) - ), - "file_citation": Schema.optionalKey( - Schema.Struct({ - "file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the specific File the citation is from." }) + }).annotate({ "description": "A list of the categories, and whether they are flagged or not." }), + "category_scores": Schema.Struct({ + "hate": Schema.Number.annotate({ "description": "The score for the category 'hate'." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) ), - "quote": Schema.optionalKey(Schema.String.annotate({ "description": "The specific quote in the file." })) - }) - ), - "start_index": Schema.optionalKey(Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0))), - "end_index": Schema.optionalKey(Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0))) + "hate/threatening": Schema.Number.annotate({ "description": "The score for the category 'hate/threatening'." }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "harassment": Schema.Number.annotate({ "description": "The score for the category 'harassment'." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "harassment/threatening": Schema.Number.annotate({ + "description": "The score for the category 'harassment/threatening'." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "illicit": Schema.Number.annotate({ "description": "The score for the category 'illicit'." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "illicit/violent": Schema.Number.annotate({ "description": "The score for the category 'illicit/violent'." }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "self-harm": Schema.Number.annotate({ "description": "The score for the category 'self-harm'." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "self-harm/intent": Schema.Number.annotate({ "description": "The score for the category 'self-harm/intent'." }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "self-harm/instructions": Schema.Number.annotate({ + "description": "The score for the category 'self-harm/instructions'." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "sexual": Schema.Number.annotate({ "description": "The score for the category 'sexual'." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "sexual/minors": Schema.Number.annotate({ "description": "The score for the category 'sexual/minors'." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "violence": Schema.Number.annotate({ "description": "The score for the category 'violence'." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "violence/graphic": Schema.Number.annotate({ "description": "The score for the category 'violence/graphic'." }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })) + }).annotate({ "description": "A list of the categories along with their scores as predicted by model." }), + "category_applied_input_types": Schema.Struct({ + "hate": Schema.Array(Schema.Literal("text")).annotate({ + "description": "The applied input type(s) for the category 'hate'." + }), + "hate/threatening": Schema.Array(Schema.Literal("text")).annotate({ + "description": "The applied input type(s) for the category 'hate/threatening'." + }), + "harassment": Schema.Array(Schema.Literal("text")).annotate({ + "description": "The applied input type(s) for the category 'harassment'." + }), + "harassment/threatening": Schema.Array(Schema.Literal("text")).annotate({ + "description": "The applied input type(s) for the category 'harassment/threatening'." + }), + "illicit": Schema.Array(Schema.Literal("text")).annotate({ + "description": "The applied input type(s) for the category 'illicit'." + }), + "illicit/violent": Schema.Array(Schema.Literal("text")).annotate({ + "description": "The applied input type(s) for the category 'illicit/violent'." + }), + "self-harm": Schema.Array(Schema.Literals(["text", "image"])).annotate({ + "description": "The applied input type(s) for the category 'self-harm'." + }), + "self-harm/intent": Schema.Array(Schema.Literals(["text", "image"])).annotate({ + "description": "The applied input type(s) for the category 'self-harm/intent'." + }), + "self-harm/instructions": Schema.Array(Schema.Literals(["text", "image"])).annotate({ + "description": "The applied input type(s) for the category 'self-harm/instructions'." + }), + "sexual": Schema.Array(Schema.Literals(["text", "image"])).annotate({ + "description": "The applied input type(s) for the category 'sexual'." + }), + "sexual/minors": Schema.Array(Schema.Literal("text")).annotate({ + "description": "The applied input type(s) for the category 'sexual/minors'." + }), + "violence": Schema.Array(Schema.Literals(["text", "image"])).annotate({ + "description": "The applied input type(s) for the category 'violence'." + }), + "violence/graphic": Schema.Array(Schema.Literals(["text", "image"])).annotate({ + "description": "The applied input type(s) for the category 'violence/graphic'." + }) + }).annotate({ "description": "A list of the categories along with the input type(s) that the score applies to." }) + })).annotate({ "description": "A list of moderation objects." }) }).annotate({ - "title": "File citation", - "description": - "A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the \"file_search\" tool to search files." + "description": "Represents if a given text input is potentially harmful.", + "identifier": "CreateModerationResponse" }) -export type MessageDeltaContentTextAnnotationsFilePathObject = { - readonly "index": number - readonly "type": "file_path" - readonly "text"?: string - readonly "file_path"?: { readonly "file_id"?: string } - readonly "start_index"?: number - readonly "end_index"?: number +export type AdminApiKey = { + readonly "object": "organization.admin_api_key" + readonly "id": string + readonly "name"?: string | null + readonly "redacted_value": string + readonly "created_at": number + readonly "expires_at": number | null + readonly "last_used_at"?: number | null + readonly "owner": { + readonly "type"?: string + readonly "object"?: string + readonly "id"?: string + readonly "name"?: string + readonly "created_at"?: number + readonly "role"?: string + } } -export const MessageDeltaContentTextAnnotationsFilePathObject = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the annotation in the text content part." }).check( - Schema.isInt() - ), - "type": Schema.Literal("file_path").annotate({ "description": "Always `file_path`." }), - "text": Schema.optionalKey( - Schema.String.annotate({ "description": "The text in the message content that needs to be replaced." }) +export const AdminApiKey = Schema.Struct({ + "object": Schema.Literal("organization.admin_api_key").annotate({ + "description": "The object type, which is always `organization.admin_api_key`" + }), + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the API key" }) ), - "file_path": Schema.optionalKey( - Schema.Struct({ - "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the file that was generated." })) - }) + "redacted_value": Schema.String.annotate({ "description": "The redacted value of the API key" }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the API key was created", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "expires_at": Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the API key expires", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "last_used_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the API key was last used", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) ), - "start_index": Schema.optionalKey(Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0))), - "end_index": Schema.optionalKey(Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0))) -}).annotate({ - "title": "File path", - "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`." }), - "text": Schema.String.annotate({ "description": "Text content to be sent to the model" }) -}).annotate({ "title": "Text", "description": "The text content that is part of a message." }) -export type Metadata = {} | null -export const Metadata = 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 -]) -export type Model = { + "owner": Schema.Struct({ + "type": Schema.optionalKey(Schema.String.annotate({ "description": "Always `user`" })), + "object": Schema.optionalKey( + Schema.String.annotate({ "description": "The object type, which is always organization.user" }) + ), + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }) + ), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the user" })), + "created_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the user was created", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "role": Schema.optionalKey(Schema.String.annotate({ "description": "Always `owner`" })) + }) +}).annotate({ "description": "Represents an individual Admin API key in an org.", "identifier": "AdminApiKey" }) +export type AdminApiKeyCreateResponse = { + readonly "object": "organization.admin_api_key" readonly "id": string - readonly "created": number - readonly "object": "model" - readonly "owned_by": string - readonly [x: string]: unknown + readonly "name"?: string | null + readonly "redacted_value": string + readonly "created_at": number + readonly "expires_at": number | null + readonly "last_used_at"?: number | null + readonly "owner": { + readonly "type"?: string + readonly "object"?: string + readonly "id"?: string + readonly "name"?: string + readonly "created_at"?: number + readonly "role"?: string + } + readonly "value": string } -export const Model = Schema.StructWithRest( - Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The model identifier, which can be referenced in the API endpoints." - }), - "created": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) when the model was created.", +export const AdminApiKeyCreateResponse = Schema.Struct({ + "object": Schema.Literal("organization.admin_api_key").annotate({ + "description": "The object type, which is always `organization.admin_api_key`" + }), + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the API key" }) + ), + "redacted_value": Schema.String.annotate({ "description": "The redacted value of the API key" }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the API key was created", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "expires_at": Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the API key expires", "format": "unixtime" - }).check(Schema.isInt()), - "object": Schema.Literal("model").annotate({ "description": "The object type, which is always \"model\"." }), - "owned_by": Schema.String.annotate({ "description": "The organization that owns the model." }) + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "last_used_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the API key was last used", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "owner": Schema.Struct({ + "type": Schema.optionalKey(Schema.String.annotate({ "description": "Always `user`" })), + "object": Schema.optionalKey( + Schema.String.annotate({ "description": "The object type, which is always organization.user" }) + ), + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }) + ), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the user" })), + "created_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the user was created", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "role": Schema.optionalKey(Schema.String.annotate({ "description": "Always `owner`" })) }), - [Schema.Record(Schema.String, Schema.Json)] -).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.4-mini" - | "gpt-5.4-nano" - | "gpt-5.4-mini-2026-03-17" - | "gpt-5.4-nano-2026-03-17" - | "gpt-5.3-chat-latest" - | "gpt-5.2" - | "gpt-5.2-2025-12-11" - | "gpt-5.2-chat-latest" - | "gpt-5.2-pro" - | "gpt-5.2-pro-2025-12-11" - | "gpt-5.1" - | "gpt-5.1-2025-11-13" - | "gpt-5.1-codex" - | "gpt-5.1-mini" - | "gpt-5.1-chat-latest" - | "gpt-5" - | "gpt-5-mini" - | "gpt-5-nano" - | "gpt-5-2025-08-07" - | "gpt-5-mini-2025-08-07" - | "gpt-5-nano-2025-08-07" - | "gpt-5-chat-latest" - | "gpt-4.1" - | "gpt-4.1-mini" - | "gpt-4.1-nano" - | "gpt-4.1-2025-04-14" - | "gpt-4.1-mini-2025-04-14" - | "gpt-4.1-nano-2025-04-14" - | "o4-mini" - | "o4-mini-2025-04-16" - | "o3" - | "o3-2025-04-16" - | "o3-mini" - | "o3-mini-2025-01-31" - | "o1" - | "o1-2024-12-17" - | "o1-preview" - | "o1-preview-2024-09-12" - | "o1-mini" - | "o1-mini-2024-09-12" - | "gpt-4o" - | "gpt-4o-2024-11-20" - | "gpt-4o-2024-08-06" - | "gpt-4o-2024-05-13" - | "gpt-4o-audio-preview" - | "gpt-4o-audio-preview-2024-10-01" - | "gpt-4o-audio-preview-2024-12-17" - | "gpt-4o-audio-preview-2025-06-03" - | "gpt-4o-mini-audio-preview" - | "gpt-4o-mini-audio-preview-2024-12-17" - | "gpt-4o-search-preview" - | "gpt-4o-mini-search-preview" - | "gpt-4o-search-preview-2025-03-11" - | "gpt-4o-mini-search-preview-2025-03-11" - | "chatgpt-4o-latest" - | "codex-mini-latest" - | "gpt-4o-mini" - | "gpt-4o-mini-2024-07-18" - | "gpt-4-turbo" - | "gpt-4-turbo-2024-04-09" - | "gpt-4-0125-preview" - | "gpt-4-turbo-preview" - | "gpt-4-1106-preview" - | "gpt-4-vision-preview" - | "gpt-4" - | "gpt-4-0314" - | "gpt-4-0613" - | "gpt-4-32k" - | "gpt-4-32k-0314" - | "gpt-4-32k-0613" - | "gpt-3.5-turbo" - | "gpt-3.5-turbo-16k" - | "gpt-3.5-turbo-0301" - | "gpt-3.5-turbo-0613" - | "gpt-3.5-turbo-1106" - | "gpt-3.5-turbo-0125" - | "gpt-3.5-turbo-16k-0613" -export const ModelIdsShared = Schema.Union([ - Schema.String, - Schema.Literals([ - "gpt-5.4", - "gpt-5.4-mini", - "gpt-5.4-nano", - "gpt-5.4-mini-2026-03-17", - "gpt-5.4-nano-2026-03-17", - "gpt-5.3-chat-latest", - "gpt-5.2", - "gpt-5.2-2025-12-11", - "gpt-5.2-chat-latest", - "gpt-5.2-pro", - "gpt-5.2-pro-2025-12-11", - "gpt-5.1", - "gpt-5.1-2025-11-13", - "gpt-5.1-codex", - "gpt-5.1-mini", - "gpt-5.1-chat-latest", - "gpt-5", - "gpt-5-mini", - "gpt-5-nano", - "gpt-5-2025-08-07", - "gpt-5-mini-2025-08-07", - "gpt-5-nano-2025-08-07", - "gpt-5-chat-latest", - "gpt-4.1", - "gpt-4.1-mini", - "gpt-4.1-nano", - "gpt-4.1-2025-04-14", - "gpt-4.1-mini-2025-04-14", - "gpt-4.1-nano-2025-04-14", - "o4-mini", - "o4-mini-2025-04-16", - "o3", - "o3-2025-04-16", - "o3-mini", - "o3-mini-2025-01-31", - "o1", - "o1-2024-12-17", - "o1-preview", - "o1-preview-2024-09-12", - "o1-mini", - "o1-mini-2024-09-12", - "gpt-4o", - "gpt-4o-2024-11-20", - "gpt-4o-2024-08-06", - "gpt-4o-2024-05-13", - "gpt-4o-audio-preview", - "gpt-4o-audio-preview-2024-10-01", - "gpt-4o-audio-preview-2024-12-17", - "gpt-4o-audio-preview-2025-06-03", - "gpt-4o-mini-audio-preview", - "gpt-4o-mini-audio-preview-2024-12-17", - "gpt-4o-search-preview", - "gpt-4o-mini-search-preview", - "gpt-4o-search-preview-2025-03-11", - "gpt-4o-mini-search-preview-2025-03-11", - "chatgpt-4o-latest", - "codex-mini-latest", - "gpt-4o-mini", - "gpt-4o-mini-2024-07-18", - "gpt-4-turbo", - "gpt-4-turbo-2024-04-09", - "gpt-4-0125-preview", - "gpt-4-turbo-preview", - "gpt-4-1106-preview", - "gpt-4-vision-preview", - "gpt-4", - "gpt-4-0314", - "gpt-4-0613", - "gpt-4-32k", - "gpt-4-32k-0314", - "gpt-4-32k-0613", - "gpt-3.5-turbo", - "gpt-3.5-turbo-16k", - "gpt-3.5-turbo-0301", - "gpt-3.5-turbo-0613", - "gpt-3.5-turbo-1106", - "gpt-3.5-turbo-0125", - "gpt-3.5-turbo-16k-0613" - ]) -]) -export type ModifyCertificateRequest = { readonly "name"?: string } -export const ModifyCertificateRequest = Schema.Struct({ - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The updated name for the certificate" })) + "value": Schema.String.annotate({ "description": "The value of the API key. Only shown on create." }) +}).annotate({ + "description": "The newly created admin API key. The `value` field is only returned once, when the key is created.", + "identifier": "AdminApiKeyCreateResponse" }) -export type NoiseReductionType = "near_field" | "far_field" -export const NoiseReductionType = Schema.Literals(["near_field", "far_field"]).annotate({ - "description": - "Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.\n" +export type AuditLogEventType = + | "api_key.created" + | "api_key.updated" + | "api_key.deleted" + | "certificate.created" + | "certificate.updated" + | "certificate.deleted" + | "certificates.activated" + | "certificates.deactivated" + | "checkpoint.permission.created" + | "checkpoint.permission.deleted" + | "external_key.registered" + | "external_key.removed" + | "group.created" + | "group.updated" + | "group.deleted" + | "invite.sent" + | "invite.accepted" + | "invite.deleted" + | "ip_allowlist.created" + | "ip_allowlist.updated" + | "ip_allowlist.deleted" + | "ip_allowlist.config.activated" + | "ip_allowlist.config.deactivated" + | "login.succeeded" + | "login.failed" + | "logout.succeeded" + | "logout.failed" + | "organization.updated" + | "project.created" + | "project.updated" + | "project.archived" + | "project.deleted" + | "rate_limit.updated" + | "rate_limit.deleted" + | "resource.deleted" + | "tunnel.created" + | "tunnel.updated" + | "tunnel.deleted" + | "workload_identity_provider.created" + | "workload_identity_provider.updated" + | "workload_identity_provider.deleted" + | "workload_identity_provider_mapping.created" + | "workload_identity_provider_mapping.updated" + | "workload_identity_provider_mapping.deleted" + | "role.created" + | "role.updated" + | "role.deleted" + | "role.assignment.created" + | "role.assignment.deleted" + | "role.bound_to_resource" + | "role.unbound_from_resource" + | "scim.enabled" + | "scim.disabled" + | "service_account.created" + | "service_account.updated" + | "service_account.deleted" + | "user.added" + | "user.updated" + | "user.deleted" + | "tenant.metadata.updated" + | "tenant.microsoft_entra_mapping.upserted" + | "tenant.microsoft_entra_mapping.deleted" + | "tenant.workload_identity.provider.created" + | "tenant.workload_identity.provider.updated" + | "tenant.workload_identity.provider.archived" + | "tenant.workload_identity.mapping.created" + | "tenant.workload_identity.mapping.updated" + | "tenant.workload_identity.mapping.archived" + | "tenant.workload_identity.binding.created" + | "tenant.workload_identity.principal.provisioned" + | "tenant.admin_api_key.created" + | "tenant.admin_api_key.updated" + | "tenant.admin_api_key.deleted" + | "tenant.project_api_key.created" + | "tenant.chatgpt_access_token.revoked" + | "tenant.migration.completed" + | "tenant.sso.migrated" + | "tenant.domains.migrated" + | "tenant.sso_connection.created" + | "tenant.sso_connection.updated" + | "tenant.sso_connection.deleted" + | "tenant.sso_connection.setup.started" + | "tenant.policy.created" + | "tenant.policy.updated" + | "tenant.policy.deleted" + | "tenant.policy.attached" + | "tenant.policy.detached" + | "tenant.principal_authentication_policy.resolved" + | "tenant.scim.setup.started" + | "tenant.scim.deletion.requested" + | "tenant.scim.directory.created" + | "tenant.product_access_policy.updated" + | "tenant.resource_share_grant.created" + | "tenant.resource_share_grant.updated" + | "tenant.resource_share_grant.accepted" + | "tenant.resource_share_grant.declined" + | "tenant.resource_share_grant.revoked" + | "tenant.resource_share_grant.deleted" + | "tenant.service_account.updated" + | "tenant.service_account.deleted" + | "tenant.service_account.token.revoked" + | "tenant.billing.overage_limit.updated" + | "tenant.billing.alerts.updated" + | "tenant.billing.info.updated" + | "tenant.usage_limit.workspace.updated" + | "tenant.usage_limit.group.updated" + | "tenant.usage_limit.user.updated" + | "tenant.usage_limit.increase_request.updated" + | "tenant.usage_limit.increase_request.resolved" + | "tenant.group.created" + | "tenant.group.updated" + | "tenant.group.deleted" + | "tenant.group.member.added" + | "tenant.group.member.removed" + | "tenant.migration_rollout.status.updated" + | "tenant.migration_rollout.tier.updated" + | "tenant.role.metadata.updated" + | "tenant.custom_role.created" + | "tenant.custom_role.updated" + | "tenant.custom_role.deleted" + | "tenant.role_assignment.created" + | "tenant.role_assignment.deleted" + | "tenant.resource_role_assignment.created" + | "tenant.resource_role_assignment.deleted" + | "tenant.resource_access.updated" + | "tenant.resource_access.deleted" + | "tenant.session_policy.created" + | "tenant.session_policy.updated" + | "tenant.session_policy.deleted" + | "tenant.session_revocation.started" + | "tenant.third_party_app_policy.updated" + | "tenant.user.added" + | "tenant.user.updated" + | "tenant.user.removed" + | "tenant.user.looked_up" + | "tenant.user.invited" + | "tenant.membership.revoked" + | "tenant.api_organization_invite.upserted" + | "tenant.api_organization_invite.deleted" + | "tenant.chatgpt_workspace_invite.upserted" + | "tenant.membership.accepted" + | "tenant.membership.declined" + | "tenant.workspace_invite_email_settings.updated" +export const AuditLogEventType = Schema.Literals([ + "api_key.created", + "api_key.updated", + "api_key.deleted", + "certificate.created", + "certificate.updated", + "certificate.deleted", + "certificates.activated", + "certificates.deactivated", + "checkpoint.permission.created", + "checkpoint.permission.deleted", + "external_key.registered", + "external_key.removed", + "group.created", + "group.updated", + "group.deleted", + "invite.sent", + "invite.accepted", + "invite.deleted", + "ip_allowlist.created", + "ip_allowlist.updated", + "ip_allowlist.deleted", + "ip_allowlist.config.activated", + "ip_allowlist.config.deactivated", + "login.succeeded", + "login.failed", + "logout.succeeded", + "logout.failed", + "organization.updated", + "project.created", + "project.updated", + "project.archived", + "project.deleted", + "rate_limit.updated", + "rate_limit.deleted", + "resource.deleted", + "tunnel.created", + "tunnel.updated", + "tunnel.deleted", + "workload_identity_provider.created", + "workload_identity_provider.updated", + "workload_identity_provider.deleted", + "workload_identity_provider_mapping.created", + "workload_identity_provider_mapping.updated", + "workload_identity_provider_mapping.deleted", + "role.created", + "role.updated", + "role.deleted", + "role.assignment.created", + "role.assignment.deleted", + "role.bound_to_resource", + "role.unbound_from_resource", + "scim.enabled", + "scim.disabled", + "service_account.created", + "service_account.updated", + "service_account.deleted", + "user.added", + "user.updated", + "user.deleted", + "tenant.metadata.updated", + "tenant.microsoft_entra_mapping.upserted", + "tenant.microsoft_entra_mapping.deleted", + "tenant.workload_identity.provider.created", + "tenant.workload_identity.provider.updated", + "tenant.workload_identity.provider.archived", + "tenant.workload_identity.mapping.created", + "tenant.workload_identity.mapping.updated", + "tenant.workload_identity.mapping.archived", + "tenant.workload_identity.binding.created", + "tenant.workload_identity.principal.provisioned", + "tenant.admin_api_key.created", + "tenant.admin_api_key.updated", + "tenant.admin_api_key.deleted", + "tenant.project_api_key.created", + "tenant.chatgpt_access_token.revoked", + "tenant.migration.completed", + "tenant.sso.migrated", + "tenant.domains.migrated", + "tenant.sso_connection.created", + "tenant.sso_connection.updated", + "tenant.sso_connection.deleted", + "tenant.sso_connection.setup.started", + "tenant.policy.created", + "tenant.policy.updated", + "tenant.policy.deleted", + "tenant.policy.attached", + "tenant.policy.detached", + "tenant.principal_authentication_policy.resolved", + "tenant.scim.setup.started", + "tenant.scim.deletion.requested", + "tenant.scim.directory.created", + "tenant.product_access_policy.updated", + "tenant.resource_share_grant.created", + "tenant.resource_share_grant.updated", + "tenant.resource_share_grant.accepted", + "tenant.resource_share_grant.declined", + "tenant.resource_share_grant.revoked", + "tenant.resource_share_grant.deleted", + "tenant.service_account.updated", + "tenant.service_account.deleted", + "tenant.service_account.token.revoked", + "tenant.billing.overage_limit.updated", + "tenant.billing.alerts.updated", + "tenant.billing.info.updated", + "tenant.usage_limit.workspace.updated", + "tenant.usage_limit.group.updated", + "tenant.usage_limit.user.updated", + "tenant.usage_limit.increase_request.updated", + "tenant.usage_limit.increase_request.resolved", + "tenant.group.created", + "tenant.group.updated", + "tenant.group.deleted", + "tenant.group.member.added", + "tenant.group.member.removed", + "tenant.migration_rollout.status.updated", + "tenant.migration_rollout.tier.updated", + "tenant.role.metadata.updated", + "tenant.custom_role.created", + "tenant.custom_role.updated", + "tenant.custom_role.deleted", + "tenant.role_assignment.created", + "tenant.role_assignment.deleted", + "tenant.resource_role_assignment.created", + "tenant.resource_role_assignment.deleted", + "tenant.resource_access.updated", + "tenant.resource_access.deleted", + "tenant.session_policy.created", + "tenant.session_policy.updated", + "tenant.session_policy.deleted", + "tenant.session_revocation.started", + "tenant.third_party_app_policy.updated", + "tenant.user.added", + "tenant.user.updated", + "tenant.user.removed", + "tenant.user.looked_up", + "tenant.user.invited", + "tenant.membership.revoked", + "tenant.api_organization_invite.upserted", + "tenant.api_organization_invite.deleted", + "tenant.chatgpt_workspace_invite.upserted", + "tenant.membership.accepted", + "tenant.membership.declined", + "tenant.workspace_invite_email_settings.updated" +]).annotate({ "description": "The event type.", "identifier": "AuditLogEventType" }) +export type AuditLogActorUser = { readonly "id"?: string; readonly "email"?: string } +export const AuditLogActorUser = Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The user id." })), + "email": Schema.optionalKey(Schema.String.annotate({ "description": "The user email." })) +}).annotate({ "description": "The user who performed the audit logged action.", "identifier": "AuditLogActorUser" }) +export type AuditLogActorServiceAccount = { readonly "id"?: string } +export const AuditLogActorServiceAccount = Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The service account id." })) +}).annotate({ + "description": "The service account that performed the audit logged action.", + "identifier": "AuditLogActorServiceAccount" }) -export type OpenAIFile = { +export type OrganizationCertificate = { + readonly "object": "organization.certificate" readonly "id": string - readonly "bytes": number - readonly "created_at": number - readonly "expires_at"?: number | null - readonly "filename": string - readonly "object": "file" - readonly "purpose": - | "assistants" - | "assistants_output" - | "batch" - | "batch_output" - | "fine-tune" - | "fine-tune-results" - | "vision" - | "user_data" - readonly "status": "uploaded" | "processed" | "error" - readonly "status_details"?: string | null - readonly [x: string]: unknown -} -export const OpenAIFile = Schema.StructWithRest( - Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The file identifier, which can be referenced in the API endpoints." - }), - "bytes": Schema.Number.annotate({ "description": "The size of the file, in bytes." }).check(Schema.isInt()), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the file was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "expires_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the file will expire.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]) - ), - "filename": Schema.String.annotate({ "description": "The name of the file." }), - "object": Schema.Literal("file").annotate({ "description": "The object type, which is always `file`." }), - "purpose": Schema.Literals([ - "assistants", - "assistants_output", - "batch", - "batch_output", - "fine-tune", - "fine-tune-results", - "vision", - "user_data" - ]).annotate({ - "description": - "The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`." - }), - "status": Schema.Literals(["uploaded", "processed", "error"]).annotate({ - "description": - "Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`." - }), - "status_details": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`." - }) - ) - }), - [Schema.Record(Schema.String, Schema.Json)] -).annotate({ - "title": "OpenAIFile", - "description": "The `File` object represents a document that has been uploaded to OpenAI." -}) -export type OrganizationCertificate = { - readonly "object": "organization.certificate" - readonly "id": string - readonly "name": string | null + readonly "name": string | null readonly "created_at": number readonly "certificate_details": { readonly "valid_at"?: number; readonly "expires_at"?: number } readonly "active": boolean @@ -3426,2892 +4514,2765 @@ export const OrganizationCertificate = Schema.Struct({ "created_at": Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) of when the certificate was uploaded.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "certificate_details": Schema.Struct({ "valid_at": Schema.optionalKey( Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) of when the certificate becomes valid.", "format": "unixtime" - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "expires_at": Schema.optionalKey( Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) of when the certificate expires.", "format": "unixtime" - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ) }), "active": Schema.Boolean.annotate({ "description": "Whether the certificate is currently active at the organization level." }) -}).annotate({ "description": "Represents an individual certificate configured at the organization level." }) -export type OrganizationProjectCertificate = { - readonly "object": "organization.project.certificate" +}).annotate({ + "description": "Represents an individual certificate configured at the organization level.", + "identifier": "OrganizationCertificate" +}) +export type UploadCertificateRequest = { readonly "name"?: string; readonly "certificate": string } +export const UploadCertificateRequest = Schema.Struct({ + "name": Schema.optionalKey(Schema.String.annotate({ "description": "An optional name for the certificate" })), + "certificate": Schema.String.annotate({ "description": "The certificate content in PEM format" }) +}).annotate({ "identifier": "UploadCertificateRequest" }) +export type Certificate = { + readonly "object": "certificate" | "organization.certificate" | "organization.project.certificate" readonly "id": string readonly "name": string | null readonly "created_at": number - readonly "certificate_details": { readonly "valid_at"?: number; readonly "expires_at"?: number } - readonly "active": boolean + readonly "certificate_details": { + readonly "valid_at"?: number + readonly "expires_at"?: number + readonly "content"?: string + } + readonly "active"?: boolean } -export const OrganizationProjectCertificate = Schema.Struct({ - "object": Schema.Literal("organization.project.certificate").annotate({ - "description": "The object type, which is always `organization.project.certificate`." +export const Certificate = Schema.Struct({ + "object": Schema.Literals(["certificate", "organization.certificate", "organization.project.certificate"]).annotate({ + "description": + "The object type.\n\n- If creating, updating, or getting a specific certificate, the object type is `certificate`.\n- If listing, activating, or deactivating certificates for the organization, the object type is `organization.certificate`.\n- If listing, activating, or deactivating certificates for a project, the object type is `organization.project.certificate`.\n" }), "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), "name": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the certificate." }), "created_at": Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) of when the certificate was uploaded.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "certificate_details": Schema.Struct({ "valid_at": Schema.optionalKey( Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) of when the certificate becomes valid.", "format": "unixtime" - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "expires_at": Schema.optionalKey( Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) of when the certificate expires.", "format": "unixtime" - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "content": Schema.optionalKey( + Schema.String.annotate({ "description": "The content of the certificate in PEM format." }) ) }), - "active": Schema.Boolean.annotate({ - "description": "Whether the certificate is currently active at the project level." - }) -}).annotate({ "description": "Represents an individual certificate configured at the project level." }) -export type ParallelToolCalls = boolean -export const ParallelToolCalls = Schema.Boolean.annotate({ - "description": - "Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use." + "active": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate." + }) + ) +}).annotate({ + "description": "Represents an individual `certificate` uploaded to the organization.", + "identifier": "Certificate" }) -export type PartialImages = number | null -export const PartialImages = Schema.Union([ - Schema.Number.annotate({ - "description": - "The number of partial images to generate. This parameter is used for\nstreaming responses that return partial images. Value must be between 0 and 3.\nWhen set to 0, the response will be a single image sent in one streaming event.\n\nNote that the final image may be sent before the full number of partial images\nare generated if the full image is generated more quickly.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(3)), - Schema.Null -]) -export type Project = { - readonly "id": string - readonly "object": "organization.project" - readonly "name"?: string | null - readonly "created_at": number - readonly "archived_at"?: number | null - readonly "status"?: string | null - readonly "external_key_id"?: string | null -} -export const Project = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "object": Schema.Literal("organization.project").annotate({ - "description": "The object type, which is always `organization.project`" +export type ToggleCertificatesRequest = { readonly "certificate_ids": ReadonlyArray } +export const ToggleCertificatesRequest = Schema.Struct({ + "certificate_ids": Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(10).annotate({ "expected": "a value with a length of at most 10" })) +}).annotate({ "identifier": "ToggleCertificatesRequest" }) +export type ModifyCertificateRequest = { readonly "name"?: string } +export const ModifyCertificateRequest = Schema.Struct({ + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The updated name for the certificate" })) +}).annotate({ "identifier": "ModifyCertificateRequest" }) +export type DeleteCertificateResponse = { readonly "object": "certificate.deleted"; readonly "id": string } +export const DeleteCertificateResponse = Schema.Struct({ + "object": Schema.Literal("certificate.deleted").annotate({ + "description": "The object type, must be `certificate.deleted`." }), - "name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The name of the project. This appears in reporting." - }) + "id": Schema.String.annotate({ "description": "The ID of the certificate that was deleted." }) +}).annotate({ "identifier": "DeleteCertificateResponse" }) +export type UsageCompletionsResult = { + readonly "object": "organization.usage.completions.result" + readonly "input_tokens": number + readonly "input_cached_tokens"?: number + readonly "input_cache_write_tokens"?: number + readonly "input_uncached_tokens"?: number + readonly "output_tokens": number + readonly "input_text_tokens"?: number + readonly "output_text_tokens"?: number + readonly "input_cached_text_tokens"?: number + readonly "input_audio_tokens"?: number + readonly "input_cached_audio_tokens"?: number + readonly "output_audio_tokens"?: number + readonly "input_image_tokens"?: number + readonly "input_cached_image_tokens"?: number + readonly "output_image_tokens"?: number + readonly "num_model_requests": number + readonly "project_id"?: string | null + readonly "user_id"?: string | null + readonly "api_key_id"?: string | null + readonly "model"?: string | null + readonly "batch"?: boolean | null + readonly "service_tier"?: string | null +} +export const UsageCompletionsResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.completions.result"), + "input_tokens": Schema.Number.annotate({ + "description": + "The aggregated number of input tokens used, including cached and cache-write tokens. This includes text, audio, and image tokens. For customers subscribed to Scale Tier, this includes Scale Tier tokens." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "input_cached_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The aggregated number of cached input tokens used across text, audio, and image inputs. For customers subscribed to Scale Tier, this includes Scale Tier tokens." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the project was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "archived_at": Schema.optionalKey( + "input_cache_write_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The aggregated number of input tokens written to the cache." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "input_uncached_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The aggregated number of uncached input tokens used across text, audio, and image inputs, excluding cache-write tokens." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "output_tokens": Schema.Number.annotate({ + "description": + "The aggregated number of output tokens used across text, audio, and image outputs. For customers subscribed to Scale Tier, this includes Scale Tier tokens." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "input_text_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The aggregated number of uncached text input tokens used, excluding cache-write tokens." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "output_text_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The aggregated number of text output tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "input_cached_text_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The aggregated number of cached text input tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "input_audio_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The aggregated number of uncached audio input tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "input_cached_audio_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The aggregated number of cached audio input tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "output_audio_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The aggregated number of audio output tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "input_image_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The aggregated number of uncached image input tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "input_cached_image_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The aggregated number of cached image input tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "output_image_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The aggregated number of image output tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "project_id": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the project was archived or `null`.", - "format": "unixtime" - }).check(Schema.isInt()), + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), Schema.Null ]) ), - "status": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "`active` or `archived`" }) + "user_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." + }), + Schema.Null + ]) ), - "external_key_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The external key associated with the project." - }) + "api_key_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." + }), + Schema.Null + ]) + ), + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=model`, this field provides the model name of the grouped usage result." + }), + Schema.Null + ]) + ), + "batch": Schema.optionalKey( + Schema.Union([ + Schema.Boolean.annotate({ + "description": "When `group_by=batch`, this field tells whether the grouped usage result is batch or not." + }), + Schema.Null + ]) + ), + "service_tier": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=service_tier`, this field provides the service tier of the grouped usage result." + }), + Schema.Null + ]) ) -}).annotate({ "description": "Represents an individual project." }) -export type ProjectApiKeyDeleteResponse = { - readonly "object": "organization.project.api_key.deleted" - readonly "id": string - readonly "deleted": boolean -} -export const ProjectApiKeyDeleteResponse = Schema.Struct({ - "object": Schema.Literal("organization.project.api_key.deleted"), - "id": Schema.String, - "deleted": Schema.Boolean +}).annotate({ + "description": "The aggregated completions usage details of the specific time bucket.", + "identifier": "UsageCompletionsResult" }) -export type ProjectApiKeyOwnerServiceAccount = { - readonly "id": string - readonly "name": string - readonly "created_at": number - readonly "role": string -} -export const ProjectApiKeyOwnerServiceAccount = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "name": Schema.String.annotate({ "description": "The name of the service account." }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the service account was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "role": Schema.String.annotate({ "description": "The service account's project role." }) -}).annotate({ "description": "The service account that owns a project API key." }) -export type ProjectApiKeyOwnerUser = { - readonly "id": string - readonly "email": string - readonly "name": string - readonly "created_at": number - readonly "role": string -} -export const ProjectApiKeyOwnerUser = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "email": Schema.String.annotate({ "description": "The email address of the user." }), - "name": Schema.String.annotate({ "description": "The name of the user." }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the user was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "role": Schema.String.annotate({ "description": "The user's project role." }) -}).annotate({ "description": "The user that owns a project API key." }) -export type ProjectCreateRequest = { - readonly "name": string - readonly "geography"?: string | null - readonly "external_key_id"?: string | null -} -export const ProjectCreateRequest = Schema.Struct({ - "name": Schema.String.annotate({ "description": "The friendly name of the project, this name appears in reports." }), - "geography": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "Create the project with the specified data residency region. Your organization must have access to Data residency functionality in order to use. See [data residency controls](/docs/guides/your-data#data-residency-controls) to review the functionality and limitations of setting this field." - }) - ), - "external_key_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "External key ID to associate with the project." - }) - ) -}) -export type ProjectGroup = { - readonly "object": "project.group" - readonly "project_id": string - readonly "group_id": string - readonly "group_name": string - readonly "group_type": string - readonly "created_at": number -} -export const ProjectGroup = Schema.Struct({ - "object": Schema.Literal("project.group").annotate({ "description": "Always `project.group`." }), - "project_id": Schema.String.annotate({ "description": "Identifier of the project." }), - "group_id": Schema.String.annotate({ "description": "Identifier of the group that has access to the project." }), - "group_name": Schema.String.annotate({ "description": "Display name of the group." }), - "group_type": Schema.String.annotate({ "description": "The type of the group." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the group was granted project access.", - "format": "unixtime" - }).check(Schema.isInt()) -}).annotate({ "description": "Details about a group's membership in a project." }) -export type ProjectGroupDeletedResource = { readonly "object": "project.group.deleted"; readonly "deleted": boolean } -export const ProjectGroupDeletedResource = Schema.Struct({ - "object": Schema.Literal("project.group.deleted").annotate({ "description": "Always `project.group.deleted`." }), - "deleted": Schema.Boolean.annotate({ "description": "Whether the group membership in the project was removed." }) -}).annotate({ "description": "Confirmation payload returned after removing a group from a project." }) -export type ProjectModelPermissions = { - readonly "object": "project.model_permissions" - readonly "mode": "allow_list" | "deny_list" - readonly "model_ids": ReadonlyArray -} -export const ProjectModelPermissions = Schema.Struct({ - "object": Schema.Literal("project.model_permissions").annotate({ - "description": "The object type, which is always `project.model_permissions`." - }), - "mode": Schema.Literals(["allow_list", "deny_list"]).annotate({ - "description": "Whether the project uses an allowlist or a denylist." - }), - "model_ids": Schema.Array(Schema.String).annotate({ - "description": "The model IDs included in the model permissions policy." - }) -}).annotate({ "description": "Represents the model allowlist or denylist policy for a project." }) -export type ProjectModelPermissionsDeleteResponse = { - readonly "object": "project.model_permissions.deleted" - readonly "deleted": boolean -} -export const ProjectModelPermissionsDeleteResponse = Schema.Struct({ - "object": Schema.Literal("project.model_permissions.deleted").annotate({ - "description": "The object type, which is always `project.model_permissions.deleted`." - }), - "deleted": Schema.Boolean.annotate({ "description": "Whether the project model permissions were deleted." }) -}).annotate({ "description": "Confirmation payload returned after deleting project model permissions." }) -export type ProjectModelPermissionsUpdateRequest = { - readonly "mode": "allow_list" | "deny_list" - readonly "model_ids": ReadonlyArray -} -export const ProjectModelPermissionsUpdateRequest = Schema.Struct({ - "mode": Schema.Literals(["allow_list", "deny_list"]).annotate({ - "description": "The model permissions mode to apply." - }), - "model_ids": Schema.Array(Schema.String).annotate({ - "description": "The model IDs included in this permissions policy." - }) -}) -export type ProjectRateLimit = { - readonly "object": "project.rate_limit" - readonly "id": string - readonly "model": string - readonly "max_requests_per_1_minute": number - readonly "max_tokens_per_1_minute": number - readonly "max_images_per_1_minute"?: number - readonly "max_audio_megabytes_per_1_minute"?: number - readonly "max_requests_per_1_day"?: number - readonly "batch_1_day_max_input_tokens"?: number +export type UsageEmbeddingsResult = { + readonly "object": "organization.usage.embeddings.result" + readonly "input_tokens": number + readonly "num_model_requests": number + readonly "project_id"?: string | null + readonly "user_id"?: string | null + readonly "api_key_id"?: string | null + readonly "model"?: string | null } -export const ProjectRateLimit = Schema.Struct({ - "object": Schema.Literal("project.rate_limit").annotate({ - "description": "The object type, which is always `project.rate_limit`" - }), - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), - "model": Schema.String.annotate({ "description": "The model this rate limit applies to." }), - "max_requests_per_1_minute": Schema.Number.annotate({ "description": "The maximum requests per minute." }).check( - Schema.isInt() +export const UsageEmbeddingsResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.embeddings.result"), + "input_tokens": Schema.Number.annotate({ "description": "The aggregated number of input tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "max_tokens_per_1_minute": Schema.Number.annotate({ "description": "The maximum tokens per minute." }).check( - Schema.isInt() + "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "max_images_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum images per minute. Only present for relevant models." }).check( - Schema.isInt() - ) + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), + Schema.Null + ]) ), - "max_audio_megabytes_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The maximum audio megabytes per minute. Only present for relevant models." - }).check(Schema.isInt()) + "user_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." + }), + Schema.Null + ]) ), - "max_requests_per_1_day": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum requests per day. Only present for relevant models." }).check( - Schema.isInt() - ) + "api_key_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." + }), + Schema.Null + ]) ), - "batch_1_day_max_input_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The maximum batch input tokens per day. Only present for relevant models." - }).check(Schema.isInt()) + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=model`, this field provides the model name of the grouped usage result." + }), + Schema.Null + ]) ) -}).annotate({ "description": "Represents a project rate limit config." }) -export type ProjectRateLimitUpdateRequest = { - readonly "max_requests_per_1_minute"?: number - readonly "max_tokens_per_1_minute"?: number - readonly "max_images_per_1_minute"?: number - readonly "max_audio_megabytes_per_1_minute"?: number - readonly "max_requests_per_1_day"?: number - readonly "batch_1_day_max_input_tokens"?: number +}).annotate({ + "description": "The aggregated embeddings usage details of the specific time bucket.", + "identifier": "UsageEmbeddingsResult" +}) +export type UsageModerationsResult = { + readonly "object": "organization.usage.moderations.result" + readonly "input_tokens": number + readonly "num_model_requests": number + readonly "project_id"?: string | null + readonly "user_id"?: string | null + readonly "api_key_id"?: string | null + readonly "model"?: string | null } -export const ProjectRateLimitUpdateRequest = Schema.Struct({ - "max_requests_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum requests per minute." }).check(Schema.isInt()) +export const UsageModerationsResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.moderations.result"), + "input_tokens": Schema.Number.annotate({ "description": "The aggregated number of input tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "max_tokens_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum tokens per minute." }).check(Schema.isInt()) + "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "max_images_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum images per minute. Only relevant for certain models." }).check( - Schema.isInt() - ) + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), + Schema.Null + ]) ), - "max_audio_megabytes_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The maximum audio megabytes per minute. Only relevant for certain models." - }).check(Schema.isInt()) + "user_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." + }), + Schema.Null + ]) ), - "max_requests_per_1_day": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum requests per day. Only relevant for certain models." }).check( - Schema.isInt() - ) + "api_key_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." + }), + Schema.Null + ]) ), - "batch_1_day_max_input_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The maximum batch input tokens per day. Only relevant for certain models." - }).check(Schema.isInt()) + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=model`, this field provides the model name of the grouped usage result." + }), + Schema.Null + ]) ) +}).annotate({ + "description": "The aggregated moderations usage details of the specific time bucket.", + "identifier": "UsageModerationsResult" }) -export type ProjectServiceAccount = { - readonly "object": "organization.project.service_account" - readonly "id": string - readonly "name": string - readonly "role": "owner" | "member" - readonly "created_at": number +export type UsageImagesResult = { + readonly "object": "organization.usage.images.result" + readonly "images": number + readonly "num_model_requests": number + readonly "source"?: string | null + readonly "size"?: string | null + readonly "project_id"?: string | null + readonly "user_id"?: string | null + readonly "api_key_id"?: string | null + readonly "model"?: string | null } -export const ProjectServiceAccount = Schema.Struct({ - "object": Schema.Literal("organization.project.service_account").annotate({ - "description": "The object type, which is always `organization.project.service_account`" - }), - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "name": Schema.String.annotate({ "description": "The name of the service account" }), - "role": Schema.Literals(["owner", "member"]).annotate({ "description": "`owner` or `member`" }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the service account was created", - "format": "unixtime" - }).check(Schema.isInt()) -}).annotate({ "description": "Represents an individual service account in a project." }) -export type ProjectServiceAccountApiKey = { - readonly "object": "organization.project.service_account.api_key" - readonly "value": string - readonly "name": string - readonly "created_at": number - readonly "id": string -} -export const ProjectServiceAccountApiKey = Schema.Struct({ - "object": Schema.Literal("organization.project.service_account.api_key").annotate({ - "description": "The object type, which is always `organization.project.service_account.api_key`" - }), - "value": Schema.String, - "name": Schema.String, - "created_at": Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt()), - "id": Schema.String -}) -export type ProjectServiceAccountCreateRequest = { readonly "name": string } -export const ProjectServiceAccountCreateRequest = Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the service account being created." }) -}) -export type ProjectServiceAccountDeleteResponse = { - readonly "object": "organization.project.service_account.deleted" - readonly "id": string - readonly "deleted": boolean -} -export const ProjectServiceAccountDeleteResponse = Schema.Struct({ - "object": Schema.Literal("organization.project.service_account.deleted"), - "id": Schema.String, - "deleted": Schema.Boolean -}) -export type ProjectUpdateRequest = { - readonly "name"?: string | null - readonly "external_key_id"?: string | null - readonly "geography"?: string | null -} -export const ProjectUpdateRequest = Schema.Struct({ - "name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The updated name of the project, this name appears in reports." - }) +export const UsageImagesResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.images.result"), + "images": Schema.Number.annotate({ "description": "The number of images processed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "external_key_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "External key ID to associate with the project." - }) + "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "geography": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Geography for the project." }) + "source": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`." + }), + Schema.Null + ]) + ), + "size": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=size`, this field provides the image size of the grouped usage result." + }), + Schema.Null + ]) + ), + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), + Schema.Null + ]) + ), + "user_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." + }), + Schema.Null + ]) + ), + "api_key_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." + }), + Schema.Null + ]) + ), + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=model`, this field provides the model name of the grouped usage result." + }), + Schema.Null + ]) ) +}).annotate({ + "description": "The aggregated images usage details of the specific time bucket.", + "identifier": "UsageImagesResult" }) -export type ProjectUser = { - readonly "object": "organization.project.user" - readonly "id": string - readonly "name"?: string | null - readonly "email"?: string | null - readonly "role": string - readonly "added_at": number +export type UsageAudioSpeechesResult = { + readonly "object": "organization.usage.audio_speeches.result" + readonly "characters": number + readonly "num_model_requests": number + readonly "project_id"?: string | null + readonly "user_id"?: string | null + readonly "api_key_id"?: string | null + readonly "model"?: string | null } -export const ProjectUser = Schema.Struct({ - "object": Schema.Literal("organization.project.user").annotate({ - "description": "The object type, which is always `organization.project.user`" - }), - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the user" }) +export const UsageAudioSpeechesResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.audio_speeches.result"), + "characters": Schema.Number.annotate({ "description": "The number of characters processed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "email": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The email address of the user" }) + "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "role": Schema.String.annotate({ "description": "`owner` or `member`" }), - "added_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the project was added.", - "format": "unixtime" - }).check(Schema.isInt()) -}).annotate({ "description": "Represents an individual user in a project." }) -export type ProjectUserCreateRequest = { + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), + Schema.Null + ]) + ), + "user_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." + }), + Schema.Null + ]) + ), + "api_key_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." + }), + Schema.Null + ]) + ), + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=model`, this field provides the model name of the grouped usage result." + }), + Schema.Null + ]) + ) +}).annotate({ + "description": "The aggregated audio speeches usage details of the specific time bucket.", + "identifier": "UsageAudioSpeechesResult" +}) +export type UsageAudioTranscriptionsResult = { + readonly "object": "organization.usage.audio_transcriptions.result" + readonly "seconds": number + readonly "num_model_requests": number + readonly "project_id"?: string | null readonly "user_id"?: string | null - readonly "email"?: string | null - readonly "role": string + readonly "api_key_id"?: string | null + readonly "model"?: string | null } -export const ProjectUserCreateRequest = Schema.Struct({ +export const UsageAudioTranscriptionsResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.audio_transcriptions.result"), + "seconds": Schema.Number.annotate({ "description": "The number of seconds processed.", "format": "int64" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), + Schema.Null + ]) + ), "user_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The ID of the user." }) + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." + }), + Schema.Null + ]) ), - "email": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Email of the user to add." }) + "api_key_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." + }), + Schema.Null + ]) ), - "role": Schema.String.annotate({ "description": "`owner` or `member`" }) + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=model`, this field provides the model name of the grouped usage result." + }), + Schema.Null + ]) + ) +}).annotate({ + "description": "The aggregated audio transcriptions usage details of the specific time bucket.", + "identifier": "UsageAudioTranscriptionsResult" }) -export type ProjectUserDeleteResponse = { - readonly "object": "organization.project.user.deleted" - readonly "id": string - readonly "deleted": boolean +export type UsageVectorStoresResult = { + readonly "object": "organization.usage.vector_stores.result" + readonly "usage_bytes": number + readonly "project_id"?: string | null } -export const ProjectUserDeleteResponse = Schema.Struct({ - "object": Schema.Literal("organization.project.user.deleted"), - "id": Schema.String, - "deleted": Schema.Boolean -}) -export type ProjectUserUpdateRequest = { readonly "role"?: string | null } -export const ProjectUserUpdateRequest = Schema.Struct({ - "role": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "`owner` or `member`" }) +export const UsageVectorStoresResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.vector_stores.result"), + "usage_bytes": Schema.Number.annotate({ "description": "The vector stores usage in bytes." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), + Schema.Null + ]) ) +}).annotate({ + "description": "The aggregated vector stores usage details of the specific time bucket.", + "identifier": "UsageVectorStoresResult" }) -export type PublicAssignOrganizationGroupRoleBody = { readonly "role_id": string } -export const PublicAssignOrganizationGroupRoleBody = Schema.Struct({ - "role_id": Schema.String.annotate({ "description": "Identifier of the role to assign." }) -}).annotate({ "description": "Request payload for assigning a role to a group or user." }) -export type PublicCreateOrganizationRoleBody = { - readonly "role_name": string - readonly "permissions": ReadonlyArray - readonly "description"?: string | null +export type UsageCodeInterpreterSessionsResult = { + readonly "object": "organization.usage.code_interpreter_sessions.result" + readonly "num_sessions": number + readonly "project_id"?: string | null } -export const PublicCreateOrganizationRoleBody = Schema.Struct({ - "role_name": Schema.String.annotate({ "description": "Unique name for the role." }), - "permissions": Schema.Array(Schema.String).annotate({ "description": "Permissions to grant to the role." }), - "description": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Optional description of the role." }) - ) -}).annotate({ "description": "Request payload for creating a custom role." }) -export type PublicUpdateOrganizationRoleBody = { - readonly "permissions"?: ReadonlyArray | null - readonly "description"?: string | null - readonly "role_name"?: string | null -} -export const PublicUpdateOrganizationRoleBody = Schema.Struct({ - "permissions": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": "Updated set of permissions for the role." - }) - ), - "description": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "New description for the role." }) +export const UsageCodeInterpreterSessionsResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.code_interpreter_sessions.result"), + "num_sessions": Schema.Number.annotate({ "description": "The number of code interpreter sessions." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "role_name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "New name for the role." }) - ) -}).annotate({ "description": "Request payload for updating an existing role." }) -export type RealtimeAudioFormats = { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" -} | { readonly "type"?: "audio/pcma" } -export const RealtimeAudioFormats = Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) -]) -export type RealtimeCallReferRequest = { readonly "target_uri": string } -export const RealtimeCallReferRequest = Schema.Struct({ - "target_uri": Schema.String.annotate({ - "description": - "URI that should appear in the SIP Refer-To header. Supports values like\n`tel:+14155550123` or `sip:agent@example.com`." - }) -}).annotate({ - "title": "Realtime call refer request", - "description": "Parameters required to transfer a SIP call to a new destination using the\nRealtime API." -}) -export type RealtimeCallRejectRequest = { readonly "status_code"?: number } -export const RealtimeCallRejectRequest = Schema.Struct({ - "status_code": Schema.optionalKey( - Schema.Number.annotate({ - "description": "SIP response code to send back to the caller. Defaults to `603` (Decline)\nwhen omitted." - }).check(Schema.isInt()) + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), + Schema.Null + ]) ) }).annotate({ - "title": "Realtime call reject request", - "description": "Parameters used to decline an incoming SIP call handled by the Realtime API." + "description": "The aggregated code interpreter sessions usage details of the specific time bucket.", + "identifier": "UsageCodeInterpreterSessionsResult" }) -export type RealtimeClientEventConversationItemDelete = { - readonly "event_id"?: string - readonly "type": "conversation.item.delete" - readonly "item_id": string +export type UsageFileSearchCallsResult = { + readonly "object": "organization.usage.file_searches.result" + readonly "num_requests": number + readonly "project_id"?: string | null + readonly "user_id"?: string | null + readonly "api_key_id"?: string | null + readonly "vector_store_id"?: string | null } -export const RealtimeClientEventConversationItemDelete = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) +export const UsageFileSearchCallsResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.file_searches.result"), + "num_requests": Schema.Number.annotate({ "description": "The count of file search calls." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "type": Schema.Literal("conversation.item.delete").annotate({ - "description": "The event type, must be `conversation.item.delete`." - }), - "item_id": Schema.String.annotate({ "description": "The ID of the item to delete." }) -}).annotate({ - "description": - "Send this event when you want to remove any item from the conversation \nhistory. The server will respond with a `conversation.item.deleted` event, \nunless the item does not exist in the conversation history, in which case the \nserver will respond with an error.\n" -}) -export type RealtimeClientEventConversationItemRetrieve = { - readonly "event_id"?: string - readonly "type": "conversation.item.retrieve" - readonly "item_id": string -} -export const RealtimeClientEventConversationItemRetrieve = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), + Schema.Null + ]) ), - "type": Schema.Literal("conversation.item.retrieve").annotate({ - "description": "The event type, must be `conversation.item.retrieve`." - }), - "item_id": Schema.String.annotate({ "description": "The ID of the item to retrieve." }) -}).annotate({ - "description": - "Send this event when you want to retrieve the server's representation of a specific item in the conversation history. This is useful, for example, to inspect user audio after noise cancellation and VAD.\nThe server will respond with a `conversation.item.retrieved` event, \nunless the item does not exist in the conversation history, in which case the \nserver will respond with an error.\n" -}) -export type RealtimeClientEventConversationItemTruncate = { - readonly "event_id"?: string - readonly "type": "conversation.item.truncate" - readonly "item_id": string - readonly "content_index": number - readonly "audio_end_ms": number -} -export const RealtimeClientEventConversationItemTruncate = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) + "user_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." + }), + Schema.Null + ]) ), - "type": Schema.Literal("conversation.item.truncate").annotate({ - "description": "The event type, must be `conversation.item.truncate`." - }), - "item_id": Schema.String.annotate({ - "description": - "The ID of the assistant message item to truncate. Only assistant message \nitems can be truncated.\n" - }), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part to truncate. Set this to `0`." - }).check(Schema.isInt()), - "audio_end_ms": Schema.Number.annotate({ - "description": - "Inclusive duration up to which audio is truncated, in milliseconds. If \nthe audio_end_ms is greater than the actual audio duration, the server \nwill respond with an error.\n" - }).check(Schema.isInt()) -}).annotate({ - "description": - "Send this event to truncate a previous assistant message’s audio. The server \nwill produce audio faster than realtime, so this event is useful when the user \ninterrupts to truncate audio that has already been sent to the client but not \nyet played. This will synchronize the server's understanding of the audio with \nthe client's playback.\n\nTruncating audio will delete the server-side text transcript to ensure there \nis not text in the context that hasn't been heard by the user.\n\nIf successful, the server will respond with a `conversation.item.truncated` \nevent. \n" -}) -export type RealtimeClientEventInputAudioBufferAppend = { - readonly "event_id"?: string - readonly "type": "input_audio_buffer.append" - readonly "audio": string -} -export const RealtimeClientEventInputAudioBufferAppend = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) + "api_key_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." + }), + Schema.Null + ]) ), - "type": Schema.Literal("input_audio_buffer.append").annotate({ - "description": "The event type, must be `input_audio_buffer.append`." - }), - "audio": Schema.String.annotate({ - "description": - "Base64-encoded audio bytes. This must be in the format specified by the \n`input_audio_format` field in the session configuration.\n" - }) + "vector_store_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result." + }), + Schema.Null + ]) + ) }).annotate({ - "description": - "Send this event to append audio bytes to the input audio buffer. The audio \nbuffer is temporary storage you can write to and later commit. A \"commit\" will create a new\nuser message item in the conversation history from the buffer content and clear the buffer.\nInput audio transcription (if enabled) will be generated when the buffer is committed.\n\nIf VAD is enabled the audio buffer is used to detect speech and the server will decide \nwhen to commit. When Server VAD is disabled, you must commit the audio buffer\nmanually. Input audio noise reduction operates on writes to the audio buffer.\n\nThe client may choose how much audio to place in each event up to a maximum \nof 15 MiB, for example streaming smaller chunks from the client may allow the \nVAD to be more responsive. Unlike most other client events, the server will \nnot send a confirmation response to this event.\n" + "description": "The aggregated file search calls usage details of the specific time bucket.", + "identifier": "UsageFileSearchCallsResult" }) -export type RealtimeClientEventInputAudioBufferClear = { - readonly "event_id"?: string - readonly "type": "input_audio_buffer.clear" +export type UsageWebSearchCallsResult = { + readonly "object": "organization.usage.web_searches.result" + readonly "num_model_requests": number + readonly "num_requests": number + readonly "project_id"?: string | null + readonly "user_id"?: string | null + readonly "api_key_id"?: string | null + readonly "model"?: string | null + readonly "context_level"?: string | null } -export const RealtimeClientEventInputAudioBufferClear = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) +export const UsageWebSearchCallsResult = Schema.Struct({ + "object": Schema.Literal("organization.usage.web_searches.result"), + "num_model_requests": Schema.Number.annotate({ "description": "The count of model requests." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "type": Schema.Literal("input_audio_buffer.clear").annotate({ - "description": "The event type, must be `input_audio_buffer.clear`." - }) -}).annotate({ - "description": - "Send this event to clear the audio bytes in the buffer. The server will \nrespond with an `input_audio_buffer.cleared` event.\n" -}) -export type RealtimeClientEventInputAudioBufferCommit = { - readonly "event_id"?: string - readonly "type": "input_audio_buffer.commit" -} -export const RealtimeClientEventInputAudioBufferCommit = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) + "num_requests": Schema.Number.annotate({ "description": "The count of web search calls." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "type": Schema.Literal("input_audio_buffer.commit").annotate({ - "description": "The event type, must be `input_audio_buffer.commit`." - }) -}).annotate({ - "description": - "Send this event to commit the user input audio buffer, which will create a new user message item in the conversation. This event will produce an error if the input audio buffer is empty. When in Server VAD mode, the client does not need to send this event, the server will commit the audio buffer automatically.\n\nCommitting the input audio buffer will trigger input audio transcription (if enabled in session configuration), but it will not create a response from the model. The server will respond with an `input_audio_buffer.committed` event.\n" -}) -export type RealtimeClientEventOutputAudioBufferClear = { - readonly "event_id"?: string - readonly "type": "output_audio_buffer.clear" -} -export const RealtimeClientEventOutputAudioBufferClear = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The unique ID of the client event used for error handling." }) + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + }), + Schema.Null + ]) ), - "type": Schema.Literal("output_audio_buffer.clear").annotate({ - "description": "The event type, must be `output_audio_buffer.clear`." - }) -}).annotate({ - "description": - "**WebRTC/SIP Only:** Emit to cut off the current audio response. This will trigger the server to\nstop generating audio and emit a `output_audio_buffer.cleared` event. This\nevent should be preceded by a `response.cancel` client event to stop the\ngeneration of the current response.\n[Learn more](/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).\n" -}) -export type RealtimeClientEventResponseCancel = { - readonly "event_id"?: string - readonly "type": "response.cancel" - readonly "response_id"?: string -} -export const RealtimeClientEventResponseCancel = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) + "user_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." + }), + Schema.Null + ]) ), - "type": Schema.Literal("response.cancel").annotate({ "description": "The event type, must be `response.cancel`." }), - "response_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A specific response ID to cancel - if not provided, will cancel an \nin-progress response in the default conversation.\n" - }) + "api_key_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." + }), + Schema.Null + ]) + ), + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=model`, this field provides the model name of the grouped usage result." + }), + Schema.Null + ]) + ), + "context_level": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "When `group_by=context_level`, this field provides the search context size of the grouped usage result." + }), + Schema.Null + ]) ) }).annotate({ - "description": - "Send this event to cancel an in-progress response. The server will respond \nwith a `response.done` event with a status of `response.status=cancelled`. If \nthere is no response to cancel, the server will respond with an error. It's safe\nto call `response.cancel` even if no response is in progress, an error will be\nreturned the session will remain unaffected.\n" + "description": "The aggregated web search calls usage details of the specific time bucket.", + "identifier": "UsageWebSearchCallsResult" }) -export type RealtimeConversationItemFunctionCall = { - readonly "id"?: string - readonly "object"?: "realtime.item" - readonly "type": "function_call" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "call_id"?: string - readonly "name": string - readonly "arguments": string +export type CostsResult = { + readonly "object": "organization.costs.result" + readonly "amount"?: { readonly "value"?: number; readonly "currency"?: string } + readonly "line_item"?: string | null + readonly "project_id"?: string | null + readonly "api_key_id"?: string | null + readonly "quantity"?: number | null } -export const RealtimeConversationItemFunctionCall = Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The unique ID of the item. This may be provided by the client or generated by the server." - }) +export const CostsResult = Schema.Struct({ + "object": Schema.Literal("organization.costs.result"), + "amount": Schema.optionalKey( + Schema.Struct({ + "value": Schema.optionalKey( + Schema.Number.annotate({ "description": "The numeric value of the cost." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "currency": Schema.optionalKey( + Schema.String.annotate({ "description": "Lowercase ISO-4217 currency e.g. \"usd\"" }) + ) + }).annotate({ "description": "The monetary value in its associated currency." }) ), - "object": Schema.optionalKey( - Schema.Literal("realtime.item").annotate({ - "description": - "Identifier for the API object being returned - always `realtime.item`. Optional when creating a new item." - }) + "line_item": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=line_item`, this field provides the line item of the grouped costs result." + }), + Schema.Null + ]) ), - "type": Schema.Literal("function_call").annotate({ "description": "The type of the item. Always `function_call`." }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "incomplete", "in_progress"]).annotate({ - "description": "The status of the item. Has no effect on the conversation." - }) + "project_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=project_id`, this field provides the project ID of the grouped costs result." + }), + Schema.Null + ]) ), - "call_id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the function call." })), - "name": Schema.String.annotate({ "description": "The name of the function being called." }), - "arguments": Schema.String.annotate({ - "description": - "The arguments of the function call. This is a JSON-encoded string representing the arguments passed to the function, for example `{\"arg1\": \"value1\", \"arg2\": 42}`." - }) -}).annotate({ - "title": "Realtime function call item", - "description": "A function call item in a Realtime conversation." -}) -export type RealtimeConversationItemFunctionCallOutput = { - readonly "id"?: string - readonly "object"?: "realtime.item" - readonly "type": "function_call_output" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "call_id": string - readonly "output": string -} -export const RealtimeConversationItemFunctionCallOutput = Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The unique ID of the item. This may be provided by the client or generated by the server." - }) - ), - "object": Schema.optionalKey( - Schema.Literal("realtime.item").annotate({ - "description": - "Identifier for the API object being returned - always `realtime.item`. Optional when creating a new item." - }) - ), - "type": Schema.Literal("function_call_output").annotate({ - "description": "The type of the item. Always `function_call_output`." - }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "incomplete", "in_progress"]).annotate({ - "description": "The status of the item. Has no effect on the conversation." - }) + "api_key_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result." + }), + Schema.Null + ]) ), - "call_id": Schema.String.annotate({ "description": "The ID of the function call this output is for." }), - "output": Schema.String.annotate({ - "description": - "The output of the function call, this is free text and can contain any information or simply be empty." - }) -}).annotate({ - "title": "Realtime function call output item", - "description": "A function call output item in a Realtime conversation." -}) -export type RealtimeConversationItemMessageAssistant = { - readonly "id"?: string - readonly "object"?: "realtime.item" - readonly "type": "message" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "role": "assistant" - readonly "content": ReadonlyArray< - { - readonly "type"?: "output_text" | "output_audio" - readonly "text"?: string - readonly "audio"?: string - readonly "transcript"?: string - } - > + "quantity": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "When `group_by=line_item`, this field provides the quantity of the grouped costs result." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ) +}).annotate({ "description": "The aggregated costs details of the specific time bucket.", "identifier": "CostsResult" }) +export type OrganizationDataRetention = { + readonly "object": "organization.data_retention" + readonly "type": + | "zero_data_retention" + | "modified_abuse_monitoring" + | "enhanced_zero_data_retention" + | "enhanced_modified_abuse_monitoring" } -export const RealtimeConversationItemMessageAssistant = Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The unique ID of the item. This may be provided by the client or generated by the server." - }) - ), - "object": Schema.optionalKey( - Schema.Literal("realtime.item").annotate({ - "description": - "Identifier for the API object being returned - always `realtime.item`. Optional when creating a new item." - }) - ), - "type": Schema.Literal("message").annotate({ "description": "The type of the item. Always `message`." }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "incomplete", "in_progress"]).annotate({ - "description": "The status of the item. Has no effect on the conversation." - }) - ), - "role": Schema.Literal("assistant").annotate({ - "description": "The role of the message sender. Always `assistant`." +export const OrganizationDataRetention = Schema.Struct({ + "object": Schema.Literal("organization.data_retention").annotate({ + "description": "The object type, which is always `organization.data_retention`." }), - "content": Schema.Array(Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literals(["output_text", "output_audio"]).annotate({ - "description": - "The content type, `output_text` or `output_audio` depending on the session `output_modalities` configuration." - }) - ), - "text": Schema.optionalKey(Schema.String.annotate({ "description": "The text content." })), - "audio": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Base64-encoded audio bytes, these will be parsed as the format specified in the session output audio type configuration. This defaults to PCM 16-bit 24kHz mono if not specified." - }) - ), - "transcript": Schema.optionalKey( - Schema.String.annotate({ - "description": "The transcript of the audio content, this will always be present if the output type is `audio`." - }) - ) - })).annotate({ "description": "The content of the message." }) + "type": Schema.Literals([ + "zero_data_retention", + "modified_abuse_monitoring", + "enhanced_zero_data_retention", + "enhanced_modified_abuse_monitoring" + ]).annotate({ "description": "The configured organization data retention type." }) }).annotate({ - "title": "Realtime assistant message item", - "description": "An assistant message item in a Realtime conversation." -}) -export type RealtimeConversationItemMessageSystem = { - readonly "id"?: string - readonly "object"?: "realtime.item" - readonly "type": "message" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "role": "system" - readonly "content": ReadonlyArray<{ readonly "type"?: "input_text"; readonly "text"?: string }> -} -export const RealtimeConversationItemMessageSystem = Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The unique ID of the item. This may be provided by the client or generated by the server." - }) - ), - "object": Schema.optionalKey( - Schema.Literal("realtime.item").annotate({ - "description": - "Identifier for the API object being returned - always `realtime.item`. Optional when creating a new item." - }) - ), - "type": Schema.Literal("message").annotate({ "description": "The type of the item. Always `message`." }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "incomplete", "in_progress"]).annotate({ - "description": "The status of the item. Has no effect on the conversation." - }) - ), - "role": Schema.Literal("system").annotate({ "description": "The role of the message sender. Always `system`." }), - "content": Schema.Array( - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("input_text").annotate({ - "description": "The content type. Always `input_text` for system messages." - }) - ), - "text": Schema.optionalKey(Schema.String.annotate({ "description": "The text content." })) - }) - ).annotate({ "description": "The content of the message." }) + "description": "Represents the organization's data retention control setting.", + "identifier": "OrganizationDataRetention" +}) +export type UpdateOrganizationDataRetentionBody = { + readonly "retention_type": + | "zero_data_retention" + | "modified_abuse_monitoring" + | "enhanced_zero_data_retention" + | "enhanced_modified_abuse_monitoring" +} +export const UpdateOrganizationDataRetentionBody = Schema.Struct({ + "retention_type": Schema.Literals([ + "zero_data_retention", + "modified_abuse_monitoring", + "enhanced_zero_data_retention", + "enhanced_modified_abuse_monitoring" + ]).annotate({ "description": "The desired organization data retention type." }) }).annotate({ - "title": "Realtime system message item", - "description": - "A system message in a Realtime conversation can be used to provide additional context or instructions to the model. This is similar but distinct from the instruction prompt provided at the start of a conversation, as system messages can be added at any point in the conversation. For major changes to the conversation's behavior, use instructions, but for smaller updates (e.g. \"the user is now asking about a different topic\"), use system messages." + "description": "Parameters for updating organization data retention controls.", + "identifier": "UpdateOrganizationDataRetentionBody" }) -export type RealtimeConversationItemMessageUser = { - readonly "id"?: string - readonly "object"?: "realtime.item" - readonly "type": "message" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "role": "user" - readonly "content": ReadonlyArray< - { - readonly "type"?: "input_text" | "input_audio" | "input_image" - readonly "text"?: string - readonly "audio"?: string - readonly "image_url"?: string - readonly "detail"?: "auto" | "low" | "high" - readonly "transcript"?: string - } - > -} -export const RealtimeConversationItemMessageUser = Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The unique ID of the item. This may be provided by the client or generated by the server." - }) - ), - "object": Schema.optionalKey( - Schema.Literal("realtime.item").annotate({ - "description": - "Identifier for the API object being returned - always `realtime.item`. Optional when creating a new item." - }) - ), - "type": Schema.Literal("message").annotate({ "description": "The type of the item. Always `message`." }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "incomplete", "in_progress"]).annotate({ - "description": "The status of the item. Has no effect on the conversation." - }) - ), - "role": Schema.Literal("user").annotate({ "description": "The role of the message sender. Always `user`." }), - "content": Schema.Array(Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literals(["input_text", "input_audio", "input_image"]).annotate({ - "description": "The content type (`input_text`, `input_audio`, or `input_image`)." - }) - ), - "text": Schema.optionalKey(Schema.String.annotate({ "description": "The text content (for `input_text`)." })), - "audio": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Base64-encoded audio bytes (for `input_audio`), these will be parsed as the format specified in the session input audio type configuration. This defaults to PCM 16-bit 24kHz mono if not specified." - }) - ), - "image_url": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Base64-encoded image bytes (for `input_image`) as a data URI. For example `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...`. Supported formats are PNG and JPEG.", - "format": "uri" - }) - ), - "detail": Schema.optionalKey( - Schema.Literals(["auto", "low", "high"]).annotate({ - "description": "The detail level of the image (for `input_image`). `auto` will default to `high`." - }) - ), - "transcript": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Transcript of the audio (for `input_audio`). This is not sent to the model, but will be attached to the message item for reference." - }) - ) - })).annotate({ "description": "The content of the message." }) -}).annotate({ "title": "Realtime user message item", "description": "A user message item in a Realtime conversation." }) -export type RealtimeFunctionTool = { - readonly "type"?: "function" - readonly "name"?: string - readonly "description"?: string - readonly "parameters"?: {} -} -export const RealtimeFunctionTool = Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("function").annotate({ "description": "The type of the tool, i.e. `function`." }) - ), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function." })), - "description": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The description of the function, including guidance on when and how\nto call it, and guidance about what to tell the user when calling\n(if anything).\n" - }) - ), - "parameters": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Parameters of the function in JSON Schema." }) - ) -}).annotate({ "title": "Function tool" }) -export type RealtimeMCPApprovalRequest = { - readonly "type": "mcp_approval_request" +export type GroupResponse = { readonly "id": string - readonly "server_label": string readonly "name": string - readonly "arguments": string + readonly "created_at": number + readonly "is_scim_managed": boolean + readonly "group_type": "group" | "tenant_group" } -export const RealtimeMCPApprovalRequest = Schema.Struct({ - "type": Schema.Literal("mcp_approval_request").annotate({ - "description": "The type of the item. Always `mcp_approval_request`." +export const GroupResponse = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier for the group." }), + "name": Schema.String.annotate({ "description": "Display name of the group." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the group was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "is_scim_managed": Schema.Boolean.annotate({ + "description": "Whether the group is managed through SCIM and controlled by your identity provider." }), - "id": Schema.String.annotate({ "description": "The unique ID of the approval request." }), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server making the request." }), - "name": Schema.String.annotate({ "description": "The name of the tool to run." }), - "arguments": Schema.String.annotate({ "description": "A JSON string of arguments for the tool." }) + "group_type": Schema.Literals(["group", "tenant_group"]).annotate({ "description": "The type of the group." }) +}).annotate({ "description": "Details about an organization group.", "identifier": "GroupResponse" }) +export type CreateGroupBody = { readonly "name": string } +export const CreateGroupBody = Schema.Struct({ + "name": Schema.String.annotate({ "description": "Human readable name for the group." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })) }).annotate({ - "title": "Realtime MCP approval request", - "description": "A Realtime item requesting human approval of a tool invocation.\n" + "description": "Request payload for creating a new group in the organization.", + "identifier": "CreateGroupBody" }) -export type RealtimeMCPApprovalResponse = { - readonly "type": "mcp_approval_response" - readonly "id": string - readonly "approval_request_id": string - readonly "approve": boolean - readonly "reason"?: string | null -} -export const RealtimeMCPApprovalResponse = Schema.Struct({ - "type": Schema.Literal("mcp_approval_response").annotate({ - "description": "The type of the item. Always `mcp_approval_response`." - }), - "id": Schema.String.annotate({ "description": "The unique ID of the approval response." }), - "approval_request_id": Schema.String.annotate({ "description": "The ID of the approval request being answered." }), - "approve": Schema.Boolean.annotate({ "description": "Whether the request was approved." }), - "reason": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "Optional reason for the decision." }), Schema.Null]) - ) +export type UpdateGroupBody = { readonly "name": string } +export const UpdateGroupBody = Schema.Struct({ + "name": Schema.String.annotate({ "description": "New display name for the group." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })) }).annotate({ - "title": "Realtime MCP approval response", - "description": "A Realtime item responding to an MCP approval request.\n" + "description": "Request payload for updating the details of an existing group.", + "identifier": "UpdateGroupBody" }) -export type RealtimeMCPHTTPError = { - readonly "type": "http_error" - readonly "code": number - readonly "message": string +export type GroupResourceWithSuccess = { + readonly "id": string + readonly "name": string + readonly "created_at": number + readonly "is_scim_managed": boolean } -export const RealtimeMCPHTTPError = Schema.Struct({ - "type": Schema.Literal("http_error"), - "code": Schema.Number.check(Schema.isInt()), - "message": Schema.String -}).annotate({ "title": "Realtime MCP HTTP error" }) -export type RealtimeMCPProtocolError = { - readonly "type": "protocol_error" - readonly "code": number - readonly "message": string +export const GroupResourceWithSuccess = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier for the group." }), + "name": Schema.String.annotate({ "description": "Updated display name for the group." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the group was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "is_scim_managed": Schema.Boolean.annotate({ + "description": "Whether the group is managed through SCIM and controlled by your identity provider." + }) +}).annotate({ "description": "Response returned after updating a group.", "identifier": "GroupResourceWithSuccess" }) +export type GroupDeletedResource = { + readonly "object": "group.deleted" + readonly "id": string + readonly "deleted": boolean } -export const RealtimeMCPProtocolError = Schema.Struct({ - "type": Schema.Literal("protocol_error"), - "code": Schema.Number.check(Schema.isInt()), - "message": Schema.String -}).annotate({ "title": "Realtime MCP protocol error" }) -export type RealtimeMCPToolExecutionError = { readonly "type": "tool_execution_error"; readonly "message": string } -export const RealtimeMCPToolExecutionError = Schema.Struct({ - "type": Schema.Literal("tool_execution_error"), - "message": Schema.String -}).annotate({ "title": "Realtime MCP tool execution error" }) -export type RealtimeReasoningEffort = "minimal" | "low" | "medium" | "high" | "xhigh" -export const RealtimeReasoningEffort = Schema.Literals(["minimal", "low", "medium", "high", "xhigh"]).annotate({ - "description": "Constrains effort on reasoning for reasoning-capable Realtime models such as\n`gpt-realtime-2`.\n" +export const GroupDeletedResource = Schema.Struct({ + "object": Schema.Literal("group.deleted").annotate({ "description": "Always `group.deleted`." }), + "id": Schema.String.annotate({ "description": "Identifier of the deleted group." }), + "deleted": Schema.Boolean.annotate({ "description": "Whether the group was deleted." }) +}).annotate({ + "description": "Confirmation payload returned after deleting a group.", + "identifier": "GroupDeletedResource" }) -export type RealtimeServerEventConversationCreated = { - readonly "event_id": string - readonly "type": "conversation.created" - readonly "conversation": { readonly "id"?: string; readonly "object"?: string } +export type AssignedRoleDetails = { + readonly "id": string + readonly "name": string + readonly "permissions": ReadonlyArray + readonly "resource_type": string + readonly "predefined_role": boolean + readonly "description": string | null + readonly "created_at": number | null + readonly "updated_at": number | null + readonly "created_by": string | null + readonly "created_by_user_obj": {} | null + readonly "metadata": {} | null + readonly "assignment_sources": + | ReadonlyArray<{ readonly "principal_id": string; readonly "principal_type": string }> + | null } -export const RealtimeServerEventConversationCreated = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.created").annotate({ - "description": "The event type, must be `conversation.created`." +export const AssignedRoleDetails = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier for the role." }), + "name": Schema.String.annotate({ "description": "Name of the role." }), + "permissions": Schema.Array(Schema.String).annotate({ "description": "Permissions associated with the role." }), + "resource_type": Schema.String.annotate({ "description": "Resource type the role applies to." }), + "predefined_role": Schema.Boolean.annotate({ "description": "Whether the role is predefined by OpenAI." }), + "description": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Description of the role." }), + "created_at": Schema.Union([ + Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "When the role was created." }), + "updated_at": Schema.Union([ + Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "When the role was last updated." }), + "created_by": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Identifier of the actor who created the role." }), - "conversation": Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the conversation." })), - "object": Schema.optionalKey( - Schema.String.annotate({ "description": "The object type, must be `realtime.conversation`." }) - ) - }).annotate({ "description": "The conversation resource." }) -}).annotate({ "description": "Returned when a conversation is created. Emitted right after session creation.\n" }) -export type RealtimeServerEventConversationItemDeleted = { - readonly "event_id": string - readonly "type": "conversation.item.deleted" - readonly "item_id": string -} -export const RealtimeServerEventConversationItemDeleted = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.deleted").annotate({ - "description": "The event type, must be `conversation.item.deleted`." + "created_by_user_obj": Schema.Union([Schema.Struct({}), Schema.Null]).annotate({ + "description": "User details for the actor that created the role, when available." }), - "item_id": Schema.String.annotate({ "description": "The ID of the item that was deleted." }) + "metadata": Schema.Union([Schema.Struct({}), Schema.Null]).annotate({ + "description": "Arbitrary metadata stored on the role." + }), + "assignment_sources": Schema.Union([ + Schema.Array(Schema.Struct({ "principal_id": Schema.String, "principal_type": Schema.String })), + Schema.Null + ]).annotate({ "description": "Principals from which the role assignment is inherited, when available." }) }).annotate({ - "description": - "Returned when an item in the conversation is deleted by the client with a \n`conversation.item.delete` event. This event is used to synchronize the \nserver's understanding of the conversation history with the client's view.\n" + "description": "Detailed information about a role assignment entry returned when listing assignments.", + "identifier": "AssignedRoleDetails" }) -export type RealtimeServerEventConversationItemInputAudioTranscriptionFailed = { - readonly "event_id": string - readonly "type": "conversation.item.input_audio_transcription.failed" - readonly "item_id": string - readonly "content_index": number - readonly "error": { - readonly "type"?: string - readonly "code"?: string - readonly "message"?: string - readonly "param"?: string - } -} -export const RealtimeServerEventConversationItemInputAudioTranscriptionFailed = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.input_audio_transcription.failed").annotate({ - "description": "The event type, must be\n`conversation.item.input_audio_transcription.failed`.\n" - }), - "item_id": Schema.String.annotate({ "description": "The ID of the user message item." }), - "content_index": Schema.Number.annotate({ "description": "The index of the content part containing the audio." }) - .check(Schema.isInt()), - "error": Schema.Struct({ - "type": Schema.optionalKey(Schema.String.annotate({ "description": "The type of error." })), - "code": Schema.optionalKey(Schema.String.annotate({ "description": "Error code, if any." })), - "message": Schema.optionalKey(Schema.String.annotate({ "description": "A human-readable error message." })), - "param": Schema.optionalKey(Schema.String.annotate({ "description": "Parameter related to the error, if any." })) - }).annotate({ "description": "Details of the transcription error." }) +export type PublicAssignOrganizationGroupRoleBody = { readonly "role_id": string } +export const PublicAssignOrganizationGroupRoleBody = Schema.Struct({ + "role_id": Schema.String.annotate({ "description": "Identifier of the role to assign." }) }).annotate({ - "description": - "Returned when input audio transcription is configured, and a transcription \nrequest for a user message failed. These events are separate from other \n`error` events so that the client can identify the related Item.\n" + "description": "Request payload for assigning a role to a group or user.", + "identifier": "PublicAssignOrganizationGroupRoleBody" }) -export type RealtimeServerEventConversationItemInputAudioTranscriptionSegment = { - readonly "event_id": string - readonly "type": "conversation.item.input_audio_transcription.segment" - readonly "item_id": string - readonly "content_index": number - readonly "text": string +export type Group = { + readonly "object": "group" readonly "id": string - readonly "speaker": string - readonly "start": number - readonly "end": number -} -export const RealtimeServerEventConversationItemInputAudioTranscriptionSegment = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.input_audio_transcription.segment").annotate({ - "description": "The event type, must be `conversation.item.input_audio_transcription.segment`." - }), - "item_id": Schema.String.annotate({ "description": "The ID of the item containing the input audio content." }), - "content_index": Schema.Number.annotate({ - "description": "The index of the input audio content part within the item." - }).check(Schema.isInt()), - "text": Schema.String.annotate({ "description": "The text for this segment." }), - "id": Schema.String.annotate({ "description": "The segment identifier." }), - "speaker": Schema.String.annotate({ "description": "The detected speaker label for this segment." }), - "start": Schema.Number.annotate({ "description": "Start time of the segment in seconds.", "format": "double" }).check( - Schema.isFinite() - ), - "end": Schema.Number.annotate({ "description": "End time of the segment in seconds.", "format": "double" }).check( - Schema.isFinite() - ) -}).annotate({ "description": "Returned when an input audio transcription segment is identified for an item." }) -export type RealtimeServerEventConversationItemTruncated = { - readonly "event_id": string - readonly "type": "conversation.item.truncated" - readonly "item_id": string - readonly "content_index": number - readonly "audio_end_ms": number -} -export const RealtimeServerEventConversationItemTruncated = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.truncated").annotate({ - "description": "The event type, must be `conversation.item.truncated`." - }), - "item_id": Schema.String.annotate({ "description": "The ID of the assistant message item that was truncated." }), - "content_index": Schema.Number.annotate({ "description": "The index of the content part that was truncated." }).check( - Schema.isInt() - ), - "audio_end_ms": Schema.Number.annotate({ - "description": "The duration up to which the audio was truncated, in milliseconds.\n" - }).check(Schema.isInt()) -}).annotate({ - "description": - "Returned when an earlier assistant audio message item is truncated by the \nclient with a `conversation.item.truncate` event. This event is used to \nsynchronize the server's understanding of the audio with the client's playback.\n\nThis action will truncate the audio and remove the server-side text transcript \nto ensure there is no text in the context that hasn't been heard by the user.\n" -}) -export type RealtimeServerEventError = { - readonly "event_id": string - readonly "type": "error" - readonly "error": { - readonly "type": string - readonly "code"?: string | null - readonly "message": string - readonly "param"?: string | null - readonly "event_id"?: string | null - } -} -export const RealtimeServerEventError = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("error").annotate({ "description": "The event type, must be `error`." }), - "error": Schema.Struct({ - "type": Schema.String.annotate({ - "description": "The type of error (e.g., \"invalid_request_error\", \"server_error\").\n" - }), - "code": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "Error code, if any." }), Schema.Null]) - ), - "message": Schema.String.annotate({ "description": "A human-readable error message." }), - "param": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "Parameter related to the error, if any." }), Schema.Null]) - ), - "event_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "The event_id of the client event that caused the error, if applicable.\n" - }), - Schema.Null - ]) - ) - }).annotate({ "description": "Details of the error." }) -}).annotate({ - "description": - "Returned when an error occurs, which could be a client problem or a server\nproblem. Most errors are recoverable and the session will stay open, we\nrecommend to implementors to monitor and log error messages by default.\n" -}) -export type RealtimeServerEventInputAudioBufferCleared = { - readonly "event_id": string - readonly "type": "input_audio_buffer.cleared" + readonly "name": string + readonly "created_at": number + readonly "scim_managed": boolean } -export const RealtimeServerEventInputAudioBufferCleared = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("input_audio_buffer.cleared").annotate({ - "description": "The event type, must be `input_audio_buffer.cleared`." - }) +export const Group = Schema.Struct({ + "object": Schema.Literal("group").annotate({ "description": "Always `group`." }), + "id": Schema.String.annotate({ "description": "Identifier for the group." }), + "name": Schema.String.annotate({ "description": "Display name of the group." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the group was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "scim_managed": Schema.Boolean.annotate({ "description": "Whether the group is managed through SCIM." }) }).annotate({ - "description": - "Returned when the input audio buffer is cleared by the client with a \n`input_audio_buffer.clear` event.\n" + "description": "Summary information about a group returned in role assignment responses.", + "identifier": "Group" }) -export type RealtimeServerEventInputAudioBufferCommitted = { - readonly "event_id": string - readonly "type": "input_audio_buffer.committed" - readonly "previous_item_id"?: string | null - readonly "item_id": string +export type Role = { + readonly "object": "role" + readonly "id": string + readonly "name": string + readonly "description": string | null + readonly "permissions": ReadonlyArray + readonly "resource_type": string + readonly "predefined_role": boolean } -export const RealtimeServerEventInputAudioBufferCommitted = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("input_audio_buffer.committed").annotate({ - "description": "The event type, must be `input_audio_buffer.committed`." +export const Role = Schema.Struct({ + "object": Schema.Literal("role").annotate({ "description": "Always `role`." }), + "id": Schema.String.annotate({ "description": "Identifier for the role." }), + "name": Schema.String.annotate({ "description": "Unique name for the role." }), + "description": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Optional description of the role." }), - "previous_item_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The ID of the preceding item after which the new item will be inserted.\nCan be `null` if the item has no predecessor.\n" - }), - Schema.Null - ]) - ), - "item_id": Schema.String.annotate({ "description": "The ID of the user message item that will be created." }) -}).annotate({ - "description": - "Returned when an input audio buffer is committed, either by the client or\nautomatically in server VAD mode. The `item_id` property is the ID of the user\nmessage item that will be created, thus a `conversation.item.created` event\nwill also be sent to the client.\n" -}) -export type RealtimeServerEventInputAudioBufferDtmfEventReceived = { - readonly "type": "input_audio_buffer.dtmf_event_received" - readonly "event": string - readonly "received_at": number -} -export const RealtimeServerEventInputAudioBufferDtmfEventReceived = Schema.Struct({ - "type": Schema.Literal("input_audio_buffer.dtmf_event_received").annotate({ - "description": "The event type, must be `input_audio_buffer.dtmf_event_received`." + "permissions": Schema.Array(Schema.String).annotate({ "description": "Permissions granted by the role." }), + "resource_type": Schema.String.annotate({ + "description": "Resource type the role is bound to (for example `api.organization` or `api.project`)." }), - "event": Schema.String.annotate({ "description": "The telephone keypad that was pressed by the user." }), - "received_at": Schema.Number.annotate({ - "description": "UTC Unix Timestamp when DTMF Event was received by server.\n" - }).check(Schema.isInt()) + "predefined_role": Schema.Boolean.annotate({ "description": "Whether the role is predefined and managed by OpenAI." }) }).annotate({ - "description": - "**SIP Only:** Returned when an DTMF event is received. A DTMF event is a message that\nrepresents a telephone keypad press (0–9, *, #, A–D). The `event` property\nis the keypad that the user press. The `received_at` is the UTC Unix Timestamp\nthat the server received the event.\n" + "description": "Details about a role that can be assigned through the public Roles API.", + "identifier": "Role" }) -export type RealtimeServerEventInputAudioBufferSpeechStarted = { - readonly "event_id": string - readonly "type": "input_audio_buffer.speech_started" - readonly "audio_start_ms": number - readonly "item_id": string -} -export const RealtimeServerEventInputAudioBufferSpeechStarted = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("input_audio_buffer.speech_started").annotate({ - "description": "The event type, must be `input_audio_buffer.speech_started`." +export type DeletedRoleAssignmentResource = { readonly "object": string; readonly "deleted": boolean } +export const DeletedRoleAssignmentResource = Schema.Struct({ + "object": Schema.String.annotate({ + "description": "Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`." }), - "audio_start_ms": Schema.Number.annotate({ - "description": - "Milliseconds from the start of all audio written to the buffer during the \nsession when speech was first detected. This will correspond to the \nbeginning of audio sent to the model, and thus includes the \n`prefix_padding_ms` configured in the Session.\n" - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The ID of the user message item that will be created when speech stops.\n" - }) + "deleted": Schema.Boolean.annotate({ "description": "Whether the assignment was removed." }) }).annotate({ - "description": - "Sent by the server when in `server_vad` mode to indicate that speech has been \ndetected in the audio buffer. This can happen any time audio is added to the \nbuffer (unless speech is already detected). The client may want to use this \nevent to interrupt audio playback or provide visual feedback to the user. \n\nThe client should expect to receive a `input_audio_buffer.speech_stopped` event \nwhen speech stops. The `item_id` property is the ID of the user message item \nthat will be created when speech stops and will also be included in the \n`input_audio_buffer.speech_stopped` event (unless the client manually commits \nthe audio buffer during VAD activation).\n" + "description": "Confirmation payload returned after unassigning a role.", + "identifier": "DeletedRoleAssignmentResource" }) -export type RealtimeServerEventInputAudioBufferSpeechStopped = { - readonly "event_id": string - readonly "type": "input_audio_buffer.speech_stopped" - readonly "audio_end_ms": number - readonly "item_id": string -} -export const RealtimeServerEventInputAudioBufferSpeechStopped = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("input_audio_buffer.speech_stopped").annotate({ - "description": "The event type, must be `input_audio_buffer.speech_stopped`." - }), - "audio_end_ms": Schema.Number.annotate({ - "description": - "Milliseconds since the session started when speech stopped. This will \ncorrespond to the end of audio sent to the model, and thus includes the \n`min_silence_duration_ms` configured in the Session.\n" - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ "description": "The ID of the user message item that will be created." }) +export type GroupUser = { readonly "id": string; readonly "name": string; readonly "email": string | null } +export const GroupUser = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "name": Schema.String.annotate({ "description": "The name of the user." }), + "email": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The email address of the user." }) }).annotate({ - "description": - "Returned in `server_vad` mode when the server detects the end of speech in \nthe audio buffer. The server will also send an `conversation.item.created` \nevent with the user message item that is created from the audio buffer.\n" + "description": "Represents an individual user returned when inspecting group membership.", + "identifier": "GroupUser" }) -export type RealtimeServerEventInputAudioBufferTimeoutTriggered = { - readonly "event_id": string - readonly "type": "input_audio_buffer.timeout_triggered" - readonly "audio_start_ms": number - readonly "audio_end_ms": number - readonly "item_id": string +export type CreateGroupUserBody = { readonly "user_id": string } +export const CreateGroupUserBody = Schema.Struct({ + "user_id": Schema.String.annotate({ "description": "Identifier of the user to add to the group." }) +}).annotate({ "description": "Request payload for adding a user to a group.", "identifier": "CreateGroupUserBody" }) +export type GroupUserAssignment = { + readonly "object": "group.user" + readonly "user_id": string + readonly "group_id": string } -export const RealtimeServerEventInputAudioBufferTimeoutTriggered = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("input_audio_buffer.timeout_triggered").annotate({ - "description": "The event type, must be `input_audio_buffer.timeout_triggered`." - }), - "audio_start_ms": Schema.Number.annotate({ - "description": - "Millisecond offset of audio written to the input audio buffer that was after the playback time of the last model response." - }).check(Schema.isInt()), - "audio_end_ms": Schema.Number.annotate({ - "description": - "Millisecond offset of audio written to the input audio buffer at the time the timeout was triggered." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ "description": "The ID of the item associated with this segment." }) +export const GroupUserAssignment = Schema.Struct({ + "object": Schema.Literal("group.user").annotate({ "description": "Always `group.user`." }), + "user_id": Schema.String.annotate({ "description": "Identifier of the user that was added." }), + "group_id": Schema.String.annotate({ "description": "Identifier of the group the user was added to." }) }).annotate({ - "description": - "Returned when the Server VAD timeout is triggered for the input audio buffer. This is configured\nwith `idle_timeout_ms` in the `turn_detection` settings of the session, and it indicates that\nthere hasn't been any speech detected for the configured duration.\n\nThe `audio_start_ms` and `audio_end_ms` fields indicate the segment of audio after the last\nmodel response up to the triggering time, as an offset from the beginning of audio written\nto the input audio buffer. This means it demarcates the segment of audio that was silent and\nthe difference between the start and end values will roughly match the configured timeout.\n\nThe empty audio will be committed to the conversation as an `input_audio` item (there will be a\n`input_audio_buffer.committed` event) and a model response will be generated. There may be speech\nthat didn't trigger VAD but is still detected by the model, so the model may respond with\nsomething relevant to the conversation or a prompt to continue speaking.\n" + "description": "Confirmation payload returned after adding a user to a group.", + "identifier": "GroupUserAssignment" }) -export type RealtimeServerEventMCPListToolsCompleted = { - readonly "event_id": string - readonly "type": "mcp_list_tools.completed" - readonly "item_id": string -} -export const RealtimeServerEventMCPListToolsCompleted = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("mcp_list_tools.completed").annotate({ - "description": "The event type, must be `mcp_list_tools.completed`." - }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP list tools item." }) -}).annotate({ "description": "Returned when listing MCP tools has completed for an item." }) -export type RealtimeServerEventMCPListToolsFailed = { - readonly "event_id": string - readonly "type": "mcp_list_tools.failed" - readonly "item_id": string -} -export const RealtimeServerEventMCPListToolsFailed = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("mcp_list_tools.failed").annotate({ - "description": "The event type, must be `mcp_list_tools.failed`." - }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP list tools item." }) -}).annotate({ "description": "Returned when listing MCP tools has failed for an item." }) -export type RealtimeServerEventMCPListToolsInProgress = { - readonly "event_id": string - readonly "type": "mcp_list_tools.in_progress" - readonly "item_id": string +export type GroupMemberUser = { + readonly "id": string + readonly "name": string + readonly "email": string | null + readonly "picture": string | null + readonly "is_service_account": boolean | null + readonly "user_type": "user" | "tenant_user" } -export const RealtimeServerEventMCPListToolsInProgress = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("mcp_list_tools.in_progress").annotate({ - "description": "The event type, must be `mcp_list_tools.in_progress`." +export const GroupMemberUser = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier for the user." }), + "name": Schema.String.annotate({ "description": "Display name of the user." }), + "email": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Email address of the user, or `null` for users without an email." }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP list tools item." }) -}).annotate({ "description": "Returned when listing MCP tools is in progress for an item." }) -export type RealtimeServerEventOutputAudioBufferCleared = { - readonly "event_id": string - readonly "type": "output_audio_buffer.cleared" - readonly "response_id": string -} -export const RealtimeServerEventOutputAudioBufferCleared = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("output_audio_buffer.cleared").annotate({ - "description": "The event type, must be `output_audio_buffer.cleared`." + "picture": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "URL of the user's profile picture, if available." }), - "response_id": Schema.String.annotate({ "description": "The unique ID of the response that produced the audio." }) -}).annotate({ - "description": - "**WebRTC/SIP Only:** Emitted when the output audio buffer is cleared. This happens either in VAD\nmode when the user has interrupted (`input_audio_buffer.speech_started`),\nor when the client has emitted the `output_audio_buffer.clear` event to manually\ncut off the current audio response.\n[Learn more](/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).\n" -}) -export type RealtimeServerEventOutputAudioBufferStarted = { - readonly "event_id": string - readonly "type": "output_audio_buffer.started" - readonly "response_id": string -} -export const RealtimeServerEventOutputAudioBufferStarted = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("output_audio_buffer.started").annotate({ - "description": "The event type, must be `output_audio_buffer.started`." + "is_service_account": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether the user is a service account." }), - "response_id": Schema.String.annotate({ "description": "The unique ID of the response that produced the audio." }) + "user_type": Schema.Literals(["user", "tenant_user"]).annotate({ "description": "The type of user." }) }).annotate({ - "description": - "**WebRTC/SIP Only:** Emitted when the server begins streaming audio to the client. This event is\nemitted after an audio content part has been added (`response.content_part.added`)\nto the response.\n[Learn more](/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).\n" + "description": "Details about a user returned from an organization group membership lookup.", + "identifier": "GroupMemberUser" }) -export type RealtimeServerEventOutputAudioBufferStopped = { - readonly "event_id": string - readonly "type": "output_audio_buffer.stopped" - readonly "response_id": string -} -export const RealtimeServerEventOutputAudioBufferStopped = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("output_audio_buffer.stopped").annotate({ - "description": "The event type, must be `output_audio_buffer.stopped`." - }), - "response_id": Schema.String.annotate({ "description": "The unique ID of the response that produced the audio." }) +export type GroupUserDeletedResource = { readonly "object": "group.user.deleted"; readonly "deleted": boolean } +export const GroupUserDeletedResource = Schema.Struct({ + "object": Schema.Literal("group.user.deleted").annotate({ "description": "Always `group.user.deleted`." }), + "deleted": Schema.Boolean.annotate({ "description": "Whether the group membership was removed." }) }).annotate({ - "description": - "**WebRTC/SIP Only:** Emitted when the output audio buffer has been completely drained on the server,\nand no more audio is forthcoming. This event is emitted after the full response\ndata has been sent to the client (`response.done`).\n[Learn more](/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).\n" + "description": "Confirmation payload returned after removing a user from a group.", + "identifier": "GroupUserDeletedResource" }) -export type RealtimeServerEventRateLimitsUpdated = { - readonly "event_id": string - readonly "type": "rate_limits.updated" - readonly "rate_limits": ReadonlyArray< - { - readonly "name"?: "requests" | "tokens" - readonly "limit"?: number - readonly "remaining"?: number - readonly "reset_seconds"?: number - } - > +export type Invite = { + readonly "object": "organization.invite" + readonly "id": string + readonly "email": string + readonly "role": "owner" | "reader" + readonly "status": "accepted" | "expired" | "pending" + readonly "created_at": number + readonly "expires_at"?: number | null + readonly "accepted_at"?: number | null + readonly "projects": ReadonlyArray<{ readonly "id": string; readonly "role": "member" | "owner" }> } -export const RealtimeServerEventRateLimitsUpdated = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("rate_limits.updated").annotate({ - "description": "The event type, must be `rate_limits.updated`." +export const Invite = Schema.Struct({ + "object": Schema.Literal("organization.invite").annotate({ + "description": "The object type, which is always `organization.invite`" }), - "rate_limits": Schema.Array(Schema.Struct({ - "name": Schema.optionalKey( - Schema.Literals(["requests", "tokens"]).annotate({ - "description": "The name of the rate limit (`requests`, `tokens`).\n" - }) - ), - "limit": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum allowed value for the rate limit." }).check(Schema.isInt()) - ), - "remaining": Schema.optionalKey( - Schema.Number.annotate({ "description": "The remaining value before the limit is reached." }).check( - Schema.isInt() - ) - ), - "reset_seconds": Schema.optionalKey( - Schema.Number.annotate({ "description": "Seconds until the rate limit resets." }).check(Schema.isFinite()) - ) - })).annotate({ "description": "List of rate limit information." }) -}).annotate({ - "description": - "Emitted at the beginning of a Response to indicate the updated rate limits. \nWhen a Response is created some tokens will be \"reserved\" for the output \ntokens, the rate limits shown here reflect that reservation, which is then \nadjusted accordingly once the Response is completed.\n" -}) -export type RealtimeServerEventResponseAudioDelta = { - readonly "event_id": string - readonly "type": "response.output_audio.delta" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "delta": string -} -export const RealtimeServerEventResponseAudioDelta = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.output_audio.delta").annotate({ - "description": "The event type, must be `response.output_audio.delta`." + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "email": Schema.String.annotate({ "description": "The email address of the individual to whom the invite was sent" }), + "role": Schema.Literals(["owner", "reader"]).annotate({ "description": "`owner` or `reader`" }), + "status": Schema.Literals(["accepted", "expired", "pending"]).annotate({ + "description": "`accepted`,`expired`, or `pending`" }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the invite was sent.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "expires_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "The Unix timestamp (in seconds) of when the invite expires." }) ), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part in the item's content array." - }).check(Schema.isInt()), - "delta": Schema.String.annotate({ "description": "Base64-encoded audio data delta." }) -}).annotate({ "description": "Returned when the model-generated audio is updated." }) -export type RealtimeServerEventResponseAudioDone = { - readonly "event_id": string - readonly "type": "response.output_audio.done" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number -} -export const RealtimeServerEventResponseAudioDone = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.output_audio.done").annotate({ - "description": "The event type, must be `response.output_audio.done`." - }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() + "accepted_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "The Unix timestamp (in seconds) of when the invite was accepted." }) ), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part in the item's content array." - }).check(Schema.isInt()) -}).annotate({ - "description": - "Returned when the model-generated audio is done. Also emitted when a Response\nis interrupted, incomplete, or cancelled.\n" -}) -export type RealtimeServerEventResponseAudioTranscriptDelta = { - readonly "event_id": string - readonly "type": "response.output_audio_transcript.delta" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "delta": string + "projects": Schema.Array( + Schema.Struct({ + "id": Schema.String.annotate({ "description": "Project's public ID" }), + "role": Schema.Literals(["member", "owner"]).annotate({ "description": "Project membership role" }) + }) + ).annotate({ "description": "The projects that were granted membership upon acceptance of the invite." }) +}).annotate({ "description": "Represents an individual `invite` to the organization.", "identifier": "Invite" }) +export type InviteRequest = { + readonly "email": string + readonly "role": "reader" | "owner" + readonly "projects"?: ReadonlyArray<{ readonly "id": string; readonly "role": "member" | "owner" }> +} +export const InviteRequest = Schema.Struct({ + "email": Schema.String.annotate({ "description": "Send an email to this address" }), + "role": Schema.Literals(["reader", "owner"]).annotate({ "description": "`owner` or `reader`" }), + "projects": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "id": Schema.String.annotate({ "description": "Project's public ID" }), + "role": Schema.Literals(["member", "owner"]).annotate({ "description": "Project membership role" }) + }) + ).annotate({ + "description": + "An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. If empty list is passed, the user will not be invited to any projects, including the default one." + }) + ) +}).annotate({ "identifier": "InviteRequest" }) +export type InviteDeleteResponse = { + readonly "object": "organization.invite.deleted" + readonly "id": string + readonly "deleted": boolean } -export const RealtimeServerEventResponseAudioTranscriptDelta = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.output_audio_transcript.delta").annotate({ - "description": "The event type, must be `response.output_audio_transcript.delta`." +export const InviteDeleteResponse = Schema.Struct({ + "object": Schema.Literal("organization.invite.deleted").annotate({ + "description": "The object type, which is always `organization.invite.deleted`" }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part in the item's content array." - }).check(Schema.isInt()), - "delta": Schema.String.annotate({ "description": "The transcript delta." }) -}).annotate({ "description": "Returned when the model-generated transcription of audio output is updated.\n" }) -export type RealtimeServerEventResponseAudioTranscriptDone = { - readonly "event_id": string - readonly "type": "response.output_audio_transcript.done" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "transcript": string + "id": Schema.String, + "deleted": Schema.Boolean +}).annotate({ "identifier": "InviteDeleteResponse" }) +export type Project = { + readonly "id": string + readonly "object": "organization.project" + readonly "name"?: string | null + readonly "created_at": number + readonly "archived_at"?: number | null + readonly "status"?: string | null + readonly "external_key_id"?: string | null } -export const RealtimeServerEventResponseAudioTranscriptDone = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.output_audio_transcript.done").annotate({ - "description": "The event type, must be `response.output_audio_transcript.done`." +export const Project = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "object": Schema.Literal("organization.project").annotate({ + "description": "The object type, which is always `organization.project`" }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() + "name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The name of the project. This appears in reporting." + }) ), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part in the item's content array." - }).check(Schema.isInt()), - "transcript": Schema.String.annotate({ "description": "The final transcript of the audio." }) + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the project was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "archived_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the project was archived or `null`.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "status": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "`active` or `archived`" }) + ), + "external_key_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The external key associated with the project." + }) + ) +}).annotate({ "description": "Represents an individual project.", "identifier": "Project" }) +export type ProjectCreateRequest = { + readonly "name": string + readonly "geography"?: string | null + readonly "external_key_id"?: string | null +} +export const ProjectCreateRequest = Schema.Struct({ + "name": Schema.String.annotate({ "description": "The friendly name of the project, this name appears in reports." }), + "geography": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "Create the project with the specified data residency region. Your organization must have access to Data residency functionality in order to use. See [data residency controls](/docs/guides/your-data#data-residency-controls) to review the functionality and limitations of setting this field." + }) + ), + "external_key_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "External key ID to associate with the project." + }) + ) +}).annotate({ "identifier": "ProjectCreateRequest" }) +export type ProjectUpdateRequest = { + readonly "name"?: string | null + readonly "external_key_id"?: string | null + readonly "geography"?: string | null +} +export const ProjectUpdateRequest = Schema.Struct({ + "name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The updated name of the project, this name appears in reports." + }) + ), + "external_key_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "External key ID to associate with the project." + }) + ), + "geography": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Geography for the project." }) + ) +}).annotate({ "identifier": "ProjectUpdateRequest" }) +export type ProjectApiKeyOwnerUser = { + readonly "id": string + readonly "email": string + readonly "name": string + readonly "created_at": number + readonly "role": string +} +export const ProjectApiKeyOwnerUser = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "email": Schema.String.annotate({ "description": "The email address of the user." }), + "name": Schema.String.annotate({ "description": "The name of the user." }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the user was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "role": Schema.String.annotate({ "description": "The user's project role." }) +}).annotate({ "description": "The user that owns a project API key.", "identifier": "ProjectApiKeyOwnerUser" }) +export type ProjectApiKeyOwnerServiceAccount = { + readonly "id": string + readonly "name": string + readonly "created_at": number + readonly "role": string +} +export const ProjectApiKeyOwnerServiceAccount = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "name": Schema.String.annotate({ "description": "The name of the service account." }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the service account was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "role": Schema.String.annotate({ "description": "The service account's project role." }) }).annotate({ - "description": - "Returned when the model-generated transcription of audio output is done\nstreaming. Also emitted when a Response is interrupted, incomplete, or\ncancelled.\n" + "description": "The service account that owns a project API key.", + "identifier": "ProjectApiKeyOwnerServiceAccount" }) -export type RealtimeServerEventResponseContentPartAdded = { - readonly "event_id": string - readonly "type": "response.content_part.added" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "part": { - readonly "type"?: "audio" | "text" - readonly "text"?: string - readonly "audio"?: string - readonly "transcript"?: string - } +export type ProjectApiKeyDeleteResponse = { + readonly "object": "organization.project.api_key.deleted" + readonly "id": string + readonly "deleted": boolean } -export const RealtimeServerEventResponseContentPartAdded = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.content_part.added").annotate({ - "description": "The event type, must be `response.content_part.added`." +export const ProjectApiKeyDeleteResponse = Schema.Struct({ + "object": Schema.Literal("organization.project.api_key.deleted"), + "id": Schema.String, + "deleted": Schema.Boolean +}).annotate({ "identifier": "ProjectApiKeyDeleteResponse" }) +export type OrganizationProjectCertificate = { + readonly "object": "organization.project.certificate" + readonly "id": string + readonly "name": string | null + readonly "created_at": number + readonly "certificate_details": { readonly "valid_at"?: number; readonly "expires_at"?: number } + readonly "active": boolean +} +export const OrganizationProjectCertificate = Schema.Struct({ + "object": Schema.Literal("organization.project.certificate").annotate({ + "description": "The object type, which is always `organization.project.certificate`." }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the item to which the content part was added." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part in the item's content array." - }).check(Schema.isInt()), - "part": Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literals(["audio", "text"]).annotate({ "description": "The content type (\"text\", \"audio\")." }) - ), - "text": Schema.optionalKey(Schema.String.annotate({ "description": "The text content (if type is \"text\")." })), - "audio": Schema.optionalKey( - Schema.String.annotate({ "description": "Base64-encoded audio data (if type is \"audio\")." }) + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the certificate." }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the certificate was uploaded.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "certificate_details": Schema.Struct({ + "valid_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the certificate becomes valid.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "transcript": Schema.optionalKey( - Schema.String.annotate({ "description": "The transcript of the audio (if type is \"audio\")." }) + "expires_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the certificate expires.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ) - }).annotate({ "description": "The content part that was added." }) + }), + "active": Schema.Boolean.annotate({ + "description": "Whether the certificate is currently active at the project level." + }) }).annotate({ - "description": "Returned when a new content part is added to an assistant message item during\nresponse generation.\n" + "description": "Represents an individual certificate configured at the project level.", + "identifier": "OrganizationProjectCertificate" }) -export type RealtimeServerEventResponseContentPartDone = { - readonly "event_id": string - readonly "type": "response.content_part.done" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "part": { - readonly "type"?: "audio" | "text" - readonly "text"?: string - readonly "audio"?: string - readonly "transcript"?: string - } +export type ProjectDataRetention = { + readonly "object": "project.data_retention" + readonly "type": + | "organization_default" + | "none" + | "zero_data_retention" + | "modified_abuse_monitoring" + | "enhanced_zero_data_retention" + | "enhanced_modified_abuse_monitoring" } -export const RealtimeServerEventResponseContentPartDone = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.content_part.done").annotate({ - "description": "The event type, must be `response.content_part.done`." +export const ProjectDataRetention = Schema.Struct({ + "object": Schema.Literal("project.data_retention").annotate({ + "description": "The object type, which is always `project.data_retention`." }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part in the item's content array." - }).check(Schema.isInt()), - "part": Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literals(["audio", "text"]).annotate({ "description": "The content type (\"text\", \"audio\")." }) - ), - "text": Schema.optionalKey(Schema.String.annotate({ "description": "The text content (if type is \"text\")." })), - "audio": Schema.optionalKey( - Schema.String.annotate({ "description": "Base64-encoded audio data (if type is \"audio\")." }) - ), - "transcript": Schema.optionalKey( - Schema.String.annotate({ "description": "The transcript of the audio (if type is \"audio\")." }) - ) - }).annotate({ "description": "The content part that is done." }) + "type": Schema.Literals([ + "organization_default", + "none", + "zero_data_retention", + "modified_abuse_monitoring", + "enhanced_zero_data_retention", + "enhanced_modified_abuse_monitoring" + ]).annotate({ "description": "The configured project data retention type." }) }).annotate({ - "description": - "Returned when a content part is done streaming in an assistant message item.\nAlso emitted when a Response is interrupted, incomplete, or cancelled.\n" + "description": "Represents a project's data retention control setting.", + "identifier": "ProjectDataRetention" +}) +export type UpdateProjectDataRetentionBody = { + readonly "retention_type": + | "organization_default" + | "none" + | "zero_data_retention" + | "modified_abuse_monitoring" + | "enhanced_zero_data_retention" + | "enhanced_modified_abuse_monitoring" +} +export const UpdateProjectDataRetentionBody = Schema.Struct({ + "retention_type": Schema.Literals([ + "organization_default", + "none", + "zero_data_retention", + "modified_abuse_monitoring", + "enhanced_zero_data_retention", + "enhanced_modified_abuse_monitoring" + ]).annotate({ "description": "The desired project data retention type." }) +}).annotate({ + "description": "Parameters for updating project data retention controls.", + "identifier": "UpdateProjectDataRetentionBody" }) -export type RealtimeServerEventResponseFunctionCallArgumentsDelta = { - readonly "event_id": string - readonly "type": "response.function_call_arguments.delta" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "call_id": string - readonly "delta": string -} -export const RealtimeServerEventResponseFunctionCallArgumentsDelta = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.function_call_arguments.delta").annotate({ - "description": "The event type, must be `response.function_call_arguments.delta`.\n" - }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the function call item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "call_id": Schema.String.annotate({ "description": "The ID of the function call." }), - "delta": Schema.String.annotate({ "description": "The arguments delta as a JSON string." }) -}).annotate({ "description": "Returned when the model-generated function call arguments are updated.\n" }) -export type RealtimeServerEventResponseFunctionCallArgumentsDone = { - readonly "event_id": string - readonly "type": "response.function_call_arguments.done" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "call_id": string - readonly "name": string - readonly "arguments": string +export type ProjectGroup = { + readonly "object": "project.group" + readonly "project_id": string + readonly "group_id": string + readonly "group_name": string + readonly "group_type": "group" | "tenant_group" + readonly "created_at": number } -export const RealtimeServerEventResponseFunctionCallArgumentsDone = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.function_call_arguments.done").annotate({ - "description": "The event type, must be `response.function_call_arguments.done`.\n" - }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the function call item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "call_id": Schema.String.annotate({ "description": "The ID of the function call." }), - "name": Schema.String.annotate({ "description": "The name of the function that was called." }), - "arguments": Schema.String.annotate({ "description": "The final arguments as a JSON string." }) +export const ProjectGroup = Schema.Struct({ + "object": Schema.Literal("project.group").annotate({ "description": "Always `project.group`." }), + "project_id": Schema.String.annotate({ "description": "Identifier of the project." }), + "group_id": Schema.String.annotate({ "description": "Identifier of the group that has access to the project." }), + "group_name": Schema.String.annotate({ "description": "Display name of the group." }), + "group_type": Schema.Literals(["group", "tenant_group"]).annotate({ "description": "The type of the group." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the group was granted project access.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "description": "Details about a group's membership in a project.", "identifier": "ProjectGroup" }) +export type InviteProjectGroupBody = { readonly "group_id": string; readonly "role": string } +export const InviteProjectGroupBody = Schema.Struct({ + "group_id": Schema.String.annotate({ "description": "Identifier of the group to add to the project." }), + "role": Schema.String.annotate({ "description": "Identifier of the project role to grant to the group." }) }).annotate({ - "description": - "Returned when the model-generated function call arguments are done streaming.\nAlso emitted when a Response is interrupted, incomplete, or cancelled.\n" + "description": "Request payload for granting a group access to a project.", + "identifier": "InviteProjectGroupBody" }) -export type RealtimeServerEventResponseMCPCallArgumentsDelta = { - readonly "event_id": string - readonly "type": "response.mcp_call_arguments.delta" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "delta": string - readonly "obfuscation"?: string | null +export type ProjectGroupDeletedResource = { readonly "object": "project.group.deleted"; readonly "deleted": boolean } +export const ProjectGroupDeletedResource = Schema.Struct({ + "object": Schema.Literal("project.group.deleted").annotate({ "description": "Always `project.group.deleted`." }), + "deleted": Schema.Boolean.annotate({ "description": "Whether the group membership in the project was removed." }) +}).annotate({ + "description": "Confirmation payload returned after removing a group from a project.", + "identifier": "ProjectGroupDeletedResource" +}) +export type HostedToolPermission = { readonly "enabled": boolean } +export const HostedToolPermission = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ "description": "Whether the hosted tool is enabled for the project." }) +}).annotate({ + "description": "Permission state for a single hosted tool on a project.", + "identifier": "HostedToolPermission" +}) +export type HostedToolPermissionUpdate = { readonly "enabled": boolean } +export const HostedToolPermissionUpdate = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ "description": "Whether to enable the hosted tool for the project." }) +}).annotate({ "identifier": "HostedToolPermissionUpdate" }) +export type ProjectModelPermissions = { + readonly "object": "project.model_permissions" + readonly "mode": "allow_list" | "deny_list" + readonly "model_ids": ReadonlyArray } -export const RealtimeServerEventResponseMCPCallArgumentsDelta = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.mcp_call_arguments.delta").annotate({ - "description": "The event type, must be `response.mcp_call_arguments.delta`." +export const ProjectModelPermissions = Schema.Struct({ + "object": Schema.Literal("project.model_permissions").annotate({ + "description": "The object type, which is always `project.model_permissions`." }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "delta": Schema.String.annotate({ "description": "The JSON-encoded arguments delta." }), - "obfuscation": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "If present, indicates the delta text was obfuscated." }), - Schema.Null - ]) - ) -}).annotate({ "description": "Returned when MCP tool call arguments are updated during response generation." }) -export type RealtimeServerEventResponseMCPCallArgumentsDone = { - readonly "event_id": string - readonly "type": "response.mcp_call_arguments.done" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "arguments": string -} -export const RealtimeServerEventResponseMCPCallArgumentsDone = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.mcp_call_arguments.done").annotate({ - "description": "The event type, must be `response.mcp_call_arguments.done`." + "mode": Schema.Literals(["allow_list", "deny_list"]).annotate({ + "description": "Whether the project uses an allowlist or a denylist." }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "arguments": Schema.String.annotate({ "description": "The final JSON-encoded arguments string." }) -}).annotate({ "description": "Returned when MCP tool call arguments are finalized during response generation." }) -export type RealtimeServerEventResponseMCPCallCompleted = { - readonly "event_id": string - readonly "type": "response.mcp_call.completed" - readonly "output_index": number - readonly "item_id": string + "model_ids": Schema.Array(Schema.String).annotate({ + "description": "The model IDs included in the model permissions policy." + }) +}).annotate({ + "description": "Represents the model allowlist or denylist policy for a project.", + "identifier": "ProjectModelPermissions" +}) +export type ProjectModelPermissionsUpdateRequest = { + readonly "mode": "allow_list" | "deny_list" + readonly "model_ids": ReadonlyArray } -export const RealtimeServerEventResponseMCPCallCompleted = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.mcp_call.completed").annotate({ - "description": "The event type, must be `response.mcp_call.completed`." +export const ProjectModelPermissionsUpdateRequest = Schema.Struct({ + "mode": Schema.Literals(["allow_list", "deny_list"]).annotate({ + "description": "The model permissions mode to apply." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item." }) -}).annotate({ "description": "Returned when an MCP tool call has completed successfully." }) -export type RealtimeServerEventResponseMCPCallFailed = { - readonly "event_id": string - readonly "type": "response.mcp_call.failed" - readonly "output_index": number - readonly "item_id": string + "model_ids": Schema.Array(Schema.String).annotate({ + "description": "The model IDs included in this permissions policy." + }) +}).annotate({ "identifier": "ProjectModelPermissionsUpdateRequest" }) +export type ProjectModelPermissionsDeleteResponse = { + readonly "object": "project.model_permissions.deleted" + readonly "deleted": boolean } -export const RealtimeServerEventResponseMCPCallFailed = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.mcp_call.failed").annotate({ - "description": "The event type, must be `response.mcp_call.failed`." +export const ProjectModelPermissionsDeleteResponse = Schema.Struct({ + "object": Schema.Literal("project.model_permissions.deleted").annotate({ + "description": "The object type, which is always `project.model_permissions.deleted`." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item." }) -}).annotate({ "description": "Returned when an MCP tool call has failed." }) -export type RealtimeServerEventResponseMCPCallInProgress = { - readonly "event_id": string - readonly "type": "response.mcp_call.in_progress" - readonly "output_index": number - readonly "item_id": string -} -export const RealtimeServerEventResponseMCPCallInProgress = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.mcp_call.in_progress").annotate({ - "description": "The event type, must be `response.mcp_call.in_progress`." - }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item." }) -}).annotate({ "description": "Returned when an MCP tool call has started and is in progress." }) -export type RealtimeServerEventResponseTextDelta = { - readonly "event_id": string - readonly "type": "response.output_text.delta" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "delta": string -} -export const RealtimeServerEventResponseTextDelta = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.output_text.delta").annotate({ - "description": "The event type, must be `response.output_text.delta`." - }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part in the item's content array." - }).check(Schema.isInt()), - "delta": Schema.String.annotate({ "description": "The text delta." }) -}).annotate({ "description": "Returned when the text value of an \"output_text\" content part is updated." }) -export type RealtimeServerEventResponseTextDone = { - readonly "event_id": string - readonly "type": "response.output_text.done" - readonly "response_id": string - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "text": string -} -export const RealtimeServerEventResponseTextDone = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.output_text.done").annotate({ - "description": "The event type, must be `response.output_text.done`." - }), - "response_id": Schema.String.annotate({ "description": "The ID of the response." }), - "item_id": Schema.String.annotate({ "description": "The ID of the item." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the response." }).check( - Schema.isInt() - ), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part in the item's content array." - }).check(Schema.isInt()), - "text": Schema.String.annotate({ "description": "The final text content." }) + "deleted": Schema.Boolean.annotate({ "description": "Whether the project model permissions were deleted." }) }).annotate({ - "description": - "Returned when the text value of an \"output_text\" content part is done streaming. Also\nemitted when a Response is interrupted, incomplete, or cancelled.\n" + "description": "Confirmation payload returned after deleting project model permissions.", + "identifier": "ProjectModelPermissionsDeleteResponse" }) -export type RealtimeTranscriptionSessionCreateResponse = { - readonly "client_secret": { readonly "value": string; readonly "expires_at": number } - readonly "modalities"?: ReadonlyArray<"text" | "audio"> - readonly "input_audio_format"?: string - readonly "input_audio_transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - } - readonly "turn_detection"?: { - readonly "type"?: string - readonly "threshold"?: number - readonly "prefix_padding_ms"?: number - readonly "silence_duration_ms"?: number - } +export type ProjectRateLimit = { + readonly "object": "project.rate_limit" + readonly "id": string + readonly "model": string + readonly "max_requests_per_1_minute": number + readonly "max_tokens_per_1_minute": number + readonly "max_images_per_1_minute"?: number + readonly "max_audio_megabytes_per_1_minute"?: number + readonly "max_requests_per_1_day"?: number + readonly "batch_1_day_max_input_tokens"?: number } -export const RealtimeTranscriptionSessionCreateResponse = Schema.Struct({ - "client_secret": Schema.Struct({ - "value": Schema.String.annotate({ - "description": - "Ephemeral key usable in client environments to authenticate connections\nto the Realtime API. Use this in client-side environments rather than\na standard API token, which should only be used server-side.\n" - }), - "expires_at": Schema.Number.annotate({ - "description": "Timestamp for when the token expires. Currently, all tokens expire\nafter one minute.\n", - "format": "unixtime" - }).check(Schema.isInt()) - }).annotate({ - "description": - "Ephemeral key returned by the API. Only present when the session is\ncreated on the server via REST API.\n" +export const ProjectRateLimit = Schema.Struct({ + "object": Schema.Literal("project.rate_limit").annotate({ + "description": "The object type, which is always `project.rate_limit`" }), - "modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": "The set of modalities the model can respond with. To disable audio,\nset this to [\"text\"].\n" - }) + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), + "model": Schema.String.annotate({ "description": "The model this rate limit applies to." }), + "max_requests_per_1_minute": Schema.Number.annotate({ "description": "The maximum requests per minute." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "input_audio_format": Schema.optionalKey( - Schema.String.annotate({ - "description": "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n" - }) + "max_tokens_per_1_minute": Schema.Number.annotate({ "description": "The maximum tokens per minute." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "input_audio_transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model used for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.\n" - }) - ), - "language": Schema.optionalKey(Schema.String.annotate({ "description": "The language of the input audio.\n" })), - "prompt": Schema.optionalKey( - Schema.String.annotate({ - "description": "The prompt configured for input audio transcription, when present.\n" - }) - ) - }).annotate({ "description": "Configuration of the transcription model.\n" }) + "max_images_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum images per minute. Only present for relevant models." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ), - "turn_detection": Schema.optionalKey( - Schema.Struct({ - "type": Schema.optionalKey( - Schema.String.annotate({ "description": "Type of turn detection, only `server_vad` is currently supported.\n" }) - ), - "threshold": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" - }).check(Schema.isFinite()) - ), - "prefix_padding_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" - }).check(Schema.isInt()) - ), - "silence_duration_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" - }).check(Schema.isInt()) - ) - }).annotate({ - "description": - "Configuration for turn detection. Can be set to `null` to turn off. Server\nVAD means that the model will detect the start and end of speech based on\naudio volume and respond at the end of user speech.\n" - }) + "max_audio_megabytes_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum audio megabytes per minute. Only present for relevant models." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "max_requests_per_1_day": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum requests per day. Only present for relevant models." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "batch_1_day_max_input_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum batch input tokens per day. Only present for relevant models." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ) -}).annotate({ - "description": - "A new Realtime transcription session configuration.\n\nWhen a session is created on the server via REST API, the session object\nalso contains an ephemeral key. Default TTL for keys is 10 minutes. This\nproperty is not present when a session is updated via the WebSocket API.\n" -}) -export type RealtimeTranslationClientEventInputAudioBufferAppend = { - readonly "event_id"?: string - readonly "type": "session.input_audio_buffer.append" - readonly "audio": string +}).annotate({ "description": "Represents a project rate limit config.", "identifier": "ProjectRateLimit" }) +export type ProjectRateLimitUpdateRequest = { + readonly "max_requests_per_1_minute"?: number + readonly "max_tokens_per_1_minute"?: number + readonly "max_images_per_1_minute"?: number + readonly "max_audio_megabytes_per_1_minute"?: number + readonly "max_requests_per_1_day"?: number + readonly "batch_1_day_max_input_tokens"?: number } -export const RealtimeTranslationClientEventInputAudioBufferAppend = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) +export const ProjectRateLimitUpdateRequest = Schema.Struct({ + "max_requests_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum requests per minute." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) ), - "type": Schema.Literal("session.input_audio_buffer.append").annotate({ - "description": "The event type, must be `session.input_audio_buffer.append`." - }), - "audio": Schema.String.annotate({ "description": "Base64-encoded 24 kHz PCM16 mono audio bytes." }) -}).annotate({ - "description": - "Send this event to append audio bytes to the translation session input audio buffer.\n\nWebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono\nlittle-endian raw audio bytes. Unsupported websocket audio formats return a\nvalidation error because lower-quality audio materially degrades translation\nquality.\n\nTranslation consumes 200 ms engine frames. For best realtime behavior, append\naudio in 200 ms chunks. If a chunk is shorter, the server buffers it until it\nhas enough audio for one frame. If a chunk is longer, the server splits it into\n200 ms frames and enqueues them back-to-back.\n\nKeep appending silence while the session is active. If a client stops sending\naudio and later resumes, model time treats the resumed audio as contiguous with\nthe previous audio rather than as a real-world pause.\n" -}) -export type RealtimeTranslationClientEventSessionClose = { - readonly "event_id"?: string - readonly "type": "session.close" -} -export const RealtimeTranslationClientEventSessionClose = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) + "max_tokens_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum tokens per minute." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) ), - "type": Schema.Literal("session.close").annotate({ "description": "The event type, must be `session.close`." }) -}).annotate({ - "description": - "Gracefully close the realtime translation session. The server flushes pending\ninput audio and emits any remaining translated output before closing the\nsession.\n" -}) -export type RealtimeTranslationServerEventSessionClosed = { - readonly "event_id": string - readonly "type": "session.closed" -} -export const RealtimeTranslationServerEventSessionClosed = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("session.closed").annotate({ "description": "The event type, must be `session.closed`." }) -}).annotate({ "description": "Returned when a realtime translation session is closed.\n" }) -export type RealtimeTranslationServerEventSessionInputTranscriptDelta = { - readonly "event_id": string - readonly "type": "session.input_transcript.delta" - readonly "delta": string - readonly "elapsed_ms"?: number | null + "max_images_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum images per minute. Only relevant for certain models." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "max_audio_megabytes_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum audio megabytes per minute. Only relevant for certain models." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "max_requests_per_1_day": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum requests per day. Only relevant for certain models." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "batch_1_day_max_input_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum batch input tokens per day. Only relevant for certain models." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) +}).annotate({ "identifier": "ProjectRateLimitUpdateRequest" }) +export type ProjectServiceAccount = { + readonly "object": "organization.project.service_account" + readonly "id": string + readonly "name": string + readonly "role": "owner" | "member" | "none" + readonly "created_at": number } -export const RealtimeTranslationServerEventSessionInputTranscriptDelta = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("session.input_transcript.delta").annotate({ - "description": "The event type, must be `session.input_transcript.delta`." +export const ProjectServiceAccount = Schema.Struct({ + "object": Schema.Literal("organization.project.service_account").annotate({ + "description": "The object type, which is always `organization.project.service_account`" }), - "delta": Schema.String.annotate({ "description": "Append-only source-language transcript text." }), - "elapsed_ms": Schema.optionalKey(Schema.Union([ - Schema.Number.annotate({ - "description": - "Timing metadata for stream alignment, derived from the translation frame\nwhen available. It advances in 200 ms increments, but multiple transcript\ndeltas may share the same `elapsed_ms`. Treat it as alignment metadata,\nnot a unique transcript-delta identifier.\n" - }).check(Schema.isInt()), - Schema.Null - ])) + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "name": Schema.String.annotate({ "description": "The name of the service account" }), + "role": Schema.Literals(["owner", "member", "none"]).annotate({ "description": "`owner`, `member`, or `none`" }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the service account was created", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) }).annotate({ - "description": - "Returned when optional source-language transcript text is available. This event\nis emitted only when `audio.input.transcription` is configured.\n\nTranscript deltas are append-only text fragments. Clients should not insert\nunconditional spaces between deltas.\n" + "description": "Represents an individual service account in a project.", + "identifier": "ProjectServiceAccount" }) -export type RealtimeTranslationServerEventSessionOutputAudioDelta = { - readonly "event_id": string - readonly "type": "session.output_audio.delta" - readonly "delta": string - readonly "sample_rate"?: number - readonly "channels"?: number - readonly "format"?: "pcm16" - readonly "elapsed_ms"?: number | null +export type ProjectServiceAccountCreateRequest = { + readonly "name": string + readonly "create_service_account_only"?: boolean | null } -export const RealtimeTranslationServerEventSessionOutputAudioDelta = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("session.output_audio.delta").annotate({ - "description": "The event type, must be `session.output_audio.delta`." - }), - "delta": Schema.String.annotate({ "description": "Base64-encoded translated audio data." }), - "sample_rate": Schema.optionalKey( - Schema.Number.annotate({ "description": "Sample rate of the audio delta." }).check(Schema.isInt()) - ), - "channels": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of audio channels." }).check(Schema.isInt()) - ), - "format": Schema.optionalKey(Schema.Literal("pcm16").annotate({ "description": "Audio encoding for `delta`." })), - "elapsed_ms": Schema.optionalKey( +export const ProjectServiceAccountCreateRequest = Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the service account being created." }), + "create_service_account_only": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ - "description": - "Timing metadata for stream alignment, derived from the translation frame\nwhen available. Treat `elapsed_ms` as alignment metadata, not a unique\nevent identifier.\n" - }).check(Schema.isInt()), + Schema.Boolean.annotate({ "description": "Create the service account without default roles or an API key." }), Schema.Null ]) ) +}).annotate({ "identifier": "ProjectServiceAccountCreateRequest" }) +export type ProjectServiceAccountApiKey = { + readonly "object": "organization.project.service_account.api_key" + readonly "value": string + readonly "name": string + readonly "created_at": number + readonly "id": string +} +export const ProjectServiceAccountApiKey = Schema.Struct({ + "object": Schema.Literal("organization.project.service_account.api_key").annotate({ + "description": "The object type, which is always `organization.project.service_account.api_key`" + }), + "value": Schema.String, + "name": Schema.String, + "created_at": Schema.Number.annotate({ "format": "unixtime" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "id": Schema.String +}).annotate({ "identifier": "ProjectServiceAccountApiKey" }) +export type UpdateProjectServiceAccountBody = { readonly "name"?: string; readonly "role"?: "member" | "owner" } +export const UpdateProjectServiceAccountBody = Schema.Struct({ + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The updated service account name." })), + "role": Schema.optionalKey( + Schema.Literals(["member", "owner"]).annotate({ "description": "The updated service account role." }) + ) }).annotate({ - "description": - "Returned when translated output audio is available. Output audio deltas are\n200 ms frames of PCM16 audio.\n" + "description": "Parameters for updating a project service account.", + "identifier": "UpdateProjectServiceAccountBody" }) -export type RealtimeTranslationServerEventSessionOutputTranscriptDelta = { - readonly "event_id": string - readonly "type": "session.output_transcript.delta" - readonly "delta": string - readonly "elapsed_ms"?: number | null +export type ProjectServiceAccountDeleteResponse = { + readonly "object": "organization.project.service_account.deleted" + readonly "id": string + readonly "deleted": boolean } -export const RealtimeTranslationServerEventSessionOutputTranscriptDelta = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("session.output_transcript.delta").annotate({ - "description": "The event type, must be `session.output_transcript.delta`." +export const ProjectServiceAccountDeleteResponse = Schema.Struct({ + "object": Schema.Literal("organization.project.service_account.deleted"), + "id": Schema.String, + "deleted": Schema.Boolean +}).annotate({ "identifier": "ProjectServiceAccountDeleteResponse" }) +export type SpendAlertNotificationChannel = { + readonly "type": "email" + readonly "recipients": ReadonlyArray + readonly "subject_prefix"?: string | null +} +export const SpendAlertNotificationChannel = Schema.Struct({ + "type": Schema.Literal("email").annotate({ + "description": "The notification channel type. Currently only `email` is supported." }), - "delta": Schema.String.annotate({ "description": "Append-only transcript text for the translated output audio." }), - "elapsed_ms": Schema.optionalKey(Schema.Union([ - Schema.Number.annotate({ - "description": - "Timing metadata for stream alignment, derived from the translation frame\nwhen available. It advances in 200 ms increments, but multiple transcript\ndeltas may share the same `elapsed_ms`. Treat it as alignment metadata,\nnot a unique transcript-delta identifier.\n" - }).check(Schema.isInt()), - Schema.Null - ])) + "recipients": Schema.Array(Schema.String).annotate({ + "description": "Email addresses that receive the spend alert notification." + }), + "subject_prefix": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Optional subject prefix for alert emails." }) + ) }).annotate({ - "description": - "Returned when translated transcript text is available.\n\nTranscript deltas are append-only text fragments. Clients should not insert\nunconditional spaces between deltas.\n" + "description": "Email notification settings for a spend alert.", + "identifier": "SpendAlertNotificationChannel" }) -export type RealtimeTruncation = "auto" | "disabled" | { - readonly "type": "retention_ratio" - readonly "retention_ratio": number - readonly "token_limits"?: { readonly "post_instructions"?: number } +export type ProjectSpendAlertDeletedResource = { + readonly "id": string + readonly "object": "project.spend_alert.deleted" + readonly "deleted": boolean } -export const RealtimeTruncation = Schema.Union([ - Schema.Literals(["auto", "disabled"]).annotate({ - "description": - "The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit." +export const ProjectSpendAlertDeletedResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The deleted spend alert ID." }), + "object": Schema.Literal("project.spend_alert.deleted").annotate({ + "description": "Always `project.spend_alert.deleted`." }), - Schema.Struct({ - "type": Schema.Literal("retention_ratio").annotate({ "description": "Use retention ratio truncation." }), - "retention_ratio": Schema.Number.annotate({ - "description": - "Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)), - "token_limits": Schema.optionalKey( - Schema.Struct({ - "post_instructions": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)) - ) - }).annotate({ - "description": - "Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used." - }) - ) - }).annotate({ - "title": "Retention ratio truncation", - "description": - "Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage." - }) -], { mode: "oneOf" }).annotate({ - "title": "Realtime Truncation Controls", - "description": - "When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.\n\nClients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.\n\nTruncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.\n\nTruncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.\n" + "deleted": Schema.Boolean.annotate({ "description": "Whether the spend alert was deleted." }) +}).annotate({ + "description": "Confirmation payload returned after deleting a project spend alert.", + "identifier": "ProjectSpendAlertDeletedResource" }) -export type RealtimeTurnDetection = { - readonly "type": "server_vad" - readonly "threshold"?: number - readonly "prefix_padding_ms"?: number - readonly "silence_duration_ms"?: number - readonly "create_response"?: boolean - readonly "interrupt_response"?: boolean - readonly "idle_timeout_ms"?: number | null -} | { - readonly "type": "semantic_vad" - readonly "eagerness"?: "low" | "medium" | "high" | "auto" - readonly "create_response"?: boolean - readonly "interrupt_response"?: boolean -} | null -export const RealtimeTurnDetection = Schema.Union([ - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("server_vad").annotate({ - "description": "Type of turn detection, `server_vad` to turn on simple Server VAD.\n" - }), - "threshold": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" - }).check(Schema.isFinite()) - ), - "prefix_padding_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" - }).check(Schema.isInt()) - ), - "silence_duration_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" - }).check(Schema.isInt()) - ), - "create_response": Schema.optionalKey(Schema.Boolean.annotate({ - "description": - "Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.\n\nIf both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.\n" - })), - "interrupt_response": Schema.optionalKey(Schema.Boolean.annotate({ - "description": - "Whether or not to automatically interrupt (cancel) any ongoing response with output to the default\nconversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.\n\nIf both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.\n" - })), - "idle_timeout_ms": Schema.optionalKey(Schema.Union([ - Schema.Number.annotate({ - "description": - "Optional timeout after which a model response will be triggered automatically. This is\nuseful for situations in which a long pause from the user is unexpected, such as a phone\ncall. The model will effectively prompt the user to continue the conversation based\non the current context.\n\nThe timeout value will be applied after the last model response's audio has finished playing,\ni.e. it's set to the `response.done` time plus audio playback duration.\n\nAn `input_audio_buffer.timeout_triggered` event (plus events\nassociated with the Response) will be emitted when the timeout is reached.\nIdle timeout is currently only supported for `server_vad` mode.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(5000)).check(Schema.isLessThanOrEqualTo(30000)), - Schema.Null - ])) - }).annotate({ - "title": "Server VAD", - "description": - "Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence." - }), - Schema.Struct({ - "type": Schema.Literal("semantic_vad").annotate({ - "description": "Type of turn detection, `semantic_vad` to turn on Semantic VAD.\n" - }), - "eagerness": Schema.optionalKey( - Schema.Literals(["low", "medium", "high", "auto"]).annotate({ - "description": - "Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.\n" - }) - ), - "create_response": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Whether or not to automatically generate a response when a VAD stop event occurs.\n" - }) - ), - "interrupt_response": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether or not to automatically interrupt any ongoing response with output to the default\nconversation (i.e. `conversation` of `auto`) when a VAD start event occurs.\n" - }) - ) - }).annotate({ - "title": "Semantic VAD", - "description": - "Server-side semantic turn detection which uses a model to determine when the user has finished speaking." - }) - ], { mode: "oneOf" }).annotate({ - "title": "Realtime Turn Detection", - "description": - "Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.\n\nServer VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.\n\nSemantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with \"uhhm\", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.\n\nFor `gpt-realtime-whisper` transcription sessions, turn detection must be\nset to `null`; VAD is not supported.\n" - }), - Schema.Null -]) -export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | null -export const ReasoningEffort = Schema.Union([ - Schema.Literals(["none", "minimal", "low", "medium", "high", "xhigh"]).annotate({ - "description": - "Constrains effort on reasoning for\n[reasoning models](https://platform.openai.com/docs/guides/reasoning).\nCurrently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing\nreasoning effort can result in faster responses and fewer tokens used\non reasoning in a response.\n\n- `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all reasoning values in gpt-5.1.\n- All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.\n- The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.\n- `xhigh` is supported for all models after `gpt-5.1-codex-max`.\n" - }), - Schema.Null -]) -export type ResponseAudioDeltaEvent = { - readonly "type": "response.audio.delta" - readonly "sequence_number": number - readonly "delta": string -} -export const ResponseAudioDeltaEvent = Schema.Struct({ - "type": Schema.Literal("response.audio.delta").annotate({ - "description": "The type of the event. Always `response.audio.delta`.\n" - }), - "sequence_number": Schema.Number.annotate({ - "description": "A sequence number for this chunk of the stream response.\n" - }).check(Schema.isInt()), - "delta": Schema.String.annotate({ "description": "A chunk of Base64 encoded response audio bytes.\n" }) -}).annotate({ "description": "Emitted when there is a partial audio response." }) -export type ResponseAudioDoneEvent = { - readonly "type": "response.audio.done" - readonly "sequence_number": number - readonly "response_id": unknown +export type ProjectUser = { + readonly "object": "organization.project.user" + readonly "id": string + readonly "name"?: string | null + readonly "email"?: string | null + readonly "role": string + readonly "added_at": number } -export const ResponseAudioDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.audio.done").annotate({ - "description": "The type of the event. Always `response.audio.done`.\n" +export const ProjectUser = Schema.Struct({ + "object": Schema.Literal("organization.project.user").annotate({ + "description": "The object type, which is always `organization.project.user`" }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of the delta.\n" }).check( - Schema.isInt() + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the user" }) ), - "response_id": Schema.Unknown -}).annotate({ "description": "Emitted when the audio response is complete." }) -export type ResponseAudioTranscriptDeltaEvent = { - readonly "type": "response.audio.transcript.delta" - readonly "delta": string - readonly "sequence_number": number - readonly "response_id": unknown + "email": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The email address of the user" }) + ), + "role": Schema.String.annotate({ "description": "`owner` or `member`" }), + "added_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the project was added.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "description": "Represents an individual user in a project.", "identifier": "ProjectUser" }) +export type ProjectUserCreateRequest = { + readonly "user_id"?: string | null + readonly "email"?: string | null + readonly "role": string } -export const ResponseAudioTranscriptDeltaEvent = Schema.Struct({ - "type": Schema.Literal("response.audio.transcript.delta").annotate({ - "description": "The type of the event. Always `response.audio.transcript.delta`.\n" - }), - "delta": Schema.String.annotate({ "description": "The partial transcript of the audio response.\n" }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() +export const ProjectUserCreateRequest = Schema.Struct({ + "user_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The ID of the user." }) ), - "response_id": Schema.Unknown -}).annotate({ "description": "Emitted when there is a partial transcript of audio." }) -export type ResponseAudioTranscriptDoneEvent = { - readonly "type": "response.audio.transcript.done" - readonly "sequence_number": number - readonly "response_id": unknown + "email": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Email of the user to add." }) + ), + "role": Schema.String.annotate({ "description": "`owner` or `member`" }) +}).annotate({ "identifier": "ProjectUserCreateRequest" }) +export type ProjectUserUpdateRequest = { readonly "role"?: string | null } +export const ProjectUserUpdateRequest = Schema.Struct({ + "role": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "`owner` or `member`" }) + ) +}).annotate({ "identifier": "ProjectUserUpdateRequest" }) +export type ProjectUserDeleteResponse = { + readonly "object": "organization.project.user.deleted" + readonly "id": string + readonly "deleted": boolean } -export const ResponseAudioTranscriptDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.audio.transcript.done").annotate({ - "description": "The type of the event. Always `response.audio.transcript.done`.\n" - }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() +export const ProjectUserDeleteResponse = Schema.Struct({ + "object": Schema.Literal("organization.project.user.deleted"), + "id": Schema.String, + "deleted": Schema.Boolean +}).annotate({ "identifier": "ProjectUserDeleteResponse" }) +export type PublicCreateOrganizationRoleBody = { + readonly "role_name": string + readonly "permissions": ReadonlyArray + readonly "description"?: string | null +} +export const PublicCreateOrganizationRoleBody = Schema.Struct({ + "role_name": Schema.String.annotate({ "description": "Unique name for the role." }), + "permissions": Schema.Array(Schema.String).annotate({ "description": "Permissions to grant to the role." }), + "description": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Optional description of the role." }) + ) +}).annotate({ + "description": "Request payload for creating a custom role.", + "identifier": "PublicCreateOrganizationRoleBody" +}) +export type PublicUpdateOrganizationRoleBody = { + readonly "permissions"?: ReadonlyArray | null + readonly "description"?: string | null + readonly "role_name"?: string | null +} +export const PublicUpdateOrganizationRoleBody = Schema.Struct({ + "permissions": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": "Updated set of permissions for the role." + }) ), - "response_id": Schema.Unknown -}).annotate({ "description": "Emitted when the full audio transcript is completed." }) -export type ResponseCodeInterpreterCallCodeDeltaEvent = { - readonly "type": "response.code_interpreter_call_code.delta" - readonly "output_index": number - readonly "item_id": string - readonly "delta": string - readonly "sequence_number": number + "description": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "New description for the role." }) + ), + "role_name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "New name for the role." }) + ) +}).annotate({ + "description": "Request payload for updating an existing role.", + "identifier": "PublicUpdateOrganizationRoleBody" +}) +export type RoleDeletedResource = { + readonly "object": "role.deleted" + readonly "id": string + readonly "deleted": boolean } -export const ResponseCodeInterpreterCallCodeDeltaEvent = Schema.Struct({ - "type": Schema.Literal("response.code_interpreter_call_code.delta").annotate({ - "description": "The type of the event. Always `response.code_interpreter_call_code.delta`." - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response for which the code is being streamed." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), - "delta": Schema.String.annotate({ - "description": "The partial code snippet being streamed by the code interpreter." - }), - "sequence_number": Schema.Number.annotate({ - "description": "The sequence number of this event, used to order streaming events." - }).check(Schema.isInt()) -}).annotate({ "description": "Emitted when a partial code snippet is streamed by the code interpreter." }) -export type ResponseCodeInterpreterCallCodeDoneEvent = { - readonly "type": "response.code_interpreter_call_code.done" - readonly "output_index": number - readonly "item_id": string - readonly "code": string - readonly "sequence_number": number +export const RoleDeletedResource = Schema.Struct({ + "object": Schema.Literal("role.deleted").annotate({ "description": "Always `role.deleted`." }), + "id": Schema.String.annotate({ "description": "Identifier of the deleted role." }), + "deleted": Schema.Boolean.annotate({ "description": "Whether the role was deleted." }) +}).annotate({ + "description": "Confirmation payload returned after deleting a role.", + "identifier": "RoleDeletedResource" +}) +export type OrganizationSpendAlertDeletedResource = { + readonly "id": string + readonly "object": "organization.spend_alert.deleted" + readonly "deleted": boolean } -export const ResponseCodeInterpreterCallCodeDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.code_interpreter_call_code.done").annotate({ - "description": "The type of the event. Always `response.code_interpreter_call_code.done`." +export const OrganizationSpendAlertDeletedResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The deleted spend alert ID." }), + "object": Schema.Literal("organization.spend_alert.deleted").annotate({ + "description": "Always `organization.spend_alert.deleted`." }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response for which the code is finalized." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), - "code": Schema.String.annotate({ "description": "The final code snippet output by the code interpreter." }), - "sequence_number": Schema.Number.annotate({ - "description": "The sequence number of this event, used to order streaming events." - }).check(Schema.isInt()) -}).annotate({ "description": "Emitted when the code snippet is finalized by the code interpreter." }) -export type ResponseCodeInterpreterCallCompletedEvent = { - readonly "type": "response.code_interpreter_call.completed" - readonly "output_index": number - readonly "item_id": string - readonly "sequence_number": number -} -export const ResponseCodeInterpreterCallCompletedEvent = Schema.Struct({ - "type": Schema.Literal("response.code_interpreter_call.completed").annotate({ - "description": "The type of the event. Always `response.code_interpreter_call.completed`." - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response for which the code interpreter call is completed." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), - "sequence_number": Schema.Number.annotate({ - "description": "The sequence number of this event, used to order streaming events." - }).check(Schema.isInt()) -}).annotate({ "description": "Emitted when the code interpreter call is completed." }) -export type ResponseCodeInterpreterCallInProgressEvent = { - readonly "type": "response.code_interpreter_call.in_progress" - readonly "output_index": number - readonly "item_id": string - readonly "sequence_number": number -} -export const ResponseCodeInterpreterCallInProgressEvent = Schema.Struct({ - "type": Schema.Literal("response.code_interpreter_call.in_progress").annotate({ - "description": "The type of the event. Always `response.code_interpreter_call.in_progress`." - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response for which the code interpreter call is in progress." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), - "sequence_number": Schema.Number.annotate({ - "description": "The sequence number of this event, used to order streaming events." - }).check(Schema.isInt()) -}).annotate({ "description": "Emitted when a code interpreter call is in progress." }) -export type ResponseCodeInterpreterCallInterpretingEvent = { - readonly "type": "response.code_interpreter_call.interpreting" - readonly "output_index": number - readonly "item_id": string - readonly "sequence_number": number + "deleted": Schema.Boolean.annotate({ "description": "Whether the spend alert was deleted." }) +}).annotate({ + "description": "Confirmation payload returned after deleting an organization spend alert.", + "identifier": "OrganizationSpendAlertDeletedResource" +}) +export type User = { + readonly "object": "organization.user" + readonly "id": string + readonly "name"?: string | null + readonly "email"?: string | null + readonly "role"?: string | null + readonly "added_at": number + readonly "is_default"?: boolean + readonly "created"?: number + readonly "user"?: { + readonly "object": "user" + readonly "id": string + readonly "email"?: string | null + readonly "name"?: string | null + readonly "picture"?: string | null + readonly "enabled"?: boolean | null + readonly "banned"?: boolean | null + readonly "banned_at"?: number | null + } + readonly "is_service_account"?: boolean + readonly "is_scale_tier_authorized_purchaser"?: boolean | null + readonly "is_scim_managed"?: boolean + readonly "api_key_last_used_at"?: number | null + readonly "technical_level"?: string | null + readonly "developer_persona"?: string | null + readonly "projects"?: { + readonly "object": "list" + readonly "data": ReadonlyArray< + { readonly "id"?: string | null; readonly "name"?: string | null; readonly "role"?: string | null } + > + } | null } -export const ResponseCodeInterpreterCallInterpretingEvent = Schema.Struct({ - "type": Schema.Literal("response.code_interpreter_call.interpreting").annotate({ - "description": "The type of the event. Always `response.code_interpreter_call.interpreting`." +export const User = Schema.Struct({ + "object": Schema.Literal("organization.user").annotate({ + "description": "The object type, which is always `organization.user`" }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response for which the code interpreter is interpreting code." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), - "sequence_number": Schema.Number.annotate({ - "description": "The sequence number of this event, used to order streaming events." - }).check(Schema.isInt()) -}).annotate({ "description": "Emitted when the code interpreter is actively interpreting the code snippet." }) -export type ResponseCustomToolCallInputDeltaEvent = { - readonly "type": "response.custom_tool_call_input.delta" - readonly "sequence_number": number - readonly "output_index": number - readonly "item_id": string - readonly "delta": string + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the user" }) + ), + "email": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The email address of the user" }) + ), + "role": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "`owner` or `reader`" }) + ), + "added_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the user was added.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "is_default": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this is the organization's default user." }) + ), + "created": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the user was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "user": Schema.optionalKey( + Schema.Struct({ + "object": Schema.Literal("user"), + "id": Schema.String, + "email": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "name": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "picture": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "enabled": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "banned": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "banned_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ) + }).annotate({ "description": "Nested user details." }) + ), + "is_service_account": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the user is a service account." }) + ), + "is_scale_tier_authorized_purchaser": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether the user is an authorized purchaser for Scale Tier." + }) + ), + "is_scim_managed": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the user is managed through SCIM." }) + ), + "api_key_last_used_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "The Unix timestamp (in seconds) of the user's last API key usage." }) + ), + "technical_level": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The technical level metadata for the user." }) + ), + "developer_persona": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The developer persona metadata for the user." + }) + ), + "projects": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "object": Schema.Literal("list"), + "data": Schema.Array( + Schema.Struct({ + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "name": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "role": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + }) + ) + }), + Schema.Null + ]).annotate({ "description": "Projects associated with the user, if included." }) + ) +}).annotate({ "description": "Represents an individual `user` within an organization.", "identifier": "User" }) +export type UserRoleUpdateRequest = { + readonly "role"?: string | null + readonly "role_id"?: string | null + readonly "technical_level"?: string | null + readonly "developer_persona"?: string | null } -export const ResponseCustomToolCallInputDeltaEvent = Schema.Struct({ - "type": Schema.Literal("response.custom_tool_call_input.delta").annotate({ - "description": "The event type identifier." - }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() +export const UserRoleUpdateRequest = Schema.Struct({ + "role": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "`owner` or `reader`" }) ), - "output_index": Schema.Number.annotate({ "description": "The index of the output this delta applies to." }).check( - Schema.isInt() + "role_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Role ID to assign to the user." }) ), - "item_id": Schema.String.annotate({ - "description": "Unique identifier for the API item associated with this event." - }), - "delta": Schema.String.annotate({ "description": "The incremental input data (delta) for the custom tool call." }) -}).annotate({ - "title": "ResponseCustomToolCallInputDelta", - "description": "Event representing a delta (partial update) to the input of a custom tool call.\n" -}) -export type ResponseCustomToolCallInputDoneEvent = { - readonly "type": "response.custom_tool_call_input.done" - readonly "sequence_number": number - readonly "output_index": number - readonly "item_id": string - readonly "input": string + "technical_level": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Technical level metadata." }) + ), + "developer_persona": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Developer persona metadata." }) + ) +}).annotate({ "identifier": "UserRoleUpdateRequest" }) +export type UserDeleteResponse = { + readonly "object": "organization.user.deleted" + readonly "id": string + readonly "deleted": boolean } -export const ResponseCustomToolCallInputDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.custom_tool_call_input.done").annotate({ - "description": "The event type identifier." +export const UserDeleteResponse = Schema.Struct({ + "object": Schema.Literal("organization.user.deleted"), + "id": Schema.String, + "deleted": Schema.Boolean +}).annotate({ "identifier": "UserDeleteResponse" }) +export type RealtimeAudioFormats = { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { + readonly "type"?: "audio/pcmu" +} | { readonly "type"?: "audio/pcma" } +export const RealtimeAudioFormats = Schema.Union([ + Schema.Struct({ + "type": Schema.optionalKey( + Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) + ), + "rate": Schema.optionalKey( + Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) + ) + }).annotate({ + "title": "PCM audio format", + "description": "The PCM audio format. Only a 24kHz sample rate is supported." }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() + Schema.Struct({ + "type": Schema.optionalKey( + Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) + ) + }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), + Schema.Struct({ + "type": Schema.optionalKey( + Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) + ) + }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) +]).annotate({ "identifier": "RealtimeAudioFormats" }) +export type AudioTranscription = { + readonly "model"?: + | string + | "whisper-1" + | "gpt-transcribe" + | "gpt-live-transcribe" + | "gpt-4o-mini-transcribe" + | "gpt-4o-mini-transcribe-2025-12-15" + | "gpt-4o-transcribe" + | "gpt-4o-transcribe-diarize" + | "gpt-realtime-whisper" + readonly "language"?: string + readonly "languages"?: ReadonlyArray + readonly "keywords"?: ReadonlyArray + readonly "prompt"?: string + readonly "delay"?: "minimal" | "low" | "medium" | "high" | "xhigh" +} +export const AudioTranscription = Schema.Struct({ + "model": Schema.optionalKey( + Schema.Union([ + Schema.String, + Schema.Literals([ + "whisper-1", + "gpt-transcribe", + "gpt-live-transcribe", + "gpt-4o-mini-transcribe", + "gpt-4o-mini-transcribe-2025-12-15", + "gpt-4o-transcribe", + "gpt-4o-transcribe-diarize", + "gpt-realtime-whisper" + ]) + ]).annotate({ + "description": + "The model to use for transcription. Current options are `whisper-1`, `gpt-transcribe`, `gpt-live-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.\n" + }) ), - "output_index": Schema.Number.annotate({ "description": "The index of the output this event applies to." }).check( - Schema.isInt() + "language": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The language of the input audio. Supplying the input language in\n[ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format\nwill improve accuracy and latency.\n" + }) ), - "item_id": Schema.String.annotate({ - "description": "Unique identifier for the API item associated with this event." - }), - "input": Schema.String.annotate({ "description": "The complete input data for the custom tool call." }) -}).annotate({ - "title": "ResponseCustomToolCallInputDone", - "description": "Event indicating that input for a custom tool call is complete.\n" -}) -export type ResponseErrorCode = - | "server_error" - | "rate_limit_exceeded" - | "invalid_prompt" - | "vector_store_timeout" - | "invalid_image" - | "invalid_image_format" - | "invalid_base64_image" - | "invalid_image_url" - | "image_too_large" - | "image_too_small" - | "image_parse_error" - | "image_content_policy_violation" - | "invalid_image_mode" - | "image_file_too_large" - | "unsupported_image_media_type" - | "empty_image_file" - | "failed_to_download_image" - | "image_file_not_found" -export const ResponseErrorCode = Schema.Literals([ - "server_error", - "rate_limit_exceeded", - "invalid_prompt", - "vector_store_timeout", - "invalid_image", - "invalid_image_format", - "invalid_base64_image", - "invalid_image_url", - "image_too_large", - "image_too_small", - "image_parse_error", - "image_content_policy_violation", - "invalid_image_mode", - "image_file_too_large", - "unsupported_image_media_type", - "empty_image_file", - "failed_to_download_image", - "image_file_not_found" -]).annotate({ "description": "The error code for the response.\n" }) -export type ResponseErrorEvent = { - readonly "type": "error" - readonly "code": string | null - readonly "message": string - readonly "param": string | null - readonly "sequence_number": number -} -export const ResponseErrorEvent = Schema.Struct({ - "type": Schema.Literal("error").annotate({ "description": "The type of the event. Always `error`.\n" }), - "code": Schema.Union([Schema.String.annotate({ "description": "The error code.\n" }), Schema.Null]), - "message": Schema.String.annotate({ "description": "The error message.\n" }), - "param": Schema.Union([Schema.String.annotate({ "description": "The error parameter.\n" }), Schema.Null]), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() + "languages": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe` and `gpt-live-transcribe`.\n" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ), + "keywords": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe` and `gpt-live-transcribe`.\n" + }) + ), + "prompt": Schema.optionalKey(Schema.String.annotate({ + "description": + "An optional text to guide the model's style or continue a previous audio\nsegment.\nFor `whisper-1`, the [prompt is a list of keywords](/docs/guides/speech-to-text#prompting).\nFor `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example \"expect words related to technology\".\nPrompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" + })), + "delay": Schema.optionalKey( + Schema.Literals(["minimal", "low", "medium", "high", "xhigh"]).annotate({ + "description": + "Controls how long the model waits before emitting transcription text.\nHigher values can improve transcription accuracy at the cost of latency.\nOnly supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" + }) ) -}).annotate({ "description": "Emitted when an error occurs." }) -export type ResponseFileSearchCallCompletedEvent = { - readonly "type": "response.file_search_call.completed" - readonly "output_index": number - readonly "item_id": string - readonly "sequence_number": number -} -export const ResponseFileSearchCallCompletedEvent = Schema.Struct({ - "type": Schema.Literal("response.file_search_call.completed").annotate({ - "description": "The type of the event. Always `response.file_search_call.completed`.\n" - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item that the file search call is initiated.\n" - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The ID of the output item that the file search call is initiated.\n" +}).annotate({ "identifier": "AudioTranscription" }) +export type NoiseReductionType = "near_field" | "far_field" +export const NoiseReductionType = Schema.Literals(["near_field", "far_field"]).annotate({ + "description": + "Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.\n", + "identifier": "NoiseReductionType" +}) +export type RealtimeTurnDetection = { + readonly "type": "server_vad" + readonly "threshold"?: number + readonly "prefix_padding_ms"?: number + readonly "silence_duration_ms"?: number + readonly "create_response"?: boolean + readonly "interrupt_response"?: boolean + readonly "idle_timeout_ms"?: number | null +} | { + readonly "type": "semantic_vad" + readonly "eagerness"?: "low" | "medium" | "high" | "auto" + readonly "create_response"?: boolean + readonly "interrupt_response"?: boolean +} | null +export const RealtimeTurnDetection = Schema.Union([ + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("server_vad").annotate({ + "description": "Type of turn detection, `server_vad` to turn on simple Server VAD.\n" + }), + "threshold": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "prefix_padding_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "silence_duration_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "create_response": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.\n\nIf both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.\n" + })), + "interrupt_response": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "Whether or not to automatically interrupt (cancel) any ongoing response with output to the default\nconversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.\n\nIf both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.\n" + })), + "idle_timeout_ms": Schema.optionalKey(Schema.Union([ + Schema.Number.annotate({ + "description": + "Optional timeout after which a model response will be triggered automatically. This is\nuseful for situations in which a long pause from the user is unexpected, such as a phone\ncall. The model will effectively prompt the user to continue the conversation based\non the current context.\n\nThe timeout value will be applied after the last model response's audio has finished playing,\ni.e. it's set to the `response.done` time plus audio playback duration.\n\nAn `input_audio_buffer.timeout_triggered` event (plus events\nassociated with the Response) will be emitted when the timeout is reached.\nIdle timeout is currently only supported for `server_vad` mode.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(5000).annotate({ "expected": "a value greater than or equal to 5000" }) + ).check(Schema.isLessThanOrEqualTo(30000).annotate({ "expected": "a value less than or equal to 30000" })), + Schema.Null + ])) + }).annotate({ + "title": "Server VAD", + "description": + "Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence." + }), + Schema.Struct({ + "type": Schema.Literal("semantic_vad").annotate({ + "description": "Type of turn detection, `semantic_vad` to turn on Semantic VAD.\n" + }), + "eagerness": Schema.optionalKey( + Schema.Literals(["low", "medium", "high", "auto"]).annotate({ + "description": + "Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.\n" + }) + ), + "create_response": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Whether or not to automatically generate a response when a VAD stop event occurs.\n" + }) + ), + "interrupt_response": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether or not to automatically interrupt any ongoing response with output to the default\nconversation (i.e. `conversation` of `auto`) when a VAD start event occurs.\n" + }) + ) + }).annotate({ + "title": "Semantic VAD", + "description": + "Server-side semantic turn detection which uses a model to determine when the user has finished speaking." + }) + ], { mode: "oneOf" }).annotate({ + "title": "Realtime Turn Detection", + "description": + "Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.\n\nServer VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.\n\nSemantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with \"uhhm\", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.\n\nFor `gpt-realtime-whisper` transcription sessions, turn detection must be\nset to `null`; VAD is not supported.\n" }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ) -}).annotate({ "description": "Emitted when a file search call is completed (results found)." }) -export type ResponseFileSearchCallInProgressEvent = { - readonly "type": "response.file_search_call.in_progress" - readonly "output_index": number - readonly "item_id": string - readonly "sequence_number": number + Schema.Null +]).annotate({ "identifier": "RealtimeTurnDetection" }) +export type RealtimeFunctionTool = { + readonly "type"?: "function" + readonly "name"?: string + readonly "description"?: string + readonly "parameters"?: {} } -export const ResponseFileSearchCallInProgressEvent = Schema.Struct({ - "type": Schema.Literal("response.file_search_call.in_progress").annotate({ - "description": "The type of the event. Always `response.file_search_call.in_progress`.\n" - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item that the file search call is initiated.\n" - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The ID of the output item that the file search call is initiated.\n" - }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() +export const RealtimeFunctionTool = Schema.Struct({ + "type": Schema.optionalKey( + Schema.Literal("function").annotate({ "description": "The type of the tool, i.e. `function`." }) + ), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function." })), + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The description of the function, including guidance on when and how\nto call it, and guidance about what to tell the user when calling\n(if anything).\n" + }) + ), + "parameters": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Parameters of the function in JSON Schema." }) ) -}).annotate({ "description": "Emitted when a file search call is initiated." }) -export type ResponseFileSearchCallSearchingEvent = { - readonly "type": "response.file_search_call.searching" - readonly "output_index": number - readonly "item_id": string - readonly "sequence_number": number -} -export const ResponseFileSearchCallSearchingEvent = Schema.Struct({ - "type": Schema.Literal("response.file_search_call.searching").annotate({ - "description": "The type of the event. Always `response.file_search_call.searching`.\n" - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item that the file search call is searching.\n" - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The ID of the output item that the file search call is initiated.\n" +}).annotate({ "title": "Function tool", "identifier": "RealtimeFunctionTool" }) +export type ToolChoiceOptions = "none" | "auto" | "required" +export const ToolChoiceOptions = Schema.Literals(["none", "auto", "required"]).annotate({ + "title": "Tool choice mode", + "description": + "Controls which (if any) tool is called by the model.\n\n`none` means the model will not call any tool and instead generates a message.\n\n`auto` means the model can pick between generating a message or calling one or\nmore tools.\n\n`required` means the model must call one or more tools.\n", + "identifier": "ToolChoiceOptions" +}) +export type ToolChoiceFunction = { readonly "type": "function"; readonly "name": string } +export const ToolChoiceFunction = Schema.Struct({ + "type": Schema.Literal("function").annotate({ + "description": "For function calling, the type is always `function`." }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() + "name": Schema.String.annotate({ "description": "The name of the function to call." }) +}).annotate({ + "title": "Function tool", + "description": "Use this option to force the model to call a specific function.\n", + "identifier": "ToolChoiceFunction" +}) +export type ToolChoiceMCP = { readonly "type": "mcp"; readonly "server_label": string; readonly "name"?: string | null } +export const ToolChoiceMCP = Schema.Struct({ + "type": Schema.Literal("mcp").annotate({ "description": "For MCP tools, the type is always `mcp`." }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server to use.\n" }), + "name": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The name of the tool to call on the server.\n" }), + Schema.Null + ]) ) -}).annotate({ "description": "Emitted when a file search is currently searching." }) -export type ResponseFormatJsonObject = { readonly "type": "json_object" } -export const ResponseFormatJsonObject = Schema.Struct({ - "type": Schema.Literal("json_object").annotate({ - "description": "The type of response format being defined. Always `json_object`." - }) }).annotate({ - "title": "JSON object", - "description": - "JSON object response format. An older method of generating JSON responses.\nUsing `json_schema` is recommended for models that support it. Note that the\nmodel will not generate JSON without a system or user message instructing it\nto do so.\n" + "title": "MCP tool", + "description": "Use this option to force the model to call a specific tool on a remote MCP server.\n", + "identifier": "ToolChoiceMCP" }) -export type ResponseFormatJsonSchemaSchema = {} -export const ResponseFormatJsonSchemaSchema = Schema.Struct({}).annotate({ - "title": "JSON schema", - "description": - "The schema for the response format, described as a JSON Schema object.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n" +export type RealtimeReasoningEffort = "minimal" | "low" | "medium" | "high" | "xhigh" +export const RealtimeReasoningEffort = Schema.Literals(["minimal", "low", "medium", "high", "xhigh"]).annotate({ + "description": "Constrains effort on reasoning for reasoning-capable Realtime models such as\n`gpt-realtime-2`.\n", + "identifier": "RealtimeReasoningEffort" }) -export type ResponseFormatText = { readonly "type": "text" } -export const ResponseFormatText = Schema.Struct({ - "type": Schema.Literal("text").annotate({ - "description": "The type of response format being defined. Always `text`." - }) -}).annotate({ "title": "Text", "description": "Default response format. Used to generate text responses.\n" }) -export type ResponseFunctionCallArgumentsDeltaEvent = { - readonly "type": "response.function_call_arguments.delta" - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "delta": string -} -export const ResponseFunctionCallArgumentsDeltaEvent = Schema.Struct({ - "type": Schema.Literal("response.function_call_arguments.delta").annotate({ - "description": "The type of the event. Always `response.function_call_arguments.delta`.\n" - }), - "item_id": Schema.String.annotate({ - "description": "The ID of the output item that the function-call arguments delta is added to.\n" - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item that the function-call arguments delta is added to.\n" - }).check(Schema.isInt()), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ), - "delta": Schema.String.annotate({ "description": "The function-call arguments delta that is added.\n" }) -}).annotate({ "description": "Emitted when there is a partial function-call arguments delta." }) -export type ResponseFunctionCallArgumentsDoneEvent = { - readonly "type": "response.function_call_arguments.done" - readonly "item_id": string - readonly "name"?: string - readonly "output_index": number - readonly "sequence_number": number - readonly "arguments": string -} -export const ResponseFunctionCallArgumentsDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.function_call_arguments.done"), - "item_id": Schema.String.annotate({ "description": "The ID of the item." }), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function that was called." })), - "output_index": Schema.Number.annotate({ "description": "The index of the output item." }).check(Schema.isInt()), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ), - "arguments": Schema.String.annotate({ "description": "The function-call arguments." }) -}).annotate({ "description": "Emitted when function-call arguments are finalized." }) -export type ResponseImageGenCallCompletedEvent = { - readonly "type": "response.image_generation_call.completed" - readonly "output_index": number - readonly "sequence_number": number - readonly "item_id": string +export type RealtimeTruncation = "auto" | "disabled" | { + readonly "type": "retention_ratio" + readonly "retention_ratio": number + readonly "token_limits"?: { readonly "post_instructions"?: number } } -export const ResponseImageGenCallCompletedEvent = Schema.Struct({ - "type": Schema.Literal("response.image_generation_call.completed").annotate({ - "description": "The type of the event. Always 'response.image_generation_call.completed'." +export const RealtimeTruncation = Schema.Union([ + Schema.Literals(["auto", "disabled"]).annotate({ + "description": + "The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit." }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response's output array." - }).check(Schema.isInt()), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ), - "item_id": Schema.String.annotate({ - "description": "The unique identifier of the image generation item being processed." + Schema.Struct({ + "type": Schema.Literal("retention_ratio").annotate({ "description": "Use retention ratio truncation." }), + "retention_ratio": Schema.Number.annotate({ + "description": + "Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), + "token_limits": Schema.optionalKey( + Schema.Struct({ + "post_instructions": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) + ) + }).annotate({ + "description": + "Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used." + }) + ) + }).annotate({ + "title": "Retention ratio truncation", + "description": + "Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage." }) -}).annotate({ - "title": "ResponseImageGenCallCompletedEvent", - "description": "Emitted when an image generation tool call has completed and the final image is available.\n" +], { mode: "oneOf" }).annotate({ + "title": "Realtime Truncation Controls", + "description": + "When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.\n\nClients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.\n\nTruncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.\n\nTruncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.\n", + "identifier": "RealtimeTruncation" }) -export type ResponseImageGenCallGeneratingEvent = { - readonly "type": "response.image_generation_call.generating" - readonly "output_index": number - readonly "item_id": string - readonly "sequence_number": number -} -export const ResponseImageGenCallGeneratingEvent = Schema.Struct({ - "type": Schema.Literal("response.image_generation_call.generating").annotate({ - "description": "The type of the event. Always 'response.image_generation_call.generating'." - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response's output array." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The unique identifier of the image generation item being processed." +export type ResponsePromptVariables = {} | null +export const ResponsePromptVariables = Schema.Union([ + Schema.Struct({}).annotate({ + "title": "Prompt Variables", + "description": + "Optional map of values to substitute in for variables in your\nprompt. The substitution values can either be strings, or other\nResponse input types like images or files.\n" }), - "sequence_number": Schema.Number.annotate({ - "description": "The sequence number of the image generation item being processed." - }).check(Schema.isInt()) + Schema.Null +]).annotate({ "identifier": "ResponsePromptVariables" }) +export type RealtimeCallReferRequest = { readonly "target_uri": string } +export const RealtimeCallReferRequest = Schema.Struct({ + "target_uri": Schema.String.annotate({ + "description": + "URI that should appear in the SIP Refer-To header. Supports values like\n`tel:+14155550123` or `sip:agent@example.com`." + }) }).annotate({ - "title": "ResponseImageGenCallGeneratingEvent", - "description": "Emitted when an image generation tool call is actively generating an image (intermediate state).\n" + "title": "Realtime call refer request", + "description": "Parameters required to transfer a SIP call to a new destination using the\nRealtime API.", + "identifier": "RealtimeCallReferRequest" }) -export type ResponseImageGenCallInProgressEvent = { - readonly "type": "response.image_generation_call.in_progress" - readonly "output_index": number - readonly "item_id": string - readonly "sequence_number": number -} -export const ResponseImageGenCallInProgressEvent = Schema.Struct({ - "type": Schema.Literal("response.image_generation_call.in_progress").annotate({ - "description": "The type of the event. Always 'response.image_generation_call.in_progress'." - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response's output array." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The unique identifier of the image generation item being processed." - }), - "sequence_number": Schema.Number.annotate({ - "description": "The sequence number of the image generation item being processed." - }).check(Schema.isInt()) +export type RealtimeCallRejectRequest = { readonly "status_code"?: number } +export const RealtimeCallRejectRequest = Schema.Struct({ + "status_code": Schema.optionalKey( + Schema.Number.annotate({ + "description": "SIP response code to send back to the caller. Defaults to `603` (Decline)\nwhen omitted." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) }).annotate({ - "title": "ResponseImageGenCallInProgressEvent", - "description": "Emitted when an image generation tool call is in progress.\n" + "title": "Realtime call reject request", + "description": "Parameters used to decline an incoming SIP call handled by the Realtime API.", + "identifier": "RealtimeCallRejectRequest" }) -export type ResponseImageGenCallPartialImageEvent = { - readonly "type": "response.image_generation_call.partial_image" - readonly "output_index": number - readonly "item_id": string - readonly "sequence_number": number - readonly "partial_image_index": number - readonly "partial_image_b64": string +export type AudioTranscriptionResponse = { + readonly "model"?: + | string + | "whisper-1" + | "gpt-transcribe" + | "gpt-live-transcribe" + | "gpt-4o-mini-transcribe" + | "gpt-4o-mini-transcribe-2025-12-15" + | "gpt-4o-transcribe" + | "gpt-4o-transcribe-diarize" + | "gpt-realtime-whisper" + readonly "language"?: string + readonly "languages"?: ReadonlyArray + readonly "prompt"?: string } -export const ResponseImageGenCallPartialImageEvent = Schema.Struct({ - "type": Schema.Literal("response.image_generation_call.partial_image").annotate({ - "description": "The type of the event. Always 'response.image_generation_call.partial_image'." +export const AudioTranscriptionResponse = Schema.Struct({ + "model": Schema.optionalKey( + Schema.Union([ + Schema.String, + Schema.Literals([ + "whisper-1", + "gpt-transcribe", + "gpt-live-transcribe", + "gpt-4o-mini-transcribe", + "gpt-4o-mini-transcribe-2025-12-15", + "gpt-4o-transcribe", + "gpt-4o-transcribe-diarize", + "gpt-realtime-whisper" + ]) + ]).annotate({ + "description": + "The model used for transcription. Current options are `whisper-1`, `gpt-transcribe`, `gpt-live-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.\n" + }) + ), + "language": Schema.optionalKey(Schema.String.annotate({ "description": "The language of the input audio.\n" })), + "languages": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "The possible input audio languages configured for transcription, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format.\n" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ), + "prompt": Schema.optionalKey( + Schema.String.annotate({ "description": "The prompt configured for input audio transcription, when present.\n" }) + ) +}).annotate({ "identifier": "AudioTranscriptionResponse" }) +export type ToolChoiceAllowed = { + readonly "type": "allowed_tools" + readonly "mode": "auto" | "required" + readonly "tools": ReadonlyArray<{}> +} +export const ToolChoiceAllowed = Schema.Struct({ + "type": Schema.Literal("allowed_tools").annotate({ + "description": "Allowed tool configuration type. Always `allowed_tools`." }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response's output array." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The unique identifier of the image generation item being processed." + "mode": Schema.Literals(["auto", "required"]).annotate({ + "description": + "Constrains the tools available to the model to a pre-defined set.\n\n`auto` allows the model to pick from among the allowed tools and generate a\nmessage.\n\n`required` requires the model to call one or more of the allowed tools.\n" }), - "sequence_number": Schema.Number.annotate({ - "description": "The sequence number of the image generation item being processed." - }).check(Schema.isInt()), - "partial_image_index": Schema.Number.annotate({ - "description": "0-based index for the partial image (backend is 1-based, but this is 0-based for the user)." - }).check(Schema.isInt()), - "partial_image_b64": Schema.String.annotate({ - "description": "Base64-encoded partial image data, suitable for rendering as an image." + "tools": Schema.Array( + Schema.Struct({}).annotate({ "description": "A tool definition that the model should be allowed to call.\n" }) + ).annotate({ + "description": + "A list of tool definitions that the model should be allowed to call.\n\nFor the Responses API, the list of tool definitions might look like:\n```json\n[\n { \"type\": \"function\", \"name\": \"get_weather\" },\n { \"type\": \"mcp\", \"server_label\": \"deepwiki\" },\n { \"type\": \"image_generation\" }\n]\n```\n" }) }).annotate({ - "title": "ResponseImageGenCallPartialImageEvent", - "description": "Emitted when a partial image is available during image generation streaming.\n" + "title": "Allowed tools", + "description": "Constrains the tools available to the model to a pre-defined set.\n", + "identifier": "ToolChoiceAllowed" }) -export type ResponseLogProb = { - readonly "token": string - readonly "logprob": number - readonly "top_logprobs"?: ReadonlyArray<{ readonly "token"?: string; readonly "logprob"?: number }> +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" } -export const ResponseLogProb = Schema.Struct({ - "token": Schema.String.annotate({ "description": "A possible text token." }), - "logprob": Schema.Number.annotate({ "description": "The log probability of this token.\n" }).check(Schema.isFinite()), - "top_logprobs": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "token": Schema.optionalKey(Schema.String.annotate({ "description": "A possible text token." })), - "logprob": Schema.optionalKey( - Schema.Number.annotate({ "description": "The log probability of this token." }).check(Schema.isFinite()) - ) - }) - ).annotate({ "description": "The log probabilities of up to 20 of the most likely tokens.\n" }) - ) +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`\n- `computer_use_preview`\n- `computer_use`\n- `code_interpreter`\n- `image_generation`\n" + }) }).annotate({ + "title": "Hosted tool", "description": - "A logprob is the logarithmic probability that the model assigns to producing \na particular token at a given position in the sequence. Less-negative (higher) \nlogprob values indicate greater model confidence in that token choice.\n" + "Indicates that the model should use a built-in tool to generate a response.\n[Learn more about built-in tools](/docs/guides/tools).\n", + "identifier": "ToolChoiceTypes" }) -export type ResponseMCPCallArgumentsDeltaEvent = { - readonly "type": "response.mcp_call_arguments.delta" - readonly "output_index": number - readonly "item_id": string - readonly "delta": string - readonly "sequence_number": number -} -export const ResponseMCPCallArgumentsDeltaEvent = Schema.Struct({ - "type": Schema.Literal("response.mcp_call_arguments.delta").annotate({ - "description": "The type of the event. Always 'response.mcp_call_arguments.delta'." - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response's output array." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The unique identifier of the MCP tool call item being processed." - }), - "delta": Schema.String.annotate({ - "description": "A JSON string containing the partial update to the arguments for the MCP tool call.\n" +export type ToolChoiceCustom = { readonly "type": "custom"; readonly "name": string } +export const ToolChoiceCustom = Schema.Struct({ + "type": Schema.Literal("custom").annotate({ "description": "For custom tool calling, the type is always `custom`." }), + "name": Schema.String.annotate({ "description": "The name of the custom tool to call." }) +}).annotate({ + "title": "Custom tool", + "description": "Use this option to force the model to call a specific custom tool.\n", + "identifier": "ToolChoiceCustom" +}) +export type SpecificProgrammaticToolCallingParam = { readonly "type": "programmatic_tool_calling" } +export const SpecificProgrammaticToolCallingParam = Schema.Struct({ + "type": Schema.Literal("programmatic_tool_calling").annotate({ + "description": "The tool to call. Always `programmatic_tool_calling`." + }) +}).annotate({ "identifier": "SpecificProgrammaticToolCallingParam" }) +export type SpecificApplyPatchParam = { readonly "type": "apply_patch" } +export const SpecificApplyPatchParam = Schema.Struct({ + "type": Schema.Literal("apply_patch").annotate({ "description": "The tool to call. Always `apply_patch`." }) +}).annotate({ + "title": "Specific apply patch tool choice", + "description": "Forces the model to call the apply_patch tool when executing a tool call.", + "identifier": "SpecificApplyPatchParam" +}) +export type SpecificFunctionShellParam = { readonly "type": "shell" } +export const SpecificFunctionShellParam = Schema.Struct({ + "type": Schema.Literal("shell").annotate({ "description": "The tool to call. Always `shell`." }) +}).annotate({ + "title": "Specific shell tool choice", + "description": "Forces the model to call the shell tool when a tool call is required.", + "identifier": "SpecificFunctionShellParam" +}) +export type ReasoningModeEnum = string | "standard" | "pro" +export const ReasoningModeEnum = Schema.Union([Schema.String, Schema.Literals(["standard", "pro"])]).annotate({ + "identifier": "ReasoningModeEnum" +}) +export type ResponseStreamOptions = { readonly "include_obfuscation"?: boolean } | null +export const ResponseStreamOptions = Schema.Union([ + Schema.Struct({ + "include_obfuscation": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "When true, stream obfuscation will be enabled. Stream obfuscation adds\nrandom characters to an `obfuscation` field on streaming delta events to\nnormalize payload sizes as a mitigation to certain side-channel attacks.\nThese obfuscation fields are included by default, but add a small amount\nof overhead to the data stream. You can set `include_obfuscation` to\nfalse to optimize for bandwidth if you trust the network links between\nyour application and the OpenAI API.\n" + })) + }).annotate({ "description": "Options for streaming responses. Only set this when you set `stream: true`.\n" }), + Schema.Null +]).annotate({ "identifier": "ResponseStreamOptions" }) +export type ConversationParam_2 = { readonly "id": string } +export const ConversationParam_2 = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the conversation." }) +}).annotate({ + "title": "Conversation object", + "description": "The conversation that this response belongs to.", + "identifier": "ConversationParam-2" +}) +export type ContextManagementParam = { readonly "type": string; readonly "compact_threshold"?: number | null } +export const ContextManagementParam = Schema.Struct({ + "type": Schema.String.annotate({ + "description": "The context management entry type. Currently only 'compaction' is supported." }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() + "compact_threshold": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "Token threshold at which compaction should be triggered for this entry." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1000).annotate({ "expected": "a value greater than or equal to 1000" }) + ), + Schema.Null + ]) + ) +}).annotate({ "identifier": "ContextManagementParam" }) +export type ResponseErrorCode = + | "server_error" + | "rate_limit_exceeded" + | "invalid_prompt" + | "data_residency_mismatch" + | "bio_policy" + | "vector_store_timeout" + | "invalid_image" + | "invalid_image_format" + | "invalid_base64_image" + | "invalid_image_url" + | "image_too_large" + | "image_too_small" + | "image_parse_error" + | "image_content_policy_violation" + | "invalid_image_mode" + | "image_file_too_large" + | "unsupported_image_media_type" + | "empty_image_file" + | "failed_to_download_image" + | "image_file_not_found" +export const ResponseErrorCode = Schema.Literals([ + "server_error", + "rate_limit_exceeded", + "invalid_prompt", + "data_residency_mismatch", + "bio_policy", + "vector_store_timeout", + "invalid_image", + "invalid_image_format", + "invalid_base64_image", + "invalid_image_url", + "image_too_large", + "image_too_small", + "image_parse_error", + "image_content_policy_violation", + "invalid_image_mode", + "image_file_too_large", + "unsupported_image_media_type", + "empty_image_file", + "failed_to_download_image", + "image_file_not_found" +]).annotate({ "description": "The error code for the response.\n", "identifier": "ResponseErrorCode" }) +export type ResponseUsage = { + readonly "input_tokens": number + readonly "input_tokens_details": { readonly "cached_tokens": number; readonly "cache_write_tokens": number } + readonly "output_tokens": number + readonly "output_tokens_details": { readonly "reasoning_tokens": number } + readonly "total_tokens": number +} +export const ResponseUsage = Schema.Struct({ + "input_tokens": Schema.Number.annotate({ "description": "The number of input tokens." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "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({ "expected": "an integer" })), + "cache_write_tokens": Schema.Number.annotate({ + "description": "The number of input tokens that were written to the cache." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + }).annotate({ "description": "A detailed breakdown of the input tokens." }), + "output_tokens": Schema.Number.annotate({ "description": "The number of output tokens." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "output_tokens_details": Schema.Struct({ + "reasoning_tokens": Schema.Number.annotate({ "description": "The number of reasoning tokens." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).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({ "expected": "an integer" }) ) }).annotate({ - "title": "ResponseMCPCallArgumentsDeltaEvent", - "description": "Emitted when there is a delta (partial update) to the arguments of an MCP tool call.\n" + "description": + "Represents token usage details including input tokens, output tokens,\na breakdown of output tokens, and the total tokens used.\n", + "identifier": "ResponseUsage" }) -export type ResponseMCPCallArgumentsDoneEvent = { - readonly "type": "response.mcp_call_arguments.done" - readonly "output_index": number - readonly "item_id": string - readonly "arguments": string - readonly "sequence_number": number -} -export const ResponseMCPCallArgumentsDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.mcp_call_arguments.done").annotate({ - "description": "The type of the event. Always 'response.mcp_call_arguments.done'." - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response's output array." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The unique identifier of the MCP tool call item being processed." +export type ModerationErrorBody = { readonly "type": "error"; readonly "code": string; readonly "message": string } +export const ModerationErrorBody = Schema.Struct({ + "type": Schema.Literal("error").annotate({ + "description": "The object type, which was always `error` for moderation failures." }), - "arguments": Schema.String.annotate({ - "description": "A JSON string containing the finalized arguments for the MCP tool call.\n" - }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ) + "code": Schema.String.annotate({ "description": "The error code." }), + "message": Schema.String.annotate({ "description": "The error message." }) }).annotate({ - "title": "ResponseMCPCallArgumentsDoneEvent", - "description": "Emitted when the arguments for an MCP tool call are finalized.\n" + "title": "Moderation error", + "description": "An error produced while attempting moderation for the response input or output.", + "identifier": "ModerationErrorBody" }) -export type ResponseMCPCallCompletedEvent = { - readonly "type": "response.mcp_call.completed" - readonly "item_id": string - readonly "output_index": number +export type ResponseConversation = { readonly "id": string } +export const ResponseConversation = Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The unique ID of the conversation that this response was associated with." + }) +}).annotate({ + "title": "Conversation", + "description": + "The conversation that this response belonged to. Input items and output items from this response were automatically added to this conversation.", + "identifier": "ResponseConversation" +}) +export type ResponseAudioDeltaEvent = { + readonly "type": "response.audio.delta" readonly "sequence_number": number + readonly "delta": string } -export const ResponseMCPCallCompletedEvent = Schema.Struct({ - "type": Schema.Literal("response.mcp_call.completed").annotate({ - "description": "The type of the event. Always 'response.mcp_call.completed'." +export const ResponseAudioDeltaEvent = Schema.Struct({ + "type": Schema.Literal("response.audio.delta").annotate({ + "description": "The type of the event. Always `response.audio.delta`.\n" }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that completed." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item that completed." }).check( - Schema.isInt() - ), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ) + "sequence_number": Schema.Number.annotate({ + "description": "A sequence number for this chunk of the stream response.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String.annotate({ "description": "A chunk of Base64 encoded response audio bytes.\n" }) }).annotate({ - "title": "ResponseMCPCallCompletedEvent", - "description": "Emitted when an MCP tool call has completed successfully.\n" + "description": "Emitted when there is a partial audio response.", + "identifier": "ResponseAudioDeltaEvent" }) -export type ResponseMCPCallFailedEvent = { - readonly "type": "response.mcp_call.failed" - readonly "item_id": string - readonly "output_index": number +export type ResponseAudioDoneEvent = { + readonly "type": "response.audio.done" readonly "sequence_number": number + readonly "response_id": Schema.Json } -export const ResponseMCPCallFailedEvent = Schema.Struct({ - "type": Schema.Literal("response.mcp_call.failed").annotate({ - "description": "The type of the event. Always 'response.mcp_call.failed'." +export const ResponseAudioDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.audio.done").annotate({ + "description": "The type of the event. Always `response.audio.done`.\n" }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that failed." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item that failed." }).check( - Schema.isInt() + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of the delta.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ) -}).annotate({ "title": "ResponseMCPCallFailedEvent", "description": "Emitted when an MCP tool call has failed.\n" }) -export type ResponseMCPCallInProgressEvent = { - readonly "type": "response.mcp_call.in_progress" + "response_id": Schema.Json.annotate({ "expected": "JSON value" }) +}).annotate({ "description": "Emitted when the audio response is complete.", "identifier": "ResponseAudioDoneEvent" }) +export type ResponseAudioTranscriptDeltaEvent = { + readonly "type": "response.audio.transcript.delta" + readonly "delta": string readonly "sequence_number": number - readonly "output_index": number - readonly "item_id": string + readonly "response_id": Schema.Json } -export const ResponseMCPCallInProgressEvent = Schema.Struct({ - "type": Schema.Literal("response.mcp_call.in_progress").annotate({ - "description": "The type of the event. Always 'response.mcp_call.in_progress'." +export const ResponseAudioTranscriptDeltaEvent = Schema.Struct({ + "type": Schema.Literal("response.audio.transcript.delta").annotate({ + "description": "The type of the event. Always `response.audio.transcript.delta`.\n" }), + "delta": Schema.String.annotate({ "description": "The partial transcript of the audio response.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response's output array." - }).check(Schema.isInt()), - "item_id": Schema.String.annotate({ - "description": "The unique identifier of the MCP tool call item being processed." - }) + "response_id": Schema.Json.annotate({ "expected": "JSON value" }) }).annotate({ - "title": "ResponseMCPCallInProgressEvent", - "description": "Emitted when an MCP tool call is in progress.\n" + "description": "Emitted when there is a partial transcript of audio.", + "identifier": "ResponseAudioTranscriptDeltaEvent" }) -export type ResponseMCPListToolsCompletedEvent = { - readonly "type": "response.mcp_list_tools.completed" - readonly "item_id": string - readonly "output_index": number +export type ResponseAudioTranscriptDoneEvent = { + readonly "type": "response.audio.transcript.done" readonly "sequence_number": number + readonly "response_id": Schema.Json } -export const ResponseMCPListToolsCompletedEvent = Schema.Struct({ - "type": Schema.Literal("response.mcp_list_tools.completed").annotate({ - "description": "The type of the event. Always 'response.mcp_list_tools.completed'." +export const ResponseAudioTranscriptDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.audio.transcript.done").annotate({ + "description": "The type of the event. Always `response.audio.transcript.done`.\n" }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that produced this output." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item that was processed." }).check( - Schema.isInt() - ), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ) + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "response_id": Schema.Json.annotate({ "expected": "JSON value" }) }).annotate({ - "title": "ResponseMCPListToolsCompletedEvent", - "description": "Emitted when the list of available MCP tools has been successfully retrieved.\n" + "description": "Emitted when the full audio transcript is completed.", + "identifier": "ResponseAudioTranscriptDoneEvent" }) -export type ResponseMCPListToolsFailedEvent = { - readonly "type": "response.mcp_list_tools.failed" - readonly "item_id": string +export type ResponseCodeInterpreterCallCodeDeltaEvent = { + readonly "type": "response.code_interpreter_call_code.delta" readonly "output_index": number + readonly "item_id": string + readonly "delta": string readonly "sequence_number": number } -export const ResponseMCPListToolsFailedEvent = Schema.Struct({ - "type": Schema.Literal("response.mcp_list_tools.failed").annotate({ - "description": "The type of the event. Always 'response.mcp_list_tools.failed'." +export const ResponseCodeInterpreterCallCodeDeltaEvent = Schema.Struct({ + "type": Schema.Literal("response.code_interpreter_call_code.delta").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call_code.delta`." }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that failed." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item that failed." }).check( - Schema.isInt() - ), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ) + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code is being streamed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "delta": Schema.String.annotate({ + "description": "The partial code snippet being streamed by the code interpreter." + }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) }).annotate({ - "title": "ResponseMCPListToolsFailedEvent", - "description": "Emitted when the attempt to list available MCP tools has failed.\n" + "description": "Emitted when a partial code snippet is streamed by the code interpreter.", + "identifier": "ResponseCodeInterpreterCallCodeDeltaEvent" }) -export type ResponseMCPListToolsInProgressEvent = { - readonly "type": "response.mcp_list_tools.in_progress" - readonly "item_id": string +export type ResponseCodeInterpreterCallCodeDoneEvent = { + readonly "type": "response.code_interpreter_call_code.done" readonly "output_index": number + readonly "item_id": string + readonly "code": string readonly "sequence_number": number } -export const ResponseMCPListToolsInProgressEvent = Schema.Struct({ - "type": Schema.Literal("response.mcp_list_tools.in_progress").annotate({ - "description": "The type of the event. Always 'response.mcp_list_tools.in_progress'." +export const ResponseCodeInterpreterCallCodeDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.code_interpreter_call_code.done").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call_code.done`." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code is finalized." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "code": Schema.String.annotate({ "description": "The final code snippet output by the code interpreter." }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when the code snippet is finalized by the code interpreter.", + "identifier": "ResponseCodeInterpreterCallCodeDoneEvent" +}) +export type ResponseCodeInterpreterCallCompletedEvent = { + readonly "type": "response.code_interpreter_call.completed" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const ResponseCodeInterpreterCallCompletedEvent = Schema.Struct({ + "type": Schema.Literal("response.code_interpreter_call.completed").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call.completed`." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code interpreter call is completed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when the code interpreter call is completed.", + "identifier": "ResponseCodeInterpreterCallCompletedEvent" +}) +export type ResponseCodeInterpreterCallInProgressEvent = { + readonly "type": "response.code_interpreter_call.in_progress" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const ResponseCodeInterpreterCallInProgressEvent = Schema.Struct({ + "type": Schema.Literal("response.code_interpreter_call.in_progress").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call.in_progress`." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code interpreter call is in progress." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a code interpreter call is in progress.", + "identifier": "ResponseCodeInterpreterCallInProgressEvent" +}) +export type ResponseCodeInterpreterCallInterpretingEvent = { + readonly "type": "response.code_interpreter_call.interpreting" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const ResponseCodeInterpreterCallInterpretingEvent = Schema.Struct({ + "type": Schema.Literal("response.code_interpreter_call.interpreting").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call.interpreting`." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code interpreter is interpreting code." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when the code interpreter is actively interpreting the code snippet.", + "identifier": "ResponseCodeInterpreterCallInterpretingEvent" +}) +export type ResponseErrorEvent = { + readonly "type": "error" + readonly "code": string | null + readonly "message": string + readonly "param": string | null + readonly "sequence_number": number +} +export const ResponseErrorEvent = Schema.Struct({ + "type": Schema.Literal("error").annotate({ "description": "The type of the event. Always `error`.\n" }), + "code": Schema.Union([Schema.String.annotate({ "description": "The error code.\n" }), Schema.Null]), + "message": Schema.String.annotate({ "description": "The error message.\n" }), + "param": Schema.Union([Schema.String.annotate({ "description": "The error parameter.\n" }), Schema.Null]), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "description": "Emitted when an error occurs.", "identifier": "ResponseErrorEvent" }) +export type ResponseFileSearchCallCompletedEvent = { + readonly "type": "response.file_search_call.completed" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const ResponseFileSearchCallCompletedEvent = Schema.Struct({ + "type": Schema.Literal("response.file_search_call.completed").annotate({ + "description": "The type of the event. Always `response.file_search_call.completed`.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the file search call is initiated.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the file search call is initiated.\n" }), - "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that is being processed." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item that is being processed." }) - .check(Schema.isInt()), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ) }).annotate({ - "title": "ResponseMCPListToolsInProgressEvent", - "description": "Emitted when the system is in the process of retrieving the list of available MCP tools.\n" + "description": "Emitted when a file search call is completed (results found).", + "identifier": "ResponseFileSearchCallCompletedEvent" }) -export type ResponseModalities = ReadonlyArray<"text" | "audio"> | null -export const ResponseModalities = Schema.Union([ - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": - "Output types that you would like the model to generate.\nMost models are capable of generating text, which is the default:\n\n`[\"text\"]`\n\nThe `gpt-4o-audio-preview` model can also be used to\n[generate audio](/docs/guides/audio). To request that this model generate\nboth text and audio responses, you can use:\n\n`[\"text\", \"audio\"]`\n" +export type ResponseFileSearchCallInProgressEvent = { + readonly "type": "response.file_search_call.in_progress" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const ResponseFileSearchCallInProgressEvent = Schema.Struct({ + "type": Schema.Literal("response.file_search_call.in_progress").annotate({ + "description": "The type of the event. Always `response.file_search_call.in_progress`.\n" }), - Schema.Null -]) -export type ResponseOutputTextAnnotationAddedEvent = { - readonly "type": "response.output_text.annotation.added" + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the file search call is initiated.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the file search call is initiated.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a file search call is initiated.", + "identifier": "ResponseFileSearchCallInProgressEvent" +}) +export type ResponseFileSearchCallSearchingEvent = { + readonly "type": "response.file_search_call.searching" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const ResponseFileSearchCallSearchingEvent = Schema.Struct({ + "type": Schema.Literal("response.file_search_call.searching").annotate({ + "description": "The type of the event. Always `response.file_search_call.searching`.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the file search call is searching.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the file search call is initiated.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a file search is currently searching.", + "identifier": "ResponseFileSearchCallSearchingEvent" +}) +export type ResponseFunctionCallArgumentsDeltaEvent = { + readonly "type": "response.function_call_arguments.delta" readonly "item_id": string readonly "output_index": number - readonly "content_index": number - readonly "annotation_index": number readonly "sequence_number": number - readonly "annotation": {} + readonly "delta": string } -export const ResponseOutputTextAnnotationAddedEvent = Schema.Struct({ - "type": Schema.Literal("response.output_text.annotation.added").annotate({ - "description": "The type of the event. Always 'response.output_text.annotation.added'." +export const ResponseFunctionCallArgumentsDeltaEvent = Schema.Struct({ + "type": Schema.Literal("response.function_call_arguments.delta").annotate({ + "description": "The type of the event. Always `response.function_call_arguments.delta`.\n" }), "item_id": Schema.String.annotate({ - "description": "The unique identifier of the item to which the annotation is being added." + "description": "The ID of the output item that the function-call arguments delta is added to.\n" }), "output_index": Schema.Number.annotate({ - "description": "The index of the output item in the response's output array." - }).check(Schema.isInt()), - "content_index": Schema.Number.annotate({ "description": "The index of the content part within the output item." }) - .check(Schema.isInt()), - "annotation_index": Schema.Number.annotate({ "description": "The index of the annotation within the content part." }) - .check(Schema.isInt()), + "description": "The index of the output item that the function-call arguments delta is added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ), - "annotation": Schema.Struct({}).annotate({ - "description": "The annotation object being added. (See annotation schema for details.)" - }) + "delta": Schema.String.annotate({ "description": "The function-call arguments delta that is added.\n" }) }).annotate({ - "title": "ResponseOutputTextAnnotationAddedEvent", - "description": "Emitted when an annotation is added to output text content.\n" + "description": "Emitted when there is a partial function-call arguments delta.", + "identifier": "ResponseFunctionCallArgumentsDeltaEvent" +}) +export type ResponseFunctionCallArgumentsDoneEvent = { + readonly "type": "response.function_call_arguments.done" + readonly "item_id": string + readonly "name"?: string + readonly "output_index": number + readonly "sequence_number": number + readonly "arguments": string +} +export const ResponseFunctionCallArgumentsDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.function_call_arguments.done"), + "item_id": Schema.String.annotate({ "description": "The ID of the item." }), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function that was called." })), + "output_index": Schema.Number.annotate({ "description": "The index of the output item." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "arguments": Schema.String.annotate({ "description": "The function-call arguments." }) +}).annotate({ + "description": "Emitted when function-call arguments are finalized.", + "identifier": "ResponseFunctionCallArgumentsDoneEvent" }) -export type ResponsePromptVariables = {} | null -export const ResponsePromptVariables = Schema.Union([ - Schema.Struct({}).annotate({ - "title": "Prompt Variables", - "description": - "Optional map of values to substitute in for variables in your\nprompt. The substitution values can either be strings, or other\nResponse input types like images or files.\n" - }), - Schema.Null -]) export type ResponseReasoningSummaryPartAddedEvent = { readonly "type": "response.reasoning_summary_part.added" readonly "item_id": string @@ -6327,12 +7288,12 @@ export const ResponseReasoningSummaryPartAddedEvent = Schema.Struct({ "item_id": Schema.String.annotate({ "description": "The ID of the item this summary part is associated with.\n" }), "output_index": Schema.Number.annotate({ "description": "The index of the output item this summary part is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "summary_index": Schema.Number.annotate({ "description": "The index of the summary part within the reasoning summary.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ), "part": Schema.Struct({ "type": Schema.Literal("summary_text").annotate({ @@ -6340,12 +7301,16 @@ export const ResponseReasoningSummaryPartAddedEvent = Schema.Struct({ }), "text": Schema.String.annotate({ "description": "The text of the summary part." }) }).annotate({ "description": "The summary part that was added.\n" }) -}).annotate({ "description": "Emitted when a new reasoning summary part is added." }) +}).annotate({ + "description": "Emitted when a new reasoning summary part is added.", + "identifier": "ResponseReasoningSummaryPartAddedEvent" +}) export type ResponseReasoningSummaryPartDoneEvent = { readonly "type": "response.reasoning_summary_part.done" readonly "item_id": string readonly "output_index": number readonly "summary_index": number + readonly "status"?: "incomplete" readonly "sequence_number": number readonly "part": { readonly "type": "summary_text"; readonly "text": string } } @@ -6356,12 +7321,18 @@ export const ResponseReasoningSummaryPartDoneEvent = Schema.Struct({ "item_id": Schema.String.annotate({ "description": "The ID of the item this summary part is associated with.\n" }), "output_index": Schema.Number.annotate({ "description": "The index of the output item this summary part is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "summary_index": Schema.Number.annotate({ "description": "The index of the summary part within the reasoning summary.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "status": Schema.optionalKey( + Schema.Literal("incomplete").annotate({ + "description": + "The completion status of the summary part. Omitted when the part completed\nnormally and set to `incomplete` when generation was interrupted.\n" + }) + ), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ), "part": Schema.Struct({ "type": Schema.Literal("summary_text").annotate({ @@ -6369,7 +7340,10 @@ export const ResponseReasoningSummaryPartDoneEvent = Schema.Struct({ }), "text": Schema.String.annotate({ "description": "The text of the summary part." }) }).annotate({ "description": "The completed summary part.\n" }) -}).annotate({ "description": "Emitted when a reasoning summary part is completed." }) +}).annotate({ + "description": "Emitted when a reasoning summary part is completed.", + "identifier": "ResponseReasoningSummaryPartDoneEvent" +}) export type ResponseReasoningSummaryTextDeltaEvent = { readonly "type": "response.reasoning_summary_text.delta" readonly "item_id": string @@ -6387,15 +7361,18 @@ export const ResponseReasoningSummaryTextDeltaEvent = Schema.Struct({ }), "output_index": Schema.Number.annotate({ "description": "The index of the output item this summary text delta is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "summary_index": Schema.Number.annotate({ "description": "The index of the summary part within the reasoning summary.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "delta": Schema.String.annotate({ "description": "The text delta that was added to the summary.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "description": "Emitted when a delta is added to a reasoning summary text." }) +}).annotate({ + "description": "Emitted when a delta is added to a reasoning summary text.", + "identifier": "ResponseReasoningSummaryTextDeltaEvent" +}) export type ResponseReasoningSummaryTextDoneEvent = { readonly "type": "response.reasoning_summary_text.done" readonly "item_id": string @@ -6411,15 +7388,18 @@ export const ResponseReasoningSummaryTextDoneEvent = Schema.Struct({ "item_id": Schema.String.annotate({ "description": "The ID of the item this summary text is associated with.\n" }), "output_index": Schema.Number.annotate({ "description": "The index of the output item this summary text is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "summary_index": Schema.Number.annotate({ "description": "The index of the summary part within the reasoning summary.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "text": Schema.String.annotate({ "description": "The full text of the completed reasoning summary.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "description": "Emitted when a reasoning summary text is completed." }) +}).annotate({ + "description": "Emitted when a reasoning summary text is completed.", + "identifier": "ResponseReasoningSummaryTextDoneEvent" +}) export type ResponseReasoningTextDeltaEvent = { readonly "type": "response.reasoning_text.delta" readonly "item_id": string @@ -6437,15 +7417,18 @@ export const ResponseReasoningTextDeltaEvent = Schema.Struct({ }), "output_index": Schema.Number.annotate({ "description": "The index of the output item this reasoning text delta is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "content_index": Schema.Number.annotate({ "description": "The index of the reasoning content part this delta is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "delta": Schema.String.annotate({ "description": "The text delta that was added to the reasoning content.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "description": "Emitted when a delta is added to a reasoning text." }) +}).annotate({ + "description": "Emitted when a delta is added to a reasoning text.", + "identifier": "ResponseReasoningTextDeltaEvent" +}) export type ResponseReasoningTextDoneEvent = { readonly "type": "response.reasoning_text.done" readonly "item_id": string @@ -6461,15 +7444,18 @@ export const ResponseReasoningTextDoneEvent = Schema.Struct({ "item_id": Schema.String.annotate({ "description": "The ID of the item this reasoning text is associated with.\n" }), "output_index": Schema.Number.annotate({ "description": "The index of the output item this reasoning text is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "content_index": Schema.Number.annotate({ "description": "The index of the reasoning content part.\n" }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ), "text": Schema.String.annotate({ "description": "The full text of the completed reasoning content.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "description": "Emitted when a reasoning text is completed." }) +}).annotate({ + "description": "Emitted when a reasoning text is completed.", + "identifier": "ResponseReasoningTextDoneEvent" +}) export type ResponseRefusalDeltaEvent = { readonly "type": "response.refusal.delta" readonly "item_id": string @@ -6487,15 +7473,18 @@ export const ResponseRefusalDeltaEvent = Schema.Struct({ }), "output_index": Schema.Number.annotate({ "description": "The index of the output item that the refusal text is added to.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "content_index": Schema.Number.annotate({ "description": "The index of the content part that the refusal text is added to.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "delta": Schema.String.annotate({ "description": "The refusal text that is added.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "description": "Emitted when there is a partial refusal text." }) +}).annotate({ + "description": "Emitted when there is a partial refusal text.", + "identifier": "ResponseRefusalDeltaEvent" +}) export type ResponseRefusalDoneEvent = { readonly "type": "response.refusal.done" readonly "item_id": string @@ -6513,50 +7502,39 @@ export const ResponseRefusalDoneEvent = Schema.Struct({ }), "output_index": Schema.Number.annotate({ "description": "The index of the output item that the refusal text is finalized.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "content_index": Schema.Number.annotate({ "description": "The index of the content part that the refusal text is finalized.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "refusal": Schema.String.annotate({ "description": "The refusal text that is finalized.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "description": "Emitted when refusal text is finalized." }) -export type ResponseStreamOptions = { readonly "include_obfuscation"?: boolean } | null -export const ResponseStreamOptions = Schema.Union([ - Schema.Struct({ - "include_obfuscation": Schema.optionalKey(Schema.Boolean.annotate({ - "description": - "When true, stream obfuscation will be enabled. Stream obfuscation adds\nrandom characters to an `obfuscation` field on streaming delta events to\nnormalize payload sizes as a mitigation to certain side-channel attacks.\nThese obfuscation fields are included by default, but add a small amount\nof overhead to the data stream. You can set `include_obfuscation` to\nfalse to optimize for bandwidth if you trust the network links between\nyour application and the OpenAI API.\n" - })) - }).annotate({ "description": "Options for streaming responses. Only set this when you set `stream: true`.\n" }), - Schema.Null -]) -export type ResponseUsage = { - 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 +}).annotate({ "description": "Emitted when refusal text is finalized.", "identifier": "ResponseRefusalDoneEvent" }) +export type ResponseLogProb = { + readonly "token": string + readonly "logprob": number + readonly "top_logprobs"?: ReadonlyArray<{ readonly "token"?: string; readonly "logprob"?: number }> } -export const ResponseUsage = 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()) +export const ResponseLogProb = Schema.Struct({ + "token": Schema.String.annotate({ "description": "A possible text token." }), + "logprob": Schema.Number.annotate({ "description": "The log probability of this token.\n" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "top_logprobs": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "token": Schema.optionalKey(Schema.String.annotate({ "description": "A possible text token." })), + "logprob": Schema.optionalKey( + Schema.Number.annotate({ "description": "The log probability of this token." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ) + })).annotate({ "description": "The log probabilities of up to 20 of the most likely tokens.\n" }) + ) }).annotate({ "description": - "Represents token usage details including input tokens, output tokens,\na breakdown of output tokens, and the total tokens used.\n" + "A logprob is the logarithmic probability that the model assigns to producing \na particular token at a given position in the sequence. Less-negative (higher) \nlogprob values indicate greater model confidence in that token choice.\n", + "identifier": "ResponseLogProb" }) export type ResponseWebSearchCallCompletedEvent = { readonly "type": "response.web_search_call.completed" @@ -6570,14 +7548,17 @@ export const ResponseWebSearchCallCompletedEvent = Schema.Struct({ }), "output_index": Schema.Number.annotate({ "description": "The index of the output item that the web search call is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "item_id": Schema.String.annotate({ "description": "Unique ID for the output item associated with the web search call.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of the web search call being processed." - }).check(Schema.isInt()) -}).annotate({ "description": "Emitted when a web search call is completed." }) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a web search call is completed.", + "identifier": "ResponseWebSearchCallCompletedEvent" +}) export type ResponseWebSearchCallInProgressEvent = { readonly "type": "response.web_search_call.in_progress" readonly "output_index": number @@ -6590,14 +7571,17 @@ export const ResponseWebSearchCallInProgressEvent = Schema.Struct({ }), "output_index": Schema.Number.annotate({ "description": "The index of the output item that the web search call is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "item_id": Schema.String.annotate({ "description": "Unique ID for the output item associated with the web search call.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of the web search call being processed." - }).check(Schema.isInt()) -}).annotate({ "description": "Emitted when a web search call is initiated." }) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a web search call is initiated.", + "identifier": "ResponseWebSearchCallInProgressEvent" +}) export type ResponseWebSearchCallSearchingEvent = { readonly "type": "response.web_search_call.searching" readonly "output_index": number @@ -6610,1728 +7594,2026 @@ export const ResponseWebSearchCallSearchingEvent = Schema.Struct({ }), "output_index": Schema.Number.annotate({ "description": "The index of the output item that the web search call is associated with.\n" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "item_id": Schema.String.annotate({ "description": "Unique ID for the output item associated with the web search call.\n" }), "sequence_number": Schema.Number.annotate({ "description": "The sequence number of the web search call being processed." - }).check(Schema.isInt()) -}).annotate({ "description": "Emitted when a web search call is executing." }) -export type Role = { - readonly "object": "role" - readonly "id": string - readonly "name": string - readonly "description": string | null - readonly "permissions": ReadonlyArray - readonly "resource_type": string - readonly "predefined_role": boolean -} -export const Role = Schema.Struct({ - "object": Schema.Literal("role").annotate({ "description": "Always `role`." }), - "id": Schema.String.annotate({ "description": "Identifier for the role." }), - "name": Schema.String.annotate({ "description": "Unique name for the role." }), - "description": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Optional description of the role." - }), - "permissions": Schema.Array(Schema.String).annotate({ "description": "Permissions granted by the role." }), - "resource_type": Schema.String.annotate({ - "description": "Resource type the role is bound to (for example `api.organization` or `api.project`)." - }), - "predefined_role": Schema.Boolean.annotate({ "description": "Whether the role is predefined and managed by OpenAI." }) -}).annotate({ "description": "Details about a role that can be assigned through the public Roles API." }) -export type RoleDeletedResource = { - readonly "object": "role.deleted" - readonly "id": string - readonly "deleted": boolean + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a web search call is executing.", + "identifier": "ResponseWebSearchCallSearchingEvent" +}) +export type ResponseImageGenCallCompletedEvent = { + readonly "type": "response.image_generation_call.completed" + readonly "output_index": number + readonly "sequence_number": number + readonly "item_id": string } -export const RoleDeletedResource = Schema.Struct({ - "object": Schema.Literal("role.deleted").annotate({ "description": "Always `role.deleted`." }), - "id": Schema.String.annotate({ "description": "Identifier of the deleted role." }), - "deleted": Schema.Boolean.annotate({ "description": "Whether the role was deleted." }) -}).annotate({ "description": "Confirmation payload returned after deleting a role." }) -export type RunCompletionUsage = { - readonly "completion_tokens": number - readonly "prompt_tokens": number - readonly "total_tokens": number -} | null -export const RunCompletionUsage = Schema.Union([ - Schema.Struct({ - "completion_tokens": Schema.Number.annotate({ - "description": "Number of completion tokens used over the course of the run." - }).check(Schema.isInt()), - "prompt_tokens": Schema.Number.annotate({ - "description": "Number of prompt tokens used over the course of the run." - }).check(Schema.isInt()), - "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (prompt + completion)." }) - .check(Schema.isInt()) - }).annotate({ - "description": - "Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.)." +export const ResponseImageGenCallCompletedEvent = Schema.Struct({ + "type": Schema.Literal("response.image_generation_call.completed").annotate({ + "description": "The type of the event. Always 'response.image_generation_call.completed'." }), - Schema.Null -]) -export type RunGraderResponse = { - readonly "reward": number - readonly "metadata": { - readonly "name": string - readonly "type": string - readonly "errors": { - readonly "formula_parse_error": boolean - readonly "sample_parse_error": boolean - readonly "truncated_observation_error": boolean - readonly "unresponsive_reward_error": boolean - readonly "invalid_variable_error": boolean - readonly "other_error": boolean - readonly "python_grader_server_error": boolean - readonly "python_grader_server_error_type": string | null - readonly "python_grader_runtime_error": boolean - readonly "python_grader_runtime_error_details": string | null - readonly "model_grader_server_error": boolean - readonly "model_grader_refusal_error": boolean - readonly "model_grader_parse_error": boolean - readonly "model_grader_server_error_details": string | null - } - readonly "execution_time": number - readonly "scores": {} - readonly "token_usage": number | null - readonly "sampled_model_name": string | null - } - readonly "sub_rewards": {} - readonly "model_grader_token_usage_per_model": {} + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the image generation item being processed." + }) +}).annotate({ + "title": "ResponseImageGenCallCompletedEvent", + "description": "Emitted when an image generation tool call has completed and the final image is available.\n", + "identifier": "ResponseImageGenCallCompletedEvent" +}) +export type ResponseImageGenCallGeneratingEvent = { + readonly "type": "response.image_generation_call.generating" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number } -export const RunGraderResponse = Schema.Struct({ - "reward": Schema.Number.check(Schema.isFinite()), - "metadata": Schema.Struct({ - "name": Schema.String, - "type": Schema.String, - "errors": Schema.Struct({ - "formula_parse_error": Schema.Boolean, - "sample_parse_error": Schema.Boolean, - "truncated_observation_error": Schema.Boolean, - "unresponsive_reward_error": Schema.Boolean, - "invalid_variable_error": Schema.Boolean, - "other_error": Schema.Boolean, - "python_grader_server_error": Schema.Boolean, - "python_grader_server_error_type": Schema.Union([Schema.String, Schema.Null]), - "python_grader_runtime_error": Schema.Boolean, - "python_grader_runtime_error_details": Schema.Union([Schema.String, Schema.Null]), - "model_grader_server_error": Schema.Boolean, - "model_grader_refusal_error": Schema.Boolean, - "model_grader_parse_error": Schema.Boolean, - "model_grader_server_error_details": Schema.Union([Schema.String, Schema.Null]) - }), - "execution_time": Schema.Number.check(Schema.isFinite()), - "scores": Schema.Struct({}), - "token_usage": Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]), - "sampled_model_name": Schema.Union([Schema.String, Schema.Null]) +export const ResponseImageGenCallGeneratingEvent = Schema.Struct({ + "type": Schema.Literal("response.image_generation_call.generating").annotate({ + "description": "The type of the event. Always 'response.image_generation_call.generating'." }), - "sub_rewards": Schema.Struct({}), - "model_grader_token_usage_per_model": Schema.Struct({}) -}) -export type RunStepCompletionUsage = { - readonly "completion_tokens": number - readonly "prompt_tokens": number - readonly "total_tokens": number -} | null -export const RunStepCompletionUsage = Schema.Union([ - Schema.Struct({ - "completion_tokens": Schema.Number.annotate({ - "description": "Number of completion tokens used over the course of the run step." - }).check(Schema.isInt()), - "prompt_tokens": Schema.Number.annotate({ - "description": "Number of prompt tokens used over the course of the run step." - }).check(Schema.isInt()), - "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (prompt + completion)." }) - .check(Schema.isInt()) - }).annotate({ - "description": - "Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`." + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the image generation item being processed." }), - Schema.Null -]) -export type RunStepDeltaStepDetailsToolCallsCodeObject = { - readonly "index": number - readonly "id"?: string - readonly "type": "code_interpreter" - readonly "code_interpreter"?: { - readonly "input"?: string - readonly "outputs"?: ReadonlyArray< - { readonly "index": number; readonly "type": "logs"; readonly "logs"?: string } | { - readonly "index": number - readonly "type": "image" - readonly "image"?: { readonly "file_id"?: string } - } - > - } + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of the image generation item being processed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "title": "ResponseImageGenCallGeneratingEvent", + "description": "Emitted when an image generation tool call is actively generating an image (intermediate state).\n", + "identifier": "ResponseImageGenCallGeneratingEvent" +}) +export type ResponseImageGenCallInProgressEvent = { + readonly "type": "response.image_generation_call.in_progress" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number } -export const RunStepDeltaStepDetailsToolCallsCodeObject = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the tool call in the tool calls array." }).check( - Schema.isInt() - ), - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the tool call." })), - "type": Schema.Literal("code_interpreter").annotate({ - "description": "The type of tool call. This is always going to be `code_interpreter` for this type of tool call." +export const ResponseImageGenCallInProgressEvent = Schema.Struct({ + "type": Schema.Literal("response.image_generation_call.in_progress").annotate({ + "description": "The type of the event. Always 'response.image_generation_call.in_progress'." }), - "code_interpreter": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey( - Schema.String.annotate({ "description": "The input to the Code Interpreter tool call." }) - ), - "outputs": Schema.optionalKey( - Schema.Array(Schema.Union([ - Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the output in the outputs array." }).check( - Schema.isInt() - ), - "type": Schema.Literal("logs").annotate({ "description": "Always `logs`." }), - "logs": Schema.optionalKey( - Schema.String.annotate({ "description": "The text output from the Code Interpreter tool call." }) - ) - }).annotate({ - "title": "Code interpreter log output", - "description": "Text output from the Code Interpreter tool call as part of a run step." - }), - Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the output in the outputs array." }).check( - Schema.isInt() - ), - "type": Schema.Literal("image").annotate({ "description": "Always `image`." }), - "image": Schema.optionalKey( - Schema.Struct({ - "file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The [file](/docs/api-reference/files) ID of the image." }) - ) - }) - ) - }).annotate({ "title": "Code interpreter image output" }) - ], { mode: "oneOf" })).annotate({ - "description": - "The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type." - }) - ) - }).annotate({ "description": "The Code Interpreter tool call definition." }) - ) + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the image generation item being processed." + }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of the image generation item being processed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) }).annotate({ - "title": "Code interpreter tool call", - "description": "Details of the Code Interpreter tool call the run step was involved in." + "title": "ResponseImageGenCallInProgressEvent", + "description": "Emitted when an image generation tool call is in progress.\n", + "identifier": "ResponseImageGenCallInProgressEvent" }) -export type RunStepDeltaStepDetailsToolCallsFileSearchObject = { - readonly "index": number - readonly "id"?: string - readonly "type": "file_search" - readonly "file_search": {} +export type ResponseImageGenCallPartialImageEvent = { + readonly "type": "response.image_generation_call.partial_image" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number + readonly "partial_image_index": number + readonly "partial_image_b64": string } -export const RunStepDeltaStepDetailsToolCallsFileSearchObject = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the tool call in the tool calls array." }).check( - Schema.isInt() - ), - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the tool call object." })), - "type": Schema.Literal("file_search").annotate({ - "description": "The type of tool call. This is always going to be `file_search` for this type of tool call." +export const ResponseImageGenCallPartialImageEvent = Schema.Struct({ + "type": Schema.Literal("response.image_generation_call.partial_image").annotate({ + "description": "The type of the event. Always 'response.image_generation_call.partial_image'." }), - "file_search": Schema.Struct({}).annotate({ "description": "For now, this is always going to be an empty object." }) -}).annotate({ "title": "File search tool call" }) -export type RunStepDeltaStepDetailsToolCallsFunctionObject = { - readonly "index": number - readonly "id"?: string - readonly "type": "function" - readonly "function"?: { readonly "name"?: string; readonly "arguments"?: string; readonly "output"?: string | null } + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the image generation item being processed." + }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of the image generation item being processed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "partial_image_index": Schema.Number.annotate({ + "description": "0-based index for the partial image (backend is 1-based, but this is 0-based for the user)." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "partial_image_b64": Schema.String.annotate({ + "description": "Base64-encoded partial image data, suitable for rendering as an image." + }) +}).annotate({ + "title": "ResponseImageGenCallPartialImageEvent", + "description": "Emitted when a partial image is available during image generation streaming.\n", + "identifier": "ResponseImageGenCallPartialImageEvent" +}) +export type ResponseMCPCallArgumentsDeltaEvent = { + readonly "type": "response.mcp_call_arguments.delta" + readonly "output_index": number + readonly "item_id": string + readonly "delta": string + readonly "sequence_number": number } -export const RunStepDeltaStepDetailsToolCallsFunctionObject = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the tool call in the tool calls array." }).check( - Schema.isInt() - ), - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the tool call object." })), - "type": Schema.Literal("function").annotate({ - "description": "The type of tool call. This is always going to be `function` for this type of tool call." +export const ResponseMCPCallArgumentsDeltaEvent = Schema.Struct({ + "type": Schema.Literal("response.mcp_call_arguments.delta").annotate({ + "description": "The type of the event. Always 'response.mcp_call_arguments.delta'." }), - "function": Schema.optionalKey( - Schema.Struct({ - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function." })), - "arguments": Schema.optionalKey( - Schema.String.annotate({ "description": "The arguments passed to the function." }) - ), - "output": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet." - }), - Schema.Null - ]) - ) - }).annotate({ "description": "The definition of the function that was called." }) + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the MCP tool call item being processed." + }), + "delta": Schema.String.annotate({ + "description": "A JSON string containing the partial update to the arguments for the MCP tool call.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "title": "Function tool call" }) -export type RunStepDetailsToolCallsCodeObject = { - readonly "id": string - readonly "type": "code_interpreter" - readonly "code_interpreter": { - readonly "input": string - readonly "outputs": ReadonlyArray< - { readonly "type": "logs"; readonly "logs": string } | { - readonly "type": "image" - readonly "image": { readonly "file_id": string } - } - > - } -} -export const RunStepDetailsToolCallsCodeObject = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The ID of the tool call." }), - "type": Schema.Literal("code_interpreter").annotate({ - "description": "The type of tool call. This is always going to be `code_interpreter` for this type of tool call." - }), - "code_interpreter": Schema.Struct({ - "input": Schema.String.annotate({ "description": "The input to the Code Interpreter tool call." }), - "outputs": Schema.Array( - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("logs").annotate({ "description": "Always `logs`." }), - "logs": Schema.String.annotate({ "description": "The text output from the Code Interpreter tool call." }) - }).annotate({ - "title": "Code Interpreter log output", - "description": "Text output from the Code Interpreter tool call as part of a run step." - }), - Schema.Struct({ - "type": Schema.Literal("image").annotate({ "description": "Always `image`." }), - "image": Schema.Struct({ - "file_id": Schema.String.annotate({ - "description": "The [file](/docs/api-reference/files) ID of the image." - }) - }) - }).annotate({ "title": "Code Interpreter image output" }) - ], { mode: "oneOf" }) - ).annotate({ - "description": - "The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type." - }) - }).annotate({ "description": "The Code Interpreter tool call definition." }) }).annotate({ - "title": "Code Interpreter tool call", - "description": "Details of the Code Interpreter tool call the run step was involved in." + "title": "ResponseMCPCallArgumentsDeltaEvent", + "description": "Emitted when there is a delta (partial update) to the arguments of an MCP tool call.\n", + "identifier": "ResponseMCPCallArgumentsDeltaEvent" }) -export type RunStepDetailsToolCallsFileSearchResultObject = { - readonly "file_id": string - readonly "file_name": string - readonly "score": number - readonly "content"?: ReadonlyArray<{ readonly "type"?: "text"; readonly "text"?: string }> -} -export const RunStepDetailsToolCallsFileSearchResultObject = Schema.Struct({ - "file_id": Schema.String.annotate({ "description": "The ID of the file that result was found in." }), - "file_name": Schema.String.annotate({ "description": "The name of the file that result was found in." }), - "score": Schema.Number.annotate({ - "description": "The score of the result. All values must be a floating point number between 0 and 1." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)), - "content": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "type": Schema.optionalKey(Schema.Literal("text").annotate({ "description": "The type of the content." })), - "text": Schema.optionalKey(Schema.String.annotate({ "description": "The text content of the file." })) - }) - ).annotate({ - "description": - "The content of the result that was found. The content is only included if requested via the include query parameter." - }) - ) -}).annotate({ "title": "File search tool call result", "description": "A result instance of the file search." }) -export type RunStepDetailsToolCallsFunctionObject = { - readonly "id": string - readonly "type": "function" - readonly "function": { readonly "name": string; readonly "arguments": string; readonly "output": string | null } -} -export const RunStepDetailsToolCallsFunctionObject = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The ID of the tool call object." }), - "type": Schema.Literal("function").annotate({ - "description": "The type of tool call. This is always going to be `function` for this type of tool call." - }), - "function": Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the function." }), - "arguments": Schema.String.annotate({ "description": "The arguments passed to the function." }), - "output": Schema.Union([ - Schema.String.annotate({ - "description": - "The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet." - }), - Schema.Null - ]) - }).annotate({ "description": "The definition of the function that was called." }) -}).annotate({ "title": "Function tool call" }) -export type RunToolCallObject = { - readonly "id": string - readonly "type": "function" - readonly "function": { readonly "name": string; readonly "arguments": string } +export type ResponseMCPCallArgumentsDoneEvent = { + readonly "type": "response.mcp_call_arguments.done" + readonly "output_index": number + readonly "item_id": string + readonly "arguments": string + readonly "sequence_number": number } -export const RunToolCallObject = Schema.Struct({ - "id": Schema.String.annotate({ - "description": - "The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint." - }), - "type": Schema.Literal("function").annotate({ - "description": "The type of tool call the output is required for. For now, this is always `function`." +export const ResponseMCPCallArgumentsDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.mcp_call_arguments.done").annotate({ + "description": "The type of the event. Always 'response.mcp_call_arguments.done'." }), - "function": Schema.Struct({ - "name": Schema.String.annotate({ "description": "The name of the function." }), - "arguments": Schema.String.annotate({ - "description": "The arguments that the model expects you to pass to the function." - }) - }).annotate({ "description": "The function definition." }) -}).annotate({ "description": "Tool call objects" }) -export type ServiceTier = "auto" | "default" | "flex" | "scale" | "priority" | null -export const ServiceTier = Schema.Union([ - Schema.Literals(["auto", "default", "flex", "scale", "priority"]).annotate({ - "description": - "Specifies the processing type used for serving the request.\n - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.\n - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.\n - If set to '[flex](/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.\n - When not set, the default behavior is 'auto'.\n\n When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.\n" + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the MCP tool call item being processed." }), - Schema.Null -]) -export type SpeechAudioDeltaEvent = { readonly "type": "speech.audio.delta"; readonly "audio": string } -export const SpeechAudioDeltaEvent = Schema.Struct({ - "type": Schema.Literal("speech.audio.delta").annotate({ - "description": "The type of the event. Always `speech.audio.delta`.\n" + "arguments": Schema.String.annotate({ + "description": "A JSON string containing the finalized arguments for the MCP tool call.\n" }), - "audio": Schema.String.annotate({ "description": "A chunk of Base64-encoded audio data.\n" }) -}).annotate({ "description": "Emitted for each chunk of audio data generated during speech synthesis." }) -export type SpeechAudioDoneEvent = { - readonly "type": "speech.audio.done" - readonly "usage": { - readonly "input_tokens": number - readonly "output_tokens": number - readonly "total_tokens": number - } + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "ResponseMCPCallArgumentsDoneEvent", + "description": "Emitted when the arguments for an MCP tool call are finalized.\n", + "identifier": "ResponseMCPCallArgumentsDoneEvent" +}) +export type ResponseMCPCallCompletedEvent = { + readonly "type": "response.mcp_call.completed" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number } -export const SpeechAudioDoneEvent = Schema.Struct({ - "type": Schema.Literal("speech.audio.done").annotate({ - "description": "The type of the event. Always `speech.audio.done`.\n" +export const ResponseMCPCallCompletedEvent = Schema.Struct({ + "type": Schema.Literal("response.mcp_call.completed").annotate({ + "description": "The type of the event. Always 'response.mcp_call.completed'." }), - "usage": Schema.Struct({ - "input_tokens": Schema.Number.annotate({ "description": "Number of input tokens in the prompt." }).check( - Schema.isInt() - ), - "output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check( - Schema.isInt() - ), - "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check( - Schema.isInt() - ) - }).annotate({ "description": "Token usage statistics for the request.\n" }) -}).annotate({ "description": "Emitted when the speech synthesis is complete and all audio has been streamed." }) -export type StaticChunkingStrategy = { - readonly "max_chunk_size_tokens": number - readonly "chunk_overlap_tokens": number -} -export const StaticChunkingStrategy = Schema.Struct({ - "max_chunk_size_tokens": Schema.Number.annotate({ - "description": - "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(100)).check(Schema.isLessThanOrEqualTo(4096)), - "chunk_overlap_tokens": Schema.Number.annotate({ - "description": - "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" - }).check(Schema.isInt()) + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that completed." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that completed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "ResponseMCPCallCompletedEvent", + "description": "Emitted when an MCP tool call has completed successfully.\n", + "identifier": "ResponseMCPCallCompletedEvent" }) -export type StopConfiguration = string | null | ReadonlyArray | null -export const StopConfiguration = Schema.Union([ - Schema.Union([ - Schema.Union([Schema.String, Schema.Null]), - Schema.Array(Schema.String).check(Schema.isMinLength(1)).check(Schema.isMaxLength(4)) - ], { mode: "oneOf" }).annotate({ - "description": - "Not supported with latest reasoning models `o3` and `o4-mini`.\n\nUp to 4 sequences where the API will stop generating further tokens. The\nreturned text will not contain the stop sequence.\n" - }), - Schema.Null -]) -export type SubmitToolOutputsRunRequest = { - readonly "tool_outputs": ReadonlyArray<{ readonly "tool_call_id"?: string; readonly "output"?: string }> - readonly "stream"?: boolean | null +export type ResponseMCPCallFailedEvent = { + readonly "type": "response.mcp_call.failed" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number } -export const SubmitToolOutputsRunRequest = Schema.Struct({ - "tool_outputs": Schema.Array(Schema.Struct({ - "tool_call_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The ID of the tool call in the `required_action` object within the run object the output is being submitted for." - }) - ), - "output": Schema.optionalKey( - Schema.String.annotate({ "description": "The output of the tool call to be submitted to continue the run." }) - ) - })).annotate({ "description": "A list of tools for which the outputs are being submitted." }), - "stream": Schema.optionalKey( - Schema.Union([ - Schema.Boolean.annotate({ - "description": - "If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.\n" - }), - Schema.Null - ]) +export const ResponseMCPCallFailedEvent = Schema.Struct({ + "type": Schema.Literal("response.mcp_call.failed").annotate({ + "description": "The type of the event. Always 'response.mcp_call.failed'." + }), + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that failed." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that failed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) +}).annotate({ + "title": "ResponseMCPCallFailedEvent", + "description": "Emitted when an MCP tool call has failed.\n", + "identifier": "ResponseMCPCallFailedEvent" }) -export type ToggleCertificatesRequest = { readonly "certificate_ids": ReadonlyArray } -export const ToggleCertificatesRequest = Schema.Struct({ - "certificate_ids": Schema.Array(Schema.String).check(Schema.isMinLength(1)).check(Schema.isMaxLength(10)) -}) -export type ToolChoiceAllowed = { - readonly "type": "allowed_tools" - readonly "mode": "auto" | "required" - readonly "tools": ReadonlyArray<{}> +export type ResponseMCPCallInProgressEvent = { + readonly "type": "response.mcp_call.in_progress" + readonly "sequence_number": number + readonly "output_index": number + readonly "item_id": string } -export const ToolChoiceAllowed = Schema.Struct({ - "type": Schema.Literal("allowed_tools").annotate({ - "description": "Allowed tool configuration type. Always `allowed_tools`." - }), - "mode": Schema.Literals(["auto", "required"]).annotate({ - "description": - "Constrains the tools available to the model to a pre-defined set.\n\n`auto` allows the model to pick from among the allowed tools and generate a\nmessage.\n\n`required` requires the model to call one or more of the allowed tools.\n" +export const ResponseMCPCallInProgressEvent = Schema.Struct({ + "type": Schema.Literal("response.mcp_call.in_progress").annotate({ + "description": "The type of the event. Always 'response.mcp_call.in_progress'." }), - "tools": Schema.Array( - Schema.Struct({}).annotate({ "description": "A tool definition that the model should be allowed to call.\n" }) - ).annotate({ - "description": - "A list of tool definitions that the model should be allowed to call.\n\nFor the Responses API, the list of tool definitions might look like:\n```json\n[\n { \"type\": \"function\", \"name\": \"get_weather\" },\n { \"type\": \"mcp\", \"server_label\": \"deepwiki\" },\n { \"type\": \"image_generation\" }\n]\n```\n" + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the MCP tool call item being processed." }) }).annotate({ - "title": "Allowed tools", - "description": "Constrains the tools available to the model to a pre-defined set.\n" + "title": "ResponseMCPCallInProgressEvent", + "description": "Emitted when an MCP tool call is in progress.\n", + "identifier": "ResponseMCPCallInProgressEvent" }) -export type ToolChoiceCustom = { readonly "type": "custom"; readonly "name": string } -export const ToolChoiceCustom = Schema.Struct({ - "type": Schema.Literal("custom").annotate({ "description": "For custom tool calling, the type is always `custom`." }), - "name": Schema.String.annotate({ "description": "The name of the custom tool to call." }) +export type ResponseMCPListToolsCompletedEvent = { + readonly "type": "response.mcp_list_tools.completed" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number +} +export const ResponseMCPListToolsCompletedEvent = Schema.Struct({ + "type": Schema.Literal("response.mcp_list_tools.completed").annotate({ + "description": "The type of the event. Always 'response.mcp_list_tools.completed'." + }), + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that produced this output." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that was processed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) }).annotate({ - "title": "Custom tool", - "description": "Use this option to force the model to call a specific custom tool.\n" + "title": "ResponseMCPListToolsCompletedEvent", + "description": "Emitted when the list of available MCP tools has been successfully retrieved.\n", + "identifier": "ResponseMCPListToolsCompletedEvent" }) -export type ToolChoiceFunction = { readonly "type": "function"; readonly "name": string } -export const ToolChoiceFunction = Schema.Struct({ - "type": Schema.Literal("function").annotate({ - "description": "For function calling, the type is always `function`." +export type ResponseMCPListToolsFailedEvent = { + readonly "type": "response.mcp_list_tools.failed" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number +} +export const ResponseMCPListToolsFailedEvent = Schema.Struct({ + "type": Schema.Literal("response.mcp_list_tools.failed").annotate({ + "description": "The type of the event. Always 'response.mcp_list_tools.failed'." }), - "name": Schema.String.annotate({ "description": "The name of the function to call." }) + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that failed." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that failed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) }).annotate({ - "title": "Function tool", - "description": "Use this option to force the model to call a specific function.\n" + "title": "ResponseMCPListToolsFailedEvent", + "description": "Emitted when the attempt to list available MCP tools has failed.\n", + "identifier": "ResponseMCPListToolsFailedEvent" }) -export type ToolChoiceMCP = { readonly "type": "mcp"; readonly "server_label": string; readonly "name"?: string | null } -export const ToolChoiceMCP = Schema.Struct({ - "type": Schema.Literal("mcp").annotate({ "description": "For MCP tools, the type is always `mcp`." }), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server to use.\n" }), - "name": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The name of the tool to call on the server.\n" }), - Schema.Null - ]) +export type ResponseMCPListToolsInProgressEvent = { + readonly "type": "response.mcp_list_tools.in_progress" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number +} +export const ResponseMCPListToolsInProgressEvent = Schema.Struct({ + "type": Schema.Literal("response.mcp_list_tools.in_progress").annotate({ + "description": "The type of the event. Always 'response.mcp_list_tools.in_progress'." + }), + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that is being processed." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that is being processed." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) }).annotate({ - "title": "MCP tool", - "description": "Use this option to force the model to call a specific tool on a remote MCP server.\n" -}) -export type ToolChoiceOptions = "none" | "auto" | "required" -export const ToolChoiceOptions = Schema.Literals(["none", "auto", "required"]).annotate({ - "title": "Tool choice mode", - "description": - "Controls which (if any) tool is called by the model.\n\n`none` means the model will not call any tool and instead generates a message.\n\n`auto` means the model can pick between generating a message or calling one or\nmore tools.\n\n`required` means the model must call one or more tools.\n" + "title": "ResponseMCPListToolsInProgressEvent", + "description": "Emitted when the system is in the process of retrieving the list of available MCP tools.\n", + "identifier": "ResponseMCPListToolsInProgressEvent" }) -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" +export type ResponseOutputTextAnnotationAddedEvent = { + readonly "type": "response.output_text.annotation.added" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "annotation_index": number + readonly "sequence_number": number + readonly "annotation": {} } -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`\n- `computer_use_preview`\n- `computer_use`\n- `code_interpreter`\n- `image_generation`\n" +export const ResponseOutputTextAnnotationAddedEvent = Schema.Struct({ + "type": Schema.Literal("response.output_text.annotation.added").annotate({ + "description": "The type of the event. Always 'response.output_text.annotation.added'." + }), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the item to which the annotation is being added." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ "description": "The index of the content part within the output item." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "annotation_index": Schema.Number.annotate({ "description": "The index of the annotation within the content part." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "annotation": Schema.Struct({}).annotate({ + "description": "The annotation object being added. (See annotation schema for details.)" }) }).annotate({ - "title": "Hosted tool", - "description": - "Indicates that the model should use a built-in tool to generate a response.\n[Learn more about built-in tools](/docs/guides/tools).\n" + "title": "ResponseOutputTextAnnotationAddedEvent", + "description": "Emitted when an annotation is added to output text content.\n", + "identifier": "ResponseOutputTextAnnotationAddedEvent" }) -export type TranscriptTextDeltaEvent = { - readonly "type": "transcript.text.delta" +export type ResponseCustomToolCallInputDeltaEvent = { + readonly "type": "response.custom_tool_call_input.delta" + readonly "sequence_number": number + readonly "output_index": number + readonly "item_id": string readonly "delta": string - readonly "logprobs"?: ReadonlyArray< - { readonly "token"?: string; readonly "logprob"?: number; readonly "bytes"?: ReadonlyArray } - > - readonly "segment_id"?: string } -export const TranscriptTextDeltaEvent = Schema.Struct({ - "type": Schema.Literal("transcript.text.delta").annotate({ - "description": "The type of the event. Always `transcript.text.delta`.\n" +export const ResponseCustomToolCallInputDeltaEvent = Schema.Struct({ + "type": Schema.Literal("response.custom_tool_call_input.delta").annotate({ + "description": "The event type identifier." }), - "delta": Schema.String.annotate({ "description": "The text delta that was additionally transcribed.\n" }), - "logprobs": Schema.optionalKey( - Schema.Array(Schema.Struct({ - "token": Schema.optionalKey( - Schema.String.annotate({ "description": "The token that was used to generate the log probability.\n" }) - ), - "logprob": Schema.optionalKey( - Schema.Number.annotate({ "description": "The log probability of the token.\n" }).check(Schema.isFinite()) - ), - "bytes": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "description": "The bytes that were used to generate the log probability.\n" - }) - ) - })).annotate({ - "description": - "The log probabilities of the delta. Only included if you [create a transcription](/docs/api-reference/audio/create-transcription) with the `include[]` parameter set to `logprobs`.\n" - }) + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "segment_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Identifier of the diarized segment that this delta belongs to. Only present when using `gpt-4o-transcribe-diarize`.\n" - }) - ) + "output_index": Schema.Number.annotate({ "description": "The index of the output this delta applies to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "item_id": Schema.String.annotate({ + "description": "Unique identifier for the API item associated with this event." + }), + "delta": Schema.String.annotate({ "description": "The incremental input data (delta) for the custom tool call." }) }).annotate({ - "description": - "Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`." + "title": "ResponseCustomToolCallInputDelta", + "description": "Event representing a delta (partial update) to the input of a custom tool call.\n", + "identifier": "ResponseCustomToolCallInputDeltaEvent" }) -export type TranscriptTextSegmentEvent = { - readonly "type": "transcript.text.segment" - readonly "id": string - readonly "start": number - readonly "end": number - readonly "text": string - readonly "speaker": string +export type ResponseCustomToolCallInputDoneEvent = { + readonly "type": "response.custom_tool_call_input.done" + readonly "sequence_number": number + readonly "output_index": number + readonly "item_id": string + readonly "input": string } -export const TranscriptTextSegmentEvent = Schema.Struct({ - "type": Schema.Literal("transcript.text.segment").annotate({ - "description": "The type of the event. Always `transcript.text.segment`." +export const ResponseCustomToolCallInputDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.custom_tool_call_input.done").annotate({ + "description": "The event type identifier." }), - "id": Schema.String.annotate({ "description": "Unique identifier for the segment." }), - "start": Schema.Number.annotate({ "description": "Start timestamp of the segment in seconds.", "format": "double" }) - .check(Schema.isFinite()), - "end": Schema.Number.annotate({ "description": "End timestamp of the segment in seconds.", "format": "double" }) - .check(Schema.isFinite()), - "text": Schema.String.annotate({ "description": "Transcript text for this segment." }), - "speaker": Schema.String.annotate({ "description": "Speaker label for this segment." }) + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "output_index": Schema.Number.annotate({ "description": "The index of the output this event applies to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "item_id": Schema.String.annotate({ + "description": "Unique identifier for the API item associated with this event." + }), + "input": Schema.String.annotate({ "description": "The complete input data for the custom tool call." }) }).annotate({ - "description": - "Emitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you [create a transcription](/docs/api-reference/audio/create-transcription) with `stream` set to `true` and `response_format` set to `diarized_json`.\n" + "title": "ResponseCustomToolCallInputDone", + "description": "Event indicating that input for a custom tool call is complete.\n", + "identifier": "ResponseCustomToolCallInputDoneEvent" }) -export type TranscriptTextUsageDuration = { readonly "type": "duration"; readonly "seconds": number } -export const TranscriptTextUsageDuration = Schema.Struct({ - "type": Schema.Literal("duration").annotate({ - "description": "The type of the usage object. Always `duration` for this variant." +export type ResponseKeepAliveEvent = { readonly "type": "keepalive"; readonly "sequence_number": number } +export const ResponseKeepAliveEvent = Schema.Struct({ + "type": Schema.Literal("keepalive").annotate({ + "description": "The type of the keepalive event. Always `keepalive`." }), - "seconds": Schema.Number.annotate({ "description": "Duration of the input audio in seconds.", "format": "double" }) - .check(Schema.isFinite()) -}).annotate({ "title": "Duration Usage", "description": "Usage statistics for models billed by audio input duration." }) -export type TranscriptTextUsageTokens = { - readonly "type": "tokens" - readonly "input_tokens": number - readonly "input_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number } - readonly "output_tokens": number - readonly "total_tokens": number + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this keepalive event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "Keep alive", + "description": "A keepalive event emitted during long-running response streams.", + "identifier": "ResponseKeepAliveEvent" +}) +export type ResponseApplyPatchCallOperationDiffDeltaEvent = { + readonly "type": "response.apply_patch_call_operation_diff.delta" + readonly "sequence_number": number + readonly "output_index": number + readonly "item_id": string + readonly "delta": string } -export const TranscriptTextUsageTokens = Schema.Struct({ - "type": Schema.Literal("tokens").annotate({ - "description": "The type of the usage object. Always `tokens` for this variant." +export const ResponseApplyPatchCallOperationDiffDeltaEvent = Schema.Struct({ + "type": Schema.Literal("response.apply_patch_call_operation_diff.delta").annotate({ + "description": "The event type identifier." }), - "input_tokens": Schema.Number.annotate({ "description": "Number of input tokens billed for this request." }).check( - Schema.isInt() - ), - "input_token_details": Schema.optionalKey( - Schema.Struct({ - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of text tokens billed for this request." }).check( - Schema.isInt() - ) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of audio tokens billed for this request." }).check( - Schema.isInt() - ) - ) - }).annotate({ "description": "Details about the input tokens billed for this request." }) + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check( - Schema.isInt() + "output_index": Schema.Number.annotate({ "description": "The index of the output this delta applies to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check( - Schema.isInt() - ) -}).annotate({ "title": "Token Usage", "description": "Usage statistics for models billed by token usage." }) -export type TranscriptionDiarizedSegment = { - readonly "type": "transcript.text.segment" - readonly "id": string - readonly "start": number - readonly "end": number - readonly "text": string - readonly "speaker": string -} -export const TranscriptionDiarizedSegment = Schema.Struct({ - "type": Schema.Literal("transcript.text.segment").annotate({ - "description": "The type of the segment. Always `transcript.text.segment`.\n" + "item_id": Schema.String.annotate({ + "description": "Unique identifier for the API item associated with this event." }), - "id": Schema.String.annotate({ "description": "Unique identifier for the segment." }), - "start": Schema.Number.annotate({ "description": "Start timestamp of the segment in seconds.", "format": "double" }) - .check(Schema.isFinite()), - "end": Schema.Number.annotate({ "description": "End timestamp of the segment in seconds.", "format": "double" }) - .check(Schema.isFinite()), - "text": Schema.String.annotate({ "description": "Transcript text for this segment." }), - "speaker": Schema.String.annotate({ - "description": - "Speaker label for this segment. When known speakers are provided, the label matches `known_speaker_names[]`. Otherwise speakers are labeled sequentially using capital letters (`A`, `B`, ...).\n" - }) -}).annotate({ "description": "A segment of diarized transcript text with speaker metadata." }) -export type TranscriptionInclude = "logprobs" -export const TranscriptionInclude = Schema.Literal("logprobs") -export type TranscriptionSegment = { - readonly "id": number - readonly "seek": number - readonly "start": number - readonly "end": number - readonly "text": string - readonly "tokens": ReadonlyArray - readonly "temperature": number - readonly "avg_logprob": number - readonly "compression_ratio": number - readonly "no_speech_prob": number + "delta": Schema.String.annotate({ "description": "The incremental diff data for the apply_patch tool call." }) +}).annotate({ + "title": "ResponseApplyPatchCallOperationDiffDelta", + "description": "Event representing a delta for an apply_patch tool call operation diff.", + "identifier": "ResponseApplyPatchCallOperationDiffDeltaEvent" +}) +export type ResponseApplyPatchCallOperationDiffDoneEvent = { + readonly "type": "response.apply_patch_call_operation_diff.done" + readonly "sequence_number": number + readonly "output_index": number + readonly "item_id": string + readonly "delta"?: string } -export const TranscriptionSegment = Schema.Struct({ - "id": Schema.Number.annotate({ "description": "Unique identifier of the segment." }).check(Schema.isInt()), - "seek": Schema.Number.annotate({ "description": "Seek offset of the segment." }).check(Schema.isInt()), - "start": Schema.Number.annotate({ "description": "Start time of the segment in seconds.", "format": "double" }).check( - Schema.isFinite() +export const ResponseApplyPatchCallOperationDiffDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.apply_patch_call_operation_diff.done").annotate({ + "description": "The event type identifier." + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "end": Schema.Number.annotate({ "description": "End time of the segment in seconds.", "format": "double" }).check( - Schema.isFinite() + "output_index": Schema.Number.annotate({ "description": "The index of the output this event applies to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "text": Schema.String.annotate({ "description": "Text content of the segment." }), - "tokens": Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "description": "Array of token IDs for the text content." + "item_id": Schema.String.annotate({ + "description": "Unique identifier for the API item associated with this event." }), - "temperature": Schema.Number.annotate({ - "description": "Temperature parameter used for generating the segment.", - "format": "float" - }).check(Schema.isFinite()), - "avg_logprob": Schema.Number.annotate({ - "description": "Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.", - "format": "float" - }).check(Schema.isFinite()), - "compression_ratio": Schema.Number.annotate({ - "description": - "Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.", - "format": "float" - }).check(Schema.isFinite()), - "no_speech_prob": Schema.Number.annotate({ - "description": - "Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.", - "format": "float" - }).check(Schema.isFinite()) -}) -export type TranscriptionWord = { readonly "word": string; readonly "start": number; readonly "end": number } -export const TranscriptionWord = Schema.Struct({ - "word": Schema.String.annotate({ "description": "The text content of the word." }), - "start": Schema.Number.annotate({ "description": "Start time of the word in seconds.", "format": "double" }).check( - Schema.isFinite() - ), - "end": Schema.Number.annotate({ "description": "End time of the word in seconds.", "format": "double" }).check( - Schema.isFinite() + "delta": Schema.optionalKey( + Schema.String.annotate({ "description": "The final diff data for the apply_patch tool call." }) ) +}).annotate({ + "title": "ResponseApplyPatchCallOperationDiffDone", + "description": "Event indicating that the operation diff for an apply_patch tool call is complete.", + "identifier": "ResponseApplyPatchCallOperationDiffDoneEvent" }) -export type UpdateGroupBody = { readonly "name": string } -export const UpdateGroupBody = Schema.Struct({ - "name": Schema.String.annotate({ "description": "New display name for the group." }).check(Schema.isMinLength(1)) - .check(Schema.isMaxLength(255)) -}).annotate({ "description": "Request payload for updating the details of an existing group." }) -export type UpdateVoiceConsentRequest = { readonly "name": string } -export const UpdateVoiceConsentRequest = Schema.Struct({ - "name": Schema.String.annotate({ "description": "The updated label for this consent recording." }) +export type MessageContentImageFileObject = { + readonly "type": "image_file" + readonly "image_file": { readonly "file_id": string; readonly "detail"?: "auto" | "low" | "high" } +} +export const MessageContentImageFileObject = Schema.Struct({ + "type": Schema.Literal("image_file").annotate({ "description": "Always `image_file`." }), + "image_file": Schema.Struct({ + "file_id": Schema.String.annotate({ + "description": + "The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose=\"vision\"` when uploading the File if you need to later display the file content." + }), + "detail": Schema.optionalKey( + Schema.Literals(["auto", "low", "high"]).annotate({ + "description": + "Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`." + }) + ) + }) +}).annotate({ + "title": "Image file", + "description": "References an image [File](/docs/api-reference/files) in the content of a message.", + "identifier": "MessageContentImageFileObject" }) -export type Upload = { +export type MessageContentImageUrlObject = { + readonly "type": "image_url" + readonly "image_url": { readonly "url": string; readonly "detail"?: "auto" | "low" | "high" } +} +export const MessageContentImageUrlObject = Schema.Struct({ + "type": Schema.Literal("image_url").annotate({ "description": "The type of the content part." }), + "image_url": Schema.Struct({ + "url": Schema.String.annotate({ + "description": "The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.", + "format": "uri" + }), + "detail": Schema.optionalKey( + Schema.Literals(["auto", "low", "high"]).annotate({ + "description": + "Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`" + }) + ) + }) +}).annotate({ + "title": "Image URL", + "description": "References an image URL in the content of a message.", + "identifier": "MessageContentImageUrlObject" +}) +export type MessageRequestContentTextObject = { readonly "type": "text"; readonly "text": string } +export const MessageRequestContentTextObject = Schema.Struct({ + "type": Schema.Literal("text").annotate({ "description": "Always `text`." }), + "text": Schema.String.annotate({ "description": "Text content to be sent to the model" }) +}).annotate({ + "title": "Text", + "description": "The text content that is part of a message.", + "identifier": "MessageRequestContentTextObject" +}) +export type AssistantToolsFileSearchTypeOnly = { readonly "type": "file_search" } +export const AssistantToolsFileSearchTypeOnly = Schema.Struct({ + "type": Schema.Literal("file_search").annotate({ "description": "The type of tool being defined: `file_search`" }) +}).annotate({ "title": "FileSearch tool", "identifier": "AssistantToolsFileSearchTypeOnly" }) +export type RunToolCallObject = { readonly "id": string - readonly "created_at": number - readonly "filename": string - readonly "bytes": number - readonly "purpose": string - readonly "status": "pending" | "completed" | "cancelled" | "expired" - readonly "expires_at": number - readonly "object"?: "upload" - readonly "file"?: { - readonly "id": string - readonly "bytes": number - readonly "created_at": number - readonly "expires_at"?: number | null - readonly "filename": string - readonly "object": "file" - readonly "purpose": - | "assistants" - | "assistants_output" - | "batch" - | "batch_output" - | "fine-tune" - | "fine-tune-results" - | "vision" - | "user_data" - readonly "status": "uploaded" | "processed" | "error" - readonly "status_details"?: string | null - readonly [x: string]: unknown - } + readonly "type": "function" + readonly "function": { readonly "name": string; readonly "arguments": string } } -export const Upload = Schema.Struct({ +export const RunToolCallObject = Schema.Struct({ "id": Schema.String.annotate({ - "description": "The Upload unique identifier, which can be referenced in API endpoints." - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the Upload was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "filename": Schema.String.annotate({ "description": "The name of the file to be uploaded." }), - "bytes": Schema.Number.annotate({ "description": "The intended number of bytes to be uploaded." }).check( - Schema.isInt() - ), - "purpose": Schema.String.annotate({ "description": - "The intended purpose of the file. [Please refer here](/docs/api-reference/files/object#files/object-purpose) for acceptable values." + "The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint." }), - "status": Schema.Literals(["pending", "completed", "cancelled", "expired"]).annotate({ - "description": "The status of the Upload." + "type": Schema.Literal("function").annotate({ + "description": "The type of tool call the output is required for. For now, this is always `function`." }), - "expires_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the Upload will expire.", - "format": "unixtime" - }).check(Schema.isInt()), - "object": Schema.optionalKey( - Schema.Literal("upload").annotate({ "description": "The object type, which is always \"upload\"." }) - ), - "file": Schema.optionalKey(Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The file identifier, which can be referenced in the API endpoints." - }), - "bytes": Schema.Number.annotate({ "description": "The size of the file, in bytes." }).check(Schema.isInt()), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the file was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "expires_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the file will expire.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]) - ), - "filename": Schema.String.annotate({ "description": "The name of the file." }), - "object": Schema.Literal("file").annotate({ "description": "The object type, which is always `file`." }), - "purpose": Schema.Literals([ - "assistants", - "assistants_output", - "batch", - "batch_output", - "fine-tune", - "fine-tune-results", - "vision", - "user_data" - ]).annotate({ - "description": - "The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`." - }), - "status": Schema.Literals(["uploaded", "processed", "error"]).annotate({ - "description": - "Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`." - }), - "status_details": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`." - }) - ) - }), - [Schema.Record(Schema.String, Schema.Json)] - ).annotate({ - "description": "The `File` object represents a document that has been uploaded to OpenAI.", - "title": "OpenAIFile" + "function": Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the function." }), + "arguments": Schema.String.annotate({ + "description": "The arguments that the model expects you to pass to the function." }) - ])) -}).annotate({ "title": "Upload", "description": "The Upload object can accept byte chunks in the form of Parts.\n" }) -export type UploadCertificateRequest = { readonly "name"?: string; readonly "certificate": string } -export const UploadCertificateRequest = Schema.Struct({ - "name": Schema.optionalKey(Schema.String.annotate({ "description": "An optional name for the certificate" })), - "certificate": Schema.String.annotate({ "description": "The certificate content in PEM format" }) -}) -export type UploadPart = { + }).annotate({ "description": "The function definition." }) +}).annotate({ "description": "Tool call objects", "identifier": "RunToolCallObject" }) +export type RunCompletionUsage = { + readonly "completion_tokens": number + readonly "prompt_tokens": number + readonly "total_tokens": number +} | null +export const RunCompletionUsage = Schema.Union([ + Schema.Struct({ + "completion_tokens": Schema.Number.annotate({ + "description": "Number of completion tokens used over the course of the run." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "prompt_tokens": Schema.Number.annotate({ + "description": "Number of prompt tokens used over the course of the run." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (prompt + completion)." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + }).annotate({ + "description": + "Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.)." + }), + Schema.Null +]).annotate({ "identifier": "RunCompletionUsage" }) +export type DeleteThreadResponse = { readonly "id": string - readonly "created_at": number - readonly "upload_id": string - readonly "object": "upload.part" + readonly "deleted": boolean + readonly "object": "thread.deleted" } -export const UploadPart = Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The upload Part unique identifier, which can be referenced in API endpoints." +export const DeleteThreadResponse = Schema.Struct({ + "id": Schema.String, + "deleted": Schema.Boolean, + "object": Schema.Literal("thread.deleted") +}).annotate({ "identifier": "DeleteThreadResponse" }) +export type MessageContentTextAnnotationsFileCitationObject = { + readonly "type": "file_citation" + readonly "text": string + readonly "file_citation": { readonly "file_id": string } + readonly "start_index": number + readonly "end_index": number +} +export const MessageContentTextAnnotationsFileCitationObject = Schema.Struct({ + "type": Schema.Literal("file_citation").annotate({ "description": "Always `file_citation`." }), + "text": Schema.String.annotate({ "description": "The text in the message content that needs to be replaced." }), + "file_citation": Schema.Struct({ + "file_id": Schema.String.annotate({ "description": "The ID of the specific File the citation is from." }) }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the Part was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "upload_id": Schema.String.annotate({ "description": "The ID of the Upload object that this Part was added to." }), - "object": Schema.Literal("upload.part").annotate({ "description": "The object type, which is always `upload.part`." }) + "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) }).annotate({ - "title": "UploadPart", - "description": "The upload Part represents a chunk of bytes we can add to an Upload object.\n" + "title": "File citation", + "description": + "A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the \"file_search\" tool to search files.", + "identifier": "MessageContentTextAnnotationsFileCitationObject" }) -export type UsageAudioSpeechesResult = { - readonly "object": "organization.usage.audio_speeches.result" - readonly "characters": number - readonly "num_model_requests": number - readonly "project_id"?: string | null - readonly "user_id"?: string | null - readonly "api_key_id"?: string | null - readonly "model"?: string | null +export type MessageContentTextAnnotationsFilePathObject = { + readonly "type": "file_path" + readonly "text": string + readonly "file_path": { readonly "file_id": string } + readonly "start_index": number + readonly "end_index": number } -export const UsageAudioSpeechesResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.audio_speeches.result"), - "characters": Schema.Number.annotate({ "description": "The number of characters processed." }).check(Schema.isInt()), - "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( - Schema.isInt() - ), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "user_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "api_key_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." - }), - Schema.Null - ]) +export const MessageContentTextAnnotationsFilePathObject = Schema.Struct({ + "type": Schema.Literal("file_path").annotate({ "description": "Always `file_path`." }), + "text": Schema.String.annotate({ "description": "The text in the message content that needs to be replaced." }), + "file_path": Schema.Struct({ + "file_id": Schema.String.annotate({ "description": "The ID of the file that was generated." }) + }), + "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=model`, this field provides the model name of the grouped usage result." - }), - Schema.Null - ]) + "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ) -}).annotate({ "description": "The aggregated audio speeches usage details of the specific time bucket." }) -export type UsageAudioTranscriptionsResult = { - readonly "object": "organization.usage.audio_transcriptions.result" - readonly "seconds": number - readonly "num_model_requests": number - readonly "project_id"?: string | null - readonly "user_id"?: string | null - readonly "api_key_id"?: string | null - readonly "model"?: string | null +}).annotate({ + "title": "File path", + "description": + "A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.", + "identifier": "MessageContentTextAnnotationsFilePathObject" +}) +export type MessageContentRefusalObject = { readonly "type": "refusal"; readonly "refusal": string } +export const MessageContentRefusalObject = Schema.Struct({ + "type": Schema.Literal("refusal").annotate({ "description": "Always `refusal`." }), + "refusal": Schema.String +}).annotate({ + "title": "Refusal", + "description": "The refusal content generated by the assistant.", + "identifier": "MessageContentRefusalObject" +}) +export type DeleteMessageResponse = { + readonly "id": string + readonly "deleted": boolean + readonly "object": "thread.message.deleted" } -export const UsageAudioTranscriptionsResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.audio_transcriptions.result"), - "seconds": Schema.Number.annotate({ "description": "The number of seconds processed.", "format": "int64" }).check( - Schema.isInt() - ), - "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( - Schema.isInt() - ), - "project_id": Schema.optionalKey( - Schema.Union([ +export const DeleteMessageResponse = Schema.Struct({ + "id": Schema.String, + "deleted": Schema.Boolean, + "object": Schema.Literal("thread.message.deleted") +}).annotate({ "identifier": "DeleteMessageResponse" }) +export type RunStepDetailsToolCallsCodeObject = { + readonly "id": string + readonly "type": "code_interpreter" + readonly "code_interpreter": { + readonly "input": string + readonly "outputs": ReadonlyArray< + { readonly "type": "logs"; readonly "logs": string } | { + readonly "type": "image" + readonly "image": { readonly "file_id": string } + } + > + } +} +export const RunStepDetailsToolCallsCodeObject = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The ID of the tool call." }), + "type": Schema.Literal("code_interpreter").annotate({ + "description": "The type of tool call. This is always going to be `code_interpreter` for this type of tool call." + }), + "code_interpreter": Schema.Struct({ + "input": Schema.String.annotate({ "description": "The input to the Code Interpreter tool call." }), + "outputs": Schema.Array( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("logs").annotate({ "description": "Always `logs`." }), + "logs": Schema.String.annotate({ "description": "The text output from the Code Interpreter tool call." }) + }).annotate({ + "title": "Code Interpreter log output", + "description": "Text output from the Code Interpreter tool call as part of a run step." + }), + Schema.Struct({ + "type": Schema.Literal("image").annotate({ "description": "Always `image`." }), + "image": Schema.Struct({ + "file_id": Schema.String.annotate({ + "description": "The [file](/docs/api-reference/files) ID of the image." + }) + }) + }).annotate({ "title": "Code Interpreter image output" }) + ], { mode: "oneOf" }) + ).annotate({ + "description": + "The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type." + }) + }).annotate({ "description": "The Code Interpreter tool call definition." }) +}).annotate({ + "title": "Code Interpreter tool call", + "description": "Details of the Code Interpreter tool call the run step was involved in.", + "identifier": "RunStepDetailsToolCallsCodeObject" +}) +export type RunStepDetailsToolCallsFileSearchResultObject = { + readonly "file_id": string + readonly "file_name": string + readonly "score": number + readonly "content"?: ReadonlyArray<{ readonly "type"?: "text"; readonly "text"?: string }> +} +export const RunStepDetailsToolCallsFileSearchResultObject = Schema.Struct({ + "file_id": Schema.String.annotate({ "description": "The ID of the file that result was found in." }), + "file_name": Schema.String.annotate({ "description": "The name of the file that result was found in." }), + "score": Schema.Number.annotate({ + "description": "The score of the result. All values must be a floating point number between 0 and 1." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), + "content": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "type": Schema.optionalKey(Schema.Literal("text").annotate({ "description": "The type of the content." })), + "text": Schema.optionalKey(Schema.String.annotate({ "description": "The text content of the file." })) + }) + ).annotate({ + "description": + "The content of the result that was found. The content is only included if requested via the include query parameter." + }) + ) +}).annotate({ + "title": "File search tool call result", + "description": "A result instance of the file search.", + "identifier": "RunStepDetailsToolCallsFileSearchResultObject" +}) +export type RunStepDetailsToolCallsFunctionObject = { + readonly "id": string + readonly "type": "function" + readonly "function": { readonly "name": string; readonly "arguments": string; readonly "output": string | null } +} +export const RunStepDetailsToolCallsFunctionObject = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The ID of the tool call object." }), + "type": Schema.Literal("function").annotate({ + "description": "The type of tool call. This is always going to be `function` for this type of tool call." + }), + "function": Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the function." }), + "arguments": Schema.String.annotate({ "description": "The arguments passed to the function." }), + "output": Schema.Union([ Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + "description": + "The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet." }), Schema.Null ]) - ), - "user_id": Schema.optionalKey( - Schema.Union([ + }).annotate({ "description": "The definition of the function that was called." }) +}).annotate({ "title": "Function tool call", "identifier": "RunStepDetailsToolCallsFunctionObject" }) +export type RunStepCompletionUsage = { + readonly "completion_tokens": number + readonly "prompt_tokens": number + readonly "total_tokens": number +} | null +export const RunStepCompletionUsage = Schema.Union([ + Schema.Struct({ + "completion_tokens": Schema.Number.annotate({ + "description": "Number of completion tokens used over the course of the run step." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "prompt_tokens": Schema.Number.annotate({ + "description": "Number of prompt tokens used over the course of the run step." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (prompt + completion)." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + }).annotate({ + "description": + "Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`." + }), + Schema.Null +]).annotate({ "identifier": "RunStepCompletionUsage" }) +export type SubmitToolOutputsRunRequest = { + readonly "tool_outputs": ReadonlyArray<{ readonly "tool_call_id"?: string; readonly "output"?: string }> + readonly "stream"?: boolean | null +} +export const SubmitToolOutputsRunRequest = Schema.Struct({ + "tool_outputs": Schema.Array(Schema.Struct({ + "tool_call_id": Schema.optionalKey( Schema.String.annotate({ - "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "api_key_id": Schema.optionalKey( + "description": + "The ID of the tool call in the `required_action` object within the run object the output is being submitted for." + }) + ), + "output": Schema.optionalKey( + Schema.String.annotate({ "description": "The output of the tool call to be submitted to continue the run." }) + ) + })).annotate({ "description": "A list of tools for which the outputs are being submitted." }), + "stream": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=model`, this field provides the model name of the grouped usage result." + Schema.Boolean.annotate({ + "description": + "If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.\n" }), Schema.Null ]) ) -}).annotate({ "description": "The aggregated audio transcriptions usage details of the specific time bucket." }) -export type UsageCodeInterpreterSessionsResult = { - readonly "object": "organization.usage.code_interpreter_sessions.result" - readonly "num_sessions": number - readonly "project_id"?: string | null +}).annotate({ "identifier": "SubmitToolOutputsRunRequest" }) +export type Upload = { + readonly "id": string + readonly "created_at": number + readonly "filename": string + readonly "bytes": number + readonly "purpose": string + readonly "status": "pending" | "completed" | "cancelled" | "expired" + readonly "expires_at": number + readonly "object"?: "upload" + readonly "file"?: { + readonly "id": string + readonly "bytes": number + readonly "created_at": number + readonly "expires_at"?: number | null + readonly "filename": string + readonly "object": "file" + readonly "purpose": + | "assistants" + | "assistants_output" + | "batch" + | "batch_output" + | "fine-tune" + | "fine-tune-results" + | "vision" + | "user_data" + readonly "status": "uploaded" | "processed" | "error" + readonly "status_details"?: string | null + readonly [x: string]: Schema.Json + } } -export const UsageCodeInterpreterSessionsResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.code_interpreter_sessions.result"), - "num_sessions": Schema.Number.annotate({ "description": "The number of code interpreter sessions." }).check( - Schema.isInt() +export const Upload = Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The Upload unique identifier, which can be referenced in API endpoints." + }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the Upload was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "filename": Schema.String.annotate({ "description": "The name of the file to be uploaded." }), + "bytes": Schema.Number.annotate({ "description": "The intended number of bytes to be uploaded." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." + "purpose": Schema.String.annotate({ + "description": + "The intended purpose of the file. [Please refer here](/docs/api-reference/files/object#files/object-purpose) for acceptable values." + }), + "status": Schema.Literals(["pending", "completed", "cancelled", "expired"]).annotate({ + "description": "The status of the Upload." + }), + "expires_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the Upload will expire.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "object": Schema.optionalKey( + Schema.Literal("upload").annotate({ "description": "The object type, which is always \"upload\"." }) + ), + "file": Schema.optionalKey(Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The file identifier, which can be referenced in the API endpoints." + }), + "bytes": Schema.Number.annotate({ "description": "The size of the file, in bytes." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the file was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "expires_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the file will expire.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "filename": Schema.String.annotate({ "description": "The name of the file." }), + "object": Schema.Literal("file").annotate({ "description": "The object type, which is always `file`." }), + "purpose": Schema.Literals([ + "assistants", + "assistants_output", + "batch", + "batch_output", + "fine-tune", + "fine-tune-results", + "vision", + "user_data" + ]).annotate({ + "description": + "The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`." + }), + "status": Schema.Literals(["uploaded", "processed", "error"]).annotate({ + "description": + "Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`." + }), + "status_details": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`." + }) + ) }), - Schema.Null - ]) + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ).annotate({ + "title": "OpenAIFile", + "description": "The `File` object represents a document that has been uploaded to OpenAI." + }) + ])) +}).annotate({ + "title": "Upload", + "description": "The Upload object can accept byte chunks in the form of Parts.\n", + "identifier": "Upload" +}) +export type CompleteUploadRequest = { readonly "part_ids": ReadonlyArray; readonly "md5"?: string } +export const CompleteUploadRequest = Schema.Struct({ + "part_ids": Schema.Array(Schema.String).annotate({ "description": "The ordered list of Part IDs.\n" }), + "md5": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The optional md5 checksum for the file contents to verify if the bytes uploaded matches what you expect.\n" + }) ) -}).annotate({ "description": "The aggregated code interpreter sessions usage details of the specific time bucket." }) -export type UsageCompletionsResult = { - readonly "object": "organization.usage.completions.result" - readonly "input_tokens": number - readonly "input_cached_tokens"?: number - readonly "output_tokens": number - readonly "input_audio_tokens"?: number - readonly "output_audio_tokens"?: number - readonly "num_model_requests": number - readonly "project_id"?: string | null - readonly "user_id"?: string | null - readonly "api_key_id"?: string | null - readonly "model"?: string | null - readonly "batch"?: boolean | null - readonly "service_tier"?: string | null +}).annotate({ "identifier": "CompleteUploadRequest" }) +export type AddUploadPartRequest = { readonly "data": string } +export const AddUploadPartRequest = Schema.Struct({ + "data": Schema.String.annotate({ "description": "The chunk of bytes for this Part.\n", "format": "binary" }) +}).annotate({ "identifier": "AddUploadPartRequest" }) +export type UploadPart = { + readonly "id": string + readonly "created_at": number + readonly "upload_id": string + readonly "object": "upload.part" } -export const UsageCompletionsResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.completions.result"), - "input_tokens": Schema.Number.annotate({ +export const UploadPart = Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The upload Part unique identifier, which can be referenced in API endpoints." + }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the Part was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "upload_id": Schema.String.annotate({ "description": "The ID of the Upload object that this Part was added to." }), + "object": Schema.Literal("upload.part").annotate({ "description": "The object type, which is always `upload.part`." }) +}).annotate({ + "title": "UploadPart", + "description": "The upload Part represents a chunk of bytes we can add to an Upload object.\n", + "identifier": "UploadPart" +}) +export type VectorStoreExpirationAfter = { readonly "anchor": "last_active_at"; readonly "days": number } +export const VectorStoreExpirationAfter = Schema.Struct({ + "anchor": Schema.Literal("last_active_at").annotate({ + "description": "Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`." + }), + "days": Schema.Number.annotate({ + "description": "The number of days after the anchor time that the vector store will expire." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(365).annotate({ "expected": "a value less than or equal to 365" })) +}).annotate({ + "title": "Vector store expiration policy", + "description": "The expiration policy for a vector store.", + "identifier": "VectorStoreExpirationAfter" +}) +export type StaticChunkingStrategy = { + readonly "max_chunk_size_tokens": number + readonly "chunk_overlap_tokens": number +} +export const StaticChunkingStrategy = Schema.Struct({ + "max_chunk_size_tokens": Schema.Number.annotate({ "description": - "The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens." - }).check(Schema.isInt()), - "input_cached_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens." - }).check(Schema.isInt()) - ), - "output_tokens": Schema.Number.annotate({ + "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(100).annotate({ "expected": "a value greater than or equal to 100" }) + ).check(Schema.isLessThanOrEqualTo(4096).annotate({ "expected": "a value less than or equal to 4096" })), + "chunk_overlap_tokens": Schema.Number.annotate({ "description": - "The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens." - }).check(Schema.isInt()), - "input_audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The aggregated number of audio input tokens used, including cached tokens." - }).check(Schema.isInt()) - ), - "output_audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The aggregated number of audio output tokens used." }).check( - Schema.isInt() - ) - ), - "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( - Schema.isInt() - ), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "user_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "api_key_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=model`, this field provides the model name of the grouped usage result." - }), - Schema.Null - ]) - ), - "batch": Schema.optionalKey( - Schema.Union([ - Schema.Boolean.annotate({ - "description": "When `group_by=batch`, this field tells whether the grouped usage result is batch or not." - }), - Schema.Null - ]) - ), - "service_tier": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=service_tier`, this field provides the service tier of the grouped usage result." - }), - Schema.Null - ]) - ) -}).annotate({ "description": "The aggregated completions usage details of the specific time bucket." }) -export type UsageEmbeddingsResult = { - readonly "object": "organization.usage.embeddings.result" - readonly "input_tokens": number - readonly "num_model_requests": number - readonly "project_id"?: string | null - readonly "user_id"?: string | null - readonly "api_key_id"?: string | null - readonly "model"?: string | null + "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "StaticChunkingStrategy" }) +export type DeleteVectorStoreResponse = { + readonly "id": string + readonly "deleted": boolean + readonly "object": "vector_store.deleted" } -export const UsageEmbeddingsResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.embeddings.result"), - "input_tokens": Schema.Number.annotate({ "description": "The aggregated number of input tokens used." }).check( - Schema.isInt() - ), - "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( - Schema.isInt() - ), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "user_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "api_key_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=model`, this field provides the model name of the grouped usage result." - }), - Schema.Null - ]) - ) -}).annotate({ "description": "The aggregated embeddings usage details of the specific time bucket." }) -export type UsageFileSearchCallsResult = { - readonly "object": "organization.usage.file_searches.result" - readonly "num_requests": number - readonly "project_id"?: string | null - readonly "user_id"?: string | null - readonly "api_key_id"?: string | null - readonly "vector_store_id"?: string | null +export const DeleteVectorStoreResponse = Schema.Struct({ + "id": Schema.String, + "deleted": Schema.Boolean, + "object": Schema.Literal("vector_store.deleted") +}).annotate({ "identifier": "DeleteVectorStoreResponse" }) +export type VectorStoreFileBatchObject = { + readonly "id": string + readonly "object": "vector_store.files_batch" + readonly "created_at": number + readonly "vector_store_id": string + readonly "status": "in_progress" | "completed" | "cancelled" | "failed" + readonly "file_counts": { + readonly "in_progress": number + readonly "completed": number + readonly "failed": number + readonly "cancelled": number + readonly "total": number + } } -export const UsageFileSearchCallsResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.file_searches.result"), - "num_requests": Schema.Number.annotate({ "description": "The count of file search calls." }).check(Schema.isInt()), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "user_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "api_key_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "vector_store_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result." - }), - Schema.Null - ]) +export const VectorStoreFileBatchObject = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), + "object": Schema.Literal("vector_store.files_batch").annotate({ + "description": "The object type, which is always `vector_store.file_batch`." + }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the vector store files batch was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "vector_store_id": Schema.String.annotate({ + "description": + "The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to." + }), + "status": Schema.Literals(["in_progress", "completed", "cancelled", "failed"]).annotate({ + "description": + "The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`." + }), + "file_counts": Schema.Struct({ + "in_progress": Schema.Number.annotate({ "description": "The number of files that are currently being processed." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "completed": Schema.Number.annotate({ "description": "The number of files that have been processed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "failed": Schema.Number.annotate({ "description": "The number of files that have failed to process." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "cancelled": Schema.Number.annotate({ "description": "The number of files that where cancelled." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "total": Schema.Number.annotate({ "description": "The total number of files." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }) +}).annotate({ + "title": "Vector store file batch", + "description": "A batch of files attached to a vector store.", + "identifier": "VectorStoreFileBatchObject" +}) +export type DeleteVectorStoreFileResponse = { + readonly "id": string + readonly "deleted": boolean + readonly "object": "vector_store.file.deleted" +} +export const DeleteVectorStoreFileResponse = Schema.Struct({ + "id": Schema.String, + "deleted": Schema.Boolean, + "object": Schema.Literal("vector_store.file.deleted") +}).annotate({ "identifier": "DeleteVectorStoreFileResponse" }) +export type VectorStoreFileContentResponse = { + readonly "object": "vector_store.file_content.page" + readonly "data": ReadonlyArray<{ readonly "type"?: string; readonly "text"?: string }> + readonly "has_more": boolean + readonly "next_page": string | null +} +export const VectorStoreFileContentResponse = Schema.Struct({ + "object": Schema.Literal("vector_store.file_content.page").annotate({ + "description": "The object type, which is always `vector_store.file_content.page`" + }), + "data": Schema.Array( + Schema.Struct({ + "type": Schema.optionalKey( + Schema.String.annotate({ "description": "The content type (currently only `\"text\"`)" }) + ), + "text": Schema.optionalKey(Schema.String.annotate({ "description": "The text content" })) + }) + ).annotate({ "description": "Parsed content of the file." }), + "has_more": Schema.Boolean.annotate({ "description": "Indicates if there are more content pages to fetch." }), + "next_page": Schema.Union([ + Schema.String.annotate({ "description": "The token for the next page, if any." }), + Schema.Null + ]) +}).annotate({ + "description": "Represents the parsed content of a vector store file.", + "identifier": "VectorStoreFileContentResponse" +}) +export type VectorStoreSearchResultContentObject = { readonly "type": "text"; readonly "text": string } +export const VectorStoreSearchResultContentObject = Schema.Struct({ + "type": Schema.Literal("text").annotate({ "description": "The type of content." }), + "text": Schema.String.annotate({ "description": "The text content returned from search." }) +}).annotate({ "identifier": "VectorStoreSearchResultContentObject" }) +export type DeletedConversationResource = { + readonly "object": "conversation.deleted" + readonly "deleted": boolean + readonly "id": string +} +export const DeletedConversationResource = Schema.Struct({ + "object": Schema.Literal("conversation.deleted"), + "deleted": Schema.Boolean, + "id": Schema.String +}).annotate({ "identifier": "DeletedConversationResource" }) +export type SpendLimitCurrency = string | "USD" +export const SpendLimitCurrency = Schema.Union([Schema.String, Schema.Literal("USD")]).annotate({ + "identifier": "SpendLimitCurrency" +}) +export type SpendLimitInterval = string | "month" +export const SpendLimitInterval = Schema.Union([Schema.String, Schema.Literal("month")]).annotate({ + "identifier": "SpendLimitInterval" +}) +export type SpendLimitEnforcementStatus = string | "inactive" | "enforcing" +export const SpendLimitEnforcementStatus = Schema.Union([Schema.String, Schema.Literals(["inactive", "enforcing"])]) + .annotate({ "identifier": "SpendLimitEnforcementStatus" }) +export type UpdateOrganizationSpendLimitBody = { + readonly "threshold_amount": number + readonly "currency": "USD" + readonly "interval": "month" +} +export const UpdateOrganizationSpendLimitBody = Schema.Struct({ + "threshold_amount": Schema.Number.annotate({ "description": "The hard spend limit amount, in cents." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })), + "currency": Schema.Literal("USD").annotate({ + "description": "The currency for the threshold amount. Currently, only `USD` is supported." + }), + "interval": Schema.Literal("month").annotate({ + "description": "The time interval for evaluating spend against the threshold. Currently, only `month` is supported." + }) +}).annotate({ + "description": "Parameters for the hard spend limit you want to create or replace.", + "identifier": "UpdateOrganizationSpendLimitBody" +}) +export type OrganizationSpendLimitDeletedResource = { + readonly "object": "organization.spend_limit.deleted" + readonly "deleted": boolean +} +export const OrganizationSpendLimitDeletedResource = Schema.Struct({ + "object": Schema.Literal("organization.spend_limit.deleted").annotate({ + "description": "The object type, which is always `organization.spend_limit.deleted`." + }), + "deleted": Schema.Boolean.annotate({ "description": "Whether the hard spend limit was deleted." }) +}).annotate({ + "description": "Confirmation payload returned after deleting an organization hard spend limit.", + "identifier": "OrganizationSpendLimitDeletedResource" +}) +export type UpdateProjectSpendLimitBody = { + readonly "threshold_amount": number + readonly "currency": "USD" + readonly "interval": "month" +} +export const UpdateProjectSpendLimitBody = Schema.Struct({ + "threshold_amount": Schema.Number.annotate({ "description": "The hard spend limit amount, in cents." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })), + "currency": Schema.Literal("USD").annotate({ + "description": "The currency for the threshold amount. Currently, only `USD` is supported." + }), + "interval": Schema.Literal("month").annotate({ + "description": "The time interval for evaluating spend against the threshold. Currently, only `month` is supported." + }) +}).annotate({ + "description": "Parameters for the hard spend limit you want to create or replace.", + "identifier": "UpdateProjectSpendLimitBody" +}) +export type ProjectSpendLimitDeletedResource = { + readonly "object": "project.spend_limit.deleted" + readonly "deleted": boolean +} +export const ProjectSpendLimitDeletedResource = Schema.Struct({ + "object": Schema.Literal("project.spend_limit.deleted").annotate({ + "description": "The object type, which is always `project.spend_limit.deleted`." + }), + "deleted": Schema.Boolean.annotate({ "description": "Whether the hard spend limit was deleted." }) +}).annotate({ + "description": "Confirmation payload returned after deleting a project hard spend limit.", + "identifier": "ProjectSpendLimitDeletedResource" +}) +export type CreateProjectServiceAccountApiKeyBody = { + readonly "name"?: string + readonly "scopes"?: ReadonlyArray +} +export const CreateProjectServiceAccountApiKeyBody = Schema.Struct({ + "name": Schema.optionalKey(Schema.String.annotate({ "description": "API key name." })), + "scopes": Schema.optionalKey( + Schema.Array(Schema.String.annotate({ "description": "API key scope." })).annotate({ + "description": "API key scopes." + }) ) -}).annotate({ "description": "The aggregated file search calls usage details of the specific time bucket." }) -export type UsageImagesResult = { - readonly "object": "organization.usage.images.result" - readonly "images": number - readonly "num_model_requests": number - readonly "source"?: string | null - readonly "size"?: string | null - readonly "project_id"?: string | null - readonly "user_id"?: string | null - readonly "api_key_id"?: string | null - readonly "model"?: string | null +}).annotate({ + "description": "The service account API key create request payload.", + "identifier": "CreateProjectServiceAccountApiKeyBody" +}) +export type ServiceAccountApiKeyBody = { + readonly "object": "organization.project.service_account.api_key" + readonly "value": string + readonly "name": string + readonly "created_at": number + readonly "id": string } -export const UsageImagesResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.images.result"), - "images": Schema.Number.annotate({ "description": "The number of images processed." }).check(Schema.isInt()), - "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( - Schema.isInt() - ), - "source": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`." - }), - Schema.Null - ]) - ), - "size": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=size`, this field provides the image size of the grouped usage result." - }), - Schema.Null - ]) - ), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." - }), - Schema.Null - ]) +export const ServiceAccountApiKeyBody = Schema.Struct({ + "object": Schema.Literal("organization.project.service_account.api_key").annotate({ + "description": "The object type, which is always `organization.project.service_account.api_key`" + }), + "value": Schema.String.annotate({ "description": "The unredacted API key value." }), + "name": Schema.String.annotate({ "description": "The name of the API key." }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) when the API key was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "id": Schema.String.annotate({ "description": "The identifier of the API key." }) +}).annotate({ "identifier": "ServiceAccountApiKeyBody" }) +export type CreateContentProvenanceBody = { readonly "file": string } +export const CreateContentProvenanceBody = Schema.Struct({ + "file": Schema.String.annotate({ + "description": "The image or audio file to check for supported OpenAI provenance signals.", + "format": "binary" + }) +}).annotate({ "identifier": "CreateContentProvenanceBody" }) +export type ProvenanceCheckObject = "content_provenance_check" +export const ProvenanceCheckObject = Schema.Literal("content_provenance_check").annotate({ + "identifier": "ProvenanceCheckObject" +}) +export type ProvenanceDetectionResultApi = "detected" | "not_detected" +export const ProvenanceDetectionResultApi = Schema.Literals(["detected", "not_detected"]).annotate({ + "identifier": "ProvenanceDetectionResultApi" +}) +export type C2PAValidationStateApi = "trusted" | "valid" | "invalid" | "not_present" +export const C2PAValidationStateApi = Schema.Literals(["trusted", "valid", "invalid", "not_present"]).annotate({ + "identifier": "C2PAValidationStateApi" +}) +export type OrderEnum = "asc" | "desc" +export const OrderEnum = Schema.Literals(["asc", "desc"]).annotate({ "identifier": "OrderEnum" }) +export type VideoModel = + | string + | "sora-2" + | "sora-2-pro" + | "sora-2-2025-10-06" + | "sora-2-pro-2025-10-06" + | "sora-2-2025-12-08" +export const VideoModel = Schema.Union([ + Schema.String, + Schema.Literals(["sora-2", "sora-2-pro", "sora-2-2025-10-06", "sora-2-pro-2025-10-06", "sora-2-2025-12-08"]) +]).annotate({ "identifier": "VideoModel" }) +export type VideoStatus = "queued" | "in_progress" | "completed" | "failed" +export const VideoStatus = Schema.Literals(["queued", "in_progress", "completed", "failed"]).annotate({ + "identifier": "VideoStatus" +}) +export type VideoSize = "720x1280" | "1280x720" | "1024x1792" | "1792x1024" +export const VideoSize = Schema.Literals(["720x1280", "1280x720", "1024x1792", "1792x1024"]).annotate({ + "identifier": "VideoSize" +}) +export type Error_2 = { readonly "code": string; readonly "message": string } +export const Error_2 = Schema.Struct({ + "code": Schema.String.annotate({ "description": "A machine-readable error code that was returned." }), + "message": Schema.String.annotate({ "description": "A human-readable description of the error that was returned." }) +}).annotate({ + "title": "Error", + "description": "An error that occurred while generating the response.", + "identifier": "Error-2" +}) +export type ImageRefParam_2 = { readonly "image_url"?: string; readonly "file_id"?: string } +export const ImageRefParam_2 = Schema.Struct({ + "image_url": Schema.optionalKey( + Schema.String.annotate({ "description": "A fully qualified URL or base64-encoded data URL.", "format": "uri" }) + .check(Schema.isMaxLength(20971520).annotate({ "expected": "a value with a length of at most 20971520" })) ), - "user_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "api_key_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=model`, this field provides the model name of the grouped usage result." - }), - Schema.Null - ]) + "file_id": Schema.optionalKey(Schema.String) +}).annotate({ "identifier": "ImageRefParam-2" }) +export type VideoSeconds = "4" | "8" | "12" +export const VideoSeconds = Schema.Literals(["4", "8", "12"]).annotate({ "identifier": "VideoSeconds" }) +export type CreateVideoCharacterBody = { readonly "video": string; readonly "name": string } +export const CreateVideoCharacterBody = Schema.Struct({ + "video": Schema.String.annotate({ "description": "Video file used to create a character.", "format": "binary" }), + "name": Schema.String.annotate({ "description": "Display name for this API character." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(80).annotate({ "expected": "a value with a length of at most 80" })) +}).annotate({ + "title": "Create character request", + "description": "Parameters for creating a character from an uploaded video.", + "identifier": "CreateVideoCharacterBody" +}) +export type VideoCharacterResource = { + readonly "id": string | null + readonly "name": string | null + readonly "created_at": number +} +export const VideoCharacterResource = Schema.Struct({ + "id": Schema.Union([ + Schema.String.annotate({ "description": "Identifier for the character creation cameo." }), + Schema.Null + ]), + "name": Schema.Union([Schema.String.annotate({ "description": "Display name for the character." }), Schema.Null]), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the character was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "VideoCharacterResource" }) +export type VideoReferenceInputParam = { readonly "id": string } +export const VideoReferenceInputParam = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier of the completed video." }) +}).annotate({ "description": "Reference to the completed video.", "identifier": "VideoReferenceInputParam" }) +export type DeletedVideoResource = { + readonly "object": "video.deleted" + readonly "deleted": boolean + readonly "id": string +} +export const DeletedVideoResource = Schema.Struct({ + "object": Schema.Literal("video.deleted").annotate({ + "description": "The object type that signals the deletion response." + }), + "deleted": Schema.Boolean.annotate({ "description": "Indicates that the video resource was deleted." }), + "id": Schema.String.annotate({ "description": "Identifier of the deleted video." }) +}).annotate({ + "title": "Deleted video response", + "description": "Confirmation payload returned after deleting a video.", + "identifier": "DeletedVideoResource" +}) +export type VideoContentVariant = "video" | "thumbnail" | "spritesheet" +export const VideoContentVariant = Schema.Literals(["video", "thumbnail", "spritesheet"]).annotate({ + "identifier": "VideoContentVariant" +}) +export type CreateVideoRemixBody = { readonly "prompt": string } +export const CreateVideoRemixBody = Schema.Struct({ + "prompt": Schema.String.annotate({ "description": "Updated text prompt that directs the remix generation." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(32000).annotate({ "expected": "a value with a length of at most 32000" })) +}).annotate({ + "title": "Create video remix request", + "description": "Parameters for remixing an existing generated video.", + "identifier": "CreateVideoRemixBody" +}) +export type TruncationEnum = "auto" | "disabled" +export const TruncationEnum = Schema.Literals(["auto", "disabled"]).annotate({ "identifier": "TruncationEnum" }) +export type PersonalityEnum = string | "friendly" | "pragmatic" +export const PersonalityEnum = Schema.Union([Schema.String, Schema.Literals(["friendly", "pragmatic"])]).annotate({ + "identifier": "PersonalityEnum" +}) +export type TokenCountsResource = { readonly "object": "response.input_tokens"; readonly "input_tokens": number } +export const TokenCountsResource = Schema.Struct({ + "object": Schema.Literal("response.input_tokens"), + "input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "title": "Token counts", "identifier": "TokenCountsResource" }) +export type PromptCacheRetentionEnum = "in_memory" | "in-memory" | "24h" +export const PromptCacheRetentionEnum = Schema.Literals(["in_memory", "in-memory", "24h"]).annotate({ + "identifier": "PromptCacheRetentionEnum" +}) +export type ServiceTierEnum = "auto" | "default" | "fast" | "flex" | "priority" +export const ServiceTierEnum = Schema.Literals(["auto", "default", "fast", "flex", "priority"]).annotate({ + "identifier": "ServiceTierEnum" +}) +export type SkillResource = { + readonly "id": string + readonly "object": "skill" + readonly "name": string + readonly "description": string + readonly "created_at": number + readonly "default_version": string + readonly "latest_version": string +} +export const SkillResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique identifier for the skill." }), + "object": Schema.Literal("skill").annotate({ "description": "The object type, which is `skill`." }), + "name": Schema.String.annotate({ "description": "Name of the skill." }), + "description": Schema.String.annotate({ "description": "Description of the skill." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (seconds) for when the skill was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "default_version": Schema.String.annotate({ "description": "Default version for the skill." }), + "latest_version": Schema.String.annotate({ "description": "Latest version for the skill." }) +}).annotate({ "identifier": "SkillResource" }) +export type CreateSkillBody = { readonly "files": ReadonlyArray | string } +export const CreateSkillBody = Schema.Struct({ + "files": Schema.Union([ + Schema.Array(Schema.String.annotate({ "format": "binary" })).annotate({ + "description": "Skill files to upload (directory upload) or a single zip file." + }).check(Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" })), + Schema.String.annotate({ "description": "Skill zip file to upload.", "format": "binary" }) + ], { mode: "oneOf" }) +}).annotate({ + "title": "Create skill request", + "description": "Uploads a skill either as a directory (multipart `files[]`) or as a single zip file.", + "identifier": "CreateSkillBody" +}) +export type SetDefaultSkillVersionBody = { readonly "default_version": string } +export const SetDefaultSkillVersionBody = Schema.Struct({ + "default_version": Schema.String.annotate({ "description": "The skill version number to set as default." }) +}).annotate({ + "title": "Update skill request", + "description": "Updates the default version pointer for a skill.", + "identifier": "SetDefaultSkillVersionBody" +}) +export type DeletedSkillResource = { + readonly "object": "skill.deleted" + readonly "deleted": boolean + readonly "id": string +} +export const DeletedSkillResource = Schema.Struct({ + "object": Schema.Literal("skill.deleted"), + "deleted": Schema.Boolean, + "id": Schema.String +}).annotate({ "identifier": "DeletedSkillResource" }) +export type SkillVersionResource = { + readonly "object": "skill.version" + readonly "id": string + readonly "skill_id": string + readonly "version": string + readonly "created_at": number + readonly "name": string + readonly "description": string +} +export const SkillVersionResource = Schema.Struct({ + "object": Schema.Literal("skill.version").annotate({ "description": "The object type, which is `skill.version`." }), + "id": Schema.String.annotate({ "description": "Unique identifier for the skill version." }), + "skill_id": Schema.String.annotate({ "description": "Identifier of the skill for this version." }), + "version": Schema.String.annotate({ "description": "Version number for this skill." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (seconds) for when the version was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "name": Schema.String.annotate({ "description": "Name of the skill version." }), + "description": Schema.String.annotate({ "description": "Description of the skill version." }) +}).annotate({ "identifier": "SkillVersionResource" }) +export type CreateSkillVersionBody = { readonly "files": ReadonlyArray | string; readonly "default"?: boolean } +export const CreateSkillVersionBody = Schema.Struct({ + "files": Schema.Union([ + Schema.Array(Schema.String.annotate({ "format": "binary" })).annotate({ + "description": "Skill files to upload (directory upload) or a single zip file." + }).check(Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" })), + Schema.String.annotate({ "description": "Skill zip file to upload.", "format": "binary" }) + ], { mode: "oneOf" }), + "default": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether to set this version as the default." }) ) -}).annotate({ "description": "The aggregated images usage details of the specific time bucket." }) -export type UsageModerationsResult = { - readonly "object": "organization.usage.moderations.result" - readonly "input_tokens": number - readonly "num_model_requests": number - readonly "project_id"?: string | null - readonly "user_id"?: string | null - readonly "api_key_id"?: string | null - readonly "model"?: string | null +}).annotate({ + "title": "Create skill version request", + "description": "Uploads a new immutable version of a skill.", + "identifier": "CreateSkillVersionBody" +}) +export type DeletedSkillVersionResource = { + readonly "object": "skill.version.deleted" + readonly "deleted": boolean + readonly "id": string + readonly "version": string } -export const UsageModerationsResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.moderations.result"), - "input_tokens": Schema.Number.annotate({ "description": "The aggregated number of input tokens used." }).check( - Schema.isInt() - ), - "num_model_requests": Schema.Number.annotate({ "description": "The count of requests made to the model." }).check( - Schema.isInt() - ), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." - }), - Schema.Null - ]) +export const DeletedSkillVersionResource = Schema.Struct({ + "object": Schema.Literal("skill.version.deleted"), + "deleted": Schema.Boolean, + "id": Schema.String, + "version": Schema.String.annotate({ "description": "The deleted skill version." }) +}).annotate({ "identifier": "DeletedSkillVersionResource" }) +export type ChatkitWorkflowTracing = { readonly "enabled": boolean } +export const ChatkitWorkflowTracing = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ "description": "Indicates whether tracing is enabled." }) +}).annotate({ + "title": "Tracing Configuration", + "description": "Controls diagnostic tracing during the session.", + "identifier": "ChatkitWorkflowTracing" +}) +export type ChatSessionRateLimits = { readonly "max_requests_per_1_minute": number } +export const ChatSessionRateLimits = Schema.Struct({ + "max_requests_per_1_minute": Schema.Number.annotate({ + "description": "Maximum allowed requests per one-minute window." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "title": "Rate limits", + "description": "Active per-minute request limit for the session.", + "identifier": "ChatSessionRateLimits" +}) +export type ChatSessionStatus = "active" | "expired" | "cancelled" +export const ChatSessionStatus = Schema.Literals(["active", "expired", "cancelled"]).annotate({ + "identifier": "ChatSessionStatus" +}) +export type ChatSessionAutomaticThreadTitling = { readonly "enabled": boolean } +export const ChatSessionAutomaticThreadTitling = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ "description": "Whether automatic thread titling is enabled." }) +}).annotate({ + "title": "Automatic thread titling", + "description": "Automatic thread title preferences for the session.", + "identifier": "ChatSessionAutomaticThreadTitling" +}) +export type ChatSessionFileUpload = { + readonly "enabled": boolean + readonly "max_file_size": number | null + readonly "max_files": number | null +} +export const ChatSessionFileUpload = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ "description": "Indicates if uploads are enabled for the session." }), + "max_file_size": Schema.Union([ + Schema.Number.annotate({ "description": "Maximum upload size in megabytes." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + Schema.Null + ]), + "max_files": Schema.Union([ + Schema.Number.annotate({ "description": "Maximum number of uploads allowed during the session." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + Schema.Null + ]) +}).annotate({ + "title": "File upload settings", + "description": "Upload permissions and limits applied to the session.", + "identifier": "ChatSessionFileUpload" +}) +export type ChatSessionHistory = { readonly "enabled": boolean; readonly "recent_threads": number | null } +export const ChatSessionHistory = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ "description": "Indicates if chat history is persisted for the session." }), + "recent_threads": Schema.Union([ + Schema.Number.annotate({ + "description": "Number of prior threads surfaced in history views. Defaults to null when all history is retained." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) +}).annotate({ + "title": "History settings", + "description": "History retention preferences returned for the session.", + "identifier": "ChatSessionHistory" +}) +export type WorkflowTracingParam = { readonly "enabled"?: boolean } +export const WorkflowTracingParam = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether tracing is enabled during the session. Defaults to true." }) + ) +}).annotate({ + "title": "Tracing Configuration", + "description": "Controls diagnostic tracing during the session.", + "identifier": "WorkflowTracingParam" +}) +export type ExpiresAfterParam = { readonly "anchor": "created_at"; readonly "seconds": number } +export const ExpiresAfterParam = Schema.Struct({ + "anchor": Schema.Literal("created_at").annotate({ + "description": "Base timestamp used to calculate expiration. Currently fixed to `created_at`." + }), + "seconds": Schema.Number.annotate({ + "description": "Number of seconds after the anchor when the session expires.", + "format": "int64" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(600).annotate({ "expected": "a value less than or equal to 600" })) +}).annotate({ + "title": "Expiration overrides", + "description": "Controls when the session expires relative to an anchor timestamp.", + "identifier": "ExpiresAfterParam" +}) +export type RateLimitsParam = { readonly "max_requests_per_1_minute"?: number } +export const RateLimitsParam = Schema.Struct({ + "max_requests_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Maximum number of requests allowed per minute for the session. Defaults to 10." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ) + ) +}).annotate({ + "title": "Rate limit overrides", + "description": "Controls request rate limits for the session.", + "identifier": "RateLimitsParam" +}) +export type AutomaticThreadTitlingParam = { readonly "enabled"?: boolean } +export const AutomaticThreadTitlingParam = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Enable automatic thread title generation. Defaults to true." }) + ) +}).annotate({ + "title": "Automatic thread titling configuration", + "description": "Controls whether ChatKit automatically generates thread titles.", + "identifier": "AutomaticThreadTitlingParam" +}) +export type FileUploadParam = { + readonly "enabled"?: boolean + readonly "max_file_size"?: number + readonly "max_files"?: number +} +export const FileUploadParam = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Enable uploads for this session. Defaults to false." }) ), - "user_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." - }), - Schema.Null - ]) + "max_file_size": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum size in megabytes for each uploaded file. Defaults to 512 MB, which is the maximum allowable size." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(512).annotate({ "expected": "a value less than or equal to 512" })) ), - "api_key_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." - }), - Schema.Null - ]) + "max_files": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Maximum number of files that can be uploaded to the session. Defaults to 10." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ) + ) +}).annotate({ + "title": "File upload configuration", + "description": "Controls whether users can upload files.", + "identifier": "FileUploadParam" +}) +export type HistoryParam = { readonly "enabled"?: boolean; readonly "recent_threads"?: number } +export const HistoryParam = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Enables chat users to access previous ChatKit threads. Defaults to true." + }) ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=model`, this field provides the model name of the grouped usage result." - }), - Schema.Null - ]) + "recent_threads": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Number of recent ChatKit threads users have access to. Defaults to unlimited when unset." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ) ) -}).annotate({ "description": "The aggregated moderations usage details of the specific time bucket." }) -export type UsageVectorStoresResult = { - readonly "object": "organization.usage.vector_stores.result" - readonly "usage_bytes": number - readonly "project_id"?: string | null -} -export const UsageVectorStoresResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.vector_stores.result"), - "usage_bytes": Schema.Number.annotate({ "description": "The vector stores usage in bytes." }).check(Schema.isInt()), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." - }), - Schema.Null - ]) - ) -}).annotate({ "description": "The aggregated vector stores usage details of the specific time bucket." }) -export type UsageWebSearchCallsResult = { - readonly "object": "organization.usage.web_searches.result" - readonly "num_model_requests": number - readonly "num_requests": number - readonly "project_id"?: string | null - readonly "user_id"?: string | null - readonly "api_key_id"?: string | null - readonly "model"?: string | null - readonly "context_level"?: string | null -} -export const UsageWebSearchCallsResult = Schema.Struct({ - "object": Schema.Literal("organization.usage.web_searches.result"), - "num_model_requests": Schema.Number.annotate({ "description": "The count of model requests." }).check(Schema.isInt()), - "num_requests": Schema.Number.annotate({ "description": "The count of web search calls." }).check(Schema.isInt()), - "project_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=project_id`, this field provides the project ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "user_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=user_id`, this field provides the user ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "api_key_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result." - }), - Schema.Null - ]) - ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "When `group_by=model`, this field provides the model name of the grouped usage result." - }), - Schema.Null - ]) - ), - "context_level": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "When `group_by=context_level`, this field provides the search context size of the grouped usage result." - }), - Schema.Null - ]) - ) -}).annotate({ "description": "The aggregated web search calls usage details of the specific time bucket." }) -export type User = { - readonly "object": "organization.user" +}).annotate({ + "title": "Chat history configuration", + "description": "Controls how much historical context is retained for the session.", + "identifier": "HistoryParam" +}) +export type UserMessageInputText = { readonly "type": "input_text"; readonly "text": string } +export const UserMessageInputText = Schema.Struct({ + "type": Schema.Literal("input_text").annotate({ "description": "Type discriminator that is always `input_text`." }), + "text": Schema.String.annotate({ "description": "Plain-text content supplied by the user." }) +}).annotate({ + "title": "User message input", + "description": "Text block that a user contributed to the thread.", + "identifier": "UserMessageInputText" +}) +export type UserMessageQuotedText = { readonly "type": "quoted_text"; readonly "text": string } +export const UserMessageQuotedText = Schema.Struct({ + "type": Schema.Literal("quoted_text").annotate({ "description": "Type discriminator that is always `quoted_text`." }), + "text": Schema.String.annotate({ "description": "Quoted text content." }) +}).annotate({ + "title": "User message quoted text", + "description": "Quoted snippet that the user referenced in their message.", + "identifier": "UserMessageQuotedText" +}) +export type AttachmentType = "image" | "file" +export const AttachmentType = Schema.Literals(["image", "file"]).annotate({ "identifier": "AttachmentType" }) +export type ToolChoice = { readonly "id": string } +export const ToolChoice = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier of the requested tool." }) +}).annotate({ + "title": "Tool choice", + "description": "Tool selection that the assistant should honor when executing the item.", + "identifier": "ToolChoice" +}) +export type FileAnnotationSource = { readonly "type": "file"; readonly "filename": string } +export const FileAnnotationSource = Schema.Struct({ + "type": Schema.Literal("file").annotate({ "description": "Type discriminator that is always `file`." }), + "filename": Schema.String.annotate({ "description": "Filename referenced by the annotation." }) +}).annotate({ + "title": "File annotation source", + "description": "Attachment source referenced by an annotation.", + "identifier": "FileAnnotationSource" +}) +export type UrlAnnotationSource = { readonly "type": "url"; readonly "url": string } +export const UrlAnnotationSource = Schema.Struct({ + "type": Schema.Literal("url").annotate({ "description": "Type discriminator that is always `url`." }), + "url": Schema.String.annotate({ "description": "URL referenced by the annotation.", "format": "uri" }) +}).annotate({ + "title": "URL annotation source", + "description": "URL backing an annotation entry.", + "identifier": "UrlAnnotationSource" +}) +export type WidgetMessageItem = { readonly "id": string - readonly "name"?: string | null - readonly "email"?: string | null - readonly "role"?: string | null - readonly "added_at": number - readonly "is_default"?: boolean - readonly "created"?: number - readonly "user"?: { - readonly "object": "user" - readonly "id": string - readonly "email"?: string | null - readonly "name"?: string | null - readonly "picture"?: string | null - readonly "enabled"?: boolean | null - readonly "banned"?: boolean | null - readonly "banned_at"?: number | null - } - readonly "is_service_account"?: boolean - readonly "is_scale_tier_authorized_purchaser"?: boolean | null - readonly "is_scim_managed"?: boolean - readonly "api_key_last_used_at"?: number | null - readonly "technical_level"?: string | null - readonly "developer_persona"?: string | null - readonly "projects"?: { - readonly "object": "list" - readonly "data": ReadonlyArray< - { readonly "id"?: string | null; readonly "name"?: string | null; readonly "role"?: string | null } - > - } | null + readonly "object": "chatkit.thread_item" + readonly "created_at": number + readonly "thread_id": string + readonly "type": "chatkit.widget" + readonly "widget": string } -export const User = Schema.Struct({ - "object": Schema.Literal("organization.user").annotate({ - "description": "The object type, which is always `organization.user`" +export const WidgetMessageItem = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), + "object": Schema.Literal("chatkit.thread_item").annotate({ + "description": "Type discriminator that is always `chatkit.thread_item`." }), - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the user" }) - ), - "email": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The email address of the user" }) - ), - "role": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "`owner` or `reader`" }) - ), - "added_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the user was added.", + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) for when the item was created.", "format": "unixtime" - }).check(Schema.isInt()), - "is_default": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether this is the organization's default user." }) - ), - "created": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the user was created.", - "format": "unixtime" - }).check(Schema.isInt()) - ), - "user": Schema.optionalKey( - Schema.Struct({ - "object": Schema.Literal("user"), - "id": Schema.String, - "email": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "name": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "picture": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "enabled": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "banned": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "banned_at": Schema.optionalKey( - Schema.Union([Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt()), Schema.Null]) - ) - }).annotate({ "description": "Nested user details." }) - ), - "is_service_account": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether the user is a service account." }) - ), - "is_scale_tier_authorized_purchaser": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": "Whether the user is an authorized purchaser for Scale Tier." - }) - ), - "is_scim_managed": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether the user is managed through SCIM." }) - ), - "api_key_last_used_at": Schema.optionalKey( - Schema.Union([Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt()), Schema.Null]).annotate({ - "description": "The Unix timestamp (in seconds) of the user's last API key usage." - }) - ), - "technical_level": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The technical level metadata for the user." }) - ), - "developer_persona": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The developer persona metadata for the user." - }) - ), - "projects": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "object": Schema.Literal("list"), - "data": Schema.Array( - Schema.Struct({ - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "name": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "role": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) - }) - ) - }), - Schema.Null - ]).annotate({ "description": "Projects associated with the user, if included." }) - ) -}).annotate({ "description": "Represents an individual `user` within an organization." }) -export type UserDeleteResponse = { - readonly "object": "organization.user.deleted" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), + "type": Schema.Literal("chatkit.widget").annotate({ + "description": "Type discriminator that is always `chatkit.widget`." + }), + "widget": Schema.String.annotate({ "description": "Serialized widget payload rendered in the UI." }) +}).annotate({ + "title": "Widget message", + "description": "Thread item that renders a widget payload.", + "identifier": "WidgetMessageItem" +}) +export type ClientToolCallStatus = "in_progress" | "completed" +export const ClientToolCallStatus = Schema.Literals(["in_progress", "completed"]).annotate({ + "identifier": "ClientToolCallStatus" +}) +export type TaskType = "custom" | "thought" +export const TaskType = Schema.Literals(["custom", "thought"]).annotate({ "identifier": "TaskType" }) +export type ActiveStatus = { readonly "type": "active" } +export const ActiveStatus = Schema.Struct({ + "type": Schema.Literal("active").annotate({ "description": "Status discriminator that is always `active`." }) +}).annotate({ + "title": "Active thread status", + "description": "Indicates that a thread is active.", + "identifier": "ActiveStatus" +}) +export type LockedStatus = { readonly "type": "locked"; readonly "reason": string | null } +export const LockedStatus = Schema.Struct({ + "type": Schema.Literal("locked").annotate({ "description": "Status discriminator that is always `locked`." }), + "reason": Schema.Union([ + Schema.String.annotate({ + "description": "Reason that the thread was locked. Defaults to null when no reason is recorded." + }), + Schema.Null + ]) +}).annotate({ + "title": "Locked thread status", + "description": "Indicates that a thread is locked and cannot accept new input.", + "identifier": "LockedStatus" +}) +export type ClosedStatus = { readonly "type": "closed"; readonly "reason": string | null } +export const ClosedStatus = Schema.Struct({ + "type": Schema.Literal("closed").annotate({ "description": "Status discriminator that is always `closed`." }), + "reason": Schema.Union([ + Schema.String.annotate({ + "description": "Reason that the thread was closed. Defaults to null when no reason is recorded." + }), + Schema.Null + ]) +}).annotate({ + "title": "Closed thread status", + "description": "Indicates that a thread has been closed.", + "identifier": "ClosedStatus" +}) +export type DeletedThreadResource = { readonly "id": string + readonly "object": "chatkit.thread.deleted" readonly "deleted": boolean } -export const UserDeleteResponse = Schema.Struct({ - "object": Schema.Literal("organization.user.deleted"), - "id": Schema.String, - "deleted": Schema.Boolean +export const DeletedThreadResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier of the deleted thread." }), + "object": Schema.Literal("chatkit.thread.deleted").annotate({ + "description": "Type discriminator that is always `chatkit.thread.deleted`." + }), + "deleted": Schema.Boolean.annotate({ "description": "Indicates that the thread has been deleted." }) +}).annotate({ + "title": "Deleted thread", + "description": "Confirmation payload returned after deleting a thread.", + "identifier": "DeletedThreadResource" }) -export type UserRoleUpdateRequest = { - readonly "role"?: string | null - readonly "role_id"?: string | null - readonly "technical_level"?: string | null - readonly "developer_persona"?: string | null -} -export const UserRoleUpdateRequest = Schema.Struct({ - "role": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "`owner` or `reader`" }) - ), - "role_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Role ID to assign to the user." }) - ), - "technical_level": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Technical level metadata." }) - ), - "developer_persona": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Developer persona metadata." }) - ) -}) -export type VadConfig = { - readonly "type": "server_vad" - readonly "prefix_padding_ms"?: number - readonly "silence_duration_ms"?: number - readonly "threshold"?: number -} -export const VadConfig = Schema.Struct({ - "type": Schema.Literal("server_vad").annotate({ - "description": "Must be set to `server_vad` to enable manual chunking using server side VAD." - }), - "prefix_padding_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Amount of audio to include before the VAD detected speech (in \nmilliseconds).\n" - }).check(Schema.isInt()) - ), - "silence_duration_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Duration of silence to detect speech stop (in milliseconds).\nWith shorter values the model will respond more quickly, \nbut may jump in on short pauses from the user.\n" - }).check(Schema.isInt()) - ), - "threshold": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Sensitivity threshold (0.0 to 1.0) for voice activity detection. A \nhigher threshold will require louder audio to activate the model, and \nthus might perform better in noisy environments.\n" - }).check(Schema.isFinite()) - ) -}) -export type VectorStoreExpirationAfter = { readonly "anchor": "last_active_at"; readonly "days": number } -export const VectorStoreExpirationAfter = Schema.Struct({ - "anchor": Schema.Literal("last_active_at").annotate({ - "description": "Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`." - }), - "days": Schema.Number.annotate({ - "description": "The number of days after the anchor time that the vector store will expire." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(365)) -}).annotate({ "title": "Vector store expiration policy", "description": "The expiration policy for a vector store." }) -export type VectorStoreFileAttributes = {} | null -export const VectorStoreFileAttributes = Schema.Union([ +export type BetaMetadata = {} | null +export const BetaMetadata = 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. Keys are strings\nwith a maximum length of 64 characters. Values are strings with a maximum\nlength of 512 characters, booleans, or numbers.\n" - }).check(Schema.isMaxProperties(16)).check(Schema.isPropertyNames(Schema.String.check(Schema.isMaxLength(64)))), - Schema.Null -]) -export type VectorStoreFileBatchObject = { - readonly "id": string - readonly "object": "vector_store.files_batch" - readonly "created_at": number - readonly "vector_store_id": string - readonly "status": "in_progress" | "completed" | "cancelled" | "failed" - readonly "file_counts": { - readonly "in_progress": number - readonly "completed": number - readonly "failed": number - readonly "cancelled": number - readonly "total": number - } -} -export const VectorStoreFileBatchObject = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), - "object": Schema.Literal("vector_store.files_batch").annotate({ - "description": "The object type, which is always `vector_store.file_batch`." - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the vector store files batch was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "vector_store_id": Schema.String.annotate({ - "description": - "The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to." - }), - "status": Schema.Literals(["in_progress", "completed", "cancelled", "failed"]).annotate({ - "description": - "The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`." - }), - "file_counts": Schema.Struct({ - "in_progress": Schema.Number.annotate({ "description": "The number of files that are currently being processed." }) - .check(Schema.isInt()), - "completed": Schema.Number.annotate({ "description": "The number of files that have been processed." }).check( - Schema.isInt() - ), - "failed": Schema.Number.annotate({ "description": "The number of files that have failed to process." }).check( - Schema.isInt() - ), - "cancelled": Schema.Number.annotate({ "description": "The number of files that where cancelled." }).check( - Schema.isInt() - ), - "total": Schema.Number.annotate({ "description": "The total number of files." }).check(Schema.isInt()) - }) -}).annotate({ "title": "Vector store file batch", "description": "A batch of files attached to a vector store." }) -export type VectorStoreFileContentResponse = { - readonly "object": "vector_store.file_content.page" - readonly "data": ReadonlyArray<{ readonly "type"?: string; readonly "text"?: string }> - readonly "has_more": boolean - readonly "next_page": string | null -} -export const VectorStoreFileContentResponse = Schema.Struct({ - "object": Schema.Literal("vector_store.file_content.page").annotate({ - "description": "The object type, which is always `vector_store.file_content.page`" + "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" }), - "data": Schema.Array( - Schema.Struct({ - "type": Schema.optionalKey( - Schema.String.annotate({ "description": "The content type (currently only `\"text\"`)" }) - ), - "text": Schema.optionalKey(Schema.String.annotate({ "description": "The text content" })) - }) - ).annotate({ "description": "Parsed content of the file." }), - "has_more": Schema.Boolean.annotate({ "description": "Indicates if there are more content pages to fetch." }), - "next_page": Schema.Union([ - Schema.String.annotate({ "description": "The token for the next page, if any." }), - Schema.Null - ]) -}).annotate({ "description": "Represents the parsed content of a vector store file." }) -export type VectorStoreSearchResultContentObject = { readonly "type": "text"; readonly "text": string } -export const VectorStoreSearchResultContentObject = Schema.Struct({ - "type": Schema.Literal("text").annotate({ "description": "The type of content." }), - "text": Schema.String.annotate({ "description": "The text content returned from search." }) -}) -export type Verbosity = "low" | "medium" | "high" | null -export const Verbosity = Schema.Union([ - Schema.Literals(["low", "medium", "high"]).annotate({ + Schema.Null +]).annotate({ "identifier": "BetaMetadata" }) +export type BetaServiceTier = "auto" | "default" | "flex" | "scale" | "priority" | "fast" | null +export const BetaServiceTier = Schema.Union([ + Schema.Literals(["auto", "default", "flex", "scale", "priority", "fast"]).annotate({ "description": - "Constrains the verbosity of the model's response. Lower values will result in\nmore concise responses, while higher values will result in more verbose responses.\nCurrently supported values are `low`, `medium`, and `high`.\n" + "Specifies the processing type used for serving the request.\n - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.\n - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.\n - If set to '[flex](/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.\n - To opt-in to [Fast mode](/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request.\n - When not set, the default behavior is 'auto'.\n\n When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.\n" }), Schema.Null -]) -export type VoiceConsentDeletedResource = { - readonly "id": string - readonly "object": "audio.voice_consent" - readonly "deleted": boolean -} -export const VoiceConsentDeletedResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The consent recording identifier." }), - "object": Schema.Literal("audio.voice_consent"), - "deleted": Schema.Boolean -}) -export type VoiceConsentResource = { - readonly "object": "audio.voice_consent" - readonly "id": string - readonly "name": string - readonly "language": string - readonly "created_at": number -} -export const VoiceConsentResource = Schema.Struct({ - "object": Schema.Literal("audio.voice_consent").annotate({ - "description": "The object type, which is always `audio.voice_consent`." - }), - "id": Schema.String.annotate({ "description": "The consent recording identifier." }), - "name": Schema.String.annotate({ "description": "The label provided when the consent recording was uploaded." }), - "language": Schema.String.annotate({ - "description": "The BCP 47 language tag for the consent phrase (for example, `en-US`)." - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the consent recording was created.", - "format": "unixtime" - }).check(Schema.isInt()) -}).annotate({ - "title": "Voice consent", - "description": "A consent recording used to authorize creation of a custom voice." -}) -export type VoiceIdsShared = +]).annotate({ "identifier": "BetaServiceTier" }) +export type BetaPromptCacheTTLEnum = "30m" +export const BetaPromptCacheTTLEnum = Schema.Literal("30m").annotate({ "identifier": "BetaPromptCacheTTLEnum" }) +export type BetaPromptCacheModeEnum = "implicit" | "explicit" +export const BetaPromptCacheModeEnum = Schema.Literals(["implicit", "explicit"]).annotate({ + "identifier": "BetaPromptCacheModeEnum" +}) +export type BetaModelIdsShared = | string - | "alloy" - | "ash" - | "ballad" - | "coral" - | "echo" - | "sage" - | "shimmer" - | "verse" - | "marin" - | "cedar" -export const VoiceIdsShared = Schema.Union([ + | "gpt-5.6-sol" + | "gpt-5.6-terra" + | "gpt-5.6-luna" + | "gpt-5.5" + | "gpt-5.4" + | "gpt-5.4-mini" + | "gpt-5.4-nano" + | "gpt-5.4-mini-2026-03-17" + | "gpt-5.4-nano-2026-03-17" + | "gpt-5.3-chat-latest" + | "gpt-5.2" + | "gpt-5.2-2025-12-11" + | "gpt-5.2-chat-latest" + | "gpt-5.2-pro" + | "gpt-5.2-pro-2025-12-11" + | "gpt-5.1" + | "gpt-5.1-2025-11-13" + | "gpt-5.1-codex" + | "gpt-5.1-mini" + | "gpt-5.1-chat-latest" + | "gpt-5" + | "gpt-5-mini" + | "gpt-5-nano" + | "gpt-5-2025-08-07" + | "gpt-5-mini-2025-08-07" + | "gpt-5-nano-2025-08-07" + | "gpt-5-chat-latest" + | "gpt-4.1" + | "gpt-4.1-mini" + | "gpt-4.1-nano" + | "gpt-4.1-2025-04-14" + | "gpt-4.1-mini-2025-04-14" + | "gpt-4.1-nano-2025-04-14" + | "o4-mini" + | "o4-mini-2025-04-16" + | "o3" + | "o3-2025-04-16" + | "o3-mini" + | "o3-mini-2025-01-31" + | "o1" + | "o1-2024-12-17" + | "o1-preview" + | "o1-preview-2024-09-12" + | "o1-mini" + | "o1-mini-2024-09-12" + | "gpt-4o" + | "gpt-4o-2024-11-20" + | "gpt-4o-2024-08-06" + | "gpt-4o-2024-05-13" + | "gpt-4o-audio-preview" + | "gpt-4o-audio-preview-2024-10-01" + | "gpt-4o-audio-preview-2024-12-17" + | "gpt-4o-audio-preview-2025-06-03" + | "gpt-4o-mini-audio-preview" + | "gpt-4o-mini-audio-preview-2024-12-17" + | "gpt-4o-search-preview" + | "gpt-4o-mini-search-preview" + | "gpt-4o-search-preview-2025-03-11" + | "gpt-4o-mini-search-preview-2025-03-11" + | "chatgpt-4o-latest" + | "codex-mini-latest" + | "gpt-4o-mini" + | "gpt-4o-mini-2024-07-18" + | "gpt-4-turbo" + | "gpt-4-turbo-2024-04-09" + | "gpt-4-0125-preview" + | "gpt-4-turbo-preview" + | "gpt-4-1106-preview" + | "gpt-4-vision-preview" + | "gpt-4" + | "gpt-4-0314" + | "gpt-4-0613" + | "gpt-4-32k" + | "gpt-4-32k-0314" + | "gpt-4-32k-0613" + | "gpt-3.5-turbo" + | "gpt-3.5-turbo-16k" + | "gpt-3.5-turbo-0301" + | "gpt-3.5-turbo-0613" + | "gpt-3.5-turbo-1106" + | "gpt-3.5-turbo-0125" + | "gpt-3.5-turbo-16k-0613" +export const BetaModelIdsShared = Schema.Union([ Schema.String, - Schema.Literals(["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse", "marin", "cedar"]) -]) -export type VoiceResource = { - readonly "object": "audio.voice" - readonly "id": string - readonly "name": string - readonly "created_at": number -} -export const VoiceResource = Schema.Struct({ - "object": Schema.Literal("audio.voice").annotate({ - "description": "The object type, which is always `audio.voice`." - }), - "id": Schema.String.annotate({ "description": "The voice identifier, which can be referenced in API endpoints." }), - "name": Schema.String.annotate({ "description": "The name of the voice." }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the voice was created.", - "format": "unixtime" - }).check(Schema.isInt()) -}).annotate({ "title": "Voice", "description": "A custom voice that can be used for audio output." }) -export type WebSearchApproximateLocation = { - readonly "type"?: "approximate" - readonly "country"?: string | null - readonly "region"?: string | null - readonly "city"?: string | null + Schema.Literals([ + "gpt-5.6-sol", + "gpt-5.6-terra", + "gpt-5.6-luna", + "gpt-5.5", + "gpt-5.4", + "gpt-5.4-mini", + "gpt-5.4-nano", + "gpt-5.4-mini-2026-03-17", + "gpt-5.4-nano-2026-03-17", + "gpt-5.3-chat-latest", + "gpt-5.2", + "gpt-5.2-2025-12-11", + "gpt-5.2-chat-latest", + "gpt-5.2-pro", + "gpt-5.2-pro-2025-12-11", + "gpt-5.1", + "gpt-5.1-2025-11-13", + "gpt-5.1-codex", + "gpt-5.1-mini", + "gpt-5.1-chat-latest", + "gpt-5", + "gpt-5-mini", + "gpt-5-nano", + "gpt-5-2025-08-07", + "gpt-5-mini-2025-08-07", + "gpt-5-nano-2025-08-07", + "gpt-5-chat-latest", + "gpt-4.1", + "gpt-4.1-mini", + "gpt-4.1-nano", + "gpt-4.1-2025-04-14", + "gpt-4.1-mini-2025-04-14", + "gpt-4.1-nano-2025-04-14", + "o4-mini", + "o4-mini-2025-04-16", + "o3", + "o3-2025-04-16", + "o3-mini", + "o3-mini-2025-01-31", + "o1", + "o1-2024-12-17", + "o1-preview", + "o1-preview-2024-09-12", + "o1-mini", + "o1-mini-2024-09-12", + "gpt-4o", + "gpt-4o-2024-11-20", + "gpt-4o-2024-08-06", + "gpt-4o-2024-05-13", + "gpt-4o-audio-preview", + "gpt-4o-audio-preview-2024-10-01", + "gpt-4o-audio-preview-2024-12-17", + "gpt-4o-audio-preview-2025-06-03", + "gpt-4o-mini-audio-preview", + "gpt-4o-mini-audio-preview-2024-12-17", + "gpt-4o-search-preview", + "gpt-4o-mini-search-preview", + "gpt-4o-search-preview-2025-03-11", + "gpt-4o-mini-search-preview-2025-03-11", + "chatgpt-4o-latest", + "codex-mini-latest", + "gpt-4o-mini", + "gpt-4o-mini-2024-07-18", + "gpt-4-turbo", + "gpt-4-turbo-2024-04-09", + "gpt-4-0125-preview", + "gpt-4-turbo-preview", + "gpt-4-1106-preview", + "gpt-4-vision-preview", + "gpt-4", + "gpt-4-0314", + "gpt-4-0613", + "gpt-4-32k", + "gpt-4-32k-0314", + "gpt-4-32k-0613", + "gpt-3.5-turbo", + "gpt-3.5-turbo-16k", + "gpt-3.5-turbo-0301", + "gpt-3.5-turbo-0613", + "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", + "gpt-3.5-turbo-16k-0613" + ]) +]).annotate({ "identifier": "BetaModelIdsShared" }) +export type BetaResponseFormatText = { readonly "type": "text" } +export const BetaResponseFormatText = Schema.Struct({ + "type": Schema.Literal("text").annotate({ + "description": "The type of response format being defined. Always `text`." + }) +}).annotate({ + "title": "Text", + "description": "Default response format. Used to generate text responses.\n", + "identifier": "BetaResponseFormatText" +}) +export type BetaResponseFormatJsonSchemaSchema = {} +export const BetaResponseFormatJsonSchemaSchema = Schema.Struct({}).annotate({ + "title": "JSON schema", + "description": + "The schema for the response format, described as a JSON Schema object.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n", + "identifier": "BetaResponseFormatJsonSchemaSchema" +}) +export type BetaResponseFormatJsonObject = { readonly "type": "json_object" } +export const BetaResponseFormatJsonObject = Schema.Struct({ + "type": Schema.Literal("json_object").annotate({ + "description": "The type of response format being defined. Always `json_object`." + }) +}).annotate({ + "title": "JSON object", + "description": + "JSON object response format. An older method of generating JSON responses.\nUsing `json_schema` is recommended for models that support it. Note that the\nmodel will not generate JSON without a system or user message instructing it\nto do so.\n", + "identifier": "BetaResponseFormatJsonObject" +}) +export type BetaVerbosity = "low" | "medium" | "high" | null +export const BetaVerbosity = Schema.Union([ + Schema.Literals(["low", "medium", "high"]).annotate({ + "description": + "Constrains the verbosity of the model's response. Lower values will result in\nmore concise responses, while higher values will result in more verbose responses.\nCurrently supported values are `low`, `medium`, and `high`. The default is\n`medium`.\n" + }), + Schema.Null +]).annotate({ "identifier": "BetaVerbosity" }) +export type BetaCallableToolAllowedCaller = "direct" | "programmatic" +export const BetaCallableToolAllowedCaller = Schema.Literals(["direct", "programmatic"]).annotate({ + "identifier": "BetaCallableToolAllowedCaller" +}) +export type BetaRankerVersionType = "auto" | "default-2024-11-15" +export const BetaRankerVersionType = Schema.Literals(["auto", "default-2024-11-15"]).annotate({ + "identifier": "BetaRankerVersionType" +}) +export type BetaHybridSearchOptions = { readonly "embedding_weight": number; readonly "text_weight": number } +export const BetaHybridSearchOptions = Schema.Struct({ + "embedding_weight": Schema.Number.annotate({ + "description": "The weight of the embedding in the reciprocal ranking fusion." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "text_weight": Schema.Number.annotate({ "description": "The weight of the text in the reciprocal ranking fusion." }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })) +}).annotate({ "identifier": "BetaHybridSearchOptions" }) +export type BetaComparisonFilter = { + readonly "type": "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" + readonly "key": string + readonly "value": string | number | boolean | ReadonlyArray +} +export const BetaComparisonFilter = Schema.Struct({ + "type": Schema.Literals(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]).annotate({ + "description": + "Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`.\n- `eq`: equals\n- `ne`: not equal\n- `gt`: greater than\n- `gte`: greater than or equal\n- `lt`: less than\n- `lte`: less than or equal\n- `in`: in\n- `nin`: not in\n" + }), + "key": Schema.String.annotate({ "description": "The key to compare against the value." }), + "value": Schema.Union([ + Schema.String, + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Boolean, + Schema.Array( + Schema.Union( + [Schema.String, Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))], + { mode: "oneOf" } + ) + ) + ], { mode: "oneOf" }).annotate({ + "description": "The value to compare against the attribute key; supports string, number, or boolean types." + }) +}).annotate({ + "title": "Comparison Filter", + "description": + "A filter used to compare a specified attribute key to a given value using a defined comparison operation.\n", + "identifier": "BetaComparisonFilter" +}) +export type BetaComputerTool = { readonly "type": "computer" } +export const BetaComputerTool = 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).", + "identifier": "BetaComputerTool" +}) +export type BetaComputerEnvironment = "windows" | "mac" | "linux" | "ubuntu" | "browser" +export const BetaComputerEnvironment = Schema.Literals(["windows", "mac", "linux", "ubuntu", "browser"]).annotate({ + "identifier": "BetaComputerEnvironment" +}) +export type BetaWebSearchApproximateLocation = { + readonly "type"?: "approximate" + readonly "country"?: string | null + readonly "region"?: string | null + readonly "city"?: string | null readonly "timezone"?: string | null } | null -export const WebSearchApproximateLocation = Schema.Union([ +export const BetaWebSearchApproximateLocation = Schema.Union([ Schema.Struct({ "type": Schema.optionalKey( Schema.Literal("approximate").annotate({ @@ -8370,238 +9652,398 @@ export const WebSearchApproximateLocation = Schema.Union([ ) }).annotate({ "title": "Web search approximate location", "description": "The approximate location of the user.\n" }), Schema.Null -]) -export type WebSearchContextSize = "low" | "medium" | "high" -export const WebSearchContextSize = Schema.Literals(["low", "medium", "high"]).annotate({ - "description": - "High level guidance for the amount of context window space to use for the \nsearch. One of `low`, `medium`, or `high`. `medium` is the default.\n" -}) -export type WebSearchLocation = { - readonly "country"?: string - readonly "region"?: string - readonly "city"?: string - readonly "timezone"?: string -} -export const WebSearchLocation = Schema.Struct({ - "country": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The two-letter \n[ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user,\ne.g. `US`.\n" - }) - ), - "region": Schema.optionalKey( - Schema.String.annotate({ "description": "Free text input for the region of the user, e.g. `California`.\n" }) - ), - "city": Schema.optionalKey( - Schema.String.annotate({ "description": "Free text input for the city of the user, e.g. `San Francisco`.\n" }) +]).annotate({ "identifier": "BetaWebSearchApproximateLocation" }) +export type BetaMCPToolFilter = { readonly "tool_names"?: ReadonlyArray; readonly "read_only"?: boolean } +export const BetaMCPToolFilter = Schema.Struct({ + "tool_names": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "title": "MCP allowed tools", "description": "List of allowed tool names." }) ), - "timezone": Schema.optionalKey( - Schema.String.annotate({ + "read_only": Schema.optionalKey( + Schema.Boolean.annotate({ "description": - "The [IANA timezone](https://timeapi.io/documentation/iana-timezones) \nof the user, e.g. `America/Los_Angeles`.\n" + "Indicates whether or not a tool modifies data or is read-only. If an\nMCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),\nit will match this filter.\n" }) ) -}).annotate({ "title": "Web search location", "description": "Approximate location parameters for the search." }) -export type WebSearchToolCall = { - readonly "id": string - readonly "type": "web_search_call" - readonly "status": "in_progress" | "searching" | "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 | null } - | { readonly "type": "find_in_page"; readonly "url": string; readonly "pattern": string } -} -export const WebSearchToolCall = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the web search tool call.\n" }), - "type": Schema.Literal("web_search_call").annotate({ - "description": "The type of the web search tool call. Always `web_search_call`.\n" - }), - "status": Schema.Literals(["in_progress", "searching", "completed", "failed"]).annotate({ - "description": "The status of the web search tool call.\n" - }), - "action": Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("search").annotate({ "description": "The action type.\n" }), - "query": Schema.optionalKey(Schema.String.annotate({ "description": "[DEPRECATED] The search query.\n" })), - "queries": Schema.optionalKey( - Schema.Array(Schema.String.annotate({ "description": "A search query.\n" })).annotate({ - "title": "Search queries", - "description": "The search queries.\n" - }) - ), - "sources": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "type": Schema.Literal("url").annotate({ "description": "The type of source. Always `url`.\n" }), - "url": Schema.String.annotate({ "description": "The URL of the source.\n", "format": "uri" }) - }).annotate({ "title": "Web search source", "description": "A source used in the search.\n" }) - ).annotate({ "title": "Web search sources", "description": "The sources used in the search.\n" }) - ) - }).annotate({ - "title": "Search action", - "description": - "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" - }), - Schema.Struct({ - "type": Schema.Literal("open_page").annotate({ "description": "The action type. Always `open_page`.\n" }), - "url": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "format": "uri" }), Schema.Null]).annotate({ - "description": "The URL opened by the model.\n" - }) - ) - }).annotate({ - "title": "Open page action", - "description": - "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" - }), - Schema.Struct({ - "type": Schema.Literal("find_in_page").annotate({ "description": "The action type.\n" }), - "url": Schema.String.annotate({ - "description": "The URL of the page searched for the pattern.\n", - "format": "uri" - }), - "pattern": Schema.String.annotate({ "description": "The pattern or text to search for within the page.\n" }) - }).annotate({ - "title": "Find action", - "description": - "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" - }) - ], { mode: "oneOf" }) }).annotate({ - "title": "Web search tool call", + "title": "MCP tool filter", + "description": "A filter object to specify which tools are allowed.\n", + "identifier": "BetaMCPToolFilter" +}) +export type BetaContainerMemoryLimit = "1g" | "4g" | "16g" | "64g" +export const BetaContainerMemoryLimit = Schema.Literals(["1g", "4g", "16g", "64g"]).annotate({ + "identifier": "BetaContainerMemoryLimit" +}) +export type BetaContainerNetworkPolicyDisabledParam = { readonly "type": "disabled" } +export const BetaContainerNetworkPolicyDisabledParam = Schema.Struct({ + "type": Schema.Literal("disabled").annotate({ "description": "Disable outbound network access. Always `disabled`." }) +}).annotate({ "identifier": "BetaContainerNetworkPolicyDisabledParam" }) +export type BetaContainerNetworkPolicyDomainSecretParam = { + readonly "domain": string + readonly "name": string + readonly "value": string +} +export const BetaContainerNetworkPolicyDomainSecretParam = Schema.Struct({ + "domain": Schema.String.annotate({ "description": "The domain associated with the secret." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "name": Schema.String.annotate({ "description": "The name of the secret to inject for the domain." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "value": Schema.String.annotate({ "description": "The secret value to inject for the domain." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })) +}).annotate({ "identifier": "BetaContainerNetworkPolicyDomainSecretParam" }) +export type BetaProgrammaticToolCallingParam = { readonly "type": "programmatic_tool_calling" } +export const BetaProgrammaticToolCallingParam = Schema.Struct({ + "type": Schema.Literal("programmatic_tool_calling").annotate({ + "description": "The type of the tool. Always `programmatic_tool_calling`." + }) +}).annotate({ "identifier": "BetaProgrammaticToolCallingParam" }) +export type BetaInputFidelity = "high" | "low" +export const BetaInputFidelity = Schema.Literals(["high", "low"]).annotate({ "description": - "The results of a web search tool call. See the\n[web search guide](/docs/guides/tools-web-search) for more information.\n" + "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`.", + "identifier": "BetaInputFidelity" }) -export type SkillReferenceParam = { +export type BetaImageGenActionEnum = "generate" | "edit" | "auto" +export const BetaImageGenActionEnum = Schema.Literals(["generate", "edit", "auto"]).annotate({ + "identifier": "BetaImageGenActionEnum" +}) +export type BetaLocalShellToolParam = { readonly "type": "local_shell" } +export const BetaLocalShellToolParam = 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.", + "identifier": "BetaLocalShellToolParam" +}) +export type BetaSkillReferenceParam = { readonly "type": "skill_reference" readonly "skill_id": string readonly "version"?: string } -export const SkillReferenceParam = Schema.Struct({ +export const BetaSkillReferenceParam = Schema.Struct({ "type": Schema.Literal("skill_reference").annotate({ "description": "References a skill created with the /v1/skills endpoint." }), - "skill_id": Schema.String.annotate({ "description": "The ID of the referenced skill." }).check(Schema.isMinLength(1)) - .check(Schema.isMaxLength(64)), + "skill_id": Schema.String.annotate({ "description": "The ID of the referenced skill." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), "version": Schema.optionalKey( Schema.String.annotate({ "description": "Optional skill version. Use a positive integer or 'latest'. Omit for default." }) ) -}) -export type InlineSkillParam = { - readonly "type": "inline" - readonly "name": string - readonly "description": string - readonly "source": { readonly "type": "base64"; readonly "media_type": "application/zip"; readonly "data": string } -} -export const InlineSkillParam = Schema.Struct({ - "type": Schema.Literal("inline").annotate({ "description": "Defines an inline skill for this request." }), +}).annotate({ "identifier": "BetaSkillReferenceParam" }) +export type BetaInlineSkillSourceParam = { + readonly "type": "base64" + readonly "media_type": "application/zip" + readonly "data": string +} +export const BetaInlineSkillSourceParam = Schema.Struct({ + "type": Schema.Literal("base64").annotate({ + "description": "The type of the inline skill source. Must be `base64`." + }), + "media_type": Schema.Literal("application/zip").annotate({ + "description": "The media type of the inline skill payload. Must be `application/zip`." + }), + "data": Schema.String.annotate({ "description": "Base64-encoded skill zip bundle." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(70254592).annotate({ "expected": "a value with a length of at most 70254592" })) +}).annotate({ "description": "Inline skill payload", "identifier": "BetaInlineSkillSourceParam" }) +export type BetaLocalSkillParam = { readonly "name": string; readonly "description": string; readonly "path": string } +export const BetaLocalSkillParam = Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the skill." }), "description": Schema.String.annotate({ "description": "The description of the skill." }), - "source": Schema.Struct({ - "type": Schema.Literal("base64").annotate({ - "description": "The type of the inline skill source. Must be `base64`." - }), - "media_type": Schema.Literal("application/zip").annotate({ - "description": "The media type of the inline skill payload. Must be `application/zip`." - }), - "data": Schema.String.annotate({ "description": "Base64-encoded skill zip bundle." }).check(Schema.isMinLength(1)) - .check(Schema.isMaxLength(70254592)) - }).annotate({ "description": "Inline skill payload" }) -}) -export type ContainerNetworkPolicyDisabledParam = { readonly "type": "disabled" } -export const ContainerNetworkPolicyDisabledParam = Schema.Struct({ - "type": Schema.Literal("disabled").annotate({ "description": "Disable outbound network access. Always `disabled`." }) -}) -export type ContainerNetworkPolicyDomainSecretParam = { - readonly "domain": string - readonly "name": string - readonly "value": string + "path": Schema.String.annotate({ "description": "The path to the directory containing the skill." }) +}).annotate({ "identifier": "BetaLocalSkillParam" }) +export type BetaContainerReferenceParam = { readonly "type": "container_reference"; readonly "container_id": string } +export const BetaContainerReferenceParam = 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." }) +}).annotate({ "identifier": "BetaContainerReferenceParam" }) +export type BetaCustomTextFormatParam = { readonly "type": "text" } +export const BetaCustomTextFormatParam = Schema.Struct({ + "type": Schema.Literal("text").annotate({ "description": "Unconstrained text format. Always `text`." }) +}).annotate({ + "title": "Text format", + "description": "Unconstrained free-form text.", + "identifier": "BetaCustomTextFormatParam" +}) +export type BetaGrammarSyntax1 = "lark" | "regex" +export const BetaGrammarSyntax1 = Schema.Literals(["lark", "regex"]).annotate({ "identifier": "BetaGrammarSyntax1" }) +export type BetaEmptyModelParam = {} +export const BetaEmptyModelParam = Schema.Struct({}).annotate({ "identifier": "BetaEmptyModelParam" }) +export type BetaToolSearchExecutionType = "server" | "client" +export const BetaToolSearchExecutionType = Schema.Literals(["server", "client"]).annotate({ + "identifier": "BetaToolSearchExecutionType" +}) +export type BetaApproximateLocation = { + readonly "type": "approximate" + readonly "country"?: string | null + readonly "region"?: string | null + readonly "city"?: string | null + readonly "timezone"?: string | null } -export const ContainerNetworkPolicyDomainSecretParam = Schema.Struct({ - "domain": Schema.String.annotate({ "description": "The domain associated with the secret." }).check( - Schema.isMinLength(1) +export const BetaApproximateLocation = 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 + ]) ), - "name": Schema.String.annotate({ "description": "The name of the secret to inject for the domain." }).check( - Schema.isMinLength(1) + "region": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "Free text input for the region of the user, e.g. `California`." }), + Schema.Null + ]) ), - "value": Schema.String.annotate({ "description": "The secret value to inject for the domain." }).check( - Schema.isMinLength(1) - ).check(Schema.isMaxLength(10485760)) + "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({ "identifier": "BetaApproximateLocation" }) +export type BetaSearchContextSize = "low" | "medium" | "high" +export const BetaSearchContextSize = Schema.Literals(["low", "medium", "high"]).annotate({ + "identifier": "BetaSearchContextSize" }) -export type IncludeEnum = - | "file_search_call.results" - | "web_search_call.results" - | "web_search_call.action.sources" - | "message.input_image.image_url" - | "computer_call_output.output.image_url" - | "code_interpreter_call.outputs" - | "reasoning.encrypted_content" - | "message.output_text.logprobs" -export const IncludeEnum = Schema.Literals([ - "file_search_call.results", - "web_search_call.results", - "web_search_call.action.sources", - "message.input_image.image_url", - "computer_call_output.output.image_url", - "code_interpreter_call.outputs", - "reasoning.encrypted_content", - "message.output_text.logprobs" -]).annotate({ +export type BetaSearchContentType = "text" | "image" +export const BetaSearchContentType = Schema.Literals(["text", "image"]).annotate({ + "identifier": "BetaSearchContentType" +}) +export type BetaToolChoiceOptions = "none" | "auto" | "required" +export const BetaToolChoiceOptions = Schema.Literals(["none", "auto", "required"]).annotate({ + "title": "Tool choice mode", "description": - "Specify additional output data to include in the model response. Currently supported values are:\n- `web_search_call.results`: Include the search results of the web search tool call.\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)." + "Controls which (if any) tool is called by the model.\n\n`none` means the model will not call any tool and instead generates a message.\n\n`auto` means the model can pick between generating a message or calling one or\nmore tools.\n\n`required` means the model must call one or more tools.\n", + "identifier": "BetaToolChoiceOptions" }) -export type InputTextContent = { readonly "type": "input_text"; readonly "text": string } -export const InputTextContent = Schema.Struct({ - "type": Schema.Literal("input_text").annotate({ "description": "The type of the input item. Always `input_text`." }), - "text": Schema.String.annotate({ "description": "The text input to the model." }) -}).annotate({ "title": "Input text", "description": "A text input to the model." }) -export type FileCitationBody = { +export type BetaToolChoiceAllowed = { + readonly "type": "allowed_tools" + readonly "mode": "auto" | "required" + readonly "tools": ReadonlyArray<{}> +} +export const BetaToolChoiceAllowed = Schema.Struct({ + "type": Schema.Literal("allowed_tools").annotate({ + "description": "Allowed tool configuration type. Always `allowed_tools`." + }), + "mode": Schema.Literals(["auto", "required"]).annotate({ + "description": + "Constrains the tools available to the model to a pre-defined set.\n\n`auto` allows the model to pick from among the allowed tools and generate a\nmessage.\n\n`required` requires the model to call one or more of the allowed tools.\n" + }), + "tools": Schema.Array( + Schema.Struct({}).annotate({ "description": "A tool definition that the model should be allowed to call.\n" }) + ).annotate({ + "description": + "A list of tool definitions that the model should be allowed to call.\n\nFor the Responses API, the list of tool definitions might look like:\n```json\n[\n { \"type\": \"function\", \"name\": \"get_weather\" },\n { \"type\": \"mcp\", \"server_label\": \"deepwiki\" },\n { \"type\": \"image_generation\" }\n]\n```\n" + }) +}).annotate({ + "title": "Allowed tools", + "description": "Constrains the tools available to the model to a pre-defined set.\n", + "identifier": "BetaToolChoiceAllowed" +}) +export type BetaToolChoiceTypes = { + readonly "type": + | "file_search" + | "web_search_preview" + | "computer" + | "computer_use_preview" + | "computer_use" + | "web_search_preview_2025_03_11" + | "image_generation" + | "code_interpreter" +} +export const BetaToolChoiceTypes = 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`\n- `computer_use_preview`\n- `computer_use`\n- `code_interpreter`\n- `image_generation`\n" + }) +}).annotate({ + "title": "Hosted tool", + "description": + "Indicates that the model should use a built-in tool to generate a response.\n[Learn more about built-in tools](/docs/guides/tools).\n", + "identifier": "BetaToolChoiceTypes" +}) +export type BetaToolChoiceFunction = { readonly "type": "function"; readonly "name": string } +export const BetaToolChoiceFunction = Schema.Struct({ + "type": Schema.Literal("function").annotate({ + "description": "For function calling, the type is always `function`." + }), + "name": Schema.String.annotate({ "description": "The name of the function to call." }) +}).annotate({ + "title": "Function tool", + "description": "Use this option to force the model to call a specific function.\n", + "identifier": "BetaToolChoiceFunction" +}) +export type BetaToolChoiceMCP = { + readonly "type": "mcp" + readonly "server_label": string + readonly "name"?: string | null +} +export const BetaToolChoiceMCP = Schema.Struct({ + "type": Schema.Literal("mcp").annotate({ "description": "For MCP tools, the type is always `mcp`." }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server to use.\n" }), + "name": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The name of the tool to call on the server.\n" }), + Schema.Null + ]) + ) +}).annotate({ + "title": "MCP tool", + "description": "Use this option to force the model to call a specific tool on a remote MCP server.\n", + "identifier": "BetaToolChoiceMCP" +}) +export type BetaToolChoiceCustom = { readonly "type": "custom"; readonly "name": string } +export const BetaToolChoiceCustom = Schema.Struct({ + "type": Schema.Literal("custom").annotate({ "description": "For custom tool calling, the type is always `custom`." }), + "name": Schema.String.annotate({ "description": "The name of the custom tool to call." }) +}).annotate({ + "title": "Custom tool", + "description": "Use this option to force the model to call a specific custom tool.\n", + "identifier": "BetaToolChoiceCustom" +}) +export type BetaSpecificProgrammaticToolCallingParam = { readonly "type": "programmatic_tool_calling" } +export const BetaSpecificProgrammaticToolCallingParam = Schema.Struct({ + "type": Schema.Literal("programmatic_tool_calling").annotate({ + "description": "The tool to call. Always `programmatic_tool_calling`." + }) +}).annotate({ "identifier": "BetaSpecificProgrammaticToolCallingParam" }) +export type BetaSpecificApplyPatchParam = { readonly "type": "apply_patch" } +export const BetaSpecificApplyPatchParam = Schema.Struct({ + "type": Schema.Literal("apply_patch").annotate({ "description": "The tool to call. Always `apply_patch`." }) +}).annotate({ + "title": "Specific apply patch tool choice", + "description": "Forces the model to call the apply_patch tool when executing a tool call.", + "identifier": "BetaSpecificApplyPatchParam" +}) +export type BetaSpecificFunctionShellParam = { readonly "type": "shell" } +export const BetaSpecificFunctionShellParam = Schema.Struct({ + "type": Schema.Literal("shell").annotate({ "description": "The tool to call. Always `shell`." }) +}).annotate({ + "title": "Specific shell tool choice", + "description": "Forces the model to call the shell tool when a tool call is required.", + "identifier": "BetaSpecificFunctionShellParam" +}) +export type BetaResponsePromptVariables = {} | null +export const BetaResponsePromptVariables = Schema.Union([ + Schema.Struct({}).annotate({ + "title": "Prompt Variables", + "description": + "Optional map of values to substitute in for variables in your\nprompt. The substitution values can either be strings, or other\nResponse input types like images or files.\n" + }), + Schema.Null +]).annotate({ "identifier": "BetaResponsePromptVariables" }) +export type BetaReasoningModeEnum = string | "standard" | "pro" +export const BetaReasoningModeEnum = Schema.Union([Schema.String, Schema.Literals(["standard", "pro"])]).annotate({ + "identifier": "BetaReasoningModeEnum" +}) +export type BetaReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | null +export const BetaReasoningEffort = Schema.Union([ + Schema.Literals(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).annotate({ + "description": + "Constrains effort on reasoning for reasoning models. Currently supported\nvalues are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.\nReducing reasoning effort can result in faster responses and fewer tokens\nused on reasoning in a response. Not all reasoning models support every\nvalue. See the\n[reasoning guide](https://platform.openai.com/docs/guides/reasoning)\nfor model-specific support.\n" + }), + Schema.Null +]).annotate({ "identifier": "BetaReasoningEffort" }) +export type BetaPromptCacheBreakpointConfig = { readonly "mode": "explicit" } +export const BetaPromptCacheBreakpointConfig = Schema.Struct({ + "mode": Schema.Literal("explicit").annotate({ "description": "The breakpoint mode. Always `explicit`." }) +}).annotate({ + "title": "Prompt cache breakpoint", + "description": + "Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.", + "identifier": "BetaPromptCacheBreakpointConfig" +}) +export type BetaImageDetail = "low" | "high" | "auto" | "original" +export const BetaImageDetail = Schema.Literals(["low", "high", "auto", "original"]).annotate({ + "identifier": "BetaImageDetail" +}) +export type BetaFileInputDetail = "auto" | "low" | "high" +export const BetaFileInputDetail = Schema.Literals(["auto", "low", "high"]).annotate({ + "identifier": "BetaFileInputDetail" +}) +export type BetaMessagePhase = "commentary" | "final_answer" +export const BetaMessagePhase = 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", + "identifier": "BetaMessagePhase" +}) +export type BetaAgentTag = { readonly "agent_name": string } +export const BetaAgentTag = Schema.Struct({ + "agent_name": Schema.String.annotate({ "description": "The canonical name of the agent that produced this item." }) +}).annotate({ "identifier": "BetaAgentTag" }) +export type BetaFileCitationBody = { readonly "type": "file_citation" readonly "file_id": string readonly "index": number readonly "filename": string } -export const FileCitationBody = Schema.Struct({ +export const BetaFileCitationBody = Schema.Struct({ "type": Schema.Literal("file_citation").annotate({ "description": "The type of the file citation. Always `file_citation`." }), "file_id": Schema.String.annotate({ "description": "The ID of the file." }), "index": Schema.Number.annotate({ "description": "The index of the file in the list of files." }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ), "filename": Schema.String.annotate({ "description": "The filename of the file cited." }) -}).annotate({ "title": "File citation", "description": "A citation to a file." }) -export type UrlCitationBody = { +}).annotate({ "title": "File citation", "description": "A citation to a file.", "identifier": "BetaFileCitationBody" }) +export type BetaUrlCitationBody = { readonly "type": "url_citation" readonly "url": string readonly "start_index": number readonly "end_index": number readonly "title": string } -export const UrlCitationBody = Schema.Struct({ +export const BetaUrlCitationBody = Schema.Struct({ "type": Schema.Literal("url_citation").annotate({ "description": "The type of the URL citation. Always `url_citation`." }), "url": Schema.String.annotate({ "description": "The URL of the web resource.", "format": "uri" }), "start_index": Schema.Number.annotate({ "description": "The index of the first character of the URL citation in the message." - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "end_index": Schema.Number.annotate({ "description": "The index of the last character of the URL citation in the message." - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "title": Schema.String.annotate({ "description": "The title of the web resource." }) }).annotate({ "title": "URL citation", - "description": "A citation for a web resource used to generate a model response." + "description": "A citation for a web resource used to generate a model response.", + "identifier": "BetaUrlCitationBody" }) -export type ContainerFileCitationBody = { +export type BetaContainerFileCitationBody = { readonly "type": "container_file_citation" readonly "container_id": string readonly "file_id": string @@ -8609,7 +10051,7 @@ export type ContainerFileCitationBody = { readonly "end_index": number readonly "filename": string } -export const ContainerFileCitationBody = Schema.Struct({ +export const BetaContainerFileCitationBody = Schema.Struct({ "type": Schema.Literal("container_file_citation").annotate({ "description": "The type of the container file citation. Always `container_file_citation`." }), @@ -8617,225 +10059,139 @@ export const ContainerFileCitationBody = Schema.Struct({ "file_id": Schema.String.annotate({ "description": "The ID of the file." }), "start_index": Schema.Number.annotate({ "description": "The index of the first character of the container file citation in the message." - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "end_index": Schema.Number.annotate({ "description": "The index of the last character of the container file citation in the message." - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "filename": Schema.String.annotate({ "description": "The filename of the container file cited." }) }).annotate({ "title": "Container file citation", - "description": "A citation for a container file used to generate a model response." + "description": "A citation for a container file used to generate a model response.", + "identifier": "BetaContainerFileCitationBody" }) -export type TopLogProb = { +export type BetaFilePath = { readonly "type": "file_path"; readonly "file_id": string; readonly "index": number } +export const BetaFilePath = Schema.Struct({ + "type": Schema.Literal("file_path").annotate({ "description": "The type of the file path. Always `file_path`.\n" }), + "file_id": Schema.String.annotate({ "description": "The ID of the file.\n" }), + "index": Schema.Number.annotate({ "description": "The index of the file in the list of files.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "title": "File path", "description": "A path to a file.\n", "identifier": "BetaFilePath" }) +export type BetaTopLogProb = { readonly "token": string readonly "logprob": number readonly "bytes": ReadonlyArray } -export const TopLogProb = Schema.Struct({ +export const BetaTopLogProb = Schema.Struct({ "token": Schema.String, - "logprob": Schema.Number.check(Schema.isFinite()), - "bytes": Schema.Array(Schema.Number.check(Schema.isInt())) -}).annotate({ "title": "Top log probability", "description": "The top log probability of a token." }) -export type TextContent = { readonly "type": "text"; readonly "text": string } -export const TextContent = Schema.Struct({ "type": Schema.Literal("text"), "text": Schema.String }).annotate({ - "title": "Text Content", - "description": "A text content." + "logprob": Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) +}).annotate({ + "title": "Top log probability", + "description": "The top log probability of a token.", + "identifier": "BetaTopLogProb" }) -export type SummaryTextContent = { readonly "type": "summary_text"; readonly "text": string } -export const SummaryTextContent = Schema.Struct({ - "type": Schema.Literal("summary_text").annotate({ "description": "The type of the object. Always `summary_text`." }), - "text": Schema.String.annotate({ "description": "A summary of the reasoning output from the model so far." }) -}).annotate({ "title": "Summary text", "description": "A summary text from the model." }) -export type ReasoningTextContent = { readonly "type": "reasoning_text"; readonly "text": string } -export const ReasoningTextContent = Schema.Struct({ - "type": Schema.Literal("reasoning_text").annotate({ - "description": "The type of the reasoning text. Always `reasoning_text`." - }), - "text": Schema.String.annotate({ "description": "The reasoning text from the model." }) -}).annotate({ "title": "Reasoning text", "description": "Reasoning text from the model." }) -export type RefusalContent = { readonly "type": "refusal"; readonly "refusal": string } -export const RefusalContent = Schema.Struct({ +export type BetaRefusalContent = { readonly "type": "refusal"; readonly "refusal": string } +export const BetaRefusalContent = Schema.Struct({ "type": Schema.Literal("refusal").annotate({ "description": "The type of the refusal. Always `refusal`." }), "refusal": Schema.String.annotate({ "description": "The refusal explanation from the model." }) -}).annotate({ "title": "Refusal", "description": "A refusal from the model." }) -export type InputImageContent = { - readonly "type": "input_image" - readonly "image_url"?: string | null - readonly "file_id"?: string | null - readonly "detail": "low" | "high" | "auto" | "original" +}).annotate({ "title": "Refusal", "description": "A refusal from the model.", "identifier": "BetaRefusalContent" }) +export type BetaVectorStoreFileAttributes = {} | null +export const BetaVectorStoreFileAttributes = 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. Keys are strings\nwith a maximum length of 64 characters. Values are strings with a maximum\nlength of 512 characters, booleans, or numbers.\n" + }).check(Schema.isMaxProperties(16).annotate({ "expected": "a value with at most 16 entries" })).check( + Schema.isPropertyNames( + Schema.String.check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })) + ).annotate({ "expected": "an object with property names matching the schema" }) + ), + Schema.Null +]).annotate({ "identifier": "BetaVectorStoreFileAttributes" }) +export type BetaClickButtonType = "left" | "right" | "wheel" | "back" | "forward" +export const BetaClickButtonType = Schema.Literals(["left", "right", "wheel", "back", "forward"]).annotate({ + "identifier": "BetaClickButtonType" +}) +export type BetaDoubleClickAction = { + readonly "type": "double_click" + readonly "x": number + readonly "y": number + readonly "keys": ReadonlyArray | null } -export const InputImageContent = Schema.Struct({ - "type": Schema.Literal("input_image").annotate({ - "description": "The type of the input item. Always `input_image`." +export const BetaDoubleClickAction = Schema.Struct({ + "type": Schema.Literal("double_click").annotate({ + "description": "Specifies the event type. For a double click action, this property is always set to `double_click`." }), - "image_url": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.", - "format": "uri" - }), - Schema.Null - ]) + "x": Schema.Number.annotate({ "description": "The x-coordinate where the double click occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "file_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), - Schema.Null - ]) + "y": Schema.Number.annotate({ "description": "The y-coordinate where the double click occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "detail": Schema.Literals(["low", "high", "auto", "original"]).annotate({ + "keys": Schema.Union([ + Schema.Array(Schema.String).annotate({ "description": "The keys being held while double-clicking." }), + Schema.Null + ]) +}).annotate({ "title": "DoubleClick", "description": "A double click action.", "identifier": "BetaDoubleClickAction" }) +export type BetaCoordParam = { readonly "x": number; readonly "y": number } +export const BetaCoordParam = Schema.Struct({ + "x": Schema.Number.annotate({ "description": "The x-coordinate." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "y": Schema.Number.annotate({ "description": "The y-coordinate." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "Coordinate", + "description": "An x/y coordinate pair, e.g. `{ x: 100, y: 200 }`.", + "identifier": "BetaCoordParam" +}) +export type BetaKeyPressAction = { readonly "type": "keypress"; readonly "keys": ReadonlyArray } +export const BetaKeyPressAction = Schema.Struct({ + "type": Schema.Literal("keypress").annotate({ + "description": "Specifies the event type. For a keypress action, this property is always set to `keypress`." + }), + "keys": Schema.Array( + Schema.String.annotate({ "description": "One of the keys the model is requesting to be pressed." }) + ).annotate({ "description": - "The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`." + "The combination of keys the model is requesting to be pressed. This is an array of strings, each representing a key." }) }).annotate({ - "title": "Input image", - "description": "An image input to the model. Learn about [image inputs](/docs/guides/vision)." + "title": "KeyPress", + "description": "A collection of keypresses the model would like to perform.", + "identifier": "BetaKeyPressAction" }) -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({ - "description": - "Specifies the event type. For a computer screenshot, this property is always set to `computer_screenshot`." - }), - "image_url": Schema.Union([ - Schema.String.annotate({ "description": "The URL of the screenshot image.", "format": "uri" }), - Schema.Null - ]), - "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_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`." }), - "file_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), - Schema.Null - ]) - ), - "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.", "format": "uri" }) - ), - "detail": Schema.optionalKey( - Schema.Literals(["low", "high"]).annotate({ - "description": - "The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`." - }) - ) -}).annotate({ "title": "Input file", "description": "A file input to the model." }) -export type ClickParam = { - readonly "type": "click" - readonly "button": "left" | "right" | "wheel" | "back" | "forward" - readonly "x": number - readonly "y": number - readonly "keys"?: ReadonlyArray | null -} -export const ClickParam = Schema.Struct({ - "type": Schema.Literal("click").annotate({ - "description": "Specifies the event type. For a click action, this property is always `click`." - }), - "button": Schema.Literals(["left", "right", "wheel", "back", "forward"]).annotate({ - "description": - "Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`." - }), - "x": Schema.Number.annotate({ "description": "The x-coordinate where the click occurred." }).check(Schema.isInt()), - "y": Schema.Number.annotate({ "description": "The y-coordinate where the click occurred." }).check(Schema.isInt()), - "keys": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).annotate({ "description": "The keys being held while clicking." }), - Schema.Null - ]) - ) -}).annotate({ "title": "Click", "description": "A click action." }) -export type DoubleClickAction = { - readonly "type": "double_click" - readonly "x": number - readonly "y": number - readonly "keys": ReadonlyArray | null -} -export const DoubleClickAction = Schema.Struct({ - "type": Schema.Literal("double_click").annotate({ - "description": "Specifies the event type. For a double click action, this property is always set to `double_click`." - }), - "x": Schema.Number.annotate({ "description": "The x-coordinate where the double click occurred." }).check( - Schema.isInt() - ), - "y": Schema.Number.annotate({ "description": "The y-coordinate where the double click occurred." }).check( - Schema.isInt() - ), - "keys": Schema.Union([ - Schema.Array(Schema.String).annotate({ "description": "The keys being held while double-clicking." }), - Schema.Null - ]) -}).annotate({ "title": "DoubleClick", "description": "A double click action." }) -export type CoordParam = { readonly "x": number; readonly "y": number } -export const CoordParam = Schema.Struct({ - "x": Schema.Number.annotate({ "description": "The x-coordinate." }).check(Schema.isInt()), - "y": Schema.Number.annotate({ "description": "The y-coordinate." }).check(Schema.isInt()) -}).annotate({ "title": "Coordinate", "description": "An x/y coordinate pair, e.g. `{ x: 100, y: 200 }`." }) -export type KeyPressAction = { readonly "type": "keypress"; readonly "keys": ReadonlyArray } -export const KeyPressAction = Schema.Struct({ - "type": Schema.Literal("keypress").annotate({ - "description": "Specifies the event type. For a keypress action, this property is always set to `keypress`." - }), - "keys": Schema.Array( - Schema.String.annotate({ "description": "One of the keys the model is requesting to be pressed." }) - ).annotate({ - "description": - "The combination of keys the model is requesting to be pressed. This is an array of strings, each representing a key." - }) -}).annotate({ "title": "KeyPress", "description": "A collection of keypresses the model would like to perform." }) -export type MoveParam = { +export type BetaMoveParam = { readonly "type": "move" readonly "x": number readonly "y": number readonly "keys"?: ReadonlyArray | null } -export const MoveParam = Schema.Struct({ +export const BetaMoveParam = Schema.Struct({ "type": Schema.Literal("move").annotate({ "description": "Specifies the event type. For a move action, this property is always set to `move`." }), - "x": Schema.Number.annotate({ "description": "The x-coordinate to move to." }).check(Schema.isInt()), - "y": Schema.Number.annotate({ "description": "The y-coordinate to move to." }).check(Schema.isInt()), + "x": Schema.Number.annotate({ "description": "The x-coordinate to move to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "y": Schema.Number.annotate({ "description": "The y-coordinate to move to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), "keys": Schema.optionalKey( Schema.Union([ Schema.Array(Schema.String).annotate({ "description": "The keys being held while moving the mouse." }), Schema.Null ]) ) -}).annotate({ "title": "Move", "description": "A mouse move action." }) -export type ScreenshotParam = { readonly "type": "screenshot" } -export const ScreenshotParam = Schema.Struct({ +}).annotate({ "title": "Move", "description": "A mouse move action.", "identifier": "BetaMoveParam" }) +export type BetaScreenshotParam = { readonly "type": "screenshot" } +export const BetaScreenshotParam = Schema.Struct({ "type": Schema.Literal("screenshot").annotate({ "description": "Specifies the event type. For a screenshot action, this property is always set to `screenshot`." }) -}).annotate({ "title": "Screenshot", "description": "A screenshot action." }) -export type ScrollParam = { +}).annotate({ "title": "Screenshot", "description": "A screenshot action.", "identifier": "BetaScreenshotParam" }) +export type BetaScrollParam = { readonly "type": "scroll" readonly "x": number readonly "y": number @@ -8843,40 +10199,48 @@ export type ScrollParam = { readonly "scroll_y": number readonly "keys"?: ReadonlyArray | null } -export const ScrollParam = Schema.Struct({ +export const BetaScrollParam = Schema.Struct({ "type": Schema.Literal("scroll").annotate({ "description": "Specifies the event type. For a scroll action, this property is always set to `scroll`." }), - "x": Schema.Number.annotate({ "description": "The x-coordinate where the scroll occurred." }).check(Schema.isInt()), - "y": Schema.Number.annotate({ "description": "The y-coordinate where the scroll occurred." }).check(Schema.isInt()), - "scroll_x": Schema.Number.annotate({ "description": "The horizontal scroll distance." }).check(Schema.isInt()), - "scroll_y": Schema.Number.annotate({ "description": "The vertical scroll distance." }).check(Schema.isInt()), + "x": Schema.Number.annotate({ "description": "The x-coordinate where the scroll occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "y": Schema.Number.annotate({ "description": "The y-coordinate where the scroll occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "scroll_x": Schema.Number.annotate({ "description": "The horizontal scroll distance." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "scroll_y": Schema.Number.annotate({ "description": "The vertical scroll distance." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), "keys": Schema.optionalKey( Schema.Union([ Schema.Array(Schema.String).annotate({ "description": "The keys being held while scrolling." }), Schema.Null ]) ) -}).annotate({ "title": "Scroll", "description": "A scroll action." }) -export type TypeParam = { readonly "type": "type"; readonly "text": string } -export const TypeParam = Schema.Struct({ +}).annotate({ "title": "Scroll", "description": "A scroll action.", "identifier": "BetaScrollParam" }) +export type BetaTypeParam = { readonly "type": "type"; readonly "text": string } +export const BetaTypeParam = Schema.Struct({ "type": Schema.Literal("type").annotate({ "description": "Specifies the event type. For a type action, this property is always set to `type`." }), "text": Schema.String.annotate({ "description": "The text to type." }) -}).annotate({ "title": "Type", "description": "An action to type in text." }) -export type WaitParam = { readonly "type": "wait" } -export const WaitParam = Schema.Struct({ +}).annotate({ "title": "Type", "description": "An action to type in text.", "identifier": "BetaTypeParam" }) +export type BetaWaitParam = { readonly "type": "wait" } +export const BetaWaitParam = Schema.Struct({ "type": Schema.Literal("wait").annotate({ "description": "Specifies the event type. For a wait action, this property is always set to `wait`." }) -}).annotate({ "title": "Wait", "description": "A wait action." }) -export type ComputerCallSafetyCheckParam = { +}).annotate({ "title": "Wait", "description": "A wait action.", "identifier": "BetaWaitParam" }) +export type BetaComputerCallSafetyCheckParam = { readonly "id": string readonly "code"?: string | null readonly "message"?: string | null } -export const ComputerCallSafetyCheckParam = Schema.Struct({ +export const BetaComputerCallSafetyCheckParam = Schema.Struct({ "id": Schema.String.annotate({ "description": "The ID of the pending safety check." }), "code": Schema.optionalKey( Schema.Union([Schema.String.annotate({ "description": "The type of the pending safety check." }), Schema.Null]) @@ -8884,223 +10248,211 @@ export const ComputerCallSafetyCheckParam = Schema.Struct({ "message": Schema.optionalKey( 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 +}).annotate({ + "description": "A pending safety check for the computer call.", + "identifier": "BetaComputerCallSafetyCheckParam" +}) +export type Beta_AgentTagParam = { readonly "agent_name": string } +export const Beta_AgentTagParam = Schema.Struct({ + "agent_name": Schema.String.annotate({ "description": "The canonical name of the agent that produced this item." }) +}).annotate({ "description": "The agent that produced this item.", "identifier": "Beta_AgentTagParam" }) +export type BetaComputerScreenshotImage = { + readonly "type": "computer_screenshot" + readonly "image_url"?: string + readonly "file_id"?: 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." +export const BetaComputerScreenshotImage = Schema.Struct({ + "type": Schema.Literal("computer_screenshot").annotate({ + "description": + "Specifies the event type. For a computer screenshot, this property is \nalways set to `computer_screenshot`.\n" }), - "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 - ]) + "image_url": Schema.optionalKey( + Schema.String.annotate({ "description": "The URL of the screenshot image.", "format": "uri" }) ), - "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." }) + "file_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of an uploaded file that contains the screenshot." }) ) }).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`." }) + "description": "A computer screenshot image used with the computer use tool.\n", + "identifier": "BetaComputerScreenshotImage" +}) +export type BetaFunctionCallItemStatus = "in_progress" | "completed" | "incomplete" +export const BetaFunctionCallItemStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "BetaFunctionCallItemStatus" +}) +export type BetaDirectToolCallCaller = { readonly "type": "direct" } +export const BetaDirectToolCallCaller = Schema.Struct({ "type": Schema.Literal("direct") }).annotate({ + "identifier": "BetaDirectToolCallCaller" +}) +export type BetaProgramToolCallCaller = { readonly "type": "program"; readonly "caller_id": string } +export const BetaProgramToolCallCaller = Schema.Struct({ + "type": Schema.Literal("program"), + "caller_id": Schema.String.annotate({ + "description": "The call ID of the program item that produced this tool call." + }) +}).annotate({ "identifier": "BetaProgramToolCallCaller" }) +export type BetaPromptCacheBreakpointParam = { readonly "mode": "explicit" } +export const BetaPromptCacheBreakpointParam = Schema.Struct({ + "mode": Schema.Literal("explicit").annotate({ "description": "The breakpoint mode. Always `explicit`." }) }).annotate({ - "title": "Computer", + "title": "Prompt cache breakpoint", "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 + "Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.", + "identifier": "BetaPromptCacheBreakpointParam" +}) +export type BetaDetailEnum = "low" | "high" | "auto" | "original" +export const BetaDetailEnum = Schema.Literals(["low", "high", "auto", "original"]).annotate({ + "identifier": "BetaDetailEnum" +}) +export type BetaFileDetailEnum = "auto" | "low" | "high" +export const BetaFileDetailEnum = Schema.Literals(["auto", "low", "high"]).annotate({ + "identifier": "BetaFileDetailEnum" +}) +export type BetaDirectToolCallCallerParam = { readonly "type": "direct" } +export const BetaDirectToolCallCallerParam = Schema.Struct({ + "type": Schema.Literal("direct").annotate({ "description": "The caller type. Always `direct`." }) +}).annotate({ "identifier": "BetaDirectToolCallCallerParam" }) +export type BetaProgramToolCallCallerParam = { readonly "type": "program"; readonly "caller_id": string } +export const BetaProgramToolCallCallerParam = Schema.Struct({ + "type": Schema.Literal("program").annotate({ "description": "The caller type. Always `program`." }), + "caller_id": Schema.String.annotate({ + "description": "The call ID of the program item that produced this tool call." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ) +}).annotate({ "identifier": "BetaProgramToolCallCallerParam" }) +export type BetaEncryptedContentParam = { readonly "type": "encrypted_content"; readonly "encrypted_content": string } +export const BetaEncryptedContentParam = Schema.Struct({ + "type": Schema.Literal("encrypted_content").annotate({ + "description": "The type of the input item. Always `encrypted_content`." + }), + "encrypted_content": Schema.String.annotate({ "description": "Opaque encrypted content." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ) +}).annotate({ + "title": "Encrypted content", + "description": "Opaque encrypted content that Responses API decrypts inside trusted model execution.", + "identifier": "BetaEncryptedContentParam" +}) +export type BetaMultiAgentAction1 = + | "spawn_agent" + | "interrupt_agent" + | "list_agents" + | "send_message" + | "followup_task" + | "wait_agent" +export const BetaMultiAgentAction1 = Schema.Literals([ + "spawn_agent", + "interrupt_agent", + "list_agents", + "send_message", + "followup_task", + "wait_agent" +]).annotate({ "identifier": "BetaMultiAgentAction1" }) +export type BetaFileCitationParam = { + readonly "type": "file_citation" + readonly "index": number + readonly "file_id": string + readonly "filename": string } -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." +export const BetaFileCitationParam = Schema.Struct({ + "type": Schema.Literal("file_citation").annotate({ "description": "The citation type. Always `file_citation`." }), + "index": Schema.Number.annotate({ "description": "The index of the file in the list of files." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "file_id": Schema.String.annotate({ "description": "The ID of the file." }), + "filename": Schema.String.annotate({ "description": "The filename of the file cited." }) +}).annotate({ "identifier": "BetaFileCitationParam" }) +export type BetaUrlCitationParam = { + readonly "type": "url_citation" + readonly "start_index": number + readonly "end_index": number + readonly "url": string + readonly "title": string +} +export const BetaUrlCitationParam = Schema.Struct({ + "type": Schema.Literal("url_citation").annotate({ "description": "The citation type. Always `url_citation`." }), + "start_index": Schema.Number.annotate({ + "description": "The index of the first character of the citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "end_index": Schema.Number.annotate({ + "description": "The index of the last character of the citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "url": Schema.String.annotate({ "description": "The URL of the cited resource.", "format": "uri" }), + "title": Schema.String.annotate({ "description": "The title of the cited resource." }) +}).annotate({ "identifier": "BetaUrlCitationParam" }) +export type BetaContainerFileCitationParam = { + readonly "type": "container_file_citation" + readonly "start_index": number + readonly "end_index": number + readonly "container_id": string + readonly "file_id": string + readonly "filename": string +} +export const BetaContainerFileCitationParam = Schema.Struct({ + "type": Schema.Literal("container_file_citation").annotate({ + "description": "The citation type. Always `container_file_citation`." }), - "display_width": Schema.Number.annotate({ "description": "The width of the computer display." }).check( - Schema.isInt() + "start_index": Schema.Number.annotate({ + "description": "The index of the first character of the citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ), - "display_height": Schema.Number.annotate({ "description": "The height of the computer display." }).check( - Schema.isInt() - ) + "end_index": Schema.Number.annotate({ + "description": "The index of the last character of the citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + "container_id": Schema.String.annotate({ "description": "The ID of the container." }), + "file_id": Schema.String.annotate({ "description": "The ID of the container file." }), + "filename": Schema.String.annotate({ "description": "The filename of the container file cited." }) +}).annotate({ "identifier": "BetaContainerFileCitationParam" }) +export type BetaSummaryTextContent = { readonly "type": "summary_text"; readonly "text": string } +export const BetaSummaryTextContent = Schema.Struct({ + "type": Schema.Literal("summary_text").annotate({ "description": "The type of the object. Always `summary_text`." }), + "text": Schema.String.annotate({ "description": "A summary of the reasoning output from the model so far." }) }).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)." + "title": "Summary text", + "description": "A summary text from the model.", + "identifier": "BetaSummaryTextContent" }) -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 BetaReasoningTextContent = { readonly "type": "reasoning_text"; readonly "text": string } +export const BetaReasoningTextContent = Schema.Struct({ + "type": Schema.Literal("reasoning_text").annotate({ + "description": "The type of the reasoning text. Always `reasoning_text`." + }), + "text": Schema.String.annotate({ "description": "The reasoning text from the model." }) +}).annotate({ + "title": "Reasoning text", + "description": "Reasoning text from the model.", + "identifier": "BetaReasoningTextContent" }) -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`." +export type BetaCodeInterpreterOutputLogs = { readonly "type": "logs"; readonly "logs": string } +export const BetaCodeInterpreterOutputLogs = Schema.Struct({ + "type": Schema.Literal("logs").annotate({ "description": "The type of the output. Always `logs`." }), + "logs": Schema.String.annotate({ "description": "The logs output from the code interpreter." }) +}).annotate({ + "title": "Code interpreter output logs", + "description": "The logs output from the code interpreter.", + "identifier": "BetaCodeInterpreterOutputLogs" +}) +export type BetaCodeInterpreterOutputImage = { readonly "type": "image"; readonly "url": string } +export const BetaCodeInterpreterOutputImage = Schema.Struct({ + "type": Schema.Literal("image").annotate({ "description": "The type of the output. Always `image`." }), + "url": Schema.String.annotate({ + "description": "The URL of the image output from the code interpreter.", + "format": "uri" }) }).annotate({ - "title": "Local shell tool", - "description": "A tool that allows the model to execute shell commands in a local environment." + "title": "Code interpreter output image", + "description": "The image output from the code interpreter.", + "identifier": "BetaCodeInterpreterOutputImage" }) -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 CompactionBody = { - readonly "type": "compaction" - readonly "id": string - readonly "encrypted_content": string - readonly "created_by"?: string -} -export const CompactionBody = Schema.Struct({ - "type": Schema.Literal("compaction").annotate({ "description": "The type of the item. Always `compaction`." }), - "id": Schema.String.annotate({ "description": "The unique ID of the compaction item." }), - "encrypted_content": Schema.String.annotate({ - "description": "The encrypted content that was produced by compaction." - }), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) - ) -}).annotate({ - "title": "Compaction item", - "description": - "A compaction item generated by the [`v1/responses/compact` API](/docs/api-reference/responses/compact)." -}) -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`." }), - "logs": Schema.String.annotate({ "description": "The logs output from the code interpreter." }) -}).annotate({ "title": "Code interpreter output logs", "description": "The logs output from the code interpreter." }) -export type CodeInterpreterOutputImage = { readonly "type": "image"; readonly "url": string } -export const CodeInterpreterOutputImage = Schema.Struct({ - "type": Schema.Literal("image").annotate({ "description": "The type of the output. Always `image`." }), - "url": Schema.String.annotate({ - "description": "The URL of the image output from the code interpreter.", - "format": "uri" - }) -}).annotate({ "title": "Code interpreter output image", "description": "The image output from the code interpreter." }) -export type LocalShellExecAction = { +export type BetaLocalShellExecAction = { readonly "type": "exec" readonly "command": ReadonlyArray readonly "timeout_ms"?: number | null @@ -9108,13 +10460,13 @@ export type LocalShellExecAction = { readonly "env": {} readonly "user"?: string | null } -export const LocalShellExecAction = Schema.Struct({ +export const BetaLocalShellExecAction = Schema.Struct({ "type": Schema.Literal("exec").annotate({ "description": "The type of the local shell action. Always `exec`." }), "command": Schema.Array(Schema.String).annotate({ "description": "The command to run." }), "timeout_ms": Schema.optionalKey( Schema.Union([ Schema.Number.annotate({ "description": "Optional timeout in milliseconds for the command." }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ), Schema.Null ]) @@ -9129,335 +10481,200 @@ export const LocalShellExecAction = Schema.Struct({ "user": Schema.optionalKey( Schema.Union([Schema.String.annotate({ "description": "Optional user to run the command as." }), Schema.Null]) ) -}).annotate({ "title": "Local shell exec action", "description": "Execute a shell command on the server." }) -export type LocalEnvironmentResource = { readonly "type": "local" } -export const LocalEnvironmentResource = Schema.Struct({ - "type": Schema.Literal("local").annotate({ "description": "The environment type. Always `local`." }) -}).annotate({ - "title": "Local Environment", - "description": "Represents the use of a local environment to perform shell actions." -}) -export type ContainerReferenceResource = { readonly "type": "container_reference"; readonly "container_id": string } -export const ContainerReferenceResource = Schema.Struct({ - "type": Schema.Literal("container_reference").annotate({ - "description": "The environment type. Always `container_reference`." - }), - "container_id": Schema.String -}).annotate({ "title": "Container Reference", "description": "Represents a container created with /v1/containers." }) -export type FunctionShellCallOutputTimeoutOutcome = { readonly "type": "timeout" } -export const FunctionShellCallOutputTimeoutOutcome = Schema.Struct({ - "type": Schema.Literal("timeout").annotate({ "description": "The outcome type. Always `timeout`." }) -}).annotate({ - "title": "Shell call timeout outcome", - "description": "Indicates that the shell call exceeded its configured time limit." -}) -export type FunctionShellCallOutputExitOutcome = { readonly "type": "exit"; readonly "exit_code": number } -export const FunctionShellCallOutputExitOutcome = Schema.Struct({ - "type": Schema.Literal("exit").annotate({ "description": "The outcome type. Always `exit`." }), - "exit_code": Schema.Number.annotate({ "description": "Exit code from the shell process." }).check(Schema.isInt()) -}).annotate({ - "title": "Shell call exit outcome", - "description": "Indicates that the shell commands finished and returned an exit code." -}) -export type ApplyPatchCreateFileOperation = { - readonly "type": "create_file" - readonly "path": string - readonly "diff": string -} -export const ApplyPatchCreateFileOperation = Schema.Struct({ - "type": Schema.Literal("create_file").annotate({ "description": "Create a new file with the provided diff." }), - "path": Schema.String.annotate({ "description": "Path of the file to create." }), - "diff": Schema.String.annotate({ "description": "Diff to apply." }) -}).annotate({ - "title": "Apply patch create file operation", - "description": "Instruction describing how to create a file via the apply_patch tool." -}) -export type ApplyPatchDeleteFileOperation = { readonly "type": "delete_file"; readonly "path": string } -export const ApplyPatchDeleteFileOperation = Schema.Struct({ - "type": Schema.Literal("delete_file").annotate({ "description": "Delete the specified file." }), - "path": Schema.String.annotate({ "description": "Path of the file to delete." }) -}).annotate({ - "title": "Apply patch delete file operation", - "description": "Instruction describing how to delete a file via the apply_patch tool." -}) -export type ApplyPatchUpdateFileOperation = { - readonly "type": "update_file" - readonly "path": string - readonly "diff": string -} -export const ApplyPatchUpdateFileOperation = Schema.Struct({ - "type": Schema.Literal("update_file").annotate({ "description": "Update an existing file with the provided diff." }), - "path": Schema.String.annotate({ "description": "Path of the file to update." }), - "diff": Schema.String.annotate({ "description": "Diff to apply." }) -}).annotate({ - "title": "Apply patch update file operation", - "description": "Instruction describing how to update a file via the apply_patch tool." -}) -export type ApplyPatchToolCallOutput = { - readonly "type": "apply_patch_call_output" - readonly "id": string - readonly "call_id": string - readonly "status": "completed" | "failed" - readonly "output"?: string | null - readonly "created_by"?: string -} -export const ApplyPatchToolCallOutput = Schema.Struct({ - "type": Schema.Literal("apply_patch_call_output").annotate({ - "description": "The type of the item. Always `apply_patch_call_output`." - }), - "id": Schema.String.annotate({ - "description": "The unique ID of the apply patch tool call output. Populated when this item is returned via API." - }), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the apply patch tool call generated by the model." - }), - "status": Schema.Literals(["completed", "failed"]).annotate({ - "description": "The status of the apply patch tool call output. One of `completed` or `failed`." - }), - "output": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "Optional textual output returned by the apply patch tool." }), - Schema.Null - ]) - ), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the entity that created this tool call output." }) - ) }).annotate({ - "title": "Apply patch tool call output", - "description": "The output emitted by an apply patch tool call." + "title": "Local shell exec action", + "description": "Execute a shell command on the server.", + "identifier": "BetaLocalShellExecAction" }) -export type InputTextContentParam = { readonly "type": "input_text"; readonly "text": string } -export const InputTextContentParam = Schema.Struct({ - "type": Schema.Literal("input_text").annotate({ "description": "The type of the input item. Always `input_text`." }), - "text": Schema.String.annotate({ "description": "The text input to the model." }).check(Schema.isMaxLength(10485760)) -}).annotate({ "title": "Input text", "description": "A text input to the model." }) -export type InputImageContentParamAutoParam = { - readonly "type": "input_image" - readonly "image_url"?: string | null - readonly "file_id"?: string | null - readonly "detail"?: "low" | "high" | "auto" | "original" | null +export type BetaFunctionShellActionParam = { + readonly "commands": ReadonlyArray + readonly "timeout_ms"?: number | null + readonly "max_output_length"?: number | null } -export const InputImageContentParamAutoParam = Schema.Struct({ - "type": Schema.Literal("input_image").annotate({ - "description": "The type of the input item. Always `input_image`." +export const BetaFunctionShellActionParam = Schema.Struct({ + "commands": Schema.Array(Schema.String).annotate({ + "description": "Ordered shell commands for the execution environment to run." }), - "image_url": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.", - "format": "uri" - }).check(Schema.isMaxLength(20971520)), - Schema.Null - ]) - ), - "file_id": Schema.optionalKey( + "timeout_ms": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), + Schema.Number.annotate({ + "description": "Maximum wall-clock time in milliseconds to allow the shell commands to run." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null ]) ), - "detail": Schema.optionalKey( + "max_output_length": Schema.optionalKey( Schema.Union([ - Schema.Literals(["low", "high", "auto", "original"]).annotate({ - "description": - "The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`." - }), + Schema.Number.annotate({ + "description": "Maximum number of UTF-8 characters to capture from combined stdout and stderr output." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null ]) ) }).annotate({ - "title": "Input image", - "description": "An image input to the model. Learn about [image inputs](/docs/guides/vision)" -}) -export type InputFileContentParam = { - readonly "type": "input_file" - readonly "file_id"?: string | null - readonly "filename"?: string | null - readonly "file_data"?: string | null - readonly "file_url"?: string | null - readonly "detail"?: "low" | "high" -} -export const InputFileContentParam = Schema.Struct({ - "type": Schema.Literal("input_file").annotate({ "description": "The type of the input item. Always `input_file`." }), - "file_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), - Schema.Null - ]) - ), - "filename": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The name of the file to be sent to the model." }), - Schema.Null - ]) - ), - "file_data": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The base64-encoded data of the file to be sent to the model." }).check( - Schema.isMaxLength(73400320) - ), - Schema.Null - ]) - ), - "file_url": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The URL of the file to be sent to the model.", "format": "uri" }), - Schema.Null - ]) - ), - "detail": Schema.optionalKey( - Schema.Literals(["low", "high"]).annotate({ - "description": - "The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`." - }) - ) -}).annotate({ "title": "Input file", "description": "A file input to the model." }) -export type FunctionShellCallOutputTimeoutOutcomeParam = { readonly "type": "timeout" } -export const FunctionShellCallOutputTimeoutOutcomeParam = Schema.Struct({ + "title": "Shell action", + "description": "Commands and limits describing how to run the shell tool call.", + "identifier": "BetaFunctionShellActionParam" +}) +export type BetaFunctionShellCallItemStatus = "in_progress" | "completed" | "incomplete" +export const BetaFunctionShellCallItemStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "title": "Shell call status", + "description": "Status values reported for shell tool calls.", + "identifier": "BetaFunctionShellCallItemStatus" +}) +export type BetaFunctionShellCallOutputTimeoutOutcomeParam = { readonly "type": "timeout" } +export const BetaFunctionShellCallOutputTimeoutOutcomeParam = Schema.Struct({ "type": Schema.Literal("timeout").annotate({ "description": "The outcome type. Always `timeout`." }) }).annotate({ "title": "Shell call timeout outcome", - "description": "Indicates that the shell call exceeded its configured time limit." + "description": "Indicates that the shell call exceeded its configured time limit.", + "identifier": "BetaFunctionShellCallOutputTimeoutOutcomeParam" }) -export type FunctionShellCallOutputExitOutcomeParam = { readonly "type": "exit"; readonly "exit_code": number } -export const FunctionShellCallOutputExitOutcomeParam = Schema.Struct({ +export type BetaFunctionShellCallOutputExitOutcomeParam = { readonly "type": "exit"; readonly "exit_code": number } +export const BetaFunctionShellCallOutputExitOutcomeParam = Schema.Struct({ "type": Schema.Literal("exit").annotate({ "description": "The outcome type. Always `exit`." }), "exit_code": Schema.Number.annotate({ "description": "The exit code returned by the shell process." }).check( - Schema.isInt() + Schema.isInt().annotate({ "expected": "an integer" }) ) }).annotate({ "title": "Shell call exit outcome", - "description": "Indicates that the shell commands finished and returned an exit code." + "description": "Indicates that the shell commands finished and returned an exit code.", + "identifier": "BetaFunctionShellCallOutputExitOutcomeParam" }) -export type ApplyPatchCreateFileOperationParam = { +export type BetaApplyPatchCallStatusParam = "in_progress" | "completed" +export const BetaApplyPatchCallStatusParam = Schema.Literals(["in_progress", "completed"]).annotate({ + "title": "Apply patch call status", + "description": "Status values reported for apply_patch tool calls.", + "identifier": "BetaApplyPatchCallStatusParam" +}) +export type BetaApplyPatchCreateFileOperationParam = { readonly "type": "create_file" readonly "path": string readonly "diff": string } -export const ApplyPatchCreateFileOperationParam = Schema.Struct({ +export const BetaApplyPatchCreateFileOperationParam = Schema.Struct({ "type": Schema.Literal("create_file").annotate({ "description": "The operation type. Always `create_file`." }), "path": Schema.String.annotate({ "description": "Path of the file to create relative to the workspace root." }).check( - Schema.isMinLength(1) + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), "diff": Schema.String.annotate({ "description": "Unified diff content to apply when creating the file." }).check( - Schema.isMaxLength(10485760) + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) ) }).annotate({ "title": "Apply patch create file operation", - "description": "Instruction for creating a new file via the apply_patch tool." + "description": "Instruction for creating a new file via the apply_patch tool.", + "identifier": "BetaApplyPatchCreateFileOperationParam" }) -export type ApplyPatchDeleteFileOperationParam = { readonly "type": "delete_file"; readonly "path": string } -export const ApplyPatchDeleteFileOperationParam = Schema.Struct({ +export type BetaApplyPatchDeleteFileOperationParam = { readonly "type": "delete_file"; readonly "path": string } +export const BetaApplyPatchDeleteFileOperationParam = Schema.Struct({ "type": Schema.Literal("delete_file").annotate({ "description": "The operation type. Always `delete_file`." }), "path": Schema.String.annotate({ "description": "Path of the file to delete relative to the workspace root." }).check( - Schema.isMinLength(1) + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ) }).annotate({ "title": "Apply patch delete file operation", - "description": "Instruction for deleting an existing file via the apply_patch tool." + "description": "Instruction for deleting an existing file via the apply_patch tool.", + "identifier": "BetaApplyPatchDeleteFileOperationParam" }) -export type ApplyPatchUpdateFileOperationParam = { +export type BetaApplyPatchUpdateFileOperationParam = { readonly "type": "update_file" readonly "path": string readonly "diff": string } -export const ApplyPatchUpdateFileOperationParam = Schema.Struct({ +export const BetaApplyPatchUpdateFileOperationParam = Schema.Struct({ "type": Schema.Literal("update_file").annotate({ "description": "The operation type. Always `update_file`." }), "path": Schema.String.annotate({ "description": "Path of the file to update relative to the workspace root." }).check( - Schema.isMinLength(1) + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), "diff": Schema.String.annotate({ "description": "Unified diff content to apply to the existing file." }).check( - Schema.isMaxLength(10485760) + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) ) }).annotate({ "title": "Apply patch update file operation", - "description": "Instruction for updating an existing file via the apply_patch tool." + "description": "Instruction for updating an existing file via the apply_patch tool.", + "identifier": "BetaApplyPatchUpdateFileOperationParam" }) -export type CompactionTriggerItemParam = { readonly "type": "compaction_trigger" } -export const CompactionTriggerItemParam = Schema.Struct({ - "type": Schema.Literal("compaction_trigger").annotate({ - "description": "The type of the item. Always `compaction_trigger`." - }) -}).annotate({ - "title": "Compaction trigger", - "description": "Compacts the current context. Must be the final input item." +export type BetaApplyPatchCallOutputStatusParam = "completed" | "failed" +export const BetaApplyPatchCallOutputStatusParam = Schema.Literals(["completed", "failed"]).annotate({ + "title": "Apply patch call output status", + "description": "Outcome values reported for apply_patch tool call outputs.", + "identifier": "BetaApplyPatchCallOutputStatusParam" }) -export type ItemReferenceParam = { readonly "type"?: "item_reference" | null; readonly "id": string } -export const ItemReferenceParam = Schema.Struct({ - "type": Schema.optionalKey( +export type BetaMCPListToolsTool = { + readonly "name": string + readonly "description"?: string | null + readonly "input_schema": {} + readonly "annotations"?: {} | null +} +export const BetaMCPListToolsTool = Schema.Struct({ + "name": Schema.String.annotate({ "description": "The name of the tool.\n" }), + "description": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The description of the tool.\n" }), Schema.Null]) + ), + "input_schema": Schema.Struct({}).annotate({ "description": "The JSON schema describing the tool's input.\n" }), + "annotations": Schema.optionalKey( Schema.Union([ - Schema.Literal("item_reference").annotate({ - "description": "The type of item to reference. Always `item_reference`." - }), + Schema.Struct({}).annotate({ "description": "Additional annotations about the tool.\n" }), Schema.Null ]) - ), - "id": Schema.String.annotate({ "description": "The ID of the item to reference." }) -}).annotate({ "title": "Item reference", "description": "An internal identifier for an item to reference." }) -export type ConversationResource = { - readonly "id": string - readonly "object": "conversation" - readonly "metadata": unknown - readonly "created_at": number -} -export const ConversationResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the conversation." }), - "object": Schema.Literal("conversation").annotate({ - "description": "The object type, which is always `conversation`." - }), - "metadata": Schema.Unknown.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." - }), - "created_at": Schema.Number.annotate({ - "description": "The time at which the conversation was created, measured in seconds since the Unix epoch.", - "format": "unixtime" - }).check(Schema.isInt()) -}) -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( - Schema.isInt() ) }).annotate({ - "title": "Input usage details", - "description": "The input tokens detailed information for the image generation." -}) -export type SpecificApplyPatchParam = { readonly "type": "apply_patch" } -export const SpecificApplyPatchParam = Schema.Struct({ - "type": Schema.Literal("apply_patch").annotate({ "description": "The tool to call. Always `apply_patch`." }) -}).annotate({ - "title": "Specific apply patch tool choice", - "description": "Forces the model to call the apply_patch tool when executing a tool call." + "title": "MCP list tools tool", + "description": "A tool available on an MCP server.\n", + "identifier": "BetaMCPListToolsTool" +}) +export type BetaMCPToolCallStatus = "in_progress" | "completed" | "incomplete" | "calling" | "failed" +export const BetaMCPToolCallStatus = Schema.Literals(["in_progress", "completed", "incomplete", "calling", "failed"]) + .annotate({ "identifier": "BetaMCPToolCallStatus" }) +export type BetaProgramOutputItemStatus = "completed" | "incomplete" +export const BetaProgramOutputItemStatus = Schema.Literals(["completed", "incomplete"]).annotate({ + "identifier": "BetaProgramOutputItemStatus" +}) +export type BetaIncludeEnum = + | "file_search_call.results" + | "web_search_call.results" + | "web_search_call.action.sources" + | "message.input_image.image_url" + | "computer_call_output.output.image_url" + | "code_interpreter_call.outputs" + | "reasoning.encrypted_content" + | "message.output_text.logprobs" +export const BetaIncludeEnum = Schema.Literals([ + "file_search_call.results", + "web_search_call.results", + "web_search_call.action.sources", + "message.input_image.image_url", + "computer_call_output.output.image_url", + "code_interpreter_call.outputs", + "reasoning.encrypted_content", + "message.output_text.logprobs" +]).annotate({ + "description": + "Specify additional output data to include in the model response. Currently supported values are:\n- `web_search_call.results`: Include the search results of the web search tool call.\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).", + "identifier": "BetaIncludeEnum" }) -export type SpecificFunctionShellParam = { readonly "type": "shell" } -export const SpecificFunctionShellParam = Schema.Struct({ - "type": Schema.Literal("shell").annotate({ "description": "The tool to call. Always `shell`." }) +export type BetaModerationMode = "score" | "block" +export const BetaModerationMode = Schema.Literals(["score", "block"]).annotate({ "identifier": "BetaModerationMode" }) +export type BetaResponseStreamOptions = { readonly "include_obfuscation"?: boolean } | null +export const BetaResponseStreamOptions = Schema.Union([ + Schema.Struct({ + "include_obfuscation": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "When true, stream obfuscation will be enabled. Stream obfuscation adds\nrandom characters to an `obfuscation` field on streaming delta events to\nnormalize payload sizes as a mitigation to certain side-channel attacks.\nThese obfuscation fields are included by default, but add a small amount\nof overhead to the data stream. You can set `include_obfuscation` to\nfalse to optimize for bandwidth if you trust the network links between\nyour application and the OpenAI API.\n" + })) + }).annotate({ "description": "Options for streaming responses. Only set this when you set `stream: true`.\n" }), + Schema.Null +]).annotate({ "identifier": "BetaResponseStreamOptions" }) +export type BetaConversationParam_2 = { readonly "id": string } +export const BetaConversationParam_2 = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the conversation." }) }).annotate({ - "title": "Specific shell tool choice", - "description": "Forces the model to call the shell tool when a tool call is required." + "title": "Conversation object", + "description": "The conversation that this response belongs to.", + "identifier": "BetaConversationParam-2" }) -export type ConversationParam_2 = { readonly "id": string } -export const ConversationParam_2 = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the conversation." }) -}).annotate({ "title": "Conversation object", "description": "The conversation that this response belongs to." }) -export type ContextManagementParam = { readonly "type": string; readonly "compact_threshold"?: number | null } -export const ContextManagementParam = Schema.Struct({ +export type BetaContextManagementParam = { readonly "type": string; readonly "compact_threshold"?: number | null } +export const BetaContextManagementParam = Schema.Struct({ "type": Schema.String.annotate({ "description": "The context management entry type. Currently only 'compaction' is supported." }), @@ -9465,4091 +10682,3900 @@ export const ContextManagementParam = Schema.Struct({ Schema.Union([ Schema.Number.annotate({ "description": "Token threshold at which compaction should be triggered for this entry." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1000)), + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1000).annotate({ "expected": "a value greater than or equal to 1000" }) + ), Schema.Null ]) ) -}) -export type Conversation_2 = { readonly "id": string } -export const Conversation_2 = Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The unique ID of the conversation that this response was associated with." - }) -}).annotate({ - "title": "Conversation", - "description": - "The conversation that this response belonged to. Input items and output items from this response were automatically added to this conversation." -}) -export type UpdateConversationBody = { readonly "metadata": {} | null } -export const UpdateConversationBody = Schema.Struct({ - "metadata": Schema.Union([ - Schema.Struct({}).annotate({ +}).annotate({ "identifier": "BetaContextManagementParam" }) +export type BetaMultiAgentParam = { readonly "enabled": boolean; readonly "max_concurrent_subagents"?: number } +export const BetaMultiAgentParam = Schema.Struct({ + "enabled": Schema.Boolean.annotate({ + "description": "Whether to enable server-hosted multi-agent execution for this response." + }), + "max_concurrent_subagents": Schema.optionalKey( + Schema.Number.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." - }) + "`max_concurrent_subagents` sets the maximum number of subagents that can be active simultaneously across the entire agent tree. It includes all descendants—children, grandchildren, and deeper subagents—but excludes the root agent.\nThe API does not impose a fixed upper bound on this setting. The default is `3`, which is recommended for most workloads. Multi-agent runs also have no fixed limit on tree depth or the total number of subagents created during a run." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ) + ) +}).annotate({ + "description": "Configuration for server-hosted multi-agent execution.", + "identifier": "BetaMultiAgentParam" }) -export type DeletedConversationResource = { - readonly "object": "conversation.deleted" - readonly "deleted": boolean - readonly "id": string -} -export const DeletedConversationResource = Schema.Struct({ - "object": Schema.Literal("conversation.deleted"), - "deleted": Schema.Boolean, - "id": Schema.String +export type BetaResponseErrorCode = + | "server_error" + | "rate_limit_exceeded" + | "invalid_prompt" + | "data_residency_mismatch" + | "bio_policy" + | "vector_store_timeout" + | "invalid_image" + | "invalid_image_format" + | "invalid_base64_image" + | "invalid_image_url" + | "image_too_large" + | "image_too_small" + | "image_parse_error" + | "image_content_policy_violation" + | "invalid_image_mode" + | "image_file_too_large" + | "unsupported_image_media_type" + | "empty_image_file" + | "failed_to_download_image" + | "image_file_not_found" +export const BetaResponseErrorCode = Schema.Literals([ + "server_error", + "rate_limit_exceeded", + "invalid_prompt", + "data_residency_mismatch", + "bio_policy", + "vector_store_timeout", + "invalid_image", + "invalid_image_format", + "invalid_base64_image", + "invalid_image_url", + "image_too_large", + "image_too_small", + "image_parse_error", + "image_content_policy_violation", + "invalid_image_mode", + "image_file_too_large", + "unsupported_image_media_type", + "empty_image_file", + "failed_to_download_image", + "image_file_not_found" +]).annotate({ "description": "The error code for the response.\n", "identifier": "BetaResponseErrorCode" }) +export type BetaTextContent = { readonly "type": "text"; readonly "text": string } +export const BetaTextContent = Schema.Struct({ "type": Schema.Literal("text"), "text": Schema.String }).annotate({ + "title": "Text Content", + "description": "A text content.", + "identifier": "BetaTextContent" }) -export type OrderEnum = "asc" | "desc" -export const OrderEnum = Schema.Literals(["asc", "desc"]) -export type VideoResource = { - readonly "id": string - readonly "object": "video" - readonly "model": - | string - | "sora-2" - | "sora-2-pro" - | "sora-2-2025-10-06" - | "sora-2-pro-2025-10-06" - | "sora-2-2025-12-08" - readonly "status": "queued" | "in_progress" | "completed" | "failed" - readonly "progress": number - readonly "created_at": number - readonly "completed_at": number | null - readonly "expires_at": number | null - readonly "prompt": string | null - readonly "size": "720x1280" | "1280x720" | "1024x1792" | "1792x1024" - readonly "seconds": string - readonly "remixed_from_video_id": string | null - readonly "error": { readonly "code": string; readonly "message": string } | null -} -export const VideoResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Unique identifier for the video job." }), - "object": Schema.Literal("video").annotate({ "description": "The object type, which is always `video`." }), - "model": Schema.Union([ - Schema.String, - Schema.Literals(["sora-2", "sora-2-pro", "sora-2-2025-10-06", "sora-2-pro-2025-10-06", "sora-2-2025-12-08"]) - ]).annotate({ "description": "The video generation model that produced the job." }), - "status": Schema.Literals(["queued", "in_progress", "completed", "failed"]).annotate({ - "description": "Current lifecycle status of the video job." - }), - "progress": Schema.Number.annotate({ "description": "Approximate completion percentage for the generation task." }) - .check(Schema.isInt()), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (seconds) for when the job was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "completed_at": Schema.Union([ - Schema.Number.annotate({ - "description": "Unix timestamp (seconds) for when the job completed, if finished.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]), - "expires_at": Schema.Union([ - Schema.Number.annotate({ - "description": "Unix timestamp (seconds) for when the downloadable assets expire, if set.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]), - "prompt": Schema.Union([ - Schema.String.annotate({ "description": "The prompt that was used to generate the video." }), - Schema.Null - ]), - "size": Schema.Literals(["720x1280", "1280x720", "1024x1792", "1792x1024"]).annotate({ - "description": "The resolution of the generated video." +export type BetaEncryptedContent = { readonly "type": "encrypted_content"; readonly "encrypted_content": string } +export const BetaEncryptedContent = Schema.Struct({ + "type": Schema.Literal("encrypted_content").annotate({ + "description": "The type of the input item. Always `encrypted_content`." }), - "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." }), + "encrypted_content": Schema.String.annotate({ "description": "Opaque encrypted content." }) +}).annotate({ + "title": "Encrypted content", + "description": "Opaque encrypted content that Responses API decrypts inside trusted model execution.", + "identifier": "BetaEncryptedContent" +}) +export type BetaMultiAgentAction = + | "spawn_agent" + | "interrupt_agent" + | "list_agents" + | "send_message" + | "followup_task" + | "wait_agent" +export const BetaMultiAgentAction = Schema.Literals([ + "spawn_agent", + "interrupt_agent", + "list_agents", + "send_message", + "followup_task", + "wait_agent" +]).annotate({ "identifier": "BetaMultiAgentAction" }) +export type BetaProgramOutputStatus = "completed" | "incomplete" +export const BetaProgramOutputStatus = Schema.Literals(["completed", "incomplete"]).annotate({ + "identifier": "BetaProgramOutputStatus" +}) +export type BetaFunctionCallStatus = "in_progress" | "completed" | "incomplete" +export const BetaFunctionCallStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "BetaFunctionCallStatus" +}) +export type BetaFunctionCallOutputStatusEnum = "in_progress" | "completed" | "incomplete" +export const BetaFunctionCallOutputStatusEnum = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "BetaFunctionCallOutputStatusEnum" +}) +export type BetaMessageRole = + | "unknown" + | "user" + | "assistant" + | "system" + | "critic" + | "discriminator" + | "developer" + | "tool" +export const BetaMessageRole = Schema.Literals([ + "unknown", + "user", + "assistant", + "system", + "critic", + "discriminator", + "developer", + "tool" +]).annotate({ "identifier": "BetaMessageRole" }) +export type BetaFunctionShellAction = { + readonly "commands": ReadonlyArray + readonly "timeout_ms": number | null + readonly "max_output_length": number | null +} +export const BetaFunctionShellAction = 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().annotate({ "expected": "an integer" }) + ), Schema.Null ]), - "error": Schema.Union([ - Schema.Struct({ - "code": Schema.String.annotate({ "description": "A machine-readable error code that was returned." }), - "message": Schema.String.annotate({ - "description": "A human-readable description of the error that was returned." - }) - }).annotate({ - "title": "Error", - "description": "Error payload that explains why generation failed, if applicable." - }), + "max_output_length": Schema.Union([ + Schema.Number.annotate({ "description": "Optional maximum number of characters to return from each command." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null ]) -}).annotate({ "title": "Video job", "description": "Structured information describing a generated video job." }) -export type ImageRefParam_2 = { readonly "image_url"?: string; readonly "file_id"?: string } -export const ImageRefParam_2 = Schema.Struct({ - "image_url": Schema.optionalKey( - Schema.String.annotate({ "description": "A fully qualified URL or base64-encoded data URL.", "format": "uri" }) - .check(Schema.isMaxLength(20971520)) - ), - "file_id": Schema.optionalKey(Schema.String) +}).annotate({ + "title": "Shell exec action", + "description": "Execute a shell command.", + "identifier": "BetaFunctionShellAction" }) -export type CreateVideoJsonBody = { - readonly "model"?: - | string - | "sora-2" - | "sora-2-pro" - | "sora-2-2025-10-06" - | "sora-2-pro-2025-10-06" - | "sora-2-2025-12-08" - readonly "prompt": string - readonly "input_reference"?: { readonly "image_url"?: string; readonly "file_id"?: string } - readonly "seconds"?: "4" | "8" | "12" - readonly "size"?: "720x1280" | "1280x720" | "1024x1792" | "1792x1024" +export type BetaFunctionShellCallStatus = "in_progress" | "completed" | "incomplete" +export const BetaFunctionShellCallStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "BetaFunctionShellCallStatus" +}) +export type BetaLocalEnvironmentResource = { readonly "type": "local" } +export const BetaLocalEnvironmentResource = Schema.Struct({ + "type": Schema.Literal("local").annotate({ "description": "The environment type. Always `local`." }) +}).annotate({ + "title": "Local Environment", + "description": "Represents the use of a local environment to perform shell actions.", + "identifier": "BetaLocalEnvironmentResource" +}) +export type BetaContainerReferenceResource = { readonly "type": "container_reference"; readonly "container_id": string } +export const BetaContainerReferenceResource = Schema.Struct({ + "type": Schema.Literal("container_reference").annotate({ + "description": "The environment type. Always `container_reference`." + }), + "container_id": Schema.String +}).annotate({ + "title": "Container Reference", + "description": "Represents a container created with /v1/containers.", + "identifier": "BetaContainerReferenceResource" +}) +export type BetaFunctionShellCallOutputStatusEnum = "in_progress" | "completed" | "incomplete" +export const BetaFunctionShellCallOutputStatusEnum = Schema.Literals(["in_progress", "completed", "incomplete"]) + .annotate({ "identifier": "BetaFunctionShellCallOutputStatusEnum" }) +export type BetaFunctionShellCallOutputTimeoutOutcome = { readonly "type": "timeout" } +export const BetaFunctionShellCallOutputTimeoutOutcome = Schema.Struct({ + "type": Schema.Literal("timeout").annotate({ "description": "The outcome type. Always `timeout`." }) +}).annotate({ + "title": "Shell call timeout outcome", + "description": "Indicates that the shell call exceeded its configured time limit.", + "identifier": "BetaFunctionShellCallOutputTimeoutOutcome" +}) +export type BetaFunctionShellCallOutputExitOutcome = { readonly "type": "exit"; readonly "exit_code": number } +export const BetaFunctionShellCallOutputExitOutcome = Schema.Struct({ + "type": Schema.Literal("exit").annotate({ "description": "The outcome type. Always `exit`." }), + "exit_code": Schema.Number.annotate({ "description": "Exit code from the shell process." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "Shell call exit outcome", + "description": "Indicates that the shell commands finished and returned an exit code.", + "identifier": "BetaFunctionShellCallOutputExitOutcome" +}) +export type BetaApplyPatchCallStatus = "in_progress" | "completed" +export const BetaApplyPatchCallStatus = Schema.Literals(["in_progress", "completed"]).annotate({ + "identifier": "BetaApplyPatchCallStatus" +}) +export type BetaApplyPatchCreateFileOperation = { + readonly "type": "create_file" + readonly "path": string + readonly "diff": string } -export const CreateVideoJsonBody = Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals(["sora-2", "sora-2-pro", "sora-2-2025-10-06", "sora-2-pro-2025-10-06", "sora-2-2025-12-08"]) - ]).annotate({ - "description": "The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`." - }) - ), - "prompt": Schema.String.annotate({ "description": "Text prompt that describes the video to generate." }).check( - Schema.isMinLength(1) - ).check(Schema.isMaxLength(32000)), - "input_reference": Schema.optionalKey( - Schema.Struct({ - "image_url": Schema.optionalKey( - Schema.String.annotate({ "description": "A fully qualified URL or base64-encoded data URL.", "format": "uri" }) - .check(Schema.isMaxLength(20971520)) - ), - "file_id": Schema.optionalKey(Schema.String) - }).annotate({ - "description": - "Optional reference object that guides generation. Provide exactly one of `image_url` or `file_id`." - }) - ), - "seconds": Schema.optionalKey( - Schema.Literals(["4", "8", "12"]).annotate({ - "description": "Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds." - }) - ), - "size": Schema.optionalKey( - Schema.Literals(["720x1280", "1280x720", "1024x1792", "1792x1024"]).annotate({ - "description": - "Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280." - }) - ) +export const BetaApplyPatchCreateFileOperation = Schema.Struct({ + "type": Schema.Literal("create_file").annotate({ "description": "Create a new file with the provided diff." }), + "path": Schema.String.annotate({ "description": "Path of the file to create." }), + "diff": Schema.String.annotate({ "description": "Diff to apply." }) }).annotate({ - "title": "Create video JSON request", - "description": "JSON parameters for creating a new video generation job." + "title": "Apply patch create file operation", + "description": "Instruction describing how to create a file via the apply_patch tool.", + "identifier": "BetaApplyPatchCreateFileOperation" }) -export type CreateVideoCharacterBody = { readonly "video": string; readonly "name": string } -export const CreateVideoCharacterBody = Schema.Struct({ - "video": Schema.String.annotate({ "description": "Video file used to create a character.", "format": "binary" }), - "name": Schema.String.annotate({ "description": "Display name for this API character." }).check(Schema.isMinLength(1)) - .check(Schema.isMaxLength(80)) +export type BetaApplyPatchDeleteFileOperation = { readonly "type": "delete_file"; readonly "path": string } +export const BetaApplyPatchDeleteFileOperation = Schema.Struct({ + "type": Schema.Literal("delete_file").annotate({ "description": "Delete the specified file." }), + "path": Schema.String.annotate({ "description": "Path of the file to delete." }) }).annotate({ - "title": "Create character request", - "description": "Parameters for creating a character from an uploaded video." + "title": "Apply patch delete file operation", + "description": "Instruction describing how to delete a file via the apply_patch tool.", + "identifier": "BetaApplyPatchDeleteFileOperation" }) -export type VideoCharacterResource = { - readonly "id": string | null - readonly "name": string | null - readonly "created_at": number +export type BetaApplyPatchUpdateFileOperation = { + readonly "type": "update_file" + readonly "path": string + readonly "diff": string } -export const VideoCharacterResource = Schema.Struct({ - "id": Schema.Union([ - Schema.String.annotate({ "description": "Identifier for the character creation cameo." }), - Schema.Null - ]), - "name": Schema.Union([Schema.String.annotate({ "description": "Display name for the character." }), Schema.Null]), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the character was created.", - "format": "unixtime" - }).check(Schema.isInt()) -}) -export type VideoReferenceInputParam = { readonly "id": string } -export const VideoReferenceInputParam = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier of the completed video." }) -}).annotate({ "description": "Reference to the completed video." }) -export type CreateVideoEditJsonBody = { readonly "video": { readonly "id": string }; readonly "prompt": string } -export const CreateVideoEditJsonBody = Schema.Struct({ - "video": Schema.Struct({ "id": Schema.String.annotate({ "description": "The identifier of the completed video." }) }) - .annotate({ "description": "Reference to the completed video to edit." }), - "prompt": Schema.String.annotate({ "description": "Text prompt that describes how to edit the source video." }).check( - Schema.isMinLength(1) - ).check(Schema.isMaxLength(32000)) +export const BetaApplyPatchUpdateFileOperation = Schema.Struct({ + "type": Schema.Literal("update_file").annotate({ "description": "Update an existing file with the provided diff." }), + "path": Schema.String.annotate({ "description": "Path of the file to update." }), + "diff": Schema.String.annotate({ "description": "Diff to apply." }) }).annotate({ - "title": "Create video edit JSON request", - "description": "JSON parameters for editing an existing generated video." + "title": "Apply patch update file operation", + "description": "Instruction describing how to update a file via the apply_patch tool.", + "identifier": "BetaApplyPatchUpdateFileOperation" }) -export type CreateVideoExtendJsonBody = { - readonly "video": { readonly "id": string } - readonly "prompt": string - readonly "seconds": "4" | "8" | "12" +export type BetaApplyPatchCallOutputStatus = "completed" | "failed" +export const BetaApplyPatchCallOutputStatus = Schema.Literals(["completed", "failed"]).annotate({ + "identifier": "BetaApplyPatchCallOutputStatus" +}) +export type BetaResponseUsage = { + readonly "input_tokens": number + readonly "input_tokens_details": { readonly "cached_tokens": number; readonly "cache_write_tokens": number } + readonly "output_tokens": number + readonly "output_tokens_details": { readonly "reasoning_tokens": number } + readonly "total_tokens": number } -export const CreateVideoExtendJsonBody = Schema.Struct({ - "video": Schema.Struct({ "id": Schema.String.annotate({ "description": "The identifier of the completed video." }) }) - .annotate({ "description": "Reference to the completed video to extend." }), - "prompt": Schema.String.annotate({ "description": "Updated text prompt that directs the extension generation." }) - .check(Schema.isMinLength(1)).check(Schema.isMaxLength(32000)), - "seconds": Schema.Literals(["4", "8", "12"]).annotate({ - "description": "Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20)." - }) +export const BetaResponseUsage = Schema.Struct({ + "input_tokens": Schema.Number.annotate({ "description": "The number of input tokens." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "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({ "expected": "an integer" })), + "cache_write_tokens": Schema.Number.annotate({ + "description": "The number of input tokens that were written to the cache." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + }).annotate({ "description": "A detailed breakdown of the input tokens." }), + "output_tokens": Schema.Number.annotate({ "description": "The number of output tokens." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "output_tokens_details": Schema.Struct({ + "reasoning_tokens": Schema.Number.annotate({ "description": "The number of reasoning tokens." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).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({ "expected": "an integer" }) + ) }).annotate({ - "title": "Create video extension JSON request", - "description": "JSON parameters for extending an existing generated video." + "description": + "Represents token usage details including input tokens, output tokens,\na breakdown of output tokens, and the total tokens used.\n", + "identifier": "BetaResponseUsage" }) -export type DeletedVideoResource = { - readonly "object": "video.deleted" - readonly "deleted": boolean - readonly "id": string +export type BetaModerationResultBody = { + readonly "type": "moderation_result" + readonly "model": string + readonly "flagged": boolean + readonly "categories": {} + readonly "category_scores": {} + readonly "category_applied_input_types": {} } -export const DeletedVideoResource = Schema.Struct({ - "object": Schema.Literal("video.deleted").annotate({ - "description": "The object type that signals the deletion response." +export const BetaModerationResultBody = Schema.Struct({ + "type": Schema.Literal("moderation_result").annotate({ + "description": "The object type, which was always `moderation_result` for successful moderation results." }), - "deleted": Schema.Boolean.annotate({ "description": "Indicates that the video resource was deleted." }), - "id": Schema.String.annotate({ "description": "Identifier of the deleted video." }) + "model": Schema.String.annotate({ "description": "The moderation model that produced this result." }), + "flagged": Schema.Boolean.annotate({ + "description": "A boolean indicating whether the content was flagged by any category." + }), + "categories": Schema.Struct({}).annotate({ + "description": + "A dictionary of moderation categories to booleans, True if the input is flagged under this category." + }), + "category_scores": Schema.Struct({}).annotate({ "description": "A dictionary of moderation categories to scores." }), + "category_applied_input_types": Schema.Struct({}).annotate({ + "description": "Which modalities of input are reflected by the score for each category." + }) }).annotate({ - "title": "Deleted video response", - "description": "Confirmation payload returned after deleting a video." + "title": "Moderation result", + "description": "A moderation result produced for the response input or output.", + "identifier": "BetaModerationResultBody" }) -export type VideoContentVariant = "video" | "thumbnail" | "spritesheet" -export const VideoContentVariant = Schema.Literals(["video", "thumbnail", "spritesheet"]) -export type CreateVideoRemixBody = { readonly "prompt": string } -export const CreateVideoRemixBody = Schema.Struct({ - "prompt": Schema.String.annotate({ "description": "Updated text prompt that directs the remix generation." }).check( - Schema.isMinLength(1) - ).check(Schema.isMaxLength(32000)) +export type BetaModerationErrorBody = { readonly "type": "error"; readonly "code": string; readonly "message": string } +export const BetaModerationErrorBody = Schema.Struct({ + "type": Schema.Literal("error").annotate({ + "description": "The object type, which was always `error` for moderation failures." + }), + "code": Schema.String.annotate({ "description": "The error code." }), + "message": Schema.String.annotate({ "description": "The error message." }) }).annotate({ - "title": "Create video remix request", - "description": "Parameters for remixing an existing generated video." -}) -export type TokenCountsResource = { readonly "object": "response.input_tokens"; readonly "input_tokens": number } -export const TokenCountsResource = Schema.Struct({ - "object": Schema.Literal("response.input_tokens"), - "input_tokens": Schema.Number.check(Schema.isInt()) -}).annotate({ "title": "Token counts" }) -export type SkillResource = { - readonly "id": string - readonly "object": "skill" - readonly "name": string - readonly "description": string - readonly "created_at": number - readonly "default_version": string - readonly "latest_version": string -} -export const SkillResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Unique identifier for the skill." }), - "object": Schema.Literal("skill").annotate({ "description": "The object type, which is `skill`." }), - "name": Schema.String.annotate({ "description": "Name of the skill." }), - "description": Schema.String.annotate({ "description": "Description of the skill." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (seconds) for when the skill was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "default_version": Schema.String.annotate({ "description": "Default version for the skill." }), - "latest_version": Schema.String.annotate({ "description": "Latest version for the skill." }) + "title": "Moderation error", + "description": "An error produced while attempting moderation for the response input or output.", + "identifier": "BetaModerationErrorBody" }) -export type CreateSkillBody = { readonly "files": ReadonlyArray | string } -export const CreateSkillBody = Schema.Struct({ - "files": Schema.Union([ - Schema.Array(Schema.String.annotate({ "format": "binary" })).annotate({ - "description": "Skill files to upload (directory upload) or a single zip file." - }).check(Schema.isMaxLength(500)), - Schema.String.annotate({ "description": "Skill zip file to upload.", "format": "binary" }) - ], { mode: "oneOf" }) +export type BetaResponseConversation = { readonly "id": string } +export const BetaResponseConversation = Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The unique ID of the conversation that this response was associated with." + }) }).annotate({ - "title": "Create skill request", - "description": "Uploads a skill either as a directory (multipart `files[]`) or as a single zip file." + "title": "Conversation", + "description": + "The conversation that this response belonged to. Input items and output items from this response were automatically added to this conversation.", + "identifier": "BetaResponseConversation" }) -export type SetDefaultSkillVersionBody = { readonly "default_version": string } -export const SetDefaultSkillVersionBody = Schema.Struct({ - "default_version": Schema.String.annotate({ "description": "The skill version number to set as default." }) -}).annotate({ "title": "Update skill request", "description": "Updates the default version pointer for a skill." }) -export type DeletedSkillResource = { - readonly "object": "skill.deleted" - readonly "deleted": boolean - readonly "id": string +export type BetaResponseLogProb = { + readonly "token": string + readonly "logprob": number + readonly "top_logprobs"?: ReadonlyArray<{ readonly "token"?: string; readonly "logprob"?: number }> } -export const DeletedSkillResource = Schema.Struct({ - "object": Schema.Literal("skill.deleted"), - "deleted": Schema.Boolean, - "id": Schema.String +export const BetaResponseLogProb = Schema.Struct({ + "token": Schema.String.annotate({ "description": "A possible text token." }), + "logprob": Schema.Number.annotate({ "description": "The log probability of this token.\n" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "top_logprobs": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "token": Schema.optionalKey(Schema.String.annotate({ "description": "A possible text token." })), + "logprob": Schema.optionalKey( + Schema.Number.annotate({ "description": "The log probability of this token." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ) + })).annotate({ "description": "The log probabilities of up to 20 of the most likely tokens.\n" }) + ) +}).annotate({ + "description": + "A logprob is the logarithmic probability that the model assigns to producing \na particular token at a given position in the sequence. Less-negative (higher) \nlogprob values indicate greater model confidence in that token choice.\n", + "identifier": "BetaResponseLogProb" }) -export type SkillVersionResource = { - readonly "object": "skill.version" - readonly "id": string - readonly "skill_id": string - readonly "version": string - readonly "created_at": number - readonly "name": string - readonly "description": string +export type BetaError = { + readonly "code": string | null + readonly "message": string + readonly "param": string | null + readonly "type": string } -export const SkillVersionResource = Schema.Struct({ - "object": Schema.Literal("skill.version").annotate({ "description": "The object type, which is `skill.version`." }), - "id": Schema.String.annotate({ "description": "Unique identifier for the skill version." }), - "skill_id": Schema.String.annotate({ "description": "Identifier of the skill for this version." }), - "version": Schema.String.annotate({ "description": "Version number for this skill." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (seconds) for when the version was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "name": Schema.String.annotate({ "description": "Name of the skill version." }), - "description": Schema.String.annotate({ "description": "Description of the skill version." }) +export const BetaError = Schema.Struct({ + "code": Schema.Union([Schema.String, Schema.Null]), + "message": Schema.String, + "param": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.String +}).annotate({ "identifier": "BetaError" }) +export type BetaPromptCacheRetentionEnum = "in_memory" | "24h" +export const BetaPromptCacheRetentionEnum = Schema.Literals(["in_memory", "24h"]).annotate({ + "identifier": "BetaPromptCacheRetentionEnum" +}) +export type BetaServiceTierEnum = "auto" | "default" | "fast" | "flex" | "priority" +export const BetaServiceTierEnum = Schema.Literals(["auto", "default", "fast", "flex", "priority"]).annotate({ + "identifier": "BetaServiceTierEnum" +}) +export type BetaMessageStatus = "in_progress" | "completed" | "incomplete" +export const BetaMessageStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "BetaMessageStatus" +}) +export type BetaMessagePhase_2 = "commentary" | "final_answer" +export const BetaMessagePhase_2 = Schema.Literals(["commentary", "final_answer"]).annotate({ + "identifier": "BetaMessagePhase-2" +}) +export type BetaTruncationEnum = "auto" | "disabled" +export const BetaTruncationEnum = Schema.Literals(["auto", "disabled"]).annotate({ "identifier": "BetaTruncationEnum" }) +export type BetaPersonalityEnum = string | "friendly" | "pragmatic" +export const BetaPersonalityEnum = Schema.Union([Schema.String, Schema.Literals(["friendly", "pragmatic"])]).annotate({ + "identifier": "BetaPersonalityEnum" +}) +export type BetaTokenCountsResource = { readonly "object": "response.input_tokens"; readonly "input_tokens": number } +export const BetaTokenCountsResource = Schema.Struct({ + "object": Schema.Literal("response.input_tokens"), + "input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "title": "Token counts", "identifier": "BetaTokenCountsResource" }) +export type FileSearchRankingOptions = { readonly "ranker"?: FileSearchRanker; readonly "score_threshold": number } +export const FileSearchRankingOptions = Schema.Struct({ + "ranker": Schema.optionalKey(FileSearchRanker), + "score_threshold": Schema.Number.annotate({ + "description": + "The score threshold for the file search. All values must be a floating point number between 0 and 1." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) +}).annotate({ + "title": "File search tool call ranking options", + "description": + "The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.\n\nSee the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.\n", + "identifier": "FileSearchRankingOptions" }) -export type CreateSkillVersionBody = { readonly "files": ReadonlyArray | string; readonly "default"?: boolean } -export const CreateSkillVersionBody = Schema.Struct({ - "files": Schema.Union([ - Schema.Array(Schema.String.annotate({ "format": "binary" })).annotate({ - "description": "Skill files to upload (directory upload) or a single zip file." - }).check(Schema.isMaxLength(500)), - Schema.String.annotate({ "description": "Skill zip file to upload.", "format": "binary" }) - ], { mode: "oneOf" }), - "default": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether to set this version as the default." }) - ) -}).annotate({ "title": "Create skill version request", "description": "Uploads a new immutable version of a skill." }) -export type DeletedSkillVersionResource = { - readonly "object": "skill.version.deleted" - readonly "deleted": boolean - readonly "id": string - readonly "version": string +export type RunStepDetailsToolCallsFileSearchRankingOptionsObject = { + readonly "ranker": FileSearchRanker + readonly "score_threshold": number } -export const DeletedSkillVersionResource = Schema.Struct({ - "object": Schema.Literal("skill.version.deleted"), - "deleted": Schema.Boolean, - "id": Schema.String, - "version": Schema.String.annotate({ "description": "The deleted skill version." }) +export const RunStepDetailsToolCallsFileSearchRankingOptionsObject = Schema.Struct({ + "ranker": FileSearchRanker, + "score_threshold": Schema.Number.annotate({ + "description": + "The score threshold for the file search. All values must be a floating point number between 0 and 1." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) +}).annotate({ + "title": "File search tool call ranking options", + "description": "The ranking options for the file search.", + "identifier": "RunStepDetailsToolCallsFileSearchRankingOptionsObject" }) -export type ChatSessionResource = { - readonly "id": string - readonly "object": "chatkit.session" - readonly "expires_at": number - readonly "client_secret": string - readonly "workflow": { - readonly "id": string - readonly "version": string | null - readonly "state_variables": {} | null - readonly "tracing": { readonly "enabled": boolean } - } - readonly "user": string - readonly "rate_limits": { readonly "max_requests_per_1_minute": number } - readonly "max_requests_per_1_minute": number - readonly "status": "active" | "expired" | "cancelled" - readonly "chatkit_configuration": { - readonly "automatic_thread_titling": { readonly "enabled": boolean } - readonly "file_upload": { - readonly "enabled": boolean - readonly "max_file_size": number | null - readonly "max_files": number | null - } - readonly "history": { readonly "enabled": boolean; readonly "recent_threads": number | null } - } +export type FunctionObject = { + readonly "description"?: string + readonly "name": string + readonly "parameters"?: FunctionParameters + readonly "strict"?: boolean | null } -export const ChatSessionResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier for the ChatKit session." }), - "object": Schema.Literal("chatkit.session").annotate({ - "description": "Type discriminator that is always `chatkit.session`." +export const FunctionObject = Schema.Struct({ + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A description of what the function does, used by the model to choose when and how to call the function." + }) + ), + "name": Schema.String.annotate({ + "description": + "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64." }), - "expires_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) for when the session expires.", - "format": "unixtime" - }).check(Schema.isInt()), - "client_secret": Schema.String.annotate({ - "description": "Ephemeral client secret that authenticates session requests." + "parameters": Schema.optionalKey(FunctionParameters), + "strict": Schema.optionalKey(Schema.Union([ + Schema.Boolean.annotate({ + "description": + "Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling)." + }), + Schema.Null + ])) +}).annotate({ "identifier": "FunctionObject" }) +export type ChatCompletionFunctions = { + readonly "description"?: string + readonly "name": string + readonly "parameters"?: FunctionParameters +} +export const ChatCompletionFunctions = Schema.Struct({ + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A description of what the function does, used by the model to choose when and how to call the function." + }) + ), + "name": Schema.String.annotate({ + "description": + "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64." }), - "workflow": Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier of the workflow backing the session." }), - "version": Schema.Union([ - Schema.String.annotate({ - "description": - "Specific workflow version used for the session. Defaults to null when using the latest deployment." - }), + "parameters": Schema.optionalKey(FunctionParameters) +}).annotate({ "identifier": "ChatCompletionFunctions" }) +export type EvalStoredCompletionsSource = { + readonly "type": "stored_completions" + readonly "metadata"?: Metadata + readonly "model"?: string | null + readonly "created_after"?: number | null + readonly "created_before"?: number | null + readonly "limit"?: number | null +} +export const EvalStoredCompletionsSource = Schema.Struct({ + "type": Schema.Literal("stored_completions").annotate({ + "description": "The type of source. Always `stored_completions`." + }), + "metadata": Schema.optionalKey(Metadata), + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "An optional model to filter by (e.g., 'gpt-4o')." }), Schema.Null - ]), - "state_variables": Schema.Union([ - Schema.Struct({}).annotate({ - "description": - "State variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided." - }), + ]) + ), + "created_after": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "An optional Unix timestamp to filter items created after this time." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null - ]), - "tracing": Schema.Struct({ - "enabled": Schema.Boolean.annotate({ "description": "Indicates whether tracing is enabled." }) - }).annotate({ "title": "Tracing Configuration", "description": "Tracing settings applied to the workflow." }) - }).annotate({ "title": "Workflow", "description": "Workflow metadata for the session." }), - "user": Schema.String.annotate({ "description": "User identifier associated with the session." }), - "rate_limits": Schema.Struct({ - "max_requests_per_1_minute": Schema.Number.annotate({ - "description": "Maximum allowed requests per one-minute window." - }).check(Schema.isInt()) - }).annotate({ "title": "Rate limits", "description": "Resolved rate limit values." }), - "max_requests_per_1_minute": Schema.Number.annotate({ - "description": "Convenience copy of the per-minute request limit." - }).check(Schema.isInt()), - "status": Schema.Literals(["active", "expired", "cancelled"]).annotate({ - "description": "Current lifecycle state of the session." - }), - "chatkit_configuration": Schema.Struct({ - "automatic_thread_titling": Schema.Struct({ - "enabled": Schema.Boolean.annotate({ "description": "Whether automatic thread titling is enabled." }) - }).annotate({ "title": "Automatic thread titling", "description": "Automatic thread titling preferences." }), - "file_upload": Schema.Struct({ - "enabled": Schema.Boolean.annotate({ "description": "Indicates if uploads are enabled for the session." }), - "max_file_size": Schema.Union([ - Schema.Number.annotate({ "description": "Maximum upload size in megabytes." }).check(Schema.isInt()), - Schema.Null - ]), - "max_files": Schema.Union([ - Schema.Number.annotate({ "description": "Maximum number of uploads allowed during the session." }).check( - Schema.isInt() - ), - Schema.Null - ]) - }).annotate({ "title": "File upload settings", "description": "Upload settings for the session." }), - "history": Schema.Struct({ - "enabled": Schema.Boolean.annotate({ "description": "Indicates if chat history is persisted for the session." }), - "recent_threads": Schema.Union([ - Schema.Number.annotate({ - "description": - "Number of prior threads surfaced in history views. Defaults to null when all history is retained." - }).check(Schema.isInt()), - Schema.Null - ]) - }).annotate({ "title": "History settings", "description": "History retention configuration." }) - }).annotate({ - "title": "ChatKit configuration", - "description": "Resolved ChatKit feature configuration for the session." - }) -}).annotate({ - "title": "The chat session object", - "description": "Represents a ChatKit session and its resolved configuration." -}) -export type CreateChatSessionBody = { - readonly "workflow": { - readonly "id": string - readonly "version"?: string - readonly "state_variables"?: {} - readonly "tracing"?: { readonly "enabled"?: boolean } - } - readonly "user": string - readonly "expires_after"?: { readonly "anchor": "created_at"; readonly "seconds": number } - readonly "rate_limits"?: { readonly "max_requests_per_1_minute"?: number } - readonly "chatkit_configuration"?: { - readonly "automatic_thread_titling"?: { readonly "enabled"?: boolean } - readonly "file_upload"?: { - readonly "enabled"?: boolean - readonly "max_file_size"?: number - readonly "max_files"?: number - } - readonly "history"?: { readonly "enabled"?: boolean; readonly "recent_threads"?: number } - } -} -export const CreateChatSessionBody = Schema.Struct({ - "workflow": Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier for the workflow invoked by the session." }), - "version": Schema.optionalKey( - Schema.String.annotate({ - "description": "Specific workflow version to run. Defaults to the latest deployed version." - }) - ), - "state_variables": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "State variables forwarded to the workflow. Keys may be up to 64 characters, values must be primitive types, and the map defaults to an empty object." - }).check(Schema.isMaxProperties(64)) - ), - "tracing": Schema.optionalKey( - Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether tracing is enabled during the session. Defaults to true." }) - ) - }).annotate({ - "title": "Tracing Configuration", - "description": - "Optional tracing overrides for the workflow invocation. When omitted, tracing is enabled by default." - }) - ) - }).annotate({ "title": "Workflow settings", "description": "Workflow that powers the session." }), - "user": Schema.String.annotate({ - "description": - "A free-form string that identifies your end user; ensures this Session can access other objects that have the same `user` scope." - }).check(Schema.isMinLength(1)), - "expires_after": Schema.optionalKey( - Schema.Struct({ - "anchor": Schema.Literal("created_at").annotate({ - "description": "Base timestamp used to calculate expiration. Currently fixed to `created_at`." - }), - "seconds": Schema.Number.annotate({ - "description": "Number of seconds after the anchor when the session expires.", - "format": "int64" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(600)) - }).annotate({ - "title": "Expiration overrides", - "description": "Optional override for session expiration timing in seconds from creation. Defaults to 10 minutes." - }) + ]) ), - "rate_limits": Schema.optionalKey( - Schema.Struct({ - "max_requests_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Maximum number of requests allowed per minute for the session. Defaults to 10." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)) - ) - }).annotate({ - "title": "Rate limit overrides", - "description": "Optional override for per-minute request limits. When omitted, defaults to 10." - }) + "created_before": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "An optional Unix timestamp to filter items created before this time." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) ), - "chatkit_configuration": Schema.optionalKey( - Schema.Struct({ - "automatic_thread_titling": Schema.optionalKey( - Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Enable automatic thread title generation. Defaults to true." }) - ) - }).annotate({ - "title": "Automatic thread titling configuration", - "description": - "Configuration for automatic thread titling. When omitted, automatic thread titling is enabled by default." - }) - ), - "file_upload": Schema.optionalKey( - Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Enable uploads for this session. Defaults to false." }) - ), - "max_file_size": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Maximum size in megabytes for each uploaded file. Defaults to 512 MB, which is the maximum allowable size." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(512)) - ), - "max_files": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Maximum number of files that can be uploaded to the session. Defaults to 10." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)) - ) - }).annotate({ - "title": "File upload configuration", - "description": - "Configuration for upload enablement and limits. When omitted, uploads are disabled by default (max_files 10, max_file_size 512 MB)." - }) + "limit": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "An optional maximum number of items to return." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "history": Schema.optionalKey( - Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Enables chat users to access previous ChatKit threads. Defaults to true." - }) - ), - "recent_threads": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Number of recent ChatKit threads users have access to. Defaults to unlimited when unset." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)) - ) - }).annotate({ - "title": "Chat history configuration", - "description": - "Configuration for chat history retention. When omitted, history is enabled by default with no limit on recent_threads (null)." - }) - ) - }).annotate({ - "title": "ChatKit configuration overrides", - "description": "Optional overrides for ChatKit runtime configuration features" - }) + Schema.Null + ]) ) }).annotate({ - "title": "Create chat session request", - "description": "Parameters for provisioning a new ChatKit session." -}) -export type UserMessageInputText = { readonly "type": "input_text"; readonly "text": string } -export const UserMessageInputText = Schema.Struct({ - "type": Schema.Literal("input_text").annotate({ "description": "Type discriminator that is always `input_text`." }), - "text": Schema.String.annotate({ "description": "Plain-text content supplied by the user." }) -}).annotate({ "title": "User message input", "description": "Text block that a user contributed to the thread." }) -export type UserMessageQuotedText = { readonly "type": "quoted_text"; readonly "text": string } -export const UserMessageQuotedText = Schema.Struct({ - "type": Schema.Literal("quoted_text").annotate({ "description": "Type discriminator that is always `quoted_text`." }), - "text": Schema.String.annotate({ "description": "Quoted text content." }) -}).annotate({ - "title": "User message quoted text", - "description": "Quoted snippet that the user referenced in their message." + "title": "StoredCompletionsRunDataSource", + "description": "A StoredCompletionsRunDataSource configuration describing a set of filters\n", + "identifier": "EvalStoredCompletionsSource" }) -export type Attachment = { - readonly "type": "image" | "file" - readonly "id": string - readonly "name": string - readonly "mime_type": string - readonly "preview_url": string | null -} -export const Attachment = Schema.Struct({ - "type": Schema.Literals(["image", "file"]).annotate({ "description": "Attachment discriminator." }), - "id": Schema.String.annotate({ "description": "Identifier for the attachment." }), - "name": Schema.String.annotate({ "description": "Original display name for the attachment." }), - "mime_type": Schema.String.annotate({ "description": "MIME type of the attachment." }), - "preview_url": Schema.Union([ - Schema.String.annotate({ "description": "Preview URL for rendering the attachment inline.", "format": "uri" }), - Schema.Null - ]) -}).annotate({ "title": "Attachment", "description": "Attachment metadata included on thread items." }) -export type FileAnnotation = { - readonly "type": "file" - readonly "source": { readonly "type": "file"; readonly "filename": string } -} -export const FileAnnotation = Schema.Struct({ - "type": Schema.Literal("file").annotate({ - "description": "Type discriminator that is always `file` for this annotation." - }), - "source": Schema.Struct({ - "type": Schema.Literal("file").annotate({ "description": "Type discriminator that is always `file`." }), - "filename": Schema.String.annotate({ "description": "Filename referenced by the annotation." }) - }).annotate({ "title": "File annotation source", "description": "File attachment referenced by the annotation." }) -}).annotate({ "title": "File annotation", "description": "Annotation that references an uploaded file." }) -export type UrlAnnotation = { - readonly "type": "url" - readonly "source": { readonly "type": "url"; readonly "url": string } -} -export const UrlAnnotation = Schema.Struct({ - "type": Schema.Literal("url").annotate({ - "description": "Type discriminator that is always `url` for this annotation." - }), - "source": Schema.Struct({ - "type": Schema.Literal("url").annotate({ "description": "Type discriminator that is always `url`." }), - "url": Schema.String.annotate({ "description": "URL referenced by the annotation.", "format": "uri" }) - }).annotate({ "title": "URL annotation source", "description": "URL referenced by the annotation." }) -}).annotate({ "title": "URL annotation", "description": "Annotation that references a URL." }) -export type WidgetMessageItem = { - readonly "id": string - readonly "object": "chatkit.thread_item" - readonly "created_at": number - readonly "thread_id": string - readonly "type": "chatkit.widget" - readonly "widget": string -} -export const WidgetMessageItem = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), - "object": Schema.Literal("chatkit.thread_item").annotate({ - "description": "Type discriminator that is always `chatkit.thread_item`." - }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) for when the item was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), - "type": Schema.Literal("chatkit.widget").annotate({ - "description": "Type discriminator that is always `chatkit.widget`." - }), - "widget": Schema.String.annotate({ "description": "Serialized widget payload rendered in the UI." }) -}).annotate({ "title": "Widget message", "description": "Thread item that renders a widget payload." }) -export type ClientToolCallItem = { +export type ThreadObject = { readonly "id": string - readonly "object": "chatkit.thread_item" + readonly "object": "thread" readonly "created_at": number - readonly "thread_id": string - readonly "type": "chatkit.client_tool_call" - readonly "status": "in_progress" | "completed" - readonly "call_id": string - readonly "name": string - readonly "arguments": string - readonly "output": string | null + readonly "tool_resources": { + readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } + readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } + } | null + readonly "metadata": Metadata } -export const ClientToolCallItem = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), - "object": Schema.Literal("chatkit.thread_item").annotate({ - "description": "Type discriminator that is always `chatkit.thread_item`." - }), +export const ThreadObject = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), + "object": Schema.Literal("thread").annotate({ "description": "The object type, which is always `thread`." }), "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) for when the item was created.", + "description": "The Unix timestamp (in seconds) for when the thread was created.", "format": "unixtime" - }).check(Schema.isInt()), - "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), - "type": Schema.Literal("chatkit.client_tool_call").annotate({ - "description": "Type discriminator that is always `chatkit.client_tool_call`." - }), - "status": Schema.Literals(["in_progress", "completed"]).annotate({ - "description": "Execution status for the tool call." - }), - "call_id": Schema.String.annotate({ "description": "Identifier for the client tool call." }), - "name": Schema.String.annotate({ "description": "Tool name that was invoked." }), - "arguments": Schema.String.annotate({ "description": "JSON-encoded arguments that were sent to the tool." }), - "output": Schema.Union([ - Schema.String.annotate({ - "description": "JSON-encoded output captured from the tool. Defaults to null while execution is in progress." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "tool_resources": Schema.Union([ + Schema.Struct({ + "code_interpreter": Schema.optionalKey(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) + ) + })), + "file_search": Schema.optionalKey(Schema.Struct({ + "vector_store_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })) + ) + })) + }).annotate({ + "description": + "A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" }), Schema.Null - ]) + ]), + "metadata": Metadata }).annotate({ - "title": "Client tool call", - "description": "Record of a client side tool invocation initiated by the assistant." + "title": "Thread", + "description": "Represents a thread that contains [messages](/docs/api-reference/messages).", + "identifier": "ThreadObject" }) -export type TaskItem = { - readonly "id": string - readonly "object": "chatkit.thread_item" - readonly "created_at": number - readonly "thread_id": string - readonly "type": "chatkit.task" - readonly "task_type": "custom" | "thought" - readonly "heading": string | null - readonly "summary": string | null +export type ModifyThreadRequest = { + readonly "tool_resources"?: { + readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } + readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } + } | null + readonly "metadata"?: Metadata } -export const TaskItem = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), - "object": Schema.Literal("chatkit.thread_item").annotate({ - "description": "Type discriminator that is always `chatkit.thread_item`." - }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) for when the item was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), - "type": Schema.Literal("chatkit.task").annotate({ - "description": "Type discriminator that is always `chatkit.task`." - }), - "task_type": Schema.Literals(["custom", "thought"]).annotate({ "description": "Subtype for the task." }), - "heading": Schema.Union([ - Schema.String.annotate({ "description": "Optional heading for the task. Defaults to null when not provided." }), - Schema.Null - ]), - "summary": Schema.Union([ - Schema.String.annotate({ - "description": "Optional summary that describes the task. Defaults to null when omitted." +export const ModifyThreadRequest = Schema.Struct({ + "tool_resources": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "code_interpreter": Schema.optionalKey(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) + ) + })), + "file_search": Schema.optionalKey(Schema.Struct({ + "vector_store_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })) + ) + })) + }).annotate({ + "description": + "A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" }), Schema.Null - ]) -}).annotate({ - "title": "Task item", - "description": "Task emitted by the workflow to show progress and status updates." + ])), + "metadata": Schema.optionalKey(Metadata) +}).annotate({ "identifier": "ModifyThreadRequest" }) +export type ModifyMessageRequest = { readonly "metadata"?: Metadata } +export const ModifyMessageRequest = Schema.Struct({ "metadata": Schema.optionalKey(Metadata) }).annotate({ + "identifier": "ModifyMessageRequest" }) -export type TaskGroupTask = { - readonly "type": "custom" | "thought" - readonly "heading": string | null - readonly "summary": string | null +export type ModifyRunRequest = { readonly "metadata"?: Metadata } +export const ModifyRunRequest = Schema.Struct({ "metadata": Schema.optionalKey(Metadata) }).annotate({ + "identifier": "ModifyRunRequest" +}) +export type UpdateVectorStoreRequest = { + readonly "name"?: string | null + readonly "expires_after"?: { readonly "anchor": "last_active_at"; readonly "days": number } + readonly "metadata"?: Metadata } -export const TaskGroupTask = Schema.Struct({ - "type": Schema.Literals(["custom", "thought"]).annotate({ "description": "Subtype for the grouped task." }), - "heading": Schema.Union([ - Schema.String.annotate({ - "description": "Optional heading for the grouped task. Defaults to null when not provided." - }), - Schema.Null - ]), - "summary": Schema.Union([ - Schema.String.annotate({ - "description": "Optional summary that describes the grouped task. Defaults to null when omitted." - }), - Schema.Null - ]) -}).annotate({ "title": "Task group task", "description": "Task entry that appears within a TaskGroup." }) -export type ActiveStatus = { readonly "type": "active" } -export const ActiveStatus = Schema.Struct({ - "type": Schema.Literal("active").annotate({ "description": "Status discriminator that is always `active`." }) -}).annotate({ "title": "Active thread status", "description": "Indicates that a thread is active." }) -export type LockedStatus = { readonly "type": "locked"; readonly "reason": string | null } -export const LockedStatus = Schema.Struct({ - "type": Schema.Literal("locked").annotate({ "description": "Status discriminator that is always `locked`." }), - "reason": Schema.Union([ - Schema.String.annotate({ - "description": "Reason that the thread was locked. Defaults to null when no reason is recorded." +export const UpdateVectorStoreRequest = Schema.Struct({ + "name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the vector store." }) + ), + "expires_after": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "anchor": Schema.Literal("last_active_at").annotate({ + "description": + "Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`." + }), + "days": Schema.Number.annotate({ + "description": "The number of days after the anchor time that the vector store will expire." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(365).annotate({ "expected": "a value less than or equal to 365" })) + }).annotate({ + "title": "Vector store expiration policy", + "description": "The expiration policy for a vector store." + }) + ])), + "metadata": Schema.optionalKey(Metadata) +}).annotate({ "identifier": "UpdateVectorStoreRequest" }) +export type UpdateConversationBody = { readonly "metadata": Metadata } +export const UpdateConversationBody = Schema.Struct({ + "metadata": Schema.suspend((): Schema.Codec => Metadata).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." + }) +}).annotate({ "identifier": "UpdateConversationBody" }) +export type ResponseFormatJsonSchema = { + readonly "type": "json_schema" + readonly "json_schema": { + readonly "description"?: string + readonly "name": string + readonly "schema"?: ResponseFormatJsonSchemaSchema + readonly "strict"?: boolean | null + } +} +export const ResponseFormatJsonSchema = Schema.Struct({ + "type": Schema.Literal("json_schema").annotate({ + "description": "The type of response format being defined. Always `json_schema`." + }), + "json_schema": Schema.Struct({ + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A description of what the response format is for, used by the model to\ndetermine how to respond in the format.\n" + }) + ), + "name": Schema.String.annotate({ + "description": + "The name of the response format. Must be a-z, A-Z, 0-9, or contain\nunderscores and dashes, with a maximum length of 64.\n" }), - Schema.Null - ]) + "schema": Schema.optionalKey(ResponseFormatJsonSchemaSchema), + "strict": Schema.optionalKey(Schema.Union([ + Schema.Boolean.annotate({ + "description": + "Whether to enable strict schema adherence when generating the output.\nIf set to true, the model will always follow the exact schema defined\nin the `schema` field. Only a subset of JSON Schema is supported when\n`strict` is `true`. To learn more, read the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n" + }), + Schema.Null + ])) + }).annotate({ + "title": "JSON schema", + "description": "Structured Outputs configuration options, including a JSON Schema.\n" + }) }).annotate({ - "title": "Locked thread status", - "description": "Indicates that a thread is locked and cannot accept new input." + "title": "JSON schema", + "description": + "JSON Schema response format. Used to generate structured JSON responses.\nLearn more about [Structured Outputs](/docs/guides/structured-outputs).\n", + "identifier": "ResponseFormatJsonSchema" }) -export type ClosedStatus = { readonly "type": "closed"; readonly "reason": string | null } -export const ClosedStatus = Schema.Struct({ - "type": Schema.Literal("closed").annotate({ "description": "Status discriminator that is always `closed`." }), - "reason": Schema.Union([ - Schema.String.annotate({ - "description": "Reason that the thread was closed. Defaults to null when no reason is recorded." - }), - Schema.Null - ]) -}).annotate({ "title": "Closed thread status", "description": "Indicates that a thread has been closed." }) -export type DeletedThreadResource = { - readonly "id": string - readonly "object": "chatkit.thread.deleted" - readonly "deleted": boolean -} -export const DeletedThreadResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier of the deleted thread." }), - "object": Schema.Literal("chatkit.thread.deleted").annotate({ - "description": "Type discriminator that is always `chatkit.thread.deleted`." - }), - "deleted": Schema.Boolean.annotate({ "description": "Indicates that the thread has been deleted." }) -}).annotate({ "title": "Deleted thread", "description": "Confirmation payload returned after deleting a thread." }) -export type ResponseKeepAliveEvent = { readonly "type": "keepalive"; readonly "sequence_number": number } -export const ResponseKeepAliveEvent = Schema.Struct({ - "type": Schema.Literal("keepalive").annotate({ - "description": "The type of the keepalive event. Always `keepalive`." - }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this keepalive event." }).check( - Schema.isInt() - ) -}).annotate({ "title": "Keep alive", "description": "A keepalive event emitted during long-running response streams." }) -export type ResponseApplyPatchCallOperationDiffDeltaEvent = { - readonly "type": "response.apply_patch_call_operation_diff.delta" - readonly "sequence_number": number - readonly "output_index": number - readonly "item_id": string - readonly "delta": string +export type TextResponseFormatJsonSchema = { + readonly "type": "json_schema" + readonly "description"?: string + readonly "name": string + readonly "schema": ResponseFormatJsonSchemaSchema + readonly "strict"?: boolean | null } -export const ResponseApplyPatchCallOperationDiffDeltaEvent = Schema.Struct({ - "type": Schema.Literal("response.apply_patch_call_operation_diff.delta").annotate({ - "description": "The event type identifier." +export const TextResponseFormatJsonSchema = Schema.Struct({ + "type": Schema.Literal("json_schema").annotate({ + "description": "The type of response format being defined. Always `json_schema`." }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ), - "output_index": Schema.Number.annotate({ "description": "The index of the output this delta applies to." }).check( - Schema.isInt() + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A description of what the response format is for, used by the model to\ndetermine how to respond in the format.\n" + }) ), - "item_id": Schema.String.annotate({ - "description": "Unique identifier for the API item associated with this event." + "name": Schema.String.annotate({ + "description": + "The name of the response format. Must be a-z, A-Z, 0-9, or contain\nunderscores and dashes, with a maximum length of 64.\n" }), - "delta": Schema.String.annotate({ "description": "The incremental diff data for the apply_patch tool call." }) + "schema": ResponseFormatJsonSchemaSchema, + "strict": Schema.optionalKey(Schema.Union([ + Schema.Boolean.annotate({ + "description": + "Whether to enable strict schema adherence when generating the output.\nIf set to true, the model will always follow the exact schema defined\nin the `schema` field. Only a subset of JSON Schema is supported when\n`strict` is `true`. To learn more, read the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n" + }), + Schema.Null + ])) }).annotate({ - "title": "ResponseApplyPatchCallOperationDiffDelta", - "description": "Event representing a delta for an apply_patch tool call operation diff." + "title": "JSON schema", + "description": + "JSON Schema response format. Used to generate structured JSON responses.\nLearn more about [Structured Outputs](/docs/guides/structured-outputs).\n", + "identifier": "TextResponseFormatJsonSchema" }) -export type ResponseApplyPatchCallOperationDiffDoneEvent = { - readonly "type": "response.apply_patch_call_operation_diff.done" - readonly "sequence_number": number - readonly "output_index": number - readonly "item_id": string - readonly "delta"?: string +export type EvalResponsesSource = { + readonly "type": "responses" + readonly "metadata"?: {} | null + readonly "model"?: string | null + readonly "instructions_search"?: string | null + readonly "created_after"?: number | null + readonly "created_before"?: number | null + readonly "reasoning_effort"?: ReasoningEffort | null + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "users"?: ReadonlyArray | null + readonly "tools"?: ReadonlyArray | null } -export const ResponseApplyPatchCallOperationDiffDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.apply_patch_call_operation_diff.done").annotate({ - "description": "The event type identifier." - }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() +export const EvalResponsesSource = Schema.Struct({ + "type": Schema.Literal("responses").annotate({ "description": "The type of run data source. Always `responses`." }), + "metadata": Schema.optionalKey( + Schema.Union([ + Schema.Struct({}).annotate({ + "description": "Metadata filter for the responses. This is a query parameter used to select responses." + }), + Schema.Null + ]) ), - "output_index": Schema.Number.annotate({ "description": "The index of the output this event applies to." }).check( - Schema.isInt() + "model": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The name of the model to find responses for. This is a query parameter used to select responses." + }), + Schema.Null + ]) ), - "item_id": Schema.String.annotate({ - "description": "Unique identifier for the API item associated with this event." - }), - "delta": Schema.optionalKey( - Schema.String.annotate({ "description": "The final diff data for the apply_patch tool call." }) + "instructions_search": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "Optional string to search the 'instructions' field. This is a query parameter used to select responses." + }), + Schema.Null + ]) + ), + "created_after": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": + "Only include items created after this timestamp (inclusive). This is a query parameter used to select responses." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]) + ), + "created_before": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": + "Only include items created before this timestamp (inclusive). This is a query parameter used to select responses." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]) + ), + "reasoning_effort": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ReasoningEffort).annotate({ + "description": "Optional reasoning effort parameter. This is a query parameter used to select responses." + }), + Schema.Null + ]) + ), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "Sampling temperature. This is a query parameter used to select responses." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "Nucleus sampling parameter. This is a query parameter used to select responses." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "users": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).annotate({ + "description": "List of user identifiers. This is a query parameter used to select responses." + }), + Schema.Null + ]) + ), + "tools": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).annotate({ + "description": "List of tool names. This is a query parameter used to select responses." + }), + Schema.Null + ]) ) }).annotate({ - "title": "ResponseApplyPatchCallOperationDiffDone", - "description": "Event indicating that the operation diff for an apply_patch tool call is complete." + "title": "EvalResponsesSource", + "description": "A EvalResponsesSource object describing a run data source configuration.\n", + "identifier": "EvalResponsesSource" +}) +export type VoiceIdsOrCustomVoice = VoiceIdsShared | { readonly "id": string } +export const VoiceIdsOrCustomVoice = Schema.Union([ + VoiceIdsShared, + Schema.Struct({ "id": Schema.String.annotate({ "description": "The custom voice ID, e.g. `voice_1234`." }) }) + .annotate({ "description": "Custom voice reference." }) +]).annotate({ + "title": "Voice", + "description": "A built-in voice name or a custom voice reference.\n", + "identifier": "VoiceIdsOrCustomVoice" }) -export type ApiKeyList = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "first_id"?: string | null - readonly "last_id"?: string | null -} -export const ApiKeyList = Schema.Struct({ - "object": Schema.Literal("list"), - "data": Schema.Array(AdminApiKey), - "has_more": Schema.Boolean, - "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +export type CreateSpeechResponseStreamEvent = SpeechAudioDeltaEvent | SpeechAudioDoneEvent +export const CreateSpeechResponseStreamEvent = Schema.Union([SpeechAudioDeltaEvent, SpeechAudioDoneEvent]).annotate({ + "identifier": "CreateSpeechResponseStreamEvent" }) -export type RoleListResource = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next": string | null +export type CreateTranscriptionRequest = { + readonly "file": string + readonly "model": + | string + | "whisper-1" + | "gpt-transcribe" + | "gpt-4o-transcribe" + | "gpt-4o-mini-transcribe" + | "gpt-4o-mini-transcribe-2025-12-15" + | "gpt-4o-transcribe-diarize" + readonly "language"?: string + readonly "languages"?: ReadonlyArray + readonly "keywords"?: ReadonlyArray + readonly "prompt"?: string + readonly "response_format"?: AudioResponseFormat + readonly "temperature"?: number + readonly "include"?: ReadonlyArray + readonly "timestamp_granularities"?: ReadonlyArray<"word" | "segment"> + readonly "stream"?: boolean | null + readonly "chunking_strategy"?: "auto" | VadConfig | null + readonly "known_speaker_names"?: ReadonlyArray + readonly "known_speaker_references"?: ReadonlyArray } -export const RoleListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), - "data": Schema.Array(AssignedRoleDetails).annotate({ - "description": "Role assignments returned in the current page." +export const CreateTranscriptionRequest = Schema.Struct({ + "file": Schema.String.annotate({ + "description": + "The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.\n", + "format": "binary" }), - "has_more": Schema.Boolean.annotate({ - "description": "Whether additional assignments are available when paginating." + "model": Schema.Union([ + Schema.String, + Schema.Literals([ + "whisper-1", + "gpt-transcribe", + "gpt-4o-transcribe", + "gpt-4o-mini-transcribe", + "gpt-4o-mini-transcribe-2025-12-15", + "gpt-4o-transcribe-diarize" + ]) + ]).annotate({ + "description": + "ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.\n" }), - "next": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Cursor to fetch the next page of results, or `null` when there are no more assignments." - }) -}).annotate({ "description": "Paginated list of roles assigned to a principal." }) -export type AuditLogActorApiKey = { - readonly "id"?: string - readonly "type"?: "user" | "service_account" - readonly "user"?: AuditLogActorUser - readonly "service_account"?: AuditLogActorServiceAccount -} -export const AuditLogActorApiKey = Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The tracking id of the API key." })), - "type": Schema.optionalKey( - Schema.Literals(["user", "service_account"]).annotate({ - "description": "The type of API key. Can be either `user` or `service_account`." + "language": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency.\n" }) ), - "user": Schema.optionalKey(AuditLogActorUser), - "service_account": Schema.optionalKey(AuditLogActorServiceAccount) -}).annotate({ "description": "The API Key used to perform the audit logged action." }) -export type AuditLogActorSession = { readonly "user"?: AuditLogActorUser; readonly "ip_address"?: string } -export const AuditLogActorSession = Schema.Struct({ - "user": Schema.optionalKey(AuditLogActorUser), - "ip_address": Schema.optionalKey( - Schema.String.annotate({ "description": "The IP address from which the action was performed." }) - ) -}).annotate({ "description": "The session in which the audit logged action was performed." }) -export type ChatCompletionAllowedToolsChoice = { - readonly "type": "allowed_tools" - readonly "allowed_tools": ChatCompletionAllowedTools -} -export const ChatCompletionAllowedToolsChoice = Schema.Struct({ - "type": Schema.Literal("allowed_tools").annotate({ - "description": "Allowed tool configuration type. Always `allowed_tools`." - }), - "allowed_tools": ChatCompletionAllowedTools -}).annotate({ - "title": "Allowed tools", - "description": "Constrains the tools available to the model to a pre-defined set.\n" -}) -export type ChatCompletionMessageToolCalls = ReadonlyArray< - ChatCompletionMessageToolCall | ChatCompletionMessageCustomToolCall -> -export const ChatCompletionMessageToolCalls = Schema.Array( - Schema.Union([ChatCompletionMessageToolCall, ChatCompletionMessageCustomToolCall], { mode: "oneOf" }) -).annotate({ "description": "The tool calls generated by the model, such as function calls." }) -export type ChatCompletionStreamResponseDelta = { - readonly "content"?: string | null - readonly "function_call"?: { readonly "arguments"?: string; readonly "name"?: string } - readonly "tool_calls"?: ReadonlyArray - readonly "role"?: "developer" | "system" | "user" | "assistant" | "tool" - readonly "refusal"?: string | null -} -export const ChatCompletionStreamResponseDelta = Schema.Struct({ - "content": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "The contents of the chunk message." }), Schema.Null]) + "languages": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe`.\n" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) ), - "function_call": Schema.optionalKey( - Schema.Struct({ - "arguments": Schema.optionalKey(Schema.String.annotate({ - "description": - "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." - })), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function to call." })) - }).annotate({ + "keywords": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe`.\n" + }) + ), + "prompt": Schema.optionalKey( + Schema.String.annotate({ "description": - "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model." + "An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`.\n" }) ), - "tool_calls": Schema.optionalKey(Schema.Array(ChatCompletionMessageToolCallChunk)), - "role": Schema.optionalKey( - Schema.Literals(["developer", "system", "user", "assistant", "tool"]).annotate({ - "description": "The role of the author of this message." + "response_format": Schema.optionalKey(AudioResponseFormat), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "include": Schema.optionalKey( + Schema.Array(TranscriptionInclude).annotate({ + "description": + "Additional information to include in the transcription response.\n`logprobs` will return the log probabilities of the tokens in the\nresponse to understand the model's confidence in the transcription.\n`logprobs` only works with response_format set to `json` and only with\nthe models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`.\n" }) ), - "refusal": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The refusal message generated by the model." }), - Schema.Null - ]) - ) -}).annotate({ "description": "A chat completion delta generated by streamed model responses." }) -export type ChatCompletionRequestAssistantMessageContentPart = - | ChatCompletionRequestMessageContentPartText - | ChatCompletionRequestMessageContentPartRefusal -export const ChatCompletionRequestAssistantMessageContentPart = Schema.Union([ - ChatCompletionRequestMessageContentPartText, - ChatCompletionRequestMessageContentPartRefusal -], { mode: "oneOf" }) -export type ChatCompletionRequestDeveloperMessage = { - readonly "content": string | ReadonlyArray - readonly "role": "developer" - readonly "name"?: string -} -export const ChatCompletionRequestDeveloperMessage = Schema.Struct({ - "content": Schema.Union([ - Schema.String.annotate({ "title": "Text content", "description": "The contents of the developer message." }), - Schema.Array(ChatCompletionRequestMessageContentPartText).annotate({ - "title": "Array of content parts", - "description": - "An array of content parts with a defined type. For developer messages, only type `text` is supported." - }).check(Schema.isMinLength(1)) - ], { mode: "oneOf" }).annotate({ "description": "The contents of the developer message." }), - "role": Schema.Literal("developer").annotate({ - "description": "The role of the messages author, in this case `developer`." - }), - "name": Schema.optionalKey( - Schema.String.annotate({ + "timestamp_granularities": Schema.optionalKey( + Schema.Array(Schema.Literals(["word", "segment"])).annotate({ "description": - "An optional name for the participant. Provides the model information to differentiate between participants of the same role." + "The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.\nThis option is not available for `gpt-4o-transcribe-diarize`.\n" }) - ) -}).annotate({ - "title": "Developer message", - "description": - "Developer-provided instructions that the model should follow, regardless of\nmessages sent by the user. With o1 models and newer, `developer` messages\nreplace the previous `system` messages.\n" -}) -export type ChatCompletionRequestSystemMessageContentPart = ChatCompletionRequestMessageContentPartText -export const ChatCompletionRequestSystemMessageContentPart = Schema.Union( - [ChatCompletionRequestMessageContentPartText], - { mode: "oneOf" } -) -export type ChatCompletionRequestToolMessageContentPart = ChatCompletionRequestMessageContentPartText -export const ChatCompletionRequestToolMessageContentPart = Schema.Union([ChatCompletionRequestMessageContentPartText], { - mode: "oneOf" -}) -export type ChatCompletionRequestUserMessageContentPart = - | ChatCompletionRequestMessageContentPartText - | ChatCompletionRequestMessageContentPartImage - | ChatCompletionRequestMessageContentPartAudio - | ChatCompletionRequestMessageContentPartFile -export const ChatCompletionRequestUserMessageContentPart = Schema.Union([ - ChatCompletionRequestMessageContentPartText, - ChatCompletionRequestMessageContentPartImage, - ChatCompletionRequestMessageContentPartAudio, - ChatCompletionRequestMessageContentPartFile -], { mode: "oneOf" }) -export type PredictionContent = { - readonly "type": "content" - readonly "content": string | ReadonlyArray -} -export const PredictionContent = Schema.Struct({ - "type": Schema.Literal("content").annotate({ - "description": "The type of the predicted content you want to provide. This type is\ncurrently always `content`.\n" - }), - "content": Schema.Union([ - Schema.String.annotate({ - "title": "Text content", + ), + "stream": Schema.optionalKey(Schema.Union([ + Schema.Boolean.annotate({ "description": - "The content used for a Predicted Output. This is often the\ntext of a file you are regenerating with minor changes.\n" + "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 of the Speech-to-Text guide](/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)\nfor more information.\n\nNote: Streaming is not supported for the `whisper-1` model and will be ignored.\n" }), - Schema.Array(ChatCompletionRequestMessageContentPartText).annotate({ - "title": "Array of content parts", + Schema.Null + ])), + "chunking_strategy": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.Literal("auto").annotate({ + "description": "Automatically set chunking parameters based on the audio. Must be set to `\"auto\"`.\n" + }), + VadConfig + ]).annotate({ + "description": + "Controls how the audio is cut into chunks. When set to `\"auto\"`, the server first normalizes loudness and then uses voice activity detection (VAD) to choose boundaries. `server_vad` object can be provided to tweak VAD detection parameters manually. If unset, the audio is transcribed as a single block. Required when using `gpt-4o-transcribe-diarize` for inputs longer than 30 seconds. " + }), + Schema.Null + ]) + ), + "known_speaker_names": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "An array of content parts with a defined type. Supported options differ based on the [model](/docs/models) being used to generate the response. Can contain text inputs." - }).check(Schema.isMinLength(1)) - ], { mode: "oneOf" }).annotate({ - "description": - "The content that should be matched when generating a model response.\nIf generated tokens would match this content, the entire model response\ncan be returned much more quickly.\n" - }) -}).annotate({ - "title": "Static Content", - "description": "Static predicted output content, such as the content of a text file that is\nbeing regenerated.\n" -}) -export type CompoundFilter = { - readonly "type": "and" | "or" - readonly "filters": ReadonlyArray -} -export const CompoundFilter = Schema.Struct({ - "type": Schema.Literals(["and", "or"]).annotate({ "description": "Type of operation: `and` or `or`." }), - "filters": Schema.Array(Schema.Union([ComparisonFilter, Schema.Unknown], { mode: "oneOf" })).annotate({ - "description": "Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`." - }) -}).annotate({ "title": "Compound Filter", "description": "Combine multiple filters using `and` or `or`." }) -export type CreateCompletionResponse = { - readonly "id": string - readonly "choices": ReadonlyArray< - { - readonly "finish_reason": "stop" | "length" | "content_filter" - readonly "index": number - readonly "logprobs": { - readonly "text_offset"?: ReadonlyArray - readonly "token_logprobs"?: ReadonlyArray - readonly "tokens"?: ReadonlyArray - readonly "top_logprobs"?: ReadonlyArray<{}> - } | null - readonly "text": string - } + "Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported.\n" + }).check(Schema.isMaxLength(4).annotate({ "expected": "a value with a length of at most 4" })) + ), + "known_speaker_references": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`.\n" + }).check(Schema.isMaxLength(4).annotate({ "expected": "a value with a length of at most 4" })) + ) +}).annotate({ "identifier": "CreateTranscriptionRequest" }) +export type CreateTranscriptionResponseJson = { + readonly "text": string + readonly "languages"?: ReadonlyArray + readonly "logprobs"?: ReadonlyArray< + { readonly "token"?: string; readonly "logprob"?: number; readonly "bytes"?: ReadonlyArray } > - readonly "created": number - readonly "model": string - readonly "system_fingerprint"?: string - readonly "object": "text_completion" - readonly "usage"?: CompletionUsage + readonly "usage"?: { + readonly "type": "tokens" + readonly "input_tokens": number + readonly "input_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number } + readonly "output_tokens": number + readonly "total_tokens": number + } | { readonly "type": "duration"; readonly "seconds": number } } -export const CreateCompletionResponse = Schema.Struct({ - "id": Schema.String.annotate({ "description": "A unique identifier for the completion." }), - "choices": Schema.Array(Schema.Struct({ - "finish_reason": Schema.Literals(["stop", "length", "content_filter"]).annotate({ +export const CreateTranscriptionResponseJson = Schema.Struct({ + "text": Schema.String.annotate({ "description": "The transcribed text." }), + "languages": Schema.optionalKey( + Schema.Array(TranscriptionLanguage).annotate({ "description": - "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\nor `content_filter` if content was omitted due to a flag from our content filters.\n" - }), - "index": Schema.Number.check(Schema.isInt()), - "logprobs": Schema.Union([ - Schema.Struct({ - "text_offset": Schema.optionalKey(Schema.Array(Schema.Number.check(Schema.isInt()))), - "token_logprobs": Schema.optionalKey(Schema.Array(Schema.Number.check(Schema.isFinite()))), - "tokens": Schema.optionalKey(Schema.Array(Schema.String)), - "top_logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({}))) - }), - Schema.Null - ]), - "text": Schema.String - })).annotate({ "description": "The list of completion choices the model generated for the input prompt." }), - "created": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the completion was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "model": Schema.String.annotate({ "description": "The model used for completion." }), - "system_fingerprint": Schema.optionalKey( - Schema.String.annotate({ + "The languages detected in the audio. Returned by `gpt-transcribe`. An empty array indicates that no language could be reliably detected.\n" + }) + ), + "logprobs": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "token": Schema.optionalKey(Schema.String.annotate({ "description": "The token in the transcription." })), + "logprob": Schema.optionalKey( + Schema.Number.annotate({ "description": "The log probability of the token." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "bytes": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))).annotate({ + "description": "The bytes of the token." + }) + ) + })).annotate({ "description": - "This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" + "The log probabilities of the tokens in the transcription. Only returned with the models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added to the `include` array.\n" }) ), - "object": Schema.Literal("text_completion").annotate({ - "description": "The object type, which is always \"text_completion\"" - }), - "usage": Schema.optionalKey(CompletionUsage) + "usage": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("tokens").annotate({ + "description": "The type of the usage object. Always `tokens` for this variant." + }), + "input_tokens": Schema.Number.annotate({ "description": "Number of input tokens billed for this request." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "input_token_details": Schema.optionalKey( + Schema.Struct({ + "text_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of text tokens billed for this request." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "audio_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of audio tokens billed for this request." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ) + }).annotate({ "description": "Details about the input tokens billed for this request." }) + ), + "output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).annotate({ "title": "Token Usage", "description": "Token usage statistics for the request." }), + Schema.Struct({ + "type": Schema.Literal("duration").annotate({ + "description": "The type of the usage object. Always `duration` for this variant." + }), + "seconds": Schema.Number.annotate({ + "description": "Duration of the input audio in seconds.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + }).annotate({ "title": "Duration Usage", "description": "Token usage statistics for the request." }) + ], { mode: "oneOf" })) }).annotate({ - "description": - "Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).\n" -}) -export type ContainerFileListResource = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean -} -export const ContainerFileListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be 'list'." }), - "data": Schema.Array(ContainerFileResource).annotate({ "description": "A list of container files." }), - "first_id": Schema.String.annotate({ "description": "The ID of the first file in the list." }), - "last_id": Schema.String.annotate({ "description": "The ID of the last file in the list." }), - "has_more": Schema.Boolean.annotate({ "description": "Whether there are more files available." }) + "description": "Represents a transcription response returned by model, based on the provided input.", + "identifier": "CreateTranscriptionResponseJson" }) -export type ContainerListResource = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean +export type CreateTranscriptionResponseDiarizedJson = { + readonly "task": "transcribe" + readonly "duration": number + readonly "text": string + readonly "segments": ReadonlyArray + readonly "usage"?: { + readonly "type": "tokens" + readonly "input_tokens": number + readonly "input_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number } + readonly "output_tokens": number + readonly "total_tokens": number + } | { readonly "type": "duration"; readonly "seconds": number } } -export const ContainerListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be 'list'." }), - "data": Schema.Array(ContainerResource).annotate({ "description": "A list of containers." }), - "first_id": Schema.String.annotate({ "description": "The ID of the first container in the list." }), - "last_id": Schema.String.annotate({ "description": "The ID of the last container in the list." }), - "has_more": Schema.Boolean.annotate({ "description": "Whether there are more containers available." }) -}) -export type CreateEmbeddingResponse = { - readonly "data": ReadonlyArray - readonly "model": string - readonly "object": "list" - readonly "usage": { readonly "prompt_tokens": number; readonly "total_tokens": number } -} -export const CreateEmbeddingResponse = Schema.Struct({ - "data": Schema.Array(Embedding).annotate({ "description": "The list of embeddings generated by the model." }), - "model": Schema.String.annotate({ "description": "The name of the model used to generate the embedding." }), - "object": Schema.Literal("list").annotate({ "description": "The object type, which is always \"list\"." }), - "usage": Schema.Struct({ - "prompt_tokens": Schema.Number.annotate({ "description": "The number of tokens used by the prompt." }).check( - Schema.isInt() - ), - "total_tokens": Schema.Number.annotate({ "description": "The total number of tokens used by the request." }).check( - Schema.isInt() - ) - }).annotate({ "description": "The usage information for the request." }) -}) -export type ErrorEvent = { readonly "event": "error"; readonly "data": Error } -export const ErrorEvent = Schema.Struct({ "event": Schema.Literal("error"), "data": Error }).annotate({ - "description": - "Occurs when an [error](/docs/guides/error-codes#api-errors) occurs. This can happen due to an internal server error or a timeout." -}) -export type ErrorResponse = { readonly "error": Error } -export const ErrorResponse = Schema.Struct({ "error": Error }) -export type EvalRunOutputItem = { - readonly "object": "eval.run.output_item" - readonly "id": string - readonly "run_id": string - readonly "eval_id": string - readonly "created_at": number - readonly "status": string - readonly "datasource_item_id": number - readonly "datasource_item": {} - readonly "results": ReadonlyArray - readonly "sample": { - readonly "input": ReadonlyArray<{ readonly "role": string; readonly "content": string }> - readonly "output": ReadonlyArray<{ readonly "role"?: string; readonly "content"?: string }> - readonly "finish_reason": string - readonly "model": string - readonly "usage": { - readonly "total_tokens": number - readonly "completion_tokens": number - readonly "prompt_tokens": number - readonly "cached_tokens": number - } - readonly "error": EvalApiError - readonly "temperature": number - readonly "max_completion_tokens": number - readonly "top_p": number - readonly "seed": number - } -} -export const EvalRunOutputItem = Schema.Struct({ - "object": Schema.Literal("eval.run.output_item").annotate({ - "description": "The type of the object. Always \"eval.run.output_item\"." - }), - "id": Schema.String.annotate({ "description": "Unique identifier for the evaluation run output item." }), - "run_id": Schema.String.annotate({ - "description": "The identifier of the evaluation run associated with this output item." +export const CreateTranscriptionResponseDiarizedJson = Schema.Struct({ + "task": Schema.Literal("transcribe").annotate({ + "description": "The type of task that was run. Always `transcribe`." }), - "eval_id": Schema.String.annotate({ "description": "The identifier of the evaluation group." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the evaluation run was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "status": Schema.String.annotate({ "description": "The status of the evaluation run." }), - "datasource_item_id": Schema.Number.annotate({ "description": "The identifier for the data source item." }).check( - Schema.isInt() - ), - "datasource_item": Schema.Struct({}).annotate({ "description": "Details of the input data source item." }), - "results": Schema.Array(EvalRunOutputItemResult).annotate({ - "description": "A list of grader results for this output item." + "duration": Schema.Number.annotate({ "description": "Duration of the input audio in seconds.", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "text": Schema.String.annotate({ "description": "The concatenated transcript text for the entire audio input." }), + "segments": Schema.Array(TranscriptionDiarizedSegment).annotate({ + "description": "Segments of the transcript annotated with timestamps and speaker labels." }), - "sample": Schema.Struct({ - "input": Schema.Array( - Schema.Struct({ - "role": Schema.String.annotate({ - "description": "The role of the message sender (e.g., system, user, developer)." - }), - "content": Schema.String.annotate({ "description": "The content of the message." }) - }).annotate({ "description": "An input message." }) - ).annotate({ "description": "An array of input messages." }), - "output": Schema.Array( - Schema.Struct({ - "role": Schema.optionalKey( - Schema.String.annotate({ - "description": "The role of the message (e.g. \"system\", \"assistant\", \"user\")." - }) - ), - "content": Schema.optionalKey(Schema.String.annotate({ "description": "The content of the message." })) - }) - ).annotate({ "description": "An array of output messages." }), - "finish_reason": Schema.String.annotate({ "description": "The reason why the sample generation was finished." }), - "model": Schema.String.annotate({ "description": "The model used for generating the sample." }), - "usage": Schema.Struct({ - "total_tokens": Schema.Number.annotate({ "description": "The total number of tokens used." }).check( - Schema.isInt() + "usage": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("tokens").annotate({ + "description": "The type of the usage object. Always `tokens` for this variant." + }), + "input_tokens": Schema.Number.annotate({ "description": "Number of input tokens billed for this request." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "input_token_details": Schema.optionalKey( + Schema.Struct({ + "text_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of text tokens billed for this request." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "audio_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of audio tokens billed for this request." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ) + }).annotate({ "description": "Details about the input tokens billed for this request." }) ), - "completion_tokens": Schema.Number.annotate({ "description": "The number of completion tokens generated." }) - .check(Schema.isInt()), - "prompt_tokens": Schema.Number.annotate({ "description": "The number of prompt tokens used." }).check( - Schema.isInt() + "output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "cached_tokens": Schema.Number.annotate({ "description": "The number of tokens retrieved from cache." }).check( - Schema.isInt() + "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) - }).annotate({ "description": "Token usage details for the sample." }), - "error": EvalApiError, - "temperature": Schema.Number.annotate({ "description": "The sampling temperature used." }).check(Schema.isFinite()), - "max_completion_tokens": Schema.Number.annotate({ - "description": "The maximum number of tokens allowed for completion." - }).check(Schema.isInt()), - "top_p": Schema.Number.annotate({ "description": "The top_p value used for sampling." }).check(Schema.isFinite()), - "seed": Schema.Number.annotate({ "description": "The seed used for generating the sample." }).check(Schema.isInt()) - }).annotate({ "description": "A sample containing the input and output of the evaluation run." }) -}).annotate({ "title": "EvalRunOutputItem", "description": "A schema representing an evaluation run output item.\n" }) -export type CreateFileRequest = { - readonly "file": string - readonly "purpose": "assistants" | "batch" | "fine-tune" | "vision" | "user_data" | "evals" - readonly "expires_after"?: FileExpirationAfter + }).annotate({ "title": "Token Usage", "description": "Token or duration usage statistics for the request." }), + Schema.Struct({ + "type": Schema.Literal("duration").annotate({ + "description": "The type of the usage object. Always `duration` for this variant." + }), + "seconds": Schema.Number.annotate({ + "description": "Duration of the input audio in seconds.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + }).annotate({ "title": "Duration Usage", "description": "Token or duration usage statistics for the request." }) + ], { mode: "oneOf" })) +}).annotate({ + "description": + "Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.\n", + "identifier": "CreateTranscriptionResponseDiarizedJson" +}) +export type CreateTranslationResponseVerboseJson = { + readonly "language": string + readonly "duration": number + readonly "text": string + readonly "segments"?: ReadonlyArray } -export const CreateFileRequest = Schema.Struct({ - "file": Schema.String.annotate({ - "description": "The File object (not file name) to be uploaded.\n", - "format": "binary" - }), - "purpose": Schema.Literals(["assistants", "batch", "fine-tune", "vision", "user_data", "evals"]).annotate({ - "description": - "The intended purpose of the uploaded file. One of:\n- `assistants`: Used in the Assistants API\n- `batch`: Used in the Batch API\n- `fine-tune`: Used for fine-tuning\n- `vision`: Images used for vision fine-tuning\n- `user_data`: Flexible file type for any purpose\n- `evals`: Used for eval data sets\n" - }), - "expires_after": Schema.optionalKey(FileExpirationAfter) +export const CreateTranslationResponseVerboseJson = Schema.Struct({ + "language": Schema.String.annotate({ "description": "The language of the output translation (always `english`)." }), + "duration": Schema.Number.annotate({ "description": "The duration of the input audio.", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "text": Schema.String.annotate({ "description": "The translated text." }), + "segments": Schema.optionalKey( + Schema.Array(TranscriptionSegment).annotate({ + "description": "Segments of the translated text and their corresponding details." + }) + ) +}).annotate({ "identifier": "CreateTranslationResponseVerboseJson" }) +export type CreateTranscriptionResponseVerboseJson = { + readonly "language": string + readonly "duration": number + readonly "text": string + readonly "words"?: ReadonlyArray + readonly "segments"?: ReadonlyArray + readonly "usage"?: TranscriptTextUsageDuration +} +export const CreateTranscriptionResponseVerboseJson = Schema.Struct({ + "language": Schema.String.annotate({ "description": "The language of the input audio." }), + "duration": Schema.Number.annotate({ "description": "The duration of the input audio.", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "text": Schema.String.annotate({ "description": "The transcribed text." }), + "words": Schema.optionalKey( + Schema.Array(TranscriptionWord).annotate({ "description": "Extracted words and their corresponding timestamps." }) + ), + "segments": Schema.optionalKey( + Schema.Array(TranscriptionSegment).annotate({ + "description": "Segments of the transcribed text and their corresponding details." + }) + ), + "usage": Schema.optionalKey(TranscriptTextUsageDuration) +}).annotate({ + "description": "Represents a verbose json transcription response returned by model, based on the provided input.", + "identifier": "CreateTranscriptionResponseVerboseJson" }) -export type CreateUploadRequest = { - readonly "filename": string - readonly "purpose": "assistants" | "batch" | "fine-tune" | "vision" - readonly "bytes": number - readonly "mime_type": string - readonly "expires_after"?: FileExpirationAfter +export type TranscriptTextDoneEvent = { + readonly "type": "transcript.text.done" + readonly "text": string + readonly "languages"?: ReadonlyArray + readonly "logprobs"?: ReadonlyArray< + { readonly "token"?: string; readonly "logprob"?: number; readonly "bytes"?: ReadonlyArray } + > + readonly "usage"?: TranscriptTextUsageTokens } -export const CreateUploadRequest = Schema.Struct({ - "filename": Schema.String.annotate({ "description": "The name of the file to upload.\n" }), - "purpose": Schema.Literals(["assistants", "batch", "fine-tune", "vision"]).annotate({ - "description": - "The intended purpose of the uploaded file.\n\nSee the [documentation on File\npurposes](/docs/api-reference/files/create#files-create-purpose).\n" +export const TranscriptTextDoneEvent = Schema.Struct({ + "type": Schema.Literal("transcript.text.done").annotate({ + "description": "The type of the event. Always `transcript.text.done`.\n" }), - "bytes": Schema.Number.annotate({ "description": "The number of bytes in the file you are uploading.\n" }).check( - Schema.isInt() + "text": Schema.String.annotate({ "description": "The text that was transcribed.\n" }), + "languages": Schema.optionalKey( + Schema.Array(TranscriptionLanguage).annotate({ + "description": + "The languages detected in the audio. Returned by `gpt-transcribe`. An empty array indicates that no language could be reliably detected.\n" + }) ), - "mime_type": Schema.String.annotate({ - "description": - "The MIME type of the file.\n\n\nThis must fall within the supported MIME types for your file purpose. See\nthe supported MIME types for assistants and vision.\n" - }), - "expires_after": Schema.optionalKey(FileExpirationAfter) -}) -export type FileSearchRankingOptions = { readonly "ranker"?: FileSearchRanker; readonly "score_threshold": number } -export const FileSearchRankingOptions = Schema.Struct({ - "ranker": Schema.optionalKey(FileSearchRanker), - "score_threshold": Schema.Number.annotate({ - "description": - "The score threshold for the file search. All values must be a floating point number between 0 and 1." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) + "logprobs": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "token": Schema.optionalKey( + Schema.String.annotate({ "description": "The token that was used to generate the log probability.\n" }) + ), + "logprob": Schema.optionalKey( + Schema.Number.annotate({ "description": "The log probability of the token.\n" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "bytes": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({ + "description": "The bytes that were used to generate the log probability.\n" + }) + ) + })).annotate({ + "description": + "The log probabilities of the individual tokens in the transcription. Only included if you [create a transcription](/docs/api-reference/audio/create-transcription) with the `include[]` parameter set to `logprobs`.\n" + }) + ), + "usage": Schema.optionalKey(TranscriptTextUsageTokens) }).annotate({ - "title": "File search tool call ranking options", "description": - "The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.\n\nSee the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.\n" + "Emitted when the transcription is complete. Contains the complete transcription text. Only emitted when you [create a transcription](/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.", + "identifier": "TranscriptTextDoneEvent" }) -export type RunStepDetailsToolCallsFileSearchRankingOptionsObject = { - readonly "ranker": FileSearchRanker - readonly "score_threshold": number +export type VoiceConsentListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id"?: string | null + readonly "last_id"?: string | null + readonly "has_more": boolean } -export const RunStepDetailsToolCallsFileSearchRankingOptionsObject = Schema.Struct({ - "ranker": FileSearchRanker, - "score_threshold": Schema.Number.annotate({ - "description": - "The score threshold for the file search. All values must be a floating point number between 0 and 1." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)) -}).annotate({ - "title": "File search tool call ranking options", - "description": "The ranking options for the file search." -}) -export type FineTuneDPOMethod = { readonly "hyperparameters"?: FineTuneDPOHyperparameters } -export const FineTuneDPOMethod = Schema.Struct({ "hyperparameters": Schema.optionalKey(FineTuneDPOHyperparameters) }) - .annotate({ "description": "Configuration for the DPO fine-tuning method." }) -export type FineTuneSupervisedMethod = { readonly "hyperparameters"?: FineTuneSupervisedHyperparameters } -export const FineTuneSupervisedMethod = Schema.Struct({ - "hyperparameters": Schema.optionalKey(FineTuneSupervisedHyperparameters) -}).annotate({ "description": "Configuration for the supervised fine-tuning method." }) -export type ListFineTuningCheckpointPermissionResponse = { - readonly "data": ReadonlyArray - readonly "object": "list" - readonly "first_id"?: string | null - readonly "last_id"?: string | null - readonly "has_more": boolean -} -export const ListFineTuningCheckpointPermissionResponse = Schema.Struct({ - "data": Schema.Array(FineTuningCheckpointPermission), - "object": Schema.Literal("list"), - "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "has_more": Schema.Boolean -}) -export type ListFineTuningJobCheckpointsResponse = { - readonly "data": ReadonlyArray - readonly "object": "list" - readonly "first_id"?: string | null - readonly "last_id"?: string | null - readonly "has_more": boolean -} -export const ListFineTuningJobCheckpointsResponse = Schema.Struct({ - "data": Schema.Array(FineTuningJobCheckpoint), +export const VoiceConsentListResource = Schema.Struct({ "object": Schema.Literal("list"), + "data": Schema.Array(VoiceConsentResource), "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), "has_more": Schema.Boolean -}) -export type ListFineTuningJobEventsResponse = { - readonly "data": ReadonlyArray - readonly "object": "list" - readonly "has_more": boolean -} -export const ListFineTuningJobEventsResponse = Schema.Struct({ - "data": Schema.Array(FineTuningJobEvent), - "object": Schema.Literal("list"), - "has_more": Schema.Boolean -}) -export type ChatCompletionFunctions = { - readonly "description"?: string - readonly "name": string - readonly "parameters"?: FunctionParameters +}).annotate({ "identifier": "VoiceConsentListResource" }) +export type Batch = { + readonly "id": string + readonly "object": "batch" + readonly "endpoint": string + readonly "model"?: string + readonly "errors"?: { readonly "object"?: string; readonly "data"?: ReadonlyArray } + readonly "input_file_id": string + readonly "completion_window": string + readonly "status": + | "validating" + | "failed" + | "in_progress" + | "finalizing" + | "completed" + | "expired" + | "cancelling" + | "cancelled" + readonly "output_file_id"?: string + readonly "error_file_id"?: string + readonly "created_at": number + readonly "in_progress_at"?: number + readonly "expires_at"?: number + readonly "finalizing_at"?: number + readonly "completed_at"?: number + readonly "failed_at"?: number + readonly "expired_at"?: number + readonly "cancelling_at"?: number + readonly "cancelled_at"?: number + readonly "request_counts"?: BatchRequestCounts + 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 + } + readonly "metadata"?: Metadata } -export const ChatCompletionFunctions = Schema.Struct({ - "description": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A description of what the function does, used by the model to choose when and how to call the function." +export const Batch = Schema.Struct({ + "id": Schema.String, + "object": Schema.Literal("batch").annotate({ "description": "The object type, which is always `batch`." }), + "endpoint": Schema.String.annotate({ "description": "The OpenAI API endpoint used by the batch." }), + "model": Schema.optionalKey(Schema.String.annotate({ + "description": + "Model ID used to process the batch, like `gpt-5-2025-08-07`. OpenAI\noffers a wide range of models with different capabilities, performance\ncharacteristics, and price points. Refer to the [model\nguide](/docs/models) to browse and compare available models.\n" + })), + "errors": Schema.optionalKey( + Schema.Struct({ + "object": Schema.optionalKey( + Schema.String.annotate({ "description": "The object type, which is always `list`." }) + ), + "data": Schema.optionalKey(Schema.Array(BatchError)) }) ), - "name": Schema.String.annotate({ - "description": - "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64." + "input_file_id": Schema.String.annotate({ "description": "The ID of the input file for the batch." }), + "completion_window": Schema.String.annotate({ + "description": "The time frame within which the batch should be processed." }), - "parameters": Schema.optionalKey(FunctionParameters) -}) -export type FunctionObject = { - readonly "description"?: string - readonly "name": string - readonly "parameters"?: FunctionParameters - readonly "strict"?: boolean | null -} -export const FunctionObject = Schema.Struct({ - "description": Schema.optionalKey( + "status": Schema.Literals([ + "validating", + "failed", + "in_progress", + "finalizing", + "completed", + "expired", + "cancelling", + "cancelled" + ]).annotate({ "description": "The current status of the batch." }), + "output_file_id": Schema.optionalKey( Schema.String.annotate({ - "description": - "A description of what the function does, used by the model to choose when and how to call the function." + "description": "The ID of the file containing the outputs of successfully executed requests." }) ), - "name": Schema.String.annotate({ - "description": - "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64." - }), - "parameters": Schema.optionalKey(FunctionParameters), - "strict": Schema.optionalKey(Schema.Union([ - Schema.Boolean.annotate({ - "description": - "Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling)." - }), - Schema.Null - ])) -}) -export type GroupListResource = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next": string | null -} -export const GroupListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), - "data": Schema.Array(GroupResponse).annotate({ "description": "Groups returned in the current page." }), - "has_more": Schema.Boolean.annotate({ "description": "Whether additional groups are available when paginating." }), - "next": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Cursor to fetch the next page of results, or `null` if there are no more results." - }) -}).annotate({ "description": "Paginated list of organization groups." }) -export type UserListResource = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next": string | null -} -export const UserListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), - "data": Schema.Array(GroupUser).annotate({ "description": "Users in the current page." }), - "has_more": Schema.Boolean.annotate({ "description": "Whether more users are available when paginating." }), - "next": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Cursor to fetch the next page of results, or `null` when no further users are available." - }) -}).annotate({ "description": "Paginated list of user objects returned when inspecting group membership." }) -export type ProjectHostedToolPermissions = { - readonly "file_search": HostedToolPermission - readonly "web_search": HostedToolPermission - readonly "image_generation": HostedToolPermission - readonly "mcp": HostedToolPermission - readonly "code_interpreter": HostedToolPermission -} -export const ProjectHostedToolPermissions = Schema.Struct({ - "file_search": HostedToolPermission, - "web_search": HostedToolPermission, - "image_generation": HostedToolPermission, - "mcp": HostedToolPermission, - "code_interpreter": HostedToolPermission -}).annotate({ "description": "Represents hosted tool permissions for a project." }) -export type ProjectHostedToolPermissionsUpdateRequest = { - readonly "file_search"?: HostedToolPermissionUpdate | null - readonly "web_search"?: HostedToolPermissionUpdate | null - readonly "image_generation"?: HostedToolPermissionUpdate | null - readonly "mcp"?: HostedToolPermissionUpdate | null - readonly "code_interpreter"?: HostedToolPermissionUpdate | null -} -export const ProjectHostedToolPermissionsUpdateRequest = Schema.Struct({ - "file_search": Schema.optionalKey( - Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ - "description": "The file search permission update." - }) + "error_file_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the file containing the outputs of requests with errors." }) ), - "web_search": Schema.optionalKey( - Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ - "description": "The web search permission update." - }) + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the batch was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "in_progress_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the batch started processing.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "image_generation": Schema.optionalKey( - Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ - "description": "The image generation permission update." - }) + "expires_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the batch will expire.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "mcp": Schema.optionalKey( - Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ "description": "The MCP permission update." }) + "finalizing_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the batch started finalizing.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "code_interpreter": Schema.optionalKey( - Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ - "description": "The code interpreter permission update." - }) - ) -}) -export type ImageEditCompletedEvent = { - readonly "type": "image_edit.completed" - readonly "b64_json": string - readonly "created_at": number - readonly "size": "1024x1024" | "1024x1536" | "1536x1024" | "auto" - readonly "quality": "low" | "medium" | "high" | "auto" - readonly "background": "transparent" | "opaque" | "auto" - readonly "output_format": "png" | "webp" | "jpeg" - readonly "usage": ImagesUsage -} -export const ImageEditCompletedEvent = Schema.Struct({ - "type": Schema.Literal("image_edit.completed").annotate({ - "description": "The type of the event. Always `image_edit.completed`.\n" - }), - "b64_json": Schema.String.annotate({ - "description": "Base64-encoded final edited image data, suitable for rendering as an image.\n" - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp when the event was created.\n", - "format": "unixtime" - }).check(Schema.isInt()), - "size": Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"]).annotate({ - "description": "The size of the edited image.\n" - }), - "quality": Schema.Literals(["low", "medium", "high", "auto"]).annotate({ - "description": "The quality setting for the edited image.\n" - }), - "background": Schema.Literals(["transparent", "opaque", "auto"]).annotate({ - "description": "The background setting for the edited image.\n" - }), - "output_format": Schema.Literals(["png", "webp", "jpeg"]).annotate({ - "description": "The output format for the edited image.\n" - }), - "usage": ImagesUsage -}).annotate({ "description": "Emitted when image editing has completed and the final image is available.\n" }) -export type ImageGenCompletedEvent = { - readonly "type": "image_generation.completed" - readonly "b64_json": string - readonly "created_at": number - readonly "size": "1024x1024" | "1024x1536" | "1536x1024" | "auto" - readonly "quality": "low" | "medium" | "high" | "auto" - readonly "background": "transparent" | "opaque" | "auto" - readonly "output_format": "png" | "webp" | "jpeg" - readonly "usage": ImagesUsage -} -export const ImageGenCompletedEvent = Schema.Struct({ - "type": Schema.Literal("image_generation.completed").annotate({ - "description": "The type of the event. Always `image_generation.completed`.\n" - }), - "b64_json": Schema.String.annotate({ - "description": "Base64-encoded image data, suitable for rendering as an image.\n" - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp when the event was created.\n", - "format": "unixtime" - }).check(Schema.isInt()), - "size": Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"]).annotate({ - "description": "The size of the generated image.\n" - }), - "quality": Schema.Literals(["low", "medium", "high", "auto"]).annotate({ - "description": "The quality setting for the generated image.\n" - }), - "background": Schema.Literals(["transparent", "opaque", "auto"]).annotate({ - "description": "The background setting for the generated image.\n" - }), - "output_format": Schema.Literals(["png", "webp", "jpeg"]).annotate({ - "description": "The output format for the generated image.\n" - }), - "usage": ImagesUsage -}).annotate({ "description": "Emitted when image generation has completed and the final image is available.\n" }) -export type InviteListResponse = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id"?: string | null - readonly "last_id"?: string | null - readonly "has_more": boolean -} -export const InviteListResponse = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "The object type, which is always `list`" }), - "data": Schema.Array(Invite), - "first_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The first `invite_id` in the retrieved `list`" - }) + "completed_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the batch was completed.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "last_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The last `invite_id` in the retrieved `list`" - }) + "failed_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the batch failed.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "has_more": Schema.Boolean.annotate({ - "description": "The `has_more` property is used for pagination to indicate there are additional results." - }) -}) -export type RealtimeServerEventConversationItemInputAudioTranscriptionCompleted = { - readonly "event_id": string - readonly "type": "conversation.item.input_audio_transcription.completed" - readonly "item_id": string - readonly "content_index": number - readonly "transcript": string - readonly "logprobs"?: ReadonlyArray | null - readonly "usage": { - readonly "type": "tokens" - readonly "input_tokens": number - readonly "input_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number } - readonly "output_tokens": number - readonly "total_tokens": number - } | { readonly "type": "duration"; readonly "seconds": number } -} -export const RealtimeServerEventConversationItemInputAudioTranscriptionCompleted = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.input_audio_transcription.completed").annotate({ - "description": "The event type, must be\n`conversation.item.input_audio_transcription.completed`.\n" - }), - "item_id": Schema.String.annotate({ - "description": "The ID of the item containing the audio that is being transcribed." - }), - "content_index": Schema.Number.annotate({ "description": "The index of the content part containing the audio." }) - .check(Schema.isInt()), - "transcript": Schema.String.annotate({ "description": "The transcribed text." }), - "logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Array(LogProbProperties).annotate({ "description": "The log probabilities of the transcription." }), - Schema.Null - ]) + "expired_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the batch expired.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "cancelling_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the batch started cancelling.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "cancelled_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the batch was cancelled.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "usage": Schema.Union([ + "request_counts": Schema.optionalKey(BatchRequestCounts), + "usage": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("tokens").annotate({ - "description": "The type of the usage object. Always `tokens` for this variant." - }), - "input_tokens": Schema.Number.annotate({ "description": "Number of input tokens billed for this request." }) - .check(Schema.isInt()), - "input_token_details": Schema.optionalKey( - Schema.Struct({ - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of text tokens billed for this request." }).check( - Schema.isInt() - ) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of audio tokens billed for this request." }).check( - Schema.isInt() - ) - ) - }).annotate({ "description": "Details about the input tokens billed for this request." }) + "input_tokens": Schema.Number.annotate({ "description": "The number of input tokens." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check( - Schema.isInt() + "input_tokens_details": Schema.Struct({ + "cached_tokens": Schema.Number.annotate({ + "description": + "The number of tokens that were retrieved from the cache. [More on\nprompt caching](/docs/guides/prompt-caching).\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + }).annotate({ "description": "A detailed breakdown of the input tokens." }), + "output_tokens": Schema.Number.annotate({ "description": "The number of output tokens." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check( - Schema.isInt() + "output_tokens_details": Schema.Struct({ + "reasoning_tokens": Schema.Number.annotate({ "description": "The number of reasoning tokens." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).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({ "expected": "an integer" }) ) }).annotate({ - "title": "Token Usage", "description": - "Usage statistics for the transcription, this is billed according to the ASR model's pricing rather than the realtime model's pricing." + "Represents token usage details including input tokens, output tokens, a\nbreakdown of output tokens, and the total tokens used. Only populated on\nbatches created after September 7, 2025.\n" + }) + ), + "metadata": Schema.optionalKey(Metadata) +}).annotate({ "identifier": "Batch" }) +export type CreateBatchRequest = { + readonly "input_file_id": string + readonly "endpoint": + | "/v1/responses" + | "/v1/chat/completions" + | "/v1/embeddings" + | "/v1/completions" + | "/v1/moderations" + | "/v1/images/generations" + | "/v1/images/edits" + | "/v1/videos" + readonly "completion_window": "24h" + readonly "metadata"?: Metadata + readonly "output_expires_after"?: BatchFileExpirationAfter +} +export const CreateBatchRequest = Schema.Struct({ + "input_file_id": Schema.String.annotate({ + "description": + "The ID of an uploaded file that contains requests for the new batch.\n\nSee [upload file](/docs/api-reference/files/create) for how to upload a file.\n\nYour input file must be formatted as a [JSONL file](/docs/api-reference/batch/request-input), and must be uploaded with the purpose `batch`. The file can contain up to 50,000 requests, and can be up to 200 MB in size.\n" + }), + "endpoint": Schema.Literals([ + "/v1/responses", + "/v1/chat/completions", + "/v1/embeddings", + "/v1/completions", + "/v1/moderations", + "/v1/images/generations", + "/v1/images/edits", + "/v1/videos" + ]).annotate({ + "description": + "The endpoint to be used for all requests in the batch. Currently `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`, `/v1/moderations`, `/v1/images/generations`, `/v1/images/edits`, and `/v1/videos` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch." + }), + "completion_window": Schema.Literal("24h").annotate({ + "description": "The time frame within which the batch should be processed. Currently only `24h` is supported." + }), + "metadata": Schema.optionalKey(Metadata), + "output_expires_after": Schema.optionalKey(BatchFileExpirationAfter) +}).annotate({ "identifier": "CreateBatchRequest" }) +export type ChatCompletionMessageToolCalls = ReadonlyArray< + ChatCompletionMessageToolCall | ChatCompletionMessageCustomToolCall +> +export const ChatCompletionMessageToolCalls = Schema.Array( + Schema.Union([ChatCompletionMessageToolCall, ChatCompletionMessageCustomToolCall], { mode: "oneOf" }) +).annotate({ + "description": "The tool calls generated by the model, such as function calls.", + "identifier": "ChatCompletionMessageToolCalls" +}) +export type CreateCompletionResponse = { + readonly "id": string + readonly "choices": ReadonlyArray< + { + readonly "finish_reason": "stop" | "length" | "content_filter" + readonly "index": number + readonly "logprobs": { + readonly "text_offset"?: ReadonlyArray + readonly "token_logprobs"?: ReadonlyArray + readonly "tokens"?: ReadonlyArray + readonly "top_logprobs"?: ReadonlyArray<{}> + } | null + readonly "text": string + } + > + readonly "created": number + readonly "model": string + readonly "system_fingerprint"?: string + readonly "object": "text_completion" + readonly "usage"?: CompletionUsage +} +export const CreateCompletionResponse = Schema.Struct({ + "id": Schema.String.annotate({ "description": "A unique identifier for the completion." }), + "choices": Schema.Array(Schema.Struct({ + "finish_reason": Schema.Literals(["stop", "length", "content_filter"]).annotate({ + "description": + "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\nor `content_filter` if content was omitted due to a flag from our content filters.\n" }), - Schema.Struct({ - "type": Schema.Literal("duration").annotate({ - "description": "The type of the usage object. Always `duration` for this variant." + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "logprobs": Schema.Union([ + Schema.Struct({ + "text_offset": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) + ), + "token_logprobs": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))) + ), + "tokens": Schema.optionalKey(Schema.Array(Schema.String)), + "top_logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({}))) }), - "seconds": Schema.Number.annotate({ - "description": "Duration of the input audio in seconds.", - "format": "double" - }).check(Schema.isFinite()) - }).annotate({ - "title": "Duration Usage", + Schema.Null + ]), + "text": Schema.String + })).annotate({ "description": "The list of completion choices the model generated for the input prompt." }), + "created": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the completion was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "model": Schema.String.annotate({ "description": "The model used for completion." }), + "system_fingerprint": Schema.optionalKey( + Schema.String.annotate({ "description": - "Usage statistics for the transcription, this is billed according to the ASR model's pricing rather than the realtime model's pricing." + "This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" }) - ], { mode: "oneOf" }) + ), + "object": Schema.Literal("text_completion").annotate({ + "description": "The object type, which is always \"text_completion\"" + }), + "usage": Schema.optionalKey(CompletionUsage) }).annotate({ "description": - "This event is the output of audio transcription for user audio written to the\nuser audio buffer. Transcription begins when the input audio buffer is\ncommitted by the client or server (when VAD is enabled). Transcription runs\nasynchronously with Response creation, so this event may come before or after\nthe Response events.\n\nRealtime API models accept audio natively, and thus input transcription is a\nseparate process run on a separate ASR (Automatic Speech Recognition) model.\nThe transcript may diverge somewhat from the model's interpretation, and\nshould be treated as a rough guide.\n" + "Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).\n", + "identifier": "CreateCompletionResponse" }) -export type RealtimeServerEventConversationItemInputAudioTranscriptionDelta = { - readonly "event_id": string - readonly "type": "conversation.item.input_audio_transcription.delta" - readonly "item_id": string - readonly "content_index"?: number - readonly "delta"?: string - readonly "logprobs"?: ReadonlyArray | null +export type ChatCompletionModerationResults = { + readonly "type": "moderation_results" + readonly "model": string + readonly "results": ReadonlyArray } -export const RealtimeServerEventConversationItemInputAudioTranscriptionDelta = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.input_audio_transcription.delta").annotate({ - "description": "The event type, must be `conversation.item.input_audio_transcription.delta`." +export const ChatCompletionModerationResults = Schema.Struct({ + "type": Schema.Literal("moderation_results").annotate({ + "description": "The object type, which is always `moderation_results`." }), - "item_id": Schema.String.annotate({ - "description": "The ID of the item containing the audio that is being transcribed." - }), - "content_index": Schema.optionalKey( - Schema.Number.annotate({ "description": "The index of the content part in the item's content array." }).check( - Schema.isInt() - ) + "model": Schema.String.annotate({ "description": "The moderation model used to generate the results." }), + "results": Schema.Array(ModerationResultBody).annotate({ "description": "A list of moderation results." }) +}).annotate({ + "description": "Successful moderation results for the request input or generated output.", + "identifier": "ChatCompletionModerationResults" +}) +export type PromptCacheOptionsParam = { readonly "ttl"?: PromptCacheTTLEnum; readonly "mode"?: PromptCacheModeEnum } +export const PromptCacheOptionsParam = Schema.Struct({ + "ttl": Schema.optionalKey( + Schema.suspend((): Schema.Codec => PromptCacheTTLEnum).annotate({ + "description": + "The minimum lifetime applied to every implicit and explicit cache breakpoint written by the request. Defaults to `30m`, which is currently the only supported value. The backend may retain cache entries for longer." + }) ), - "delta": Schema.optionalKey(Schema.String.annotate({ "description": "The text delta." })), - "logprobs": Schema.optionalKey(Schema.Union([ - Schema.Array(LogProbProperties).annotate({ + "mode": Schema.optionalKey( + Schema.suspend((): Schema.Codec => PromptCacheModeEnum).annotate({ "description": - "The log probabilities of the transcription. These can be enabled by configurating the session with `\"include\": [\"item.input_audio_transcription.logprobs\"]`. Each entry in the array corresponds a log probability of which token would be selected for this chunk of transcription. This can help to identify if it was possible there were multiple valid options for a given chunk of transcription." - }), - Schema.Null - ])) + "Controls whether OpenAI automatically creates an implicit cache breakpoint. Defaults to `implicit`. With `implicit`, OpenAI creates one implicit breakpoint and writes up to the latest three explicit breakpoints in the request. With `explicit`, OpenAI does not create an implicit breakpoint and writes up to the latest four explicit breakpoints. If there are no explicit breakpoints, the request does not use prompt caching." + }) + ) }).annotate({ + "title": "Prompt cache options", "description": - "Returned when the text value of an input audio transcription content part is updated with incremental transcription results.\n" + "Options for prompt caching. Supported for `gpt-5.6` and later models. By default, OpenAI automatically chooses one implicit cache breakpoint. You can add explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each request can write up to four breakpoints. For cache matching, OpenAI considers up to the latest 80 breakpoints in the conversation, without a content-block lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The `ttl` defaults to `30m`, which is currently the only supported value. See the [prompt caching guide](/docs/guides/prompt-caching) for current details.", + "identifier": "PromptCacheOptionsParam" }) -export type MCPListTools = { - readonly "type": "mcp_list_tools" - readonly "id": string - readonly "server_label": string - readonly "tools": ReadonlyArray - readonly "error"?: string | null -} -export const MCPListTools = Schema.Struct({ - "type": Schema.Literal("mcp_list_tools").annotate({ - "description": "The type of the item. Always `mcp_list_tools`.\n" +export type PromptCacheOptions = { readonly "ttl": PromptCacheTTLEnum; readonly "mode": PromptCacheModeEnum } +export const PromptCacheOptions = Schema.Struct({ + "ttl": Schema.suspend((): Schema.Codec => PromptCacheTTLEnum).annotate({ + "description": "The minimum lifetime applied to each cache breakpoint." }), - "id": Schema.String.annotate({ "description": "The unique ID of the list.\n" }), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server.\n" }), - "tools": Schema.Array(MCPListToolsTool).annotate({ "description": "The tools available on the server.\n" }), - "error": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "Error message if the server could not list tools.\n" }), - Schema.Null - ]) - ) -}).annotate({ "title": "MCP list tools", "description": "A list of tools available on an MCP server.\n" }) -export type RealtimeMCPListTools = { - readonly "type": "mcp_list_tools" - readonly "id"?: string - readonly "server_label": string - readonly "tools": ReadonlyArray + "mode": Schema.suspend((): Schema.Codec => PromptCacheModeEnum).annotate({ + "description": "Whether implicit prompt-cache breakpoints were enabled." + }) +}).annotate({ + "title": "Prompt cache options", + "description": + "The prompt-caching options that were applied to the response. Supported for `gpt-5.6` and later models.", + "identifier": "PromptCacheOptions" +}) +export type ChatCompletionRequestMessageContentPartText = { + readonly "type": "text" + readonly "text": string + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointParam } -export const RealtimeMCPListTools = Schema.Struct({ - "type": Schema.Literal("mcp_list_tools").annotate({ - "description": "The type of the item. Always `mcp_list_tools`." +export const ChatCompletionRequestMessageContentPartText = Schema.Struct({ + "type": Schema.Literal("text").annotate({ "description": "The type of the content part." }), + "text": Schema.String.annotate({ "description": "The text content." }), + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpointParam) +}).annotate({ + "title": "Text content part", + "description": "Learn about [text inputs](/docs/guides/text-generation).\n", + "identifier": "ChatCompletionRequestMessageContentPartText" +}) +export type ChatCompletionRequestMessageContentPartImage = { + readonly "type": "image_url" + readonly "image_url": { readonly "url": string; readonly "detail"?: "auto" | "low" | "high" } + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointParam +} +export const ChatCompletionRequestMessageContentPartImage = Schema.Struct({ + "type": Schema.Literal("image_url").annotate({ "description": "The type of the content part." }), + "image_url": Schema.Struct({ + "url": Schema.String.annotate({ + "description": "Either a URL of the image or the base64 encoded image data.", + "format": "uri" + }), + "detail": Schema.optionalKey( + Schema.Literals(["auto", "low", "high"]).annotate({ + "description": + "Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding)." + }) + ) }), - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the list." })), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server." }), - "tools": Schema.Array(MCPListToolsTool).annotate({ "description": "The tools available on the server." }) + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpointParam) }).annotate({ - "title": "Realtime MCP list tools", - "description": "A Realtime item listing tools available on an MCP server.\n" + "title": "Image content part", + "description": "Learn about [image inputs](/docs/guides/vision).\n", + "identifier": "ChatCompletionRequestMessageContentPartImage" }) -export type MCPTool = { - readonly "type": "mcp" - readonly "server_label": string - readonly "server_url"?: string - readonly "connector_id"?: - | "connector_dropbox" - | "connector_gmail" - | "connector_googlecalendar" - | "connector_googledrive" - | "connector_microsoftteams" - | "connector_outlookcalendar" - | "connector_outlookemail" - | "connector_sharepoint" - readonly "authorization"?: string - readonly "server_description"?: string - readonly "headers"?: {} | null - readonly "allowed_tools"?: ReadonlyArray | MCPToolFilter | null - readonly "require_approval"?: - | { readonly "always"?: MCPToolFilter; readonly "never"?: MCPToolFilter } - | "always" - | "never" - | null - readonly "defer_loading"?: boolean +export type ChatCompletionRequestMessageContentPartAudio = { + readonly "type": "input_audio" + readonly "input_audio": { readonly "data": string; readonly "format": "wav" | "mp3" } + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointParam } -export const MCPTool = Schema.Struct({ - "type": Schema.Literal("mcp").annotate({ "description": "The type of the MCP tool. Always `mcp`." }), - "server_label": Schema.String.annotate({ - "description": "A label for this MCP server, used to identify it in tool calls.\n" +export const ChatCompletionRequestMessageContentPartAudio = Schema.Struct({ + "type": Schema.Literal("input_audio").annotate({ + "description": "The type of the content part. Always `input_audio`." }), - "server_url": Schema.optionalKey( - Schema.String.annotate({ - "description": "The URL for the MCP server. One of `server_url` or `connector_id` must be\nprovided.\n", - "format": "uri" + "input_audio": Schema.Struct({ + "data": Schema.String.annotate({ "description": "Base64 encoded audio data." }), + "format": Schema.Literals(["wav", "mp3"]).annotate({ + "description": "The format of the encoded audio data. Currently supports \"wav\" and \"mp3\".\n" }) + }), + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpointParam) +}).annotate({ + "title": "Audio content part", + "description": "Learn about [audio inputs](/docs/guides/audio).\n", + "identifier": "ChatCompletionRequestMessageContentPartAudio" +}) +export type ChatCompletionRequestMessageContentPartFile = { + readonly "type": "file" + readonly "file": { readonly "filename"?: string; readonly "file_data"?: string; readonly "file_id"?: string } + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointParam +} +export const ChatCompletionRequestMessageContentPartFile = Schema.Struct({ + "type": Schema.Literal("file").annotate({ "description": "The type of the content part. Always `file`." }), + "file": Schema.Struct({ + "filename": Schema.optionalKey( + Schema.String.annotate({ + "description": "The name of the file, used when passing the file to the model as a \nstring.\n" + }) + ), + "file_data": Schema.optionalKey( + Schema.String.annotate({ + "description": "The base64 encoded file data, used when passing the file to the model \nas a string.\n" + }) + ), + "file_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of an uploaded file to use as input.\n" }) + ) + }), + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpointParam) +}).annotate({ + "title": "File content part", + "description": "Learn about [file inputs](/docs/guides/text) for text generation.\n", + "identifier": "ChatCompletionRequestMessageContentPartFile" +}) +export type InputTextContentParam = { + readonly "type": "input_text" + readonly "text": string + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointParam | null +} +export const InputTextContentParam = Schema.Struct({ + "type": Schema.Literal("input_text").annotate({ "description": "The type of the input item. Always `input_text`." }), + "text": Schema.String.annotate({ "description": "The text input to the model." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) ), - "connector_id": Schema.optionalKey( - Schema.Literals([ - "connector_dropbox", - "connector_gmail", - "connector_googlecalendar", - "connector_googledrive", - "connector_microsoftteams", - "connector_outlookcalendar", - "connector_outlookemail", - "connector_sharepoint" + "prompt_cache_breakpoint": Schema.optionalKey(Schema.Union([PromptCacheBreakpointParam, Schema.Null])) +}).annotate({ + "title": "Input text", + "description": "A text input to the model.", + "identifier": "InputTextContentParam" +}) +export type ModelIdsResponses = + | 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" +export const ModelIdsResponses = 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({ "identifier": "ModelIdsResponses" }) +export type ModerationConfigParam = { readonly "mode": ModerationMode } +export const ModerationConfigParam = Schema.Struct({ "mode": ModerationMode }).annotate({ + "description": "The moderation policy for the response input.", + "identifier": "ModerationConfigParam" +}) +export type CreateCompletionRequest = { + readonly "model": string | "gpt-3.5-turbo-instruct" | "davinci-002" | "babbage-002" + readonly "prompt": + | string + | ReadonlyArray + | ReadonlyArray + | ReadonlyArray> + | null + readonly "best_of"?: number | null + readonly "echo"?: boolean | null + readonly "frequency_penalty"?: number | null + readonly "logit_bias"?: { readonly [x: string]: number } | null + readonly "logprobs"?: number | null + readonly "max_tokens"?: number | null + readonly "n"?: number | null + readonly "presence_penalty"?: number | null + readonly "seed"?: number | null + readonly "stop"?: StopConfiguration + readonly "stream"?: boolean | null + readonly "stream_options"?: ChatCompletionStreamOptions + readonly "suffix"?: string | null + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "user"?: string +} +export const CreateCompletionRequest = Schema.Struct({ + "model": Schema.Union([Schema.String, Schema.Literals(["gpt-3.5-turbo-instruct", "davinci-002", "babbage-002"])]) + .annotate({ + "description": + "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" + }), + "prompt": Schema.Union([ + Schema.Union([ + Schema.String, + Schema.Array(Schema.String), + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Array( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + ).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ], { mode: "oneOf" }).annotate({ + "description": + "The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.\n\nNote that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.\n" + }), + Schema.Null + ]), + "best_of": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" })), + Schema.Null ]).annotate({ "description": - "Identifier for service connectors, like those available in ChatGPT. One of\n`server_url` or `connector_id` must be provided. Learn more about service\nconnectors [here](/docs/guides/tools-remote-mcp#connectors).\n\nCurrently supported `connector_id` values are:\n\n- Dropbox: `connector_dropbox`\n- Gmail: `connector_gmail`\n- Google Calendar: `connector_googlecalendar`\n- Google Drive: `connector_googledrive`\n- Microsoft Teams: `connector_microsoftteams`\n- Outlook Calendar: `connector_outlookcalendar`\n- Outlook Email: `connector_outlookemail`\n- SharePoint: `connector_sharepoint`\n" + "Generates `best_of` completions server-side and returns the \"best\" (the one with the highest log probability per token). Results cannot be streamed.\n\nWhen used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n" }) ), - "authorization": Schema.optionalKey( - Schema.String.annotate({ - "description": - "An OAuth access token that can be used with a remote MCP server, either\nwith a custom MCP server URL or a service connector. Your application\nmust handle the OAuth authorization flow and provide the token here.\n" + "echo": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Echo back the prompt in addition to the completion\n" }) ), - "server_description": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional description of the MCP server, used to provide more context.\n" }) + "frequency_penalty": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(-2).annotate({ "expected": "a value greater than or equal to -2" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]).annotate({ + "description": + "Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n\n[See more information about frequency and presence penalties.](/docs/guides/text-generation)\n" + }) ), - "headers": Schema.optionalKey( + "logit_bias": Schema.optionalKey( Schema.Union([ - Schema.Struct({}).annotate({ - "description": "Optional HTTP headers to send to the MCP server. Use for authentication\nor other purposes.\n" - }), + Schema.Record(Schema.String, Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), Schema.Null - ]) + ]).annotate({ + "description": + "Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n\nAs an example, you can pass `{\"50256\": -100}` to prevent the <|endoftext|> token from being generated.\n" + }) ), - "allowed_tools": Schema.optionalKey( + "logprobs": Schema.optionalKey( Schema.Union([ - Schema.Union([ - Schema.Array(Schema.String).annotate({ - "title": "MCP allowed tools", - "description": "A string array of allowed tool names" - }), - MCPToolFilter - ], { mode: "oneOf" }).annotate({ "description": "List of allowed tool names or a filter object.\n" }), + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(5).annotate({ "expected": "a value less than or equal to 5" })), Schema.Null - ]) + ]).annotate({ + "description": + "Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.\n\nThe maximum value for `logprobs` is 5.\n" + }) ), - "require_approval": Schema.optionalKey( + "max_tokens": Schema.optionalKey( Schema.Union([ - Schema.Union([ - Schema.Struct({ "always": Schema.optionalKey(MCPToolFilter), "never": Schema.optionalKey(MCPToolFilter) }) - .annotate({ - "title": "MCP tool approval filter", - "description": - "Specify which of the MCP server's tools require approval. Can be\n`always`, `never`, or a filter object associated with tools\nthat require approval.\n" - }), - Schema.Literals(["always", "never"]).annotate({ - "title": "MCP tool approval setting", - "description": - "Specify a single approval policy for all tools. One of `always` or\n`never`. When set to `always`, all tools will require approval. When\nset to `never`, all tools will not require approval.\n" - }) - ], { mode: "oneOf" }).annotate({ "description": "Specify which of the MCP server's tools require approval." }), + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), Schema.Null - ]) + ]).annotate({ + "description": + "The maximum number of [tokens](/tokenizer) that can be generated in the completion.\n\nThe token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.\n" + }) ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether this MCP tool is deferred and discovered via tool search.\n" }) - ) -}).annotate({ - "title": "MCP tool", - "description": - "Give the model access to additional tools via remote Model Context Protocol\n(MCP) servers. [Learn more about MCP](/docs/guides/tools-remote-mcp).\n" -}) -export type MessageContentTextObject = { - readonly "type": "text" - readonly "text": { - readonly "value": string - readonly "annotations": ReadonlyArray< - MessageContentTextAnnotationsFileCitationObject | MessageContentTextAnnotationsFilePathObject - > - } -} -export const MessageContentTextObject = Schema.Struct({ - "type": Schema.Literal("text").annotate({ "description": "Always `text`." }), - "text": Schema.Struct({ - "value": Schema.String.annotate({ "description": "The data that makes up the text." }), - "annotations": Schema.Array( - Schema.Union([MessageContentTextAnnotationsFileCitationObject, MessageContentTextAnnotationsFilePathObject], { - mode: "oneOf" - }) - ) - }) -}).annotate({ "title": "Text", "description": "The text content that is part of a message." }) -export type MessageDeltaContentTextObject = { - readonly "index": number - readonly "type": "text" - readonly "text"?: { - readonly "value"?: string - readonly "annotations"?: ReadonlyArray< - MessageDeltaContentTextAnnotationsFileCitationObject | MessageDeltaContentTextAnnotationsFilePathObject - > - } -} -export const MessageDeltaContentTextObject = Schema.Struct({ - "index": Schema.Number.annotate({ "description": "The index of the content part in the message." }).check( - Schema.isInt() - ), - "type": Schema.Literal("text").annotate({ "description": "Always `text`." }), - "text": Schema.optionalKey(Schema.Struct({ - "value": Schema.optionalKey(Schema.String.annotate({ "description": "The data that makes up the text." })), - "annotations": Schema.optionalKey( - Schema.Array( - Schema.Union([ - MessageDeltaContentTextAnnotationsFileCitationObject, - MessageDeltaContentTextAnnotationsFilePathObject - ], { mode: "oneOf" }) - ) - ) - })) -}).annotate({ "title": "Text", "description": "The text content that is part of a message." }) -export type Batch = { - readonly "id": string - readonly "object": "batch" - readonly "endpoint": string - readonly "model"?: string - readonly "errors"?: { - readonly "object"?: string - readonly "data"?: ReadonlyArray< - { - readonly "code"?: string - readonly "message"?: string - readonly "param"?: string | null - readonly "line"?: number | null - } - > - } - readonly "input_file_id": string - readonly "completion_window": string - readonly "status": - | "validating" - | "failed" - | "in_progress" - | "finalizing" - | "completed" - | "expired" - | "cancelling" - | "cancelled" - readonly "output_file_id"?: string - readonly "error_file_id"?: string - readonly "created_at": number - readonly "in_progress_at"?: number - readonly "expires_at"?: number - readonly "finalizing_at"?: number - readonly "completed_at"?: number - readonly "failed_at"?: number - readonly "expired_at"?: number - readonly "cancelling_at"?: number - readonly "cancelled_at"?: number - readonly "request_counts"?: { readonly "total": number; readonly "completed": number; readonly "failed": 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 - } - readonly "metadata"?: Metadata -} -export const Batch = Schema.Struct({ - "id": Schema.String, - "object": Schema.Literal("batch").annotate({ "description": "The object type, which is always `batch`." }), - "endpoint": Schema.String.annotate({ "description": "The OpenAI API endpoint used by the batch." }), - "model": Schema.optionalKey(Schema.String.annotate({ - "description": - "Model ID used to process the batch, like `gpt-5-2025-08-07`. OpenAI\noffers a wide range of models with different capabilities, performance\ncharacteristics, and price points. Refer to the [model\nguide](/docs/models) to browse and compare available models.\n" - })), - "errors": Schema.optionalKey(Schema.Struct({ - "object": Schema.optionalKey(Schema.String.annotate({ "description": "The object type, which is always `list`." })), - "data": Schema.optionalKey(Schema.Array(Schema.Struct({ - "code": Schema.optionalKey( - Schema.String.annotate({ "description": "An error code identifying the error type." }) - ), - "message": Schema.optionalKey( - Schema.String.annotate({ "description": "A human-readable message providing more details about the error." }) - ), - "param": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The name of the parameter that caused the error, if applicable." }), - Schema.Null - ]) - ), - "line": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The line number of the input file where the error occurred, if applicable." - }).check(Schema.isInt()), - Schema.Null - ]) - ) - }))) - })), - "input_file_id": Schema.String.annotate({ "description": "The ID of the input file for the batch." }), - "completion_window": Schema.String.annotate({ - "description": "The time frame within which the batch should be processed." - }), - "status": Schema.Literals([ - "validating", - "failed", - "in_progress", - "finalizing", - "completed", - "expired", - "cancelling", - "cancelled" - ]).annotate({ "description": "The current status of the batch." }), - "output_file_id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The ID of the file containing the outputs of successfully executed requests." + "n": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(128).annotate({ "expected": "a value less than or equal to 128" })), + Schema.Null + ]).annotate({ + "description": + "How many completions to generate for each prompt.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n" }) ), - "error_file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the file containing the outputs of requests with errors." }) - ), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the batch was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "in_progress_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the batch started processing.", - "format": "unixtime" - }).check(Schema.isInt()) - ), - "expires_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the batch will expire.", - "format": "unixtime" - }).check(Schema.isInt()) - ), - "finalizing_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the batch started finalizing.", - "format": "unixtime" - }).check(Schema.isInt()) + "presence_penalty": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(-2).annotate({ "expected": "a value greater than or equal to -2" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]).annotate({ + "description": + "Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.\n\n[See more information about frequency and presence penalties.](/docs/guides/text-generation)\n" + }) ), - "completed_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the batch was completed.", - "format": "unixtime" - }).check(Schema.isInt()) + "seed": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "description": + "If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.\n\nDeterminism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.\n", + "format": "int64" + }) ), - "failed_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the batch failed.", - "format": "unixtime" - }).check(Schema.isInt()) + "stop": Schema.optionalKey(StopConfiguration), + "stream": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).\n" + }) ), - "expired_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the batch expired.", - "format": "unixtime" - }).check(Schema.isInt()) + "stream_options": Schema.optionalKey(ChatCompletionStreamOptions), + "suffix": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "The suffix that comes after a completion of inserted text.\n\nThis parameter is only supported for `gpt-3.5-turbo-instruct`.\n" + }) ), - "cancelling_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the batch started cancelling.", - "format": "unixtime" - }).check(Schema.isInt()) + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]).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.\n\nWe generally recommend altering this or `top_p` but not both.\n" + }) ), - "cancelled_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the batch was cancelled.", - "format": "unixtime" - }).check(Schema.isInt()) + "top_p": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), + Schema.Null + ]).annotate({ + "description": + "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or `temperature` but not both.\n" + }) ), - "request_counts": Schema.optionalKey( - Schema.Struct({ - "total": Schema.Number.annotate({ "description": "Total number of requests in the batch." }).check( - Schema.isInt() - ), - "completed": Schema.Number.annotate({ - "description": "Number of requests that have been completed successfully." - }).check(Schema.isInt()), - "failed": Schema.Number.annotate({ "description": "Number of requests that have failed." }).check(Schema.isInt()) - }).annotate({ "description": "The request counts for different statuses within the batch." }) + "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" + }) + ) +}).annotate({ "identifier": "CreateCompletionRequest" }) +export type ChatCompletionAllowedToolsChoice = { + readonly "type": "allowed_tools" + readonly "allowed_tools": ChatCompletionAllowedTools +} +export const ChatCompletionAllowedToolsChoice = Schema.Struct({ + "type": Schema.Literal("allowed_tools").annotate({ + "description": "Allowed tool configuration type. Always `allowed_tools`." + }), + "allowed_tools": ChatCompletionAllowedTools +}).annotate({ + "title": "Allowed tools", + "description": "Constrains the tools available to the model to a pre-defined set.\n", + "identifier": "ChatCompletionAllowedToolsChoice" +}) +export type ChatCompletionStreamResponseDelta = { + readonly "content"?: string | null + readonly "function_call"?: { readonly "arguments"?: string; readonly "name"?: string } + readonly "tool_calls"?: ReadonlyArray + readonly "role"?: "developer" | "system" | "user" | "assistant" | "tool" + readonly "refusal"?: string | null +} +export const ChatCompletionStreamResponseDelta = Schema.Struct({ + "content": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The contents of the chunk message." }), Schema.Null]) ), - "usage": Schema.optionalKey( + "function_call": Schema.optionalKey( 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. [More on\nprompt 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() - ) + "arguments": Schema.optionalKey(Schema.String.annotate({ + "description": + "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + })), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function to call." })) }).annotate({ "description": - "Represents token usage details including input tokens, output tokens, a\nbreakdown of output tokens, and the total tokens used. Only populated on\nbatches created after September 7, 2025.\n" + "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model." }) ), - "metadata": Schema.optionalKey(Metadata) -}) -export type CreateMessageRequest = { - readonly "role": "user" | "assistant" - readonly "content": - | string - | ReadonlyArray - readonly "attachments"?: - | ReadonlyArray< - { - readonly "file_id"?: string - readonly "tools"?: ReadonlyArray - } - > - | null - readonly "metadata"?: Metadata -} -export const CreateMessageRequest = Schema.Struct({ - "role": Schema.Literals(["user", "assistant"]).annotate({ - "description": - "The role of the entity that is creating the message. Allowed values include:\n- `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.\n- `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.\n" - }), - "content": Schema.Union([ - Schema.String.annotate({ "title": "Text content", "description": "The text contents of the message." }), - Schema.Array( - Schema.Union([MessageContentImageFileObject, MessageContentImageUrlObject, MessageRequestContentTextObject], { - mode: "oneOf" - }) - ).annotate({ - "title": "Array of content parts", - "description": - "An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models)." - }).check(Schema.isMinLength(1)) - ], { mode: "oneOf" }), - "attachments": Schema.optionalKey(Schema.Union([ - Schema.Array(Schema.Struct({ - "file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the file to attach to the message." }) - ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Union([AssistantToolsCode, AssistantToolsFileSearchTypeOnly], { mode: "oneOf" })).annotate({ - "description": "The tools to add this file to." - }) - ) - })).annotate({ "description": "A list of files attached to the message, and the tools they should be added to." }), - Schema.Null - ])), - "metadata": Schema.optionalKey(Metadata) + "tool_calls": Schema.optionalKey(Schema.Array(ChatCompletionMessageToolCallChunk)), + "role": Schema.optionalKey( + Schema.Literals(["developer", "system", "user", "assistant", "tool"]).annotate({ + "description": "The role of the author of this message." + }) + ), + "refusal": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The refusal message generated by the model." }), + Schema.Null + ]) + ) +}).annotate({ + "description": "A chat completion delta generated by streamed model responses.", + "identifier": "ChatCompletionStreamResponseDelta" }) -export type EvalStoredCompletionsSource = { - readonly "type": "stored_completions" - readonly "metadata"?: Metadata - readonly "model"?: string | null - readonly "created_after"?: number | null - readonly "created_before"?: number | null - readonly "limit"?: number | null +export type ContainerListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean } -export const EvalStoredCompletionsSource = Schema.Struct({ - "type": Schema.Literal("stored_completions").annotate({ - "description": "The type of source. Always `stored_completions`." +export const ContainerListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be 'list'." }), + "data": Schema.Array(ContainerResource).annotate({ "description": "A list of containers." }), + "first_id": Schema.String.annotate({ "description": "The ID of the first container in the list." }), + "last_id": Schema.String.annotate({ "description": "The ID of the last container in the list." }), + "has_more": Schema.Boolean.annotate({ "description": "Whether there are more containers available." }) +}).annotate({ "identifier": "ContainerListResource" }) +export type InlineSkillParam = { + readonly "type": "inline" + readonly "name": string + readonly "description": string + readonly "source": InlineSkillSourceParam +} +export const InlineSkillParam = Schema.Struct({ + "type": Schema.Literal("inline").annotate({ "description": "Defines an inline skill for this request." }), + "name": Schema.String.annotate({ "description": "The name of the skill." }), + "description": Schema.String.annotate({ "description": "The description of the skill." }), + "source": Schema.suspend((): Schema.Codec => InlineSkillSourceParam).annotate({ + "description": "Inline skill payload" + }) +}).annotate({ "identifier": "InlineSkillParam" }) +export type ContainerNetworkPolicyAllowlistParam = { + readonly "type": "allowlist" + readonly "allowed_domains": ReadonlyArray + readonly "domain_secrets"?: ReadonlyArray +} +export const ContainerNetworkPolicyAllowlistParam = Schema.Struct({ + "type": Schema.Literal("allowlist").annotate({ + "description": "Allow outbound network access only to specified domains. Always `allowlist`." }), - "metadata": Schema.optionalKey(Metadata), - "model": Schema.optionalKey( + "allowed_domains": Schema.Array(Schema.String).annotate({ + "description": "A list of allowed domains when type is `allowlist`." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "domain_secrets": Schema.optionalKey( + Schema.Array(ContainerNetworkPolicyDomainSecretParam).annotate({ + "description": "Optional domain-scoped secrets for allowlisted domains." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ) +}).annotate({ "identifier": "ContainerNetworkPolicyAllowlistParam" }) +export type ContainerFileListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean +} +export const ContainerFileListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be 'list'." }), + "data": Schema.Array(ContainerFileResource).annotate({ "description": "A list of container files." }), + "first_id": Schema.String.annotate({ "description": "The ID of the first file in the list." }), + "last_id": Schema.String.annotate({ "description": "The ID of the last file in the list." }), + "has_more": Schema.Boolean.annotate({ "description": "Whether there are more files available." }) +}).annotate({ "identifier": "ContainerFileListResource" }) +export type InputTextContent = { + readonly "type": "input_text" + readonly "text": string + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointConfig +} +export const InputTextContent = Schema.Struct({ + "type": Schema.Literal("input_text").annotate({ "description": "The type of the input item. Always `input_text`." }), + "text": Schema.String.annotate({ "description": "The text input to the model." }), + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpointConfig) +}).annotate({ "title": "Input text", "description": "A text input to the model.", "identifier": "InputTextContent" }) +export type Annotation = FileCitationBody | UrlCitationBody | ContainerFileCitationBody | FilePath +export const Annotation = Schema.Union([FileCitationBody, UrlCitationBody, ContainerFileCitationBody, FilePath], { + mode: "oneOf" +}).annotate({ "description": "An annotation that applies to a span of output text.", "identifier": "Annotation" }) +export type LogProb = { + readonly "token": string + readonly "logprob": number + readonly "bytes": ReadonlyArray + readonly "top_logprobs": ReadonlyArray +} +export const LogProb = Schema.Struct({ + "token": Schema.String, + "logprob": Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "top_logprobs": Schema.Array(TopLogProb) +}).annotate({ "title": "Log probability", "description": "The log probability of a token.", "identifier": "LogProb" }) +export type ReasoningItem = { + readonly "type": "reasoning" + readonly "id": string + readonly "encrypted_content"?: string | null + readonly "summary": ReadonlyArray + readonly "content"?: ReadonlyArray + readonly "status"?: "in_progress" | "completed" | "incomplete" +} +export const ReasoningItem = Schema.Struct({ + "type": Schema.Literal("reasoning").annotate({ "description": "The type of the object. Always `reasoning`.\n" }), + "id": Schema.String.annotate({ "description": "The unique identifier of the reasoning content.\n" }), + "encrypted_content": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ "description": "An optional model to filter by (e.g., 'gpt-4o')." }), + Schema.String.annotate({ + "description": + "The encrypted content of the reasoning item. This is populated by default\nfor reasoning items returned by `POST /v1/responses` and WebSocket\n`response.create` requests.\n" + }), Schema.Null ]) ), - "created_after": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "An optional Unix timestamp to filter items created after this time." }) - .check(Schema.isInt()), - Schema.Null - ]) + "summary": Schema.Array(SummaryTextContent).annotate({ "description": "Reasoning summary content.\n" }), + "content": Schema.optionalKey( + Schema.Array(ReasoningTextContent).annotate({ "description": "Reasoning text content.\n" }) ), - "created_before": Schema.optionalKey( + "status": Schema.optionalKey( + 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": "Reasoning", + "description": + "A description of the chain of thought used by a reasoning model while generating\na response. Be sure to include these items in your `input` to the Responses API\nfor subsequent turns of a conversation if you are manually\n[managing context](/docs/guides/conversation-state).\n", + "identifier": "ReasoningItem" +}) +export type InputImageContent = { + readonly "type": "input_image" + readonly "image_url"?: string | null + readonly "file_id"?: string | null + readonly "detail": ImageDetail + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointConfig +} +export const InputImageContent = Schema.Struct({ + "type": Schema.Literal("input_image").annotate({ + "description": "The type of the input item. Always `input_image`." + }), + "image_url": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ "description": "An optional Unix timestamp to filter items created before this time." }) - .check(Schema.isInt()), + Schema.String.annotate({ + "description": + "The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.", + "format": "uri" + }), Schema.Null ]) ), - "limit": Schema.optionalKey( + "file_id": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ "description": "An optional maximum number of items to return." }).check(Schema.isInt()), + Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), Schema.Null ]) - ) + ), + "detail": Schema.suspend((): Schema.Codec => ImageDetail).annotate({ + "description": + "The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`." + }), + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpointConfig) }).annotate({ - "title": "StoredCompletionsRunDataSource", - "description": "A StoredCompletionsRunDataSource configuration describing a set of filters\n" + "title": "Input image", + "description": "An image input to the model. Learn about [image inputs](/docs/guides/vision).", + "identifier": "InputImageContent" }) -export type ModifyMessageRequest = { readonly "metadata"?: Metadata } -export const ModifyMessageRequest = Schema.Struct({ "metadata": Schema.optionalKey(Metadata) }) -export type ModifyRunRequest = { readonly "metadata"?: Metadata } -export const ModifyRunRequest = Schema.Struct({ "metadata": Schema.optionalKey(Metadata) }) -export type ModifyThreadRequest = { - readonly "tool_resources"?: { - readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } - readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } - } | null - readonly "metadata"?: Metadata +export type ComputerScreenshotContent = { + readonly "type": "computer_screenshot" + readonly "image_url": string | null + readonly "file_id": string | null + readonly "detail": ImageDetail + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointConfig } -export const ModifyThreadRequest = Schema.Struct({ - "tool_resources": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "code_interpreter": Schema.optionalKey(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" - }).check(Schema.isMaxLength(20)) - ) - })), - "file_search": Schema.optionalKey(Schema.Struct({ - "vector_store_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.\n" - }).check(Schema.isMaxLength(1)) - ) - })) - }).annotate({ - "description": - "A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" - }), +export const ComputerScreenshotContent = Schema.Struct({ + "type": Schema.Literal("computer_screenshot").annotate({ + "description": + "Specifies the event type. For a computer screenshot, this property is always set to `computer_screenshot`." + }), + "image_url": Schema.Union([ + Schema.String.annotate({ "description": "The URL of the screenshot image.", "format": "uri" }), Schema.Null - ])), - "metadata": Schema.optionalKey(Metadata) + ]), + "file_id": Schema.Union([ + Schema.String.annotate({ "description": "The identifier of an uploaded file that contains the screenshot." }), + Schema.Null + ]), + "detail": Schema.suspend((): Schema.Codec => ImageDetail).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`." + }), + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpointConfig) +}).annotate({ + "title": "Computer screenshot", + "description": "A screenshot of a computer.", + "identifier": "ComputerScreenshotContent" }) -export type ThreadObject = { - readonly "id": string - readonly "object": "thread" - readonly "created_at": number - readonly "tool_resources": { - readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } - readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } - } | null - readonly "metadata": Metadata +export type InputFileContent = { + readonly "type": "input_file" + readonly "file_id"?: string | null + readonly "filename"?: string + readonly "file_data"?: string + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointConfig + readonly "file_url"?: string + readonly "detail"?: FileInputDetail } -export const ThreadObject = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), - "object": Schema.Literal("thread").annotate({ "description": "The object type, which is always `thread`." }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the thread was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "tool_resources": Schema.Union([ - Schema.Struct({ - "code_interpreter": Schema.optionalKey(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" - }).check(Schema.isMaxLength(20)) - ) - })), - "file_search": Schema.optionalKey(Schema.Struct({ - "vector_store_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.\n" - }).check(Schema.isMaxLength(1)) - ) - })) - }).annotate({ - "description": - "A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" - }), - Schema.Null - ]), - "metadata": Metadata -}).annotate({ - "title": "Thread", - "description": "Represents a thread that contains [messages](/docs/api-reference/messages)." -}) -export type UpdateVectorStoreRequest = { - readonly "name"?: string | null - readonly "expires_after"?: { readonly "anchor": "last_active_at"; readonly "days": number } - readonly "metadata"?: Metadata -} -export const UpdateVectorStoreRequest = Schema.Struct({ - "name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The name of the vector store." }) - ), - "expires_after": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "anchor": Schema.Literal("last_active_at").annotate({ - "description": - "Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`." - }), - "days": Schema.Number.annotate({ - "description": "The number of days after the anchor time that the vector store will expire." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(365)) - }).annotate({ - "title": "Vector store expiration policy", - "description": "The expiration policy for a vector store." - }) - ])), - "metadata": Schema.optionalKey(Metadata) -}) -export type ListModelsResponse = { readonly "object": "list"; readonly "data": ReadonlyArray } -export const ListModelsResponse = Schema.Struct({ "object": Schema.Literal("list"), "data": Schema.Array(Model) }) -export type ModelIdsResponses = - | 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" -export const ModelIdsResponses = 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" }) -]) -export type RealtimeTranscriptionSessionCreateRequest = { - readonly "turn_detection"?: { - readonly "type"?: "server_vad" - readonly "threshold"?: number - readonly "prefix_padding_ms"?: number - readonly "silence_duration_ms"?: number - } - readonly "input_audio_noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "input_audio_format"?: "pcm16" | "g711_ulaw" | "g711_alaw" - readonly "input_audio_transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - readonly "delay"?: "minimal" | "low" | "medium" | "high" | "xhigh" - } - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> -} -export const RealtimeTranscriptionSessionCreateRequest = Schema.Struct({ - "turn_detection": Schema.optionalKey( - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("server_vad").annotate({ - "description": - "Type of turn detection. Only `server_vad` is currently supported for transcription sessions.\n" - }) - ), - "threshold": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" - }).check(Schema.isFinite()) - ), - "prefix_padding_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" - }).check(Schema.isInt()) - ), - "silence_duration_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" - }).check(Schema.isInt()) - ) - }).annotate({ - "description": - "Configuration for turn detection. Can be set to `null` to turn off. Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.\n" - }) +export const InputFileContent = Schema.Struct({ + "type": Schema.Literal("input_file").annotate({ "description": "The type of the input item. Always `input_file`." }), + "file_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), + Schema.Null + ]) ), - "input_audio_noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": - "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" - }) + "filename": Schema.optionalKey( + Schema.String.annotate({ "description": "The name of the file to be sent to the model." }) ), - "input_audio_format": Schema.optionalKey( - Schema.Literals(["pcm16", "g711_ulaw", "g711_alaw"]).annotate({ - "description": - "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\nFor `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate,\nsingle channel (mono), and little-endian byte order.\n" - }) + "file_data": Schema.optionalKey( + Schema.String.annotate({ "description": "The content of the file to be sent to the model.\n" }) ), - "input_audio_transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.\n" - }) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The language of the input audio. Supplying the input language in\n[ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format\nwill improve accuracy and latency.\n" - }) - ), - "prompt": Schema.optionalKey(Schema.String.annotate({ - "description": - "An optional text to guide the model's style or continue a previous audio\nsegment.\nFor `whisper-1`, the [prompt is a list of keywords](/docs/guides/speech-to-text#prompting).\nFor `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example \"expect words related to technology\".\nPrompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - })), - "delay": Schema.optionalKey( - Schema.Literals(["minimal", "low", "medium", "high", "xhigh"]).annotate({ - "description": - "Controls how long the model waits before emitting transcription text.\nHigher values can improve transcription accuracy at the cost of latency.\nOnly supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - }) - ) - }).annotate({ - "description": - "Configuration for input audio transcription. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" - }) + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpointConfig), + "file_url": Schema.optionalKey( + Schema.String.annotate({ "description": "The URL of the file to be sent to the model.", "format": "uri" }) ), - "include": Schema.optionalKey( - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ + "detail": Schema.optionalKey( + Schema.suspend((): Schema.Codec => FileInputDetail).annotate({ "description": - "The set of items to include in the transcription. Current available items are:\n`item.input_audio_transcription.logprobs`\n" + "The detail level of the file to be sent to the model. Use `auto` to let the system select the detail level; for GPT-5.6 and later models, `auto` uses high-quality rendering, which may increase input token usage. Use `low` for lower-cost rendering, or `high` to render the file at higher quality. Defaults to `auto`." }) ) +}).annotate({ "title": "Input file", "description": "A file input to the model.", "identifier": "InputFileContent" }) +export type ToolCallCaller = DirectToolCallCaller | ProgramToolCallCaller +export const ToolCallCaller = Schema.Union([DirectToolCallCaller, ProgramToolCallCaller], { mode: "oneOf" }).annotate({ + "description": "The execution context that produced this tool call.", + "identifier": "ToolCallCaller" +}) +export type ToolCallCallerParam = DirectToolCallCallerParam | ProgramToolCallCallerParam +export const ToolCallCallerParam = Schema.Union([DirectToolCallCallerParam, ProgramToolCallCallerParam], { + mode: "oneOf" }).annotate({ - "title": "Realtime transcription session configuration", - "description": "Realtime transcription session object configuration." -}) -export type RealtimeTranslationClientEventSessionUpdate = { - readonly "event_id"?: string - readonly "type": "session.update" - readonly "session": { - readonly "audio"?: { - readonly "input"?: { - readonly "transcription"?: { readonly "model": string } | null - readonly "noise_reduction"?: { readonly "type": NoiseReductionType } | null + "description": "The execution context that produced this tool call.", + "identifier": "ToolCallCallerParam" +}) +export type FileSearchToolCall = { + readonly "id": string + readonly "type": "file_search_call" + readonly "status": "in_progress" | "searching" | "completed" | "incomplete" | "failed" + readonly "queries": ReadonlyArray + readonly "results"?: + | ReadonlyArray< + { + readonly "file_id"?: string + readonly "text"?: string + readonly "filename"?: string + readonly "attributes"?: VectorStoreFileAttributes + readonly "score"?: number } - readonly "output"?: { readonly "language"?: string } - } - } + > + | null } -export const RealtimeTranslationClientEventSessionUpdate = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) - ), - "type": Schema.Literal("session.update").annotate({ "description": "The event type, must be `session.update`." }), - "session": Schema.Struct({ - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "transcription": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "model": Schema.String.annotate({ - "description": "The transcription model to use for source transcript deltas." - }) - }).annotate({ - "description": - "Optional source-language transcription. When configured, the server emits\n`session.input_transcript.delta` events. Translation itself still runs from\nthe input audio stream.\n" - }), - Schema.Null - ]) - ), - "noise_reduction": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": NoiseReductionType }).annotate({ - "description": "Optional input noise reduction. Set to `null` to disable it.\n" - }), - Schema.Null - ]) - ) - })), - "output": Schema.optionalKey( - Schema.Struct({ - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": "Target language for translated output audio and transcript deltas.\n" - }) - ) - }) - ) - }).annotate({ "description": "Configuration for translation input and output audio.\n" }) - ) - }).annotate({ - "title": "Realtime translation session update", +export const FileSearchToolCall = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the file search tool call.\n" }), + "type": Schema.Literal("file_search_call").annotate({ + "description": "The type of the file search tool call. Always `file_search_call`.\n" + }), + "status": Schema.Literals(["in_progress", "searching", "completed", "incomplete", "failed"]).annotate({ "description": - "Translation session fields to update. The session `type` and `model` are set\nat creation and cannot be changed with `session.update`.\n" - }) + "The status of the file search tool call. One of `in_progress`,\n`searching`, `incomplete` or `failed`,\n" + }), + "queries": Schema.Array(Schema.String).annotate({ "description": "The queries used to search for files.\n" }), + "results": Schema.optionalKey(Schema.Union([ + Schema.Array(Schema.Struct({ + "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the file.\n" })), + "text": Schema.optionalKey( + Schema.String.annotate({ "description": "The text that was retrieved from the file.\n" }) + ), + "filename": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the file.\n" })), + "attributes": Schema.optionalKey(VectorStoreFileAttributes), + "score": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The relevance score of the file - a value between 0 and 1.\n", + "format": "float" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) + })).annotate({ "description": "The results of the file search tool call.\n" }), + Schema.Null + ])) }).annotate({ + "title": "File search tool call", "description": - "Send this event to update the translation session configuration. Translation\nsessions support updates to `audio.output.language`, `audio.input.transcription`,\nand `audio.input.noise_reduction`.\n" + "The results of a file search tool call. See the\n[file search guide](/docs/guides/tools-file-search) for more information.\n", + "identifier": "FileSearchToolCall" }) -export type RealtimeTranslationServerEventSessionCreated = { - readonly "event_id": string - readonly "type": "session.created" - readonly "session": { - readonly "id": string - readonly "type": "translation" - readonly "expires_at": number - readonly "model": string - readonly "audio": { - readonly "input"?: { - readonly "transcription"?: { readonly "model": string } | null - readonly "noise_reduction"?: { readonly "type": NoiseReductionType } | null - } - readonly "output"?: { readonly "language"?: string } - } - } +export type UpdateVectorStoreFileAttributesRequest = { readonly "attributes": VectorStoreFileAttributes } +export const UpdateVectorStoreFileAttributesRequest = Schema.Struct({ "attributes": VectorStoreFileAttributes }) + .annotate({ "identifier": "UpdateVectorStoreFileAttributesRequest" }) +export type ClickParam = { + readonly "type": "click" + readonly "button": ClickButtonType + readonly "x": number + readonly "y": number + readonly "keys"?: ReadonlyArray | null } -export const RealtimeTranslationServerEventSessionCreated = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("session.created").annotate({ "description": "The event type, must be `session.created`." }), - "session": Schema.Struct({ - "id": Schema.String.annotate({ - "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" - }), - "type": Schema.Literal("translation").annotate({ - "description": "The session type. Always `translation` for Realtime translation sessions.\n" - }), - "expires_at": Schema.Number.annotate({ - "description": "Expiration timestamp for the session, in seconds since epoch.", - "format": "unixtime" - }).check(Schema.isInt()), - "model": Schema.String.annotate({ - "description": - "The Realtime translation model used for this session. This field is set at\nsession creation and cannot be changed with `session.update`.\n" - }), - "audio": Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "transcription": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "model": Schema.String.annotate({ - "description": "The transcription model used for source transcript deltas." - }) - }).annotate({ - "description": - "Optional source-language transcription. When configured, the server emits\n`session.input_transcript.delta` events. Translation itself still runs from\nthe input audio stream.\n" - }), - Schema.Null - ]) - ), - "noise_reduction": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": NoiseReductionType }).annotate({ - "description": "Optional input noise reduction.\n" - }), - Schema.Null - ]) - ) - })), - "output": Schema.optionalKey( - Schema.Struct({ - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": "Target language for translated output audio and transcript deltas.\n" - }) - ) - }) - ) - }).annotate({ "description": "Configuration for translation input and output audio.\n" }) - }).annotate({ "title": "Realtime translation session", "description": "The translation session configuration." }) -}).annotate({ - "description": - "Returned when a translation session is created. Emitted automatically when a\nnew connection is established as the first server event. This event contains\nthe default translation session configuration.\n" -}) -export type RealtimeTranslationServerEventSessionUpdated = { - readonly "event_id": string - readonly "type": "session.updated" - readonly "session": { - readonly "id": string - readonly "type": "translation" - readonly "expires_at": number - readonly "model": string - readonly "audio": { - readonly "input"?: { - readonly "transcription"?: { readonly "model": string } | null - readonly "noise_reduction"?: { readonly "type": NoiseReductionType } | null - } - readonly "output"?: { readonly "language"?: string } - } - } +export const ClickParam = Schema.Struct({ + "type": Schema.Literal("click").annotate({ + "description": "Specifies the event type. For a click action, this property is always `click`." + }), + "button": Schema.suspend((): Schema.Codec => ClickButtonType).annotate({ + "description": + "Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`." + }), + "x": Schema.Number.annotate({ "description": "The x-coordinate where the click occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "y": Schema.Number.annotate({ "description": "The y-coordinate where the click occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "keys": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).annotate({ "description": "The keys being held while clicking." }), + Schema.Null + ]) + ) +}).annotate({ "title": "Click", "description": "A click action.", "identifier": "ClickParam" }) +export type DragParam = { + readonly "type": "drag" + readonly "path": ReadonlyArray + readonly "keys"?: ReadonlyArray | null } -export const RealtimeTranslationServerEventSessionUpdated = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("session.updated").annotate({ "description": "The event type, must be `session.updated`." }), - "session": Schema.Struct({ - "id": Schema.String.annotate({ - "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" - }), - "type": Schema.Literal("translation").annotate({ - "description": "The session type. Always `translation` for Realtime translation sessions.\n" - }), - "expires_at": Schema.Number.annotate({ - "description": "Expiration timestamp for the session, in seconds since epoch.", - "format": "unixtime" - }).check(Schema.isInt()), - "model": Schema.String.annotate({ - "description": - "The Realtime translation model used for this session. This field is set at\nsession creation and cannot be changed with `session.update`.\n" - }), - "audio": Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "transcription": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "model": Schema.String.annotate({ - "description": "The transcription model used for source transcript deltas." - }) - }).annotate({ - "description": - "Optional source-language transcription. When configured, the server emits\n`session.input_transcript.delta` events. Translation itself still runs from\nthe input audio stream.\n" - }), - Schema.Null - ]) - ), - "noise_reduction": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": NoiseReductionType }).annotate({ - "description": "Optional input noise reduction.\n" - }), - Schema.Null - ]) - ) - })), - "output": Schema.optionalKey( - Schema.Struct({ - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": "Target language for translated output audio and transcript deltas.\n" - }) - ) - }) - ) - }).annotate({ "description": "Configuration for translation input and output audio.\n" }) - }).annotate({ "title": "Realtime translation session", "description": "The translation session configuration." }) -}).annotate({ - "description": - "Returned when a translation session is updated with a `session.update` event,\nunless there is an error.\n" -}) -export type RealtimeTranslationSession = { +export const DragParam = Schema.Struct({ + "type": Schema.Literal("drag").annotate({ + "description": "Specifies the event type. For a drag action, this property is always set to `drag`." + }), + "path": Schema.Array(CoordParam).annotate({ + "description": + "An array of coordinates representing the path of the drag action. Coordinates will appear as an array of objects, eg\n```\n[\n { x: 100, y: 200 },\n { x: 200, y: 300 }\n]\n```" + }), + "keys": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).annotate({ "description": "The keys being held while dragging the mouse." }), + Schema.Null + ]) + ) +}).annotate({ "title": "Drag", "description": "A drag action.", "identifier": "DragParam" }) +export type ComputerToolCallOutputResource = { + readonly "type": "computer_call_output" readonly "id": string - readonly "type": "translation" - readonly "expires_at": number - readonly "model": string - readonly "audio": { - readonly "input"?: { - readonly "transcription"?: { readonly "model": string } | null - readonly "noise_reduction"?: { readonly "type": NoiseReductionType } | null - } - readonly "output"?: { readonly "language"?: string } - } + readonly "call_id": string + readonly "acknowledged_safety_checks"?: ReadonlyArray + readonly "output": ComputerScreenshotImage + readonly "status": "completed" | "incomplete" + readonly "created_by"?: string } -export const RealtimeTranslationSession = Schema.Struct({ - "id": Schema.String.annotate({ - "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" - }), - "type": Schema.Literal("translation").annotate({ - "description": "The session type. Always `translation` for Realtime translation sessions.\n" +export const ComputerToolCallOutputResource = Schema.Struct({ + "type": Schema.Literal("computer_call_output").annotate({ + "description": "The type of the computer tool call output. Always `computer_call_output`.\n" }), - "expires_at": Schema.Number.annotate({ - "description": "Expiration timestamp for the session, in seconds since epoch.", - "format": "unixtime" - }).check(Schema.isInt()), - "model": Schema.String.annotate({ + "id": Schema.String.annotate({ "description": "The unique ID of the computer call tool output.\n" }), + "call_id": Schema.String.annotate({ "description": "The ID of the computer tool call that produced the output.\n" }), + "acknowledged_safety_checks": Schema.optionalKey( + Schema.Array(ComputerCallSafetyCheckParam).annotate({ + "description": "The safety checks reported by the API that have been acknowledged by the\ndeveloper.\n" + }) + ), + "output": ComputerScreenshotImage, + "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("incomplete")]).annotate({ "description": - "The Realtime translation model used for this session. This field is set at\nsession creation and cannot be changed with `session.update`.\n" + "The status of the message input. One of `in_progress`, `completed`, or\n`incomplete`. Populated when input items are returned via API.\n" }), - "audio": Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "transcription": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "model": Schema.String.annotate({ - "description": "The transcription model used for source transcript deltas." - }) - }).annotate({ - "description": - "Optional source-language transcription. When configured, the server emits\n`session.input_transcript.delta` events. Translation itself still runs from\nthe input audio stream.\n" - }), - Schema.Null - ]) - ), - "noise_reduction": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": NoiseReductionType }).annotate({ - "description": "Optional input noise reduction.\n" - }), - Schema.Null - ]) - ) - })), - "output": Schema.optionalKey( - Schema.Struct({ - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": "Target language for translated output audio and transcript deltas.\n" - }) - ) - }) - ) - }).annotate({ "description": "Configuration for translation input and output audio.\n" }) + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ) }).annotate({ - "title": "Realtime translation session", - "description": - "A Realtime translation session. Translation sessions continuously translate input\naudio into the configured output language.\n" + "title": "Computer tool call output", + "description": "The output of a computer tool call.\n", + "identifier": "ComputerToolCallOutputResource" }) -export type RealtimeTranslationSessionCreateRequest = { - readonly "model": string - readonly "audio"?: { - readonly "input"?: { - readonly "transcription"?: { readonly "model": string } | null - readonly "noise_reduction"?: { readonly "type": NoiseReductionType } | null - } - readonly "output"?: { readonly "language"?: string } - } +export type ToolSearchCall = { + readonly "type": "tool_search_call" + readonly "id": string + readonly "call_id": string | null + readonly "execution": ToolSearchExecutionType + readonly "arguments": Schema.Json + readonly "status": FunctionCallStatus + readonly "created_by"?: string } -export const RealtimeTranslationSessionCreateRequest = Schema.Struct({ - "model": Schema.String.annotate({ "description": "The Realtime translation model used for this session.\n" }), - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "transcription": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "model": Schema.String.annotate({ - "description": "The transcription model to use for source transcript deltas." - }) - }).annotate({ - "description": - "Optional source-language transcription. When configured, the server emits\n`session.input_transcript.delta` events. Translation itself still runs from\nthe input audio stream.\n" - }), - Schema.Null - ]) - ), - "noise_reduction": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": NoiseReductionType }).annotate({ - "description": "Optional input noise reduction. Set to `null` to disable it.\n" - }), - Schema.Null - ]) - ) - })), - "output": Schema.optionalKey( - Schema.Struct({ - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": "Target language for translated output audio and transcript deltas.\n" - }) - ) - }) - ) - }).annotate({ "description": "Configuration for translation input and output audio.\n" }) - ) -}).annotate({ - "title": "Realtime translation session configuration", - "description": - "Realtime translation session configuration. Translation sessions stream source\naudio in and translated audio plus transcript deltas out continuously.\n" -}) -export type ListFilesResponse = { - readonly "object": string - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean -} -export const ListFilesResponse = Schema.Struct({ - "object": Schema.String, - "data": Schema.Array(OpenAIFile), - "first_id": Schema.String, - "last_id": Schema.String, - "has_more": Schema.Boolean -}) -export type ListCertificatesResponse = { - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "last_id": string | null - readonly "has_more": boolean - readonly "object": "list" -} -export const ListCertificatesResponse = Schema.Struct({ - "data": Schema.Array(OrganizationCertificate), - "first_id": Schema.Union([Schema.String, Schema.Null]), - "last_id": Schema.Union([Schema.String, Schema.Null]), - "has_more": Schema.Boolean, - "object": Schema.Literal("list") -}) -export type OrganizationCertificateActivationResponse = { - readonly "object": "organization.certificate.activation" - readonly "data": ReadonlyArray -} -export const OrganizationCertificateActivationResponse = Schema.Struct({ - "object": Schema.Literal("organization.certificate.activation").annotate({ - "description": "The organization certificate activation result type." +export const ToolSearchCall = Schema.Struct({ + "type": Schema.Literal("tool_search_call").annotate({ + "description": "The type of the item. Always `tool_search_call`." }), - "data": Schema.Array(OrganizationCertificate) -}) -export type OrganizationCertificateDeactivationResponse = { - readonly "object": "organization.certificate.deactivation" - readonly "data": ReadonlyArray -} -export const OrganizationCertificateDeactivationResponse = Schema.Struct({ - "object": Schema.Literal("organization.certificate.deactivation").annotate({ - "description": "The organization certificate deactivation result type." + "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.suspend((): Schema.Codec => ToolSearchExecutionType).annotate({ + "description": "Whether tool search was executed by the server or by the client." }), - "data": Schema.Array(OrganizationCertificate) -}) -export type ListProjectCertificatesResponse = { - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "last_id": string | null - readonly "has_more": boolean - readonly "object": "list" -} -export const ListProjectCertificatesResponse = Schema.Struct({ - "data": Schema.Array(OrganizationProjectCertificate), - "first_id": Schema.Union([Schema.String, Schema.Null]), - "last_id": Schema.Union([Schema.String, Schema.Null]), - "has_more": Schema.Boolean, - "object": Schema.Literal("list") -}) -export type OrganizationProjectCertificateActivationResponse = { - readonly "object": "organization.project.certificate.activation" - readonly "data": ReadonlyArray -} -export const OrganizationProjectCertificateActivationResponse = Schema.Struct({ - "object": Schema.Literal("organization.project.certificate.activation").annotate({ - "description": "The project certificate activation result type." + "arguments": Schema.Json.annotate({ + "expected": "JSON value", + "description": "Arguments used for the tool search call." }), - "data": Schema.Array(OrganizationProjectCertificate) -}) -export type OrganizationProjectCertificateDeactivationResponse = { - readonly "object": "organization.project.certificate.deactivation" - readonly "data": ReadonlyArray -} -export const OrganizationProjectCertificateDeactivationResponse = Schema.Struct({ - "object": Schema.Literal("organization.project.certificate.deactivation").annotate({ - "description": "The project certificate deactivation result type." + "status": Schema.suspend((): Schema.Codec => FunctionCallStatus).annotate({ + "description": "The status of the tool search call item that was recorded." }), - "data": Schema.Array(OrganizationProjectCertificate) -}) -export type CreateImageRequest = { - readonly "prompt": string - readonly "model"?: string | "gpt-image-1.5" | "dall-e-2" | "dall-e-3" | "gpt-image-1" | "gpt-image-1-mini" | null - readonly "n"?: number - readonly "quality"?: "standard" | "hd" | "low" | "medium" | "high" | "auto" | null - readonly "response_format"?: "url" | "b64_json" | null - readonly "output_format"?: "png" | "jpeg" | "webp" | null - readonly "output_compression"?: number | null - readonly "stream"?: boolean | null - readonly "partial_images"?: PartialImages - readonly "size"?: - | string - | "auto" - | "1024x1024" - | "1536x1024" - | "1024x1536" - | "256x256" - | "512x512" - | "1792x1024" - | "1024x1792" - | null - readonly "moderation"?: "low" | "auto" | null - readonly "background"?: "transparent" | "opaque" | "auto" | null - readonly "style"?: "vivid" | "natural" | null - readonly "user"?: string + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) + ) +}).annotate({ "identifier": "ToolSearchCall" }) +export type FunctionTool = { + readonly "type": "function" + readonly "name": string + readonly "description"?: string | null + readonly "parameters": {} | null + readonly "output_schema"?: {} | null + readonly "strict": boolean | null + readonly "defer_loading"?: boolean + readonly "allowed_callers"?: ReadonlyArray | null } -export const CreateImageRequest = Schema.Struct({ - "prompt": Schema.String.annotate({ - "description": - "A text description of the desired image(s). The maximum length is 32000 characters for the GPT image models, 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`." - }), - "model": Schema.optionalKey( +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.Union([ - Schema.String, - Schema.Literals(["gpt-image-1.5", "dall-e-2", "dall-e-3", "gpt-image-1", "gpt-image-1-mini"]) - ]).annotate({ + Schema.String.annotate({ "description": - "The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to `dall-e-2` unless a parameter specific to the GPT image models is used." + "A description of the function. Used by the model to determine whether or not to call the function." }), Schema.Null ]) ), - "n": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(10)], { - "description": - "The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported." - }) - ) - ]) - ), - "quality": Schema.optionalKey( + "parameters": Schema.Union([ + Schema.Struct({}).annotate({ "description": "A JSON schema object describing the parameters of the function." }), + Schema.Null + ]), + "output_schema": Schema.optionalKey( Schema.Union([ - Schema.Literals(["standard", "hd", "low", "medium", "high", "auto"]).annotate({ - "description": - "The quality of the image that will be generated.\n\n- `auto` (default value) will automatically select the best quality for the given model.\n- `high`, `medium` and `low` are supported for the GPT image models.\n- `hd` and `standard` are supported for `dall-e-3`.\n- `standard` is the only option for `dall-e-2`.\n" + Schema.Struct({}).annotate({ + "description": "A JSON schema object describing the JSON value encoded in string outputs for this function." }), - Schema.Union([Schema.Null]).annotate({ - "description": - "The quality of the image that will be generated.\n\n- `auto` (default value) will automatically select the best quality for the given model.\n- `high`, `medium` and `low` are supported for the GPT image models.\n- `hd` and `standard` are supported for `dall-e-3`.\n- `standard` is the only option for `dall-e-2`.\n" - }) + Schema.Null ]) ), - "response_format": Schema.optionalKey(Schema.Union([ - Schema.Literals(["url", "b64_json"]).annotate({ - "description": - "The format in which generated images with `dall-e-2` and `dall-e-3` 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 isn't supported for the GPT image models, which always return base64-encoded images." + "strict": Schema.Union([ + Schema.Boolean.annotate({ + "description": "Whether strict parameter validation is enforced for this function tool." }), - Schema.Union([Schema.Null]).annotate({ - "description": - "The format in which generated images with `dall-e-2` and `dall-e-3` 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 isn't supported for the GPT image models, which always return base64-encoded images." - }) - ])), - "output_format": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["png", "jpeg", "webp"]).annotate({ - "description": - "The format in which the generated images are returned. This parameter is only supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`." - }), - Schema.Union([Schema.Null]).annotate({ - "description": - "The format in which the generated images are returned. This parameter is only supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`." - }) - ]) - ), - "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 is only supported for the GPT image models with the `webp` or `jpeg` output formats, and defaults to 100." - }) - ), - "stream": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Generate the image in streaming mode. Defaults to `false`. See the\n[Image generation guide](/docs/guides/image-generation) for more information.\nThis parameter is only supported for the GPT image models.\n" - }) + Schema.Null + ]), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this function is deferred and loaded via tool search." }) ), - "partial_images": Schema.optionalKey(PartialImages), - "size": Schema.optionalKey( + "allowed_callers": Schema.optionalKey( Schema.Union([ - Schema.Union([ - Schema.String, - Schema.Literals(["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"]) - ]).annotate({ - "description": - "The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`." - }), + Schema.Array(CallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }), Schema.Null ]) - ), - "moderation": Schema.optionalKey( + ) +}).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).", + "identifier": "FunctionTool" +}) +export type ApplyPatchToolParam = { + readonly "type": "apply_patch" + readonly "allowed_callers"?: ReadonlyArray | null +} +export const ApplyPatchToolParam = Schema.Struct({ + "type": Schema.Literal("apply_patch").annotate({ "description": "The type of the tool. Always `apply_patch`." }), + "allowed_callers": Schema.optionalKey( Schema.Union([ - Schema.Literals(["low", "auto"]).annotate({ - "description": - "Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default value)." - }), - Schema.Union([Schema.Null]).annotate({ - "description": - "Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default value)." - }) + Schema.Array(CallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null ]) - ), - "background": Schema.optionalKey(Schema.Union([ - Schema.Literals(["transparent", "opaque", "auto"]).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" - }), - Schema.Union([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" + ) +}).annotate({ + "title": "Apply patch tool", + "description": "Allows the assistant to create, delete, or update files using unified diffs.", + "identifier": "ApplyPatchToolParam" +}) +export type RankingOptions = { + readonly "ranker"?: RankerVersionType + readonly "score_threshold"?: number + readonly "hybrid_search"?: HybridSearchOptions +} +export const RankingOptions = Schema.Struct({ + "ranker": Schema.optionalKey( + Schema.suspend((): Schema.Codec => RankerVersionType).annotate({ + "description": "The ranker to use for the file search." }) - ])), - "style": Schema.optionalKey(Schema.Union([ - Schema.Literals(["vivid", "natural"]).annotate({ - "description": - "The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images." - }), - Schema.Union([Schema.Null]).annotate({ + ), + "score_threshold": Schema.optionalKey( + Schema.Number.annotate({ "description": - "The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images." - }) - ])), - "user": Schema.optionalKey( - Schema.String.annotate({ + "The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "hybrid_search": Schema.optionalKey( + Schema.suspend((): Schema.Codec => HybridSearchOptions).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" + "Weights that control how reciprocal rank fusion balances semantic embedding matches versus sparse keyword matches when hybrid search is enabled." }) ) +}).annotate({ "identifier": "RankingOptions" }) +export type CompoundFilter = { + readonly "type": "and" | "or" + readonly "filters": ReadonlyArray +} +export const CompoundFilter = Schema.Struct({ + "type": Schema.Literals(["and", "or"]).annotate({ "description": "Type of operation: `and` or `or`." }), + "filters": Schema.Array( + Schema.Union([ComparisonFilter, Schema.Json.annotate({ "expected": "JSON value" })], { mode: "oneOf" }) + ).annotate({ "description": "Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`." }) +}).annotate({ + "title": "Compound Filter", + "description": "Combine multiple filters using `and` or `or`.", + "identifier": "CompoundFilter" }) -export type EditImageBodyJsonParam = { - readonly "model"?: string | "gpt-image-1.5" | "gpt-image-1" | "gpt-image-1-mini" | "chatgpt-image-latest" | null - readonly "images": ReadonlyArray - readonly "mask"?: ImageRefParam - readonly "prompt": string - readonly "n"?: number | null - readonly "quality"?: "low" | "medium" | "high" | "auto" | null - readonly "input_fidelity"?: "high" | "low" | null - readonly "size"?: "auto" | "1024x1024" | "1536x1024" | "1024x1536" | null - readonly "user"?: string - readonly "output_format"?: "png" | "jpeg" | "webp" | null - readonly "output_compression"?: number | null - readonly "moderation"?: "low" | "auto" | null - readonly "background"?: "transparent" | "opaque" | "auto" | null - readonly "stream"?: boolean | null - readonly "partial_images"?: PartialImages +export type ComputerUsePreviewTool = { + readonly "type": "computer_use_preview" + readonly "environment": ComputerEnvironment + readonly "display_width": number + readonly "display_height": number } -export const EditImageBodyJsonParam = Schema.Struct({ - "model": Schema.optionalKey( +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.suspend((): Schema.Codec => ComputerEnvironment).annotate({ + "description": "The type of computer environment to control." + }), + "display_width": Schema.Number.annotate({ "description": "The width of the computer display." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "display_height": Schema.Number.annotate({ "description": "The height of the computer display." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).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).", + "identifier": "ComputerUsePreviewTool" +}) +export type WebSearchTool = { + readonly "type": "web_search" | "web_search_2025_08_26" + readonly "filters"?: { readonly "allowed_domains"?: ReadonlyArray | null } | null + readonly "user_location"?: WebSearchApproximateLocation + readonly "search_context_size"?: "low" | "medium" | "high" +} +export const WebSearchTool = Schema.Struct({ + "type": Schema.Literals(["web_search", "web_search_2025_08_26"]).annotate({ + "description": "The type of the web search tool. One of `web_search` or `web_search_2025_08_26`." + }), + "filters": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "allowed_domains": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String.annotate({ "description": "Allowed domain for the search." })).annotate({ + "title": "Allowed domains for the search.", + "description": + "Allowed domains for the search. If not provided, all domains are allowed.\nSubdomains of the provided domains are allowed as well.\n\nExample: `[\"pubmed.ncbi.nlm.nih.gov\"]`\n" + }), + Schema.Null + ]) + ) + }).annotate({ "description": "Filters for the search.\n" }), + Schema.Null + ])), + "user_location": Schema.optionalKey(WebSearchApproximateLocation), + "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", + "description": + "Search the Internet for sources related to the prompt. Learn more about the\n[web search tool](/docs/guides/tools-web-search).\n", + "identifier": "WebSearchTool" +}) +export type MCPTool = { + readonly "type": "mcp" + readonly "server_label": string + readonly "server_url"?: string + readonly "connector_id"?: + | "connector_dropbox" + | "connector_gmail" + | "connector_googlecalendar" + | "connector_googledrive" + | "connector_microsoftteams" + | "connector_outlookcalendar" + | "connector_outlookemail" + | "connector_sharepoint" + readonly "tunnel_id"?: string + readonly "authorization"?: string + readonly "server_description"?: string + readonly "headers"?: {} | null + readonly "allowed_tools"?: ReadonlyArray | MCPToolFilter | null + readonly "allowed_callers"?: ReadonlyArray | null + readonly "require_approval"?: + | { readonly "always"?: MCPToolFilter; readonly "never"?: MCPToolFilter } + | "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`." }), + "server_label": Schema.String.annotate({ + "description": "A label for this MCP server, used to identify it in tool calls.\n" + }), + "server_url": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The URL for the MCP server. One of `server_url`, `connector_id`, or\n`tunnel_id` must be provided.\n", + "format": "uri" + }) + ), + "connector_id": Schema.optionalKey( + Schema.Literals([ + "connector_dropbox", + "connector_gmail", + "connector_googlecalendar", + "connector_googledrive", + "connector_microsoftteams", + "connector_outlookcalendar", + "connector_outlookemail", + "connector_sharepoint" + ]).annotate({ + "description": + "Identifier for service connectors, like those available in ChatGPT. One of\n`server_url`, `connector_id`, or `tunnel_id` must be provided. Learn more\nabout service connectors [here](/docs/guides/tools-remote-mcp#connectors).\n\nCurrently supported `connector_id` values are:\n\n- Dropbox: `connector_dropbox`\n- Gmail: `connector_gmail`\n- Google Calendar: `connector_googlecalendar`\n- Google Drive: `connector_googledrive`\n- Microsoft Teams: `connector_microsoftteams`\n- Outlook Calendar: `connector_outlookcalendar`\n- Outlook Email: `connector_outlookemail`\n- SharePoint: `connector_sharepoint`\n" + }) + ), + "tunnel_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The Secure MCP Tunnel ID to use instead of a direct server URL. One of\n`server_url`, `connector_id`, or `tunnel_id` must be provided.\n" + }).check( + Schema.isPattern(new RegExp("^tunnel_[a-z0-9]{32}$")).annotate({ + "expected": "a string matching the RegExp ^tunnel_[a-z0-9]{32}$" + }) + ) + ), + "authorization": Schema.optionalKey( + Schema.String.annotate({ + "description": + "An OAuth access token that can be used with a remote MCP server, either\nwith a custom MCP server URL or a service connector. Your application\nmust handle the OAuth authorization flow and provide the token here.\n" + }) + ), + "server_description": Schema.optionalKey( + Schema.String.annotate({ "description": "Optional description of the MCP server, used to provide more context.\n" }) + ), + "headers": Schema.optionalKey( Schema.Union([ - Schema.String, - Schema.Literals(["gpt-image-1.5", "gpt-image-1", "gpt-image-1-mini", "chatgpt-image-latest"]), + Schema.Struct({}).annotate({ + "description": "Optional HTTP headers to send to the MCP server. Use for authentication\nor other purposes.\n" + }), Schema.Null - ]).annotate({ "description": "The model to use for image editing." }) + ]) ), - "images": Schema.Array(ImageRefParam).annotate({ - "description": "Input image references to edit.\nFor GPT image models, you can provide up to 16 images.\n" - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(16)), - "mask": Schema.optionalKey(ImageRefParam), - "prompt": Schema.String.annotate({ "description": "A text description of the desired image edit." }).check( - Schema.isMinLength(1) - ).check(Schema.isMaxLength(32000)), - "n": Schema.optionalKey( + "allowed_tools": Schema.optionalKey( Schema.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(10)), + Schema.Union([ + Schema.Array(Schema.String).annotate({ + "title": "MCP allowed tools", + "description": "A string array of allowed tool names" + }), + MCPToolFilter + ], { mode: "oneOf" }).annotate({ "description": "List of allowed tool names or a filter object.\n" }), Schema.Null - ]).annotate({ "description": "The number of edited images to generate." }) + ]) ), - "quality": Schema.optionalKey( - Schema.Union([Schema.Literals(["low", "medium", "high", "auto"]), Schema.Null]).annotate({ - "description": "Output quality for GPT image models.\n" - }) + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(CallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]) ), - "input_fidelity": Schema.optionalKey( - Schema.Union([Schema.Literals(["high", "low"]), Schema.Null]).annotate({ - "description": "Controls fidelity to the original input image(s)." - }) + "require_approval": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.Struct({ "always": Schema.optionalKey(MCPToolFilter), "never": Schema.optionalKey(MCPToolFilter) }) + .annotate({ + "title": "MCP tool approval filter", + "description": + "Specify which of the MCP server's tools require approval. Can be\n`always`, `never`, or a filter object associated with tools\nthat require approval.\n" + }), + Schema.Literals(["always", "never"]).annotate({ + "title": "MCP tool approval setting", + "description": + "Specify a single approval policy for all tools. One of `always` or\n`never`. When set to `always`, all tools will require approval. When\nset to `never`, all tools will not require approval.\n" + }) + ], { mode: "oneOf" }).annotate({ "description": "Specify which of the MCP server's tools require approval." }), + Schema.Null + ]) ), - "size": Schema.optionalKey( - Schema.Union([Schema.Literals(["auto", "1024x1024", "1536x1024", "1024x1536"]), Schema.Null]).annotate({ - "description": "Requested output image size." + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this MCP tool is deferred and discovered via tool search.\n" }) + ) +}).annotate({ + "title": "MCP tool", + "description": + "Give the model access to additional tools via remote Model Context Protocol\n(MCP) servers. [Learn more about MCP](/docs/guides/tools-remote-mcp).\n", + "identifier": "MCPTool" +}) +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"?: string | "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"?: ImageGenActionEnum +} +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" }) ), - "user": Schema.optionalKey( - Schema.String.annotate({ + "size": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"])]).annotate({ "description": - "A unique identifier representing your end-user, which can help OpenAI\nmonitor and detect abuse.\n" + "The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`." }) ), "output_format": Schema.optionalKey( - Schema.Union([Schema.Literals(["png", "jpeg", "webp"]), Schema.Null]).annotate({ - "description": "Output image format. Supported for GPT image models." + 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.Union([ - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check( - Schema.isLessThanOrEqualTo(100) - ), - Schema.Null - ]).annotate({ "description": "Compression level for `jpeg` or `webp` output." }) + Schema.Number.annotate({ "description": "Compression level for the output image. Default: 100.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })).check( + Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" }) + ) ), "moderation": Schema.optionalKey( - Schema.Union([Schema.Literals(["low", "auto"]), Schema.Null]).annotate({ - "description": "Moderation level for GPT image models." + Schema.Literals(["auto", "low"]).annotate({ + "description": "Moderation level for the generated image. Default: `auto`.\n" }) ), "background": Schema.optionalKey( - Schema.Union([Schema.Literals(["transparent", "opaque", "auto"]), Schema.Null]).annotate({ - "description": "Background behavior for generated image output." + Schema.Literals(["transparent", "opaque", "auto"]).annotate({ + "description": + "Background type for the generated image. One of `transparent`,\n`opaque`, or `auto`. Default: `auto`.\n" }) ), - "stream": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ "description": "Stream partial image results as events." }) - ), - "partial_images": Schema.optionalKey(PartialImages) -}).annotate({ - "description": - "JSON request body for image edits.\n\nUse `images` (array of `ImageRefParam`) instead of multipart `image` uploads.\nYou can reference images via external URLs, data URLs, or uploaded file IDs.\nJSON edits support GPT image models only; DALL-E edits require multipart (`dall-e-2` only).\n" -}) -export type ProjectListResponse = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id"?: string | null - readonly "last_id"?: string | null - readonly "has_more": boolean -} -export const ProjectListResponse = Schema.Struct({ - "object": Schema.Literal("list"), - "data": Schema.Array(Project), - "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "has_more": Schema.Boolean + "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().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(3).annotate({ "expected": "a value less than or equal to 3" })) + ), + "action": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ImageGenActionEnum).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", + "identifier": "ImageGenTool" }) -export type ProjectApiKey = { - readonly "object": "organization.project.api_key" - readonly "redacted_value": string - readonly "name": string - readonly "created_at": number - readonly "last_used_at": number | null - readonly "id": string - readonly "owner": { - readonly "type"?: "user" | "service_account" - readonly "user"?: ProjectApiKeyOwnerUser - readonly "service_account"?: ProjectApiKeyOwnerServiceAccount - } -} -export const ProjectApiKey = Schema.Struct({ - "object": Schema.Literal("organization.project.api_key").annotate({ - "description": "The object type, which is always `organization.project.api_key`" - }), - "redacted_value": Schema.String.annotate({ "description": "The redacted value of the API key" }), - "name": Schema.String.annotate({ "description": "The name of the API key" }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the API key was created", - "format": "unixtime" - }).check(Schema.isInt()), - "last_used_at": Schema.Union([Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt()), Schema.Null]) - .annotate({ "description": "The Unix timestamp (in seconds) of when the API key was last used." }), - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), - "owner": Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literals(["user", "service_account"]).annotate({ "description": "`user` or `service_account`" }) - ), - "user": Schema.optionalKey(ProjectApiKeyOwnerUser), - "service_account": Schema.optionalKey(ProjectApiKeyOwnerServiceAccount) - }) -}).annotate({ "description": "Represents an individual API key in a project." }) -export type ProjectGroupListResource = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next": string | null +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).annotate({ "expected": "a value with a length of at most 200" }) + ) + ) +}).annotate({ "identifier": "LocalEnvironmentParam" }) +export type CustomGrammarFormatParam = { + readonly "type": "grammar" + readonly "syntax": GrammarSyntax1 + readonly "definition": string } -export const ProjectGroupListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), - "data": Schema.Array(ProjectGroup).annotate({ - "description": "Project group memberships returned in the current page." +export const CustomGrammarFormatParam = Schema.Struct({ + "type": Schema.Literal("grammar").annotate({ "description": "Grammar format. Always `grammar`." }), + "syntax": Schema.suspend((): Schema.Codec => GrammarSyntax1).annotate({ + "description": "The syntax of the grammar definition. One of `lark` or `regex`." }), - "has_more": Schema.Boolean.annotate({ "description": "Whether additional project group memberships are available." }), - "next": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Cursor to fetch the next page of results, or `null` when there are no more results." - }) -}).annotate({ "description": "Paginated list of groups that have access to a project." }) -export type ProjectRateLimitListResponse = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id"?: string | null - readonly "last_id"?: string | null - readonly "has_more": boolean -} -export const ProjectRateLimitListResponse = Schema.Struct({ - "object": Schema.Literal("list"), - "data": Schema.Array(ProjectRateLimit), - "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "has_more": Schema.Boolean -}) -export type ProjectServiceAccountListResponse = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id"?: string | null - readonly "last_id"?: string | null - readonly "has_more": boolean -} -export const ProjectServiceAccountListResponse = Schema.Struct({ - "object": Schema.Literal("list"), - "data": Schema.Array(ProjectServiceAccount), - "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "has_more": Schema.Boolean + "definition": Schema.String.annotate({ "description": "The grammar definition." }) +}).annotate({ + "title": "Grammar format", + "description": "A grammar defined by the user.", + "identifier": "CustomGrammarFormatParam" }) -export type ProjectServiceAccountCreateResponse = { - readonly "object": "organization.project.service_account" - readonly "id": string +export type FunctionToolParam = { readonly "name": string - readonly "role": "member" - readonly "created_at": number - readonly "api_key": ProjectServiceAccountApiKey | null + readonly "description"?: string | null + readonly "parameters"?: EmptyModelParam | null + readonly "strict"?: boolean | null + readonly "type": "function" + readonly "output_schema"?: {} | null + readonly "defer_loading"?: boolean + readonly "allowed_callers"?: ReadonlyArray | null } -export const ProjectServiceAccountCreateResponse = Schema.Struct({ - "object": Schema.Literal("organization.project.service_account"), - "id": Schema.String, - "name": Schema.String, - "role": Schema.Literal("member").annotate({ - "description": "Service accounts can only have one role of type `member`" - }), - "created_at": Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt()), - "api_key": Schema.Union([ProjectServiceAccountApiKey, Schema.Null]) -}) -export type ProjectUserListResponse = { - readonly "object": string - readonly "data": ReadonlyArray - readonly "first_id"?: string | null - readonly "last_id"?: string | null - readonly "has_more": boolean +export const FunctionToolParam = Schema.Struct({ + "name": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + .check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the 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.annotate({ + "description": + "Whether to enforce strict parameter validation. If omitted, Responses attempts to use strict validation when the schema is compatible, and falls back to non-strict validation otherwise." + }), + Schema.Null + ]) + ), + "type": Schema.Literal("function"), + "output_schema": Schema.optionalKey( + Schema.Union([ + Schema.Struct({}).annotate({ + "description": + "A JSON Schema describing the JSON value encoded in string outputs for this function tool. This does not describe content-array outputs." + }), + Schema.Null + ]) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Whether this function should be deferred and discovered via tool search." + }) + ), + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(CallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]) + ) +}).annotate({ "identifier": "FunctionToolParam" }) +export type ToolSearchToolParam = { + readonly "type": "tool_search" + readonly "execution"?: ToolSearchExecutionType + readonly "description"?: string | null + readonly "parameters"?: EmptyModelParam | null } -export const ProjectUserListResponse = Schema.Struct({ - "object": Schema.String, - "data": Schema.Array(ProjectUser), - "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "has_more": Schema.Boolean +export const ToolSearchToolParam = Schema.Struct({ + "type": Schema.Literal("tool_search").annotate({ "description": "The type of the tool. Always `tool_search`." }), + "execution": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ToolSearchExecutionType).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.suspend((): Schema.Codec => EmptyModelParam).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.", + "identifier": "ToolSearchToolParam" }) -export type RealtimeTranscriptionSessionCreateResponseGA = { - readonly "type": "transcription" - readonly "id": string - readonly "object": string - readonly "expires_at"?: number - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> - readonly "audio"?: { - readonly "input"?: { - readonly "format"?: RealtimeAudioFormats - readonly "transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - } - readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "turn_detection"?: { - readonly "type"?: string - readonly "threshold"?: number - readonly "prefix_padding_ms"?: number - readonly "silence_duration_ms"?: number - } | null - } - } +export type WebSearchPreviewTool = { + readonly "type": "web_search_preview" | "web_search_preview_2025_03_11" + readonly "user_location"?: ApproximateLocation | null + readonly "search_context_size"?: SearchContextSize + readonly "search_content_types"?: ReadonlyArray } -export const RealtimeTranscriptionSessionCreateResponseGA = Schema.Struct({ - "type": Schema.Literal("transcription").annotate({ - "description": "The type of session. Always `transcription` for transcription sessions.\n" - }), - "id": Schema.String.annotate({ - "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" +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`." }), - "object": Schema.String.annotate({ "description": "The object type. Always `realtime.transcription_session`." }), - "expires_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Expiration timestamp for the session, in seconds since epoch.", - "format": "unixtime" - }).check(Schema.isInt()) + "user_location": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ApproximateLocation).annotate({ + "description": "The user's location." + }), + Schema.Null + ]) ), - "include": Schema.optionalKey( - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ + "search_context_size": Schema.optionalKey( + Schema.suspend((): Schema.Codec => SearchContextSize).annotate({ "description": - "Additional fields to include in server outputs.\n- `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" + "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." }) ), - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey(RealtimeAudioFormats), - "transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model used for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.\n" - }) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ "description": "The language of the input audio.\n" }) - ), - "prompt": Schema.optionalKey( - Schema.String.annotate({ - "description": "The prompt configured for input audio transcription, when present.\n" - }) - ) - }).annotate({ "description": "Configuration of the transcription model.\n" }) - ), - "noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": "Configuration for input audio noise reduction.\n" - }) - ), - "turn_detection": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.String.annotate({ - "description": "Type of turn detection, only `server_vad` is currently supported.\n" - }) - ), - "threshold": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" - }).check(Schema.isFinite()) - ), - "prefix_padding_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" - }).check(Schema.isInt()) - ), - "silence_duration_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" - }).check(Schema.isInt()) - ) - }).annotate({ - "description": - "Configuration for turn detection. Can be set to `null` to turn off. Server\nVAD means that the model will detect the start and end of speech based on\naudio volume and respond at the end of user speech. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.\n" - }), - Schema.Null - ]).annotate({ - "description": - "Configuration for turn detection. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.\n" - }) - ) - })) - }).annotate({ "description": "Configuration for input audio for the session.\n" }) + "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).", + "identifier": "WebSearchPreviewTool" +}) +export type ProgramOutput = { + readonly "type": "program_output" + readonly "id": string + readonly "call_id": string + readonly "result": string + readonly "status": ProgramOutputStatus +} +export const ProgramOutput = Schema.Struct({ + "type": Schema.Literal("program_output").annotate({ + "description": "The type of the item. Always `program_output`." + }), + "id": Schema.String.annotate({ "description": "The unique ID of the program output item." }), + "call_id": Schema.String.annotate({ "description": "The call ID of the program item." }), + "result": Schema.String.annotate({ "description": "The result produced by the program item." }), + "status": Schema.suspend((): Schema.Codec => ProgramOutputStatus).annotate({ + "description": "The terminal status of the program output item." + }) +}).annotate({ "identifier": "ProgramOutput" }) +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", + "identifier": "CodeInterpreterToolCall" +}) +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", + "identifier": "LocalShellToolCall" +}) +export type FunctionShellCallOutputContent = { + readonly "stdout": string + readonly "stderr": string + readonly "outcome": FunctionShellCallOutputTimeoutOutcome | FunctionShellCallOutputExitOutcome + readonly "created_by"?: string +} +export const FunctionShellCallOutputContent = Schema.Struct({ + "stdout": Schema.String.annotate({ "description": "The standard output that was captured." }), + "stderr": Schema.String.annotate({ "description": "The standard error output that was captured." }), + "outcome": Schema.Union([FunctionShellCallOutputTimeoutOutcome, FunctionShellCallOutputExitOutcome], { + mode: "oneOf" + }).annotate({ + "title": "Shell call outcome", + "description": + "Represents either an exit outcome (with an exit code) or a timeout outcome for a shell call output chunk." + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) ) }).annotate({ - "title": "Realtime transcription session configuration object", - "description": "A Realtime transcription session configuration object.\n" + "title": "Shell call output content", + "description": "The content of a shell tool call output that was emitted.", + "identifier": "FunctionShellCallOutputContent" }) -export type RealtimeMCPToolCall = { - readonly "type": "mcp_call" +export type MCPListTools = { + readonly "type": "mcp_list_tools" readonly "id": string readonly "server_label": string - readonly "name": string - readonly "arguments": string - readonly "approval_request_id"?: string | null - readonly "output"?: string | null - readonly "error"?: RealtimeMCPProtocolError | RealtimeMCPToolExecutionError | RealtimeMCPHTTPError | null -} -export const RealtimeMCPToolCall = Schema.Struct({ - "type": Schema.Literal("mcp_call").annotate({ "description": "The type of the item. Always `mcp_call`." }), - "id": Schema.String.annotate({ "description": "The unique ID of the tool call." }), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server running the tool." }), - "name": Schema.String.annotate({ "description": "The name of the tool that was run." }), - "arguments": Schema.String.annotate({ "description": "A JSON string of the arguments passed to the tool." }), - "approval_request_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The ID of an associated approval request, if any." }), - Schema.Null - ]) - ), - "output": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "The output from the tool call." }), Schema.Null]) - ), + readonly "tools": ReadonlyArray + readonly "error"?: string | null +} +export const MCPListTools = Schema.Struct({ + "type": Schema.Literal("mcp_list_tools").annotate({ + "description": "The type of the item. Always `mcp_list_tools`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the list.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server.\n" }), + "tools": Schema.Array(MCPListToolsTool).annotate({ "description": "The tools available on the server.\n" }), "error": Schema.optionalKey( Schema.Union([ - Schema.Union([RealtimeMCPProtocolError, RealtimeMCPToolExecutionError, RealtimeMCPHTTPError], { mode: "oneOf" }) - .annotate({ "description": "The error from the tool call, if any." }), + Schema.String.annotate({ "description": "Error message if the server could not list tools.\n" }), Schema.Null ]) ) }).annotate({ - "title": "Realtime MCP tool call", - "description": "A Realtime item representing an invocation of a tool on an MCP server.\n" -}) -export type RealtimeReasoning = { readonly "effort"?: RealtimeReasoningEffort } -export const RealtimeReasoning = Schema.Struct({ "effort": Schema.optionalKey(RealtimeReasoningEffort) }).annotate({ - "title": "Realtime reasoning configuration", - "description": "Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.\n" + "title": "MCP list tools", + "description": "A list of tools available on an MCP server.\n", + "identifier": "MCPListTools" }) -export type RealtimeTranscriptionSessionCreateRequestGA = { - readonly "type": "transcription" - readonly "audio"?: { - readonly "input"?: { - readonly "format"?: RealtimeAudioFormats - readonly "transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - readonly "delay"?: "minimal" | "low" | "medium" | "high" | "xhigh" - } - readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "turn_detection"?: RealtimeTurnDetection - } - } - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> +export type MCPToolCall = { + readonly "type": "mcp_call" + readonly "id": string + readonly "server_label": string + readonly "name": string + readonly "arguments": string + readonly "output"?: string | null + readonly "error"?: string | null + readonly "status"?: MCPToolCallStatus + readonly "approval_request_id"?: string | null } -export const RealtimeTranscriptionSessionCreateRequestGA = Schema.Struct({ - "type": Schema.Literal("transcription").annotate({ - "description": "The type of session to create. Always `transcription` for transcription sessions.\n" - }), - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey(RealtimeAudioFormats), - "transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.\n" - }) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The language of the input audio. Supplying the input language in\n[ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format\nwill improve accuracy and latency.\n" - }) - ), - "prompt": Schema.optionalKey(Schema.String.annotate({ - "description": - "An optional text to guide the model's style or continue a previous audio\nsegment.\nFor `whisper-1`, the [prompt is a list of keywords](/docs/guides/speech-to-text#prompting).\nFor `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example \"expect words related to technology\".\nPrompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - })), - "delay": Schema.optionalKey( - Schema.Literals(["minimal", "low", "medium", "high", "xhigh"]).annotate({ - "description": - "Controls how long the model waits before emitting transcription text.\nHigher values can improve transcription accuracy at the cost of latency.\nOnly supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - }) - ) - }).annotate({ - "description": - "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" - }) - ), - "noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": - "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" - }) - ), - "turn_detection": Schema.optionalKey(RealtimeTurnDetection) - })) - }).annotate({ "description": "Configuration for input and output audio.\n" }) +export const MCPToolCall = Schema.Struct({ + "type": Schema.Literal("mcp_call").annotate({ "description": "The type of the item. Always `mcp_call`.\n" }), + "id": Schema.String.annotate({ "description": "The unique ID of the tool call.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server running the tool.\n" }), + "name": Schema.String.annotate({ "description": "The name of the tool that was run.\n" }), + "arguments": Schema.String.annotate({ "description": "A JSON string of the arguments passed to the tool.\n" }), + "output": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The output from the tool call.\n" }), Schema.Null]) ), - "include": Schema.optionalKey( - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ + "error": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The error from the tool call, if any.\n" }), Schema.Null]) + ), + "status": Schema.optionalKey( + Schema.suspend((): Schema.Codec => MCPToolCallStatus).annotate({ "description": - "Additional fields to include in server outputs.\n\n`item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" + "The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`, or `failed`.\n" }) - ) -}).annotate({ - "title": "Realtime transcription session configuration", - "description": "Realtime transcription session object configuration." -}) -export type Reasoning = { - readonly "effort"?: ReasoningEffort - readonly "summary"?: "auto" | "concise" | "detailed" | null - readonly "generate_summary"?: "auto" | "concise" | "detailed" | null -} -export const Reasoning = 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( + ), + "approval_request_id": Schema.optionalKey( Schema.Union([ - Schema.Literals(["auto", "concise", "detailed"]).annotate({ + Schema.String.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" + "Unique identifier for the MCP tool call approval request.\nInclude this value in a subsequent `mcp_approval_response` input to approve or reject the corresponding tool call.\n" }), Schema.Null ]) ) }).annotate({ - "title": "Reasoning", - "description": - "**gpt-5 and o-series models only**\n\nConfiguration options for\n[reasoning models](https://platform.openai.com/docs/guides/reasoning).\n" + "title": "MCP tool call", + "description": "An invocation of a tool on an MCP server.\n", + "identifier": "MCPToolCall" }) -export type ResponseError = { readonly "code": ResponseErrorCode; readonly "message": string } | null -export const ResponseError = Schema.Union([ - Schema.Struct({ - "code": ResponseErrorCode, - "message": Schema.String.annotate({ "description": "A human-readable description of the error.\n" }) - }).annotate({ "description": "An error object returned when the model fails to generate a Response.\n" }), - Schema.Null -]) -export type ResponseFormatJsonSchema = { - readonly "type": "json_schema" - readonly "json_schema": { - readonly "description"?: string - readonly "name": string - readonly "schema"?: ResponseFormatJsonSchemaSchema - readonly "strict"?: boolean | null - } +export type InputImageContentParamAutoParam = { + readonly "type": "input_image" + readonly "image_url"?: string | null + readonly "file_id"?: string | null + readonly "detail"?: DetailEnum | null + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointParam | null } -export const ResponseFormatJsonSchema = Schema.Struct({ - "type": Schema.Literal("json_schema").annotate({ - "description": "The type of response format being defined. Always `json_schema`." +export const InputImageContentParamAutoParam = Schema.Struct({ + "type": Schema.Literal("input_image").annotate({ + "description": "The type of the input item. Always `input_image`." }), - "json_schema": Schema.Struct({ - "description": Schema.optionalKey( + "image_url": Schema.optionalKey( + Schema.Union([ Schema.String.annotate({ "description": - "A description of what the response format is for, used by the model to\ndetermine how to respond in the format.\n" - }) - ), - "name": Schema.String.annotate({ - "description": - "The name of the response format. Must be a-z, A-Z, 0-9, or contain\nunderscores and dashes, with a maximum length of 64.\n" - }), - "schema": Schema.optionalKey(ResponseFormatJsonSchemaSchema), - "strict": Schema.optionalKey(Schema.Union([ - Schema.Boolean.annotate({ + "The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.", + "format": "uri" + }).check(Schema.isMaxLength(20971520).annotate({ "expected": "a value with a length of at most 20971520" })), + Schema.Null + ]) + ), + "file_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), + Schema.Null + ]) + ), + "detail": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => DetailEnum).annotate({ "description": - "Whether to enable strict schema adherence when generating the output.\nIf set to true, the model will always follow the exact schema defined\nin the `schema` field. Only a subset of JSON Schema is supported when\n`strict` is `true`. To learn more, read the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n" + "The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`." }), Schema.Null - ])) - }).annotate({ - "title": "JSON schema", - "description": "Structured Outputs configuration options, including a JSON Schema.\n" - }) + ]) + ), + "prompt_cache_breakpoint": Schema.optionalKey(Schema.Union([PromptCacheBreakpointParam, Schema.Null])) }).annotate({ - "title": "JSON schema", - "description": - "JSON Schema response format. Used to generate structured JSON responses.\nLearn more about [Structured Outputs](/docs/guides/structured-outputs).\n" + "title": "Input image", + "description": "An image input to the model. Learn about [image inputs](/docs/guides/vision)", + "identifier": "InputImageContentParamAutoParam" }) -export type TextResponseFormatJsonSchema = { - readonly "type": "json_schema" - readonly "description"?: string - readonly "name": string - readonly "schema": ResponseFormatJsonSchemaSchema - readonly "strict"?: boolean | null +export type InputFileContentParam = { + readonly "type": "input_file" + readonly "file_id"?: string | null + readonly "filename"?: string | null + readonly "file_data"?: string | null + readonly "file_url"?: string | null + readonly "detail"?: FileDetailEnum + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpointParam | null } -export const TextResponseFormatJsonSchema = Schema.Struct({ - "type": Schema.Literal("json_schema").annotate({ - "description": "The type of response format being defined. Always `json_schema`." - }), - "description": Schema.optionalKey( - Schema.String.annotate({ +export const InputFileContentParam = Schema.Struct({ + "type": Schema.Literal("input_file").annotate({ "description": "The type of the input item. Always `input_file`." }), + "file_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), + Schema.Null + ]) + ), + "filename": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The name of the file to be sent to the model." }), + Schema.Null + ]) + ), + "file_data": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The base64-encoded data of the file to be sent to the model." }).check( + Schema.isMaxLength(73400320).annotate({ "expected": "a value with a length of at most 73400320" }) + ), + Schema.Null + ]) + ), + "file_url": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The URL of the file to be sent to the model.", "format": "uri" }), + Schema.Null + ]) + ), + "detail": Schema.optionalKey( + Schema.suspend((): Schema.Codec => FileDetailEnum).annotate({ "description": - "A description of what the response format is for, used by the model to\ndetermine how to respond in the format.\n" + "The detail level of the file to be sent to the model. Use `auto` to let the system select the detail level; for GPT-5.6 and later models, `auto` uses high-quality rendering, which may increase input token usage. Use `low` for lower-cost rendering, or `high` to render the file at higher quality. Defaults to `auto`." }) ), - "name": Schema.String.annotate({ - "description": - "The name of the response format. Must be a-z, A-Z, 0-9, or contain\nunderscores and dashes, with a maximum length of 64.\n" - }), - "schema": ResponseFormatJsonSchemaSchema, - "strict": Schema.optionalKey(Schema.Union([ - Schema.Boolean.annotate({ - "description": - "Whether to enable strict schema adherence when generating the output.\nIf set to true, the model will always follow the exact schema defined\nin the `schema` field. Only a subset of JSON Schema is supported when\n`strict` is `true`. To learn more, read the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n" - }), - Schema.Null - ])) + "prompt_cache_breakpoint": Schema.optionalKey(Schema.Union([PromptCacheBreakpointParam, Schema.Null])) }).annotate({ - "title": "JSON schema", - "description": - "JSON Schema response format. Used to generate structured JSON responses.\nLearn more about [Structured Outputs](/docs/guides/structured-outputs).\n" + "title": "Input file", + "description": "A file input to the model.", + "identifier": "InputFileContentParam" +}) +export type FunctionShellCallOutputOutcomeParam = + | FunctionShellCallOutputTimeoutOutcomeParam + | FunctionShellCallOutputExitOutcomeParam +export const FunctionShellCallOutputOutcomeParam = Schema.Union([ + FunctionShellCallOutputTimeoutOutcomeParam, + FunctionShellCallOutputExitOutcomeParam +], { mode: "oneOf" }).annotate({ + "title": "Shell call outcome", + "description": "The exit or timeout outcome associated with this shell call.", + "identifier": "FunctionShellCallOutputOutcomeParam" +}) +export type ApplyPatchOperationParam = + | ApplyPatchCreateFileOperationParam + | ApplyPatchDeleteFileOperationParam + | ApplyPatchUpdateFileOperationParam +export const ApplyPatchOperationParam = Schema.Union([ + ApplyPatchCreateFileOperationParam, + ApplyPatchDeleteFileOperationParam, + ApplyPatchUpdateFileOperationParam +], { mode: "oneOf" }).annotate({ + "title": "Apply patch operation", + "description": "One of the create_file, delete_file, or update_file operations supplied to the apply_patch tool.", + "identifier": "ApplyPatchOperationParam" }) -export type ResponseTextDeltaEvent = { - readonly "type": "response.output_text.delta" - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "delta": string - readonly "sequence_number": number - readonly "logprobs": ReadonlyArray -} -export const ResponseTextDeltaEvent = Schema.Struct({ - "type": Schema.Literal("response.output_text.delta").annotate({ - "description": "The type of the event. Always `response.output_text.delta`.\n" - }), - "item_id": Schema.String.annotate({ "description": "The ID of the output item that the text delta was added to.\n" }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item that the text delta was added to.\n" - }).check(Schema.isInt()), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part that the text delta was added to.\n" - }).check(Schema.isInt()), - "delta": Schema.String.annotate({ "description": "The text delta that was added.\n" }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( - Schema.isInt() - ), - "logprobs": Schema.Array(ResponseLogProb).annotate({ - "description": "The log probabilities of the tokens in the delta.\n" - }) -}).annotate({ "description": "Emitted when there is an additional text delta." }) -export type ResponseTextDoneEvent = { - readonly "type": "response.output_text.done" - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "text": string - readonly "sequence_number": number - readonly "logprobs": ReadonlyArray -} -export const ResponseTextDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.output_text.done").annotate({ - "description": "The type of the event. Always `response.output_text.done`.\n" - }), - "item_id": Schema.String.annotate({ - "description": "The ID of the output item that the text content is finalized.\n" - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item that the text content is finalized.\n" - }).check(Schema.isInt()), - "content_index": Schema.Number.annotate({ - "description": "The index of the content part that the text content is finalized.\n" - }).check(Schema.isInt()), - "text": Schema.String.annotate({ "description": "The text content that is finalized.\n" }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( - Schema.isInt() - ), - "logprobs": Schema.Array(ResponseLogProb).annotate({ - "description": "The log probabilities of the tokens in the delta.\n" - }) -}).annotate({ "description": "Emitted when text content is finalized." }) -export type Prompt = { +export type ProgramOutputItemParam = { readonly "id": string - readonly "version"?: string | null - readonly "variables"?: ResponsePromptVariables -} | null -export const Prompt = Schema.Union([ - Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique identifier of the prompt template to use." }), - "version": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "Optional version of the prompt template." }), Schema.Null]) - ), - "variables": Schema.optionalKey(ResponsePromptVariables) - }).annotate({ - "description": - "Reference to a prompt template and its variables.\n[Learn more](/docs/guides/text?api-mode=responses#reusable-prompts).\n" - }), - Schema.Null -]) -export type GroupRoleAssignment = { readonly "object": "group.role"; readonly "group": Group; readonly "role": Role } -export const GroupRoleAssignment = Schema.Struct({ - "object": Schema.Literal("group.role").annotate({ "description": "Always `group.role`." }), - "group": Group, - "role": Role -}).annotate({ "description": "Role assignment linking a group to a role." }) -export type PublicRoleListResource = { + readonly "type": "program_output" + readonly "call_id": string + readonly "result": string + readonly "status": ProgramOutputItemStatus +} +export const ProgramOutputItemParam = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of this program output item." }), + "type": Schema.Literal("program_output").annotate({ "description": "The item type. Always `program_output`." }), + "call_id": Schema.String.annotate({ "description": "The call ID of the program item." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "result": Schema.String.annotate({ "description": "The result produced by the program item." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ), + "status": Schema.suspend((): Schema.Codec => ProgramOutputItemStatus).annotate({ + "description": "The terminal status of the program output." + }) +}).annotate({ "identifier": "ProgramOutputItemParam" }) +export type CreateEmbeddingResponse = { + readonly "data": ReadonlyArray + readonly "model": string readonly "object": "list" - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next": string | null + readonly "usage": { readonly "prompt_tokens": number; readonly "total_tokens": number } } -export const PublicRoleListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), - "data": Schema.Array(Role).annotate({ "description": "Roles returned in the current page." }), - "has_more": Schema.Boolean.annotate({ "description": "Whether more roles are available when paginating." }), - "next": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Cursor to fetch the next page of results, or `null` when there are no additional roles." - }) -}).annotate({ "description": "Paginated list of roles available on an organization or project." }) -export type RunStepDeltaObject = { +export const CreateEmbeddingResponse = Schema.Struct({ + "data": Schema.Array(Embedding).annotate({ "description": "The list of embeddings generated by the model." }), + "model": Schema.String.annotate({ "description": "The name of the model used to generate the embedding." }), + "object": Schema.Literal("list").annotate({ "description": "The object type, which is always \"list\"." }), + "usage": Schema.Struct({ + "prompt_tokens": Schema.Number.annotate({ "description": "The number of tokens used by the prompt." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "total_tokens": Schema.Number.annotate({ "description": "The total number of tokens used by the request." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).annotate({ "description": "The usage information for the request." }) +}).annotate({ "identifier": "CreateEmbeddingResponse" }) +export type ErrorResponse = { readonly "error": Error } +export const ErrorResponse = Schema.Struct({ "error": Error }).annotate({ "identifier": "ErrorResponse" }) +export type EvalRunOutputItem = { + readonly "object": "eval.run.output_item" readonly "id": string - readonly "object": "thread.run.step.delta" - readonly "delta": { - readonly "step_details"?: { - readonly "type": "message_creation" - readonly "message_creation"?: { readonly "message_id"?: string } - } | { - readonly "type": "tool_calls" - readonly "tool_calls"?: ReadonlyArray< - | RunStepDeltaStepDetailsToolCallsCodeObject - | RunStepDeltaStepDetailsToolCallsFileSearchObject - | RunStepDeltaStepDetailsToolCallsFunctionObject - > + readonly "run_id": string + readonly "eval_id": string + readonly "created_at": number + readonly "status": string + readonly "datasource_item_id": number + readonly "datasource_item": {} + readonly "results": ReadonlyArray + readonly "sample": { + readonly "input": ReadonlyArray<{ readonly "role": string; readonly "content": string }> + readonly "output": ReadonlyArray<{ readonly "role"?: string; readonly "content"?: string }> + readonly "finish_reason": string + readonly "model": string + readonly "usage": { + readonly "total_tokens": number + readonly "completion_tokens": number + readonly "prompt_tokens": number + readonly "cached_tokens": number } + readonly "error": EvalApiError + readonly "temperature": number + readonly "max_completion_tokens": number + readonly "top_p": number + readonly "seed": number } } -export const RunStepDeltaObject = Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The identifier of the run step, which can be referenced in API endpoints." - }), - "object": Schema.Literal("thread.run.step.delta").annotate({ - "description": "The object type, which is always `thread.run.step.delta`." +export const EvalRunOutputItem = Schema.Struct({ + "object": Schema.Literal("eval.run.output_item").annotate({ + "description": "The type of the object. Always \"eval.run.output_item\"." }), - "delta": Schema.Struct({ - "step_details": Schema.optionalKey(Schema.Union([ + "id": Schema.String.annotate({ "description": "Unique identifier for the evaluation run output item." }), + "run_id": Schema.String.annotate({ + "description": "The identifier of the evaluation run associated with this output item." + }), + "eval_id": Schema.String.annotate({ "description": "The identifier of the evaluation group." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the evaluation run was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "status": Schema.String.annotate({ "description": "The status of the evaluation run." }), + "datasource_item_id": Schema.Number.annotate({ "description": "The identifier for the data source item." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "datasource_item": Schema.Struct({}).annotate({ "description": "Details of the input data source item." }), + "results": Schema.Array(EvalRunOutputItemResult).annotate({ + "description": "A list of grader results for this output item." + }), + "sample": Schema.Struct({ + "input": Schema.Array( Schema.Struct({ - "type": Schema.Literal("message_creation").annotate({ "description": "Always `message_creation`." }), - "message_creation": Schema.optionalKey( - Schema.Struct({ - "message_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the message that was created by this run step." }) - ) - }) - ) - }).annotate({ "title": "Message creation", "description": "The details of the run step." }), + "role": Schema.String.annotate({ + "description": "The role of the message sender (e.g., system, user, developer)." + }), + "content": Schema.String.annotate({ "description": "The content of the message." }) + }).annotate({ "description": "An input message." }) + ).annotate({ "description": "An array of input messages." }), + "output": Schema.Array( Schema.Struct({ - "type": Schema.Literal("tool_calls").annotate({ "description": "Always `tool_calls`." }), - "tool_calls": Schema.optionalKey( - Schema.Array( - Schema.Union([ - RunStepDeltaStepDetailsToolCallsCodeObject, - RunStepDeltaStepDetailsToolCallsFileSearchObject, - RunStepDeltaStepDetailsToolCallsFunctionObject - ], { mode: "oneOf" }) - ).annotate({ - "description": - "An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`.\n" + "role": Schema.optionalKey( + Schema.String.annotate({ + "description": "The role of the message (e.g. \"system\", \"assistant\", \"user\")." }) - ) - }).annotate({ "title": "Tool calls", "description": "The details of the run step." }) - ], { mode: "oneOf" })) - }).annotate({ "description": "The delta containing the fields that have changed on the run step." }) + ), + "content": Schema.optionalKey(Schema.String.annotate({ "description": "The content of the message." })) + }) + ).annotate({ "description": "An array of output messages." }), + "finish_reason": Schema.String.annotate({ "description": "The reason why the sample generation was finished." }), + "model": Schema.String.annotate({ "description": "The model used for generating the sample." }), + "usage": Schema.Struct({ + "total_tokens": Schema.Number.annotate({ "description": "The total number of tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "completion_tokens": Schema.Number.annotate({ "description": "The number of completion tokens generated." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "prompt_tokens": Schema.Number.annotate({ "description": "The number of prompt tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "cached_tokens": Schema.Number.annotate({ "description": "The number of tokens retrieved from cache." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).annotate({ "description": "Token usage details for the sample." }), + "error": EvalApiError, + "temperature": Schema.Number.annotate({ "description": "The sampling temperature used." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "max_completion_tokens": Schema.Number.annotate({ + "description": "The maximum number of tokens allowed for completion." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "top_p": Schema.Number.annotate({ "description": "The top_p value used for sampling." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "seed": Schema.Number.annotate({ "description": "The seed used for generating the sample." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).annotate({ "description": "A sample containing the input and output of the evaluation run." }) }).annotate({ - "title": "Run step delta object", - "description": "Represents a run step delta i.e. any changed fields on a run step during streaming.\n" + "title": "EvalRunOutputItem", + "description": "A schema representing an evaluation run output item.\n", + "identifier": "EvalRunOutputItem" }) -export type CreateSpeechResponseStreamEvent = SpeechAudioDeltaEvent | SpeechAudioDoneEvent -export const CreateSpeechResponseStreamEvent = Schema.Union([SpeechAudioDeltaEvent, SpeechAudioDoneEvent]) -export type ChunkingStrategyRequestParam = { readonly "type": "auto" } | { - readonly "type": "static" - readonly "static": StaticChunkingStrategy +export type ListFilesResponse = { + readonly "object": string + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean } -export const ChunkingStrategyRequestParam = Schema.Union([ - Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }).annotate({ - "title": "Auto Chunking Strategy", - "description": "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." +export const ListFilesResponse = Schema.Struct({ + "object": Schema.String, + "data": Schema.Array(OpenAIFile), + "first_id": Schema.String, + "last_id": Schema.String, + "has_more": Schema.Boolean +}).annotate({ "identifier": "ListFilesResponse" }) +export type CreateFileRequest = { + readonly "file": string + readonly "purpose": "assistants" | "batch" | "fine-tune" | "vision" | "user_data" | "evals" + readonly "expires_after"?: FileExpirationAfter +} +export const CreateFileRequest = Schema.Struct({ + "file": Schema.String.annotate({ + "description": "The File object (not file name) to be uploaded.\n", + "format": "binary" }), - Schema.Struct({ - "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), - "static": StaticChunkingStrategy - }).annotate({ - "title": "Static Chunking Strategy", - "description": "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." - }) -], { mode: "oneOf" }) -export type CreateCompletionRequest = { - readonly "model": string | "gpt-3.5-turbo-instruct" | "davinci-002" | "babbage-002" - readonly "prompt": - | string - | ReadonlyArray - | ReadonlyArray - | ReadonlyArray> - | null - readonly "best_of"?: number - readonly "echo"?: boolean | null - readonly "frequency_penalty"?: number - readonly "logit_bias"?: {} - readonly "logprobs"?: number - readonly "max_tokens"?: number - readonly "n"?: number - readonly "presence_penalty"?: number - readonly "seed"?: never - readonly "stop"?: StopConfiguration - readonly "stream"?: boolean | null - readonly "stream_options"?: ChatCompletionStreamOptions - readonly "suffix"?: string | null - readonly "temperature"?: number - readonly "top_p"?: number + "purpose": Schema.Literals(["assistants", "batch", "fine-tune", "vision", "user_data", "evals"]).annotate({ + "description": + "The intended purpose of the uploaded file. One of:\n- `assistants`: Used in the Assistants API\n- `batch`: Used in the Batch API\n- `fine-tune`: Used for fine-tuning\n- `vision`: Images used for vision fine-tuning\n- `user_data`: Flexible file type for any purpose\n- `evals`: Used for eval data sets\n" + }), + "expires_after": Schema.optionalKey(FileExpirationAfter) +}).annotate({ "identifier": "CreateFileRequest" }) +export type CreateUploadRequest = { + readonly "filename": string + readonly "purpose": "assistants" | "batch" | "fine-tune" | "vision" + readonly "bytes": number + readonly "mime_type": string + readonly "expires_after"?: FileExpirationAfter +} +export const CreateUploadRequest = Schema.Struct({ + "filename": Schema.String.annotate({ "description": "The name of the file to upload.\n" }), + "purpose": Schema.Literals(["assistants", "batch", "fine-tune", "vision"]).annotate({ + "description": + "The intended purpose of the uploaded file.\n\nSee the [documentation on File\npurposes](/docs/api-reference/files/create#files-create-purpose).\n" + }), + "bytes": Schema.Number.annotate({ "description": "The number of bytes in the file you are uploading.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "mime_type": Schema.String.annotate({ + "description": + "The MIME type of the file.\n\n\nThis must fall within the supported MIME types for your file purpose. See\nthe supported MIME types for assistants and vision.\n" + }), + "expires_after": Schema.optionalKey(FileExpirationAfter) +}).annotate({ "identifier": "CreateUploadRequest" }) +export type ListFineTuningCheckpointPermissionResponse = { + readonly "data": ReadonlyArray + readonly "object": "list" + readonly "first_id"?: string | null + readonly "last_id"?: string | null + readonly "has_more": boolean +} +export const ListFineTuningCheckpointPermissionResponse = Schema.Struct({ + "data": Schema.Array(FineTuningCheckpointPermission), + "object": Schema.Literal("list"), + "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "has_more": Schema.Boolean +}).annotate({ "identifier": "ListFineTuningCheckpointPermissionResponse" }) +export type FineTuneSupervisedMethod = { readonly "hyperparameters"?: FineTuneSupervisedHyperparameters } +export const FineTuneSupervisedMethod = Schema.Struct({ + "hyperparameters": Schema.optionalKey(FineTuneSupervisedHyperparameters) +}).annotate({ + "description": "Configuration for the supervised fine-tuning method.", + "identifier": "FineTuneSupervisedMethod" +}) +export type FineTuneDPOMethod = { readonly "hyperparameters"?: FineTuneDPOHyperparameters } +export const FineTuneDPOMethod = Schema.Struct({ "hyperparameters": Schema.optionalKey(FineTuneDPOHyperparameters) }) + .annotate({ "description": "Configuration for the DPO fine-tuning method.", "identifier": "FineTuneDPOMethod" }) +export type ListFineTuningJobCheckpointsResponse = { + readonly "data": ReadonlyArray + readonly "object": "list" + readonly "first_id"?: string | null + readonly "last_id"?: string | null + readonly "has_more": boolean +} +export const ListFineTuningJobCheckpointsResponse = Schema.Struct({ + "data": Schema.Array(FineTuningJobCheckpoint), + "object": Schema.Literal("list"), + "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "has_more": Schema.Boolean +}).annotate({ "identifier": "ListFineTuningJobCheckpointsResponse" }) +export type ListFineTuningJobEventsResponse = { + readonly "data": ReadonlyArray + readonly "object": "list" + readonly "has_more": boolean +} +export const ListFineTuningJobEventsResponse = Schema.Struct({ + "data": Schema.Array(FineTuningJobEvent), + "object": Schema.Literal("list"), + "has_more": Schema.Boolean +}).annotate({ "identifier": "ListFineTuningJobEventsResponse" }) +export type EditImageBodyJsonParam = { + readonly "model"?: string | "gpt-image-1.5" | "gpt-image-1" | "gpt-image-1-mini" | "chatgpt-image-latest" | null + readonly "images": ReadonlyArray + readonly "mask"?: ImageRefParam + readonly "prompt": string + readonly "n"?: number | null + readonly "quality"?: "low" | "medium" | "high" | "auto" | null + readonly "input_fidelity"?: "high" | "low" | null + readonly "size"?: "auto" | "1024x1024" | "1536x1024" | "1024x1536" | null readonly "user"?: string + readonly "output_format"?: "png" | "jpeg" | "webp" | null + readonly "output_compression"?: number | null + readonly "moderation"?: "low" | "auto" | null + readonly "background"?: "transparent" | "opaque" | "auto" | null + readonly "stream"?: boolean | null + readonly "partial_images"?: PartialImages } -export const CreateCompletionRequest = Schema.Struct({ - "model": Schema.Union([Schema.String, Schema.Literals(["gpt-3.5-turbo-instruct", "davinci-002", "babbage-002"])]) - .annotate({ - "description": - "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" - }), - "prompt": Schema.Union([ +export const EditImageBodyJsonParam = Schema.Struct({ + "model": Schema.optionalKey( Schema.Union([ Schema.String, - Schema.Array(Schema.String), - Schema.Array(Schema.Number.check(Schema.isInt())).check(Schema.isMinLength(1)), - Schema.Array(Schema.Array(Schema.Number.check(Schema.isInt())).check(Schema.isMinLength(1))).check( - Schema.isMinLength(1) - ) - ], { mode: "oneOf" }).annotate({ - "description": - "The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.\n\nNote that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.\n" - }), - Schema.Null - ]), - "best_of": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(20)], { - "description": - "Generates `best_of` completions server-side and returns the \"best\" (the one with the highest log probability per token). Results cannot be streamed.\n\nWhen used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n" - }) - ) - ]) + Schema.Literals(["gpt-image-1.5", "gpt-image-1", "gpt-image-1-mini", "chatgpt-image-latest"]), + Schema.Null + ]).annotate({ "description": "The model to use for image editing." }) ), - "echo": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": "Echo back the prompt in addition to the completion\n" - }) + "images": Schema.Array(ImageRefParam).annotate({ + "description": "Input image references to edit.\nFor GPT image models, you can provide up to 16 images.\n" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(16).annotate({ "expected": "a value with a length of at most 16" }) ), - "frequency_penalty": Schema.optionalKey( + "mask": Schema.optionalKey(ImageRefParam), + "prompt": Schema.String.annotate({ "description": "A text description of the desired image edit." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(32000).annotate({ "expected": "a value with a length of at most 32000" })), + "n": Schema.optionalKey( Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(-2), Schema.isLessThanOrEqualTo(2)], { - "description": - "Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n\n[See more information about frequency and presence penalties.](/docs/guides/text-generation)\n" - }) - ) - ]) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(10).annotate({ "expected": "a value less than or equal to 10" })), + Schema.Null + ]).annotate({ "description": "The number of edited images to generate." }) ), - "logit_bias": Schema.optionalKey(Schema.Union([ - Schema.Struct({}).annotate({ - "description": - "Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n\nAs an example, you can pass `{\"50256\": -100}` to prevent the <|endoftext|> token from being generated.\n" + "quality": Schema.optionalKey( + Schema.Union([Schema.Literals(["low", "medium", "high", "auto"]), Schema.Null]).annotate({ + "description": "Output quality for GPT image models.\n" }) - ])), - "logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(5)], { - "description": - "Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.\n\nThe maximum value for `logprobs` is 5.\n" - }) - ) - ]) ), - "max_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(0)], { - "description": - "The maximum number of [tokens](/tokenizer) that can be generated in the completion.\n\nThe token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.\n" - }) - ) - ]) + "input_fidelity": Schema.optionalKey( + Schema.Union([Schema.Literals(["high", "low"]), Schema.Null]).annotate({ + "description": "Controls fidelity to the original input image(s)." + }) ), - "n": Schema.optionalKey( + "size": Schema.optionalKey( + Schema.Union([Schema.Literals(["auto", "1024x1024", "1536x1024", "1024x1536"]), Schema.Null]).annotate({ + "description": "Requested output image size." + }) + ), + "user": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A unique identifier representing your end-user, which can help OpenAI\nmonitor and detect abuse.\n" + }) + ), + "output_format": Schema.optionalKey( + Schema.Union([Schema.Literals(["png", "jpeg", "webp"]), Schema.Null]).annotate({ + "description": "Output image format. Supported for GPT image models." + }) + ), + "output_compression": Schema.optionalKey( Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(128)], { - "description": - "How many completions to generate for each prompt.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n" - }) - ) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" })), + Schema.Null + ]).annotate({ "description": "Compression level for `jpeg` or `webp` output." }) + ), + "moderation": Schema.optionalKey( + Schema.Union([Schema.Literals(["low", "auto"]), Schema.Null]).annotate({ + "description": "Moderation level for GPT image models." + }) + ), + "background": Schema.optionalKey( + Schema.Union([Schema.Literals(["transparent", "opaque", "auto"]), Schema.Null]).annotate({ + "description": "Background behavior for generated image output." + }) + ), + "stream": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ "description": "Stream partial image results as events." }) + ), + "partial_images": Schema.optionalKey(PartialImages) +}).annotate({ + "description": + "JSON request body for image edits.\n\nUse `images` (array of `ImageRefParam`) instead of multipart `image` uploads.\nYou can reference images via external URLs, data URLs, or uploaded file IDs.\nJSON edits support GPT image models only; DALL-E edits require multipart (`dall-e-2` only).\n", + "identifier": "EditImageBodyJsonParam" +}) +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"?: string | "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({ "expected": "a value with a length of at most 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 ]) ), - "presence_penalty": Schema.optionalKey( + "n": Schema.optionalKey( Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(-2), Schema.isLessThanOrEqualTo(2)], { - "description": - "Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.\n\n[See more information about frequency and presence penalties.](/docs/guides/text-generation)\n" - }) - ) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(10).annotate({ "expected": "a value less than or equal to 10" })), + Schema.Null + ]).annotate({ "description": "The number of images to generate. Must be between 1 and 10." }) + ), + "size": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.String, + Schema.Literals(["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]) + ]).annotate({ + "description": + "The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`." + }), + Schema.Null ]) ), - "seed": Schema.optionalKey(Schema.Never), - "stop": Schema.optionalKey(StopConfiguration), + "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().annotate({ "expected": "an integer" })), 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": - "Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).\n" + "Edit the image in streaming mode. Defaults to `false`. See the\n[Image generation guide](/docs/guides/image-generation) for more information.\n" }) ), - "stream_options": Schema.optionalKey(ChatCompletionStreamOptions), - "suffix": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ + "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" + }) + ) +}).annotate({ "identifier": "CreateImageEditRequest" }) +export type CreateImageRequest = { + readonly "prompt": string + readonly "model"?: string | "gpt-image-1.5" | "dall-e-2" | "dall-e-3" | "gpt-image-1" | "gpt-image-1-mini" | null + readonly "n"?: number | null + readonly "quality"?: "standard" | "hd" | "low" | "medium" | "high" | "auto" | null + readonly "response_format"?: "url" | "b64_json" | null + readonly "output_format"?: "png" | "jpeg" | "webp" | null + readonly "output_compression"?: number | null + readonly "stream"?: boolean | null + readonly "partial_images"?: PartialImages + readonly "size"?: + | string + | "auto" + | "1024x1024" + | "1536x1024" + | "1024x1536" + | "256x256" + | "512x512" + | "1792x1024" + | "1024x1792" + | null + readonly "moderation"?: "low" | "auto" | null + readonly "background"?: "transparent" | "opaque" | "auto" | null + readonly "style"?: "vivid" | "natural" | null + readonly "user"?: string +} +export const CreateImageRequest = Schema.Struct({ + "prompt": Schema.String.annotate({ + "description": + "A text description of the desired image(s). The maximum length is 32000 characters for the GPT image models, 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`." + }), + "model": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.String, + Schema.Literals(["gpt-image-1.5", "dall-e-2", "dall-e-3", "gpt-image-1", "gpt-image-1-mini"]) + ]).annotate({ + "description": + "The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to `dall-e-2` unless a parameter specific to the GPT image models is used." + }), + Schema.Null + ]) + ), + "n": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(10).annotate({ "expected": "a value less than or equal to 10" })), + Schema.Null + ]).annotate({ "description": - "The suffix that comes after a completion of inserted text.\n\nThis parameter is only supported for `gpt-3.5-turbo-instruct`.\n" + "The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported." }) ), - "temperature": Schema.optionalKey( + "quality": Schema.optionalKey( Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(2)], { - "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.\n\nWe generally recommend altering this or `top_p` but not both.\n" - }) - ) - ]) + Schema.Literal("standard"), + Schema.Literal("hd"), + 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.\n\n- `auto` (default value) will automatically select the best quality for the given model.\n- `high`, `medium` and `low` are supported for the GPT image models.\n- `hd` and `standard` are supported for `dall-e-3`.\n- `standard` is the only option for `dall-e-2`.\n" + }) ), - "top_p": Schema.optionalKey( + "response_format": Schema.optionalKey( + Schema.Union([Schema.Literal("url"), Schema.Literal("b64_json"), Schema.Null]).annotate({ + "description": + "The format in which generated images with `dall-e-2` and `dall-e-3` 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 isn't supported for the GPT image models, which 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 only supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`." + }) + ), + "output_compression": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "description": + "The compression level (0-100%) for the generated images. This parameter is only supported for the GPT image models with the `webp` or `jpeg` output formats, and defaults to 100." + }) + ), + "stream": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Generate the image in streaming mode. Defaults to `false`. See the\n[Image generation guide](/docs/guides/image-generation) for more information.\nThis parameter is only supported for the GPT image models.\n" + }) + ), + "partial_images": Schema.optionalKey(PartialImages), + "size": Schema.optionalKey( Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(1)], { - "description": - "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or `temperature` but not both.\n" - }) - ) + Schema.Union([ + Schema.String, + Schema.Literals(["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"]) + ]).annotate({ + "description": + "The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`." + }), + Schema.Null ]) ), + "moderation": Schema.optionalKey( + Schema.Union([Schema.Literal("low"), Schema.Literal("auto"), Schema.Null]).annotate({ + "description": + "Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default value)." + }) + ), + "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" + }) + ), + "style": Schema.optionalKey( + Schema.Union([Schema.Literal("vivid"), Schema.Literal("natural"), Schema.Null]).annotate({ + "description": + "The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images." + }) + ), "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" }) ) -}) -export type TranscriptTextDoneEvent = { - readonly "type": "transcript.text.done" - readonly "text": string - readonly "logprobs"?: ReadonlyArray< - { readonly "token"?: string; readonly "logprob"?: number; readonly "bytes"?: ReadonlyArray } - > - readonly "usage"?: TranscriptTextUsageTokens +}).annotate({ "identifier": "CreateImageRequest" }) +export type ImageGenUsage = { + readonly "input_tokens": number + readonly "total_tokens": number + readonly "output_tokens": number + readonly "output_tokens_details"?: ImageGenOutputTokensDetails + readonly "input_tokens_details": ImageGenInputUsageDetails } -export const TranscriptTextDoneEvent = Schema.Struct({ - "type": Schema.Literal("transcript.text.done").annotate({ - "description": "The type of the event. Always `transcript.text.done`.\n" +export const ImageGenUsage = Schema.Struct({ + "input_tokens": Schema.Number.annotate({ + "description": "The number of tokens (images and text) in the input prompt." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "total_tokens": Schema.Number.annotate({ + "description": "The total number of tokens (images and text) used for the image generation." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "output_tokens": Schema.Number.annotate({ "description": "The number of output tokens generated by the model." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "output_tokens_details": Schema.optionalKey(ImageGenOutputTokensDetails), + "input_tokens_details": ImageGenInputUsageDetails +}).annotate({ + "title": "Image generation usage", + "description": "For `gpt-image-1` only, the token usage information for the image generation.", + "identifier": "ImageGenUsage" +}) +export type ImageEditCompletedEvent = { + readonly "type": "image_edit.completed" + readonly "b64_json": string + readonly "created_at": number + readonly "size": "1024x1024" | "1024x1536" | "1536x1024" | "auto" + readonly "quality": "low" | "medium" | "high" | "auto" + readonly "background": "transparent" | "opaque" | "auto" + readonly "output_format": "png" | "webp" | "jpeg" + readonly "usage": ImagesUsage +} +export const ImageEditCompletedEvent = Schema.Struct({ + "type": Schema.Literal("image_edit.completed").annotate({ + "description": "The type of the event. Always `image_edit.completed`.\n" }), - "text": Schema.String.annotate({ "description": "The text that was transcribed.\n" }), - "logprobs": Schema.optionalKey( - Schema.Array(Schema.Struct({ - "token": Schema.optionalKey( - Schema.String.annotate({ "description": "The token that was used to generate the log probability.\n" }) - ), - "logprob": Schema.optionalKey( - Schema.Number.annotate({ "description": "The log probability of the token.\n" }).check(Schema.isFinite()) - ), - "bytes": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "description": "The bytes that were used to generate the log probability.\n" - }) - ) - })).annotate({ - "description": - "The log probabilities of the individual tokens in the transcription. Only included if you [create a transcription](/docs/api-reference/audio/create-transcription) with the `include[]` parameter set to `logprobs`.\n" - }) - ), - "usage": Schema.optionalKey(TranscriptTextUsageTokens) + "b64_json": Schema.String.annotate({ + "description": "Base64-encoded final edited image data, suitable for rendering as an image.\n" + }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp when the event was created.\n", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "size": Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"]).annotate({ + "description": "The size of the edited image.\n" + }), + "quality": Schema.Literals(["low", "medium", "high", "auto"]).annotate({ + "description": "The quality setting for the edited image.\n" + }), + "background": Schema.Literals(["transparent", "opaque", "auto"]).annotate({ + "description": "The background setting for the edited image.\n" + }), + "output_format": Schema.Literals(["png", "webp", "jpeg"]).annotate({ + "description": "The output format for the edited image.\n" + }), + "usage": ImagesUsage }).annotate({ - "description": - "Emitted when the transcription is complete. Contains the complete transcription text. Only emitted when you [create a transcription](/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`." + "description": "Emitted when image editing has completed and the final image is available.\n", + "identifier": "ImageEditCompletedEvent" }) -export type CreateTranscriptionResponseDiarizedJson = { - readonly "task": "transcribe" - readonly "duration": number - readonly "text": string - readonly "segments": ReadonlyArray - readonly "usage"?: { - readonly "type": "tokens" - readonly "input_tokens": number - readonly "input_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number } - readonly "output_tokens": number - readonly "total_tokens": number - } | { readonly "type": "duration"; readonly "seconds": number } +export type ImageGenCompletedEvent = { + readonly "type": "image_generation.completed" + readonly "b64_json": string + readonly "created_at": number + readonly "size": "1024x1024" | "1024x1536" | "1536x1024" | "auto" + readonly "quality": "low" | "medium" | "high" | "auto" + readonly "background": "transparent" | "opaque" | "auto" + readonly "output_format": "png" | "webp" | "jpeg" + readonly "usage": ImagesUsage } -export const CreateTranscriptionResponseDiarizedJson = Schema.Struct({ - "task": Schema.Literal("transcribe").annotate({ - "description": "The type of task that was run. Always `transcribe`." +export const ImageGenCompletedEvent = Schema.Struct({ + "type": Schema.Literal("image_generation.completed").annotate({ + "description": "The type of the event. Always `image_generation.completed`.\n" }), - "duration": Schema.Number.annotate({ "description": "Duration of the input audio in seconds.", "format": "double" }) - .check(Schema.isFinite()), - "text": Schema.String.annotate({ "description": "The concatenated transcript text for the entire audio input." }), - "segments": Schema.Array(TranscriptionDiarizedSegment).annotate({ - "description": "Segments of the transcript annotated with timestamps and speaker labels." + "b64_json": Schema.String.annotate({ + "description": "Base64-encoded image data, suitable for rendering as an image.\n" }), - "usage": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("tokens").annotate({ - "description": "The type of the usage object. Always `tokens` for this variant." - }), - "input_tokens": Schema.Number.annotate({ "description": "Number of input tokens billed for this request." }) - .check(Schema.isInt()), - "input_token_details": Schema.optionalKey( - Schema.Struct({ - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of text tokens billed for this request." }).check( - Schema.isInt() - ) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of audio tokens billed for this request." }).check( - Schema.isInt() - ) - ) - }).annotate({ "description": "Details about the input tokens billed for this request." }) - ), - "output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check( - Schema.isInt() - ), - "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check( - Schema.isInt() - ) - }).annotate({ "title": "Token Usage", "description": "Token or duration usage statistics for the request." }), - Schema.Struct({ - "type": Schema.Literal("duration").annotate({ - "description": "The type of the usage object. Always `duration` for this variant." - }), - "seconds": Schema.Number.annotate({ - "description": "Duration of the input audio in seconds.", - "format": "double" - }).check(Schema.isFinite()) - }).annotate({ "title": "Duration Usage", "description": "Token or duration usage statistics for the request." }) - ], { mode: "oneOf" })) + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp when the event was created.\n", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "size": Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"]).annotate({ + "description": "The size of the generated image.\n" + }), + "quality": Schema.Literals(["low", "medium", "high", "auto"]).annotate({ + "description": "The quality setting for the generated image.\n" + }), + "background": Schema.Literals(["transparent", "opaque", "auto"]).annotate({ + "description": "The background setting for the generated image.\n" + }), + "output_format": Schema.Literals(["png", "webp", "jpeg"]).annotate({ + "description": "The output format for the generated image.\n" + }), + "usage": ImagesUsage }).annotate({ - "description": - "Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.\n" + "description": "Emitted when image generation has completed and the final image is available.\n", + "identifier": "ImageGenCompletedEvent" }) -export type CreateTranslationResponseVerboseJson = { - readonly "language": string - readonly "duration": number - readonly "text": string - readonly "segments"?: ReadonlyArray +export type ListModelsResponse = { readonly "object": "list"; readonly "data": ReadonlyArray } +export const ListModelsResponse = Schema.Struct({ "object": Schema.Literal("list"), "data": Schema.Array(Model) }) + .annotate({ "identifier": "ListModelsResponse" }) +export type ApiKeyList = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "first_id"?: string | null + readonly "last_id"?: string | null } -export const CreateTranslationResponseVerboseJson = Schema.Struct({ - "language": Schema.String.annotate({ "description": "The language of the output translation (always `english`)." }), - "duration": Schema.Number.annotate({ "description": "The duration of the input audio.", "format": "double" }).check( - Schema.isFinite() - ), - "text": Schema.String.annotate({ "description": "The translated text." }), - "segments": Schema.optionalKey( - Schema.Array(TranscriptionSegment).annotate({ - "description": "Segments of the translated text and their corresponding details." - }) +export const ApiKeyList = Schema.Struct({ + "object": Schema.Literal("list"), + "data": Schema.Array(AdminApiKey), + "has_more": Schema.Boolean, + "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +}).annotate({ "identifier": "ApiKeyList" }) +export type AuditLogActorSession = { readonly "user"?: AuditLogActorUser; readonly "ip_address"?: string } +export const AuditLogActorSession = Schema.Struct({ + "user": Schema.optionalKey(AuditLogActorUser), + "ip_address": Schema.optionalKey( + Schema.String.annotate({ "description": "The IP address from which the action was performed." }) ) +}).annotate({ + "description": "The session in which the audit logged action was performed.", + "identifier": "AuditLogActorSession" }) -export type CreateTranscriptionResponseVerboseJson = { - readonly "language": string - readonly "duration": number - readonly "text": string - readonly "words"?: ReadonlyArray - readonly "segments"?: ReadonlyArray - readonly "usage"?: TranscriptTextUsageDuration +export type AuditLogActorApiKey = { + readonly "id"?: string + readonly "type"?: "user" | "service_account" + readonly "user"?: AuditLogActorUser + readonly "service_account"?: AuditLogActorServiceAccount } -export const CreateTranscriptionResponseVerboseJson = Schema.Struct({ - "language": Schema.String.annotate({ "description": "The language of the input audio." }), - "duration": Schema.Number.annotate({ "description": "The duration of the input audio.", "format": "double" }).check( - Schema.isFinite() - ), - "text": Schema.String.annotate({ "description": "The transcribed text." }), - "words": Schema.optionalKey( - Schema.Array(TranscriptionWord).annotate({ "description": "Extracted words and their corresponding timestamps." }) - ), - "segments": Schema.optionalKey( - Schema.Array(TranscriptionSegment).annotate({ - "description": "Segments of the transcribed text and their corresponding details." +export const AuditLogActorApiKey = Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The tracking id of the API key." })), + "type": Schema.optionalKey( + Schema.Literals(["user", "service_account"]).annotate({ + "description": "The type of API key. Can be either `user` or `service_account`." }) ), - "usage": Schema.optionalKey(TranscriptTextUsageDuration) + "user": Schema.optionalKey(AuditLogActorUser), + "service_account": Schema.optionalKey(AuditLogActorServiceAccount) }).annotate({ - "description": "Represents a verbose json transcription response returned by model, based on the provided input." + "description": "The API Key used to perform the audit logged action.", + "identifier": "AuditLogActorApiKey" }) +export type ListCertificatesResponse = { + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "last_id": string | null + readonly "has_more": boolean + readonly "object": "list" +} +export const ListCertificatesResponse = Schema.Struct({ + "data": Schema.Array(OrganizationCertificate), + "first_id": Schema.Union([Schema.String, Schema.Null]), + "last_id": Schema.Union([Schema.String, Schema.Null]), + "has_more": Schema.Boolean, + "object": Schema.Literal("list") +}).annotate({ "identifier": "ListCertificatesResponse" }) +export type OrganizationCertificateActivationResponse = { + readonly "object": "organization.certificate.activation" + readonly "data": ReadonlyArray +} +export const OrganizationCertificateActivationResponse = Schema.Struct({ + "object": Schema.Literal("organization.certificate.activation").annotate({ + "description": "The organization certificate activation result type." + }), + "data": Schema.Array(OrganizationCertificate) +}).annotate({ "identifier": "OrganizationCertificateActivationResponse" }) +export type OrganizationCertificateDeactivationResponse = { + readonly "object": "organization.certificate.deactivation" + readonly "data": ReadonlyArray +} +export const OrganizationCertificateDeactivationResponse = Schema.Struct({ + "object": Schema.Literal("organization.certificate.deactivation").annotate({ + "description": "The organization certificate deactivation result type." + }), + "data": Schema.Array(OrganizationCertificate) +}).annotate({ "identifier": "OrganizationCertificateDeactivationResponse" }) export type UsageTimeBucket = { readonly "object": "bucket" readonly "start_time": number @@ -13570,8 +14596,8 @@ export type UsageTimeBucket = { } export const UsageTimeBucket = Schema.Struct({ "object": Schema.Literal("bucket"), - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.Number.check(Schema.isInt()), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), "results": Schema.Array( Schema.Union([ UsageCompletionsResult, @@ -13587,1485 +14613,1726 @@ export const UsageTimeBucket = Schema.Struct({ CostsResult ], { mode: "oneOf" }) ) -}) -export type UserListResponse = { +}).annotate({ "identifier": "UsageTimeBucket" }) +export type GroupListResource = { readonly "object": "list" - readonly "data": ReadonlyArray + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "next": string | null +} +export const GroupListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), + "data": Schema.Array(GroupResponse).annotate({ "description": "Groups returned in the current page." }), + "has_more": Schema.Boolean.annotate({ "description": "Whether additional groups are available when paginating." }), + "next": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Cursor to fetch the next page of results, or `null` if there are no more results." + }) +}).annotate({ "description": "Paginated list of organization groups.", "identifier": "GroupListResource" }) +export type RoleListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "next": string | null +} +export const RoleListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), + "data": Schema.Array(AssignedRoleDetails).annotate({ + "description": "Role assignments returned in the current page." + }), + "has_more": Schema.Boolean.annotate({ + "description": "Whether additional assignments are available when paginating." + }), + "next": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Cursor to fetch the next page of results, or `null` when there are no more assignments." + }) +}).annotate({ "description": "Paginated list of roles assigned to a principal.", "identifier": "RoleListResource" }) +export type GroupRoleAssignment = { readonly "object": "group.role"; readonly "group": Group; readonly "role": Role } +export const GroupRoleAssignment = Schema.Struct({ + "object": Schema.Literal("group.role").annotate({ "description": "Always `group.role`." }), + "group": Group, + "role": Role +}).annotate({ "description": "Role assignment linking a group to a role.", "identifier": "GroupRoleAssignment" }) +export type PublicRoleListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "next": string | null +} +export const PublicRoleListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), + "data": Schema.Array(Role).annotate({ "description": "Roles returned in the current page." }), + "has_more": Schema.Boolean.annotate({ "description": "Whether more roles are available when paginating." }), + "next": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Cursor to fetch the next page of results, or `null` when there are no additional roles." + }) +}).annotate({ + "description": "Paginated list of roles available on an organization or project.", + "identifier": "PublicRoleListResource" +}) +export type UserListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "next": string | null +} +export const UserListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), + "data": Schema.Array(GroupUser).annotate({ "description": "Users in the current page." }), + "has_more": Schema.Boolean.annotate({ "description": "Whether more users are available when paginating." }), + "next": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Cursor to fetch the next page of results, or `null` when no further users are available." + }) +}).annotate({ + "description": "Paginated list of user objects returned when inspecting group membership.", + "identifier": "UserListResource" +}) +export type InviteListResponse = { + readonly "object": "list" + readonly "data": ReadonlyArray readonly "first_id"?: string | null readonly "last_id"?: string | null readonly "has_more": boolean } -export const UserListResponse = Schema.Struct({ +export const InviteListResponse = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "The object type, which is always `list`" }), + "data": Schema.Array(Invite), + "first_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The first `invite_id` in the retrieved `list`" + }) + ), + "last_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The last `invite_id` in the retrieved `list`" + }) + ), + "has_more": Schema.Boolean.annotate({ + "description": "The `has_more` property is used for pagination to indicate there are additional results." + }) +}).annotate({ "identifier": "InviteListResponse" }) +export type ProjectListResponse = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id"?: string | null + readonly "last_id"?: string | null + readonly "has_more": boolean +} +export const ProjectListResponse = Schema.Struct({ "object": Schema.Literal("list"), - "data": Schema.Array(User), + "data": Schema.Array(Project), "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), "has_more": Schema.Boolean -}) -export type UserRoleAssignment = { readonly "object": "user.role"; readonly "user": User; readonly "role": Role } -export const UserRoleAssignment = Schema.Struct({ - "object": Schema.Literal("user.role").annotate({ "description": "Always `user.role`." }), - "user": User, - "role": Role -}).annotate({ "description": "Role assignment linking a user to a role." }) -export type CreateTranscriptionRequest = { - readonly "file": string - readonly "model": - | string - | "whisper-1" - | "gpt-4o-transcribe" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe-diarize" - readonly "language"?: string - readonly "prompt"?: string - readonly "response_format"?: AudioResponseFormat - readonly "temperature"?: number - readonly "include"?: ReadonlyArray - readonly "timestamp_granularities"?: ReadonlyArray<"word" | "segment"> - readonly "stream"?: boolean | null - readonly "chunking_strategy"?: "auto" | VadConfig | null - readonly "known_speaker_names"?: ReadonlyArray - readonly "known_speaker_references"?: ReadonlyArray +}).annotate({ "identifier": "ProjectListResponse" }) +export type ProjectApiKey = { + readonly "object": "organization.project.api_key" + readonly "redacted_value": string + readonly "name": string + readonly "created_at": number + readonly "last_used_at": number | null + readonly "id": string + readonly "owner_project_access": "active" | "inactive" + readonly "owner": { + readonly "type"?: "user" | "service_account" + readonly "user"?: ProjectApiKeyOwnerUser + readonly "service_account"?: ProjectApiKeyOwnerServiceAccount + } } -export const CreateTranscriptionRequest = Schema.Struct({ - "file": Schema.String.annotate({ - "description": - "The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.\n", - "format": "binary" +export const ProjectApiKey = Schema.Struct({ + "object": Schema.Literal("organization.project.api_key").annotate({ + "description": "The object type, which is always `organization.project.api_key`" }), - "model": Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-transcribe", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe-diarize" - ]) - ]).annotate({ - "description": - "ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.\n" + "redacted_value": Schema.String.annotate({ "description": "The redacted value of the API key" }), + "name": Schema.String.annotate({ "description": "The name of the API key" }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the API key was created", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "last_used_at": Schema.Union([ + Schema.Number.annotate({ "format": "unixtime" }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "The Unix timestamp (in seconds) of when the API key was last used." }), + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints" }), + "owner_project_access": Schema.Literals(["active", "inactive"]).annotate({ + "description": "Whether the API key's owner currently has effective access to the project." }), - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency.\n" + "owner": Schema.Struct({ + "type": Schema.optionalKey( + Schema.Literals(["user", "service_account"]).annotate({ "description": "`user` or `service_account`" }) + ), + "user": Schema.optionalKey(ProjectApiKeyOwnerUser), + "service_account": Schema.optionalKey(ProjectApiKeyOwnerServiceAccount) + }) +}).annotate({ "description": "Represents an individual API key in a project.", "identifier": "ProjectApiKey" }) +export type ListProjectCertificatesResponse = { + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "last_id": string | null + readonly "has_more": boolean + readonly "object": "list" +} +export const ListProjectCertificatesResponse = Schema.Struct({ + "data": Schema.Array(OrganizationProjectCertificate), + "first_id": Schema.Union([Schema.String, Schema.Null]), + "last_id": Schema.Union([Schema.String, Schema.Null]), + "has_more": Schema.Boolean, + "object": Schema.Literal("list") +}).annotate({ "identifier": "ListProjectCertificatesResponse" }) +export type OrganizationProjectCertificateActivationResponse = { + readonly "object": "organization.project.certificate.activation" + readonly "data": ReadonlyArray +} +export const OrganizationProjectCertificateActivationResponse = Schema.Struct({ + "object": Schema.Literal("organization.project.certificate.activation").annotate({ + "description": "The project certificate activation result type." + }), + "data": Schema.Array(OrganizationProjectCertificate) +}).annotate({ "identifier": "OrganizationProjectCertificateActivationResponse" }) +export type OrganizationProjectCertificateDeactivationResponse = { + readonly "object": "organization.project.certificate.deactivation" + readonly "data": ReadonlyArray +} +export const OrganizationProjectCertificateDeactivationResponse = Schema.Struct({ + "object": Schema.Literal("organization.project.certificate.deactivation").annotate({ + "description": "The project certificate deactivation result type." + }), + "data": Schema.Array(OrganizationProjectCertificate) +}).annotate({ "identifier": "OrganizationProjectCertificateDeactivationResponse" }) +export type ProjectGroupListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "next": string | null +} +export const ProjectGroupListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), + "data": Schema.Array(ProjectGroup).annotate({ + "description": "Project group memberships returned in the current page." + }), + "has_more": Schema.Boolean.annotate({ "description": "Whether additional project group memberships are available." }), + "next": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Cursor to fetch the next page of results, or `null` when there are no more results." + }) +}).annotate({ + "description": "Paginated list of groups that have access to a project.", + "identifier": "ProjectGroupListResource" +}) +export type ProjectHostedToolPermissions = { + readonly "file_search": HostedToolPermission + readonly "web_search": HostedToolPermission + readonly "image_generation": HostedToolPermission + readonly "mcp": HostedToolPermission + readonly "code_interpreter": HostedToolPermission +} +export const ProjectHostedToolPermissions = Schema.Struct({ + "file_search": HostedToolPermission, + "web_search": HostedToolPermission, + "image_generation": HostedToolPermission, + "mcp": HostedToolPermission, + "code_interpreter": HostedToolPermission +}).annotate({ + "description": "Represents hosted tool permissions for a project.", + "identifier": "ProjectHostedToolPermissions" +}) +export type ProjectHostedToolPermissionsUpdateRequest = { + readonly "file_search"?: HostedToolPermissionUpdate | null + readonly "web_search"?: HostedToolPermissionUpdate | null + readonly "image_generation"?: HostedToolPermissionUpdate | null + readonly "mcp"?: HostedToolPermissionUpdate | null + readonly "code_interpreter"?: HostedToolPermissionUpdate | null +} +export const ProjectHostedToolPermissionsUpdateRequest = Schema.Struct({ + "file_search": Schema.optionalKey( + Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ + "description": "The file search permission update." }) ), - "prompt": Schema.optionalKey( - Schema.String.annotate({ - "description": - "An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`.\n" + "web_search": Schema.optionalKey( + Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ + "description": "The web search permission update." }) ), - "response_format": Schema.optionalKey(AudioResponseFormat), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.\n" - }).check(Schema.isFinite()) - ), - "include": Schema.optionalKey( - Schema.Array(TranscriptionInclude).annotate({ - "description": - "Additional information to include in the transcription response.\n`logprobs` will return the log probabilities of the tokens in the\nresponse to understand the model's confidence in the transcription.\n`logprobs` only works with response_format set to `json` and only with\nthe models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`.\n" - }) - ), - "timestamp_granularities": Schema.optionalKey( - Schema.Array(Schema.Literals(["word", "segment"])).annotate({ - "description": - "The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.\nThis option is not available for `gpt-4o-transcribe-diarize`.\n" + "image_generation": Schema.optionalKey( + Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ + "description": "The image generation permission update." }) ), - "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 of the Speech-to-Text guide](/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)\nfor more information.\n\nNote: Streaming is not supported for the `whisper-1` model and will be ignored.\n" - }), - Schema.Null - ])), - "chunking_strategy": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Literal("auto").annotate({ - "description": "Automatically set chunking parameters based on the audio. Must be set to `\"auto\"`.\n" - }), - VadConfig - ]).annotate({ - "description": - "Controls how the audio is cut into chunks. When set to `\"auto\"`, the server first normalizes loudness and then uses voice activity detection (VAD) to choose boundaries. `server_vad` object can be provided to tweak VAD detection parameters manually. If unset, the audio is transcribed as a single block. Required when using `gpt-4o-transcribe-diarize` for inputs longer than 30 seconds. " - }), - Schema.Null - ]) - ), - "known_speaker_names": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported.\n" - }).check(Schema.isMaxLength(4)) + "mcp": Schema.optionalKey( + Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ "description": "The MCP permission update." }) ), - "known_speaker_references": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`.\n" - }).check(Schema.isMaxLength(4)) + "code_interpreter": Schema.optionalKey( + Schema.Union([HostedToolPermissionUpdate, Schema.Null]).annotate({ + "description": "The code interpreter permission update." + }) ) -}) -export type CreateVectorStoreRequest = { - readonly "file_ids"?: ReadonlyArray - readonly "name"?: string - readonly "description"?: string - readonly "expires_after"?: VectorStoreExpirationAfter - readonly "chunking_strategy"?: { readonly "type": "auto" } | { - readonly "type": "static" - readonly "static": StaticChunkingStrategy - } - readonly "metadata"?: Metadata +}).annotate({ "identifier": "ProjectHostedToolPermissionsUpdateRequest" }) +export type ProjectRateLimitListResponse = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id"?: string | null + readonly "last_id"?: string | null + readonly "has_more": boolean } -export const CreateVectorStoreRequest = Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files." - }).check(Schema.isMaxLength(500)) - ), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the vector store." })), - "description": Schema.optionalKey( - Schema.String.annotate({ - "description": "A description for the vector store. Can be used to describe the vector store's purpose." - }) - ), - "expires_after": Schema.optionalKey(VectorStoreExpirationAfter), - "chunking_strategy": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }).annotate({ - "title": "Auto Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty." - }), - Schema.Struct({ - "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), - "static": StaticChunkingStrategy - }).annotate({ - "title": "Static Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty." - }) - ], { mode: "oneOf" }) - ), - "metadata": Schema.optionalKey(Metadata) -}) -export type VectorStoreObject = { +export const ProjectRateLimitListResponse = Schema.Struct({ + "object": Schema.Literal("list"), + "data": Schema.Array(ProjectRateLimit), + "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "has_more": Schema.Boolean +}).annotate({ "identifier": "ProjectRateLimitListResponse" }) +export type ProjectServiceAccountListResponse = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id"?: string | null + readonly "last_id"?: string | null + readonly "has_more": boolean +} +export const ProjectServiceAccountListResponse = Schema.Struct({ + "object": Schema.Literal("list"), + "data": Schema.Array(ProjectServiceAccount), + "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "has_more": Schema.Boolean +}).annotate({ "identifier": "ProjectServiceAccountListResponse" }) +export type ProjectServiceAccountCreateResponse = { + readonly "object": "organization.project.service_account" readonly "id": string - readonly "object": "vector_store" - readonly "created_at": number readonly "name": string - readonly "usage_bytes": number - readonly "file_counts": { - readonly "in_progress": number - readonly "completed": number - readonly "failed": number - readonly "cancelled": number - readonly "total": number - } - readonly "status": "expired" | "in_progress" | "completed" - readonly "expires_after"?: VectorStoreExpirationAfter - readonly "expires_at"?: number | null - readonly "last_active_at": number | null - readonly "metadata": Metadata + readonly "role": "member" | "none" + readonly "created_at": number + readonly "api_key": ProjectServiceAccountApiKey | null } -export const VectorStoreObject = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), - "object": Schema.Literal("vector_store").annotate({ - "description": "The object type, which is always `vector_store`." - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the vector store was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "name": Schema.String.annotate({ "description": "The name of the vector store." }), - "usage_bytes": Schema.Number.annotate({ - "description": "The total number of bytes used by the files in the vector store." - }).check(Schema.isInt()), - "file_counts": Schema.Struct({ - "in_progress": Schema.Number.annotate({ "description": "The number of files that are currently being processed." }) - .check(Schema.isInt()), - "completed": Schema.Number.annotate({ "description": "The number of files that have been successfully processed." }) - .check(Schema.isInt()), - "failed": Schema.Number.annotate({ "description": "The number of files that have failed to process." }).check( - Schema.isInt() - ), - "cancelled": Schema.Number.annotate({ "description": "The number of files that were cancelled." }).check( - Schema.isInt() - ), - "total": Schema.Number.annotate({ "description": "The total number of files." }).check(Schema.isInt()) - }), - "status": Schema.Literals(["expired", "in_progress", "completed"]).annotate({ +export const ProjectServiceAccountCreateResponse = Schema.Struct({ + "object": Schema.Literal("organization.project.service_account"), + "id": Schema.String, + "name": Schema.String, + "role": Schema.Literals(["member", "none"]).annotate({ "description": - "The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use." + "Service accounts created with default project membership have role `member`. Accounts created with `create_service_account_only` have role `none`.\n" }), - "expires_after": Schema.optionalKey(VectorStoreExpirationAfter), - "expires_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the vector store will expire.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]) + "created_at": Schema.Number.annotate({ "format": "unixtime" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "last_active_at": Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the vector store was last active.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]), - "metadata": Metadata -}).annotate({ - "title": "Vector store", - "description": "A vector store is a collection of processed files can be used by the `file_search` tool." -}) -export type FileSearchToolCall = { + "api_key": Schema.Union([ProjectServiceAccountApiKey, Schema.Null]) +}).annotate({ "identifier": "ProjectServiceAccountCreateResponse" }) +export type ProjectSpendAlert = { readonly "id": string - readonly "type": "file_search_call" - readonly "status": "in_progress" | "searching" | "completed" | "incomplete" | "failed" - readonly "queries": ReadonlyArray - readonly "results"?: - | ReadonlyArray< - { - readonly "file_id"?: string - readonly "text"?: string - readonly "filename"?: string - readonly "attributes"?: VectorStoreFileAttributes - readonly "score"?: number - } - > - | null + readonly "object": "project.spend_alert" + readonly "threshold_amount": number + readonly "currency": "USD" + readonly "interval": "month" + readonly "notification_channel": SpendAlertNotificationChannel } -export const FileSearchToolCall = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the file search tool call.\n" }), - "type": Schema.Literal("file_search_call").annotate({ - "description": "The type of the file search tool call. Always `file_search_call`.\n" +export const ProjectSpendAlert = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), + "object": Schema.Literal("project.spend_alert").annotate({ + "description": "The object type, which is always `project.spend_alert`." }), - "status": Schema.Literals(["in_progress", "searching", "completed", "incomplete", "failed"]).annotate({ - "description": - "The status of the file search tool call. One of `in_progress`,\n`searching`, `incomplete` or `failed`,\n" + "threshold_amount": Schema.Number.annotate({ "description": "The alert threshold amount, in cents." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "currency": Schema.Literal("USD").annotate({ "description": "The currency for the threshold amount." }), + "interval": Schema.Literal("month").annotate({ + "description": "The time interval for evaluating spend against the threshold." }), - "queries": Schema.Array(Schema.String).annotate({ "description": "The queries used to search for files.\n" }), - "results": Schema.optionalKey(Schema.Union([ - Schema.Array(Schema.Struct({ - "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the file.\n" })), - "text": Schema.optionalKey( - Schema.String.annotate({ "description": "The text that was retrieved from the file.\n" }) - ), - "filename": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the file.\n" })), - "attributes": Schema.optionalKey(VectorStoreFileAttributes), - "score": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The relevance score of the file - a value between 0 and 1.\n", - "format": "float" - }).check(Schema.isFinite()) - ) - })).annotate({ "description": "The results of the file search tool call.\n" }), - Schema.Null - ])) + "notification_channel": SpendAlertNotificationChannel }).annotate({ - "title": "File search tool call", - "description": - "The results of a file search tool call. See the\n[file search guide](/docs/guides/tools-file-search) for more information.\n" + "description": "Represents a spend alert configured at the project level.", + "identifier": "ProjectSpendAlert" +}) +export type CreateSpendAlertBody = { + readonly "threshold_amount": number + readonly "currency": "USD" + readonly "interval": "month" + readonly "notification_channel": SpendAlertNotificationChannel +} +export const CreateSpendAlertBody = Schema.Struct({ + "threshold_amount": Schema.Number.annotate({ "description": "The alert threshold amount, in cents." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })), + "currency": Schema.Literal("USD").annotate({ "description": "The currency for the threshold amount." }), + "interval": Schema.Literal("month").annotate({ + "description": "The time interval for evaluating spend against the threshold." + }), + "notification_channel": SpendAlertNotificationChannel +}).annotate({ + "description": "Parameters for creating or updating a spend alert.", + "identifier": "CreateSpendAlertBody" }) -export type UpdateVectorStoreFileAttributesRequest = { readonly "attributes": VectorStoreFileAttributes } -export const UpdateVectorStoreFileAttributesRequest = Schema.Struct({ "attributes": VectorStoreFileAttributes }) -export type VectorStoreFileObject = { +export type OrganizationSpendAlert = { readonly "id": string - readonly "object": "vector_store.file" - readonly "usage_bytes": number - readonly "created_at": number - readonly "vector_store_id": string - readonly "status": "in_progress" | "completed" | "cancelled" | "failed" - readonly "last_error": { - readonly "code": "server_error" | "unsupported_file" | "invalid_file" - readonly "message": string - } | null - readonly "chunking_strategy"?: { readonly "type": "static"; readonly "static": StaticChunkingStrategy } | { - readonly "type": "other" - } - readonly "attributes"?: VectorStoreFileAttributes + readonly "object": "organization.spend_alert" + readonly "threshold_amount": number + readonly "currency": "USD" + readonly "interval": "month" + readonly "notification_channel": SpendAlertNotificationChannel } -export const VectorStoreFileObject = Schema.Struct({ +export const OrganizationSpendAlert = Schema.Struct({ "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), - "object": Schema.Literal("vector_store.file").annotate({ - "description": "The object type, which is always `vector_store.file`." - }), - "usage_bytes": Schema.Number.annotate({ - "description": "The total vector store usage in bytes. Note that this may be different from the original file size." - }).check(Schema.isInt()), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the vector store file was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "vector_store_id": Schema.String.annotate({ - "description": - "The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to." + "object": Schema.Literal("organization.spend_alert").annotate({ + "description": "The object type, which is always `organization.spend_alert`." }), - "status": Schema.Literals(["in_progress", "completed", "cancelled", "failed"]).annotate({ - "description": - "The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use." + "threshold_amount": Schema.Number.annotate({ "description": "The alert threshold amount, in cents." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "currency": Schema.Literal("USD").annotate({ "description": "The currency for the threshold amount." }), + "interval": Schema.Literal("month").annotate({ + "description": "The time interval for evaluating spend against the threshold." }), - "last_error": Schema.Union([ - Schema.Struct({ - "code": Schema.Literals(["server_error", "unsupported_file", "invalid_file"]).annotate({ - "description": "One of `server_error`, `unsupported_file`, or `invalid_file`." - }), - "message": Schema.String.annotate({ "description": "A human-readable description of the error." }) - }).annotate({ - "description": "The last error associated with this vector store file. Will be `null` if there are no errors." - }), - Schema.Null - ]), - "chunking_strategy": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), - "static": StaticChunkingStrategy - }).annotate({ "title": "Static Chunking Strategy", "description": "The strategy used to chunk the file." }), - Schema.Struct({ "type": Schema.Literal("other").annotate({ "description": "Always `other`." }) }).annotate({ - "title": "Other Chunking Strategy", - "description": "The strategy used to chunk the file." - }) - ], { mode: "oneOf" }) - ), - "attributes": Schema.optionalKey(VectorStoreFileAttributes) -}).annotate({ "title": "Vector store files", "description": "A list of files attached to a vector store." }) -export type VectorStoreSearchResultItem = { - readonly "file_id": string - readonly "filename": string - readonly "score": number - readonly "attributes": VectorStoreFileAttributes - readonly "content": ReadonlyArray -} -export const VectorStoreSearchResultItem = Schema.Struct({ - "file_id": Schema.String.annotate({ "description": "The ID of the vector store file." }), - "filename": Schema.String.annotate({ "description": "The name of the vector store file." }), - "score": Schema.Number.annotate({ "description": "The similarity score for the result." }).check(Schema.isFinite()) - .check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)), - "attributes": VectorStoreFileAttributes, - "content": Schema.Array(VectorStoreSearchResultContentObject).annotate({ - "description": "Content chunks from the file." - }) + "notification_channel": SpendAlertNotificationChannel +}).annotate({ + "description": "Represents a spend alert configured at the organization level.", + "identifier": "OrganizationSpendAlert" }) -export type VoiceConsentListResource = { +export type ProjectUserListResponse = { + readonly "object": string + readonly "data": ReadonlyArray + readonly "first_id"?: string | null + readonly "last_id"?: string | null + readonly "has_more": boolean +} +export const ProjectUserListResponse = Schema.Struct({ + "object": Schema.String, + "data": Schema.Array(ProjectUser), + "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "has_more": Schema.Boolean +}).annotate({ "identifier": "ProjectUserListResponse" }) +export type UserListResponse = { readonly "object": "list" - readonly "data": ReadonlyArray + readonly "data": ReadonlyArray readonly "first_id"?: string | null readonly "last_id"?: string | null readonly "has_more": boolean } -export const VoiceConsentListResource = Schema.Struct({ +export const UserListResponse = Schema.Struct({ "object": Schema.Literal("list"), - "data": Schema.Array(VoiceConsentResource), + "data": Schema.Array(User), "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), "has_more": Schema.Boolean -}) -export type CreateSpeechRequest = { - readonly "model": string | "tts-1" | "tts-1-hd" | "gpt-4o-mini-tts" | "gpt-4o-mini-tts-2025-12-15" - readonly "input": string - readonly "instructions"?: string - readonly "voice": VoiceIdsShared | { readonly "id": string } - readonly "response_format"?: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm" - readonly "speed"?: number - readonly "stream_format"?: "sse" | "audio" -} -export const CreateSpeechRequest = Schema.Struct({ - "model": Schema.Union([ - Schema.String, - Schema.Literals(["tts-1", "tts-1-hd", "gpt-4o-mini-tts", "gpt-4o-mini-tts-2025-12-15"]) - ]).annotate({ - "description": - "One of the available [TTS models](/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.\n" - }), - "input": Schema.String.annotate({ - "description": "The text to generate audio for. The maximum length is 4096 characters." - }).check(Schema.isMaxLength(4096)), - "instructions": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`." - }).check(Schema.isMaxLength(4096)) - ), - "voice": Schema.Union([ - VoiceIdsShared, - Schema.Struct({ "id": Schema.String.annotate({ "description": "The custom voice ID, e.g. `voice_1234`." }) }) - .annotate({ "description": "Custom voice reference." }) - ]).annotate({ - "title": "Voice", - "description": - "The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ \"id\": \"voice_1234\" }`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech#voice-options)." - }), - "response_format": Schema.optionalKey( - Schema.Literals(["mp3", "opus", "aac", "flac", "wav", "pcm"]).annotate({ - "description": "The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`." - }) - ), - "speed": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default." - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0.25)).check(Schema.isLessThanOrEqualTo(4)) - ), - "stream_format": Schema.optionalKey( - Schema.Literals(["sse", "audio"]).annotate({ - "description": - "The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`." - }) - ) -}) -export type RealtimeSessionCreateResponse = { - readonly "id"?: string - readonly "object"?: string - readonly "expires_at"?: number - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> - readonly "model"?: string - readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> - readonly "instructions"?: string - readonly "audio"?: { - readonly "input"?: { - readonly "format"?: RealtimeAudioFormats - readonly "transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - } - readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "turn_detection"?: { - readonly "type"?: string - readonly "threshold"?: number - readonly "prefix_padding_ms"?: number - readonly "silence_duration_ms"?: number - } - } - readonly "output"?: { - readonly "format"?: RealtimeAudioFormats - readonly "voice"?: VoiceIdsShared - readonly "speed"?: number - } - } - readonly "tracing"?: "auto" | { - readonly "workflow_name"?: string - readonly "group_id"?: string - readonly "metadata"?: {} - } +}).annotate({ "identifier": "UserListResponse" }) +export type UserRoleAssignment = { readonly "object": "user.role"; readonly "user": User; readonly "role": Role } +export const UserRoleAssignment = Schema.Struct({ + "object": Schema.Literal("user.role").annotate({ "description": "Always `user.role`." }), + "user": User, + "role": Role +}).annotate({ "description": "Role assignment linking a user to a role.", "identifier": "UserRoleAssignment" }) +export type RealtimeTranscriptionSessionCreateRequest = { readonly "turn_detection"?: { - readonly "type"?: string + readonly "type"?: "server_vad" readonly "threshold"?: number readonly "prefix_padding_ms"?: number readonly "silence_duration_ms"?: number } - readonly "tools"?: ReadonlyArray - readonly "tool_choice"?: string - readonly "max_output_tokens"?: number | "inf" + readonly "input_audio_noise_reduction"?: { readonly "type"?: NoiseReductionType } + readonly "input_audio_format"?: "pcm16" | "g711_ulaw" | "g711_alaw" + readonly "input_audio_transcription"?: AudioTranscription + readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> } -export const RealtimeSessionCreateResponse = Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ - "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" - }) - ), - "object": Schema.optionalKey( - Schema.String.annotate({ "description": "The object type. Always `realtime.session`." }) - ), - "expires_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Expiration timestamp for the session, in seconds since epoch.", - "format": "unixtime" - }).check(Schema.isInt()) - ), - "include": Schema.optionalKey( - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ - "description": - "Additional fields to include in server outputs.\n- `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" - }) - ), - "model": Schema.optionalKey(Schema.String.annotate({ "description": "The Realtime model used for this session." })), - "output_modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": "The set of modalities the model can respond with. To disable audio,\nset this to [\"text\"].\n" - }) - ), - "instructions": Schema.optionalKey(Schema.String.annotate({ - "description": - "The default system instructions (i.e. system message) prepended to model\ncalls. This field allows the client to guide the model on desired\nresponses. The model can be instructed on response content and format,\n(e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good\nresponses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion\ninto your voice\", \"laugh frequently\"). The instructions are not guaranteed\nto be followed by the model, but they provide guidance to the model on the\ndesired behavior.\n\nNote that the server sets default instructions which will be used if this\nfield is not set and are visible in the `session.created` event at the\nstart of the session.\n" - })), - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey(RealtimeAudioFormats), - "transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model used for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.\n" - }) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ "description": "The language of the input audio.\n" }) - ), - "prompt": Schema.optionalKey( - Schema.String.annotate({ - "description": "The prompt configured for input audio transcription, when present.\n" - }) - ) - }).annotate({ "description": "Configuration for input audio transcription.\n" }) - ), - "noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": "Configuration for input audio noise reduction.\n" - }) - ), - "turn_detection": Schema.optionalKey( - Schema.Struct({ - "type": Schema.optionalKey( - Schema.String.annotate({ - "description": "Type of turn detection, only `server_vad` is currently supported.\n" - }) - ), - "threshold": Schema.optionalKey(Schema.Number.check(Schema.isFinite())), - "prefix_padding_ms": Schema.optionalKey(Schema.Number.check(Schema.isInt())), - "silence_duration_ms": Schema.optionalKey(Schema.Number.check(Schema.isInt())) - }).annotate({ "description": "Configuration for turn detection.\n" }) - ) - })), - "output": Schema.optionalKey( - Schema.Struct({ - "format": Schema.optionalKey(RealtimeAudioFormats), - "voice": Schema.optionalKey(VoiceIdsShared), - "speed": Schema.optionalKey(Schema.Number.check(Schema.isFinite())) - }) - ) - }).annotate({ "description": "Configuration for input and output audio for the session.\n" }) - ), - "tracing": Schema.optionalKey( - Schema.Union([ - Schema.Literal("auto").annotate({ "description": "Default tracing mode for the session.\n" }), - Schema.Struct({ - "workflow_name": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The name of the workflow to attach to this trace. This is used to\nname the trace in the traces dashboard.\n" - }) - ), - "group_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The group id to attach to this trace to enable filtering and\ngrouping in the traces dashboard.\n" - }) - ), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "The arbitrary metadata to attach to this trace to enable\nfiltering in the traces dashboard.\n" - }) - ) - }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) - ], { mode: "oneOf" }).annotate({ - "title": "Tracing Configuration", - "description": - "Configuration options for tracing. Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" - }) - ), +export const RealtimeTranscriptionSessionCreateRequest = Schema.Struct({ "turn_detection": Schema.optionalKey( Schema.Struct({ "type": Schema.optionalKey( - Schema.String.annotate({ "description": "Type of turn detection, only `server_vad` is currently supported.\n" }) + Schema.Literal("server_vad").annotate({ + "description": + "Type of turn detection. Only `server_vad` is currently supported for transcription sessions.\n" + }) ), "threshold": Schema.optionalKey( Schema.Number.annotate({ "description": "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" - }).check(Schema.isFinite()) + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), "prefix_padding_ms": Schema.optionalKey( Schema.Number.annotate({ "description": "Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "silence_duration_ms": Schema.optionalKey( Schema.Number.annotate({ "description": "Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ) }).annotate({ "description": - "Configuration for turn detection. Can be set to `null` to turn off. Server\nVAD means that the model will detect the start and end of speech based on\naudio volume and respond at the end of user speech.\n" + "Configuration for turn detection. Can be set to `null` to turn off. Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.\n" }) ), - "tools": Schema.optionalKey( - Schema.Array(RealtimeFunctionTool).annotate({ "description": "Tools (functions) available to the model." }) - ), - "tool_choice": Schema.optionalKey( - Schema.String.annotate({ - "description": "How the model chooses tools. Options are `auto`, `none`, `required`, or\nspecify a function.\n" + "input_audio_noise_reduction": Schema.optionalKey( + Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ + "description": + "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" }) ), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ + "input_audio_format": Schema.optionalKey( + Schema.Literals(["pcm16", "g711_ulaw", "g711_alaw"]).annotate({ "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" + "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\nFor `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate,\nsingle channel (mono), and little-endian byte order.\n" + }) + ), + "input_audio_transcription": Schema.optionalKey( + Schema.suspend((): Schema.Codec => AudioTranscription).annotate({ + "description": + "Configuration for input audio transcription. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" + }) + ), + "include": Schema.optionalKey( + Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ + "description": + "The set of items to include in the transcription. Current available items are:\n`item.input_audio_transcription.logprobs`\n" }) ) }).annotate({ - "title": "Realtime session configuration object", - "description": "A Realtime session configuration object.\n" + "title": "Realtime transcription session configuration", + "description": "Realtime transcription session object configuration.", + "identifier": "RealtimeTranscriptionSessionCreateRequest" }) -export type WebSearchTool = { - readonly "type": "web_search" | "web_search_2025_08_26" - readonly "filters"?: { readonly "allowed_domains"?: ReadonlyArray | null } | null - readonly "user_location"?: WebSearchApproximateLocation - readonly "search_context_size"?: "low" | "medium" | "high" +export type RealtimeTranslationSessionCreateRequest = { + readonly "model": string + readonly "audio"?: { + readonly "input"?: { + readonly "transcription"?: { readonly "model": string } | null + readonly "noise_reduction"?: { readonly "type": NoiseReductionType } | null + } + readonly "output"?: { readonly "language"?: string } + } } -export const WebSearchTool = Schema.Struct({ - "type": Schema.Literals(["web_search", "web_search_2025_08_26"]).annotate({ - "description": "The type of the web search tool. One of `web_search` or `web_search_2025_08_26`." - }), - "filters": Schema.optionalKey(Schema.Union([ +export const RealtimeTranslationSessionCreateRequest = Schema.Struct({ + "model": Schema.String.annotate({ "description": "The Realtime translation model used for this session.\n" }), + "audio": Schema.optionalKey( Schema.Struct({ - "allowed_domains": Schema.optionalKey( + "input": Schema.optionalKey(Schema.Struct({ + "transcription": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "model": Schema.String.annotate({ + "description": "The transcription model to use for source transcript deltas." + }) + }).annotate({ + "description": + "Optional source-language transcription. When configured, the server emits\n`session.input_transcript.delta` events. Translation itself still runs from\nthe input audio stream.\n" + }), + Schema.Null + ]) + ), + "noise_reduction": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": NoiseReductionType }).annotate({ + "description": "Optional input noise reduction. Set to `null` to disable it.\n" + }), + Schema.Null + ]) + ) + })), + "output": Schema.optionalKey( + Schema.Struct({ + "language": Schema.optionalKey( + Schema.String.annotate({ + "description": "Target language for translated output audio and transcript deltas.\n" + }) + ) + }) + ) + }).annotate({ "description": "Configuration for translation input and output audio.\n" }) + ) +}).annotate({ + "title": "Realtime translation session configuration", + "description": + "Realtime translation session configuration. Translation sessions stream source\naudio in and translated audio plus transcript deltas out continuously.\n", + "identifier": "RealtimeTranslationSessionCreateRequest" +}) +export type RealtimeTranslationSession = { + readonly "id": string + readonly "type": "translation" + readonly "expires_at": number + readonly "model": string + readonly "audio": { + readonly "input"?: { + readonly "transcription"?: { readonly "model": string } | null + readonly "noise_reduction"?: { readonly "type": NoiseReductionType } | null + } + readonly "output"?: { readonly "language"?: string } + } +} +export const RealtimeTranslationSession = Schema.Struct({ + "id": Schema.String.annotate({ + "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" + }), + "type": Schema.Literal("translation").annotate({ + "description": "The session type. Always `translation` for Realtime translation sessions.\n" + }), + "expires_at": Schema.Number.annotate({ + "description": "Expiration timestamp for the session, in seconds since epoch.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "model": Schema.String.annotate({ + "description": + "The Realtime translation model used for this session. This field is set at\nsession creation and cannot be changed with `session.update`.\n" + }), + "audio": Schema.Struct({ + "input": Schema.optionalKey(Schema.Struct({ + "transcription": Schema.optionalKey( Schema.Union([ - Schema.Array(Schema.String.annotate({ "description": "Allowed domain for the search." })).annotate({ - "title": "Allowed domains for the search.", + Schema.Struct({ + "model": Schema.String.annotate({ + "description": "The transcription model used for source transcript deltas." + }) + }).annotate({ "description": - "Allowed domains for the search. If not provided, all domains are allowed.\nSubdomains of the provided domains are allowed as well.\n\nExample: `[\"pubmed.ncbi.nlm.nih.gov\"]`\n" + "Optional source-language transcription. When configured, the server emits\n`session.input_transcript.delta` events. Translation itself still runs from\nthe input audio stream.\n" + }), + Schema.Null + ]) + ), + "noise_reduction": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": NoiseReductionType }).annotate({ + "description": "Optional input noise reduction.\n" }), Schema.Null ]) ) - }).annotate({ "description": "Filters for the search.\n" }), - Schema.Null - ])), - "user_location": Schema.optionalKey(WebSearchApproximateLocation), - "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." - }) - ) + })), + "output": Schema.optionalKey( + Schema.Struct({ + "language": Schema.optionalKey( + Schema.String.annotate({ + "description": "Target language for translated output audio and transcript deltas.\n" + }) + ) + }) + ) + }).annotate({ "description": "Configuration for translation input and output audio.\n" }) }).annotate({ - "title": "Web search", + "title": "Realtime translation session", "description": - "Search the Internet for sources related to the prompt. Learn more about the\n[web search tool](/docs/guides/tools-web-search).\n" + "A Realtime translation session. Translation sessions continuously translate input\naudio into the configured output language.\n", + "identifier": "RealtimeTranslationSession" }) -export type ContainerNetworkPolicyAllowlistParam = { - readonly "type": "allowlist" - readonly "allowed_domains": ReadonlyArray - readonly "domain_secrets"?: ReadonlyArray +export type RealtimeTranscriptionSessionCreateRequestGA = { + readonly "type": "transcription" + readonly "audio"?: { + readonly "input"?: { + readonly "format"?: RealtimeAudioFormats + readonly "transcription"?: AudioTranscription + readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } + readonly "turn_detection"?: RealtimeTurnDetection + } + } + readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> } -export const ContainerNetworkPolicyAllowlistParam = Schema.Struct({ - "type": Schema.Literal("allowlist").annotate({ - "description": "Allow outbound network access only to specified domains. Always `allowlist`." +export const RealtimeTranscriptionSessionCreateRequestGA = Schema.Struct({ + "type": Schema.Literal("transcription").annotate({ + "description": "The type of session to create. Always `transcription` for transcription sessions.\n" }), - "allowed_domains": Schema.Array(Schema.String).annotate({ - "description": "A list of allowed domains when type is `allowlist`." - }).check(Schema.isMinLength(1)), - "domain_secrets": Schema.optionalKey( - Schema.Array(ContainerNetworkPolicyDomainSecretParam).annotate({ - "description": "Optional domain-scoped secrets for allowlisted domains." - }).check(Schema.isMinLength(1)) - ) -}) -export type EvalItemContentItem = - | EvalItemContentText - | InputTextContent - | EvalItemContentOutputText - | EvalItemInputImage - | InputAudio -export const EvalItemContentItem = Schema.Union([ - EvalItemContentText, - InputTextContent, - EvalItemContentOutputText, - EvalItemInputImage, - InputAudio -], { mode: "oneOf" }).annotate({ - "title": "Eval content item", - "description": "A single content item: input text, output text, input image, or input audio.\n" -}) -export type Annotation = FileCitationBody | UrlCitationBody | ContainerFileCitationBody | FilePath -export const Annotation = Schema.Union([FileCitationBody, UrlCitationBody, ContainerFileCitationBody, FilePath], { - mode: "oneOf" -}).annotate({ "description": "An annotation that applies to a span of output text." }) -export type LogProb = { - readonly "token": string - readonly "logprob": number - readonly "bytes": ReadonlyArray - readonly "top_logprobs": ReadonlyArray -} -export const LogProb = Schema.Struct({ - "token": Schema.String, - "logprob": Schema.Number.check(Schema.isFinite()), - "bytes": Schema.Array(Schema.Number.check(Schema.isInt())), - "top_logprobs": Schema.Array(TopLogProb) -}).annotate({ "title": "Log probability", "description": "The log probability of a token." }) -export type ReasoningItem = { - readonly "type": "reasoning" - readonly "id": string - readonly "encrypted_content"?: string | null - readonly "summary": ReadonlyArray - readonly "content"?: ReadonlyArray - readonly "status"?: "in_progress" | "completed" | "incomplete" -} -export const ReasoningItem = Schema.Struct({ - "type": Schema.Literal("reasoning").annotate({ "description": "The type of the object. Always `reasoning`.\n" }), - "id": Schema.String.annotate({ "description": "The unique identifier of the reasoning content.\n" }), - "encrypted_content": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The encrypted content of the reasoning item - populated when a response is\ngenerated with `reasoning.encrypted_content` in the `include` parameter.\n" - }), - Schema.Null - ]) - ), - "summary": Schema.Array(SummaryTextContent).annotate({ "description": "Reasoning summary content.\n" }), - "content": Schema.optionalKey( - Schema.Array(ReasoningTextContent).annotate({ "description": "Reasoning text content.\n" }) + "audio": Schema.optionalKey( + Schema.Struct({ + "input": Schema.optionalKey(Schema.Struct({ + "format": Schema.optionalKey(RealtimeAudioFormats), + "transcription": Schema.optionalKey( + Schema.suspend((): Schema.Codec => AudioTranscription).annotate({ + "description": + "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" + }) + ), + "noise_reduction": Schema.optionalKey( + Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ + "description": + "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" + }) + ), + "turn_detection": Schema.optionalKey(RealtimeTurnDetection) + })) + }).annotate({ "description": "Configuration for input and output audio.\n" }) ), - "status": Schema.optionalKey( - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "include": Schema.optionalKey( + Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + "Additional fields to include in server outputs.\n\n`item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" }) ) }).annotate({ - "title": "Reasoning", - "description": - "A description of the chain of thought used by a reasoning model while generating\na response. Be sure to include these items in your `input` to the Responses API\nfor subsequent turns of a conversation if you are manually\n[managing context](/docs/guides/conversation-state).\n" + "title": "Realtime transcription session configuration", + "description": "Realtime transcription session object configuration.", + "identifier": "RealtimeTranscriptionSessionCreateRequestGA" }) -export type FunctionAndCustomToolCallOutput = InputTextContent | InputImageContent | InputFileContent -export const FunctionAndCustomToolCallOutput = Schema.Union([InputTextContent, InputImageContent, InputFileContent], { - mode: "oneOf" +export type RealtimeReasoning = { readonly "effort"?: RealtimeReasoningEffort } +export const RealtimeReasoning = Schema.Struct({ "effort": Schema.optionalKey(RealtimeReasoningEffort) }).annotate({ + "title": "Realtime reasoning configuration", + "description": "Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.\n", + "identifier": "RealtimeReasoning" }) -export type InputContent = InputTextContent | InputImageContent | InputFileContent -export const InputContent = Schema.Union([InputTextContent, InputImageContent, InputFileContent], { mode: "oneOf" }) -export type DragParam = { - readonly "type": "drag" - readonly "path": ReadonlyArray - readonly "keys"?: ReadonlyArray | null -} -export const DragParam = Schema.Struct({ - "type": Schema.Literal("drag").annotate({ - "description": "Specifies the event type. For a drag action, this property is always set to `drag`." - }), - "path": Schema.Array(CoordParam).annotate({ +export type Prompt = { + readonly "id": string + readonly "version"?: string | null + readonly "variables"?: ResponsePromptVariables +} | null +export const Prompt = Schema.Union([ + Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique identifier of the prompt template to use." }), + "version": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "Optional version of the prompt template." }), Schema.Null]) + ), + "variables": Schema.optionalKey(ResponsePromptVariables) + }).annotate({ "description": - "An array of coordinates representing the path of the drag action. Coordinates will appear as an array of objects, eg\n```\n[\n { x: 100, y: 200 },\n { x: 200, y: 300 }\n]\n```" + "Reference to a prompt template and its variables.\n[Learn more](/docs/guides/text?api-mode=responses#reusable-prompts).\n" }), - "keys": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).annotate({ "description": "The keys being held while dragging the mouse." }), - Schema.Null - ]) - ) -}).annotate({ "title": "Drag", "description": "A drag action." }) -export type ComputerToolCallOutputResource = { - readonly "type": "computer_call_output" + Schema.Null +]).annotate({ "identifier": "Prompt" }) +export type RealtimeTranscriptionSessionCreateResponseGA = { + readonly "type": "transcription" readonly "id": string - readonly "call_id": string - readonly "acknowledged_safety_checks"?: ReadonlyArray - readonly "output": ComputerScreenshotImage - readonly "status": "completed" | "incomplete" - readonly "created_by"?: string + readonly "object": string + readonly "expires_at"?: number + readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> + readonly "audio"?: { + readonly "input"?: { + readonly "format"?: RealtimeAudioFormats + readonly "transcription"?: AudioTranscriptionResponse + readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } + readonly "turn_detection"?: { + readonly "type"?: string + readonly "threshold"?: number + readonly "prefix_padding_ms"?: number + readonly "silence_duration_ms"?: number + } | null + } + } } -export const ComputerToolCallOutputResource = Schema.Struct({ - "type": Schema.Literal("computer_call_output").annotate({ - "description": "The type of the computer tool call output. Always `computer_call_output`.\n" +export const RealtimeTranscriptionSessionCreateResponseGA = Schema.Struct({ + "type": Schema.Literal("transcription").annotate({ + "description": "The type of session. Always `transcription` for transcription sessions.\n" }), - "id": Schema.String.annotate({ "description": "The unique ID of the computer call tool output.\n" }), - "call_id": Schema.String.annotate({ "description": "The ID of the computer tool call that produced the output.\n" }), - "acknowledged_safety_checks": Schema.optionalKey( - Schema.Array(ComputerCallSafetyCheckParam).annotate({ - "description": "The safety checks reported by the API that have been acknowledged by the\ndeveloper.\n" - }) + "id": Schema.String.annotate({ + "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" + }), + "object": Schema.String.annotate({ "description": "The object type. Always `realtime.transcription_session`." }), + "expires_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Expiration timestamp for the session, in seconds since epoch.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "output": ComputerScreenshotImage, - "status": Schema.Union([ - Schema.Literal("completed").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" - }), - Schema.Literal("incomplete").annotate({ + "include": Schema.optionalKey( + Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).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" + "Additional fields to include in server outputs.\n- `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" }) - ]).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" - }), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ), + "audio": Schema.optionalKey( + Schema.Struct({ + "input": Schema.optionalKey(Schema.Struct({ + "format": Schema.optionalKey(RealtimeAudioFormats), + "transcription": Schema.optionalKey( + Schema.suspend((): Schema.Codec => AudioTranscriptionResponse).annotate({ + "description": "Configuration of the transcription model.\n" + }) + ), + "noise_reduction": Schema.optionalKey( + Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ + "description": "Configuration for input audio noise reduction.\n" + }) + ), + "turn_detection": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.optionalKey( + Schema.String.annotate({ + "description": "Type of turn detection, only `server_vad` is currently supported.\n" + }) + ), + "threshold": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "prefix_padding_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "silence_duration_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).annotate({ + "description": + "Configuration for turn detection. Can be set to `null` to turn off. Server\nVAD means that the model will detect the start and end of speech based on\naudio volume and respond at the end of user speech. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.\n" + }), + Schema.Null + ]).annotate({ + "description": + "Configuration for turn detection. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.\n" + }) + ) + })) + }).annotate({ "description": "Configuration for input audio for the session.\n" }) ) -}).annotate({ "title": "Computer tool call output", "description": "The output of a computer tool call.\n" }) -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 - readonly "size"?: string | "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 +}).annotate({ + "title": "Realtime transcription session configuration object", + "description": "A Realtime transcription session configuration object.\n", + "identifier": "RealtimeTranscriptionSessionCreateResponseGA" +}) +export type RealtimeSessionCreateResponse = { + readonly "id"?: string + readonly "object"?: string + readonly "expires_at"?: number + readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> + readonly "model"?: string + readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> + readonly "instructions"?: string + readonly "audio"?: { + readonly "input"?: { + readonly "format"?: RealtimeAudioFormats + readonly "transcription"?: AudioTranscriptionResponse + readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } + readonly "turn_detection"?: { + readonly "type"?: string + readonly "threshold"?: number + readonly "prefix_padding_ms"?: number + readonly "silence_duration_ms"?: number + } + } + readonly "output"?: { + readonly "format"?: RealtimeAudioFormats + readonly "voice"?: VoiceIdsShared + readonly "speed"?: number + } + } + readonly "tracing"?: "auto" | { + readonly "workflow_name"?: string + readonly "group_id"?: string + readonly "metadata"?: {} + } + readonly "turn_detection"?: { + readonly "type"?: string + readonly "threshold"?: number + readonly "prefix_padding_ms"?: number + readonly "silence_duration_ms"?: number + } + readonly "tools"?: ReadonlyArray + readonly "tool_choice"?: string + readonly "max_output_tokens"?: number | "inf" } -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.Literals(["transparent", "opaque", "auto"]).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" - }), - Schema.Union([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" +export const RealtimeSessionCreateResponse = Schema.Struct({ + "id": Schema.optionalKey( + Schema.String.annotate({ + "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\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()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(10)], { - "description": "The number of images to generate. Must be between 1 and 10." - }) - ) - ]) + "object": Schema.optionalKey( + Schema.String.annotate({ "description": "The object type. Always `realtime.session`." }) ), - "size": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.String, - Schema.Literals(["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]) - ]).annotate({ - "description": - "The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`." - }), - Schema.Null - ]) + "expires_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Expiration timestamp for the session, in seconds since epoch.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "response_format": Schema.optionalKey(Schema.Union([ - Schema.Literals(["url", "b64_json"]).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." - }), - Schema.Union([Schema.Null]).annotate({ + "include": Schema.optionalKey( + Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).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." + "Additional fields to include in server outputs.\n- `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" }) - ])), - "output_format": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["png", "jpeg", "webp"]).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" - }), - Schema.Union([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" + "model": Schema.optionalKey(Schema.String.annotate({ "description": "The Realtime model used for this session." })), + "output_modalities": Schema.optionalKey( + Schema.Array(Schema.Literals(["text", "audio"])).annotate({ + "description": "The set of modalities the model can respond with. To disable audio,\nset this to [\"text\"].\n" }) ), - "user": Schema.optionalKey( - Schema.String.annotate({ + "instructions": Schema.optionalKey(Schema.String.annotate({ + "description": + "The default system instructions (i.e. system message) prepended to model\ncalls. This field allows the client to guide the model on desired\nresponses. The model can be instructed on response content and format,\n(e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good\nresponses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion\ninto your voice\", \"laugh frequently\"). The instructions are not guaranteed\nto be followed by the model, but they provide guidance to the model on the\ndesired behavior.\n\nNote that the server sets default instructions which will be used if this\nfield is not set and are visible in the `session.created` event at the\nstart of the session.\n" + })), + "audio": Schema.optionalKey( + Schema.Struct({ + "input": Schema.optionalKey(Schema.Struct({ + "format": Schema.optionalKey(RealtimeAudioFormats), + "transcription": Schema.optionalKey( + Schema.suspend((): Schema.Codec => AudioTranscriptionResponse).annotate({ + "description": "Configuration for input audio transcription.\n" + }) + ), + "noise_reduction": Schema.optionalKey( + Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ + "description": "Configuration for input audio noise reduction.\n" + }) + ), + "turn_detection": Schema.optionalKey( + Schema.Struct({ + "type": Schema.optionalKey( + Schema.String.annotate({ + "description": "Type of turn detection, only `server_vad` is currently supported.\n" + }) + ), + "threshold": Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "prefix_padding_ms": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "silence_duration_ms": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).annotate({ "description": "Configuration for turn detection.\n" }) + ) + })), + "output": Schema.optionalKey( + Schema.Struct({ + "format": Schema.optionalKey(RealtimeAudioFormats), + "voice": Schema.optionalKey(VoiceIdsShared), + "speed": Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) + }) + ) + }).annotate({ "description": "Configuration for input and output audio for the session.\n" }) + ), + "tracing": Schema.optionalKey( + Schema.Union([ + Schema.Literal("auto").annotate({ "description": "Default tracing mode for the session.\n" }), + Schema.Struct({ + "workflow_name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The name of the workflow to attach to this trace. This is used to\nname the trace in the traces dashboard.\n" + }) + ), + "group_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The group id to attach to this trace to enable filtering and\ngrouping in the traces dashboard.\n" + }) + ), + "metadata": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": + "The arbitrary metadata to attach to this trace to enable\nfiltering in the traces dashboard.\n" + }) + ) + }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) + ], { mode: "oneOf" }).annotate({ + "title": "Tracing Configuration", "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" + "Configuration options for tracing. Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" }) ), - "input_fidelity": Schema.optionalKey(Schema.Union([InputFidelity, Schema.Null])), - "stream": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "turn_detection": Schema.optionalKey( + Schema.Struct({ + "type": Schema.optionalKey( + Schema.String.annotate({ "description": "Type of turn detection, only `server_vad` is currently supported.\n" }) + ), + "threshold": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "prefix_padding_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "silence_duration_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).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" + "Configuration for turn detection. Can be set to `null` to turn off. Server\nVAD means that the model will detect the start and end of speech based on\naudio volume and respond at the end of user speech.\n" }) ), - "partial_images": Schema.optionalKey(PartialImages), - "quality": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["standard", "low", "medium", "high", "auto"]).annotate({ - "description": "The quality of the image that will be generated for GPT image models. Defaults to `auto`.\n" - }), - Schema.Union([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"?: string | "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" - }) - ]) + "tools": Schema.optionalKey( + Schema.Array(RealtimeFunctionTool).annotate({ "description": "Tools (functions) available to the model." }) ), - "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" + "tool_choice": Schema.optionalKey( + Schema.String.annotate({ + "description": "How the model chooses tools. Options are `auto`, `none`, `required`, or\nspecify a function.\n" }) ), - "size": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"])]).annotate({ + "max_output_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Literal("inf")], { + mode: "oneOf" + }).annotate({ "description": - "The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`." + "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\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" + ) +}).annotate({ + "title": "Realtime session configuration object", + "description": "A Realtime session configuration object.\n", + "identifier": "RealtimeSessionCreateResponse" +}) +export type RealtimeTranscriptionSessionCreateResponse = { + readonly "client_secret": { readonly "value": string; readonly "expires_at": number } + readonly "modalities"?: ReadonlyArray<"text" | "audio"> + readonly "input_audio_format"?: string + readonly "input_audio_transcription"?: AudioTranscriptionResponse + readonly "turn_detection"?: { + readonly "type"?: string + readonly "threshold"?: number + readonly "prefix_padding_ms"?: number + readonly "silence_duration_ms"?: number + } +} +export const RealtimeTranscriptionSessionCreateResponse = Schema.Struct({ + "client_secret": Schema.Struct({ + "value": Schema.String.annotate({ + "description": + "Ephemeral key usable in client environments to authenticate connections\nto the Realtime API. Use this in client-side environments rather than\na standard API token, which should only be used server-side.\n" + }), + "expires_at": Schema.Number.annotate({ + "description": "Timestamp for when the token expires. Currently, all tokens expire\nafter one minute.\n", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + }).annotate({ + "description": + "Ephemeral key returned by the API. Only present when the session is\ncreated on the server via REST API.\n" + }), + "modalities": Schema.optionalKey( + Schema.Array(Schema.Literals(["text", "audio"])).annotate({ + "description": "The set of modalities the model can respond with. To disable audio,\nset this to [\"text\"].\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" + "input_audio_format": Schema.optionalKey( + Schema.String.annotate({ + "description": "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\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_audio_transcription": Schema.optionalKey( + Schema.suspend((): Schema.Codec => AudioTranscriptionResponse).annotate({ + "description": "Configuration of the transcription model.\n" }) ), - "input_fidelity": Schema.optionalKey(Schema.Union([InputFidelity, Schema.Null])), - "input_image_mask": Schema.optionalKey( + "turn_detection": 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" })) + "type": Schema.optionalKey( + Schema.String.annotate({ "description": "Type of turn detection, only `server_vad` is currently supported.\n" }) + ), + "threshold": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "prefix_padding_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "silence_duration_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) }).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" + "Configuration for turn detection. Can be set to `null` to turn off. Server\nVAD means that the model will detect the start and end of speech based on\naudio volume and respond at the end of user speech.\n" }) ) }).annotate({ - "title": "Image generation tool", - "description": "A tool that generates images using the GPT image models.\n" + "description": + "A new Realtime transcription session configuration.\n\nWhen a session is created on the server via REST API, the session object\nalso contains an ephemeral key. Default TTL for keys is 10 minutes. This\nproperty is not present when a session is updated via the WebSocket API.\n", + "identifier": "RealtimeTranscriptionSessionCreateResponse" }) -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 ToolChoiceParam = + | ToolChoiceOptions + | ToolChoiceAllowed + | ToolChoiceTypes + | ToolChoiceFunction + | ToolChoiceMCP + | ToolChoiceCustom + | SpecificProgrammaticToolCallingParam + | SpecificApplyPatchParam + | SpecificFunctionShellParam +export const ToolChoiceParam = Schema.Union([ + ToolChoiceOptions, + ToolChoiceAllowed, + ToolChoiceTypes, + ToolChoiceFunction, + ToolChoiceMCP, + ToolChoiceCustom, + SpecificProgrammaticToolCallingParam, + SpecificApplyPatchParam, + SpecificFunctionShellParam +], { mode: "oneOf" }).annotate({ + "description": + "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n", + "identifier": "ToolChoiceParam" }) -export type CustomToolParam = { - readonly "type": "custom" - readonly "name": string - readonly "description"?: string - readonly "format"?: CustomTextFormatParam | CustomGrammarFormatParam - readonly "defer_loading"?: boolean +export type Reasoning = { + readonly "mode"?: ReasoningModeEnum + readonly "effort"?: ReasoningEffort + readonly "summary"?: "auto" | "concise" | "detailed" | null + readonly "context"?: "auto" | "current_turn" | "all_turns" | null + readonly "generate_summary"?: "auto" | "concise" | "detailed" | null } -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." +export const Reasoning = Schema.Struct({ + "mode": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ReasoningModeEnum).annotate({ + "description": + "Controls the reasoning execution mode for the request.\n\nWhen returned on a response, this is the effective execution mode.\n" }) ), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether this tool should be deferred and discovered via tool search." }) + "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 + ])), + "context": Schema.optionalKey(Schema.Union([ + Schema.Literals(["auto", "current_turn", "all_turns"]).annotate({ + "description": + "Controls which reasoning items are rendered back to the model on later turns.\nIf omitted or set to `auto`, the model determines the context mode. The\n`gpt-5.6` model family defaults to `all_turns`; earlier models default to\n`current_turn`.\n\nWhen returned on a response, this is the effective reasoning context mode\nused for the response.\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": "Custom tool", + "title": "Reasoning", "description": - "A custom tool that processes input using a specified format. Learn more about [custom tools](/docs/guides/function-calling#custom-tools)" + "**gpt-5 and o-series models only**\n\nConfiguration options for\n[reasoning models](https://platform.openai.com/docs/guides/reasoning).\n", + "identifier": "Reasoning" }) -export type FunctionToolParam = { - readonly "name": string - readonly "description"?: string | null - readonly "parameters"?: EmptyModelParam | null - readonly "strict"?: boolean | null - readonly "type": "function" - readonly "defer_loading"?: boolean +export type ConversationParam = string | ConversationParam_2 +export const ConversationParam = Schema.Union([ + Schema.String.annotate({ "title": "Conversation ID", "description": "The unique ID of the conversation.\n" }), + ConversationParam_2 +], { mode: "oneOf" }).annotate({ + "description": + "The conversation that this response belongs to. Items from this conversation are prepended to `input_items` for this response request.\nInput items and output items from this response are automatically added to this conversation after this response completes.\n", + "identifier": "ConversationParam" +}) +export type ResponseError = { readonly "code": ResponseErrorCode; readonly "message": string } | null +export const ResponseError = Schema.Union([ + Schema.Struct({ + "code": ResponseErrorCode, + "message": Schema.String.annotate({ "description": "A human-readable description of the error.\n" }) + }).annotate({ "description": "An error object returned when the model fails to generate a Response.\n" }), + Schema.Null +]).annotate({ "identifier": "ResponseError" }) +export type Moderation = { + readonly "input": ModerationResultBody | ModerationErrorBody + readonly "output": ModerationResultBody | ModerationErrorBody } -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"), - "defer_loading": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Whether this function should be deferred and discovered via tool search." - }) - ) +export const Moderation = Schema.Struct({ + "input": Schema.Union([ModerationResultBody, ModerationErrorBody], { mode: "oneOf" }).annotate({ + "description": "Moderation for the response input." + }), + "output": Schema.Union([ModerationResultBody, ModerationErrorBody], { mode: "oneOf" }).annotate({ + "description": "Moderation for the response output." + }) +}).annotate({ + "title": "Moderation", + "description": "Moderation results or errors for the response input and output.", + "identifier": "Moderation" }) -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 type ResponseTextDeltaEvent = { + readonly "type": "response.output_text.delta" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "delta": string + readonly "sequence_number": number + readonly "logprobs": 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`." +export const ResponseTextDeltaEvent = Schema.Struct({ + "type": Schema.Literal("response.output_text.delta").annotate({ + "description": "The type of the event. Always `response.output_text.delta`.\n" }), - "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." - }) + "item_id": Schema.String.annotate({ "description": "The ID of the output item that the text delta was added to.\n" }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the text delta was added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ + "description": "The index of the content part that the text delta was added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String.annotate({ "description": "The text delta that was added.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "search_content_types": Schema.optionalKey(Schema.Array(SearchContentType)) + "logprobs": Schema.Array(ResponseLogProb).annotate({ + "description": "The log probabilities of the tokens in the delta.\n" + }) }).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)." + "description": "Emitted when there is an additional text delta.", + "identifier": "ResponseTextDeltaEvent" }) -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 ResponseTextDoneEvent = { + readonly "type": "response.output_text.done" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "text": string + readonly "sequence_number": number + readonly "logprobs": ReadonlyArray } -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" +export const ResponseTextDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.output_text.done").annotate({ + "description": "The type of the event. Always `response.output_text.done`.\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" + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the text content is finalized.\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" + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the text content is finalized.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ + "description": "The index of the content part that the text content is finalized.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "text": Schema.String.annotate({ "description": "The text content that is finalized.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "logprobs": Schema.Array(ResponseLogProb).annotate({ + "description": "The log probabilities of the tokens in the delta.\n" + }) +}).annotate({ "description": "Emitted when text content is finalized.", "identifier": "ResponseTextDoneEvent" }) +export type CreateMessageRequest = { + readonly "role": "user" | "assistant" + readonly "content": + | string + | ReadonlyArray + readonly "attachments"?: + | ReadonlyArray< + { + readonly "file_id"?: string + readonly "tools"?: ReadonlyArray + } + > + | null + readonly "metadata"?: Metadata } -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" +export const CreateMessageRequest = Schema.Struct({ + "role": Schema.Literals(["user", "assistant"]).annotate({ + "description": + "The role of the entity that is creating the message. Allowed values include:\n- `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.\n- `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.\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() + "content": Schema.Union([ + Schema.String.annotate({ "title": "Text content", "description": "The text contents of the message." }), + Schema.Array( + Schema.Union([MessageContentImageFileObject, MessageContentImageUrlObject, MessageRequestContentTextObject], { + mode: "oneOf" + }) + ).annotate({ + "title": "Array of content parts", + "description": + "An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models)." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ], { mode: "oneOf" }), + "attachments": Schema.optionalKey(Schema.Union([ + Schema.Array(Schema.Struct({ + "file_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the file to attach to the message." }) ), - 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({ - "title": "Shell exec action", - "description": "The shell commands and limits that describe how to run the tool call." - }), - "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": "The status of the shell call. One of `in_progress`, `completed`, or `incomplete`." - }), - "environment": Schema.Union([ - Schema.Union([LocalEnvironmentResource, ContainerReferenceResource], { mode: "oneOf" }), + "tools": Schema.optionalKey( + Schema.Array(Schema.Union([AssistantToolsCode, AssistantToolsFileSearchTypeOnly], { mode: "oneOf" })).annotate({ + "description": "The tools to add this file to." + }) + ) + })).annotate({ "description": "A list of files attached to the message, and the tools they should be added to." }), Schema.Null - ]), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the entity that created this tool call." }) - ) -}).annotate({ - "title": "Shell tool call", - "description": "A tool call that executes one or more shell commands in a managed environment." -}) -export type FunctionShellCallOutputContent = { - readonly "stdout": string - readonly "stderr": string - readonly "outcome": FunctionShellCallOutputTimeoutOutcome | FunctionShellCallOutputExitOutcome - readonly "created_by"?: string + ])), + "metadata": Schema.optionalKey(Metadata) +}).annotate({ "identifier": "CreateMessageRequest" }) +export type MessageContentTextObject = { + readonly "type": "text" + readonly "text": { + readonly "value": string + readonly "annotations": ReadonlyArray< + MessageContentTextAnnotationsFileCitationObject | MessageContentTextAnnotationsFilePathObject + > + } } -export const FunctionShellCallOutputContent = Schema.Struct({ - "stdout": Schema.String.annotate({ "description": "The standard output that was captured." }), - "stderr": Schema.String.annotate({ "description": "The standard error output that was captured." }), - "outcome": Schema.Union([FunctionShellCallOutputTimeoutOutcome, FunctionShellCallOutputExitOutcome], { - mode: "oneOf" - }).annotate({ - "title": "Shell call outcome", - "description": - "Represents either an exit outcome (with an exit code) or a timeout outcome for a shell call output chunk." - }), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) - ) +export const MessageContentTextObject = Schema.Struct({ + "type": Schema.Literal("text").annotate({ "description": "Always `text`." }), + "text": Schema.Struct({ + "value": Schema.String.annotate({ "description": "The data that makes up the text." }), + "annotations": Schema.Array( + Schema.Union([MessageContentTextAnnotationsFileCitationObject, MessageContentTextAnnotationsFilePathObject], { + mode: "oneOf" + }) + ) + }) }).annotate({ - "title": "Shell call output content", - "description": "The content of a shell tool call output that was emitted." + "title": "Text", + "description": "The text content that is part of a message.", + "identifier": "MessageContentTextObject" }) -export type ApplyPatchToolCall = { - readonly "type": "apply_patch_call" +export type VectorStoreObject = { readonly "id": string - readonly "call_id": string - readonly "status": "in_progress" | "completed" - readonly "operation": ApplyPatchCreateFileOperation | ApplyPatchDeleteFileOperation | ApplyPatchUpdateFileOperation - readonly "created_by"?: string + readonly "object": "vector_store" + readonly "created_at": number + readonly "name": string + readonly "usage_bytes": number + readonly "file_counts": { + readonly "in_progress": number + readonly "completed": number + readonly "failed": number + readonly "cancelled": number + readonly "total": number + } + readonly "status": "expired" | "in_progress" | "completed" + readonly "expires_after"?: VectorStoreExpirationAfter + readonly "expires_at"?: number | null + readonly "last_active_at": number | null + readonly "metadata": Metadata } -export const ApplyPatchToolCall = Schema.Struct({ - "type": Schema.Literal("apply_patch_call").annotate({ - "description": "The type of the item. Always `apply_patch_call`." - }), - "id": Schema.String.annotate({ - "description": "The unique ID of the apply patch tool call. Populated when this item is returned via API." - }), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the apply patch tool call generated by the model." +export const VectorStoreObject = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), + "object": Schema.Literal("vector_store").annotate({ + "description": "The object type, which is always `vector_store`." }), - "status": Schema.Literals(["in_progress", "completed"]).annotate({ - "description": "The status of the apply patch tool call. One of `in_progress` or `completed`." + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the vector store was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "name": Schema.String.annotate({ "description": "The name of the vector store." }), + "usage_bytes": Schema.Number.annotate({ + "description": "The total number of bytes used by the files in the vector store." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "file_counts": Schema.Struct({ + "in_progress": Schema.Number.annotate({ "description": "The number of files that are currently being processed." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "completed": Schema.Number.annotate({ "description": "The number of files that have been successfully processed." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "failed": Schema.Number.annotate({ "description": "The number of files that have failed to process." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "cancelled": Schema.Number.annotate({ "description": "The number of files that were cancelled." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "total": Schema.Number.annotate({ "description": "The total number of files." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) }), - "operation": Schema.Union([ - ApplyPatchCreateFileOperation, - ApplyPatchDeleteFileOperation, - ApplyPatchUpdateFileOperation - ], { mode: "oneOf" }).annotate({ - "title": "Apply patch operation", - "description": "One of the create_file, delete_file, or update_file operations applied via apply_patch." + "status": Schema.Literals(["expired", "in_progress", "completed"]).annotate({ + "description": + "The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use." }), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the entity that created this tool call." }) - ) + "expires_after": Schema.optionalKey(VectorStoreExpirationAfter), + "expires_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the vector store will expire.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "last_active_at": Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the vector store was last active.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "metadata": Metadata }).annotate({ - "title": "Apply patch tool call", - "description": "A tool call that applies file diffs by creating, deleting, or updating files." + "title": "Vector store", + "description": "A vector store is a collection of processed files can be used by the `file_search` tool.", + "identifier": "VectorStoreObject" }) -export type FunctionShellCallOutputContentParam = { - readonly "stdout": string - readonly "stderr": string - readonly "outcome": FunctionShellCallOutputTimeoutOutcomeParam | FunctionShellCallOutputExitOutcomeParam +export type CreateVectorStoreRequest = { + readonly "file_ids"?: ReadonlyArray + readonly "name"?: string + readonly "description"?: string + readonly "expires_after"?: VectorStoreExpirationAfter + readonly "chunking_strategy"?: { readonly "type": "auto" } | { + readonly "type": "static" + readonly "static": StaticChunkingStrategy + } + readonly "metadata"?: Metadata } -export const FunctionShellCallOutputContentParam = Schema.Struct({ - "stdout": Schema.String.annotate({ "description": "Captured stdout output for the shell call." }).check( - Schema.isMaxLength(10485760) +export const CreateVectorStoreRequest = Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files." + }).check(Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" })) ), - "stderr": Schema.String.annotate({ "description": "Captured stderr output for the shell call." }).check( - Schema.isMaxLength(10485760) + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the vector store." })), + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": "A description for the vector store. Can be used to describe the vector store's purpose." + }) ), - "outcome": Schema.Union([FunctionShellCallOutputTimeoutOutcomeParam, FunctionShellCallOutputExitOutcomeParam], { - mode: "oneOf" + "expires_after": Schema.optionalKey(VectorStoreExpirationAfter), + "chunking_strategy": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }).annotate({ + "title": "Auto Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty." + }), + Schema.Struct({ + "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), + "static": StaticChunkingStrategy + }).annotate({ + "title": "Static Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty." + }) + ], { mode: "oneOf" }) + ), + "metadata": Schema.optionalKey(Metadata) +}).annotate({ "identifier": "CreateVectorStoreRequest" }) +export type ChunkingStrategyRequestParam = { readonly "type": "auto" } | { + readonly "type": "static" + readonly "static": StaticChunkingStrategy +} +export const ChunkingStrategyRequestParam = Schema.Union([ + Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }).annotate({ + "title": "Auto Chunking Strategy", + "description": "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." + }), + Schema.Struct({ + "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), + "static": StaticChunkingStrategy }).annotate({ - "title": "Shell call outcome", - "description": "The exit or timeout outcome associated with this shell call." + "title": "Static Chunking Strategy", + "description": "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." }) -}).annotate({ - "title": "Shell output content", - "description": "Captured stdout and stderr for a portion of a shell tool call output." -}) -export type ImageGenUsage = { - readonly "input_tokens": number - readonly "total_tokens": number - readonly "output_tokens": number - readonly "output_tokens_details"?: ImageGenOutputTokensDetails - readonly "input_tokens_details": ImageGenInputUsageDetails -} -export const ImageGenUsage = Schema.Struct({ - "input_tokens": Schema.Number.annotate({ - "description": "The number of tokens (images and text) in the input prompt." - }).check(Schema.isInt()), - "total_tokens": Schema.Number.annotate({ - "description": "The total number of tokens (images and text) used for the image generation." - }).check(Schema.isInt()), - "output_tokens": Schema.Number.annotate({ "description": "The number of output tokens generated by the model." }) - .check(Schema.isInt()), - "output_tokens_details": Schema.optionalKey(ImageGenOutputTokensDetails), - "input_tokens_details": ImageGenInputUsageDetails -}).annotate({ - "title": "Image generation usage", - "description": "For `gpt-image-1` only, the token usage information for the image generation." -}) -export type ToolChoiceParam = - | ToolChoiceOptions - | ToolChoiceAllowed - | ToolChoiceTypes - | ToolChoiceFunction - | ToolChoiceMCP - | ToolChoiceCustom - | SpecificApplyPatchParam - | SpecificFunctionShellParam -export const ToolChoiceParam = Schema.Union([ - ToolChoiceOptions, - ToolChoiceAllowed, - ToolChoiceTypes, - ToolChoiceFunction, - ToolChoiceMCP, - ToolChoiceCustom, - SpecificApplyPatchParam, - SpecificFunctionShellParam -], { mode: "oneOf" }).annotate({ - "description": - "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n" -}) -export type ConversationParam = string | ConversationParam_2 -export const ConversationParam = Schema.Union([ - Schema.String.annotate({ "title": "Conversation ID", "description": "The unique ID of the conversation.\n" }), - ConversationParam_2 -], { mode: "oneOf" }).annotate({ - "description": - "The conversation that this response belongs to. Items from this conversation are prepended to `input_items` for this response request.\nInput items and output items from this response are automatically added to this conversation after this response completes.\n" +], { mode: "oneOf" }).annotate({ "identifier": "ChunkingStrategyRequestParam" }) +export type VectorStoreFileObject = { + readonly "id": string + readonly "object": "vector_store.file" + readonly "usage_bytes": number + readonly "created_at": number + readonly "vector_store_id": string + readonly "status": "in_progress" | "completed" | "cancelled" | "failed" + readonly "last_error": { + readonly "code": "server_error" | "unsupported_file" | "invalid_file" + readonly "message": string + } | null + readonly "chunking_strategy"?: { readonly "type": "static"; readonly "static": StaticChunkingStrategy } | { + readonly "type": "other" + } + readonly "attributes"?: VectorStoreFileAttributes +} +export const VectorStoreFileObject = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), + "object": Schema.Literal("vector_store.file").annotate({ + "description": "The object type, which is always `vector_store.file`." + }), + "usage_bytes": Schema.Number.annotate({ + "description": "The total vector store usage in bytes. Note that this may be different from the original file size." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the vector store file was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "vector_store_id": Schema.String.annotate({ + "description": + "The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to." + }), + "status": Schema.Literals(["in_progress", "completed", "cancelled", "failed"]).annotate({ + "description": + "The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use." + }), + "last_error": Schema.Union([ + Schema.Struct({ + "code": Schema.Literals(["server_error", "unsupported_file", "invalid_file"]).annotate({ + "description": "One of `server_error`, `unsupported_file`, or `invalid_file`." + }), + "message": Schema.String.annotate({ "description": "A human-readable description of the error." }) + }).annotate({ + "description": "The last error associated with this vector store file. Will be `null` if there are no errors." + }), + Schema.Null + ]), + "chunking_strategy": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), + "static": StaticChunkingStrategy + }).annotate({ "title": "Static Chunking Strategy", "description": "The strategy used to chunk the file." }), + Schema.Struct({ "type": Schema.Literal("other").annotate({ "description": "Always `other`." }) }).annotate({ + "title": "Other Chunking Strategy", + "description": "The strategy used to chunk the file." + }) + ], { mode: "oneOf" }) + ), + "attributes": Schema.optionalKey(VectorStoreFileAttributes) +}).annotate({ + "title": "Vector store files", + "description": "A list of files attached to a vector store.", + "identifier": "VectorStoreFileObject" }) -export type VideoListResource = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "last_id": string | null - readonly "has_more": boolean +export type VectorStoreSearchResultItem = { + readonly "file_id": string + readonly "filename": string + readonly "score": number + readonly "attributes": VectorStoreFileAttributes + readonly "content": ReadonlyArray } -export const VideoListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), - "data": Schema.Array(VideoResource).annotate({ "description": "A list of items" }), - "first_id": Schema.Union([ - Schema.String.annotate({ "description": "The ID of the first item in the list." }), +export const VectorStoreSearchResultItem = Schema.Struct({ + "file_id": Schema.String.annotate({ "description": "The ID of the vector store file." }), + "filename": Schema.String.annotate({ "description": "The name of the vector store file." }), + "score": Schema.Number.annotate({ "description": "The similarity score for the result." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })).check( + Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" }) + ), + "attributes": VectorStoreFileAttributes, + "content": Schema.Array(VectorStoreSearchResultContentObject).annotate({ + "description": "Content chunks from the file." + }) +}).annotate({ "identifier": "VectorStoreSearchResultItem" }) +export type SpendLimitEnforcement = { readonly "status": SpendLimitEnforcementStatus } +export const SpendLimitEnforcement = Schema.Struct({ + "status": Schema.suspend((): Schema.Codec => SpendLimitEnforcementStatus).annotate({ + "description": "Whether the hard spend limit is currently enforcing." + }) +}).annotate({ + "description": "The current enforcement state of a hard spend limit.", + "identifier": "SpendLimitEnforcement" +}) +export type SynthIDProvenanceResult = { + readonly "type": "synthid" + readonly "outcome": ProvenanceDetectionResultApi + readonly "model": string | null + readonly "generated_at": string | null +} +export const SynthIDProvenanceResult = Schema.Struct({ + "type": Schema.Literal("synthid").annotate({ "description": "The provenance signal type. Always `synthid`." }), + "outcome": Schema.suspend((): Schema.Codec => ProvenanceDetectionResultApi).annotate({ + "description": + "Whether a supported OpenAI SynthID watermark was detected.\nIf `not_detected`, it means the tool did not find supported signals in the uploaded file. The content could still have been generated by OpenAI if the metadata was stripped or has evidence of tampering, the watermark was degraded, it comes from a legacy generation model, or it was created before provenance signals were available. Content could also still be AI-generated by another company's model, which the tool currently does not detect." + }), + "model": Schema.Union([ + Schema.String.annotate({ "description": "The OpenAI model recorded by the provenance signal, when available." }), Schema.Null ]), - "last_id": Schema.Union([ - Schema.String.annotate({ "description": "The ID of the last item in the list." }), + "generated_at": Schema.Union([ + Schema.String.annotate({ + "description": + "The UTC RFC 3339 timestamp recorded by the provenance signal for when the asset was generated, when available." + }), + Schema.Null + ]) +}).annotate({ "identifier": "SynthIDProvenanceResult" }) +export type C2PAProvenanceResult = { + readonly "type": "c2pa" + readonly "outcome": ProvenanceDetectionResultApi + readonly "validation_state": C2PAValidationStateApi + readonly "issuer": string | null + readonly "model": string | null + readonly "generated_at": string | null +} +export const C2PAProvenanceResult = Schema.Struct({ + "type": Schema.Literal("c2pa").annotate({ "description": "The provenance signal type. Always `c2pa`." }), + "outcome": Schema.suspend((): Schema.Codec => ProvenanceDetectionResultApi).annotate({ + "description": + "Whether a supported OpenAI C2PA provenance signal was detected.\nIf `not_detected`, it means the tool did not find supported signals in the uploaded file. The content could still have been generated by OpenAI if the metadata was stripped or has evidence of tampering, the watermark was degraded, it comes from a legacy generation model, or it was created before provenance signals were available. Content could also still be AI-generated by another company's model, which the tool currently does not detect." + }), + "validation_state": Schema.suspend((): Schema.Codec => C2PAValidationStateApi).annotate({ + "description": "The validation status of the C2PA manifest in the uploaded image." + }), + "issuer": Schema.Union([ + Schema.String.annotate({ "description": "The C2PA manifest issuer, when available." }), Schema.Null ]), - "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }) + "model": Schema.Union([ + Schema.String.annotate({ "description": "The OpenAI model recorded by the provenance signal, when available." }), + Schema.Null + ]), + "generated_at": Schema.Union([ + Schema.String.annotate({ + "description": + "The UTC RFC 3339 timestamp recorded by the provenance signal for when the asset was generated, when available." + }), + Schema.Null + ]) +}).annotate({ "identifier": "C2PAProvenanceResult" }) +export type VideoResource = { + readonly "id": string + readonly "object": "video" + readonly "model": VideoModel + readonly "status": VideoStatus + readonly "progress": number + readonly "created_at": number + readonly "completed_at": number | null + readonly "expires_at": number | null + readonly "prompt": string | null + readonly "size": VideoSize + readonly "seconds": string + readonly "remixed_from_video_id": string | null + readonly "error": Error_2 | null +} +export const VideoResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique identifier for the video job." }), + "object": Schema.Literal("video").annotate({ "description": "The object type, which is always `video`." }), + "model": Schema.suspend((): Schema.Codec => VideoModel).annotate({ + "description": "The video generation model that produced the job." + }), + "status": Schema.suspend((): Schema.Codec => VideoStatus).annotate({ + "description": "Current lifecycle status of the video job." + }), + "progress": Schema.Number.annotate({ "description": "Approximate completion percentage for the generation task." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (seconds) for when the job was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "completed_at": Schema.Union([ + Schema.Number.annotate({ + "description": "Unix timestamp (seconds) for when the job completed, if finished.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "expires_at": Schema.Union([ + Schema.Number.annotate({ + "description": "Unix timestamp (seconds) for when the downloadable assets expire, if set.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "prompt": Schema.Union([ + Schema.String.annotate({ "description": "The prompt that was used to generate the video." }), + Schema.Null + ]), + "size": Schema.suspend((): Schema.Codec => VideoSize).annotate({ + "description": "The resolution of the generated video." + }), + "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." }), + Schema.Null + ]), + "error": Schema.Union([ + Schema.suspend((): Schema.Codec => Error_2).annotate({ + "description": "Error payload that explains why generation failed, if applicable." + }), + Schema.Null + ]) +}).annotate({ + "title": "Video job", + "description": "Structured information describing a generated video job.", + "identifier": "VideoResource" +}) +export type CreateVideoJsonBody = { + readonly "model"?: VideoModel + readonly "prompt": string + readonly "input_reference"?: ImageRefParam_2 + readonly "seconds"?: VideoSeconds + readonly "size"?: VideoSize +} +export const CreateVideoJsonBody = Schema.Struct({ + "model": Schema.optionalKey( + Schema.suspend((): Schema.Codec => VideoModel).annotate({ + "description": "The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`." + }) + ), + "prompt": Schema.String.annotate({ "description": "Text prompt that describes the video to generate." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(32000).annotate({ "expected": "a value with a length of at most 32000" })), + "input_reference": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ImageRefParam_2).annotate({ + "description": + "Optional reference object that guides generation. Provide exactly one of `image_url` or `file_id`." + }) + ), + "seconds": Schema.optionalKey( + Schema.suspend((): Schema.Codec => VideoSeconds).annotate({ + "description": "Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds." + }) + ), + "size": Schema.optionalKey( + Schema.suspend((): Schema.Codec => VideoSize).annotate({ + "description": + "Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280." + }) + ) +}).annotate({ + "title": "Create video JSON request", + "description": "JSON parameters for creating a new video generation job.", + "identifier": "CreateVideoJsonBody" }) export type CreateVideoMultipartBody = { - readonly "model"?: - | string - | "sora-2" - | "sora-2-pro" - | "sora-2-2025-10-06" - | "sora-2-pro-2025-10-06" - | "sora-2-2025-12-08" + readonly "model"?: VideoModel readonly "prompt": string readonly "input_reference"?: string | ImageRefParam_2 - readonly "seconds"?: "4" | "8" | "12" - readonly "size"?: "720x1280" | "1280x720" | "1024x1792" | "1792x1024" + readonly "seconds"?: VideoSeconds + readonly "size"?: VideoSize } export const CreateVideoMultipartBody = Schema.Struct({ "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals(["sora-2", "sora-2-pro", "sora-2-2025-10-06", "sora-2-pro-2025-10-06", "sora-2-2025-12-08"]) - ]).annotate({ + Schema.suspend((): Schema.Codec => VideoModel).annotate({ "description": "The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`." }) ), "prompt": Schema.String.annotate({ "description": "Text prompt that describes the video to generate." }).check( - Schema.isMinLength(1) - ).check(Schema.isMaxLength(32000)), + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(32000).annotate({ "expected": "a value with a length of at most 32000" })), "input_reference": Schema.optionalKey( Schema.Union([ Schema.String.annotate({ "description": "Optional reference asset upload or reference object that guides generation.", "format": "binary" }), - ImageRefParam_2 + Schema.suspend((): Schema.Codec => ImageRefParam_2).annotate({ + "description": + "Optional reference asset upload or reference object that guides generation. Provide exactly one of `image_url` or `file_id` when using an object." + }) ], { mode: "oneOf" }) ), "seconds": Schema.optionalKey( - Schema.Literals(["4", "8", "12"]).annotate({ + Schema.suspend((): Schema.Codec => VideoSeconds).annotate({ "description": "Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds." }) ), "size": Schema.optionalKey( - Schema.Literals(["720x1280", "1280x720", "1024x1792", "1792x1024"]).annotate({ + Schema.suspend((): Schema.Codec => VideoSize).annotate({ "description": "Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280." }) ) }).annotate({ "title": "Create video multipart request", - "description": "Multipart parameters for creating a new video generation job." + "description": "Multipart parameters for creating a new video generation job.", + "identifier": "CreateVideoMultipartBody" +}) +export type CreateVideoEditJsonBody = { readonly "video": VideoReferenceInputParam; readonly "prompt": string } +export const CreateVideoEditJsonBody = Schema.Struct({ + "video": Schema.suspend((): Schema.Codec => VideoReferenceInputParam).annotate({ + "description": "Reference to the completed video to edit." + }), + "prompt": Schema.String.annotate({ "description": "Text prompt that describes how to edit the source video." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(32000).annotate({ "expected": "a value with a length of at most 32000" })) +}).annotate({ + "title": "Create video edit JSON request", + "description": "JSON parameters for editing an existing generated video.", + "identifier": "CreateVideoEditJsonBody" }) export type CreateVideoEditMultipartBody = { readonly "video": string | VideoReferenceInputParam @@ -15074,33 +16341,62 @@ export type CreateVideoEditMultipartBody = { export const CreateVideoEditMultipartBody = Schema.Struct({ "video": Schema.Union([ Schema.String.annotate({ "description": "Reference to the completed video to edit.", "format": "binary" }), - VideoReferenceInputParam + Schema.suspend((): Schema.Codec => VideoReferenceInputParam).annotate({ + "description": "Reference to the completed video to edit." + }) ], { mode: "oneOf" }), "prompt": Schema.String.annotate({ "description": "Text prompt that describes how to edit the source video." }).check( - Schema.isMinLength(1) - ).check(Schema.isMaxLength(32000)) + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(32000).annotate({ "expected": "a value with a length of at most 32000" })) }).annotate({ "title": "Create video edit multipart request", - "description": "Parameters for editing an existing generated video." + "description": "Parameters for editing an existing generated video.", + "identifier": "CreateVideoEditMultipartBody" +}) +export type CreateVideoExtendJsonBody = { + readonly "video": VideoReferenceInputParam + readonly "prompt": string + readonly "seconds": VideoSeconds +} +export const CreateVideoExtendJsonBody = Schema.Struct({ + "video": Schema.suspend((): Schema.Codec => VideoReferenceInputParam).annotate({ + "description": "Reference to the completed video to extend." + }), + "prompt": Schema.String.annotate({ "description": "Updated text prompt that directs the extension generation." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(32000).annotate({ "expected": "a value with a length of at most 32000" }) + ), + "seconds": Schema.suspend((): Schema.Codec => VideoSeconds).annotate({ + "description": "Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20)." + }) +}).annotate({ + "title": "Create video extension JSON request", + "description": "JSON parameters for extending an existing generated video.", + "identifier": "CreateVideoExtendJsonBody" }) export type CreateVideoExtendMultipartBody = { readonly "video": VideoReferenceInputParam | string readonly "prompt": string - readonly "seconds": "4" | "8" | "12" + readonly "seconds": VideoSeconds } export const CreateVideoExtendMultipartBody = Schema.Struct({ "video": Schema.Union([ - VideoReferenceInputParam, + Schema.suspend((): Schema.Codec => VideoReferenceInputParam).annotate({ + "description": "Reference to the completed video to extend." + }), Schema.String.annotate({ "description": "Reference to the completed video to extend.", "format": "binary" }) ], { mode: "oneOf" }), "prompt": Schema.String.annotate({ "description": "Updated text prompt that directs the extension generation." }) - .check(Schema.isMinLength(1)).check(Schema.isMaxLength(32000)), - "seconds": Schema.Literals(["4", "8", "12"]).annotate({ + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(32000).annotate({ "expected": "a value with a length of at most 32000" }) + ), + "seconds": Schema.suspend((): Schema.Codec => VideoSeconds).annotate({ "description": "Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20)." }) }).annotate({ "title": "Create video extension multipart request", - "description": "Multipart parameters for extending an existing generated video." + "description": "Multipart parameters for extending an existing generated video.", + "identifier": "CreateVideoExtendMultipartBody" }) export type SkillListResource = { readonly "object": "list" @@ -15121,7 +16417,7 @@ export const SkillListResource = Schema.Struct({ Schema.Null ]), "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }) -}) +}).annotate({ "identifier": "SkillListResource" }) export type SkillVersionListResource = { readonly "object": "list" readonly "data": ReadonlyArray @@ -15141,88 +16437,237 @@ export const SkillVersionListResource = Schema.Struct({ Schema.Null ]), "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }) -}) -export type UserMessageItem = { +}).annotate({ "identifier": "SkillVersionListResource" }) +export type ChatkitWorkflow = { readonly "id": string - readonly "object": "chatkit.thread_item" - readonly "created_at": number - readonly "thread_id": string - readonly "type": "chatkit.user_message" - readonly "content": ReadonlyArray - readonly "attachments": ReadonlyArray - readonly "inference_options": { - readonly "tool_choice": { readonly "id": string } | null - readonly "model": string | null - } | null + readonly "version": string | null + readonly "state_variables": {} | null + readonly "tracing": ChatkitWorkflowTracing } -export const UserMessageItem = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), - "object": Schema.Literal("chatkit.thread_item").annotate({ - "description": "Type discriminator that is always `chatkit.thread_item`." +export const ChatkitWorkflow = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier of the workflow backing the session." }), + "version": Schema.Union([ + Schema.String.annotate({ + "description": + "Specific workflow version used for the session. Defaults to null when using the latest deployment." + }), + Schema.Null + ]), + "state_variables": Schema.Union([ + Schema.Struct({}).annotate({ + "description": + "State variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided." + }), + Schema.Null + ]), + "tracing": Schema.suspend((): Schema.Codec => ChatkitWorkflowTracing).annotate({ + "description": "Tracing settings applied to the workflow." + }) +}).annotate({ + "title": "Workflow", + "description": "Workflow metadata and state returned for the session.", + "identifier": "ChatkitWorkflow" +}) +export type ChatSessionChatkitConfiguration = { + readonly "automatic_thread_titling": ChatSessionAutomaticThreadTitling + readonly "file_upload": ChatSessionFileUpload + readonly "history": ChatSessionHistory +} +export const ChatSessionChatkitConfiguration = Schema.Struct({ + "automatic_thread_titling": Schema.suspend((): Schema.Codec => + ChatSessionAutomaticThreadTitling + ).annotate({ "description": "Automatic thread titling preferences." }), + "file_upload": Schema.suspend((): Schema.Codec => ChatSessionFileUpload).annotate({ + "description": "Upload settings for the session." + }), + "history": Schema.suspend((): Schema.Codec => ChatSessionHistory).annotate({ + "description": "History retention configuration." + }) +}).annotate({ + "title": "ChatKit configuration", + "description": "ChatKit configuration for the session.", + "identifier": "ChatSessionChatkitConfiguration" +}) +export type WorkflowParam = { + readonly "id": string + readonly "version"?: string + readonly "state_variables"?: {} + readonly "tracing"?: WorkflowTracingParam +} +export const WorkflowParam = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier for the workflow invoked by the session." }), + "version": Schema.optionalKey( + Schema.String.annotate({ + "description": "Specific workflow version to run. Defaults to the latest deployed version." + }) + ), + "state_variables": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": + "State variables forwarded to the workflow. Keys may be up to 64 characters, values must be primitive types, and the map defaults to an empty object." + }).check(Schema.isMaxProperties(64).annotate({ "expected": "a value with at most 64 entries" })) + ), + "tracing": Schema.optionalKey( + Schema.suspend((): Schema.Codec => WorkflowTracingParam).annotate({ + "description": + "Optional tracing overrides for the workflow invocation. When omitted, tracing is enabled by default." + }) + ) +}).annotate({ + "title": "Workflow settings", + "description": "Workflow reference and overrides applied to the chat session.", + "identifier": "WorkflowParam" +}) +export type ChatkitConfigurationParam = { + readonly "automatic_thread_titling"?: AutomaticThreadTitlingParam + readonly "file_upload"?: FileUploadParam + readonly "history"?: HistoryParam +} +export const ChatkitConfigurationParam = Schema.Struct({ + "automatic_thread_titling": Schema.optionalKey( + Schema.suspend((): Schema.Codec => AutomaticThreadTitlingParam).annotate({ + "description": + "Configuration for automatic thread titling. When omitted, automatic thread titling is enabled by default." + }) + ), + "file_upload": Schema.optionalKey( + Schema.suspend((): Schema.Codec => FileUploadParam).annotate({ + "description": + "Configuration for upload enablement and limits. When omitted, uploads are disabled by default (max_files 10, max_file_size 512 MB)." + }) + ), + "history": Schema.optionalKey( + Schema.suspend((): Schema.Codec => HistoryParam).annotate({ + "description": + "Configuration for chat history retention. When omitted, history is enabled by default with no limit on recent_threads (null)." + }) + ) +}).annotate({ + "title": "ChatKit configuration overrides", + "description": "Optional per-session configuration settings for ChatKit behavior.", + "identifier": "ChatkitConfigurationParam" +}) +export type Attachment = { + readonly "type": AttachmentType + readonly "id": string + readonly "name": string + readonly "mime_type": string + readonly "preview_url": string | null +} +export const Attachment = Schema.Struct({ + "type": Schema.suspend((): Schema.Codec => AttachmentType).annotate({ + "description": "Attachment discriminator." + }), + "id": Schema.String.annotate({ "description": "Identifier for the attachment." }), + "name": Schema.String.annotate({ "description": "Original display name for the attachment." }), + "mime_type": Schema.String.annotate({ "description": "MIME type of the attachment." }), + "preview_url": Schema.Union([ + Schema.String.annotate({ "description": "Preview URL for rendering the attachment inline.", "format": "uri" }), + Schema.Null + ]) +}).annotate({ + "title": "Attachment", + "description": "Attachment metadata included on thread items.", + "identifier": "Attachment" +}) +export type InferenceOptions = { readonly "tool_choice": ToolChoice | null; readonly "model": string | null } +export const InferenceOptions = Schema.Struct({ + "tool_choice": Schema.Union([ + Schema.suspend((): Schema.Codec => ToolChoice).annotate({ + "description": "Preferred tool to invoke. Defaults to null when ChatKit should auto-select." + }), + Schema.Null + ]), + "model": Schema.Union([ + Schema.String.annotate({ + "description": "Model name that generated the response. Defaults to null when using the session default." + }), + Schema.Null + ]) +}).annotate({ + "title": "Inference options", + "description": "Model and tool overrides applied when generating the assistant response.", + "identifier": "InferenceOptions" +}) +export type FileAnnotation = { readonly "type": "file"; readonly "source": FileAnnotationSource } +export const FileAnnotation = Schema.Struct({ + "type": Schema.Literal("file").annotate({ + "description": "Type discriminator that is always `file` for this annotation." + }), + "source": Schema.suspend((): Schema.Codec => FileAnnotationSource).annotate({ + "description": "File attachment referenced by the annotation." + }) +}).annotate({ + "title": "File annotation", + "description": "Annotation that references an uploaded file.", + "identifier": "FileAnnotation" +}) +export type UrlAnnotation = { readonly "type": "url"; readonly "source": UrlAnnotationSource } +export const UrlAnnotation = Schema.Struct({ + "type": Schema.Literal("url").annotate({ + "description": "Type discriminator that is always `url` for this annotation." + }), + "source": Schema.suspend((): Schema.Codec => UrlAnnotationSource).annotate({ + "description": "URL referenced by the annotation." + }) +}).annotate({ + "title": "URL annotation", + "description": "Annotation that references a URL.", + "identifier": "UrlAnnotation" +}) +export type ClientToolCallItem = { + readonly "id": string + readonly "object": "chatkit.thread_item" + readonly "created_at": number + readonly "thread_id": string + readonly "type": "chatkit.client_tool_call" + readonly "status": ClientToolCallStatus + readonly "call_id": string + readonly "name": string + readonly "arguments": string + readonly "output": string | null +} +export const ClientToolCallItem = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), + "object": Schema.Literal("chatkit.thread_item").annotate({ + "description": "Type discriminator that is always `chatkit.thread_item`." }), "created_at": Schema.Number.annotate({ "description": "Unix timestamp (in seconds) for when the item was created.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), - "type": Schema.Literal("chatkit.user_message"), - "content": Schema.Array( - Schema.Union([UserMessageInputText, UserMessageQuotedText], { mode: "oneOf" }).annotate({ - "description": "Content blocks that comprise a user message." - }) - ).annotate({ "description": "Ordered content elements supplied by the user." }), - "attachments": Schema.Array(Attachment).annotate({ - "description": "Attachments associated with the user message. Defaults to an empty list." + "type": Schema.Literal("chatkit.client_tool_call").annotate({ + "description": "Type discriminator that is always `chatkit.client_tool_call`." }), - "inference_options": Schema.Union([ - Schema.Struct({ - "tool_choice": Schema.Union([ - Schema.Struct({ "id": Schema.String.annotate({ "description": "Identifier of the requested tool." }) }) - .annotate({ - "title": "Tool choice", - "description": "Preferred tool to invoke. Defaults to null when ChatKit should auto-select." - }), - Schema.Null - ]), - "model": Schema.Union([ - Schema.String.annotate({ - "description": "Model name that generated the response. Defaults to null when using the session default." - }), - Schema.Null - ]) - }).annotate({ - "title": "Inference options", - "description": "Inference overrides applied to the message. Defaults to null when unset." + "status": Schema.suspend((): Schema.Codec => ClientToolCallStatus).annotate({ + "description": "Execution status for the tool call." + }), + "call_id": Schema.String.annotate({ "description": "Identifier for the client tool call." }), + "name": Schema.String.annotate({ "description": "Tool name that was invoked." }), + "arguments": Schema.String.annotate({ "description": "JSON-encoded arguments that were sent to the tool." }), + "output": Schema.Union([ + Schema.String.annotate({ + "description": "JSON-encoded output captured from the tool. Defaults to null while execution is in progress." }), Schema.Null ]) -}).annotate({ "title": "User Message Item", "description": "User-authored messages within a thread." }) -export type ResponseOutputText = { - readonly "type": "output_text" - readonly "text": string - readonly "annotations": ReadonlyArray -} -export const ResponseOutputText = Schema.Struct({ - "type": Schema.Literal("output_text").annotate({ "description": "Type discriminator that is always `output_text`." }), - "text": Schema.String.annotate({ "description": "Assistant generated text." }), - "annotations": Schema.Array( - Schema.Union([FileAnnotation, UrlAnnotation], { mode: "oneOf" }).annotate({ - "description": "Annotation object describing a cited source." - }) - ).annotate({ "description": "Ordered list of annotations attached to the response text." }) }).annotate({ - "title": "Assistant message content", - "description": "Assistant response text accompanied by optional annotations." + "title": "Client tool call", + "description": "Record of a client side tool invocation initiated by the assistant.", + "identifier": "ClientToolCallItem" }) -export type TaskGroupItem = { +export type TaskItem = { readonly "id": string readonly "object": "chatkit.thread_item" readonly "created_at": number readonly "thread_id": string - readonly "type": "chatkit.task_group" - readonly "tasks": ReadonlyArray + readonly "type": "chatkit.task" + readonly "task_type": TaskType + readonly "heading": string | null + readonly "summary": string | null } -export const TaskGroupItem = Schema.Struct({ +export const TaskItem = Schema.Struct({ "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), "object": Schema.Literal("chatkit.thread_item").annotate({ "description": "Type discriminator that is always `chatkit.thread_item`." @@ -15230,13 +16675,55 @@ export const TaskGroupItem = Schema.Struct({ "created_at": Schema.Number.annotate({ "description": "Unix timestamp (in seconds) for when the item was created.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), - "type": Schema.Literal("chatkit.task_group").annotate({ - "description": "Type discriminator that is always `chatkit.task_group`." + "type": Schema.Literal("chatkit.task").annotate({ + "description": "Type discriminator that is always `chatkit.task`." }), - "tasks": Schema.Array(TaskGroupTask).annotate({ "description": "Tasks included in the group." }) -}).annotate({ "title": "Task group", "description": "Collection of workflow tasks grouped together in the thread." }) + "task_type": Schema.suspend((): Schema.Codec => TaskType).annotate({ + "description": "Subtype for the task." + }), + "heading": Schema.Union([ + Schema.String.annotate({ "description": "Optional heading for the task. Defaults to null when not provided." }), + Schema.Null + ]), + "summary": Schema.Union([ + Schema.String.annotate({ + "description": "Optional summary that describes the task. Defaults to null when omitted." + }), + Schema.Null + ]) +}).annotate({ + "title": "Task item", + "description": "Task emitted by the workflow to show progress and status updates.", + "identifier": "TaskItem" +}) +export type TaskGroupTask = { + readonly "type": TaskType + readonly "heading": string | null + readonly "summary": string | null +} +export const TaskGroupTask = Schema.Struct({ + "type": Schema.suspend((): Schema.Codec => TaskType).annotate({ + "description": "Subtype for the grouped task." + }), + "heading": Schema.Union([ + Schema.String.annotate({ + "description": "Optional heading for the grouped task. Defaults to null when not provided." + }), + Schema.Null + ]), + "summary": Schema.Union([ + Schema.String.annotate({ + "description": "Optional summary that describes the grouped task. Defaults to null when omitted." + }), + Schema.Null + ]) +}).annotate({ + "title": "Task group task", + "description": "Task entry that appears within a TaskGroup.", + "identifier": "TaskGroupTask" +}) export type ThreadResource = { readonly "id": string readonly "object": "chatkit.thread" @@ -15253,7 +16740,7 @@ export const ThreadResource = Schema.Struct({ "created_at": Schema.Number.annotate({ "description": "Unix timestamp (in seconds) for when the thread was created.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "title": Schema.Union([ Schema.String.annotate({ "description": "Optional human-readable title for the thread. Defaults to null when no title has been generated." @@ -15266,6051 +16753,5187 @@ export const ThreadResource = Schema.Struct({ "user": Schema.String.annotate({ "description": "Free-form string that identifies your end user who owns the thread." }) -}).annotate({ "title": "The thread object", "description": "Represents a ChatKit thread and its current status." }) -export type AuditLogActor = { - readonly "type"?: "session" | "api_key" - readonly "session"?: AuditLogActorSession - readonly "api_key"?: AuditLogActorApiKey +}).annotate({ + "title": "The thread object", + "description": "Represents a ChatKit thread and its current status.", + "identifier": "ThreadResource" +}) +export type BetaPromptCacheOptionsParam = { + readonly "ttl"?: BetaPromptCacheTTLEnum + readonly "mode"?: BetaPromptCacheModeEnum } -export const AuditLogActor = Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literals(["session", "api_key"]).annotate({ - "description": "The type of actor. Is either `session` or `api_key`." +export const BetaPromptCacheOptionsParam = Schema.Struct({ + "ttl": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaPromptCacheTTLEnum).annotate({ + "description": + "The minimum lifetime applied to every implicit and explicit cache breakpoint written by the request. Defaults to `30m`, which is currently the only supported value. The backend may retain cache entries for longer." }) ), - "session": Schema.optionalKey(AuditLogActorSession), - "api_key": Schema.optionalKey(AuditLogActorApiKey) -}).annotate({ "description": "The actor who performed the audit logged action." }) -export type ChatCompletionToolChoiceOption = - | "none" - | "auto" - | "required" - | ChatCompletionAllowedToolsChoice - | ChatCompletionNamedToolChoice - | ChatCompletionNamedToolChoiceCustom -export const ChatCompletionToolChoiceOption = Schema.Union([ - Schema.Literals(["none", "auto", "required"]).annotate({ - "title": "Tool choice mode", - "description": - "`none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools.\n" + "mode": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaPromptCacheModeEnum).annotate({ + "description": + "Controls whether OpenAI automatically creates an implicit cache breakpoint. Defaults to `implicit`. With `implicit`, OpenAI creates one implicit breakpoint and writes up to the latest three explicit breakpoints in the request. With `explicit`, OpenAI does not create an implicit breakpoint and writes up to the latest four explicit breakpoints. If there are no explicit breakpoints, the request does not use prompt caching." + }) + ) +}).annotate({ + "title": "Prompt cache options", + "description": + "Options for prompt caching. Supported for `gpt-5.6` and later models. By default, OpenAI automatically chooses one implicit cache breakpoint. You can add explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each request can write up to four breakpoints. For cache matching, OpenAI considers up to the latest 80 breakpoints in the conversation, without a content-block lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The `ttl` defaults to `30m`, which is currently the only supported value. See the [prompt caching guide](/docs/guides/prompt-caching) for current details.", + "identifier": "BetaPromptCacheOptionsParam" +}) +export type BetaPromptCacheOptions = { + readonly "ttl": BetaPromptCacheTTLEnum + readonly "mode": BetaPromptCacheModeEnum +} +export const BetaPromptCacheOptions = Schema.Struct({ + "ttl": Schema.suspend((): Schema.Codec => BetaPromptCacheTTLEnum).annotate({ + "description": "The minimum lifetime applied to each cache breakpoint." }), - ChatCompletionAllowedToolsChoice, - ChatCompletionNamedToolChoice, - ChatCompletionNamedToolChoiceCustom -], { mode: "oneOf" }).annotate({ + "mode": Schema.suspend((): Schema.Codec => BetaPromptCacheModeEnum).annotate({ + "description": "Whether implicit prompt-cache breakpoints were enabled." + }) +}).annotate({ + "title": "Prompt cache options", "description": - "Controls which (if any) tool is called by the model.\n`none` means the model will not call any tool and instead generates a message.\n`auto` means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools.\nSpecifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n\n`none` is the default when no tools are present. `auto` is the default if tools are present.\n" + "The prompt-caching options that were applied to the response. Supported for `gpt-5.6` and later models.", + "identifier": "BetaPromptCacheOptions" }) -export type ChatCompletionMessageList = { - readonly "object": "list" - readonly "data": ReadonlyArray< - { - readonly "content": string | null - readonly "refusal": string | null - readonly "tool_calls"?: ChatCompletionMessageToolCalls - readonly "annotations"?: ReadonlyArray< - { - readonly "type": "url_citation" - readonly "url_citation": { - readonly "end_index": number - readonly "start_index": number - readonly "url": string - readonly "title": string - } - } - > - readonly "role": "assistant" - readonly "function_call"?: { readonly "arguments": string; readonly "name": string } - readonly "audio"?: { - readonly "id": string - readonly "expires_at": number - readonly "data": string - readonly "transcript": string - } | null - readonly "id": string - readonly "content_parts"?: - | ReadonlyArray - | null - } - > - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean +export type BetaModelIdsResponses = + | BetaModelIdsShared + | "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" +export const BetaModelIdsResponses = Schema.Union([ + BetaModelIdsShared, + 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({ "identifier": "BetaModelIdsResponses" }) +export type BetaTextResponseFormatJsonSchema = { + readonly "type": "json_schema" + readonly "description"?: string + readonly "name": string + readonly "schema": BetaResponseFormatJsonSchemaSchema + readonly "strict"?: boolean | null } -export const ChatCompletionMessageList = Schema.Struct({ - "object": Schema.Literal("list").annotate({ - "description": "The type of this object. It is always set to \"list\".\n" +export const BetaTextResponseFormatJsonSchema = Schema.Struct({ + "type": Schema.Literal("json_schema").annotate({ + "description": "The type of response format being defined. Always `json_schema`." }), - "data": Schema.Array( - Schema.Struct({ - "content": Schema.Union([Schema.String.annotate({ "description": "The contents of the message." }), Schema.Null]), - "refusal": Schema.Union([ - Schema.String.annotate({ "description": "The refusal message generated by the model." }), - Schema.Null - ]), - "tool_calls": Schema.optionalKey(ChatCompletionMessageToolCalls), - "annotations": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "type": Schema.Literal("url_citation").annotate({ - "description": "The type of the URL citation. Always `url_citation`." - }), - "url_citation": Schema.Struct({ - "end_index": Schema.Number.annotate({ - "description": "The index of the last character of the URL citation in the message." - }).check(Schema.isInt()), - "start_index": Schema.Number.annotate({ - "description": "The index of the first character of the URL citation in the message." - }).check(Schema.isInt()), - "url": Schema.String.annotate({ "description": "The URL of the web resource.", "format": "uri" }), - "title": Schema.String.annotate({ "description": "The title of the web resource." }) - }).annotate({ "description": "A URL citation when using web search." }) - }).annotate({ "description": "A URL citation when using web search.\n" }) - ).annotate({ - "description": - "Annotations for the message, when applicable, as when using the\n[web search tool](/docs/guides/tools-web-search?api-mode=chat).\n" - }) - ), - "role": Schema.Literal("assistant").annotate({ "description": "The role of the author of this message." }), - "function_call": Schema.optionalKey( - Schema.Struct({ - "arguments": Schema.String.annotate({ - "description": - "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." - }), - "name": Schema.String.annotate({ "description": "The name of the function to call." }) - }).annotate({ - "description": - "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model." - }) - ), - "audio": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "id": Schema.String.annotate({ "description": "Unique identifier for this audio response." }), - "expires_at": Schema.Number.annotate({ - "description": - "The Unix timestamp (in seconds) for when this audio response will\nno longer be accessible on the server for use in multi-turn\nconversations.\n", - "format": "unixtime" - }).check(Schema.isInt()), - "data": Schema.String.annotate({ - "description": - "Base64 encoded audio bytes generated by the model, in the format\nspecified in the request.\n" - }), - "transcript": Schema.String.annotate({ "description": "Transcript of the audio generated by the model." }) - }).annotate({ - "description": - "If the audio output modality is requested, this object contains data\nabout the audio response from the model. [Learn more](/docs/guides/audio).\n" - }), - Schema.Null - ])), - "id": Schema.String.annotate({ "description": "The identifier of the chat message." }), - "content_parts": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([ChatCompletionRequestMessageContentPartText, ChatCompletionRequestMessageContentPartImage], { - mode: "oneOf" - }) - ).annotate({ - "description": - "If a content parts array was provided, this is an array of `text` and `image_url` parts.\nOtherwise, null.\n" - }), - Schema.Null - ]) - ) - }).annotate({ "description": "A chat completion message generated by the model." }) - ).annotate({ "description": "An array of chat completion message objects.\n" }), - "first_id": Schema.String.annotate({ "description": "The identifier of the first chat message in the data array." }), - "last_id": Schema.String.annotate({ "description": "The identifier of the last chat message in the data array." }), - "has_more": Schema.Boolean.annotate({ "description": "Indicates whether there are more chat messages available." }) -}).annotate({ - "title": "ChatCompletionMessageList", - "description": "An object representing a list of chat completion messages.\n" -}) -export type ChatCompletionResponseMessage = { - readonly "content": string | null - readonly "refusal": string | null - readonly "tool_calls"?: ChatCompletionMessageToolCalls - readonly "annotations"?: ReadonlyArray< - { - readonly "type": "url_citation" - readonly "url_citation": { - readonly "end_index": number - readonly "start_index": number - readonly "url": string - readonly "title": string - } - } - > - readonly "role": "assistant" - readonly "function_call"?: { readonly "arguments": string; readonly "name": string } - readonly "audio"?: { - readonly "id": string - readonly "expires_at": number - readonly "data": string - readonly "transcript": string - } | null -} -export const ChatCompletionResponseMessage = Schema.Struct({ - "content": Schema.Union([Schema.String.annotate({ "description": "The contents of the message." }), Schema.Null]), - "refusal": Schema.Union([ - Schema.String.annotate({ "description": "The refusal message generated by the model." }), - Schema.Null - ]), - "tool_calls": Schema.optionalKey(ChatCompletionMessageToolCalls), - "annotations": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "type": Schema.Literal("url_citation").annotate({ - "description": "The type of the URL citation. Always `url_citation`." - }), - "url_citation": Schema.Struct({ - "end_index": Schema.Number.annotate({ - "description": "The index of the last character of the URL citation in the message." - }).check(Schema.isInt()), - "start_index": Schema.Number.annotate({ - "description": "The index of the first character of the URL citation in the message." - }).check(Schema.isInt()), - "url": Schema.String.annotate({ "description": "The URL of the web resource.", "format": "uri" }), - "title": Schema.String.annotate({ "description": "The title of the web resource." }) - }).annotate({ "description": "A URL citation when using web search." }) - }).annotate({ "description": "A URL citation when using web search.\n" }) - ).annotate({ + "description": Schema.optionalKey( + Schema.String.annotate({ "description": - "Annotations for the message, when applicable, as when using the\n[web search tool](/docs/guides/tools-web-search?api-mode=chat).\n" + "A description of what the response format is for, used by the model to\ndetermine how to respond in the format.\n" }) ), - "role": Schema.Literal("assistant").annotate({ "description": "The role of the author of this message." }), - "function_call": Schema.optionalKey( - Schema.Struct({ - "arguments": Schema.String.annotate({ + "name": Schema.String.annotate({ + "description": + "The name of the response format. Must be a-z, A-Z, 0-9, or contain\nunderscores and dashes, with a maximum length of 64.\n" + }), + "schema": BetaResponseFormatJsonSchemaSchema, + "strict": Schema.optionalKey(Schema.Union([ + Schema.Boolean.annotate({ + "description": + "Whether to enable strict schema adherence when generating the output.\nIf set to true, the model will always follow the exact schema defined\nin the `schema` field. Only a subset of JSON Schema is supported when\n`strict` is `true`. To learn more, read the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n" + }), + Schema.Null + ])) +}).annotate({ + "title": "JSON schema", + "description": + "JSON Schema response format. Used to generate structured JSON responses.\nLearn more about [Structured Outputs](/docs/guides/structured-outputs).\n", + "identifier": "BetaTextResponseFormatJsonSchema" +}) +export type BetaFunctionTool = { + readonly "type": "function" + readonly "name": string + readonly "description"?: string | null + readonly "parameters": {} | null + readonly "output_schema"?: {} | null + readonly "strict": boolean | null + readonly "defer_loading"?: boolean + readonly "allowed_callers"?: ReadonlyArray | null +} +export const BetaFunctionTool = 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": - "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + "A description of the function. Used by the model to determine whether or not to call the function." }), - "name": Schema.String.annotate({ "description": "The name of the function to call." }) - }).annotate({ - "description": - "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model." - }) + Schema.Null + ]) ), - "audio": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "id": Schema.String.annotate({ "description": "Unique identifier for this audio response." }), - "expires_at": Schema.Number.annotate({ - "description": - "The Unix timestamp (in seconds) for when this audio response will\nno longer be accessible on the server for use in multi-turn\nconversations.\n", - "format": "unixtime" - }).check(Schema.isInt()), - "data": Schema.String.annotate({ - "description": "Base64 encoded audio bytes generated by the model, in the format\nspecified in the request.\n" + "parameters": Schema.Union([ + Schema.Struct({}).annotate({ "description": "A JSON schema object describing the parameters of the function." }), + Schema.Null + ]), + "output_schema": Schema.optionalKey( + Schema.Union([ + Schema.Struct({}).annotate({ + "description": "A JSON schema object describing the JSON value encoded in string outputs for this function." }), - "transcript": Schema.String.annotate({ "description": "Transcript of the audio generated by the model." }) - }).annotate({ - "description": - "If the audio output modality is requested, this object contains data\nabout the audio response from the model. [Learn more](/docs/guides/audio).\n" + Schema.Null + ]) + ), + "strict": Schema.Union([ + Schema.Boolean.annotate({ + "description": "Whether strict parameter validation is enforced for this function tool." }), Schema.Null - ])) -}).annotate({ "description": "A chat completion message generated by the model." }) -export type CreateChatCompletionStreamResponse = { - readonly "id": string - readonly "choices": ReadonlyArray< - { - readonly "delta": ChatCompletionStreamResponseDelta - readonly "logprobs"?: { - readonly "content": ReadonlyArray< - { - readonly "token": string - readonly "logprob": number - readonly "bytes": ReadonlyArray | null - readonly "top_logprobs": ReadonlyArray< - { readonly "token": string; readonly "logprob": number; readonly "bytes": ReadonlyArray | null } - > - } - > - readonly "refusal": ReadonlyArray< - { - readonly "token": string - readonly "logprob": number - readonly "bytes": ReadonlyArray | null - readonly "top_logprobs": ReadonlyArray< - { readonly "token": string; readonly "logprob": number; readonly "bytes": ReadonlyArray | null } - > - } - > - } - readonly "finish_reason": "stop" | "length" | "tool_calls" | "content_filter" | "function_call" | null - readonly "index": number - } - > - readonly "created": number - readonly "model": string - readonly "service_tier"?: ServiceTier - readonly "system_fingerprint"?: string - readonly "object": "chat.completion.chunk" - readonly "usage"?: { - readonly "completion_tokens": number - readonly "prompt_tokens": number - readonly "total_tokens": number - readonly "completion_tokens_details"?: { - readonly "accepted_prediction_tokens"?: number - readonly "audio_tokens"?: number - readonly "reasoning_tokens"?: number - readonly "rejected_prediction_tokens"?: number - } - readonly "prompt_tokens_details"?: { readonly "audio_tokens"?: number; readonly "cached_tokens"?: number } - } | null -} -export const CreateChatCompletionStreamResponse = Schema.Struct({ - "id": Schema.String.annotate({ - "description": "A unique identifier for the chat completion. Each chunk has the same ID." - }), - "choices": Schema.Array(Schema.Struct({ - "delta": ChatCompletionStreamResponseDelta, - "logprobs": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "content": Schema.Union([ - Schema.Array(Schema.Struct({ - "token": Schema.String.annotate({ "description": "The token." }), - "logprob": Schema.Number.annotate({ - "description": - "The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely." - }).check(Schema.isFinite()), - "bytes": Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "description": - "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token." - }), - Schema.Null - ]), - "top_logprobs": Schema.Array(Schema.Struct({ - "token": Schema.String.annotate({ "description": "The token." }), - "logprob": Schema.Number.annotate({ - "description": - "The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely." - }).check(Schema.isFinite()), - "bytes": Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "description": - "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token." - }), - Schema.Null - ]) - })).annotate({ - "description": - "List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`." - }) - })).annotate({ "description": "A list of message content tokens with log probability information." }) - ]), - "refusal": Schema.Union([ - Schema.Array(Schema.Struct({ - "token": Schema.String.annotate({ "description": "The token." }), - "logprob": Schema.Number.annotate({ - "description": - "The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely." - }).check(Schema.isFinite()), - "bytes": Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "description": - "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token." - }), - Schema.Null - ]), - "top_logprobs": Schema.Array(Schema.Struct({ - "token": Schema.String.annotate({ "description": "The token." }), - "logprob": Schema.Number.annotate({ - "description": - "The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely." - }).check(Schema.isFinite()), - "bytes": Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt())).annotate({ - "description": - "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token." - }), - Schema.Null - ]) - })).annotate({ - "description": - "List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`." - }) - })).annotate({ "description": "A list of message refusal tokens with log probability information." }) - ]) - }).annotate({ "description": "Log probability information for the choice." }) - ])), - "finish_reason": Schema.Union([ - Schema.Literals(["stop", "length", "tool_calls", "content_filter", "function_call"]).annotate({ - "description": - "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\n" - }), - Schema.Union([Schema.Null]).annotate({ - "description": - "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\n" - }) - ]), - "index": Schema.Number.annotate({ "description": "The index of the choice in the list of choices." }).check( - Schema.isInt() - ) - })).annotate({ - "description": - "A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the\nlast chunk if you set `stream_options: {\"include_usage\": true}`.\n" - }), - "created": Schema.Number.annotate({ - "description": - "The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.", - "format": "unixtime" - }).check(Schema.isInt()), - "model": Schema.String.annotate({ "description": "The model to generate the completion." }), - "service_tier": Schema.optionalKey(ServiceTier), - "system_fingerprint": Schema.optionalKey( - Schema.String.annotate({ - "description": - "This fingerprint represents the backend configuration that the model runs with.\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" - }) + ]), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this function is deferred and loaded via tool search." }) ), - "object": Schema.Literal("chat.completion.chunk").annotate({ - "description": "The object type, which is always `chat.completion.chunk`." - }), - "usage": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "completion_tokens": Schema.Number.annotate({ "description": "Number of tokens in the generated completion." }) - .check(Schema.isInt()), - "prompt_tokens": Schema.Number.annotate({ "description": "Number of tokens in the prompt." }).check( - Schema.isInt() - ), - "total_tokens": Schema.Number.annotate({ - "description": "Total number of tokens used in the request (prompt + completion)." - }).check(Schema.isInt()), - "completion_tokens_details": Schema.optionalKey( - Schema.Struct({ - "accepted_prediction_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "When using Predicted Outputs, the number of tokens in the\nprediction that appeared in the completion.\n" - }).check(Schema.isInt()) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Audio input tokens generated by the model." }).check( - Schema.isInt() - ) - ), - "reasoning_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Tokens generated by the model for reasoning." }).check( - Schema.isInt() - ) - ), - "rejected_prediction_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "When using Predicted Outputs, the number of tokens in the\nprediction that did not appear in the completion. However, like\nreasoning tokens, these tokens are still counted in the total\ncompletion tokens for purposes of billing, output, and context window\nlimits.\n" - }).check(Schema.isInt()) - ) - }).annotate({ "description": "Breakdown of tokens used in a completion." }) - ), - "prompt_tokens_details": Schema.optionalKey( - Schema.Struct({ - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Audio input tokens present in the prompt." }).check(Schema.isInt()) - ), - "cached_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Cached tokens present in the prompt." }).check(Schema.isInt()) - ) - }).annotate({ "description": "Breakdown of tokens used in the prompt." }) - ) - }).annotate({ - "description": - "An optional field that will only be present when you set\n`stream_options: {\"include_usage\": true}` in your request. When present, it\ncontains a null value **except for the last chunk** which contains the\ntoken usage statistics for the entire request.\n\n**NOTE:** If the stream is interrupted or cancelled, you may not\nreceive the final usage chunk which contains the total token usage for\nthe request.\n" - }), - Schema.Null - ])) + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(BetaCallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }), + Schema.Null + ]) + ) }).annotate({ + "title": "Function", "description": - "Represents a streamed chunk of a chat completion response returned\nby the model, based on the provided input. \n[Learn more](/docs/guides/streaming-responses).\n" + "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).", + "identifier": "BetaFunctionTool" }) -export type ChatCompletionRequestAssistantMessage = { - readonly "content"?: string | ReadonlyArray | null - readonly "refusal"?: string | null - readonly "role": "assistant" - readonly "name"?: string - readonly "audio"?: { readonly "id": string } | null - readonly "tool_calls"?: ChatCompletionMessageToolCalls - readonly "function_call"?: { readonly "arguments": string; readonly "name": string } | null +export type BetaApplyPatchToolParam = { + readonly "type": "apply_patch" + readonly "allowed_callers"?: ReadonlyArray | null } -export const ChatCompletionRequestAssistantMessage = Schema.Struct({ - "content": Schema.optionalKey( +export const BetaApplyPatchToolParam = Schema.Struct({ + "type": Schema.Literal("apply_patch").annotate({ "description": "The type of the tool. Always `apply_patch`." }), + "allowed_callers": Schema.optionalKey( Schema.Union([ - Schema.Union([ - Schema.String.annotate({ "title": "Text content", "description": "The contents of the assistant message." }), - Schema.Array(ChatCompletionRequestAssistantMessageContentPart).annotate({ - "title": "Array of content parts", - "description": - "An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`." - }).check(Schema.isMinLength(1)) - ], { mode: "oneOf" }).annotate({ - "description": - "The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.\n" - }), + Schema.Array(BetaCallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), Schema.Null ]) + ) +}).annotate({ + "title": "Apply patch tool", + "description": "Allows the assistant to create, delete, or update files using unified diffs.", + "identifier": "BetaApplyPatchToolParam" +}) +export type BetaRankingOptions = { + readonly "ranker"?: BetaRankerVersionType + readonly "score_threshold"?: number + readonly "hybrid_search"?: BetaHybridSearchOptions +} +export const BetaRankingOptions = Schema.Struct({ + "ranker": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaRankerVersionType).annotate({ + "description": "The ranker to use for the file search." + }) ), - "refusal": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "The refusal message by the assistant." }), Schema.Null]) + "score_threshold": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), - "role": Schema.Literal("assistant").annotate({ - "description": "The role of the messages author, in this case `assistant`." - }), - "name": Schema.optionalKey( - Schema.String.annotate({ + "hybrid_search": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaHybridSearchOptions).annotate({ "description": - "An optional name for the participant. Provides the model information to differentiate between participants of the same role." + "Weights that control how reciprocal rank fusion balances semantic embedding matches versus sparse keyword matches when hybrid search is enabled." }) + ) +}).annotate({ "identifier": "BetaRankingOptions" }) +export type BetaCompoundFilter = { + readonly "type": "and" | "or" + readonly "filters": ReadonlyArray +} +export const BetaCompoundFilter = Schema.Struct({ + "type": Schema.Literals(["and", "or"]).annotate({ "description": "Type of operation: `and` or `or`." }), + "filters": Schema.Array( + Schema.Union([BetaComparisonFilter, Schema.Json.annotate({ "expected": "JSON value" })], { mode: "oneOf" }) + ).annotate({ "description": "Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`." }) +}).annotate({ + "title": "Compound Filter", + "description": "Combine multiple filters using `and` or `or`.", + "identifier": "BetaCompoundFilter" +}) +export type BetaComputerUsePreviewTool = { + readonly "type": "computer_use_preview" + readonly "environment": BetaComputerEnvironment + readonly "display_width": number + readonly "display_height": number +} +export const BetaComputerUsePreviewTool = Schema.Struct({ + "type": Schema.Literal("computer_use_preview").annotate({ + "description": "The type of the computer use tool. Always `computer_use_preview`." + }), + "environment": Schema.suspend((): Schema.Codec => BetaComputerEnvironment).annotate({ + "description": "The type of computer environment to control." + }), + "display_width": Schema.Number.annotate({ "description": "The width of the computer display." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "audio": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "id": Schema.String.annotate({ - "description": "Unique identifier for a previous audio response from the model.\n" - }) - }).annotate({ - "description": "Data about a previous audio response from the model.\n[Learn more](/docs/guides/audio).\n" - }), - Schema.Null - ]) - ), - "tool_calls": Schema.optionalKey(ChatCompletionMessageToolCalls), - "function_call": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "arguments": Schema.String.annotate({ - "description": - "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." - }), - "name": Schema.String.annotate({ "description": "The name of the function to call." }) - }).annotate({ - "description": - "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model." - }), - Schema.Null - ])) + "display_height": Schema.Number.annotate({ "description": "The height of the computer display." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) }).annotate({ - "title": "Assistant message", - "description": "Messages sent by the model in response to user messages.\n" + "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).", + "identifier": "BetaComputerUsePreviewTool" }) -export type ChatCompletionRequestSystemMessage = { - readonly "content": string | ReadonlyArray - readonly "role": "system" - readonly "name"?: string +export type BetaWebSearchTool = { + readonly "type": "web_search" | "web_search_2025_08_26" + readonly "filters"?: { readonly "allowed_domains"?: ReadonlyArray | null } | null + readonly "user_location"?: BetaWebSearchApproximateLocation + readonly "search_context_size"?: "low" | "medium" | "high" } -export const ChatCompletionRequestSystemMessage = Schema.Struct({ - "content": Schema.Union([ - Schema.String.annotate({ "title": "Text content", "description": "The contents of the system message." }), - Schema.Array(ChatCompletionRequestSystemMessageContentPart).annotate({ - "title": "Array of content parts", - "description": - "An array of content parts with a defined type. For system messages, only type `text` is supported." - }).check(Schema.isMinLength(1)) - ], { mode: "oneOf" }).annotate({ "description": "The contents of the system message." }), - "role": Schema.Literal("system").annotate({ - "description": "The role of the messages author, in this case `system`." +export const BetaWebSearchTool = Schema.Struct({ + "type": Schema.Literals(["web_search", "web_search_2025_08_26"]).annotate({ + "description": "The type of the web search tool. One of `web_search` or `web_search_2025_08_26`." }), - "name": Schema.optionalKey( - Schema.String.annotate({ + "filters": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "allowed_domains": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String.annotate({ "description": "Allowed domain for the search." })).annotate({ + "title": "Allowed domains for the search.", + "description": + "Allowed domains for the search. If not provided, all domains are allowed.\nSubdomains of the provided domains are allowed as well.\n\nExample: `[\"pubmed.ncbi.nlm.nih.gov\"]`\n" + }), + Schema.Null + ]) + ) + }).annotate({ "description": "Filters for the search.\n" }), + Schema.Null + ])), + "user_location": Schema.optionalKey(BetaWebSearchApproximateLocation), + "search_context_size": Schema.optionalKey( + Schema.Literals(["low", "medium", "high"]).annotate({ "description": - "An optional name for the participant. Provides the model information to differentiate between participants of the same role." + "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": "System message", + "title": "Web search", "description": - "Developer-provided instructions that the model should follow, regardless of\nmessages sent by the user. With o1 models and newer, use `developer` messages\nfor this purpose instead.\n" + "Search the Internet for sources related to the prompt. Learn more about the\n[web search tool](/docs/guides/tools-web-search).\n", + "identifier": "BetaWebSearchTool" }) -export type ChatCompletionRequestToolMessage = { - readonly "role": "tool" - readonly "content": string | ReadonlyArray - readonly "tool_call_id": string +export type BetaMCPTool = { + readonly "type": "mcp" + readonly "server_label": string + readonly "server_url"?: string + readonly "connector_id"?: + | "connector_dropbox" + | "connector_gmail" + | "connector_googlecalendar" + | "connector_googledrive" + | "connector_microsoftteams" + | "connector_outlookcalendar" + | "connector_outlookemail" + | "connector_sharepoint" + readonly "tunnel_id"?: string + readonly "authorization"?: string + readonly "server_description"?: string + readonly "headers"?: {} | null + readonly "allowed_tools"?: ReadonlyArray | BetaMCPToolFilter | null + readonly "allowed_callers"?: ReadonlyArray | null + readonly "require_approval"?: + | { readonly "always"?: BetaMCPToolFilter; readonly "never"?: BetaMCPToolFilter } + | "always" + | "never" + | null + readonly "defer_loading"?: boolean } -export const ChatCompletionRequestToolMessage = Schema.Struct({ - "role": Schema.Literal("tool").annotate({ "description": "The role of the messages author, in this case `tool`." }), - "content": Schema.Union([ - Schema.String.annotate({ "title": "Text content", "description": "The contents of the tool message." }), - Schema.Array(ChatCompletionRequestToolMessageContentPart).annotate({ - "title": "Array of content parts", - "description": "An array of content parts with a defined type. For tool messages, only type `text` is supported." - }).check(Schema.isMinLength(1)) - ], { mode: "oneOf" }).annotate({ "description": "The contents of the tool message." }), - "tool_call_id": Schema.String.annotate({ "description": "Tool call that this message is responding to." }) -}).annotate({ "title": "Tool message" }) -export type ChatCompletionRequestUserMessage = { - readonly "content": string | ReadonlyArray - readonly "role": "user" - readonly "name"?: string -} -export const ChatCompletionRequestUserMessage = Schema.Struct({ - "content": Schema.Union([ - Schema.String.annotate({ "title": "Text content", "description": "The text contents of the message." }), - Schema.Array(ChatCompletionRequestUserMessageContentPart).annotate({ - "title": "Array of content parts", - "description": - "An array of content parts with a defined type. Supported options differ based on the [model](/docs/models) being used to generate the response. Can contain text, image, or audio inputs." - }).check(Schema.isMinLength(1)) - ], { mode: "oneOf" }).annotate({ "description": "The contents of the user message.\n" }), - "role": Schema.Literal("user").annotate({ "description": "The role of the messages author, in this case `user`." }), - "name": Schema.optionalKey( +export const BetaMCPTool = Schema.Struct({ + "type": Schema.Literal("mcp").annotate({ "description": "The type of the MCP tool. Always `mcp`." }), + "server_label": Schema.String.annotate({ + "description": "A label for this MCP server, used to identify it in tool calls.\n" + }), + "server_url": Schema.optionalKey( Schema.String.annotate({ "description": - "An optional name for the participant. Provides the model information to differentiate between participants of the same role." + "The URL for the MCP server. One of `server_url`, `connector_id`, or\n`tunnel_id` must be provided.\n", + "format": "uri" }) - ) -}).annotate({ - "title": "User message", - "description": "Messages sent by an end user, containing prompts or additional context\ninformation.\n" -}) -export type VectorStoreSearchRequest = { - readonly "query": string | ReadonlyArray - readonly "rewrite_query"?: boolean - readonly "max_num_results"?: number - readonly "filters"?: ComparisonFilter | CompoundFilter - readonly "ranking_options"?: { - readonly "ranker"?: "none" | "auto" | "default-2024-11-15" - readonly "score_threshold"?: number - } -} -export const VectorStoreSearchRequest = Schema.Struct({ - "query": Schema.Union([ - Schema.String, - Schema.Array(Schema.String.annotate({ "description": "A list of queries to search for." })) - ], { mode: "oneOf" }).annotate({ "description": "A query string for a search" }), - "rewrite_query": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether to rewrite the natural language query for vector search." }) ), - "max_num_results": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The maximum number of results to return. This number should be between 1 and 50 inclusive." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(50)) + "connector_id": Schema.optionalKey( + Schema.Literals([ + "connector_dropbox", + "connector_gmail", + "connector_googlecalendar", + "connector_googledrive", + "connector_microsoftteams", + "connector_outlookcalendar", + "connector_outlookemail", + "connector_sharepoint" + ]).annotate({ + "description": + "Identifier for service connectors, like those available in ChatGPT. One of\n`server_url`, `connector_id`, or `tunnel_id` must be provided. Learn more\nabout service connectors [here](/docs/guides/tools-remote-mcp#connectors).\n\nCurrently supported `connector_id` values are:\n\n- Dropbox: `connector_dropbox`\n- Gmail: `connector_gmail`\n- Google Calendar: `connector_googlecalendar`\n- Google Drive: `connector_googledrive`\n- Microsoft Teams: `connector_microsoftteams`\n- Outlook Calendar: `connector_outlookcalendar`\n- Outlook Email: `connector_outlookemail`\n- SharePoint: `connector_sharepoint`\n" + }) ), - "filters": Schema.optionalKey( - Schema.Union([ComparisonFilter, CompoundFilter], { mode: "oneOf" }).annotate({ - "description": "A filter to apply based on file attributes." + "tunnel_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The Secure MCP Tunnel ID to use instead of a direct server URL. One of\n`server_url`, `connector_id`, or `tunnel_id` must be provided.\n" + }).check( + Schema.isPattern(new RegExp("^tunnel_[a-z0-9]{32}$")).annotate({ + "expected": "a string matching the RegExp ^tunnel_[a-z0-9]{32}$" + }) + ) + ), + "authorization": Schema.optionalKey( + Schema.String.annotate({ + "description": + "An OAuth access token that can be used with a remote MCP server, either\nwith a custom MCP server URL or a service connector. Your application\nmust handle the OAuth authorization flow and provide the token here.\n" }) ), - "ranking_options": Schema.optionalKey( - Schema.Struct({ - "ranker": Schema.optionalKey( - Schema.Literals(["none", "auto", "default-2024-11-15"]).annotate({ - "description": "Enable re-ranking; set to `none` to disable, which can help reduce latency." - }) - ), - "score_threshold": Schema.optionalKey( - Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check( - Schema.isLessThanOrEqualTo(1) - ) - ) - }).annotate({ "description": "Ranking options for search." }) - ) -}) -export type FileSearchTool = { - readonly "type": "file_search" - readonly "vector_store_ids": ReadonlyArray - readonly "max_num_results"?: number - readonly "ranking_options"?: { - readonly "ranker"?: "auto" | "default-2024-11-15" - readonly "score_threshold"?: number - readonly "hybrid_search"?: { readonly "embedding_weight": number; readonly "text_weight": number } - } - readonly "filters"?: ComparisonFilter | CompoundFilter | null -} -export const FileSearchTool = Schema.Struct({ - "type": Schema.Literal("file_search").annotate({ - "description": "The type of the file search tool. Always `file_search`." - }), - "vector_store_ids": Schema.Array(Schema.String).annotate({ - "description": "The IDs of the vector stores to search." - }), - "max_num_results": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The maximum number of results to return. This number should be between 1 and 50 inclusive." - }).check(Schema.isInt()) + "server_description": Schema.optionalKey( + Schema.String.annotate({ "description": "Optional description of the MCP server, used to provide more context.\n" }) ), - "ranking_options": Schema.optionalKey( - Schema.Struct({ - "ranker": Schema.optionalKey( - Schema.Literals(["auto", "default-2024-11-15"]).annotate({ - "description": "The ranker to use for the file search." - }) - ), - "score_threshold": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results." - }).check(Schema.isFinite()) + "headers": Schema.optionalKey( + Schema.Union([ + Schema.Struct({}).annotate({ + "description": "Optional HTTP headers to send to the MCP server. Use for authentication\nor other purposes.\n" + }), + Schema.Null + ]) + ), + "allowed_tools": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.Array(Schema.String).annotate({ + "title": "MCP allowed tools", + "description": "A string array of allowed tool names" + }), + BetaMCPToolFilter + ], { mode: "oneOf" }).annotate({ "description": "List of allowed tool names or a filter object.\n" }), + Schema.Null + ]) + ), + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(BetaCallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), - "hybrid_search": Schema.optionalKey( + Schema.Null + ]) + ), + "require_approval": Schema.optionalKey( + Schema.Union([ + Schema.Union([ Schema.Struct({ - "embedding_weight": Schema.Number.annotate({ - "description": "The weight of the embedding in the reciprocal ranking fusion." - }).check(Schema.isFinite()), - "text_weight": Schema.Number.annotate({ - "description": "The weight of the text in the reciprocal ranking fusion." - }).check(Schema.isFinite()) + "always": Schema.optionalKey(BetaMCPToolFilter), + "never": Schema.optionalKey(BetaMCPToolFilter) }).annotate({ + "title": "MCP tool approval filter", "description": - "Weights that control how reciprocal rank fusion balances semantic embedding matches versus sparse keyword matches when hybrid search is enabled." + "Specify which of the MCP server's tools require approval. Can be\n`always`, `never`, or a filter object associated with tools\nthat require approval.\n" + }), + Schema.Literals(["always", "never"]).annotate({ + "title": "MCP tool approval setting", + "description": + "Specify a single approval policy for all tools. One of `always` or\n`never`. When set to `always`, all tools will require approval. When\nset to `never`, all tools will not require approval.\n" }) - ) - }).annotate({ "description": "Ranking options for search." }) - ), - "filters": Schema.optionalKey( - Schema.Union([ - Schema.Union([ComparisonFilter, CompoundFilter]).annotate({ "description": "A filter to apply." }), + ], { 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": "File search", + "title": "MCP tool", "description": - "A tool that searches for relevant content from uploaded files. Learn more about the [file search tool](https://platform.openai.com/docs/guides/tools-file-search)." + "Give the model access to additional tools via remote Model Context Protocol\n(MCP) servers. [Learn more about MCP](/docs/guides/tools-remote-mcp).\n", + "identifier": "BetaMCPTool" }) -export type EvalRunOutputItemList = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean +export type BetaContainerNetworkPolicyAllowlistParam = { + readonly "type": "allowlist" + readonly "allowed_domains": ReadonlyArray + readonly "domain_secrets"?: ReadonlyArray } -export const EvalRunOutputItemList = Schema.Struct({ - "object": Schema.Literal("list").annotate({ - "description": "The type of this object. It is always set to \"list\".\n" - }), - "data": Schema.Array(EvalRunOutputItem).annotate({ "description": "An array of eval run output item objects.\n" }), - "first_id": Schema.String.annotate({ - "description": "The identifier of the first eval run output item in the data array." - }), - "last_id": Schema.String.annotate({ - "description": "The identifier of the last eval run output item in the data array." +export const BetaContainerNetworkPolicyAllowlistParam = Schema.Struct({ + "type": Schema.Literal("allowlist").annotate({ + "description": "Allow outbound network access only to specified domains. Always `allowlist`." }), - "has_more": Schema.Boolean.annotate({ - "description": "Indicates whether there are more eval run output items available." - }) -}).annotate({ - "title": "EvalRunOutputItemList", - "description": "An object representing a list of output items for an evaluation run.\n" -}) -export type AssistantToolsFileSearch = { - readonly "type": "file_search" - readonly "file_search"?: { - readonly "max_num_results"?: number - readonly "ranking_options"?: FileSearchRankingOptions - } -} -export const AssistantToolsFileSearch = Schema.Struct({ - "type": Schema.Literal("file_search").annotate({ "description": "The type of tool being defined: `file_search`" }), - "file_search": Schema.optionalKey( - Schema.Struct({ - "max_num_results": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.\n\nNote that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check(Schema.isLessThanOrEqualTo(50)) - ), - "ranking_options": Schema.optionalKey(FileSearchRankingOptions) - }).annotate({ "description": "Overrides for the file search tool." }) + "allowed_domains": Schema.Array(Schema.String).annotate({ + "description": "A list of allowed domains when type is `allowlist`." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "domain_secrets": Schema.optionalKey( + Schema.Array(BetaContainerNetworkPolicyDomainSecretParam).annotate({ + "description": "Optional domain-scoped secrets for allowlisted domains." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) ) -}).annotate({ "title": "FileSearch tool" }) -export type RunStepDetailsToolCallsFileSearchObject = { - readonly "id": string - readonly "type": "file_search" - readonly "file_search": { - readonly "ranking_options"?: RunStepDetailsToolCallsFileSearchRankingOptionsObject - readonly "results"?: ReadonlyArray - } +}).annotate({ "identifier": "BetaContainerNetworkPolicyAllowlistParam" }) +export type BetaImageGenTool = { + 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"?: string | "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"?: BetaInputFidelity | null + readonly "input_image_mask"?: { readonly "image_url"?: string; readonly "file_id"?: string } + readonly "partial_images"?: number + readonly "action"?: BetaImageGenActionEnum } -export const RunStepDetailsToolCallsFileSearchObject = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The ID of the tool call object." }), - "type": Schema.Literal("file_search").annotate({ - "description": "The type of tool call. This is always going to be `file_search` for this type of tool call." +export const BetaImageGenTool = Schema.Struct({ + "type": Schema.Literal("image_generation").annotate({ + "description": "The type of the image generation tool. Always `image_generation`.\n" }), - "file_search": Schema.Struct({ - "ranking_options": Schema.optionalKey(RunStepDetailsToolCallsFileSearchRankingOptionsObject), - "results": Schema.optionalKey( - Schema.Array(RunStepDetailsToolCallsFileSearchResultObject).annotate({ - "description": "The results of the file search." + "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" }) - ) - }).annotate({ "description": "For now, this is always going to be an empty object." }) -}).annotate({ "title": "File search tool call" }) -export type AssistantToolsFunction = { readonly "type": "function"; readonly "function": FunctionObject } -export const AssistantToolsFunction = Schema.Struct({ - "type": Schema.Literal("function").annotate({ "description": "The type of tool being defined: `function`" }), - "function": FunctionObject -}).annotate({ "title": "Function tool" }) -export type ChatCompletionTool = { readonly "type": "function"; readonly "function": FunctionObject } -export const ChatCompletionTool = Schema.Struct({ - "type": Schema.Literal("function").annotate({ - "description": "The type of the tool. Currently, only `function` is supported." - }), - "function": FunctionObject -}).annotate({ "title": "Function tool", "description": "A function tool that can be used to generate a response.\n" }) -export type ImageEditStreamEvent = ImageEditPartialImageEvent | ImageEditCompletedEvent -export const ImageEditStreamEvent = Schema.Union([ImageEditPartialImageEvent, ImageEditCompletedEvent]) -export type ImageGenStreamEvent = ImageGenPartialImageEvent | ImageGenCompletedEvent -export const ImageGenStreamEvent = Schema.Union([ImageGenPartialImageEvent, ImageGenCompletedEvent]) -export type MessageObject = { - readonly "id": string - readonly "object": "thread.message" - readonly "created_at": number - readonly "thread_id": string - readonly "status": "in_progress" | "incomplete" | "completed" - readonly "incomplete_details": { - readonly "reason": "content_filter" | "max_tokens" | "run_cancelled" | "run_expired" | "run_failed" - } | null - readonly "completed_at": number | null - readonly "incomplete_at": number | null - readonly "role": "user" | "assistant" - readonly "content": ReadonlyArray< - | MessageContentImageFileObject - | MessageContentImageUrlObject - | MessageContentTextObject - | MessageContentRefusalObject - > - readonly "assistant_id": string | null - readonly "run_id": string | null - readonly "attachments": - | ReadonlyArray< - { - readonly "file_id"?: string - readonly "tools"?: ReadonlyArray - } - > - | null - readonly "metadata": Metadata -} -export const MessageObject = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), - "object": Schema.Literal("thread.message").annotate({ - "description": "The object type, which is always `thread.message`." - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the message was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "thread_id": Schema.String.annotate({ - "description": "The [thread](/docs/api-reference/threads) ID that this message belongs to." - }), - "status": Schema.Literals(["in_progress", "incomplete", "completed"]).annotate({ - "description": "The status of the message, which can be either `in_progress`, `incomplete`, or `completed`." - }), - "incomplete_details": Schema.Union([ - Schema.Struct({ - "reason": Schema.Literals(["content_filter", "max_tokens", "run_cancelled", "run_expired", "run_failed"]) - .annotate({ "description": "The reason the message is incomplete." }) - }).annotate({ "description": "On an incomplete message, details about why the message is incomplete." }), - Schema.Null - ]), - "completed_at": Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the message was completed.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]), - "incomplete_at": Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the message was marked as incomplete.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]), - "role": Schema.Literals(["user", "assistant"]).annotate({ - "description": "The entity that produced the message. One of `user` or `assistant`." - }), - "content": Schema.Array( - Schema.Union([ - MessageContentImageFileObject, - MessageContentImageUrlObject, - MessageContentTextObject, - MessageContentRefusalObject - ], { mode: "oneOf" }) - ).annotate({ "description": "The content of the message in array of text and/or images." }), - "assistant_id": Schema.Union([ - Schema.String.annotate({ + ]) + ), + "quality": Schema.optionalKey( + Schema.Literals(["low", "medium", "high", "auto"]).annotate({ "description": - "If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message." - }), - Schema.Null - ]), - "run_id": Schema.Union([ - Schema.String.annotate({ + "The quality of the generated image. One of `low`, `medium`, `high`,\nor `auto`. Default: `auto`.\n" + }) + ), + "size": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Literals(["1024x1024", "1024x1536", "1536x1024", "auto"])]).annotate({ "description": - "The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints." - }), - Schema.Null - ]), - "attachments": Schema.Union([ - Schema.Array(Schema.Struct({ - "file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the file to attach to the message." }) - ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Union([AssistantToolsCode, AssistantToolsFileSearchTypeOnly], { mode: "oneOf" })).annotate({ - "description": "The tools to add this file to." - }) - ) - })).annotate({ "description": "A list of files attached to the message, and the tools they were added to." }), - Schema.Null - ]), - "metadata": Metadata + "The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`." + }) + ), + "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().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" })).check( + Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 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([BetaInputFidelity, 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().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(3).annotate({ "expected": "a value less than or equal to 3" })) + ), + "action": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaImageGenActionEnum).annotate({ + "description": "Whether to generate a new image or edit an existing image. Default: `auto`.\n" + }) + ) }).annotate({ - "title": "The message object", - "description": "Represents a message within a [thread](/docs/api-reference/threads)." + "title": "Image generation tool", + "description": "A tool that generates images using the GPT image models.\n", + "identifier": "BetaImageGenTool" }) -export type MessageDeltaObject = { - readonly "id": string - readonly "object": "thread.message.delta" - readonly "delta": { - readonly "role"?: "user" | "assistant" - readonly "content"?: ReadonlyArray< - | MessageDeltaContentImageFileObject - | MessageDeltaContentTextObject - | MessageDeltaContentRefusalObject - | MessageDeltaContentImageUrlObject - > - } +export type BetaInlineSkillParam = { + readonly "type": "inline" + readonly "name": string + readonly "description": string + readonly "source": BetaInlineSkillSourceParam } -export const MessageDeltaObject = Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The identifier of the message, which can be referenced in API endpoints." - }), - "object": Schema.Literal("thread.message.delta").annotate({ - "description": "The object type, which is always `thread.message.delta`." - }), - "delta": Schema.Struct({ - "role": Schema.optionalKey( - Schema.Literals(["user", "assistant"]).annotate({ - "description": "The entity that produced the message. One of `user` or `assistant`." - }) - ), - "content": Schema.optionalKey( - Schema.Array( - Schema.Union([ - MessageDeltaContentImageFileObject, - MessageDeltaContentTextObject, - MessageDeltaContentRefusalObject, - MessageDeltaContentImageUrlObject - ], { mode: "oneOf" }) - ).annotate({ "description": "The content of the message in array of text and/or images." }) +export const BetaInlineSkillParam = Schema.Struct({ + "type": Schema.Literal("inline").annotate({ "description": "Defines an inline skill for this request." }), + "name": Schema.String.annotate({ "description": "The name of the skill." }), + "description": Schema.String.annotate({ "description": "The description of the skill." }), + "source": Schema.suspend((): Schema.Codec => BetaInlineSkillSourceParam).annotate({ + "description": "Inline skill payload" + }) +}).annotate({ "identifier": "BetaInlineSkillParam" }) +export type BetaLocalEnvironmentParam = { + readonly "type": "local" + readonly "skills"?: ReadonlyArray +} +export const BetaLocalEnvironmentParam = Schema.Struct({ + "type": Schema.Literal("local").annotate({ "description": "Use a local computer environment." }), + "skills": Schema.optionalKey( + Schema.Array(BetaLocalSkillParam).annotate({ "description": "An optional list of skills." }).check( + Schema.isMaxLength(200).annotate({ "expected": "a value with a length of at most 200" }) ) - }).annotate({ "description": "The delta containing the fields that have changed on the Message." }) -}).annotate({ - "title": "Message delta object", - "description": "Represents a message delta i.e. any changed fields on a message during streaming.\n" -}) -export type ListBatchesResponse = { - readonly "data": ReadonlyArray - readonly "first_id"?: string - readonly "last_id"?: string - readonly "has_more": boolean - readonly "object": "list" + ) +}).annotate({ "identifier": "BetaLocalEnvironmentParam" }) +export type BetaCustomGrammarFormatParam = { + readonly "type": "grammar" + readonly "syntax": BetaGrammarSyntax1 + readonly "definition": string } -export const ListBatchesResponse = Schema.Struct({ - "data": Schema.Array(Batch), - "first_id": Schema.optionalKey(Schema.String), - "last_id": Schema.optionalKey(Schema.String), - "has_more": Schema.Boolean, - "object": Schema.Literal("list") +export const BetaCustomGrammarFormatParam = Schema.Struct({ + "type": Schema.Literal("grammar").annotate({ "description": "Grammar format. Always `grammar`." }), + "syntax": Schema.suspend((): Schema.Codec => BetaGrammarSyntax1).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.", + "identifier": "BetaCustomGrammarFormatParam" }) -export type CreateThreadRequest = { - readonly "messages"?: ReadonlyArray - readonly "tool_resources"?: { - readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } - readonly "file_search"?: { - readonly "vector_store_ids": ReadonlyArray - readonly "vector_stores"?: ReadonlyArray< - { - readonly "file_ids"?: ReadonlyArray - readonly "chunking_strategy"?: { readonly "type": "auto" } | { - readonly "type": "static" - readonly "static": { readonly "max_chunk_size_tokens": number; readonly "chunk_overlap_tokens": number } - } - readonly "metadata"?: Metadata - } - > - } | { - readonly "vector_stores": ReadonlyArray< - { - readonly "file_ids"?: ReadonlyArray - readonly "chunking_strategy"?: { readonly "type": "auto" } | { - readonly "type": "static" - readonly "static": { readonly "max_chunk_size_tokens": number; readonly "chunk_overlap_tokens": number } - } - readonly "metadata"?: Metadata - } - > - readonly "vector_store_ids"?: ReadonlyArray - } - } | null - readonly "metadata"?: Metadata +export type BetaFunctionToolParam = { + readonly "name": string + readonly "description"?: string | null + readonly "parameters"?: BetaEmptyModelParam | null + readonly "strict"?: boolean | null + readonly "type": "function" + readonly "output_schema"?: {} | null + readonly "defer_loading"?: boolean + readonly "allowed_callers"?: ReadonlyArray | null } -export const CreateThreadRequest = Schema.Struct({ - "messages": Schema.optionalKey( - Schema.Array(CreateMessageRequest).annotate({ - "description": "A list of [messages](/docs/api-reference/messages) to start the thread with." +export const BetaFunctionToolParam = Schema.Struct({ + "name": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + .check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" + }) + ), + "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "parameters": Schema.optionalKey(Schema.Union([BetaEmptyModelParam, Schema.Null])), + "strict": Schema.optionalKey( + Schema.Union([ + Schema.Boolean.annotate({ + "description": + "Whether to enforce strict parameter validation. If omitted, Responses attempts to use strict validation when the schema is compatible, and falls back to non-strict validation otherwise." + }), + Schema.Null + ]) + ), + "type": Schema.Literal("function"), + "output_schema": Schema.optionalKey( + Schema.Union([ + Schema.Struct({}).annotate({ + "description": + "A JSON Schema describing the JSON value encoded in string outputs for this function tool. This does not describe content-array outputs." + }), + Schema.Null + ]) + ), + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Whether this function should be deferred and discovered via tool search." }) ), - "tool_resources": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "code_interpreter": Schema.optionalKey(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" - }).check(Schema.isMaxLength(20)) - ) - })), - "file_search": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "vector_store_ids": Schema.Array(Schema.String).annotate({ - "description": - "The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.\n" - }).check(Schema.isMaxLength(1)), - "vector_stores": Schema.optionalKey( - Schema.Array(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.\n" - }).check(Schema.isMaxLength(100000000)) - ), - "chunking_strategy": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }) - .annotate({ - "title": "Auto Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." - }), - Schema.Struct({ - "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), - "static": Schema.Struct({ - "max_chunk_size_tokens": Schema.Number.annotate({ - "description": - "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(100)).check( - Schema.isLessThanOrEqualTo(4096) - ), - "chunk_overlap_tokens": Schema.Number.annotate({ - "description": - "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" - }).check(Schema.isInt()) - }) - }).annotate({ - "title": "Static Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." - }) - ], { mode: "oneOf" }) - ), - "metadata": Schema.optionalKey(Metadata) - })).annotate({ - "description": - "A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.\n" - }).check(Schema.isMaxLength(1)) - ) - }), - Schema.Struct({ - "vector_stores": Schema.Array(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.\n" - }).check(Schema.isMaxLength(100000000)) - ), - "chunking_strategy": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }) - .annotate({ - "title": "Auto Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." - }), - Schema.Struct({ - "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), - "static": Schema.Struct({ - "max_chunk_size_tokens": Schema.Number.annotate({ - "description": - "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(100)).check( - Schema.isLessThanOrEqualTo(4096) - ), - "chunk_overlap_tokens": Schema.Number.annotate({ - "description": - "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" - }).check(Schema.isInt()) - }) - }).annotate({ - "title": "Static Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." - }) - ], { mode: "oneOf" }) - ), - "metadata": Schema.optionalKey(Metadata) - })).annotate({ - "description": - "A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.\n" - }).check(Schema.isMaxLength(1)), - "vector_store_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.\n" - }).check(Schema.isMaxLength(1)) - ) - }) - ], { mode: "oneOf" })) - }).annotate({ + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(BetaCallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]) + ) +}).annotate({ "identifier": "BetaFunctionToolParam" }) +export type BetaToolSearchToolParam = { + readonly "type": "tool_search" + readonly "execution"?: BetaToolSearchExecutionType + readonly "description"?: string | null + readonly "parameters"?: BetaEmptyModelParam | null +} +export const BetaToolSearchToolParam = Schema.Struct({ + "type": Schema.Literal("tool_search").annotate({ "description": "The type of the tool. Always `tool_search`." }), + "execution": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaToolSearchExecutionType).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.suspend((): Schema.Codec => BetaEmptyModelParam).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.", + "identifier": "BetaToolSearchToolParam" +}) +export type BetaWebSearchPreviewTool = { + readonly "type": "web_search_preview" | "web_search_preview_2025_03_11" + readonly "user_location"?: BetaApproximateLocation | null + readonly "search_context_size"?: BetaSearchContextSize + readonly "search_content_types"?: ReadonlyArray +} +export const BetaWebSearchPreviewTool = 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.suspend((): Schema.Codec => BetaApproximateLocation).annotate({ + "description": "The user's location." + }), + Schema.Null + ]) + ), + "search_context_size": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaSearchContextSize).annotate({ "description": - "A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" - }), - Schema.Null - ])), - "metadata": Schema.optionalKey(Metadata) + "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(BetaSearchContentType)) }).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).", + "identifier": "BetaWebSearchPreviewTool" +}) +export type BetaToolChoiceParam = + | BetaToolChoiceOptions + | BetaToolChoiceAllowed + | BetaToolChoiceTypes + | BetaToolChoiceFunction + | BetaToolChoiceMCP + | BetaToolChoiceCustom + | BetaSpecificProgrammaticToolCallingParam + | BetaSpecificApplyPatchParam + | BetaSpecificFunctionShellParam +export const BetaToolChoiceParam = Schema.Union([ + BetaToolChoiceOptions, + BetaToolChoiceAllowed, + BetaToolChoiceTypes, + BetaToolChoiceFunction, + BetaToolChoiceMCP, + BetaToolChoiceCustom, + BetaSpecificProgrammaticToolCallingParam, + BetaSpecificApplyPatchParam, + BetaSpecificFunctionShellParam +], { mode: "oneOf" }).annotate({ "description": - "Options to create a new thread. If no thread is provided when running a\nrequest, an empty thread will be created.\n" + "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n", + "identifier": "BetaToolChoiceParam" }) -export type ThreadStreamEvent = { - readonly "enabled"?: boolean - readonly "event": "thread.created" - readonly "data": ThreadObject -} -export const ThreadStreamEvent = Schema.Union([ +export type BetaPrompt = { + readonly "id": string + readonly "version"?: string | null + readonly "variables"?: BetaResponsePromptVariables +} | null +export const BetaPrompt = Schema.Union([ Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether to enable input audio transcription." }) + "id": Schema.String.annotate({ "description": "The unique identifier of the prompt template to use." }), + "version": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "Optional version of the prompt template." }), Schema.Null]) ), - "event": Schema.Literal("thread.created"), - "data": ThreadObject - }).annotate({ "description": "Occurs when a new [thread](/docs/api-reference/threads/object) is created." }) -], { mode: "oneOf" }) -export type ModelIdsCompaction = ModelIdsResponses | string | null -export const ModelIdsCompaction = Schema.Union([ModelIdsResponses, Schema.String, Schema.Null]).annotate({ + "variables": Schema.optionalKey(BetaResponsePromptVariables) + }).annotate({ + "description": + "Reference to a prompt template and its variables.\n[Learn more](/docs/guides/text?api-mode=responses#reusable-prompts).\n" + }), + Schema.Null +]).annotate({ "identifier": "BetaPrompt" }) +export type BetaReasoning = { + readonly "mode"?: BetaReasoningModeEnum + readonly "effort"?: BetaReasoningEffort + readonly "summary"?: "auto" | "concise" | "detailed" | null + readonly "context"?: "auto" | "current_turn" | "all_turns" | null + readonly "generate_summary"?: "auto" | "concise" | "detailed" | null +} +export const BetaReasoning = Schema.Struct({ + "mode": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaReasoningModeEnum).annotate({ + "description": + "Controls the reasoning execution mode for the request.\n\nWhen returned on a response, this is the effective execution mode.\n" + }) + ), + "effort": Schema.optionalKey(BetaReasoningEffort), + "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 + ])), + "context": Schema.optionalKey(Schema.Union([ + Schema.Literals(["auto", "current_turn", "all_turns"]).annotate({ + "description": + "Controls which reasoning items are rendered back to the model on later turns.\nIf omitted or set to `auto`, the model determines the context mode. The\n`gpt-5.6` model family defaults to `all_turns`; earlier models default to\n`current_turn`.\n\nWhen returned on a response, this is the effective reasoning context mode\nused for the response.\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": - "Model ID used to generate the response, like `gpt-5` 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." + "**gpt-5 and o-series models only**\n\nConfiguration options for\n[reasoning models](https://platform.openai.com/docs/guides/reasoning).\n", + "identifier": "BetaReasoning" }) -export type RealtimeTranslationClientSecretCreateResponse = { - readonly "value": string - readonly "expires_at": number - readonly "session": RealtimeTranslationSession +export type BetaInputTextContent = { + readonly "type": "input_text" + readonly "text": string + readonly "prompt_cache_breakpoint"?: BetaPromptCacheBreakpointConfig } -export const RealtimeTranslationClientSecretCreateResponse = Schema.Struct({ - "value": Schema.String.annotate({ "description": "The generated client secret value." }), - "expires_at": Schema.Number.annotate({ - "description": "Expiration timestamp for the client secret, in seconds since epoch.", - "format": "unixtime" - }).check(Schema.isInt()), - "session": RealtimeTranslationSession +export const BetaInputTextContent = Schema.Struct({ + "type": Schema.Literal("input_text").annotate({ "description": "The type of the input item. Always `input_text`." }), + "text": Schema.String.annotate({ "description": "The text input to the model." }), + "prompt_cache_breakpoint": Schema.optionalKey(BetaPromptCacheBreakpointConfig) }).annotate({ - "title": "Realtime translation session and client secret", - "description": "Response from creating a translation session and client secret for the Realtime API.\n" + "title": "Input text", + "description": "A text input to the model.", + "identifier": "BetaInputTextContent" }) -export type RealtimeTranslationClientSecretCreateRequest = { - readonly "expires_after"?: { readonly "anchor"?: "created_at"; readonly "seconds"?: number } - readonly "session": RealtimeTranslationSessionCreateRequest +export type BetaInputImageContent = { + readonly "type": "input_image" + readonly "image_url"?: string | null + readonly "file_id"?: string | null + readonly "detail": BetaImageDetail + readonly "prompt_cache_breakpoint"?: BetaPromptCacheBreakpointConfig } -export const RealtimeTranslationClientSecretCreateRequest = Schema.Struct({ - "expires_after": Schema.optionalKey( - Schema.Struct({ - "anchor": Schema.optionalKey( - Schema.Literal("created_at").annotate({ - "description": - "The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.\n" - }) - ), - "seconds": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.\n", - "format": "int64" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(10)).check(Schema.isLessThanOrEqualTo(7200)) - ) - }).annotate({ - "title": "Client secret expiration", - "description": - "Configuration for the client secret expiration. Expiration refers to the time after which\na client secret will no longer be valid for creating sessions. The session itself may\ncontinue after that time once started. A secret can be used to create multiple sessions\nuntil it expires.\n" - }) +export const BetaInputImageContent = Schema.Struct({ + "type": Schema.Literal("input_image").annotate({ + "description": "The type of the input item. Always `input_image`." + }), + "image_url": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.", + "format": "uri" + }), + Schema.Null + ]) ), - "session": RealtimeTranslationSessionCreateRequest + "file_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), + Schema.Null + ]) + ), + "detail": Schema.suspend((): Schema.Codec => BetaImageDetail).annotate({ + "description": + "The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`." + }), + "prompt_cache_breakpoint": Schema.optionalKey(BetaPromptCacheBreakpointConfig) }).annotate({ - "title": "Realtime translation client secret creation request", - "description": "Create a translation session and client secret for the Realtime API.\n" + "title": "Input image", + "description": "An image input to the model. Learn about [image inputs](/docs/guides/vision).", + "identifier": "BetaInputImageContent" }) -export type ProjectApiKeyListResponse = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id"?: string | null - readonly "last_id"?: string | null - readonly "has_more": boolean +export type BetaComputerScreenshotContent = { + readonly "type": "computer_screenshot" + readonly "image_url": string | null + readonly "file_id": string | null + readonly "detail": BetaImageDetail + readonly "prompt_cache_breakpoint"?: BetaPromptCacheBreakpointConfig } -export const ProjectApiKeyListResponse = Schema.Struct({ - "object": Schema.Literal("list"), - "data": Schema.Array(ProjectApiKey), - "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "has_more": Schema.Boolean +export const BetaComputerScreenshotContent = Schema.Struct({ + "type": Schema.Literal("computer_screenshot").annotate({ + "description": + "Specifies the event type. For a computer screenshot, this property is always set to `computer_screenshot`." + }), + "image_url": Schema.Union([ + Schema.String.annotate({ "description": "The URL of the screenshot image.", "format": "uri" }), + Schema.Null + ]), + "file_id": Schema.Union([ + Schema.String.annotate({ "description": "The identifier of an uploaded file that contains the screenshot." }), + Schema.Null + ]), + "detail": Schema.suspend((): Schema.Codec => BetaImageDetail).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`." + }), + "prompt_cache_breakpoint": Schema.optionalKey(BetaPromptCacheBreakpointConfig) +}).annotate({ + "title": "Computer screenshot", + "description": "A screenshot of a computer.", + "identifier": "BetaComputerScreenshotContent" }) -export type RealtimeConversationItem = - | RealtimeConversationItemMessageSystem - | RealtimeConversationItemMessageUser - | RealtimeConversationItemMessageAssistant - | RealtimeConversationItemFunctionCall - | RealtimeConversationItemFunctionCallOutput - | RealtimeMCPApprovalResponse - | RealtimeMCPListTools - | RealtimeMCPToolCall - | RealtimeMCPApprovalRequest -export const RealtimeConversationItem = Schema.Union([ - RealtimeConversationItemMessageSystem, - RealtimeConversationItemMessageUser, - RealtimeConversationItemMessageAssistant, - RealtimeConversationItemFunctionCall, - RealtimeConversationItemFunctionCallOutput, - RealtimeMCPApprovalResponse, - RealtimeMCPListTools, - RealtimeMCPToolCall, - RealtimeMCPApprovalRequest -]).annotate({ "description": "A single item within a Realtime conversation." }) -export type AssistantsApiResponseFormatOption = - | "auto" - | ResponseFormatText - | ResponseFormatJsonObject - | ResponseFormatJsonSchema -export const AssistantsApiResponseFormatOption = Schema.Union([ - Schema.Literal("auto").annotate({ "description": "`auto` is the default value\n" }), - ResponseFormatText, - ResponseFormatJsonObject, - ResponseFormatJsonSchema -], { mode: "oneOf" }).annotate({ - "description": - "Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.\n\n**Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if `finish_reason=\"length\"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.\n" +export type BetaInputFileContent = { + readonly "type": "input_file" + readonly "file_id"?: string | null + readonly "filename"?: string + readonly "file_data"?: string + readonly "prompt_cache_breakpoint"?: BetaPromptCacheBreakpointConfig + readonly "file_url"?: string + readonly "detail"?: BetaFileInputDetail +} +export const BetaInputFileContent = Schema.Struct({ + "type": Schema.Literal("input_file").annotate({ "description": "The type of the input item. Always `input_file`." }), + "file_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), + Schema.Null + ]) + ), + "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" }) + ), + "prompt_cache_breakpoint": Schema.optionalKey(BetaPromptCacheBreakpointConfig), + "file_url": Schema.optionalKey( + Schema.String.annotate({ "description": "The URL of the file to be sent to the model.", "format": "uri" }) + ), + "detail": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaFileInputDetail).annotate({ + "description": + "The detail level of the file to be sent to the model. Use `auto` to let the system select the detail level; for GPT-5.6 and later models, `auto` uses high-quality rendering, which may increase input token usage. Use `low` for lower-cost rendering, or `high` to render the file at higher quality. Defaults to `auto`." + }) + ) +}).annotate({ + "title": "Input file", + "description": "A file input to the model.", + "identifier": "BetaInputFileContent" }) -export type TextResponseFormatConfiguration = - | ResponseFormatText - | TextResponseFormatJsonSchema - | ResponseFormatJsonObject -export const TextResponseFormatConfiguration = Schema.Union([ - ResponseFormatText, - TextResponseFormatJsonSchema, - ResponseFormatJsonObject -], { mode: "oneOf" }).annotate({ - "description": - "An object specifying the format that the model must output.\n\nConfiguring `{ \"type\": \"json_schema\" }` enables Structured Outputs, \nwhich ensures the model will match your supplied JSON schema. Learn more in the \n[Structured Outputs guide](/docs/guides/structured-outputs).\n\nThe default format is `{ \"type\": \"text\" }` with no additional options.\n\n**Not recommended for gpt-4o and newer models:**\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n" -}) -export type RealtimeCallCreateRequest = { - readonly "sdp": string - readonly "session"?: { - readonly "type": "realtime" - readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> - readonly "model"?: - | string - | "gpt-realtime" - | "gpt-realtime-1.5" - | "gpt-realtime-2" - | "gpt-realtime-2025-08-28" - | "gpt-4o-realtime-preview" - | "gpt-4o-realtime-preview-2024-10-01" - | "gpt-4o-realtime-preview-2024-12-17" - | "gpt-4o-realtime-preview-2025-06-03" - | "gpt-4o-mini-realtime-preview" - | "gpt-4o-mini-realtime-preview-2024-12-17" - | "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" - readonly "instructions"?: string - readonly "audio"?: { - readonly "input"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - readonly "delay"?: "minimal" | "low" | "medium" | "high" | "xhigh" - } - readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "turn_detection"?: RealtimeTurnDetection - } - readonly "output"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "voice"?: VoiceIdsShared | { readonly "id": string } - readonly "speed"?: number - } +export type BetaWebSearchToolCall = { + readonly "agent"?: BetaAgentTag | null + readonly "id": string + readonly "type": "web_search_call" + readonly "status": "in_progress" | "searching" | "completed" | "failed" + readonly "action": + | { + readonly "type": "search" + readonly "query"?: string + readonly "queries"?: ReadonlyArray + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> } - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> - readonly "tracing"?: "auto" | { - readonly "workflow_name"?: string - readonly "group_id"?: string - readonly "metadata"?: {} - } | null - readonly "tools"?: ReadonlyArray - readonly "tool_choice"?: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMCP - readonly "parallel_tool_calls"?: boolean - readonly "reasoning"?: RealtimeReasoning - readonly "max_output_tokens"?: number | "inf" - readonly "truncation"?: RealtimeTruncation - readonly "prompt"?: Prompt - } + | { readonly "type": "open_page"; readonly "url"?: string | null } + | { readonly "type": "find_in_page"; readonly "url": string; readonly "pattern": string } } -export const RealtimeCallCreateRequest = Schema.Struct({ - "sdp": Schema.String.annotate({ - "description": "WebRTC Session Description Protocol (SDP) offer generated by the caller." +export const BetaWebSearchToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "id": Schema.String.annotate({ "description": "The unique ID of the web search tool call.\n" }), + "type": Schema.Literal("web_search_call").annotate({ + "description": "The type of the web search tool call. Always `web_search_call`.\n" }), - "session": Schema.optionalKey( + "status": Schema.Literals(["in_progress", "searching", "completed", "failed"]).annotate({ + "description": "The status of the web search tool call.\n" + }), + "action": Schema.Union([ Schema.Struct({ - "type": Schema.Literal("realtime").annotate({ - "description": "The type of session to create. Always `realtime` for the Realtime API.\n" - }), - "output_modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": - "The set of modalities the model can respond with. It defaults to `[\"audio\"]`, indicating\nthat the model will respond with audio plus a transcript. `[\"text\"]` can be used to make\nthe model respond with text only. It is not possible to request both `text` and `audio` at the same time.\n" - }) - ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "gpt-realtime", - "gpt-realtime-1.5", - "gpt-realtime-2", - "gpt-realtime-2025-08-28", - "gpt-4o-realtime-preview", - "gpt-4o-realtime-preview-2024-10-01", - "gpt-4o-realtime-preview-2024-12-17", - "gpt-4o-realtime-preview-2025-06-03", - "gpt-4o-mini-realtime-preview", - "gpt-4o-mini-realtime-preview-2024-12-17", - "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" - ]) - ]).annotate({ "description": "The Realtime model used for this session.\n" }) - ), - "instructions": Schema.optionalKey(Schema.String.annotate({ - "description": - "The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.\n\nNote that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.\n" - })), - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the input audio." }) - ), - "transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.\n" - }) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The language of the input audio. Supplying the input language in\n[ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format\nwill improve accuracy and latency.\n" - }) - ), - "prompt": Schema.optionalKey(Schema.String.annotate({ - "description": - "An optional text to guide the model's style or continue a previous audio\nsegment.\nFor `whisper-1`, the [prompt is a list of keywords](/docs/guides/speech-to-text#prompting).\nFor `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example \"expect words related to technology\".\nPrompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - })), - "delay": Schema.optionalKey( - Schema.Literals(["minimal", "low", "medium", "high", "xhigh"]).annotate({ - "description": - "Controls how long the model waits before emitting transcription text.\nHigher values can improve transcription accuracy at the cost of latency.\nOnly supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - }) - ) - }).annotate({ - "description": - "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" - }) - ), - "noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": - "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" - }) - ), - "turn_detection": Schema.optionalKey(RealtimeTurnDetection) - })), - "output": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the output audio." }) - ), - "voice": Schema.optionalKey( - Schema.Union([ - VoiceIdsShared, - Schema.Struct({ - "id": Schema.String.annotate({ "description": "The custom voice ID, e.g. `voice_1234`." }) - }).annotate({ "description": "Custom voice reference." }) - ]).annotate({ - "title": "Voice", - "description": - "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,\n`marin`, and `cedar`. You may also provide a custom voice object with\nan `id`, for example `{ \"id\": \"voice_1234\" }`. Voice cannot be changed\nduring the session once the model has responded with audio at least once.\nWe recommend `marin` and `cedar` for best quality.\n" - }) - ), - "speed": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The speed of the model's spoken response as a multiple of the original speed.\n1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.\n\nThis parameter is a post-processing adjustment to the audio after it is generated, it's\nalso possible to prompt the model to speak faster or slower.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0.25)).check( - Schema.isLessThanOrEqualTo(1.5) - ) - ) - })) - }).annotate({ "description": "Configuration for input and output audio.\n" }) - ), - "include": Schema.optionalKey( - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ - "description": - "Additional fields to include in server outputs.\n\n`item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" - }) - ), - "tracing": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Literal("auto").annotate({ - "title": "auto", - "description": - "Enables tracing and sets default values for tracing configuration options. Always `auto`.\n" - }), - Schema.Struct({ - "workflow_name": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The name of the workflow to attach to this trace. This is used to\nname the trace in the Traces Dashboard.\n" - }) - ), - "group_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The group id to attach to this trace to enable filtering and\ngrouping in the Traces Dashboard.\n" - }) - ), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "The arbitrary metadata to attach to this trace to enable\nfiltering in the Traces Dashboard.\n" - }) - ) - }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) - ], { mode: "oneOf" }).annotate({ - "title": "Tracing Configuration", - "description": - "Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" - }), - Schema.Null - ]) - ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Union([RealtimeFunctionTool, MCPTool], { mode: "oneOf" })).annotate({ - "description": "Tools available to the model." - }) - ), - "tool_choice": Schema.optionalKey( - Schema.Union([ToolChoiceOptions, ToolChoiceFunction, ToolChoiceMCP], { mode: "oneOf" }).annotate({ - "description": - "How the model chooses tools. Provide one of the string modes or force a specific\nfunction/MCP tool.\n" - }) - ), - "parallel_tool_calls": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether the model may call multiple tools in parallel. Only supported by\nreasoning Realtime models such as `gpt-realtime-2`.\n" + "type": Schema.Literal("search").annotate({ "description": "The action type.\n" }), + "query": Schema.optionalKey(Schema.String.annotate({ "description": "The search query.\n" })), + "queries": Schema.optionalKey( + Schema.Array(Schema.String.annotate({ "description": "A search query.\n" })).annotate({ + "title": "Search queries", + "description": "The search queries.\n" }) ), - "reasoning": Schema.optionalKey(RealtimeReasoning), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ - "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" + "sources": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "type": Schema.Literal("url").annotate({ "description": "The type of source. Always `url`.\n" }), + "url": Schema.String.annotate({ "description": "The URL of the source.\n", "format": "uri" }) + }).annotate({ "title": "Web search source", "description": "A source used in the search.\n" }) + ).annotate({ "title": "Web search sources", "description": "The sources used in the search.\n" }) + ) + }).annotate({ + "title": "Search action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }), + Schema.Struct({ + "type": Schema.Literal("open_page").annotate({ "description": "The action type.\n" }), + "url": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "format": "uri" }), Schema.Null]).annotate({ + "description": "The URL opened by the model.\n" }) - ), - "truncation": Schema.optionalKey(RealtimeTruncation), - "prompt": Schema.optionalKey(Prompt) - }).annotate({ "title": "Realtime session configuration", "description": "Realtime session object configuration." }) - ) -}).annotate({ - "title": "Realtime call creation request", - "description": - "Parameters required to initiate a realtime call and receive the SDP answer\nneeded to complete a WebRTC peer connection. Provide an SDP offer generated\nby your client and optionally configure the session that will answer the call." -}) -export type RealtimeClientEventSessionUpdate = { - readonly "event_id"?: string - readonly "type": "session.update" - readonly "session": { - readonly "type": "realtime" - readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> - readonly "model"?: - | string - | "gpt-realtime" - | "gpt-realtime-1.5" - | "gpt-realtime-2" - | "gpt-realtime-2025-08-28" - | "gpt-4o-realtime-preview" - | "gpt-4o-realtime-preview-2024-10-01" - | "gpt-4o-realtime-preview-2024-12-17" - | "gpt-4o-realtime-preview-2025-06-03" - | "gpt-4o-mini-realtime-preview" - | "gpt-4o-mini-realtime-preview-2024-12-17" - | "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" - readonly "instructions"?: string - readonly "audio"?: { - readonly "input"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - readonly "delay"?: "minimal" | "low" | "medium" | "high" | "xhigh" - } - readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "turn_detection"?: RealtimeTurnDetection - } - readonly "output"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "voice"?: VoiceIdsShared | { readonly "id": string } - readonly "speed"?: number - } - } - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> - readonly "tracing"?: "auto" | { - readonly "workflow_name"?: string - readonly "group_id"?: string - readonly "metadata"?: {} - } | null - readonly "tools"?: ReadonlyArray - readonly "tool_choice"?: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMCP - readonly "parallel_tool_calls"?: boolean - readonly "reasoning"?: RealtimeReasoning - readonly "max_output_tokens"?: number | "inf" - readonly "truncation"?: RealtimeTruncation - readonly "prompt"?: Prompt - } | { - readonly "type": "transcription" - readonly "audio"?: { - readonly "input"?: { - readonly "format"?: RealtimeAudioFormats - readonly "transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - readonly "delay"?: "minimal" | "low" | "medium" | "high" | "xhigh" - } - readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "turn_detection"?: RealtimeTurnDetection - } - } - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> - } -} -export const RealtimeClientEventSessionUpdate = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ + ) + }).annotate({ + "title": "Open page action", "description": - "Optional client-generated ID used to identify this event. This is an arbitrary string that a client may assign. It will be passed back if there is an error with the event, but the corresponding `session.updated` event will not include it." - }).check(Schema.isMaxLength(512)) - ), - "type": Schema.Literal("session.update").annotate({ "description": "The event type, must be `session.update`." }), - "session": Schema.Union([ + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }), Schema.Struct({ - "type": Schema.Literal("realtime").annotate({ - "description": "The type of session to create. Always `realtime` for the Realtime API.\n" + "type": Schema.Literal("find_in_page").annotate({ "description": "The action type.\n" }), + "url": Schema.String.annotate({ + "description": "The URL of the page searched for the pattern.\n", + "format": "uri" }), - "output_modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": - "The set of modalities the model can respond with. It defaults to `[\"audio\"]`, indicating\nthat the model will respond with audio plus a transcript. `[\"text\"]` can be used to make\nthe model respond with text only. It is not possible to request both `text` and `audio` at the same time.\n" - }) - ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "gpt-realtime", - "gpt-realtime-1.5", - "gpt-realtime-2", - "gpt-realtime-2025-08-28", - "gpt-4o-realtime-preview", - "gpt-4o-realtime-preview-2024-10-01", - "gpt-4o-realtime-preview-2024-12-17", - "gpt-4o-realtime-preview-2025-06-03", - "gpt-4o-mini-realtime-preview", - "gpt-4o-mini-realtime-preview-2024-12-17", - "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" - ]) - ]).annotate({ "description": "The Realtime model used for this session.\n" }) - ), - "instructions": Schema.optionalKey(Schema.String.annotate({ - "description": - "The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.\n\nNote that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.\n" - })), - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the input audio." }) - ), - "transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.\n" - }) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The language of the input audio. Supplying the input language in\n[ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format\nwill improve accuracy and latency.\n" - }) - ), - "prompt": Schema.optionalKey(Schema.String.annotate({ - "description": - "An optional text to guide the model's style or continue a previous audio\nsegment.\nFor `whisper-1`, the [prompt is a list of keywords](/docs/guides/speech-to-text#prompting).\nFor `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example \"expect words related to technology\".\nPrompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - })), - "delay": Schema.optionalKey( - Schema.Literals(["minimal", "low", "medium", "high", "xhigh"]).annotate({ - "description": - "Controls how long the model waits before emitting transcription text.\nHigher values can improve transcription accuracy at the cost of latency.\nOnly supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - }) - ) - }).annotate({ - "description": - "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" - }) - ), - "noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": - "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" - }) - ), - "turn_detection": Schema.optionalKey(RealtimeTurnDetection) - })), - "output": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the output audio." }) - ), - "voice": Schema.optionalKey( - Schema.Union([ - VoiceIdsShared, - Schema.Struct({ - "id": Schema.String.annotate({ "description": "The custom voice ID, e.g. `voice_1234`." }) - }).annotate({ "description": "Custom voice reference." }) - ]).annotate({ - "title": "Voice", - "description": - "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,\n`marin`, and `cedar`. You may also provide a custom voice object with\nan `id`, for example `{ \"id\": \"voice_1234\" }`. Voice cannot be changed\nduring the session once the model has responded with audio at least once.\nWe recommend `marin` and `cedar` for best quality.\n" - }) - ), - "speed": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The speed of the model's spoken response as a multiple of the original speed.\n1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.\n\nThis parameter is a post-processing adjustment to the audio after it is generated, it's\nalso possible to prompt the model to speak faster or slower.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0.25)).check( - Schema.isLessThanOrEqualTo(1.5) - ) - ) - })) - }).annotate({ "description": "Configuration for input and output audio.\n" }) - ), - "include": Schema.optionalKey( - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ - "description": - "Additional fields to include in server outputs.\n\n`item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" - }) - ), - "tracing": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Literal("auto").annotate({ - "title": "auto", - "description": - "Enables tracing and sets default values for tracing configuration options. Always `auto`.\n" - }), - Schema.Struct({ - "workflow_name": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The name of the workflow to attach to this trace. This is used to\nname the trace in the Traces Dashboard.\n" - }) - ), - "group_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The group id to attach to this trace to enable filtering and\ngrouping in the Traces Dashboard.\n" - }) - ), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "The arbitrary metadata to attach to this trace to enable\nfiltering in the Traces Dashboard.\n" - }) - ) - }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) - ], { mode: "oneOf" }).annotate({ - "title": "Tracing Configuration", - "description": - "Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" - }), - Schema.Null - ]) - ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Union([RealtimeFunctionTool, MCPTool], { mode: "oneOf" })).annotate({ - "description": "Tools available to the model." - }) - ), - "tool_choice": Schema.optionalKey( - Schema.Union([ToolChoiceOptions, ToolChoiceFunction, ToolChoiceMCP], { mode: "oneOf" }).annotate({ - "description": - "How the model chooses tools. Provide one of the string modes or force a specific\nfunction/MCP tool.\n" - }) - ), - "parallel_tool_calls": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether the model may call multiple tools in parallel. Only supported by\nreasoning Realtime models such as `gpt-realtime-2`.\n" - }) - ), - "reasoning": Schema.optionalKey(RealtimeReasoning), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ - "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" - }) - ), - "truncation": Schema.optionalKey(RealtimeTruncation), - "prompt": Schema.optionalKey(Prompt) - }).annotate({ - "title": "Realtime session configuration", - "description": "Update the Realtime session. Choose either a realtime\nsession or a transcription session.\n" - }), - Schema.Struct({ - "type": Schema.Literal("transcription").annotate({ - "description": "The type of session to create. Always `transcription` for transcription sessions.\n" - }), - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey(RealtimeAudioFormats), - "transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.\n" - }) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The language of the input audio. Supplying the input language in\n[ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format\nwill improve accuracy and latency.\n" - }) - ), - "prompt": Schema.optionalKey(Schema.String.annotate({ - "description": - "An optional text to guide the model's style or continue a previous audio\nsegment.\nFor `whisper-1`, the [prompt is a list of keywords](/docs/guides/speech-to-text#prompting).\nFor `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example \"expect words related to technology\".\nPrompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - })), - "delay": Schema.optionalKey( - Schema.Literals(["minimal", "low", "medium", "high", "xhigh"]).annotate({ - "description": - "Controls how long the model waits before emitting transcription text.\nHigher values can improve transcription accuracy at the cost of latency.\nOnly supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - }) - ) - }).annotate({ - "description": - "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" - }) - ), - "noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": - "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" - }) - ), - "turn_detection": Schema.optionalKey(RealtimeTurnDetection) - })) - }).annotate({ "description": "Configuration for input and output audio.\n" }) - ), - "include": Schema.optionalKey( - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ - "description": - "Additional fields to include in server outputs.\n\n`item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" - }) - ) + "pattern": Schema.String.annotate({ "description": "The pattern or text to search for within the page.\n" }) }).annotate({ - "title": "Realtime transcription session configuration", - "description": "Update the Realtime session. Choose either a realtime\nsession or a transcription session.\n" + "title": "Find action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" }) ], { mode: "oneOf" }) }).annotate({ + "title": "Web search tool call", "description": - "Send this event to update the session’s configuration.\nThe client may send this event at any time to update any field\nexcept for `voice` and `model`. `voice` can be updated only if there have been no other audio outputs yet.\n\nWhen the server receives a `session.update`, it will respond\nwith a `session.updated` event showing the full, effective configuration.\nOnly the fields that are present in the `session.update` are updated. To clear a field like\n`instructions`, pass an empty string. To clear a field like `tools`, pass an empty array.\nTo clear a field like `turn_detection`, pass `null`.\n" + "The results of a web search tool call. See the\n[web search guide](/docs/guides/tools-web-search) for more information.\n", + "identifier": "BetaWebSearchToolCall" }) -export type RealtimeSession = { - readonly "id"?: string - readonly "object"?: "realtime.session" - readonly "modalities"?: ReadonlyArray<"text" | "audio"> - 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" - | "gpt-4o-realtime-preview-2024-12-17" - | "gpt-4o-realtime-preview-2025-06-03" - | "gpt-4o-mini-realtime-preview" - | "gpt-4o-mini-realtime-preview-2024-12-17" - | "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" - readonly "instructions"?: string - readonly "voice"?: - | string - | "alloy" - | "ash" - | "ballad" - | "coral" - | "echo" - | "sage" - | "shimmer" - | "verse" - | "marin" - | "cedar" - readonly "input_audio_format"?: "pcm16" | "g711_ulaw" | "g711_alaw" - readonly "output_audio_format"?: "pcm16" | "g711_ulaw" | "g711_alaw" - readonly "input_audio_transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - } | null - readonly "turn_detection"?: RealtimeTurnDetection - readonly "input_audio_noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "speed"?: number - readonly "tracing"?: "auto" | { - readonly "workflow_name"?: string - readonly "group_id"?: string - readonly "metadata"?: {} - } | null - readonly "tools"?: ReadonlyArray - readonly "tool_choice"?: string - readonly "temperature"?: number - readonly "max_response_output_tokens"?: number | "inf" - readonly "expires_at"?: number - readonly "prompt"?: Prompt | null - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> | null +export type BetaProgram = { + readonly "agent"?: BetaAgentTag + readonly "type": "program" + readonly "id": string + readonly "call_id": string + readonly "code": string + readonly "fingerprint": string } -export const RealtimeSession = Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ - "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" +export const BetaProgram = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." }) ), - "object": Schema.optionalKey( - Schema.Literal("realtime.session").annotate({ "description": "The object type. Always `realtime.session`." }) - ), - "modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": "The set of modalities the model can respond with. To disable audio,\nset this to [\"text\"].\n" + "type": Schema.Literal("program").annotate({ "description": "The type of the item. Always `program`." }), + "id": Schema.String.annotate({ "description": "The unique ID of the program item." }), + "call_id": Schema.String.annotate({ "description": "The stable call ID of the program item." }), + "code": Schema.String.annotate({ "description": "The JavaScript source executed by programmatic tool calling." }), + "fingerprint": Schema.String.annotate({ + "description": "Opaque program replay fingerprint that must be round-tripped." + }) +}).annotate({ "identifier": "BetaProgram" }) +export type BetaCompactionBody = { + readonly "agent"?: BetaAgentTag + readonly "type": "compaction" + readonly "id": string + readonly "encrypted_content": string + readonly "created_by"?: string +} +export const BetaCompactionBody = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." }) ), - "model": Schema.optionalKey( - Schema.Union([ - 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", - "gpt-4o-realtime-preview-2024-12-17", - "gpt-4o-realtime-preview-2025-06-03", - "gpt-4o-mini-realtime-preview", - "gpt-4o-mini-realtime-preview-2024-12-17", - "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" - ]) - ]).annotate({ "description": "The Realtime model used for this session.\n" }) + "type": Schema.Literal("compaction").annotate({ "description": "The type of the item. Always `compaction`." }), + "id": Schema.String.annotate({ "description": "The unique ID of the compaction item." }), + "encrypted_content": Schema.String.annotate({ + "description": "The encrypted content that was produced by compaction." + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) + ) +}).annotate({ + "title": "Compaction item", + "description": + "A compaction item generated by the [`v1/responses/compact` API](/docs/api-reference/responses/compact).", + "identifier": "BetaCompactionBody" +}) +export type BetaImageGenToolCall = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "image_generation_call" + readonly "id": string + readonly "status": "in_progress" | "completed" | "generating" | "failed" + readonly "result": string | null +} +export const BetaImageGenToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "instructions": Schema.optionalKey(Schema.String.annotate({ - "description": - "The default system instructions (i.e. system message) prepended to model\ncalls. This field allows the client to guide the model on desired\nresponses. The model can be instructed on response content and format,\n(e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good\nresponses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion\ninto your voice\", \"laugh frequently\"). The instructions are not\nguaranteed to be followed by the model, but they provide guidance to the\nmodel on the desired behavior.\n\n\nNote that the server sets default instructions which will be used if this\nfield is not set and are visible in the `session.created` event at the\nstart of the session.\n" - })), - "voice": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals(["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse", "marin", "cedar"]) - ]).annotate({ - "description": - "The voice the model uses to respond. Voice cannot be changed during the\nsession once the model has responded with audio at least once. Current\nvoice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,\n`shimmer`, and `verse`.\n" - }) + "type": Schema.Literal("image_generation_call").annotate({ + "description": "The type of the image generation call. Always `image_generation_call`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the image generation call.\n" }), + "status": Schema.Literals(["in_progress", "completed", "generating", "failed"]).annotate({ + "description": "The status of the image generation call.\n" + }), + "result": Schema.Union([ + Schema.String.annotate({ "description": "The generated image encoded in base64.\n" }), + Schema.Null + ]) +}).annotate({ + "title": "Image generation call", + "description": "An image generation request made by the model.\n", + "identifier": "BetaImageGenToolCall" +}) +export type BetaLocalShellToolCallOutput = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "local_shell_call_output" + readonly "id": string + readonly "output": string + readonly "status"?: "in_progress" | "completed" | "incomplete" | null + readonly "call_id": Schema.Json +} +export const BetaLocalShellToolCallOutput = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "input_audio_format": Schema.optionalKey( - Schema.Literals(["pcm16", "g711_ulaw", "g711_alaw"]).annotate({ - "description": - "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\nFor `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate,\nsingle channel (mono), and little-endian byte order.\n" - }) + "type": Schema.Literal("local_shell_call_output").annotate({ + "description": "The type of the local shell tool call output. Always `local_shell_call_output`.\n" + }), + "id": Schema.String.annotate({ + "description": "The unique ID of the local shell tool call generated by the model.\n" + }), + "output": Schema.String.annotate({ "description": "A JSON string of the output of the local shell tool call.\n" }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the item. One of `in_progress`, `completed`, or `incomplete`.\n" + }), + Schema.Null + ]) ), - "output_audio_format": Schema.optionalKey( - Schema.Literals(["pcm16", "g711_ulaw", "g711_alaw"]).annotate({ - "description": - "The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\nFor `pcm16`, output audio is sampled at a rate of 24kHz.\n" - }) + "call_id": Schema.Json.annotate({ "expected": "JSON value" }) +}).annotate({ + "title": "Local shell call output", + "description": "The output of a local shell tool call.\n", + "identifier": "BetaLocalShellToolCallOutput" +}) +export type BetaMCPApprovalRequest = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "mcp_approval_request" + readonly "id": string + readonly "server_label": string + readonly "name": string + readonly "arguments": string +} +export const BetaMCPApprovalRequest = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "input_audio_transcription": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model used for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.\n" - }) - ), - "language": Schema.optionalKey(Schema.String.annotate({ "description": "The language of the input audio.\n" })), - "prompt": Schema.optionalKey( - Schema.String.annotate({ - "description": "The prompt configured for input audio transcription, when present.\n" - }) - ) - }).annotate({ - "description": - "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" - }), - Schema.Null - ])), - "turn_detection": Schema.optionalKey(RealtimeTurnDetection), - "input_audio_noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": - "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" - }) - ), - "speed": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The speed of the model's spoken response. 1.0 is the default speed. 0.25 is\nthe minimum speed. 1.5 is the maximum speed. This value can only be changed\nin between model turns, not while a response is in progress.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0.25)).check(Schema.isLessThanOrEqualTo(1.5)) + "type": Schema.Literal("mcp_approval_request").annotate({ + "description": "The type of the item. Always `mcp_approval_request`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the approval request.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server making the request.\n" }), + "name": Schema.String.annotate({ "description": "The name of the tool to run.\n" }), + "arguments": Schema.String.annotate({ "description": "A JSON string of arguments for the tool.\n" }) +}).annotate({ + "title": "MCP approval request", + "description": "A request for human approval of a tool invocation.\n", + "identifier": "BetaMCPApprovalRequest" +}) +export type BetaMCPApprovalResponseResource = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "mcp_approval_response" + readonly "id": string + readonly "approval_request_id": string + readonly "approve": boolean + readonly "reason"?: string | null + readonly "request_id": Schema.Json +} +export const BetaMCPApprovalResponseResource = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "tracing": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Literal("auto").annotate({ "description": "Default tracing mode for the session.\n" }), - Schema.Struct({ - "workflow_name": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The name of the workflow to attach to this trace. This is used to\nname the trace in the traces dashboard.\n" - }) - ), - "group_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The group id to attach to this trace to enable filtering and\ngrouping in the traces dashboard.\n" - }) - ), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "The arbitrary metadata to attach to this trace to enable\nfiltering in the traces dashboard.\n" - }) - ) - }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) - ], { mode: "oneOf" }).annotate({ - "title": "Tracing Configuration", - "description": - "Configuration options for tracing. Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" - }), - Schema.Null - ]) + "type": Schema.Literal("mcp_approval_response").annotate({ + "description": "The type of the item. Always `mcp_approval_response`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the approval response\n" }), + "approval_request_id": Schema.String.annotate({ "description": "The ID of the approval request being answered.\n" }), + "approve": Schema.Boolean.annotate({ "description": "Whether the request was approved.\n" }), + "reason": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "Optional reason for the decision.\n" }), Schema.Null]) ), - "tools": Schema.optionalKey( - Schema.Array(RealtimeFunctionTool).annotate({ "description": "Tools (functions) available to the model." }) + "request_id": Schema.Json.annotate({ "expected": "JSON value" }) +}).annotate({ + "title": "MCP approval response", + "description": "A response to an MCP approval request.\n", + "identifier": "BetaMCPApprovalResponseResource" +}) +export type BetaResponseAudioDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.audio.delta" + readonly "sequence_number": number + readonly "delta": string +} +export const BetaResponseAudioDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "tool_choice": Schema.optionalKey( - Schema.String.annotate({ - "description": "How the model chooses tools. Options are `auto`, `none`, `required`, or\nspecify a function.\n" + "type": Schema.Literal("response.audio.delta").annotate({ + "description": "The type of the event. Always `response.audio.delta`.\n" + }), + "sequence_number": Schema.Number.annotate({ + "description": "A sequence number for this chunk of the stream response.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String.annotate({ "description": "A chunk of Base64 encoded response audio bytes.\n" }) +}).annotate({ + "description": "Emitted when there is a partial audio response.", + "identifier": "BetaResponseAudioDeltaEvent" +}) +export type BetaResponseAudioDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.audio.done" + readonly "sequence_number": number + readonly "response_id": Schema.Json +} +export const BetaResponseAudioDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a temperature of 0.8 is highly recommended for best performance.\n" - }).check(Schema.isFinite()) + "type": Schema.Literal("response.audio.done").annotate({ + "description": "The type of the event. Always `response.audio.done`.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of the delta.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "max_response_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ - "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" + "response_id": Schema.Json.annotate({ "expected": "JSON value" }) +}).annotate({ + "description": "Emitted when the audio response is complete.", + "identifier": "BetaResponseAudioDoneEvent" +}) +export type BetaResponseAudioTranscriptDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.audio.transcript.delta" + readonly "delta": string + readonly "sequence_number": number + readonly "response_id": Schema.Json +} +export const BetaResponseAudioTranscriptDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "expires_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Expiration timestamp for the session, in seconds since epoch.", - "format": "unixtime" - }).check(Schema.isInt()) + "type": Schema.Literal("response.audio.transcript.delta").annotate({ + "description": "The type of the event. Always `response.audio.transcript.delta`.\n" + }), + "delta": Schema.String.annotate({ "description": "The partial transcript of the audio response.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "prompt": Schema.optionalKey(Schema.Union([Prompt, Schema.Null])), - "include": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ - "description": - "Additional fields to include in server outputs.\n- `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" - }), - Schema.Null - ]) - ) -}).annotate({ "description": "Realtime session object for the beta interface." }) -export type RealtimeSessionCreateRequest = { - readonly "client_secret": { readonly "value": string; readonly "expires_at": number } - readonly "modalities"?: ReadonlyArray<"text" | "audio"> - readonly "instructions"?: string - readonly "voice"?: VoiceIdsShared | { readonly "id": string } - readonly "input_audio_format"?: string - readonly "output_audio_format"?: string - readonly "input_audio_transcription"?: { readonly "model"?: string } - readonly "speed"?: number - readonly "tracing"?: "auto" | { - readonly "workflow_name"?: string - readonly "group_id"?: string - readonly "metadata"?: {} - } - readonly "turn_detection"?: { - readonly "type"?: string - readonly "threshold"?: number - readonly "prefix_padding_ms"?: number - readonly "silence_duration_ms"?: number - } - readonly "tools"?: ReadonlyArray< - { - readonly "type"?: "function" - readonly "name"?: string - readonly "description"?: string - readonly "parameters"?: {} - } - > - readonly "tool_choice"?: string - readonly "temperature"?: number - readonly "max_response_output_tokens"?: number | "inf" - readonly "truncation"?: RealtimeTruncation - readonly "prompt"?: Prompt + "response_id": Schema.Json.annotate({ "expected": "JSON value" }) +}).annotate({ + "description": "Emitted when there is a partial transcript of audio.", + "identifier": "BetaResponseAudioTranscriptDeltaEvent" +}) +export type BetaResponseAudioTranscriptDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.audio.transcript.done" + readonly "sequence_number": number + readonly "response_id": Schema.Json } -export const RealtimeSessionCreateRequest = Schema.Struct({ - "client_secret": Schema.Struct({ - "value": Schema.String.annotate({ - "description": - "Ephemeral key usable in client environments to authenticate connections\nto the Realtime API. Use this in client-side environments rather than\na standard API token, which should only be used server-side.\n" - }), - "expires_at": Schema.Number.annotate({ - "description": "Timestamp for when the token expires. Currently, all tokens expire\nafter one minute.\n", - "format": "unixtime" - }).check(Schema.isInt()) - }).annotate({ "description": "Ephemeral key returned by the API." }), - "modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": "The set of modalities the model can respond with. To disable audio,\nset this to [\"text\"].\n" +export const BetaResponseAudioTranscriptDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "instructions": Schema.optionalKey(Schema.String.annotate({ - "description": - "The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.\nNote that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.\n" - })), - "voice": Schema.optionalKey( - Schema.Union([ - VoiceIdsShared, - Schema.Struct({ "id": Schema.String.annotate({ "description": "The custom voice ID, e.g. `voice_1234`." }) }) - .annotate({ "description": "Custom voice reference." }) - ]).annotate({ - "title": "Voice", - "description": - "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,\n`marin`, and `cedar`. You may also provide a custom voice object with an\n`id`, for example `{ \"id\": \"voice_1234\" }`. Voice cannot be changed during\nthe session once the model has responded with audio at least once.\n" - }) + "type": Schema.Literal("response.audio.transcript.done").annotate({ + "description": "The type of the event. Always `response.audio.transcript.done`.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "input_audio_format": Schema.optionalKey( - Schema.String.annotate({ - "description": "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n" + "response_id": Schema.Json.annotate({ "expected": "JSON value" }) +}).annotate({ + "description": "Emitted when the full audio transcript is completed.", + "identifier": "BetaResponseAudioTranscriptDoneEvent" +}) +export type BetaResponseCodeInterpreterCallCodeDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.code_interpreter_call_code.delta" + readonly "output_index": number + readonly "item_id": string + readonly "delta": string + readonly "sequence_number": number +} +export const BetaResponseCodeInterpreterCallCodeDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "output_audio_format": Schema.optionalKey( - Schema.String.annotate({ - "description": "The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n" + "type": Schema.Literal("response.code_interpreter_call_code.delta").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call_code.delta`." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code is being streamed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "delta": Schema.String.annotate({ + "description": "The partial code snippet being streamed by the code interpreter." + }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a partial code snippet is streamed by the code interpreter.", + "identifier": "BetaResponseCodeInterpreterCallCodeDeltaEvent" +}) +export type BetaResponseCodeInterpreterCallCodeDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.code_interpreter_call_code.done" + readonly "output_index": number + readonly "item_id": string + readonly "code": string + readonly "sequence_number": number +} +export const BetaResponseCodeInterpreterCallCodeDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "input_audio_transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey(Schema.String.annotate({ "description": "The model to use for transcription.\n" })) - }).annotate({ - "description": - "Configuration for input audio transcription, defaults to off and can be\nset to `null` to turn off once on. Input audio transcription is not native\nto the model, since the model consumes audio directly. Transcription runs\nasynchronously and should be treated as rough guidance\nrather than the representation understood by the model.\n" + "type": Schema.Literal("response.code_interpreter_call_code.done").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call_code.done`." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code is finalized." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "code": Schema.String.annotate({ "description": "The final code snippet output by the code interpreter." }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when the code snippet is finalized by the code interpreter.", + "identifier": "BetaResponseCodeInterpreterCallCodeDoneEvent" +}) +export type BetaResponseCodeInterpreterCallCompletedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.code_interpreter_call.completed" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const BetaResponseCodeInterpreterCallCompletedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "speed": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The speed of the model's spoken response. 1.0 is the default speed. 0.25 is\nthe minimum speed. 1.5 is the maximum speed. This value can only be changed\nin between model turns, not while a response is in progress.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0.25)).check(Schema.isLessThanOrEqualTo(1.5)) - ), - "tracing": Schema.optionalKey( - Schema.Union([ - Schema.Literal("auto").annotate({ "description": "Default tracing mode for the session.\n" }), - Schema.Struct({ - "workflow_name": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The name of the workflow to attach to this trace. This is used to\nname the trace in the traces dashboard.\n" - }) - ), - "group_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The group id to attach to this trace to enable filtering and\ngrouping in the traces dashboard.\n" - }) - ), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "The arbitrary metadata to attach to this trace to enable\nfiltering in the traces dashboard.\n" - }) - ) - }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) - ], { mode: "oneOf" }).annotate({ - "title": "Tracing Configuration", - "description": - "Configuration options for tracing. Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" + "type": Schema.Literal("response.code_interpreter_call.completed").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call.completed`." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code interpreter call is completed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when the code interpreter call is completed.", + "identifier": "BetaResponseCodeInterpreterCallCompletedEvent" +}) +export type BetaResponseCodeInterpreterCallInProgressEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.code_interpreter_call.in_progress" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const BetaResponseCodeInterpreterCallInProgressEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "turn_detection": Schema.optionalKey( - Schema.Struct({ - "type": Schema.optionalKey( - Schema.String.annotate({ "description": "Type of turn detection, only `server_vad` is currently supported.\n" }) - ), - "threshold": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" - }).check(Schema.isFinite()) - ), - "prefix_padding_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" - }).check(Schema.isInt()) - ), - "silence_duration_ms": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" - }).check(Schema.isInt()) - ) - }).annotate({ - "description": - "Configuration for turn detection. Can be set to `null` to turn off. Server\nVAD means that the model will detect the start and end of speech based on\naudio volume and respond at the end of user speech.\n" + "type": Schema.Literal("response.code_interpreter_call.in_progress").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call.in_progress`." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code interpreter call is in progress." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a code interpreter call is in progress.", + "identifier": "BetaResponseCodeInterpreterCallInProgressEvent" +}) +export type BetaResponseCodeInterpreterCallInterpretingEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.code_interpreter_call.interpreting" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const BetaResponseCodeInterpreterCallInterpretingEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("function").annotate({ "description": "The type of the tool, i.e. `function`." }) - ), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function." })), - "description": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The description of the function, including guidance on when and how\nto call it, and guidance about what to tell the user when calling\n(if anything).\n" - }) - ), - "parameters": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Parameters of the function in JSON Schema." }) - ) - })).annotate({ "description": "Tools (functions) available to the model." }) + "type": Schema.Literal("response.code_interpreter_call.interpreting").annotate({ + "description": "The type of the event. Always `response.code_interpreter_call.interpreting`." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response for which the code interpreter is interpreting code." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ "description": "The unique identifier of the code interpreter tool call item." }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of this event, used to order streaming events." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when the code interpreter is actively interpreting the code snippet.", + "identifier": "BetaResponseCodeInterpreterCallInterpretingEvent" +}) +export type BetaResponseErrorEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "error" + readonly "code": string | null + readonly "message": string + readonly "param": string | null + readonly "sequence_number": number +} +export const BetaResponseErrorEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "tool_choice": Schema.optionalKey( - Schema.String.annotate({ - "description": "How the model chooses tools. Options are `auto`, `none`, `required`, or\nspecify a function.\n" + "type": Schema.Literal("error").annotate({ "description": "The type of the event. Always `error`.\n" }), + "code": Schema.Union([Schema.String.annotate({ "description": "The error code.\n" }), Schema.Null]), + "message": Schema.String.annotate({ "description": "The error message.\n" }), + "param": Schema.Union([Schema.String.annotate({ "description": "The error parameter.\n" }), Schema.Null]), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "description": "Emitted when an error occurs.", "identifier": "BetaResponseErrorEvent" }) +export type BetaResponseFileSearchCallCompletedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.file_search_call.completed" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const BetaResponseFileSearchCallCompletedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.\n" - }).check(Schema.isFinite()) + "type": Schema.Literal("response.file_search_call.completed").annotate({ + "description": "The type of the event. Always `response.file_search_call.completed`.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the file search call is initiated.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the file search call is initiated.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a file search call is completed (results found).", + "identifier": "BetaResponseFileSearchCallCompletedEvent" +}) +export type BetaResponseFileSearchCallInProgressEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.file_search_call.in_progress" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const BetaResponseFileSearchCallInProgressEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "max_response_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ - "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" + "type": Schema.Literal("response.file_search_call.in_progress").annotate({ + "description": "The type of the event. Always `response.file_search_call.in_progress`.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the file search call is initiated.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the file search call is initiated.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a file search call is initiated.", + "identifier": "BetaResponseFileSearchCallInProgressEvent" +}) +export type BetaResponseFileSearchCallSearchingEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.file_search_call.searching" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const BetaResponseFileSearchCallSearchingEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "truncation": Schema.optionalKey(RealtimeTruncation), - "prompt": Schema.optionalKey(Prompt) + "type": Schema.Literal("response.file_search_call.searching").annotate({ + "description": "The type of the event. Always `response.file_search_call.searching`.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the file search call is searching.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the file search call is initiated.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) }).annotate({ - "description": "A new Realtime session configuration, with an ephemeral key. Default TTL\nfor keys is one minute.\n" + "description": "Emitted when a file search is currently searching.", + "identifier": "BetaResponseFileSearchCallSearchingEvent" }) -export type RealtimeSessionCreateRequestGA = { - readonly "type": "realtime" - readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> - readonly "model"?: - | string - | "gpt-realtime" - | "gpt-realtime-1.5" - | "gpt-realtime-2" - | "gpt-realtime-2025-08-28" - | "gpt-4o-realtime-preview" - | "gpt-4o-realtime-preview-2024-10-01" - | "gpt-4o-realtime-preview-2024-12-17" - | "gpt-4o-realtime-preview-2025-06-03" - | "gpt-4o-mini-realtime-preview" - | "gpt-4o-mini-realtime-preview-2024-12-17" - | "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" - readonly "instructions"?: string - readonly "audio"?: { - readonly "input"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - readonly "delay"?: "minimal" | "low" | "medium" | "high" | "xhigh" - } - readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "turn_detection"?: RealtimeTurnDetection - } - readonly "output"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "voice"?: VoiceIdsShared | { readonly "id": string } - readonly "speed"?: number - } - } - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> - readonly "tracing"?: "auto" | { - readonly "workflow_name"?: string - readonly "group_id"?: string - readonly "metadata"?: {} - } | null - readonly "tools"?: ReadonlyArray - readonly "tool_choice"?: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMCP - readonly "parallel_tool_calls"?: boolean - readonly "reasoning"?: RealtimeReasoning - readonly "max_output_tokens"?: number | "inf" - readonly "truncation"?: RealtimeTruncation - readonly "prompt"?: Prompt +export type BetaResponseFunctionCallArgumentsDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.function_call_arguments.delta" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "delta": string } -export const RealtimeSessionCreateRequestGA = Schema.Struct({ - "type": Schema.Literal("realtime").annotate({ - "description": "The type of session to create. Always `realtime` for the Realtime API.\n" +export const BetaResponseFunctionCallArgumentsDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.function_call_arguments.delta").annotate({ + "description": "The type of the event. Always `response.function_call_arguments.delta`.\n" }), - "output_modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": - "The set of modalities the model can respond with. It defaults to `[\"audio\"]`, indicating\nthat the model will respond with audio plus a transcript. `[\"text\"]` can be used to make\nthe model respond with text only. It is not possible to request both `text` and `audio` at the same time.\n" + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the function-call arguments delta is added to.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the function-call arguments delta is added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "delta": Schema.String.annotate({ "description": "The function-call arguments delta that is added.\n" }) +}).annotate({ + "description": "Emitted when there is a partial function-call arguments delta.", + "identifier": "BetaResponseFunctionCallArgumentsDeltaEvent" +}) +export type BetaResponseFunctionCallArgumentsDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.function_call_arguments.done" + readonly "item_id": string + readonly "name": string + readonly "output_index": number + readonly "sequence_number": number + readonly "arguments": string +} +export const BetaResponseFunctionCallArgumentsDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "gpt-realtime", - "gpt-realtime-1.5", - "gpt-realtime-2", - "gpt-realtime-2025-08-28", - "gpt-4o-realtime-preview", - "gpt-4o-realtime-preview-2024-10-01", - "gpt-4o-realtime-preview-2024-12-17", - "gpt-4o-realtime-preview-2025-06-03", - "gpt-4o-mini-realtime-preview", - "gpt-4o-mini-realtime-preview-2024-12-17", - "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" - ]) - ]).annotate({ "description": "The Realtime model used for this session.\n" }) + "type": Schema.Literal("response.function_call_arguments.done"), + "item_id": Schema.String.annotate({ "description": "The ID of the item." }), + "name": Schema.String.annotate({ "description": "The name of the function that was called." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "instructions": Schema.optionalKey(Schema.String.annotate({ - "description": - "The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.\n\nNote that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.\n" - })), - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the input audio." }) - ), - "transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.\n" - }) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The language of the input audio. Supplying the input language in\n[ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format\nwill improve accuracy and latency.\n" - }) - ), - "prompt": Schema.optionalKey(Schema.String.annotate({ - "description": - "An optional text to guide the model's style or continue a previous audio\nsegment.\nFor `whisper-1`, the [prompt is a list of keywords](/docs/guides/speech-to-text#prompting).\nFor `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example \"expect words related to technology\".\nPrompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - })), - "delay": Schema.optionalKey( - Schema.Literals(["minimal", "low", "medium", "high", "xhigh"]).annotate({ - "description": - "Controls how long the model waits before emitting transcription text.\nHigher values can improve transcription accuracy at the cost of latency.\nOnly supported with `gpt-realtime-whisper` in GA Realtime sessions.\n" - }) - ) - }).annotate({ - "description": - "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" - }) - ), - "noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": - "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" - }) - ), - "turn_detection": Schema.optionalKey(RealtimeTurnDetection) - })), - "output": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the output audio." }) - ), - "voice": Schema.optionalKey( - Schema.Union([ - VoiceIdsShared, - Schema.Struct({ - "id": Schema.String.annotate({ "description": "The custom voice ID, e.g. `voice_1234`." }) - }).annotate({ "description": "Custom voice reference." }) - ]).annotate({ - "title": "Voice", - "description": - "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,\n`marin`, and `cedar`. You may also provide a custom voice object with\nan `id`, for example `{ \"id\": \"voice_1234\" }`. Voice cannot be changed\nduring the session once the model has responded with audio at least once.\nWe recommend `marin` and `cedar` for best quality.\n" - }) - ), - "speed": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The speed of the model's spoken response as a multiple of the original speed.\n1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.\n\nThis parameter is a post-processing adjustment to the audio after it is generated, it's\nalso possible to prompt the model to speak faster or slower.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0.25)).check(Schema.isLessThanOrEqualTo(1.5)) - ) - })) - }).annotate({ "description": "Configuration for input and output audio.\n" }) + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "include": Schema.optionalKey( - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ - "description": - "Additional fields to include in server outputs.\n\n`item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" + "arguments": Schema.String.annotate({ "description": "The function-call arguments." }) +}).annotate({ + "description": "Emitted when function-call arguments are finalized.", + "identifier": "BetaResponseFunctionCallArgumentsDoneEvent" +}) +export type BetaResponseReasoningSummaryPartAddedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.reasoning_summary_part.added" + readonly "item_id": string + readonly "output_index": number + readonly "summary_index": number + readonly "sequence_number": number + readonly "part": { readonly "type": "summary_text"; readonly "text": string } +} +export const BetaResponseReasoningSummaryPartAddedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "tracing": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Literal("auto").annotate({ - "title": "auto", - "description": "Enables tracing and sets default values for tracing configuration options. Always `auto`.\n" - }), - Schema.Struct({ - "workflow_name": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The name of the workflow to attach to this trace. This is used to\nname the trace in the Traces Dashboard.\n" - }) - ), - "group_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The group id to attach to this trace to enable filtering and\ngrouping in the Traces Dashboard.\n" - }) - ), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "The arbitrary metadata to attach to this trace to enable\nfiltering in the Traces Dashboard.\n" - }) - ) - }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) - ], { mode: "oneOf" }).annotate({ - "title": "Tracing Configuration", - "description": - "Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" - }), - Schema.Null - ]) + "type": Schema.Literal("response.reasoning_summary_part.added").annotate({ + "description": "The type of the event. Always `response.reasoning_summary_part.added`.\n" + }), + "item_id": Schema.String.annotate({ "description": "The ID of the item this summary part is associated with.\n" }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item this summary part is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "summary_index": Schema.Number.annotate({ + "description": "The index of the summary part within the reasoning summary.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Union([RealtimeFunctionTool, MCPTool], { mode: "oneOf" })).annotate({ - "description": "Tools available to the model." + "part": Schema.Struct({ + "type": Schema.Literal("summary_text").annotate({ + "description": "The type of the summary part. Always `summary_text`." + }), + "text": Schema.String.annotate({ "description": "The text of the summary part." }) + }).annotate({ "description": "The summary part that was added.\n" }) +}).annotate({ + "description": "Emitted when a new reasoning summary part is added.", + "identifier": "BetaResponseReasoningSummaryPartAddedEvent" +}) +export type BetaResponseReasoningSummaryPartDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.reasoning_summary_part.done" + readonly "item_id": string + readonly "output_index": number + readonly "summary_index": number + readonly "status"?: "incomplete" + readonly "sequence_number": number + readonly "part": { readonly "type": "summary_text"; readonly "text": string } +} +export const BetaResponseReasoningSummaryPartDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "tool_choice": Schema.optionalKey( - Schema.Union([ToolChoiceOptions, ToolChoiceFunction, ToolChoiceMCP], { mode: "oneOf" }).annotate({ + "type": Schema.Literal("response.reasoning_summary_part.done").annotate({ + "description": "The type of the event. Always `response.reasoning_summary_part.done`.\n" + }), + "item_id": Schema.String.annotate({ "description": "The ID of the item this summary part is associated with.\n" }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item this summary part is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "summary_index": Schema.Number.annotate({ + "description": "The index of the summary part within the reasoning summary.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "status": Schema.optionalKey( + Schema.Literal("incomplete").annotate({ "description": - "How the model chooses tools. Provide one of the string modes or force a specific\nfunction/MCP tool.\n" + "The completion status of the summary part. Omitted when the part completed\nnormally and set to `incomplete` when generation was interrupted.\n" }) ), - "parallel_tool_calls": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether the model may call multiple tools in parallel. Only supported by\nreasoning Realtime models such as `gpt-realtime-2`.\n" + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "part": Schema.Struct({ + "type": Schema.Literal("summary_text").annotate({ + "description": "The type of the summary part. Always `summary_text`." + }), + "text": Schema.String.annotate({ "description": "The text of the summary part." }) + }).annotate({ "description": "The completed summary part.\n" }) +}).annotate({ + "description": "Emitted when a reasoning summary part is completed.", + "identifier": "BetaResponseReasoningSummaryPartDoneEvent" +}) +export type BetaResponseReasoningSummaryTextDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.reasoning_summary_text.delta" + readonly "item_id": string + readonly "output_index": number + readonly "summary_index": number + readonly "delta": string + readonly "sequence_number": number +} +export const BetaResponseReasoningSummaryTextDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "reasoning": Schema.optionalKey(RealtimeReasoning), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ - "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" + "type": Schema.Literal("response.reasoning_summary_text.delta").annotate({ + "description": "The type of the event. Always `response.reasoning_summary_text.delta`.\n" + }), + "item_id": Schema.String.annotate({ + "description": "The ID of the item this summary text delta is associated with.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item this summary text delta is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "summary_index": Schema.Number.annotate({ + "description": "The index of the summary part within the reasoning summary.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String.annotate({ "description": "The text delta that was added to the summary.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a delta is added to a reasoning summary text.", + "identifier": "BetaResponseReasoningSummaryTextDeltaEvent" +}) +export type BetaResponseReasoningSummaryTextDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.reasoning_summary_text.done" + readonly "item_id": string + readonly "output_index": number + readonly "summary_index": number + readonly "text": string + readonly "sequence_number": number +} +export const BetaResponseReasoningSummaryTextDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "truncation": Schema.optionalKey(RealtimeTruncation), - "prompt": Schema.optionalKey(Prompt) -}).annotate({ "title": "Realtime session configuration", "description": "Realtime session object configuration." }) -export type RealtimeSessionCreateResponseGA = { - readonly "type": "realtime" - readonly "id": string - readonly "object": "realtime.session" - readonly "expires_at"?: number - readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> - readonly "model"?: - | string - | "gpt-realtime" - | "gpt-realtime-1.5" - | "gpt-realtime-2" - | "gpt-realtime-2025-08-28" - | "gpt-4o-realtime-preview" - | "gpt-4o-realtime-preview-2024-10-01" - | "gpt-4o-realtime-preview-2024-12-17" - | "gpt-4o-realtime-preview-2025-06-03" - | "gpt-4o-mini-realtime-preview" - | "gpt-4o-mini-realtime-preview-2024-12-17" - | "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" - readonly "instructions"?: string - readonly "audio"?: { - readonly "input"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "transcription"?: { - readonly "model"?: - | string - | "whisper-1" - | "gpt-4o-mini-transcribe" - | "gpt-4o-mini-transcribe-2025-12-15" - | "gpt-4o-transcribe" - | "gpt-4o-transcribe-diarize" - | "gpt-realtime-whisper" - readonly "language"?: string - readonly "prompt"?: string - } - readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } - readonly "turn_detection"?: RealtimeTurnDetection - } - readonly "output"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "voice"?: - | string - | "alloy" - | "ash" - | "ballad" - | "coral" - | "echo" - | "sage" - | "shimmer" - | "verse" - | "marin" - | "cedar" - readonly "speed"?: number - } - } - readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> - readonly "tracing"?: "auto" | { - readonly "workflow_name"?: string - readonly "group_id"?: string - readonly "metadata"?: {} - } | null - readonly "tools"?: ReadonlyArray - readonly "tool_choice"?: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMCP - readonly "reasoning"?: RealtimeReasoning - readonly "max_output_tokens"?: number | "inf" - readonly "truncation"?: RealtimeTruncation - readonly "prompt"?: Prompt + "type": Schema.Literal("response.reasoning_summary_text.done").annotate({ + "description": "The type of the event. Always `response.reasoning_summary_text.done`.\n" + }), + "item_id": Schema.String.annotate({ "description": "The ID of the item this summary text is associated with.\n" }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item this summary text is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "summary_index": Schema.Number.annotate({ + "description": "The index of the summary part within the reasoning summary.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "text": Schema.String.annotate({ "description": "The full text of the completed reasoning summary.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a reasoning summary text is completed.", + "identifier": "BetaResponseReasoningSummaryTextDoneEvent" +}) +export type BetaResponseReasoningTextDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.reasoning_text.delta" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "delta": string + readonly "sequence_number": number } -export const RealtimeSessionCreateResponseGA = Schema.Struct({ - "type": Schema.Literal("realtime").annotate({ - "description": "The type of session to create. Always `realtime` for the Realtime API.\n" +export const BetaResponseReasoningTextDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.reasoning_text.delta").annotate({ + "description": "The type of the event. Always `response.reasoning_text.delta`.\n" }), - "id": Schema.String.annotate({ - "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" + "item_id": Schema.String.annotate({ + "description": "The ID of the item this reasoning text delta is associated with.\n" }), - "object": Schema.Literal("realtime.session").annotate({ - "description": "The object type. Always `realtime.session`." + "output_index": Schema.Number.annotate({ + "description": "The index of the output item this reasoning text delta is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ + "description": "The index of the reasoning content part this delta is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String.annotate({ "description": "The text delta that was added to the reasoning content.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a delta is added to a reasoning text.", + "identifier": "BetaResponseReasoningTextDeltaEvent" +}) +export type BetaResponseReasoningTextDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.reasoning_text.done" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "text": string + readonly "sequence_number": number +} +export const BetaResponseReasoningTextDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.reasoning_text.done").annotate({ + "description": "The type of the event. Always `response.reasoning_text.done`.\n" }), - "expires_at": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Expiration timestamp for the session, in seconds since epoch.", - "format": "unixtime" - }).check(Schema.isInt()) + "item_id": Schema.String.annotate({ "description": "The ID of the item this reasoning text is associated with.\n" }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item this reasoning text is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ "description": "The index of the reasoning content part.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "output_modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": - "The set of modalities the model can respond with. It defaults to `[\"audio\"]`, indicating\nthat the model will respond with audio plus a transcript. `[\"text\"]` can be used to make\nthe model respond with text only. It is not possible to request both `text` and `audio` at the same time.\n" + "text": Schema.String.annotate({ "description": "The full text of the completed reasoning content.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a reasoning text is completed.", + "identifier": "BetaResponseReasoningTextDoneEvent" +}) +export type BetaResponseRefusalDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.refusal.delta" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "delta": string + readonly "sequence_number": number +} +export const BetaResponseRefusalDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "gpt-realtime", - "gpt-realtime-1.5", - "gpt-realtime-2", - "gpt-realtime-2025-08-28", - "gpt-4o-realtime-preview", - "gpt-4o-realtime-preview-2024-10-01", - "gpt-4o-realtime-preview-2024-12-17", - "gpt-4o-realtime-preview-2025-06-03", - "gpt-4o-mini-realtime-preview", - "gpt-4o-mini-realtime-preview-2024-12-17", - "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" - ]) - ]).annotate({ "description": "The Realtime model used for this session.\n" }) - ), - "instructions": Schema.optionalKey(Schema.String.annotate({ - "description": - "The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.\n\nNote that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.\n" - })), - "audio": Schema.optionalKey( - Schema.Struct({ - "input": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the input audio." }) - ), - "transcription": Schema.optionalKey( - Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals([ - "whisper-1", - "gpt-4o-mini-transcribe", - "gpt-4o-mini-transcribe-2025-12-15", - "gpt-4o-transcribe", - "gpt-4o-transcribe-diarize", - "gpt-realtime-whisper" - ]) - ]).annotate({ - "description": - "The model used for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.\n" - }) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ "description": "The language of the input audio.\n" }) - ), - "prompt": Schema.optionalKey( - Schema.String.annotate({ - "description": "The prompt configured for input audio transcription, when present.\n" - }) - ) - }).annotate({ - "description": - "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" - }) - ), - "noise_reduction": Schema.optionalKey( - Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ - "description": - "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" - }) - ), - "turn_detection": Schema.optionalKey(RealtimeTurnDetection) - })), - "output": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the output audio." }) - ), - "voice": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals(["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse", "marin", "cedar"]) - ]).annotate({ - "description": - "The voice the model uses to respond. Voice cannot be changed during the\nsession once the model has responded with audio at least once. Current\nvoice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,\n`shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for\nbest quality.\n" - }) - ), - "speed": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The speed of the model's spoken response as a multiple of the original speed.\n1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.\n\nThis parameter is a post-processing adjustment to the audio after it is generated, it's\nalso possible to prompt the model to speak faster or slower.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0.25)).check(Schema.isLessThanOrEqualTo(1.5)) - ) - })) - }).annotate({ "description": "Configuration for input and output audio.\n" }) + "type": Schema.Literal("response.refusal.delta").annotate({ + "description": "The type of the event. Always `response.refusal.delta`.\n" + }), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the refusal text is added to.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the refusal text is added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ + "description": "The index of the content part that the refusal text is added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String.annotate({ "description": "The refusal text that is added.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when there is a partial refusal text.", + "identifier": "BetaResponseRefusalDeltaEvent" +}) +export type BetaResponseRefusalDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.refusal.done" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "refusal": string + readonly "sequence_number": number +} +export const BetaResponseRefusalDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "include": Schema.optionalKey( - Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ - "description": - "Additional fields to include in server outputs.\n\n`item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" + "type": Schema.Literal("response.refusal.done").annotate({ + "description": "The type of the event. Always `response.refusal.done`.\n" + }), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the refusal text is finalized.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the refusal text is finalized.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ + "description": "The index of the content part that the refusal text is finalized.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "refusal": Schema.String.annotate({ "description": "The refusal text that is finalized.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "description": "Emitted when refusal text is finalized.", "identifier": "BetaResponseRefusalDoneEvent" }) +export type BetaResponseWebSearchCallCompletedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.web_search_call.completed" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number +} +export const BetaResponseWebSearchCallCompletedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "tracing": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Literal("auto").annotate({ - "title": "auto", - "description": "Enables tracing and sets default values for tracing configuration options. Always `auto`.\n" - }), - Schema.Struct({ - "workflow_name": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The name of the workflow to attach to this trace. This is used to\nname the trace in the Traces Dashboard.\n" - }) - ), - "group_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The group id to attach to this trace to enable filtering and\ngrouping in the Traces Dashboard.\n" - }) - ), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "The arbitrary metadata to attach to this trace to enable\nfiltering in the Traces Dashboard.\n" - }) - ) - }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) - ], { mode: "oneOf" }).annotate({ - "title": "Tracing Configuration", - "description": - "Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" - }), - Schema.Null - ]) - ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Union([RealtimeFunctionTool, MCPTool], { mode: "oneOf" })).annotate({ - "description": "Tools available to the model." - }) - ), - "tool_choice": Schema.optionalKey( - Schema.Union([ToolChoiceOptions, ToolChoiceFunction, ToolChoiceMCP], { mode: "oneOf" }).annotate({ - "description": - "How the model chooses tools. Provide one of the string modes or force a specific\nfunction/MCP tool.\n" - }) - ), - "reasoning": Schema.optionalKey(RealtimeReasoning), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ - "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" - }) - ), - "truncation": Schema.optionalKey(RealtimeTruncation), - "prompt": Schema.optionalKey(Prompt) + "type": Schema.Literal("response.web_search_call.completed").annotate({ + "description": "The type of the event. Always `response.web_search_call.completed`.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the web search call is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "Unique ID for the output item associated with the web search call.\n" + }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of the web search call being processed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) }).annotate({ - "title": "Realtime session configuration object", - "description": "A Realtime session configuration object.\n" + "description": "Emitted when a web search call is completed.", + "identifier": "BetaResponseWebSearchCallCompletedEvent" }) -export type CreateVectorStoreFileRequest = { - readonly "file_id": string - readonly "chunking_strategy"?: ChunkingStrategyRequestParam - readonly "attributes"?: VectorStoreFileAttributes +export type BetaResponseWebSearchCallInProgressEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.web_search_call.in_progress" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number } -export const CreateVectorStoreFileRequest = Schema.Struct({ - "file_id": Schema.String.annotate({ - "description": - "A [File](/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files. For multi-file ingestion, we recommend [`file_batches`](/docs/api-reference/vector-stores-file-batches/createBatch) to minimize per-vector-store write requests." +export const BetaResponseWebSearchCallInProgressEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.web_search_call.in_progress").annotate({ + "description": "The type of the event. Always `response.web_search_call.in_progress`.\n" }), - "chunking_strategy": Schema.optionalKey(ChunkingStrategyRequestParam), - "attributes": Schema.optionalKey(VectorStoreFileAttributes) -}) -export type CreateTranscriptionResponseStreamEvent = - | TranscriptTextSegmentEvent - | TranscriptTextDeltaEvent - | TranscriptTextDoneEvent -export const CreateTranscriptionResponseStreamEvent = Schema.Union([ - TranscriptTextSegmentEvent, - TranscriptTextDeltaEvent, - TranscriptTextDoneEvent -]) -export type UsageResponse = { - readonly "object": "page" - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next_page": string | null -} -export const UsageResponse = Schema.Struct({ - "object": Schema.Literal("page"), - "data": Schema.Array(UsageTimeBucket), - "has_more": Schema.Boolean, - "next_page": Schema.Union([Schema.String, Schema.Null]) -}) -export type ListVectorStoresResponse = { - readonly "object": string - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean - readonly [x: string]: unknown -} -export const ListVectorStoresResponse = Schema.StructWithRest( - Schema.Struct({ - "object": Schema.String, - "data": Schema.Array(VectorStoreObject), - "first_id": Schema.String, - "last_id": Schema.String, - "has_more": Schema.Boolean + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the web search call is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "Unique ID for the output item associated with the web search call.\n" }), - [Schema.Record(Schema.String, Schema.Json)] -) -export type ListVectorStoreFilesResponse = { - readonly "object": string - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean - readonly [x: string]: unknown + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of the web search call being processed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a web search call is initiated.", + "identifier": "BetaResponseWebSearchCallInProgressEvent" +}) +export type BetaResponseWebSearchCallSearchingEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.web_search_call.searching" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number } -export const ListVectorStoreFilesResponse = Schema.StructWithRest( - Schema.Struct({ - "object": Schema.String, - "data": Schema.Array(VectorStoreFileObject), - "first_id": Schema.String, - "last_id": Schema.String, - "has_more": Schema.Boolean +export const BetaResponseWebSearchCallSearchingEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.web_search_call.searching").annotate({ + "description": "The type of the event. Always `response.web_search_call.searching`.\n" }), - [Schema.Record(Schema.String, Schema.Json)] -) -export type VectorStoreSearchResultsPage = { - readonly "object": "vector_store.search_results.page" - readonly "search_query": ReadonlyArray - readonly "data": ReadonlyArray - readonly "has_more": boolean - readonly "next_page": string | null -} -export const VectorStoreSearchResultsPage = Schema.Struct({ - "object": Schema.Literal("vector_store.search_results.page").annotate({ - "description": "The object type, which is always `vector_store.search_results.page`" + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the web search call is associated with.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "Unique ID for the output item associated with the web search call.\n" }), - "search_query": Schema.Array(Schema.String.annotate({ "description": "The query used for this search." })), - "data": Schema.Array(VectorStoreSearchResultItem).annotate({ "description": "The list of search result items." }), - "has_more": Schema.Boolean.annotate({ "description": "Indicates if there are more results to fetch." }), - "next_page": Schema.Union([ - Schema.String.annotate({ "description": "The token for the next page, if any." }), - Schema.Null - ]) + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of the web search call being processed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "description": "Emitted when a web search call is executing.", + "identifier": "BetaResponseWebSearchCallSearchingEvent" }) -export type CreateContainerBody = { - readonly "name": string - readonly "file_ids"?: ReadonlyArray - readonly "expires_after"?: { readonly "anchor": "last_active_at"; readonly "minutes": number } - readonly "skills"?: ReadonlyArray - readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g" - readonly "network_policy"?: ContainerNetworkPolicyDisabledParam | ContainerNetworkPolicyAllowlistParam +export type BetaResponseImageGenCallCompletedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.image_generation_call.completed" + readonly "output_index": number + readonly "sequence_number": number + readonly "item_id": string } -export const CreateContainerBody = Schema.Struct({ - "name": Schema.String.annotate({ "description": "Name of the container to create." }), - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ "description": "IDs of files to copy to the container." }) - ), - "expires_after": Schema.optionalKey( - Schema.Struct({ - "anchor": Schema.Literal("last_active_at").annotate({ - "description": "Time anchor for the expiration time. Currently only 'last_active_at' is supported." - }), - "minutes": Schema.Number.check(Schema.isInt()) - }).annotate({ "description": "Container expiration time in seconds relative to the 'anchor' time." }) - ), - "skills": Schema.optionalKey( - Schema.Array(Schema.Union([SkillReferenceParam, InlineSkillParam], { mode: "oneOf" })).annotate({ - "description": "An optional list of skills referenced by id or inline data." +export const BetaResponseImageGenCallCompletedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "memory_limit": Schema.optionalKey( - Schema.Literals(["1g", "4g", "16g", "64g"]).annotate({ - "description": "Optional memory limit for the container. Defaults to \"1g\"." - }) + "type": Schema.Literal("response.image_generation_call.completed").annotate({ + "description": "The type of the event. Always 'response.image_generation_call.completed'." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "network_policy": Schema.optionalKey( - Schema.Union([ContainerNetworkPolicyDisabledParam, ContainerNetworkPolicyAllowlistParam], { mode: "oneOf" }) - .annotate({ "description": "Network access policy for the container." }) - ) + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the image generation item being processed." + }) +}).annotate({ + "title": "ResponseImageGenCallCompletedEvent", + "description": "Emitted when an image generation tool call has completed and the final image is available.\n", + "identifier": "BetaResponseImageGenCallCompletedEvent" }) -export type AutoCodeInterpreterToolParam = { - readonly "type": "auto" - readonly "file_ids"?: ReadonlyArray - readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g" | null - readonly "network_policy"?: ContainerNetworkPolicyDisabledParam | ContainerNetworkPolicyAllowlistParam +export type BetaResponseImageGenCallGeneratingEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.image_generation_call.generating" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number } -export const AutoCodeInterpreterToolParam = Schema.Struct({ - "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }), - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": "An optional list of uploaded files to make available to your code." - }).check(Schema.isMaxLength(50)) - ), - "memory_limit": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["1g", "4g", "16g", "64g"]).annotate({ - "description": "The memory limit for the code interpreter container." - }), - Schema.Null - ]) +export const BetaResponseImageGenCallGeneratingEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "network_policy": Schema.optionalKey( - Schema.Union([ContainerNetworkPolicyDisabledParam, ContainerNetworkPolicyAllowlistParam], { mode: "oneOf" }) - .annotate({ "description": "Network access policy for the container." }) - ) + "type": Schema.Literal("response.image_generation_call.generating").annotate({ + "description": "The type of the event. Always 'response.image_generation_call.generating'." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the image generation item being processed." + }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of the image generation item being processed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) }).annotate({ - "title": "CodeInterpreterToolAuto", - "description": - "Configuration for a code interpreter container. Optionally specify the IDs of the files to run the code on." + "title": "ResponseImageGenCallGeneratingEvent", + "description": "Emitted when an image generation tool call is actively generating an image (intermediate state).\n", + "identifier": "BetaResponseImageGenCallGeneratingEvent" }) -export type ContainerAutoParam = { - readonly "type": "container_auto" - readonly "file_ids"?: ReadonlyArray - readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g" | null - readonly "network_policy"?: ContainerNetworkPolicyDisabledParam | ContainerNetworkPolicyAllowlistParam - readonly "skills"?: ReadonlyArray +export type BetaResponseImageGenCallInProgressEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.image_generation_call.in_progress" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number } -export const ContainerAutoParam = Schema.Struct({ - "type": Schema.Literal("container_auto").annotate({ - "description": "Automatically creates a container for this request" - }), - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": "An optional list of uploaded files to make available to your code." - }).check(Schema.isMaxLength(50)) - ), - "memory_limit": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["1g", "4g", "16g", "64g"]).annotate({ "description": "The memory limit for the container." }), - Schema.Null - ]) - ), - "network_policy": Schema.optionalKey( - Schema.Union([ContainerNetworkPolicyDisabledParam, ContainerNetworkPolicyAllowlistParam], { mode: "oneOf" }) - .annotate({ "description": "Network access policy for the container." }) +export const BetaResponseImageGenCallInProgressEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "skills": Schema.optionalKey( - Schema.Array(Schema.Union([SkillReferenceParam, InlineSkillParam], { mode: "oneOf" })).annotate({ - "description": "An optional list of skills referenced by id or inline data." - }).check(Schema.isMaxLength(200)) - ) -}) -export type EvalItemContentArray = ReadonlyArray -export const EvalItemContentArray = Schema.Array(EvalItemContentItem).annotate({ - "title": "An array of Input text, Output text, Input image, and Input audio", - "description": - "A list of inputs, each of which may be either an input text, output text, input\nimage, or input audio object.\n" -}) -export type OutputTextContent = { - readonly "type": "output_text" - readonly "text": string - readonly "annotations": ReadonlyArray - readonly "logprobs": ReadonlyArray -} -export const OutputTextContent = Schema.Struct({ - "type": Schema.Literal("output_text").annotate({ - "description": "The type of the output text. Always `output_text`." + "type": Schema.Literal("response.image_generation_call.in_progress").annotate({ + "description": "The type of the event. Always 'response.image_generation_call.in_progress'." }), - "text": Schema.String.annotate({ "description": "The text output from the model." }), - "annotations": Schema.Array(Annotation).annotate({ "description": "The annotations of the text output." }), - "logprobs": Schema.Array(LogProb) -}).annotate({ "title": "Output text", "description": "A text output from the model." }) -export type CustomToolCallOutput = { - readonly "type": "custom_tool_call_output" - readonly "id"?: string - readonly "call_id": string - readonly "output": string | ReadonlyArray -} -export const CustomToolCallOutput = Schema.Struct({ - "type": Schema.Literal("custom_tool_call_output").annotate({ - "description": "The type of the custom tool call output. Always `custom_tool_call_output`.\n" + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the image generation item being processed." }), - "id": Schema.optionalKey( - Schema.String.annotate({ "description": "The unique ID of the custom tool call output in the OpenAI platform.\n" }) + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of the image generation item being processed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ + "title": "ResponseImageGenCallInProgressEvent", + "description": "Emitted when an image generation tool call is in progress.\n", + "identifier": "BetaResponseImageGenCallInProgressEvent" +}) +export type BetaResponseImageGenCallPartialImageEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.image_generation_call.partial_image" + readonly "output_index": number + readonly "item_id": string + readonly "sequence_number": number + readonly "partial_image_index": number + readonly "partial_image_b64": string +} +export const BetaResponseImageGenCallPartialImageEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "call_id": Schema.String.annotate({ - "description": "The call ID, used to map this custom tool call output to a custom tool call.\n" + "type": Schema.Literal("response.image_generation_call.partial_image").annotate({ + "description": "The type of the event. Always 'response.image_generation_call.partial_image'." }), - "output": Schema.Union([ - Schema.String.annotate({ - "title": "string output", - "description": "A string of the output of the custom tool call.\n" - }), - Schema.Array(FunctionAndCustomToolCallOutput).annotate({ - "title": "output content list", - "description": "Text, image, or file output of the custom tool call.\n" - }) - ], { mode: "oneOf" }).annotate({ - "description": - "The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n" + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the image generation item being processed." + }), + "sequence_number": Schema.Number.annotate({ + "description": "The sequence number of the image generation item being processed." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "partial_image_index": Schema.Number.annotate({ + "description": "0-based index for the partial image (backend is 1-based, but this is 0-based for the user)." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "partial_image_b64": Schema.String.annotate({ + "description": "Base64-encoded partial image data, suitable for rendering as an image." }) }).annotate({ - "title": "Custom tool call output", - "description": "The output of a custom tool call from your code, being sent back to the model.\n" + "title": "ResponseImageGenCallPartialImageEvent", + "description": "Emitted when a partial image is available during image generation streaming.\n", + "identifier": "BetaResponseImageGenCallPartialImageEvent" }) -export type CustomToolCallOutputResource = { - readonly "type": "custom_tool_call_output" - readonly "id": string - readonly "call_id": string - readonly "output": string | ReadonlyArray - readonly "status": "in_progress" | "completed" | "incomplete" - readonly "created_by"?: string +export type BetaResponseMCPCallArgumentsDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.mcp_call_arguments.delta" + readonly "output_index": number + readonly "item_id": string + readonly "delta": string + readonly "sequence_number": number } -export const CustomToolCallOutputResource = Schema.Struct({ - "type": Schema.Literal("custom_tool_call_output").annotate({ - "description": "The type of the custom tool call output. Always `custom_tool_call_output`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the custom tool call output item.\n" }), - "call_id": Schema.String.annotate({ - "description": "The call ID, used to map this custom tool call output to a custom tool call.\n" - }), - "output": Schema.Union([ - Schema.String.annotate({ - "title": "string output", - "description": "A string of the output of the custom tool call.\n" - }), - Schema.Array(FunctionAndCustomToolCallOutput).annotate({ - "title": "output content list", - "description": "Text, image, or file output of the custom tool call.\n" +export const BetaResponseMCPCallArgumentsDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) - ], { mode: "oneOf" }).annotate({ - "description": - "The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n" + ), + "type": Schema.Literal("response.mcp_call_arguments.delta").annotate({ + "description": "The type of the event. Always 'response.mcp_call_arguments.delta'." }), - "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" + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the MCP tool call item being processed." }), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + "delta": Schema.String.annotate({ + "description": "A JSON string containing the partial update to the arguments for the MCP tool call.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) }).annotate({ - "title": "Custom tool call output", - "description": "The output of a custom tool call from your code, being sent back to the model.\n" + "title": "ResponseMCPCallArgumentsDeltaEvent", + "description": "Emitted when there is a delta (partial update) to the arguments of an MCP tool call.\n", + "identifier": "BetaResponseMCPCallArgumentsDeltaEvent" }) -export type FunctionToolCallOutput = { - readonly "id"?: string - readonly "type": "function_call_output" - readonly "call_id": string - readonly "output": string | ReadonlyArray - readonly "status"?: "in_progress" | "completed" | "incomplete" +export type BetaResponseMCPCallArgumentsDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.mcp_call_arguments.done" + readonly "output_index": number + readonly "item_id": string + readonly "arguments": string + readonly "sequence_number": number } -export const FunctionToolCallOutput = Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The unique ID of the function tool call output. Populated when this item\nis returned via API.\n" +export const BetaResponseMCPCallArgumentsDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "type": Schema.Literal("function_call_output").annotate({ - "description": "The type of the function tool call output. Always `function_call_output`.\n" + "type": Schema.Literal("response.mcp_call_arguments.done").annotate({ + "description": "The type of the event. Always 'response.mcp_call_arguments.done'." }), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the function tool call generated by the model.\n" + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the MCP tool call item being processed." }), - "output": Schema.Union([ - Schema.String.annotate({ - "title": "string output", - "description": "A string of the output of the function call.\n" - }), - Schema.Array(FunctionAndCustomToolCallOutput).annotate({ - "title": "output content list", - "description": "Text, image, or file output of the function call.\n" - }) - ], { mode: "oneOf" }).annotate({ - "description": - "The output from the function call generated by your code.\nCan be a string or an list of output content.\n" + "arguments": Schema.String.annotate({ + "description": "A JSON string containing the finalized arguments for the MCP tool call.\n" }), - "status": Schema.optionalKey( - 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" - }) + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "title": "Function tool call output", "description": "The output of a function tool call.\n" }) -export type FunctionToolCallOutputResource = { - readonly "id": string - readonly "type": "function_call_output" - readonly "call_id": string - readonly "output": string | ReadonlyArray - readonly "status": "in_progress" | "completed" | "incomplete" - readonly "created_by"?: string +}).annotate({ + "title": "ResponseMCPCallArgumentsDoneEvent", + "description": "Emitted when the arguments for an MCP tool call are finalized.\n", + "identifier": "BetaResponseMCPCallArgumentsDoneEvent" +}) +export type BetaResponseMCPCallCompletedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.mcp_call.completed" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number } -export const FunctionToolCallOutputResource = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the function call tool output.\n" }), - "type": Schema.Literal("function_call_output").annotate({ - "description": "The type of the function tool call output. Always `function_call_output`.\n" - }), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the function tool call generated by the model.\n" - }), - "output": Schema.Union([ - Schema.String.annotate({ - "title": "string output", - "description": "A string of the output of the function call.\n" - }), - Schema.Array(FunctionAndCustomToolCallOutput).annotate({ - "title": "output content list", - "description": "Text, image, or file output of the function call.\n" - }) - ], { mode: "oneOf" }).annotate({ - "description": - "The output from the function call generated by your code.\nCan be a string or an list of output content.\n" - }), - "status": Schema.Union([ - Schema.Literal("in_progress").annotate({ - "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" - }), - Schema.Literal("completed").annotate({ - "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" - }), - Schema.Literal("incomplete").annotate({ - "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" +export const BetaResponseMCPCallCompletedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) - ]).annotate({ - "description": - "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + ), + "type": Schema.Literal("response.mcp_call.completed").annotate({ + "description": "The type of the event. Always 'response.mcp_call.completed'." }), - "created_by": Schema.optionalKey( - Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that completed." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that completed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "title": "Function tool call output", "description": "The output of a function tool call.\n" }) -export type InputMessageContentList = ReadonlyArray -export const InputMessageContentList = Schema.Array(InputContent).annotate({ - "title": "Input item content list", - "description": "A list of one or many input items to the model, containing different content \ntypes.\n" +}).annotate({ + "title": "ResponseMCPCallCompletedEvent", + "description": "Emitted when an MCP tool call has completed successfully.\n", + "identifier": "BetaResponseMCPCallCompletedEvent" }) -export type ComputerAction = - | ClickParam - | DoubleClickAction - | DragParam - | KeyPressAction - | MoveParam - | ScreenshotParam - | ScrollParam - | TypeParam - | WaitParam -export const ComputerAction = Schema.Union([ - ClickParam, - DoubleClickAction, - DragParam, - KeyPressAction, - MoveParam, - ScreenshotParam, - ScrollParam, - TypeParam, - WaitParam -], { mode: "oneOf" }) -export type NamespaceToolParam = { - readonly "type": "namespace" - readonly "name": string - readonly "description": string - readonly "tools": ReadonlyArray +export type BetaResponseMCPCallFailedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.mcp_call.failed" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number } -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." +export const BetaResponseMCPCallFailedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) - ).annotate({ "description": "The function/custom tools available inside this namespace." }).check( - Schema.isMinLength(1) + ), + "type": Schema.Literal("response.mcp_call.failed").annotate({ + "description": "The type of the event. Always 'response.mcp_call.failed'." + }), + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that failed." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that failed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).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 +}).annotate({ + "title": "ResponseMCPCallFailedEvent", + "description": "Emitted when an MCP tool call has failed.\n", + "identifier": "BetaResponseMCPCallFailedEvent" +}) +export type BetaResponseMCPCallInProgressEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.mcp_call.in_progress" + readonly "sequence_number": number + readonly "output_index": number + readonly "item_id": 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`." +export const BetaResponseMCPCallInProgressEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.mcp_call.in_progress").annotate({ + "description": "The type of the event. Always 'response.mcp_call.in_progress'." }), - "output": Schema.Array(FunctionShellCallOutputContent).annotate({ - "description": "An array of shell call output contents" + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the MCP tool call item being processed." + }) +}).annotate({ + "title": "ResponseMCPCallInProgressEvent", + "description": "Emitted when an MCP tool call is in progress.\n", + "identifier": "BetaResponseMCPCallInProgressEvent" +}) +export type BetaResponseMCPListToolsCompletedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.mcp_list_tools.completed" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number +} +export const BetaResponseMCPListToolsCompletedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.mcp_list_tools.completed").annotate({ + "description": "The type of the event. Always 'response.mcp_list_tools.completed'." }), - "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." }) + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that produced this output." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that was processed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "title": "Shell call output", "description": "The output of a shell tool call that was emitted." }) -export type ImagesResponse = { - readonly "created": number - readonly "data"?: ReadonlyArray - readonly "background"?: "transparent" | "opaque" - readonly "output_format"?: "png" | "webp" | "jpeg" - readonly "size"?: "1024x1024" | "1024x1536" | "1536x1024" - readonly "quality"?: "low" | "medium" | "high" - readonly "usage"?: ImageGenUsage +}).annotate({ + "title": "ResponseMCPListToolsCompletedEvent", + "description": "Emitted when the list of available MCP tools has been successfully retrieved.\n", + "identifier": "BetaResponseMCPListToolsCompletedEvent" +}) +export type BetaResponseMCPListToolsFailedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.mcp_list_tools.failed" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number } -export const ImagesResponse = Schema.Struct({ - "created": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the image was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "data": Schema.optionalKey(Schema.Array(Image).annotate({ "description": "The list of generated images." })), - "background": Schema.optionalKey( - Schema.Literals(["transparent", "opaque"]).annotate({ - "description": "The background parameter used for the image generation. Either `transparent` or `opaque`." +export const BetaResponseMCPListToolsFailedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "output_format": Schema.optionalKey( - Schema.Literals(["png", "webp", "jpeg"]).annotate({ - "description": "The output format of the image generation. Either `png`, `webp`, or `jpeg`." - }) + "type": Schema.Literal("response.mcp_list_tools.failed").annotate({ + "description": "The type of the event. Always 'response.mcp_list_tools.failed'." + }), + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that failed." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that failed." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "size": Schema.optionalKey( - Schema.Literals(["1024x1024", "1024x1536", "1536x1024"]).annotate({ - "description": "The size of the image generated. Either `1024x1024`, `1024x1536`, or `1536x1024`." + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "ResponseMCPListToolsFailedEvent", + "description": "Emitted when the attempt to list available MCP tools has failed.\n", + "identifier": "BetaResponseMCPListToolsFailedEvent" +}) +export type BetaResponseMCPListToolsInProgressEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.mcp_list_tools.in_progress" + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number +} +export const BetaResponseMCPListToolsInProgressEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "quality": Schema.optionalKey( - Schema.Literals(["low", "medium", "high"]).annotate({ - "description": "The quality of the image generated. Either `low`, `medium`, or `high`." + "type": Schema.Literal("response.mcp_list_tools.in_progress").annotate({ + "description": "The type of the event. Always 'response.mcp_list_tools.in_progress'." + }), + "item_id": Schema.String.annotate({ "description": "The ID of the MCP tool call item that is being processed." }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that is being processed." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "ResponseMCPListToolsInProgressEvent", + "description": "Emitted when the system is in the process of retrieving the list of available MCP tools.\n", + "identifier": "BetaResponseMCPListToolsInProgressEvent" +}) +export type BetaResponseOutputTextAnnotationAddedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.output_text.annotation.added" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "annotation_index": number + readonly "sequence_number": number + readonly "annotation": {} +} +export const BetaResponseOutputTextAnnotationAddedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "usage": Schema.optionalKey(ImageGenUsage) -}).annotate({ "title": "Image generation response", "description": "The response from the image generation endpoint." }) -export type AssistantMessageItem = { - readonly "id": string - readonly "object": "chatkit.thread_item" - readonly "created_at": number - readonly "thread_id": string - readonly "type": "chatkit.assistant_message" - readonly "content": ReadonlyArray + "type": Schema.Literal("response.output_text.annotation.added").annotate({ + "description": "The type of the event. Always 'response.output_text.annotation.added'." + }), + "item_id": Schema.String.annotate({ + "description": "The unique identifier of the item to which the annotation is being added." + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item in the response's output array." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ "description": "The index of the content part within the output item." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "annotation_index": Schema.Number.annotate({ "description": "The index of the annotation within the content part." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "annotation": Schema.Struct({}).annotate({ + "description": "The annotation object being added. (See annotation schema for details.)" + }) +}).annotate({ + "title": "ResponseOutputTextAnnotationAddedEvent", + "description": "Emitted when an annotation is added to output text content.\n", + "identifier": "BetaResponseOutputTextAnnotationAddedEvent" +}) +export type BetaResponseCustomToolCallInputDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.custom_tool_call_input.delta" + readonly "sequence_number": number + readonly "output_index": number + readonly "item_id": string + readonly "delta": string } -export const AssistantMessageItem = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), - "object": Schema.Literal("chatkit.thread_item").annotate({ - "description": "Type discriminator that is always `chatkit.thread_item`." +export const BetaResponseCustomToolCallInputDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.custom_tool_call_input.delta").annotate({ + "description": "The event type identifier." }), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) for when the item was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), - "type": Schema.Literal("chatkit.assistant_message").annotate({ - "description": "Type discriminator that is always `chatkit.assistant_message`." + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "output_index": Schema.Number.annotate({ "description": "The index of the output this delta applies to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "item_id": Schema.String.annotate({ + "description": "Unique identifier for the API item associated with this event." }), - "content": Schema.Array(ResponseOutputText).annotate({ "description": "Ordered assistant response segments." }) -}).annotate({ "title": "Assistant message", "description": "Assistant-authored message within a thread." }) -export type ThreadListResource = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "last_id": string | null - readonly "has_more": boolean + "delta": Schema.String.annotate({ "description": "The incremental input data (delta) for the custom tool call." }) +}).annotate({ + "title": "ResponseCustomToolCallInputDelta", + "description": "Event representing a delta (partial update) to the input of a custom tool call.\n", + "identifier": "BetaResponseCustomToolCallInputDeltaEvent" +}) +export type BetaResponseCustomToolCallInputDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.custom_tool_call_input.done" + readonly "sequence_number": number + readonly "output_index": number + readonly "item_id": string + readonly "input": string } -export const ThreadListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), - "data": Schema.Array(ThreadResource).annotate({ "description": "A list of items" }), - "first_id": Schema.Union([ - Schema.String.annotate({ "description": "The ID of the first item in the list." }), - Schema.Null - ]), - "last_id": Schema.Union([ - Schema.String.annotate({ "description": "The ID of the last item in the list." }), - Schema.Null - ]), - "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }) -}).annotate({ "title": "Threads", "description": "A paginated list of ChatKit threads." }) -export type AuditLog = { - readonly "id": string - readonly "type": AuditLogEventType - readonly "effective_at": number - readonly "project"?: { readonly "id"?: string; readonly "name"?: string } - readonly "actor"?: AuditLogActor | null - readonly "api_key.created"?: { - readonly "id"?: string - readonly "data"?: { readonly "scopes"?: ReadonlyArray } - } - readonly "api_key.updated"?: { - readonly "id"?: string - readonly "changes_requested"?: { readonly "scopes"?: ReadonlyArray } - } - readonly "api_key.deleted"?: { readonly "id"?: string } - readonly "checkpoint.permission.created"?: { - readonly "id"?: string - readonly "data"?: { readonly "project_id"?: string; readonly "fine_tuned_model_checkpoint"?: string } - } - readonly "checkpoint.permission.deleted"?: { readonly "id"?: string } - readonly "external_key.registered"?: { readonly "id"?: string; readonly "data"?: {} } - readonly "external_key.removed"?: { readonly "id"?: string } - readonly "group.created"?: { readonly "id"?: string; readonly "data"?: { readonly "group_name"?: string } } - readonly "group.updated"?: { - readonly "id"?: string - readonly "changes_requested"?: { readonly "group_name"?: string } - } - readonly "group.deleted"?: { readonly "id"?: string } - readonly "scim.enabled"?: { readonly "id"?: string } - readonly "scim.disabled"?: { readonly "id"?: string } - readonly "invite.sent"?: { - readonly "id"?: string - readonly "data"?: { readonly "email"?: string; readonly "role"?: string } - } - readonly "invite.accepted"?: { readonly "id"?: string } - readonly "invite.deleted"?: { readonly "id"?: string } - readonly "ip_allowlist.created"?: { - readonly "id"?: string - readonly "name"?: string - readonly "allowed_ips"?: ReadonlyArray - } - readonly "ip_allowlist.updated"?: { readonly "id"?: string; readonly "allowed_ips"?: ReadonlyArray } - readonly "ip_allowlist.deleted"?: { - readonly "id"?: string - readonly "name"?: string - readonly "allowed_ips"?: ReadonlyArray - } - readonly "ip_allowlist.config.activated"?: { - readonly "configs"?: ReadonlyArray<{ readonly "id"?: string; readonly "name"?: string }> - } - readonly "ip_allowlist.config.deactivated"?: { - readonly "configs"?: ReadonlyArray<{ readonly "id"?: string; readonly "name"?: string }> - } - readonly "login.succeeded"?: {} - readonly "login.failed"?: { readonly "error_code"?: string; readonly "error_message"?: string } - readonly "logout.succeeded"?: {} - readonly "logout.failed"?: { readonly "error_code"?: string; readonly "error_message"?: string } - readonly "organization.updated"?: { - readonly "id"?: string - readonly "changes_requested"?: { - readonly "title"?: string - readonly "description"?: string - readonly "name"?: string - readonly "threads_ui_visibility"?: string - readonly "usage_dashboard_visibility"?: string - readonly "api_call_logging"?: string - readonly "api_call_logging_project_ids"?: string - } - } - readonly "project.created"?: { - readonly "id"?: string - readonly "data"?: { readonly "name"?: string; readonly "title"?: string } - } - readonly "project.updated"?: { readonly "id"?: string; readonly "changes_requested"?: { readonly "title"?: string } } - readonly "project.archived"?: { readonly "id"?: string } - readonly "project.deleted"?: { readonly "id"?: string } - readonly "rate_limit.updated"?: { - readonly "id"?: string - readonly "changes_requested"?: { - readonly "max_requests_per_1_minute"?: number - readonly "max_tokens_per_1_minute"?: number - readonly "max_images_per_1_minute"?: number - readonly "max_audio_megabytes_per_1_minute"?: number - readonly "max_requests_per_1_day"?: number - readonly "batch_1_day_max_input_tokens"?: number - } - } - readonly "rate_limit.deleted"?: { readonly "id"?: string } - readonly "role.created"?: { - readonly "id"?: string - readonly "role_name"?: string - readonly "permissions"?: ReadonlyArray - readonly "resource_type"?: string - readonly "resource_id"?: string - } - readonly "role.updated"?: { - readonly "id"?: string - readonly "changes_requested"?: { - readonly "role_name"?: string - readonly "resource_id"?: string - readonly "resource_type"?: string - readonly "permissions_added"?: ReadonlyArray - readonly "permissions_removed"?: ReadonlyArray - readonly "description"?: string - readonly "metadata"?: {} - } - } - readonly "role.deleted"?: { readonly "id"?: string } - readonly "role.assignment.created"?: { - readonly "id"?: string - readonly "principal_id"?: string - readonly "principal_type"?: string - readonly "resource_id"?: string - readonly "resource_type"?: string - } - readonly "role.assignment.deleted"?: { - readonly "id"?: string - readonly "principal_id"?: string - readonly "principal_type"?: string - readonly "resource_id"?: string - readonly "resource_type"?: string - } - readonly "service_account.created"?: { readonly "id"?: string; readonly "data"?: { readonly "role"?: string } } - readonly "service_account.updated"?: { - readonly "id"?: string - readonly "changes_requested"?: { readonly "role"?: string } - } - readonly "service_account.deleted"?: { readonly "id"?: string } - readonly "user.added"?: { readonly "id"?: string; readonly "data"?: { readonly "role"?: string } } - readonly "user.updated"?: { readonly "id"?: string; readonly "changes_requested"?: { readonly "role"?: string } } - readonly "user.deleted"?: { readonly "id"?: string } - readonly "certificate.created"?: { readonly "id"?: string; readonly "name"?: string } - readonly "certificate.updated"?: { readonly "id"?: string; readonly "name"?: string } - readonly "certificate.deleted"?: { readonly "id"?: string; readonly "name"?: string; readonly "certificate"?: string } - readonly "certificates.activated"?: { - readonly "certificates"?: ReadonlyArray<{ readonly "id"?: string; readonly "name"?: string }> - } - readonly "certificates.deactivated"?: { - readonly "certificates"?: ReadonlyArray<{ readonly "id"?: string; readonly "name"?: string }> - } -} -export const AuditLog = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The ID of this log." }), - "type": AuditLogEventType, - "effective_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of the event.", - "format": "unixtime" - }).check(Schema.isInt()), - "project": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The project title." })) - }).annotate({ - "description": - "The project that the action was scoped to. Absent for actions not scoped to projects. Note that any admin actions taken via Admin API keys are associated with the default project." +export const BetaResponseCustomToolCallInputDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "actor": Schema.optionalKey(Schema.Union([AuditLogActor, Schema.Null])), - "api_key.created": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The tracking ID of the API key." })), - "data": Schema.optionalKey( - Schema.Struct({ - "scopes": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": "A list of scopes allowed for the API key, e.g. `[\"api.model.request\"]`" - }) - ) - }).annotate({ "description": "The payload used to create the API key." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "type": Schema.Literal("response.custom_tool_call_input.done").annotate({ + "description": "The event type identifier." + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "api_key.updated": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The tracking ID of the API key." })), - "changes_requested": Schema.optionalKey( - Schema.Struct({ - "scopes": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": "A list of scopes allowed for the API key, e.g. `[\"api.model.request\"]`" - }) - ) - }).annotate({ "description": "The payload used to update the API key." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "output_index": Schema.Number.annotate({ "description": "The index of the output this event applies to." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "api_key.deleted": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The tracking ID of the API key." })) - }).annotate({ "description": "The details for events with this `type`." }) + "item_id": Schema.String.annotate({ + "description": "Unique identifier for the API item associated with this event." + }), + "input": Schema.String.annotate({ "description": "The complete input data for the custom tool call." }) +}).annotate({ + "title": "ResponseCustomToolCallInputDone", + "description": "Event indicating that input for a custom tool call is complete.\n", + "identifier": "BetaResponseCustomToolCallInputDoneEvent" +}) +export type BetaAnnotation = BetaFileCitationBody | BetaUrlCitationBody | BetaContainerFileCitationBody | BetaFilePath +export const BetaAnnotation = Schema.Union([ + BetaFileCitationBody, + BetaUrlCitationBody, + BetaContainerFileCitationBody, + BetaFilePath +], { mode: "oneOf" }).annotate({ + "description": "An annotation that applies to a span of output text.", + "identifier": "BetaAnnotation" +}) +export type BetaLogProb = { + readonly "token": string + readonly "logprob": number + readonly "bytes": ReadonlyArray + readonly "top_logprobs": ReadonlyArray +} +export const BetaLogProb = Schema.Struct({ + "token": Schema.String, + "logprob": Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "top_logprobs": Schema.Array(BetaTopLogProb) +}).annotate({ + "title": "Log probability", + "description": "The log probability of a token.", + "identifier": "BetaLogProb" +}) +export type BetaFileSearchToolCall = { + readonly "agent"?: BetaAgentTag | null + readonly "id": string + readonly "type": "file_search_call" + readonly "status": "in_progress" | "searching" | "completed" | "incomplete" | "failed" + readonly "queries": ReadonlyArray + readonly "results"?: + | ReadonlyArray< + { + readonly "file_id"?: string + readonly "text"?: string + readonly "filename"?: string + readonly "attributes"?: BetaVectorStoreFileAttributes + readonly "score"?: number + } + > + | null +} +export const BetaFileSearchToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "checkpoint.permission.created": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the checkpoint permission." })), - "data": Schema.optionalKey( - Schema.Struct({ - "project_id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The ID of the project that the checkpoint permission was created for." - }) - ), - "fine_tuned_model_checkpoint": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the fine-tuned model checkpoint." }) - ) - }).annotate({ "description": "The payload used to create the checkpoint permission." }) + "id": Schema.String.annotate({ "description": "The unique ID of the file search tool call.\n" }), + "type": Schema.Literal("file_search_call").annotate({ + "description": "The type of the file search tool call. Always `file_search_call`.\n" + }), + "status": Schema.Literals(["in_progress", "searching", "completed", "incomplete", "failed"]).annotate({ + "description": + "The status of the file search tool call. One of `in_progress`,\n`searching`, `incomplete` or `failed`,\n" + }), + "queries": Schema.Array(Schema.String).annotate({ "description": "The queries used to search for files.\n" }), + "results": Schema.optionalKey(Schema.Union([ + Schema.Array(Schema.Struct({ + "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the file.\n" })), + "text": Schema.optionalKey( + Schema.String.annotate({ "description": "The text that was retrieved from the file.\n" }) + ), + "filename": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the file.\n" })), + "attributes": Schema.optionalKey(BetaVectorStoreFileAttributes), + "score": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The relevance score of the file - a value between 0 and 1.\n", + "format": "float" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ) - }).annotate({ - "description": "The project and fine-tuned model checkpoint that the checkpoint permission was created for." - }) + })).annotate({ "description": "The results of the file search tool call.\n" }), + Schema.Null + ])) +}).annotate({ + "title": "File search tool call", + "description": + "The results of a file search tool call. See the\n[file search guide](/docs/guides/tools-file-search) for more information.\n", + "identifier": "BetaFileSearchToolCall" +}) +export type BetaClickParam = { + readonly "type": "click" + readonly "button": BetaClickButtonType + readonly "x": number + readonly "y": number + readonly "keys"?: ReadonlyArray | null +} +export const BetaClickParam = Schema.Struct({ + "type": Schema.Literal("click").annotate({ + "description": "Specifies the event type. For a click action, this property is always `click`." + }), + "button": Schema.suspend((): Schema.Codec => BetaClickButtonType).annotate({ + "description": + "Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`." + }), + "x": Schema.Number.annotate({ "description": "The x-coordinate where the click occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "checkpoint.permission.deleted": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the checkpoint permission." })) - }).annotate({ "description": "The details for events with this `type`." }) + "y": Schema.Number.annotate({ "description": "The y-coordinate where the click occurred." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "external_key.registered": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the external key configuration." })), - "data": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "The configuration for the external key." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "keys": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).annotate({ "description": "The keys being held while clicking." }), + Schema.Null + ]) + ) +}).annotate({ "title": "Click", "description": "A click action.", "identifier": "BetaClickParam" }) +export type BetaDragParam = { + readonly "type": "drag" + readonly "path": ReadonlyArray + readonly "keys"?: ReadonlyArray | null +} +export const BetaDragParam = Schema.Struct({ + "type": Schema.Literal("drag").annotate({ + "description": "Specifies the event type. For a drag action, this property is always set to `drag`." + }), + "path": Schema.Array(BetaCoordParam).annotate({ + "description": + "An array of coordinates representing the path of the drag action. Coordinates will appear as an array of objects, eg\n```\n[\n { x: 100, y: 200 },\n { x: 200, y: 300 }\n]\n```" + }), + "keys": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).annotate({ "description": "The keys being held while dragging the mouse." }), + Schema.Null + ]) + ) +}).annotate({ "title": "Drag", "description": "A drag action.", "identifier": "BetaDragParam" }) +export type BetaCompactionTriggerItemParam = { + readonly "agent"?: Beta_AgentTagParam | null + readonly "type": "compaction_trigger" +} +export const BetaCompactionTriggerItemParam = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) ), - "external_key.removed": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the external key configuration." })) - }).annotate({ "description": "The details for events with this `type`." }) + "type": Schema.Literal("compaction_trigger").annotate({ + "description": "The type of the item. Always `compaction_trigger`." + }) +}).annotate({ + "title": "Compaction trigger", + "description": "Compacts the current context. Must be the final input item.", + "identifier": "BetaCompactionTriggerItemParam" +}) +export type BetaItemReferenceParam = { + readonly "agent"?: Beta_AgentTagParam | null + readonly "type"?: "item_reference" | null + readonly "id": string +} +export const BetaItemReferenceParam = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) ), - "group.created": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the group." })), - "data": Schema.optionalKey( - Schema.Struct({ - "group_name": Schema.optionalKey(Schema.String.annotate({ "description": "The group name." })) - }).annotate({ "description": "Information about the created group." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "type": Schema.optionalKey( + Schema.Union([ + Schema.Literal("item_reference").annotate({ + "description": "The type of item to reference. Always `item_reference`." + }), + Schema.Null + ]) ), - "group.updated": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the group." })), - "changes_requested": Schema.optionalKey( - Schema.Struct({ - "group_name": Schema.optionalKey(Schema.String.annotate({ "description": "The updated group name." })) - }).annotate({ "description": "The payload used to update the group." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "id": Schema.String.annotate({ "description": "The ID of the item to reference." }) +}).annotate({ + "title": "Item reference", + "description": "An internal identifier for an item to reference.", + "identifier": "BetaItemReferenceParam" +}) +export type BetaProgramItemParam = { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id": string + readonly "type": "program" + readonly "call_id": string + readonly "code": string + readonly "fingerprint": string +} +export const BetaProgramItemParam = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) ), - "group.deleted": Schema.optionalKey( - Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the group." })) }) - .annotate({ "description": "The details for events with this `type`." }) + "id": Schema.String.annotate({ "description": "The unique ID of this program item." }), + "type": Schema.Literal("program").annotate({ "description": "The item type. Always `program`." }), + "call_id": Schema.String.annotate({ "description": "The stable call ID of the program item." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "code": Schema.String.annotate({ "description": "The JavaScript source executed by programmatic tool calling." }) + .check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })), + "fingerprint": Schema.String.annotate({ + "description": "Opaque program replay fingerprint that must be round-tripped." + }).check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })) +}).annotate({ "identifier": "BetaProgramItemParam" }) +export type BetaComputerToolCallOutputResource = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "computer_call_output" + readonly "id": string + readonly "call_id": string + readonly "acknowledged_safety_checks"?: ReadonlyArray + readonly "output": BetaComputerScreenshotImage + readonly "status": "completed" | "incomplete" + readonly "created_by"?: string +} +export const BetaComputerToolCallOutputResource = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "scim.enabled": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the SCIM was enabled for." })) - }).annotate({ "description": "The details for events with this `type`." }) + "type": Schema.Literal("computer_call_output").annotate({ + "description": "The type of the computer tool call output. Always `computer_call_output`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the computer call tool output.\n" }), + "call_id": Schema.String.annotate({ "description": "The ID of the computer tool call that produced the output.\n" }), + "acknowledged_safety_checks": Schema.optionalKey( + Schema.Array(BetaComputerCallSafetyCheckParam).annotate({ + "description": "The safety checks reported by the API that have been acknowledged by the\ndeveloper.\n" + }) ), - "scim.disabled": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the SCIM was disabled for." })) - }).annotate({ "description": "The details for events with this `type`." }) + "output": BetaComputerScreenshotImage, + "status": Schema.Union([Schema.Literal("completed"), Schema.Literal("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" + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ) +}).annotate({ + "title": "Computer tool call output", + "description": "The output of a computer tool call.\n", + "identifier": "BetaComputerToolCallOutputResource" +}) +export type BetaToolCallCaller = BetaDirectToolCallCaller | BetaProgramToolCallCaller +export const BetaToolCallCaller = Schema.Union([BetaDirectToolCallCaller, BetaProgramToolCallCaller], { mode: "oneOf" }) + .annotate({ + "description": "The execution context that produced this tool call.", + "identifier": "BetaToolCallCaller" + }) +export type BetaInputTextContentParam = { + readonly "type": "input_text" + readonly "text": string + readonly "prompt_cache_breakpoint"?: BetaPromptCacheBreakpointParam | null +} +export const BetaInputTextContentParam = Schema.Struct({ + "type": Schema.Literal("input_text").annotate({ "description": "The type of the input item. Always `input_text`." }), + "text": Schema.String.annotate({ "description": "The text input to the model." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) ), - "invite.sent": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the invite." })), - "data": Schema.optionalKey( - Schema.Struct({ - "email": Schema.optionalKey( - Schema.String.annotate({ "description": "The email invited to the organization." }) - ), - "role": Schema.optionalKey( - Schema.String.annotate({ - "description": "The role the email was invited to be. Is either `owner` or `member`." - }) - ) - }).annotate({ "description": "The payload used to create the invite." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "prompt_cache_breakpoint": Schema.optionalKey(Schema.Union([BetaPromptCacheBreakpointParam, Schema.Null])) +}).annotate({ + "title": "Input text", + "description": "A text input to the model.", + "identifier": "BetaInputTextContentParam" +}) +export type BetaInputImageContentParamAutoParam = { + readonly "type": "input_image" + readonly "image_url"?: string | null + readonly "file_id"?: string | null + readonly "detail"?: BetaDetailEnum | null + readonly "prompt_cache_breakpoint"?: BetaPromptCacheBreakpointParam | null +} +export const BetaInputImageContentParamAutoParam = Schema.Struct({ + "type": Schema.Literal("input_image").annotate({ + "description": "The type of the input item. Always `input_image`." + }), + "image_url": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.", + "format": "uri" + }).check(Schema.isMaxLength(20971520).annotate({ "expected": "a value with a length of at most 20971520" })), + Schema.Null + ]) ), - "invite.accepted": Schema.optionalKey( - Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the invite." })) }) - .annotate({ "description": "The details for events with this `type`." }) + "file_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), + Schema.Null + ]) ), - "invite.deleted": Schema.optionalKey( - Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the invite." })) }) - .annotate({ "description": "The details for events with this `type`." }) + "detail": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaDetailEnum).annotate({ + "description": + "The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`." + }), + Schema.Null + ]) ), - "ip_allowlist.created": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." })), - "name": Schema.optionalKey( - Schema.String.annotate({ "description": "The name of the IP allowlist configuration." }) - ), - "allowed_ips": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": "The IP addresses or CIDR ranges included in the configuration." - }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "prompt_cache_breakpoint": Schema.optionalKey(Schema.Union([BetaPromptCacheBreakpointParam, Schema.Null])) +}).annotate({ + "title": "Input image", + "description": "An image input to the model. Learn about [image inputs](/docs/guides/vision)", + "identifier": "BetaInputImageContentParamAutoParam" +}) +export type BetaInputFileContentParam = { + readonly "type": "input_file" + readonly "file_id"?: string | null + readonly "filename"?: string | null + readonly "file_data"?: string | null + readonly "file_url"?: string | null + readonly "detail"?: BetaFileDetailEnum + readonly "prompt_cache_breakpoint"?: BetaPromptCacheBreakpointParam | null +} +export const BetaInputFileContentParam = Schema.Struct({ + "type": Schema.Literal("input_file").annotate({ "description": "The type of the input item. Always `input_file`." }), + "file_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The ID of the file to be sent to the model." }), + Schema.Null + ]) ), - "ip_allowlist.updated": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." })), - "allowed_ips": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": "The updated set of IP addresses or CIDR ranges in the configuration." - }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "filename": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The name of the file to be sent to the model." }), + Schema.Null + ]) ), - "ip_allowlist.deleted": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." })), - "name": Schema.optionalKey( - Schema.String.annotate({ "description": "The name of the IP allowlist configuration." }) + "file_data": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The base64-encoded data of the file to be sent to the model." }).check( + Schema.isMaxLength(73400320).annotate({ "expected": "a value with a length of at most 73400320" }) ), - "allowed_ips": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": "The IP addresses or CIDR ranges that were in the configuration." - }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + Schema.Null + ]) ), - "ip_allowlist.config.activated": Schema.optionalKey( - Schema.Struct({ - "configs": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." }) - ), - "name": Schema.optionalKey( - Schema.String.annotate({ "description": "The name of the IP allowlist configuration." }) - ) - }) - ).annotate({ "description": "The configurations that were activated." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) - ), - "ip_allowlist.config.deactivated": Schema.optionalKey( - Schema.Struct({ - "configs": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." }) - ), - "name": Schema.optionalKey( - Schema.String.annotate({ "description": "The name of the IP allowlist configuration." }) - ) - }) - ).annotate({ "description": "The configurations that were deactivated." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "file_url": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The URL of the file to be sent to the model.", "format": "uri" }), + Schema.Null + ]) ), - "login.succeeded": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": "This event has no additional fields beyond the standard audit log attributes." + "detail": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaFileDetailEnum).annotate({ + "description": + "The detail level of the file to be sent to the model. Use `auto` to let the system select the detail level; for GPT-5.6 and later models, `auto` uses high-quality rendering, which may increase input token usage. Use `low` for lower-cost rendering, or `high` to render the file at higher quality. Defaults to `auto`." }) ), - "login.failed": Schema.optionalKey( - Schema.Struct({ - "error_code": Schema.optionalKey(Schema.String.annotate({ "description": "The error code of the failure." })), - "error_message": Schema.optionalKey( - Schema.String.annotate({ "description": "The error message of the failure." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "prompt_cache_breakpoint": Schema.optionalKey(Schema.Union([BetaPromptCacheBreakpointParam, Schema.Null])) +}).annotate({ + "title": "Input file", + "description": "A file input to the model.", + "identifier": "BetaInputFileContentParam" +}) +export type BetaToolCallCallerParam = BetaDirectToolCallCallerParam | BetaProgramToolCallCallerParam +export const BetaToolCallCallerParam = Schema.Union([BetaDirectToolCallCallerParam, BetaProgramToolCallCallerParam], { + mode: "oneOf" +}).annotate({ + "description": "The execution context that produced this tool call.", + "identifier": "BetaToolCallCallerParam" +}) +export type BetaOutputTextContentParam = { + readonly "type": "output_text" + readonly "text": string + readonly "annotations"?: ReadonlyArray +} +export const BetaOutputTextContentParam = Schema.Struct({ + "type": Schema.Literal("output_text").annotate({ "description": "The content type. Always `output_text`." }), + "text": Schema.String.annotate({ "description": "The text content." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) ), - "logout.succeeded": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": "This event has no additional fields beyond the standard audit log attributes." + "annotations": Schema.optionalKey( + Schema.Array( + Schema.Union([BetaFileCitationParam, BetaUrlCitationParam, BetaContainerFileCitationParam], { mode: "oneOf" }) + ).annotate({ "description": "Citations associated with the text content." }) + ) +}).annotate({ "identifier": "BetaOutputTextContentParam" }) +export type BetaReasoningItem = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "reasoning" + readonly "id": string + readonly "encrypted_content"?: string | null + readonly "summary": ReadonlyArray + readonly "content"?: ReadonlyArray + readonly "status"?: "in_progress" | "completed" | "incomplete" +} +export const BetaReasoningItem = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("reasoning").annotate({ "description": "The type of the object. Always `reasoning`.\n" }), + "id": Schema.String.annotate({ "description": "The unique identifier of the reasoning content.\n" }), + "encrypted_content": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The encrypted content of the reasoning item. This is populated by default\nfor reasoning items returned by `POST /v1/responses` and WebSocket\n`response.create` requests.\n" + }), + Schema.Null + ]) + ), + "summary": Schema.Array(BetaSummaryTextContent).annotate({ "description": "Reasoning summary content.\n" }), + "content": Schema.optionalKey( + Schema.Array(BetaReasoningTextContent).annotate({ "description": "Reasoning text content.\n" }) + ), + "status": Schema.optionalKey( + 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": "Reasoning", + "description": + "A description of the chain of thought used by a reasoning model while generating\na response. Be sure to include these items in your `input` to the Responses API\nfor subsequent turns of a conversation if you are manually\n[managing context](/docs/guides/conversation-state).\n", + "identifier": "BetaReasoningItem" +}) +export type BetaCodeInterpreterToolCall = { + readonly "agent"?: BetaAgentTag | null + 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 BetaCodeInterpreterToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "logout.failed": Schema.optionalKey( - Schema.Struct({ - "error_code": Schema.optionalKey(Schema.String.annotate({ "description": "The error code of the failure." })), - "error_message": Schema.optionalKey( - Schema.String.annotate({ "description": "The error message of the failure." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "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([BetaCodeInterpreterOutputLogs, BetaCodeInterpreterOutputImage], { 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", + "identifier": "BetaCodeInterpreterToolCall" +}) +export type BetaLocalShellToolCall = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "local_shell_call" + readonly "id": string + readonly "call_id": string + readonly "action": BetaLocalShellExecAction + readonly "status": "in_progress" | "completed" | "incomplete" +} +export const BetaLocalShellToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "organization.updated": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The organization ID." })), - "changes_requested": Schema.optionalKey( - Schema.Struct({ - "title": Schema.optionalKey(Schema.String.annotate({ "description": "The organization title." })), - "description": Schema.optionalKey(Schema.String.annotate({ "description": "The organization description." })), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The organization name." })), - "threads_ui_visibility": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Visibility of the threads page which shows messages created with the Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`." - }) - ), - "usage_dashboard_visibility": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Visibility of the usage dashboard which shows activity and costs for your organization. One of `ANY_ROLE` or `OWNERS`." - }) - ), - "api_call_logging": Schema.optionalKey( - Schema.String.annotate({ - "description": - "How your organization logs data from supported API calls. One of `disabled`, `enabled_per_call`, `enabled_for_all_projects`, or `enabled_for_selected_projects`" - }) - ), - "api_call_logging_project_ids": Schema.optionalKey( - Schema.String.annotate({ - "description": "The list of project ids if api_call_logging is set to `enabled_for_selected_projects`" - }) - ) - }).annotate({ "description": "The payload used to update the organization settings." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "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": BetaLocalShellExecAction, + "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", + "identifier": "BetaLocalShellToolCall" +}) +export type BetaFunctionShellCallOutputOutcomeParam = + | BetaFunctionShellCallOutputTimeoutOutcomeParam + | BetaFunctionShellCallOutputExitOutcomeParam +export const BetaFunctionShellCallOutputOutcomeParam = Schema.Union([ + BetaFunctionShellCallOutputTimeoutOutcomeParam, + BetaFunctionShellCallOutputExitOutcomeParam +], { mode: "oneOf" }).annotate({ + "title": "Shell call outcome", + "description": "The exit or timeout outcome associated with this shell call.", + "identifier": "BetaFunctionShellCallOutputOutcomeParam" +}) +export type BetaApplyPatchOperationParam = + | BetaApplyPatchCreateFileOperationParam + | BetaApplyPatchDeleteFileOperationParam + | BetaApplyPatchUpdateFileOperationParam +export const BetaApplyPatchOperationParam = Schema.Union([ + BetaApplyPatchCreateFileOperationParam, + BetaApplyPatchDeleteFileOperationParam, + BetaApplyPatchUpdateFileOperationParam +], { mode: "oneOf" }).annotate({ + "title": "Apply patch operation", + "description": "One of the create_file, delete_file, or update_file operations supplied to the apply_patch tool.", + "identifier": "BetaApplyPatchOperationParam" +}) +export type BetaMCPListTools = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "mcp_list_tools" + readonly "id": string + readonly "server_label": string + readonly "tools": ReadonlyArray + readonly "error"?: string | null +} +export const BetaMCPListTools = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "project.created": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })), - "data": Schema.optionalKey( - Schema.Struct({ - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The project name." })), - "title": Schema.optionalKey( - Schema.String.annotate({ "description": "The title of the project as seen on the dashboard." }) - ) - }).annotate({ "description": "The payload used to create the project." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "type": Schema.Literal("mcp_list_tools").annotate({ + "description": "The type of the item. Always `mcp_list_tools`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the list.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server.\n" }), + "tools": Schema.Array(BetaMCPListToolsTool).annotate({ "description": "The tools available on the server.\n" }), + "error": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "Error message if the server could not list tools.\n" }), + Schema.Null + ]) + ) +}).annotate({ + "title": "MCP list tools", + "description": "A list of tools available on an MCP server.\n", + "identifier": "BetaMCPListTools" +}) +export type BetaMCPToolCall = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "mcp_call" + readonly "id": string + readonly "server_label": string + readonly "name": string + readonly "arguments": string + readonly "output"?: string | null + readonly "error"?: string | null + readonly "status"?: BetaMCPToolCallStatus + readonly "approval_request_id"?: string | null +} +export const BetaMCPToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "project.updated": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })), - "changes_requested": Schema.optionalKey( - Schema.Struct({ - "title": Schema.optionalKey( - Schema.String.annotate({ "description": "The title of the project as seen on the dashboard." }) - ) - }).annotate({ "description": "The payload used to update the project." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "type": Schema.Literal("mcp_call").annotate({ "description": "The type of the item. Always `mcp_call`.\n" }), + "id": Schema.String.annotate({ "description": "The unique ID of the tool call.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server running the tool.\n" }), + "name": Schema.String.annotate({ "description": "The name of the tool that was run.\n" }), + "arguments": Schema.String.annotate({ "description": "A JSON string of the arguments passed to the tool.\n" }), + "output": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The output from the tool call.\n" }), Schema.Null]) ), - "project.archived": Schema.optionalKey( - Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })) }).annotate({ - "description": "The details for events with this `type`." - }) + "error": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The error from the tool call, if any.\n" }), Schema.Null]) ), - "project.deleted": Schema.optionalKey( - Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })) }).annotate({ - "description": "The details for events with this `type`." + "status": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaMCPToolCallStatus).annotate({ + "description": + "The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`, or `failed`.\n" }) ), - "rate_limit.updated": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The rate limit ID" })), - "changes_requested": Schema.optionalKey( - Schema.Struct({ - "max_requests_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum requests per minute." }).check(Schema.isInt()) - ), - "max_tokens_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum tokens per minute." }).check(Schema.isInt()) - ), - "max_images_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The maximum images per minute. Only relevant for certain models." - }).check(Schema.isInt()) - ), - "max_audio_megabytes_per_1_minute": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The maximum audio megabytes per minute. Only relevant for certain models." - }).check(Schema.isInt()) - ), - "max_requests_per_1_day": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum requests per day. Only relevant for certain models." }) - .check(Schema.isInt()) - ), - "batch_1_day_max_input_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The maximum batch input tokens per day. Only relevant for certain models." - }).check(Schema.isInt()) - ) - }).annotate({ "description": "The payload used to update the rate limits." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) - ), - "rate_limit.deleted": Schema.optionalKey( - Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The rate limit ID" })) }) - .annotate({ "description": "The details for events with this `type`." }) + "approval_request_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "Unique identifier for the MCP tool call approval request.\nInclude this value in a subsequent `mcp_approval_response` input to approve or reject the corresponding tool call.\n" + }), + Schema.Null + ]) + ) +}).annotate({ + "title": "MCP tool call", + "description": "An invocation of a tool on an MCP server.\n", + "identifier": "BetaMCPToolCall" +}) +export type BetaProgramOutputItemParam = { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id": string + readonly "type": "program_output" + readonly "call_id": string + readonly "result": string + readonly "status": BetaProgramOutputItemStatus +} +export const BetaProgramOutputItemParam = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) ), - "role.created": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The role ID." })), - "role_name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the role." })), - "permissions": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ "description": "The permissions granted by the role." }) - ), - "resource_type": Schema.optionalKey( - Schema.String.annotate({ "description": "The type of resource the role belongs to." }) - ), - "resource_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The resource the role is scoped to." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "id": Schema.String.annotate({ "description": "The unique ID of this program output item." }), + "type": Schema.Literal("program_output").annotate({ "description": "The item type. Always `program_output`." }), + "call_id": Schema.String.annotate({ "description": "The call ID of the program item." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "result": Schema.String.annotate({ "description": "The result produced by the program item." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) ), - "role.updated": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The role ID." })), - "changes_requested": Schema.optionalKey( - Schema.Struct({ - "role_name": Schema.optionalKey( - Schema.String.annotate({ "description": "The updated role name, when provided." }) - ), - "resource_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The resource the role is scoped to." }) - ), - "resource_type": Schema.optionalKey( - Schema.String.annotate({ "description": "The type of resource the role belongs to." }) - ), - "permissions_added": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ "description": "The permissions added to the role." }) - ), - "permissions_removed": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ "description": "The permissions removed from the role." }) - ), - "description": Schema.optionalKey( - Schema.String.annotate({ "description": "The updated role description, when provided." }) - ), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Additional metadata stored on the role." }) - ) - }).annotate({ "description": "The payload used to update the role." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "status": Schema.suspend((): Schema.Codec => BetaProgramOutputItemStatus).annotate({ + "description": "The terminal status of the program output." + }) +}).annotate({ "identifier": "BetaProgramOutputItemParam" }) +export type BetaModerationConfigParam = { readonly "mode": BetaModerationMode } +export const BetaModerationConfigParam = Schema.Struct({ "mode": BetaModerationMode }).annotate({ + "description": "The moderation policy for the response input.", + "identifier": "BetaModerationConfigParam" +}) +export type BetaConversationParam = string | BetaConversationParam_2 +export const BetaConversationParam = Schema.Union([ + Schema.String.annotate({ "title": "Conversation ID", "description": "The unique ID of the conversation.\n" }), + BetaConversationParam_2 +], { mode: "oneOf" }).annotate({ + "description": + "The conversation that this response belongs to. Items from this conversation are prepended to `input_items` for this response request.\nInput items and output items from this response are automatically added to this conversation after this response completes.\n", + "identifier": "BetaConversationParam" +}) +export type BetaResponseError = { readonly "code": BetaResponseErrorCode; readonly "message": string } | null +export const BetaResponseError = Schema.Union([ + Schema.Struct({ + "code": BetaResponseErrorCode, + "message": Schema.String.annotate({ "description": "A human-readable description of the error.\n" }) + }).annotate({ "description": "An error object returned when the model fails to generate a Response.\n" }), + Schema.Null +]).annotate({ "identifier": "BetaResponseError" }) +export type BetaMultiAgentCall = { + readonly "agent"?: BetaAgentTag + readonly "type": "multi_agent_call" + readonly "id": string + readonly "call_id": string + readonly "action": BetaMultiAgentAction + readonly "arguments": string +} +export const BetaMultiAgentCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." + }) ), - "role.deleted": Schema.optionalKey( - Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The role ID." })) }).annotate({ - "description": "The details for events with this `type`." + "type": Schema.Literal("multi_agent_call").annotate({ + "description": "The type of the multi-agent call. Always `multi_agent_call`." + }), + "id": Schema.String.annotate({ "description": "The unique ID of the multi-agent call item." }), + "call_id": Schema.String.annotate({ "description": "The unique ID linking this call to its output." }), + "action": Schema.suspend((): Schema.Codec => BetaMultiAgentAction).annotate({ + "description": "The multi-agent action to execute." + }), + "arguments": Schema.String.annotate({ "description": "The JSON string of arguments generated for the action." }) +}).annotate({ "identifier": "BetaMultiAgentCall" }) +export type BetaProgramOutput = { + readonly "agent"?: BetaAgentTag + readonly "type": "program_output" + readonly "id": string + readonly "call_id": string + readonly "result": string + readonly "status": BetaProgramOutputStatus +} +export const BetaProgramOutput = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." }) ), - "role.assignment.created": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The identifier of the role assignment." })), - "principal_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The principal (user or group) that received the role." }) - ), - "principal_type": Schema.optionalKey( - Schema.String.annotate({ "description": "The type of principal (user or group) that received the role." }) - ), - "resource_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The resource the role assignment is scoped to." }) - ), - "resource_type": Schema.optionalKey( - Schema.String.annotate({ "description": "The type of resource the role assignment is scoped to." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "type": Schema.Literal("program_output").annotate({ + "description": "The type of the item. Always `program_output`." + }), + "id": Schema.String.annotate({ "description": "The unique ID of the program output item." }), + "call_id": Schema.String.annotate({ "description": "The call ID of the program item." }), + "result": Schema.String.annotate({ "description": "The result produced by the program item." }), + "status": Schema.suspend((): Schema.Codec => BetaProgramOutputStatus).annotate({ + "description": "The terminal status of the program output item." + }) +}).annotate({ "identifier": "BetaProgramOutput" }) +export type BetaToolSearchCall = { + readonly "agent"?: BetaAgentTag + readonly "type": "tool_search_call" + readonly "id": string + readonly "call_id": string | null + readonly "execution": BetaToolSearchExecutionType + readonly "arguments": Schema.Json + readonly "status": BetaFunctionCallStatus + readonly "created_by"?: string +} +export const BetaToolSearchCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." + }) ), - "role.assignment.deleted": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The identifier of the role assignment." })), - "principal_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The principal (user or group) that had the role removed." }) - ), - "principal_type": Schema.optionalKey( - Schema.String.annotate({ "description": "The type of principal (user or group) that had the role removed." }) - ), - "resource_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The resource the role assignment was scoped to." }) - ), - "resource_type": Schema.optionalKey( - Schema.String.annotate({ "description": "The type of resource the role assignment was scoped to." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "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.suspend((): Schema.Codec => BetaToolSearchExecutionType).annotate({ + "description": "Whether tool search was executed by the server or by the client." + }), + "arguments": Schema.Json.annotate({ + "expected": "JSON value", + "description": "Arguments used for the tool search call." + }), + "status": Schema.suspend((): Schema.Codec => BetaFunctionCallStatus).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." }) + ) +}).annotate({ "identifier": "BetaToolSearchCall" }) +export type BetaFunctionShellCallOutputContent = { + readonly "stdout": string + readonly "stderr": string + readonly "outcome": BetaFunctionShellCallOutputTimeoutOutcome | BetaFunctionShellCallOutputExitOutcome + readonly "created_by"?: string +} +export const BetaFunctionShellCallOutputContent = Schema.Struct({ + "stdout": Schema.String.annotate({ "description": "The standard output that was captured." }), + "stderr": Schema.String.annotate({ "description": "The standard error output that was captured." }), + "outcome": Schema.Union([BetaFunctionShellCallOutputTimeoutOutcome, BetaFunctionShellCallOutputExitOutcome], { + mode: "oneOf" + }).annotate({ + "title": "Shell call outcome", + "description": + "Represents either an exit outcome (with an exit code) or a timeout outcome for a shell call output chunk." + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item." }) + ) +}).annotate({ + "title": "Shell call output content", + "description": "The content of a shell tool call output that was emitted.", + "identifier": "BetaFunctionShellCallOutputContent" +}) +export type BetaModeration = { + readonly "input": BetaModerationResultBody | BetaModerationErrorBody + readonly "output": BetaModerationResultBody | BetaModerationErrorBody +} +export const BetaModeration = Schema.Struct({ + "input": Schema.Union([BetaModerationResultBody, BetaModerationErrorBody], { mode: "oneOf" }).annotate({ + "description": "Moderation for the response input." + }), + "output": Schema.Union([BetaModerationResultBody, BetaModerationErrorBody], { mode: "oneOf" }).annotate({ + "description": "Moderation for the response output." + }) +}).annotate({ + "title": "Moderation", + "description": "Moderation results or errors for the response input and output.", + "identifier": "BetaModeration" +}) +export type BetaResponseTextDeltaEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.output_text.delta" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "delta": string + readonly "sequence_number": number + readonly "logprobs": ReadonlyArray +} +export const BetaResponseTextDeltaEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "service_account.created": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The service account ID." })), - "data": Schema.optionalKey( - Schema.Struct({ - "role": Schema.optionalKey( - Schema.String.annotate({ "description": "The role of the service account. Is either `owner` or `member`." }) - ) - }).annotate({ "description": "The payload used to create the service account." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "type": Schema.Literal("response.output_text.delta").annotate({ + "description": "The type of the event. Always `response.output_text.delta`.\n" + }), + "item_id": Schema.String.annotate({ "description": "The ID of the output item that the text delta was added to.\n" }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the text delta was added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ + "description": "The index of the content part that the text delta was added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String.annotate({ "description": "The text delta that was added.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "service_account.updated": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The service account ID." })), - "changes_requested": Schema.optionalKey( - Schema.Struct({ - "role": Schema.optionalKey( - Schema.String.annotate({ "description": "The role of the service account. Is either `owner` or `member`." }) - ) - }).annotate({ "description": "The payload used to updated the service account." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "logprobs": Schema.Array(BetaResponseLogProb).annotate({ + "description": "The log probabilities of the tokens in the delta.\n" + }) +}).annotate({ + "description": "Emitted when there is an additional text delta.", + "identifier": "BetaResponseTextDeltaEvent" +}) +export type BetaResponseTextDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.output_text.done" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "text": string + readonly "sequence_number": number + readonly "logprobs": ReadonlyArray +} +export const BetaResponseTextDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "service_account.deleted": Schema.optionalKey( - Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The service account ID." })) }) - .annotate({ "description": "The details for events with this `type`." }) + "type": Schema.Literal("response.output_text.done").annotate({ + "description": "The type of the event. Always `response.output_text.done`.\n" + }), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the text content is finalized.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the text content is finalized.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ + "description": "The index of the content part that the text content is finalized.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "text": Schema.String.annotate({ "description": "The text content that is finalized.\n" }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "user.added": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The user ID." })), - "data": Schema.optionalKey( - Schema.Struct({ - "role": Schema.optionalKey( - Schema.String.annotate({ "description": "The role of the user. Is either `owner` or `member`." }) - ) - }).annotate({ "description": "The payload used to add the user to the project." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) - ), - "user.updated": Schema.optionalKey( + "logprobs": Schema.Array(BetaResponseLogProb).annotate({ + "description": "The log probabilities of the tokens in the delta.\n" + }) +}).annotate({ "description": "Emitted when text content is finalized.", "identifier": "BetaResponseTextDoneEvent" }) +export type AssistantToolsFileSearch = { + readonly "type": "file_search" + readonly "file_search"?: { + readonly "max_num_results"?: number + readonly "ranking_options"?: FileSearchRankingOptions + } +} +export const AssistantToolsFileSearch = Schema.Struct({ + "type": Schema.Literal("file_search").annotate({ "description": "The type of tool being defined: `file_search`" }), + "file_search": Schema.optionalKey( Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })), - "changes_requested": Schema.optionalKey( - Schema.Struct({ - "role": Schema.optionalKey( - Schema.String.annotate({ "description": "The role of the user. Is either `owner` or `member`." }) - ) - }).annotate({ "description": "The payload used to update the user." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "max_num_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.\n\nNote that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(50).annotate({ "expected": "a value less than or equal to 50" })) + ), + "ranking_options": Schema.optionalKey(FileSearchRankingOptions) + }).annotate({ "description": "Overrides for the file search tool." }) + ) +}).annotate({ "title": "FileSearch tool", "identifier": "AssistantToolsFileSearch" }) +export type RunStepDetailsToolCallsFileSearchObject = { + readonly "id": string + readonly "type": "file_search" + readonly "file_search": { + readonly "ranking_options"?: RunStepDetailsToolCallsFileSearchRankingOptionsObject + readonly "results"?: ReadonlyArray + } +} +export const RunStepDetailsToolCallsFileSearchObject = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The ID of the tool call object." }), + "type": Schema.Literal("file_search").annotate({ + "description": "The type of tool call. This is always going to be `file_search` for this type of tool call." + }), + "file_search": Schema.Struct({ + "ranking_options": Schema.optionalKey(RunStepDetailsToolCallsFileSearchRankingOptionsObject), + "results": Schema.optionalKey( + Schema.Array(RunStepDetailsToolCallsFileSearchResultObject).annotate({ + "description": "The results of the file search." + }) + ) + }).annotate({ "description": "For now, this is always going to be an empty object." }) +}).annotate({ "title": "File search tool call", "identifier": "RunStepDetailsToolCallsFileSearchObject" }) +export type AssistantToolsFunction = { readonly "type": "function"; readonly "function": FunctionObject } +export const AssistantToolsFunction = Schema.Struct({ + "type": Schema.Literal("function").annotate({ "description": "The type of tool being defined: `function`" }), + "function": FunctionObject +}).annotate({ "title": "Function tool", "identifier": "AssistantToolsFunction" }) +export type ChatCompletionTool = { readonly "type": "function"; readonly "function": FunctionObject } +export const ChatCompletionTool = Schema.Struct({ + "type": Schema.Literal("function").annotate({ + "description": "The type of the tool. Currently, only `function` is supported." + }), + "function": FunctionObject +}).annotate({ + "title": "Function tool", + "description": "A function tool that can be used to generate a response.\n", + "identifier": "ChatCompletionTool" +}) +export type AssistantsApiResponseFormatOption = + | "auto" + | ResponseFormatText + | ResponseFormatJsonObject + | ResponseFormatJsonSchema +export const AssistantsApiResponseFormatOption = Schema.Union([ + Schema.Literal("auto").annotate({ "description": "`auto` is the default value\n" }), + ResponseFormatText, + ResponseFormatJsonObject, + ResponseFormatJsonSchema +], { mode: "oneOf" }).annotate({ + "description": + "Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables JSON mode, which ensures the message the model generates is valid JSON.\n\n**Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if `finish_reason=\"length\"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.\n", + "identifier": "AssistantsApiResponseFormatOption" +}) +export type TextResponseFormatConfiguration = + | ResponseFormatText + | TextResponseFormatJsonSchema + | ResponseFormatJsonObject +export const TextResponseFormatConfiguration = Schema.Union([ + ResponseFormatText, + TextResponseFormatJsonSchema, + ResponseFormatJsonObject +], { mode: "oneOf" }).annotate({ + "description": + "An object specifying the format that the model must output.\n\nConfiguring `{ \"type\": \"json_schema\" }` enables Structured Outputs, \nwhich ensures the model will match your supplied JSON schema. Learn more in the \n[Structured Outputs guide](/docs/guides/structured-outputs).\n\nThe default format is `{ \"type\": \"text\" }` with no additional options.\n\n**Not recommended for gpt-4o and newer models:**\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n", + "identifier": "TextResponseFormatConfiguration" +}) +export type CreateSpeechRequest = { + readonly "model": string | "tts-1" | "tts-1-hd" | "gpt-4o-mini-tts" | "gpt-4o-mini-tts-2025-12-15" + readonly "input": string + readonly "instructions"?: string + readonly "voice": VoiceIdsOrCustomVoice + readonly "response_format"?: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm" + readonly "speed"?: number + readonly "stream_format"?: "sse" | "audio" +} +export const CreateSpeechRequest = Schema.Struct({ + "model": Schema.Union([ + Schema.String, + Schema.Literals(["tts-1", "tts-1-hd", "gpt-4o-mini-tts", "gpt-4o-mini-tts-2025-12-15"]) + ]).annotate({ + "description": + "One of the available [TTS models](/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.\n" + }), + "input": Schema.String.annotate({ + "description": "The text to generate audio for. The maximum length is 4096 characters." + }).check(Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" })), + "instructions": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`." + }).check(Schema.isMaxLength(4096).annotate({ "expected": "a value with a length of at most 4096" })) ), - "user.deleted": Schema.optionalKey( - Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The user ID." })) }).annotate({ - "description": "The details for events with this `type`." + "voice": Schema.suspend((): Schema.Codec => VoiceIdsOrCustomVoice).annotate({ + "description": + "The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ \"id\": \"voice_1234\" }`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech#voice-options)." + }), + "response_format": Schema.optionalKey( + Schema.Literals(["mp3", "opus", "aac", "flac", "wav", "pcm"]).annotate({ + "description": "The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`." }) ), - "certificate.created": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })) - }).annotate({ "description": "The details for events with this `type`." }) - ), - "certificate.updated": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })) - }).annotate({ "description": "The details for events with this `type`." }) - ), - "certificate.deleted": Schema.optionalKey( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })), - "certificate": Schema.optionalKey( - Schema.String.annotate({ "description": "The certificate content in PEM format." }) - ) - }).annotate({ "description": "The details for events with this `type`." }) - ), - "certificates.activated": Schema.optionalKey( - Schema.Struct({ - "certificates": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })) - }) - ) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "speed": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0.25).annotate({ "expected": "a value greater than or equal to 0.25" }) + ).check(Schema.isLessThanOrEqualTo(4).annotate({ "expected": "a value less than or equal to 4" })) ), - "certificates.deactivated": Schema.optionalKey( - Schema.Struct({ - "certificates": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })) - }) - ) - ) - }).annotate({ "description": "The details for events with this `type`." }) + "stream_format": Schema.optionalKey( + Schema.Literals(["sse", "audio"]).annotate({ + "description": + "The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`." + }) ) -}).annotate({ "description": "A log of a user action or configuration change within this organization." }) -export type CreateChatCompletionResponse = { - readonly "id": string - readonly "choices": ReadonlyArray< +}).annotate({ "identifier": "CreateSpeechRequest" }) +export type CreateTranscriptionResponseStreamEvent = + | TranscriptTextSegmentEvent + | TranscriptTextDeltaEvent + | TranscriptTextDoneEvent +export const CreateTranscriptionResponseStreamEvent = Schema.Union([ + TranscriptTextSegmentEvent, + TranscriptTextDeltaEvent, + TranscriptTextDoneEvent +]).annotate({ "identifier": "CreateTranscriptionResponseStreamEvent" }) +export type ListBatchesResponse = { + readonly "data": ReadonlyArray + readonly "first_id"?: string + readonly "last_id"?: string + readonly "has_more": boolean + readonly "object": "list" +} +export const ListBatchesResponse = Schema.Struct({ + "data": Schema.Array(Batch), + "first_id": Schema.optionalKey(Schema.String), + "last_id": Schema.optionalKey(Schema.String), + "has_more": Schema.Boolean, + "object": Schema.Literal("list") +}).annotate({ "identifier": "ListBatchesResponse" }) +export type ChatCompletionResponseMessage = { + readonly "content": string | null + readonly "refusal": string | null + readonly "tool_calls"?: ChatCompletionMessageToolCalls + readonly "annotations"?: ReadonlyArray< { - readonly "finish_reason": "stop" | "length" | "tool_calls" | "content_filter" | "function_call" - readonly "index": number - readonly "message": ChatCompletionResponseMessage - readonly "logprobs": { - readonly "content": ReadonlyArray | null - readonly "refusal": ReadonlyArray | null - } | null + readonly "type": "url_citation" + readonly "url_citation": { + readonly "end_index": number + readonly "start_index": number + readonly "url": string + readonly "title": string + } } > - readonly "created": number - readonly "model": string - readonly "service_tier"?: ServiceTier - readonly "system_fingerprint"?: string - readonly "object": "chat.completion" - readonly "usage"?: CompletionUsage + readonly "role": "assistant" + readonly "function_call"?: { readonly "arguments": string; readonly "name": string } + readonly "audio"?: { + readonly "id": string + readonly "expires_at": number + readonly "data": string + readonly "transcript": string + } | null } -export const CreateChatCompletionResponse = Schema.Struct({ - "id": Schema.String.annotate({ "description": "A unique identifier for the chat completion." }), - "choices": Schema.Array(Schema.Struct({ - "finish_reason": Schema.Literals(["stop", "length", "tool_calls", "content_filter", "function_call"]).annotate({ - "description": - "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\n" - }), - "index": Schema.Number.annotate({ "description": "The index of the choice in the list of choices." }).check( - Schema.isInt() - ), - "message": ChatCompletionResponseMessage, - "logprobs": Schema.Union([ +export const ChatCompletionResponseMessage = Schema.Struct({ + "content": Schema.Union([Schema.String.annotate({ "description": "The contents of the message." }), Schema.Null]), + "refusal": Schema.Union([ + Schema.String.annotate({ "description": "The refusal message generated by the model." }), + Schema.Null + ]), + "tool_calls": Schema.optionalKey(ChatCompletionMessageToolCalls), + "annotations": Schema.optionalKey( + Schema.Array( Schema.Struct({ - "content": Schema.Union([ - Schema.Array(ChatCompletionTokenLogprob).annotate({ - "description": "A list of message content tokens with log probability information." - }), - Schema.Null - ]), - "refusal": Schema.Union([ - Schema.Array(ChatCompletionTokenLogprob).annotate({ - "description": "A list of message refusal tokens with log probability information." - }), - Schema.Null - ]) - }).annotate({ "description": "Log probability information for the choice." }), - Schema.Null - ]) - })).annotate({ "description": "A list of chat completion choices. Can be more than one if `n` is greater than 1." }), - "created": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) of when the chat completion was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "model": Schema.String.annotate({ "description": "The model used for the chat completion." }), - "service_tier": Schema.optionalKey(ServiceTier), - "system_fingerprint": Schema.optionalKey( - Schema.String.annotate({ + "type": Schema.Literal("url_citation").annotate({ + "description": "The type of the URL citation. Always `url_citation`." + }), + "url_citation": Schema.Struct({ + "end_index": Schema.Number.annotate({ + "description": "The index of the last character of the URL citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_index": Schema.Number.annotate({ + "description": "The index of the first character of the URL citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "url": Schema.String.annotate({ "description": "The URL of the web resource.", "format": "uri" }), + "title": Schema.String.annotate({ "description": "The title of the web resource." }) + }).annotate({ "description": "A URL citation when using web search." }) + }).annotate({ "description": "A URL citation when using web search.\n" }) + ).annotate({ "description": - "This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" + "Annotations for the message, when applicable, as when using the\n[web search tool](/docs/guides/tools-web-search?api-mode=chat).\n" }) ), - "object": Schema.Literal("chat.completion").annotate({ - "description": "The object type, which is always `chat.completion`." - }), - "usage": Schema.optionalKey(CompletionUsage) -}).annotate({ "description": "Represents a chat completion response returned by model, based on the provided input." }) -export type ChatCompletionRequestMessage = - | ChatCompletionRequestDeveloperMessage - | ChatCompletionRequestSystemMessage - | ChatCompletionRequestUserMessage - | ChatCompletionRequestAssistantMessage - | ChatCompletionRequestToolMessage - | ChatCompletionRequestFunctionMessage -export const ChatCompletionRequestMessage = Schema.Union([ - ChatCompletionRequestDeveloperMessage, - ChatCompletionRequestSystemMessage, - ChatCompletionRequestUserMessage, - ChatCompletionRequestAssistantMessage, - ChatCompletionRequestToolMessage, - ChatCompletionRequestFunctionMessage -], { mode: "oneOf" }) -export type RunStepObject = { - readonly "id": string - readonly "object": "thread.run.step" - readonly "created_at": number - readonly "assistant_id": string - readonly "thread_id": string - readonly "run_id": string - readonly "type": "message_creation" | "tool_calls" - readonly "status": "in_progress" | "cancelled" | "failed" | "completed" | "expired" - readonly "step_details": { - readonly "type": "message_creation" - readonly "message_creation": { readonly "message_id": string } - } | { - readonly "type": "tool_calls" - readonly "tool_calls": ReadonlyArray< - | RunStepDetailsToolCallsCodeObject - | RunStepDetailsToolCallsFileSearchObject - | RunStepDetailsToolCallsFunctionObject - > - } - readonly "last_error": { readonly "code": "server_error" | "rate_limit_exceeded"; readonly "message": string } | null - readonly "expired_at": number | null - readonly "cancelled_at": number | null - readonly "failed_at": number | null - readonly "completed_at": number | null - readonly "metadata": Metadata - readonly "usage": RunStepCompletionUsage -} -export const RunStepObject = Schema.Struct({ - "id": Schema.String.annotate({ - "description": "The identifier of the run step, which can be referenced in API endpoints." - }), - "object": Schema.Literal("thread.run.step").annotate({ - "description": "The object type, which is always `thread.run.step`." - }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the run step was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "assistant_id": Schema.String.annotate({ - "description": "The ID of the [assistant](/docs/api-reference/assistants) associated with the run step." - }), - "thread_id": Schema.String.annotate({ - "description": "The ID of the [thread](/docs/api-reference/threads) that was run." - }), - "run_id": Schema.String.annotate({ - "description": "The ID of the [run](/docs/api-reference/runs) that this run step is a part of." - }), - "type": Schema.Literals(["message_creation", "tool_calls"]).annotate({ - "description": "The type of run step, which can be either `message_creation` or `tool_calls`." - }), - "status": Schema.Literals(["in_progress", "cancelled", "failed", "completed", "expired"]).annotate({ - "description": - "The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`." - }), - "step_details": Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("message_creation").annotate({ "description": "Always `message_creation`." }), - "message_creation": Schema.Struct({ - "message_id": Schema.String.annotate({ - "description": "The ID of the message that was created by this run step." - }) - }) - }).annotate({ "title": "Message creation", "description": "The details of the run step." }), + "role": Schema.Literal("assistant").annotate({ "description": "The role of the author of this message." }), + "function_call": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("tool_calls").annotate({ "description": "Always `tool_calls`." }), - "tool_calls": Schema.Array( - Schema.Union([ - RunStepDetailsToolCallsCodeObject, - RunStepDetailsToolCallsFileSearchObject, - RunStepDetailsToolCallsFunctionObject - ], { mode: "oneOf" }) - ).annotate({ + "arguments": Schema.String.annotate({ "description": - "An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`.\n" - }) - }).annotate({ "title": "Tool calls", "description": "The details of the run step." }) - ], { mode: "oneOf" }), - "last_error": Schema.Union([ + "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + }), + "name": Schema.String.annotate({ "description": "The name of the function to call." }) + }).annotate({ + "description": + "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model." + }) + ), + "audio": Schema.optionalKey(Schema.Union([ Schema.Struct({ - "code": Schema.Literals(["server_error", "rate_limit_exceeded"]).annotate({ - "description": "One of `server_error` or `rate_limit_exceeded`." + "id": Schema.String.annotate({ "description": "Unique identifier for this audio response." }), + "expires_at": Schema.Number.annotate({ + "description": + "The Unix timestamp (in seconds) for when this audio response will\nno longer be accessible on the server for use in multi-turn\nconversations.\n", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "data": Schema.String.annotate({ + "description": "Base64 encoded audio bytes generated by the model, in the format\nspecified in the request.\n" }), - "message": Schema.String.annotate({ "description": "A human-readable description of the error." }) + "transcript": Schema.String.annotate({ "description": "Transcript of the audio generated by the model." }) }).annotate({ - "description": "The last error associated with this run step. Will be `null` if there are no errors." - }), - Schema.Null - ]), - "expired_at": Schema.Union([ - Schema.Number.annotate({ "description": - "The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]), - "cancelled_at": Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the run step was cancelled.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]), - "failed_at": Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the run step failed.", - "format": "unixtime" - }).check(Schema.isInt()), - Schema.Null - ]), - "completed_at": Schema.Union([ - Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the run step completed.", - "format": "unixtime" - }).check(Schema.isInt()), + "If the audio output modality is requested, this object contains data\nabout the audio response from the model. [Learn more](/docs/guides/audio).\n" + }), Schema.Null - ]), - "metadata": Metadata, - "usage": RunStepCompletionUsage -}).annotate({ "title": "Run steps", "description": "Represents a step in execution of a run.\n" }) -export type ListMessagesResponse = { - readonly "object": string - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean - readonly [x: string]: unknown + ])) +}).annotate({ + "description": "A chat completion message generated by the model.", + "identifier": "ChatCompletionResponseMessage" +}) +export type ChatCompletionModeration = { + readonly "input": ChatCompletionModerationResults | ChatCompletionModerationError + readonly "output": ChatCompletionModerationResults | ChatCompletionModerationError } -export const ListMessagesResponse = Schema.StructWithRest( - Schema.Struct({ - "object": Schema.String, - "data": Schema.Array(MessageObject), - "first_id": Schema.String, - "last_id": Schema.String, - "has_more": Schema.Boolean +export const ChatCompletionModeration = Schema.Struct({ + "input": Schema.Union([ChatCompletionModerationResults, ChatCompletionModerationError], { mode: "oneOf" }).annotate({ + "description": "Moderation for the request input." }), - [Schema.Record(Schema.String, Schema.Json)] -) -export type MessageStreamEvent = - | { readonly "event": "thread.message.created"; readonly "data": MessageObject } - | { readonly "event": "thread.message.in_progress"; readonly "data": MessageObject } - | { readonly "event": "thread.message.delta"; readonly "data": MessageDeltaObject } - | { readonly "event": "thread.message.completed"; readonly "data": MessageObject } - | { readonly "event": "thread.message.incomplete"; readonly "data": MessageObject } -export const MessageStreamEvent = Schema.Union([ - Schema.Struct({ "event": Schema.Literal("thread.message.created"), "data": MessageObject }).annotate({ - "description": "Occurs when a [message](/docs/api-reference/messages/object) is created." - }), - Schema.Struct({ "event": Schema.Literal("thread.message.in_progress"), "data": MessageObject }).annotate({ - "description": "Occurs when a [message](/docs/api-reference/messages/object) moves to an `in_progress` state." - }), - Schema.Struct({ "event": Schema.Literal("thread.message.delta"), "data": MessageDeltaObject }).annotate({ - "description": "Occurs when parts of a [Message](/docs/api-reference/messages/object) are being streamed." - }), - Schema.Struct({ "event": Schema.Literal("thread.message.completed"), "data": MessageObject }).annotate({ - "description": "Occurs when a [message](/docs/api-reference/messages/object) is completed." - }), - Schema.Struct({ "event": Schema.Literal("thread.message.incomplete"), "data": MessageObject }).annotate({ - "description": "Occurs when a [message](/docs/api-reference/messages/object) ends before it is completed." + "output": Schema.Union([ChatCompletionModerationResults, ChatCompletionModerationError], { mode: "oneOf" }).annotate({ + "description": "Moderation for the generated output." }) -], { mode: "oneOf" }) -export type RealtimeBetaResponse = { - readonly "id"?: string - readonly "object"?: "realtime.response" - readonly "status"?: "completed" | "cancelled" | "failed" | "incomplete" | "in_progress" - readonly "status_details"?: { - readonly "type"?: "completed" | "cancelled" | "failed" | "incomplete" - readonly "reason"?: "turn_detected" | "client_cancelled" | "max_output_tokens" | "content_filter" - readonly "error"?: { readonly "type"?: string; readonly "code"?: string } - } - readonly "output"?: ReadonlyArray - readonly "metadata"?: Metadata - readonly "usage"?: { - readonly "total_tokens"?: number - readonly "input_tokens"?: number - readonly "output_tokens"?: number - readonly "input_token_details"?: { - readonly "cached_tokens"?: number - readonly "text_tokens"?: number - readonly "image_tokens"?: number - readonly "audio_tokens"?: number - readonly "cached_tokens_details"?: { - readonly "text_tokens"?: number - readonly "image_tokens"?: number - readonly "audio_tokens"?: number - } - } - readonly "output_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number } - } - readonly "conversation_id"?: string - readonly "voice"?: - | string - | "alloy" - | "ash" - | "ballad" - | "coral" - | "echo" - | "sage" - | "shimmer" - | "verse" - | "marin" - | "cedar" - readonly "modalities"?: ReadonlyArray<"text" | "audio"> - readonly "output_audio_format"?: "pcm16" | "g711_ulaw" | "g711_alaw" - readonly "temperature"?: number - readonly "max_output_tokens"?: number | "inf" +}).annotate({ + "description": "Moderation results or errors for the request input and generated output.", + "identifier": "ChatCompletionModeration" +}) +export type ChatCompletionRequestDeveloperMessage = { + readonly "content": string | ReadonlyArray + readonly "role": "developer" + readonly "name"?: string } -export const RealtimeBetaResponse = Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the response." })), - "object": Schema.optionalKey( - Schema.Literal("realtime.response").annotate({ "description": "The object type, must be `realtime.response`." }) - ), - "status": Schema.optionalKey( - Schema.Literals(["completed", "cancelled", "failed", "incomplete", "in_progress"]).annotate({ +export const ChatCompletionRequestDeveloperMessage = Schema.Struct({ + "content": Schema.Union([ + Schema.String.annotate({ "title": "Text content", "description": "The contents of the developer message." }), + Schema.Array(ChatCompletionRequestMessageContentPartText).annotate({ + "title": "Array of content parts", "description": - "The final status of the response (`completed`, `cancelled`, `failed`, or \n`incomplete`, `in_progress`).\n" - }) - ), - "status_details": Schema.optionalKey( - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literals(["completed", "cancelled", "failed", "incomplete"]).annotate({ - "description": - "The type of error that caused the response to fail, corresponding \nwith the `status` field (`completed`, `cancelled`, `incomplete`, \n`failed`).\n" - }) - ), - "reason": Schema.optionalKey( - Schema.Literals(["turn_detected", "client_cancelled", "max_output_tokens", "content_filter"]).annotate({ - "description": - "The reason the Response did not complete. For a `cancelled` Response, \none of `turn_detected` (the server VAD detected a new start of speech) \nor `client_cancelled` (the client sent a cancel event). For an \n`incomplete` Response, one of `max_output_tokens` or `content_filter` \n(the server-side safety filter activated and cut off the response).\n" - }) - ), - "error": Schema.optionalKey( - Schema.Struct({ - "type": Schema.optionalKey(Schema.String.annotate({ "description": "The type of error." })), - "code": Schema.optionalKey(Schema.String.annotate({ "description": "Error code, if any." })) - }).annotate({ - "description": - "A description of the error that caused the response to fail, \npopulated when the `status` is `failed`.\n" - }) - ) - }).annotate({ "description": "Additional details about the status." }) - ), - "output": Schema.optionalKey( - Schema.Array(RealtimeConversationItem).annotate({ - "description": "The list of output items generated by the response." + "An array of content parts with a defined type. For developer messages, only type `text` is supported." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ], { mode: "oneOf" }).annotate({ "description": "The contents of the developer message." }), + "role": Schema.Literal("developer").annotate({ + "description": "The role of the messages author, in this case `developer`." + }), + "name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "An optional name for the participant. Provides the model information to differentiate between participants of the same role." }) - ), - "metadata": Schema.optionalKey(Metadata), - "usage": Schema.optionalKey( - Schema.Struct({ - "total_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The total number of tokens in the Response including input and output \ntext and audio tokens.\n" - }).check(Schema.isInt()) - ), - "input_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of input tokens used in the Response, including text and \naudio tokens.\n" - }).check(Schema.isInt()) - ), - "output_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of output tokens sent in the Response, including text and \naudio tokens.\n" - }).check(Schema.isInt()) - ), - "input_token_details": Schema.optionalKey( - Schema.Struct({ - "cached_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of cached tokens used as input for the Response." }) - .check(Schema.isInt()) - ), - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of text tokens used as input for the Response." }) - .check(Schema.isInt()) - ), - "image_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of image tokens used as input for the Response." }) - .check(Schema.isInt()) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of audio tokens used as input for the Response." }) - .check(Schema.isInt()) - ), - "cached_tokens_details": Schema.optionalKey( - Schema.Struct({ - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of cached text tokens used as input for the Response." - }).check(Schema.isInt()) - ), - "image_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of cached image tokens used as input for the Response." - }).check(Schema.isInt()) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of cached audio tokens used as input for the Response." - }).check(Schema.isInt()) - ) - }).annotate({ "description": "Details about the cached tokens used as input for the Response." }) - ) - }).annotate({ "description": "Details about the input tokens used in the Response." }) - ), - "output_token_details": Schema.optionalKey( - Schema.Struct({ - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of text tokens used in the Response." }).check( - Schema.isInt() - ) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of audio tokens used in the Response." }).check( - Schema.isInt() - ) - ) - }).annotate({ "description": "Details about the output tokens used in the Response." }) - ) - }).annotate({ - "description": - "Usage statistics for the Response, this will correspond to billing. A \nRealtime API session will maintain a conversation context and append new \nItems to the Conversation, thus output from previous turns (text and \naudio tokens) will become the input for later turns.\n" - }) - ), - "conversation_id": Schema.optionalKey(Schema.String.annotate({ - "description": - "Which conversation the response is added to, determined by the `conversation`\nfield in the `response.create` event. If `auto`, the response will be added to\nthe default conversation and the value of `conversation_id` will be an id like\n`conv_1234`. If `none`, the response will not be added to any conversation and\nthe value of `conversation_id` will be `null`. If responses are being triggered\nby server VAD, the response will be added to the default conversation, thus\nthe `conversation_id` will be an id like `conv_1234`.\n" - })), - "voice": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals(["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse", "marin", "cedar"]) - ]).annotate({ - "description": - "The voice the model used to respond.\nCurrent voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,\n`shimmer`, and `verse`.\n" - }) - ), - "modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ + ) +}).annotate({ + "title": "Developer message", + "description": + "Developer-provided instructions that the model should follow, regardless of\nmessages sent by the user. With o1 models and newer, `developer` messages\nreplace the previous `system` messages.\n", + "identifier": "ChatCompletionRequestDeveloperMessage" +}) +export type ChatCompletionRequestSystemMessageContentPart = ChatCompletionRequestMessageContentPartText +export const ChatCompletionRequestSystemMessageContentPart = Schema.Union( + [ChatCompletionRequestMessageContentPartText], + { mode: "oneOf" } +).annotate({ "identifier": "ChatCompletionRequestSystemMessageContentPart" }) +export type ChatCompletionRequestAssistantMessageContentPart = + | ChatCompletionRequestMessageContentPartText + | ChatCompletionRequestMessageContentPartRefusal +export const ChatCompletionRequestAssistantMessageContentPart = Schema.Union([ + ChatCompletionRequestMessageContentPartText, + ChatCompletionRequestMessageContentPartRefusal +], { mode: "oneOf" }).annotate({ "identifier": "ChatCompletionRequestAssistantMessageContentPart" }) +export type ChatCompletionRequestToolMessageContentPart = ChatCompletionRequestMessageContentPartText +export const ChatCompletionRequestToolMessageContentPart = Schema.Union([ChatCompletionRequestMessageContentPartText], { + mode: "oneOf" +}).annotate({ "identifier": "ChatCompletionRequestToolMessageContentPart" }) +export type PredictionContent = { + readonly "type": "content" + readonly "content": string | ReadonlyArray +} +export const PredictionContent = Schema.Struct({ + "type": Schema.Literal("content").annotate({ + "description": "The type of the predicted content you want to provide. This type is\ncurrently always `content`.\n" + }), + "content": Schema.Union([ + Schema.String.annotate({ + "title": "Text content", "description": - "The set of modalities the model used to respond. If there are multiple modalities,\nthe model will pick one, for example if `modalities` is `[\"text\", \"audio\"]`, the model\ncould be responding in either text or audio.\n" - }) - ), - "output_audio_format": Schema.optionalKey( - Schema.Literals(["pcm16", "g711_ulaw", "g711_alaw"]).annotate({ - "description": "The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n" - }) - ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.\n" - }).check(Schema.isFinite()) - ), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ + "The content used for a Predicted Output. This is often the\ntext of a file you are regenerating with minor changes.\n" + }), + Schema.Array(ChatCompletionRequestMessageContentPartText).annotate({ + "title": "Array of content parts", "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls, that was used in this response.\n" - }) - ) -}).annotate({ "description": "The response resource." }) -export type RealtimeBetaResponseCreateParams = { - readonly "modalities"?: ReadonlyArray<"text" | "audio"> - readonly "instructions"?: string - readonly "voice"?: VoiceIdsShared | { readonly "id": string } - readonly "output_audio_format"?: "pcm16" | "g711_ulaw" | "g711_alaw" - readonly "tools"?: ReadonlyArray< + "An array of content parts with a defined type. Supported options differ based on the [model](/docs/models) being used to generate the response. Can contain text inputs." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ], { mode: "oneOf" }).annotate({ + "description": + "The content that should be matched when generating a model response.\nIf generated tokens would match this content, the entire model response\ncan be returned much more quickly.\n" + }) +}).annotate({ + "title": "Static Content", + "description": "Static predicted output content, such as the content of a text file that is\nbeing regenerated.\n", + "identifier": "PredictionContent" +}) +export type ChatCompletionMessageList = { + readonly "object": "list" + readonly "data": ReadonlyArray< { - readonly "type"?: "function" - readonly "name"?: string - readonly "description"?: string - readonly "parameters"?: {} + readonly "content": string | null + readonly "refusal": string | null + readonly "tool_calls"?: ChatCompletionMessageToolCalls + readonly "annotations"?: ReadonlyArray< + { + readonly "type": "url_citation" + readonly "url_citation": { + readonly "end_index": number + readonly "start_index": number + readonly "url": string + readonly "title": string + } + } + > + readonly "role": "assistant" + readonly "function_call"?: { readonly "arguments": string; readonly "name": string } + readonly "audio"?: { + readonly "id": string + readonly "expires_at": number + readonly "data": string + readonly "transcript": string + } | null + readonly "id": string + readonly "content_parts"?: + | ReadonlyArray + | null } > - readonly "tool_choice"?: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMCP - readonly "temperature"?: number - readonly "max_output_tokens"?: number | "inf" - readonly "conversation"?: string | "auto" | "none" - readonly "metadata"?: Metadata - readonly "prompt"?: Prompt - readonly "input"?: ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean } -export const RealtimeBetaResponseCreateParams = Schema.Struct({ - "modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": "The set of modalities the model can respond with. To disable audio,\nset this to [\"text\"].\n" - }) - ), - "instructions": Schema.optionalKey(Schema.String.annotate({ - "description": - "The default system instructions (i.e. system message) prepended to model \ncalls. This field allows the client to guide the model on desired \nresponses. The model can be instructed on response content and format, \n(e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good \nresponses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion \ninto your voice\", \"laugh frequently\"). The instructions are not guaranteed \nto be followed by the model, but they provide guidance to the model on the \ndesired behavior.\n\nNote that the server sets default instructions which will be used if this \nfield is not set and are visible in the `session.created` event at the \nstart of the session.\n" - })), - "voice": Schema.optionalKey( - Schema.Union([ - VoiceIdsShared, - Schema.Struct({ "id": Schema.String.annotate({ "description": "The custom voice ID, e.g. `voice_1234`." }) }) - .annotate({ "description": "Custom voice reference." }) - ]).annotate({ - "title": "Voice", - "description": - "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,\n`marin`, and `cedar`. You may also provide a custom voice object with an\n`id`, for example `{ \"id\": \"voice_1234\" }`. Voice cannot be changed during\nthe session once the model has responded with audio at least once.\n" - }) - ), - "output_audio_format": Schema.optionalKey( - Schema.Literals(["pcm16", "g711_ulaw", "g711_alaw"]).annotate({ - "description": "The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n" - }) - ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("function").annotate({ "description": "The type of the tool, i.e. `function`." }) +export const ChatCompletionMessageList = Schema.Struct({ + "object": Schema.Literal("list").annotate({ + "description": "The type of this object. It is always set to \"list\".\n" + }), + "data": Schema.Array( + Schema.Struct({ + "content": Schema.Union([Schema.String.annotate({ "description": "The contents of the message." }), Schema.Null]), + "refusal": Schema.Union([ + Schema.String.annotate({ "description": "The refusal message generated by the model." }), + Schema.Null + ]), + "tool_calls": Schema.optionalKey(ChatCompletionMessageToolCalls), + "annotations": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "type": Schema.Literal("url_citation").annotate({ + "description": "The type of the URL citation. Always `url_citation`." + }), + "url_citation": Schema.Struct({ + "end_index": Schema.Number.annotate({ + "description": "The index of the last character of the URL citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_index": Schema.Number.annotate({ + "description": "The index of the first character of the URL citation in the message." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "url": Schema.String.annotate({ "description": "The URL of the web resource.", "format": "uri" }), + "title": Schema.String.annotate({ "description": "The title of the web resource." }) + }).annotate({ "description": "A URL citation when using web search." }) + }).annotate({ "description": "A URL citation when using web search.\n" }) + ).annotate({ + "description": + "Annotations for the message, when applicable, as when using the\n[web search tool](/docs/guides/tools-web-search?api-mode=chat).\n" + }) ), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function." })), - "description": Schema.optionalKey( - Schema.String.annotate({ + "role": Schema.Literal("assistant").annotate({ "description": "The role of the author of this message." }), + "function_call": Schema.optionalKey( + Schema.Struct({ + "arguments": Schema.String.annotate({ + "description": + "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + }), + "name": Schema.String.annotate({ "description": "The name of the function to call." }) + }).annotate({ "description": - "The description of the function, including guidance on when and how \nto call it, and guidance about what to tell the user when calling \n(if anything).\n" + "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model." }) ), - "parameters": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Parameters of the function in JSON Schema." }) + "audio": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "id": Schema.String.annotate({ "description": "Unique identifier for this audio response." }), + "expires_at": Schema.Number.annotate({ + "description": + "The Unix timestamp (in seconds) for when this audio response will\nno longer be accessible on the server for use in multi-turn\nconversations.\n", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "data": Schema.String.annotate({ + "description": + "Base64 encoded audio bytes generated by the model, in the format\nspecified in the request.\n" + }), + "transcript": Schema.String.annotate({ "description": "Transcript of the audio generated by the model." }) + }).annotate({ + "description": + "If the audio output modality is requested, this object contains data\nabout the audio response from the model. [Learn more](/docs/guides/audio).\n" + }), + Schema.Null + ])), + "id": Schema.String.annotate({ "description": "The identifier of the chat message." }), + "content_parts": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Union([ChatCompletionRequestMessageContentPartText, ChatCompletionRequestMessageContentPartImage], { + mode: "oneOf" + }) + ).annotate({ + "description": + "If a content parts array was provided, this is an array of `text` and `image_url` parts.\nOtherwise, null.\n" + }), + Schema.Null + ]) ) - })).annotate({ "description": "Tools (functions) available to the model." }) - ), - "tool_choice": Schema.optionalKey( - Schema.Union([ToolChoiceOptions, ToolChoiceFunction, ToolChoiceMCP], { mode: "oneOf" }).annotate({ - "description": - "How the model chooses tools. Provide one of the string modes or force a specific\nfunction/MCP tool.\n" - }) + }).annotate({ "description": "A chat completion message generated by the model." }) + ).annotate({ "description": "An array of chat completion message objects.\n" }), + "first_id": Schema.String.annotate({ "description": "The identifier of the first chat message in the data array." }), + "last_id": Schema.String.annotate({ "description": "The identifier of the last chat message in the data array." }), + "has_more": Schema.Boolean.annotate({ "description": "Indicates whether there are more chat messages available." }) +}).annotate({ + "title": "ChatCompletionMessageList", + "description": "An object representing a list of chat completion messages.\n", + "identifier": "ChatCompletionMessageList" +}) +export type ChatCompletionRequestUserMessageContentPart = + | ChatCompletionRequestMessageContentPartText + | ChatCompletionRequestMessageContentPartImage + | ChatCompletionRequestMessageContentPartAudio + | ChatCompletionRequestMessageContentPartFile +export const ChatCompletionRequestUserMessageContentPart = Schema.Union([ + ChatCompletionRequestMessageContentPartText, + ChatCompletionRequestMessageContentPartImage, + ChatCompletionRequestMessageContentPartAudio, + ChatCompletionRequestMessageContentPartFile +], { mode: "oneOf" }).annotate({ "identifier": "ChatCompletionRequestUserMessageContentPart" }) +export type ModelIdsCompaction = ModelIdsResponses | string | null +export const ModelIdsCompaction = Schema.Union([ModelIdsResponses, Schema.String, Schema.Null]).annotate({ + "description": + "Model ID used to generate the response, like `gpt-5` 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.", + "identifier": "ModelIdsCompaction" +}) +export type ModerationPolicyParam = { + readonly "input"?: ModerationConfigParam | null + readonly "output"?: ModerationConfigParam | null +} +export const ModerationPolicyParam = Schema.Struct({ + "input": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ModerationConfigParam).annotate({ + "description": "The moderation policy for the response input." + }), + Schema.Null + ]) ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.\n" - }).check(Schema.isFinite()) + "output": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ModerationConfigParam).annotate({ + "description": "The moderation policy for the response output." + }), + Schema.Null + ]) + ) +}).annotate({ + "description": "The policy to apply to moderated response input and output.", + "identifier": "ModerationPolicyParam" +}) +export type ChatCompletionToolChoiceOption = + | "none" + | "auto" + | "required" + | ChatCompletionAllowedToolsChoice + | ChatCompletionNamedToolChoice + | ChatCompletionNamedToolChoiceCustom +export const ChatCompletionToolChoiceOption = Schema.Union([ + Schema.Literals(["none", "auto", "required"]).annotate({ + "title": "Tool choice mode", + "description": + "`none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools.\n" + }), + ChatCompletionAllowedToolsChoice, + ChatCompletionNamedToolChoice, + ChatCompletionNamedToolChoiceCustom +], { mode: "oneOf" }).annotate({ + "description": + "Controls which (if any) tool is called by the model.\n`none` means the model will not call any tool and instead generates a message.\n`auto` means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools.\nSpecifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n\n`none` is the default when no tools are present. `auto` is the default if tools are present.\n", + "identifier": "ChatCompletionToolChoiceOption" +}) +export type CreateContainerBody = { + readonly "name": string + readonly "file_ids"?: ReadonlyArray + readonly "expires_after"?: { readonly "anchor": "last_active_at"; readonly "minutes": number } + readonly "skills"?: ReadonlyArray + readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g" + readonly "network_policy"?: ContainerNetworkPolicyDisabledParam | ContainerNetworkPolicyAllowlistParam +} +export const CreateContainerBody = Schema.Struct({ + "name": Schema.String.annotate({ "description": "Name of the container to create." }), + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "IDs of files to copy to the container." }) ), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ - "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" - }) + "expires_after": Schema.optionalKey( + Schema.Struct({ + "anchor": Schema.Literal("last_active_at").annotate({ + "description": "Time anchor for the expiration time. Currently only 'last_active_at' is supported." + }), + "minutes": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + }).annotate({ "description": "Container expiration time in seconds relative to the 'anchor' time." }) ), - "conversation": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Literals(["auto", "none"])], { mode: "oneOf" }).annotate({ - "description": - "Controls which conversation the response is added to. Currently supports\n`auto` and `none`, with `auto` as the default value. The `auto` value\nmeans that the contents of the response will be added to the default\nconversation. Set this to `none` to create an out-of-band response which \nwill not add items to default conversation.\n" + "skills": Schema.optionalKey( + Schema.Array(Schema.Union([SkillReferenceParam, InlineSkillParam], { mode: "oneOf" })).annotate({ + "description": "An optional list of skills referenced by id or inline data." }) ), - "metadata": Schema.optionalKey(Metadata), - "prompt": Schema.optionalKey(Prompt), - "input": Schema.optionalKey( - Schema.Array(RealtimeConversationItem).annotate({ - "description": - "Input items to include in the prompt for the model. Using this field\ncreates a new context for this Response instead of using the default\nconversation. An empty array `[]` will clear the context for this Response.\nNote that this can include references to items from the default conversation.\n" + "memory_limit": Schema.optionalKey( + Schema.Literals(["1g", "4g", "16g", "64g"]).annotate({ + "description": "Optional memory limit for the container. Defaults to \"1g\"." }) + ), + "network_policy": Schema.optionalKey( + Schema.Union([ContainerNetworkPolicyDisabledParam, ContainerNetworkPolicyAllowlistParam], { mode: "oneOf" }) + .annotate({ "description": "Network access policy for the container." }) ) -}).annotate({ "description": "Create a new Realtime response with these parameters" }) -export type RealtimeClientEventConversationItemCreate = { - readonly "event_id"?: string - readonly "type": "conversation.item.create" - readonly "previous_item_id"?: string - readonly "item": RealtimeConversationItem +}).annotate({ "identifier": "CreateContainerBody" }) +export type AutoCodeInterpreterToolParam = { + readonly "type": "auto" + readonly "file_ids"?: ReadonlyArray + readonly "memory_limit"?: ContainerMemoryLimit | null + readonly "network_policy"?: ContainerNetworkPolicyDisabledParam | ContainerNetworkPolicyAllowlistParam } -export const RealtimeClientEventConversationItemCreate = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) +export const AutoCodeInterpreterToolParam = Schema.Struct({ + "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }), + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "An optional list of uploaded files to make available to your code." + }).check(Schema.isMaxLength(50).annotate({ "expected": "a value with a length of at most 50" })) ), - "type": Schema.Literal("conversation.item.create").annotate({ - "description": "The event type, must be `conversation.item.create`." - }), - "previous_item_id": Schema.optionalKey(Schema.String.annotate({ - "description": - "The ID of the preceding item after which the new item will be inserted. If not set, the new item will be appended to the end of the conversation.\n\nIf set to `root`, the new item will be added to the beginning of the conversation.\n\nIf set to an existing ID, it allows an item to be inserted mid-conversation. If the ID cannot be found, an error will be returned and the item will not be added.\n" - })), - "item": RealtimeConversationItem + "memory_limit": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ContainerMemoryLimit).annotate({ + "description": "The memory limit for the code interpreter container." + }), + Schema.Null + ]) + ), + "network_policy": Schema.optionalKey( + Schema.Union([ContainerNetworkPolicyDisabledParam, ContainerNetworkPolicyAllowlistParam], { mode: "oneOf" }) + .annotate({ "description": "Network access policy for the container." }) + ) }).annotate({ + "title": "CodeInterpreterToolAuto", "description": - "Add a new Item to the Conversation's context, including messages, function \ncalls, and function call responses. This event can be used both to populate a \n\"history\" of the conversation and to add new items mid-stream, but has the \ncurrent limitation that it cannot populate assistant audio messages.\n\nIf successful, the server will respond with a `conversation.item.created` \nevent, otherwise an `error` event will be sent.\n" + "Configuration for a code interpreter container. Optionally specify the IDs of the files to run the code on.", + "identifier": "AutoCodeInterpreterToolParam" }) -export type RealtimeResponse = { - readonly "id"?: string - readonly "object"?: "realtime.response" - readonly "status"?: "completed" | "cancelled" | "failed" | "incomplete" | "in_progress" - readonly "status_details"?: { - readonly "type"?: "completed" | "cancelled" | "failed" | "incomplete" - readonly "reason"?: "turn_detected" | "client_cancelled" | "max_output_tokens" | "content_filter" - readonly "error"?: { readonly "type"?: string; readonly "code"?: string } - } - readonly "output"?: ReadonlyArray - readonly "metadata"?: Metadata - readonly "audio"?: { - readonly "output"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "voice"?: - | string - | "alloy" - | "ash" - | "ballad" - | "coral" - | "echo" - | "sage" - | "shimmer" - | "verse" - | "marin" - | "cedar" - } - } - readonly "usage"?: { - readonly "total_tokens"?: number - readonly "input_tokens"?: number - readonly "output_tokens"?: number - readonly "input_token_details"?: { - readonly "cached_tokens"?: number - readonly "text_tokens"?: number - readonly "image_tokens"?: number - readonly "audio_tokens"?: number - readonly "cached_tokens_details"?: { - readonly "text_tokens"?: number - readonly "image_tokens"?: number - readonly "audio_tokens"?: number - } - } - readonly "output_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number } - } - readonly "conversation_id"?: string - readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> - readonly "max_output_tokens"?: number | "inf" +export type ContainerAutoParam = { + readonly "type": "container_auto" + readonly "file_ids"?: ReadonlyArray + readonly "memory_limit"?: ContainerMemoryLimit | null + readonly "network_policy"?: ContainerNetworkPolicyDisabledParam | ContainerNetworkPolicyAllowlistParam + readonly "skills"?: ReadonlyArray } -export const RealtimeResponse = Schema.Struct({ - "id": Schema.optionalKey( - Schema.String.annotate({ "description": "The unique ID of the response, will look like `resp_1234`." }) +export const ContainerAutoParam = Schema.Struct({ + "type": Schema.Literal("container_auto").annotate({ + "description": "Automatically creates a container for this request" + }), + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "An optional list of uploaded files to make available to your code." + }).check(Schema.isMaxLength(50).annotate({ "expected": "a value with a length of at most 50" })) ), - "object": Schema.optionalKey( - Schema.Literal("realtime.response").annotate({ "description": "The object type, must be `realtime.response`." }) + "memory_limit": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ContainerMemoryLimit).annotate({ + "description": "The memory limit for the container." + }), + Schema.Null + ]) ), - "status": Schema.optionalKey( - Schema.Literals(["completed", "cancelled", "failed", "incomplete", "in_progress"]).annotate({ + "network_policy": Schema.optionalKey( + Schema.Union([ContainerNetworkPolicyDisabledParam, ContainerNetworkPolicyAllowlistParam], { mode: "oneOf" }) + .annotate({ "description": "Network access policy for the container." }) + ), + "skills": Schema.optionalKey( + Schema.Array(Schema.Union([SkillReferenceParam, InlineSkillParam], { mode: "oneOf" })).annotate({ + "description": "An optional list of skills referenced by id or inline data." + }).check(Schema.isMaxLength(200).annotate({ "expected": "a value with a length of at most 200" })) + ) +}).annotate({ "identifier": "ContainerAutoParam" }) +export type EvalItemContentItem = + | EvalItemContentText + | InputTextContent + | EvalItemContentOutputText + | EvalItemInputImage + | InputAudio +export const EvalItemContentItem = Schema.Union([ + EvalItemContentText, + InputTextContent, + EvalItemContentOutputText, + EvalItemInputImage, + InputAudio +], { mode: "oneOf" }).annotate({ + "title": "Eval content item", + "description": "A single content item: input text, output text, input image, or input audio.\n", + "identifier": "EvalItemContentItem" +}) +export type OutputTextContent = { + readonly "type": "output_text" + readonly "text": string + readonly "annotations": ReadonlyArray + readonly "logprobs": ReadonlyArray +} +export const OutputTextContent = Schema.Struct({ + "type": Schema.Literal("output_text").annotate({ + "description": "The type of the output text. Always `output_text`." + }), + "text": Schema.String.annotate({ "description": "The text output from the model." }), + "annotations": Schema.Array(Annotation).annotate({ "description": "The annotations of the text output." }), + "logprobs": Schema.Array(LogProb) +}).annotate({ + "title": "Output text", + "description": "A text output from the model.", + "identifier": "OutputTextContent" +}) +export type FunctionAndCustomToolCallOutput = InputTextContent | InputImageContent | InputFileContent +export const FunctionAndCustomToolCallOutput = Schema.Union([InputTextContent, InputImageContent, InputFileContent], { + mode: "oneOf" +}).annotate({ "identifier": "FunctionAndCustomToolCallOutput" }) +export type InputContent = InputTextContent | InputImageContent | InputFileContent +export const InputContent = Schema.Union([InputTextContent, InputImageContent, InputFileContent], { mode: "oneOf" }) + .annotate({ "identifier": "InputContent" }) +export type FunctionToolCallResource = { + readonly "id": string + readonly "type": "function_call" + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "arguments": string + readonly "status": "in_progress" | "completed" | "incomplete" + readonly "created_by"?: string +} +export const FunctionToolCallResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the function tool call.\n" }), + "type": Schema.Literal("function_call").annotate({ + "description": "The type of the function tool call. Always `function_call`.\n" + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" + }), + "caller": Schema.optionalKey(Schema.Union([ToolCallCaller, Schema.Null])), + "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.Union([Schema.Literal("in_progress"), Schema.Literal("completed"), Schema.Literal("incomplete")]) + .annotate({ "description": - "The final status of the response (`completed`, `cancelled`, `failed`, or \n`incomplete`, `in_progress`).\n" - }) + "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ) +}).annotate({ + "title": "Function tool call", + "description": + "A tool call to run a function. See the \n[function calling guide](/docs/guides/function-calling) for more information.\n", + "identifier": "FunctionToolCallResource" +}) +export type FunctionShellCall = { + readonly "type": "shell_call" + readonly "id": string + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "action": FunctionShellAction + readonly "status": FunctionShellCallStatus + 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." }), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ToolCallCaller).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) ), - "status_details": Schema.optionalKey( - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literals(["completed", "cancelled", "failed", "incomplete"]).annotate({ - "description": - "The type of error that caused the response to fail, corresponding \nwith the `status` field (`completed`, `cancelled`, `incomplete`, \n`failed`).\n" - }) - ), - "reason": Schema.optionalKey( - Schema.Literals(["turn_detected", "client_cancelled", "max_output_tokens", "content_filter"]).annotate({ - "description": - "The reason the Response did not complete. For a `cancelled` Response, one of `turn_detected` (the server VAD detected a new start of speech) or `client_cancelled` (the client sent a cancel event). For an `incomplete` Response, one of `max_output_tokens` or `content_filter` (the server-side safety filter activated and cut off the response).\n" - }) - ), - "error": Schema.optionalKey( - Schema.Struct({ - "type": Schema.optionalKey(Schema.String.annotate({ "description": "The type of error." })), - "code": Schema.optionalKey(Schema.String.annotate({ "description": "Error code, if any." })) - }).annotate({ - "description": - "A description of the error that caused the response to fail, \npopulated when the `status` is `failed`.\n" - }) - ) - }).annotate({ "description": "Additional details about the status." }) - ), - "output": Schema.optionalKey( - Schema.Array(RealtimeConversationItem).annotate({ - "description": "The list of output items generated by the response." - }) - ), - "metadata": Schema.optionalKey(Metadata), - "audio": Schema.optionalKey( - Schema.Struct({ - "output": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the output audio." }) - ), - "voice": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Literals(["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse", "marin", "cedar"]) - ]).annotate({ - "description": - "The voice the model uses to respond. Voice cannot be changed during the\nsession once the model has responded with audio at least once. Current\nvoice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,\n`shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for\nbest quality.\n" - }) - ) - })) - }).annotate({ "description": "Configuration for audio output." }) - ), - "usage": Schema.optionalKey( - Schema.Struct({ - "total_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The total number of tokens in the Response including input and output \ntext and audio tokens.\n" - }).check(Schema.isInt()) - ), - "input_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of input tokens used in the Response, including text and \naudio tokens.\n" - }).check(Schema.isInt()) - ), - "output_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of output tokens sent in the Response, including text and \naudio tokens.\n" - }).check(Schema.isInt()) - ), - "input_token_details": Schema.optionalKey( - Schema.Struct({ - "cached_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of cached tokens used as input for the Response." }) - .check(Schema.isInt()) - ), - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of text tokens used as input for the Response." }) - .check(Schema.isInt()) - ), - "image_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of image tokens used as input for the Response." }) - .check(Schema.isInt()) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of audio tokens used as input for the Response." }) - .check(Schema.isInt()) - ), - "cached_tokens_details": Schema.optionalKey( - Schema.Struct({ - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of cached text tokens used as input for the Response." - }).check(Schema.isInt()) - ), - "image_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of cached image tokens used as input for the Response." - }).check(Schema.isInt()) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The number of cached audio tokens used as input for the Response." - }).check(Schema.isInt()) - ) - }).annotate({ "description": "Details about the cached tokens used as input for the Response." }) - ) - }).annotate({ - "description": - "Details about the input tokens used in the Response. Cached tokens are tokens from previous turns in the conversation that are included as context for the current response. Cached tokens here are counted as a subset of input tokens, meaning input tokens will include cached and uncached tokens." - }) - ), - "output_token_details": Schema.optionalKey( - Schema.Struct({ - "text_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of text tokens used in the Response." }).check( - Schema.isInt() - ) - ), - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The number of audio tokens used in the Response." }).check( - Schema.isInt() - ) - ) - }).annotate({ "description": "Details about the output tokens used in the Response." }) - ) - }).annotate({ - "description": - "Usage statistics for the Response, this will correspond to billing. A \nRealtime API session will maintain a conversation context and append new \nItems to the Conversation, thus output from previous turns (text and \naudio tokens) will become the input for later turns.\n" - }) - ), - "conversation_id": Schema.optionalKey(Schema.String.annotate({ - "description": - "Which conversation the response is added to, determined by the `conversation`\nfield in the `response.create` event. If `auto`, the response will be added to\nthe default conversation and the value of `conversation_id` will be an id like\n`conv_1234`. If `none`, the response will not be added to any conversation and\nthe value of `conversation_id` will be `null`. If responses are being triggered\nautomatically by VAD the response will be added to the default conversation\n" - })), - "output_modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": - "The set of modalities the model used to respond, currently the only possible values are\n`[\\\"audio\\\"]`, `[\\\"text\\\"]`. Audio output always include a text transcript. Setting the\noutput to mode `text` will disable audio output from the model.\n" - }) - ), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ - "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls, that was used in this response.\n" - }) - ) -}).annotate({ "description": "The response resource." }) -export type RealtimeResponseCreateParams = { - readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> - readonly "instructions"?: string - readonly "audio"?: { - readonly "output"?: { - readonly "format"?: { readonly "type"?: "audio/pcm"; readonly "rate"?: 24000 } | { - readonly "type"?: "audio/pcmu" - } | { readonly "type"?: "audio/pcma" } - readonly "voice"?: VoiceIdsShared | { readonly "id": string } - } - } - readonly "tools"?: ReadonlyArray - readonly "tool_choice"?: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMCP - readonly "parallel_tool_calls"?: boolean - readonly "reasoning"?: RealtimeReasoning - readonly "max_output_tokens"?: number | "inf" - readonly "conversation"?: string | "auto" | "none" - readonly "metadata"?: Metadata - readonly "prompt"?: Prompt - readonly "input"?: ReadonlyArray -} -export const RealtimeResponseCreateParams = Schema.Struct({ - "output_modalities": Schema.optionalKey( - Schema.Array(Schema.Literals(["text", "audio"])).annotate({ - "description": - "The set of modalities the model used to respond, currently the only possible values are\n`[\\\"audio\\\"]`, `[\\\"text\\\"]`. Audio output always include a text transcript. Setting the\noutput to mode `text` will disable audio output from the model.\n" - }) - ), - "instructions": Schema.optionalKey(Schema.String.annotate({ - "description": - "The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.\nNote that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.\n" - })), - "audio": Schema.optionalKey( - Schema.Struct({ - "output": Schema.optionalKey(Schema.Struct({ - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcm").annotate({ "description": "The audio format. Always `audio/pcm`." }) - ), - "rate": Schema.optionalKey( - Schema.Literal(24000).annotate({ "description": "The sample rate of the audio. Always `24000`." }) - ) - }).annotate({ - "title": "PCM audio format", - "description": "The PCM audio format. Only a 24kHz sample rate is supported." - }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcmu").annotate({ "description": "The audio format. Always `audio/pcmu`." }) - ) - }).annotate({ "title": "PCMU audio format", "description": "The G.711 μ-law format." }), - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("audio/pcma").annotate({ "description": "The audio format. Always `audio/pcma`." }) - ) - }).annotate({ "title": "PCMA audio format", "description": "The G.711 A-law format." }) - ]).annotate({ "description": "The format of the output audio." }) - ), - "voice": Schema.optionalKey( - Schema.Union([ - VoiceIdsShared, - Schema.Struct({ - "id": Schema.String.annotate({ "description": "The custom voice ID, e.g. `voice_1234`." }) - }).annotate({ "description": "Custom voice reference." }) - ]).annotate({ - "title": "Voice", - "description": - "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,\n`marin`, and `cedar`. You may also provide a custom voice object with\nan `id`, for example `{ \"id\": \"voice_1234\" }`. Voice cannot be changed\nduring the session once the model has responded with audio at least once.\nWe recommend `marin` and `cedar` for best quality.\n" - }) - ) - })) - }).annotate({ "description": "Configuration for audio input and output." }) - ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Union([RealtimeFunctionTool, MCPTool], { mode: "oneOf" })).annotate({ - "description": "Tools available to the model." - }) - ), - "tool_choice": Schema.optionalKey( - Schema.Union([ToolChoiceOptions, ToolChoiceFunction, ToolChoiceMCP], { mode: "oneOf" }).annotate({ - "description": - "How the model chooses tools. Provide one of the string modes or force a specific\nfunction/MCP tool.\n" - }) - ), - "parallel_tool_calls": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether the model may call multiple tools in parallel. Only supported by\nreasoning Realtime models such as `gpt-realtime-2`.\n" - }) - ), - "reasoning": Schema.optionalKey(RealtimeReasoning), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Literal("inf")], { mode: "oneOf" }).annotate({ - "description": - "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" - }) - ), - "conversation": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Literals(["auto", "none"])], { mode: "oneOf" }).annotate({ - "description": - "Controls which conversation the response is added to. Currently supports\n`auto` and `none`, with `auto` as the default value. The `auto` value\nmeans that the contents of the response will be added to the default\nconversation. Set this to `none` to create an out-of-band response which\nwill not add items to default conversation.\n" - }) - ), - "metadata": Schema.optionalKey(Metadata), - "prompt": Schema.optionalKey(Prompt), - "input": Schema.optionalKey( - Schema.Array(RealtimeConversationItem).annotate({ - "description": - "Input items to include in the prompt for the model. Using this field\ncreates a new context for this Response instead of using the default\nconversation. An empty array `[]` will clear the context for this Response.\nNote that this can include references to items that previously appeared in the session\nusing their id.\n" - }) + "action": Schema.suspend((): Schema.Codec => FunctionShellAction).annotate({ + "description": "The shell commands and limits that describe how to run the tool call." + }), + "status": Schema.suspend((): Schema.Codec => FunctionShellCallStatus).annotate({ + "description": "The status of the shell call. One of `in_progress`, `completed`, or `incomplete`." + }), + "environment": Schema.Union([ + Schema.Union([LocalEnvironmentResource, ContainerReferenceResource], { mode: "oneOf" }), + Schema.Null + ]), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the entity that created this tool call." }) ) -}).annotate({ "description": "Create a new Realtime response with these parameters" }) -export type RealtimeServerEventConversationItemAdded = { - readonly "event_id": string - readonly "type": "conversation.item.added" - readonly "previous_item_id"?: string | null - readonly "item": RealtimeConversationItem +}).annotate({ + "title": "Shell tool call", + "description": "A tool call that executes one or more shell commands in a managed environment.", + "identifier": "FunctionShellCall" +}) +export type ApplyPatchToolCall = { + readonly "type": "apply_patch_call" + readonly "id": string + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "status": ApplyPatchCallStatus + readonly "operation": ApplyPatchCreateFileOperation | ApplyPatchDeleteFileOperation | ApplyPatchUpdateFileOperation + readonly "created_by"?: string } -export const RealtimeServerEventConversationItemAdded = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.added").annotate({ - "description": "The event type, must be `conversation.item.added`." +export const ApplyPatchToolCall = Schema.Struct({ + "type": Schema.Literal("apply_patch_call").annotate({ + "description": "The type of the item. Always `apply_patch_call`." + }), + "id": Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call. Populated when this item is returned via API." }), - "previous_item_id": Schema.optionalKey( + "call_id": Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call generated by the model." + }), + "caller": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ - "description": - "The ID of the item that precedes this one, if any. This is used to\nmaintain ordering when items are inserted.\n" + Schema.suspend((): Schema.Codec => ToolCallCaller).annotate({ + "description": "The execution context that produced this tool call." }), Schema.Null ]) ), - "item": RealtimeConversationItem + "status": Schema.suspend((): Schema.Codec => ApplyPatchCallStatus).annotate({ + "description": "The status of the apply patch tool call. One of `in_progress` or `completed`." + }), + "operation": Schema.Union([ + ApplyPatchCreateFileOperation, + ApplyPatchDeleteFileOperation, + ApplyPatchUpdateFileOperation + ], { mode: "oneOf" }).annotate({ + "title": "Apply patch operation", + "description": "One of the create_file, delete_file, or update_file operations applied via apply_patch." + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the entity that created this tool call." }) + ) }).annotate({ - "description": - "Sent by the server when an Item is added to the default Conversation. This can happen in several cases:\n- When the client sends a `conversation.item.create` event.\n- When the input audio buffer is committed. In this case the item will be a user message containing the audio from the buffer.\n- When the model is generating a Response. In this case the `conversation.item.added` event will be sent when the model starts generating a specific Item, and thus it will not yet have any content (and `status` will be `in_progress`).\n\nThe event will include the full content of the Item (except when model is generating a Response) except for audio data, which can be retrieved separately with a `conversation.item.retrieve` event if necessary.\n" + "title": "Apply patch tool call", + "description": "A tool call that applies file diffs by creating, deleting, or updating files.", + "identifier": "ApplyPatchToolCall" }) -export type RealtimeServerEventConversationItemCreated = { - readonly "event_id": string - readonly "type": "conversation.item.created" - readonly "previous_item_id"?: string | null - readonly "item": RealtimeConversationItem +export type ApplyPatchToolCallOutput = { + readonly "type": "apply_patch_call_output" + readonly "id": string + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "status": ApplyPatchCallOutputStatus + readonly "output"?: string | null + readonly "created_by"?: string } -export const RealtimeServerEventConversationItemCreated = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.created").annotate({ - "description": "The event type, must be `conversation.item.created`." +export const ApplyPatchToolCallOutput = Schema.Struct({ + "type": Schema.Literal("apply_patch_call_output").annotate({ + "description": "The type of the item. Always `apply_patch_call_output`." + }), + "id": Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call output. Populated when this item is returned via API." }), - "previous_item_id": Schema.optionalKey( + "call_id": Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call generated by the model." + }), + "caller": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ - "description": - "The ID of the preceding item in the Conversation context, allows the\nclient to understand the order of the conversation. Can be `null` if the\nitem has no predecessor.\n" + Schema.suspend((): Schema.Codec => ToolCallCaller).annotate({ + "description": "The execution context that produced this tool call." }), Schema.Null ]) ), - "item": RealtimeConversationItem -}).annotate({ - "description": - "Returned when a conversation item is created. There are several scenarios that produce this event:\n - The server is generating a Response, which if successful will produce\n either one or two Items, which will be of type `message`\n (role `assistant`) or type `function_call`.\n - The input audio buffer has been committed, either by the client or the\n server (in `server_vad` mode). The server will take the content of the\n input audio buffer and add it to a new user message Item.\n - The client has sent a `conversation.item.create` event to add a new Item\n to the Conversation.\n" -}) -export type RealtimeServerEventConversationItemDone = { - readonly "event_id": string - readonly "type": "conversation.item.done" - readonly "previous_item_id"?: string | null - readonly "item": RealtimeConversationItem -} -export const RealtimeServerEventConversationItemDone = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.done").annotate({ - "description": "The event type, must be `conversation.item.done`." + "status": Schema.suspend((): Schema.Codec => ApplyPatchCallOutputStatus).annotate({ + "description": "The status of the apply patch tool call output. One of `completed` or `failed`." }), - "previous_item_id": Schema.optionalKey( + "output": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ - "description": - "The ID of the item that precedes this one, if any. This is used to\nmaintain ordering when items are inserted.\n" - }), + Schema.String.annotate({ "description": "Optional textual output returned by the apply patch tool." }), Schema.Null ]) ), - "item": RealtimeConversationItem + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the entity that created this tool call output." }) + ) }).annotate({ - "description": - "Returned when a conversation item is finalized.\n\nThe event will include the full content of the Item except for audio data, which can be retrieved separately with a `conversation.item.retrieve` event if needed.\n" + "title": "Apply patch tool call output", + "description": "The output emitted by an apply patch tool call.", + "identifier": "ApplyPatchToolCallOutput" }) -export type RealtimeServerEventConversationItemRetrieved = { - readonly "event_id": string - readonly "type": "conversation.item.retrieved" - readonly "item": RealtimeConversationItem +export type CustomToolCall = { + readonly "type": "custom_tool_call" + readonly "id"?: string + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "input": string } -export const RealtimeServerEventConversationItemRetrieved = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("conversation.item.retrieved").annotate({ - "description": "The event type, must be `conversation.item.retrieved`." - }), - "item": RealtimeConversationItem +export const CustomToolCall = Schema.Struct({ + "type": Schema.Literal("custom_tool_call").annotate({ + "description": "The type of the custom tool call. Always `custom_tool_call`.\n" + }), + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The unique ID of the custom tool call in the OpenAI platform.\n" }) + ), + "call_id": Schema.String.annotate({ + "description": "An identifier used to map this custom tool call to a tool call output.\n" + }), + "caller": Schema.optionalKey(Schema.Union([ToolCallCaller, Schema.Null])), + "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", + "identifier": "CustomToolCall" +}) +export type FunctionToolCall = { + readonly "id"?: string + readonly "type": "function_call" + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "arguments": string + readonly "status"?: "in_progress" | "completed" | "incomplete" +} +export const FunctionToolCall = Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the function tool call.\n" })), + "type": Schema.Literal("function_call").annotate({ + "description": "The type of the function tool call. Always `function_call`.\n" + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" + }), + "caller": Schema.optionalKey(Schema.Union([ToolCallCaller, Schema.Null])), + "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( + 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": "Function tool call", "description": - "Returned when a conversation item is retrieved with `conversation.item.retrieve`. This is provided as a way to fetch the server's representation of an item, for example to get access to the post-processed audio data after noise cancellation and VAD. It includes the full content of the Item, including audio data.\n" + "A tool call to run a function. See the \n[function calling guide](/docs/guides/function-calling) for more information.\n", + "identifier": "FunctionToolCall" }) -export type RealtimeServerEventResponseOutputItemAdded = { - readonly "event_id": string - readonly "type": "response.output_item.added" - readonly "response_id": string - readonly "output_index": number - readonly "item": RealtimeConversationItem +export type CustomToolCallResource = { + readonly "type": "custom_tool_call" + readonly "id": string + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "input": string + readonly "status": FunctionCallStatus + readonly "created_by"?: string } -export const RealtimeServerEventResponseOutputItemAdded = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.output_item.added").annotate({ - "description": "The event type, must be `response.output_item.added`." +export const CustomToolCallResource = Schema.Struct({ + "type": Schema.Literal("custom_tool_call").annotate({ + "description": "The type of the custom tool call. Always `custom_tool_call`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the custom tool call item.\n" }), + "call_id": Schema.String.annotate({ + "description": "An identifier used to map this custom tool call to a tool call output.\n" }), - "response_id": Schema.String.annotate({ "description": "The ID of the Response to which the item belongs." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the Response." }).check( - Schema.isInt() + "caller": Schema.optionalKey(Schema.Union([ToolCallCaller, Schema.Null])), + "namespace": Schema.optionalKey( + Schema.String.annotate({ "description": "The namespace of the custom tool being called.\n" }) ), - "item": RealtimeConversationItem -}).annotate({ "description": "Returned when a new Item is created during Response generation." }) -export type RealtimeServerEventResponseOutputItemDone = { - readonly "event_id": string - readonly "type": "response.output_item.done" - readonly "response_id": string - readonly "output_index": number - readonly "item": RealtimeConversationItem -} -export const RealtimeServerEventResponseOutputItemDone = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.output_item.done").annotate({ - "description": "The event type, must be `response.output_item.done`." + "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" }), + "status": Schema.suspend((): Schema.Codec => FunctionCallStatus).annotate({ + "description": + "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" }), - "response_id": Schema.String.annotate({ "description": "The ID of the Response to which the item belongs." }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item in the Response." }).check( - Schema.isInt() + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ) +}).annotate({ + "title": "ResponseCustomToolCallItem", + "description": "A call to a custom tool created by the model.\n", + "identifier": "CustomToolCallResource" +}) +export type ComputerAction = + | ClickParam + | DoubleClickAction + | DragParam + | KeyPressAction + | MoveParam + | ScreenshotParam + | ScrollParam + | TypeParam + | WaitParam +export const ComputerAction = Schema.Union([ + ClickParam, + DoubleClickAction, + DragParam, + KeyPressAction, + MoveParam, + ScreenshotParam, + ScrollParam, + TypeParam, + WaitParam +], { mode: "oneOf" }).annotate({ "identifier": "ComputerAction" }) +export type Filters = ComparisonFilter | CompoundFilter +export const Filters = Schema.Union([ComparisonFilter, CompoundFilter]).annotate({ "identifier": "Filters" }) +export type VectorStoreSearchRequest = { + readonly "query": string | ReadonlyArray + readonly "rewrite_query"?: boolean + readonly "max_num_results"?: number + readonly "filters"?: ComparisonFilter | CompoundFilter + readonly "ranking_options"?: { + readonly "ranker"?: "none" | "auto" | "default-2024-11-15" + readonly "score_threshold"?: number + } +} +export const VectorStoreSearchRequest = Schema.Struct({ + "query": Schema.Union([ + Schema.String, + Schema.Array(Schema.String.annotate({ "description": "A list of queries to search for." })) + ], { mode: "oneOf" }).annotate({ "description": "A query string for a search" }), + "rewrite_query": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether to rewrite the natural language query for vector search." }) + ), + "max_num_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum number of results to return. This number should be between 1 and 50 inclusive." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(50).annotate({ "expected": "a value less than or equal to 50" })) + ), + "filters": Schema.optionalKey( + Schema.Union([ComparisonFilter, CompoundFilter], { mode: "oneOf" }).annotate({ + "description": "A filter to apply based on file attributes." + }) + ), + "ranking_options": Schema.optionalKey( + Schema.Struct({ + "ranker": Schema.optionalKey( + Schema.Literals(["none", "auto", "default-2024-11-15"]).annotate({ + "description": "Enable re-ranking; set to `none` to disable, which can help reduce latency." + }) + ), + "score_threshold": Schema.optionalKey( + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) + ) + }).annotate({ "description": "Ranking options for search." }) + ) +}).annotate({ "identifier": "VectorStoreSearchRequest" }) +export type CustomToolParam = { + readonly "type": "custom" + readonly "name": string + readonly "description"?: string + readonly "format"?: CustomTextFormatParam | CustomGrammarFormatParam + readonly "defer_loading"?: boolean + readonly "allowed_callers"?: ReadonlyArray | null +} +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." + }) ), - "item": RealtimeConversationItem + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this tool should be deferred and discovered via tool search." }) + ), + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(CallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]) + ) }).annotate({ + "title": "Custom tool", "description": - "Returned when an Item is done streaming. Also emitted when a Response is \ninterrupted, incomplete, or cancelled.\n" + "A custom tool that processes input using a specified format. Learn more about [custom tools](/docs/guides/function-calling#custom-tools)", + "identifier": "CustomToolParam" }) -export type AssistantObject = { +export type FunctionShellCallOutput = { + readonly "type": "shell_call_output" readonly "id": string - readonly "object": "assistant" - readonly "created_at": number - readonly "name": string | null - readonly "description": string | null - readonly "model": string - readonly "instructions": string | null - readonly "tools": ReadonlyArray - readonly "tool_resources"?: { - readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } - readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } - } | null - readonly "metadata": Metadata - readonly "temperature"?: number | null - readonly "top_p"?: number | null - readonly "response_format"?: AssistantsApiResponseFormatOption | null + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "status": FunctionShellCallOutputStatusEnum + readonly "output": ReadonlyArray + readonly "max_output_length": number | null + readonly "created_by"?: string } -export const AssistantObject = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), - "object": Schema.Literal("assistant").annotate({ "description": "The object type, which is always `assistant`." }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the assistant was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "name": Schema.Union([ - Schema.String.annotate({ "description": "The name of the assistant. The maximum length is 256 characters.\n" }) - .check(Schema.isMaxLength(256)), - Schema.Null - ]), - "description": Schema.Union([ - Schema.String.annotate({ - "description": "The description of the assistant. The maximum length is 512 characters.\n" - }).check(Schema.isMaxLength(512)), - Schema.Null - ]), - "model": Schema.String.annotate({ - "description": - "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" +export const FunctionShellCallOutput = Schema.Struct({ + "type": Schema.Literal("shell_call_output").annotate({ + "description": "The type of the shell call output. Always `shell_call_output`." }), - "instructions": Schema.Union([ - Schema.String.annotate({ - "description": "The system instructions that the assistant uses. The maximum length is 256,000 characters.\n" - }).check(Schema.isMaxLength(256000)), - Schema.Null - ]), - "tools": Schema.Array( - Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) - ).annotate({ - "description": - "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.\n" - }).check(Schema.isMaxLength(128)), - "tool_resources": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "code_interpreter": Schema.optionalKey(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.\n" - }).check(Schema.isMaxLength(20)) - ) - })), - "file_search": Schema.optionalKey(Schema.Struct({ - "vector_store_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" - }).check(Schema.isMaxLength(1)) - ) - })) - }).annotate({ - "description": - "A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" - }), - Schema.Null - ])), - "metadata": Metadata, - "temperature": Schema.optionalKey( + "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." }), + "caller": 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.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(2)), + Schema.suspend((): Schema.Codec => ToolCallCaller).annotate({ + "description": "The execution context that produced this tool call." + }), Schema.Null ]) ), - "top_p": Schema.optionalKey(Schema.Union([ + "status": Schema.suspend((): Schema.Codec => FunctionShellCallOutputStatusEnum) + .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": - "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or temperature but not both.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1)), + "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().annotate({ "expected": "an integer" })), Schema.Null - ])), - "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) -}).annotate({ "title": "Assistant", "description": "Represents an `assistant` that can call the model and use tools." }) -export type CreateAssistantRequest = { - readonly "model": string | AssistantSupportedModels - readonly "name"?: string | null - readonly "description"?: string | null - readonly "instructions"?: string | null - readonly "reasoning_effort"?: ReasoningEffort - readonly "tools"?: ReadonlyArray - readonly "tool_resources"?: { - readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } - readonly "file_search"?: { - readonly "vector_store_ids": ReadonlyArray - readonly "vector_stores"?: ReadonlyArray< - { - readonly "file_ids"?: ReadonlyArray - readonly "chunking_strategy"?: { readonly "type": "auto" } | { - readonly "type": "static" - readonly "static": { readonly "max_chunk_size_tokens": number; readonly "chunk_overlap_tokens": number } - } - readonly "metadata"?: Metadata - } - > - } | { - readonly "vector_stores": ReadonlyArray< - { - readonly "file_ids"?: ReadonlyArray - readonly "chunking_strategy"?: { readonly "type": "auto" } | { - readonly "type": "static" - readonly "static": { readonly "max_chunk_size_tokens": number; readonly "chunk_overlap_tokens": number } - } - readonly "metadata"?: Metadata - } - > - readonly "vector_store_ids"?: ReadonlyArray - } - } | null - readonly "metadata"?: Metadata - readonly "temperature"?: number | null - readonly "top_p"?: number | null - readonly "response_format"?: AssistantsApiResponseFormatOption | 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.", + "identifier": "FunctionShellCallOutput" +}) +export type FunctionShellCallOutputContentParam = { + readonly "stdout": string + readonly "stderr": string + readonly "outcome": FunctionShellCallOutputOutcomeParam } -export const CreateAssistantRequest = Schema.Struct({ - "model": Schema.Union([Schema.String, AssistantSupportedModels]).annotate({ - "description": - "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" +export const FunctionShellCallOutputContentParam = Schema.Struct({ + "stdout": Schema.String.annotate({ "description": "Captured stdout output for the shell call." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ), + "stderr": Schema.String.annotate({ "description": "Captured stderr output for the shell call." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ), + "outcome": Schema.suspend((): Schema.Codec => + FunctionShellCallOutputOutcomeParam + ).annotate({ "description": "The exit or timeout outcome associated with this shell call." }) +}).annotate({ + "title": "Shell output content", + "description": "Captured stdout and stderr for a portion of a shell tool call output.", + "identifier": "FunctionShellCallOutputContentParam" +}) +export type EvalRunOutputItemList = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean +} +export const EvalRunOutputItemList = Schema.Struct({ + "object": Schema.Literal("list").annotate({ + "description": "The type of this object. It is always set to \"list\".\n" }), - "name": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The name of the assistant. The maximum length is 256 characters.\n" }) - .check(Schema.isMaxLength(256)), - Schema.Null - ]) + "data": Schema.Array(EvalRunOutputItem).annotate({ "description": "An array of eval run output item objects.\n" }), + "first_id": Schema.String.annotate({ + "description": "The identifier of the first eval run output item in the data array." + }), + "last_id": Schema.String.annotate({ + "description": "The identifier of the last eval run output item in the data array." + }), + "has_more": Schema.Boolean.annotate({ + "description": "Indicates whether there are more eval run output items available." + }) +}).annotate({ + "title": "EvalRunOutputItemList", + "description": "An object representing a list of output items for an evaluation run.\n", + "identifier": "EvalRunOutputItemList" +}) +export type ImagesResponse = { + readonly "created": number + readonly "data"?: ReadonlyArray + readonly "background"?: "transparent" | "opaque" + readonly "output_format"?: "png" | "webp" | "jpeg" + readonly "size"?: "1024x1024" | "1024x1536" | "1536x1024" + readonly "quality"?: "low" | "medium" | "high" + readonly "usage"?: ImageGenUsage +} +export const ImagesResponse = Schema.Struct({ + "created": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the image was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "data": Schema.optionalKey(Schema.Array(Image).annotate({ "description": "The list of generated images." })), + "background": Schema.optionalKey( + Schema.Literals(["transparent", "opaque"]).annotate({ + "description": "The background parameter used for the image generation. Either `transparent` or `opaque`." + }) ), - "description": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "The description of the assistant. The maximum length is 512 characters.\n" - }).check(Schema.isMaxLength(512)), - Schema.Null - ]) + "output_format": Schema.optionalKey( + Schema.Literals(["png", "webp", "jpeg"]).annotate({ + "description": "The output format of the image generation. Either `png`, `webp`, or `jpeg`." + }) ), - "instructions": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "The system instructions that the assistant uses. The maximum length is 256,000 characters.\n" - }).check(Schema.isMaxLength(256000)), - Schema.Null - ]) + "size": Schema.optionalKey( + Schema.Literals(["1024x1024", "1024x1536", "1536x1024"]).annotate({ + "description": "The size of the image generated. Either `1024x1024`, `1024x1536`, or `1536x1024`." + }) ), - "reasoning_effort": Schema.optionalKey(ReasoningEffort), - "tools": Schema.optionalKey( - Schema.Array( - Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) - ).annotate({ - "description": - "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.\n" - }).check(Schema.isMaxLength(128)) + "quality": Schema.optionalKey( + Schema.Literals(["low", "medium", "high"]).annotate({ + "description": "The quality of the image generated. Either `low`, `medium`, or `high`." + }) ), - "tool_resources": Schema.optionalKey(Schema.Union([ + "usage": Schema.optionalKey(ImageGenUsage) +}).annotate({ + "title": "Image generation response", + "description": "The response from the image generation endpoint.", + "identifier": "ImagesResponse" +}) +export type ImageEditStreamEvent = ImageEditPartialImageEvent | ImageEditCompletedEvent +export const ImageEditStreamEvent = Schema.Union([ImageEditPartialImageEvent, ImageEditCompletedEvent]).annotate({ + "identifier": "ImageEditStreamEvent" +}) +export type ImageGenStreamEvent = ImageGenPartialImageEvent | ImageGenCompletedEvent +export const ImageGenStreamEvent = Schema.Union([ImageGenPartialImageEvent, ImageGenCompletedEvent]).annotate({ + "identifier": "ImageGenStreamEvent" +}) +export type AuditLogActor = { + readonly "type"?: "session" | "api_key" + readonly "session"?: AuditLogActorSession + readonly "api_key"?: AuditLogActorApiKey +} +export const AuditLogActor = Schema.Struct({ + "type": Schema.optionalKey( + Schema.Literals(["session", "api_key"]).annotate({ + "description": "The type of actor. Is either `session` or `api_key`." + }) + ), + "session": Schema.optionalKey(AuditLogActorSession), + "api_key": Schema.optionalKey(AuditLogActorApiKey) +}).annotate({ "description": "The actor who performed the audit logged action.", "identifier": "AuditLogActor" }) +export type UsageResponse = { + readonly "object": "page" + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "next_page": string | null +} +export const UsageResponse = Schema.Struct({ + "object": Schema.Literal("page"), + "data": Schema.Array(UsageTimeBucket), + "has_more": Schema.Boolean, + "next_page": Schema.Union([Schema.String, Schema.Null]) +}).annotate({ "identifier": "UsageResponse" }) +export type ProjectApiKeyListResponse = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id"?: string | null + readonly "last_id"?: string | null + readonly "has_more": boolean +} +export const ProjectApiKeyListResponse = Schema.Struct({ + "object": Schema.Literal("list"), + "data": Schema.Array(ProjectApiKey), + "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "has_more": Schema.Boolean +}).annotate({ "identifier": "ProjectApiKeyListResponse" }) +export type ProjectSpendAlertListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "last_id": string | null + readonly "has_more": boolean +} +export const ProjectSpendAlertListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), + "data": Schema.Array(ProjectSpendAlert).annotate({ "description": "Spend alerts returned in the current page." }), + "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The ID of the first spend alert in this page." + }), + "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The ID of the last spend alert in this page." + }), + "has_more": Schema.Boolean.annotate({ "description": "Whether more spend alerts are available when paginating." }) +}).annotate({ "description": "Paginated list of project spend alerts.", "identifier": "ProjectSpendAlertListResource" }) +export type OrganizationSpendAlertListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "last_id": string | null + readonly "has_more": boolean +} +export const OrganizationSpendAlertListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "Always `list`." }), + "data": Schema.Array(OrganizationSpendAlert).annotate({ + "description": "Spend alerts returned in the current page." + }), + "first_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The ID of the first spend alert in this page." + }), + "last_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The ID of the last spend alert in this page." + }), + "has_more": Schema.Boolean.annotate({ "description": "Whether more spend alerts are available when paginating." }) +}).annotate({ + "description": "Paginated list of organization spend alerts.", + "identifier": "OrganizationSpendAlertListResource" +}) +export type RealtimeTranslationClientSecretCreateRequest = { + readonly "expires_after"?: { readonly "anchor"?: "created_at"; readonly "seconds"?: number } + readonly "session": RealtimeTranslationSessionCreateRequest +} +export const RealtimeTranslationClientSecretCreateRequest = Schema.Struct({ + "expires_after": Schema.optionalKey( Schema.Struct({ - "code_interpreter": Schema.optionalKey(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" - }).check(Schema.isMaxLength(20)) - ) - })), - "file_search": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "vector_store_ids": Schema.Array(Schema.String).annotate({ - "description": - "The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" - }).check(Schema.isMaxLength(1)), - "vector_stores": Schema.optionalKey( - Schema.Array(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.\n" - }).check(Schema.isMaxLength(100000000)) - ), - "chunking_strategy": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }) - .annotate({ - "title": "Auto Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." - }), - Schema.Struct({ - "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), - "static": Schema.Struct({ - "max_chunk_size_tokens": Schema.Number.annotate({ - "description": - "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(100)).check( - Schema.isLessThanOrEqualTo(4096) - ), - "chunk_overlap_tokens": Schema.Number.annotate({ - "description": - "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" - }).check(Schema.isInt()) - }) - }).annotate({ - "title": "Static Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." - }) - ], { mode: "oneOf" }) - ), - "metadata": Schema.optionalKey(Metadata) - })).annotate({ - "description": - "A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" - }).check(Schema.isMaxLength(1)) - ) - }), - Schema.Struct({ - "vector_stores": Schema.Array(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.\n" - }).check(Schema.isMaxLength(100000000)) - ), - "chunking_strategy": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }) - .annotate({ - "title": "Auto Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." - }), - Schema.Struct({ - "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), - "static": Schema.Struct({ - "max_chunk_size_tokens": Schema.Number.annotate({ - "description": - "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(100)).check( - Schema.isLessThanOrEqualTo(4096) - ), - "chunk_overlap_tokens": Schema.Number.annotate({ - "description": - "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" - }).check(Schema.isInt()) - }) - }).annotate({ - "title": "Static Chunking Strategy", - "description": - "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." - }) - ], { mode: "oneOf" }) - ), - "metadata": Schema.optionalKey(Metadata) - })).annotate({ - "description": - "A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" - }).check(Schema.isMaxLength(1)), - "vector_store_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" - }).check(Schema.isMaxLength(1)) - ) + "anchor": Schema.optionalKey( + Schema.Literal("created_at").annotate({ + "description": + "The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.\n" }) - ], { mode: "oneOf" })) + ), + "seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.\n", + "format": "int64" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(10).annotate({ "expected": "a value greater than or equal to 10" }) + ).check(Schema.isLessThanOrEqualTo(7200).annotate({ "expected": "a value less than or equal to 7200" })) + ) }).annotate({ + "title": "Client secret expiration", "description": - "A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" - }), - Schema.Null - ])), - "metadata": Schema.optionalKey(Metadata), - "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.\n" - }).check(Schema.isFinite()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(2)), - Schema.Null - ]) + "Configuration for the client secret expiration. Expiration refers to the time after which\na client secret will no longer be valid for creating sessions. The session itself may\ncontinue after that time once started. A secret can be used to create multiple sessions\nuntil it expires.\n" + }) ), - "top_p": Schema.optionalKey(Schema.Union([ - Schema.Number.annotate({ - "description": - "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are 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 - ])), - "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) + "session": RealtimeTranslationSessionCreateRequest +}).annotate({ + "title": "Realtime translation client secret creation request", + "description": "Create a translation session and client secret for the Realtime API.\n", + "identifier": "RealtimeTranslationClientSecretCreateRequest" }) -export type CreateRunRequest = { - readonly "assistant_id": string - readonly "model"?: string | AssistantSupportedModels | null - readonly "reasoning_effort"?: ReasoningEffort - readonly "instructions"?: string | null - readonly "additional_instructions"?: string | null - readonly "additional_messages"?: ReadonlyArray< - { - readonly "role": "user" | "assistant" - readonly "content": - | string - | ReadonlyArray - readonly "attachments"?: - | ReadonlyArray< - { - readonly "file_id"?: string - readonly "tools"?: ReadonlyArray - } - > - | null - readonly "metadata"?: Metadata +export type RealtimeTranslationClientSecretCreateResponse = { + readonly "value": string + readonly "expires_at": number + readonly "session": RealtimeTranslationSession +} +export const RealtimeTranslationClientSecretCreateResponse = Schema.Struct({ + "value": Schema.String.annotate({ "description": "The generated client secret value." }), + "expires_at": Schema.Number.annotate({ + "description": "Expiration timestamp for the client secret, in seconds since epoch.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "session": RealtimeTranslationSession +}).annotate({ + "title": "Realtime translation session and client secret", + "description": "Response from creating a translation session and client secret for the Realtime API.\n", + "identifier": "RealtimeTranslationClientSecretCreateResponse" +}) +export type RealtimeSessionCreateRequestGA = { + readonly "type": "realtime" + readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> + readonly "model"?: + | string + | "gpt-realtime" + | "gpt-realtime-1.5" + | "gpt-realtime-2" + | "gpt-realtime-2.1" + | "gpt-realtime-2.1-mini" + | "gpt-realtime-2025-08-28" + | "gpt-4o-realtime-preview" + | "gpt-4o-realtime-preview-2024-10-01" + | "gpt-4o-realtime-preview-2024-12-17" + | "gpt-4o-realtime-preview-2025-06-03" + | "gpt-4o-mini-realtime-preview" + | "gpt-4o-mini-realtime-preview-2024-12-17" + | "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" + readonly "instructions"?: string + readonly "audio"?: { + readonly "input"?: { + readonly "format"?: RealtimeAudioFormats + readonly "transcription"?: AudioTranscription + readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } + readonly "turn_detection"?: RealtimeTurnDetection + } + readonly "output"?: { + readonly "format"?: RealtimeAudioFormats + readonly "voice"?: VoiceIdsOrCustomVoice + readonly "speed"?: number } - > - readonly "tools"?: ReadonlyArray - readonly "metadata"?: Metadata - readonly "temperature"?: number - readonly "top_p"?: number - readonly "stream"?: boolean | null - readonly "max_prompt_tokens"?: number - readonly "max_completion_tokens"?: number - readonly "truncation_strategy"?: { - readonly "type": "auto" | "last_messages" - readonly "last_messages"?: number | null - } - readonly "tool_choice"?: "none" | "auto" | "required" | { - readonly "type": "function" | "code_interpreter" | "file_search" - readonly "function"?: { readonly "name": string } } - readonly "parallel_tool_calls"?: ParallelToolCalls - readonly "response_format"?: AssistantsApiResponseFormatOption | null + readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> + readonly "tracing"?: "auto" | { + readonly "workflow_name"?: string + readonly "group_id"?: string + readonly "metadata"?: {} + } | null + readonly "tools"?: ReadonlyArray + readonly "tool_choice"?: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMCP + readonly "parallel_tool_calls"?: boolean + readonly "reasoning"?: RealtimeReasoning + readonly "max_output_tokens"?: number | "inf" + readonly "truncation"?: RealtimeTruncation + readonly "prompt"?: Prompt } -export const CreateRunRequest = Schema.Struct({ - "assistant_id": Schema.String.annotate({ - "description": "The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run." +export const RealtimeSessionCreateRequestGA = Schema.Struct({ + "type": Schema.Literal("realtime").annotate({ + "description": "The type of session to create. Always `realtime` for the Realtime API.\n" }), + "output_modalities": Schema.optionalKey( + Schema.Array(Schema.Literals(["text", "audio"])).annotate({ + "description": + "The set of modalities the model can respond with. It defaults to `[\"audio\"]`, indicating\nthat the model will respond with audio plus a transcript. `[\"text\"]` can be used to make\nthe model respond with text only. It is not possible to request both `text` and `audio` at the same time.\n" + }) + ), "model": Schema.optionalKey( Schema.Union([ - Schema.Union([Schema.String, AssistantSupportedModels]).annotate({ - "description": - "The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used." - }), - Schema.Null - ]) + Schema.String, + Schema.Literals([ + "gpt-realtime", + "gpt-realtime-1.5", + "gpt-realtime-2", + "gpt-realtime-2.1", + "gpt-realtime-2.1-mini", + "gpt-realtime-2025-08-28", + "gpt-4o-realtime-preview", + "gpt-4o-realtime-preview-2024-10-01", + "gpt-4o-realtime-preview-2024-12-17", + "gpt-4o-realtime-preview-2025-06-03", + "gpt-4o-mini-realtime-preview", + "gpt-4o-mini-realtime-preview-2024-12-17", + "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" + ]) + ]).annotate({ "description": "The Realtime model used for this session.\n" }) ), - "reasoning_effort": Schema.optionalKey(ReasoningEffort), - "instructions": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis." - }) + "instructions": Schema.optionalKey(Schema.String.annotate({ + "description": + "The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.\n\nNote that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.\n" + })), + "audio": Schema.optionalKey( + Schema.Struct({ + "input": Schema.optionalKey(Schema.Struct({ + "format": Schema.optionalKey( + Schema.suspend((): Schema.Codec => RealtimeAudioFormats).annotate({ + "description": "The format of the input audio." + }) + ), + "transcription": Schema.optionalKey( + Schema.suspend((): Schema.Codec => AudioTranscription).annotate({ + "description": + "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" + }) + ), + "noise_reduction": Schema.optionalKey( + Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ + "description": + "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" + }) + ), + "turn_detection": Schema.optionalKey(RealtimeTurnDetection) + })), + "output": Schema.optionalKey(Schema.Struct({ + "format": Schema.optionalKey( + Schema.suspend((): Schema.Codec => RealtimeAudioFormats).annotate({ + "description": "The format of the output audio." + }) + ), + "voice": Schema.optionalKey( + Schema.suspend((): Schema.Codec => VoiceIdsOrCustomVoice).annotate({ + "description": + "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,\n`marin`, and `cedar`. You may also provide a custom voice object with\nan `id`, for example `{ \"id\": \"voice_1234\" }`. Voice cannot be changed\nduring the session once the model has responded with audio at least once.\nWe recommend `marin` and `cedar` for best quality.\n" + }) + ), + "speed": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The speed of the model's spoken response as a multiple of the original speed.\n1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.\n\nThis parameter is a post-processing adjustment to the audio after it is generated, it's\nalso possible to prompt the model to speak faster or slower.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0.25).annotate({ "expected": "a value greater than or equal to 0.25" }) + ).check(Schema.isLessThanOrEqualTo(1.5).annotate({ "expected": "a value less than or equal to 1.5" })) + ) + })) + }).annotate({ "description": "Configuration for input and output audio.\n" }) ), - "additional_instructions": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ + "include": Schema.optionalKey( + Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ "description": - "Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions." + "Additional fields to include in server outputs.\n\n`item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" }) ), - "additional_messages": Schema.optionalKey(Schema.Union([ - Schema.Array(Schema.Struct({ - "role": Schema.Literals(["user", "assistant"]).annotate({ - "description": - "The role of the entity that is creating the message. Allowed values include:\n- `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.\n- `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.\n" - }), - "content": Schema.Union([ - Schema.String.annotate({ "title": "Text content", "description": "The text contents of the message." }), - Schema.Array( - Schema.Union([MessageContentImageFileObject, MessageContentImageUrlObject, MessageRequestContentTextObject], { - mode: "oneOf" - }) - ).annotate({ - "title": "Array of content parts", - "description": - "An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models)." - }).check(Schema.isMinLength(1)) - ], { mode: "oneOf" }), - "attachments": Schema.optionalKey(Schema.Union([ - Schema.Array(Schema.Struct({ - "file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The ID of the file to attach to the message." }) + "tracing": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.Literal("auto").annotate({ + "title": "auto", + "description": "Enables tracing and sets default values for tracing configuration options. Always `auto`.\n" + }), + Schema.Struct({ + "workflow_name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The name of the workflow to attach to this trace. This is used to\nname the trace in the Traces Dashboard.\n" + }) + ), + "group_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The group id to attach to this trace to enable filtering and\ngrouping in the Traces Dashboard.\n" + }) ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Union([AssistantToolsCode, AssistantToolsFileSearchTypeOnly], { mode: "oneOf" })) - .annotate({ "description": "The tools to add this file to." }) + "metadata": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": + "The arbitrary metadata to attach to this trace to enable\nfiltering in the Traces Dashboard.\n" + }) ) - })).annotate({ - "description": "A list of files attached to the message, and the tools they should be added to." - }), - Schema.Null - ])), - "metadata": Schema.optionalKey(Metadata) - })).annotate({ "description": "Adds additional messages to the thread before creating the run." }) - ])), - "tools": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) - ).check( - Schema.isMaxLength(20, { - "description": - "Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis." - }) - ) - ]) - ), - "metadata": Schema.optionalKey(Metadata), - "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(2)], { - "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.\n" - }) - ) + }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) + ], { mode: "oneOf" }).annotate({ + "title": "Tracing Configuration", + "description": + "Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" + }), + Schema.Null ]) ), - "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(1)], { - "description": - "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or temperature but not both.\n" - }) - ) - ]) + "tools": Schema.optionalKey( + Schema.Array(Schema.Union([RealtimeFunctionTool, MCPTool], { mode: "oneOf" })).annotate({ + "description": "Tools available to the model." + }) ), - "stream": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "tool_choice": Schema.optionalKey( + Schema.Union([ToolChoiceOptions, ToolChoiceFunction, ToolChoiceMCP], { mode: "oneOf" }).annotate({ "description": - "If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.\n" + "How the model chooses tools. Provide one of the string modes or force a specific\nfunction/MCP tool.\n" }) ), - "max_prompt_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(256)], { - "description": - "The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.\n" - }) - ) - ]) - ), - "max_completion_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(256)], { - "description": - "The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.\n" - }) - ) - ]) - ), - "truncation_strategy": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "type": Schema.Literals(["auto", "last_messages"]).annotate({ - "description": - "The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`." - }), - "last_messages": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "The number of most recent messages from the thread when constructing the context for the run." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - Schema.Null - ]) - ) - }).annotate({ - "title": "Thread Truncation Controls", + "parallel_tool_calls": Schema.optionalKey( + Schema.Boolean.annotate({ "description": - "Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run." + "Whether the model may call multiple tools in parallel. Only supported by\nreasoning Realtime models such as `gpt-realtime-2`.\n" }) - ])), - "tool_choice": Schema.optionalKey( - Schema.Union([ - Schema.Union([Schema.Literal("none"), Schema.Literal("auto"), Schema.Literal("required")]).annotate({ - "description": - "`none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.\n" - }), - Schema.Union([ - Schema.Struct({ - "type": Schema.Literals(["function", "code_interpreter", "file_search"]).annotate({ - "description": "The type of the tool. If type is `function`, the function name must be set" - }), - "function": Schema.optionalKey( - Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) }) - ) - }).annotate({ - "description": "Specifies a tool the model should use. Use to force the model to call a specific tool." - }) - ]) - ], { mode: "oneOf" }).annotate({ + ), + "reasoning": Schema.optionalKey(RealtimeReasoning), + "max_output_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Literal("inf")], { + mode: "oneOf" + }).annotate({ "description": - "Controls which (if any) tool is called by the model.\n`none` means the model will not call any tools and instead generates a message.\n`auto` is the default value and means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools before responding to the user.\nSpecifying a particular tool like `{\"type\": \"file_search\"}` or `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n" + "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" }) ), - "parallel_tool_calls": Schema.optionalKey(ParallelToolCalls), - "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) + "truncation": Schema.optionalKey(RealtimeTruncation), + "prompt": Schema.optionalKey(Prompt) +}).annotate({ + "title": "Realtime session configuration", + "description": "Realtime session object configuration.", + "identifier": "RealtimeSessionCreateRequestGA" }) -export type CreateThreadAndRunRequest = { - readonly "assistant_id": string - readonly "thread"?: CreateThreadRequest +export type RealtimeSessionCreateResponseGA = { + readonly "type": "realtime" + readonly "id": string + readonly "object": "realtime.session" + readonly "expires_at"?: number + readonly "output_modalities"?: ReadonlyArray<"text" | "audio"> readonly "model"?: | string - | "gpt-5" - | "gpt-5-mini" - | "gpt-5-nano" - | "gpt-5-2025-08-07" - | "gpt-5-mini-2025-08-07" - | "gpt-5-nano-2025-08-07" - | "gpt-4.1" - | "gpt-4.1-mini" - | "gpt-4.1-nano" - | "gpt-4.1-2025-04-14" - | "gpt-4.1-mini-2025-04-14" - | "gpt-4.1-nano-2025-04-14" - | "gpt-4o" - | "gpt-4o-2024-11-20" - | "gpt-4o-2024-08-06" - | "gpt-4o-2024-05-13" - | "gpt-4o-mini" - | "gpt-4o-mini-2024-07-18" - | "gpt-4.5-preview" - | "gpt-4.5-preview-2025-02-27" - | "gpt-4-turbo" - | "gpt-4-turbo-2024-04-09" - | "gpt-4-0125-preview" - | "gpt-4-turbo-preview" - | "gpt-4-1106-preview" - | "gpt-4-vision-preview" - | "gpt-4" - | "gpt-4-0314" - | "gpt-4-0613" - | "gpt-4-32k" - | "gpt-4-32k-0314" - | "gpt-4-32k-0613" - | "gpt-3.5-turbo" - | "gpt-3.5-turbo-16k" - | "gpt-3.5-turbo-0613" - | "gpt-3.5-turbo-1106" - | "gpt-3.5-turbo-0125" - | "gpt-3.5-turbo-16k-0613" - | null - readonly "instructions"?: string | null - readonly "tools"?: ReadonlyArray - readonly "tool_resources"?: { - readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } - readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } - } - readonly "metadata"?: Metadata - readonly "temperature"?: number - readonly "top_p"?: number - readonly "stream"?: boolean | null - readonly "max_prompt_tokens"?: number - readonly "max_completion_tokens"?: number - readonly "truncation_strategy"?: { - readonly "type": "auto" | "last_messages" - readonly "last_messages"?: number | null - } - readonly "tool_choice"?: "none" | "auto" | "required" | { - readonly "type": "function" | "code_interpreter" | "file_search" - readonly "function"?: { readonly "name": string } + | "gpt-realtime" + | "gpt-realtime-1.5" + | "gpt-realtime-2" + | "gpt-realtime-2.1" + | "gpt-realtime-2.1-mini" + | "gpt-realtime-2025-08-28" + | "gpt-4o-realtime-preview" + | "gpt-4o-realtime-preview-2024-10-01" + | "gpt-4o-realtime-preview-2024-12-17" + | "gpt-4o-realtime-preview-2025-06-03" + | "gpt-4o-mini-realtime-preview" + | "gpt-4o-mini-realtime-preview-2024-12-17" + | "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" + readonly "instructions"?: string + readonly "audio"?: { + readonly "input"?: { + readonly "format"?: RealtimeAudioFormats + readonly "transcription"?: AudioTranscriptionResponse + readonly "noise_reduction"?: { readonly "type"?: NoiseReductionType } + readonly "turn_detection"?: RealtimeTurnDetection + } + readonly "output"?: { + readonly "format"?: RealtimeAudioFormats + readonly "voice"?: VoiceIdsShared + readonly "speed"?: number + } } - readonly "parallel_tool_calls"?: ParallelToolCalls - readonly "response_format"?: AssistantsApiResponseFormatOption | null + readonly "include"?: ReadonlyArray<"item.input_audio_transcription.logprobs"> + readonly "tracing"?: "auto" | { + readonly "workflow_name"?: string + readonly "group_id"?: string + readonly "metadata"?: {} + } | null + readonly "tools"?: ReadonlyArray + readonly "tool_choice"?: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMCP + readonly "reasoning"?: RealtimeReasoning + readonly "max_output_tokens"?: number | "inf" + readonly "truncation"?: RealtimeTruncation + readonly "prompt"?: Prompt } -export const CreateThreadAndRunRequest = Schema.Struct({ - "assistant_id": Schema.String.annotate({ - "description": "The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run." +export const RealtimeSessionCreateResponseGA = Schema.Struct({ + "type": Schema.Literal("realtime").annotate({ + "description": "The type of session to create. Always `realtime` for the Realtime API.\n" }), - "thread": Schema.optionalKey(CreateThreadRequest), - "model": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.String, - Schema.Literals([ - "gpt-5", - "gpt-5-mini", - "gpt-5-nano", - "gpt-5-2025-08-07", - "gpt-5-mini-2025-08-07", - "gpt-5-nano-2025-08-07", - "gpt-4.1", - "gpt-4.1-mini", - "gpt-4.1-nano", - "gpt-4.1-2025-04-14", - "gpt-4.1-mini-2025-04-14", - "gpt-4.1-nano-2025-04-14", - "gpt-4o", - "gpt-4o-2024-11-20", - "gpt-4o-2024-08-06", - "gpt-4o-2024-05-13", - "gpt-4o-mini", - "gpt-4o-mini-2024-07-18", - "gpt-4.5-preview", - "gpt-4.5-preview-2025-02-27", - "gpt-4-turbo", - "gpt-4-turbo-2024-04-09", - "gpt-4-0125-preview", - "gpt-4-turbo-preview", - "gpt-4-1106-preview", - "gpt-4-vision-preview", - "gpt-4", - "gpt-4-0314", - "gpt-4-0613", - "gpt-4-32k", - "gpt-4-32k-0314", - "gpt-4-32k-0613", - "gpt-3.5-turbo", - "gpt-3.5-turbo-16k", - "gpt-3.5-turbo-0613", - "gpt-3.5-turbo-1106", - "gpt-3.5-turbo-0125", - "gpt-3.5-turbo-16k-0613" - ]) - ]).annotate({ - "description": - "The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used." - }), - Schema.Null - ]) + "id": Schema.String.annotate({ + "description": "Unique identifier for the session that looks like `sess_1234567890abcdef`.\n" + }), + "object": Schema.Literal("realtime.session").annotate({ + "description": "The object type. Always `realtime.session`." + }), + "expires_at": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Expiration timestamp for the session, in seconds since epoch.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "instructions": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ + "output_modalities": Schema.optionalKey( + Schema.Array(Schema.Literals(["text", "audio"])).annotate({ "description": - "Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis." + "The set of modalities the model can respond with. It defaults to `[\"audio\"]`, indicating\nthat the model will respond with audio plus a transcript. `[\"text\"]` can be used to make\nthe model respond with text only. It is not possible to request both `text` and `audio` at the same time.\n" }) ), - "tools": Schema.optionalKey( + "model": Schema.optionalKey( Schema.Union([ - Schema.Array( - Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) - ).check( - Schema.isMaxLength(20, { - "description": - "Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis." - }) - ) - ]) + Schema.String, + Schema.Literals([ + "gpt-realtime", + "gpt-realtime-1.5", + "gpt-realtime-2", + "gpt-realtime-2.1", + "gpt-realtime-2.1-mini", + "gpt-realtime-2025-08-28", + "gpt-4o-realtime-preview", + "gpt-4o-realtime-preview-2024-10-01", + "gpt-4o-realtime-preview-2024-12-17", + "gpt-4o-realtime-preview-2025-06-03", + "gpt-4o-mini-realtime-preview", + "gpt-4o-mini-realtime-preview-2024-12-17", + "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" + ]) + ]).annotate({ "description": "The Realtime model used for this session.\n" }) ), - "tool_resources": Schema.optionalKey(Schema.Union([ + "instructions": Schema.optionalKey(Schema.String.annotate({ + "description": + "The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.\n\nNote that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.\n" + })), + "audio": Schema.optionalKey( Schema.Struct({ - "code_interpreter": Schema.optionalKey(Schema.Struct({ - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ + "input": Schema.optionalKey(Schema.Struct({ + "format": Schema.optionalKey( + Schema.suspend((): Schema.Codec => RealtimeAudioFormats).annotate({ + "description": "The format of the input audio." + }) + ), + "transcription": Schema.optionalKey( + Schema.suspend((): Schema.Codec => AudioTranscriptionResponse).annotate({ "description": - "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" - }).check(Schema.isMaxLength(20)) - ) + "Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.\n" + }) + ), + "noise_reduction": Schema.optionalKey( + Schema.Struct({ "type": Schema.optionalKey(NoiseReductionType) }).annotate({ + "description": + "Configuration for input audio noise reduction. This can be set to `null` to turn off.\nNoise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.\nFiltering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.\n" + }) + ), + "turn_detection": Schema.optionalKey(RealtimeTurnDetection) })), - "file_search": Schema.optionalKey(Schema.Struct({ - "vector_store_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ + "output": Schema.optionalKey(Schema.Struct({ + "format": Schema.optionalKey( + Schema.suspend((): Schema.Codec => RealtimeAudioFormats).annotate({ + "description": "The format of the output audio." + }) + ), + "voice": Schema.optionalKey( + Schema.suspend((): Schema.Codec => VoiceIdsShared).annotate({ "description": - "The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" - }).check(Schema.isMaxLength(1)) + "The voice the model uses to respond. Voice cannot be changed during the\nsession once the model has responded with audio at least once. Current\nvoice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,\n`shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for\nbest quality.\n" + }) + ), + "speed": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The speed of the model's spoken response as a multiple of the original speed.\n1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.\n\nThis parameter is a post-processing adjustment to the audio after it is generated, it's\nalso possible to prompt the model to speak faster or slower.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0.25).annotate({ "expected": "a value greater than or equal to 0.25" }) + ).check(Schema.isLessThanOrEqualTo(1.5).annotate({ "expected": "a value less than or equal to 1.5" })) ) })) - }).annotate({ - "description": - "A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" - }) - ])), - "metadata": Schema.optionalKey(Metadata), - "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(2)], { - "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.\n" - }) - ) - ]) - ), - "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(1)], { - "description": - "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or temperature but not both.\n" - }) - ) - ]) + }).annotate({ "description": "Configuration for input and output audio.\n" }) ), - "stream": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "include": Schema.optionalKey( + Schema.Array(Schema.Literal("item.input_audio_transcription.logprobs")).annotate({ "description": - "If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.\n" + "Additional fields to include in server outputs.\n\n`item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.\n" }) ), - "max_prompt_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(256)], { - "description": - "The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.\n" - }) - ) - ]) - ), - "max_completion_tokens": Schema.optionalKey( + "tracing": Schema.optionalKey( Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(256)], { - "description": - "The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.\n" - }) - ) - ]) - ), - "truncation_strategy": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "type": Schema.Literals(["auto", "last_messages"]).annotate({ + Schema.Union([ + Schema.Literal("auto").annotate({ + "title": "auto", + "description": "Enables tracing and sets default values for tracing configuration options. Always `auto`.\n" + }), + Schema.Struct({ + "workflow_name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The name of the workflow to attach to this trace. This is used to\nname the trace in the Traces Dashboard.\n" + }) + ), + "group_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The group id to attach to this trace to enable filtering and\ngrouping in the Traces Dashboard.\n" + }) + ), + "metadata": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": + "The arbitrary metadata to attach to this trace to enable\nfiltering in the Traces Dashboard.\n" + }) + ) + }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) + ], { mode: "oneOf" }).annotate({ + "title": "Tracing Configuration", "description": - "The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`." + "Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" }), - "last_messages": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "The number of most recent messages from the thread when constructing the context for the run." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - Schema.Null - ]) - ) - }).annotate({ - "title": "Thread Truncation Controls", - "description": - "Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run." + Schema.Null + ]) + ), + "tools": Schema.optionalKey( + Schema.Array(Schema.Union([RealtimeFunctionTool, MCPTool], { mode: "oneOf" })).annotate({ + "description": "Tools available to the model." }) - ])), + ), "tool_choice": Schema.optionalKey( - Schema.Union([ - Schema.Union([Schema.Literal("none"), Schema.Literal("auto"), Schema.Literal("required")]).annotate({ - "description": - "`none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.\n" - }), - Schema.Union([ - Schema.Struct({ - "type": Schema.Literals(["function", "code_interpreter", "file_search"]).annotate({ - "description": "The type of the tool. If type is `function`, the function name must be set" - }), - "function": Schema.optionalKey( - Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) }) - ) - }).annotate({ - "description": "Specifies a tool the model should use. Use to force the model to call a specific tool." - }) - ]) - ], { mode: "oneOf" }).annotate({ + Schema.Union([ToolChoiceOptions, ToolChoiceFunction, ToolChoiceMCP], { mode: "oneOf" }).annotate({ "description": - "Controls which (if any) tool is called by the model.\n`none` means the model will not call any tools and instead generates a message.\n`auto` is the default value and means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools before responding to the user.\nSpecifying a particular tool like `{\"type\": \"file_search\"}` or `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n" + "How the model chooses tools. Provide one of the string modes or force a specific\nfunction/MCP tool.\n" }) ), - "parallel_tool_calls": Schema.optionalKey(ParallelToolCalls), - "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) -}) -export type ModifyAssistantRequest = { - readonly "model"?: string | AssistantSupportedModels - readonly "reasoning_effort"?: ReasoningEffort - readonly "name"?: string | null - readonly "description"?: string | null - readonly "instructions"?: string | null - readonly "tools"?: ReadonlyArray - readonly "tool_resources"?: { - readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } - readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } - } | null - readonly "metadata"?: Metadata - readonly "temperature"?: number | null - readonly "top_p"?: number | null - readonly "response_format"?: AssistantsApiResponseFormatOption | null + "reasoning": Schema.optionalKey(RealtimeReasoning), + "max_output_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Literal("inf")], { + mode: "oneOf" + }).annotate({ + "description": + "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" + }) + ), + "truncation": Schema.optionalKey(RealtimeTruncation), + "prompt": Schema.optionalKey(Prompt) +}).annotate({ + "title": "Realtime session configuration object", + "description": "A Realtime session configuration object.\n", + "identifier": "RealtimeSessionCreateResponseGA" +}) +export type RealtimeSessionCreateRequest = { + readonly "client_secret": { readonly "value": string; readonly "expires_at": number } + readonly "modalities"?: ReadonlyArray<"text" | "audio"> + readonly "instructions"?: string + readonly "voice"?: VoiceIdsOrCustomVoice + readonly "input_audio_format"?: string + readonly "output_audio_format"?: string + readonly "input_audio_transcription"?: { readonly "model"?: string } + readonly "speed"?: number + readonly "tracing"?: "auto" | { + readonly "workflow_name"?: string + readonly "group_id"?: string + readonly "metadata"?: {} + } + readonly "turn_detection"?: { + readonly "type"?: string + readonly "threshold"?: number + readonly "prefix_padding_ms"?: number + readonly "silence_duration_ms"?: number + } + readonly "tools"?: ReadonlyArray< + { + readonly "type"?: "function" + readonly "name"?: string + readonly "description"?: string + readonly "parameters"?: {} + } + > + readonly "tool_choice"?: string + readonly "temperature"?: number + readonly "max_response_output_tokens"?: number | "inf" + readonly "truncation"?: RealtimeTruncation + readonly "prompt"?: Prompt } -export const ModifyAssistantRequest = Schema.Struct({ - "model": Schema.optionalKey( - Schema.Union([Schema.String, AssistantSupportedModels]).annotate({ +export const RealtimeSessionCreateRequest = Schema.Struct({ + "client_secret": Schema.Struct({ + "value": Schema.String.annotate({ "description": - "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" + "Ephemeral key usable in client environments to authenticate connections\nto the Realtime API. Use this in client-side environments rather than\na standard API token, which should only be used server-side.\n" + }), + "expires_at": Schema.Number.annotate({ + "description": "Timestamp for when the token expires. Currently, all tokens expire\nafter one minute.\n", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + }).annotate({ "description": "Ephemeral key returned by the API." }), + "modalities": Schema.optionalKey( + Schema.Array(Schema.Literals(["text", "audio"])).annotate({ + "description": "The set of modalities the model can respond with. To disable audio,\nset this to [\"text\"].\n" }) ), - "reasoning_effort": Schema.optionalKey(ReasoningEffort), - "name": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The name of the assistant. The maximum length is 256 characters.\n" }) - .check(Schema.isMaxLength(256)), - Schema.Null - ]) + "instructions": Schema.optionalKey(Schema.String.annotate({ + "description": + "The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.\nNote that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.\n" + })), + "voice": Schema.optionalKey( + Schema.suspend((): Schema.Codec => VoiceIdsOrCustomVoice).annotate({ + "description": + "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,\n`marin`, and `cedar`. You may also provide a custom voice object with an\n`id`, for example `{ \"id\": \"voice_1234\" }`. Voice cannot be changed during\nthe session once the model has responded with audio at least once.\n" + }) ), - "description": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "The description of the assistant. The maximum length is 512 characters.\n" - }).check(Schema.isMaxLength(512)), - Schema.Null - ]) + "input_audio_format": Schema.optionalKey( + Schema.String.annotate({ + "description": "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n" + }) ), - "instructions": Schema.optionalKey( + "output_audio_format": Schema.optionalKey( + Schema.String.annotate({ + "description": "The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n" + }) + ), + "input_audio_transcription": Schema.optionalKey( + Schema.Struct({ + "model": Schema.optionalKey(Schema.String.annotate({ "description": "The model to use for transcription.\n" })) + }).annotate({ + "description": + "Configuration for input audio transcription, defaults to off and can be\nset to `null` to turn off once on. Input audio transcription is not native\nto the model, since the model consumes audio directly. Transcription runs\nasynchronously and should be treated as rough guidance\nrather than the representation understood by the model.\n" + }) + ), + "speed": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The speed of the model's spoken response. 1.0 is the default speed. 0.25 is\nthe minimum speed. 1.5 is the maximum speed. This value can only be changed\nin between model turns, not while a response is in progress.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0.25).annotate({ "expected": "a value greater than or equal to 0.25" }) + ).check(Schema.isLessThanOrEqualTo(1.5).annotate({ "expected": "a value less than or equal to 1.5" })) + ), + "tracing": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ - "description": "The system instructions that the assistant uses. The maximum length is 256,000 characters.\n" - }).check(Schema.isMaxLength(256000)), - Schema.Null - ]) + Schema.Literal("auto").annotate({ "description": "Default tracing mode for the session.\n" }), + Schema.Struct({ + "workflow_name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The name of the workflow to attach to this trace. This is used to\nname the trace in the traces dashboard.\n" + }) + ), + "group_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The group id to attach to this trace to enable filtering and\ngrouping in the traces dashboard.\n" + }) + ), + "metadata": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": + "The arbitrary metadata to attach to this trace to enable\nfiltering in the traces dashboard.\n" + }) + ) + }).annotate({ "title": "Tracing Configuration", "description": "Granular configuration for tracing.\n" }) + ], { mode: "oneOf" }).annotate({ + "title": "Tracing Configuration", + "description": + "Configuration options for tracing. Set to null to disable tracing. Once\ntracing is enabled for a session, the configuration cannot be modified.\n\n`auto` will create a trace for the session with default values for the\nworkflow name, group id, and metadata.\n" + }) + ), + "turn_detection": Schema.optionalKey( + Schema.Struct({ + "type": Schema.optionalKey( + Schema.String.annotate({ "description": "Type of turn detection, only `server_vad` is currently supported.\n" }) + ), + "threshold": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A\nhigher threshold will require louder audio to activate the model, and\nthus might perform better in noisy environments.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "prefix_padding_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Amount of audio to include before the VAD detected speech (in\nmilliseconds). Defaults to 300ms.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "silence_duration_ms": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Duration of silence to detect speech stop (in milliseconds). Defaults\nto 500ms. With shorter values the model will respond more quickly,\nbut may jump in on short pauses from the user.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).annotate({ + "description": + "Configuration for turn detection. Can be set to `null` to turn off. Server\nVAD means that the model will detect the start and end of speech based on\naudio volume and respond at the end of user speech.\n" + }) ), "tools": Schema.optionalKey( - Schema.Array( - Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) - ).annotate({ + Schema.Array(Schema.Struct({ + "type": Schema.optionalKey( + Schema.Literal("function").annotate({ "description": "The type of the tool, i.e. `function`." }) + ), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function." })), + "description": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The description of the function, including guidance on when and how\nto call it, and guidance about what to tell the user when calling\n(if anything).\n" + }) + ), + "parameters": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Parameters of the function in JSON Schema." }) + ) + })).annotate({ "description": "Tools (functions) available to the model." }) + ), + "tool_choice": Schema.optionalKey( + Schema.String.annotate({ + "description": "How the model chooses tools. Options are `auto`, `none`, `required`, or\nspecify a function.\n" + }) + ), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "max_response_output_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Literal("inf")], { + mode: "oneOf" + }).annotate({ "description": - "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.\n" - }).check(Schema.isMaxLength(128)) + "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n" + }) + ), + "truncation": Schema.optionalKey(RealtimeTruncation), + "prompt": Schema.optionalKey(Prompt) +}).annotate({ + "description": "A new Realtime session configuration, with an ephemeral key. Default TTL\nfor keys is one minute.\n", + "identifier": "RealtimeSessionCreateRequest" +}) +export type CreateThreadRequest = { + readonly "messages"?: ReadonlyArray + readonly "tool_resources"?: { + readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } + readonly "file_search"?: { + readonly "vector_store_ids": ReadonlyArray + readonly "vector_stores"?: ReadonlyArray< + { + readonly "file_ids"?: ReadonlyArray + readonly "chunking_strategy"?: { readonly "type": "auto" } | { + readonly "type": "static" + readonly "static": { readonly "max_chunk_size_tokens": number; readonly "chunk_overlap_tokens": number } + } + readonly "metadata"?: Metadata + } + > + } | { + readonly "vector_stores": ReadonlyArray< + { + readonly "file_ids"?: ReadonlyArray + readonly "chunking_strategy"?: { readonly "type": "auto" } | { + readonly "type": "static" + readonly "static": { readonly "max_chunk_size_tokens": number; readonly "chunk_overlap_tokens": number } + } + readonly "metadata"?: Metadata + } + > + readonly "vector_store_ids"?: ReadonlyArray + } + } | null + readonly "metadata"?: Metadata +} +export const CreateThreadRequest = Schema.Struct({ + "messages": Schema.optionalKey( + Schema.Array(CreateMessageRequest).annotate({ + "description": "A list of [messages](/docs/api-reference/messages) to start the thread with." + }) ), "tool_resources": Schema.optionalKey(Schema.Union([ Schema.Struct({ @@ -21318,4536 +21941,9032 @@ export const ModifyAssistantRequest = Schema.Struct({ "file_ids": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": - "Overrides the list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" - }).check(Schema.isMaxLength(20)) + "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) ) })), - "file_search": Schema.optionalKey(Schema.Struct({ - "vector_store_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "Overrides the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" - }).check(Schema.isMaxLength(1)) - ) - })) + "file_search": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "vector_store_ids": Schema.Array(Schema.String).annotate({ + "description": + "The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })), + "vector_stores": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.\n" + }).check( + Schema.isMaxLength(100000000).annotate({ "expected": "a value with a length of at most 100000000" }) + ) + ), + "chunking_strategy": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }) + .annotate({ + "title": "Auto Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." + }), + Schema.Struct({ + "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), + "static": Schema.Struct({ + "max_chunk_size_tokens": Schema.Number.annotate({ + "description": + "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(100).annotate({ + "expected": "a value greater than or equal to 100" + }) + ).check( + Schema.isLessThanOrEqualTo(4096).annotate({ "expected": "a value less than or equal to 4096" }) + ), + "chunk_overlap_tokens": Schema.Number.annotate({ + "description": + "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + }) + }).annotate({ + "title": "Static Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." + }) + ], { mode: "oneOf" }) + ), + "metadata": Schema.optionalKey(Metadata) + })).annotate({ + "description": + "A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })) + ) + }), + Schema.Struct({ + "vector_stores": Schema.Array(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.\n" + }).check( + Schema.isMaxLength(100000000).annotate({ "expected": "a value with a length of at most 100000000" }) + ) + ), + "chunking_strategy": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }) + .annotate({ + "title": "Auto Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." + }), + Schema.Struct({ + "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), + "static": Schema.Struct({ + "max_chunk_size_tokens": Schema.Number.annotate({ + "description": + "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(100).annotate({ + "expected": "a value greater than or equal to 100" + }) + ).check( + Schema.isLessThanOrEqualTo(4096).annotate({ "expected": "a value less than or equal to 4096" }) + ), + "chunk_overlap_tokens": Schema.Number.annotate({ + "description": + "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + }) + }).annotate({ + "title": "Static Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." + }) + ], { mode: "oneOf" }) + ), + "metadata": Schema.optionalKey(Metadata) + })).annotate({ + "description": + "A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })), + "vector_store_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })) + ) + }) + ], { mode: "oneOf" })) }).annotate({ "description": - "A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" + "A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" }), Schema.Null ])), - "metadata": Schema.optionalKey(Metadata), - "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.\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, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are 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 - ])), - "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) + "metadata": Schema.optionalKey(Metadata) +}).annotate({ + "description": + "Options to create a new thread. If no thread is provided when running a\nrequest, an empty thread will be created.\n", + "identifier": "CreateThreadRequest" }) -export type RunObject = { +export type MessageObject = { readonly "id": string - readonly "object": "thread.run" + readonly "object": "thread.message" readonly "created_at": number readonly "thread_id": string - readonly "assistant_id": string - readonly "status": - | "queued" - | "in_progress" - | "requires_action" - | "cancelling" - | "cancelled" - | "failed" - | "completed" - | "incomplete" - | "expired" - readonly "required_action": { - readonly "type": "submit_tool_outputs" - readonly "submit_tool_outputs": { readonly "tool_calls": ReadonlyArray } - } - readonly "last_error": { - readonly "code": "server_error" | "rate_limit_exceeded" | "invalid_prompt" - readonly "message": string - } - readonly "expires_at": never - readonly "started_at": never - readonly "cancelled_at": never - readonly "failed_at": never - readonly "completed_at": never - readonly "incomplete_details": { readonly "reason"?: "max_completion_tokens" | "max_prompt_tokens" } - readonly "model": string - readonly "instructions": string - readonly "tools": ReadonlyArray + readonly "status": "in_progress" | "incomplete" | "completed" + readonly "incomplete_details": { + readonly "reason": "content_filter" | "max_tokens" | "run_cancelled" | "run_expired" | "run_failed" + } | null + readonly "completed_at": number | null + readonly "incomplete_at": number | null + readonly "role": "user" | "assistant" + readonly "content": ReadonlyArray< + | MessageContentImageFileObject + | MessageContentImageUrlObject + | MessageContentTextObject + | MessageContentRefusalObject + > + readonly "assistant_id": string | null + readonly "run_id": string | null + readonly "attachments": + | ReadonlyArray< + { + readonly "file_id"?: string + readonly "tools"?: ReadonlyArray + } + > + | null readonly "metadata": Metadata - readonly "usage": RunCompletionUsage - readonly "temperature"?: number | null - readonly "top_p"?: number | null - readonly "max_prompt_tokens": number - readonly "max_completion_tokens": number - readonly "truncation_strategy": { - readonly "type": "auto" | "last_messages" - readonly "last_messages"?: number | null - } - readonly "tool_choice": "none" | "auto" | "required" | { - readonly "type": "function" | "code_interpreter" | "file_search" - readonly "function"?: { readonly "name": string } - } - readonly "parallel_tool_calls": ParallelToolCalls - readonly "response_format": AssistantsApiResponseFormatOption | null } -export const RunObject = Schema.Struct({ +export const MessageObject = Schema.Struct({ "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), - "object": Schema.Literal("thread.run").annotate({ "description": "The object type, which is always `thread.run`." }), + "object": Schema.Literal("thread.message").annotate({ + "description": "The object type, which is always `thread.message`." + }), "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the run was created.", + "description": "The Unix timestamp (in seconds) for when the message was created.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "thread_id": Schema.String.annotate({ - "description": "The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run." - }), - "assistant_id": Schema.String.annotate({ - "description": "The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run." + "description": "The [thread](/docs/api-reference/threads) ID that this message belongs to." }), - "status": Schema.Literals([ - "queued", - "in_progress", - "requires_action", - "cancelling", - "cancelled", - "failed", - "completed", - "incomplete", - "expired" - ]).annotate({ - "description": - "The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`." + "status": Schema.Literals(["in_progress", "incomplete", "completed"]).annotate({ + "description": "The status of the message, which can be either `in_progress`, `incomplete`, or `completed`." }), - "required_action": Schema.Union([ + "incomplete_details": Schema.Union([ Schema.Struct({ - "type": Schema.Literal("submit_tool_outputs").annotate({ - "description": "For now, this is always `submit_tool_outputs`." - }), - "submit_tool_outputs": Schema.Struct({ - "tool_calls": Schema.Array(RunToolCallObject).annotate({ "description": "A list of the relevant tool calls." }) - }).annotate({ "description": "Details on the tool outputs needed for this run to continue." }) - }).annotate({ - "description": "Details on the action required to continue the run. Will be `null` if no action is required." - }) + "reason": Schema.Literals(["content_filter", "max_tokens", "run_cancelled", "run_expired", "run_failed"]) + .annotate({ "description": "The reason the message is incomplete." }) + }).annotate({ "description": "On an incomplete message, details about why the message is incomplete." }), + Schema.Null ]), - "last_error": Schema.Union([ - Schema.Struct({ - "code": Schema.Literals(["server_error", "rate_limit_exceeded", "invalid_prompt"]).annotate({ - "description": "One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`." - }), - "message": Schema.String.annotate({ "description": "A human-readable description of the error." }) - }).annotate({ "description": "The last error associated with this run. Will be `null` if there are no errors." }) + "completed_at": Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the message was completed.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null ]), - "expires_at": Schema.Never, - "started_at": Schema.Never, - "cancelled_at": Schema.Never, - "failed_at": Schema.Never, - "completed_at": Schema.Never, - "incomplete_details": Schema.Union([ - Schema.Struct({ - "reason": Schema.optionalKey( - Schema.Literals(["max_completion_tokens", "max_prompt_tokens"]).annotate({ - "description": - "The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run." - }) - ) - }).annotate({ "description": "Details on why the run is incomplete. Will be `null` if the run is not incomplete." }) + "incomplete_at": Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the message was marked as incomplete.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null ]), - "model": Schema.String.annotate({ - "description": "The model that the [assistant](/docs/api-reference/assistants) used for this run." - }), - "instructions": Schema.String.annotate({ - "description": "The instructions that the [assistant](/docs/api-reference/assistants) used for this run." + "role": Schema.Literals(["user", "assistant"]).annotate({ + "description": "The entity that produced the message. One of `user` or `assistant`." }), - "tools": Schema.Array( - Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) - ).annotate({ - "description": "The list of tools that the [assistant](/docs/api-reference/assistants) used for this run." - }).check(Schema.isMaxLength(20)), - "metadata": Metadata, - "usage": RunCompletionUsage, - "temperature": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null]).annotate({ - "description": "The sampling temperature used for this run. If not set, defaults to 1." - }) - ), - "top_p": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite()), Schema.Null]).annotate({ - "description": "The nucleus sampling value used for this run. If not set, defaults to 1." - }) - ), - "max_prompt_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(256)], { - "description": "The maximum number of prompt tokens specified to have been used over the course of the run.\n" - }) - ) - ]), - "max_completion_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(256)], { - "description": - "The maximum number of completion tokens specified to have been used over the course of the run.\n" - }) - ) - ]), - "truncation_strategy": Schema.Union([ - Schema.Struct({ - "type": Schema.Literals(["auto", "last_messages"]).annotate({ - "description": - "The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`." - }), - "last_messages": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "The number of most recent messages from the thread when constructing the context for the run." - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - Schema.Null - ]) - ) - }).annotate({ - "title": "Thread Truncation Controls", + "content": Schema.Array( + Schema.Union([ + MessageContentImageFileObject, + MessageContentImageUrlObject, + MessageContentTextObject, + MessageContentRefusalObject + ], { mode: "oneOf" }) + ).annotate({ "description": "The content of the message in array of text and/or images." }), + "assistant_id": Schema.Union([ + Schema.String.annotate({ "description": - "Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run." - }) + "If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message." + }), + Schema.Null ]), - "tool_choice": Schema.Union([ - Schema.Union([Schema.Literal("none"), Schema.Literal("auto"), Schema.Literal("required")]).annotate({ + "run_id": Schema.Union([ + Schema.String.annotate({ "description": - "`none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.\n" + "The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints." }), - Schema.Union([ - Schema.Struct({ - "type": Schema.Literals(["function", "code_interpreter", "file_search"]).annotate({ - "description": "The type of the tool. If type is `function`, the function name must be set" - }), - "function": Schema.optionalKey( - Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) }) - ) - }).annotate({ - "description": "Specifies a tool the model should use. Use to force the model to call a specific tool." - }) - ]) - ], { mode: "oneOf" }).annotate({ - "description": - "Controls which (if any) tool is called by the model.\n`none` means the model will not call any tools and instead generates a message.\n`auto` is the default value and means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools before responding to the user.\nSpecifying a particular tool like `{\"type\": \"file_search\"}` or `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n" - }), - "parallel_tool_calls": ParallelToolCalls, - "response_format": Schema.Union([AssistantsApiResponseFormatOption, Schema.Null]) -}).annotate({ - "title": "A run on a thread", - "description": "Represents an execution run on a [thread](/docs/api-reference/threads)." -}) -export type ResponseTextParam = { - readonly "format"?: TextResponseFormatConfiguration - readonly "verbosity"?: Verbosity -} -export const ResponseTextParam = Schema.Struct({ - "format": Schema.optionalKey(TextResponseFormatConfiguration), - "verbosity": Schema.optionalKey(Verbosity) -}).annotate({ - "description": - "Configuration options for a text response from the model. Can be plain\ntext or structured JSON data. Learn more:\n- [Text inputs and outputs](/docs/guides/text)\n- [Structured Outputs](/docs/guides/structured-outputs)\n" -}) -export type RealtimeCreateClientSecretRequest = { - readonly "expires_after"?: { readonly "anchor"?: "created_at"; readonly "seconds"?: number } - readonly "session"?: RealtimeSessionCreateRequestGA | RealtimeTranscriptionSessionCreateRequestGA -} -export const RealtimeCreateClientSecretRequest = Schema.Struct({ - "expires_after": Schema.optionalKey( - Schema.Struct({ - "anchor": Schema.optionalKey( - Schema.Literal("created_at").annotate({ - "description": - "The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.\n" - }) + Schema.Null + ]), + "attachments": Schema.Union([ + Schema.Array(Schema.Struct({ + "file_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the file to attach to the message." }) ), - "seconds": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.\n", - "format": "int64" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(10)).check(Schema.isLessThanOrEqualTo(7200)) + "tools": Schema.optionalKey( + Schema.Array(Schema.Union([AssistantToolsCode, AssistantToolsFileSearchTypeOnly], { mode: "oneOf" })).annotate({ + "description": "The tools to add this file to." + }) ) - }).annotate({ - "title": "Client secret expiration", - "description": - "Configuration for the client secret expiration. Expiration refers to the time after which\na client secret will no longer be valid for creating sessions. The session itself may\ncontinue after that time once started. A secret can be used to create multiple sessions\nuntil it expires.\n" - }) - ), - "session": Schema.optionalKey( - Schema.Union([RealtimeSessionCreateRequestGA, RealtimeTranscriptionSessionCreateRequestGA], { mode: "oneOf" }) - .annotate({ - "title": "Session configuration", - "description": - "Session configuration to use for the client secret. Choose either a realtime\nsession or a transcription session.\n" - }) - ) -}).annotate({ - "title": "Realtime client secret creation request", - "description": - "Create a session and client secret for the Realtime API. The request can specify\neither a realtime or a transcription session configuration.\n[Learn more about the Realtime API](/docs/guides/realtime).\n" -}) -export type RealtimeCreateClientSecretResponse = { - readonly "value": string - readonly "expires_at": number - readonly "session": RealtimeSessionCreateResponseGA | RealtimeTranscriptionSessionCreateResponseGA -} -export const RealtimeCreateClientSecretResponse = Schema.Struct({ - "value": Schema.String.annotate({ "description": "The generated client secret value." }), - "expires_at": Schema.Number.annotate({ - "description": "Expiration timestamp for the client secret, in seconds since epoch.", - "format": "unixtime" - }).check(Schema.isInt()), - "session": Schema.Union([RealtimeSessionCreateResponseGA, RealtimeTranscriptionSessionCreateResponseGA], { - mode: "oneOf" - }).annotate({ - "title": "Session configuration", - "description": "The session configuration for either a realtime or transcription session.\n" - }) -}).annotate({ - "title": "Realtime session and client secret", - "description": "Response from creating a session and client secret for the Realtime API.\n" -}) -export type RealtimeServerEventSessionCreated = { - readonly "event_id": string - readonly "type": "session.created" - readonly "session": RealtimeSessionCreateResponseGA | RealtimeTranscriptionSessionCreateResponseGA -} -export const RealtimeServerEventSessionCreated = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("session.created").annotate({ "description": "The event type, must be `session.created`." }), - "session": Schema.Union([RealtimeSessionCreateResponseGA, RealtimeTranscriptionSessionCreateResponseGA], { - mode: "oneOf" - }).annotate({ "description": "The session configuration." }) + })).annotate({ "description": "A list of files attached to the message, and the tools they were added to." }), + Schema.Null + ]), + "metadata": Metadata }).annotate({ - "description": - "Returned when a Session is created. Emitted automatically when a new\nconnection is established as the first server event. This event will contain\nthe default Session configuration.\n" + "title": "The message object", + "description": "Represents a message within a [thread](/docs/api-reference/threads).", + "identifier": "MessageObject" }) -export type RealtimeServerEventSessionUpdated = { - readonly "event_id": string - readonly "type": "session.updated" - readonly "session": RealtimeSessionCreateResponseGA | RealtimeTranscriptionSessionCreateResponseGA +export type ListVectorStoresResponse = { + readonly "object": string + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean + readonly [x: string]: Schema.Json } -export const RealtimeServerEventSessionUpdated = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("session.updated").annotate({ "description": "The event type, must be `session.updated`." }), - "session": Schema.Union([RealtimeSessionCreateResponseGA, RealtimeTranscriptionSessionCreateResponseGA], { - mode: "oneOf" - }).annotate({ "description": "The session configuration." }) -}).annotate({ - "description": "Returned when a session is updated with a `session.update` event, unless\nthere is an error.\n" -}) -export type CreateVectorStoreFileBatchRequest = { - readonly "file_ids": ReadonlyArray - readonly "files"?: ReadonlyArray - readonly "chunking_strategy"?: ChunkingStrategyRequestParam - readonly "attributes"?: VectorStoreFileAttributes -} | { - readonly "files": ReadonlyArray - readonly "file_ids"?: ReadonlyArray +export const ListVectorStoresResponse = Schema.StructWithRest( + Schema.Struct({ + "object": Schema.String, + "data": Schema.Array(VectorStoreObject), + "first_id": Schema.String, + "last_id": Schema.String, + "has_more": Schema.Boolean + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ "identifier": "ListVectorStoresResponse" }) +export type CreateVectorStoreFileRequest = { + readonly "file_id": string readonly "chunking_strategy"?: ChunkingStrategyRequestParam readonly "attributes"?: VectorStoreFileAttributes } -export const CreateVectorStoreFileBatchRequest = Schema.Union([ - Schema.Struct({ - "file_ids": Schema.Array(Schema.String).annotate({ - "description": - "A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. If `attributes` or `chunking_strategy` are provided, they will be applied to all files in the batch. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `files`." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(2000)), - "files": Schema.optionalKey( - Schema.Array(CreateVectorStoreFileRequest).annotate({ - "description": - "A list of objects that each include a `file_id` plus optional `attributes` or `chunking_strategy`. Use this when you need to override metadata for specific files. The global `attributes` or `chunking_strategy` will be ignored and must be specified for each file. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `file_ids`." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(2000)) - ), - "chunking_strategy": Schema.optionalKey(ChunkingStrategyRequestParam), - "attributes": Schema.optionalKey(VectorStoreFileAttributes) +export const CreateVectorStoreFileRequest = Schema.Struct({ + "file_id": Schema.String.annotate({ + "description": + "A [File](/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files. For multi-file ingestion, we recommend [`file_batches`](/docs/api-reference/vector-stores-file-batches/createBatch) to minimize per-vector-store write requests." }), + "chunking_strategy": Schema.optionalKey(ChunkingStrategyRequestParam), + "attributes": Schema.optionalKey(VectorStoreFileAttributes) +}).annotate({ "identifier": "CreateVectorStoreFileRequest" }) +export type ListVectorStoreFilesResponse = { + readonly "object": string + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean + readonly [x: string]: Schema.Json +} +export const ListVectorStoreFilesResponse = Schema.StructWithRest( Schema.Struct({ - "files": Schema.Array(CreateVectorStoreFileRequest).annotate({ - "description": - "A list of objects that each include a `file_id` plus optional `attributes` or `chunking_strategy`. Use this when you need to override metadata for specific files. The global `attributes` or `chunking_strategy` will be ignored and must be specified for each file. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `file_ids`." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(2000)), - "file_ids": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. If `attributes` or `chunking_strategy` are provided, they will be applied to all files in the batch. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `files`." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(2000)) - ), - "chunking_strategy": Schema.optionalKey(ChunkingStrategyRequestParam), - "attributes": Schema.optionalKey(VectorStoreFileAttributes) - }) -]) -export type CodeInterpreterTool = { - readonly "type": "code_interpreter" - readonly "container": string | AutoCodeInterpreterToolParam + "object": Schema.String, + "data": Schema.Array(VectorStoreFileObject), + "first_id": Schema.String, + "last_id": Schema.String, + "has_more": Schema.Boolean + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ "identifier": "ListVectorStoreFilesResponse" }) +export type VectorStoreSearchResultsPage = { + readonly "object": "vector_store.search_results.page" + readonly "search_query": ReadonlyArray + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "next_page": string | null } -export const CodeInterpreterTool = Schema.Struct({ - "type": Schema.Literal("code_interpreter").annotate({ - "description": "The type of the code interpreter tool. Always `code_interpreter`.\n" +export const VectorStoreSearchResultsPage = Schema.Struct({ + "object": Schema.Literal("vector_store.search_results.page").annotate({ + "description": "The object type, which is always `vector_store.search_results.page`" }), - "container": Schema.Union([ - Schema.String.annotate({ "description": "The container ID." }), - AutoCodeInterpreterToolParam - ], { mode: "oneOf" }).annotate({ - "description": - "The code interpreter container. Can be a container ID or an object that\nspecifies uploaded file IDs to make available to your code, along with an\noptional `memory_limit` setting.\n" + "search_query": Schema.Array(Schema.String.annotate({ "description": "The query used for this search." })), + "data": Schema.Array(VectorStoreSearchResultItem).annotate({ "description": "The list of search result items." }), + "has_more": Schema.Boolean.annotate({ "description": "Indicates if there are more results to fetch." }), + "next_page": Schema.Union([ + Schema.String.annotate({ "description": "The token for the next page, if any." }), + Schema.Null + ]) +}).annotate({ "identifier": "VectorStoreSearchResultsPage" }) +export type OrganizationSpendLimitResource = { + readonly "object": "organization.spend_limit" + readonly "threshold_amount": number + readonly "currency": SpendLimitCurrency + readonly "interval": SpendLimitInterval + readonly "enforcement": SpendLimitEnforcement +} +export const OrganizationSpendLimitResource = Schema.Struct({ + "object": Schema.Literal("organization.spend_limit").annotate({ + "description": "The object type, which is always `organization.spend_limit`." + }), + "threshold_amount": Schema.Number.annotate({ "description": "The hard spend limit amount, in cents." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "currency": Schema.suspend((): Schema.Codec => SpendLimitCurrency).annotate({ + "description": "The currency for the threshold amount. Currently, only `USD` is supported." + }), + "interval": Schema.suspend((): Schema.Codec => SpendLimitInterval).annotate({ + "description": "The time interval for evaluating spend against the threshold. Currently, only `month` is supported." + }), + "enforcement": Schema.suspend((): Schema.Codec => SpendLimitEnforcement).annotate({ + "description": "The current enforcement state of the hard spend limit." }) }).annotate({ - "title": "Code interpreter", - "description": "A tool that runs Python code to help generate a response to a prompt.\n" + "description": "Represents a hard spend limit configured at the organization level.", + "identifier": "OrganizationSpendLimitResource" }) -export type FunctionShellToolParam = { - readonly "type": "shell" - readonly "environment"?: ContainerAutoParam | LocalEnvironmentParam | ContainerReferenceParam | null +export type ProjectSpendLimitResource = { + readonly "object": "project.spend_limit" + readonly "threshold_amount": number + readonly "currency": SpendLimitCurrency + readonly "interval": SpendLimitInterval + readonly "enforcement": SpendLimitEnforcement } -export const FunctionShellToolParam = Schema.Struct({ - "type": Schema.Literal("shell").annotate({ "description": "The type of the shell tool. Always `shell`." }), - "environment": Schema.optionalKey( - Schema.Union([ - Schema.Union([ContainerAutoParam, LocalEnvironmentParam, ContainerReferenceParam], { mode: "oneOf" }), - Schema.Null - ]) - ) -}).annotate({ "title": "Shell tool", "description": "A tool that allows the model to execute shell commands." }) -export type EvalItemContent = EvalItemContentItem | EvalItemContentArray -export const EvalItemContent = Schema.Union([EvalItemContentItem, EvalItemContentArray], { mode: "oneOf" }).annotate({ - "title": "Eval content", - "description": - "Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.\n" -}) -export type OutputMessageContent = OutputTextContent | RefusalContent -export const OutputMessageContent = Schema.Union([OutputTextContent, RefusalContent], { mode: "oneOf" }) -export type ResponseContentPartAddedEvent = { - readonly "type": "response.content_part.added" - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "part": OutputTextContent | RefusalContent | ReasoningTextContent - readonly "sequence_number": number -} -export const ResponseContentPartAddedEvent = Schema.Struct({ - "type": Schema.Literal("response.content_part.added").annotate({ - "description": "The type of the event. Always `response.content_part.added`.\n" +export const ProjectSpendLimitResource = Schema.Struct({ + "object": Schema.Literal("project.spend_limit").annotate({ + "description": "The object type, which is always `project.spend_limit`." }), - "item_id": Schema.String.annotate({ - "description": "The ID of the output item that the content part was added to.\n" - }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item that the content part was added to.\n" - }).check(Schema.isInt()), - "content_index": Schema.Number.annotate({ "description": "The index of the content part that was added.\n" }).check( - Schema.isInt() + "threshold_amount": Schema.Number.annotate({ "description": "The hard spend limit amount, in cents." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "part": Schema.Union([OutputTextContent, RefusalContent, ReasoningTextContent], { mode: "oneOf" }).annotate({ - "description": "The content part that was added.\n" + "currency": Schema.suspend((): Schema.Codec => SpendLimitCurrency).annotate({ + "description": "The currency for the threshold amount. Currently, only `USD` is supported." }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ) -}).annotate({ "description": "Emitted when a new content part is added." }) -export type ResponseContentPartDoneEvent = { - readonly "type": "response.content_part.done" - readonly "item_id": string - readonly "output_index": number - readonly "content_index": number - readonly "sequence_number": number - readonly "part": OutputTextContent | RefusalContent | ReasoningTextContent -} -export const ResponseContentPartDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.content_part.done").annotate({ - "description": "The type of the event. Always `response.content_part.done`.\n" + "interval": Schema.suspend((): Schema.Codec => SpendLimitInterval).annotate({ + "description": "The time interval for evaluating spend against the threshold. Currently, only `month` is supported." }), - "item_id": Schema.String.annotate({ - "description": "The ID of the output item that the content part was added to.\n" + "enforcement": Schema.suspend((): Schema.Codec => SpendLimitEnforcement).annotate({ + "description": "The current enforcement state of the hard spend limit." + }) +}).annotate({ + "description": "Represents a hard spend limit configured at the project level.", + "identifier": "ProjectSpendLimitResource" +}) +export type ProvenanceResource = { + readonly "object": ProvenanceCheckObject + readonly "created_at": number + readonly "results": ReadonlyArray +} +export const ProvenanceResource = Schema.Struct({ + "object": Schema.suspend((): Schema.Codec => ProvenanceCheckObject).annotate({ + "description": "The object type. Always `content_provenance_check` for this endpoint." }), - "output_index": Schema.Number.annotate({ - "description": "The index of the output item that the content part was added to.\n" - }).check(Schema.isInt()), - "content_index": Schema.Number.annotate({ "description": "The index of the content part that is done.\n" }).check( - Schema.isInt() - ), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ), - "part": Schema.Union([OutputTextContent, RefusalContent, ReasoningTextContent], { mode: "oneOf" }).annotate({ - "description": "The content part that is done.\n" + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp, in seconds, when the provenance check was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "results": Schema.Array(Schema.Union([C2PAProvenanceResult, SynthIDProvenanceResult], { mode: "oneOf" })).annotate({ + "description": + "The provenance results that apply to the uploaded file. Image results include C2PA and SynthID; audio results include SynthID." }) -}).annotate({ "description": "Emitted when a content part is done." }) -export type Message = { - readonly "type": "message" +}).annotate({ "identifier": "ProvenanceResource" }) +export type VideoListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "last_id": string | null + readonly "has_more": boolean +} +export const VideoListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), + "data": Schema.Array(VideoResource).annotate({ "description": "A list of items" }), + "first_id": Schema.Union([ + Schema.String.annotate({ "description": "The ID of the first item in the list." }), + Schema.Null + ]), + "last_id": Schema.Union([ + Schema.String.annotate({ "description": "The ID of the last item in the list." }), + Schema.Null + ]), + "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }) +}).annotate({ "identifier": "VideoListResource" }) +export type ChatSessionResource = { readonly "id": string - readonly "status": "in_progress" | "completed" | "incomplete" - readonly "role": "unknown" | "user" | "assistant" | "system" | "critic" | "discriminator" | "developer" | "tool" - readonly "content": ReadonlyArray< - | InputTextContent - | OutputTextContent - | TextContent - | SummaryTextContent - | ReasoningTextContent - | RefusalContent - | InputImageContent - | ComputerScreenshotContent - | InputFileContent - > - readonly "phase"?: "commentary" | "final_answer" | null + readonly "object": "chatkit.session" + readonly "expires_at": number + readonly "client_secret": string + readonly "workflow": ChatkitWorkflow + readonly "user": string + readonly "rate_limits": ChatSessionRateLimits + readonly "max_requests_per_1_minute": number + readonly "status": ChatSessionStatus + readonly "chatkit_configuration": ChatSessionChatkitConfiguration } -export const Message = Schema.Struct({ - "type": Schema.Literal("message").annotate({ "description": "The type of the message. Always set to `message`." }), - "id": Schema.String.annotate({ "description": "The unique ID of the message." }), - "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": - "The status of item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API." +export const ChatSessionResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier for the ChatKit session." }), + "object": Schema.Literal("chatkit.session").annotate({ + "description": "Type discriminator that is always `chatkit.session`." }), - "role": Schema.Literals(["unknown", "user", "assistant", "system", "critic", "discriminator", "developer", "tool"]) - .annotate({ - "description": - "The role of the message. One of `unknown`, `user`, `assistant`, `system`, `critic`, `discriminator`, `developer`, or `tool`." - }), - "content": Schema.Array( - Schema.Union([ - InputTextContent, - OutputTextContent, - TextContent, - SummaryTextContent, - ReasoningTextContent, - RefusalContent, - InputImageContent, - ComputerScreenshotContent, - InputFileContent - ], { mode: "oneOf" }).annotate({ "description": "A content part that makes up an input or output item." }) - ).annotate({ "description": "The content of the message" }), - "phase": Schema.optionalKey(Schema.Union([ - Schema.Literals(["commentary", "final_answer"]).annotate({ - "description": - "Labels an `assistant` message as intermediate commentary (`commentary`) or the final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when sending follow-up requests, preserve and resend phase on all assistant messages — dropping it can degrade performance. Not used for user messages." - }), - Schema.Null - ])) -}).annotate({ "title": "Message", "description": "A message to or from the model." }) -export type EasyInputMessage = { - readonly "role": "user" | "assistant" | "system" | "developer" - readonly "content": string | InputMessageContentList - readonly "phase"?: MessagePhase | null - readonly "type"?: "message" + "expires_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) for when the session expires.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "client_secret": Schema.String.annotate({ + "description": "Ephemeral client secret that authenticates session requests." + }), + "workflow": Schema.suspend((): Schema.Codec => ChatkitWorkflow).annotate({ + "description": "Workflow metadata for the session." + }), + "user": Schema.String.annotate({ "description": "User identifier associated with the session." }), + "rate_limits": Schema.suspend((): Schema.Codec => ChatSessionRateLimits).annotate({ + "description": "Resolved rate limit values." + }), + "max_requests_per_1_minute": Schema.Number.annotate({ + "description": "Convenience copy of the per-minute request limit." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "status": Schema.suspend((): Schema.Codec => ChatSessionStatus).annotate({ + "description": "Current lifecycle state of the session." + }), + "chatkit_configuration": Schema.suspend((): Schema.Codec => + ChatSessionChatkitConfiguration + ).annotate({ "description": "Resolved ChatKit feature configuration for the session." }) +}).annotate({ + "title": "The chat session object", + "description": "Represents a ChatKit session and its resolved configuration.", + "identifier": "ChatSessionResource" +}) +export type CreateChatSessionBody = { + readonly "workflow": WorkflowParam + readonly "user": string + readonly "expires_after"?: ExpiresAfterParam + readonly "rate_limits"?: RateLimitsParam + readonly "chatkit_configuration"?: ChatkitConfigurationParam } -export const EasyInputMessage = Schema.Struct({ - "role": Schema.Literals(["user", "assistant", "system", "developer"]).annotate({ - "description": "The role of the message input. One of `user`, `assistant`, `system`, or\n`developer`.\n" +export const CreateChatSessionBody = Schema.Struct({ + "workflow": Schema.suspend((): Schema.Codec => WorkflowParam).annotate({ + "description": "Workflow that powers the session." }), - "content": Schema.Union([ - Schema.String.annotate({ "title": "Text input", "description": "A text input to the model.\n" }), - InputMessageContentList - ], { mode: "oneOf" }).annotate({ + "user": Schema.String.annotate({ "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" }) + "A free-form string that identifies your end user; ensures this Session can access other objects that have the same `user` scope." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "expires_after": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ExpiresAfterParam).annotate({ + "description": "Optional override for session expiration timing in seconds from creation. Defaults to 10 minutes." + }) + ), + "rate_limits": Schema.optionalKey( + Schema.suspend((): Schema.Codec => RateLimitsParam).annotate({ + "description": "Optional override for per-minute request limits. When omitted, defaults to 10." + }) + ), + "chatkit_configuration": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ChatkitConfigurationParam).annotate({ + "description": "Optional overrides for ChatKit runtime configuration features" + }) ) }).annotate({ - "title": "Input message", - "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. Messages with the\n`assistant` role are presumed to have been generated by the model in previous\ninteractions.\n" + "title": "Create chat session request", + "description": "Parameters for provisioning a new ChatKit session.", + "identifier": "CreateChatSessionBody" }) -export type InputMessageResource = { - readonly "type": "message" - readonly "role": "user" | "system" | "developer" - readonly "status"?: "in_progress" | "completed" | "incomplete" - readonly "content": InputMessageContentList +export type UserMessageItem = { readonly "id": string + readonly "object": "chatkit.thread_item" + readonly "created_at": number + readonly "thread_id": string + readonly "type": "chatkit.user_message" + readonly "content": ReadonlyArray + readonly "attachments": ReadonlyArray + readonly "inference_options": InferenceOptions | null } -export const InputMessageResource = Schema.Struct({ - "type": Schema.Literal("message").annotate({ - "description": "The type of the message input. Always set to `message`.\n" - }), - "role": Schema.Literals(["user", "system", "developer"]).annotate({ - "description": "The role of the message input. One of `user`, `system`, or `developer`.\n" +export const UserMessageItem = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), + "object": Schema.Literal("chatkit.thread_item").annotate({ + "description": "Type discriminator that is always `chatkit.thread_item`." }), - "status": Schema.optionalKey( - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": - "The status of item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) for when the item was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), + "type": Schema.Literal("chatkit.user_message"), + "content": Schema.Array( + Schema.Union([UserMessageInputText, UserMessageQuotedText], { mode: "oneOf" }).annotate({ + "description": "Content blocks that comprise a user message." }) - ), - "content": InputMessageContentList, - "id": Schema.String.annotate({ "description": "The unique ID of the message input.\n" }) + ).annotate({ "description": "Ordered content elements supplied by the user." }), + "attachments": Schema.Array(Attachment).annotate({ + "description": "Attachments associated with the user message. Defaults to an empty list." + }), + "inference_options": Schema.Union([ + Schema.suspend((): Schema.Codec => InferenceOptions).annotate({ + "description": "Inference overrides applied to the message. Defaults to null when unset." + }), + Schema.Null + ]) }).annotate({ - "title": "Input message", - "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" + "title": "User Message Item", + "description": "User-authored messages within a thread.", + "identifier": "UserMessageItem" }) -export type ComputerActionList = ReadonlyArray -export const ComputerActionList = Schema.Array(ComputerAction).annotate({ - "title": "Computer Action List", - "description": - "Flattened batched actions for `computer_use`. Each action includes an\n`type` discriminator and action-specific fields.\n" +export type ResponseOutputText = { + readonly "type": "output_text" + readonly "text": string + readonly "annotations": ReadonlyArray +} +export const ResponseOutputText = Schema.Struct({ + "type": Schema.Literal("output_text").annotate({ "description": "Type discriminator that is always `output_text`." }), + "text": Schema.String.annotate({ "description": "Assistant generated text." }), + "annotations": Schema.Array( + Schema.Union([FileAnnotation, UrlAnnotation], { mode: "oneOf" }).annotate({ + "description": "Annotation object describing a cited source." + }) + ).annotate({ "description": "Ordered list of annotations attached to the response text." }) +}).annotate({ + "title": "Assistant message content", + "description": "Assistant response text accompanied by optional annotations.", + "identifier": "ResponseOutputText" }) -export type ThreadItem = - | UserMessageItem - | AssistantMessageItem - | WidgetMessageItem - | ClientToolCallItem - | TaskItem - | TaskGroupItem -export const ThreadItem = Schema.Union([ - UserMessageItem, - AssistantMessageItem, - WidgetMessageItem, - ClientToolCallItem, - TaskItem, - TaskGroupItem -], { mode: "oneOf" }).annotate({ "title": "The thread item" }) -export type ListAuditLogsResponse = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id"?: string | null - readonly "last_id"?: string | null - readonly "has_more": boolean +export type TaskGroupItem = { + readonly "id": string + readonly "object": "chatkit.thread_item" + readonly "created_at": number + readonly "thread_id": string + readonly "type": "chatkit.task_group" + readonly "tasks": ReadonlyArray } -export const ListAuditLogsResponse = Schema.Struct({ - "object": Schema.Literal("list"), - "data": Schema.Array(AuditLog), - "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "has_more": Schema.Boolean +export const TaskGroupItem = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), + "object": Schema.Literal("chatkit.thread_item").annotate({ + "description": "Type discriminator that is always `chatkit.thread_item`." + }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) for when the item was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), + "type": Schema.Literal("chatkit.task_group").annotate({ + "description": "Type discriminator that is always `chatkit.task_group`." + }), + "tasks": Schema.Array(TaskGroupTask).annotate({ "description": "Tasks included in the group." }) +}).annotate({ + "title": "Task group", + "description": "Collection of workflow tasks grouped together in the thread.", + "identifier": "TaskGroupItem" }) -export type ChatCompletionList = { +export type ThreadListResource = { readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "last_id": string | null readonly "has_more": boolean } -export const ChatCompletionList = Schema.Struct({ - "object": Schema.Literal("list").annotate({ - "description": "The type of this object. It is always set to \"list\".\n" - }), - "data": Schema.Array(CreateChatCompletionResponse).annotate({ - "description": "An array of chat completion objects.\n" - }), - "first_id": Schema.String.annotate({ - "description": "The identifier of the first chat completion in the data array." - }), - "last_id": Schema.String.annotate({ "description": "The identifier of the last chat completion in the data array." }), - "has_more": Schema.Boolean.annotate({ "description": "Indicates whether there are more Chat Completions available." }) -}).annotate({ "title": "ChatCompletionList", "description": "An object representing a list of Chat Completions.\n" }) -export type CreateChatCompletionRequest = { - readonly "metadata"?: Metadata - readonly "top_logprobs"?: number - readonly "temperature"?: number | null - readonly "top_p"?: number | null - readonly "user"?: string | null - readonly "safety_identifier"?: string - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "in_memory" | "24h" | null - readonly "messages": ReadonlyArray - readonly "model": - | string - | "gpt-5.4" - | "gpt-5.4-mini" - | "gpt-5.4-nano" - | "gpt-5.4-mini-2026-03-17" - | "gpt-5.4-nano-2026-03-17" - | "gpt-5.3-chat-latest" - | "gpt-5.2" - | "gpt-5.2-2025-12-11" - | "gpt-5.2-chat-latest" - | "gpt-5.2-pro" - | "gpt-5.2-pro-2025-12-11" - | "gpt-5.1" - | "gpt-5.1-2025-11-13" - | "gpt-5.1-codex" - | "gpt-5.1-mini" - | "gpt-5.1-chat-latest" - | "gpt-5" - | "gpt-5-mini" - | "gpt-5-nano" - | "gpt-5-2025-08-07" - | "gpt-5-mini-2025-08-07" - | "gpt-5-nano-2025-08-07" - | "gpt-5-chat-latest" - | "gpt-4.1" - | "gpt-4.1-mini" - | "gpt-4.1-nano" - | "gpt-4.1-2025-04-14" - | "gpt-4.1-mini-2025-04-14" - | "gpt-4.1-nano-2025-04-14" - | "o4-mini" - | "o4-mini-2025-04-16" - | "o3" - | "o3-2025-04-16" - | "o3-mini" - | "o3-mini-2025-01-31" - | "o1" - | "o1-2024-12-17" - | "o1-preview" - | "o1-preview-2024-09-12" - | "o1-mini" - | "o1-mini-2024-09-12" - | "gpt-4o" - | "gpt-4o-2024-11-20" - | "gpt-4o-2024-08-06" - | "gpt-4o-2024-05-13" - | "gpt-4o-audio-preview" - | "gpt-4o-audio-preview-2024-10-01" - | "gpt-4o-audio-preview-2024-12-17" - | "gpt-4o-audio-preview-2025-06-03" - | "gpt-4o-mini-audio-preview" - | "gpt-4o-mini-audio-preview-2024-12-17" - | "gpt-4o-search-preview" - | "gpt-4o-mini-search-preview" - | "gpt-4o-search-preview-2025-03-11" - | "gpt-4o-mini-search-preview-2025-03-11" - | "chatgpt-4o-latest" - | "codex-mini-latest" - | "gpt-4o-mini" - | "gpt-4o-mini-2024-07-18" - | "gpt-4-turbo" - | "gpt-4-turbo-2024-04-09" - | "gpt-4-0125-preview" - | "gpt-4-turbo-preview" - | "gpt-4-1106-preview" - | "gpt-4-vision-preview" - | "gpt-4" - | "gpt-4-0314" - | "gpt-4-0613" - | "gpt-4-32k" - | "gpt-4-32k-0314" - | "gpt-4-32k-0613" - | "gpt-3.5-turbo" - | "gpt-3.5-turbo-16k" - | "gpt-3.5-turbo-0301" - | "gpt-3.5-turbo-0613" - | "gpt-3.5-turbo-1106" - | "gpt-3.5-turbo-0125" - | "gpt-3.5-turbo-16k-0613" - readonly "modalities"?: ResponseModalities - readonly "verbosity"?: Verbosity - readonly "reasoning_effort"?: ReasoningEffort - readonly "max_completion_tokens"?: number | null - readonly "frequency_penalty"?: number - readonly "presence_penalty"?: number - readonly "web_search_options"?: { - readonly "user_location"?: { readonly "type": "approximate"; readonly "approximate": WebSearchLocation } - readonly "search_context_size"?: WebSearchContextSize - } - readonly "response_format"?: ResponseFormatText | ResponseFormatJsonSchema | ResponseFormatJsonObject - readonly "audio"?: { - readonly "voice": VoiceIdsShared | { readonly "id": string } - readonly "format": "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16" - } - readonly "store"?: boolean | null - readonly "stream"?: boolean | null - readonly "stop"?: StopConfiguration - readonly "logit_bias"?: {} - readonly "logprobs"?: boolean | null - readonly "max_tokens"?: number | null - readonly "n"?: number - readonly "prediction"?: PredictionContent | null - readonly "seed"?: number - readonly "stream_options"?: ChatCompletionStreamOptions - readonly "tools"?: ReadonlyArray - readonly "tool_choice"?: ChatCompletionToolChoiceOption - readonly "parallel_tool_calls"?: ParallelToolCalls - readonly "function_call"?: "none" | "auto" | ChatCompletionFunctionCallOption - readonly "functions"?: ReadonlyArray +export const ThreadListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), + "data": Schema.Array(ThreadResource).annotate({ "description": "A list of items" }), + "first_id": Schema.Union([ + Schema.String.annotate({ "description": "The ID of the first item in the list." }), + Schema.Null + ]), + "last_id": Schema.Union([ + Schema.String.annotate({ "description": "The ID of the last item in the list." }), + Schema.Null + ]), + "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }) +}).annotate({ + "title": "Threads", + "description": "A paginated list of ChatKit threads.", + "identifier": "ThreadListResource" +}) +export type BetaModelIdsCompaction = BetaModelIdsResponses | string | null +export const BetaModelIdsCompaction = Schema.Union([BetaModelIdsResponses, Schema.String, Schema.Null]).annotate({ + "description": + "Model ID used to generate the response, like `gpt-5` 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.", + "identifier": "BetaModelIdsCompaction" +}) +export type BetaTextResponseFormatConfiguration = + | BetaResponseFormatText + | BetaTextResponseFormatJsonSchema + | BetaResponseFormatJsonObject +export const BetaTextResponseFormatConfiguration = Schema.Union([ + BetaResponseFormatText, + BetaTextResponseFormatJsonSchema, + BetaResponseFormatJsonObject +], { mode: "oneOf" }).annotate({ + "description": + "An object specifying the format that the model must output.\n\nConfiguring `{ \"type\": \"json_schema\" }` enables Structured Outputs, \nwhich ensures the model will match your supplied JSON schema. Learn more in the \n[Structured Outputs guide](/docs/guides/structured-outputs).\n\nThe default format is `{ \"type\": \"text\" }` with no additional options.\n\n**Not recommended for gpt-4o and newer models:**\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n", + "identifier": "BetaTextResponseFormatConfiguration" +}) +export type BetaFilters = BetaComparisonFilter | BetaCompoundFilter +export const BetaFilters = Schema.Union([BetaComparisonFilter, BetaCompoundFilter]).annotate({ + "identifier": "BetaFilters" +}) +export type BetaAutoCodeInterpreterToolParam = { + readonly "type": "auto" + readonly "file_ids"?: ReadonlyArray + readonly "memory_limit"?: BetaContainerMemoryLimit | null + readonly "network_policy"?: BetaContainerNetworkPolicyDisabledParam | BetaContainerNetworkPolicyAllowlistParam } -export const CreateChatCompletionRequest = Schema.Struct({ - "metadata": Schema.optionalKey(Metadata), - "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup( - [Schema.isFinite(), Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(20)], - { - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n`logprobs` must be set to `true` if this parameter is used.\n" - } - ) - ).check( - Schema.makeFilterGroup([ - Schema.isGreaterThanOrEqualTo(0), - Schema.isLessThanOrEqualTo(20), - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(20)], { - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }) - ], { - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }) - ) - ]) - ]) +export const BetaAutoCodeInterpreterToolParam = Schema.Struct({ + "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }), + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "An optional list of uploaded files to make available to your code." + }).check(Schema.isMaxLength(50).annotate({ "expected": "a value with a length of at most 50" })) ), - "temperature": Schema.optionalKey( + "memory_limit": 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.suspend((): Schema.Codec => BetaContainerMemoryLimit).annotate({ + "description": "The memory limit for the code interpreter container." + }), 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.check(Schema.isMaxLength(64, { - "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" - }) + "network_policy": Schema.optionalKey( + Schema.Union([BetaContainerNetworkPolicyDisabledParam, BetaContainerNetworkPolicyAllowlistParam], { mode: "oneOf" }) + .annotate({ "description": "Network access policy for the container." }) + ) +}).annotate({ + "title": "CodeInterpreterToolAuto", + "description": + "Configuration for a code interpreter container. Optionally specify the IDs of the files to run the code on.", + "identifier": "BetaAutoCodeInterpreterToolParam" +}) +export type BetaContainerAutoParam = { + readonly "type": "container_auto" + readonly "file_ids"?: ReadonlyArray + readonly "memory_limit"?: BetaContainerMemoryLimit | null + readonly "network_policy"?: BetaContainerNetworkPolicyDisabledParam | BetaContainerNetworkPolicyAllowlistParam + readonly "skills"?: ReadonlyArray +} +export const BetaContainerAutoParam = Schema.Struct({ + "type": Schema.Literal("container_auto").annotate({ + "description": "Automatically creates a container for this request" + }), + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "An optional list of uploaded files to make available to your code." + }).check(Schema.isMaxLength(50).annotate({ "expected": "a value with a length of at most 50" })) ), - "service_tier": Schema.optionalKey(ServiceTier), - "prompt_cache_retention": Schema.optionalKey( + "memory_limit": Schema.optionalKey( Schema.Union([ - Schema.Literals(["in_memory", "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.suspend((): Schema.Codec => BetaContainerMemoryLimit).annotate({ + "description": "The memory limit for the container." }), Schema.Null ]) ), - "messages": Schema.Array(ChatCompletionRequestMessage).annotate({ - "description": - "A list of messages comprising the conversation so far. Depending on the\n[model](/docs/models) you use, different message types (modalities) are\nsupported, like [text](/docs/guides/text-generation),\n[images](/docs/guides/vision), and [audio](/docs/guides/audio).\n" - }).check(Schema.isMinLength(1)), - "model": Schema.Union([ - Schema.String, - Schema.Literals([ - "gpt-5.4", - "gpt-5.4-mini", - "gpt-5.4-nano", - "gpt-5.4-mini-2026-03-17", - "gpt-5.4-nano-2026-03-17", - "gpt-5.3-chat-latest", - "gpt-5.2", - "gpt-5.2-2025-12-11", - "gpt-5.2-chat-latest", - "gpt-5.2-pro", - "gpt-5.2-pro-2025-12-11", - "gpt-5.1", - "gpt-5.1-2025-11-13", - "gpt-5.1-codex", - "gpt-5.1-mini", - "gpt-5.1-chat-latest", - "gpt-5", - "gpt-5-mini", - "gpt-5-nano", - "gpt-5-2025-08-07", - "gpt-5-mini-2025-08-07", - "gpt-5-nano-2025-08-07", - "gpt-5-chat-latest", - "gpt-4.1", - "gpt-4.1-mini", - "gpt-4.1-nano", - "gpt-4.1-2025-04-14", - "gpt-4.1-mini-2025-04-14", - "gpt-4.1-nano-2025-04-14", - "o4-mini", - "o4-mini-2025-04-16", - "o3", - "o3-2025-04-16", - "o3-mini", - "o3-mini-2025-01-31", - "o1", - "o1-2024-12-17", - "o1-preview", - "o1-preview-2024-09-12", - "o1-mini", - "o1-mini-2024-09-12", - "gpt-4o", - "gpt-4o-2024-11-20", - "gpt-4o-2024-08-06", - "gpt-4o-2024-05-13", - "gpt-4o-audio-preview", - "gpt-4o-audio-preview-2024-10-01", - "gpt-4o-audio-preview-2024-12-17", - "gpt-4o-audio-preview-2025-06-03", - "gpt-4o-mini-audio-preview", - "gpt-4o-mini-audio-preview-2024-12-17", - "gpt-4o-search-preview", - "gpt-4o-mini-search-preview", - "gpt-4o-search-preview-2025-03-11", - "gpt-4o-mini-search-preview-2025-03-11", - "chatgpt-4o-latest", - "codex-mini-latest", - "gpt-4o-mini", - "gpt-4o-mini-2024-07-18", - "gpt-4-turbo", - "gpt-4-turbo-2024-04-09", - "gpt-4-0125-preview", - "gpt-4-turbo-preview", - "gpt-4-1106-preview", - "gpt-4-vision-preview", - "gpt-4", - "gpt-4-0314", - "gpt-4-0613", - "gpt-4-32k", - "gpt-4-32k-0314", - "gpt-4-32k-0613", - "gpt-3.5-turbo", - "gpt-3.5-turbo-16k", - "gpt-3.5-turbo-0301", - "gpt-3.5-turbo-0613", - "gpt-3.5-turbo-1106", - "gpt-3.5-turbo-0125", - "gpt-3.5-turbo-16k-0613" - ]) - ]).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" - }), - "modalities": Schema.optionalKey(ResponseModalities), - "verbosity": Schema.optionalKey(Verbosity), - "reasoning_effort": Schema.optionalKey(ReasoningEffort), - "max_completion_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "description": - "An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning).\n" + "network_policy": Schema.optionalKey( + Schema.Union([BetaContainerNetworkPolicyDisabledParam, BetaContainerNetworkPolicyAllowlistParam], { mode: "oneOf" }) + .annotate({ "description": "Network access policy for the container." }) + ), + "skills": Schema.optionalKey( + Schema.Array(Schema.Union([BetaSkillReferenceParam, BetaInlineSkillParam], { mode: "oneOf" })).annotate({ + "description": "An optional list of skills referenced by id or inline data." + }).check(Schema.isMaxLength(200).annotate({ "expected": "a value with a length of at most 200" })) + ) +}).annotate({ "identifier": "BetaContainerAutoParam" }) +export type BetaCustomToolParam = { + readonly "type": "custom" + readonly "name": string + readonly "description"?: string + readonly "format"?: BetaCustomTextFormatParam | BetaCustomGrammarFormatParam + readonly "defer_loading"?: boolean + readonly "allowed_callers"?: ReadonlyArray | null +} +export const BetaCustomToolParam = 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([BetaCustomTextFormatParam, BetaCustomGrammarFormatParam], { mode: "oneOf" }).annotate({ + "description": "The input format for the custom tool. Default is unconstrained text." }) ), - "frequency_penalty": Schema.optionalKey( + "defer_loading": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this tool should be deferred and discovered via tool search." }) + ), + "allowed_callers": Schema.optionalKey( Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(-2), Schema.isLessThanOrEqualTo(2)], { - "description": - "Number between -2.0 and 2.0. Positive values penalize new tokens based on\ntheir existing frequency in the text so far, decreasing the model's\nlikelihood to repeat the same line verbatim.\n" - }) - ) - ]) - ), - "presence_penalty": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite()).check( - Schema.makeFilterGroup([Schema.isGreaterThanOrEqualTo(-2), Schema.isLessThanOrEqualTo(2)], { - "description": - "Number between -2.0 and 2.0. Positive values penalize new tokens based on\nwhether they appear in the text so far, increasing the model's likelihood\nto talk about new topics.\n" - }) - ) - ]) - ), - "web_search_options": Schema.optionalKey( - Schema.Struct({ - "user_location": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("approximate").annotate({ - "description": "The type of location approximation. Always `approximate`.\n" - }), - "approximate": WebSearchLocation - }).annotate({ "description": "Approximate location parameters for the search.\n" }) - ]) + Schema.Array(BetaCallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), - "search_context_size": Schema.optionalKey(WebSearchContextSize) - }).annotate({ - "title": "Web search", - "description": - "This tool searches the web for relevant results to use in a response.\nLearn more about the [web search tool](/docs/guides/tools-web-search?api-mode=chat).\n" - }) - ), - "response_format": Schema.optionalKey( - Schema.Union([ResponseFormatText, ResponseFormatJsonSchema, ResponseFormatJsonObject], { mode: "oneOf" }).annotate({ - "description": - "An object specifying the format that the model must output.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables\nStructured Outputs which ensures the model will match your supplied JSON\nschema. Learn more in the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n" - }) - ), - "audio": Schema.optionalKey(Schema.Union([ - Schema.Struct({ - "voice": Schema.Union([ - VoiceIdsShared, - Schema.Struct({ "id": Schema.String.annotate({ "description": "The custom voice ID, e.g. `voice_1234`." }) }) - .annotate({ "description": "Custom voice reference." }) - ]).annotate({ - "title": "Voice", - "description": - "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`,\n`sage`, `shimmer`, `marin`, and `cedar`. You may also provide a\ncustom voice object with an `id`, for example `{ \"id\": \"voice_1234\" }`.\n" - }), - "format": Schema.Literals(["wav", "aac", "mp3", "flac", "opus", "pcm16"]).annotate({ - "description": "Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`,\n`opus`, or `pcm16`.\n" - }) - }).annotate({ - "description": - "Parameters for audio output. Required when audio output is requested with\n`modalities: [\"audio\"]`. [Learn more](/docs/guides/audio).\n" - }) - ])), - "store": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether or not to store the output of this chat completion request for\nuse in our [model distillation](/docs/guides/distillation) or\n[evals](/docs/guides/evals) products.\n\nSupports text and image inputs. Note: image inputs over 8MB will be dropped.\n" - }) - ), - "stream": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).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/chat/streaming)\nfor more information, along with the [streaming responses](/docs/guides/streaming-responses)\nguide for more information on how to handle the streaming events.\n" - }) + Schema.Null + ]) + ) +}).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)", + "identifier": "BetaCustomToolParam" +}) +export type BetaInputContent = BetaInputTextContent | BetaInputImageContent | BetaInputFileContent +export const BetaInputContent = Schema.Union([BetaInputTextContent, BetaInputImageContent, BetaInputFileContent], { + mode: "oneOf" +}).annotate({ "identifier": "BetaInputContent" }) +export type BetaFunctionAndCustomToolCallOutput = BetaInputTextContent | BetaInputImageContent | BetaInputFileContent +export const BetaFunctionAndCustomToolCallOutput = Schema.Union([ + BetaInputTextContent, + BetaInputImageContent, + BetaInputFileContent +], { mode: "oneOf" }).annotate({ "identifier": "BetaFunctionAndCustomToolCallOutput" }) +export type BetaOutputTextContent = { + readonly "type": "output_text" + readonly "text": string + readonly "annotations": ReadonlyArray + readonly "logprobs": ReadonlyArray +} +export const BetaOutputTextContent = Schema.Struct({ + "type": Schema.Literal("output_text").annotate({ + "description": "The type of the output text. Always `output_text`." + }), + "text": Schema.String.annotate({ "description": "The text output from the model." }), + "annotations": Schema.Array(BetaAnnotation).annotate({ "description": "The annotations of the text output." }), + "logprobs": Schema.Array(BetaLogProb) +}).annotate({ + "title": "Output text", + "description": "A text output from the model.", + "identifier": "BetaOutputTextContent" +}) +export type BetaComputerAction = + | BetaClickParam + | BetaDoubleClickAction + | BetaDragParam + | BetaKeyPressAction + | BetaMoveParam + | BetaScreenshotParam + | BetaScrollParam + | BetaTypeParam + | BetaWaitParam +export const BetaComputerAction = Schema.Union([ + BetaClickParam, + BetaDoubleClickAction, + BetaDragParam, + BetaKeyPressAction, + BetaMoveParam, + BetaScreenshotParam, + BetaScrollParam, + BetaTypeParam, + BetaWaitParam +], { mode: "oneOf" }).annotate({ "identifier": "BetaComputerAction" }) +export type BetaFunctionToolCall = { + readonly "agent"?: BetaAgentTag | null + readonly "id"?: string + readonly "type": "function_call" + readonly "call_id": string + readonly "caller"?: BetaToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "arguments": string + readonly "status"?: "in_progress" | "completed" | "incomplete" +} +export const BetaFunctionToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) ), - "stop": Schema.optionalKey(StopConfiguration), - "logit_bias": Schema.optionalKey(Schema.Union([ - Schema.Struct({}).annotate({ - "description": - "Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a JSON object that maps tokens (specified by their token ID in the\ntokenizer) to an associated bias value from -100 to 100. Mathematically,\nthe bias is added to the logits generated by the model prior to sampling.\nThe exact effect will vary per model, but values between -1 and 1 should\ndecrease or increase likelihood of selection; values like -100 or 100\nshould result in a ban or exclusive selection of the relevant token.\n" - }) - ])), - "logprobs": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the function tool call.\n" })), + "type": Schema.Literal("function_call").annotate({ + "description": "The type of the function tool call. Always `function_call`.\n" + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" + }), + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCaller, Schema.Null])), + "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( + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ "description": - "Whether to return log probabilities of the output tokens or not. If true,\nreturns the log probabilities of each output token returned in the\n`content` of `message`.\n" + "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" }) - ), - "max_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt()), Schema.Null]).annotate({ - "description": - "The maximum number of [tokens](/tokenizer) that can be generated in the\nchat completion. This value can be used to control\n[costs](https://openai.com/api/pricing/) for text generated via API.\n\nThis value is now deprecated in favor of `max_completion_tokens`, and is\nnot compatible with [o-series models](/docs/guides/reasoning).\n" + ) +}).annotate({ + "title": "Function tool call", + "description": + "A tool call to run a function. See the \n[function calling guide](/docs/guides/function-calling) for more information.\n", + "identifier": "BetaFunctionToolCall" +}) +export type BetaFunctionShellCall = { + readonly "agent"?: BetaAgentTag + readonly "type": "shell_call" + readonly "id": string + readonly "call_id": string + readonly "caller"?: BetaToolCallCaller | null + readonly "action": BetaFunctionShellAction + readonly "status": BetaFunctionShellCallStatus + readonly "environment": BetaLocalEnvironmentResource | BetaContainerReferenceResource | null + readonly "created_by"?: string +} +export const BetaFunctionShellCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." }) ), - "n": Schema.optionalKey( + "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." }), + "caller": Schema.optionalKey( Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([Schema.isFinite(), Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(128)], { - "description": - "How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs." - }) - ) + Schema.suspend((): Schema.Codec => BetaToolCallCaller).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null ]) ), - "prediction": Schema.optionalKey(Schema.Union([ - Schema.Union([PredictionContent], { mode: "oneOf" }).annotate({ - "description": - "Configuration for a [Predicted Output](/docs/guides/predicted-outputs),\nwhich can greatly improve response times when large parts of the model\nresponse are known ahead of time. This is most common when you are\nregenerating a file with only minor changes to most of the content.\n" - }), + "action": Schema.suspend((): Schema.Codec => BetaFunctionShellAction).annotate({ + "description": "The shell commands and limits that describe how to run the tool call." + }), + "status": Schema.suspend((): Schema.Codec => BetaFunctionShellCallStatus).annotate({ + "description": "The status of the shell call. One of `in_progress`, `completed`, or `incomplete`." + }), + "environment": Schema.Union([ + Schema.Union([BetaLocalEnvironmentResource, BetaContainerReferenceResource], { mode: "oneOf" }), Schema.Null - ])), - "seed": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([ - Schema.isFinite(), - Schema.isGreaterThanOrEqualTo(-9223372036854776000), - Schema.isLessThanOrEqualTo(9223372036854776000) - ], { - "description": - "This feature is in Beta.\nIf specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.\nDeterminism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.\n" - }) - ) - ]) - ), - "stream_options": Schema.optionalKey(ChatCompletionStreamOptions), - "tools": Schema.optionalKey( - Schema.Array(Schema.Union([ChatCompletionTool, CustomToolChatCompletions], { mode: "oneOf" })).annotate({ - "description": - "A list of tools the model may call. You can provide either\n[custom tools](/docs/guides/function-calling#custom-tools) or\n[function tools](/docs/guides/function-calling).\n" + ]), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the entity that created this tool call." }) + ) +}).annotate({ + "title": "Shell tool call", + "description": "A tool call that executes one or more shell commands in a managed environment.", + "identifier": "BetaFunctionShellCall" +}) +export type BetaApplyPatchToolCall = { + readonly "agent"?: BetaAgentTag + readonly "type": "apply_patch_call" + readonly "id": string + readonly "call_id": string + readonly "caller"?: BetaToolCallCaller | null + readonly "status": BetaApplyPatchCallStatus + readonly "operation": + | BetaApplyPatchCreateFileOperation + | BetaApplyPatchDeleteFileOperation + | BetaApplyPatchUpdateFileOperation + readonly "created_by"?: string +} +export const BetaApplyPatchToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." }) ), - "tool_choice": Schema.optionalKey(ChatCompletionToolChoiceOption), - "parallel_tool_calls": Schema.optionalKey(ParallelToolCalls), - "function_call": Schema.optionalKey( + "type": Schema.Literal("apply_patch_call").annotate({ + "description": "The type of the item. Always `apply_patch_call`." + }), + "id": Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call. Populated when this item is returned via API." + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call generated by the model." + }), + "caller": Schema.optionalKey( Schema.Union([ - Schema.Literals(["none", "auto"]).annotate({ - "description": - "`none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.\n" + Schema.suspend((): Schema.Codec => BetaToolCallCaller).annotate({ + "description": "The execution context that produced this tool call." }), - ChatCompletionFunctionCallOption - ], { mode: "oneOf" }).annotate({ - "description": - "Deprecated in favor of `tool_choice`.\n\nControls which (if any) function is called by the model.\n\n`none` means the model will not call a function and instead generates a\nmessage.\n\n`auto` means the model can pick between generating a message or calling a\nfunction.\n\nSpecifying a particular function via `{\"name\": \"my_function\"}` forces the\nmodel to call that function.\n\n`none` is the default when no functions are present. `auto` is the default\nif functions are present.\n" - }) + Schema.Null + ]) ), - "functions": Schema.optionalKey( - Schema.Array(ChatCompletionFunctions).annotate({ - "description": "Deprecated in favor of `tools`.\n\nA list of functions the model may generate JSON inputs for.\n" - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(128)) + "status": Schema.suspend((): Schema.Codec => BetaApplyPatchCallStatus).annotate({ + "description": "The status of the apply patch tool call. One of `in_progress` or `completed`." + }), + "operation": Schema.Union([ + BetaApplyPatchCreateFileOperation, + BetaApplyPatchDeleteFileOperation, + BetaApplyPatchUpdateFileOperation + ], { mode: "oneOf" }).annotate({ + "title": "Apply patch operation", + "description": "One of the create_file, delete_file, or update_file operations applied via apply_patch." + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the entity that created this tool call." }) ) +}).annotate({ + "title": "Apply patch tool call", + "description": "A tool call that applies file diffs by creating, deleting, or updating files.", + "identifier": "BetaApplyPatchToolCall" }) -export type ListRunStepsResponse = { - readonly "object": string - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean - readonly [x: string]: unknown +export type BetaApplyPatchToolCallOutput = { + readonly "agent"?: BetaAgentTag + readonly "type": "apply_patch_call_output" + readonly "id": string + readonly "call_id": string + readonly "caller"?: BetaToolCallCaller | null + readonly "status": BetaApplyPatchCallOutputStatus + readonly "output"?: string | null + readonly "created_by"?: string } -export const ListRunStepsResponse = Schema.StructWithRest( - Schema.Struct({ - "object": Schema.String, - "data": Schema.Array(RunStepObject), - "first_id": Schema.String, - "last_id": Schema.String, - "has_more": Schema.Boolean - }), - [Schema.Record(Schema.String, Schema.Json)] -) -export type RunStepStreamEvent = - | { readonly "event": "thread.run.step.created"; readonly "data": RunStepObject } - | { readonly "event": "thread.run.step.in_progress"; readonly "data": RunStepObject } - | { readonly "event": "thread.run.step.delta"; readonly "data": RunStepDeltaObject } - | { readonly "event": "thread.run.step.completed"; readonly "data": RunStepObject } - | { readonly "event": "thread.run.step.failed"; readonly "data": RunStepObject } - | { readonly "event": "thread.run.step.cancelled"; readonly "data": RunStepObject } - | { readonly "event": "thread.run.step.expired"; readonly "data": RunStepObject } -export const RunStepStreamEvent = Schema.Union([ - Schema.Struct({ "event": Schema.Literal("thread.run.step.created"), "data": RunStepObject }).annotate({ - "description": "Occurs when a [run step](/docs/api-reference/run-steps/step-object) is created." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.step.in_progress"), "data": RunStepObject }).annotate({ - "description": - "Occurs when a [run step](/docs/api-reference/run-steps/step-object) moves to an `in_progress` state." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.step.delta"), "data": RunStepDeltaObject }).annotate({ - "description": "Occurs when parts of a [run step](/docs/api-reference/run-steps/step-object) are being streamed." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.step.completed"), "data": RunStepObject }).annotate({ - "description": "Occurs when a [run step](/docs/api-reference/run-steps/step-object) is completed." +export const BetaApplyPatchToolCallOutput = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." + }) + ), + "type": Schema.Literal("apply_patch_call_output").annotate({ + "description": "The type of the item. Always `apply_patch_call_output`." }), - Schema.Struct({ "event": Schema.Literal("thread.run.step.failed"), "data": RunStepObject }).annotate({ - "description": "Occurs when a [run step](/docs/api-reference/run-steps/step-object) fails." + "id": Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call output. Populated when this item is returned via API." }), - Schema.Struct({ "event": Schema.Literal("thread.run.step.cancelled"), "data": RunStepObject }).annotate({ - "description": "Occurs when a [run step](/docs/api-reference/run-steps/step-object) is cancelled." + "call_id": Schema.String.annotate({ + "description": "The unique ID of the apply patch tool call generated by the model." }), - Schema.Struct({ "event": Schema.Literal("thread.run.step.expired"), "data": RunStepObject }).annotate({ - "description": "Occurs when a [run step](/docs/api-reference/run-steps/step-object) expires." - }) -], { mode: "oneOf" }) -export type RealtimeServerEventResponseCreated = { - readonly "event_id": string - readonly "type": "response.created" - readonly "response": RealtimeResponse -} -export const RealtimeServerEventResponseCreated = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.created").annotate({ "description": "The event type, must be `response.created`." }), - "response": RealtimeResponse + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaToolCallCaller).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "status": Schema.suspend((): Schema.Codec => BetaApplyPatchCallOutputStatus).annotate( + { "description": "The status of the apply patch tool call output. One of `completed` or `failed`." } + ), + "output": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "Optional textual output returned by the apply patch tool." }), + Schema.Null + ]) + ), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the entity that created this tool call output." }) + ) }).annotate({ - "description": - "Returned when a new Response is created. The first event of response creation,\nwhere the response is in an initial state of `in_progress`.\n" + "title": "Apply patch tool call output", + "description": "The output emitted by an apply patch tool call.", + "identifier": "BetaApplyPatchToolCallOutput" }) -export type RealtimeServerEventResponseDone = { - readonly "event_id": string - readonly "type": "response.done" - readonly "response": RealtimeResponse +export type BetaCustomToolCall = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "custom_tool_call" + readonly "id"?: string + readonly "call_id": string + readonly "caller"?: BetaToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "input": string } -export const RealtimeServerEventResponseDone = Schema.Struct({ - "event_id": Schema.String.annotate({ "description": "The unique ID of the server event." }), - "type": Schema.Literal("response.done").annotate({ "description": "The event type, must be `response.done`." }), - "response": RealtimeResponse -}).annotate({ - "description": - "Returned when a Response is done streaming. Always emitted, no matter the \nfinal state. The Response object included in the `response.done` event will \ninclude all output Items in the Response but will omit the raw audio data.\n\nClients should check the `status` field of the Response to determine if it was successful\n(`completed`) or if there was another outcome: `cancelled`, `failed`, or `incomplete`.\n\nA response will contain all output items that were generated during the response, excluding\nany audio content.\n" -}) -export type RealtimeClientEventResponseCreate = { - readonly "event_id"?: string - readonly "type": "response.create" - readonly "response"?: RealtimeResponseCreateParams -} -export const RealtimeClientEventResponseCreate = Schema.Struct({ - "event_id": Schema.optionalKey( - Schema.String.annotate({ "description": "Optional client-generated ID used to identify this event." }).check( - Schema.isMaxLength(512) - ) +export const BetaCustomToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("custom_tool_call").annotate({ + "description": "The type of the custom tool call. Always `custom_tool_call`.\n" + }), + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The unique ID of the custom tool call in the OpenAI platform.\n" }) + ), + "call_id": Schema.String.annotate({ + "description": "An identifier used to map this custom tool call to a tool call output.\n" + }), + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCaller, Schema.Null])), + "namespace": Schema.optionalKey( + Schema.String.annotate({ "description": "The namespace of the custom tool being called.\n" }) ), - "type": Schema.Literal("response.create").annotate({ "description": "The event type, must be `response.create`." }), - "response": Schema.optionalKey(RealtimeResponseCreateParams) + "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({ - "description": - "This event instructs the server to create a Response, which means triggering \nmodel inference. When in Server VAD mode, the server will create Responses \nautomatically.\n\nA Response will include at least one Item, and may have two, in which case \nthe second will be a function call. These Items will be appended to the \nconversation history by default.\n\nThe server will respond with a `response.created` event, events for Items \nand content created, and finally a `response.done` event to indicate the \nResponse is complete.\n\nThe `response.create` event includes inference configuration like \n`instructions` and `tools`. If these are set, they will override the Session's \nconfiguration for this Response only.\n\nResponses can be created out-of-band of the default Conversation, meaning that they can\nhave arbitrary input, and it's possible to disable writing the output to the Conversation.\nOnly one Response can write to the default Conversation at a time, but otherwise multiple\nResponses can be created in parallel. The `metadata` field is a good way to disambiguate\nmultiple simultaneous Responses.\n\nClients can set `conversation` to `none` to create a Response that does not write to the default\nConversation. Arbitrary input can be provided with the `input` field, which is an array accepting\nraw Items and references to existing Items.\n" -}) -export type ListAssistantsResponse = { - readonly "object": string - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean -} -export const ListAssistantsResponse = Schema.Struct({ - "object": Schema.String, - "data": Schema.Array(AssistantObject), - "first_id": Schema.String, - "last_id": Schema.String, - "has_more": Schema.Boolean + "title": "Custom tool call", + "description": "A call to a custom tool created by the model.\n", + "identifier": "BetaCustomToolCall" }) -export type ListRunsResponse = { - readonly "object": string - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean +export type BetaFunctionToolCallResource = { + readonly "agent"?: BetaAgentTag | null + readonly "id": string + readonly "type": "function_call" + readonly "call_id": string + readonly "caller"?: BetaToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "arguments": string + readonly "status": "in_progress" | "completed" | "incomplete" + readonly "created_by"?: string } -export const ListRunsResponse = Schema.Struct({ - "object": Schema.String, - "data": Schema.Array(RunObject), - "first_id": Schema.String, - "last_id": Schema.String, - "has_more": Schema.Boolean -}) -export type RunStreamEvent = - | { readonly "event": "thread.run.created"; readonly "data": RunObject } - | { readonly "event": "thread.run.queued"; readonly "data": RunObject } - | { readonly "event": "thread.run.in_progress"; readonly "data": RunObject } - | { readonly "event": "thread.run.requires_action"; readonly "data": RunObject } - | { readonly "event": "thread.run.completed"; readonly "data": RunObject } - | { readonly "event": "thread.run.incomplete"; readonly "data": RunObject } - | { readonly "event": "thread.run.failed"; readonly "data": RunObject } - | { readonly "event": "thread.run.cancelling"; readonly "data": RunObject } - | { readonly "event": "thread.run.cancelled"; readonly "data": RunObject } - | { readonly "event": "thread.run.expired"; readonly "data": RunObject } -export const RunStreamEvent = Schema.Union([ - Schema.Struct({ "event": Schema.Literal("thread.run.created"), "data": RunObject }).annotate({ - "description": "Occurs when a new [run](/docs/api-reference/runs/object) is created." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.queued"), "data": RunObject }).annotate({ - "description": "Occurs when a [run](/docs/api-reference/runs/object) moves to a `queued` status." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.in_progress"), "data": RunObject }).annotate({ - "description": "Occurs when a [run](/docs/api-reference/runs/object) moves to an `in_progress` status." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.requires_action"), "data": RunObject }).annotate({ - "description": "Occurs when a [run](/docs/api-reference/runs/object) moves to a `requires_action` status." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.completed"), "data": RunObject }).annotate({ - "description": "Occurs when a [run](/docs/api-reference/runs/object) is completed." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.incomplete"), "data": RunObject }).annotate({ - "description": "Occurs when a [run](/docs/api-reference/runs/object) ends with status `incomplete`." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.failed"), "data": RunObject }).annotate({ - "description": "Occurs when a [run](/docs/api-reference/runs/object) fails." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.cancelling"), "data": RunObject }).annotate({ - "description": "Occurs when a [run](/docs/api-reference/runs/object) moves to a `cancelling` status." - }), - Schema.Struct({ "event": Schema.Literal("thread.run.cancelled"), "data": RunObject }).annotate({ - "description": "Occurs when a [run](/docs/api-reference/runs/object) is cancelled." +export const BetaFunctionToolCallResource = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "id": Schema.String.annotate({ "description": "The unique ID of the function tool call.\n" }), + "type": Schema.Literal("function_call").annotate({ + "description": "The type of the function tool call. Always `function_call`.\n" }), - Schema.Struct({ "event": Schema.Literal("thread.run.expired"), "data": RunObject }).annotate({ - "description": "Occurs when a [run](/docs/api-reference/runs/object) expires." - }) -], { mode: "oneOf" }) -export type Tool = - | FunctionTool - | FileSearchTool - | ComputerTool - | ComputerUsePreviewTool - | WebSearchTool - | MCPTool - | CodeInterpreterTool - | ImageGenTool - | LocalShellToolParam - | FunctionShellToolParam - | CustomToolParam - | NamespaceToolParam - | ToolSearchToolParam - | WebSearchPreviewTool - | ApplyPatchToolParam -export const Tool = Schema.Union([ - FunctionTool, - FileSearchTool, - ComputerTool, - ComputerUsePreviewTool, - WebSearchTool, - MCPTool, - CodeInterpreterTool, - ImageGenTool, - LocalShellToolParam, - FunctionShellToolParam, - CustomToolParam, - NamespaceToolParam, - ToolSearchToolParam, - WebSearchPreviewTool, - ApplyPatchToolParam -], { mode: "oneOf" }).annotate({ "description": "A tool that can be used to generate a response.\n" }) -export type CreateEvalItem = { readonly "role": string; readonly "content": string } | { - readonly "role": "user" | "assistant" | "system" | "developer" - readonly "content": EvalItemContent - readonly "type"?: "message" -} -export const CreateEvalItem = Schema.Union([ - Schema.Struct({ - "role": Schema.String.annotate({ - "description": "The role of the message (e.g. \"system\", \"assistant\", \"user\")." - }), - "content": Schema.String.annotate({ "description": "The content of the message." }) - }).annotate({ - "title": "CreateEvalItem", - "description": - "A chat message that makes up the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" }), - Schema.Struct({ - "role": Schema.Literals(["user", "assistant", "system", "developer"]).annotate({ - "description": "The role of the message input. One of `user`, `assistant`, `system`, or\n`developer`.\n" + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCaller, Schema.Null])), + "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.Union([Schema.Literal("in_progress"), Schema.Literal("completed"), Schema.Literal("incomplete")]) + .annotate({ + "description": + "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" }), - "content": EvalItemContent, - "type": Schema.optionalKey( - Schema.Literal("message").annotate({ "description": "The type of the message input. Always `message`.\n" }) - ) - }).annotate({ - "title": "CreateEvalItem", - "description": - "A chat message that makes up the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." - }) -], { mode: "oneOf" }) -export type EvalItem = { - readonly "role": "user" | "assistant" | "system" | "developer" - readonly "content": EvalItemContent - readonly "type"?: "message" -} -export const EvalItem = Schema.Struct({ - "role": Schema.Literals(["user", "assistant", "system", "developer"]).annotate({ - "description": "The role of the message input. One of `user`, `assistant`, `system`, or\n`developer`.\n" - }), - "content": EvalItemContent, - "type": Schema.optionalKey( - Schema.Literal("message").annotate({ "description": "The type of the message input. Always `message`.\n" }) + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) ) }).annotate({ - "title": "Eval message object", + "title": "Function tool call", "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. Messages with the\n`assistant` role are presumed to have been generated by the model in previous\ninteractions.\n" + "A tool call to run a function. See the \n[function calling guide](/docs/guides/function-calling) for more information.\n", + "identifier": "BetaFunctionToolCallResource" }) -export type OutputMessage = { - readonly "id": string - readonly "type": "message" - readonly "role": "assistant" - readonly "content": ReadonlyArray - readonly "phase"?: MessagePhase | null - readonly "status": "in_progress" | "completed" | "incomplete" -} -export const OutputMessage = Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the output message.\n" }), - "type": Schema.Literal("message").annotate({ "description": "The type of the output message. Always `message`.\n" }), - "role": Schema.Literal("assistant").annotate({ - "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 ComputerToolCall = { - readonly "type": "computer_call" +export type BetaCustomToolCallResource = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "custom_tool_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" + readonly "caller"?: BetaToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "input": string + readonly "status": BetaFunctionCallStatus + readonly "created_by"?: string } -export const ComputerToolCall = Schema.Struct({ - "type": Schema.Literal("computer_call").annotate({ - "description": "The type of the computer call. Always `computer_call`." +export const BetaCustomToolCallResource = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("custom_tool_call").annotate({ + "description": "The type of the custom tool call. Always `custom_tool_call`.\n" }), - "id": Schema.String.annotate({ "description": "The unique ID of the computer call." }), + "id": Schema.String.annotate({ "description": "The unique ID of the custom tool call item.\n" }), "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" + "description": "An identifier used to map this custom tool call to a tool call output.\n" }), - "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCaller, Schema.Null])), + "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" }), + "status": Schema.suspend((): Schema.Codec => BetaFunctionCallStatus).annotate({ "description": "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" - }) + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ) }).annotate({ - "title": "Computer tool call", - "description": - "A tool call to a computer use tool. See the\n[computer use guide](/docs/guides/tools-computer-use) for more information.\n" + "title": "ResponseCustomToolCallItem", + "description": "A call to a custom tool created by the model.\n", + "identifier": "BetaCustomToolCallResource" }) -export type ThreadItemListResource = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "last_id": string | null - readonly "has_more": boolean +export type BetaFunctionShellCallOutputContentParam = { + readonly "stdout": string + readonly "stderr": string + readonly "outcome": BetaFunctionShellCallOutputOutcomeParam } -export const ThreadItemListResource = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), - "data": Schema.Array(ThreadItem).annotate({ "description": "A list of items" }), - "first_id": Schema.Union([ - Schema.String.annotate({ "description": "The ID of the first item in the list." }), - Schema.Null - ]), - "last_id": Schema.Union([ - Schema.String.annotate({ "description": "The ID of the last item in the list." }), - Schema.Null - ]), - "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }) +export const BetaFunctionShellCallOutputContentParam = Schema.Struct({ + "stdout": Schema.String.annotate({ "description": "Captured stdout output for the shell call." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ), + "stderr": Schema.String.annotate({ "description": "Captured stderr output for the shell call." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ), + "outcome": Schema.suspend((): Schema.Codec => + BetaFunctionShellCallOutputOutcomeParam + ).annotate({ "description": "The exit or timeout outcome associated with this shell call." }) }).annotate({ - "title": "Thread Items", - "description": "A paginated list of thread items rendered for the ChatKit API." + "title": "Shell output content", + "description": "Captured stdout and stderr for a portion of a shell tool call output.", + "identifier": "BetaFunctionShellCallOutputContentParam" }) -export type InputItem = - | EasyInputMessage - | { - readonly "type"?: "message" - readonly "role": "user" | "system" | "developer" - readonly "status"?: "in_progress" | "completed" | "incomplete" - readonly "content": InputMessageContentList - } - | { - readonly "id": string - readonly "type": "message" - readonly "role": "assistant" - readonly "content": ReadonlyArray - readonly "phase"?: MessagePhase | null - readonly "status": "in_progress" | "completed" | "incomplete" - } - | { - readonly "id": string - readonly "type": "file_search_call" - readonly "status": "in_progress" | "searching" | "completed" | "incomplete" | "failed" - readonly "queries": ReadonlyArray - readonly "results"?: - | ReadonlyArray< - { - readonly "file_id"?: string - readonly "text"?: string - readonly "filename"?: string - readonly "attributes"?: VectorStoreFileAttributes - readonly "score"?: number - } - > - | null - } - | { - 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" - } - | { - readonly "id"?: string | null - readonly "call_id": string - readonly "type": "computer_call_output" - readonly "output": ComputerScreenshotImage - readonly "acknowledged_safety_checks"?: ReadonlyArray | null - readonly "status"?: "in_progress" | "completed" | "incomplete" | null - } - | { - readonly "id": string - readonly "type": "web_search_call" - readonly "status": "in_progress" | "searching" | "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 | null } - | { readonly "type": "find_in_page"; readonly "url": string; readonly "pattern": string } - } - | { - 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" - } - | { - readonly "id"?: string | null - readonly "call_id": string - readonly "type": "function_call_output" - readonly "output": - | string - | ReadonlyArray - readonly "status"?: "in_progress" | "completed" | "incomplete" | null - } - | { - 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 - } - | { - 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 - } - | { - readonly "type": "reasoning" - readonly "id": string - readonly "encrypted_content"?: string | null - readonly "summary": ReadonlyArray - readonly "content"?: ReadonlyArray - readonly "status"?: "in_progress" | "completed" | "incomplete" - } - | { readonly "id"?: string | null; readonly "type": "compaction"; readonly "encrypted_content": string } - | { - readonly "type": "image_generation_call" - readonly "id": string - readonly "status": "in_progress" | "completed" | "generating" | "failed" - readonly "result": string | null - } - | { - 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 - } - | { - readonly "type": "local_shell_call" - readonly "id": string - readonly "call_id": string - readonly "action": LocalShellExecAction - readonly "status": "in_progress" | "completed" | "incomplete" - } - | { - readonly "type": "local_shell_call_output" - readonly "id": string - readonly "output": string - readonly "status"?: "in_progress" | "completed" | "incomplete" | null - readonly "call_id": unknown - } - | { - readonly "id"?: string | null - readonly "call_id": string - readonly "type": "shell_call" - readonly "action": { - readonly "commands": ReadonlyArray - readonly "timeout_ms"?: number | null - readonly "max_output_length"?: number | null - } - readonly "status"?: "in_progress" | "completed" | "incomplete" | null - readonly "environment"?: LocalEnvironmentParam | ContainerReferenceParam | null - } - | { - readonly "id"?: string | null - readonly "call_id": string - readonly "type": "shell_call_output" - readonly "output": ReadonlyArray - readonly "status"?: "in_progress" | "completed" | "incomplete" | null - readonly "max_output_length"?: number | null - } - | { - readonly "type": "apply_patch_call" - readonly "id"?: string | null - readonly "call_id": string - readonly "status": "in_progress" | "completed" - readonly "operation": - | ApplyPatchCreateFileOperationParam - | ApplyPatchDeleteFileOperationParam - | ApplyPatchUpdateFileOperationParam - } - | { - readonly "type": "apply_patch_call_output" - readonly "id"?: string | null - readonly "call_id": string - readonly "status": "completed" | "failed" - readonly "output"?: string | null - } - | { - readonly "type": "mcp_list_tools" - readonly "id": string - readonly "server_label": string - readonly "tools": ReadonlyArray - readonly "error"?: string | null - } - | { - readonly "type": "mcp_approval_request" - readonly "id": string - readonly "server_label": string - readonly "name": string - readonly "arguments": string - } - | { - readonly "type": "mcp_approval_response" - readonly "id"?: string | null - readonly "approval_request_id": string - readonly "approve": boolean - readonly "reason"?: string | null - readonly "request_id": unknown - } - | { - readonly "type": "mcp_call" - readonly "id": string - readonly "server_label": string - readonly "name": string - readonly "arguments": string - readonly "output"?: string | null - readonly "error"?: string | null - readonly "status"?: "in_progress" | "completed" | "incomplete" | "calling" | "failed" - readonly "approval_request_id"?: string | null - } - | { - readonly "type": "custom_tool_call_output" - readonly "id"?: string - readonly "call_id": string - readonly "output": string | ReadonlyArray - } - | { - readonly "type": "custom_tool_call" - readonly "id"?: string - readonly "call_id": string - readonly "namespace"?: string - readonly "name": string - readonly "input": string - } - | CompactionTriggerItemParam - | ItemReferenceParam -export const InputItem = Schema.Union([ - EasyInputMessage, - Schema.Union([ - Schema.Struct({ - "type": Schema.optionalKey( - Schema.Literal("message").annotate({ - "description": "The type of the message input. Always set to `message`.\n" - }) - ), - "role": Schema.Literals(["user", "system", "developer"]).annotate({ - "description": "The role of the message input. One of `user`, `system`, or `developer`.\n" - }), - "status": Schema.optionalKey( - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": - "The status of item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" - }) - ), - "content": InputMessageContentList - }).annotate({ "title": "Input message", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the output message.\n" }), - "type": Schema.Literal("message").annotate({ - "description": "The type of the output message. Always `message`.\n" - }), - "role": Schema.Literal("assistant").annotate({ - "description": "The role of the output message. Always `assistant`.\n" +export type BetaModerationPolicyParam = { + readonly "input"?: BetaModerationConfigParam | null + readonly "output"?: BetaModerationConfigParam | null +} +export const BetaModerationPolicyParam = Schema.Struct({ + "input": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaModerationConfigParam).annotate({ + "description": "The moderation policy for the response input." }), - "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": "Content item used to generate a response.\n" }), - Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the file search tool call.\n" }), - "type": Schema.Literal("file_search_call").annotate({ - "description": "The type of the file search tool call. Always `file_search_call`.\n" + Schema.Null + ]) + ), + "output": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaModerationConfigParam).annotate({ + "description": "The moderation policy for the response output." }), - "status": Schema.Literals(["in_progress", "searching", "completed", "incomplete", "failed"]).annotate({ - "description": - "The status of the file search tool call. One of `in_progress`,\n`searching`, `incomplete` or `failed`,\n" + Schema.Null + ]) + ) +}).annotate({ + "description": "The policy to apply to moderated response input and output.", + "identifier": "BetaModerationPolicyParam" +}) +export type BetaFunctionShellCallOutput = { + readonly "agent"?: BetaAgentTag + readonly "type": "shell_call_output" + readonly "id": string + readonly "call_id": string + readonly "caller"?: BetaToolCallCaller | null + readonly "status": BetaFunctionShellCallOutputStatusEnum + readonly "output": ReadonlyArray + readonly "max_output_length": number | null + readonly "created_by"?: string +} +export const BetaFunctionShellCallOutput = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." + }) + ), + "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." }), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaToolCallCaller).annotate({ + "description": "The execution context that produced this tool call." }), - "queries": Schema.Array(Schema.String).annotate({ "description": "The queries used to search for files.\n" }), - "results": Schema.optionalKey(Schema.Union([ - Schema.Array(Schema.Struct({ - "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the file.\n" })), - "text": Schema.optionalKey( - Schema.String.annotate({ "description": "The text that was retrieved from the file.\n" }) - ), - "filename": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the file.\n" })), - "attributes": Schema.optionalKey(VectorStoreFileAttributes), - "score": Schema.optionalKey( - Schema.Number.annotate({ - "description": "The relevance score of the file - a value between 0 and 1.\n", - "format": "float" - }).check(Schema.isFinite()) - ) - })).annotate({ "description": "The results of the file search tool call.\n" }), - Schema.Null - ])) - }).annotate({ "title": "File search tool call", "description": "Content item used to generate a response.\n" }), + Schema.Null + ]) + ), + "status": Schema.suspend((): Schema.Codec => + BetaFunctionShellCallOutputStatusEnum + ).annotate({ + "description": "The status of the shell call output. One of `in_progress`, `completed`, or `incomplete`." + }), + "output": Schema.Array(BetaFunctionShellCallOutputContent).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().annotate({ "expected": "an integer" })), + 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.", + "identifier": "BetaFunctionShellCallOutput" +}) +export type RunStepObject = { + readonly "id": string + readonly "object": "thread.run.step" + readonly "created_at": number + readonly "assistant_id": string + readonly "thread_id": string + readonly "run_id": string + readonly "type": "message_creation" | "tool_calls" + readonly "status": "in_progress" | "cancelled" | "failed" | "completed" | "expired" + readonly "step_details": { + readonly "type": "message_creation" + readonly "message_creation": { readonly "message_id": string } + } | { + readonly "type": "tool_calls" + readonly "tool_calls": ReadonlyArray< + | RunStepDetailsToolCallsCodeObject + | RunStepDetailsToolCallsFileSearchObject + | RunStepDetailsToolCallsFunctionObject + > + } + readonly "last_error": { readonly "code": "server_error" | "rate_limit_exceeded"; readonly "message": string } | null + readonly "expired_at": number | null + readonly "cancelled_at": number | null + readonly "failed_at": number | null + readonly "completed_at": number | null + readonly "metadata": Metadata + readonly "usage": RunStepCompletionUsage +} +export const RunStepObject = Schema.Struct({ + "id": Schema.String.annotate({ + "description": "The identifier of the run step, which can be referenced in API endpoints." + }), + "object": Schema.Literal("thread.run.step").annotate({ + "description": "The object type, which is always `thread.run.step`." + }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the run step was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "assistant_id": Schema.String.annotate({ + "description": "The ID of the [assistant](/docs/api-reference/assistants) associated with the run step." + }), + "thread_id": Schema.String.annotate({ + "description": "The ID of the [thread](/docs/api-reference/threads) that was run." + }), + "run_id": Schema.String.annotate({ + "description": "The ID of the [run](/docs/api-reference/runs) that this run step is a part of." + }), + "type": Schema.Literals(["message_creation", "tool_calls"]).annotate({ + "description": "The type of run step, which can be either `message_creation` or `tool_calls`." + }), + "status": Schema.Literals(["in_progress", "cancelled", "failed", "completed", "expired"]).annotate({ + "description": + "The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`." + }), + "step_details": Schema.Union([ 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" + "type": Schema.Literal("message_creation").annotate({ "description": "Always `message_creation`." }), + "message_creation": Schema.Struct({ + "message_id": Schema.String.annotate({ + "description": "The ID of the message that was created by this run step." + }) }) - }).annotate({ "title": "Computer tool call", "description": "Content item used to generate a response.\n" }), + }).annotate({ "title": "Message creation", "description": "The details of the run step." }), Schema.Struct({ - "id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The ID of the computer tool call output." }), - Schema.Null - ]) - ), - "call_id": Schema.String.annotate({ "description": "The ID of the computer tool call that produced the output." }) - .check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)), - "type": Schema.Literal("computer_call_output").annotate({ - "description": "The type of the computer tool call output. Always `computer_call_output`." - }), - "output": ComputerScreenshotImage, - "acknowledged_safety_checks": Schema.optionalKey( - Schema.Union([ - Schema.Array(ComputerCallSafetyCheckParam).annotate({ - "description": "The safety checks reported by the API that have been acknowledged by the developer." - }), - Schema.Null - ]) - ), - "status": Schema.optionalKey( + "type": Schema.Literal("tool_calls").annotate({ "description": "Always `tool_calls`." }), + "tool_calls": Schema.Array( Schema.Union([ - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": - "The status of the message input. One of `in_progress`, `completed`, or `incomplete`. Populated when input items are returned via API." - }), - Schema.Null - ]) - ) - }).annotate({ "title": "Computer tool call output", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "id": Schema.String.annotate({ "description": "The unique ID of the web search tool call.\n" }), - "type": Schema.Literal("web_search_call").annotate({ - "description": "The type of the web search tool call. Always `web_search_call`.\n" - }), - "status": Schema.Literals(["in_progress", "searching", "completed", "failed"]).annotate({ - "description": "The status of the web search tool call.\n" - }), - "action": Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("search").annotate({ "description": "The action type.\n" }), - "query": Schema.optionalKey(Schema.String.annotate({ "description": "[DEPRECATED] The search query.\n" })), - "queries": Schema.optionalKey( - Schema.Array(Schema.String.annotate({ "description": "A search query.\n" })).annotate({ - "title": "Search queries", - "description": "The search queries.\n" - }) - ), - "sources": Schema.optionalKey( - Schema.Array( - Schema.Struct({ - "type": Schema.Literal("url").annotate({ "description": "The type of source. Always `url`.\n" }), - "url": Schema.String.annotate({ "description": "The URL of the source.\n", "format": "uri" }) - }).annotate({ "title": "Web search source", "description": "A source used in the search.\n" }) - ).annotate({ "title": "Web search sources", "description": "The sources used in the search.\n" }) - ) - }).annotate({ - "title": "Search action", - "description": - "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" - }), - Schema.Struct({ - "type": Schema.Literal("open_page").annotate({ "description": "The action type. Always `open_page`.\n" }), - "url": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "format": "uri" }), Schema.Null]).annotate({ - "description": "The URL opened by the model.\n" - }) - ) - }).annotate({ - "title": "Open page action", - "description": - "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" - }), - Schema.Struct({ - "type": Schema.Literal("find_in_page").annotate({ "description": "The action type.\n" }), - "url": Schema.String.annotate({ - "description": "The URL of the page searched for the pattern.\n", - "format": "uri" - }), - "pattern": Schema.String.annotate({ "description": "The pattern or text to search for within the page.\n" }) - }).annotate({ - "title": "Find action", - "description": - "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" - }) - ], { mode: "oneOf" }) - }).annotate({ "title": "Web search tool call", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the function tool call.\n" })), - "type": Schema.Literal("function_call").annotate({ - "description": "The type of the function tool call. Always `function_call`.\n" - }), - "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( - 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": "Function tool call", "description": "Content item used to generate a response.\n" }), + RunStepDetailsToolCallsCodeObject, + RunStepDetailsToolCallsFileSearchObject, + RunStepDetailsToolCallsFunctionObject + ], { mode: "oneOf" }) + ).annotate({ + "description": + "An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`.\n" + }) + }).annotate({ "title": "Tool calls", "description": "The details of the run step." }) + ], { mode: "oneOf" }), + "last_error": Schema.Union([ Schema.Struct({ - "id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "The unique ID of the function tool call output. Populated when this item is returned via API." - }), - Schema.Null - ]) - ), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the function tool call generated by the model." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)), - "type": Schema.Literal("function_call_output").annotate({ - "description": "The type of the function tool call output. Always `function_call_output`." + "code": Schema.Literals(["server_error", "rate_limit_exceeded"]).annotate({ + "description": "One of `server_error` or `rate_limit_exceeded`." }), - "output": Schema.Union([ - Schema.String.annotate({ "description": "A JSON string of the output of the function tool call." }).check( - Schema.isMaxLength(10485760) - ), - Schema.Array( - Schema.Union([InputTextContentParam, InputImageContentParamAutoParam, InputFileContentParam], { - mode: "oneOf" - }).annotate({ "description": "A piece of message content, such as text, an image, or a file." }) - ).annotate({ "description": "An array of content outputs (text, image, file) for the function tool call." }) - ], { mode: "oneOf" }).annotate({ "description": "Text, image, or file output of the function tool call." }), - "status": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": - "The status of the item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API." - }), - Schema.Null - ]) - ) - }).annotate({ "title": "Function tool call output", "description": "Content item used to generate a response.\n" }), - 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 - ]) - ) - }).annotate({ "description": "Content item used to generate a response.\n" }), - 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 - ]) - ) - }).annotate({ "description": "Content item used to generate a response.\n" }), + "message": Schema.String.annotate({ "description": "A human-readable description of the error." }) + }).annotate({ + "description": "The last error associated with this run step. Will be `null` if there are no errors." + }), + Schema.Null + ]), + "expired_at": Schema.Union([ + Schema.Number.annotate({ + "description": + "The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "cancelled_at": Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the run step was cancelled.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "failed_at": Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the run step failed.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "completed_at": Schema.Union([ + Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the run step completed.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "metadata": Metadata, + "usage": RunStepCompletionUsage +}).annotate({ + "title": "Run steps", + "description": "Represents a step in execution of a run.\n", + "identifier": "RunStepObject" +}) +export type AssistantObject = { + readonly "id": string + readonly "object": "assistant" + readonly "created_at": number + readonly "name": string | null + readonly "description": string | null + readonly "model": string + readonly "instructions": string | null + readonly "tools": ReadonlyArray + readonly "tool_resources"?: { + readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } + readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } + } | null + readonly "metadata": Metadata + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "response_format"?: AssistantsApiResponseFormatOption | null +} +export const AssistantObject = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), + "object": Schema.Literal("assistant").annotate({ "description": "The object type, which is always `assistant`." }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the assistant was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "name": Schema.Union([ + Schema.String.annotate({ "description": "The name of the assistant. The maximum length is 256 characters.\n" }) + .check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })), + Schema.Null + ]), + "description": Schema.Union([ + Schema.String.annotate({ + "description": "The description of the assistant. The maximum length is 512 characters.\n" + }).check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })), + Schema.Null + ]), + "model": Schema.String.annotate({ + "description": + "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" + }), + "instructions": Schema.Union([ + Schema.String.annotate({ + "description": "The system instructions that the assistant uses. The maximum length is 256,000 characters.\n" + }).check(Schema.isMaxLength(256000).annotate({ "expected": "a value with a length of at most 256000" })), + Schema.Null + ]), + "tools": Schema.Array( + Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) + ).annotate({ + "description": + "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.\n" + }).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })), + "tool_resources": Schema.optionalKey(Schema.Union([ Schema.Struct({ - "type": Schema.Literal("reasoning").annotate({ "description": "The type of the object. Always `reasoning`.\n" }), - "id": Schema.String.annotate({ "description": "The unique identifier of the reasoning content.\n" }), - "encrypted_content": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ + "code_interpreter": Schema.optionalKey(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "The encrypted content of the reasoning item - populated when a response is\ngenerated with `reasoning.encrypted_content` in the `include` parameter.\n" - }), - Schema.Null - ]) - ), - "summary": Schema.Array(SummaryTextContent).annotate({ "description": "Reasoning summary content.\n" }), - "content": Schema.optionalKey( - Schema.Array(ReasoningTextContent).annotate({ "description": "Reasoning text content.\n" }) - ), - "status": Schema.optionalKey( - 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": "Reasoning", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "id": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "The ID of the compaction item." }), Schema.Null]) - ), - "type": Schema.Literal("compaction").annotate({ "description": "The type of the item. Always `compaction`." }), - "encrypted_content": Schema.String.annotate({ "description": "The encrypted content of the compaction summary." }) - .check(Schema.isMaxLength(10485760)) - }).annotate({ "title": "Compaction item", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "type": Schema.Literal("image_generation_call").annotate({ - "description": "The type of the image generation call. Always `image_generation_call`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the image generation call.\n" }), - "status": Schema.Literals(["in_progress", "completed", "generating", "failed"]).annotate({ - "description": "The status of the image generation call.\n" - }), - "result": Schema.Union([ - Schema.String.annotate({ "description": "The generated image encoded in base64.\n" }), - Schema.Null - ]) - }).annotate({ "title": "Image generation call", "description": "Content item used to generate a response.\n" }), - 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( - { + "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.\n" + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) + ) + })), + "file_search": Schema.optionalKey(Schema.Struct({ + "vector_store_ids": Schema.optionalKey( + Schema.Array(Schema.String).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 - ]) + "The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })) + ) + })) }).annotate({ - "title": "Code interpreter tool call", - "description": "Content item used to generate a response.\n" + "description": + "A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" }), + Schema.Null + ])), + "metadata": Metadata, + "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.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey(Schema.Union([ + Schema.Number.annotate({ + "description": + "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or temperature but not both.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), + Schema.Null + ])), + "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) +}).annotate({ + "title": "Assistant", + "description": "Represents an `assistant` that can call the model and use tools.", + "identifier": "AssistantObject" +}) +export type CreateAssistantRequest = { + readonly "model": string | AssistantSupportedModels + readonly "name"?: string | null + readonly "description"?: string | null + readonly "instructions"?: string | null + readonly "reasoning_effort"?: ReasoningEffort + readonly "tools"?: ReadonlyArray + readonly "tool_resources"?: { + readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } + readonly "file_search"?: { + readonly "vector_store_ids": ReadonlyArray + readonly "vector_stores"?: ReadonlyArray< + { + readonly "file_ids"?: ReadonlyArray + readonly "chunking_strategy"?: { readonly "type": "auto" } | { + readonly "type": "static" + readonly "static": { readonly "max_chunk_size_tokens": number; readonly "chunk_overlap_tokens": number } + } + readonly "metadata"?: Metadata + } + > + } | { + readonly "vector_stores": ReadonlyArray< + { + readonly "file_ids"?: ReadonlyArray + readonly "chunking_strategy"?: { readonly "type": "auto" } | { + readonly "type": "static" + readonly "static": { readonly "max_chunk_size_tokens": number; readonly "chunk_overlap_tokens": number } + } + readonly "metadata"?: Metadata + } + > + readonly "vector_store_ids"?: ReadonlyArray + } + } | null + readonly "metadata"?: Metadata + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "response_format"?: AssistantsApiResponseFormatOption | null +} +export const CreateAssistantRequest = Schema.Struct({ + "model": Schema.Union([Schema.String, AssistantSupportedModels]).annotate({ + "description": + "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" + }), + "name": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The name of the assistant. The maximum length is 256 characters.\n" }) + .check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })), + Schema.Null + ]) + ), + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "The description of the assistant. The maximum length is 512 characters.\n" + }).check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })), + Schema.Null + ]) + ), + "instructions": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "The system instructions that the assistant uses. The maximum length is 256,000 characters.\n" + }).check(Schema.isMaxLength(256000).annotate({ "expected": "a value with a length of at most 256000" })), + Schema.Null + ]) + ), + "reasoning_effort": Schema.optionalKey(ReasoningEffort), + "tools": Schema.optionalKey( + Schema.Array( + Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) + ).annotate({ + "description": + "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.\n" + }).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })) + ), + "tool_resources": Schema.optionalKey(Schema.Union([ 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": "Content item used to generate a response.\n" }), - Schema.Struct({ - "type": Schema.Literal("local_shell_call_output").annotate({ - "description": "The type of the local shell tool call output. Always `local_shell_call_output`.\n" - }), - "id": Schema.String.annotate({ - "description": "The unique ID of the local shell tool call generated by the model.\n" - }), - "output": Schema.String.annotate({ - "description": "A JSON string of the output of the local shell tool call.\n" - }), - "status": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": "The status of the item. One of `in_progress`, `completed`, or `incomplete`.\n" - }), - Schema.Null - ]) - ), - "call_id": Schema.Unknown - }).annotate({ "title": "Local shell call output", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "The unique ID of the shell tool call. Populated when this item is returned via API." - }), - Schema.Null - ]) - ), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the shell tool call generated by the model." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)), - "type": Schema.Literal("shell_call").annotate({ "description": "The type of the item. Always `shell_call`." }), - "action": Schema.Struct({ - "commands": Schema.Array(Schema.String).annotate({ - "description": "Ordered shell commands for the execution environment to run." - }), - "timeout_ms": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "Maximum wall-clock time in milliseconds to allow the shell commands to run." - }).check(Schema.isInt()), - Schema.Null - ]) - ), - "max_output_length": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "Maximum number of UTF-8 characters to capture from combined stdout and stderr output." - }).check(Schema.isInt()), - Schema.Null - ]) + "code_interpreter": Schema.optionalKey(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) ) - }).annotate({ - "title": "Shell action", - "description": "The shell commands and limits that describe how to run the tool call." - }), - "status": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "title": "Shell call status", - "description": "The status of the shell call. One of `in_progress`, `completed`, or `incomplete`." - }), - Schema.Null - ]) - ), - "environment": Schema.optionalKey( - Schema.Union([ - Schema.Union([LocalEnvironmentParam, ContainerReferenceParam], { mode: "oneOf" }).annotate({ - "description": "The environment to execute the shell commands in." - }), - Schema.Null - ]) - ) - }).annotate({ "title": "Shell tool call", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "The unique ID of the shell tool call output. Populated when this item is returned via API." - }), - Schema.Null - ]) - ), - "call_id": Schema.String.annotate({ - "description": "The unique ID of the shell tool call generated by the model." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(64)), - "type": Schema.Literal("shell_call_output").annotate({ - "description": "The type of the item. Always `shell_call_output`." - }), - "output": Schema.Array(FunctionShellCallOutputContentParam).annotate({ - "description": "Captured chunks of stdout and stderr output, along with their associated outcomes." - }), - "status": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "title": "Shell call status", - "description": "The status of the shell call output." - }), - Schema.Null - ]) - ), - "max_output_length": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The maximum number of UTF-8 characters captured for this shell call's combined output." - }).check(Schema.isInt()), - Schema.Null - ]) - ) - }).annotate({ "title": "Shell tool call output", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "type": Schema.Literal("apply_patch_call").annotate({ - "description": "The type of the item. Always `apply_patch_call`." - }), - "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": "Content item used to generate a response.\n" }), - Schema.Struct({ - "type": Schema.Literal("apply_patch_call_output").annotate({ - "description": "The type of the item. Always `apply_patch_call_output`." - }), - "id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ + })), + "file_search": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "vector_store_ids": Schema.Array(Schema.String).annotate({ "description": - "The unique ID of the apply patch tool call output. 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(["completed", "failed"]).annotate({ - "title": "Apply patch call output status", - "description": "The status of the apply patch tool call output. One of `completed` or `failed`." - }), - "output": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": "Optional human-readable log text from the apply patch tool (e.g., patch results or errors)." - }).check(Schema.isMaxLength(10485760)), - Schema.Null - ]) - ) - }).annotate({ - "title": "Apply patch tool call output", - "description": "Content item used to generate a response.\n" - }), - Schema.Struct({ - "type": Schema.Literal("mcp_list_tools").annotate({ - "description": "The type of the item. Always `mcp_list_tools`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the list.\n" }), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server.\n" }), - "tools": Schema.Array(MCPListToolsTool).annotate({ "description": "The tools available on the server.\n" }), - "error": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "Error message if the server could not list tools.\n" }), - Schema.Null - ]) - ) - }).annotate({ "title": "MCP list tools", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "type": Schema.Literal("mcp_approval_request").annotate({ - "description": "The type of the item. Always `mcp_approval_request`.\n" - }), - "id": Schema.String.annotate({ "description": "The unique ID of the approval request.\n" }), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server making the request.\n" }), - "name": Schema.String.annotate({ "description": "The name of the tool to run.\n" }), - "arguments": Schema.String.annotate({ "description": "A JSON string of arguments for the tool.\n" }) - }).annotate({ "title": "MCP approval request", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "type": Schema.Literal("mcp_approval_response").annotate({ - "description": "The type of the item. Always `mcp_approval_response`.\n" - }), - "id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The unique ID of the approval response\n" }), - Schema.Null - ]) - ), - "approval_request_id": Schema.String.annotate({ - "description": "The ID of the approval request being answered.\n" - }), - "approve": Schema.Boolean.annotate({ "description": "Whether the request was approved.\n" }), - "reason": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "Optional reason for the decision.\n" }), Schema.Null]) - ), - "request_id": Schema.Unknown - }).annotate({ "title": "MCP approval response", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "type": Schema.Literal("mcp_call").annotate({ "description": "The type of the item. Always `mcp_call`.\n" }), - "id": Schema.String.annotate({ "description": "The unique ID of the tool call.\n" }), - "server_label": Schema.String.annotate({ "description": "The label of the MCP server running the tool.\n" }), - "name": Schema.String.annotate({ "description": "The name of the tool that was run.\n" }), - "arguments": Schema.String.annotate({ "description": "A JSON string of the arguments passed to the tool.\n" }), - "output": Schema.optionalKey( - Schema.Union([Schema.String.annotate({ "description": "The output from the tool call.\n" }), Schema.Null]) - ), - "error": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ "description": "The error from the tool call, if any.\n" }), - Schema.Null - ]) - ), - "status": Schema.optionalKey( - Schema.Literals(["in_progress", "completed", "incomplete", "calling", "failed"]).annotate({ - "description": - "The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`, or `failed`.\n" - }) - ), - "approval_request_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "Unique identifier for the MCP tool call approval request.\nInclude this value in a subsequent `mcp_approval_response` input to approve or reject the corresponding tool call.\n" - }), - Schema.Null - ]) - ) - }).annotate({ "title": "MCP tool call", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "type": Schema.Literal("custom_tool_call_output").annotate({ - "description": "The type of the custom tool call output. Always `custom_tool_call_output`.\n" - }), - "id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The unique ID of the custom tool call output in the OpenAI platform.\n" - }) - ), - "call_id": Schema.String.annotate({ - "description": "The call ID, used to map this custom tool call output to a custom tool call.\n" - }), - "output": Schema.Union([ - Schema.String.annotate({ - "title": "string output", - "description": "A string of the output of the custom tool call.\n" + "The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })), + "vector_stores": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.\n" + }).check( + Schema.isMaxLength(100000000).annotate({ "expected": "a value with a length of at most 100000000" }) + ) + ), + "chunking_strategy": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }) + .annotate({ + "title": "Auto Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." + }), + Schema.Struct({ + "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), + "static": Schema.Struct({ + "max_chunk_size_tokens": Schema.Number.annotate({ + "description": + "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(100).annotate({ + "expected": "a value greater than or equal to 100" + }) + ).check( + Schema.isLessThanOrEqualTo(4096).annotate({ "expected": "a value less than or equal to 4096" }) + ), + "chunk_overlap_tokens": Schema.Number.annotate({ + "description": + "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + }) + }).annotate({ + "title": "Static Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." + }) + ], { mode: "oneOf" }) + ), + "metadata": Schema.optionalKey(Metadata) + })).annotate({ + "description": + "A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })) + ) }), - Schema.Array(FunctionAndCustomToolCallOutput).annotate({ - "title": "output content list", - "description": "Text, image, or file output of the custom tool call.\n" + Schema.Struct({ + "vector_stores": Schema.Array(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.\n" + }).check( + Schema.isMaxLength(100000000).annotate({ "expected": "a value with a length of at most 100000000" }) + ) + ), + "chunking_strategy": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ "type": Schema.Literal("auto").annotate({ "description": "Always `auto`." }) }) + .annotate({ + "title": "Auto Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." + }), + Schema.Struct({ + "type": Schema.Literal("static").annotate({ "description": "Always `static`." }), + "static": Schema.Struct({ + "max_chunk_size_tokens": Schema.Number.annotate({ + "description": + "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(100).annotate({ + "expected": "a value greater than or equal to 100" + }) + ).check( + Schema.isLessThanOrEqualTo(4096).annotate({ "expected": "a value less than or equal to 4096" }) + ), + "chunk_overlap_tokens": Schema.Number.annotate({ + "description": + "The number of tokens that overlap between chunks. The default value is `400`.\n\nNote that the overlap must not exceed half of `max_chunk_size_tokens`.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + }) + }).annotate({ + "title": "Static Chunking Strategy", + "description": + "The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy." + }) + ], { mode: "oneOf" }) + ), + "metadata": Schema.optionalKey(Metadata) + })).annotate({ + "description": + "A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })), + "vector_store_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })) + ) }) - ], { mode: "oneOf" }).annotate({ + ], { mode: "oneOf" })) + }).annotate({ + "description": + "A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" + }), + Schema.Null + ])), + "metadata": Schema.optionalKey(Metadata), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": - "The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n" - }) - }).annotate({ "title": "Custom tool call output", "description": "Content item used to generate a response.\n" }), - Schema.Struct({ - "type": Schema.Literal("custom_tool_call").annotate({ - "description": "The type of the custom tool call. Always `custom_tool_call`.\n" - }), - "id": Schema.optionalKey( - Schema.String.annotate({ "description": "The unique ID of the custom tool call in the OpenAI platform.\n" }) - ), - "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": "Content item used to generate a response.\n" }) - ], { mode: "oneOf" }).annotate({ - "title": "Item", - "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" - }), - CompactionTriggerItemParam, - ItemReferenceParam -], { mode: "oneOf" }) -export type ToolsArray = ReadonlyArray -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." }), + "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.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey(Schema.Union([ + Schema.Number.annotate({ + "description": + "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or temperature but not both.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), 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 CreateEvalLabelModelGrader = { - readonly "type": "label_model" - readonly "name": string - readonly "model": string - readonly "input": ReadonlyArray - readonly "labels": ReadonlyArray - readonly "passing_labels": ReadonlyArray + ])), + "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) +}).annotate({ "identifier": "CreateAssistantRequest" }) +export type ModifyAssistantRequest = { + readonly "model"?: string | AssistantSupportedModels + readonly "reasoning_effort"?: ReasoningEffort + readonly "name"?: string | null + readonly "description"?: string | null + readonly "instructions"?: string | null + readonly "tools"?: ReadonlyArray + readonly "tool_resources"?: { + readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } + readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } + } | null + readonly "metadata"?: Metadata + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "response_format"?: AssistantsApiResponseFormatOption | null } -export const CreateEvalLabelModelGrader = Schema.Struct({ - "type": Schema.Literal("label_model").annotate({ "description": "The object type, which is always `label_model`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "model": Schema.String.annotate({ - "description": "The model to use for the evaluation. Must support structured outputs." - }), - "input": Schema.Array(CreateEvalItem).annotate({ - "description": - "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." - }), - "labels": Schema.Array(Schema.String).annotate({ - "description": "The labels to classify to each item in the evaluation." - }), - "passing_labels": Schema.Array(Schema.String).annotate({ - "description": "The labels that indicate a passing result. Must be a subset of labels." - }) -}).annotate({ - "title": "LabelModelGrader", - "description": "A LabelModelGrader object which uses a model to assign labels to each item\nin the evaluation.\n" -}) -export type CreateEvalRunRequest = { - readonly "name"?: string - readonly "metadata"?: Metadata - readonly "data_source": { - readonly "type": "jsonl" - readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource - } | { - readonly "type": "completions" - readonly "input_messages"?: { - readonly "type": "template" - readonly "template": ReadonlyArray - } | { readonly "type": "item_reference"; readonly "item_reference": string } - readonly "sampling_params"?: { - readonly "reasoning_effort"?: ReasoningEffort - readonly "temperature"?: number - readonly "max_completion_tokens"?: number - readonly "top_p"?: number - readonly "seed"?: number - readonly "response_format"?: ResponseFormatText | ResponseFormatJsonSchema | ResponseFormatJsonObject - readonly "tools"?: ReadonlyArray - } - readonly "model"?: string - readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource | EvalStoredCompletionsSource - } | { - readonly "type": "responses" - readonly "input_messages"?: { - readonly "type": "template" - readonly "template": ReadonlyArray<{ readonly "role": string; readonly "content": string } | EvalItem> - } | { readonly "type": "item_reference"; readonly "item_reference": string } - readonly "sampling_params"?: { - readonly "reasoning_effort"?: ReasoningEffort - readonly "temperature"?: number - readonly "max_completion_tokens"?: number - readonly "top_p"?: number - readonly "seed"?: number - readonly "tools"?: ReadonlyArray - readonly "text"?: { readonly "format"?: TextResponseFormatConfiguration } - } - readonly "model"?: string - readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource | EvalResponsesSource - } -} -export const CreateEvalRunRequest = Schema.Struct({ - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the run." })), - "metadata": Schema.optionalKey(Metadata), - "data_source": Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("jsonl").annotate({ "description": "The type of data source. Always `jsonl`." }), - "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource], { mode: "oneOf" }).annotate({ - "description": "Determines what populates the `item` namespace in the data source." - }) - }).annotate({ "title": "JsonlRunDataSource", "description": "Details about the run's data source." }), +export const ModifyAssistantRequest = Schema.Struct({ + "model": Schema.optionalKey( + Schema.Union([Schema.String, AssistantSupportedModels]).annotate({ + "description": + "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.\n" + }) + ), + "reasoning_effort": Schema.optionalKey(ReasoningEffort), + "name": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The name of the assistant. The maximum length is 256 characters.\n" }) + .check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })), + Schema.Null + ]) + ), + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "The description of the assistant. The maximum length is 512 characters.\n" + }).check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })), + Schema.Null + ]) + ), + "instructions": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "The system instructions that the assistant uses. The maximum length is 256,000 characters.\n" + }).check(Schema.isMaxLength(256000).annotate({ "expected": "a value with a length of at most 256000" })), + Schema.Null + ]) + ), + "tools": Schema.optionalKey( + Schema.Array( + Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) + ).annotate({ + "description": + "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.\n" + }).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })) + ), + "tool_resources": Schema.optionalKey(Schema.Union([ Schema.Struct({ - "type": Schema.Literal("completions").annotate({ - "description": "The type of run data source. Always `completions`." - }), - "input_messages": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("template").annotate({ - "description": "The type of input messages. Always `template`." - }), - "template": Schema.Array(Schema.Union([EasyInputMessage, EvalItem], { mode: "oneOf" })).annotate({ - "description": - "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." - }) - }).annotate({ "title": "TemplateInputMessages" }), - Schema.Struct({ - "type": Schema.Literal("item_reference").annotate({ - "description": "The type of input messages. Always `item_reference`." - }), - "item_reference": Schema.String.annotate({ - "description": "A reference to a variable in the `item` namespace. Ie, \"item.input_trajectory\"" - }) - }).annotate({ "title": "ItemReferenceInputMessages" }) - ], { mode: "oneOf" }).annotate({ - "description": - "Used when sampling from a model. Dictates the structure of the messages passed into the model. Can either be a reference to a prebuilt trajectory (ie, `item.input_trajectory`), or a template with variable references to the `item` namespace." - }) - ), - "sampling_params": Schema.optionalKey(Schema.Struct({ - "reasoning_effort": Schema.optionalKey(ReasoningEffort), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs." }).check( - Schema.isFinite() - ) - ), - "max_completion_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum number of tokens in the generated output." }).check( - Schema.isInt() - ) - ), - "top_p": Schema.optionalKey( - Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens." - }).check(Schema.isFinite()) - ), - "seed": Schema.optionalKey( - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling." }) - .check(Schema.isInt()) - ), - "response_format": Schema.optionalKey( - Schema.Union([ResponseFormatText, ResponseFormatJsonSchema, ResponseFormatJsonObject], { mode: "oneOf" }) - .annotate({ - "description": - "An object specifying the format that the model must output.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables\nStructured Outputs which ensures the model will match your supplied JSON\nschema. Learn more in the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n" - }) - ), - "tools": Schema.optionalKey( - Schema.Array(ChatCompletionTool).annotate({ + "code_interpreter": Schema.optionalKey(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.\n" - }) + "Overrides the list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) ) })), - "model": Schema.optionalKey( - Schema.String.annotate({ - "description": "The name of the model to use for generating completions (e.g. \"o3-mini\")." - }) - ), - "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource, EvalStoredCompletionsSource], { - mode: "oneOf" - }).annotate({ "description": "Determines what populates the `item` namespace in this run's data source." }) - }).annotate({ "title": "CompletionsRunDataSource", "description": "Details about the run's data source." }), - Schema.Struct({ - "type": Schema.Literal("responses").annotate({ - "description": "The type of run data source. Always `responses`." - }), - "input_messages": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("template").annotate({ - "description": "The type of input messages. Always `template`." - }), - "template": Schema.Array( - Schema.Union([ - Schema.Struct({ - "role": Schema.String.annotate({ - "description": "The role of the message (e.g. \"system\", \"assistant\", \"user\")." - }), - "content": Schema.String.annotate({ "description": "The content of the message." }) - }).annotate({ "title": "ChatMessage" }), - EvalItem - ], { mode: "oneOf" }) - ).annotate({ - "description": - "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." - }) - }).annotate({ "title": "InputMessagesTemplate" }), - Schema.Struct({ - "type": Schema.Literal("item_reference").annotate({ - "description": "The type of input messages. Always `item_reference`." - }), - "item_reference": Schema.String.annotate({ - "description": "A reference to a variable in the `item` namespace. Ie, \"item.name\"" - }) - }).annotate({ "title": "InputMessagesItemReference" }) - ], { mode: "oneOf" }).annotate({ - "description": - "Used when sampling from a model. Dictates the structure of the messages passed into the model. Can either be a reference to a prebuilt trajectory (ie, `item.input_trajectory`), or a template with variable references to the `item` namespace." - }) - ), - "sampling_params": Schema.optionalKey(Schema.Struct({ - "reasoning_effort": Schema.optionalKey(ReasoningEffort), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs." }).check( - Schema.isFinite() - ) - ), - "max_completion_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum number of tokens in the generated output." }).check( - Schema.isInt() - ) - ), - "top_p": Schema.optionalKey( - Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens." - }).check(Schema.isFinite()) - ), - "seed": Schema.optionalKey( - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling." }) - .check(Schema.isInt()) - ), - "tools": Schema.optionalKey( - 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\nThe two categories of tools you can provide the model are:\n\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- **Function calls (custom tools)**: Functions that are defined by you,\n enabling the model to call your own code. Learn more about\n [function calling](/docs/guides/function-calling).\n" - }) - ), - "text": Schema.optionalKey( - Schema.Struct({ "format": Schema.optionalKey(TextResponseFormatConfiguration) }).annotate({ + "file_search": Schema.optionalKey(Schema.Struct({ + "vector_store_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "Configuration options for a text response from the model. Can be plain\ntext or structured JSON data. Learn more:\n- [Text inputs and outputs](/docs/guides/text)\n- [Structured Outputs](/docs/guides/structured-outputs)\n" - }) + "Overrides the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })) ) - })), - "model": Schema.optionalKey( - Schema.String.annotate({ - "description": "The name of the model to use for generating completions (e.g. \"o3-mini\")." - }) - ), - "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource, EvalResponsesSource], { - mode: "oneOf" - }).annotate({ "description": "Determines what populates the `item` namespace in this run's data source." }) - }).annotate({ "title": "ResponsesRunDataSource", "description": "Details about the run's data source." }) - ], { mode: "oneOf" }) -}).annotate({ "title": "CreateEvalRunRequest" }) -export type EvalGraderLabelModel = { - readonly "type": "label_model" - readonly "name": string - readonly "model": string - readonly "input": ReadonlyArray - readonly "labels": ReadonlyArray - readonly "passing_labels": ReadonlyArray -} -export const EvalGraderLabelModel = Schema.Struct({ - "type": Schema.Literal("label_model").annotate({ "description": "The object type, which is always `label_model`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "model": Schema.String.annotate({ - "description": "The model to use for the evaluation. Must support structured outputs." - }), - "input": Schema.Array(EvalItem), - "labels": Schema.Array(Schema.String).annotate({ - "description": "The labels to assign to each item in the evaluation." - }), - "passing_labels": Schema.Array(Schema.String).annotate({ - "description": "The labels that indicate a passing result. Must be a subset of labels." - }) -}).annotate({ - "title": "LabelModelGrader", - "description": "A LabelModelGrader object which uses a model to assign labels to each item\nin the evaluation.\n" -}) -export type EvalGraderScoreModel = { - readonly "type": "score_model" - readonly "name": string - readonly "model": string - readonly "sampling_params"?: { - readonly "seed"?: number | null - readonly "top_p"?: number | null - readonly "temperature"?: number | null - readonly "max_completions_tokens"?: number | null - readonly "reasoning_effort"?: ReasoningEffort - } - readonly "input": ReadonlyArray - readonly "range"?: ReadonlyArray - readonly "pass_threshold"?: number -} -export const EvalGraderScoreModel = Schema.Struct({ - "type": Schema.Literal("score_model").annotate({ "description": "The object type, which is always `score_model`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), - "sampling_params": Schema.optionalKey( - Schema.Struct({ - "seed": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) - .check(Schema.isInt()), - Schema.Null - ]) - ), - "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) - .check(Schema.isFinite()), - Schema.Null - ]) - ), - "max_completions_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The maximum number of tokens the grader model may generate in its response.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - Schema.Null - ]) - ), - "reasoning_effort": Schema.optionalKey(ReasoningEffort) - }).annotate({ "description": "The sampling parameters for the model." }) - ), - "input": Schema.Array(EvalItem).annotate({ - "description": - "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" - }), - "range": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isFinite())).annotate({ - "description": "The range of the score. Defaults to `[0, 1]`." - }) + })) + }).annotate({ + "description": + "A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" + }), + Schema.Null + ])), + "metadata": Schema.optionalKey(Metadata), + "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.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]) ), - "pass_threshold": Schema.optionalKey( - Schema.Number.annotate({ "description": "The threshold for the score." }).check(Schema.isFinite()) - ) -}).annotate({ - "title": "ScoreModelGrader", - "description": "A ScoreModelGrader object that uses a model to assign a score to the input.\n" -}) -export type EvalRun = { - readonly "object": "eval.run" + "top_p": Schema.optionalKey(Schema.Union([ + Schema.Number.annotate({ + "description": + "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or temperature but not both.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), + Schema.Null + ])), + "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) +}).annotate({ "identifier": "ModifyAssistantRequest" }) +export type RunObject = { readonly "id": string - readonly "eval_id": string - readonly "status": string - readonly "model": string - readonly "name": string + readonly "object": "thread.run" readonly "created_at": number - readonly "report_url": string - readonly "result_counts": { - readonly "total": number - readonly "errored": number - readonly "failed": number - readonly "passed": number + readonly "thread_id": string + readonly "assistant_id": string + readonly "status": + | "queued" + | "in_progress" + | "requires_action" + | "cancelling" + | "cancelled" + | "failed" + | "completed" + | "incomplete" + | "expired" + readonly "required_action": { + readonly "type": "submit_tool_outputs" + readonly "submit_tool_outputs": { readonly "tool_calls": ReadonlyArray } + readonly [x: string]: Schema.Json + } | null + readonly "last_error": { + readonly "code": "server_error" | "rate_limit_exceeded" | "invalid_prompt" + readonly "message": string + readonly [x: string]: Schema.Json + } | null + readonly "expires_at": number | null + readonly "started_at": number | null + readonly "cancelled_at": number | null + readonly "failed_at": number | null + readonly "completed_at": number | null + readonly "incomplete_details": { + readonly "reason"?: "max_completion_tokens" | "max_prompt_tokens" + readonly [x: string]: Schema.Json + } | null + readonly "model": string + readonly "instructions": string + readonly "tools": ReadonlyArray + readonly "metadata": Metadata + readonly "usage": RunCompletionUsage + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "max_prompt_tokens": number | null + readonly "max_completion_tokens": number | null + readonly "truncation_strategy": { + readonly "type": "auto" | "last_messages" + readonly "last_messages"?: number | null } - readonly "per_model_usage": ReadonlyArray< - { - readonly "model_name": string - readonly "invocation_count": number - readonly "prompt_tokens": number - readonly "completion_tokens": number - readonly "total_tokens": number - readonly "cached_tokens": number - } - > - readonly "per_testing_criteria_results": ReadonlyArray< - { readonly "testing_criteria": string; readonly "passed": number; readonly "failed": number } - > - readonly "data_source": { - readonly "type": "jsonl" - readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource - } | { - readonly "type": "completions" - readonly "input_messages"?: { - readonly "type": "template" - readonly "template": ReadonlyArray - } | { readonly "type": "item_reference"; readonly "item_reference": string } - readonly "sampling_params"?: { - readonly "reasoning_effort"?: ReasoningEffort - readonly "temperature"?: number - readonly "max_completion_tokens"?: number - readonly "top_p"?: number - readonly "seed"?: number - readonly "response_format"?: ResponseFormatText | ResponseFormatJsonSchema | ResponseFormatJsonObject - readonly "tools"?: ReadonlyArray - } - readonly "model"?: string - readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource | EvalStoredCompletionsSource - } | { - readonly "type": "responses" - readonly "input_messages"?: { - readonly "type": "template" - readonly "template": ReadonlyArray<{ readonly "role": string; readonly "content": string } | EvalItem> - } | { readonly "type": "item_reference"; readonly "item_reference": string } - readonly "sampling_params"?: { - readonly "reasoning_effort"?: ReasoningEffort - readonly "temperature"?: number - readonly "max_completion_tokens"?: number - readonly "top_p"?: number - readonly "seed"?: number - readonly "tools"?: ReadonlyArray - readonly "text"?: { readonly "format"?: TextResponseFormatConfiguration } - } - readonly "model"?: string - readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource | EvalResponsesSource + readonly "tool_choice": "none" | "auto" | "required" | { + readonly "type": "function" | "code_interpreter" | "file_search" + readonly "function"?: { readonly "name": string } } - readonly "metadata": Metadata - readonly "error": EvalApiError + readonly "parallel_tool_calls": ParallelToolCalls + readonly "response_format": AssistantsApiResponseFormatOption | null } -export const EvalRun = Schema.Struct({ - "object": Schema.Literal("eval.run").annotate({ "description": "The type of the object. Always \"eval.run\"." }), - "id": Schema.String.annotate({ "description": "Unique identifier for the evaluation run." }), - "eval_id": Schema.String.annotate({ "description": "The identifier of the associated evaluation." }), - "status": Schema.String.annotate({ "description": "The status of the evaluation run." }), - "model": Schema.String.annotate({ "description": "The model that is evaluated, if applicable." }), - "name": Schema.String.annotate({ "description": "The name of the evaluation run." }), +export const RunObject = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The identifier, which can be referenced in API endpoints." }), + "object": Schema.Literal("thread.run").annotate({ "description": "The object type, which is always `thread.run`." }), "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) when the evaluation run was created.", + "description": "The Unix timestamp (in seconds) for when the run was created.", "format": "unixtime" - }).check(Schema.isInt()), - "report_url": Schema.String.annotate({ - "description": "The URL to the rendered evaluation run report on the UI dashboard.", - "format": "uri" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "thread_id": Schema.String.annotate({ + "description": "The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run." }), - "result_counts": Schema.Struct({ - "total": Schema.Number.annotate({ "description": "Total number of executed output items." }).check(Schema.isInt()), - "errored": Schema.Number.annotate({ "description": "Number of output items that resulted in an error." }).check( - Schema.isInt() - ), - "failed": Schema.Number.annotate({ "description": "Number of output items that failed to pass the evaluation." }) - .check(Schema.isInt()), - "passed": Schema.Number.annotate({ "description": "Number of output items that passed the evaluation." }).check( - Schema.isInt() - ) - }).annotate({ "description": "Counters summarizing the outcomes of the evaluation run." }), - "per_model_usage": Schema.Array(Schema.Struct({ - "model_name": Schema.String.annotate({ "description": "The name of the model." }), - "invocation_count": Schema.Number.annotate({ "description": "The number of invocations." }).check(Schema.isInt()), - "prompt_tokens": Schema.Number.annotate({ "description": "The number of prompt tokens used." }).check( - Schema.isInt() + "assistant_id": Schema.String.annotate({ + "description": "The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run." + }), + "status": Schema.Literals([ + "queued", + "in_progress", + "requires_action", + "cancelling", + "cancelled", + "failed", + "completed", + "incomplete", + "expired" + ]).annotate({ + "description": + "The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`." + }), + "required_action": Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "type": Schema.Literal("submit_tool_outputs").annotate({ + "description": "For now, this is always `submit_tool_outputs`." + }), + "submit_tool_outputs": Schema.Struct({ + "tool_calls": Schema.Array(RunToolCallObject).annotate({ + "description": "A list of the relevant tool calls." + }) + }).annotate({ "description": "Details on the tool outputs needed for this run to continue." }) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] ), - "completion_tokens": Schema.Number.annotate({ "description": "The number of completion tokens generated." }).check( - Schema.isInt() - ), - "total_tokens": Schema.Number.annotate({ "description": "The total number of tokens used." }).check(Schema.isInt()), - "cached_tokens": Schema.Number.annotate({ "description": "The number of tokens retrieved from cache." }).check( - Schema.isInt() - ) - })).annotate({ "description": "Usage statistics for each model during the evaluation run." }), - "per_testing_criteria_results": Schema.Array(Schema.Struct({ - "testing_criteria": Schema.String.annotate({ "description": "A description of the testing criteria." }), - "passed": Schema.Number.annotate({ "description": "Number of tests passed for this criteria." }).check( - Schema.isInt() - ), - "failed": Schema.Number.annotate({ "description": "Number of tests failed for this criteria." }).check( - Schema.isInt() - ) - })).annotate({ "description": "Results per testing criteria applied during the evaluation run." }), - "data_source": Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("jsonl").annotate({ "description": "The type of data source. Always `jsonl`." }), - "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource], { mode: "oneOf" }).annotate({ - "description": "Determines what populates the `item` namespace in the data source." - }) - }).annotate({ "title": "JsonlRunDataSource", "description": "Information about the run's data source." }), - Schema.Struct({ - "type": Schema.Literal("completions").annotate({ - "description": "The type of run data source. Always `completions`." + Schema.Null + ]).annotate({ + "description": "Details on the action required to continue the run. Will be `null` if no action is required." + }), + "last_error": Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "code": Schema.Literals(["server_error", "rate_limit_exceeded", "invalid_prompt"]).annotate({ + "description": "One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`." + }), + "message": Schema.String.annotate({ "description": "A human-readable description of the error." }) }), - "input_messages": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("template").annotate({ - "description": "The type of input messages. Always `template`." - }), - "template": Schema.Array(Schema.Union([EasyInputMessage, EvalItem], { mode: "oneOf" })).annotate({ - "description": - "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." - }) - }).annotate({ "title": "TemplateInputMessages" }), - Schema.Struct({ - "type": Schema.Literal("item_reference").annotate({ - "description": "The type of input messages. Always `item_reference`." - }), - "item_reference": Schema.String.annotate({ - "description": "A reference to a variable in the `item` namespace. Ie, \"item.input_trajectory\"" - }) - }).annotate({ "title": "ItemReferenceInputMessages" }) - ], { mode: "oneOf" }).annotate({ - "description": - "Used when sampling from a model. Dictates the structure of the messages passed into the model. Can either be a reference to a prebuilt trajectory (ie, `item.input_trajectory`), or a template with variable references to the `item` namespace." - }) - ), - "sampling_params": Schema.optionalKey(Schema.Struct({ - "reasoning_effort": Schema.optionalKey(ReasoningEffort), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs." }).check( - Schema.isFinite() - ) - ), - "max_completion_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum number of tokens in the generated output." }).check( - Schema.isInt() - ) - ), - "top_p": Schema.optionalKey( - Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens." - }).check(Schema.isFinite()) - ), - "seed": Schema.optionalKey( - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling." }) - .check(Schema.isInt()) - ), - "response_format": Schema.optionalKey( - Schema.Union([ResponseFormatText, ResponseFormatJsonSchema, ResponseFormatJsonObject], { mode: "oneOf" }) - .annotate({ - "description": - "An object specifying the format that the model must output.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables\nStructured Outputs which ensures the model will match your supplied JSON\nschema. Learn more in the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n" - }) - ), - "tools": Schema.optionalKey( - Schema.Array(ChatCompletionTool).annotate({ + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ "description": "The last error associated with this run. Will be `null` if there are no errors." }), + "expires_at": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "The Unix timestamp (in seconds) for when the run will expire.", "format": "unixtime" }), + "started_at": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "The Unix timestamp (in seconds) for when the run was started.", "format": "unixtime" }), + "cancelled_at": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ + "description": "The Unix timestamp (in seconds) for when the run was cancelled.", + "format": "unixtime" + }), + "failed_at": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "The Unix timestamp (in seconds) for when the run failed.", "format": "unixtime" }), + "completed_at": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ + "description": "The Unix timestamp (in seconds) for when the run was completed.", + "format": "unixtime" + }), + "incomplete_details": Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "reason": Schema.optionalKey( + Schema.Literals(["max_completion_tokens", "max_prompt_tokens"]).annotate({ "description": - "A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.\n" + "The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run." }) ) - })), - "model": Schema.optionalKey( - Schema.String.annotate({ - "description": "The name of the model to use for generating completions (e.g. \"o3-mini\")." - }) - ), - "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource, EvalStoredCompletionsSource], { - mode: "oneOf" - }).annotate({ "description": "Determines what populates the `item` namespace in this run's data source." }) - }).annotate({ "title": "CompletionsRunDataSource", "description": "Information about the run's data source." }), + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ "description": "Details on why the run is incomplete. Will be `null` if the run is not incomplete." }), + "model": Schema.String.annotate({ + "description": "The model that the [assistant](/docs/api-reference/assistants) used for this run." + }), + "instructions": Schema.String.annotate({ + "description": "The instructions that the [assistant](/docs/api-reference/assistants) used for this run." + }), + "tools": Schema.Array( + Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) + ).annotate({ + "description": "The list of tools that the [assistant](/docs/api-reference/assistants) used for this run." + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })), + "metadata": Metadata, + "usage": RunCompletionUsage, + "temperature": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "The sampling temperature used for this run. If not set, defaults to 1." }) + ), + "top_p": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "The nucleus sampling value used for this run. If not set, defaults to 1." }) + ), + "max_prompt_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(256).annotate({ "expected": "a value greater than or equal to 256" }) + ), + Schema.Null + ]).annotate({ + "description": "The maximum number of prompt tokens specified to have been used over the course of the run.\n" + }), + "max_completion_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(256).annotate({ "expected": "a value greater than or equal to 256" }) + ), + Schema.Null + ]).annotate({ + "description": "The maximum number of completion tokens specified to have been used over the course of the run.\n" + }), + "truncation_strategy": Schema.Union([ Schema.Struct({ - "type": Schema.Literal("responses").annotate({ - "description": "The type of run data source. Always `responses`." + "type": Schema.Literals(["auto", "last_messages"]).annotate({ + "description": + "The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`." }), - "input_messages": Schema.optionalKey( + "last_messages": Schema.optionalKey( Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("template").annotate({ - "description": "The type of input messages. Always `template`." - }), - "template": Schema.Array( - Schema.Union([ - Schema.Struct({ - "role": Schema.String.annotate({ - "description": "The role of the message (e.g. \"system\", \"assistant\", \"user\")." - }), - "content": Schema.String.annotate({ "description": "The content of the message." }) - }).annotate({ "title": "ChatMessage" }), - EvalItem - ], { mode: "oneOf" }) - ).annotate({ - "description": - "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." - }) - }).annotate({ "title": "InputMessagesTemplate" }), - Schema.Struct({ - "type": Schema.Literal("item_reference").annotate({ - "description": "The type of input messages. Always `item_reference`." - }), - "item_reference": Schema.String.annotate({ - "description": "A reference to a variable in the `item` namespace. Ie, \"item.name\"" - }) - }).annotate({ "title": "InputMessagesItemReference" }) - ], { mode: "oneOf" }).annotate({ - "description": - "Used when sampling from a model. Dictates the structure of the messages passed into the model. Can either be a reference to a prebuilt trajectory (ie, `item.input_trajectory`), or a template with variable references to the `item` namespace." - }) - ), - "sampling_params": Schema.optionalKey(Schema.Struct({ - "reasoning_effort": Schema.optionalKey(ReasoningEffort), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs." }).check( - Schema.isFinite() - ) - ), - "max_completion_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "The maximum number of tokens in the generated output." }).check( - Schema.isInt() - ) - ), - "top_p": Schema.optionalKey( Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens." - }).check(Schema.isFinite()) - ), - "seed": Schema.optionalKey( - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling." }) - .check(Schema.isInt()) - ), - "tools": Schema.optionalKey( - 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\nThe two categories of tools you can provide the model are:\n\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- **Function calls (custom tools)**: Functions that are defined by you,\n enabling the model to call your own code. Learn more about\n [function calling](/docs/guides/function-calling).\n" - }) - ), - "text": Schema.optionalKey( - Schema.Struct({ "format": Schema.optionalKey(TextResponseFormatConfiguration) }).annotate({ "description": - "Configuration options for a text response from the model. Can be plain\ntext or structured JSON data. Learn more:\n- [Text inputs and outputs](/docs/guides/text)\n- [Structured Outputs](/docs/guides/structured-outputs)\n" - }) + "The number of most recent messages from the thread when constructing the context for the run." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]) + ) + }).annotate({ + "title": "Thread Truncation Controls", + "description": + "Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run." + }) + ]), + "tool_choice": Schema.Union([ + Schema.Union([Schema.Literal("none"), Schema.Literal("auto"), Schema.Literal("required")]).annotate({ + "description": + "`none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.\n" + }), + Schema.Union([ + Schema.Struct({ + "type": Schema.Literals(["function", "code_interpreter", "file_search"]).annotate({ + "description": "The type of the tool. If type is `function`, the function name must be set" + }), + "function": Schema.optionalKey( + Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) }) ) - })), - "model": Schema.optionalKey( - Schema.String.annotate({ - "description": "The name of the model to use for generating completions (e.g. \"o3-mini\")." - }) - ), - "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource, EvalResponsesSource], { - mode: "oneOf" - }).annotate({ "description": "Determines what populates the `item` namespace in this run's data source." }) - }).annotate({ "title": "ResponsesRunDataSource", "description": "Information about the run's data source." }) - ], { mode: "oneOf" }), - "metadata": Metadata, - "error": EvalApiError -}).annotate({ "title": "EvalRun", "description": "A schema representing an evaluation run.\n" }) -export type GraderLabelModel = { - readonly "type": "label_model" - readonly "name": string - readonly "model": string - readonly "input": ReadonlyArray - readonly "labels": ReadonlyArray - readonly "passing_labels": ReadonlyArray -} -export const GraderLabelModel = Schema.Struct({ - "type": Schema.Literal("label_model").annotate({ "description": "The object type, which is always `label_model`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "model": Schema.String.annotate({ - "description": "The model to use for the evaluation. Must support structured outputs." - }), - "input": Schema.Array(EvalItem), - "labels": Schema.Array(Schema.String).annotate({ - "description": "The labels to assign to each item in the evaluation." - }), - "passing_labels": Schema.Array(Schema.String).annotate({ - "description": "The labels that indicate a passing result. Must be a subset of labels." - }) -}).annotate({ - "title": "LabelModelGrader", - "description": "A LabelModelGrader object which uses a model to assign labels to each item\nin the evaluation.\n" -}) -export type GraderScoreModel = { - readonly "type": "score_model" - readonly "name": string - readonly "model": string - readonly "sampling_params"?: { - readonly "seed"?: number | null - readonly "top_p"?: number | null - readonly "temperature"?: number | null - readonly "max_completions_tokens"?: number | null - readonly "reasoning_effort"?: ReasoningEffort - } - readonly "input": ReadonlyArray - readonly "range"?: ReadonlyArray -} -export const GraderScoreModel = Schema.Struct({ - "type": Schema.Literal("score_model").annotate({ "description": "The object type, which is always `score_model`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), - "sampling_params": Schema.optionalKey( - Schema.Struct({ - "seed": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) - .check(Schema.isInt()), - Schema.Null - ]) - ), - "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) - .check(Schema.isFinite()), - Schema.Null - ]) - ), - "max_completions_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The maximum number of tokens the grader model may generate in its response.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - Schema.Null - ]) - ), - "reasoning_effort": Schema.optionalKey(ReasoningEffort) - }).annotate({ "description": "The sampling parameters for the model." }) - ), - "input": Schema.Array(EvalItem).annotate({ + }).annotate({ + "description": "Specifies a tool the model should use. Use to force the model to call a specific tool." + }) + ]) + ], { mode: "oneOf" }).annotate({ "description": - "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" + "Controls which (if any) tool is called by the model.\n`none` means the model will not call any tools and instead generates a message.\n`auto` is the default value and means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools before responding to the user.\nSpecifying a particular tool like `{\"type\": \"file_search\"}` or `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n" }), - "range": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isFinite())).annotate({ - "description": "The range of the score. Defaults to `[0, 1]`." - }) - ) + "parallel_tool_calls": ParallelToolCalls, + "response_format": Schema.Union([AssistantsApiResponseFormatOption, Schema.Null]) }).annotate({ - "title": "ScoreModelGrader", - "description": "A ScoreModelGrader object that uses a model to assign a score to the input.\n" -}) -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" + "title": "A run on a thread", + "description": "Represents an execution run on a [thread](/docs/api-reference/threads).", + "identifier": "RunObject" }) -export type CreateConversationBody = { - readonly "metadata"?: {} | null | null - readonly "items"?: ReadonlyArray | null +export type CreateRunRequest = { + readonly "assistant_id": string + readonly "model"?: string | AssistantSupportedModels | null + readonly "reasoning_effort"?: ReasoningEffort + readonly "instructions"?: string | null + readonly "additional_instructions"?: string | null + readonly "additional_messages"?: ReadonlyArray | null + readonly "tools"?: ReadonlyArray | null + readonly "metadata"?: Metadata + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "stream"?: boolean | null + readonly "max_prompt_tokens"?: number | null + readonly "max_completion_tokens"?: number | null + readonly "truncation_strategy"?: { + readonly "type": "auto" | "last_messages" + readonly "last_messages"?: number | null + } + readonly "tool_choice"?: "none" | "auto" | "required" | { + readonly "type": "function" | "code_interpreter" | "file_search" + readonly "function"?: { readonly "name": string } + } + readonly "parallel_tool_calls"?: ParallelToolCalls + readonly "response_format"?: AssistantsApiResponseFormatOption | null } -export const CreateConversationBody = Schema.Struct({ - "metadata": Schema.optionalKey(Schema.Union([ +export const CreateRunRequest = Schema.Struct({ + "assistant_id": Schema.String.annotate({ + "description": "The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run." + }), + "model": Schema.optionalKey( Schema.Union([ - Schema.Struct({}).annotate({ + Schema.Union([Schema.String, AssistantSupportedModels]).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" + "The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used." }), Schema.Null - ]).annotate({ + ]) + ), + "reasoning_effort": Schema.optionalKey(ReasoningEffort), + "instructions": Schema.optionalKey( + Schema.Union([Schema.String, 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( + "Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis." + }) + ), + "additional_instructions": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions." + }) + ), + "additional_messages": Schema.optionalKey( + Schema.Union([Schema.Array(CreateMessageRequest), Schema.Null]).annotate({ + "description": "Adds additional messages to the thread before creating the run." + }) + ), + "tools": 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.Array( + Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) + ).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 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( + ]).annotate({ + "description": + "Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis." + }) + ), + "metadata": Schema.optionalKey(Metadata), + "temperature": 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.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), Schema.Null - ]) + ]).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.\n" + }) ), - "input": Schema.optionalKey( + "top_p": 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.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), Schema.Null - ]) + ]).annotate({ + "description": + "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or temperature but not both.\n" + }) ), - "previous_response_id": Schema.optionalKey( + "stream": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.\n" + }) + ), + "max_prompt_tokens": 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.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(256).annotate({ "expected": "a value greater than or equal to 256" }) + ), Schema.Null - ]) + ]).annotate({ + "description": + "The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.\n" + }) ), - "tools": Schema.optionalKey( + "max_completion_tokens": 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.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(256).annotate({ "expected": "a value greater than or equal to 256" }) + ), Schema.Null - ]) + ]).annotate({ + "description": + "The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.\n" + }) ), - "text": Schema.optionalKey(Schema.Union([ResponseTextParam, Schema.Null])), - "reasoning": Schema.optionalKey(Schema.Union([ + "truncation_strategy": 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( + "type": Schema.Literals(["auto", "last_messages"]).annotate({ + "description": + "The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`." + }), + "last_messages": Schema.optionalKey( Schema.Union([ - Schema.Literals(["auto", "concise", "detailed"]).annotate({ + Schema.Number.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" - }), + "The number of most recent messages from the thread when constructing the context for the run." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), 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({ + "title": "Thread Truncation Controls", "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." + "Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run." }) - ), - "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([Schema.Literal("none"), Schema.Literal("auto"), Schema.Literal("required")]).annotate({ + "description": + "`none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.\n" + }), 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 - ]) + Schema.Struct({ + "type": Schema.Literals(["function", "code_interpreter", "file_search"]).annotate({ + "description": "The type of the tool. If type is `function`, the function name must be set" + }), + "function": Schema.optionalKey( + Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) }) + ) + }).annotate({ + "description": "Specifies a tool the model should use. Use to force the model to call a specific tool." + }) + ]) + ], { mode: "oneOf" }).annotate({ + "description": + "Controls which (if any) tool is called by the model.\n`none` means the model will not call any tools and instead generates a message.\n`auto` is the default value and means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools before responding to the user.\nSpecifying a particular tool like `{\"type\": \"file_search\"}` or `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n" + }) ), - "parallel_tool_calls": Schema.optionalKey( + "parallel_tool_calls": Schema.optionalKey(ParallelToolCalls), + "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) +}).annotate({ "identifier": "CreateRunRequest" }) +export type ResponseTextParam = { + readonly "format"?: TextResponseFormatConfiguration + readonly "verbosity"?: Verbosity +} +export const ResponseTextParam = Schema.Struct({ + "format": Schema.optionalKey(TextResponseFormatConfiguration), + "verbosity": Schema.optionalKey(Verbosity) +}).annotate({ + "description": + "Configuration options for a text response from the model. Can be plain\ntext or structured JSON data. Learn more:\n- [Text inputs and outputs](/docs/guides/text)\n- [Structured Outputs](/docs/guides/structured-outputs)\n", + "identifier": "ResponseTextParam" +}) +export type CreateChatCompletionResponse = { + readonly "id": string + readonly "choices": ReadonlyArray< + { + readonly "finish_reason": "stop" | "length" | "tool_calls" | "content_filter" | "function_call" + readonly "index": number + readonly "message": ChatCompletionResponseMessage + readonly "logprobs": { + readonly "content": ReadonlyArray | null + readonly "refusal": ReadonlyArray | null + } | null + } + > + readonly "created": number + readonly "model": string + readonly "service_tier"?: ServiceTier + readonly "system_fingerprint"?: string + readonly "object": "chat.completion" + readonly "usage"?: CompletionUsage + readonly "moderation"?: ChatCompletionModeration | null +} +export const CreateChatCompletionResponse = Schema.Struct({ + "id": Schema.String.annotate({ "description": "A unique identifier for the chat completion." }), + "choices": Schema.Array(Schema.Struct({ + "finish_reason": Schema.Literals(["stop", "length", "tool_calls", "content_filter", "function_call"]).annotate({ + "description": + "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\nRead the [Model Spec](https://model-spec.openai.com/2025-12-18.html) for more.\n" + }), + "index": Schema.Number.annotate({ "description": "The index of the choice in the list of choices." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "message": ChatCompletionResponseMessage, + "logprobs": Schema.Union([ + Schema.Struct({ + "content": Schema.Union([ + Schema.Array(ChatCompletionTokenLogprob).annotate({ + "description": "A list of message content tokens with log probability information." + }), + Schema.Null + ]), + "refusal": Schema.Union([ + Schema.Array(ChatCompletionTokenLogprob).annotate({ + "description": "A list of message refusal tokens with log probability information." + }), + Schema.Null + ]) + }).annotate({ "description": "Log probability information for the choice." }), + Schema.Null + ]) + })).annotate({ "description": "A list of chat completion choices. Can be more than one if `n` is greater than 1." }), + "created": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of when the chat completion was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "model": Schema.String.annotate({ "description": "The model used for the chat completion." }), + "service_tier": Schema.optionalKey(ServiceTier), + "system_fingerprint": Schema.optionalKey( + Schema.String.annotate({ + "description": + "This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" + }) + ), + "object": Schema.Literal("chat.completion").annotate({ + "description": "The object type, which is always `chat.completion`." + }), + "usage": Schema.optionalKey(CompletionUsage), + "moderation": Schema.optionalKey( Schema.Union([ - Schema.Boolean.annotate({ "description": "Whether to allow the model to run tool calls in parallel." }), + Schema.suspend((): Schema.Codec => ChatCompletionModeration).annotate({ + "description": + "Moderation results for the request input and generated output, if moderated\ncompletions were requested.\n" + }), Schema.Null ]) ) +}).annotate({ + "description": "Represents a chat completion response returned by model, based on the provided input.", + "identifier": "CreateChatCompletionResponse" }) -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 - readonly "prompt_cache_retention"?: "in_memory" | "in-memory" | "24h" | null - readonly "service_tier"?: "auto" | "default" | "flex" | "priority" | null +export type CreateChatCompletionStreamResponse = { + readonly "id": string + readonly "choices": ReadonlyArray< + { + readonly "delta": ChatCompletionStreamResponseDelta + readonly "logprobs"?: { + readonly "content": ReadonlyArray | null + readonly "refusal": ReadonlyArray | null + readonly [x: string]: Schema.Json + } | null + readonly "finish_reason": "stop" | "length" | "tool_calls" | "content_filter" | "function_call" | null + readonly "index": number + } + > + readonly "created": number + readonly "model": string + readonly "service_tier"?: ServiceTier + readonly "system_fingerprint"?: string + readonly "object": "chat.completion.chunk" + readonly "usage"?: CompletionUsage | null + readonly "moderation"?: ChatCompletionModeration | null } -export const CompactResponseMethodPublicBody = Schema.Struct({ - "model": ModelIdsCompaction, - "input": Schema.optionalKey( - Schema.Union([ +export const CreateChatCompletionStreamResponse = Schema.Struct({ + "id": Schema.String.annotate({ + "description": "A unique identifier for the chat completion. Each chunk has the same ID." + }), + "choices": Schema.Array(Schema.Struct({ + "delta": ChatCompletionStreamResponseDelta, + "logprobs": Schema.optionalKey( 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.StructWithRest( + Schema.Struct({ + "content": Schema.Union([Schema.Array(ChatCompletionTokenLogprob), Schema.Null]).annotate({ + "description": "A list of message content tokens with log probability information." + }), + "refusal": Schema.Union([Schema.Array(ChatCompletionTokenLogprob), Schema.Null]).annotate({ + "description": "A list of message refusal tokens with log probability information." + }) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ "description": "Log probability information for the choice." }) + ), + "finish_reason": Schema.Union([ + Schema.Literal("stop"), + Schema.Literal("length"), + Schema.Literal("tool_calls"), + Schema.Literal("content_filter"), + Schema.Literal("function_call"), + Schema.Null + ]).annotate({ + "description": + "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\n" + }), + "index": Schema.Number.annotate({ "description": "The index of the choice in the list of choices." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + })).annotate({ + "description": + "A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the\nlast chunk if you set `stream_options: {\"include_usage\": true}`.\n" + }), + "created": Schema.Number.annotate({ + "description": + "The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "model": Schema.String.annotate({ "description": "The model to generate the completion." }), + "service_tier": Schema.optionalKey(ServiceTier), + "system_fingerprint": Schema.optionalKey( + Schema.String.annotate({ + "description": + "This fingerprint represents the backend configuration that the model runs with.\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" + }) + ), + "object": Schema.Literal("chat.completion.chunk").annotate({ + "description": "The object type, which is always `chat.completion.chunk`." + }), + "usage": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => CompletionUsage).annotate({ + "description": + "An optional field that will only be present when you set\n`stream_options: {\"include_usage\": true}` in your request. When present, it\ncontains a null value **except for the last chunk** which contains the\ntoken usage statistics for the entire request.\n\n**NOTE:** If the stream is interrupted or cancelled, you may not\nreceive the final usage chunk which contains the total token usage for\nthe request.\n" }), Schema.Null ]) ), - "previous_response_id": Schema.optionalKey( + "moderation": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ + Schema.suspend((): Schema.Codec => ChatCompletionModeration).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`." + "Moderation results for the request input and generated output. Present\non the moderation chunk when moderated completions are requested.\n" }), Schema.Null ]) - ), - "instructions": Schema.optionalKey(Schema.Union([ + ) +}).annotate({ + "description": + "Represents a streamed chunk of a chat completion response returned\nby the model, based on the provided input. \n[Learn more](/docs/guides/streaming-responses).\n", + "identifier": "CreateChatCompletionStreamResponse" +}) +export type ChatCompletionRequestSystemMessage = { + readonly "content": string | ReadonlyArray + readonly "role": "system" + readonly "name"?: string +} +export const ChatCompletionRequestSystemMessage = Schema.Struct({ + "content": Schema.Union([ + Schema.String.annotate({ "title": "Text content", "description": "The contents of the system message." }), + Schema.Array(ChatCompletionRequestSystemMessageContentPart).annotate({ + "title": "Array of content parts", + "description": + "An array of content parts with a defined type. For system messages, only type `text` is supported." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ], { mode: "oneOf" }).annotate({ "description": "The contents of the system message." }), + "role": Schema.Literal("system").annotate({ + "description": "The role of the messages author, in this case `system`." + }), + "name": Schema.optionalKey( 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( + "An optional name for the participant. Provides the model information to differentiate between participants of the same role." + }) + ) +}).annotate({ + "title": "System message", + "description": + "Developer-provided instructions that the model should follow, regardless of\nmessages sent by the user. With o1 models and newer, use `developer` messages\nfor this purpose instead.\n", + "identifier": "ChatCompletionRequestSystemMessage" +}) +export type ChatCompletionRequestAssistantMessage = { + readonly "content"?: string | ReadonlyArray | null + readonly "refusal"?: string | null + readonly "role": "assistant" + readonly "name"?: string + readonly "audio"?: { readonly "id": string } | null + readonly "tool_calls"?: ChatCompletionMessageToolCalls + readonly "function_call"?: { readonly "arguments": string; readonly "name": string } | null +} +export const ChatCompletionRequestAssistantMessage = Schema.Struct({ + "content": 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.Union([ + Schema.String.annotate({ "title": "Text content", "description": "The contents of the assistant message." }), + Schema.Array(ChatCompletionRequestAssistantMessageContentPart).annotate({ + "title": "Array of content parts", + "description": + "An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ], { mode: "oneOf" }).annotate({ + "description": + "The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.\n" + }), Schema.Null ]) ), - "prompt_cache_retention": Schema.optionalKey( + "refusal": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The refusal message by the assistant." }), Schema.Null]) + ), + "role": Schema.Literal("assistant").annotate({ + "description": "The role of the messages author, in this case `assistant`." + }), + "name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "An optional name for the participant. Provides the model information to differentiate between participants of the same role." + }) + ), + "audio": Schema.optionalKey( Schema.Union([ - Schema.Literals(["in_memory", "in-memory", "24h"]).annotate({ - "description": "How long to retain a prompt cache entry created by this request." + Schema.Struct({ + "id": Schema.String.annotate({ + "description": "Unique identifier for a previous audio response from the model.\n" + }) + }).annotate({ + "description": "Data about a previous audio response from the model.\n[Learn more](/docs/guides/audio).\n" }), Schema.Null ]) ), - "service_tier": Schema.optionalKey( + "tool_calls": Schema.optionalKey(ChatCompletionMessageToolCalls), + "function_call": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "arguments": Schema.String.annotate({ + "description": + "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + }), + "name": Schema.String.annotate({ "description": "The name of the function to call." }) + }).annotate({ + "description": + "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model." + }), + Schema.Null + ])) +}).annotate({ + "title": "Assistant message", + "description": "Messages sent by the model in response to user messages.\n", + "identifier": "ChatCompletionRequestAssistantMessage" +}) +export type ChatCompletionRequestToolMessage = { + readonly "role": "tool" + readonly "content": string | ReadonlyArray + readonly "tool_call_id": string +} +export const ChatCompletionRequestToolMessage = Schema.Struct({ + "role": Schema.Literal("tool").annotate({ "description": "The role of the messages author, in this case `tool`." }), + "content": Schema.Union([ + Schema.String.annotate({ "title": "Text content", "description": "The contents of the tool message." }), + Schema.Array(ChatCompletionRequestToolMessageContentPart).annotate({ + "title": "Array of content parts", + "description": "An array of content parts with a defined type. For tool messages, only type `text` is supported." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ], { mode: "oneOf" }).annotate({ "description": "The contents of the tool message." }), + "tool_call_id": Schema.String.annotate({ "description": "Tool call that this message is responding to." }) +}).annotate({ "title": "Tool message", "identifier": "ChatCompletionRequestToolMessage" }) +export type ChatCompletionRequestUserMessage = { + readonly "content": string | ReadonlyArray + readonly "role": "user" + readonly "name"?: string +} +export const ChatCompletionRequestUserMessage = Schema.Struct({ + "content": Schema.Union([ + Schema.String.annotate({ "title": "Text content", "description": "The text contents of the message." }), + Schema.Array(ChatCompletionRequestUserMessageContentPart).annotate({ + "title": "Array of content parts", + "description": + "An array of content parts with a defined type. Supported options differ based on the [model](/docs/models) being used to generate the response. Can contain text, image, or audio inputs." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ], { mode: "oneOf" }).annotate({ "description": "The contents of the user message.\n" }), + "role": Schema.Literal("user").annotate({ "description": "The role of the messages author, in this case `user`." }), + "name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "An optional name for the participant. Provides the model information to differentiate between participants of the same role." + }) + ) +}).annotate({ + "title": "User message", + "description": "Messages sent by an end user, containing prompts or additional context\ninformation.\n", + "identifier": "ChatCompletionRequestUserMessage" +}) +export type ModerationParam = { readonly "model": string; readonly "policy"?: ModerationPolicyParam | null } +export const ModerationParam = Schema.Struct({ + "model": Schema.String.annotate({ + "description": "The moderation model to use for moderated completions, e.g. 'omni-moderation-latest'." + }), + "policy": Schema.optionalKey( Schema.Union([ - Schema.Literals(["auto", "default", "flex", "priority"]).annotate({ - "description": "The service tier to use for this request." + Schema.suspend((): Schema.Codec => ModerationPolicyParam).annotate({ + "description": "The policy to apply to moderated response input and output." }), Schema.Null ]) ) +}).annotate({ + "description": "Configuration for running moderation on the input and output of this response.", + "identifier": "ModerationParam" }) -export type ConversationItem = - | Message - | FunctionToolCallResource - | FunctionToolCallOutputResource - | FileSearchToolCall - | WebSearchToolCall - | ImageGenToolCall - | ComputerToolCall - | ComputerToolCallOutputResource - | ToolSearchCall - | ToolSearchOutput - | ReasoningItem - | CompactionBody - | 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, - ToolSearchCall, - ToolSearchOutput, - ReasoningItem, - CompactionBody, - 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 - | FileSearchToolCall - | ComputerToolCall - | ComputerToolCallOutputResource - | WebSearchToolCall - | FunctionToolCallResource - | FunctionToolCallOutputResource - | ToolSearchCall - | ToolSearchOutput - | ReasoningItem - | CompactionBody - | ImageGenToolCall - | CodeInterpreterToolCall - | LocalShellToolCall - | LocalShellToolCallOutput - | FunctionShellCall - | FunctionShellCallOutput - | ApplyPatchToolCall - | ApplyPatchToolCallOutput - | MCPListTools - | MCPApprovalRequest - | MCPApprovalResponseResource - | MCPToolCall - | CustomToolCallResource - | CustomToolCallOutputResource -export const ItemResource = Schema.Union([ - InputMessageResource, - OutputMessage, - FileSearchToolCall, - ComputerToolCall, - ComputerToolCallOutputResource, - WebSearchToolCall, - FunctionToolCallResource, - FunctionToolCallOutputResource, - ToolSearchCall, - ToolSearchOutput, - ReasoningItem, - CompactionBody, - ImageGenToolCall, - CodeInterpreterToolCall, - LocalShellToolCall, - LocalShellToolCallOutput, - FunctionShellCall, - FunctionShellCallOutput, - ApplyPatchToolCall, - ApplyPatchToolCallOutput, - MCPListTools, - MCPApprovalRequest, - MCPApprovalResponseResource, - MCPToolCall, - CustomToolCallResource, - CustomToolCallOutputResource -], { mode: "oneOf" }).annotate({ "description": "Content item used to generate a response.\n" }) -export type OutputItem = - | OutputMessage - | FileSearchToolCall - | FunctionToolCall - | FunctionToolCallOutputResource - | WebSearchToolCall - | ComputerToolCall - | ComputerToolCallOutputResource - | ReasoningItem - | ToolSearchCall - | ToolSearchOutput - | CompactionBody - | ImageGenToolCall - | CodeInterpreterToolCall - | LocalShellToolCall - | LocalShellToolCallOutput - | FunctionShellCall - | FunctionShellCallOutput - | ApplyPatchToolCall - | ApplyPatchToolCallOutput - | MCPToolCall - | MCPListTools - | MCPApprovalRequest - | MCPApprovalResponseResource - | CustomToolCall - | CustomToolCallOutputResource -export const OutputItem = Schema.Union([ - OutputMessage, - FileSearchToolCall, - FunctionToolCall, - FunctionToolCallOutputResource, - WebSearchToolCall, - ComputerToolCall, - ComputerToolCallOutputResource, - ReasoningItem, - ToolSearchCall, - ToolSearchOutput, - CompactionBody, - ImageGenToolCall, - CodeInterpreterToolCall, - LocalShellToolCall, - LocalShellToolCallOutput, - FunctionShellCall, - FunctionShellCallOutput, - ApplyPatchToolCall, - ApplyPatchToolCallOutput, - MCPToolCall, - MCPListTools, - MCPApprovalRequest, - MCPApprovalResponseResource, - CustomToolCall, - CustomToolCallOutputResource -], { mode: "oneOf" }) -export type ResponseOutputItemAddedEvent = { - readonly "type": "response.output_item.added" - readonly "output_index": number - readonly "sequence_number": number - readonly "item": - | OutputMessage - | FileSearchToolCall - | FunctionToolCall - | FunctionToolCallOutputResource - | WebSearchToolCall - | ComputerToolCall - | ComputerToolCallOutputResource - | ReasoningItem - | ToolSearchCall - | ToolSearchOutput - | CompactionBody - | ImageGenToolCall - | CodeInterpreterToolCall - | LocalShellToolCall - | LocalShellToolCallOutput - | FunctionShellCall - | FunctionShellCallOutput - | ApplyPatchToolCall - | ApplyPatchToolCallOutput - | MCPToolCall - | MCPListTools - | MCPApprovalRequest - | MCPApprovalResponseResource - | CustomToolCall - | CustomToolCallOutputResource +export type CodeInterpreterTool = { + readonly "type": "code_interpreter" + readonly "container": string | AutoCodeInterpreterToolParam + readonly "allowed_callers"?: ReadonlyArray | null } -export const ResponseOutputItemAddedEvent = Schema.Struct({ - "type": Schema.Literal("response.output_item.added").annotate({ - "description": "The type of the event. Always `response.output_item.added`.\n" +export const CodeInterpreterTool = Schema.Struct({ + "type": Schema.Literal("code_interpreter").annotate({ + "description": "The type of the code interpreter tool. Always `code_interpreter`.\n" }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item that was added.\n" }).check( - Schema.isInt() - ), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() - ), - "item": Schema.Union([ - OutputMessage, - FileSearchToolCall, - FunctionToolCall, - FunctionToolCallOutputResource, - WebSearchToolCall, - ComputerToolCall, - ComputerToolCallOutputResource, - ReasoningItem, - ToolSearchCall, - ToolSearchOutput, - CompactionBody, - ImageGenToolCall, - CodeInterpreterToolCall, - LocalShellToolCall, - LocalShellToolCallOutput, - FunctionShellCall, - FunctionShellCallOutput, - ApplyPatchToolCall, - ApplyPatchToolCallOutput, - MCPToolCall, - MCPListTools, - MCPApprovalRequest, - MCPApprovalResponseResource, - CustomToolCall, - CustomToolCallOutputResource - ], { mode: "oneOf" }).annotate({ "description": "The output item that was added.\n" }) -}).annotate({ "description": "Emitted when a new output item is added." }) -export type ResponseOutputItemDoneEvent = { - readonly "type": "response.output_item.done" - readonly "output_index": number - readonly "sequence_number": number - readonly "item": - | OutputMessage - | FileSearchToolCall - | FunctionToolCall - | FunctionToolCallOutputResource - | WebSearchToolCall - | ComputerToolCall - | ComputerToolCallOutputResource - | ReasoningItem - | ToolSearchCall - | ToolSearchOutput - | CompactionBody - | ImageGenToolCall - | CodeInterpreterToolCall - | LocalShellToolCall - | LocalShellToolCallOutput - | FunctionShellCall - | FunctionShellCallOutput - | ApplyPatchToolCall - | ApplyPatchToolCallOutput - | MCPToolCall - | MCPListTools - | MCPApprovalRequest - | MCPApprovalResponseResource - | CustomToolCall - | CustomToolCallOutputResource -} -export const ResponseOutputItemDoneEvent = Schema.Struct({ - "type": Schema.Literal("response.output_item.done").annotate({ - "description": "The type of the event. Always `response.output_item.done`.\n" + "container": Schema.Union([ + Schema.String.annotate({ "description": "The container ID." }), + AutoCodeInterpreterToolParam + ], { mode: "oneOf" }).annotate({ + "description": + "The code interpreter container. Can be a container ID or an object that\nspecifies uploaded file IDs to make available to your code, along with an\noptional `memory_limit` setting.\n" }), - "output_index": Schema.Number.annotate({ "description": "The index of the output item that was marked done.\n" }) - .check(Schema.isInt()), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( - Schema.isInt() - ), - "item": Schema.Union([ - OutputMessage, - FileSearchToolCall, - FunctionToolCall, - FunctionToolCallOutputResource, - WebSearchToolCall, - ComputerToolCall, - ComputerToolCallOutputResource, - ReasoningItem, - ToolSearchCall, - ToolSearchOutput, - CompactionBody, - ImageGenToolCall, - CodeInterpreterToolCall, - LocalShellToolCall, - LocalShellToolCallOutput, - FunctionShellCall, - FunctionShellCallOutput, - ApplyPatchToolCall, - ApplyPatchToolCallOutput, - MCPToolCall, - MCPListTools, - MCPApprovalRequest, - MCPApprovalResponseResource, - CustomToolCall, - CustomToolCallOutputResource - ], { mode: "oneOf" }).annotate({ "description": "The output item that was marked done.\n" }) -}).annotate({ "description": "Emitted when an output item is marked done." }) -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." + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(CallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]) + ) +}).annotate({ + "title": "Code interpreter", + "description": "A tool that runs Python code to help generate a response to a prompt.\n", + "identifier": "CodeInterpreterTool" }) -export type CreateEvalRequest = { - readonly "name"?: string - readonly "metadata"?: Metadata - readonly "data_source_config": - | { readonly "type": "custom"; readonly "item_schema": {}; readonly "include_sample_schema"?: boolean } - | { readonly "type": "logs"; readonly "metadata"?: {} } - | { readonly "type": "stored_completions"; readonly "metadata"?: {} } - readonly "testing_criteria": ReadonlyArray< - | CreateEvalLabelModelGrader - | EvalGraderStringCheck - | EvalGraderTextSimilarity - | EvalGraderPython - | EvalGraderScoreModel +export type FunctionShellToolParam = { + readonly "type": "shell" + readonly "environment"?: ContainerAutoParam | LocalEnvironmentParam | ContainerReferenceParam | null + readonly "allowed_callers"?: ReadonlyArray | null +} +export const FunctionShellToolParam = Schema.Struct({ + "type": Schema.Literal("shell").annotate({ "description": "The type of the shell tool. Always `shell`." }), + "environment": Schema.optionalKey( + Schema.Union([ + Schema.Union([ContainerAutoParam, LocalEnvironmentParam, ContainerReferenceParam], { mode: "oneOf" }), + Schema.Null + ]) + ), + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(CallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]) + ) +}).annotate({ + "title": "Shell tool", + "description": "A tool that allows the model to execute shell commands.", + "identifier": "FunctionShellToolParam" +}) +export type EvalItemContentArray = ReadonlyArray +export const EvalItemContentArray = Schema.Array(EvalItemContentItem).annotate({ + "title": "An array of Input text, Output text, Input image, and Input audio", + "description": + "A list of inputs, each of which may be either an input text, output text, input\nimage, or input audio object.\n", + "identifier": "EvalItemContentArray" +}) +export type Message = { + readonly "type": "message" + readonly "id": string + readonly "status": MessageStatus + readonly "role": MessageRole + readonly "content": ReadonlyArray< + | InputTextContent + | OutputTextContent + | TextContent + | SummaryTextContent + | ReasoningTextContent + | RefusalContent + | InputImageContent + | ComputerScreenshotContent + | InputFileContent > + readonly "phase"?: MessagePhase_2 | null } -export const CreateEvalRequest = Schema.Struct({ - "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the evaluation." })), - "metadata": Schema.optionalKey(Metadata), - "data_source_config": Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("custom").annotate({ "description": "The type of data source. Always `custom`." }), - "item_schema": Schema.Struct({}).annotate({ "description": "The json schema for each row in the data source." }), - "include_sample_schema": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether the eval should expect you to populate the sample namespace (ie, by generating responses off of your data source)" - }) - ) - }).annotate({ - "title": "CustomDataSourceConfig", - "description": - "The configuration for the data source used for the evaluation runs. Dictates the schema of the data used in the evaluation." +export const Message = Schema.Struct({ + "type": Schema.Literal("message").annotate({ "description": "The type of the message. Always set to `message`." }), + "id": Schema.String.annotate({ "description": "The unique ID of the message." }), + "status": Schema.suspend((): Schema.Codec => MessageStatus).annotate({ + "description": + "The status of item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API." + }), + "role": Schema.suspend((): Schema.Codec => MessageRole).annotate({ + "description": + "The role of the message. One of `unknown`, `user`, `assistant`, `system`, `critic`, `discriminator`, `developer`, or `tool`." + }), + "content": Schema.Array( + Schema.Union([ + InputTextContent, + OutputTextContent, + TextContent, + SummaryTextContent, + ReasoningTextContent, + RefusalContent, + InputImageContent, + ComputerScreenshotContent, + InputFileContent + ], { mode: "oneOf" }).annotate({ "description": "A content part that makes up an input or output item." }) + ).annotate({ "description": "The content of the message" }), + "phase": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => MessagePhase_2).annotate({ + "description": + "Labels an `assistant` message as intermediate commentary (`commentary`) or the final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when sending follow-up requests, preserve and resend phase on all assistant messages — dropping it can degrade performance. Not used for user messages." + }), + Schema.Null + ]) + ) +}).annotate({ "title": "Message", "description": "A message to or from the model.", "identifier": "Message" }) +export type OutputMessageContent = OutputTextContent | RefusalContent +export const OutputMessageContent = Schema.Union([OutputTextContent, RefusalContent], { mode: "oneOf" }).annotate({ + "identifier": "OutputMessageContent" +}) +export type OutputContent = OutputTextContent | RefusalContent | ReasoningTextContent +export const OutputContent = Schema.Union([OutputTextContent, RefusalContent, ReasoningTextContent], { mode: "oneOf" }) + .annotate({ "identifier": "OutputContent" }) +export type FunctionToolCallOutputResource = { + readonly "id": string + readonly "type": "function_call_output" + readonly "call_id": string + readonly "name"?: string + readonly "namespace"?: string + readonly "caller"?: ToolCallCallerParam | null + readonly "output": string | ReadonlyArray + readonly "status": "in_progress" | "completed" | "incomplete" + readonly "created_by"?: string +} +export const FunctionToolCallOutputResource = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the function call tool output.\n" }), + "type": Schema.Literal("function_call_output").annotate({ + "description": "The type of the function tool call output. Always `function_call_output`.\n" + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" + }), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "The name of the tool that produced the output.\n" }) + ), + "namespace": Schema.optionalKey( + Schema.String.annotate({ "description": "The namespace of the tool that produced the output.\n" }) + ), + "caller": Schema.optionalKey(Schema.Union([ToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the function call.\n" }), - Schema.Struct({ - "type": Schema.Literal("logs").annotate({ "description": "The type of data source. Always `logs`." }), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Metadata filters for the logs data source." }) - ) - }).annotate({ - "title": "LogsDataSourceConfig", + Schema.Array(FunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the function call.\n" + }) + ], { mode: "oneOf" }).annotate({ + "description": + "The output from the function call generated by your code.\nCan be a string or an list of output content.\n" + }), + "status": Schema.Union([Schema.Literal("in_progress"), Schema.Literal("completed"), Schema.Literal("incomplete")]) + .annotate({ "description": - "The configuration for the data source used for the evaluation runs. Dictates the schema of the data used in the evaluation." + "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" }), - Schema.Struct({ - "type": Schema.Literal("stored_completions").annotate({ - "description": "The type of data source. Always `stored_completions`." - }), - "metadata": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Metadata filters for the stored completions data source." }) - ) - }).annotate({ - "title": "StoredCompletionsDataSourceConfig", - "description": - "The configuration for the data source used for the evaluation runs. Dictates the schema of the data used in the evaluation." + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ) +}).annotate({ + "title": "Function tool call output", + "description": "The output of a function tool call.\n", + "identifier": "FunctionToolCallOutputResource" +}) +export type CustomToolCallOutput = { + readonly "type": "custom_tool_call_output" + readonly "id"?: string + readonly "call_id": string + readonly "caller"?: ToolCallCallerParam | null + readonly "output": string | ReadonlyArray +} +export const CustomToolCallOutput = Schema.Struct({ + "type": Schema.Literal("custom_tool_call_output").annotate({ + "description": "The type of the custom tool call output. Always `custom_tool_call_output`.\n" + }), + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The unique ID of the custom tool call output in the OpenAI platform.\n" }) + ), + "call_id": Schema.String.annotate({ + "description": "The call ID, used to map this custom tool call output to a custom tool call.\n" + }), + "caller": Schema.optionalKey(Schema.Union([ToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the custom tool call.\n" + }), + Schema.Array(FunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the custom tool call.\n" }) - ], { mode: "oneOf" }), - "testing_criteria": Schema.Array( - Schema.Union([ - CreateEvalLabelModelGrader, - EvalGraderStringCheck, - EvalGraderTextSimilarity, - EvalGraderPython, - EvalGraderScoreModel - ], { mode: "oneOf" }) - ).annotate({ + ], { mode: "oneOf" }).annotate({ "description": - "A list of graders for all eval runs in this group. Graders can reference variables in the data source using double curly braces notation, like `{{item.variable_name}}`. To reference the model's output, use the `sample` namespace (ie, `{{sample.output_text}}`)." + "The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n" }) -}).annotate({ "title": "CreateEvalRequest" }) -export type Eval = { - readonly "object": "eval" +}).annotate({ + "title": "Custom tool call output", + "description": "The output of a custom tool call from your code, being sent back to the model.\n", + "identifier": "CustomToolCallOutput" +}) +export type CustomToolCallOutputResource = { + readonly "type": "custom_tool_call_output" readonly "id": string - readonly "name": string - readonly "data_source_config": { readonly "type": "custom"; readonly "schema": {} } | { - readonly "type": "logs" - readonly "metadata"?: Metadata - readonly "schema": {} - } | { readonly "type": "stored_completions"; readonly "metadata"?: Metadata; readonly "schema": {} } - readonly "testing_criteria": ReadonlyArray< - EvalGraderLabelModel | EvalGraderStringCheck | EvalGraderTextSimilarity | EvalGraderPython | EvalGraderScoreModel - > - readonly "created_at": number - readonly "metadata": Metadata + readonly "call_id": string + readonly "caller"?: ToolCallCallerParam | null + readonly "output": string | ReadonlyArray + readonly "status": FunctionCallOutputStatusEnum + readonly "created_by"?: string } -export const Eval = Schema.Struct({ - "object": Schema.Literal("eval").annotate({ "description": "The object type." }), - "id": Schema.String.annotate({ "description": "Unique identifier for the evaluation." }), - "name": Schema.String.annotate({ "description": "The name of the evaluation." }), - "data_source_config": Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("custom").annotate({ "description": "The type of data source. Always `custom`." }), - "schema": Schema.Struct({}).annotate({ - "description": - "The json schema for the run data source items.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n" - }) - }).annotate({ - "title": "CustomDataSourceConfig", - "description": "Configuration of data sources used in runs of the evaluation." +export const CustomToolCallOutputResource = Schema.Struct({ + "type": Schema.Literal("custom_tool_call_output").annotate({ + "description": "The type of the custom tool call output. Always `custom_tool_call_output`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the custom tool call output item.\n" }), + "call_id": Schema.String.annotate({ + "description": "The call ID, used to map this custom tool call output to a custom tool call.\n" + }), + "caller": Schema.optionalKey(Schema.Union([ToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the custom tool call.\n" }), - Schema.Struct({ - "type": Schema.Literal("logs").annotate({ "description": "The type of data source. Always `logs`." }), - "metadata": Schema.optionalKey(Metadata), - "schema": Schema.Struct({}).annotate({ - "description": - "The json schema for the run data source items.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n" - }) - }).annotate({ - "title": "LogsDataSourceConfig", - "description": "Configuration of data sources used in runs of the evaluation." + Schema.Array(FunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the custom tool call.\n" + }) + ], { mode: "oneOf" }).annotate({ + "description": + "The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n" + }), + "status": Schema.suspend((): Schema.Codec => FunctionCallOutputStatusEnum).annotate({ + "description": + "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ) +}).annotate({ + "title": "ResponseCustomToolCallOutputItem", + "description": "The output of a custom tool call from your code, being sent back to the model.\n", + "identifier": "CustomToolCallOutputResource" +}) +export type FunctionToolCallOutput = { + readonly "id"?: string + readonly "type": "function_call_output" + readonly "call_id": string + readonly "name"?: string + readonly "namespace"?: string + readonly "caller"?: ToolCallCallerParam | null + readonly "output": string | ReadonlyArray + readonly "status"?: "in_progress" | "completed" | "incomplete" +} +export const FunctionToolCallOutput = Schema.Struct({ + "id": Schema.optionalKey( + Schema.String.annotate({ + "description": "The unique ID of the function tool call output. Populated when this item\nis returned via API.\n" + }) + ), + "type": Schema.Literal("function_call_output").annotate({ + "description": "The type of the function tool call output. Always `function_call_output`.\n" + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" + }), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "The name of the tool that produced the output.\n" }) + ), + "namespace": Schema.optionalKey( + Schema.String.annotate({ "description": "The namespace of the tool that produced the output.\n" }) + ), + "caller": Schema.optionalKey(Schema.Union([ToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the function call.\n" }), - Schema.Struct({ - "type": Schema.Literal("stored_completions").annotate({ - "description": "The type of data source. Always `stored_completions`." - }), - "metadata": Schema.optionalKey(Metadata), - "schema": Schema.Struct({}).annotate({ - "description": - "The json schema for the run data source items.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n" - }) - }).annotate({ - "title": "StoredCompletionsDataSourceConfig", - "description": "Configuration of data sources used in runs of the evaluation." + Schema.Array(FunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the function call.\n" }) - ], { mode: "oneOf" }), - "testing_criteria": Schema.Array( - Schema.Union([ - EvalGraderLabelModel, - EvalGraderStringCheck, - EvalGraderTextSimilarity, - EvalGraderPython, - EvalGraderScoreModel - ], { mode: "oneOf" }) - ).annotate({ "description": "A list of testing criteria." }), - "created_at": Schema.Number.annotate({ - "description": "The Unix timestamp (in seconds) for when the eval was created.", - "format": "unixtime" - }).check(Schema.isInt()), - "metadata": Metadata + ], { mode: "oneOf" }).annotate({ + "description": + "The output from the function call generated by your code.\nCan be a string or an list of output content.\n" + }), + "status": Schema.optionalKey( + 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": "Eval", + "title": "Function tool call output", + "description": "The output of a function tool call.\n", + "identifier": "FunctionToolCallOutput" +}) +export type InputMessageContentList = ReadonlyArray +export const InputMessageContentList = Schema.Array(InputContent).annotate({ + "title": "Input item content list", + "description": "A list of one or many input items to the model, containing different content \ntypes.\n", + "identifier": "InputMessageContentList" +}) +export type ComputerActionList = ReadonlyArray +export const ComputerActionList = Schema.Array(ComputerAction).annotate({ + "title": "Computer Action List", "description": - "An Eval object with a data source config and testing criteria.\nAn Eval represents a task to be done for your LLM integration.\nLike:\n - Improve the quality of my chatbot\n - See how well my chatbot handles customer support\n - Check if o4-mini is better at my usecase than gpt-4o\n" + "Flattened batched actions for `computer_use`. Each action includes an\n`type` discriminator and action-specific fields.\n", + "identifier": "ComputerActionList" }) -export type EvalRunList = { - readonly "object": "list" - readonly "data": ReadonlyArray - readonly "first_id": string - readonly "last_id": string - readonly "has_more": boolean +export type FileSearchTool = { + readonly "type": "file_search" + readonly "vector_store_ids": ReadonlyArray + readonly "max_num_results"?: number + readonly "ranking_options"?: RankingOptions + readonly "filters"?: Filters | null } -export const EvalRunList = Schema.Struct({ - "object": Schema.Literal("list").annotate({ - "description": "The type of this object. It is always set to \"list\".\n" +export const FileSearchTool = Schema.Struct({ + "type": Schema.Literal("file_search").annotate({ + "description": "The type of the file search tool. Always `file_search`." }), - "data": Schema.Array(EvalRun).annotate({ "description": "An array of eval run objects.\n" }), - "first_id": Schema.String.annotate({ "description": "The identifier of the first eval run in the data array." }), - "last_id": Schema.String.annotate({ "description": "The identifier of the last eval run in the data array." }), - "has_more": Schema.Boolean.annotate({ "description": "Indicates whether there are more evals available." }) -}).annotate({ "title": "EvalRunList", "description": "An object representing a list of runs for an evaluation.\n" }) -export type FineTuneReinforcementMethod = { - readonly "grader": - | { - readonly "type": "string_check" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "operation": "eq" | "ne" | "like" | "ilike" - } - | { - readonly "type": "text_similarity" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "evaluation_metric": - | "cosine" - | "fuzzy_match" - | "bleu" - | "gleu" - | "meteor" - | "rouge_1" - | "rouge_2" - | "rouge_3" - | "rouge_4" - | "rouge_5" - | "rouge_l" - } - | { readonly "type": "python"; readonly "name": string; readonly "source": string; readonly "image_tag"?: string } - | { - readonly "type": "score_model" - readonly "name": string - readonly "model": string - readonly "sampling_params"?: { - readonly "seed"?: number | null - readonly "top_p"?: number | null - readonly "temperature"?: number | null - readonly "max_completions_tokens"?: number | null - readonly "reasoning_effort"?: ReasoningEffort - } - readonly "input": ReadonlyArray - readonly "range"?: ReadonlyArray - } - | { - readonly "type": "multi" - readonly "name": string - readonly "graders": GraderStringCheck | GraderTextSimilarity | GraderPython | GraderScoreModel | GraderLabelModel - readonly "calculate_output": string - } - readonly "hyperparameters"?: FineTuneReinforcementHyperparameters + "vector_store_ids": Schema.Array(Schema.String).annotate({ + "description": "The IDs of the vector stores to search." + }), + "max_num_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum number of results to return. This number should be between 1 and 50 inclusive." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "ranking_options": Schema.optionalKey( + Schema.suspend((): Schema.Codec => RankingOptions).annotate({ + "description": "Ranking options for search." + }) + ), + "filters": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Filters).annotate({ "description": "A filter to apply." }), + Schema.Null + ]) + ) +}).annotate({ + "title": "File search", + "description": + "A tool that searches for relevant content from uploaded files. Learn more about the [file search tool](https://platform.openai.com/docs/guides/tools-file-search).", + "identifier": "FileSearchTool" +}) +export type NamespaceToolParam = { + readonly "type": "namespace" + readonly "name": string + readonly "description": string + readonly "tools": ReadonlyArray } -export const FineTuneReinforcementMethod = Schema.Struct({ - "grader": Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("string_check").annotate({ - "description": "The object type, which is always `string_check`." - }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), - "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), - "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ - "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." - }) - }).annotate({ "title": "StringCheckGrader", "description": "The grader used for the fine-tuning job." }), - Schema.Struct({ - "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The text being graded." }), - "reference": Schema.String.annotate({ "description": "The text being graded against." }), - "evaluation_metric": Schema.Literals([ - "cosine", - "fuzzy_match", - "bleu", - "gleu", - "meteor", - "rouge_1", - "rouge_2", - "rouge_3", - "rouge_4", - "rouge_5", - "rouge_l" - ]).annotate({ - "description": - "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" - }) - }).annotate({ "title": "TextSimilarityGrader", "description": "The grader used for the fine-tuning job." }), +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).annotate({ "expected": "a value with a length of at least 1" })), + "description": Schema.String.annotate({ "description": "A description of the namespace shown to the model." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 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({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ + "title": "Namespace", + "description": "Groups function/custom tools under a shared namespace.", + "identifier": "NamespaceToolParam" +}) +export type AuditLog = { + readonly "id": string + readonly "type": AuditLogEventType + readonly "effective_at": number + readonly "project"?: { readonly "id"?: string; readonly "name"?: string } + readonly "actor"?: AuditLogActor | null + readonly "api_key.created"?: { + readonly "id"?: string + readonly "data"?: { readonly "scopes"?: ReadonlyArray } + } + readonly "api_key.updated"?: { + readonly "id"?: string + readonly "changes_requested"?: { readonly "scopes"?: ReadonlyArray } + } + readonly "api_key.deleted"?: { readonly "id"?: string } + readonly "checkpoint.permission.created"?: { + readonly "id"?: string + readonly "data"?: { readonly "project_id"?: string; readonly "fine_tuned_model_checkpoint"?: string } + } + readonly "checkpoint.permission.deleted"?: { readonly "id"?: string } + readonly "external_key.registered"?: { readonly "id"?: string; readonly "data"?: {} } + readonly "external_key.removed"?: { readonly "id"?: string } + readonly "group.created"?: { readonly "id"?: string; readonly "data"?: { readonly "group_name"?: string } } + readonly "group.updated"?: { + readonly "id"?: string + readonly "changes_requested"?: { readonly "group_name"?: string } + } + readonly "group.deleted"?: { readonly "id"?: string } + readonly "scim.enabled"?: { readonly "id"?: string } + readonly "scim.disabled"?: { readonly "id"?: string } + readonly "invite.sent"?: { + readonly "id"?: string + readonly "data"?: { readonly "email"?: string; readonly "role"?: string } + } + readonly "invite.accepted"?: { readonly "id"?: string } + readonly "invite.deleted"?: { readonly "id"?: string } + readonly "ip_allowlist.created"?: { + readonly "id"?: string + readonly "name"?: string + readonly "allowed_ips"?: ReadonlyArray + } + readonly "ip_allowlist.updated"?: { readonly "id"?: string; readonly "allowed_ips"?: ReadonlyArray } + readonly "ip_allowlist.deleted"?: { + readonly "id"?: string + readonly "name"?: string + readonly "allowed_ips"?: ReadonlyArray + } + readonly "ip_allowlist.config.activated"?: { + readonly "configs"?: ReadonlyArray<{ readonly "id"?: string; readonly "name"?: string }> + } + readonly "ip_allowlist.config.deactivated"?: { + readonly "configs"?: ReadonlyArray<{ readonly "id"?: string; readonly "name"?: string }> + } + readonly "login.succeeded"?: {} + readonly "login.failed"?: { readonly "error_code"?: string; readonly "error_message"?: string } + readonly "logout.succeeded"?: {} + readonly "logout.failed"?: { readonly "error_code"?: string; readonly "error_message"?: string } + readonly "organization.updated"?: { + readonly "id"?: string + readonly "changes_requested"?: { + readonly "title"?: string + readonly "description"?: string + readonly "name"?: string + readonly "threads_ui_visibility"?: string + readonly "usage_dashboard_visibility"?: string + readonly "api_call_logging"?: string + readonly "api_call_logging_project_ids"?: string + } + } + readonly "project.created"?: { + readonly "id"?: string + readonly "data"?: { readonly "name"?: string; readonly "title"?: string } + } + readonly "project.updated"?: { readonly "id"?: string; readonly "changes_requested"?: { readonly "title"?: string } } + readonly "project.archived"?: { readonly "id"?: string } + readonly "project.deleted"?: { readonly "id"?: string } + readonly "rate_limit.updated"?: { + readonly "id"?: string + readonly "changes_requested"?: { + readonly "max_requests_per_1_minute"?: number + readonly "max_tokens_per_1_minute"?: number + readonly "max_images_per_1_minute"?: number + readonly "max_audio_megabytes_per_1_minute"?: number + readonly "max_requests_per_1_day"?: number + readonly "batch_1_day_max_input_tokens"?: number + } + } + readonly "rate_limit.deleted"?: { readonly "id"?: string } + readonly "role.created"?: { + readonly "id"?: string + readonly "role_name"?: string + readonly "permissions"?: ReadonlyArray + readonly "resource_type"?: string + readonly "resource_id"?: string + } + readonly "role.updated"?: { + readonly "id"?: string + readonly "changes_requested"?: { + readonly "role_name"?: string + readonly "resource_id"?: string + readonly "resource_type"?: string + readonly "permissions_added"?: ReadonlyArray + readonly "permissions_removed"?: ReadonlyArray + readonly "description"?: string + readonly "metadata"?: {} + } + } + readonly "role.deleted"?: { readonly "id"?: string } + readonly "role.assignment.created"?: { + readonly "id"?: string + readonly "principal_id"?: string + readonly "principal_type"?: string + readonly "resource_id"?: string + readonly "resource_type"?: string + } + readonly "role.assignment.deleted"?: { + readonly "id"?: string + readonly "principal_id"?: string + readonly "principal_type"?: string + readonly "resource_id"?: string + readonly "resource_type"?: string + } + readonly "role.bound_to_resource"?: { + readonly "id"?: string + readonly "role_id"?: string + readonly "resource_id"?: string + readonly "resource_type"?: string + readonly "permissions"?: ReadonlyArray + readonly "workspace_id"?: string + readonly "connector_id"?: string + readonly "connector_name"?: string + readonly "enabled"?: boolean + readonly "source"?: + | "role_toggle" + | "role_connector_update" + | "role_delete" + | "workspace_permissions" + | "connector_publish" + } + readonly "role.unbound_from_resource"?: { + readonly "id"?: string + readonly "role_id"?: string + readonly "resource_id"?: string + readonly "resource_type"?: string + readonly "permissions"?: ReadonlyArray + readonly "workspace_id"?: string + readonly "connector_id"?: string + readonly "connector_name"?: string + readonly "enabled"?: boolean + readonly "source"?: + | "role_toggle" + | "role_connector_update" + | "role_delete" + | "workspace_permissions" + | "connector_publish" + } + readonly "service_account.created"?: { readonly "id"?: string; readonly "data"?: { readonly "role"?: string } } + readonly "service_account.updated"?: { + readonly "id"?: string + readonly "changes_requested"?: { readonly "role"?: string } + } + readonly "service_account.deleted"?: { readonly "id"?: string } + readonly "workload_identity_provider.created"?: { readonly "id"?: string; readonly "data"?: {} } + readonly "workload_identity_provider.updated"?: { readonly "id"?: string; readonly "changes_requested"?: {} } + readonly "workload_identity_provider.deleted"?: { readonly "id"?: string; readonly "name"?: string } + readonly "workload_identity_provider_mapping.created"?: { + readonly "id"?: string + readonly "identity_provider_id"?: string + readonly "data"?: {} + } + readonly "workload_identity_provider_mapping.updated"?: { + readonly "id"?: string + readonly "identity_provider_id"?: string + readonly "changes_requested"?: {} + } + readonly "workload_identity_provider_mapping.deleted"?: { + readonly "id"?: string + readonly "identity_provider_id"?: string + readonly "project_id"?: string + readonly "service_account_id"?: string + } + readonly "user.added"?: { readonly "id"?: string; readonly "data"?: { readonly "role"?: string } } + readonly "user.updated"?: { readonly "id"?: string; readonly "changes_requested"?: { readonly "role"?: string } } + readonly "user.deleted"?: { readonly "id"?: string } + readonly "certificate.created"?: { readonly "id"?: string; readonly "name"?: string } + readonly "certificate.updated"?: { readonly "id"?: string; readonly "name"?: string } + readonly "certificate.deleted"?: { readonly "id"?: string; readonly "name"?: string; readonly "certificate"?: string } + readonly "certificates.activated"?: { + readonly "certificates"?: ReadonlyArray<{ readonly "id"?: string; readonly "name"?: string }> + } + readonly "certificates.deactivated"?: { + readonly "certificates"?: ReadonlyArray<{ readonly "id"?: string; readonly "name"?: string }> + } +} +export const AuditLog = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The ID of this log." }), + "type": AuditLogEventType, + "effective_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) of the event.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "project": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "source": Schema.String.annotate({ "description": "The source code of the python script." }), - "image_tag": Schema.optionalKey( - Schema.String.annotate({ "description": "The image tag to use for the python script." }) + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The project title." })) + }).annotate({ + "description": + "The project that the action was scoped to. Absent for actions not scoped to projects. Note that any admin actions taken via Admin API keys are associated with the default project." + }) + ), + "actor": Schema.optionalKey(Schema.Union([AuditLogActor, Schema.Null])), + "api_key.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The tracking ID of the API key." })), + "data": Schema.optionalKey( + Schema.Struct({ + "scopes": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "A list of scopes allowed for the API key, e.g. `[\"api.model.request\"]`" + }) + ) + }).annotate({ "description": "The payload used to create the API key." }) ) - }).annotate({ "title": "PythonGrader", "description": "The grader used for the fine-tuning job." }), + }).annotate({ "description": "The details for events with this `type`." }) + ), + "api_key.updated": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("score_model").annotate({ - "description": "The object type, which is always `score_model`." - }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), - "sampling_params": Schema.optionalKey( + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The tracking ID of the API key." })), + "changes_requested": Schema.optionalKey( Schema.Struct({ - "seed": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) - .check(Schema.isInt()), - Schema.Null - ]) + "scopes": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "A list of scopes allowed for the API key, e.g. `[\"api.model.request\"]`" + }) + ) + }).annotate({ "description": "The payload used to update the API key." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "api_key.deleted": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The tracking ID of the API key." })) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "checkpoint.permission.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the checkpoint permission." })), + "data": Schema.optionalKey( + Schema.Struct({ + "project_id": Schema.optionalKey( + Schema.String.annotate({ + "description": "The ID of the project that the checkpoint permission was created for." + }) ), - "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) - .check(Schema.isFinite()), - Schema.Null - ]) - ), - "max_completions_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The maximum number of tokens the grader model may generate in its response.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - Schema.Null - ]) - ), - "reasoning_effort": Schema.optionalKey(ReasoningEffort) - }).annotate({ "description": "The sampling parameters for the model." }) - ), - "input": Schema.Array(EvalItem).annotate({ - "description": - "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" - }), - "range": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isFinite())).annotate({ - "description": "The range of the score. Defaults to `[0, 1]`." - }) + "fine_tuned_model_checkpoint": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the fine-tuned model checkpoint." }) + ) + }).annotate({ "description": "The payload used to create the checkpoint permission." }) ) - }).annotate({ "title": "ScoreModelGrader", "description": "The grader used for the fine-tuning job." }), + }).annotate({ + "description": "The project and fine-tuned model checkpoint that the checkpoint permission was created for." + }) + ), + "checkpoint.permission.deleted": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("multi").annotate({ "description": "The object type, which is always `multi`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "graders": Schema.Union([ - GraderStringCheck, - GraderTextSimilarity, - GraderPython, - GraderScoreModel, - GraderLabelModel - ], { mode: "oneOf" }), - "calculate_output": Schema.String.annotate({ - "description": "A formula to calculate the output based on grader results." - }) - }).annotate({ "title": "MultiGrader", "description": "The grader used for the fine-tuning job." }) - ], { mode: "oneOf" }), - "hyperparameters": Schema.optionalKey(FineTuneReinforcementHyperparameters) -}).annotate({ "description": "Configuration for the reinforcement fine-tuning method." }) -export type RunGraderRequest = { - readonly "grader": - | { - readonly "type": "string_check" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "operation": "eq" | "ne" | "like" | "ilike" - } - | { - readonly "type": "text_similarity" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "evaluation_metric": - | "cosine" - | "fuzzy_match" - | "bleu" - | "gleu" - | "meteor" - | "rouge_1" - | "rouge_2" - | "rouge_3" - | "rouge_4" - | "rouge_5" - | "rouge_l" - } - | { readonly "type": "python"; readonly "name": string; readonly "source": string; readonly "image_tag"?: string } - | { - readonly "type": "score_model" - readonly "name": string - readonly "model": string - readonly "sampling_params"?: { - readonly "seed"?: number | null - readonly "top_p"?: number | null - readonly "temperature"?: number | null - readonly "max_completions_tokens"?: number | null - readonly "reasoning_effort"?: ReasoningEffort - } - readonly "input": ReadonlyArray - readonly "range"?: ReadonlyArray - } - | { - readonly "type": "multi" - readonly "name": string - readonly "graders": GraderStringCheck | GraderTextSimilarity | GraderPython | GraderScoreModel | GraderLabelModel - readonly "calculate_output": string - } - readonly "item"?: {} - readonly "model_sample": string -} -export const RunGraderRequest = Schema.Struct({ - "grader": Schema.Union([ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the checkpoint permission." })) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "external_key.registered": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("string_check").annotate({ - "description": "The object type, which is always `string_check`." - }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), - "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), - "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ - "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." - }) - }).annotate({ "title": "StringCheckGrader", "description": "The grader used for the fine-tuning job." }), + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the external key configuration." })), + "data": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "The configuration for the external key." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "external_key.removed": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The text being graded." }), - "reference": Schema.String.annotate({ "description": "The text being graded against." }), - "evaluation_metric": Schema.Literals([ - "cosine", - "fuzzy_match", - "bleu", - "gleu", - "meteor", - "rouge_1", - "rouge_2", - "rouge_3", - "rouge_4", - "rouge_5", - "rouge_l" - ]).annotate({ - "description": - "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" - }) - }).annotate({ "title": "TextSimilarityGrader", "description": "The grader used for the fine-tuning job." }), + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the external key configuration." })) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "group.created": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "source": Schema.String.annotate({ "description": "The source code of the python script." }), - "image_tag": Schema.optionalKey( - Schema.String.annotate({ "description": "The image tag to use for the python script." }) + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the group." })), + "data": Schema.optionalKey( + Schema.Struct({ + "group_name": Schema.optionalKey(Schema.String.annotate({ "description": "The group name." })) + }).annotate({ "description": "Information about the created group." }) ) - }).annotate({ "title": "PythonGrader", "description": "The grader used for the fine-tuning job." }), + }).annotate({ "description": "The details for events with this `type`." }) + ), + "group.updated": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("score_model").annotate({ - "description": "The object type, which is always `score_model`." - }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), - "sampling_params": Schema.optionalKey( + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the group." })), + "changes_requested": Schema.optionalKey( Schema.Struct({ - "seed": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) - .check(Schema.isInt()), - Schema.Null - ]) - ), - "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) - .check(Schema.isFinite()), - Schema.Null - ]) - ), - "max_completions_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The maximum number of tokens the grader model may generate in its response.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - Schema.Null - ]) - ), - "reasoning_effort": Schema.optionalKey(ReasoningEffort) - }).annotate({ "description": "The sampling parameters for the model." }) - ), - "input": Schema.Array(EvalItem).annotate({ - "description": - "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" - }), - "range": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isFinite())).annotate({ - "description": "The range of the score. Defaults to `[0, 1]`." - }) + "group_name": Schema.optionalKey(Schema.String.annotate({ "description": "The updated group name." })) + }).annotate({ "description": "The payload used to update the group." }) ) - }).annotate({ "title": "ScoreModelGrader", "description": "The grader used for the fine-tuning job." }), + }).annotate({ "description": "The details for events with this `type`." }) + ), + "group.deleted": Schema.optionalKey( + Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the group." })) }) + .annotate({ "description": "The details for events with this `type`." }) + ), + "scim.enabled": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("multi").annotate({ "description": "The object type, which is always `multi`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "graders": Schema.Union([ - GraderStringCheck, - GraderTextSimilarity, - GraderPython, - GraderScoreModel, - GraderLabelModel - ], { mode: "oneOf" }), - "calculate_output": Schema.String.annotate({ - "description": "A formula to calculate the output based on grader results." - }) - }).annotate({ "title": "MultiGrader", "description": "The grader used for the fine-tuning job." }) - ], { mode: "oneOf" }), - "item": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "The dataset item provided to the grader. This will be used to populate \nthe `item` namespace. See [the guide](/docs/guides/graders) for more details. \n" - }) + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the SCIM was enabled for." })) + }).annotate({ "description": "The details for events with this `type`." }) ), - "model_sample": Schema.String.annotate({ - "description": - "The model sample to be evaluated. This value will be used to populate \nthe `sample` namespace. See [the guide](/docs/guides/graders) for more details.\nThe `output_json` variable will be populated if the model sample is a \nvalid JSON string.\n \n" - }) -}).annotate({ "title": "RunGraderRequest" }) -export type ValidateGraderRequest = { - readonly "grader": - | { - readonly "type": "string_check" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "operation": "eq" | "ne" | "like" | "ilike" - } - | { - readonly "type": "text_similarity" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "evaluation_metric": - | "cosine" - | "fuzzy_match" - | "bleu" - | "gleu" - | "meteor" - | "rouge_1" - | "rouge_2" - | "rouge_3" - | "rouge_4" - | "rouge_5" - | "rouge_l" - } - | { readonly "type": "python"; readonly "name": string; readonly "source": string; readonly "image_tag"?: string } - | { - readonly "type": "score_model" - readonly "name": string - readonly "model": string - readonly "sampling_params"?: { - readonly "seed"?: number | null - readonly "top_p"?: number | null - readonly "temperature"?: number | null - readonly "max_completions_tokens"?: number | null - readonly "reasoning_effort"?: ReasoningEffort - } - readonly "input": ReadonlyArray - readonly "range"?: ReadonlyArray - } - | { - readonly "type": "multi" - readonly "name": string - readonly "graders": GraderStringCheck | GraderTextSimilarity | GraderPython | GraderScoreModel | GraderLabelModel - readonly "calculate_output": string - } -} -export const ValidateGraderRequest = Schema.Struct({ - "grader": Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("string_check").annotate({ - "description": "The object type, which is always `string_check`." - }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), - "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), - "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ - "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." - }) - }).annotate({ "title": "StringCheckGrader", "description": "The grader used for the fine-tuning job." }), - Schema.Struct({ - "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The text being graded." }), - "reference": Schema.String.annotate({ "description": "The text being graded against." }), - "evaluation_metric": Schema.Literals([ - "cosine", - "fuzzy_match", - "bleu", - "gleu", - "meteor", - "rouge_1", - "rouge_2", - "rouge_3", - "rouge_4", - "rouge_5", - "rouge_l" - ]).annotate({ - "description": - "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" - }) - }).annotate({ "title": "TextSimilarityGrader", "description": "The grader used for the fine-tuning job." }), + "scim.disabled": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "source": Schema.String.annotate({ "description": "The source code of the python script." }), - "image_tag": Schema.optionalKey( - Schema.String.annotate({ "description": "The image tag to use for the python script." }) - ) - }).annotate({ "title": "PythonGrader", "description": "The grader used for the fine-tuning job." }), + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the SCIM was disabled for." })) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "invite.sent": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("score_model").annotate({ - "description": "The object type, which is always `score_model`." - }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), - "sampling_params": Schema.optionalKey( + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the invite." })), + "data": Schema.optionalKey( Schema.Struct({ - "seed": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) - .check(Schema.isInt()), - Schema.Null - ]) - ), - "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) - .check(Schema.isFinite()), - Schema.Null - ]) - ), - "max_completions_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The maximum number of tokens the grader model may generate in its response.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - Schema.Null - ]) + "email": Schema.optionalKey( + Schema.String.annotate({ "description": "The email invited to the organization." }) ), - "reasoning_effort": Schema.optionalKey(ReasoningEffort) - }).annotate({ "description": "The sampling parameters for the model." }) + "role": Schema.optionalKey( + Schema.String.annotate({ + "description": "The role the email was invited to be. Is either `owner` or `member`." + }) + ) + }).annotate({ "description": "The payload used to create the invite." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "invite.accepted": Schema.optionalKey( + Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the invite." })) }) + .annotate({ "description": "The details for events with this `type`." }) + ), + "invite.deleted": Schema.optionalKey( + Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the invite." })) }) + .annotate({ "description": "The details for events with this `type`." }) + ), + "ip_allowlist.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." })), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "The name of the IP allowlist configuration." }) ), - "input": Schema.Array(EvalItem).annotate({ - "description": - "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" - }), - "range": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isFinite())).annotate({ - "description": "The range of the score. Defaults to `[0, 1]`." + "allowed_ips": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "The IP addresses or CIDR ranges included in the configuration." }) ) - }).annotate({ "title": "ScoreModelGrader", "description": "The grader used for the fine-tuning job." }), + }).annotate({ "description": "The details for events with this `type`." }) + ), + "ip_allowlist.updated": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("multi").annotate({ "description": "The object type, which is always `multi`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "graders": Schema.Union([ - GraderStringCheck, - GraderTextSimilarity, - GraderPython, - GraderScoreModel, - GraderLabelModel - ], { mode: "oneOf" }), - "calculate_output": Schema.String.annotate({ - "description": "A formula to calculate the output based on grader results." - }) - }).annotate({ "title": "MultiGrader", "description": "The grader used for the fine-tuning job." }) - ], { mode: "oneOf" }) -}).annotate({ "title": "ValidateGraderRequest" }) -export type ValidateGraderResponse = { - readonly "grader"?: - | { - readonly "type": "string_check" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "operation": "eq" | "ne" | "like" | "ilike" - } - | { - readonly "type": "text_similarity" - readonly "name": string - readonly "input": string - readonly "reference": string - readonly "evaluation_metric": - | "cosine" - | "fuzzy_match" - | "bleu" - | "gleu" - | "meteor" - | "rouge_1" - | "rouge_2" - | "rouge_3" - | "rouge_4" - | "rouge_5" - | "rouge_l" - } - | { readonly "type": "python"; readonly "name": string; readonly "source": string; readonly "image_tag"?: string } - | { - readonly "type": "score_model" - readonly "name": string - readonly "model": string - readonly "sampling_params"?: { - readonly "seed"?: number | null - readonly "top_p"?: number | null - readonly "temperature"?: number | null - readonly "max_completions_tokens"?: number | null - readonly "reasoning_effort"?: ReasoningEffort - } - readonly "input": ReadonlyArray - readonly "range"?: ReadonlyArray - } - | { - readonly "type": "multi" - readonly "name": string - readonly "graders": GraderStringCheck | GraderTextSimilarity | GraderPython | GraderScoreModel | GraderLabelModel - readonly "calculate_output": string - } -} -export const ValidateGraderResponse = Schema.Struct({ - "grader": Schema.optionalKey(Schema.Union([ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." })), + "allowed_ips": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "The updated set of IP addresses or CIDR ranges in the configuration." + }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "ip_allowlist.deleted": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("string_check").annotate({ - "description": "The object type, which is always `string_check`." - }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), - "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), - "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ - "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." - }) - }).annotate({ "title": "StringCheckGrader", "description": "The grader used for the fine-tuning job." }), + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." })), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "The name of the IP allowlist configuration." }) + ), + "allowed_ips": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "The IP addresses or CIDR ranges that were in the configuration." + }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "ip_allowlist.config.activated": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "input": Schema.String.annotate({ "description": "The text being graded." }), - "reference": Schema.String.annotate({ "description": "The text being graded against." }), - "evaluation_metric": Schema.Literals([ - "cosine", - "fuzzy_match", - "bleu", - "gleu", - "meteor", - "rouge_1", - "rouge_2", - "rouge_3", - "rouge_4", - "rouge_5", - "rouge_l" - ]).annotate({ - "description": - "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" - }) - }).annotate({ "title": "TextSimilarityGrader", "description": "The grader used for the fine-tuning job." }), + "configs": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." }) + ), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "The name of the IP allowlist configuration." }) + ) + }) + ).annotate({ "description": "The configurations that were activated." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "ip_allowlist.config.deactivated": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "source": Schema.String.annotate({ "description": "The source code of the python script." }), - "image_tag": Schema.optionalKey( - Schema.String.annotate({ "description": "The image tag to use for the python script." }) + "configs": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the IP allowlist configuration." }) + ), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "The name of the IP allowlist configuration." }) + ) + }) + ).annotate({ "description": "The configurations that were deactivated." }) ) - }).annotate({ "title": "PythonGrader", "description": "The grader used for the fine-tuning job." }), + }).annotate({ "description": "The details for events with this `type`." }) + ), + "login.succeeded": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": "This event has no additional fields beyond the standard audit log attributes." + }) + ), + "login.failed": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("score_model").annotate({ - "description": "The object type, which is always `score_model`." - }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), - "sampling_params": Schema.optionalKey( + "error_code": Schema.optionalKey(Schema.String.annotate({ "description": "The error code of the failure." })), + "error_message": Schema.optionalKey( + Schema.String.annotate({ "description": "The error message of the failure." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "logout.succeeded": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": "This event has no additional fields beyond the standard audit log attributes." + }) + ), + "logout.failed": Schema.optionalKey( + Schema.Struct({ + "error_code": Schema.optionalKey(Schema.String.annotate({ "description": "The error code of the failure." })), + "error_message": Schema.optionalKey( + Schema.String.annotate({ "description": "The error message of the failure." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "organization.updated": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The organization ID." })), + "changes_requested": Schema.optionalKey( Schema.Struct({ - "seed": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) - .check(Schema.isInt()), - Schema.Null - ]) + "title": Schema.optionalKey(Schema.String.annotate({ "description": "The organization title." })), + "description": Schema.optionalKey(Schema.String.annotate({ "description": "The organization description." })), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The organization name." })), + "threads_ui_visibility": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Visibility of the threads page which shows messages created with the Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`." + }) ), - "top_p": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" - }).check(Schema.isFinite()), - Schema.Null - ]) + "usage_dashboard_visibility": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Visibility of the usage dashboard which shows activity and costs for your organization. One of `ANY_ROLE` or `OWNERS`." + }) ), - "temperature": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) - .check(Schema.isFinite()), - Schema.Null - ]) + "api_call_logging": Schema.optionalKey( + Schema.String.annotate({ + "description": + "How your organization logs data from supported API calls. One of `disabled`, `enabled_per_call`, `enabled_for_all_projects`, or `enabled_for_selected_projects`" + }) ), - "max_completions_tokens": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": "The maximum number of tokens the grader model may generate in its response.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)), - Schema.Null - ]) + "api_call_logging_project_ids": Schema.optionalKey( + Schema.String.annotate({ + "description": "The list of project ids if api_call_logging is set to `enabled_for_selected_projects`" + }) + ) + }).annotate({ "description": "The payload used to update the organization settings." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "project.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })), + "data": Schema.optionalKey( + Schema.Struct({ + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The project name." })), + "title": Schema.optionalKey( + Schema.String.annotate({ "description": "The title of the project as seen on the dashboard." }) + ) + }).annotate({ "description": "The payload used to create the project." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "project.updated": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })), + "changes_requested": Schema.optionalKey( + Schema.Struct({ + "title": Schema.optionalKey( + Schema.String.annotate({ "description": "The title of the project as seen on the dashboard." }) + ) + }).annotate({ "description": "The payload used to update the project." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "project.archived": Schema.optionalKey( + Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })) }).annotate({ + "description": "The details for events with this `type`." + }) + ), + "project.deleted": Schema.optionalKey( + Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })) }).annotate({ + "description": "The details for events with this `type`." + }) + ), + "rate_limit.updated": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The rate limit ID" })), + "changes_requested": Schema.optionalKey( + Schema.Struct({ + "max_requests_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum requests per minute." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ), - "reasoning_effort": Schema.optionalKey(ReasoningEffort) - }).annotate({ "description": "The sampling parameters for the model." }) + "max_tokens_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum tokens per minute." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "max_images_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum images per minute. Only relevant for certain models." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "max_audio_megabytes_per_1_minute": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum audio megabytes per minute. Only relevant for certain models." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "max_requests_per_1_day": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum requests per day. Only relevant for certain models." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "batch_1_day_max_input_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum batch input tokens per day. Only relevant for certain models." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).annotate({ "description": "The payload used to update the rate limits." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "rate_limit.deleted": Schema.optionalKey( + Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The rate limit ID" })) }) + .annotate({ "description": "The details for events with this `type`." }) + ), + "role.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The role ID." })), + "role_name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the role." })), + "permissions": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "The permissions granted by the role." }) ), - "input": Schema.Array(EvalItem).annotate({ - "description": - "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" - }), - "range": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isFinite())).annotate({ - "description": "The range of the score. Defaults to `[0, 1]`." - }) + "resource_type": Schema.optionalKey( + Schema.String.annotate({ "description": "The type of resource the role belongs to." }) + ), + "resource_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The resource the role is scoped to." }) ) - }).annotate({ "title": "ScoreModelGrader", "description": "The grader used for the fine-tuning job." }), + }).annotate({ "description": "The details for events with this `type`." }) + ), + "role.updated": Schema.optionalKey( Schema.Struct({ - "type": Schema.Literal("multi").annotate({ "description": "The object type, which is always `multi`." }), - "name": Schema.String.annotate({ "description": "The name of the grader." }), - "graders": Schema.Union([ - GraderStringCheck, - GraderTextSimilarity, - GraderPython, - GraderScoreModel, - GraderLabelModel - ], { mode: "oneOf" }), - "calculate_output": Schema.String.annotate({ - "description": "A formula to calculate the output based on grader results." - }) - }).annotate({ "title": "MultiGrader", "description": "The grader used for the fine-tuning job." }) - ], { mode: "oneOf" })) -}).annotate({ "title": "ValidateGraderResponse" }) -export type CreateResponse = { - readonly "metadata"?: Metadata - readonly "top_logprobs"?: number - readonly "temperature"?: number | null - readonly "top_p"?: number | null - readonly "user"?: string | null - readonly "safety_identifier"?: string - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "in_memory" | "24h" | null + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The role ID." })), + "changes_requested": Schema.optionalKey( + Schema.Struct({ + "role_name": Schema.optionalKey( + Schema.String.annotate({ "description": "The updated role name, when provided." }) + ), + "resource_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The resource the role is scoped to." }) + ), + "resource_type": Schema.optionalKey( + Schema.String.annotate({ "description": "The type of resource the role belongs to." }) + ), + "permissions_added": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "The permissions added to the role." }) + ), + "permissions_removed": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "The permissions removed from the role." }) + ), + "description": Schema.optionalKey( + Schema.String.annotate({ "description": "The updated role description, when provided." }) + ), + "metadata": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Additional metadata stored on the role." }) + ) + }).annotate({ "description": "The payload used to update the role." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "role.deleted": Schema.optionalKey( + Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The role ID." })) }).annotate({ + "description": "The details for events with this `type`." + }) + ), + "role.assignment.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The identifier of the role assignment." })), + "principal_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The principal (user or group) that received the role." }) + ), + "principal_type": Schema.optionalKey( + Schema.String.annotate({ "description": "The type of principal (user or group) that received the role." }) + ), + "resource_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The resource the role assignment is scoped to." }) + ), + "resource_type": Schema.optionalKey( + Schema.String.annotate({ "description": "The type of resource the role assignment is scoped to." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "role.assignment.deleted": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The identifier of the role assignment." })), + "principal_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The principal (user or group) that had the role removed." }) + ), + "principal_type": Schema.optionalKey( + Schema.String.annotate({ "description": "The type of principal (user or group) that had the role removed." }) + ), + "resource_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The resource the role assignment was scoped to." }) + ), + "resource_type": Schema.optionalKey( + Schema.String.annotate({ "description": "The type of resource the role assignment was scoped to." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "role.bound_to_resource": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The ID of the resource the role was bound to. ChatGPT workspace connector resources use `__`." + }) + ), + "role_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the role that was bound to the resource." }) + ), + "resource_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the resource the role was bound to." }) + ), + "resource_type": Schema.optionalKey( + Schema.String.annotate({ "description": "The type of resource the role was bound to." }) + ), + "permissions": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "The permissions granted to the role for the resource." }) + ), + "workspace_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The workspace ID for a ChatGPT workspace connector resource." }) + ), + "connector_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The connector ID for a ChatGPT workspace connector resource." }) + ), + "connector_name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The connector display name for a ChatGPT workspace connector resource, or the connector ID when the display name could not be resolved." + }) + ), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the connector is enabled for the role." }) + ), + "source": Schema.optionalKey( + Schema.Literals([ + "role_toggle", + "role_connector_update", + "role_delete", + "workspace_permissions", + "connector_publish" + ]).annotate({ "description": "The connector role mutation path that produced the event." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "role.unbound_from_resource": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The ID of the resource the role was unbound from. ChatGPT workspace connector resources use `__`." + }) + ), + "role_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the role that was unbound from the resource." }) + ), + "resource_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The ID of the resource the role was unbound from." }) + ), + "resource_type": Schema.optionalKey( + Schema.String.annotate({ "description": "The type of resource the role was unbound from." }) + ), + "permissions": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": "The permissions remaining for the role after the change." + }) + ), + "workspace_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The workspace ID for a ChatGPT workspace connector resource." }) + ), + "connector_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The connector ID for a ChatGPT workspace connector resource." }) + ), + "connector_name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The connector display name for a ChatGPT workspace connector resource, or the connector ID when the display name could not be resolved." + }) + ), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the connector is enabled for the role." }) + ), + "source": Schema.optionalKey( + Schema.Literals([ + "role_toggle", + "role_connector_update", + "role_delete", + "workspace_permissions", + "connector_publish" + ]).annotate({ "description": "The connector role mutation path that produced the event." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "service_account.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The service account ID." })), + "data": Schema.optionalKey( + Schema.Struct({ + "role": Schema.optionalKey( + Schema.String.annotate({ "description": "The role of the service account. Is either `owner` or `member`." }) + ) + }).annotate({ "description": "The payload used to create the service account." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "service_account.updated": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The service account ID." })), + "changes_requested": Schema.optionalKey( + Schema.Struct({ + "role": Schema.optionalKey( + Schema.String.annotate({ "description": "The role of the service account. Is either `owner` or `member`." }) + ) + }).annotate({ "description": "The payload used to updated the service account." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "service_account.deleted": Schema.optionalKey( + Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The service account ID." })) }) + .annotate({ "description": "The details for events with this `type`." }) + ), + "workload_identity_provider.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The workload identity provider ID." })), + "data": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "The payload used to create the workload identity provider." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "workload_identity_provider.updated": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The workload identity provider ID." })), + "changes_requested": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "The payload used to update the workload identity provider." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "workload_identity_provider.deleted": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The workload identity provider ID." })), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The workload identity provider name." })) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "workload_identity_provider_mapping.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The workload identity provider mapping ID." })), + "identity_provider_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The workload identity provider ID." }) + ), + "data": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": "The payload used to create the workload identity provider mapping." + }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "workload_identity_provider_mapping.updated": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The workload identity provider mapping ID." })), + "identity_provider_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The workload identity provider ID." }) + ), + "changes_requested": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": "The payload used to update the workload identity provider mapping." + }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "workload_identity_provider_mapping.deleted": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The workload identity provider mapping ID." })), + "identity_provider_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The workload identity provider ID." }) + ), + "project_id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })), + "service_account_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The mapped service account ID." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "user.added": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The user ID." })), + "data": Schema.optionalKey( + Schema.Struct({ + "role": Schema.optionalKey( + Schema.String.annotate({ "description": "The role of the user. Is either `owner` or `member`." }) + ) + }).annotate({ "description": "The payload used to add the user to the project." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "user.updated": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The project ID." })), + "changes_requested": Schema.optionalKey( + Schema.Struct({ + "role": Schema.optionalKey( + Schema.String.annotate({ "description": "The role of the user. Is either `owner` or `member`." }) + ) + }).annotate({ "description": "The payload used to update the user." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "user.deleted": Schema.optionalKey( + Schema.Struct({ "id": Schema.optionalKey(Schema.String.annotate({ "description": "The user ID." })) }).annotate({ + "description": "The details for events with this `type`." + }) + ), + "certificate.created": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "certificate.updated": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "certificate.deleted": Schema.optionalKey( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })), + "certificate": Schema.optionalKey( + Schema.String.annotate({ "description": "The certificate content in PEM format." }) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "certificates.activated": Schema.optionalKey( + Schema.Struct({ + "certificates": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })) + }) + ) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ), + "certificates.deactivated": Schema.optionalKey( + Schema.Struct({ + "certificates": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The certificate ID." })), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the certificate." })) + }) + ) + ) + }).annotate({ "description": "The details for events with this `type`." }) + ) +}).annotate({ + "description": "A log of a user action or configuration change within this organization.", + "identifier": "AuditLog" +}) +export type RealtimeCallCreateRequest = { readonly "sdp": string; readonly "session"?: RealtimeSessionCreateRequestGA } +export const RealtimeCallCreateRequest = Schema.Struct({ + "sdp": Schema.String.annotate({ + "description": "WebRTC Session Description Protocol (SDP) offer generated by the caller." + }), + "session": Schema.optionalKey( + Schema.suspend((): Schema.Codec => RealtimeSessionCreateRequestGA).annotate({ + "title": "Session configuration", + "description": + "Optional session configuration to apply before the realtime session is\ncreated. Use the same parameters you would send in a [`create client secret`](/docs/api-reference/realtime-sessions/create-realtime-client-secret)\nrequest." + }) + ) +}).annotate({ + "title": "Realtime call creation request", + "description": + "Parameters required to initiate a realtime call and receive the SDP answer\nneeded to complete a WebRTC peer connection. Provide an SDP offer generated\nby your client and optionally configure the session that will answer the call.", + "identifier": "RealtimeCallCreateRequest" +}) +export type RealtimeCreateClientSecretRequest = { + readonly "expires_after"?: { readonly "anchor"?: "created_at"; readonly "seconds"?: number } + readonly "session"?: RealtimeSessionCreateRequestGA | RealtimeTranscriptionSessionCreateRequestGA +} +export const RealtimeCreateClientSecretRequest = Schema.Struct({ + "expires_after": Schema.optionalKey( + Schema.Struct({ + "anchor": Schema.optionalKey( + Schema.Literal("created_at").annotate({ + "description": + "The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.\n" + }) + ), + "seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.\n", + "format": "int64" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(10).annotate({ "expected": "a value greater than or equal to 10" }) + ).check(Schema.isLessThanOrEqualTo(7200).annotate({ "expected": "a value less than or equal to 7200" })) + ) + }).annotate({ + "title": "Client secret expiration", + "description": + "Configuration for the client secret expiration. Expiration refers to the time after which\na client secret will no longer be valid for creating sessions. The session itself may\ncontinue after that time once started. A secret can be used to create multiple sessions\nuntil it expires.\n" + }) + ), + "session": Schema.optionalKey( + Schema.Union([RealtimeSessionCreateRequestGA, RealtimeTranscriptionSessionCreateRequestGA], { mode: "oneOf" }) + .annotate({ + "title": "Session configuration", + "description": + "Session configuration to use for the client secret. Choose either a realtime\nsession or a transcription session.\n" + }) + ) +}).annotate({ + "title": "Realtime client secret creation request", + "description": + "Create a session and client secret for the Realtime API. The request can specify\neither a realtime or a transcription session configuration.\n[Learn more about the Realtime API](/docs/guides/realtime).\n", + "identifier": "RealtimeCreateClientSecretRequest" +}) +export type RealtimeCreateClientSecretResponse = { + readonly "value": string + readonly "expires_at": number + readonly "session": RealtimeSessionCreateResponseGA | RealtimeTranscriptionSessionCreateResponseGA +} +export const RealtimeCreateClientSecretResponse = Schema.Struct({ + "value": Schema.String.annotate({ "description": "The generated client secret value." }), + "expires_at": Schema.Number.annotate({ + "description": "Expiration timestamp for the client secret, in seconds since epoch.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "session": Schema.Union([RealtimeSessionCreateResponseGA, RealtimeTranscriptionSessionCreateResponseGA], { + mode: "oneOf" + }).annotate({ + "title": "Session configuration", + "description": "The session configuration for either a realtime or transcription session.\n" + }) +}).annotate({ + "title": "Realtime session and client secret", + "description": "Response from creating a session and client secret for the Realtime API.\n", + "identifier": "RealtimeCreateClientSecretResponse" +}) +export type CreateThreadAndRunRequest = { + readonly "assistant_id": string + readonly "thread"?: CreateThreadRequest + readonly "model"?: + | string + | "gpt-5" + | "gpt-5-mini" + | "gpt-5-nano" + | "gpt-5-2025-08-07" + | "gpt-5-mini-2025-08-07" + | "gpt-5-nano-2025-08-07" + | "gpt-4.1" + | "gpt-4.1-mini" + | "gpt-4.1-nano" + | "gpt-4.1-2025-04-14" + | "gpt-4.1-mini-2025-04-14" + | "gpt-4.1-nano-2025-04-14" + | "gpt-4o" + | "gpt-4o-2024-11-20" + | "gpt-4o-2024-08-06" + | "gpt-4o-2024-05-13" + | "gpt-4o-mini" + | "gpt-4o-mini-2024-07-18" + | "gpt-4.5-preview" + | "gpt-4.5-preview-2025-02-27" + | "gpt-4-turbo" + | "gpt-4-turbo-2024-04-09" + | "gpt-4-0125-preview" + | "gpt-4-turbo-preview" + | "gpt-4-1106-preview" + | "gpt-4-vision-preview" + | "gpt-4" + | "gpt-4-0314" + | "gpt-4-0613" + | "gpt-4-32k" + | "gpt-4-32k-0314" + | "gpt-4-32k-0613" + | "gpt-3.5-turbo" + | "gpt-3.5-turbo-16k" + | "gpt-3.5-turbo-0613" + | "gpt-3.5-turbo-1106" + | "gpt-3.5-turbo-0125" + | "gpt-3.5-turbo-16k-0613" + | null + readonly "instructions"?: string | null + readonly "tools"?: ReadonlyArray | null + readonly "tool_resources"?: { + readonly "code_interpreter"?: { readonly "file_ids"?: ReadonlyArray } + readonly "file_search"?: { readonly "vector_store_ids"?: ReadonlyArray } + readonly [x: string]: Schema.Json + } | null + readonly "metadata"?: Metadata + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "stream"?: boolean | null + readonly "max_prompt_tokens"?: number | null + readonly "max_completion_tokens"?: number | null + readonly "truncation_strategy"?: { + readonly "type": "auto" | "last_messages" + readonly "last_messages"?: number | null + } + readonly "tool_choice"?: "none" | "auto" | "required" | { + readonly "type": "function" | "code_interpreter" | "file_search" + readonly "function"?: { readonly "name": string } + } + readonly "parallel_tool_calls"?: ParallelToolCalls + readonly "response_format"?: AssistantsApiResponseFormatOption | null +} +export const CreateThreadAndRunRequest = Schema.Struct({ + "assistant_id": Schema.String.annotate({ + "description": "The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run." + }), + "thread": Schema.optionalKey(CreateThreadRequest), + "model": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.String, + Schema.Literals([ + "gpt-5", + "gpt-5-mini", + "gpt-5-nano", + "gpt-5-2025-08-07", + "gpt-5-mini-2025-08-07", + "gpt-5-nano-2025-08-07", + "gpt-4.1", + "gpt-4.1-mini", + "gpt-4.1-nano", + "gpt-4.1-2025-04-14", + "gpt-4.1-mini-2025-04-14", + "gpt-4.1-nano-2025-04-14", + "gpt-4o", + "gpt-4o-2024-11-20", + "gpt-4o-2024-08-06", + "gpt-4o-2024-05-13", + "gpt-4o-mini", + "gpt-4o-mini-2024-07-18", + "gpt-4.5-preview", + "gpt-4.5-preview-2025-02-27", + "gpt-4-turbo", + "gpt-4-turbo-2024-04-09", + "gpt-4-0125-preview", + "gpt-4-turbo-preview", + "gpt-4-1106-preview", + "gpt-4-vision-preview", + "gpt-4", + "gpt-4-0314", + "gpt-4-0613", + "gpt-4-32k", + "gpt-4-32k-0314", + "gpt-4-32k-0613", + "gpt-3.5-turbo", + "gpt-3.5-turbo-16k", + "gpt-3.5-turbo-0613", + "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", + "gpt-3.5-turbo-16k-0613" + ]) + ]).annotate({ + "description": + "The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used." + }), + Schema.Null + ]) + ), + "instructions": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis." + }) + ), + "tools": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Union([AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction], { mode: "oneOf" }) + ).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })), + Schema.Null + ]).annotate({ + "description": + "Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis." + }) + ), + "tool_resources": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "code_interpreter": Schema.optionalKey(Schema.Struct({ + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n" + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) + ) + })), + "file_search": Schema.optionalKey(Schema.Struct({ + "vector_store_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.\n" + }).check(Schema.isMaxLength(1).annotate({ "expected": "a value with a length of at most 1" })) + ) + })) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ + "description": + "A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.\n" + }) + ), + "metadata": Schema.optionalKey(Metadata), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]).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.\n" + }) + ), + "top_p": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), + Schema.Null + ]).annotate({ + "description": + "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or temperature but not both.\n" + }) + ), + "stream": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.\n" + }) + ), + "max_prompt_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(256).annotate({ "expected": "a value greater than or equal to 256" }) + ), + Schema.Null + ]).annotate({ + "description": + "The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.\n" + }) + ), + "max_completion_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(256).annotate({ "expected": "a value greater than or equal to 256" }) + ), + Schema.Null + ]).annotate({ + "description": + "The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.\n" + }) + ), + "truncation_strategy": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "type": Schema.Literals(["auto", "last_messages"]).annotate({ + "description": + "The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`." + }), + "last_messages": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": + "The number of most recent messages from the thread when constructing the context for the run." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]) + ) + }).annotate({ + "title": "Thread Truncation Controls", + "description": + "Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run." + }) + ])), + "tool_choice": Schema.optionalKey( + Schema.Union([ + Schema.Union([Schema.Literal("none"), Schema.Literal("auto"), Schema.Literal("required")]).annotate({ + "description": + "`none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.\n" + }), + Schema.Union([ + Schema.Struct({ + "type": Schema.Literals(["function", "code_interpreter", "file_search"]).annotate({ + "description": "The type of the tool. If type is `function`, the function name must be set" + }), + "function": Schema.optionalKey( + Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) }) + ) + }).annotate({ + "description": "Specifies a tool the model should use. Use to force the model to call a specific tool." + }) + ]) + ], { mode: "oneOf" }).annotate({ + "description": + "Controls which (if any) tool is called by the model.\n`none` means the model will not call any tools and instead generates a message.\n`auto` is the default value and means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools before responding to the user.\nSpecifying a particular tool like `{\"type\": \"file_search\"}` or `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n" + }) + ), + "parallel_tool_calls": Schema.optionalKey(ParallelToolCalls), + "response_format": Schema.optionalKey(Schema.Union([AssistantsApiResponseFormatOption, Schema.Null])) +}).annotate({ "identifier": "CreateThreadAndRunRequest" }) +export type ListMessagesResponse = { + readonly "object": string + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean + readonly [x: string]: Schema.Json +} +export const ListMessagesResponse = Schema.StructWithRest( + Schema.Struct({ + "object": Schema.String, + "data": Schema.Array(MessageObject), + "first_id": Schema.String, + "last_id": Schema.String, + "has_more": Schema.Boolean + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ "identifier": "ListMessagesResponse" }) +export type CreateVectorStoreFileBatchRequest = { + readonly "file_ids": ReadonlyArray + readonly "files"?: ReadonlyArray + readonly "chunking_strategy"?: ChunkingStrategyRequestParam + readonly "attributes"?: VectorStoreFileAttributes +} | { + readonly "files": ReadonlyArray + readonly "file_ids"?: ReadonlyArray + readonly "chunking_strategy"?: ChunkingStrategyRequestParam + readonly "attributes"?: VectorStoreFileAttributes +} +export const CreateVectorStoreFileBatchRequest = Schema.Union([ + Schema.Struct({ + "file_ids": Schema.Array(Schema.String).annotate({ + "description": + "A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. If `attributes` or `chunking_strategy` are provided, they will be applied to all files in the batch. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `files`." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2000).annotate({ "expected": "a value with a length of at most 2000" }) + ), + "files": Schema.optionalKey( + Schema.Array(CreateVectorStoreFileRequest).annotate({ + "description": + "A list of objects that each include a `file_id` plus optional `attributes` or `chunking_strategy`. Use this when you need to override metadata for specific files. The global `attributes` or `chunking_strategy` will be ignored and must be specified for each file. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `file_ids`." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2000).annotate({ "expected": "a value with a length of at most 2000" }) + ) + ), + "chunking_strategy": Schema.optionalKey(ChunkingStrategyRequestParam), + "attributes": Schema.optionalKey(VectorStoreFileAttributes) + }), + Schema.Struct({ + "files": Schema.Array(CreateVectorStoreFileRequest).annotate({ + "description": + "A list of objects that each include a `file_id` plus optional `attributes` or `chunking_strategy`. Use this when you need to override metadata for specific files. The global `attributes` or `chunking_strategy` will be ignored and must be specified for each file. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `file_ids`." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2000).annotate({ "expected": "a value with a length of at most 2000" }) + ), + "file_ids": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. If `attributes` or `chunking_strategy` are provided, they will be applied to all files in the batch. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `files`." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(2000).annotate({ "expected": "a value with a length of at most 2000" }) + ) + ), + "chunking_strategy": Schema.optionalKey(ChunkingStrategyRequestParam), + "attributes": Schema.optionalKey(VectorStoreFileAttributes) + }) +]).annotate({ "identifier": "CreateVectorStoreFileBatchRequest" }) +export type AssistantMessageItem = { + readonly "id": string + readonly "object": "chatkit.thread_item" + readonly "created_at": number + readonly "thread_id": string + readonly "type": "chatkit.assistant_message" + readonly "content": ReadonlyArray +} +export const AssistantMessageItem = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Identifier of the thread item." }), + "object": Schema.Literal("chatkit.thread_item").annotate({ + "description": "Type discriminator that is always `chatkit.thread_item`." + }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) for when the item was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "thread_id": Schema.String.annotate({ "description": "Identifier of the parent thread." }), + "type": Schema.Literal("chatkit.assistant_message").annotate({ + "description": "Type discriminator that is always `chatkit.assistant_message`." + }), + "content": Schema.Array(ResponseOutputText).annotate({ "description": "Ordered assistant response segments." }) +}).annotate({ + "title": "Assistant message", + "description": "Assistant-authored message within a thread.", + "identifier": "AssistantMessageItem" +}) +export type BetaResponseTextParam = { + readonly "format"?: BetaTextResponseFormatConfiguration + readonly "verbosity"?: BetaVerbosity +} +export const BetaResponseTextParam = Schema.Struct({ + "format": Schema.optionalKey(BetaTextResponseFormatConfiguration), + "verbosity": Schema.optionalKey(BetaVerbosity) +}).annotate({ + "description": + "Configuration options for a text response from the model. Can be plain\ntext or structured JSON data. Learn more:\n- [Text inputs and outputs](/docs/guides/text)\n- [Structured Outputs](/docs/guides/structured-outputs)\n", + "identifier": "BetaResponseTextParam" +}) +export type BetaFileSearchTool = { + readonly "type": "file_search" + readonly "vector_store_ids": ReadonlyArray + readonly "max_num_results"?: number + readonly "ranking_options"?: BetaRankingOptions + readonly "filters"?: BetaFilters | null +} +export const BetaFileSearchTool = Schema.Struct({ + "type": Schema.Literal("file_search").annotate({ + "description": "The type of the file search tool. Always `file_search`." + }), + "vector_store_ids": Schema.Array(Schema.String).annotate({ + "description": "The IDs of the vector stores to search." + }), + "max_num_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The maximum number of results to return. This number should be between 1 and 50 inclusive." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "ranking_options": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaRankingOptions).annotate({ + "description": "Ranking options for search." + }) + ), + "filters": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaFilters).annotate({ "description": "A filter to apply." }), + Schema.Null + ]) + ) +}).annotate({ + "title": "File search", + "description": + "A tool that searches for relevant content from uploaded files. Learn more about the [file search tool](https://platform.openai.com/docs/guides/tools-file-search).", + "identifier": "BetaFileSearchTool" +}) +export type BetaCodeInterpreterTool = { + readonly "type": "code_interpreter" + readonly "container": string | BetaAutoCodeInterpreterToolParam + readonly "allowed_callers"?: ReadonlyArray | null +} +export const BetaCodeInterpreterTool = Schema.Struct({ + "type": Schema.Literal("code_interpreter").annotate({ + "description": "The type of the code interpreter tool. Always `code_interpreter`.\n" + }), + "container": Schema.Union([ + Schema.String.annotate({ "description": "The container ID." }), + BetaAutoCodeInterpreterToolParam + ], { mode: "oneOf" }).annotate({ + "description": + "The code interpreter container. Can be a container ID or an object that\nspecifies uploaded file IDs to make available to your code, along with an\noptional `memory_limit` setting.\n" + }), + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(BetaCallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]) + ) +}).annotate({ + "title": "Code interpreter", + "description": "A tool that runs Python code to help generate a response to a prompt.\n", + "identifier": "BetaCodeInterpreterTool" +}) +export type BetaFunctionShellToolParam = { + readonly "type": "shell" + readonly "environment"?: BetaContainerAutoParam | BetaLocalEnvironmentParam | BetaContainerReferenceParam | null + readonly "allowed_callers"?: ReadonlyArray | null +} +export const BetaFunctionShellToolParam = Schema.Struct({ + "type": Schema.Literal("shell").annotate({ "description": "The type of the shell tool. Always `shell`." }), + "environment": Schema.optionalKey( + Schema.Union([ + Schema.Union([BetaContainerAutoParam, BetaLocalEnvironmentParam, BetaContainerReferenceParam], { mode: "oneOf" }), + Schema.Null + ]) + ), + "allowed_callers": Schema.optionalKey( + Schema.Union([ + Schema.Array(BetaCallableToolAllowedCaller).annotate({ "description": "The tool invocation context(s)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]) + ) +}).annotate({ + "title": "Shell tool", + "description": "A tool that allows the model to execute shell commands.", + "identifier": "BetaFunctionShellToolParam" +}) +export type BetaNamespaceToolParam = { + readonly "type": "namespace" + readonly "name": string + readonly "description": string + readonly "tools": ReadonlyArray +} +export const BetaNamespaceToolParam = 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).annotate({ "expected": "a value with a length of at least 1" })), + "description": Schema.String.annotate({ "description": "A description of the namespace shown to the model." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "tools": Schema.Array( + Schema.Union([BetaFunctionToolParam, BetaCustomToolParam], { 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({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ + "title": "Namespace", + "description": "Groups function/custom tools under a shared namespace.", + "identifier": "BetaNamespaceToolParam" +}) +export type BetaInputMessageContentList = ReadonlyArray +export const BetaInputMessageContentList = Schema.Array(BetaInputContent).annotate({ + "title": "Input item content list", + "description": "A list of one or many input items to the model, containing different content \ntypes.\n", + "identifier": "BetaInputMessageContentList" +}) +export type BetaFunctionToolCallOutputResource = { + readonly "agent"?: BetaAgentTag | null + readonly "id": string + readonly "type": "function_call_output" + readonly "call_id": string + readonly "name"?: string + readonly "namespace"?: string + readonly "caller"?: BetaToolCallCallerParam | null + readonly "output": string | ReadonlyArray + readonly "status": "in_progress" | "completed" | "incomplete" + readonly "created_by"?: string +} +export const BetaFunctionToolCallOutputResource = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "id": Schema.String.annotate({ "description": "The unique ID of the function call tool output.\n" }), + "type": Schema.Literal("function_call_output").annotate({ + "description": "The type of the function tool call output. Always `function_call_output`.\n" + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" + }), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "The name of the tool that produced the output.\n" }) + ), + "namespace": Schema.optionalKey( + Schema.String.annotate({ "description": "The namespace of the tool that produced the output.\n" }) + ), + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the function call.\n" + }), + Schema.Array(BetaFunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the function call.\n" + }) + ], { mode: "oneOf" }).annotate({ + "description": + "The output from the function call generated by your code.\nCan be a string or an list of output content.\n" + }), + "status": Schema.Union([Schema.Literal("in_progress"), Schema.Literal("completed"), Schema.Literal("incomplete")]) + .annotate({ + "description": + "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ) +}).annotate({ + "title": "Function tool call output", + "description": "The output of a function tool call.\n", + "identifier": "BetaFunctionToolCallOutputResource" +}) +export type BetaCustomToolCallOutputResource = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "custom_tool_call_output" + readonly "id": string + readonly "call_id": string + readonly "caller"?: BetaToolCallCallerParam | null + readonly "output": string | ReadonlyArray + readonly "status": BetaFunctionCallOutputStatusEnum + readonly "created_by"?: string +} +export const BetaCustomToolCallOutputResource = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("custom_tool_call_output").annotate({ + "description": "The type of the custom tool call output. Always `custom_tool_call_output`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the custom tool call output item.\n" }), + "call_id": Schema.String.annotate({ + "description": "The call ID, used to map this custom tool call output to a custom tool call.\n" + }), + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the custom tool call.\n" + }), + Schema.Array(BetaFunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the custom tool call.\n" + }) + ], { mode: "oneOf" }).annotate({ + "description": + "The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n" + }), + "status": Schema.suspend((): Schema.Codec => BetaFunctionCallOutputStatusEnum) + .annotate({ + "description": + "The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + }), + "created_by": Schema.optionalKey( + Schema.String.annotate({ "description": "The identifier of the actor that created the item.\n" }) + ) +}).annotate({ + "title": "ResponseCustomToolCallOutputItem", + "description": "The output of a custom tool call from your code, being sent back to the model.\n", + "identifier": "BetaCustomToolCallOutputResource" +}) +export type BetaFunctionToolCallOutput = { + readonly "agent"?: BetaAgentTag | null + readonly "id"?: string + readonly "type": "function_call_output" + readonly "call_id": string + readonly "name"?: string + readonly "namespace"?: string + readonly "caller"?: BetaToolCallCallerParam | null + readonly "output": string | ReadonlyArray + readonly "status"?: "in_progress" | "completed" | "incomplete" +} +export const BetaFunctionToolCallOutput = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "id": Schema.optionalKey( + Schema.String.annotate({ + "description": "The unique ID of the function tool call output. Populated when this item\nis returned via API.\n" + }) + ), + "type": Schema.Literal("function_call_output").annotate({ + "description": "The type of the function tool call output. Always `function_call_output`.\n" + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" + }), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "The name of the tool that produced the output.\n" }) + ), + "namespace": Schema.optionalKey( + Schema.String.annotate({ "description": "The namespace of the tool that produced the output.\n" }) + ), + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the function call.\n" + }), + Schema.Array(BetaFunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the function call.\n" + }) + ], { mode: "oneOf" }).annotate({ + "description": + "The output from the function call generated by your code.\nCan be a string or an list of output content.\n" + }), + "status": Schema.optionalKey( + 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": "Function tool call output", + "description": "The output of a function tool call.\n", + "identifier": "BetaFunctionToolCallOutput" +}) +export type BetaCustomToolCallOutput = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "custom_tool_call_output" + readonly "id"?: string + readonly "call_id": string + readonly "caller"?: BetaToolCallCallerParam | null + readonly "output": string | ReadonlyArray +} +export const BetaCustomToolCallOutput = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("custom_tool_call_output").annotate({ + "description": "The type of the custom tool call output. Always `custom_tool_call_output`.\n" + }), + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The unique ID of the custom tool call output in the OpenAI platform.\n" }) + ), + "call_id": Schema.String.annotate({ + "description": "The call ID, used to map this custom tool call output to a custom tool call.\n" + }), + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the custom tool call.\n" + }), + Schema.Array(BetaFunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the custom tool call.\n" + }) + ], { mode: "oneOf" }).annotate({ + "description": + "The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n" + }) +}).annotate({ + "title": "Custom tool call output", + "description": "The output of a custom tool call from your code, being sent back to the model.\n", + "identifier": "BetaCustomToolCallOutput" +}) +export type BetaOutputMessageContent = BetaOutputTextContent | BetaRefusalContent +export const BetaOutputMessageContent = Schema.Union([BetaOutputTextContent, BetaRefusalContent], { mode: "oneOf" }) + .annotate({ "identifier": "BetaOutputMessageContent" }) +export type BetaAgentMessage = { + readonly "agent"?: BetaAgentTag + readonly "type": "agent_message" + readonly "id": string + readonly "author": string + readonly "recipient": string + readonly "content": ReadonlyArray< + | BetaInputTextContent + | BetaOutputTextContent + | BetaTextContent + | BetaSummaryTextContent + | BetaReasoningTextContent + | BetaRefusalContent + | BetaInputImageContent + | BetaComputerScreenshotContent + | BetaInputFileContent + | BetaEncryptedContent + > +} +export const BetaAgentMessage = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." + }) + ), + "type": Schema.Literal("agent_message").annotate({ "description": "The type of the item. Always `agent_message`." }), + "id": Schema.String.annotate({ "description": "The unique ID of the agent message." }), + "author": Schema.String.annotate({ "description": "The sending agent identity." }), + "recipient": Schema.String.annotate({ "description": "The destination agent identity." }), + "content": Schema.Array( + Schema.Union([ + BetaInputTextContent, + BetaOutputTextContent, + BetaTextContent, + BetaSummaryTextContent, + BetaReasoningTextContent, + BetaRefusalContent, + BetaInputImageContent, + BetaComputerScreenshotContent, + BetaInputFileContent, + BetaEncryptedContent + ], { mode: "oneOf" }).annotate({ "description": "A content part that makes up an input or output item." }) + ).annotate({ "description": "Encrypted content sent between agents." }) +}).annotate({ "identifier": "BetaAgentMessage" }) +export type BetaMultiAgentCallOutput = { + readonly "agent"?: BetaAgentTag + readonly "type": "multi_agent_call_output" + readonly "id": string + readonly "call_id": string + readonly "action": BetaMultiAgentAction + readonly "output": ReadonlyArray +} +export const BetaMultiAgentCallOutput = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." + }) + ), + "type": Schema.Literal("multi_agent_call_output").annotate({ + "description": "The type of the multi-agent result. Always `multi_agent_call_output`." + }), + "id": Schema.String.annotate({ "description": "The unique ID of the multi-agent call output item." }), + "call_id": Schema.String.annotate({ "description": "The unique ID of the multi-agent call." }), + "action": Schema.suspend((): Schema.Codec => BetaMultiAgentAction).annotate({ + "description": "The multi-agent action that produced this result." + }), + "output": Schema.Array(BetaOutputTextContent).annotate({ + "description": "Text output returned by the multi-agent action." + }) +}).annotate({ "identifier": "BetaMultiAgentCallOutput" }) +export type BetaOutputContent = BetaOutputTextContent | BetaRefusalContent | BetaReasoningTextContent +export const BetaOutputContent = Schema.Union([BetaOutputTextContent, BetaRefusalContent, BetaReasoningTextContent], { + mode: "oneOf" +}).annotate({ "identifier": "BetaOutputContent" }) +export type BetaMessage = { + readonly "agent"?: BetaAgentTag + readonly "type": "message" + readonly "id": string + readonly "status": BetaMessageStatus + readonly "role": BetaMessageRole + readonly "content": ReadonlyArray< + | BetaInputTextContent + | BetaOutputTextContent + | BetaTextContent + | BetaSummaryTextContent + | BetaReasoningTextContent + | BetaRefusalContent + | BetaInputImageContent + | BetaComputerScreenshotContent + | BetaInputFileContent + | BetaEncryptedContent + > + readonly "phase"?: BetaMessagePhase_2 | null +} +export const BetaMessage = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." + }) + ), + "type": Schema.Literal("message").annotate({ "description": "The type of the message. Always set to `message`." }), + "id": Schema.String.annotate({ "description": "The unique ID of the message." }), + "status": Schema.suspend((): Schema.Codec => BetaMessageStatus).annotate({ + "description": + "The status of item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API." + }), + "role": Schema.suspend((): Schema.Codec => BetaMessageRole).annotate({ + "description": + "The role of the message. One of `unknown`, `user`, `assistant`, `system`, `critic`, `discriminator`, `developer`, or `tool`." + }), + "content": Schema.Array( + Schema.Union([ + BetaInputTextContent, + BetaOutputTextContent, + BetaTextContent, + BetaSummaryTextContent, + BetaReasoningTextContent, + BetaRefusalContent, + BetaInputImageContent, + BetaComputerScreenshotContent, + BetaInputFileContent, + BetaEncryptedContent + ], { mode: "oneOf" }).annotate({ "description": "A content part that makes up an input or output item." }) + ).annotate({ "description": "The content of the message" }), + "phase": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaMessagePhase_2).annotate({ + "description": + "Labels an `assistant` message as intermediate commentary (`commentary`) or the final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when sending follow-up requests, preserve and resend phase on all assistant messages — dropping it can degrade performance. Not used for user messages." + }), + Schema.Null + ]) + ) +}).annotate({ "title": "Message", "description": "A message to or from the model.", "identifier": "BetaMessage" }) +export type BetaComputerActionList = ReadonlyArray +export const BetaComputerActionList = Schema.Array(BetaComputerAction).annotate({ + "title": "Computer Action List", + "description": + "Flattened batched actions for `computer_use`. Each action includes an\n`type` discriminator and action-specific fields.\n", + "identifier": "BetaComputerActionList" +}) +export type BetaModerationParam = { readonly "model": string; readonly "policy"?: BetaModerationPolicyParam | null } +export const BetaModerationParam = Schema.Struct({ + "model": Schema.String.annotate({ + "description": "The moderation model to use for moderated completions, e.g. 'omni-moderation-latest'." + }), + "policy": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaModerationPolicyParam).annotate({ + "description": "The policy to apply to moderated response input and output." + }), + Schema.Null + ]) + ) +}).annotate({ + "description": "Configuration for running moderation on the input and output of this response.", + "identifier": "BetaModerationParam" +}) +export type ListRunStepsResponse = { + readonly "object": string + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean + readonly [x: string]: Schema.Json +} +export const ListRunStepsResponse = Schema.StructWithRest( + Schema.Struct({ + "object": Schema.String, + "data": Schema.Array(RunStepObject), + "first_id": Schema.String, + "last_id": Schema.String, + "has_more": Schema.Boolean + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] +).annotate({ "identifier": "ListRunStepsResponse" }) +export type ListAssistantsResponse = { + readonly "object": string + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean +} +export const ListAssistantsResponse = Schema.Struct({ + "object": Schema.String, + "data": Schema.Array(AssistantObject), + "first_id": Schema.String, + "last_id": Schema.String, + "has_more": Schema.Boolean +}).annotate({ "identifier": "ListAssistantsResponse" }) +export type ListRunsResponse = { + readonly "object": string + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean +} +export const ListRunsResponse = Schema.Struct({ + "object": Schema.String, + "data": Schema.Array(RunObject), + "first_id": Schema.String, + "last_id": Schema.String, + "has_more": Schema.Boolean +}).annotate({ "identifier": "ListRunsResponse" }) +export type ChatCompletionList = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id": string + readonly "last_id": string + readonly "has_more": boolean +} +export const ChatCompletionList = Schema.Struct({ + "object": Schema.Literal("list").annotate({ + "description": "The type of this object. It is always set to \"list\".\n" + }), + "data": Schema.Array(CreateChatCompletionResponse).annotate({ + "description": "An array of chat completion objects.\n" + }), + "first_id": Schema.String.annotate({ + "description": "The identifier of the first chat completion in the data array." + }), + "last_id": Schema.String.annotate({ "description": "The identifier of the last chat completion in the data array." }), + "has_more": Schema.Boolean.annotate({ "description": "Indicates whether there are more Chat Completions available." }) +}).annotate({ + "title": "ChatCompletionList", + "description": "An object representing a list of Chat Completions.\n", + "identifier": "ChatCompletionList" +}) +export type ChatCompletionRequestMessage = + | ChatCompletionRequestDeveloperMessage + | ChatCompletionRequestSystemMessage + | ChatCompletionRequestUserMessage + | ChatCompletionRequestAssistantMessage + | ChatCompletionRequestToolMessage + | ChatCompletionRequestFunctionMessage +export const ChatCompletionRequestMessage = Schema.Union([ + ChatCompletionRequestDeveloperMessage, + ChatCompletionRequestSystemMessage, + ChatCompletionRequestUserMessage, + ChatCompletionRequestAssistantMessage, + ChatCompletionRequestToolMessage, + ChatCompletionRequestFunctionMessage +], { mode: "oneOf" }).annotate({ "identifier": "ChatCompletionRequestMessage" }) +export type EvalItemContent = EvalItemContentItem | EvalItemContentArray +export const EvalItemContent = Schema.Union([EvalItemContentItem, EvalItemContentArray], { mode: "oneOf" }).annotate({ + "title": "Eval content", + "description": + "Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.\n", + "identifier": "EvalItemContent" +}) +export type OutputMessage = { + readonly "id": string + readonly "type": "message" + readonly "role": "assistant" + readonly "content": ReadonlyArray + readonly "phase"?: MessagePhase | null + readonly "status": "in_progress" | "completed" | "incomplete" +} +export const OutputMessage = Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the output message.\n" }), + "type": Schema.Literal("message").annotate({ "description": "The type of the output message. Always `message`.\n" }), + "role": Schema.Literal("assistant").annotate({ + "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", + "identifier": "OutputMessage" +}) +export type ResponseContentPartAddedEvent = { + readonly "type": "response.content_part.added" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "part": OutputContent + readonly "sequence_number": number +} +export const ResponseContentPartAddedEvent = Schema.Struct({ + "type": Schema.Literal("response.content_part.added").annotate({ + "description": "The type of the event. Always `response.content_part.added`.\n" + }), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the content part was added to.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the content part was added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ "description": "The index of the content part that was added.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "part": Schema.suspend((): Schema.Codec => OutputContent).annotate({ + "description": "The content part that was added.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a new content part is added.", + "identifier": "ResponseContentPartAddedEvent" +}) +export type ResponseContentPartDoneEvent = { + readonly "type": "response.content_part.done" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "sequence_number": number + readonly "part": OutputContent +} +export const ResponseContentPartDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.content_part.done").annotate({ + "description": "The type of the event. Always `response.content_part.done`.\n" + }), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the content part was added to.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the content part was added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ "description": "The index of the content part that is done.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "part": Schema.suspend((): Schema.Codec => OutputContent).annotate({ + "description": "The content part that is done.\n" + }) +}).annotate({ "description": "Emitted when a content part is done.", "identifier": "ResponseContentPartDoneEvent" }) +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({ + "role": Schema.Literals(["user", "assistant", "system", "developer"]).annotate({ + "description": "The role of the message input. One of `user`, `assistant`, `system`, or\n`developer`.\n" + }), + "content": Schema.Union([ + Schema.String.annotate({ "title": "Text input", "description": "A text input to the model.\n" }), + InputMessageContentList + ], { mode: "oneOf" }).annotate({ + "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" }) + ) +}).annotate({ + "title": "Input message", + "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. Messages with the\n`assistant` role are presumed to have been generated by the model in previous\ninteractions.\n", + "identifier": "EasyInputMessage" +}) +export type InputMessageResource = { + readonly "type": "message" + readonly "role": "user" | "system" | "developer" + readonly "status"?: "in_progress" | "completed" | "incomplete" + readonly "content": InputMessageContentList + readonly "id": string +} +export const InputMessageResource = Schema.Struct({ + "type": Schema.Literal("message").annotate({ + "description": "The type of the message input. Always set to `message`.\n" + }), + "role": Schema.Literals(["user", "system", "developer"]).annotate({ + "description": "The role of the message input. One of `user`, `system`, or `developer`.\n" + }), + "status": Schema.optionalKey( + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": + "The status of item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + }) + ), + "content": InputMessageContentList, + "id": Schema.String.annotate({ "description": "The unique ID of the message input.\n" }) +}).annotate({ + "title": "Input message", + "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", + "identifier": "InputMessageResource" +}) +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 tool call to a computer use tool. See the\n[computer use guide](/docs/guides/tools-computer-use) for more information.\n", + "identifier": "ComputerToolCall" +}) +export type Tool = + | FunctionTool + | FileSearchTool + | ComputerTool + | ComputerUsePreviewTool + | WebSearchTool + | MCPTool + | CodeInterpreterTool + | ProgrammaticToolCallingParam + | ImageGenTool + | LocalShellToolParam + | FunctionShellToolParam + | CustomToolParam + | NamespaceToolParam + | ToolSearchToolParam + | WebSearchPreviewTool + | ApplyPatchToolParam +export const Tool = Schema.Union([ + FunctionTool, + FileSearchTool, + ComputerTool, + ComputerUsePreviewTool, + WebSearchTool, + MCPTool, + CodeInterpreterTool, + ProgrammaticToolCallingParam, + ImageGenTool, + LocalShellToolParam, + FunctionShellToolParam, + CustomToolParam, + NamespaceToolParam, + ToolSearchToolParam, + WebSearchPreviewTool, + ApplyPatchToolParam +], { mode: "oneOf" }).annotate({ + "description": "A tool that can be used to generate a response.\n", + "identifier": "Tool" +}) +export type ListAuditLogsResponse = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id"?: string | null + readonly "last_id"?: string | null + readonly "has_more": boolean +} +export const ListAuditLogsResponse = Schema.Struct({ + "object": Schema.Literal("list"), + "data": Schema.Array(AuditLog), + "first_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "last_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "has_more": Schema.Boolean +}).annotate({ "identifier": "ListAuditLogsResponse" }) +export type ThreadItem = + | UserMessageItem + | AssistantMessageItem + | WidgetMessageItem + | ClientToolCallItem + | TaskItem + | TaskGroupItem +export const ThreadItem = Schema.Union([ + UserMessageItem, + AssistantMessageItem, + WidgetMessageItem, + ClientToolCallItem, + TaskItem, + TaskGroupItem +], { mode: "oneOf" }).annotate({ "title": "The thread item", "identifier": "ThreadItem" }) +export type BetaTool = + | BetaFunctionTool + | BetaFileSearchTool + | BetaComputerTool + | BetaComputerUsePreviewTool + | BetaWebSearchTool + | BetaMCPTool + | BetaCodeInterpreterTool + | BetaProgrammaticToolCallingParam + | BetaImageGenTool + | BetaLocalShellToolParam + | BetaFunctionShellToolParam + | BetaCustomToolParam + | BetaNamespaceToolParam + | BetaToolSearchToolParam + | BetaWebSearchPreviewTool + | BetaApplyPatchToolParam +export const BetaTool = Schema.Union([ + BetaFunctionTool, + BetaFileSearchTool, + BetaComputerTool, + BetaComputerUsePreviewTool, + BetaWebSearchTool, + BetaMCPTool, + BetaCodeInterpreterTool, + BetaProgrammaticToolCallingParam, + BetaImageGenTool, + BetaLocalShellToolParam, + BetaFunctionShellToolParam, + BetaCustomToolParam, + BetaNamespaceToolParam, + BetaToolSearchToolParam, + BetaWebSearchPreviewTool, + BetaApplyPatchToolParam +], { mode: "oneOf" }).annotate({ + "description": "A tool that can be used to generate a response.\n", + "identifier": "BetaTool" +}) +export type BetaEasyInputMessage = { + readonly "role": "user" | "assistant" | "system" | "developer" + readonly "content": string | BetaInputMessageContentList + readonly "phase"?: BetaMessagePhase | null + readonly "type"?: "message" +} +export const BetaEasyInputMessage = Schema.Struct({ + "role": Schema.Literals(["user", "assistant", "system", "developer"]).annotate({ + "description": "The role of the message input. One of `user`, `assistant`, `system`, or\n`developer`.\n" + }), + "content": Schema.Union([ + Schema.String.annotate({ "title": "Text input", "description": "A text input to the model.\n" }), + BetaInputMessageContentList + ], { mode: "oneOf" }).annotate({ + "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([BetaMessagePhase, Schema.Null])), + "type": Schema.optionalKey( + Schema.Literal("message").annotate({ "description": "The type of the message input. Always `message`.\n" }) + ) +}).annotate({ + "title": "Input message", + "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. Messages with the\n`assistant` role are presumed to have been generated by the model in previous\ninteractions.\n", + "identifier": "BetaEasyInputMessage" +}) +export type BetaInputMessageResource = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "message" + readonly "role": "user" | "system" | "developer" + readonly "status"?: "in_progress" | "completed" | "incomplete" + readonly "content": BetaInputMessageContentList + readonly "id": string +} +export const BetaInputMessageResource = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("message").annotate({ + "description": "The type of the message input. Always set to `message`.\n" + }), + "role": Schema.Literals(["user", "system", "developer"]).annotate({ + "description": "The role of the message input. One of `user`, `system`, or `developer`.\n" + }), + "status": Schema.optionalKey( + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": + "The status of item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + }) + ), + "content": BetaInputMessageContentList, + "id": Schema.String.annotate({ "description": "The unique ID of the message input.\n" }) +}).annotate({ + "title": "Input message", + "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", + "identifier": "BetaInputMessageResource" +}) +export type BetaOutputMessage = { + readonly "agent"?: BetaAgentTag | null + readonly "id": string + readonly "type": "message" + readonly "role": "assistant" + readonly "content": ReadonlyArray + readonly "phase"?: BetaMessagePhase | null + readonly "status": "in_progress" | "completed" | "incomplete" +} +export const BetaOutputMessage = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "id": Schema.String.annotate({ "description": "The unique ID of the output message.\n" }), + "type": Schema.Literal("message").annotate({ "description": "The type of the output message. Always `message`.\n" }), + "role": Schema.Literal("assistant").annotate({ + "description": "The role of the output message. Always `assistant`.\n" + }), + "content": Schema.Array(BetaOutputMessageContent).annotate({ "description": "The content of the output message.\n" }), + "phase": Schema.optionalKey(Schema.Union([BetaMessagePhase, 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", + "identifier": "BetaOutputMessage" +}) +export type BetaResponseContentPartAddedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.content_part.added" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "part": BetaOutputContent + readonly "sequence_number": number +} +export const BetaResponseContentPartAddedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.content_part.added").annotate({ + "description": "The type of the event. Always `response.content_part.added`.\n" + }), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the content part was added to.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the content part was added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ "description": "The index of the content part that was added.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "part": Schema.suspend((): Schema.Codec => BetaOutputContent).annotate({ + "description": "The content part that was added.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when a new content part is added.", + "identifier": "BetaResponseContentPartAddedEvent" +}) +export type BetaResponseContentPartDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.content_part.done" + readonly "item_id": string + readonly "output_index": number + readonly "content_index": number + readonly "sequence_number": number + readonly "part": BetaOutputContent +} +export const BetaResponseContentPartDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.content_part.done").annotate({ + "description": "The type of the event. Always `response.content_part.done`.\n" + }), + "item_id": Schema.String.annotate({ + "description": "The ID of the output item that the content part was added to.\n" + }), + "output_index": Schema.Number.annotate({ + "description": "The index of the output item that the content part was added to.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.annotate({ "description": "The index of the content part that is done.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "part": Schema.suspend((): Schema.Codec => BetaOutputContent).annotate({ + "description": "The content part that is done.\n" + }) +}).annotate({ "description": "Emitted when a content part is done.", "identifier": "BetaResponseContentPartDoneEvent" }) +export type BetaComputerToolCall = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "computer_call" + readonly "id": string + readonly "call_id": string + readonly "action"?: BetaComputerAction + readonly "actions"?: BetaComputerActionList + readonly "pending_safety_checks": ReadonlyArray + readonly "status": "in_progress" | "completed" | "incomplete" +} +export const BetaComputerToolCall = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "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(BetaComputerAction), + "actions": Schema.optionalKey(BetaComputerActionList), + "pending_safety_checks": Schema.Array(BetaComputerCallSafetyCheckParam).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 tool call to a computer use tool. See the\n[computer use guide](/docs/guides/tools-computer-use) for more information.\n", + "identifier": "BetaComputerToolCall" +}) +export type CreateChatCompletionRequest = { + 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 | null + readonly "prompt_cache_key"?: string | null | null + readonly "service_tier"?: ServiceTier + readonly "prompt_cache_retention"?: "in_memory" | "in_memory" | "24h" | null + readonly "prompt_cache_options"?: PromptCacheOptionsParam + readonly "messages": ReadonlyArray + readonly "model": ModelIdsShared + readonly "modalities"?: ResponseModalities + readonly "verbosity"?: Verbosity + readonly "reasoning_effort"?: ReasoningEffort + readonly "max_completion_tokens"?: number | null + readonly "frequency_penalty"?: number | null + readonly "presence_penalty"?: number | null + readonly "web_search_options"?: { + readonly "user_location"?: { + readonly "type": "approximate" + readonly "approximate": WebSearchLocation + readonly [x: string]: Schema.Json + } | null + readonly "search_context_size"?: WebSearchContextSize + } + readonly "response_format"?: ResponseFormatText | ResponseFormatJsonSchema | ResponseFormatJsonObject + readonly "audio"?: { + readonly "voice": VoiceIdsOrCustomVoice + readonly "format": "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16" + readonly [x: string]: Schema.Json + } | null + readonly "store"?: boolean | null + readonly "moderation"?: ModerationParam | null + readonly "stream"?: boolean | null + readonly "stop"?: StopConfiguration + readonly "logit_bias"?: { readonly [x: string]: number } | null + readonly "logprobs"?: boolean | null + readonly "max_tokens"?: number | null + readonly "n"?: number | null + readonly "prediction"?: PredictionContent | null + readonly "seed"?: number | null + readonly "stream_options"?: ChatCompletionStreamOptions + readonly "tools"?: ReadonlyArray + readonly "tool_choice"?: ChatCompletionToolChoiceOption + readonly "parallel_tool_calls"?: ParallelToolCalls + readonly "function_call"?: "none" | "auto" | ChatCompletionFunctionCallOption + readonly "functions"?: ReadonlyArray +} +export const CreateChatCompletionRequest = Schema.Struct({ + "metadata": Schema.optionalKey(Metadata), + "top_logprobs": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" })).check( + Schema.makeFilterGroup([ + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }), + Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" }), + Schema.makeFilterGroup([ + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }), + Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" }) + ]).annotate({ + "description": + "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" + }) + ]).annotate({ + "description": + "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" + }) + ) + ]).annotate({ + "description": + "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n`logprobs` must be set to `true` if this parameter is used.\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().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 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().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 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.Union([ + Schema.String.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" + }).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + Schema.Null + ]), + Schema.Null + ])), + "prompt_cache_key": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.String.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" + }), + Schema.Null + ]), + Schema.Null + ]) + ), + "service_tier": Schema.optionalKey(ServiceTier), + "prompt_cache_retention": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in_memory", "in_memory", "24h"]).annotate({ + "description": + "Deprecated. Use `prompt_cache_options.ttl` instead.\n\nThe 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).\nThis field expresses a maximum retention policy, while\n`prompt_cache_options.ttl` expresses a minimum cache lifetime. The two\nfields are independent and do not interact.\nFor `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.\n\nFor older models that support both `in_memory` and `24h`, the default depends on your organization's data retention policy:\n - Organizations without ZDR enabled default to `24h`.\n - Organizations with ZDR enabled default to `in_memory` when `prompt_cache_retention` is not specified.\n" + }), + Schema.Null + ]) + ), + "prompt_cache_options": Schema.optionalKey(PromptCacheOptionsParam), + "messages": Schema.Array(ChatCompletionRequestMessage).annotate({ + "description": + "A list of messages comprising the conversation so far. Depending on the\n[model](/docs/models) you use, different message types (modalities) are\nsupported, like [text](/docs/guides/text-generation),\n[images](/docs/guides/vision), and [audio](/docs/guides/audio).\n" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "model": Schema.suspend((): Schema.Codec => ModelIdsShared).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" + }), + "modalities": Schema.optionalKey(ResponseModalities), + "verbosity": Schema.optionalKey(Verbosity), + "reasoning_effort": Schema.optionalKey(ReasoningEffort), + "max_completion_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "description": + "An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning).\n" + }) + ), + "frequency_penalty": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(-2).annotate({ "expected": "a value greater than or equal to -2" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]).annotate({ + "description": + "Number between -2.0 and 2.0. Positive values penalize new tokens based on\ntheir existing frequency in the text so far, decreasing the model's\nlikelihood to repeat the same line verbatim.\n" + }) + ), + "presence_penalty": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(-2).annotate({ "expected": "a value greater than or equal to -2" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]).annotate({ + "description": + "Number between -2.0 and 2.0. Positive values penalize new tokens based on\nwhether they appear in the text so far, increasing the model's likelihood\nto talk about new topics.\n" + }) + ), + "web_search_options": Schema.optionalKey( + Schema.Struct({ + "user_location": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "type": Schema.Literal("approximate").annotate({ + "description": "The type of location approximation. Always `approximate`.\n" + }), + "approximate": WebSearchLocation + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ "description": "Approximate location parameters for the search.\n" }) + ), + "search_context_size": Schema.optionalKey(WebSearchContextSize) + }).annotate({ + "title": "Web search", + "description": + "This tool searches the web for relevant results to use in a response.\nLearn more about the [web search tool](/docs/guides/tools-web-search?api-mode=chat).\n" + }) + ), + "response_format": Schema.optionalKey( + Schema.Union([ResponseFormatText, ResponseFormatJsonSchema, ResponseFormatJsonObject], { mode: "oneOf" }).annotate({ + "description": + "An object specifying the format that the model must output.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables\nStructured Outputs which ensures the model will match your supplied JSON\nschema. Learn more in the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n" + }) + ), + "audio": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "voice": Schema.suspend((): Schema.Codec => VoiceIdsOrCustomVoice).annotate({ + "description": + "The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`,\n`sage`, `shimmer`, `marin`, and `cedar`. You may also provide a\ncustom voice object with an `id`, for example `{ \"id\": \"voice_1234\" }`.\n" + }), + "format": Schema.Literals(["wav", "aac", "mp3", "flac", "opus", "pcm16"]).annotate({ + "description": + "Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`,\n`opus`, or `pcm16`.\n" + }) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ + "description": + "Parameters for audio output. Required when audio output is requested with\n`modalities: [\"audio\"]`. [Learn more](/docs/guides/audio).\n" + }) + ), + "store": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether or not to store the output of this chat completion request for\nuse in our [model distillation](/docs/guides/distillation) or\n[evals](/docs/guides/evals) products.\n\nSupports text and image inputs. Note: image inputs over 8MB will be dropped.\n" + }) + ), + "moderation": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ModerationParam).annotate({ + "description": "Configuration for running moderation on the request input and generated output.\n" + }), + Schema.Null + ]) + ), + "stream": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).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/chat/streaming)\nfor more information, along with the [streaming responses](/docs/guides/streaming-responses)\nguide for more information on how to handle the streaming events.\n" + }) + ), + "stop": Schema.optionalKey(StopConfiguration), + "logit_bias": Schema.optionalKey( + Schema.Union([ + Schema.Record(Schema.String, Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + Schema.Null + ]).annotate({ + "description": + "Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a JSON object that maps tokens (specified by their token ID in the\ntokenizer) to an associated bias value from -100 to 100. Mathematically,\nthe bias is added to the logits generated by the model prior to sampling.\nThe exact effect will vary per model, but values between -1 and 1 should\ndecrease or increase likelihood of selection; values like -100 or 100\nshould result in a ban or exclusive selection of the relevant token.\n" + }) + ), + "logprobs": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to return log probabilities of the output tokens or not. If true,\nreturns the log probabilities of each output token returned in the\n`content` of `message`.\n" + }) + ), + "max_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "description": + "The maximum number of [tokens](/tokenizer) that can be generated in the\nchat completion. This value can be used to control\n[costs](https://openai.com/api/pricing/) for text generated via API.\n\nThis value is now deprecated in favor of `max_completion_tokens`, and is\nnot compatible with [o-series models](/docs/guides/reasoning).\n" + }) + ), + "n": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(128).annotate({ "expected": "a value less than or equal to 128" })), + Schema.Null + ]).annotate({ + "description": + "How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs." + }) + ), + "prediction": Schema.optionalKey(Schema.Union([ + Schema.Union([PredictionContent], { mode: "oneOf" }).annotate({ + "description": + "Configuration for a [Predicted Output](/docs/guides/predicted-outputs),\nwhich can greatly improve response times when large parts of the model\nresponse are known ahead of time. This is most common when you are\nregenerating a file with only minor changes to most of the content.\n" + }), + Schema.Null + ])), + "seed": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(-9223372036854776000).annotate({ + "expected": "a value greater than or equal to -9223372036854776000" + }) + ).check( + Schema.isLessThanOrEqualTo(9223372036854776000).annotate({ + "expected": "a value less than or equal to 9223372036854776000" + }) + ), + Schema.Null + ]).annotate({ + "description": + "This feature is in Beta.\nIf specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.\nDeterminism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.\n" + }) + ), + "stream_options": Schema.optionalKey(ChatCompletionStreamOptions), + "tools": Schema.optionalKey( + Schema.Array(Schema.Union([ChatCompletionTool, CustomToolChatCompletions], { mode: "oneOf" })).annotate({ + "description": + "A list of tools the model may call. You can provide either\n[custom tools](/docs/guides/function-calling#custom-tools) or\n[function tools](/docs/guides/function-calling).\n" + }) + ), + "tool_choice": Schema.optionalKey(ChatCompletionToolChoiceOption), + "parallel_tool_calls": Schema.optionalKey(ParallelToolCalls), + "function_call": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["none", "auto"]).annotate({ + "description": + "`none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.\n" + }), + ChatCompletionFunctionCallOption + ], { mode: "oneOf" }).annotate({ + "description": + "Deprecated in favor of `tool_choice`.\n\nControls which (if any) function is called by the model.\n\n`none` means the model will not call a function and instead generates a\nmessage.\n\n`auto` means the model can pick between generating a message or calling a\nfunction.\n\nSpecifying a particular function via `{\"name\": \"my_function\"}` forces the\nmodel to call that function.\n\n`none` is the default when no functions are present. `auto` is the default\nif functions are present.\n" + }) + ), + "functions": Schema.optionalKey( + Schema.Array(ChatCompletionFunctions).annotate({ + "description": "Deprecated in favor of `tools`.\n\nA list of functions the model may generate JSON inputs for.\n" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" }) + ) + ) +}).annotate({ "identifier": "CreateChatCompletionRequest" }) +export type EvalItem = { + readonly "role": "user" | "assistant" | "system" | "developer" + readonly "content": EvalItemContent + readonly "type"?: "message" +} +export const EvalItem = Schema.Struct({ + "role": Schema.Literals(["user", "assistant", "system", "developer"]).annotate({ + "description": "The role of the message input. One of `user`, `assistant`, `system`, or\n`developer`.\n" + }), + "content": EvalItemContent, + "type": Schema.optionalKey( + Schema.Literal("message").annotate({ "description": "The type of the message input. Always `message`.\n" }) + ) +}).annotate({ + "title": "Eval message object", + "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. Messages with the\n`assistant` role are presumed to have been generated by the model in previous\ninteractions.\n", + "identifier": "EvalItem" +}) +export type CreateEvalItem = { readonly "role": string; readonly "content": string } | { + readonly "role": "user" | "assistant" | "system" | "developer" + readonly "content": EvalItemContent + readonly "type"?: "message" +} +export const CreateEvalItem = Schema.Union([ + Schema.Struct({ + "role": Schema.String.annotate({ + "description": "The role of the message (e.g. \"system\", \"assistant\", \"user\")." + }), + "content": Schema.String.annotate({ "description": "The content of the message." }) + }).annotate({ + "title": "CreateEvalItem", + "description": + "A chat message that makes up the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." + }), + Schema.Struct({ + "role": Schema.Literals(["user", "assistant", "system", "developer"]).annotate({ + "description": "The role of the message input. One of `user`, `assistant`, `system`, or\n`developer`.\n" + }), + "content": EvalItemContent, + "type": Schema.optionalKey( + Schema.Literal("message").annotate({ "description": "The type of the message input. Always `message`.\n" }) + ) + }).annotate({ + "title": "CreateEvalItem", + "description": + "A chat message that makes up the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." + }) +], { mode: "oneOf" }).annotate({ "identifier": "CreateEvalItem" }) +export type ToolSearchOutput = { + readonly "type": "tool_search_output" + readonly "id": string + readonly "call_id": string | null + readonly "execution": ToolSearchExecutionType + readonly "tools": ReadonlyArray + readonly "status": FunctionCallOutputStatusEnum + 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.suspend((): Schema.Codec => ToolSearchExecutionType).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.suspend((): Schema.Codec => FunctionCallOutputStatusEnum).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." }) + ) +}).annotate({ "identifier": "ToolSearchOutput" }) +export type AdditionalTools = { + readonly "type": "additional_tools" + readonly "id": string + readonly "role": MessageRole + readonly "tools": ReadonlyArray +} +export const AdditionalTools = Schema.Struct({ + "type": Schema.Literal("additional_tools").annotate({ + "description": "The type of the item. Always `additional_tools`." + }), + "id": Schema.String.annotate({ "description": "The unique ID of the additional tools item." }), + "role": Schema.suspend((): Schema.Codec => MessageRole).annotate({ + "description": "The role that provided the additional tools." + }), + "tools": Schema.Array(Tool).annotate({ + "description": "The additional tool definitions made available at this item." + }) +}).annotate({ "identifier": "AdditionalTools" }) +export type InputItem = + | EasyInputMessage + | { + readonly "type"?: "message" + readonly "role": "user" | "system" | "developer" + readonly "status"?: "in_progress" | "completed" | "incomplete" + readonly "content": InputMessageContentList + } + | { + readonly "id": string + readonly "type": "message" + readonly "role": "assistant" + readonly "content": ReadonlyArray + readonly "phase"?: MessagePhase | null + readonly "status": "in_progress" | "completed" | "incomplete" + } + | { + readonly "id": string + readonly "type": "file_search_call" + readonly "status": "in_progress" | "searching" | "completed" | "incomplete" | "failed" + readonly "queries": ReadonlyArray + readonly "results"?: + | ReadonlyArray< + { + readonly "file_id"?: string + readonly "text"?: string + readonly "filename"?: string + readonly "attributes"?: VectorStoreFileAttributes + readonly "score"?: number + } + > + | null + } + | { + 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" + } + | { + readonly "id"?: string | null + readonly "call_id": string + readonly "type": "computer_call_output" + readonly "output": ComputerScreenshotImage + readonly "acknowledged_safety_checks"?: ReadonlyArray | null + readonly "status"?: FunctionCallItemStatus | null + } + | { + readonly "id": string + readonly "type": "web_search_call" + readonly "status": "in_progress" | "searching" | "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 | null } + | { readonly "type": "find_in_page"; readonly "url": string; readonly "pattern": string } + } + | { + readonly "id"?: string + readonly "type": "function_call" + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "arguments": string + readonly "status"?: "in_progress" | "completed" | "incomplete" + } + | { + readonly "id"?: string | null + readonly "call_id": string + readonly "type": "function_call_output" + readonly "output": + | string + | ReadonlyArray + readonly "name"?: string | null + readonly "namespace"?: string | null + readonly "caller"?: ToolCallCallerParam | null + readonly "status"?: FunctionCallItemStatus | null + } + | { + readonly "id"?: string | null + readonly "call_id"?: string | null + readonly "type": "tool_search_call" + readonly "execution"?: ToolSearchExecutionType + readonly "arguments": EmptyModelParam + readonly "status"?: FunctionCallItemStatus | null + } + | { + readonly "id"?: string | null + readonly "call_id"?: string | null + readonly "type": "tool_search_output" + readonly "execution"?: ToolSearchExecutionType + readonly "tools": ReadonlyArray + readonly "status"?: FunctionCallItemStatus | null + } + | { + readonly "id"?: string | null + readonly "type": "additional_tools" + readonly "role": "developer" + readonly "tools": ReadonlyArray + } + | { + readonly "type": "reasoning" + readonly "id": string + readonly "encrypted_content"?: string | null + readonly "summary": ReadonlyArray + readonly "content"?: ReadonlyArray + readonly "status"?: "in_progress" | "completed" | "incomplete" + } + | { readonly "id"?: string | null; readonly "type": "compaction"; readonly "encrypted_content": string } + | { + readonly "type": "image_generation_call" + readonly "id": string + readonly "status": "in_progress" | "completed" | "generating" | "failed" + readonly "result": string | null + } + | { + 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 + } + | { + readonly "type": "local_shell_call" + readonly "id": string + readonly "call_id": string + readonly "action": LocalShellExecAction + readonly "status": "in_progress" | "completed" | "incomplete" + } + | { + readonly "type": "local_shell_call_output" + readonly "id": string + readonly "output": string + readonly "status"?: "in_progress" | "completed" | "incomplete" | null + readonly "call_id": Schema.Json + } + | { + readonly "id"?: string | null + readonly "call_id": string + readonly "caller"?: ToolCallCallerParam | null + readonly "type": "shell_call" + readonly "action": FunctionShellActionParam + readonly "status"?: FunctionShellCallItemStatus | null + readonly "environment"?: LocalEnvironmentParam | ContainerReferenceParam | null + } + | { + readonly "id"?: string | null + readonly "call_id": string + readonly "caller"?: ToolCallCallerParam | null + readonly "type": "shell_call_output" + readonly "output": ReadonlyArray + readonly "status"?: FunctionShellCallItemStatus | null + readonly "max_output_length"?: number | null + } + | { + readonly "type": "apply_patch_call" + readonly "id"?: string | null + readonly "call_id": string + readonly "caller"?: ToolCallCallerParam | null + readonly "status": ApplyPatchCallStatusParam + readonly "operation": ApplyPatchOperationParam + } + | { + readonly "type": "apply_patch_call_output" + readonly "id"?: string | null + readonly "call_id": string + readonly "caller"?: ToolCallCallerParam | null + readonly "status": ApplyPatchCallOutputStatusParam + readonly "output"?: string | null + } + | { + readonly "type": "mcp_list_tools" + readonly "id": string + readonly "server_label": string + readonly "tools": ReadonlyArray + readonly "error"?: string | null + } + | { + readonly "type": "mcp_approval_request" + readonly "id": string + readonly "server_label": string + readonly "name": string + readonly "arguments": string + } + | { + readonly "type": "mcp_approval_response" + readonly "id"?: string | null + readonly "approval_request_id": string + readonly "approve": boolean + readonly "reason"?: string | null + readonly "request_id": Schema.Json + } + | { + readonly "type": "mcp_call" + readonly "id": string + readonly "server_label": string + readonly "name": string + readonly "arguments": string + readonly "output"?: string | null + readonly "error"?: string | null + readonly "status"?: MCPToolCallStatus + readonly "approval_request_id"?: string | null + } + | { + readonly "type": "custom_tool_call_output" + readonly "id"?: string + readonly "call_id": string + readonly "caller"?: ToolCallCallerParam | null + readonly "output": string | ReadonlyArray + } + | { + readonly "type": "custom_tool_call" + readonly "id"?: string + readonly "call_id": string + readonly "caller"?: ToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "input": string + } + | CompactionTriggerItemParam + | ItemReferenceParam + | ProgramItemParam + | ProgramOutputItemParam +export const InputItem = Schema.Union([ + EasyInputMessage, + Schema.Union([ + Schema.Struct({ + "type": Schema.optionalKey( + Schema.Literal("message").annotate({ + "description": "The type of the message input. Always set to `message`.\n" + }) + ), + "role": Schema.Literals(["user", "system", "developer"]).annotate({ + "description": "The role of the message input. One of `user`, `system`, or `developer`.\n" + }), + "status": Schema.optionalKey( + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": + "The status of item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + }) + ), + "content": InputMessageContentList + }).annotate({ "title": "Input message", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the output message.\n" }), + "type": Schema.Literal("message").annotate({ + "description": "The type of the output message. Always `message`.\n" + }), + "role": Schema.Literal("assistant").annotate({ + "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": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the file search tool call.\n" }), + "type": Schema.Literal("file_search_call").annotate({ + "description": "The type of the file search tool call. Always `file_search_call`.\n" + }), + "status": Schema.Literals(["in_progress", "searching", "completed", "incomplete", "failed"]).annotate({ + "description": + "The status of the file search tool call. One of `in_progress`,\n`searching`, `incomplete` or `failed`,\n" + }), + "queries": Schema.Array(Schema.String).annotate({ "description": "The queries used to search for files.\n" }), + "results": Schema.optionalKey(Schema.Union([ + Schema.Array(Schema.Struct({ + "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the file.\n" })), + "text": Schema.optionalKey( + Schema.String.annotate({ "description": "The text that was retrieved from the file.\n" }) + ), + "filename": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the file.\n" })), + "attributes": Schema.optionalKey(VectorStoreFileAttributes), + "score": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The relevance score of the file - a value between 0 and 1.\n", + "format": "float" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) + })).annotate({ "description": "The results of the file search tool call.\n" }), + Schema.Null + ])) + }).annotate({ "title": "File search tool call", "description": "Content item used to generate a response.\n" }), + 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": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The ID of the computer tool call output." }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ "description": "The ID of the computer tool call that produced the output." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "type": Schema.Literal("computer_call_output").annotate({ + "description": "The type of the computer tool call output. Always `computer_call_output`." + }), + "output": ComputerScreenshotImage, + "acknowledged_safety_checks": Schema.optionalKey( + Schema.Union([ + Schema.Array(ComputerCallSafetyCheckParam).annotate({ + "description": "The safety checks reported by the API that have been acknowledged by the developer." + }), + Schema.Null + ]) + ), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => FunctionCallItemStatus).annotate({ + "description": + "The status of the message input. One of `in_progress`, `completed`, or `incomplete`. Populated when input items are returned via API." + }), + Schema.Null + ]) + ) + }).annotate({ "title": "Computer tool call output", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.String.annotate({ "description": "The unique ID of the web search tool call.\n" }), + "type": Schema.Literal("web_search_call").annotate({ + "description": "The type of the web search tool call. Always `web_search_call`.\n" + }), + "status": Schema.Literals(["in_progress", "searching", "completed", "failed"]).annotate({ + "description": "The status of the web search tool call.\n" + }), + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search").annotate({ "description": "The action type.\n" }), + "query": Schema.optionalKey(Schema.String.annotate({ "description": "The search query.\n" })), + "queries": Schema.optionalKey( + Schema.Array(Schema.String.annotate({ "description": "A search query.\n" })).annotate({ + "title": "Search queries", + "description": "The search queries.\n" + }) + ), + "sources": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "type": Schema.Literal("url").annotate({ "description": "The type of source. Always `url`.\n" }), + "url": Schema.String.annotate({ "description": "The URL of the source.\n", "format": "uri" }) + }).annotate({ "title": "Web search source", "description": "A source used in the search.\n" }) + ).annotate({ "title": "Web search sources", "description": "The sources used in the search.\n" }) + ) + }).annotate({ + "title": "Search action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }), + Schema.Struct({ + "type": Schema.Literal("open_page").annotate({ "description": "The action type.\n" }), + "url": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "format": "uri" }), Schema.Null]).annotate({ + "description": "The URL opened by the model.\n" + }) + ) + }).annotate({ + "title": "Open page action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }), + Schema.Struct({ + "type": Schema.Literal("find_in_page").annotate({ "description": "The action type.\n" }), + "url": Schema.String.annotate({ + "description": "The URL of the page searched for the pattern.\n", + "format": "uri" + }), + "pattern": Schema.String.annotate({ "description": "The pattern or text to search for within the page.\n" }) + }).annotate({ + "title": "Find action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }) + ], { mode: "oneOf" }) + }).annotate({ "title": "Web search tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the function tool call.\n" })), + "type": Schema.Literal("function_call").annotate({ + "description": "The type of the function tool call. Always `function_call`.\n" + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" + }), + "caller": Schema.optionalKey(Schema.Union([ToolCallCaller, Schema.Null])), + "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( + 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": "Function tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The unique ID of the function tool call output. Populated when this item is returned via API." + }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "type": Schema.Literal("function_call_output").annotate({ + "description": "The type of the function tool call output. Always `function_call_output`." + }), + "output": Schema.Union([ + Schema.String.annotate({ "description": "A JSON string of the output of the function tool call." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ), + Schema.Array( + Schema.Union([InputTextContentParam, InputImageContentParamAutoParam, InputFileContentParam], { + mode: "oneOf" + }).annotate({ "description": "A piece of message content, such as text, an image, or a file." }) + ).annotate({ "description": "An array of content outputs (text, image, file) for the function tool call." }) + ], { mode: "oneOf" }).annotate({ "description": "Text, image, or file output of the function tool call." }), + "name": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The name of the tool that produced the output." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })), + Schema.Null + ]) + ), + "namespace": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The namespace of the tool that produced the output." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" + }) + ), + Schema.Null + ]) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => FunctionCallItemStatus).annotate({ + "description": + "The status of the item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API." + }), + Schema.Null + ]) + ) + }).annotate({ "title": "Function tool call output", "description": "Content item used to generate a response.\n" }), + 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).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + Schema.Null + ]) + ), + "type": Schema.Literal("tool_search_call").annotate({ + "description": "The item type. Always `tool_search_call`." + }), + "execution": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ToolSearchExecutionType).annotate({ + "description": "Whether tool search was executed by the server or by the client." + }) + ), + "arguments": Schema.suspend((): Schema.Codec => EmptyModelParam).annotate({ + "description": "The arguments supplied to the tool search call." + }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => FunctionCallItemStatus).annotate({ + "description": "The status of the tool search call." + }), + Schema.Null + ]) + ) + }).annotate({ "description": "Content item used to generate a response.\n" }), + 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).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + Schema.Null + ]) + ), + "type": Schema.Literal("tool_search_output").annotate({ + "description": "The item type. Always `tool_search_output`." + }), + "execution": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ToolSearchExecutionType).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.suspend((): Schema.Codec => FunctionCallItemStatus).annotate({ + "description": "The status of the tool search output." + }), + Schema.Null + ]) + ) + }).annotate({ "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of this additional tools item." }), + Schema.Null + ]) + ), + "type": Schema.Literal("additional_tools").annotate({ + "description": "The item type. Always `additional_tools`." + }), + "role": Schema.Literal("developer").annotate({ + "description": "The role that provided the additional tools. Only `developer` is supported." + }), + "tools": Schema.Array(Tool).annotate({ "description": "A list of additional tools made available at this item." }) + }).annotate({ "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("reasoning").annotate({ "description": "The type of the object. Always `reasoning`.\n" }), + "id": Schema.String.annotate({ "description": "The unique identifier of the reasoning content.\n" }), + "encrypted_content": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The encrypted content of the reasoning item. This is populated by default\nfor reasoning items returned by `POST /v1/responses` and WebSocket\n`response.create` requests.\n" + }), + Schema.Null + ]) + ), + "summary": Schema.Array(SummaryTextContent).annotate({ "description": "Reasoning summary content.\n" }), + "content": Schema.optionalKey( + Schema.Array(ReasoningTextContent).annotate({ "description": "Reasoning text content.\n" }) + ), + "status": Schema.optionalKey( + 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": "Reasoning", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The ID of the compaction item." }), Schema.Null]) + ), + "type": Schema.Literal("compaction").annotate({ "description": "The type of the item. Always `compaction`." }), + "encrypted_content": Schema.String.annotate({ "description": "The encrypted content of the compaction summary." }) + .check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })) + }).annotate({ "title": "Compaction item", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("image_generation_call").annotate({ + "description": "The type of the image generation call. Always `image_generation_call`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the image generation call.\n" }), + "status": Schema.Literals(["in_progress", "completed", "generating", "failed"]).annotate({ + "description": "The status of the image generation call.\n" + }), + "result": Schema.Union([ + Schema.String.annotate({ "description": "The generated image encoded in base64.\n" }), + Schema.Null + ]) + }).annotate({ "title": "Image generation call", "description": "Content item used to generate a response.\n" }), + 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": "Content item used to generate a response.\n" + }), + 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": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("local_shell_call_output").annotate({ + "description": "The type of the local shell tool call output. Always `local_shell_call_output`.\n" + }), + "id": Schema.String.annotate({ + "description": "The unique ID of the local shell tool call generated by the model.\n" + }), + "output": Schema.String.annotate({ + "description": "A JSON string of the output of the local shell tool call.\n" + }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the item. One of `in_progress`, `completed`, or `incomplete`.\n" + }), + Schema.Null + ]) + ), + "call_id": Schema.Json.annotate({ "expected": "JSON value" }) + }).annotate({ "title": "Local shell call output", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "The unique ID of the shell tool call. Populated when this item is returned via API." + }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the shell tool call generated by the model." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "type": Schema.Literal("shell_call").annotate({ "description": "The type of the item. Always `shell_call`." }), + "action": Schema.suspend((): Schema.Codec => FunctionShellActionParam).annotate({ + "description": "The shell commands and limits that describe how to run the tool call." + }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => FunctionShellCallItemStatus).annotate({ + "description": "The status of the shell call. One of `in_progress`, `completed`, or `incomplete`." + }), + Schema.Null + ]) + ), + "environment": Schema.optionalKey( + Schema.Union([ + Schema.Union([LocalEnvironmentParam, ContainerReferenceParam], { mode: "oneOf" }).annotate({ + "description": "The environment to execute the shell commands in." + }), + Schema.Null + ]) + ) + }).annotate({ "title": "Shell tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "The unique ID of the shell tool call output. Populated when this item is returned via API." + }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the shell tool call generated by the model." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "type": Schema.Literal("shell_call_output").annotate({ + "description": "The type of the item. Always `shell_call_output`." + }), + "output": Schema.Array(FunctionShellCallOutputContentParam).annotate({ + "description": "Captured chunks of stdout and stderr output, along with their associated outcomes." + }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => FunctionShellCallItemStatus).annotate({ + "description": "The status of the shell call output." + }), + Schema.Null + ]) + ), + "max_output_length": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The maximum number of UTF-8 characters captured for this shell call's combined output." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ) + }).annotate({ "title": "Shell tool call output", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("apply_patch_call").annotate({ + "description": "The type of the item. Always `apply_patch_call`." + }), + "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).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "status": Schema.suspend((): Schema.Codec => ApplyPatchCallStatusParam).annotate({ + "description": "The status of the apply patch tool call. One of `in_progress` or `completed`." + }), + "operation": Schema.suspend((): Schema.Codec => ApplyPatchOperationParam).annotate({ + "description": "The specific create, delete, or update instruction for the apply_patch tool call." + }) + }).annotate({ "title": "Apply patch tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("apply_patch_call_output").annotate({ + "description": "The type of the item. Always `apply_patch_call_output`." + }), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The unique ID of the apply patch tool call output. 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).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "status": Schema.suspend((): Schema.Codec => ApplyPatchCallOutputStatusParam) + .annotate({ "description": "The status of the apply patch tool call output. One of `completed` or `failed`." }), + "output": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "Optional human-readable log text from the apply patch tool (e.g., patch results or errors)." + }).check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })), + Schema.Null + ]) + ) + }).annotate({ + "title": "Apply patch tool call output", + "description": "Content item used to generate a response.\n" + }), + Schema.Struct({ + "type": Schema.Literal("mcp_list_tools").annotate({ + "description": "The type of the item. Always `mcp_list_tools`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the list.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server.\n" }), + "tools": Schema.Array(MCPListToolsTool).annotate({ "description": "The tools available on the server.\n" }), + "error": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "Error message if the server could not list tools.\n" }), + Schema.Null + ]) + ) + }).annotate({ "title": "MCP list tools", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("mcp_approval_request").annotate({ + "description": "The type of the item. Always `mcp_approval_request`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the approval request.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server making the request.\n" }), + "name": Schema.String.annotate({ "description": "The name of the tool to run.\n" }), + "arguments": Schema.String.annotate({ "description": "A JSON string of arguments for the tool.\n" }) + }).annotate({ "title": "MCP approval request", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("mcp_approval_response").annotate({ + "description": "The type of the item. Always `mcp_approval_response`.\n" + }), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of the approval response\n" }), + Schema.Null + ]) + ), + "approval_request_id": Schema.String.annotate({ + "description": "The ID of the approval request being answered.\n" + }), + "approve": Schema.Boolean.annotate({ "description": "Whether the request was approved.\n" }), + "reason": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "Optional reason for the decision.\n" }), Schema.Null]) + ), + "request_id": Schema.Json.annotate({ "expected": "JSON value" }) + }).annotate({ "title": "MCP approval response", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("mcp_call").annotate({ "description": "The type of the item. Always `mcp_call`.\n" }), + "id": Schema.String.annotate({ "description": "The unique ID of the tool call.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server running the tool.\n" }), + "name": Schema.String.annotate({ "description": "The name of the tool that was run.\n" }), + "arguments": Schema.String.annotate({ "description": "A JSON string of the arguments passed to the tool.\n" }), + "output": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The output from the tool call.\n" }), Schema.Null]) + ), + "error": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The error from the tool call, if any.\n" }), + Schema.Null + ]) + ), + "status": Schema.optionalKey( + Schema.suspend((): Schema.Codec => MCPToolCallStatus).annotate({ + "description": + "The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`, or `failed`.\n" + }) + ), + "approval_request_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "Unique identifier for the MCP tool call approval request.\nInclude this value in a subsequent `mcp_approval_response` input to approve or reject the corresponding tool call.\n" + }), + Schema.Null + ]) + ) + }).annotate({ "title": "MCP tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("custom_tool_call_output").annotate({ + "description": "The type of the custom tool call output. Always `custom_tool_call_output`.\n" + }), + "id": Schema.optionalKey( + Schema.String.annotate({ + "description": "The unique ID of the custom tool call output in the OpenAI platform.\n" + }) + ), + "call_id": Schema.String.annotate({ + "description": "The call ID, used to map this custom tool call output to a custom tool call.\n" + }), + "caller": Schema.optionalKey(Schema.Union([ToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the custom tool call.\n" + }), + Schema.Array(FunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the custom tool call.\n" + }) + ], { mode: "oneOf" }).annotate({ + "description": + "The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n" + }) + }).annotate({ "title": "Custom tool call output", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "type": Schema.Literal("custom_tool_call").annotate({ + "description": "The type of the custom tool call. Always `custom_tool_call`.\n" + }), + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The unique ID of the custom tool call in the OpenAI platform.\n" }) + ), + "call_id": Schema.String.annotate({ + "description": "An identifier used to map this custom tool call to a tool call output.\n" + }), + "caller": Schema.optionalKey(Schema.Union([ToolCallCaller, Schema.Null])), + "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": "Content item used to generate a response.\n" }) + ], { mode: "oneOf" }).annotate({ + "title": "Item", + "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" + }), + CompactionTriggerItemParam, + ItemReferenceParam, + ProgramItemParam, + ProgramOutputItemParam +], { mode: "oneOf" }).annotate({ "identifier": "InputItem" }) +export type ToolsArray = ReadonlyArray +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", + "identifier": "ToolsArray" +}) +export type ThreadItemListResource = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "last_id": string | null + readonly "has_more": boolean +} +export const ThreadItemListResource = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), + "data": Schema.Array(ThreadItem).annotate({ "description": "A list of items" }), + "first_id": Schema.Union([ + Schema.String.annotate({ "description": "The ID of the first item in the list." }), + Schema.Null + ]), + "last_id": Schema.Union([ + Schema.String.annotate({ "description": "The ID of the last item in the list." }), + Schema.Null + ]), + "has_more": Schema.Boolean.annotate({ "description": "Whether there are more items available." }) +}).annotate({ + "title": "Thread Items", + "description": "A paginated list of thread items rendered for the ChatKit API.", + "identifier": "ThreadItemListResource" +}) +export type BetaToolsArray = ReadonlyArray +export const BetaToolsArray = Schema.Array(BetaTool).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", + "identifier": "BetaToolsArray" +}) +export type BetaToolSearchOutput = { + readonly "agent"?: BetaAgentTag + readonly "type": "tool_search_output" + readonly "id": string + readonly "call_id": string | null + readonly "execution": BetaToolSearchExecutionType + readonly "tools": ReadonlyArray + readonly "status": BetaFunctionCallOutputStatusEnum + readonly "created_by"?: string +} +export const BetaToolSearchOutput = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." + }) + ), + "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.suspend((): Schema.Codec => BetaToolSearchExecutionType).annotate({ + "description": "Whether tool search was executed by the server or by the client." + }), + "tools": Schema.Array(BetaTool).annotate({ "description": "The loaded tool definitions returned by tool search." }), + "status": Schema.suspend((): Schema.Codec => BetaFunctionCallOutputStatusEnum) + .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." }) + ) +}).annotate({ "identifier": "BetaToolSearchOutput" }) +export type BetaAdditionalTools = { + readonly "agent"?: BetaAgentTag + readonly "type": "additional_tools" + readonly "id": string + readonly "role": BetaMessageRole + readonly "tools": ReadonlyArray +} +export const BetaAdditionalTools = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaAgentTag).annotate({ + "description": "The agent that produced this item." + }) + ), + "type": Schema.Literal("additional_tools").annotate({ + "description": "The type of the item. Always `additional_tools`." + }), + "id": Schema.String.annotate({ "description": "The unique ID of the additional tools item." }), + "role": Schema.suspend((): Schema.Codec => BetaMessageRole).annotate({ + "description": "The role that provided the additional tools." + }), + "tools": Schema.Array(BetaTool).annotate({ + "description": "The additional tool definitions made available at this item." + }) +}).annotate({ "identifier": "BetaAdditionalTools" }) +export type BetaInputItem = + | BetaEasyInputMessage + | { + readonly "agent"?: BetaAgentTag | null + readonly "type"?: "message" + readonly "role": "user" | "system" | "developer" + readonly "status"?: "in_progress" | "completed" | "incomplete" + readonly "content": BetaInputMessageContentList + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "id": string + readonly "type": "message" + readonly "role": "assistant" + readonly "content": ReadonlyArray + readonly "phase"?: BetaMessagePhase | null + readonly "status": "in_progress" | "completed" | "incomplete" + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "id": string + readonly "type": "file_search_call" + readonly "status": "in_progress" | "searching" | "completed" | "incomplete" | "failed" + readonly "queries": ReadonlyArray + readonly "results"?: + | ReadonlyArray< + { + readonly "file_id"?: string + readonly "text"?: string + readonly "filename"?: string + readonly "attributes"?: BetaVectorStoreFileAttributes + readonly "score"?: number + } + > + | null + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "computer_call" + readonly "id": string + readonly "call_id": string + readonly "action"?: BetaComputerAction + readonly "actions"?: BetaComputerActionList + readonly "pending_safety_checks": ReadonlyArray + readonly "status": "in_progress" | "completed" | "incomplete" + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "call_id": string + readonly "type": "computer_call_output" + readonly "output": BetaComputerScreenshotImage + readonly "acknowledged_safety_checks"?: ReadonlyArray | null + readonly "status"?: BetaFunctionCallItemStatus | null + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "id": string + readonly "type": "web_search_call" + readonly "status": "in_progress" | "searching" | "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 | null } + | { readonly "type": "find_in_page"; readonly "url": string; readonly "pattern": string } + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "id"?: string + readonly "type": "function_call" + readonly "call_id": string + readonly "caller"?: BetaToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "arguments": string + readonly "status"?: "in_progress" | "completed" | "incomplete" + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "call_id": string + readonly "type": "function_call_output" + readonly "output": + | string + | ReadonlyArray + readonly "name"?: string | null + readonly "namespace"?: string | null + readonly "caller"?: BetaToolCallCallerParam | null + readonly "status"?: BetaFunctionCallItemStatus | null + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "type": "agent_message" + readonly "author": string + readonly "recipient": string + readonly "content": ReadonlyArray< + BetaInputTextContentParam | BetaInputImageContentParamAutoParam | BetaEncryptedContentParam + > + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "call_id": string + readonly "type": "multi_agent_call" + readonly "action": BetaMultiAgentAction1 + readonly "arguments": string + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "call_id": string + readonly "type": "multi_agent_call_output" + readonly "action": BetaMultiAgentAction1 + readonly "output": ReadonlyArray + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "call_id"?: string | null + readonly "type": "tool_search_call" + readonly "execution"?: BetaToolSearchExecutionType + readonly "arguments": BetaEmptyModelParam + readonly "status"?: BetaFunctionCallItemStatus | null + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "call_id"?: string | null + readonly "type": "tool_search_output" + readonly "execution"?: BetaToolSearchExecutionType + readonly "tools": ReadonlyArray + readonly "status"?: BetaFunctionCallItemStatus | null + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "type": "additional_tools" + readonly "role": "developer" + readonly "tools": ReadonlyArray + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "reasoning" + readonly "id": string + readonly "encrypted_content"?: string | null + readonly "summary": ReadonlyArray + readonly "content"?: ReadonlyArray + readonly "status"?: "in_progress" | "completed" | "incomplete" + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "type": "compaction" + readonly "encrypted_content": string + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "image_generation_call" + readonly "id": string + readonly "status": "in_progress" | "completed" | "generating" | "failed" + readonly "result": string | null + } + | { + readonly "agent"?: BetaAgentTag | null + 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 + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "local_shell_call" + readonly "id": string + readonly "call_id": string + readonly "action": BetaLocalShellExecAction + readonly "status": "in_progress" | "completed" | "incomplete" + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "local_shell_call_output" + readonly "id": string + readonly "output": string + readonly "status"?: "in_progress" | "completed" | "incomplete" | null + readonly "call_id": Schema.Json + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "call_id": string + readonly "caller"?: BetaToolCallCallerParam | null + readonly "type": "shell_call" + readonly "action": BetaFunctionShellActionParam + readonly "status"?: BetaFunctionShellCallItemStatus | null + readonly "environment"?: BetaLocalEnvironmentParam | BetaContainerReferenceParam | null + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "id"?: string | null + readonly "call_id": string + readonly "caller"?: BetaToolCallCallerParam | null + readonly "type": "shell_call_output" + readonly "output": ReadonlyArray + readonly "status"?: BetaFunctionShellCallItemStatus | null + readonly "max_output_length"?: number | null + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "type": "apply_patch_call" + readonly "id"?: string | null + readonly "call_id": string + readonly "caller"?: BetaToolCallCallerParam | null + readonly "status": BetaApplyPatchCallStatusParam + readonly "operation": BetaApplyPatchOperationParam + } + | { + readonly "agent"?: Beta_AgentTagParam | null + readonly "type": "apply_patch_call_output" + readonly "id"?: string | null + readonly "call_id": string + readonly "caller"?: BetaToolCallCallerParam | null + readonly "status": BetaApplyPatchCallOutputStatusParam + readonly "output"?: string | null + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "mcp_list_tools" + readonly "id": string + readonly "server_label": string + readonly "tools": ReadonlyArray + readonly "error"?: string | null + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "mcp_approval_request" + readonly "id": string + readonly "server_label": string + readonly "name": string + readonly "arguments": string + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "mcp_approval_response" + readonly "id"?: string | null + readonly "approval_request_id": string + readonly "approve": boolean + readonly "reason"?: string | null + readonly "request_id": Schema.Json + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "mcp_call" + readonly "id": string + readonly "server_label": string + readonly "name": string + readonly "arguments": string + readonly "output"?: string | null + readonly "error"?: string | null + readonly "status"?: BetaMCPToolCallStatus + readonly "approval_request_id"?: string | null + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "custom_tool_call_output" + readonly "id"?: string + readonly "call_id": string + readonly "caller"?: BetaToolCallCallerParam | null + readonly "output": string | ReadonlyArray + } + | { + readonly "agent"?: BetaAgentTag | null + readonly "type": "custom_tool_call" + readonly "id"?: string + readonly "call_id": string + readonly "caller"?: BetaToolCallCaller | null + readonly "namespace"?: string + readonly "name": string + readonly "input": string + } + | BetaCompactionTriggerItemParam + | BetaItemReferenceParam + | BetaProgramItemParam + | BetaProgramOutputItemParam +export const BetaInputItem = Schema.Union([ + BetaEasyInputMessage, + Schema.Union([ + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.optionalKey( + Schema.Literal("message").annotate({ + "description": "The type of the message input. Always set to `message`.\n" + }) + ), + "role": Schema.Literals(["user", "system", "developer"]).annotate({ + "description": "The role of the message input. One of `user`, `system`, or `developer`.\n" + }), + "status": Schema.optionalKey( + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": + "The status of item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n" + }) + ), + "content": BetaInputMessageContentList + }).annotate({ "title": "Input message", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "id": Schema.String.annotate({ "description": "The unique ID of the output message.\n" }), + "type": Schema.Literal("message").annotate({ + "description": "The type of the output message. Always `message`.\n" + }), + "role": Schema.Literal("assistant").annotate({ + "description": "The role of the output message. Always `assistant`.\n" + }), + "content": Schema.Array(BetaOutputMessageContent).annotate({ + "description": "The content of the output message.\n" + }), + "phase": Schema.optionalKey(Schema.Union([BetaMessagePhase, 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": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "id": Schema.String.annotate({ "description": "The unique ID of the file search tool call.\n" }), + "type": Schema.Literal("file_search_call").annotate({ + "description": "The type of the file search tool call. Always `file_search_call`.\n" + }), + "status": Schema.Literals(["in_progress", "searching", "completed", "incomplete", "failed"]).annotate({ + "description": + "The status of the file search tool call. One of `in_progress`,\n`searching`, `incomplete` or `failed`,\n" + }), + "queries": Schema.Array(Schema.String).annotate({ "description": "The queries used to search for files.\n" }), + "results": Schema.optionalKey(Schema.Union([ + Schema.Array(Schema.Struct({ + "file_id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the file.\n" })), + "text": Schema.optionalKey( + Schema.String.annotate({ "description": "The text that was retrieved from the file.\n" }) + ), + "filename": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the file.\n" })), + "attributes": Schema.optionalKey(BetaVectorStoreFileAttributes), + "score": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The relevance score of the file - a value between 0 and 1.\n", + "format": "float" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) + })).annotate({ "description": "The results of the file search tool call.\n" }), + Schema.Null + ])) + }).annotate({ "title": "File search tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "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(BetaComputerAction), + "actions": Schema.optionalKey(BetaComputerActionList), + "pending_safety_checks": Schema.Array(BetaComputerCallSafetyCheckParam).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": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The ID of the computer tool call output." }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ "description": "The ID of the computer tool call that produced the output." }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "type": Schema.Literal("computer_call_output").annotate({ + "description": "The type of the computer tool call output. Always `computer_call_output`." + }), + "output": BetaComputerScreenshotImage, + "acknowledged_safety_checks": Schema.optionalKey( + Schema.Union([ + Schema.Array(BetaComputerCallSafetyCheckParam).annotate({ + "description": "The safety checks reported by the API that have been acknowledged by the developer." + }), + Schema.Null + ]) + ), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaFunctionCallItemStatus).annotate({ + "description": + "The status of the message input. One of `in_progress`, `completed`, or `incomplete`. Populated when input items are returned via API." + }), + Schema.Null + ]) + ) + }).annotate({ "title": "Computer tool call output", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "id": Schema.String.annotate({ "description": "The unique ID of the web search tool call.\n" }), + "type": Schema.Literal("web_search_call").annotate({ + "description": "The type of the web search tool call. Always `web_search_call`.\n" + }), + "status": Schema.Literals(["in_progress", "searching", "completed", "failed"]).annotate({ + "description": "The status of the web search tool call.\n" + }), + "action": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("search").annotate({ "description": "The action type.\n" }), + "query": Schema.optionalKey(Schema.String.annotate({ "description": "The search query.\n" })), + "queries": Schema.optionalKey( + Schema.Array(Schema.String.annotate({ "description": "A search query.\n" })).annotate({ + "title": "Search queries", + "description": "The search queries.\n" + }) + ), + "sources": Schema.optionalKey( + Schema.Array( + Schema.Struct({ + "type": Schema.Literal("url").annotate({ "description": "The type of source. Always `url`.\n" }), + "url": Schema.String.annotate({ "description": "The URL of the source.\n", "format": "uri" }) + }).annotate({ "title": "Web search source", "description": "A source used in the search.\n" }) + ).annotate({ "title": "Web search sources", "description": "The sources used in the search.\n" }) + ) + }).annotate({ + "title": "Search action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }), + Schema.Struct({ + "type": Schema.Literal("open_page").annotate({ "description": "The action type.\n" }), + "url": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "format": "uri" }), Schema.Null]).annotate({ + "description": "The URL opened by the model.\n" + }) + ) + }).annotate({ + "title": "Open page action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }), + Schema.Struct({ + "type": Schema.Literal("find_in_page").annotate({ "description": "The action type.\n" }), + "url": Schema.String.annotate({ + "description": "The URL of the page searched for the pattern.\n", + "format": "uri" + }), + "pattern": Schema.String.annotate({ "description": "The pattern or text to search for within the page.\n" }) + }).annotate({ + "title": "Find action", + "description": + "An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n" + }) + ], { mode: "oneOf" }) + }).annotate({ "title": "Web search tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "id": Schema.optionalKey(Schema.String.annotate({ "description": "The unique ID of the function tool call.\n" })), + "type": Schema.Literal("function_call").annotate({ + "description": "The type of the function tool call. Always `function_call`.\n" + }), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model.\n" + }), + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCaller, Schema.Null])), + "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( + 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": "Function tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The unique ID of the function tool call output. Populated when this item is returned via API." + }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the function tool call generated by the model." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "type": Schema.Literal("function_call_output").annotate({ + "description": "The type of the function tool call output. Always `function_call_output`." + }), + "output": Schema.Union([ + Schema.String.annotate({ "description": "A JSON string of the output of the function tool call." }).check( + Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" }) + ), + Schema.Array( + Schema.Union([BetaInputTextContentParam, BetaInputImageContentParamAutoParam, BetaInputFileContentParam], { + mode: "oneOf" + }).annotate({ "description": "A piece of message content, such as text, an image, or a file." }) + ).annotate({ "description": "An array of content outputs (text, image, file) for the function tool call." }) + ], { mode: "oneOf" }).annotate({ "description": "Text, image, or file output of the function tool call." }), + "name": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The name of the tool that produced the output." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(128).annotate({ "expected": "a value with a length of at most 128" })), + Schema.Null + ]) + ), + "namespace": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The namespace of the tool that produced the output." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_-]+$" + }) + ), + Schema.Null + ]) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaFunctionCallItemStatus).annotate({ + "description": + "The status of the item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API." + }), + Schema.Null + ]) + ) + }).annotate({ "title": "Function tool call output", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of this agent message item." }), + Schema.Null + ]) + ), + "type": Schema.Literal("agent_message").annotate({ "description": "The item type. Always `agent_message`." }), + "author": Schema.String.annotate({ "description": "The sending agent identity." }), + "recipient": Schema.String.annotate({ "description": "The destination agent identity." }), + "content": Schema.Array( + Schema.Union([BetaInputTextContentParam, BetaInputImageContentParamAutoParam, BetaEncryptedContentParam], { + mode: "oneOf" + }).annotate({ "description": "A plaintext, image, or encrypted agent message content part." }) + ).annotate({ "description": "Plaintext, image, or encrypted content sent between agents." }) + }).annotate({ "title": "Agent message", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of this multi-agent call." }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ "description": "The unique ID linking this call to its output." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "type": Schema.Literal("multi_agent_call").annotate({ + "description": "The item type. Always `multi_agent_call`." + }), + "action": Schema.suspend((): Schema.Codec => BetaMultiAgentAction1).annotate({ + "description": "The multi-agent action that was executed." + }), + "arguments": Schema.String.annotate({ "description": "The action arguments as a JSON string." }) + }).annotate({ "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of this multi-agent call output." }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ "description": "The unique ID of the multi-agent call." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "type": Schema.Literal("multi_agent_call_output").annotate({ + "description": "The item type. Always `multi_agent_call_output`." + }), + "action": Schema.suspend((): Schema.Codec => BetaMultiAgentAction1).annotate({ + "description": "The multi-agent action that produced this result." + }), + "output": Schema.Array(BetaOutputTextContentParam).annotate({ + "description": "Text output returned by the multi-agent action." + }) + }).annotate({ "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "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).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + Schema.Null + ]) + ), + "type": Schema.Literal("tool_search_call").annotate({ + "description": "The item type. Always `tool_search_call`." + }), + "execution": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaToolSearchExecutionType).annotate({ + "description": "Whether tool search was executed by the server or by the client." + }) + ), + "arguments": Schema.suspend((): Schema.Codec => BetaEmptyModelParam).annotate({ + "description": "The arguments supplied to the tool search call." + }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaFunctionCallItemStatus).annotate({ + "description": "The status of the tool search call." + }), + Schema.Null + ]) + ) + }).annotate({ "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "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).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + Schema.Null + ]) + ), + "type": Schema.Literal("tool_search_output").annotate({ + "description": "The item type. Always `tool_search_output`." + }), + "execution": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaToolSearchExecutionType).annotate({ + "description": "Whether tool search was executed by the server or by the client." + }) + ), + "tools": Schema.Array(BetaTool).annotate({ + "description": "The loaded tool definitions returned by the tool search output." + }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaFunctionCallItemStatus).annotate({ + "description": "The status of the tool search output." + }), + Schema.Null + ]) + ) + }).annotate({ "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of this additional tools item." }), + Schema.Null + ]) + ), + "type": Schema.Literal("additional_tools").annotate({ + "description": "The item type. Always `additional_tools`." + }), + "role": Schema.Literal("developer").annotate({ + "description": "The role that provided the additional tools. Only `developer` is supported." + }), + "tools": Schema.Array(BetaTool).annotate({ + "description": "A list of additional tools made available at this item." + }) + }).annotate({ "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("reasoning").annotate({ "description": "The type of the object. Always `reasoning`.\n" }), + "id": Schema.String.annotate({ "description": "The unique identifier of the reasoning content.\n" }), + "encrypted_content": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The encrypted content of the reasoning item. This is populated by default\nfor reasoning items returned by `POST /v1/responses` and WebSocket\n`response.create` requests.\n" + }), + Schema.Null + ]) + ), + "summary": Schema.Array(BetaSummaryTextContent).annotate({ "description": "Reasoning summary content.\n" }), + "content": Schema.optionalKey( + Schema.Array(BetaReasoningTextContent).annotate({ "description": "Reasoning text content.\n" }) + ), + "status": Schema.optionalKey( + 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": "Reasoning", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "id": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The ID of the compaction item." }), Schema.Null]) + ), + "type": Schema.Literal("compaction").annotate({ "description": "The type of the item. Always `compaction`." }), + "encrypted_content": Schema.String.annotate({ "description": "The encrypted content of the compaction summary." }) + .check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })) + }).annotate({ "title": "Compaction item", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("image_generation_call").annotate({ + "description": "The type of the image generation call. Always `image_generation_call`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the image generation call.\n" }), + "status": Schema.Literals(["in_progress", "completed", "generating", "failed"]).annotate({ + "description": "The status of the image generation call.\n" + }), + "result": Schema.Union([ + Schema.String.annotate({ "description": "The generated image encoded in base64.\n" }), + Schema.Null + ]) + }).annotate({ "title": "Image generation call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "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([BetaCodeInterpreterOutputLogs, BetaCodeInterpreterOutputImage], { 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": "Content item used to generate a response.\n" + }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "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": BetaLocalShellExecAction, + "status": Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the local shell call.\n" + }) + }).annotate({ "title": "Local shell call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("local_shell_call_output").annotate({ + "description": "The type of the local shell tool call output. Always `local_shell_call_output`.\n" + }), + "id": Schema.String.annotate({ + "description": "The unique ID of the local shell tool call generated by the model.\n" + }), + "output": Schema.String.annotate({ + "description": "A JSON string of the output of the local shell tool call.\n" + }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "The status of the item. One of `in_progress`, `completed`, or `incomplete`.\n" + }), + Schema.Null + ]) + ), + "call_id": Schema.Json.annotate({ "expected": "JSON value" }) + }).annotate({ "title": "Local shell call output", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "The unique ID of the shell tool call. Populated when this item is returned via API." + }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the shell tool call generated by the model." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "type": Schema.Literal("shell_call").annotate({ "description": "The type of the item. Always `shell_call`." }), + "action": Schema.suspend((): Schema.Codec => BetaFunctionShellActionParam).annotate( + { "description": "The shell commands and limits that describe how to run the tool call." } + ), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaFunctionShellCallItemStatus).annotate( + { "description": "The status of the shell call. One of `in_progress`, `completed`, or `incomplete`." } + ), + Schema.Null + ]) + ), + "environment": Schema.optionalKey( + Schema.Union([ + Schema.Union([BetaLocalEnvironmentParam, BetaContainerReferenceParam], { mode: "oneOf" }).annotate({ + "description": "The environment to execute the shell commands in." + }), + Schema.Null + ]) + ) + }).annotate({ "title": "Shell tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "The unique ID of the shell tool call output. Populated when this item is returned via API." + }), + Schema.Null + ]) + ), + "call_id": Schema.String.annotate({ + "description": "The unique ID of the shell tool call generated by the model." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "type": Schema.Literal("shell_call_output").annotate({ + "description": "The type of the item. Always `shell_call_output`." + }), + "output": Schema.Array(BetaFunctionShellCallOutputContentParam).annotate({ + "description": "Captured chunks of stdout and stderr output, along with their associated outcomes." + }), + "status": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaFunctionShellCallItemStatus).annotate( + { "description": "The status of the shell call output." } + ), + Schema.Null + ]) + ), + "max_output_length": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The maximum number of UTF-8 characters captured for this shell call's combined output." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ) + }).annotate({ "title": "Shell tool call output", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "type": Schema.Literal("apply_patch_call").annotate({ + "description": "The type of the item. Always `apply_patch_call`." + }), + "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).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "status": Schema.suspend((): Schema.Codec => BetaApplyPatchCallStatusParam) + .annotate({ "description": "The status of the apply patch tool call. One of `in_progress` or `completed`." }), + "operation": Schema.suspend((): Schema.Codec => BetaApplyPatchOperationParam) + .annotate({ + "description": "The specific create, delete, or update instruction for the apply_patch tool call." + }) + }).annotate({ "title": "Apply patch tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Beta_AgentTagParam).annotate({ + "description": "The agent that produced this item." + }), + Schema.Null + ]) + ), + "type": Schema.Literal("apply_patch_call_output").annotate({ + "description": "The type of the item. Always `apply_patch_call_output`." + }), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "The unique ID of the apply patch tool call output. 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).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + "caller": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaToolCallCallerParam).annotate({ + "description": "The execution context that produced this tool call." + }), + Schema.Null + ]) + ), + "status": Schema.suspend((): Schema.Codec => + BetaApplyPatchCallOutputStatusParam + ).annotate({ "description": "The status of the apply patch tool call output. One of `completed` or `failed`." }), + "output": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": "Optional human-readable log text from the apply patch tool (e.g., patch results or errors)." + }).check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })), + Schema.Null + ]) + ) + }).annotate({ + "title": "Apply patch tool call output", + "description": "Content item used to generate a response.\n" + }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("mcp_list_tools").annotate({ + "description": "The type of the item. Always `mcp_list_tools`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the list.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server.\n" }), + "tools": Schema.Array(BetaMCPListToolsTool).annotate({ "description": "The tools available on the server.\n" }), + "error": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "Error message if the server could not list tools.\n" }), + Schema.Null + ]) + ) + }).annotate({ "title": "MCP list tools", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("mcp_approval_request").annotate({ + "description": "The type of the item. Always `mcp_approval_request`.\n" + }), + "id": Schema.String.annotate({ "description": "The unique ID of the approval request.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server making the request.\n" }), + "name": Schema.String.annotate({ "description": "The name of the tool to run.\n" }), + "arguments": Schema.String.annotate({ "description": "A JSON string of arguments for the tool.\n" }) + }).annotate({ "title": "MCP approval request", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("mcp_approval_response").annotate({ + "description": "The type of the item. Always `mcp_approval_response`.\n" + }), + "id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The unique ID of the approval response\n" }), + Schema.Null + ]) + ), + "approval_request_id": Schema.String.annotate({ + "description": "The ID of the approval request being answered.\n" + }), + "approve": Schema.Boolean.annotate({ "description": "Whether the request was approved.\n" }), + "reason": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "Optional reason for the decision.\n" }), Schema.Null]) + ), + "request_id": Schema.Json.annotate({ "expected": "JSON value" }) + }).annotate({ "title": "MCP approval response", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("mcp_call").annotate({ "description": "The type of the item. Always `mcp_call`.\n" }), + "id": Schema.String.annotate({ "description": "The unique ID of the tool call.\n" }), + "server_label": Schema.String.annotate({ "description": "The label of the MCP server running the tool.\n" }), + "name": Schema.String.annotate({ "description": "The name of the tool that was run.\n" }), + "arguments": Schema.String.annotate({ "description": "A JSON string of the arguments passed to the tool.\n" }), + "output": Schema.optionalKey( + Schema.Union([Schema.String.annotate({ "description": "The output from the tool call.\n" }), Schema.Null]) + ), + "error": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ "description": "The error from the tool call, if any.\n" }), + Schema.Null + ]) + ), + "status": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaMCPToolCallStatus).annotate({ + "description": + "The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`, or `failed`.\n" + }) + ), + "approval_request_id": Schema.optionalKey( + Schema.Union([ + Schema.String.annotate({ + "description": + "Unique identifier for the MCP tool call approval request.\nInclude this value in a subsequent `mcp_approval_response` input to approve or reject the corresponding tool call.\n" + }), + Schema.Null + ]) + ) + }).annotate({ "title": "MCP tool call", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("custom_tool_call_output").annotate({ + "description": "The type of the custom tool call output. Always `custom_tool_call_output`.\n" + }), + "id": Schema.optionalKey( + Schema.String.annotate({ + "description": "The unique ID of the custom tool call output in the OpenAI platform.\n" + }) + ), + "call_id": Schema.String.annotate({ + "description": "The call ID, used to map this custom tool call output to a custom tool call.\n" + }), + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCallerParam, Schema.Null])), + "output": Schema.Union([ + Schema.String.annotate({ + "title": "string output", + "description": "A string of the output of the custom tool call.\n" + }), + Schema.Array(BetaFunctionAndCustomToolCallOutput).annotate({ + "title": "output content list", + "description": "Text, image, or file output of the custom tool call.\n" + }) + ], { mode: "oneOf" }).annotate({ + "description": + "The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n" + }) + }).annotate({ "title": "Custom tool call output", "description": "Content item used to generate a response.\n" }), + Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ "description": "The agent that produced this item." }) + ), + "type": Schema.Literal("custom_tool_call").annotate({ + "description": "The type of the custom tool call. Always `custom_tool_call`.\n" + }), + "id": Schema.optionalKey( + Schema.String.annotate({ "description": "The unique ID of the custom tool call in the OpenAI platform.\n" }) + ), + "call_id": Schema.String.annotate({ + "description": "An identifier used to map this custom tool call to a tool call output.\n" + }), + "caller": Schema.optionalKey(Schema.Union([BetaToolCallCaller, Schema.Null])), + "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": "Content item used to generate a response.\n" }) + ], { mode: "oneOf" }).annotate({ + "title": "Item", + "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" + }), + BetaCompactionTriggerItemParam, + BetaItemReferenceParam, + BetaProgramItemParam, + BetaProgramOutputItemParam +], { mode: "oneOf" }).annotate({ "identifier": "BetaInputItem" }) +export type EvalGraderLabelModel = { + readonly "type": "label_model" + readonly "name": string + readonly "model": string + readonly "input": ReadonlyArray + readonly "labels": ReadonlyArray + readonly "passing_labels": ReadonlyArray +} +export const EvalGraderLabelModel = Schema.Struct({ + "type": Schema.Literal("label_model").annotate({ "description": "The object type, which is always `label_model`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "model": Schema.String.annotate({ + "description": "The model to use for the evaluation. Must support structured outputs." + }), + "input": Schema.Array(EvalItem), + "labels": Schema.Array(Schema.String).annotate({ + "description": "The labels to assign to each item in the evaluation." + }), + "passing_labels": Schema.Array(Schema.String).annotate({ + "description": "The labels that indicate a passing result. Must be a subset of labels." + }) +}).annotate({ + "title": "LabelModelGrader", + "description": "A LabelModelGrader object which uses a model to assign labels to each item\nin the evaluation.\n", + "identifier": "EvalGraderLabelModel" +}) +export type EvalGraderScoreModel = { + readonly "type": "score_model" + readonly "name": string + readonly "model": string + readonly "sampling_params"?: { + readonly "seed"?: number | null + readonly "top_p"?: number | null + readonly "temperature"?: number | null + readonly "max_completions_tokens"?: number | null + readonly "reasoning_effort"?: ReasoningEffort + } + readonly "input": ReadonlyArray + readonly "range"?: ReadonlyArray + readonly "pass_threshold"?: number +} +export const EvalGraderScoreModel = Schema.Struct({ + "type": Schema.Literal("score_model").annotate({ "description": "The object type, which is always `score_model`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), + "sampling_params": Schema.optionalKey( + Schema.Struct({ + "seed": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "max_completions_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The maximum number of tokens the grader model may generate in its response.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]) + ), + "reasoning_effort": Schema.optionalKey(ReasoningEffort) + }).annotate({ "description": "The sampling parameters for the model." }) + ), + "input": Schema.Array(EvalItem).annotate({ + "description": + "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" + }), + "range": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))).annotate({ + "description": "The range of the score. Defaults to `[0, 1]`." + }) + ), + "pass_threshold": Schema.optionalKey( + Schema.Number.annotate({ "description": "The threshold for the score." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ) +}).annotate({ + "title": "ScoreModelGrader", + "description": "A ScoreModelGrader object that uses a model to assign a score to the input.\n", + "identifier": "EvalGraderScoreModel" +}) +export type EvalRun = { + readonly "object": "eval.run" + readonly "id": string + readonly "eval_id": string + readonly "status": string + readonly "model": string + readonly "name": string + readonly "created_at": number + readonly "report_url": string + readonly "result_counts": { + readonly "total": number + readonly "errored": number + readonly "failed": number + readonly "passed": number + } + readonly "per_model_usage": ReadonlyArray< + { + readonly "model_name": string + readonly "invocation_count": number + readonly "prompt_tokens": number + readonly "completion_tokens": number + readonly "total_tokens": number + readonly "cached_tokens": number + } + > + readonly "per_testing_criteria_results": ReadonlyArray< + { readonly "testing_criteria": string; readonly "passed": number; readonly "failed": number } + > + readonly "data_source": { + readonly "type": "jsonl" + readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource + } | { + readonly "type": "completions" + readonly "input_messages"?: { + readonly "type": "template" + readonly "template": ReadonlyArray + } | { readonly "type": "item_reference"; readonly "item_reference": string } + readonly "sampling_params"?: { + readonly "reasoning_effort"?: ReasoningEffort + readonly "temperature"?: number + readonly "max_completion_tokens"?: number + readonly "top_p"?: number + readonly "seed"?: number + readonly "response_format"?: ResponseFormatText | ResponseFormatJsonSchema | ResponseFormatJsonObject + readonly "tools"?: ReadonlyArray + } + readonly "model"?: string + readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource | EvalStoredCompletionsSource + } | { + readonly "type": "responses" + readonly "input_messages"?: { + readonly "type": "template" + readonly "template": ReadonlyArray<{ readonly "role": string; readonly "content": string } | EvalItem> + } | { readonly "type": "item_reference"; readonly "item_reference": string } + readonly "sampling_params"?: { + readonly "reasoning_effort"?: ReasoningEffort + readonly "temperature"?: number + readonly "max_completion_tokens"?: number + readonly "top_p"?: number + readonly "seed"?: number + readonly "tools"?: ReadonlyArray + readonly "text"?: { readonly "format"?: TextResponseFormatConfiguration } + } + readonly "model"?: string + readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource | EvalResponsesSource + } + readonly "metadata": Metadata + readonly "error": EvalApiError +} +export const EvalRun = Schema.Struct({ + "object": Schema.Literal("eval.run").annotate({ "description": "The type of the object. Always \"eval.run\"." }), + "id": Schema.String.annotate({ "description": "Unique identifier for the evaluation run." }), + "eval_id": Schema.String.annotate({ "description": "The identifier of the associated evaluation." }), + "status": Schema.String.annotate({ "description": "The status of the evaluation run." }), + "model": Schema.String.annotate({ "description": "The model that is evaluated, if applicable." }), + "name": Schema.String.annotate({ "description": "The name of the evaluation run." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the evaluation run was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "report_url": Schema.String.annotate({ + "description": "The URL to the rendered evaluation run report on the UI dashboard.", + "format": "uri" + }), + "result_counts": Schema.Struct({ + "total": Schema.Number.annotate({ "description": "Total number of executed output items." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "errored": Schema.Number.annotate({ "description": "Number of output items that resulted in an error." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "failed": Schema.Number.annotate({ "description": "Number of output items that failed to pass the evaluation." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "passed": Schema.Number.annotate({ "description": "Number of output items that passed the evaluation." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).annotate({ "description": "Counters summarizing the outcomes of the evaluation run." }), + "per_model_usage": Schema.Array(Schema.Struct({ + "model_name": Schema.String.annotate({ "description": "The name of the model." }), + "invocation_count": Schema.Number.annotate({ "description": "The number of invocations." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "prompt_tokens": Schema.Number.annotate({ "description": "The number of prompt tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "completion_tokens": Schema.Number.annotate({ "description": "The number of completion tokens generated." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "total_tokens": Schema.Number.annotate({ "description": "The total number of tokens used." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "cached_tokens": Schema.Number.annotate({ "description": "The number of tokens retrieved from cache." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + })).annotate({ "description": "Usage statistics for each model during the evaluation run." }), + "per_testing_criteria_results": Schema.Array(Schema.Struct({ + "testing_criteria": Schema.String.annotate({ "description": "A description of the testing criteria." }), + "passed": Schema.Number.annotate({ "description": "Number of tests passed for this criteria." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "failed": Schema.Number.annotate({ "description": "Number of tests failed for this criteria." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + })).annotate({ "description": "Results per testing criteria applied during the evaluation run." }), + "data_source": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("jsonl").annotate({ "description": "The type of data source. Always `jsonl`." }), + "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource], { mode: "oneOf" }).annotate({ + "description": "Determines what populates the `item` namespace in the data source." + }) + }).annotate({ "title": "JsonlRunDataSource", "description": "Information about the run's data source." }), + Schema.Struct({ + "type": Schema.Literal("completions").annotate({ + "description": "The type of run data source. Always `completions`." + }), + "input_messages": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("template").annotate({ + "description": "The type of input messages. Always `template`." + }), + "template": Schema.Array(Schema.Union([EasyInputMessage, EvalItem], { mode: "oneOf" })).annotate({ + "description": + "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." + }) + }).annotate({ "title": "TemplateInputMessages" }), + Schema.Struct({ + "type": Schema.Literal("item_reference").annotate({ + "description": "The type of input messages. Always `item_reference`." + }), + "item_reference": Schema.String.annotate({ + "description": "A reference to a variable in the `item` namespace. Ie, \"item.input_trajectory\"" + }) + }).annotate({ "title": "ItemReferenceInputMessages" }) + ], { mode: "oneOf" }).annotate({ + "description": + "Used when sampling from a model. Dictates the structure of the messages passed into the model. Can either be a reference to a prebuilt trajectory (ie, `item.input_trajectory`), or a template with variable references to the `item` namespace." + }) + ), + "sampling_params": Schema.optionalKey(Schema.Struct({ + "reasoning_effort": Schema.optionalKey(ReasoningEffort), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "max_completion_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum number of tokens in the generated output." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "top_p": Schema.optionalKey( + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "seed": Schema.optionalKey( + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "response_format": Schema.optionalKey( + Schema.Union([ResponseFormatText, ResponseFormatJsonSchema, ResponseFormatJsonObject], { mode: "oneOf" }) + .annotate({ + "description": + "An object specifying the format that the model must output.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables\nStructured Outputs which ensures the model will match your supplied JSON\nschema. Learn more in the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n" + }) + ), + "tools": Schema.optionalKey( + Schema.Array(ChatCompletionTool).annotate({ + "description": + "A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.\n" + }) + ) + })), + "model": Schema.optionalKey( + Schema.String.annotate({ + "description": "The name of the model to use for generating completions (e.g. \"o3-mini\")." + }) + ), + "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource, EvalStoredCompletionsSource], { + mode: "oneOf" + }).annotate({ "description": "Determines what populates the `item` namespace in this run's data source." }) + }).annotate({ "title": "CompletionsRunDataSource", "description": "Information about the run's data source." }), + Schema.Struct({ + "type": Schema.Literal("responses").annotate({ + "description": "The type of run data source. Always `responses`." + }), + "input_messages": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("template").annotate({ + "description": "The type of input messages. Always `template`." + }), + "template": Schema.Array( + Schema.Union([ + Schema.Struct({ + "role": Schema.String.annotate({ + "description": "The role of the message (e.g. \"system\", \"assistant\", \"user\")." + }), + "content": Schema.String.annotate({ "description": "The content of the message." }) + }).annotate({ "title": "ChatMessage" }), + EvalItem + ], { mode: "oneOf" }) + ).annotate({ + "description": + "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." + }) + }).annotate({ "title": "InputMessagesTemplate" }), + Schema.Struct({ + "type": Schema.Literal("item_reference").annotate({ + "description": "The type of input messages. Always `item_reference`." + }), + "item_reference": Schema.String.annotate({ + "description": "A reference to a variable in the `item` namespace. Ie, \"item.name\"" + }) + }).annotate({ "title": "InputMessagesItemReference" }) + ], { mode: "oneOf" }).annotate({ + "description": + "Used when sampling from a model. Dictates the structure of the messages passed into the model. Can either be a reference to a prebuilt trajectory (ie, `item.input_trajectory`), or a template with variable references to the `item` namespace." + }) + ), + "sampling_params": Schema.optionalKey(Schema.Struct({ + "reasoning_effort": Schema.optionalKey(ReasoningEffort), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "max_completion_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum number of tokens in the generated output." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "top_p": Schema.optionalKey( + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "seed": Schema.optionalKey( + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "tools": Schema.optionalKey( + 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\nThe two categories of tools you can provide the model are:\n\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- **Function calls (custom tools)**: Functions that are defined by you,\n enabling the model to call your own code. Learn more about\n [function calling](/docs/guides/function-calling).\n" + }) + ), + "text": Schema.optionalKey( + Schema.Struct({ "format": Schema.optionalKey(TextResponseFormatConfiguration) }).annotate({ + "description": + "Configuration options for a text response from the model. Can be plain\ntext or structured JSON data. Learn more:\n- [Text inputs and outputs](/docs/guides/text)\n- [Structured Outputs](/docs/guides/structured-outputs)\n" + }) + ) + })), + "model": Schema.optionalKey( + Schema.String.annotate({ + "description": "The name of the model to use for generating completions (e.g. \"o3-mini\")." + }) + ), + "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource, EvalResponsesSource], { + mode: "oneOf" + }).annotate({ "description": "Determines what populates the `item` namespace in this run's data source." }) + }).annotate({ "title": "ResponsesRunDataSource", "description": "Information about the run's data source." }) + ], { mode: "oneOf" }), + "metadata": Metadata, + "error": EvalApiError +}).annotate({ + "title": "EvalRun", + "description": "A schema representing an evaluation run.\n", + "identifier": "EvalRun" +}) +export type CreateEvalRunRequest = { + readonly "name"?: string + readonly "metadata"?: Metadata + readonly "data_source": { + readonly "type": "jsonl" + readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource + } | { + readonly "type": "completions" + readonly "input_messages"?: { + readonly "type": "template" + readonly "template": ReadonlyArray + } | { readonly "type": "item_reference"; readonly "item_reference": string } + readonly "sampling_params"?: { + readonly "reasoning_effort"?: ReasoningEffort + readonly "temperature"?: number + readonly "max_completion_tokens"?: number + readonly "top_p"?: number + readonly "seed"?: number + readonly "response_format"?: ResponseFormatText | ResponseFormatJsonSchema | ResponseFormatJsonObject + readonly "tools"?: ReadonlyArray + } + readonly "model"?: string + readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource | EvalStoredCompletionsSource + } | { + readonly "type": "responses" + readonly "input_messages"?: { + readonly "type": "template" + readonly "template": ReadonlyArray<{ readonly "role": string; readonly "content": string } | EvalItem> + } | { readonly "type": "item_reference"; readonly "item_reference": string } + readonly "sampling_params"?: { + readonly "reasoning_effort"?: ReasoningEffort + readonly "temperature"?: number + readonly "max_completion_tokens"?: number + readonly "top_p"?: number + readonly "seed"?: number + readonly "tools"?: ReadonlyArray + readonly "text"?: { readonly "format"?: TextResponseFormatConfiguration } + } + readonly "model"?: string + readonly "source": EvalJsonlFileContentSource | EvalJsonlFileIdSource | EvalResponsesSource + } +} +export const CreateEvalRunRequest = Schema.Struct({ + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the run." })), + "metadata": Schema.optionalKey(Metadata), + "data_source": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("jsonl").annotate({ "description": "The type of data source. Always `jsonl`." }), + "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource], { mode: "oneOf" }).annotate({ + "description": "Determines what populates the `item` namespace in the data source." + }) + }).annotate({ "title": "JsonlRunDataSource", "description": "Details about the run's data source." }), + Schema.Struct({ + "type": Schema.Literal("completions").annotate({ + "description": "The type of run data source. Always `completions`." + }), + "input_messages": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("template").annotate({ + "description": "The type of input messages. Always `template`." + }), + "template": Schema.Array(Schema.Union([EasyInputMessage, EvalItem], { mode: "oneOf" })).annotate({ + "description": + "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." + }) + }).annotate({ "title": "TemplateInputMessages" }), + Schema.Struct({ + "type": Schema.Literal("item_reference").annotate({ + "description": "The type of input messages. Always `item_reference`." + }), + "item_reference": Schema.String.annotate({ + "description": "A reference to a variable in the `item` namespace. Ie, \"item.input_trajectory\"" + }) + }).annotate({ "title": "ItemReferenceInputMessages" }) + ], { mode: "oneOf" }).annotate({ + "description": + "Used when sampling from a model. Dictates the structure of the messages passed into the model. Can either be a reference to a prebuilt trajectory (ie, `item.input_trajectory`), or a template with variable references to the `item` namespace." + }) + ), + "sampling_params": Schema.optionalKey(Schema.Struct({ + "reasoning_effort": Schema.optionalKey(ReasoningEffort), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "max_completion_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum number of tokens in the generated output." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "top_p": Schema.optionalKey( + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "seed": Schema.optionalKey( + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "response_format": Schema.optionalKey( + Schema.Union([ResponseFormatText, ResponseFormatJsonSchema, ResponseFormatJsonObject], { mode: "oneOf" }) + .annotate({ + "description": + "An object specifying the format that the model must output.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables\nStructured Outputs which ensures the model will match your supplied JSON\nschema. Learn more in the [Structured Outputs\nguide](/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n" + }) + ), + "tools": Schema.optionalKey( + Schema.Array(ChatCompletionTool).annotate({ + "description": + "A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.\n" + }) + ) + })), + "model": Schema.optionalKey( + Schema.String.annotate({ + "description": "The name of the model to use for generating completions (e.g. \"o3-mini\")." + }) + ), + "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource, EvalStoredCompletionsSource], { + mode: "oneOf" + }).annotate({ "description": "Determines what populates the `item` namespace in this run's data source." }) + }).annotate({ "title": "CompletionsRunDataSource", "description": "Details about the run's data source." }), + Schema.Struct({ + "type": Schema.Literal("responses").annotate({ + "description": "The type of run data source. Always `responses`." + }), + "input_messages": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("template").annotate({ + "description": "The type of input messages. Always `template`." + }), + "template": Schema.Array( + Schema.Union([ + Schema.Struct({ + "role": Schema.String.annotate({ + "description": "The role of the message (e.g. \"system\", \"assistant\", \"user\")." + }), + "content": Schema.String.annotate({ "description": "The content of the message." }) + }).annotate({ "title": "ChatMessage" }), + EvalItem + ], { mode: "oneOf" }) + ).annotate({ + "description": + "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." + }) + }).annotate({ "title": "InputMessagesTemplate" }), + Schema.Struct({ + "type": Schema.Literal("item_reference").annotate({ + "description": "The type of input messages. Always `item_reference`." + }), + "item_reference": Schema.String.annotate({ + "description": "A reference to a variable in the `item` namespace. Ie, \"item.name\"" + }) + }).annotate({ "title": "InputMessagesItemReference" }) + ], { mode: "oneOf" }).annotate({ + "description": + "Used when sampling from a model. Dictates the structure of the messages passed into the model. Can either be a reference to a prebuilt trajectory (ie, `item.input_trajectory`), or a template with variable references to the `item` namespace." + }) + ), + "sampling_params": Schema.optionalKey(Schema.Struct({ + "reasoning_effort": Schema.optionalKey(ReasoningEffort), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs." }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "max_completion_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "The maximum number of tokens in the generated output." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "top_p": Schema.optionalKey( + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens." + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "seed": Schema.optionalKey( + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "tools": Schema.optionalKey( + 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\nThe two categories of tools you can provide the model are:\n\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- **Function calls (custom tools)**: Functions that are defined by you,\n enabling the model to call your own code. Learn more about\n [function calling](/docs/guides/function-calling).\n" + }) + ), + "text": Schema.optionalKey( + Schema.Struct({ "format": Schema.optionalKey(TextResponseFormatConfiguration) }).annotate({ + "description": + "Configuration options for a text response from the model. Can be plain\ntext or structured JSON data. Learn more:\n- [Text inputs and outputs](/docs/guides/text)\n- [Structured Outputs](/docs/guides/structured-outputs)\n" + }) + ) + })), + "model": Schema.optionalKey( + Schema.String.annotate({ + "description": "The name of the model to use for generating completions (e.g. \"o3-mini\")." + }) + ), + "source": Schema.Union([EvalJsonlFileContentSource, EvalJsonlFileIdSource, EvalResponsesSource], { + mode: "oneOf" + }).annotate({ "description": "Determines what populates the `item` namespace in this run's data source." }) + }).annotate({ "title": "ResponsesRunDataSource", "description": "Details about the run's data source." }) + ], { mode: "oneOf" }) +}).annotate({ "title": "CreateEvalRunRequest", "identifier": "CreateEvalRunRequest" }) +export type GraderScoreModel = { + readonly "type": "score_model" + readonly "name": string + readonly "model": string + readonly "sampling_params"?: { + readonly "seed"?: number | null + readonly "top_p"?: number | null + readonly "temperature"?: number | null + readonly "max_completions_tokens"?: number | null + readonly "reasoning_effort"?: ReasoningEffort + } + readonly "input": ReadonlyArray + readonly "range"?: ReadonlyArray +} +export const GraderScoreModel = Schema.Struct({ + "type": Schema.Literal("score_model").annotate({ "description": "The object type, which is always `score_model`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), + "sampling_params": Schema.optionalKey( + Schema.Struct({ + "seed": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "max_completions_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The maximum number of tokens the grader model may generate in its response.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]) + ), + "reasoning_effort": Schema.optionalKey(ReasoningEffort) + }).annotate({ "description": "The sampling parameters for the model." }) + ), + "input": Schema.Array(EvalItem).annotate({ + "description": + "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" + }), + "range": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))).annotate({ + "description": "The range of the score. Defaults to `[0, 1]`." + }) + ) +}).annotate({ + "title": "ScoreModelGrader", + "description": "A ScoreModelGrader object that uses a model to assign a score to the input.\n", + "identifier": "GraderScoreModel" +}) +export type GraderLabelModel = { + readonly "type": "label_model" + readonly "name": string + readonly "model": string + readonly "input": ReadonlyArray + readonly "labels": ReadonlyArray + readonly "passing_labels": ReadonlyArray +} +export const GraderLabelModel = Schema.Struct({ + "type": Schema.Literal("label_model").annotate({ "description": "The object type, which is always `label_model`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "model": Schema.String.annotate({ + "description": "The model to use for the evaluation. Must support structured outputs." + }), + "input": Schema.Array(EvalItem), + "labels": Schema.Array(Schema.String).annotate({ + "description": "The labels to assign to each item in the evaluation." + }), + "passing_labels": Schema.Array(Schema.String).annotate({ + "description": "The labels that indicate a passing result. Must be a subset of labels." + }) +}).annotate({ + "title": "LabelModelGrader", + "description": "A LabelModelGrader object which uses a model to assign labels to each item\nin the evaluation.\n", + "identifier": "GraderLabelModel" +}) +export type CreateEvalLabelModelGrader = { + readonly "type": "label_model" + readonly "name": string + readonly "model": string + readonly "input": ReadonlyArray + readonly "labels": ReadonlyArray + readonly "passing_labels": ReadonlyArray +} +export const CreateEvalLabelModelGrader = Schema.Struct({ + "type": Schema.Literal("label_model").annotate({ "description": "The object type, which is always `label_model`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "model": Schema.String.annotate({ + "description": "The model to use for the evaluation. Must support structured outputs." + }), + "input": Schema.Array(CreateEvalItem).annotate({ + "description": + "A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}." + }), + "labels": Schema.Array(Schema.String).annotate({ + "description": "The labels to classify to each item in the evaluation." + }), + "passing_labels": Schema.Array(Schema.String).annotate({ + "description": "The labels that indicate a passing result. Must be a subset of labels." + }) +}).annotate({ + "title": "LabelModelGrader", + "description": "A LabelModelGrader object which uses a model to assign labels to each item\nin the evaluation.\n", + "identifier": "CreateEvalLabelModelGrader" +}) +export type ConversationItem = + | Message + | FunctionToolCallResource + | FunctionToolCallOutputResource + | FileSearchToolCall + | WebSearchToolCall + | ImageGenToolCall + | ComputerToolCall + | ComputerToolCallOutputResource + | ToolSearchCall + | ToolSearchOutput + | AdditionalTools + | ReasoningItem + | Program + | ProgramOutput + | CompactionBody + | 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, + ToolSearchCall, + ToolSearchOutput, + AdditionalTools, + ReasoningItem, + Program, + ProgramOutput, + CompactionBody, + 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).", + "identifier": "ConversationItem" +}) +export type OutputItem = + | OutputMessage + | FileSearchToolCall + | FunctionToolCall + | FunctionToolCallOutputResource + | WebSearchToolCall + | ComputerToolCall + | ComputerToolCallOutputResource + | ReasoningItem + | Program + | ProgramOutput + | ToolSearchCall + | ToolSearchOutput + | AdditionalTools + | CompactionBody + | ImageGenToolCall + | CodeInterpreterToolCall + | LocalShellToolCall + | LocalShellToolCallOutput + | FunctionShellCall + | FunctionShellCallOutput + | ApplyPatchToolCall + | ApplyPatchToolCallOutput + | MCPToolCall + | MCPListTools + | MCPApprovalRequest + | MCPApprovalResponseResource + | CustomToolCall + | CustomToolCallOutputResource +export const OutputItem = Schema.Union([ + OutputMessage, + FileSearchToolCall, + FunctionToolCall, + FunctionToolCallOutputResource, + WebSearchToolCall, + ComputerToolCall, + ComputerToolCallOutputResource, + ReasoningItem, + Program, + ProgramOutput, + ToolSearchCall, + ToolSearchOutput, + AdditionalTools, + CompactionBody, + ImageGenToolCall, + CodeInterpreterToolCall, + LocalShellToolCall, + LocalShellToolCallOutput, + FunctionShellCall, + FunctionShellCallOutput, + ApplyPatchToolCall, + ApplyPatchToolCallOutput, + MCPToolCall, + MCPListTools, + MCPApprovalRequest, + MCPApprovalResponseResource, + CustomToolCall, + CustomToolCallOutputResource +], { mode: "oneOf" }).annotate({ "identifier": "OutputItem" }) +export type ItemResource = + | InputMessageResource + | OutputMessage + | FileSearchToolCall + | ComputerToolCall + | ComputerToolCallOutputResource + | WebSearchToolCall + | FunctionToolCallResource + | FunctionToolCallOutputResource + | ToolSearchCall + | ToolSearchOutput + | AdditionalTools + | ReasoningItem + | Program + | ProgramOutput + | CompactionBody + | ImageGenToolCall + | CodeInterpreterToolCall + | LocalShellToolCall + | LocalShellToolCallOutput + | FunctionShellCall + | FunctionShellCallOutput + | ApplyPatchToolCall + | ApplyPatchToolCallOutput + | MCPListTools + | MCPApprovalRequest + | MCPApprovalResponseResource + | MCPToolCall + | CustomToolCallResource + | CustomToolCallOutputResource +export const ItemResource = Schema.Union([ + InputMessageResource, + OutputMessage, + FileSearchToolCall, + ComputerToolCall, + ComputerToolCallOutputResource, + WebSearchToolCall, + FunctionToolCallResource, + FunctionToolCallOutputResource, + ToolSearchCall, + ToolSearchOutput, + AdditionalTools, + ReasoningItem, + Program, + ProgramOutput, + CompactionBody, + ImageGenToolCall, + CodeInterpreterToolCall, + LocalShellToolCall, + LocalShellToolCallOutput, + FunctionShellCall, + FunctionShellCallOutput, + ApplyPatchToolCall, + ApplyPatchToolCallOutput, + MCPListTools, + MCPApprovalRequest, + MCPApprovalResponseResource, + MCPToolCall, + CustomToolCallResource, + CustomToolCallOutputResource +], { mode: "oneOf" }).annotate({ + "description": "Content item used to generate a response.\n", + "identifier": "ItemResource" +}) +export type ItemField = + | Message + | Program + | ProgramOutput + | FunctionToolCall + | ToolSearchCall + | ToolSearchOutput + | AdditionalTools + | 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, + Program, + ProgramOutput, + FunctionToolCall, + ToolSearchCall, + ToolSearchOutput, + AdditionalTools, + 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.", + "identifier": "ItemField" +}) +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", + "identifier": "InputParam" +}) +export type CreateConversationBody = { + readonly "metadata"?: Metadata | null + readonly "items"?: ReadonlyArray | null +} +export const CreateConversationBody = Schema.Struct({ + "metadata": Schema.optionalKey(Schema.Union([ + Schema.suspend((): Schema.Codec => Metadata).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).annotate({ "expected": "a value with a length of at most 20" })), + Schema.Null + ]) + ) +}).annotate({ "identifier": "CreateConversationBody" }) +export type TokenCountsBody = { + readonly "model"?: string | null + readonly "input"?: string | ReadonlyArray | 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 "tools"?: ReadonlyArray | null + readonly "text"?: ResponseTextParam | null readonly "reasoning"?: Reasoning | null - readonly "background"?: boolean | 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 "truncation"?: TruncationEnum readonly "instructions"?: string | null - readonly "stream"?: boolean | null - readonly "stream_options"?: ResponseStreamOptions + readonly "personality"?: PersonalityEnum readonly "conversation"?: ConversationParam | null - readonly "context_management"?: ReadonlyArray | null - readonly "max_output_tokens"?: number | null + readonly "tool_choice"?: ToolChoiceParam | null + readonly "parallel_tool_calls"?: boolean | null } -export const CreateResponse = Schema.Struct({ - "metadata": Schema.optionalKey(Metadata), - "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\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 maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }) - ) - ]) - ), - "temperature": Schema.optionalKey( +export const TokenCountsBody = Schema.Struct({ + "model": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ + Schema.String.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)), + "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 ]) ), - "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.check(Schema.isMaxLength(64, { - "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( + "input": Schema.optionalKey( Schema.Union([ - Schema.Literals(["in_memory", "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.Union([ + Schema.String.annotate({ + "description": "A text input to the model, equivalent to a text input with the `user` role." + }).check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 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 ]) @@ -25856,82 +30975,97 @@ export const CreateResponse = Schema.Struct({ 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" + "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 ]) ), - "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( + "tools": 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.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 ]) ), - "max_tool_calls": Schema.optionalKey( + "text": Schema.optionalKey(Schema.Union([ResponseTextParam, Schema.Null])), + "reasoning": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ + Schema.suspend((): Schema.Codec => Reasoning).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()), + "**gpt-5 and o-series models only** Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning)." + }), 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({ + "truncation": Schema.optionalKey( + Schema.suspend((): Schema.Codec => TruncationEnum).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({ + "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": - "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)." + "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 ])), + "personality": Schema.optionalKey( + Schema.suspend((): Schema.Codec => PersonalityEnum).annotate({ + "description": + "A model-owned style preset to apply to this request. Omit this parameter to use the model's default style. Supported values may expand over time. Values must be at most 64 characters." + }) + ), + "conversation": Schema.optionalKey(Schema.Union([ConversationParam, Schema.Null])), + "tool_choice": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ToolChoiceParam).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.\n" }), + Schema.Boolean.annotate({ "description": "Whether to allow the model to run tool calls in parallel." }), + Schema.Null + ]) + ) +}).annotate({ "identifier": "TokenCountsBody" }) +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 + readonly "prompt_cache_retention"?: PromptCacheRetentionEnum | null + readonly "prompt_cache_options"?: PromptCacheOptionsParam | null + readonly "service_tier"?: ServiceTierEnum | 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).annotate({ "expected": "a value with a length of at most 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 ]) ), - "store": Schema.optionalKey( + "previous_response_id": Schema.optionalKey( Schema.Union([ - Schema.Boolean.annotate({ - "description": "Whether to store the generated model response for later retrieval via\nAPI.\n" + 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 ]) @@ -25939,2292 +31073,2344 @@ export const CreateResponse = Schema.Struct({ "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" + "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 ])), - "stream_options": Schema.optionalKey(ResponseStreamOptions), - "conversation": Schema.optionalKey(Schema.Union([ConversationParam, Schema.Null])), - "context_management": Schema.optionalKey( + "prompt_cache_key": Schema.optionalKey( Schema.Union([ - Schema.Array(ContextManagementParam).annotate({ - "description": "Context management configuration for this request.\n" - }).check(Schema.isMinLength(1)), + Schema.String.annotate({ "description": "A key to use when reading from or writing to the prompt cache." }).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), Schema.Null ]) ), - "max_output_tokens": Schema.optionalKey( + "prompt_cache_retention": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ + Schema.suspend((): Schema.Codec => PromptCacheRetentionEnum).annotate({ + "description": "How long to retain a prompt cache entry created by this request." + }), + Schema.Null + ]) + ), + "prompt_cache_options": Schema.optionalKey(Schema.Union([PromptCacheOptionsParam, Schema.Null])), + "service_tier": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ServiceTierEnum).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()).check(Schema.isGreaterThanOrEqualTo(16)), + "Specifies the processing type used for serving the request. - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'. - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model. - If set to '[flex](/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier. - To opt-in to [Fast mode](/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request. - When not set, the default behavior is 'auto'.\n When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter." + }), Schema.Null ]) ) +}).annotate({ "identifier": "CompactResponseMethodPublicBody" }) +export type BetaOutputItem = + | BetaOutputMessage + | BetaFileSearchToolCall + | BetaFunctionToolCall + | BetaFunctionToolCallOutputResource + | BetaAgentMessage + | BetaMultiAgentCall + | BetaMultiAgentCallOutput + | BetaWebSearchToolCall + | BetaComputerToolCall + | BetaComputerToolCallOutputResource + | BetaReasoningItem + | BetaProgram + | BetaProgramOutput + | BetaToolSearchCall + | BetaToolSearchOutput + | BetaAdditionalTools + | BetaCompactionBody + | BetaImageGenToolCall + | BetaCodeInterpreterToolCall + | BetaLocalShellToolCall + | BetaLocalShellToolCallOutput + | BetaFunctionShellCall + | BetaFunctionShellCallOutput + | BetaApplyPatchToolCall + | BetaApplyPatchToolCallOutput + | BetaMCPToolCall + | BetaMCPListTools + | BetaMCPApprovalRequest + | BetaMCPApprovalResponseResource + | BetaCustomToolCall + | BetaCustomToolCallOutputResource +export const BetaOutputItem = Schema.Union([ + BetaOutputMessage, + BetaFileSearchToolCall, + BetaFunctionToolCall, + BetaFunctionToolCallOutputResource, + BetaAgentMessage, + BetaMultiAgentCall, + BetaMultiAgentCallOutput, + BetaWebSearchToolCall, + BetaComputerToolCall, + BetaComputerToolCallOutputResource, + BetaReasoningItem, + BetaProgram, + BetaProgramOutput, + BetaToolSearchCall, + BetaToolSearchOutput, + BetaAdditionalTools, + BetaCompactionBody, + BetaImageGenToolCall, + BetaCodeInterpreterToolCall, + BetaLocalShellToolCall, + BetaLocalShellToolCallOutput, + BetaFunctionShellCall, + BetaFunctionShellCallOutput, + BetaApplyPatchToolCall, + BetaApplyPatchToolCallOutput, + BetaMCPToolCall, + BetaMCPListTools, + BetaMCPApprovalRequest, + BetaMCPApprovalResponseResource, + BetaCustomToolCall, + BetaCustomToolCallOutputResource +], { mode: "oneOf" }).annotate({ "identifier": "BetaOutputItem" }) +export type BetaItemField = + | BetaMessage + | BetaProgram + | BetaProgramOutput + | BetaFunctionToolCall + | BetaMultiAgentCall + | BetaMultiAgentCallOutput + | BetaToolSearchCall + | BetaToolSearchOutput + | BetaAdditionalTools + | BetaAgentMessage + | BetaFunctionToolCallOutput + | BetaFileSearchToolCall + | BetaWebSearchToolCall + | BetaImageGenToolCall + | BetaComputerToolCall + | BetaComputerToolCallOutputResource + | BetaReasoningItem + | BetaCompactionBody + | BetaCodeInterpreterToolCall + | BetaLocalShellToolCall + | BetaLocalShellToolCallOutput + | BetaFunctionShellCall + | BetaFunctionShellCallOutput + | BetaApplyPatchToolCall + | BetaApplyPatchToolCallOutput + | BetaMCPListTools + | BetaMCPApprovalRequest + | BetaMCPApprovalResponseResource + | BetaMCPToolCall + | BetaCustomToolCall + | BetaCustomToolCallOutput +export const BetaItemField = Schema.Union([ + BetaMessage, + BetaProgram, + BetaProgramOutput, + BetaFunctionToolCall, + BetaMultiAgentCall, + BetaMultiAgentCallOutput, + BetaToolSearchCall, + BetaToolSearchOutput, + BetaAdditionalTools, + BetaAgentMessage, + BetaFunctionToolCallOutput, + BetaFileSearchToolCall, + BetaWebSearchToolCall, + BetaImageGenToolCall, + BetaComputerToolCall, + BetaComputerToolCallOutputResource, + BetaReasoningItem, + BetaCompactionBody, + BetaCodeInterpreterToolCall, + BetaLocalShellToolCall, + BetaLocalShellToolCallOutput, + BetaFunctionShellCall, + BetaFunctionShellCallOutput, + BetaApplyPatchToolCall, + BetaApplyPatchToolCallOutput, + BetaMCPListTools, + BetaMCPApprovalRequest, + BetaMCPApprovalResponseResource, + BetaMCPToolCall, + BetaCustomToolCall, + BetaCustomToolCallOutput +], { mode: "oneOf" }).annotate({ + "description": "An item representing a message, tool call, tool output, reasoning, or other response element.", + "identifier": "BetaItemField" +}) +export type BetaItemResource = + | BetaInputMessageResource + | BetaOutputMessage + | BetaFileSearchToolCall + | BetaComputerToolCall + | BetaComputerToolCallOutputResource + | BetaWebSearchToolCall + | BetaFunctionToolCallResource + | BetaFunctionToolCallOutputResource + | BetaAgentMessage + | BetaMultiAgentCall + | BetaMultiAgentCallOutput + | BetaToolSearchCall + | BetaToolSearchOutput + | BetaAdditionalTools + | BetaReasoningItem + | BetaProgram + | BetaProgramOutput + | BetaCompactionBody + | BetaImageGenToolCall + | BetaCodeInterpreterToolCall + | BetaLocalShellToolCall + | BetaLocalShellToolCallOutput + | BetaFunctionShellCall + | BetaFunctionShellCallOutput + | BetaApplyPatchToolCall + | BetaApplyPatchToolCallOutput + | BetaMCPListTools + | BetaMCPApprovalRequest + | BetaMCPApprovalResponseResource + | BetaMCPToolCall + | BetaCustomToolCallResource + | BetaCustomToolCallOutputResource +export const BetaItemResource = Schema.Union([ + BetaInputMessageResource, + BetaOutputMessage, + BetaFileSearchToolCall, + BetaComputerToolCall, + BetaComputerToolCallOutputResource, + BetaWebSearchToolCall, + BetaFunctionToolCallResource, + BetaFunctionToolCallOutputResource, + BetaAgentMessage, + BetaMultiAgentCall, + BetaMultiAgentCallOutput, + BetaToolSearchCall, + BetaToolSearchOutput, + BetaAdditionalTools, + BetaReasoningItem, + BetaProgram, + BetaProgramOutput, + BetaCompactionBody, + BetaImageGenToolCall, + BetaCodeInterpreterToolCall, + BetaLocalShellToolCall, + BetaLocalShellToolCallOutput, + BetaFunctionShellCall, + BetaFunctionShellCallOutput, + BetaApplyPatchToolCall, + BetaApplyPatchToolCallOutput, + BetaMCPListTools, + BetaMCPApprovalRequest, + BetaMCPApprovalResponseResource, + BetaMCPToolCall, + BetaCustomToolCallResource, + BetaCustomToolCallOutputResource +], { mode: "oneOf" }).annotate({ + "description": "Content item used to generate a response.\n", + "identifier": "BetaItemResource" }) -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 - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "in_memory" | "24h" | null +export type BetaInputParam = string | ReadonlyArray +export const BetaInputParam = 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(BetaInputItem).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", + "identifier": "BetaInputParam" +}) +export type BetaCompactResponseMethodPublicBody = { + readonly "model": BetaModelIdsCompaction + readonly "input"?: string | ReadonlyArray | 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_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 - readonly "max_output_tokens"?: number | null + readonly "prompt_cache_key"?: string | null + readonly "prompt_cache_retention"?: BetaPromptCacheRetentionEnum | null + readonly "prompt_cache_options"?: BetaPromptCacheOptionsParam | null + readonly "service_tier"?: BetaServiceTierEnum | 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( +export const BetaCompactResponseMethodPublicBody = Schema.Struct({ + "model": BetaModelIdsCompaction, + "input": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\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 maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" + 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).annotate({ "expected": "a value with a length of at most 10485760" })), + Schema.Array(BetaInputItem).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 ]) ), - "temperature": Schema.optionalKey( + "previous_response_id": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ + Schema.String.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)), + "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 ]) ), - "top_p": Schema.optionalKey(Schema.Union([ - Schema.Number.annotate({ + "instructions": Schema.optionalKey(Schema.Union([ + Schema.String.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)), + "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 ])), - "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.check(Schema.isMaxLength(64, { - "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" - }) + Schema.Union([ + Schema.String.annotate({ "description": "A key to use when reading from or writing to the prompt cache." }).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + Schema.Null + ]) ), - "service_tier": Schema.optionalKey(ServiceTier), "prompt_cache_retention": Schema.optionalKey( Schema.Union([ - Schema.Literals(["in_memory", "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.suspend((): Schema.Codec => BetaPromptCacheRetentionEnum).annotate({ + "description": "How long to retain a prompt cache entry created by this request." }), Schema.Null ]) ), - "previous_response_id": Schema.optionalKey( + "prompt_cache_options": Schema.optionalKey(Schema.Union([BetaPromptCacheOptionsParam, Schema.Null])), + "service_tier": Schema.optionalKey( Schema.Union([ - Schema.String.annotate({ + Schema.suspend((): Schema.Codec => BetaServiceTierEnum).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" + "Specifies the processing type used for serving the request. - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'. - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model. - If set to '[flex](/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier. - To opt-in to [Fast mode](/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request. - When not set, the default behavior is 'auto'.\n When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter." }), Schema.Null ]) - ), + ) +}).annotate({ "identifier": "BetaCompactResponseMethodPublicBody" }) +export type BetaTokenCountsBody = { + readonly "model"?: string | null + readonly "input"?: string | ReadonlyArray | null + readonly "previous_response_id"?: string | null + readonly "tools"?: ReadonlyArray | null + readonly "text"?: BetaResponseTextParam | null + readonly "reasoning"?: BetaReasoning | null + readonly "truncation"?: BetaTruncationEnum + readonly "instructions"?: string | null + readonly "personality"?: BetaPersonalityEnum + readonly "conversation"?: BetaConversationParam | null + readonly "tool_choice"?: BetaToolChoiceParam | null + readonly "parallel_tool_calls"?: boolean | null +} +export const BetaTokenCountsBody = Schema.Struct({ "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" - }) + 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 + ]) ), - "reasoning": Schema.optionalKey(Schema.Union([Reasoning, Schema.Null])), - "background": Schema.optionalKey( + "input": 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.Union([ + Schema.String.annotate({ + "description": "A text input to the model, equivalent to a text input with the `user` role." + }).check(Schema.isMaxLength(10485760).annotate({ "expected": "a value with a length of at most 10485760" })), + Schema.Array(BetaInputItem).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 ]) ), - "max_tool_calls": Schema.optionalKey( + "previous_response_id": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ + Schema.String.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()), + "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 ]) ), - "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( + "tools": Schema.optionalKey( Schema.Union([ - Schema.Boolean.annotate({ "description": "Whether to allow the model to run tool calls in parallel.\n" }), + Schema.Array(BetaTool).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 ]) ), - "store": Schema.optionalKey( + "text": Schema.optionalKey(Schema.Union([BetaResponseTextParam, Schema.Null])), + "reasoning": Schema.optionalKey( Schema.Union([ - Schema.Boolean.annotate({ - "description": "Whether to store the generated model response for later retrieval via\nAPI.\n" + Schema.suspend((): Schema.Codec => BetaReasoning).annotate({ + "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.suspend((): Schema.Codec => BetaTruncationEnum).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.\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" + "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 ])), - "stream": Schema.optionalKey(Schema.Union([ - Schema.Boolean.annotate({ + "personality": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaPersonalityEnum).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( + "A model-owned style preset to apply to this request. Omit this parameter to use the model's default style. Supported values may expand over time. Values must be at most 64 characters." + }) + ), + "conversation": Schema.optionalKey(Schema.Union([BetaConversationParam, Schema.Null])), + "tool_choice": Schema.optionalKey( Schema.Union([ - Schema.Array(ContextManagementParam).annotate({ - "description": "Context management configuration for this request.\n" - }).check(Schema.isMinLength(1)), + Schema.suspend((): Schema.Codec => BetaToolChoiceParam).annotate({ + "description": "Controls which tool the model should use, if any." + }), Schema.Null ]) ), - "max_output_tokens": Schema.optionalKey( + "parallel_tool_calls": Schema.optionalKey( Schema.Union([ - Schema.Number.annotate({ + Schema.Boolean.annotate({ "description": "Whether to allow the model to run tool calls in parallel." }), + Schema.Null + ]) + ) +}).annotate({ "identifier": "BetaTokenCountsBody" }) +export type Eval = { + readonly "object": "eval" + readonly "id": string + readonly "name": string + readonly "data_source_config": { readonly "type": "custom"; readonly "schema": {} } | { + readonly "type": "logs" + readonly "metadata"?: Metadata + readonly "schema": {} + } | { readonly "type": "stored_completions"; readonly "metadata"?: Metadata; readonly "schema": {} } + readonly "testing_criteria": ReadonlyArray< + EvalGraderLabelModel | EvalGraderStringCheck | EvalGraderTextSimilarity | EvalGraderPython | EvalGraderScoreModel + > + readonly "created_at": number + readonly "metadata": Metadata +} +export const Eval = Schema.Struct({ + "object": Schema.Literal("eval").annotate({ "description": "The object type." }), + "id": Schema.String.annotate({ "description": "Unique identifier for the evaluation." }), + "name": Schema.String.annotate({ "description": "The name of the evaluation." }), + "data_source_config": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("custom").annotate({ "description": "The type of data source. Always `custom`." }), + "schema": Schema.Struct({}).annotate({ + "description": + "The json schema for the run data source items.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n" + }) + }).annotate({ + "title": "CustomDataSourceConfig", + "description": "Configuration of data sources used in runs of the evaluation." + }), + Schema.Struct({ + "type": Schema.Literal("logs").annotate({ "description": "The type of data source. Always `logs`." }), + "metadata": Schema.optionalKey(Metadata), + "schema": Schema.Struct({}).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()).check(Schema.isGreaterThanOrEqualTo(16)), - Schema.Null - ]) - ) + "The json schema for the run data source items.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n" + }) + }).annotate({ + "title": "LogsDataSourceConfig", + "description": "Configuration of data sources used in runs of the evaluation." + }), + Schema.Struct({ + "type": Schema.Literal("stored_completions").annotate({ + "description": "The type of data source. Always `stored_completions`." + }), + "metadata": Schema.optionalKey(Metadata), + "schema": Schema.Struct({}).annotate({ + "description": + "The json schema for the run data source items.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n" + }) + }).annotate({ + "title": "StoredCompletionsDataSourceConfig", + "description": "Configuration of data sources used in runs of the evaluation." + }) + ], { mode: "oneOf" }), + "testing_criteria": Schema.Array( + Schema.Union([ + EvalGraderLabelModel, + EvalGraderStringCheck, + EvalGraderTextSimilarity, + EvalGraderPython, + EvalGraderScoreModel + ], { mode: "oneOf" }) + ).annotate({ "description": "A list of testing criteria." }), + "created_at": Schema.Number.annotate({ + "description": "The Unix timestamp (in seconds) for when the eval was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "metadata": Metadata }).annotate({ + "title": "Eval", "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" + "An Eval object with a data source config and testing criteria.\nAn Eval represents a task to be done for your LLM integration.\nLike:\n - Improve the quality of my chatbot\n - See how well my chatbot handles customer support\n - Check if o4-mini is better at my usecase than gpt-4o\n", + "identifier": "Eval" }) -export type ConversationItemList = { +export type EvalRunList = { readonly "object": "list" - readonly "data": ReadonlyArray - readonly "has_more": boolean + readonly "data": ReadonlyArray 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 readonly "has_more": boolean - readonly "first_id": string - readonly "last_id": string } -export const ResponseItemList = Schema.Struct({ - "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), - "data": Schema.Array(ItemResource).annotate({ "description": "A list of items used to generate this response." }), - "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({ "description": "A list of Response items." }) -export type Response = { - readonly "metadata": {} | null - readonly "top_logprobs"?: number | null - readonly "temperature": number | null - readonly "top_p": number | null - readonly "user"?: string | null - readonly "safety_identifier"?: string - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "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_tool_calls"?: number | null - readonly "text"?: ResponseTextParam - readonly "tools": ReadonlyArray - readonly "tool_choice": - | ToolChoiceOptions - | ToolChoiceAllowed - | ToolChoiceTypes - | ToolChoiceFunction - | ToolChoiceMCP - | ToolChoiceCustom - | SpecificApplyPatchParam - | SpecificFunctionShellParam - readonly "prompt"?: Prompt - readonly "truncation"?: "auto" | "disabled" | null - readonly "id": string - readonly "object": "response" - readonly "status"?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" - readonly "created_at": number - readonly "completed_at"?: number | null - readonly "error": ResponseError - readonly "incomplete_details": { readonly "reason"?: "max_output_tokens" | "content_filter" } | null - readonly "output": ReadonlyArray - readonly "instructions": string | ReadonlyArray | null - readonly "output_text"?: string | null - readonly "usage"?: ResponseUsage | null - readonly "parallel_tool_calls": boolean - readonly "conversation"?: Conversation_2 | null - readonly "max_output_tokens"?: number | null +export const EvalRunList = Schema.Struct({ + "object": Schema.Literal("list").annotate({ + "description": "The type of this object. It is always set to \"list\".\n" + }), + "data": Schema.Array(EvalRun).annotate({ "description": "An array of eval run objects.\n" }), + "first_id": Schema.String.annotate({ "description": "The identifier of the first eval run in the data array." }), + "last_id": Schema.String.annotate({ "description": "The identifier of the last eval run in the data array." }), + "has_more": Schema.Boolean.annotate({ "description": "Indicates whether there are more evals available." }) +}).annotate({ + "title": "EvalRunList", + "description": "An object representing a list of runs for an evaluation.\n", + "identifier": "EvalRunList" +}) +export type RunGraderRequest = { + readonly "grader": + | { + readonly "type": "string_check" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "operation": "eq" | "ne" | "like" | "ilike" + } + | { + readonly "type": "text_similarity" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "evaluation_metric": + | "cosine" + | "fuzzy_match" + | "bleu" + | "gleu" + | "meteor" + | "rouge_1" + | "rouge_2" + | "rouge_3" + | "rouge_4" + | "rouge_5" + | "rouge_l" + } + | { readonly "type": "python"; readonly "name": string; readonly "source": string; readonly "image_tag"?: string } + | { + readonly "type": "score_model" + readonly "name": string + readonly "model": string + readonly "sampling_params"?: { + readonly "seed"?: number | null + readonly "top_p"?: number | null + readonly "temperature"?: number | null + readonly "max_completions_tokens"?: number | null + readonly "reasoning_effort"?: ReasoningEffort + } + readonly "input": ReadonlyArray + readonly "range"?: ReadonlyArray + } + | { + readonly "type": "multi" + readonly "name": string + readonly "graders": GraderStringCheck | GraderTextSimilarity | GraderPython | GraderScoreModel | GraderLabelModel + readonly "calculate_output": string + } + readonly "item"?: {} + readonly "model_sample": string } -export const Response = Schema.Struct({ - "metadata": Schema.Union([ +export const RunGraderRequest = Schema.Struct({ + "grader": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("string_check").annotate({ + "description": "The object type, which is always `string_check`." + }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), + "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), + "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ + "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." + }) + }).annotate({ "title": "StringCheckGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The text being graded." }), + "reference": Schema.String.annotate({ "description": "The text being graded against." }), + "evaluation_metric": Schema.Literals([ + "cosine", + "fuzzy_match", + "bleu", + "gleu", + "meteor", + "rouge_1", + "rouge_2", + "rouge_3", + "rouge_4", + "rouge_5", + "rouge_l" + ]).annotate({ + "description": + "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" + }) + }).annotate({ "title": "TextSimilarityGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "source": Schema.String.annotate({ "description": "The source code of the python script." }), + "image_tag": Schema.optionalKey( + Schema.String.annotate({ "description": "The image tag to use for the python script." }) + ) + }).annotate({ "title": "PythonGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("score_model").annotate({ + "description": "The object type, which is always `score_model`." + }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), + "sampling_params": Schema.optionalKey( + Schema.Struct({ + "seed": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "max_completions_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The maximum number of tokens the grader model may generate in its response.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]) + ), + "reasoning_effort": Schema.optionalKey(ReasoningEffort) + }).annotate({ "description": "The sampling parameters for the model." }) + ), + "input": Schema.Array(EvalItem).annotate({ + "description": + "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" + }), + "range": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))).annotate({ + "description": "The range of the score. Defaults to `[0, 1]`." + }) + ) + }).annotate({ "title": "ScoreModelGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("multi").annotate({ "description": "The object type, which is always `multi`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "graders": Schema.Union([ + GraderStringCheck, + GraderTextSimilarity, + GraderPython, + GraderScoreModel, + GraderLabelModel + ], { mode: "oneOf" }), + "calculate_output": Schema.String.annotate({ + "description": "A formula to calculate the output based on grader results." + }) + }).annotate({ "title": "MultiGrader", "description": "The grader used for the fine-tuning job." }) + ], { mode: "oneOf" }), + "item": Schema.optionalKey( 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 - ]), - "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)), - Schema.Null - ]) - ), - "temperature": 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.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" + "The dataset item provided to the grader. This will be used to populate \nthe `item` namespace. See [the guide](/docs/guides/graders) for more details. \n" }) ), - "safety_identifier": Schema.optionalKey(Schema.Union([Schema.String.check(Schema.isMaxLength(64, { + "model_sample": Schema.String.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", "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" + "The model sample to be evaluated. This value will be used to populate \nthe `sample` namespace. See [the guide](/docs/guides/graders) for more details.\nThe `output_json` variable will be populated if the model sample is a \nvalid JSON string.\n \n" + }) +}).annotate({ "title": "RunGraderRequest", "identifier": "RunGraderRequest" }) +export type ValidateGraderRequest = { + readonly "grader": + | { + readonly "type": "string_check" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "operation": "eq" | "ne" | "like" | "ilike" + } + | { + readonly "type": "text_similarity" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "evaluation_metric": + | "cosine" + | "fuzzy_match" + | "bleu" + | "gleu" + | "meteor" + | "rouge_1" + | "rouge_2" + | "rouge_3" + | "rouge_4" + | "rouge_5" + | "rouge_l" + } + | { readonly "type": "python"; readonly "name": string; readonly "source": string; readonly "image_tag"?: string } + | { + readonly "type": "score_model" + readonly "name": string + readonly "model": string + readonly "sampling_params"?: { + readonly "seed"?: number | null + readonly "top_p"?: number | null + readonly "temperature"?: number | null + readonly "max_completions_tokens"?: number | null + readonly "reasoning_effort"?: ReasoningEffort + } + readonly "input": ReadonlyArray + readonly "range"?: ReadonlyArray + } + | { + readonly "type": "multi" + readonly "name": string + readonly "graders": GraderStringCheck | GraderTextSimilarity | GraderPython | GraderScoreModel | GraderLabelModel + readonly "calculate_output": string + } +} +export const ValidateGraderRequest = Schema.Struct({ + "grader": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("string_check").annotate({ + "description": "The object type, which is always `string_check`." }), - Schema.Null - ]) - ), - "previous_response_id": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), + "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), + "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ + "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." + }) + }).annotate({ "title": "StringCheckGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The text being graded." }), + "reference": Schema.String.annotate({ "description": "The text being graded against." }), + "evaluation_metric": Schema.Literals([ + "cosine", + "fuzzy_match", + "bleu", + "gleu", + "meteor", + "rouge_1", + "rouge_2", + "rouge_3", + "rouge_4", + "rouge_5", + "rouge_l" + ]).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.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" + "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" + }) + }).annotate({ "title": "TextSimilarityGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "source": Schema.String.annotate({ "description": "The source code of the python script." }), + "image_tag": Schema.optionalKey( + Schema.String.annotate({ "description": "The image tag to use for the python script." }) + ) + }).annotate({ "title": "PythonGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("score_model").annotate({ + "description": "The object type, which is always `score_model`." }), - 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.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" - }), - "tool_choice": Schema.Union([ - ToolChoiceOptions, - ToolChoiceAllowed, - ToolChoiceTypes, - ToolChoiceFunction, - ToolChoiceMCP, - ToolChoiceCustom, - SpecificApplyPatchParam, - SpecificFunctionShellParam - ], { mode: "oneOf" }).annotate({ - "description": - "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n" - }), - "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 - ])), - "id": Schema.String.annotate({ "description": "Unique identifier for this Response.\n" }), - "object": Schema.Literal("response").annotate({ - "description": "The object type of this resource - always set to `response`.\n" - }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).annotate({ - "description": - "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n" - }) - ), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) of when this Response was created.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - "completed_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), + "sampling_params": Schema.optionalKey( + Schema.Struct({ + "seed": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "max_completions_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The maximum number of tokens the grader model may generate in its response.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]) + ), + "reasoning_effort": Schema.optionalKey(ReasoningEffort) + }).annotate({ "description": "The sampling parameters for the model." }) + ), + "input": Schema.Array(EvalItem).annotate({ "description": - "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "error": ResponseError, - "incomplete_details": Schema.Union([ - Schema.Struct({ - "reason": Schema.optionalKey( - Schema.Literals(["max_output_tokens", "content_filter"]).annotate({ - "description": "The reason why the response is incomplete." + "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" + }), + "range": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))).annotate({ + "description": "The range of the score. Defaults to `[0, 1]`." }) ) - }).annotate({ "description": "Details about why the response is incomplete.\n" }), - Schema.Null - ]), - "output": Schema.Array(OutputItem).annotate({ - "description": - "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n" - }), - "instructions": Schema.Union([ - Schema.Union([ - Schema.String.annotate({ - "description": "A text input to the model, equivalent to a text input with the\n`developer` 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" + }).annotate({ "title": "ScoreModelGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("multi").annotate({ "description": "The object type, which is always `multi`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "graders": Schema.Union([ + GraderStringCheck, + GraderTextSimilarity, + GraderPython, + GraderScoreModel, + GraderLabelModel + ], { mode: "oneOf" }), + "calculate_output": Schema.String.annotate({ + "description": "A formula to calculate the output based on grader results." }) - ], { mode: "oneOf" }).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 - ]), - "output_text": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n" - }), - Schema.Null - ]) - ), - "usage": Schema.optionalKey(Schema.Union([ResponseUsage, Schema.Null])), - "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])), - "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 - ]) - ) -}).annotate({ "title": "The response object" }) -export type ResponseCompletedEvent = { - readonly "type": "response.completed" - readonly "response": { - readonly "metadata": {} | null - readonly "top_logprobs"?: number | null - readonly "temperature": number | null - readonly "top_p": number | null - readonly "user"?: string | null - readonly "safety_identifier"?: string - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "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_tool_calls"?: number | null - readonly "text"?: ResponseTextParam - readonly "tools": ReadonlyArray - readonly "tool_choice": - | ToolChoiceOptions - | ToolChoiceAllowed - | ToolChoiceTypes - | ToolChoiceFunction - | ToolChoiceMCP - | ToolChoiceCustom - | SpecificApplyPatchParam - | SpecificFunctionShellParam - readonly "prompt"?: Prompt - readonly "truncation"?: "auto" | "disabled" | null - readonly "id": string - readonly "object": "response" - readonly "status"?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" - readonly "created_at": number - readonly "completed_at"?: number | null - readonly "error": ResponseError - readonly "incomplete_details": { readonly "reason"?: "max_output_tokens" | "content_filter" } | null - readonly "output": ReadonlyArray - readonly "instructions": string | ReadonlyArray | null - readonly "output_text"?: string | null - readonly "usage"?: ResponseUsage | null - readonly "parallel_tool_calls": boolean - readonly "conversation"?: Conversation_2 | null - readonly "max_output_tokens"?: number | null - } - readonly "sequence_number": number + }).annotate({ "title": "MultiGrader", "description": "The grader used for the fine-tuning job." }) + ], { mode: "oneOf" }) +}).annotate({ "title": "ValidateGraderRequest", "identifier": "ValidateGraderRequest" }) +export type ValidateGraderResponse = { + readonly "grader"?: + | { + readonly "type": "string_check" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "operation": "eq" | "ne" | "like" | "ilike" + } + | { + readonly "type": "text_similarity" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "evaluation_metric": + | "cosine" + | "fuzzy_match" + | "bleu" + | "gleu" + | "meteor" + | "rouge_1" + | "rouge_2" + | "rouge_3" + | "rouge_4" + | "rouge_5" + | "rouge_l" + } + | { readonly "type": "python"; readonly "name": string; readonly "source": string; readonly "image_tag"?: string } + | { + readonly "type": "score_model" + readonly "name": string + readonly "model": string + readonly "sampling_params"?: { + readonly "seed"?: number | null + readonly "top_p"?: number | null + readonly "temperature"?: number | null + readonly "max_completions_tokens"?: number | null + readonly "reasoning_effort"?: ReasoningEffort + } + readonly "input": ReadonlyArray + readonly "range"?: ReadonlyArray + } + | { + readonly "type": "multi" + readonly "name": string + readonly "graders": GraderStringCheck | GraderTextSimilarity | GraderPython | GraderScoreModel | GraderLabelModel + readonly "calculate_output": string + } } -export const ResponseCompletedEvent = Schema.Struct({ - "type": Schema.Literal("response.completed").annotate({ - "description": "The type of the event. Always `response.completed`.\n" - }), - "response": Schema.Struct({ - "metadata": 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" +export const ValidateGraderResponse = Schema.Struct({ + "grader": Schema.optionalKey(Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("string_check").annotate({ + "description": "The object type, which is always `string_check`." }), - Schema.Null - ]), - "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)), - Schema.Null - ]) - ), - "temperature": 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.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" + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), + "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), + "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ + "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." }) - ), - "safety_identifier": Schema.optionalKey(Schema.Union([Schema.String.check(Schema.isMaxLength(64, { - "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({ + }).annotate({ "title": "StringCheckGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The text being graded." }), + "reference": Schema.String.annotate({ "description": "The text being graded against." }), + "evaluation_metric": Schema.Literals([ + "cosine", + "fuzzy_match", + "bleu", + "gleu", + "meteor", + "rouge_1", + "rouge_2", + "rouge_3", + "rouge_4", + "rouge_5", + "rouge_l" + ]).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" + "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" }) - ), - "service_tier": Schema.optionalKey(ServiceTier), - "prompt_cache_retention": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["in_memory", "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.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_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.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" - }), - "tool_choice": Schema.Union([ - ToolChoiceOptions, - ToolChoiceAllowed, - ToolChoiceTypes, - ToolChoiceFunction, - ToolChoiceMCP, - ToolChoiceCustom, - SpecificApplyPatchParam, - SpecificFunctionShellParam - ], { mode: "oneOf" }).annotate({ - "description": - "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n" - }), - "prompt": Schema.optionalKey(Prompt), - "truncation": Schema.optionalKey(Schema.Union([ - Schema.Literals(["auto", "disabled"]).annotate({ + }).annotate({ "title": "TextSimilarityGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "source": Schema.String.annotate({ "description": "The source code of the python script." }), + "image_tag": Schema.optionalKey( + Schema.String.annotate({ "description": "The image tag to use for the python script." }) + ) + }).annotate({ "title": "PythonGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("score_model").annotate({ + "description": "The object type, which is always `score_model`." + }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), + "sampling_params": Schema.optionalKey( + Schema.Struct({ + "seed": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "max_completions_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The maximum number of tokens the grader model may generate in its response.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]) + ), + "reasoning_effort": Schema.optionalKey(ReasoningEffort) + }).annotate({ "description": "The sampling parameters for the model." }) + ), + "input": Schema.Array(EvalItem).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" + "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" }), - Schema.Null - ])), - "id": Schema.String.annotate({ "description": "Unique identifier for this Response.\n" }), - "object": Schema.Literal("response").annotate({ - "description": "The object type of this resource - always set to `response`.\n" - }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).annotate({ - "description": - "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n" - }) - ), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) of when this Response was created.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - "completed_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "error": ResponseError, - "incomplete_details": Schema.Union([ - Schema.Struct({ - "reason": Schema.optionalKey( - Schema.Literals(["max_output_tokens", "content_filter"]).annotate({ - "description": "The reason why the response is incomplete." - }) - ) - }).annotate({ "description": "Details about why the response is incomplete.\n" }), - Schema.Null - ]), - "output": Schema.Array(OutputItem).annotate({ - "description": - "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n" - }), - "instructions": Schema.Union([ - Schema.Union([ - Schema.String.annotate({ - "description": "A text input to the model, equivalent to a text input with the\n`developer` 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" + "range": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))).annotate({ + "description": "The range of the score. Defaults to `[0, 1]`." }) - ], { mode: "oneOf" }).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 - ]), - "output_text": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n" - }), - Schema.Null - ]) - ), - "usage": Schema.optionalKey(Schema.Union([ResponseUsage, Schema.Null])), - "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])), - "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 - ]) - ) - }).annotate({ "title": "The response object", "description": "Properties of the completed response.\n" }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( - Schema.isInt() - ) -}).annotate({ "description": "Emitted when the model response is complete." }) -export type ResponseCreatedEvent = { - readonly "type": "response.created" - readonly "response": { - readonly "metadata": {} | null - readonly "top_logprobs"?: number | null - readonly "temperature": number | null - readonly "top_p": number | null - readonly "user"?: string | null - readonly "safety_identifier"?: string - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "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_tool_calls"?: number | null - readonly "text"?: ResponseTextParam - readonly "tools": ReadonlyArray - readonly "tool_choice": - | ToolChoiceOptions - | ToolChoiceAllowed - | ToolChoiceTypes - | ToolChoiceFunction - | ToolChoiceMCP - | ToolChoiceCustom - | SpecificApplyPatchParam - | SpecificFunctionShellParam - readonly "prompt"?: Prompt - readonly "truncation"?: "auto" | "disabled" | null - readonly "id": string - readonly "object": "response" - readonly "status"?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" - readonly "created_at": number - readonly "completed_at"?: number | null - readonly "error": ResponseError - readonly "incomplete_details": { readonly "reason"?: "max_output_tokens" | "content_filter" } | null - readonly "output": ReadonlyArray - readonly "instructions": string | ReadonlyArray | null - readonly "output_text"?: string | null - readonly "usage"?: ResponseUsage | null - readonly "parallel_tool_calls": boolean - readonly "conversation"?: Conversation_2 | null - readonly "max_output_tokens"?: number | null - } - readonly "sequence_number": number + ) + }).annotate({ "title": "ScoreModelGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("multi").annotate({ "description": "The object type, which is always `multi`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "graders": Schema.Union([ + GraderStringCheck, + GraderTextSimilarity, + GraderPython, + GraderScoreModel, + GraderLabelModel + ], { mode: "oneOf" }), + "calculate_output": Schema.String.annotate({ + "description": "A formula to calculate the output based on grader results." + }) + }).annotate({ "title": "MultiGrader", "description": "The grader used for the fine-tuning job." }) + ], { mode: "oneOf" })) +}).annotate({ "title": "ValidateGraderResponse", "identifier": "ValidateGraderResponse" }) +export type FineTuneReinforcementMethod = { + readonly "grader": + | { + readonly "type": "string_check" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "operation": "eq" | "ne" | "like" | "ilike" + } + | { + readonly "type": "text_similarity" + readonly "name": string + readonly "input": string + readonly "reference": string + readonly "evaluation_metric": + | "cosine" + | "fuzzy_match" + | "bleu" + | "gleu" + | "meteor" + | "rouge_1" + | "rouge_2" + | "rouge_3" + | "rouge_4" + | "rouge_5" + | "rouge_l" + } + | { readonly "type": "python"; readonly "name": string; readonly "source": string; readonly "image_tag"?: string } + | { + readonly "type": "score_model" + readonly "name": string + readonly "model": string + readonly "sampling_params"?: { + readonly "seed"?: number | null + readonly "top_p"?: number | null + readonly "temperature"?: number | null + readonly "max_completions_tokens"?: number | null + readonly "reasoning_effort"?: ReasoningEffort + } + readonly "input": ReadonlyArray + readonly "range"?: ReadonlyArray + } + | { + readonly "type": "multi" + readonly "name": string + readonly "graders": GraderStringCheck | GraderTextSimilarity | GraderPython | GraderScoreModel | GraderLabelModel + readonly "calculate_output": string + } + readonly "hyperparameters"?: FineTuneReinforcementHyperparameters } -export const ResponseCreatedEvent = Schema.Struct({ - "type": Schema.Literal("response.created").annotate({ - "description": "The type of the event. Always `response.created`.\n" - }), - "response": Schema.Struct({ - "metadata": 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" +export const FineTuneReinforcementMethod = Schema.Struct({ + "grader": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("string_check").annotate({ + "description": "The object type, which is always `string_check`." }), - Schema.Null - ]), - "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)), - Schema.Null - ]) - ), - "temperature": 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.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" + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The input text. This may include template strings." }), + "reference": Schema.String.annotate({ "description": "The reference text. This may include template strings." }), + "operation": Schema.Literals(["eq", "ne", "like", "ilike"]).annotate({ + "description": "The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`." }) - ), - "safety_identifier": Schema.optionalKey(Schema.Union([Schema.String.check(Schema.isMaxLength(64, { - "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({ + }).annotate({ "title": "StringCheckGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("text_similarity").annotate({ "description": "The type of grader." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "input": Schema.String.annotate({ "description": "The text being graded." }), + "reference": Schema.String.annotate({ "description": "The text being graded against." }), + "evaluation_metric": Schema.Literals([ + "cosine", + "fuzzy_match", + "bleu", + "gleu", + "meteor", + "rouge_1", + "rouge_2", + "rouge_3", + "rouge_4", + "rouge_5", + "rouge_l" + ]).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" + "The evaluation metric to use. One of `cosine`, `fuzzy_match`, `bleu`, \n`gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, \nor `rouge_l`.\n" }) - ), - "service_tier": Schema.optionalKey(ServiceTier), - "prompt_cache_retention": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["in_memory", "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.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([ + }).annotate({ "title": "TextSimilarityGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("python").annotate({ "description": "The object type, which is always `python`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "source": Schema.String.annotate({ "description": "The source code of the python script." }), + "image_tag": Schema.optionalKey( + Schema.String.annotate({ "description": "The image tag to use for the python script." }) + ) + }).annotate({ "title": "PythonGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("score_model").annotate({ + "description": "The object type, which is always `score_model`." + }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "model": Schema.String.annotate({ "description": "The model to use for the evaluation." }), + "sampling_params": Schema.optionalKey( + Schema.Struct({ + "seed": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A seed value to initialize the randomness, during sampling.\n" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + ), + "top_p": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "An alternative to temperature for nucleus sampling; 1.0 includes all tokens.\n" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "temperature": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": "A higher temperature increases randomness in the outputs.\n" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "max_completions_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": "The maximum number of tokens the grader model may generate in its response.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ), + Schema.Null + ]) + ), + "reasoning_effort": Schema.optionalKey(ReasoningEffort) + }).annotate({ "description": "The sampling parameters for the model." }) + ), + "input": Schema.Array(EvalItem).annotate({ + "description": + "The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.\n" + }), + "range": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))).annotate({ + "description": "The range of the score. Defaults to `[0, 1]`." + }) + ) + }).annotate({ "title": "ScoreModelGrader", "description": "The grader used for the fine-tuning job." }), + Schema.Struct({ + "type": Schema.Literal("multi").annotate({ "description": "The object type, which is always `multi`." }), + "name": Schema.String.annotate({ "description": "The name of the grader." }), + "graders": Schema.Union([ + GraderStringCheck, + GraderTextSimilarity, + GraderPython, + GraderScoreModel, + GraderLabelModel + ], { mode: "oneOf" }), + "calculate_output": Schema.String.annotate({ + "description": "A formula to calculate the output based on grader results." + }) + }).annotate({ "title": "MultiGrader", "description": "The grader used for the fine-tuning job." }) + ], { mode: "oneOf" }), + "hyperparameters": Schema.optionalKey(FineTuneReinforcementHyperparameters) +}).annotate({ + "description": "Configuration for the reinforcement fine-tuning method.", + "identifier": "FineTuneReinforcementMethod" +}) +export type CreateEvalRequest = { + readonly "name"?: string + readonly "metadata"?: Metadata + readonly "data_source_config": + | { readonly "type": "custom"; readonly "item_schema": {}; readonly "include_sample_schema"?: boolean } + | { readonly "type": "logs"; readonly "metadata"?: {} } + | { readonly "type": "stored_completions"; readonly "metadata"?: {} } + readonly "testing_criteria": ReadonlyArray< + | CreateEvalLabelModelGrader + | EvalGraderStringCheck + | EvalGraderTextSimilarity + | EvalGraderPython + | EvalGraderScoreModel + > +} +export const CreateEvalRequest = Schema.Struct({ + "name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the evaluation." })), + "metadata": Schema.optionalKey(Metadata), + "data_source_config": Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("custom").annotate({ "description": "The type of data source. Always `custom`." }), + "item_schema": Schema.Struct({}).annotate({ "description": "The json schema for each row in the data source." }), + "include_sample_schema": Schema.optionalKey( Schema.Boolean.annotate({ "description": - "Whether to run the model response in the background.\n[Learn more](/docs/guides/background).\n" - }), - 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.Array(Tool).annotate({ + "Whether the eval should expect you to populate the sample namespace (ie, by generating responses off of your data source)" + }) + ) + }).annotate({ + "title": "CustomDataSourceConfig", "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" + "The configuration for the data source used for the evaluation runs. Dictates the schema of the data used in the evaluation." }), - "tool_choice": Schema.Union([ - ToolChoiceOptions, - ToolChoiceAllowed, - ToolChoiceTypes, - ToolChoiceFunction, - ToolChoiceMCP, - ToolChoiceCustom, - SpecificApplyPatchParam, - SpecificFunctionShellParam - ], { mode: "oneOf" }).annotate({ + Schema.Struct({ + "type": Schema.Literal("logs").annotate({ "description": "The type of data source. Always `logs`." }), + "metadata": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Metadata filters for the logs data source." }) + ) + }).annotate({ + "title": "LogsDataSourceConfig", "description": - "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n" + "The configuration for the data source used for the evaluation runs. Dictates the schema of the data used in the evaluation." }), - "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.Struct({ + "type": Schema.Literal("stored_completions").annotate({ + "description": "The type of data source. Always `stored_completions`." }), - Schema.Null - ])), - "id": Schema.String.annotate({ "description": "Unique identifier for this Response.\n" }), - "object": Schema.Literal("response").annotate({ - "description": "The object type of this resource - always set to `response`.\n" - }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).annotate({ + "metadata": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Metadata filters for the stored completions data source." }) + ) + }).annotate({ + "title": "StoredCompletionsDataSourceConfig", + "description": + "The configuration for the data source used for the evaluation runs. Dictates the schema of the data used in the evaluation." + }) + ], { mode: "oneOf" }), + "testing_criteria": Schema.Array( + Schema.Union([ + CreateEvalLabelModelGrader, + EvalGraderStringCheck, + EvalGraderTextSimilarity, + EvalGraderPython, + EvalGraderScoreModel + ], { mode: "oneOf" }) + ).annotate({ + "description": + "A list of graders for all eval runs in this group. Graders can reference variables in the data source using double curly braces notation, like `{{item.variable_name}}`. To reference the model's output, use the `sample` namespace (ie, `{{sample.output_text}}`)." + }) +}).annotate({ "title": "CreateEvalRequest", "identifier": "CreateEvalRequest" }) +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.", + "identifier": "ConversationItemList" +}) +export type Response = { + readonly "metadata": Metadata + readonly "top_logprobs"?: number | null + readonly "temperature": number | null + readonly "top_p": number | null + readonly "user"?: string | null + readonly "safety_identifier"?: string | null | null + readonly "prompt_cache_key"?: string | null | null + readonly "service_tier"?: ServiceTier + readonly "prompt_cache_retention"?: "in_memory" | "in_memory" | "24h" | null + readonly "previous_response_id"?: string | null + readonly "model": ModelIdsResponses + readonly "background"?: boolean | 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 "id": string + readonly "object": "response" + readonly "status"?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" + readonly "created_at": number + readonly "completed_at"?: number | null + readonly "error": ResponseError + readonly "incomplete_details": { readonly "reason"?: "max_output_tokens" | "content_filter" } | null + readonly "output": ReadonlyArray + readonly "reasoning"?: Reasoning | null + readonly "instructions": string | ReadonlyArray | null + readonly "output_text"?: string | null + readonly "usage"?: ResponseUsage | null + readonly "prompt_cache_options"?: PromptCacheOptions + readonly "moderation"?: Moderation | null + readonly "parallel_tool_calls": boolean + readonly "conversation"?: ResponseConversation | null + readonly "max_output_tokens"?: number | null +} +export const Response = Schema.Struct({ + "metadata": Metadata, + "top_logprobs": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": - "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n" - }) - ), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) of when this Response was created.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - "completed_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "error": ResponseError, - "incomplete_details": Schema.Union([ - Schema.Struct({ - "reason": Schema.optionalKey( - Schema.Literals(["max_output_tokens", "content_filter"]).annotate({ - "description": "The reason why the response is incomplete." - }) - ) - }).annotate({ "description": "Details about why the response is incomplete.\n" }), + "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" })), Schema.Null - ]), - "output": Schema.Array(OutputItem).annotate({ + ]) + ), + "temperature": Schema.Union([ + Schema.Number.annotate({ "description": - "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n" - }), - "instructions": Schema.Union([ - Schema.Union([ - Schema.String.annotate({ - "description": "A text input to the model, equivalent to a text input with the\n`developer` 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({ + "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().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]), + "top_p": 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().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 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.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" - }), + "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" + }).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), Schema.Null ]), - "output_text": Schema.optionalKey( + Schema.Null + ])), + "prompt_cache_key": Schema.optionalKey( + Schema.Union([ Schema.Union([ Schema.String.annotate({ "description": - "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n" + "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" }), Schema.Null - ]) - ), - "usage": Schema.optionalKey(Schema.Union([ResponseUsage, Schema.Null])), - "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])), - "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 - ]) - ) - }).annotate({ "title": "The response object", "description": "The response that was created.\n" }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( - Schema.isInt() - ) -}).annotate({ "description": "An event that is emitted when a response is created.\n" }) -export type ResponseFailedEvent = { - readonly "type": "response.failed" - readonly "sequence_number": number - readonly "response": { - readonly "metadata": {} | null - readonly "top_logprobs"?: number | null - readonly "temperature": number | null - readonly "top_p": number | null - readonly "user"?: string | null - readonly "safety_identifier"?: string - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "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_tool_calls"?: number | null - readonly "text"?: ResponseTextParam - readonly "tools": ReadonlyArray - readonly "tool_choice": - | ToolChoiceOptions - | ToolChoiceAllowed - | ToolChoiceTypes - | ToolChoiceFunction - | ToolChoiceMCP - | ToolChoiceCustom - | SpecificApplyPatchParam - | SpecificFunctionShellParam - readonly "prompt"?: Prompt - readonly "truncation"?: "auto" | "disabled" | null - readonly "id": string - readonly "object": "response" - readonly "status"?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" - readonly "created_at": number - readonly "completed_at"?: number | null - readonly "error": ResponseError - readonly "incomplete_details": { readonly "reason"?: "max_output_tokens" | "content_filter" } | null - readonly "output": ReadonlyArray - readonly "instructions": string | ReadonlyArray | null - readonly "output_text"?: string | null - readonly "usage"?: ResponseUsage | null - readonly "parallel_tool_calls": boolean - readonly "conversation"?: Conversation_2 | null - readonly "max_output_tokens"?: number | null - } -} -export const ResponseFailedEvent = Schema.Struct({ - "type": Schema.Literal("response.failed").annotate({ - "description": "The type of the event. Always `response.failed`.\n" - }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() + ]), + Schema.Null + ]) ), - "response": Schema.Struct({ - "metadata": Schema.Union([ - Schema.Struct({}).annotate({ + "service_tier": Schema.optionalKey(ServiceTier), + "prompt_cache_retention": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in_memory", "in_memory", "24h"]).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" + "Deprecated. Use `prompt_cache_options.ttl` instead.\n\nThe 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).\nThis field expresses a maximum retention policy, while\n`prompt_cache_options.ttl` expresses a minimum cache lifetime. The two\nfields are independent and do not interact.\nFor `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.\n\nFor older models that support both `in_memory` and `24h`, the default depends on your organization's data retention policy:\n - Organizations without ZDR enabled default to `24h`.\n - Organizations with ZDR enabled default to `in_memory` when `prompt_cache_retention` is not specified.\n" }), Schema.Null - ]), - "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)), - Schema.Null - ]) - ), - "temperature": Schema.Union([ - Schema.Number.annotate({ + ]) + ), + "previous_response_id": Schema.optionalKey( + Schema.Union([ + Schema.String.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)), + "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.suspend((): Schema.Codec => ModelIdsResponses).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" + }), + "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 - ]), - "top_p": Schema.Union([ + ]) + ), + "max_tool_calls": 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)), + "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().annotate({ "expected": "an integer" })), 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.check(Schema.isMaxLength(64, { - "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", "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.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({ + ]) + ), + "text": Schema.optionalKey(ResponseTextParam), + "tools": ToolsArray, + "tool_choice": ToolChoiceParam, + "prompt": Schema.optionalKey(Prompt), + "truncation": Schema.optionalKey(Schema.Union([ + Schema.Literals(["auto", "disabled"]).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" + "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" }), - "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_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.Array(Tool).annotate({ + Schema.Null + ])), + "id": Schema.String.annotate({ "description": "Unique identifier for this Response.\n" }), + "object": Schema.Literal("response").annotate({ + "description": "The object type of this resource - always set to `response`.\n" + }), + "status": Schema.optionalKey( + Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).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" - }), - "tool_choice": Schema.Union([ - ToolChoiceOptions, - ToolChoiceAllowed, - ToolChoiceTypes, - ToolChoiceFunction, - ToolChoiceMCP, - ToolChoiceCustom, - SpecificApplyPatchParam, - SpecificFunctionShellParam + "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n" + }) + ), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) of when this Response was created.\n", + "format": "unixtime" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "completed_at": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": + "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n", + "format": "unixtime" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]) + ), + "error": ResponseError, + "incomplete_details": Schema.Union([ + Schema.Struct({ + "reason": Schema.optionalKey( + Schema.Literals(["max_output_tokens", "content_filter"]).annotate({ + "description": "The reason why the response is incomplete." + }) + ) + }).annotate({ "description": "Details about why the response is incomplete.\n" }), + Schema.Null + ]), + "output": Schema.Array(OutputItem).annotate({ + "description": + "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n" + }), + "reasoning": Schema.optionalKey(Schema.Union([Reasoning, Schema.Null])), + "instructions": Schema.Union([ + Schema.Union([ + Schema.String.annotate({ + "description": "A text input to the model, equivalent to a text input with the\n`developer` 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": - "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n" + "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" }), - "prompt": Schema.optionalKey(Prompt), - "truncation": Schema.optionalKey(Schema.Union([ - Schema.Literals(["auto", "disabled"]).annotate({ + Schema.Null + ]), + "output_text": Schema.optionalKey( + Schema.Union([ + Schema.String.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" + "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n" }), Schema.Null - ])), - "id": Schema.String.annotate({ "description": "Unique identifier for this Response.\n" }), - "object": Schema.Literal("response").annotate({ - "description": "The object type of this resource - always set to `response`.\n" - }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).annotate({ + ]) + ), + "usage": Schema.optionalKey(Schema.Union([ResponseUsage, Schema.Null])), + "prompt_cache_options": Schema.optionalKey(PromptCacheOptions), + "moderation": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => Moderation).annotate({ "description": - "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n" - }) - ), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) of when this Response was created.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - "completed_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "error": ResponseError, - "incomplete_details": Schema.Union([ - Schema.Struct({ - "reason": Schema.optionalKey( - Schema.Literals(["max_output_tokens", "content_filter"]).annotate({ - "description": "The reason why the response is incomplete." - }) - ) - }).annotate({ "description": "Details about why the response is incomplete.\n" }), + "Moderation results for the response input and output, if moderated completions were requested.\n" + }), Schema.Null - ]), - "output": Schema.Array(OutputItem).annotate({ - "description": - "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n" - }), - "instructions": Schema.Union([ - Schema.Union([ - Schema.String.annotate({ - "description": "A text input to the model, equivalent to a text input with the\n`developer` 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({ + ]) + ), + "parallel_tool_calls": Schema.Boolean.annotate({ + "description": "Whether to allow the model to run tool calls in parallel.\n" + }), + "conversation": Schema.optionalKey(Schema.Union([ResponseConversation, Schema.Null])), + "max_output_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.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" - }), + "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().annotate({ "expected": "an integer" })), Schema.Null - ]), - "output_text": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n" - }), - Schema.Null - ]) - ), - "usage": Schema.optionalKey(Schema.Union([ResponseUsage, Schema.Null])), - "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])), - "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 - ]) - ) - }).annotate({ "title": "The response object", "description": "The response that failed.\n" }) -}).annotate({ "description": "An event that is emitted when a response fails.\n" }) -export type ResponseInProgressEvent = { - readonly "type": "response.in_progress" - readonly "response": { - readonly "metadata": {} | null - readonly "top_logprobs"?: number | null - readonly "temperature": number | null - readonly "top_p": number | null - readonly "user"?: string | null - readonly "safety_identifier"?: string - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "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_tool_calls"?: number | null - readonly "text"?: ResponseTextParam - readonly "tools": ReadonlyArray - readonly "tool_choice": - | ToolChoiceOptions - | ToolChoiceAllowed - | ToolChoiceTypes - | ToolChoiceFunction - | ToolChoiceMCP - | ToolChoiceCustom - | SpecificApplyPatchParam - | SpecificFunctionShellParam - readonly "prompt"?: Prompt - readonly "truncation"?: "auto" | "disabled" | null - readonly "id": string - readonly "object": "response" - readonly "status"?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" - readonly "created_at": number - readonly "completed_at"?: number | null - readonly "error": ResponseError - readonly "incomplete_details": { readonly "reason"?: "max_output_tokens" | "content_filter" } | null - readonly "output": ReadonlyArray - readonly "instructions": string | ReadonlyArray | null - readonly "output_text"?: string | null - readonly "usage"?: ResponseUsage | null - readonly "parallel_tool_calls": boolean - readonly "conversation"?: Conversation_2 | null - readonly "max_output_tokens"?: number | null - } + ]) + ) +}).annotate({ "title": "The response object", "identifier": "Response" }) +export type ResponseOutputItemAddedEvent = { + readonly "type": "response.output_item.added" + readonly "output_index": number + readonly "sequence_number": number + readonly "item": OutputItem +} +export const ResponseOutputItemAddedEvent = Schema.Struct({ + "type": Schema.Literal("response.output_item.added").annotate({ + "description": "The type of the event. Always `response.output_item.added`.\n" + }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that was added.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "item": Schema.suspend((): Schema.Codec => OutputItem).annotate({ + "description": "The output item that was added.\n" + }) +}).annotate({ "description": "Emitted when a new output item is added.", "identifier": "ResponseOutputItemAddedEvent" }) +export type ResponseOutputItemDoneEvent = { + readonly "type": "response.output_item.done" + readonly "output_index": number readonly "sequence_number": number + readonly "item": OutputItem +} +export const ResponseOutputItemDoneEvent = Schema.Struct({ + "type": Schema.Literal("response.output_item.done").annotate({ + "description": "The type of the event. Always `response.output_item.done`.\n" + }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that was marked done.\n" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "item": Schema.suspend((): Schema.Codec => OutputItem).annotate({ + "description": "The output item that was marked done.\n" + }) +}).annotate({ + "description": "Emitted when an output item is marked done.", + "identifier": "ResponseOutputItemDoneEvent" +}) +export type ResponseItemList = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "first_id": string + readonly "last_id": string +} +export const ResponseItemList = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), + "data": Schema.Array(ItemResource).annotate({ "description": "A list of items used to generate this response." }), + "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({ "description": "A list of Response items.", "identifier": "ResponseItemList" }) +export type CompactResource = { + readonly "id": string + readonly "object": "response.compaction" + readonly "output": ReadonlyArray + readonly "created_at": number + readonly "usage": ResponseUsage +} +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.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "usage": Schema.suspend((): Schema.Codec => ResponseUsage).annotate({ + "description": "Token accounting for the compaction pass, including cached, reasoning, and total tokens." + }) +}).annotate({ "title": "The compacted response object", "identifier": "CompactResource" }) +export type CreateResponse = { + 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 | null + readonly "prompt_cache_key"?: string | null | null + readonly "service_tier"?: ServiceTier + readonly "prompt_cache_retention"?: "in_memory" | "in_memory" | "24h" | null + readonly "prompt_cache_options"?: PromptCacheOptionsParam + readonly "previous_response_id"?: string | null + readonly "model"?: ModelIdsResponses + readonly "background"?: boolean | 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 "reasoning"?: Reasoning | null + readonly "input"?: InputParam + readonly "include"?: ReadonlyArray | null + readonly "parallel_tool_calls"?: boolean | null + readonly "store"?: boolean | null + readonly "instructions"?: string | null + readonly "moderation"?: ModerationParam | null + readonly "stream"?: boolean | null + readonly "stream_options"?: ResponseStreamOptions + readonly "conversation"?: ConversationParam | null + readonly "context_management"?: ReadonlyArray | null + readonly "max_output_tokens"?: number | null } -export const ResponseInProgressEvent = Schema.Struct({ - "type": Schema.Literal("response.in_progress").annotate({ - "description": "The type of the event. Always `response.in_progress`.\n" - }), - "response": Schema.Struct({ - "metadata": Schema.Union([ - Schema.Struct({}).annotate({ +export const CreateResponse = Schema.Struct({ + "metadata": Schema.optionalKey(Metadata), + "top_logprobs": Schema.optionalKey( + Schema.Union([ + Schema.Number.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 - ]), - "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ + "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" })).check( + Schema.makeFilterGroup([ + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }), + Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" }) + ]).annotate({ "description": "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)), - Schema.Null - ]) - ), - "temperature": Schema.Union([ + }) + ) + ]) + ), + "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)), + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), Schema.Null - ]), - "top_p": Schema.Union([ - Schema.Number.annotate({ + ]) + ), + "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().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 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.Union([ + Schema.String.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)), + "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" + }).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), 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.check(Schema.isMaxLength(64, { - "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", "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.Null + ])), + "prompt_cache_key": Schema.optionalKey( + Schema.Union([ 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" + "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" }), Schema.Null - ]) - ), - "model": 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({ + ]), + Schema.Null + ]) + ), + "service_tier": Schema.optionalKey(ServiceTier), + "prompt_cache_retention": Schema.optionalKey( + Schema.Union([ + Schema.Literals(["in_memory", "in_memory", "24h"]).annotate({ + "description": + "Deprecated. Use `prompt_cache_options.ttl` instead.\n\nThe 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).\nThis field expresses a maximum retention policy, while\n`prompt_cache_options.ttl` expresses a minimum cache lifetime. The two\nfields are independent and do not interact.\nFor `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.\n\nFor older models that support both `in_memory` and `24h`, the default depends on your organization's data retention policy:\n - Organizations without ZDR enabled default to `24h`.\n - Organizations with ZDR enabled default to `in_memory` when `prompt_cache_retention` is not specified.\n" + }), + Schema.Null + ]) + ), + "prompt_cache_options": Schema.optionalKey(PromptCacheOptionsParam), + "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.suspend((): Schema.Codec => ModelIdsResponses).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" + }) + ), + "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_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().annotate({ "expected": "an integer" })), + 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" }), - "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_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.Array(Tool).annotate({ + Schema.Null + ])), + "reasoning": Schema.optionalKey(Schema.Union([Reasoning, Schema.Null])), + "input": Schema.optionalKey(InputParam), + "include": Schema.optionalKey(Schema.Union([ + Schema.Array(IncludeEnum).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" + "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)." }), - "tool_choice": Schema.Union([ - ToolChoiceOptions, - ToolChoiceAllowed, - ToolChoiceTypes, - ToolChoiceFunction, - ToolChoiceMCP, - ToolChoiceCustom, - SpecificApplyPatchParam, - SpecificFunctionShellParam - ], { mode: "oneOf" }).annotate({ + 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": - "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n" + "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" }), - "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 + ])), + "moderation": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => ModerationParam).annotate({ + "description": "Configuration for running moderation on the input and output of this response.\n" }), Schema.Null - ])), - "id": Schema.String.annotate({ "description": "Unique identifier for this Response.\n" }), - "object": Schema.Literal("response").annotate({ - "description": "The object type of this resource - always set to `response`.\n" + ]) + ), + "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" }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).annotate({ + 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).annotate({ "expected": "a value with a length of at least 1" })), + Schema.Null + ]) + ), + "max_output_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": - "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n" - }) - ), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) of when this Response was created.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - "completed_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "error": ResponseError, - "incomplete_details": Schema.Union([ - Schema.Struct({ - "reason": Schema.optionalKey( - Schema.Literals(["max_output_tokens", "content_filter"]).annotate({ - "description": "The reason why the response is incomplete." - }) - ) - }).annotate({ "description": "Details about why the response is incomplete.\n" }), + "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().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(16).annotate({ "expected": "a value greater than or equal to 16" }) + ), + Schema.Null + ]) + ) +}).annotate({ "identifier": "CreateResponse" }) +export type BetaResponse = { + readonly "metadata": BetaMetadata + readonly "top_logprobs"?: number | null + readonly "temperature": number | null + readonly "top_p": number | null + readonly "user"?: string + readonly "safety_identifier"?: string | null + readonly "prompt_cache_key"?: string | null + readonly "service_tier"?: BetaServiceTier + readonly "prompt_cache_retention"?: "in_memory" | "24h" | null + readonly "previous_response_id"?: string | null + readonly "model": BetaModelIdsResponses + readonly "background"?: boolean | null + readonly "max_tool_calls"?: number | null + readonly "text"?: BetaResponseTextParam + readonly "tools": BetaToolsArray + readonly "tool_choice": BetaToolChoiceParam + readonly "prompt"?: BetaPrompt + readonly "truncation"?: "auto" | "disabled" | null + readonly "id": string + readonly "object": "response" + readonly "status"?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" + readonly "created_at": number + readonly "completed_at"?: number | null + readonly "error": BetaResponseError + readonly "incomplete_details": { readonly "reason"?: "max_output_tokens" | "content_filter" } | null + readonly "output": ReadonlyArray + readonly "reasoning"?: BetaReasoning | null + readonly "instructions": string | ReadonlyArray | null + readonly "output_text"?: string | null + readonly "usage"?: BetaResponseUsage + readonly "prompt_cache_options"?: BetaPromptCacheOptions + readonly "moderation"?: BetaModeration | null + readonly "parallel_tool_calls": boolean + readonly "conversation"?: BetaResponseConversation | null + readonly "max_output_tokens"?: number | null +} +export const BetaResponse = Schema.Struct({ + "metadata": BetaMetadata, + "top_logprobs": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ + "description": + "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" })), + Schema.Null + ]) + ), + "temperature": 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().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), + Schema.Null + ]), + "top_p": 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().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), + Schema.Null + ]), + "user": Schema.optionalKey(Schema.String.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.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" + }).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + Schema.Null + ])), + "prompt_cache_key": Schema.optionalKey( + Schema.Union([ + Schema.String.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" + }), Schema.Null - ]), - "output": Schema.Array(OutputItem).annotate({ + ]) + ), + "service_tier": Schema.optionalKey(BetaServiceTier), + "prompt_cache_retention": Schema.optionalKey(Schema.Union([ + Schema.Literals(["in_memory", "24h"]).annotate({ "description": - "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n" + "Deprecated. Use `prompt_cache_options.ttl` instead.\n\nThe 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).\nThis field expresses a maximum retention policy, while\n`prompt_cache_options.ttl` expresses a minimum cache lifetime. The two\nfields are independent and do not interact.\nFor `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.\n\nFor older models that support both `in_memory` and `24h`, the default depends on your organization's data retention policy:\n - Organizations without ZDR enabled default to `24h`.\n - Organizations with ZDR enabled default to `in_memory` when `prompt_cache_retention` is not specified.\n" }), - "instructions": Schema.Union([ - Schema.Union([ - Schema.String.annotate({ - "description": "A text input to the model, equivalent to a text input with the\n`developer` 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({ + Schema.Null + ])), + "previous_response_id": 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" + "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 - ]), - "output_text": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n" - }), - Schema.Null - ]) - ), - "usage": Schema.optionalKey(Schema.Union([ResponseUsage, Schema.Null])), - "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])), - "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 - ]) - ) - }).annotate({ "title": "The response object", "description": "The response that is in progress.\n" }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() - ) -}).annotate({ "description": "Emitted when the response is in progress." }) -export type ResponseIncompleteEvent = { - readonly "type": "response.incomplete" - readonly "response": { - readonly "metadata": {} | null - readonly "top_logprobs"?: number | null - readonly "temperature": number | null - readonly "top_p": number | null - readonly "user"?: string | null - readonly "safety_identifier"?: string - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "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_tool_calls"?: number | null - readonly "text"?: ResponseTextParam - readonly "tools": ReadonlyArray - readonly "tool_choice": - | ToolChoiceOptions - | ToolChoiceAllowed - | ToolChoiceTypes - | ToolChoiceFunction - | ToolChoiceMCP - | ToolChoiceCustom - | SpecificApplyPatchParam - | SpecificFunctionShellParam - readonly "prompt"?: Prompt - readonly "truncation"?: "auto" | "disabled" | null - readonly "id": string - readonly "object": "response" - readonly "status"?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" - readonly "created_at": number - readonly "completed_at"?: number | null - readonly "error": ResponseError - readonly "incomplete_details": { readonly "reason"?: "max_output_tokens" | "content_filter" } | null - readonly "output": ReadonlyArray - readonly "instructions": string | ReadonlyArray | null - readonly "output_text"?: string | null - readonly "usage"?: ResponseUsage | null - readonly "parallel_tool_calls": boolean - readonly "conversation"?: Conversation_2 | null - readonly "max_output_tokens"?: number | null - } - readonly "sequence_number": number -} -export const ResponseIncompleteEvent = Schema.Struct({ - "type": Schema.Literal("response.incomplete").annotate({ - "description": "The type of the event. Always `response.incomplete`.\n" + ]) + ), + "model": Schema.suspend((): Schema.Codec => BetaModelIdsResponses).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" }), - "response": Schema.Struct({ - "metadata": 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" + "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 - ]), - "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)), - Schema.Null - ]) - ), - "temperature": Schema.Union([ + ]) + ), + "max_tool_calls": 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)), + "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().annotate({ "expected": "an integer" })), Schema.Null - ]), - "top_p": Schema.Union([ + ]) + ), + "text": Schema.optionalKey(BetaResponseTextParam), + "tools": BetaToolsArray, + "tool_choice": BetaToolChoiceParam, + "prompt": Schema.optionalKey(BetaPrompt), + "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 + ])), + "id": Schema.String.annotate({ "description": "Unique identifier for this Response.\n" }), + "object": Schema.Literal("response").annotate({ + "description": "The object type of this resource - always set to `response`.\n" + }), + "status": Schema.optionalKey( + Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).annotate({ + "description": + "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n" + }) + ), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) of when this Response was created.\n", + "format": "unixtime" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "completed_at": 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)), + "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n", + "format": "unixtime" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), 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.check(Schema.isMaxLength(64, { - "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" + ]) + ), + "error": BetaResponseError, + "incomplete_details": Schema.Union([ + Schema.Struct({ + "reason": Schema.optionalKey( + Schema.Literals(["max_output_tokens", "content_filter"]).annotate({ + "description": "The reason why the response is incomplete." + }) + ) + }).annotate({ "description": "Details about why the response is incomplete.\n" }), + Schema.Null + ]), + "output": Schema.Array(BetaOutputItem).annotate({ + "description": + "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n" + }), + "reasoning": Schema.optionalKey(Schema.Union([BetaReasoning, Schema.Null])), + "instructions": Schema.Union([ + Schema.Union([ + Schema.String.annotate({ + "description": "A text input to the model, equivalent to a text input with the\n`developer` role.\n" + }), + Schema.Array(BetaInputItem).annotate({ + "title": "Input item list", + "description": "A list of one or many input items to the model, containing\ndifferent content types.\n" }) - ), - "service_tier": Schema.optionalKey(ServiceTier), - "prompt_cache_retention": Schema.optionalKey( - Schema.Union([ - Schema.Literals(["in_memory", "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.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_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.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" - }), - "tool_choice": Schema.Union([ - ToolChoiceOptions, - ToolChoiceAllowed, - ToolChoiceTypes, - ToolChoiceFunction, - ToolChoiceMCP, - ToolChoiceCustom, - SpecificApplyPatchParam, - SpecificFunctionShellParam ], { mode: "oneOf" }).annotate({ "description": - "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n" + "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" }), - "prompt": Schema.optionalKey(Prompt), - "truncation": Schema.optionalKey(Schema.Union([ - Schema.Literals(["auto", "disabled"]).annotate({ + Schema.Null + ]), + "output_text": Schema.optionalKey( + Schema.Union([ + Schema.String.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" + "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n" }), Schema.Null - ])), - "id": Schema.String.annotate({ "description": "Unique identifier for this Response.\n" }), - "object": Schema.Literal("response").annotate({ - "description": "The object type of this resource - always set to `response`.\n" - }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).annotate({ + ]) + ), + "usage": Schema.optionalKey(BetaResponseUsage), + "prompt_cache_options": Schema.optionalKey(BetaPromptCacheOptions), + "moderation": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaModeration).annotate({ "description": - "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n" - }) - ), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) of when this Response was created.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - "completed_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "error": ResponseError, - "incomplete_details": Schema.Union([ - Schema.Struct({ - "reason": Schema.optionalKey( - Schema.Literals(["max_output_tokens", "content_filter"]).annotate({ - "description": "The reason why the response is incomplete." - }) - ) - }).annotate({ "description": "Details about why the response is incomplete.\n" }), + "Moderation results for the response input and output, if moderated completions were requested.\n" + }), Schema.Null - ]), - "output": Schema.Array(OutputItem).annotate({ - "description": - "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n" - }), - "instructions": Schema.Union([ - Schema.Union([ - Schema.String.annotate({ - "description": "A text input to the model, equivalent to a text input with the\n`developer` 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({ + ]) + ), + "parallel_tool_calls": Schema.Boolean.annotate({ + "description": "Whether to allow the model to run tool calls in parallel.\n" + }), + "conversation": Schema.optionalKey(Schema.Union([BetaResponseConversation, Schema.Null])), + "max_output_tokens": Schema.optionalKey( + Schema.Union([ + Schema.Number.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" - }), + "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().annotate({ "expected": "an integer" })), Schema.Null - ]), - "output_text": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n" - }), - Schema.Null - ]) - ), - "usage": Schema.optionalKey(Schema.Union([ResponseUsage, Schema.Null])), - "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])), - "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 - ]) - ) - }).annotate({ "title": "The response object", "description": "The response that was incomplete.\n" }), - "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( - Schema.isInt() + ]) ) -}).annotate({ "description": "An event that is emitted when a response finishes as incomplete.\n" }) -export type ResponseQueuedEvent = { - readonly "type": "response.queued" - readonly "response": { - readonly "metadata": {} | null - readonly "top_logprobs"?: number | null - readonly "temperature": number | null - readonly "top_p": number | null - readonly "user"?: string | null - readonly "safety_identifier"?: string - readonly "prompt_cache_key"?: string | null - readonly "service_tier"?: ServiceTier - readonly "prompt_cache_retention"?: "in_memory" | "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_tool_calls"?: number | null - readonly "text"?: ResponseTextParam - readonly "tools": ReadonlyArray - readonly "tool_choice": - | ToolChoiceOptions - | ToolChoiceAllowed - | ToolChoiceTypes - | ToolChoiceFunction - | ToolChoiceMCP - | ToolChoiceCustom - | SpecificApplyPatchParam - | SpecificFunctionShellParam - readonly "prompt"?: Prompt - readonly "truncation"?: "auto" | "disabled" | null - readonly "id": string - readonly "object": "response" - readonly "status"?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" - readonly "created_at": number - readonly "completed_at"?: number | null - readonly "error": ResponseError - readonly "incomplete_details": { readonly "reason"?: "max_output_tokens" | "content_filter" } | null - readonly "output": ReadonlyArray - readonly "instructions": string | ReadonlyArray | null - readonly "output_text"?: string | null - readonly "usage"?: ResponseUsage | null - readonly "parallel_tool_calls": boolean - readonly "conversation"?: Conversation_2 | null - readonly "max_output_tokens"?: number | null - } +}).annotate({ "title": "The response object", "identifier": "BetaResponse" }) +export type BetaResponseOutputItemAddedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.output_item.added" + readonly "output_index": number + readonly "sequence_number": number + readonly "item": BetaOutputItem +} +export const BetaResponseOutputItemAddedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.output_item.added").annotate({ + "description": "The type of the event. Always `response.output_item.added`.\n" + }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that was added.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "item": Schema.suspend((): Schema.Codec => BetaOutputItem).annotate({ + "description": "The output item that was added.\n" + }) +}).annotate({ + "description": "Emitted when a new output item is added.", + "identifier": "BetaResponseOutputItemAddedEvent" +}) +export type BetaResponseOutputItemDoneEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.output_item.done" + readonly "output_index": number readonly "sequence_number": number + readonly "item": BetaOutputItem +} +export const BetaResponseOutputItemDoneEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.output_item.done").annotate({ + "description": "The type of the event. Always `response.output_item.done`.\n" + }), + "output_index": Schema.Number.annotate({ "description": "The index of the output item that was marked done.\n" }) + .check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event.\n" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "item": Schema.suspend((): Schema.Codec => BetaOutputItem).annotate({ + "description": "The output item that was marked done.\n" + }) +}).annotate({ + "description": "Emitted when an output item is marked done.", + "identifier": "BetaResponseOutputItemDoneEvent" +}) +export type BetaCompactResource = { + readonly "id": string + readonly "object": "response.compaction" + readonly "output": ReadonlyArray + readonly "created_at": number + readonly "usage": BetaResponseUsage } -export const ResponseQueuedEvent = Schema.Struct({ - "type": Schema.Literal("response.queued").annotate({ - "description": "The type of the event. Always 'response.queued'." +export const BetaCompactResource = 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`." }), - "response": Schema.Struct({ - "metadata": Schema.Union([ - Schema.Struct({}).annotate({ + "output": Schema.Array(BetaItemField).annotate({ "description": "The compacted list of output items." }), + "created_at": Schema.Number.annotate({ + "description": "Unix timestamp (in seconds) when the compacted conversation was created.", + "format": "unixtime" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "usage": Schema.suspend((): Schema.Codec => BetaResponseUsage).annotate({ + "description": "Token accounting for the compaction pass, including cached, reasoning, and total tokens." + }) +}).annotate({ "title": "The compacted response object", "identifier": "BetaCompactResource" }) +export type BetaResponseItemList = { + readonly "object": "list" + readonly "data": ReadonlyArray + readonly "has_more": boolean + readonly "first_id": string + readonly "last_id": string +} +export const BetaResponseItemList = Schema.Struct({ + "object": Schema.Literal("list").annotate({ "description": "The type of object returned, must be `list`." }), + "data": Schema.Array(BetaItemResource).annotate({ "description": "A list of items used to generate this response." }), + "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({ "description": "A list of Response items.", "identifier": "BetaResponseItemList" }) +export type BetaCreateResponse = { + readonly "metadata"?: BetaMetadata + readonly "top_logprobs"?: number + readonly "temperature"?: number | null + readonly "top_p"?: number | null + readonly "user"?: string + readonly "safety_identifier"?: string | null + readonly "prompt_cache_key"?: string | null + readonly "service_tier"?: BetaServiceTier + readonly "prompt_cache_retention"?: "in_memory" | "24h" | null + readonly "prompt_cache_options"?: BetaPromptCacheOptionsParam + readonly "previous_response_id"?: string | null + readonly "model"?: BetaModelIdsResponses + readonly "background"?: boolean | null + readonly "max_tool_calls"?: number | null + readonly "text"?: BetaResponseTextParam + readonly "tools"?: BetaToolsArray + readonly "tool_choice"?: BetaToolChoiceParam + readonly "prompt"?: BetaPrompt + readonly "truncation"?: "auto" | "disabled" | null + readonly "reasoning"?: BetaReasoning | null + readonly "input"?: BetaInputParam + readonly "include"?: ReadonlyArray | null + readonly "parallel_tool_calls"?: boolean | null + readonly "store"?: boolean | null + readonly "instructions"?: string | null + readonly "moderation"?: BetaModerationParam | null + readonly "stream"?: boolean | null + readonly "stream_options"?: BetaResponseStreamOptions + readonly "conversation"?: BetaConversationParam | null + readonly "context_management"?: ReadonlyArray | null + readonly "max_output_tokens"?: number | null + readonly "multi_agent"?: BetaMultiAgentParam | null +} +export const BetaCreateResponse = Schema.Struct({ + "metadata": Schema.optionalKey(BetaMetadata), + "top_logprobs": Schema.optionalKey( + Schema.Union([ + Schema.Number.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 - ]), - "top_logprobs": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ + "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" })).check( + Schema.makeFilterGroup([ + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }), + Schema.isLessThanOrEqualTo(20).annotate({ "expected": "a value less than or equal to 20" }) + ]).annotate({ "description": "An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n" - }).check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(20)), - Schema.Null - ]) - ), - "temperature": Schema.Union([ + }) + ) + ]) + ), + "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.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)), + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(2).annotate({ "expected": "a value less than or equal to 2" })), 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.check(Schema.isMaxLength(64, { + ]) + ), + "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().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })), + Schema.Null + ])), + "user": Schema.optionalKey(Schema.String.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.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({ + }).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + Schema.Null + ])), + "prompt_cache_key": Schema.optionalKey( + Schema.Union([ + Schema.String.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", "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.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_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.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" - }), - "tool_choice": Schema.Union([ - ToolChoiceOptions, - ToolChoiceAllowed, - ToolChoiceTypes, - ToolChoiceFunction, - ToolChoiceMCP, - ToolChoiceCustom, - SpecificApplyPatchParam, - SpecificFunctionShellParam - ], { mode: "oneOf" }).annotate({ + }), + Schema.Null + ]) + ), + "service_tier": Schema.optionalKey(BetaServiceTier), + "prompt_cache_retention": Schema.optionalKey(Schema.Union([ + Schema.Literals(["in_memory", "24h"]).annotate({ "description": - "How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n" + "Deprecated. Use `prompt_cache_options.ttl` instead.\n\nThe 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).\nThis field expresses a maximum retention policy, while\n`prompt_cache_options.ttl` expresses a minimum cache lifetime. The two\nfields are independent and do not interact.\nFor `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.\n\nFor older models that support both `in_memory` and `24h`, the default depends on your organization's data retention policy:\n - Organizations without ZDR enabled default to `24h`.\n - Organizations with ZDR enabled default to `in_memory` when `prompt_cache_retention` is not specified.\n" }), - "prompt": Schema.optionalKey(Prompt), - "truncation": Schema.optionalKey(Schema.Union([ - Schema.Literals(["auto", "disabled"]).annotate({ + Schema.Null + ])), + "prompt_cache_options": Schema.optionalKey(BetaPromptCacheOptionsParam), + "previous_response_id": Schema.optionalKey( + Schema.Union([ + Schema.String.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" + "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 - ])), - "id": Schema.String.annotate({ "description": "Unique identifier for this Response.\n" }), - "object": Schema.Literal("response").annotate({ - "description": "The object type of this resource - always set to `response`.\n" - }), - "status": Schema.optionalKey( - Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).annotate({ + ]) + ), + "model": Schema.optionalKey( + Schema.suspend((): Schema.Codec => BetaModelIdsResponses).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" + }) + ), + "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_tool_calls": Schema.optionalKey( + Schema.Union([ + Schema.Number.annotate({ "description": - "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n" - }) - ), - "created_at": Schema.Number.annotate({ - "description": "Unix timestamp (in seconds) of when this Response was created.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - "completed_at": Schema.optionalKey( - Schema.Union([ - Schema.Number.annotate({ - "description": - "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n", - "format": "unixtime" - }).check(Schema.isFinite()), - Schema.Null - ]) - ), - "error": ResponseError, - "incomplete_details": Schema.Union([ - Schema.Struct({ - "reason": Schema.optionalKey( - Schema.Literals(["max_output_tokens", "content_filter"]).annotate({ - "description": "The reason why the response is incomplete." - }) - ) - }).annotate({ "description": "Details about why the response is incomplete.\n" }), + "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().annotate({ "expected": "an integer" })), Schema.Null - ]), - "output": Schema.Array(OutputItem).annotate({ + ]) + ), + "text": Schema.optionalKey(BetaResponseTextParam), + "tools": Schema.optionalKey(BetaToolsArray), + "tool_choice": Schema.optionalKey(BetaToolChoiceParam), + "prompt": Schema.optionalKey(BetaPrompt), + "truncation": Schema.optionalKey(Schema.Union([ + Schema.Literals(["auto", "disabled"]).annotate({ "description": - "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n" + "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" }), - "instructions": Schema.Union([ - Schema.Union([ - Schema.String.annotate({ - "description": "A text input to the model, equivalent to a text input with the\n`developer` 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": - "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 + ])), + "reasoning": Schema.optionalKey(Schema.Union([BetaReasoning, Schema.Null])), + "input": Schema.optionalKey(BetaInputParam), + "include": Schema.optionalKey(Schema.Union([ + Schema.Array(BetaIncludeEnum).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 - ]), - "output_text": Schema.optionalKey( - Schema.Union([ - Schema.String.annotate({ - "description": - "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n" - }), - Schema.Null - ]) - ), - "usage": Schema.optionalKey(Schema.Union([ResponseUsage, Schema.Null])), - "parallel_tool_calls": Schema.Boolean.annotate({ - "description": "Whether to allow the model to run tool calls in parallel.\n" + ]) + ), + "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" }), - "conversation": Schema.optionalKey(Schema.Union([Conversation_2, 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 - ]) - ) - }).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 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.", - "format": "unixtime" - }).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({ + Schema.Null + ])), + "moderation": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaModerationParam).annotate({ + "description": "Configuration for running moderation on the input and output of this response.\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(BetaResponseStreamOptions), + "conversation": Schema.optionalKey(Schema.Union([BetaConversationParam, Schema.Null])), + "context_management": Schema.optionalKey( + Schema.Union([ + Schema.Array(BetaContextManagementParam).annotate({ + "description": "Context management configuration for this request.\n" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + Schema.Null + ]) + ), + "max_output_tokens": Schema.optionalKey( + Schema.Union([ + 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" }) + "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().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(16).annotate({ "expected": "a value greater than or equal to 16" }) + ), + Schema.Null + ]) + ), + "multi_agent": Schema.optionalKey( + Schema.Union([ + Schema.suspend((): Schema.Codec => BetaMultiAgentParam).annotate({ + "description": "Configuration for server-hosted multi-agent execution." + }), + Schema.Null + ]) + ) +}).annotate({ "identifier": "BetaCreateResponse" }) export type EvalList = { readonly "object": "list" readonly "data": ReadonlyArray @@ -28240,7 +33426,11 @@ export const EvalList = Schema.Struct({ "first_id": Schema.String.annotate({ "description": "The identifier of the first eval in the data array." }), "last_id": Schema.String.annotate({ "description": "The identifier of the last eval in the data array." }), "has_more": Schema.Boolean.annotate({ "description": "Indicates whether there are more evals available." }) -}).annotate({ "title": "EvalList", "description": "An object representing a list of evals.\n" }) +}).annotate({ + "title": "EvalList", + "description": "An object representing a list of evals.\n", + "identifier": "EvalList" +}) export type FineTuneMethod = { readonly "type": "supervised" | "dpo" | "reinforcement" readonly "supervised"?: FineTuneSupervisedMethod @@ -28254,261 +33444,260 @@ export const FineTuneMethod = Schema.Struct({ "supervised": Schema.optionalKey(FineTuneSupervisedMethod), "dpo": Schema.optionalKey(FineTuneDPOMethod), "reinforcement": Schema.optionalKey(FineTuneReinforcementMethod) -}).annotate({ "description": "The method used for fine-tuning." }) -export type ResponseStreamEvent = - | ResponseAudioDeltaEvent - | ResponseAudioDoneEvent - | ResponseAudioTranscriptDeltaEvent - | ResponseAudioTranscriptDoneEvent - | ResponseCodeInterpreterCallCodeDeltaEvent - | ResponseCodeInterpreterCallCodeDoneEvent - | ResponseCodeInterpreterCallCompletedEvent - | ResponseCodeInterpreterCallInProgressEvent - | ResponseCodeInterpreterCallInterpretingEvent - | ResponseCompletedEvent - | ResponseContentPartAddedEvent - | ResponseContentPartDoneEvent - | ResponseCreatedEvent - | ResponseErrorEvent - | ResponseFileSearchCallCompletedEvent - | ResponseFileSearchCallInProgressEvent - | ResponseFileSearchCallSearchingEvent - | ResponseFunctionCallArgumentsDeltaEvent - | ResponseFunctionCallArgumentsDoneEvent - | ResponseInProgressEvent - | ResponseFailedEvent - | ResponseIncompleteEvent - | ResponseOutputItemAddedEvent - | ResponseOutputItemDoneEvent - | ResponseReasoningSummaryPartAddedEvent - | ResponseReasoningSummaryPartDoneEvent - | ResponseReasoningSummaryTextDeltaEvent - | ResponseReasoningSummaryTextDoneEvent - | ResponseReasoningTextDeltaEvent - | ResponseReasoningTextDoneEvent - | ResponseRefusalDeltaEvent - | ResponseRefusalDoneEvent - | ResponseTextDeltaEvent - | ResponseTextDoneEvent - | ResponseWebSearchCallCompletedEvent - | ResponseWebSearchCallInProgressEvent - | ResponseWebSearchCallSearchingEvent - | ResponseImageGenCallCompletedEvent - | ResponseImageGenCallGeneratingEvent - | ResponseImageGenCallInProgressEvent - | ResponseImageGenCallPartialImageEvent - | ResponseMCPCallArgumentsDeltaEvent - | ResponseMCPCallArgumentsDoneEvent - | ResponseMCPCallCompletedEvent - | ResponseMCPCallFailedEvent - | ResponseMCPCallInProgressEvent - | ResponseMCPListToolsCompletedEvent - | ResponseMCPListToolsFailedEvent - | ResponseMCPListToolsInProgressEvent - | ResponseOutputTextAnnotationAddedEvent - | ResponseQueuedEvent - | ResponseCustomToolCallInputDeltaEvent - | ResponseCustomToolCallInputDoneEvent - | ResponseKeepAliveEvent - | ResponseApplyPatchCallOperationDiffDeltaEvent - | ResponseApplyPatchCallOperationDiffDoneEvent -export const ResponseStreamEvent = Schema.Union([ - ResponseAudioDeltaEvent, - ResponseAudioDoneEvent, - ResponseAudioTranscriptDeltaEvent, - ResponseAudioTranscriptDoneEvent, - ResponseCodeInterpreterCallCodeDeltaEvent, - ResponseCodeInterpreterCallCodeDoneEvent, - ResponseCodeInterpreterCallCompletedEvent, - ResponseCodeInterpreterCallInProgressEvent, - ResponseCodeInterpreterCallInterpretingEvent, - ResponseCompletedEvent, - ResponseContentPartAddedEvent, - ResponseContentPartDoneEvent, - ResponseCreatedEvent, - ResponseErrorEvent, - ResponseFileSearchCallCompletedEvent, - ResponseFileSearchCallInProgressEvent, - ResponseFileSearchCallSearchingEvent, - ResponseFunctionCallArgumentsDeltaEvent, - ResponseFunctionCallArgumentsDoneEvent, - ResponseInProgressEvent, - ResponseFailedEvent, - ResponseIncompleteEvent, - ResponseOutputItemAddedEvent, - ResponseOutputItemDoneEvent, - ResponseReasoningSummaryPartAddedEvent, - ResponseReasoningSummaryPartDoneEvent, - ResponseReasoningSummaryTextDeltaEvent, - ResponseReasoningSummaryTextDoneEvent, - ResponseReasoningTextDeltaEvent, - ResponseReasoningTextDoneEvent, - ResponseRefusalDeltaEvent, - ResponseRefusalDoneEvent, - ResponseTextDeltaEvent, - ResponseTextDoneEvent, - ResponseWebSearchCallCompletedEvent, - ResponseWebSearchCallInProgressEvent, - ResponseWebSearchCallSearchingEvent, - ResponseImageGenCallCompletedEvent, - ResponseImageGenCallGeneratingEvent, - ResponseImageGenCallInProgressEvent, - ResponseImageGenCallPartialImageEvent, - ResponseMCPCallArgumentsDeltaEvent, - ResponseMCPCallArgumentsDoneEvent, - ResponseMCPCallCompletedEvent, - ResponseMCPCallFailedEvent, - ResponseMCPCallInProgressEvent, - ResponseMCPListToolsCompletedEvent, - ResponseMCPListToolsFailedEvent, - ResponseMCPListToolsInProgressEvent, - ResponseOutputTextAnnotationAddedEvent, - ResponseQueuedEvent, - ResponseCustomToolCallInputDeltaEvent, - ResponseCustomToolCallInputDoneEvent, - ResponseKeepAliveEvent, - ResponseApplyPatchCallOperationDiffDeltaEvent, - ResponseApplyPatchCallOperationDiffDoneEvent -]) -export type CreateFineTuningJobRequest = { - readonly "model": string | "babbage-002" | "davinci-002" | "gpt-3.5-turbo" | "gpt-4o-mini" - readonly "training_file": string - readonly "hyperparameters"?: { - readonly "batch_size"?: "auto" | number - readonly "learning_rate_multiplier"?: "auto" | number - readonly "n_epochs"?: "auto" | number - } - readonly "suffix"?: string - readonly "validation_file"?: string | null - readonly "integrations"?: ReadonlyArray< - { - readonly "type": "wandb" - readonly "wandb": { - readonly "project": string - readonly "name"?: string | null - readonly "entity"?: string | null - readonly "tags"?: ReadonlyArray - } - } - > - readonly "seed"?: number - readonly "method"?: FineTuneMethod - readonly "metadata"?: Metadata +}).annotate({ "description": "The method used for fine-tuning.", "identifier": "FineTuneMethod" }) +export type ResponseCompletedEvent = { + readonly "type": "response.completed" + readonly "response": Response + readonly "sequence_number": number +} +export const ResponseCompletedEvent = Schema.Struct({ + "type": Schema.Literal("response.completed").annotate({ + "description": "The type of the event. Always `response.completed`.\n" + }), + "response": Schema.suspend((): Schema.Codec => Response).annotate({ + "description": "Properties of the completed response.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "description": "Emitted when the model response is complete.", "identifier": "ResponseCompletedEvent" }) +export type ResponseCreatedEvent = { + readonly "type": "response.created" + readonly "response": Response + readonly "sequence_number": number +} +export const ResponseCreatedEvent = Schema.Struct({ + "type": Schema.Literal("response.created").annotate({ + "description": "The type of the event. Always `response.created`.\n" + }), + "response": Schema.suspend((): Schema.Codec => Response).annotate({ + "description": "The response that was created.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "An event that is emitted when a response is created.\n", + "identifier": "ResponseCreatedEvent" +}) +export type ResponseInProgressEvent = { + readonly "type": "response.in_progress" + readonly "response": Response + readonly "sequence_number": number +} +export const ResponseInProgressEvent = Schema.Struct({ + "type": Schema.Literal("response.in_progress").annotate({ + "description": "The type of the event. Always `response.in_progress`.\n" + }), + "response": Schema.suspend((): Schema.Codec => Response).annotate({ + "description": "The response that is in progress.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "description": "Emitted when the response is in progress.", "identifier": "ResponseInProgressEvent" }) +export type ResponseFailedEvent = { + readonly "type": "response.failed" + readonly "sequence_number": number + readonly "response": Response +} +export const ResponseFailedEvent = Schema.Struct({ + "type": Schema.Literal("response.failed").annotate({ + "description": "The type of the event. Always `response.failed`.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "response": Schema.suspend((): Schema.Codec => Response).annotate({ + "description": "The response that failed.\n" + }) +}).annotate({ "description": "An event that is emitted when a response fails.\n", "identifier": "ResponseFailedEvent" }) +export type ResponseIncompleteEvent = { + readonly "type": "response.incomplete" + readonly "response": Response + readonly "sequence_number": number +} +export const ResponseIncompleteEvent = Schema.Struct({ + "type": Schema.Literal("response.incomplete").annotate({ + "description": "The type of the event. Always `response.incomplete`.\n" + }), + "response": Schema.suspend((): Schema.Codec => Response).annotate({ + "description": "The response that was incomplete.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "An event that is emitted when a response finishes as incomplete.\n", + "identifier": "ResponseIncompleteEvent" +}) +export type ResponseQueuedEvent = { + readonly "type": "response.queued" + readonly "response": Response + readonly "sequence_number": number +} +export const ResponseQueuedEvent = Schema.Struct({ + "type": Schema.Literal("response.queued").annotate({ + "description": "The type of the event. Always 'response.queued'." + }), + "response": Schema.suspend((): Schema.Codec => Response).annotate({ + "description": "The full response object that is queued." + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "ResponseQueuedEvent", + "description": "Emitted when a response is queued and waiting to be processed.\n", + "identifier": "ResponseQueuedEvent" +}) +export type BetaResponseCompletedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.completed" + readonly "response": BetaResponse + readonly "sequence_number": number +} +export const BetaResponseCompletedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.completed").annotate({ + "description": "The type of the event. Always `response.completed`.\n" + }), + "response": Schema.suspend((): Schema.Codec => BetaResponse).annotate({ + "description": "Properties of the completed response.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Emitted when the model response is complete.", + "identifier": "BetaResponseCompletedEvent" +}) +export type BetaResponseCreatedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.created" + readonly "response": BetaResponse + readonly "sequence_number": number +} +export const BetaResponseCreatedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.created").annotate({ + "description": "The type of the event. Always `response.created`.\n" + }), + "response": Schema.suspend((): Schema.Codec => BetaResponse).annotate({ + "description": "The response that was created.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "An event that is emitted when a response is created.\n", + "identifier": "BetaResponseCreatedEvent" +}) +export type BetaResponseInProgressEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.in_progress" + readonly "response": BetaResponse + readonly "sequence_number": number } -export const CreateFineTuningJobRequest = Schema.Struct({ - "model": Schema.Union([ - Schema.String, - Schema.Literals(["babbage-002", "davinci-002", "gpt-3.5-turbo", "gpt-4o-mini"]) - ]).annotate({ - "description": - "The name of the model to fine-tune. You can select one of the\n[supported models](/docs/guides/fine-tuning#which-models-can-be-fine-tuned).\n" +export const BetaResponseInProgressEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) + ), + "type": Schema.Literal("response.in_progress").annotate({ + "description": "The type of the event. Always `response.in_progress`.\n" }), - "training_file": Schema.String.annotate({ - "description": - "The ID of an uploaded file that contains training data.\n\nSee [upload file](/docs/api-reference/files/create) for how to upload a file.\n\nYour dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`.\n\nThe contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input), [completions](/docs/api-reference/fine-tuning/completions-input) format, or if the fine-tuning method uses the [preference](/docs/api-reference/fine-tuning/preference-input) format.\n\nSee the [fine-tuning guide](/docs/guides/model-optimization) for more details.\n" + "response": Schema.suspend((): Schema.Codec => BetaResponse).annotate({ + "description": "The response that is in progress.\n" }), - "hyperparameters": Schema.optionalKey( - Schema.Struct({ - "batch_size": Schema.optionalKey( - Schema.Union([ - Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check( - Schema.isLessThanOrEqualTo(256) - ) - ], { mode: "oneOf" }).annotate({ - "description": - "Number of examples in each batch. A larger batch size means that model parameters\nare updated less frequently, but with lower variance.\n" - }) - ), - "learning_rate_multiplier": Schema.optionalKey( - Schema.Union([Schema.Literal("auto"), Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThan(0))], { - mode: "oneOf" - }).annotate({ - "description": - "Scaling factor for the learning rate. A smaller learning rate may be useful to avoid\noverfitting.\n" - }) - ), - "n_epochs": Schema.optionalKey( - Schema.Union([ - Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check( - Schema.isLessThanOrEqualTo(50) - ) - ], { mode: "oneOf" }).annotate({ - "description": - "The number of epochs to train the model for. An epoch refers to one full cycle\nthrough the training dataset.\n" - }) - ) - }).annotate({ - "description": - "The hyperparameters used for the fine-tuning job.\nThis value is now deprecated in favor of `method`, and should be passed in under the `method` parameter.\n" + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "description": "Emitted when the response is in progress.", "identifier": "BetaResponseInProgressEvent" }) +export type BetaResponseFailedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.failed" + readonly "sequence_number": number + readonly "response": BetaResponse +} +export const BetaResponseFailedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "suffix": Schema.optionalKey( - Schema.Union([ - Schema.String.check( - Schema.makeFilterGroup([Schema.isMinLength(1), Schema.isMaxLength(64)], { - "description": - "A string of up to 64 characters that will be added to your fine-tuned model name.\n\nFor example, a `suffix` of \"custom-model-name\" would produce a model name like `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`.\n" - }) - ) - ]) + "type": Schema.Literal("response.failed").annotate({ + "description": "The type of the event. Always `response.failed`.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "validation_file": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "The ID of an uploaded file that contains validation data.\n\nIf you provide this file, the data is used to generate validation\nmetrics periodically during fine-tuning. These metrics can be viewed in\nthe fine-tuning results file.\nThe same data should not be present in both train and validation files.\n\nYour dataset must be formatted as a JSONL file. You must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/model-optimization) for more details.\n" + "response": Schema.suspend((): Schema.Codec => BetaResponse).annotate({ + "description": "The response that failed.\n" + }) +}).annotate({ + "description": "An event that is emitted when a response fails.\n", + "identifier": "BetaResponseFailedEvent" +}) +export type BetaResponseIncompleteEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.incomplete" + readonly "response": BetaResponse + readonly "sequence_number": number +} +export const BetaResponseIncompleteEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." }) ), - "integrations": Schema.optionalKey(Schema.Union([ - Schema.Array(Schema.Struct({ - "type": Schema.Literal("wandb").annotate({ - "description": - "The type of integration to enable. Currently, only \"wandb\" (Weights and Biases) is supported.\n" - }), - "wandb": Schema.Struct({ - "project": Schema.String.annotate({ - "description": "The name of the project that the new run will be created under.\n" - }), - "name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "A display name to set for the run. If not set, we will use the Job ID as the name.\n" - }) - ), - "entity": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "The entity to use for the run. This allows you to set the team or username of the WandB user that you would\nlike associated with the run. If not set, the default entity for the registered WandB API key is used.\n" - }) - ), - "tags": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some\ndefault tags are generated by OpenAI: \"openai/finetune\", \"openai/{base-model}\", \"openai/{ftjob-abcdef}\".\n" - }) - ) - }).annotate({ - "description": - "The settings for your integration with Weights and Biases. This payload specifies the project that\nmetrics will be sent to. Optionally, you can set an explicit display name for your run, add tags\nto your run, and set a default entity (team, username, etc) to be associated with your run.\n" - }) - })).annotate({ "description": "A list of integrations to enable for your fine-tuning job." }) - ])), - "seed": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt()).check( - Schema.makeFilterGroup([ - Schema.isFinite(), - Schema.isGreaterThanOrEqualTo(0), - Schema.isLessThanOrEqualTo(2147483647) - ], { - "description": - "The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases.\nIf a seed is not specified, one will be generated for you.\n" - }) - ) - ]) + "type": Schema.Literal("response.incomplete").annotate({ + "description": "The type of the event. Always `response.incomplete`.\n" + }), + "response": Schema.suspend((): Schema.Codec => BetaResponse).annotate({ + "description": "The response that was incomplete.\n" + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number of this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "An event that is emitted when a response finishes as incomplete.\n", + "identifier": "BetaResponseIncompleteEvent" +}) +export type BetaResponseQueuedEvent = { + readonly "agent"?: BetaAgentTag | null + readonly "type": "response.queued" + readonly "response": BetaResponse + readonly "sequence_number": number +} +export const BetaResponseQueuedEvent = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([BetaAgentTag, Schema.Null]).annotate({ + "description": "The agent that owns this multi-agent streaming event." + }) ), - "method": Schema.optionalKey(FineTuneMethod), - "metadata": Schema.optionalKey(Metadata) + "type": Schema.Literal("response.queued").annotate({ + "description": "The type of the event. Always 'response.queued'." + }), + "response": Schema.suspend((): Schema.Codec => BetaResponse).annotate({ + "description": "The full response object that is queued." + }), + "sequence_number": Schema.Number.annotate({ "description": "The sequence number for this event." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "title": "ResponseQueuedEvent", + "description": "Emitted when a response is queued and waiting to be processed.\n", + "identifier": "BetaResponseQueuedEvent" }) export type FineTuningJob = { readonly "id": string @@ -28542,7 +33731,7 @@ export const FineTuningJob = Schema.Struct({ "created_at": Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) for when the fine-tuning job was created.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), "error": Schema.Union([ Schema.Struct({ "code": Schema.String.annotate({ "description": "A machine-readable error code." }), @@ -28572,7 +33761,7 @@ export const FineTuningJob = Schema.Struct({ "description": "The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null ]), "hyperparameters": Schema.Struct({ @@ -28580,9 +33769,9 @@ export const FineTuningJob = Schema.Struct({ Schema.Union([ Schema.Union([ Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check( - Schema.isLessThanOrEqualTo(256) - ) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(256).annotate({ "expected": "a value less than or equal to 256" })) ], { mode: "oneOf" }).annotate({ "description": "Number of examples in each batch. A larger batch size means that model parameters\nare updated less frequently, but with lower variance.\n" @@ -28591,9 +33780,12 @@ export const FineTuningJob = Schema.Struct({ ]) ), "learning_rate_multiplier": Schema.optionalKey( - Schema.Union([Schema.Literal("auto"), Schema.Number.check(Schema.isFinite()).check(Schema.isGreaterThan(0))], { - mode: "oneOf" - }).annotate({ + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ) + ], { mode: "oneOf" }).annotate({ "description": "Scaling factor for the learning rate. A smaller learning rate may be useful to avoid\noverfitting.\n" }) @@ -28601,9 +33793,9 @@ export const FineTuningJob = Schema.Struct({ "n_epochs": Schema.optionalKey( Schema.Union([ Schema.Literal("auto"), - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(1)).check( - Schema.isLessThanOrEqualTo(50) - ) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(50).annotate({ "expected": "a value less than or equal to 50" })) ], { mode: "oneOf" }).annotate({ "description": "The number of epochs to train the model for. An epoch refers to one full cycle\nthrough the training dataset.\n" @@ -28630,7 +33822,7 @@ export const FineTuningJob = Schema.Struct({ Schema.Number.annotate({ "description": "The total number of billable tokens processed by this fine-tuning job. The value will be null if the fine-tuning job is still running." - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null ]), "training_file": Schema.String.annotate({ @@ -28648,18 +33840,20 @@ export const FineTuningJob = Schema.Struct({ Schema.Union([ Schema.Array(Schema.Union([FineTuningIntegration], { mode: "oneOf" })).annotate({ "description": "A list of integrations to enable for this fine-tuning job." - }).check(Schema.isMaxLength(5)), + }).check(Schema.isMaxLength(5).annotate({ "expected": "a value with a length of at most 5" })), Schema.Null ]) ), - "seed": Schema.Number.annotate({ "description": "The seed used for the fine-tuning job." }).check(Schema.isInt()), + "seed": Schema.Number.annotate({ "description": "The seed used for the fine-tuning job." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), "estimated_finish": Schema.optionalKey( Schema.Union([ Schema.Number.annotate({ "description": "The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running.", "format": "unixtime" - }).check(Schema.isInt()), + }).check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null ]) ), @@ -28667,8 +33861,381 @@ export const FineTuningJob = Schema.Struct({ "metadata": Schema.optionalKey(Metadata) }).annotate({ "title": "FineTuningJob", - "description": "The `fine_tuning.job` object represents a fine-tuning job that has been created through the API.\n" + "description": "The `fine_tuning.job` object represents a fine-tuning job that has been created through the API.\n", + "identifier": "FineTuningJob" }) +export type CreateFineTuningJobRequest = { + readonly "model": string | "babbage-002" | "davinci-002" | "gpt-3.5-turbo" | "gpt-4o-mini" + readonly "training_file": string + readonly "hyperparameters"?: { + readonly "batch_size"?: "auto" | number + readonly "learning_rate_multiplier"?: "auto" | number + readonly "n_epochs"?: "auto" | number + } + readonly "suffix"?: string | null + readonly "validation_file"?: string | null + readonly "integrations"?: + | ReadonlyArray< + { + readonly "type": "wandb" + readonly "wandb": { + readonly "project": string + readonly "name"?: string | null + readonly "entity"?: string | null + readonly "tags"?: ReadonlyArray + } + } + > + | null + readonly "seed"?: number | null + readonly "method"?: FineTuneMethod + readonly "metadata"?: Metadata +} +export const CreateFineTuningJobRequest = Schema.Struct({ + "model": Schema.Union([ + Schema.String, + Schema.Literals(["babbage-002", "davinci-002", "gpt-3.5-turbo", "gpt-4o-mini"]) + ]).annotate({ + "description": + "The name of the model to fine-tune. You can select one of the\n[supported models](/docs/guides/fine-tuning#which-models-can-be-fine-tuned).\n" + }), + "training_file": Schema.String.annotate({ + "description": + "The ID of an uploaded file that contains training data.\n\nSee [upload file](/docs/api-reference/files/create) for how to upload a file.\n\nYour dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`.\n\nThe contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input), [completions](/docs/api-reference/fine-tuning/completions-input) format, or if the fine-tuning method uses the [preference](/docs/api-reference/fine-tuning/preference-input) format.\n\nSee the [fine-tuning guide](/docs/guides/model-optimization) for more details.\n" + }), + "hyperparameters": Schema.optionalKey( + Schema.Struct({ + "batch_size": Schema.optionalKey( + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(256).annotate({ "expected": "a value less than or equal to 256" })) + ], { mode: "oneOf" }).annotate({ + "description": + "Number of examples in each batch. A larger batch size means that model parameters\nare updated less frequently, but with lower variance.\n" + }) + ), + "learning_rate_multiplier": Schema.optionalKey( + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThan(0).annotate({ "expected": "a value greater than 0" }) + ) + ], { mode: "oneOf" }).annotate({ + "description": + "Scaling factor for the learning rate. A smaller learning rate may be useful to avoid\noverfitting.\n" + }) + ), + "n_epochs": Schema.optionalKey( + Schema.Union([ + Schema.Literal("auto"), + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(50).annotate({ "expected": "a value less than or equal to 50" })) + ], { mode: "oneOf" }).annotate({ + "description": + "The number of epochs to train the model for. An epoch refers to one full cycle\nthrough the training dataset.\n" + }) + ) + }).annotate({ + "description": + "The hyperparameters used for the fine-tuning job.\nThis value is now deprecated in favor of `method`, and should be passed in under the `method` parameter.\n" + }) + ), + "suffix": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ), + Schema.Null + ]).annotate({ + "description": + "A string of up to 64 characters that will be added to your fine-tuned model name.\n\nFor example, a `suffix` of \"custom-model-name\" would produce a model name like `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`.\n" + }) + ), + "validation_file": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "The ID of an uploaded file that contains validation data.\n\nIf you provide this file, the data is used to generate validation\nmetrics periodically during fine-tuning. These metrics can be viewed in\nthe fine-tuning results file.\nThe same data should not be present in both train and validation files.\n\nYour dataset must be formatted as a JSONL file. You must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/model-optimization) for more details.\n" + }) + ), + "integrations": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.Struct({ + "type": Schema.Literal("wandb").annotate({ + "description": + "The type of integration to enable. Currently, only \"wandb\" (Weights and Biases) is supported.\n" + }), + "wandb": Schema.Struct({ + "project": Schema.String.annotate({ + "description": "The name of the project that the new run will be created under.\n" + }), + "name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "A display name to set for the run. If not set, we will use the Job ID as the name.\n" + }) + ), + "entity": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "The entity to use for the run. This allows you to set the team or username of the WandB user that you would\nlike associated with the run. If not set, the default entity for the registered WandB API key is used.\n" + }) + ), + "tags": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some\ndefault tags are generated by OpenAI: \"openai/finetune\", \"openai/{base-model}\", \"openai/{ftjob-abcdef}\".\n" + }) + ) + }).annotate({ + "description": + "The settings for your integration with Weights and Biases. This payload specifies the project that\nmetrics will be sent to. Optionally, you can set an explicit display name for your run, add tags\nto your run, and set a default entity (team, username, etc) to be associated with your run.\n" + }) + })), + Schema.Null + ]).annotate({ "description": "A list of integrations to enable for your fine-tuning job." }) + ), + "seed": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check( + Schema.isLessThanOrEqualTo(2147483647).annotate({ "expected": "a value less than or equal to 2147483647" }) + ), + Schema.Null + ]).annotate({ + "description": + "The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases.\nIf a seed is not specified, one will be generated for you.\n" + }) + ), + "method": Schema.optionalKey(FineTuneMethod), + "metadata": Schema.optionalKey(Metadata) +}).annotate({ "identifier": "CreateFineTuningJobRequest" }) +export type ResponseStreamEvent = + | ResponseAudioDeltaEvent + | ResponseAudioDoneEvent + | ResponseAudioTranscriptDeltaEvent + | ResponseAudioTranscriptDoneEvent + | ResponseCodeInterpreterCallCodeDeltaEvent + | ResponseCodeInterpreterCallCodeDoneEvent + | ResponseCodeInterpreterCallCompletedEvent + | ResponseCodeInterpreterCallInProgressEvent + | ResponseCodeInterpreterCallInterpretingEvent + | ResponseCompletedEvent + | ResponseContentPartAddedEvent + | ResponseContentPartDoneEvent + | ResponseCreatedEvent + | ResponseErrorEvent + | ResponseFileSearchCallCompletedEvent + | ResponseFileSearchCallInProgressEvent + | ResponseFileSearchCallSearchingEvent + | ResponseFunctionCallArgumentsDeltaEvent + | ResponseFunctionCallArgumentsDoneEvent + | ResponseInProgressEvent + | ResponseFailedEvent + | ResponseIncompleteEvent + | ResponseOutputItemAddedEvent + | ResponseOutputItemDoneEvent + | ResponseReasoningSummaryPartAddedEvent + | ResponseReasoningSummaryPartDoneEvent + | ResponseReasoningSummaryTextDeltaEvent + | ResponseReasoningSummaryTextDoneEvent + | ResponseReasoningTextDeltaEvent + | ResponseReasoningTextDoneEvent + | ResponseRefusalDeltaEvent + | ResponseRefusalDoneEvent + | ResponseTextDeltaEvent + | ResponseTextDoneEvent + | ResponseWebSearchCallCompletedEvent + | ResponseWebSearchCallInProgressEvent + | ResponseWebSearchCallSearchingEvent + | ResponseImageGenCallCompletedEvent + | ResponseImageGenCallGeneratingEvent + | ResponseImageGenCallInProgressEvent + | ResponseImageGenCallPartialImageEvent + | ResponseMCPCallArgumentsDeltaEvent + | ResponseMCPCallArgumentsDoneEvent + | ResponseMCPCallCompletedEvent + | ResponseMCPCallFailedEvent + | ResponseMCPCallInProgressEvent + | ResponseMCPListToolsCompletedEvent + | ResponseMCPListToolsFailedEvent + | ResponseMCPListToolsInProgressEvent + | ResponseOutputTextAnnotationAddedEvent + | ResponseQueuedEvent + | ResponseCustomToolCallInputDeltaEvent + | ResponseCustomToolCallInputDoneEvent + | ResponseKeepAliveEvent + | ResponseApplyPatchCallOperationDiffDeltaEvent + | ResponseApplyPatchCallOperationDiffDoneEvent +export const ResponseStreamEvent = Schema.Union([ + ResponseAudioDeltaEvent, + ResponseAudioDoneEvent, + ResponseAudioTranscriptDeltaEvent, + ResponseAudioTranscriptDoneEvent, + ResponseCodeInterpreterCallCodeDeltaEvent, + ResponseCodeInterpreterCallCodeDoneEvent, + ResponseCodeInterpreterCallCompletedEvent, + ResponseCodeInterpreterCallInProgressEvent, + ResponseCodeInterpreterCallInterpretingEvent, + ResponseCompletedEvent, + ResponseContentPartAddedEvent, + ResponseContentPartDoneEvent, + ResponseCreatedEvent, + ResponseErrorEvent, + ResponseFileSearchCallCompletedEvent, + ResponseFileSearchCallInProgressEvent, + ResponseFileSearchCallSearchingEvent, + ResponseFunctionCallArgumentsDeltaEvent, + ResponseFunctionCallArgumentsDoneEvent, + ResponseInProgressEvent, + ResponseFailedEvent, + ResponseIncompleteEvent, + ResponseOutputItemAddedEvent, + ResponseOutputItemDoneEvent, + ResponseReasoningSummaryPartAddedEvent, + ResponseReasoningSummaryPartDoneEvent, + ResponseReasoningSummaryTextDeltaEvent, + ResponseReasoningSummaryTextDoneEvent, + ResponseReasoningTextDeltaEvent, + ResponseReasoningTextDoneEvent, + ResponseRefusalDeltaEvent, + ResponseRefusalDoneEvent, + ResponseTextDeltaEvent, + ResponseTextDoneEvent, + ResponseWebSearchCallCompletedEvent, + ResponseWebSearchCallInProgressEvent, + ResponseWebSearchCallSearchingEvent, + ResponseImageGenCallCompletedEvent, + ResponseImageGenCallGeneratingEvent, + ResponseImageGenCallInProgressEvent, + ResponseImageGenCallPartialImageEvent, + ResponseMCPCallArgumentsDeltaEvent, + ResponseMCPCallArgumentsDoneEvent, + ResponseMCPCallCompletedEvent, + ResponseMCPCallFailedEvent, + ResponseMCPCallInProgressEvent, + ResponseMCPListToolsCompletedEvent, + ResponseMCPListToolsFailedEvent, + ResponseMCPListToolsInProgressEvent, + ResponseOutputTextAnnotationAddedEvent, + ResponseQueuedEvent, + ResponseCustomToolCallInputDeltaEvent, + ResponseCustomToolCallInputDoneEvent, + ResponseKeepAliveEvent, + ResponseApplyPatchCallOperationDiffDeltaEvent, + ResponseApplyPatchCallOperationDiffDoneEvent +]).annotate({ "identifier": "ResponseStreamEvent" }) +export type BetaResponseStreamEvent = + | BetaResponseAudioDeltaEvent + | BetaResponseAudioDoneEvent + | BetaResponseAudioTranscriptDeltaEvent + | BetaResponseAudioTranscriptDoneEvent + | BetaResponseCodeInterpreterCallCodeDeltaEvent + | BetaResponseCodeInterpreterCallCodeDoneEvent + | BetaResponseCodeInterpreterCallCompletedEvent + | BetaResponseCodeInterpreterCallInProgressEvent + | BetaResponseCodeInterpreterCallInterpretingEvent + | BetaResponseCompletedEvent + | BetaResponseContentPartAddedEvent + | BetaResponseContentPartDoneEvent + | BetaResponseCreatedEvent + | BetaResponseErrorEvent + | BetaResponseFileSearchCallCompletedEvent + | BetaResponseFileSearchCallInProgressEvent + | BetaResponseFileSearchCallSearchingEvent + | BetaResponseFunctionCallArgumentsDeltaEvent + | BetaResponseFunctionCallArgumentsDoneEvent + | BetaResponseInProgressEvent + | BetaResponseFailedEvent + | BetaResponseIncompleteEvent + | BetaResponseOutputItemAddedEvent + | BetaResponseOutputItemDoneEvent + | BetaResponseReasoningSummaryPartAddedEvent + | BetaResponseReasoningSummaryPartDoneEvent + | BetaResponseReasoningSummaryTextDeltaEvent + | BetaResponseReasoningSummaryTextDoneEvent + | BetaResponseReasoningTextDeltaEvent + | BetaResponseReasoningTextDoneEvent + | BetaResponseRefusalDeltaEvent + | BetaResponseRefusalDoneEvent + | BetaResponseTextDeltaEvent + | BetaResponseTextDoneEvent + | BetaResponseWebSearchCallCompletedEvent + | BetaResponseWebSearchCallInProgressEvent + | BetaResponseWebSearchCallSearchingEvent + | BetaResponseImageGenCallCompletedEvent + | BetaResponseImageGenCallGeneratingEvent + | BetaResponseImageGenCallInProgressEvent + | BetaResponseImageGenCallPartialImageEvent + | BetaResponseMCPCallArgumentsDeltaEvent + | BetaResponseMCPCallArgumentsDoneEvent + | BetaResponseMCPCallCompletedEvent + | BetaResponseMCPCallFailedEvent + | BetaResponseMCPCallInProgressEvent + | BetaResponseMCPListToolsCompletedEvent + | BetaResponseMCPListToolsFailedEvent + | BetaResponseMCPListToolsInProgressEvent + | BetaResponseOutputTextAnnotationAddedEvent + | BetaResponseQueuedEvent + | BetaResponseCustomToolCallInputDeltaEvent + | BetaResponseCustomToolCallInputDoneEvent +export const BetaResponseStreamEvent = Schema.Union([ + BetaResponseAudioDeltaEvent, + BetaResponseAudioDoneEvent, + BetaResponseAudioTranscriptDeltaEvent, + BetaResponseAudioTranscriptDoneEvent, + BetaResponseCodeInterpreterCallCodeDeltaEvent, + BetaResponseCodeInterpreterCallCodeDoneEvent, + BetaResponseCodeInterpreterCallCompletedEvent, + BetaResponseCodeInterpreterCallInProgressEvent, + BetaResponseCodeInterpreterCallInterpretingEvent, + BetaResponseCompletedEvent, + BetaResponseContentPartAddedEvent, + BetaResponseContentPartDoneEvent, + BetaResponseCreatedEvent, + BetaResponseErrorEvent, + BetaResponseFileSearchCallCompletedEvent, + BetaResponseFileSearchCallInProgressEvent, + BetaResponseFileSearchCallSearchingEvent, + BetaResponseFunctionCallArgumentsDeltaEvent, + BetaResponseFunctionCallArgumentsDoneEvent, + BetaResponseInProgressEvent, + BetaResponseFailedEvent, + BetaResponseIncompleteEvent, + BetaResponseOutputItemAddedEvent, + BetaResponseOutputItemDoneEvent, + BetaResponseReasoningSummaryPartAddedEvent, + BetaResponseReasoningSummaryPartDoneEvent, + BetaResponseReasoningSummaryTextDeltaEvent, + BetaResponseReasoningSummaryTextDoneEvent, + BetaResponseReasoningTextDeltaEvent, + BetaResponseReasoningTextDoneEvent, + BetaResponseRefusalDeltaEvent, + BetaResponseRefusalDoneEvent, + BetaResponseTextDeltaEvent, + BetaResponseTextDoneEvent, + BetaResponseWebSearchCallCompletedEvent, + BetaResponseWebSearchCallInProgressEvent, + BetaResponseWebSearchCallSearchingEvent, + BetaResponseImageGenCallCompletedEvent, + BetaResponseImageGenCallGeneratingEvent, + BetaResponseImageGenCallInProgressEvent, + BetaResponseImageGenCallPartialImageEvent, + BetaResponseMCPCallArgumentsDeltaEvent, + BetaResponseMCPCallArgumentsDoneEvent, + BetaResponseMCPCallCompletedEvent, + BetaResponseMCPCallFailedEvent, + BetaResponseMCPCallInProgressEvent, + BetaResponseMCPListToolsCompletedEvent, + BetaResponseMCPListToolsFailedEvent, + BetaResponseMCPListToolsInProgressEvent, + BetaResponseOutputTextAnnotationAddedEvent, + BetaResponseQueuedEvent, + BetaResponseCustomToolCallInputDeltaEvent, + BetaResponseCustomToolCallInputDoneEvent +]).annotate({ "identifier": "BetaResponseStreamEvent" }) export type ListPaginatedFineTuningJobsResponse = { readonly "data": ReadonlyArray readonly "has_more": boolean @@ -28678,7 +34245,7 @@ export const ListPaginatedFineTuningJobsResponse = Schema.Struct({ "data": Schema.Array(FineTuningJob), "has_more": Schema.Boolean, "object": Schema.Literal("list") -}) +}).annotate({ "identifier": "ListPaginatedFineTuningJobsResponse" }) // schemas export type ListAssistantsParams = { readonly "limit"?: number @@ -28687,7 +34254,7 @@ export type ListAssistantsParams = { readonly "before"?: string } export const ListAssistantsParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "before": Schema.optionalKey(Schema.String) @@ -28733,7 +34300,7 @@ export const CreateTranslation200 = Schema.Union( export type ListVoiceConsentsParams = { readonly "after"?: string; readonly "limit"?: number } export const ListVoiceConsentsParams = Schema.Struct({ "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())) + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) }) export type ListVoiceConsents200 = VoiceConsentListResource export const ListVoiceConsents200 = VoiceConsentListResource @@ -28756,49 +34323,12 @@ export const CreateVoice200 = VoiceResource export type ListBatchesParams = { readonly "after"?: string; readonly "limit"?: number } export const ListBatchesParams = Schema.Struct({ "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())) + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) }) export type ListBatches200 = ListBatchesResponse export const ListBatches200 = ListBatchesResponse -export type CreateBatchRequestJson = { - readonly "input_file_id": string - readonly "endpoint": - | "/v1/responses" - | "/v1/chat/completions" - | "/v1/embeddings" - | "/v1/completions" - | "/v1/moderations" - | "/v1/images/generations" - | "/v1/images/edits" - | "/v1/videos" - readonly "completion_window": "24h" - readonly "metadata"?: Metadata - readonly "output_expires_after"?: BatchFileExpirationAfter -} -export const CreateBatchRequestJson = Schema.Struct({ - "input_file_id": Schema.String.annotate({ - "description": - "The ID of an uploaded file that contains requests for the new batch.\n\nSee [upload file](/docs/api-reference/files/create) for how to upload a file.\n\nYour input file must be formatted as a [JSONL file](/docs/api-reference/batch/request-input), and must be uploaded with the purpose `batch`. The file can contain up to 50,000 requests, and can be up to 200 MB in size.\n" - }), - "endpoint": Schema.Literals([ - "/v1/responses", - "/v1/chat/completions", - "/v1/embeddings", - "/v1/completions", - "/v1/moderations", - "/v1/images/generations", - "/v1/images/edits", - "/v1/videos" - ]).annotate({ - "description": - "The endpoint to be used for all requests in the batch. Currently `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`, `/v1/moderations`, `/v1/images/generations`, `/v1/images/edits`, and `/v1/videos` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch." - }), - "completion_window": Schema.Literal("24h").annotate({ - "description": "The time frame within which the batch should be processed. Currently only `24h` is supported." - }), - "metadata": Schema.optionalKey(Metadata), - "output_expires_after": Schema.optionalKey(BatchFileExpirationAfter) -}) +export type CreateBatchRequestJson = CreateBatchRequest +export const CreateBatchRequestJson = CreateBatchRequest export type CreateBatch200 = Batch export const CreateBatch200 = Batch export type RetrieveBatch200 = Batch @@ -28816,7 +34346,7 @@ export const ListChatCompletionsParams = Schema.Struct({ "model": Schema.optionalKey(Schema.String), "metadata": Schema.optionalKey(Metadata), "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) }) export type ListChatCompletions200 = ChatCompletionList @@ -28842,7 +34372,7 @@ export type GetChatCompletionMessagesParams = { } export const GetChatCompletionMessagesParams = Schema.Struct({ "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) }) export type GetChatCompletionMessages200 = ChatCompletionMessageList @@ -28858,7 +34388,7 @@ export type ListContainersParams = { readonly "name"?: string } export const ListContainersParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "name": Schema.optionalKey(Schema.String) @@ -28877,7 +34407,7 @@ export type ListContainerFilesParams = { readonly "after"?: string } export const ListContainerFilesParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String) }) @@ -28898,7 +34428,7 @@ export type ListConversationItemsParams = { readonly "include"?: ReadonlyArray } export const ListConversationItemsParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "include": Schema.optionalKey(Schema.Array(IncludeEnum)) @@ -28909,15 +34439,15 @@ export type CreateConversationItemsParams = { readonly "include"?: ReadonlyArray export const CreateConversationItemsParams = Schema.Struct({ "include": Schema.optionalKey(Schema.Array(IncludeEnum)) }) export type CreateConversationItemsRequestJson = { readonly "items": ReadonlyArray - readonly [x: string]: unknown + readonly [x: string]: Schema.Json } export const CreateConversationItemsRequestJson = Schema.StructWithRest( Schema.Struct({ "items": Schema.Array(InputItem).annotate({ "description": "The items to add to the conversation. You may add up to 20 items at a time.\n" - }).check(Schema.isMaxLength(20)) + }).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) }), - [Schema.Record(Schema.String, Schema.Unknown)] + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] ) export type CreateConversationItems200 = ConversationItemList export const CreateConversationItems200 = ConversationItemList @@ -28939,7 +34469,7 @@ export type ListEvalsParams = { } export const ListEvalsParams = Schema.Struct({ "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "order_by": Schema.optionalKey(Schema.Literals(["created_at", "updated_at"])) }) @@ -28974,7 +34504,7 @@ export type GetEvalRunsParams = { } export const GetEvalRunsParams = Schema.Struct({ "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "status": Schema.optionalKey(Schema.Literals(["queued", "in_progress", "completed", "canceled", "failed"])) }) @@ -29006,7 +34536,7 @@ export type GetEvalRunOutputItemsParams = { } export const GetEvalRunOutputItemsParams = Schema.Struct({ "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "status": Schema.optionalKey(Schema.Literals(["fail", "pass"])), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) }) @@ -29022,7 +34552,7 @@ export type ListFilesParams = { } export const ListFilesParams = Schema.Struct({ "purpose": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String) }) @@ -29055,7 +34585,7 @@ export type ListFineTuningCheckpointPermissionsParams = { export const ListFineTuningCheckpointPermissionsParams = Schema.Struct({ "project_id": Schema.optionalKey(Schema.String), "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["ascending", "descending"])) }) export type ListFineTuningCheckpointPermissions200 = ListFineTuningCheckpointPermissionResponse @@ -29069,12 +34599,12 @@ export const DeleteFineTuningCheckpointPermission200 = DeleteFineTuningCheckpoin export type ListPaginatedFineTuningJobsParams = { readonly "after"?: string readonly "limit"?: number - readonly "metadata"?: {} + readonly "metadata"?: { readonly [x: string]: string } | null } export const ListPaginatedFineTuningJobsParams = Schema.Struct({ "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), - "metadata": Schema.optionalKey(Schema.Union([Schema.Struct({})])) + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "metadata": Schema.optionalKey(Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null])) }) export type ListPaginatedFineTuningJobs200 = ListPaginatedFineTuningJobsResponse export const ListPaginatedFineTuningJobs200 = ListPaginatedFineTuningJobsResponse @@ -29089,14 +34619,14 @@ export const CancelFineTuningJob200 = FineTuningJob export type ListFineTuningJobCheckpointsParams = { readonly "after"?: string; readonly "limit"?: number } export const ListFineTuningJobCheckpointsParams = Schema.Struct({ "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())) + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) }) export type ListFineTuningJobCheckpoints200 = ListFineTuningJobCheckpointsResponse export const ListFineTuningJobCheckpoints200 = ListFineTuningJobCheckpointsResponse export type ListFineTuningEventsParams = { readonly "after"?: string; readonly "limit"?: number } export const ListFineTuningEventsParams = Schema.Struct({ "after": Schema.optionalKey(Schema.String), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())) + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) }) export type ListFineTuningEvents200 = ListFineTuningJobEventsResponse export const ListFineTuningEvents200 = ListFineTuningJobEventsResponse @@ -29149,13 +34679,24 @@ export const AdminApiKeysListParams = Schema.Struct({ }) ), "limit": Schema.optionalKey( - Schema.Number.annotate({ "description": "Maximum number of keys to return." }).check(Schema.isInt()) + Schema.Number.annotate({ "description": "Maximum number of keys to return." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ) }) export type AdminApiKeysList200 = ApiKeyList export const AdminApiKeysList200 = ApiKeyList -export type AdminApiKeysCreateRequestJson = { readonly "name": string } -export const AdminApiKeysCreateRequestJson = Schema.Struct({ "name": Schema.String }) +export type AdminApiKeysCreateRequestJson = { readonly "name": string; readonly "expires_in_seconds"?: number } +export const AdminApiKeysCreateRequestJson = Schema.Struct({ + "name": Schema.String, + "expires_in_seconds": Schema.optionalKey( + Schema.Number.annotate({ + "description": "The number of seconds until the API key expires. Omit this field for a key that does not expire." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(31536000).annotate({ "expected": "a value less than or equal to 31536000" })) + ) +}) export type AdminApiKeysCreate200 = AdminApiKeyCreateResponse export const AdminApiKeysCreate200 = AdminApiKeyCreateResponse export type AdminApiKeysGet200 = AdminApiKey @@ -29180,6 +34721,7 @@ export type ListAuditLogsParams = { readonly "actor_ids[]"?: ReadonlyArray readonly "actor_emails[]"?: ReadonlyArray readonly "resource_ids[]"?: ReadonlyArray + readonly "tenant_only"?: boolean readonly "limit"?: number readonly "after"?: string readonly "before"?: string @@ -29188,29 +34730,30 @@ export const ListAuditLogsParams = Schema.Struct({ "effective_at[gt]": Schema.optionalKey( Schema.Number.annotate({ "description": "Return only events whose `effective_at` (Unix seconds) is greater than this value." - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "effective_at[gte]": Schema.optionalKey( Schema.Number.annotate({ "description": "Return only events whose `effective_at` (Unix seconds) is greater than or equal to this value." - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "effective_at[lt]": Schema.optionalKey( Schema.Number.annotate({ "description": "Return only events whose `effective_at` (Unix seconds) is less than this value." - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "effective_at[lte]": Schema.optionalKey( Schema.Number.annotate({ "description": "Return only events whose `effective_at` (Unix seconds) is less than or equal to this value." - }).check(Schema.isInt()) + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "project_ids[]": Schema.optionalKey(Schema.Array(Schema.String)), "event_types[]": Schema.optionalKey(Schema.Array(AuditLogEventType)), "actor_ids[]": Schema.optionalKey(Schema.Array(Schema.String)), "actor_emails[]": Schema.optionalKey(Schema.Array(Schema.String)), "resource_ids[]": Schema.optionalKey(Schema.Array(Schema.String)), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "tenant_only": Schema.optionalKey(Schema.Boolean), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "after": Schema.optionalKey(Schema.String), "before": Schema.optionalKey(Schema.String) }) @@ -29222,7 +34765,7 @@ export type ListOrganizationCertificatesParams = { readonly "order"?: "asc" | "desc" } export const ListOrganizationCertificatesParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) }) @@ -29263,17 +34806,23 @@ export type UsageCostsParams = { readonly "page"?: string } export const UsageCostsParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literal("1d")), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "api_key_ids": Schema.optionalKey(Schema.Array(Schema.String)), "group_by": Schema.optionalKey(Schema.Array(Schema.Literals(["project_id", "line_item", "api_key_id"]))), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageCosts200 = UsageResponse export const UsageCosts200 = UsageResponse +export type RetrieveOrganizationDataRetention200 = OrganizationDataRetention +export const RetrieveOrganizationDataRetention200 = OrganizationDataRetention +export type UpdateOrganizationDataRetentionRequestJson = UpdateOrganizationDataRetentionBody +export const UpdateOrganizationDataRetentionRequestJson = UpdateOrganizationDataRetentionBody +export type UpdateOrganizationDataRetention200 = OrganizationDataRetention +export const UpdateOrganizationDataRetention200 = OrganizationDataRetention export type ListGroupsParams = { readonly "limit"?: number readonly "after"?: string @@ -29281,7 +34830,9 @@ export type ListGroupsParams = { } export const ListGroupsParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1000)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) ), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) @@ -29292,6 +34843,8 @@ export type CreateGroupRequestJson = CreateGroupBody export const CreateGroupRequestJson = CreateGroupBody export type CreateGroup200 = GroupResponse export const CreateGroup200 = GroupResponse +export type RetrieveGroup200 = GroupResponse +export const RetrieveGroup200 = GroupResponse export type UpdateGroupRequestJson = UpdateGroupBody export const UpdateGroupRequestJson = UpdateGroupBody export type UpdateGroup200 = GroupResourceWithSuccess @@ -29305,7 +34858,9 @@ export type ListGroupRoleAssignmentsParams = { } export const ListGroupRoleAssignmentsParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1000)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) ), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) @@ -29316,6 +34871,8 @@ export type AssignGroupRoleRequestJson = PublicAssignOrganizationGroupRoleBody export const AssignGroupRoleRequestJson = PublicAssignOrganizationGroupRoleBody export type AssignGroupRole200 = GroupRoleAssignment export const AssignGroupRole200 = GroupRoleAssignment +export type RetrieveGroupRole200 = AssignedRoleDetails +export const RetrieveGroupRole200 = AssignedRoleDetails export type UnassignGroupRole200 = DeletedRoleAssignmentResource export const UnassignGroupRole200 = DeletedRoleAssignmentResource export type ListGroupUsersParams = { @@ -29325,7 +34882,9 @@ export type ListGroupUsersParams = { } export const ListGroupUsersParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1000)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) ), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) @@ -29336,11 +34895,13 @@ export type AddGroupUserRequestJson = CreateGroupUserBody export const AddGroupUserRequestJson = CreateGroupUserBody export type AddGroupUser200 = GroupUserAssignment export const AddGroupUser200 = GroupUserAssignment +export type RetrieveGroupUser200 = GroupMemberUser +export const RetrieveGroupUser200 = GroupMemberUser export type RemoveGroupUser200 = GroupUserDeletedResource export const RemoveGroupUser200 = GroupUserDeletedResource export type ListInvitesParams = { readonly "limit"?: number; readonly "after"?: string } export const ListInvitesParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "after": Schema.optionalKey(Schema.String) }) export type ListInvites200 = InviteListResponse @@ -29359,7 +34920,7 @@ export type ListProjectsParams = { readonly "include_archived"?: boolean } export const ListProjectsParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "after": Schema.optionalKey(Schema.String), "include_archived": Schema.optionalKey(Schema.Boolean) }) @@ -29377,10 +34938,15 @@ export type ModifyProject200 = Project export const ModifyProject200 = Project export type ModifyProject400 = ErrorResponse export const ModifyProject400 = ErrorResponse -export type ListProjectApiKeysParams = { readonly "limit"?: number; readonly "after"?: string } +export type ListProjectApiKeysParams = { + readonly "limit"?: number + readonly "after"?: string + readonly "owner_project_access"?: "active" | "inactive" | "any" +} export const ListProjectApiKeysParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), - "after": Schema.optionalKey(Schema.String) + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "after": Schema.optionalKey(Schema.String), + "owner_project_access": Schema.optionalKey(Schema.Literals(["active", "inactive", "any"])) }) export type ListProjectApiKeys200 = ProjectApiKeyListResponse export const ListProjectApiKeys200 = ProjectApiKeyListResponse @@ -29398,7 +34964,7 @@ export type ListProjectCertificatesParams = { readonly "order"?: "asc" | "desc" } export const ListProjectCertificatesParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) }) @@ -29412,6 +34978,12 @@ export type DeactivateProjectCertificatesRequestJson = ToggleCertificatesRequest export const DeactivateProjectCertificatesRequestJson = ToggleCertificatesRequest export type DeactivateProjectCertificates200 = OrganizationProjectCertificateDeactivationResponse export const DeactivateProjectCertificates200 = OrganizationProjectCertificateDeactivationResponse +export type RetrieveProjectDataRetention200 = ProjectDataRetention +export const RetrieveProjectDataRetention200 = ProjectDataRetention +export type UpdateProjectDataRetentionRequestJson = UpdateProjectDataRetentionBody +export const UpdateProjectDataRetentionRequestJson = UpdateProjectDataRetentionBody +export type UpdateProjectDataRetention200 = ProjectDataRetention +export const UpdateProjectDataRetention200 = ProjectDataRetention export type ListProjectGroupsParams = { readonly "limit"?: number readonly "after"?: string @@ -29419,7 +34991,9 @@ export type ListProjectGroupsParams = { } export const ListProjectGroupsParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(100)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" })) ), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) @@ -29430,6 +35004,12 @@ export type AddProjectGroupRequestJson = InviteProjectGroupBody export const AddProjectGroupRequestJson = InviteProjectGroupBody export type AddProjectGroup200 = ProjectGroup export const AddProjectGroup200 = ProjectGroup +export type RetrieveProjectGroupParams = { readonly "group_type"?: "group" | "tenant_group" } +export const RetrieveProjectGroupParams = Schema.Struct({ + "group_type": Schema.optionalKey(Schema.Literals(["group", "tenant_group"])) +}) +export type RetrieveProjectGroup200 = ProjectGroup +export const RetrieveProjectGroup200 = ProjectGroup export type RemoveProjectGroup200 = ProjectGroupDeletedResource export const RemoveProjectGroup200 = ProjectGroupDeletedResource export type RetrieveProjectHostedToolPermissions200 = ProjectHostedToolPermissions @@ -29452,7 +35032,7 @@ export type ListProjectRateLimitsParams = { readonly "before"?: string } export const ListProjectRateLimitsParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "after": Schema.optionalKey(Schema.String), "before": Schema.optionalKey(Schema.String) }) @@ -29466,7 +35046,7 @@ export type UpdateProjectRateLimits400 = ErrorResponse export const UpdateProjectRateLimits400 = ErrorResponse export type ListProjectServiceAccountsParams = { readonly "limit"?: number; readonly "after"?: string } export const ListProjectServiceAccountsParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "after": Schema.optionalKey(Schema.String) }) export type ListProjectServiceAccounts200 = ProjectServiceAccountListResponse @@ -29481,11 +35061,45 @@ export type CreateProjectServiceAccount400 = ErrorResponse export const CreateProjectServiceAccount400 = ErrorResponse export type RetrieveProjectServiceAccount200 = ProjectServiceAccount export const RetrieveProjectServiceAccount200 = ProjectServiceAccount +export type UpdateProjectServiceAccountRequestJson = UpdateProjectServiceAccountBody +export const UpdateProjectServiceAccountRequestJson = UpdateProjectServiceAccountBody +export type UpdateProjectServiceAccount200 = ProjectServiceAccount +export const UpdateProjectServiceAccount200 = ProjectServiceAccount export type DeleteProjectServiceAccount200 = ProjectServiceAccountDeleteResponse export const DeleteProjectServiceAccount200 = ProjectServiceAccountDeleteResponse +export type ListProjectSpendAlertsParams = { + readonly "limit"?: number + readonly "order"?: "asc" | "desc" + readonly "after"?: string + readonly "before"?: string +} +export const ListProjectSpendAlertsParams = Schema.Struct({ + "limit": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" })) + ), + "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), + "after": Schema.optionalKey(Schema.String), + "before": Schema.optionalKey(Schema.String) +}) +export type ListProjectSpendAlerts200 = ProjectSpendAlertListResource +export const ListProjectSpendAlerts200 = ProjectSpendAlertListResource +export type CreateProjectSpendAlertRequestJson = CreateSpendAlertBody +export const CreateProjectSpendAlertRequestJson = CreateSpendAlertBody +export type CreateProjectSpendAlert200 = ProjectSpendAlert +export const CreateProjectSpendAlert200 = ProjectSpendAlert +export type RetrieveProjectSpendAlert200 = ProjectSpendAlert +export const RetrieveProjectSpendAlert200 = ProjectSpendAlert +export type UpdateProjectSpendAlertRequestJson = CreateSpendAlertBody +export const UpdateProjectSpendAlertRequestJson = CreateSpendAlertBody +export type UpdateProjectSpendAlert200 = ProjectSpendAlert +export const UpdateProjectSpendAlert200 = ProjectSpendAlert +export type DeleteProjectSpendAlert200 = ProjectSpendAlertDeletedResource +export const DeleteProjectSpendAlert200 = ProjectSpendAlertDeletedResource export type ListProjectUsersParams = { readonly "limit"?: number; readonly "after"?: string } export const ListProjectUsersParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "after": Schema.optionalKey(Schema.String) }) export type ListProjectUsers200 = ProjectUserListResponse @@ -29517,7 +35131,9 @@ export type ListRolesParams = { } export const ListRolesParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1000)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) ), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) @@ -29528,12 +35144,44 @@ export type CreateRoleRequestJson = PublicCreateOrganizationRoleBody export const CreateRoleRequestJson = PublicCreateOrganizationRoleBody export type CreateRole200 = Role export const CreateRole200 = Role +export type RetrieveRole200 = Role +export const RetrieveRole200 = Role export type UpdateRoleRequestJson = PublicUpdateOrganizationRoleBody export const UpdateRoleRequestJson = PublicUpdateOrganizationRoleBody export type UpdateRole200 = Role export const UpdateRole200 = Role export type DeleteRole200 = RoleDeletedResource export const DeleteRole200 = RoleDeletedResource +export type ListOrganizationSpendAlertsParams = { + readonly "limit"?: number + readonly "order"?: "asc" | "desc" + readonly "after"?: string + readonly "before"?: string +} +export const ListOrganizationSpendAlertsParams = Schema.Struct({ + "limit": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" })) + ), + "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), + "after": Schema.optionalKey(Schema.String), + "before": Schema.optionalKey(Schema.String) +}) +export type ListOrganizationSpendAlerts200 = OrganizationSpendAlertListResource +export const ListOrganizationSpendAlerts200 = OrganizationSpendAlertListResource +export type CreateOrganizationSpendAlertRequestJson = CreateSpendAlertBody +export const CreateOrganizationSpendAlertRequestJson = CreateSpendAlertBody +export type CreateOrganizationSpendAlert200 = OrganizationSpendAlert +export const CreateOrganizationSpendAlert200 = OrganizationSpendAlert +export type RetrieveOrganizationSpendAlert200 = OrganizationSpendAlert +export const RetrieveOrganizationSpendAlert200 = OrganizationSpendAlert +export type UpdateOrganizationSpendAlertRequestJson = CreateSpendAlertBody +export const UpdateOrganizationSpendAlertRequestJson = CreateSpendAlertBody +export type UpdateOrganizationSpendAlert200 = OrganizationSpendAlert +export const UpdateOrganizationSpendAlert200 = OrganizationSpendAlert +export type DeleteOrganizationSpendAlert200 = OrganizationSpendAlertDeletedResource +export const DeleteOrganizationSpendAlert200 = OrganizationSpendAlertDeletedResource export type UsageAudioSpeechesParams = { readonly "start_time": number readonly "end_time"?: number @@ -29547,15 +35195,15 @@ export type UsageAudioSpeechesParams = { readonly "page"?: string } export const UsageAudioSpeechesParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "user_ids": Schema.optionalKey(Schema.Array(Schema.String)), "api_key_ids": Schema.optionalKey(Schema.Array(Schema.String)), "models": Schema.optionalKey(Schema.Array(Schema.String)), "group_by": Schema.optionalKey(Schema.Array(Schema.Literals(["project_id", "user_id", "api_key_id", "model"]))), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageAudioSpeeches200 = UsageResponse @@ -29573,15 +35221,15 @@ export type UsageAudioTranscriptionsParams = { readonly "page"?: string } export const UsageAudioTranscriptionsParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "user_ids": Schema.optionalKey(Schema.Array(Schema.String)), "api_key_ids": Schema.optionalKey(Schema.Array(Schema.String)), "models": Schema.optionalKey(Schema.Array(Schema.String)), "group_by": Schema.optionalKey(Schema.Array(Schema.Literals(["project_id", "user_id", "api_key_id", "model"]))), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageAudioTranscriptions200 = UsageResponse @@ -29596,12 +35244,12 @@ export type UsageCodeInterpreterSessionsParams = { readonly "page"?: string } export const UsageCodeInterpreterSessionsParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "group_by": Schema.optionalKey(Schema.Array(Schema.Literal("project_id"))), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageCodeInterpreterSessions200 = UsageResponse @@ -29620,8 +35268,8 @@ export type UsageCompletionsParams = { readonly "page"?: string } export const UsageCompletionsParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "user_ids": Schema.optionalKey(Schema.Array(Schema.String)), @@ -29631,7 +35279,7 @@ export const UsageCompletionsParams = Schema.Struct({ "group_by": Schema.optionalKey( Schema.Array(Schema.Literals(["project_id", "user_id", "api_key_id", "model", "batch", "service_tier"])) ), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageCompletions200 = UsageResponse @@ -29649,15 +35297,15 @@ export type UsageEmbeddingsParams = { readonly "page"?: string } export const UsageEmbeddingsParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "user_ids": Schema.optionalKey(Schema.Array(Schema.String)), "api_key_ids": Schema.optionalKey(Schema.Array(Schema.String)), "models": Schema.optionalKey(Schema.Array(Schema.String)), "group_by": Schema.optionalKey(Schema.Array(Schema.Literals(["project_id", "user_id", "api_key_id", "model"]))), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageEmbeddings200 = UsageResponse @@ -29675,8 +35323,8 @@ export type UsageFileSearchCallsParams = { readonly "page"?: string } export const UsageFileSearchCallsParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "user_ids": Schema.optionalKey(Schema.Array(Schema.String)), @@ -29685,7 +35333,7 @@ export const UsageFileSearchCallsParams = Schema.Struct({ "group_by": Schema.optionalKey( Schema.Array(Schema.Literals(["project_id", "user_id", "api_key_id", "vector_store_id"])) ), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageFileSearchCalls200 = UsageResponse @@ -29705,8 +35353,8 @@ export type UsageImagesParams = { readonly "page"?: string } export const UsageImagesParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "sources": Schema.optionalKey(Schema.Array(Schema.Literals(["image.generation", "image.edit", "image.variation"]))), "sizes": Schema.optionalKey( @@ -29719,7 +35367,7 @@ export const UsageImagesParams = Schema.Struct({ "group_by": Schema.optionalKey( Schema.Array(Schema.Literals(["project_id", "user_id", "api_key_id", "model", "size", "source"])) ), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageImages200 = UsageResponse @@ -29737,15 +35385,15 @@ export type UsageModerationsParams = { readonly "page"?: string } export const UsageModerationsParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "user_ids": Schema.optionalKey(Schema.Array(Schema.String)), "api_key_ids": Schema.optionalKey(Schema.Array(Schema.String)), "models": Schema.optionalKey(Schema.Array(Schema.String)), "group_by": Schema.optionalKey(Schema.Array(Schema.Literals(["project_id", "user_id", "api_key_id", "model"]))), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageModerations200 = UsageResponse @@ -29760,12 +35408,12 @@ export type UsageVectorStoresParams = { readonly "page"?: string } export const UsageVectorStoresParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "group_by": Schema.optionalKey(Schema.Array(Schema.Literal("project_id"))), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageVectorStores200 = UsageResponse @@ -29784,8 +35432,8 @@ export type UsageWebSearchCallsParams = { readonly "page"?: string } export const UsageWebSearchCallsParams = Schema.Struct({ - "start_time": Schema.Number.check(Schema.isInt()), - "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "start_time": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "end_time": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "bucket_width": Schema.optionalKey(Schema.Literals(["1m", "1h", "1d"])), "project_ids": Schema.optionalKey(Schema.Array(Schema.String)), "user_ids": Schema.optionalKey(Schema.Array(Schema.String)), @@ -29795,7 +35443,7 @@ export const UsageWebSearchCallsParams = Schema.Struct({ "group_by": Schema.optionalKey( Schema.Array(Schema.Literals(["project_id", "user_id", "api_key_id", "model", "context_level"])) ), - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "page": Schema.optionalKey(Schema.String) }) export type UsageWebSearchCalls200 = UsageResponse @@ -29806,7 +35454,7 @@ export type ListUsersParams = { readonly "emails"?: ReadonlyArray } export const ListUsersParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "after": Schema.optionalKey(Schema.String), "emails": Schema.optionalKey(Schema.Array(Schema.String)) }) @@ -29827,7 +35475,9 @@ export type ListUserRoleAssignmentsParams = { } export const ListUserRoleAssignmentsParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1000)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) ), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) @@ -29838,6 +35488,8 @@ export type AssignUserRoleRequestJson = PublicAssignOrganizationGroupRoleBody export const AssignUserRoleRequestJson = PublicAssignOrganizationGroupRoleBody export type AssignUserRole200 = UserRoleAssignment export const AssignUserRole200 = UserRoleAssignment +export type RetrieveUserRole200 = AssignedRoleDetails +export const RetrieveUserRole200 = AssignedRoleDetails export type UnassignUserRole200 = DeletedRoleAssignmentResource export const UnassignUserRole200 = DeletedRoleAssignmentResource export type ListProjectGroupRoleAssignmentsParams = { @@ -29847,7 +35499,9 @@ export type ListProjectGroupRoleAssignmentsParams = { } export const ListProjectGroupRoleAssignmentsParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1000)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) ), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) @@ -29858,6 +35512,8 @@ export type AssignProjectGroupRoleRequestJson = PublicAssignOrganizationGroupRol export const AssignProjectGroupRoleRequestJson = PublicAssignOrganizationGroupRoleBody export type AssignProjectGroupRole200 = GroupRoleAssignment export const AssignProjectGroupRole200 = GroupRoleAssignment +export type RetrieveProjectGroupRole200 = AssignedRoleDetails +export const RetrieveProjectGroupRole200 = AssignedRoleDetails export type UnassignProjectGroupRole200 = DeletedRoleAssignmentResource export const UnassignProjectGroupRole200 = DeletedRoleAssignmentResource export type ListProjectRolesParams = { @@ -29867,7 +35523,9 @@ export type ListProjectRolesParams = { } export const ListProjectRolesParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1000)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) ), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) @@ -29878,6 +35536,8 @@ export type CreateProjectRoleRequestJson = PublicCreateOrganizationRoleBody export const CreateProjectRoleRequestJson = PublicCreateOrganizationRoleBody export type CreateProjectRole200 = Role export const CreateProjectRole200 = Role +export type RetrieveProjectRole200 = Role +export const RetrieveProjectRole200 = Role export type UpdateProjectRoleRequestJson = PublicUpdateOrganizationRoleBody export const UpdateProjectRoleRequestJson = PublicUpdateOrganizationRoleBody export type UpdateProjectRole200 = Role @@ -29891,7 +35551,9 @@ export type ListProjectUserRoleAssignmentsParams = { } export const ListProjectUserRoleAssignmentsParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(1000)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1000).annotate({ "expected": "a value less than or equal to 1000" })) ), "after": Schema.optionalKey(Schema.String), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])) @@ -29902,6 +35564,8 @@ export type AssignProjectUserRoleRequestJson = PublicAssignOrganizationGroupRole export const AssignProjectUserRoleRequestJson = PublicAssignOrganizationGroupRoleBody export type AssignProjectUserRole200 = UserRoleAssignment export const AssignProjectUserRole200 = UserRoleAssignment +export type RetrieveProjectUserRole200 = AssignedRoleDetails +export const RetrieveProjectUserRole200 = AssignedRoleDetails export type UnassignProjectUserRole200 = DeletedRoleAssignmentResource export const UnassignProjectUserRole200 = DeletedRoleAssignmentResource export type CreateRealtimeCallRequestFormData = RealtimeCallCreateRequest @@ -29943,7 +35607,7 @@ export type GetResponseParams = { export const GetResponseParams = Schema.Struct({ "include": Schema.optionalKey(Schema.Array(IncludeEnum)), "stream": Schema.optionalKey(Schema.Boolean), - "starting_after": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "starting_after": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "include_obfuscation": Schema.optionalKey(Schema.Boolean) }) export type GetResponse200 = Response @@ -29961,7 +35625,7 @@ export type ListInputItemsParams = { readonly "include"?: ReadonlyArray } export const ListInputItemsParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "include": Schema.optionalKey(Schema.Array(IncludeEnum)) @@ -29992,7 +35656,7 @@ export type ListMessagesParams = { readonly "run_id"?: string } export const ListMessagesParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "before": Schema.optionalKey(Schema.String), @@ -30019,7 +35683,7 @@ export type ListRunsParams = { readonly "before"?: string } export const ListRunsParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "before": Schema.optionalKey(Schema.String) @@ -30054,7 +35718,7 @@ export type ListRunStepsParams = { readonly "include[]"?: ReadonlyArray<"step_details.tool_calls[*].file_search.results[*].content"> } export const ListRunStepsParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "before": Schema.optionalKey(Schema.String), @@ -30099,7 +35763,7 @@ export type ListVectorStoresParams = { readonly "before"?: string } export const ListVectorStoresParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "before": Schema.optionalKey(Schema.String) @@ -30134,7 +35798,7 @@ export type ListFilesInVectorStoreBatchParams = { readonly "filter"?: "in_progress" | "completed" | "failed" | "cancelled" } export const ListFilesInVectorStoreBatchParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "before": Schema.optionalKey(Schema.String), @@ -30150,7 +35814,7 @@ export type ListVectorStoreFilesParams = { readonly "filter"?: "in_progress" | "completed" | "failed" | "cancelled" } export const ListVectorStoreFilesParams = Schema.Struct({ - "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt())), + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), "after": Schema.optionalKey(Schema.String), "before": Schema.optionalKey(Schema.String), @@ -30188,10 +35852,36 @@ export type UpdateConversation200 = ConversationResource export const UpdateConversation200 = ConversationResource export type DeleteConversation200 = DeletedConversationResource export const DeleteConversation200 = DeletedConversationResource +export type Getorganizationspendlimit200 = OrganizationSpendLimitResource +export const Getorganizationspendlimit200 = OrganizationSpendLimitResource +export type UpdateorganizationspendlimitRequestJson = UpdateOrganizationSpendLimitBody +export const UpdateorganizationspendlimitRequestJson = UpdateOrganizationSpendLimitBody +export type Updateorganizationspendlimit200 = OrganizationSpendLimitResource +export const Updateorganizationspendlimit200 = OrganizationSpendLimitResource +export type Deleteorganizationspendlimit200 = OrganizationSpendLimitDeletedResource +export const Deleteorganizationspendlimit200 = OrganizationSpendLimitDeletedResource +export type Getprojectspendlimit200 = ProjectSpendLimitResource +export const Getprojectspendlimit200 = ProjectSpendLimitResource +export type UpdateprojectspendlimitRequestJson = UpdateProjectSpendLimitBody +export const UpdateprojectspendlimitRequestJson = UpdateProjectSpendLimitBody +export type Updateprojectspendlimit200 = ProjectSpendLimitResource +export const Updateprojectspendlimit200 = ProjectSpendLimitResource +export type Deleteprojectspendlimit200 = ProjectSpendLimitDeletedResource +export const Deleteprojectspendlimit200 = ProjectSpendLimitDeletedResource +export type CreateanAPIkeyforaserviceaccountRequestJson = CreateProjectServiceAccountApiKeyBody +export const CreateanAPIkeyforaserviceaccountRequestJson = CreateProjectServiceAccountApiKeyBody +export type CreateanAPIkeyforaserviceaccount200 = ServiceAccountApiKeyBody +export const CreateanAPIkeyforaserviceaccount200 = ServiceAccountApiKeyBody +export type CreatecontentprovenancecheckRequestFormData = CreateContentProvenanceBody +export const CreatecontentprovenancecheckRequestFormData = CreateContentProvenanceBody +export type Createcontentprovenancecheck200 = ProvenanceResource +export const Createcontentprovenancecheck200 = ProvenanceResource export type ListVideosParams = { readonly "limit"?: number; readonly "order"?: OrderEnum; readonly "after"?: string } export const ListVideosParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(100)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" })) ), "order": Schema.optionalKey(OrderEnum), "after": Schema.optionalKey( @@ -30240,20 +35930,18 @@ export type CreateVideoRemix200 = VideoResource export const CreateVideoRemix200 = VideoResource export type GetinputtokencountsRequestJson = TokenCountsBody export const GetinputtokencountsRequestJson = TokenCountsBody -export type GetinputtokencountsRequestFormUrlEncoded = TokenCountsBody -export const GetinputtokencountsRequestFormUrlEncoded = TokenCountsBody export type Getinputtokencounts200 = TokenCountsResource export const Getinputtokencounts200 = TokenCountsResource export type CompactconversationRequestJson = CompactResponseMethodPublicBody export const CompactconversationRequestJson = CompactResponseMethodPublicBody -export type CompactconversationRequestFormUrlEncoded = CompactResponseMethodPublicBody -export const CompactconversationRequestFormUrlEncoded = CompactResponseMethodPublicBody export type Compactconversation200 = CompactResource export const Compactconversation200 = CompactResource export type ListSkillsParams = { readonly "limit"?: number; readonly "order"?: OrderEnum; readonly "after"?: string } export const ListSkillsParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(100)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" })) ), "order": Schema.optionalKey(OrderEnum), "after": Schema.optionalKey( @@ -30272,8 +35960,6 @@ export type GetSkill200 = SkillResource export const GetSkill200 = SkillResource export type UpdateSkillDefaultVersionRequestJson = SetDefaultSkillVersionBody export const UpdateSkillDefaultVersionRequestJson = SetDefaultSkillVersionBody -export type UpdateSkillDefaultVersionRequestFormUrlEncoded = SetDefaultSkillVersionBody -export const UpdateSkillDefaultVersionRequestFormUrlEncoded = SetDefaultSkillVersionBody export type UpdateSkillDefaultVersion200 = SkillResource export const UpdateSkillDefaultVersion200 = SkillResource export type DeleteSkill200 = DeletedSkillResource @@ -30287,7 +35973,9 @@ export type ListSkillVersionsParams = { } export const ListSkillVersionsParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(100)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" })) ), "order": Schema.optionalKey(OrderEnum), "after": Schema.optionalKey(Schema.String) @@ -30320,7 +36008,9 @@ export type ListThreadItemsMethodParams = { } export const ListThreadItemsMethodParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(100)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" })) ), "order": Schema.optionalKey(OrderEnum), "after": Schema.optionalKey( @@ -30349,7 +36039,9 @@ export type ListThreadsMethodParams = { } export const ListThreadsMethodParams = Schema.Struct({ "limit": Schema.optionalKey( - Schema.Number.check(Schema.isInt()).check(Schema.isGreaterThanOrEqualTo(0)).check(Schema.isLessThanOrEqualTo(100)) + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" })) ), "order": Schema.optionalKey(OrderEnum), "after": Schema.optionalKey( @@ -30365,11 +36057,85 @@ export const ListThreadsMethodParams = Schema.Struct({ "user": Schema.optionalKey( Schema.String.annotate({ "description": "Filter threads that belong to this user identifier. Defaults to null to return all users." - }).check(Schema.isMinLength(1)).check(Schema.isMaxLength(512)) + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" }) + ) ) }) export type ListThreadsMethod200 = ThreadListResource export const ListThreadsMethod200 = ThreadListResource +export type BetaCreateResponseParams = { readonly "openai-beta"?: ReadonlyArray<"responses_multi_agent=v1"> } +export const BetaCreateResponseParams = Schema.Struct({ + "openai-beta": Schema.optionalKey(Schema.Array(Schema.Literal("responses_multi_agent=v1"))) +}) +export type BetaCreateResponseRequestJson = BetaCreateResponse +export const BetaCreateResponseRequestJson = BetaCreateResponse +export type BetaCreateResponse200 = BetaResponse +export const BetaCreateResponse200 = BetaResponse +export type BetaCreateResponse200Sse = BetaResponseStreamEvent +export const BetaCreateResponse200Sse = BetaResponseStreamEvent +export type BetaGetResponseParams = { + readonly "include"?: ReadonlyArray + readonly "stream"?: boolean + readonly "starting_after"?: number + readonly "include_obfuscation"?: boolean + readonly "openai-beta"?: ReadonlyArray<"responses_multi_agent=v1"> +} +export const BetaGetResponseParams = Schema.Struct({ + "include": Schema.optionalKey(Schema.Array(BetaIncludeEnum)), + "stream": Schema.optionalKey(Schema.Boolean), + "starting_after": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "include_obfuscation": Schema.optionalKey(Schema.Boolean), + "openai-beta": Schema.optionalKey(Schema.Array(Schema.Literal("responses_multi_agent=v1"))) +}) +export type BetaGetResponse200 = BetaResponse +export const BetaGetResponse200 = BetaResponse +export type BetaDeleteResponseParams = { readonly "openai-beta"?: ReadonlyArray<"responses_multi_agent=v1"> } +export const BetaDeleteResponseParams = Schema.Struct({ + "openai-beta": Schema.optionalKey(Schema.Array(Schema.Literal("responses_multi_agent=v1"))) +}) +export type BetaDeleteResponse404 = BetaError +export const BetaDeleteResponse404 = BetaError +export type BetaCancelResponseParams = { readonly "openai-beta"?: ReadonlyArray<"responses_multi_agent=v1"> } +export const BetaCancelResponseParams = Schema.Struct({ + "openai-beta": Schema.optionalKey(Schema.Array(Schema.Literal("responses_multi_agent=v1"))) +}) +export type BetaCancelResponse200 = BetaResponse +export const BetaCancelResponse200 = BetaResponse +export type BetaCancelResponse404 = BetaError +export const BetaCancelResponse404 = BetaError +export type BetaCompactconversationParams = { readonly "openai-beta"?: ReadonlyArray<"responses_multi_agent=v1"> } +export const BetaCompactconversationParams = Schema.Struct({ + "openai-beta": Schema.optionalKey(Schema.Array(Schema.Literal("responses_multi_agent=v1"))) +}) +export type BetaCompactconversationRequestJson = BetaCompactResponseMethodPublicBody +export const BetaCompactconversationRequestJson = BetaCompactResponseMethodPublicBody +export type BetaCompactconversation200 = BetaCompactResource +export const BetaCompactconversation200 = BetaCompactResource +export type BetaListInputItemsParams = { + readonly "limit"?: number + readonly "order"?: "asc" | "desc" + readonly "after"?: string + readonly "include"?: ReadonlyArray + readonly "openai-beta"?: ReadonlyArray<"responses_multi_agent=v1"> +} +export const BetaListInputItemsParams = Schema.Struct({ + "limit": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "order": Schema.optionalKey(Schema.Literals(["asc", "desc"])), + "after": Schema.optionalKey(Schema.String), + "include": Schema.optionalKey(Schema.Array(BetaIncludeEnum)), + "openai-beta": Schema.optionalKey(Schema.Array(Schema.Literal("responses_multi_agent=v1"))) +}) +export type BetaListInputItems200 = BetaResponseItemList +export const BetaListInputItems200 = BetaResponseItemList +export type BetaGetinputtokencountsParams = { readonly "openai-beta"?: ReadonlyArray<"responses_multi_agent=v1"> } +export const BetaGetinputtokencountsParams = Schema.Struct({ + "openai-beta": Schema.optionalKey(Schema.Array(Schema.Literal("responses_multi_agent=v1"))) +}) +export type BetaGetinputtokencountsRequestJson = BetaTokenCountsBody +export const BetaGetinputtokencountsRequestJson = BetaTokenCountsBody +export type BetaGetinputtokencounts200 = BetaTokenCountsResource +export const BetaGetinputtokencounts200 = BetaTokenCountsResource export interface OperationConfig { /** @@ -31195,6 +36961,7 @@ export const make = ( "actor_ids[]": options?.params?.["actor_ids[]"] as any, "actor_emails[]": options?.params?.["actor_emails[]"] as any, "resource_ids[]": options?.params?.["resource_ids[]"] as any, + "tenant_only": options?.params?.["tenant_only"] as any, "limit": options?.params?.["limit"] as any, "after": options?.params?.["after"] as any, "before": options?.params?.["before"] as any @@ -31280,6 +37047,21 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveOrganizationDataRetention": (options) => + HttpClientRequest.get(`/organization/data_retention`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveOrganizationDataRetention200), + orElse: unexpectedStatus + })) + ), + "updateOrganizationDataRetention": (options) => + HttpClientRequest.post(`/organization/data_retention`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(UpdateOrganizationDataRetention200), + orElse: unexpectedStatus + })) + ), "listGroups": (options) => HttpClientRequest.get(`/organization/groups`).pipe( HttpClientRequest.setUrlParams({ @@ -31300,6 +37082,13 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveGroup": (groupId, options) => + HttpClientRequest.get(`/organization/groups/${groupId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveGroup200), + orElse: unexpectedStatus + })) + ), "updateGroup": (groupId, options) => HttpClientRequest.post(`/organization/groups/${groupId}`).pipe( HttpClientRequest.bodyJsonUnsafe(options.payload), @@ -31335,6 +37124,13 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveGroupRole": (groupId, roleId, options) => + HttpClientRequest.get(`/organization/groups/${groupId}/roles/${roleId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveGroupRole200), + orElse: unexpectedStatus + })) + ), "unassignGroupRole": (groupId, roleId, options) => HttpClientRequest.delete(`/organization/groups/${groupId}/roles/${roleId}`).pipe( withResponse(options?.config)(HttpClientResponse.matchStatus({ @@ -31362,6 +37158,13 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveGroupUser": (groupId, userId, options) => + HttpClientRequest.get(`/organization/groups/${groupId}/users/${userId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveGroupUser200), + orElse: unexpectedStatus + })) + ), "removeGroupUser": (groupId, userId, options) => HttpClientRequest.delete(`/organization/groups/${groupId}/users/${userId}`).pipe( withResponse(options?.config)(HttpClientResponse.matchStatus({ @@ -31442,7 +37245,8 @@ export const make = ( HttpClientRequest.get(`/organization/projects/${projectId}/api_keys`).pipe( HttpClientRequest.setUrlParams({ "limit": options?.params?.["limit"] as any, - "after": options?.params?.["after"] as any + "after": options?.params?.["after"] as any, + "owner_project_access": options?.params?.["owner_project_access"] as any }), withResponse(options?.config)(HttpClientResponse.matchStatus({ "2xx": decodeSuccess(ListProjectApiKeys200), @@ -31499,6 +37303,21 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveProjectDataRetention": (projectId, options) => + HttpClientRequest.get(`/organization/projects/${projectId}/data_retention`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveProjectDataRetention200), + orElse: unexpectedStatus + })) + ), + "updateProjectDataRetention": (projectId, options) => + HttpClientRequest.post(`/organization/projects/${projectId}/data_retention`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(UpdateProjectDataRetention200), + orElse: unexpectedStatus + })) + ), "listProjectGroups": (projectId, options) => HttpClientRequest.get(`/organization/projects/${projectId}/groups`).pipe( HttpClientRequest.setUrlParams({ @@ -31519,6 +37338,14 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveProjectGroup": (projectId, groupId, options) => + HttpClientRequest.get(`/organization/projects/${projectId}/groups/${groupId}`).pipe( + HttpClientRequest.setUrlParams({ "group_type": options?.params?.["group_type"] as any }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveProjectGroup200), + orElse: unexpectedStatus + })) + ), "removeProjectGroup": (projectId, groupId, options) => HttpClientRequest.delete(`/organization/projects/${projectId}/groups/${groupId}`).pipe( withResponse(options?.config)(HttpClientResponse.matchStatus({ @@ -31612,6 +37439,14 @@ export const make = ( orElse: unexpectedStatus })) ), + "updateProjectServiceAccount": (projectId, serviceAccountId, options) => + HttpClientRequest.post(`/organization/projects/${projectId}/service_accounts/${serviceAccountId}`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(UpdateProjectServiceAccount200), + orElse: unexpectedStatus + })) + ), "deleteProjectServiceAccount": (projectId, serviceAccountId, options) => HttpClientRequest.delete(`/organization/projects/${projectId}/service_accounts/${serviceAccountId}`).pipe( withResponse(options?.config)(HttpClientResponse.matchStatus({ @@ -31619,6 +37454,49 @@ export const make = ( orElse: unexpectedStatus })) ), + "listProjectSpendAlerts": (projectId, options) => + HttpClientRequest.get(`/organization/projects/${projectId}/spend_alerts`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "order": options?.params?.["order"] as any, + "after": options?.params?.["after"] as any, + "before": options?.params?.["before"] as any + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(ListProjectSpendAlerts200), + orElse: unexpectedStatus + })) + ), + "createProjectSpendAlert": (projectId, options) => + HttpClientRequest.post(`/organization/projects/${projectId}/spend_alerts`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(CreateProjectSpendAlert200), + orElse: unexpectedStatus + })) + ), + "retrieveProjectSpendAlert": (projectId, alertId, options) => + HttpClientRequest.get(`/organization/projects/${projectId}/spend_alerts/${alertId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveProjectSpendAlert200), + orElse: unexpectedStatus + })) + ), + "updateProjectSpendAlert": (projectId, alertId, options) => + HttpClientRequest.post(`/organization/projects/${projectId}/spend_alerts/${alertId}`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(UpdateProjectSpendAlert200), + orElse: unexpectedStatus + })) + ), + "deleteProjectSpendAlert": (projectId, alertId, options) => + HttpClientRequest.delete(`/organization/projects/${projectId}/spend_alerts/${alertId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(DeleteProjectSpendAlert200), + orElse: unexpectedStatus + })) + ), "listProjectUsers": (projectId, options) => HttpClientRequest.get(`/organization/projects/${projectId}/users`).pipe( HttpClientRequest.setUrlParams({ @@ -31684,6 +37562,13 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveRole": (roleId, options) => + HttpClientRequest.get(`/organization/roles/${roleId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveRole200), + orElse: unexpectedStatus + })) + ), "updateRole": (roleId, options) => HttpClientRequest.post(`/organization/roles/${roleId}`).pipe( HttpClientRequest.bodyJsonUnsafe(options.payload), @@ -31699,6 +37584,49 @@ export const make = ( orElse: unexpectedStatus })) ), + "listOrganizationSpendAlerts": (options) => + HttpClientRequest.get(`/organization/spend_alerts`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "order": options?.params?.["order"] as any, + "after": options?.params?.["after"] as any, + "before": options?.params?.["before"] as any + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(ListOrganizationSpendAlerts200), + orElse: unexpectedStatus + })) + ), + "createOrganizationSpendAlert": (options) => + HttpClientRequest.post(`/organization/spend_alerts`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(CreateOrganizationSpendAlert200), + orElse: unexpectedStatus + })) + ), + "retrieveOrganizationSpendAlert": (alertId, options) => + HttpClientRequest.get(`/organization/spend_alerts/${alertId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveOrganizationSpendAlert200), + orElse: unexpectedStatus + })) + ), + "updateOrganizationSpendAlert": (alertId, options) => + HttpClientRequest.post(`/organization/spend_alerts/${alertId}`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(UpdateOrganizationSpendAlert200), + orElse: unexpectedStatus + })) + ), + "deleteOrganizationSpendAlert": (alertId, options) => + HttpClientRequest.delete(`/organization/spend_alerts/${alertId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(DeleteOrganizationSpendAlert200), + orElse: unexpectedStatus + })) + ), "usageAudioSpeeches": (options) => HttpClientRequest.get(`/organization/usage/audio_speeches`).pipe( HttpClientRequest.setUrlParams({ @@ -31941,6 +37869,13 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveUserRole": (userId, roleId, options) => + HttpClientRequest.get(`/organization/users/${userId}/roles/${roleId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveUserRole200), + orElse: unexpectedStatus + })) + ), "unassignUserRole": (userId, roleId, options) => HttpClientRequest.delete(`/organization/users/${userId}/roles/${roleId}`).pipe( withResponse(options?.config)(HttpClientResponse.matchStatus({ @@ -31968,6 +37903,13 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveProjectGroupRole": (projectId, groupId, roleId, options) => + HttpClientRequest.get(`/projects/${projectId}/groups/${groupId}/roles/${roleId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveProjectGroupRole200), + orElse: unexpectedStatus + })) + ), "unassignProjectGroupRole": (projectId, groupId, roleId, options) => HttpClientRequest.delete(`/projects/${projectId}/groups/${groupId}/roles/${roleId}`).pipe( withResponse(options?.config)(HttpClientResponse.matchStatus({ @@ -31995,6 +37937,13 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveProjectRole": (projectId, roleId, options) => + HttpClientRequest.get(`/projects/${projectId}/roles/${roleId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveProjectRole200), + orElse: unexpectedStatus + })) + ), "updateProjectRole": (projectId, roleId, options) => HttpClientRequest.post(`/projects/${projectId}/roles/${roleId}`).pipe( HttpClientRequest.bodyJsonUnsafe(options.payload), @@ -32030,6 +37979,13 @@ export const make = ( orElse: unexpectedStatus })) ), + "retrieveProjectUserRole": (projectId, userId, roleId, options) => + HttpClientRequest.get(`/projects/${projectId}/users/${userId}/roles/${roleId}`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(RetrieveProjectUserRole200), + orElse: unexpectedStatus + })) + ), "unassignProjectUserRole": (projectId, userId, roleId, options) => HttpClientRequest.delete(`/projects/${projectId}/users/${userId}/roles/${roleId}`).pipe( withResponse(options?.config)(HttpClientResponse.matchStatus({ @@ -32517,6 +38473,66 @@ export const make = ( orElse: unexpectedStatus })) ), + "Getorganizationspendlimit": (options) => + HttpClientRequest.get(`/organization/spend_limit`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(Getorganizationspendlimit200), + orElse: unexpectedStatus + })) + ), + "Updateorganizationspendlimit": (options) => + HttpClientRequest.post(`/organization/spend_limit`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(Updateorganizationspendlimit200), + orElse: unexpectedStatus + })) + ), + "Deleteorganizationspendlimit": (options) => + HttpClientRequest.delete(`/organization/spend_limit`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(Deleteorganizationspendlimit200), + orElse: unexpectedStatus + })) + ), + "Getprojectspendlimit": (projectId, options) => + HttpClientRequest.get(`/organization/projects/${projectId}/spend_limit`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(Getprojectspendlimit200), + orElse: unexpectedStatus + })) + ), + "Updateprojectspendlimit": (projectId, options) => + HttpClientRequest.post(`/organization/projects/${projectId}/spend_limit`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(Updateprojectspendlimit200), + orElse: unexpectedStatus + })) + ), + "Deleteprojectspendlimit": (projectId, options) => + HttpClientRequest.delete(`/organization/projects/${projectId}/spend_limit`).pipe( + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(Deleteprojectspendlimit200), + orElse: unexpectedStatus + })) + ), + "CreateanAPIkeyforaserviceaccount": (projectId, serviceAccountId, options) => + HttpClientRequest.post(`/organization/projects/${projectId}/service_accounts/${serviceAccountId}/api_keys`).pipe( + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(CreateanAPIkeyforaserviceaccount200), + orElse: unexpectedStatus + })) + ), + "Createcontentprovenancecheck": (options) => + HttpClientRequest.post(`/content_provenance_checks`).pipe( + HttpClientRequest.bodyFormData(options.payload as any), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(Createcontentprovenancecheck200), + orElse: unexpectedStatus + })) + ), "ListVideos": (options) => HttpClientRequest.get(`/videos`).pipe( HttpClientRequest.setUrlParams({ @@ -32600,7 +38616,7 @@ export const make = ( ), "Getinputtokencounts": (options) => HttpClientRequest.post(`/responses/input_tokens`).pipe( - HttpClientRequest.bodyUrlParams(options.payload as any), + HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ "2xx": decodeSuccess(Getinputtokencounts200), orElse: unexpectedStatus @@ -32608,7 +38624,7 @@ export const make = ( ), "Compactconversation": (options) => HttpClientRequest.post(`/responses/compact`).pipe( - HttpClientRequest.bodyUrlParams(options.payload as any), + HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ "2xx": decodeSuccess(Compactconversation200), orElse: unexpectedStatus @@ -32643,7 +38659,7 @@ export const make = ( ), "UpdateSkillDefaultVersion": (skillId, options) => HttpClientRequest.post(`/skills/${skillId}`).pipe( - HttpClientRequest.bodyUrlParams(options.payload as any), + HttpClientRequest.bodyJsonUnsafe(options.payload), withResponse(options.config)(HttpClientResponse.matchStatus({ "2xx": decodeSuccess(UpdateSkillDefaultVersion200), orElse: unexpectedStatus @@ -32759,6 +38775,85 @@ export const make = ( "2xx": decodeSuccess(ListThreadsMethod200), orElse: unexpectedStatus })) + ), + "betaCreateResponse": (options) => + HttpClientRequest.post(`/responses?beta=true`).pipe( + HttpClientRequest.setHeaders({ "openai-beta": options.params?.["openai-beta"] ?? undefined }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCreateResponse200), + orElse: unexpectedStatus + })) + ), + "betaCreateResponseSse": (options) => + HttpClientRequest.post(`/responses?beta=true`).pipe( + HttpClientRequest.setHeaders({ "openai-beta": options.params?.["openai-beta"] ?? undefined }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + sseRequest(BetaCreateResponse200Sse) + ), + "betaGetResponse": (responseId, options) => + HttpClientRequest.get(`/responses/${responseId}?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "include": options?.params?.["include"] as any, + "stream": options?.params?.["stream"] as any, + "starting_after": options?.params?.["starting_after"] as any, + "include_obfuscation": options?.params?.["include_obfuscation"] as any + }), + HttpClientRequest.setHeaders({ "openai-beta": options?.params?.["openai-beta"] ?? undefined }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetResponse200), + orElse: unexpectedStatus + })) + ), + "betaDeleteResponse": (responseId, options) => + HttpClientRequest.delete(`/responses/${responseId}?beta=true`).pipe( + HttpClientRequest.setHeaders({ "openai-beta": options?.params?.["openai-beta"] ?? undefined }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "404": decodeError("BetaDeleteResponse404", BetaDeleteResponse404), + "200": () => Effect.void, + orElse: unexpectedStatus + })) + ), + "betaCancelResponse": (responseId, options) => + HttpClientRequest.post(`/responses/${responseId}/cancel?beta=true`).pipe( + HttpClientRequest.setHeaders({ "openai-beta": options?.params?.["openai-beta"] ?? undefined }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCancelResponse200), + "404": decodeError("BetaCancelResponse404", BetaCancelResponse404), + orElse: unexpectedStatus + })) + ), + "betaCompactconversation": (options) => + HttpClientRequest.post(`/responses/compact?beta=true`).pipe( + HttpClientRequest.setHeaders({ "openai-beta": options.params?.["openai-beta"] ?? undefined }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaCompactconversation200), + orElse: unexpectedStatus + })) + ), + "betaListInputItems": (responseId, options) => + HttpClientRequest.get(`/responses/${responseId}/input_items?beta=true`).pipe( + HttpClientRequest.setUrlParams({ + "limit": options?.params?.["limit"] as any, + "order": options?.params?.["order"] as any, + "after": options?.params?.["after"] as any, + "include": options?.params?.["include"] as any + }), + HttpClientRequest.setHeaders({ "openai-beta": options?.params?.["openai-beta"] ?? undefined }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaListInputItems200), + orElse: unexpectedStatus + })) + ), + "betaGetinputtokencounts": (options) => + HttpClientRequest.post(`/responses/input_tokens?beta=true`).pipe( + HttpClientRequest.setHeaders({ "openai-beta": options.params?.["openai-beta"] ?? undefined }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(BetaGetinputtokencounts200), + orElse: unexpectedStatus + })) ) } } @@ -33880,6 +39975,27 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves organization data retention controls. + */ + readonly "retrieveOrganizationDataRetention": ( + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Updates organization data retention controls. + */ + readonly "updateOrganizationDataRetention": ( + options: { + readonly payload: typeof UpdateOrganizationDataRetentionRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Lists all groups in the organization. */ @@ -33900,6 +40016,16 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves a group. + */ + readonly "retrieveGroup": ( + groupId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Updates a group's information. */ @@ -33943,6 +40069,17 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves an organization role assigned to a group. + */ + readonly "retrieveGroupRole": ( + groupId: string, + roleId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Unassigns an organization role from a group within the organization. */ @@ -33976,6 +40113,17 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves a user in a group. + */ + readonly "retrieveGroupUser": ( + groupId: string, + userId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Removes a user from a group. */ @@ -34159,6 +40307,29 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves project data retention controls. + */ + readonly "retrieveProjectDataRetention": ( + projectId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Updates project data retention controls. + */ + readonly "updateProjectDataRetention": ( + projectId: string, + options: { + readonly payload: typeof UpdateProjectDataRetentionRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Lists the groups that have access to a project. */ @@ -34182,6 +40353,20 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves a project's group. + */ + readonly "retrieveProjectGroup": ( + projectId: string, + groupId: string, + options: { + readonly params?: typeof RetrieveProjectGroupParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Revokes a group's access to a project. */ @@ -34294,7 +40479,7 @@ export interface OpenAiClient { | OpenAiClientError<"ListProjectServiceAccounts400", typeof ListProjectServiceAccounts400.Type> > /** - * Creates a new service account in the project. This also returns an unredacted API key for the service account. + * Creates a new service account in the project. By default, this also returns an unredacted API key for the service account. */ readonly "createProjectServiceAccount": ( projectId: string, @@ -34309,28 +40494,104 @@ export interface OpenAiClient { | OpenAiClientError<"CreateProjectServiceAccount400", typeof CreateProjectServiceAccount400.Type> > /** - * Retrieves a service account in the project. + * Retrieves a service account in the project. + */ + readonly "retrieveProjectServiceAccount": ( + projectId: string, + serviceAccountId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Updates a service account in the project. + */ + readonly "updateProjectServiceAccount": ( + projectId: string, + serviceAccountId: string, + options: { + readonly payload: typeof UpdateProjectServiceAccountRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Deletes a service account from the project. + * + * Returns confirmation of service account deletion, or an error if the project + * is archived (archived projects have no service accounts). + */ + readonly "deleteProjectServiceAccount": ( + projectId: string, + serviceAccountId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Lists project spend alerts. + */ + readonly "listProjectSpendAlerts": ( + projectId: string, + options: { + readonly params?: typeof ListProjectSpendAlertsParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Creates a project spend alert. + */ + readonly "createProjectSpendAlert": ( + projectId: string, + options: { + readonly payload: typeof CreateProjectSpendAlertRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Retrieves a project spend alert. + */ + readonly "retrieveProjectSpendAlert": ( + projectId: string, + alertId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Updates a project spend alert. */ - readonly "retrieveProjectServiceAccount": ( + readonly "updateProjectSpendAlert": ( projectId: string, - serviceAccountId: string, - options: { readonly config?: Config | undefined } | undefined + alertId: string, + options: { + readonly payload: typeof UpdateProjectSpendAlertRequestJson.Encoded + readonly config?: Config | undefined + } ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > /** - * Deletes a service account from the project. - * - * Returns confirmation of service account deletion, or an error if the project - * is archived (archived projects have no service accounts). + * Deletes a project spend alert. */ - readonly "deleteProjectServiceAccount": ( + readonly "deleteProjectSpendAlert": ( projectId: string, - serviceAccountId: string, + alertId: string, options: { readonly config?: Config | undefined } | undefined ) => Effect.Effect< - WithOptionalResponse, + WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > /** @@ -34420,6 +40681,16 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves an organization role. + */ + readonly "retrieveRole": ( + roleId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Updates an existing organization role. */ @@ -34440,6 +40711,63 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Lists organization spend alerts. + */ + readonly "listOrganizationSpendAlerts": ( + options: { + readonly params?: typeof ListOrganizationSpendAlertsParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Creates an organization spend alert. + */ + readonly "createOrganizationSpendAlert": ( + options: { + readonly payload: typeof CreateOrganizationSpendAlertRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Retrieves an organization spend alert. + */ + readonly "retrieveOrganizationSpendAlert": ( + alertId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Updates an organization spend alert. + */ + readonly "updateOrganizationSpendAlert": ( + alertId: string, + options: { + readonly payload: typeof UpdateOrganizationSpendAlertRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Deletes an organization spend alert. + */ + readonly "deleteOrganizationSpendAlert": ( + alertId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Get audio speeches usage details for the organization. */ @@ -34597,6 +40925,17 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves an organization role assigned to a user. + */ + readonly "retrieveUserRole": ( + userId: string, + roleId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Unassigns an organization role from a user within the organization. */ @@ -34636,6 +40975,18 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves a project role assigned to a group. + */ + readonly "retrieveProjectGroupRole": ( + projectId: string, + groupId: string, + roleId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Unassigns a project role from a group within a project. */ @@ -34671,6 +41022,17 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves a project role. + */ + readonly "retrieveProjectRole": ( + projectId: string, + roleId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Updates an existing project role. */ @@ -34718,6 +41080,18 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Retrieves a project role assigned to a user. + */ + readonly "retrieveProjectUserRole": ( + projectId: string, + userId: string, + roleId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * Unassigns a project role from a user within a project. */ @@ -35421,6 +41795,97 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Get the organization's hard spend limit. + */ + readonly "Getorganizationspendlimit": ( + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Create or replace the organization's hard spend limit. + */ + readonly "Updateorganizationspendlimit": ( + options: { + readonly payload: typeof UpdateorganizationspendlimitRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Delete the organization's hard spend limit. + */ + readonly "Deleteorganizationspendlimit": ( + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Get a project's hard spend limit. + */ + readonly "Getprojectspendlimit": ( + projectId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Create or replace a project's hard spend limit. + */ + readonly "Updateprojectspendlimit": ( + projectId: string, + options: { + readonly payload: typeof UpdateprojectspendlimitRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Delete a project's hard spend limit. + */ + readonly "Deleteprojectspendlimit": ( + projectId: string, + options: { readonly config?: Config | undefined } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Creates an API key for a service account in the project. + */ + readonly "CreateanAPIkeyforaserviceaccount": ( + projectId: string, + serviceAccountId: string, + options: { + readonly payload: typeof CreateanAPIkeyforaserviceaccountRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Check whether an image or audio file contains known OpenAI provenance signals. [Learn more about content provenance](/api/docs/guides/content-provenance). + * + * If `not_detected`, it means the tool did not find supported signals in the uploaded file. The content could still have been generated by OpenAI if the metadata was stripped or has evidence of tampering, the watermark was degraded, it comes from a legacy generation model, or it was created before provenance signals were available. Content could also still be AI-generated by another company's model, which the tool currently does not detect. + */ + readonly "Createcontentprovenancecheck": ( + options: { + readonly payload: typeof CreatecontentprovenancecheckRequestFormData.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > /** * List recently generated videos for the current project. */ @@ -35532,10 +41997,7 @@ export interface OpenAiClient { * Returns an object with `object` set to `response.input_tokens` and an `input_tokens` count. */ readonly "Getinputtokencounts": ( - options: { - readonly payload: typeof GetinputtokencountsRequestFormUrlEncoded.Encoded - readonly config?: Config | undefined - } + options: { readonly payload: typeof GetinputtokencountsRequestJson.Encoded; readonly config?: Config | undefined } ) => Effect.Effect< WithOptionalResponse, HttpClientError.HttpClientError | SchemaError @@ -35546,10 +42008,7 @@ export interface OpenAiClient { * Learn when and how to compact long-running conversations in the [conversation state guide](/docs/guides/conversation-state#managing-the-context-window). For ZDR-compatible compaction details, see [Compaction (advanced)](/docs/guides/conversation-state#compaction-advanced). */ readonly "Compactconversation": ( - options: { - readonly payload: typeof CompactconversationRequestFormUrlEncoded.Encoded - readonly config?: Config | undefined - } + options: { readonly payload: typeof CompactconversationRequestJson.Encoded; readonly config?: Config | undefined } ) => Effect.Effect< WithOptionalResponse, HttpClientError.HttpClientError | SchemaError @@ -35590,7 +42049,7 @@ export interface OpenAiClient { readonly "UpdateSkillDefaultVersion": ( skillId: string, options: { - readonly payload: typeof UpdateSkillDefaultVersionRequestFormUrlEncoded.Encoded + readonly payload: typeof UpdateSkillDefaultVersionRequestJson.Encoded readonly config?: Config | undefined } ) => Effect.Effect< @@ -35745,6 +42204,132 @@ export interface OpenAiClient { WithOptionalResponse, HttpClientError.HttpClientError | SchemaError > + /** + * Creates a model response. Provide [text](/docs/guides/text) or + * [image](/docs/guides/images) inputs to generate [text](/docs/guides/text) + * or [JSON](/docs/guides/structured-outputs) outputs. Have the model call + * your own [custom code](/docs/guides/function-calling) or use built-in + * [tools](/docs/guides/tools) like [web search](/docs/guides/tools-web-search) + * or [file search](/docs/guides/tools-file-search) to use your own data + * as input for the model's response. + */ + readonly "betaCreateResponse": ( + options: { + readonly params?: typeof BetaCreateResponseParams.Encoded | undefined + readonly payload: typeof BetaCreateResponseRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Creates a model response. Provide [text](/docs/guides/text) or + * [image](/docs/guides/images) inputs to generate [text](/docs/guides/text) + * or [JSON](/docs/guides/structured-outputs) outputs. Have the model call + * your own [custom code](/docs/guides/function-calling) or use built-in + * [tools](/docs/guides/tools) like [web search](/docs/guides/tools-web-search) + * or [file search](/docs/guides/tools-file-search) to use your own data + * as input for the model's response. + */ + readonly "betaCreateResponseSse": ( + options: { + readonly params?: typeof BetaCreateResponseParams.Encoded | undefined + readonly payload: typeof BetaCreateResponseRequestJson.Encoded + } + ) => Stream.Stream< + { readonly event: string; readonly id: string | undefined; readonly data: typeof BetaCreateResponse200Sse.Type }, + HttpClientError.HttpClientError | SchemaError | Sse.Retry | Sse.SseError, + typeof BetaCreateResponse200Sse.DecodingServices + > + /** + * Retrieves a model response with the given ID. + */ + readonly "betaGetResponse": ( + responseId: string, + options: { + readonly params?: typeof BetaGetResponseParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Deletes a model response with the given ID. + */ + readonly "betaDeleteResponse": ( + responseId: string, + options: { + readonly params?: typeof BetaDeleteResponseParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenAiClientError<"BetaDeleteResponse404", typeof BetaDeleteResponse404.Type> + > + /** + * Cancels a model response with the given ID. Only responses created with + * the `background` parameter set to `true` can be cancelled. + * [Learn more](/docs/guides/background). + */ + readonly "betaCancelResponse": ( + responseId: string, + options: { + readonly params?: typeof BetaCancelResponseParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenAiClientError<"BetaCancelResponse404", typeof BetaCancelResponse404.Type> + > + /** + * Compact a conversation. Returns a compacted response object. + * + * Learn when and how to compact long-running conversations in the [conversation state guide](/docs/guides/conversation-state#managing-the-context-window). For ZDR-compatible compaction details, see [Compaction (advanced)](/docs/guides/conversation-state#compaction-advanced). + */ + readonly "betaCompactconversation": ( + options: { + readonly params?: typeof BetaCompactconversationParams.Encoded | undefined + readonly payload: typeof BetaCompactconversationRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Returns a list of input items for a given response. + */ + readonly "betaListInputItems": ( + responseId: string, + options: { + readonly params?: typeof BetaListInputItemsParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > + /** + * Returns input token counts of the request. + * + * Returns an object with `object` set to `response.input_tokens` and an `input_tokens` count. + */ + readonly "betaGetinputtokencounts": ( + options: { + readonly params?: typeof BetaGetinputtokencountsParams.Encoded | undefined + readonly payload: typeof BetaGetinputtokencountsRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + HttpClientError.HttpClientError | SchemaError + > } export interface OpenAiClientError { diff --git a/packages/ai/openrouter/src/Generated.ts b/packages/ai/openrouter/src/Generated.ts index 4c3859a375d..efc81408874 100644 --- a/packages/ai/openrouter/src/Generated.ts +++ b/packages/ai/openrouter/src/Generated.ts @@ -13,25 +13,6 @@ import * as HttpClientError from "effect/unstable/http/HttpClientError" import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest" import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse" // non-recursive definitions -export type AABenchmarkEntry = { - readonly "agentic_index": number | null - readonly "coding_index": number | null - readonly "intelligence_index": number | null -} -export const AABenchmarkEntry = Schema.Struct({ - "agentic_index": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "description": "Artificial Analysis Agentic Index score", "format": "double" }), - "coding_index": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "description": "Artificial Analysis Coding Index score", "format": "double" }), - "intelligence_index": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "description": "Artificial Analysis Intelligence Index score", "format": "double" }) -}).annotate({ "description": "Artificial Analysis benchmark index scores.", "identifier": "AABenchmarkEntry" }) export type ActivityItem = { readonly "byok_usage_inference": number readonly "completion_tokens": number @@ -44,6 +25,7 @@ export type ActivityItem = { readonly "reasoning_tokens": number readonly "requests": number readonly "usage": number + readonly "workspace_id"?: string } export const ActivityItem = Schema.Struct({ "byok_usage_inference": Schema.Number.annotate({ @@ -68,1478 +50,2027 @@ export const ActivityItem = Schema.Struct({ Schema.isInt().annotate({ "expected": "an integer" }) ), "usage": Schema.Number.annotate({ "description": "Total cost in USD (OpenRouter credits spent)", "format": "double" }) - .check(Schema.isFinite().annotate({ "expected": "a finite number" })) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "workspace_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "ID of the workspace this activity is attributed to. Only present when `group_by=workspace` is passed; the response is then split per workspace. Activity recorded before workspace resolution existed is attributed to the account default workspace." + }) + ) }).annotate({ "identifier": "ActivityItem" }) -export type AdvisorNestedTool = { readonly "parameters"?: {}; readonly "type": string } -export const AdvisorNestedTool = Schema.Struct({ - "parameters": Schema.optionalKey(Schema.Struct({})), - "type": Schema.String +export type BadRequestResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +} +export const BadRequestResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ "description": "Error data for BadRequestResponse", "identifier": "BadRequestResponseErrorData" }) +export type UnauthorizedResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +} +export const UnauthorizedResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ "description": "Error data for UnauthorizedResponse", "identifier": "UnauthorizedResponseErrorData" }) +export type ForbiddenResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +} +export const ForbiddenResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ "description": "Error data for ForbiddenResponse", "identifier": "ForbiddenResponseErrorData" }) +export type NotFoundResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +} +export const NotFoundResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ "description": "Error data for NotFoundResponse", "identifier": "NotFoundResponseErrorData" }) +export type InternalServerResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +} +export const InternalServerResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ "description": "Error data for InternalServerResponse", "identifier": "InternalServerResponseErrorData" }) +export type RequestTimeoutResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +} +export const RequestTimeoutResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ "description": "Error data for RequestTimeoutResponse", "identifier": "RequestTimeoutResponseErrorData" }) +export type SpeechInputReferenceAudioInput = { readonly "data": string; readonly "format"?: string } +export const SpeechInputReferenceAudioInput = Schema.Struct({ + "data": Schema.String.annotate({ + "description": + "Base64-encoded reference audio (optionally a data URI). Supported audio formats are provider-specific. Limited to 20 MiB of base64 (15 MiB of decoded audio)." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(20971520).annotate({ "expected": "a value with a length of at most 20971520" }) + ), + "format": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Audio format of the reference audio (e.g., wav, mp3). Optional; most providers detect the format from the audio bytes." + }) + ) +}).annotate({ "description": "Reference audio input object", "identifier": "SpeechInputReferenceAudioInput" }) +export type SpeechInputReferenceText = { readonly "text": string; readonly "type": "text" } +export const SpeechInputReferenceText = Schema.Struct({ + "text": Schema.String.annotate({ "description": "Transcript of the accompanying reference audio." }).check( + Schema.isMaxLength(10000).annotate({ "expected": "a value with a length of at most 10000" }) + ), + "type": Schema.Literal("text") +}).annotate({ + "description": "Transcript of the accompanying reference audio", + "identifier": "SpeechInputReferenceText" +}) +export type ProviderOptions = { + readonly "01ai"?: {} + readonly "ai21"?: {} + readonly "aion-labs"?: {} + readonly "akashml"?: {} + readonly "alibaba"?: {} + readonly "amazon-bedrock"?: {} + readonly "amazon-nova"?: {} + readonly "ambient"?: {} + readonly "anthropic"?: {} + readonly "anyscale"?: {} + readonly "arcee-ai"?: {} + readonly "atlas-cloud"?: {} + readonly "atoma"?: {} + readonly "avian"?: {} + readonly "azure"?: {} + readonly "baidu"?: {} + readonly "baseten"?: {} + readonly "black-forest-labs"?: {} + readonly "byteplus"?: {} + readonly "centml"?: {} + readonly "cerebras"?: {} + readonly "chutes"?: {} + readonly "cirrascale"?: {} + readonly "clarifai"?: {} + readonly "claude-on-aws"?: {} + readonly "cloudflare"?: {} + readonly "cohere"?: {} + readonly "coreweave"?: {} + readonly "crofai"?: {} + readonly "crucible"?: {} + readonly "crusoe"?: {} + readonly "darkbloom"?: {} + readonly "decart"?: {} + readonly "deepgram"?: {} + readonly "deepinfra"?: {} + readonly "deepseek"?: {} + readonly "dekallm"?: {} + readonly "digitalocean"?: {} + readonly "enfer"?: {} + readonly "fake-provider"?: {} + readonly "featherless"?: {} + readonly "fireworks"?: {} + readonly "fish-audio"?: {} + readonly "friendli"?: {} + readonly "gmicloud"?: {} + readonly "google-ai-studio"?: {} + readonly "google-vertex"?: {} + readonly "gopomelo"?: {} + readonly "groq"?: {} + readonly "heygen"?: {} + readonly "huggingface"?: {} + readonly "hyperbolic"?: {} + readonly "hyperbolic-quantized"?: {} + readonly "inception"?: {} + readonly "inceptron"?: {} + readonly "inferact-vllm"?: {} + readonly "inference-net"?: {} + readonly "infermatic"?: {} + readonly "inflection"?: {} + readonly "inocloud"?: {} + readonly "io-net"?: {} + readonly "ionstream"?: {} + readonly "klusterai"?: {} + readonly "krea"?: {} + readonly "lambda"?: {} + readonly "lepton"?: {} + readonly "liquid"?: {} + readonly "lynn"?: {} + readonly "lynn-private"?: {} + readonly "mancer"?: {} + readonly "mancer-old"?: {} + readonly "mara"?: {} + readonly "meta"?: {} + readonly "minimax"?: {} + readonly "mistral"?: {} + readonly "modal"?: {} + readonly "modelrun"?: {} + readonly "modular"?: {} + readonly "moonshotai"?: {} + readonly "morph"?: {} + readonly "ncompass"?: {} + readonly "nebius"?: {} + readonly "nex-agi"?: {} + readonly "nextbit"?: {} + readonly "nineteen"?: {} + readonly "novita"?: {} + readonly "nvidia"?: {} + readonly "octoai"?: {} + readonly "open-inference"?: {} + readonly "openai"?: {} + readonly "parasail"?: {} + readonly "perceptron"?: {} + readonly "perplexity"?: {} + readonly "phala"?: {} + readonly "poolside"?: {} + readonly "quiver"?: {} + readonly "recraft"?: {} + readonly "recursal"?: {} + readonly "reflection"?: {} + readonly "reka"?: {} + readonly "relace"?: {} + readonly "replicate"?: {} + readonly "runway"?: {} + readonly "sail-research"?: {} + readonly "sakana"?: {} + readonly "sakana-ai"?: {} + readonly "sambanova"?: {} + readonly "sambanova-cloaked"?: {} + readonly "seed"?: {} + readonly "sf-compute"?: {} + readonly "siliconflow"?: {} + readonly "sourceful"?: {} + readonly "stealth"?: {} + readonly "stepfun"?: {} + readonly "streamlake"?: {} + readonly "switchpoint"?: {} + readonly "targon"?: {} + readonly "tencent"?: {} + readonly "tenstorrent"?: {} + readonly "thinkingmachines"?: {} + readonly "together"?: {} + readonly "together-lite"?: {} + readonly "ubicloud"?: {} + readonly "upstage"?: {} + readonly "venice"?: {} + readonly "voyageai"?: {} + readonly "wafer"?: {} + readonly "wandb"?: {} + readonly "wandb-legacy"?: {} + readonly "xai"?: {} + readonly "xiaomi"?: {} + readonly "z-ai"?: {} +} +export const ProviderOptions = Schema.Struct({ + "01ai": Schema.optionalKey(Schema.Struct({})), + "ai21": Schema.optionalKey(Schema.Struct({})), + "aion-labs": Schema.optionalKey(Schema.Struct({})), + "akashml": Schema.optionalKey(Schema.Struct({})), + "alibaba": Schema.optionalKey(Schema.Struct({})), + "amazon-bedrock": Schema.optionalKey(Schema.Struct({})), + "amazon-nova": Schema.optionalKey(Schema.Struct({})), + "ambient": Schema.optionalKey(Schema.Struct({})), + "anthropic": Schema.optionalKey(Schema.Struct({})), + "anyscale": Schema.optionalKey(Schema.Struct({})), + "arcee-ai": Schema.optionalKey(Schema.Struct({})), + "atlas-cloud": Schema.optionalKey(Schema.Struct({})), + "atoma": Schema.optionalKey(Schema.Struct({})), + "avian": Schema.optionalKey(Schema.Struct({})), + "azure": Schema.optionalKey(Schema.Struct({})), + "baidu": Schema.optionalKey(Schema.Struct({})), + "baseten": Schema.optionalKey(Schema.Struct({})), + "black-forest-labs": Schema.optionalKey(Schema.Struct({})), + "byteplus": Schema.optionalKey(Schema.Struct({})), + "centml": Schema.optionalKey(Schema.Struct({})), + "cerebras": Schema.optionalKey(Schema.Struct({})), + "chutes": Schema.optionalKey(Schema.Struct({})), + "cirrascale": Schema.optionalKey(Schema.Struct({})), + "clarifai": Schema.optionalKey(Schema.Struct({})), + "claude-on-aws": Schema.optionalKey(Schema.Struct({})), + "cloudflare": Schema.optionalKey(Schema.Struct({})), + "cohere": Schema.optionalKey(Schema.Struct({})), + "coreweave": Schema.optionalKey(Schema.Struct({})), + "crofai": Schema.optionalKey(Schema.Struct({})), + "crucible": Schema.optionalKey(Schema.Struct({})), + "crusoe": Schema.optionalKey(Schema.Struct({})), + "darkbloom": Schema.optionalKey(Schema.Struct({})), + "decart": Schema.optionalKey(Schema.Struct({})), + "deepgram": Schema.optionalKey(Schema.Struct({})), + "deepinfra": Schema.optionalKey(Schema.Struct({})), + "deepseek": Schema.optionalKey(Schema.Struct({})), + "dekallm": Schema.optionalKey(Schema.Struct({})), + "digitalocean": Schema.optionalKey(Schema.Struct({})), + "enfer": Schema.optionalKey(Schema.Struct({})), + "fake-provider": Schema.optionalKey(Schema.Struct({})), + "featherless": Schema.optionalKey(Schema.Struct({})), + "fireworks": Schema.optionalKey(Schema.Struct({})), + "fish-audio": Schema.optionalKey(Schema.Struct({})), + "friendli": Schema.optionalKey(Schema.Struct({})), + "gmicloud": Schema.optionalKey(Schema.Struct({})), + "google-ai-studio": Schema.optionalKey(Schema.Struct({})), + "google-vertex": Schema.optionalKey(Schema.Struct({})), + "gopomelo": Schema.optionalKey(Schema.Struct({})), + "groq": Schema.optionalKey(Schema.Struct({})), + "heygen": Schema.optionalKey(Schema.Struct({})), + "huggingface": Schema.optionalKey(Schema.Struct({})), + "hyperbolic": Schema.optionalKey(Schema.Struct({})), + "hyperbolic-quantized": Schema.optionalKey(Schema.Struct({})), + "inception": Schema.optionalKey(Schema.Struct({})), + "inceptron": Schema.optionalKey(Schema.Struct({})), + "inferact-vllm": Schema.optionalKey(Schema.Struct({})), + "inference-net": Schema.optionalKey(Schema.Struct({})), + "infermatic": Schema.optionalKey(Schema.Struct({})), + "inflection": Schema.optionalKey(Schema.Struct({})), + "inocloud": Schema.optionalKey(Schema.Struct({})), + "io-net": Schema.optionalKey(Schema.Struct({})), + "ionstream": Schema.optionalKey(Schema.Struct({})), + "klusterai": Schema.optionalKey(Schema.Struct({})), + "krea": Schema.optionalKey(Schema.Struct({})), + "lambda": Schema.optionalKey(Schema.Struct({})), + "lepton": Schema.optionalKey(Schema.Struct({})), + "liquid": Schema.optionalKey(Schema.Struct({})), + "lynn": Schema.optionalKey(Schema.Struct({})), + "lynn-private": Schema.optionalKey(Schema.Struct({})), + "mancer": Schema.optionalKey(Schema.Struct({})), + "mancer-old": Schema.optionalKey(Schema.Struct({})), + "mara": Schema.optionalKey(Schema.Struct({})), + "meta": Schema.optionalKey(Schema.Struct({})), + "minimax": Schema.optionalKey(Schema.Struct({})), + "mistral": Schema.optionalKey(Schema.Struct({})), + "modal": Schema.optionalKey(Schema.Struct({})), + "modelrun": Schema.optionalKey(Schema.Struct({})), + "modular": Schema.optionalKey(Schema.Struct({})), + "moonshotai": Schema.optionalKey(Schema.Struct({})), + "morph": Schema.optionalKey(Schema.Struct({})), + "ncompass": Schema.optionalKey(Schema.Struct({})), + "nebius": Schema.optionalKey(Schema.Struct({})), + "nex-agi": Schema.optionalKey(Schema.Struct({})), + "nextbit": Schema.optionalKey(Schema.Struct({})), + "nineteen": Schema.optionalKey(Schema.Struct({})), + "novita": Schema.optionalKey(Schema.Struct({})), + "nvidia": Schema.optionalKey(Schema.Struct({})), + "octoai": Schema.optionalKey(Schema.Struct({})), + "open-inference": Schema.optionalKey(Schema.Struct({})), + "openai": Schema.optionalKey(Schema.Struct({})), + "parasail": Schema.optionalKey(Schema.Struct({})), + "perceptron": Schema.optionalKey(Schema.Struct({})), + "perplexity": Schema.optionalKey(Schema.Struct({})), + "phala": Schema.optionalKey(Schema.Struct({})), + "poolside": Schema.optionalKey(Schema.Struct({})), + "quiver": Schema.optionalKey(Schema.Struct({})), + "recraft": Schema.optionalKey(Schema.Struct({})), + "recursal": Schema.optionalKey(Schema.Struct({})), + "reflection": Schema.optionalKey(Schema.Struct({})), + "reka": Schema.optionalKey(Schema.Struct({})), + "relace": Schema.optionalKey(Schema.Struct({})), + "replicate": Schema.optionalKey(Schema.Struct({})), + "runway": Schema.optionalKey(Schema.Struct({})), + "sail-research": Schema.optionalKey(Schema.Struct({})), + "sakana": Schema.optionalKey(Schema.Struct({})), + "sakana-ai": Schema.optionalKey(Schema.Struct({})), + "sambanova": Schema.optionalKey(Schema.Struct({})), + "sambanova-cloaked": Schema.optionalKey(Schema.Struct({})), + "seed": Schema.optionalKey(Schema.Struct({})), + "sf-compute": Schema.optionalKey(Schema.Struct({})), + "siliconflow": Schema.optionalKey(Schema.Struct({})), + "sourceful": Schema.optionalKey(Schema.Struct({})), + "stealth": Schema.optionalKey(Schema.Struct({})), + "stepfun": Schema.optionalKey(Schema.Struct({})), + "streamlake": Schema.optionalKey(Schema.Struct({})), + "switchpoint": Schema.optionalKey(Schema.Struct({})), + "targon": Schema.optionalKey(Schema.Struct({})), + "tencent": Schema.optionalKey(Schema.Struct({})), + "tenstorrent": Schema.optionalKey(Schema.Struct({})), + "thinkingmachines": Schema.optionalKey(Schema.Struct({})), + "together": Schema.optionalKey(Schema.Struct({})), + "together-lite": Schema.optionalKey(Schema.Struct({})), + "ubicloud": Schema.optionalKey(Schema.Struct({})), + "upstage": Schema.optionalKey(Schema.Struct({})), + "venice": Schema.optionalKey(Schema.Struct({})), + "voyageai": Schema.optionalKey(Schema.Struct({})), + "wafer": Schema.optionalKey(Schema.Struct({})), + "wandb": Schema.optionalKey(Schema.Struct({})), + "wandb-legacy": Schema.optionalKey(Schema.Struct({})), + "xai": Schema.optionalKey(Schema.Struct({})), + "xiaomi": Schema.optionalKey(Schema.Struct({})), + "z-ai": Schema.optionalKey(Schema.Struct({})) }).annotate({ "description": - "A tool made available to the advisor sub-agent. Only OpenRouter server tools (e.g. openrouter:web_search) are supported; function tools are rejected because the advisor has no way to execute them. The advisor tool may not list itself.", - "identifier": "AdvisorNestedTool" + "Provider-specific options keyed by provider slug. Only options for the matched provider are forwarded; the rest are ignored. Unrecognized keys are silently dropped.", + "identifier": "ProviderOptions" }) -export type AdvisorReasoning = { - readonly "effort"?: "max" | "xhigh" | "high" | "medium" | "low" | "minimal" | "none" - readonly "max_tokens"?: number +export type PaymentRequiredResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null } -export const AdvisorReasoning = Schema.Struct({ - "effort": Schema.optionalKey( - Schema.Literals(["max", "xhigh", "high", "medium", "low", "minimal", "none"]).annotate({ - "description": "Reasoning effort level for the advisor call." - }) - ), - "max_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Maximum number of reasoning tokens the advisor may use." }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) +export const PaymentRequiredResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ) }).annotate({ - "description": - "Reasoning configuration forwarded to the advisor call. Use this to control reasoning effort and token budget for models that support extended thinking.", - "identifier": "AdvisorReasoning" + "description": "Error data for PaymentRequiredResponse", + "identifier": "PaymentRequiredResponseErrorData" }) -export type AnthropicAdvisorToolResult = { - readonly "content": {} - readonly "tool_use_id": string - readonly "type": "advisor_tool_result" +export type TooManyRequestsResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null } -export const AnthropicAdvisorToolResult = Schema.Struct({ - "content": Schema.Struct({}), - "tool_use_id": Schema.String, - "type": Schema.Literal("advisor_tool_result") -}).annotate({ "identifier": "AnthropicAdvisorToolResult" }) -export type AnthropicAllowedCallers = ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> -export const AnthropicAllowedCallers = Schema.Array( - Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"]) -).annotate({ "identifier": "AnthropicAllowedCallers" }) -export type AnthropicBase64PdfSource = { - readonly "data": string - readonly "media_type": "application/pdf" - readonly "type": "base64" +export const TooManyRequestsResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ + "description": "Error data for TooManyRequestsResponse", + "identifier": "TooManyRequestsResponseErrorData" +}) +export type BadGatewayResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null } -export const AnthropicBase64PdfSource = Schema.Struct({ - "data": Schema.String, - "media_type": Schema.Literal("application/pdf"), - "type": Schema.Literal("base64") -}).annotate({ "identifier": "AnthropicBase64PdfSource" }) -export type AnthropicBashCodeExecutionOutput = { - readonly "file_id": string - readonly "type": "bash_code_execution_output" +export const BadGatewayResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ "description": "Error data for BadGatewayResponse", "identifier": "BadGatewayResponseErrorData" }) +export type ServiceUnavailableResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null } -export const AnthropicBashCodeExecutionOutput = Schema.Struct({ - "file_id": Schema.String, - "type": Schema.Literal("bash_code_execution_output") -}).annotate({ "identifier": "AnthropicBashCodeExecutionOutput" }) -export type AnthropicBashCodeExecutionToolResultError = { - 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" +export const ServiceUnavailableResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ + "description": "Error data for ServiceUnavailableResponse", + "identifier": "ServiceUnavailableResponseErrorData" +}) +export type EdgeNetworkTimeoutResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null } -export const AnthropicBashCodeExecutionToolResultError = 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") -}).annotate({ "identifier": "AnthropicBashCodeExecutionToolResultError" }) -export type AnthropicCacheControlTtl = "5m" | "1h" -export const AnthropicCacheControlTtl = Schema.Literals(["5m", "1h"]).annotate({ - "identifier": "AnthropicCacheControlTtl" +export const EdgeNetworkTimeoutResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ + "description": "Error data for EdgeNetworkTimeoutResponse", + "identifier": "EdgeNetworkTimeoutResponseErrorData" }) -export type Objects_ = { - readonly "ephemeral_1h_input_tokens": number - readonly "ephemeral_5m_input_tokens": number - readonly [x: string]: Schema.Json +export type ProviderOverloadedResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null } -export const Objects_ = Schema.StructWithRest( - Schema.Struct({ - "ephemeral_1h_input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "ephemeral_5m_input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type AnthropicCitationCharLocation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_char_index": number - readonly "file_id": string | null - readonly "start_char_index": number - readonly "type": "char_location" +export const ProviderOverloadedResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ + "description": "Error data for ProviderOverloadedResponse", + "identifier": "ProviderOverloadedResponseErrorData" +}) +export type STTInputAudio = { readonly "data": string; readonly "format": string } +export const STTInputAudio = Schema.Struct({ + "data": Schema.String.annotate({ "description": "Base64-encoded audio data (raw bytes, not a data URI)" }), + "format": Schema.String.annotate({ + "description": "Audio format (e.g., wav, mp3, flac, m4a, ogg, webm, aac). Supported formats vary by provider." + }) +}).annotate({ "description": "Base64-encoded audio to transcribe", "identifier": "STTInputAudio" }) +export type STTTimestampGranularity = "word" | "segment" +export const STTTimestampGranularity = Schema.Literals(["word", "segment"]).annotate({ + "description": "A timestamp detail level for verbose_json transcription responses.", + "identifier": "STTTimestampGranularity" +}) +export type STTSegment = { + readonly "avg_logprob"?: number + readonly "compression_ratio"?: number + readonly "end": number + readonly "id": number + readonly "no_speech_prob"?: number + readonly "seek"?: number + readonly "speaker"?: number + readonly "start": number + readonly "temperature"?: number + readonly "text": string + readonly "tokens"?: ReadonlyArray } -export const AnthropicCitationCharLocation = Schema.Struct({ - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "document_title": Schema.Union([Schema.String, Schema.Null]), - "end_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "file_id": Schema.Union([Schema.String, Schema.Null]), - "start_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("char_location") -}).annotate({ "identifier": "AnthropicCitationCharLocation" }) -export type AnthropicCitationCharLocationParam = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_char_index": number - readonly "start_char_index": number - readonly "type": "char_location" +export const STTSegment = Schema.Struct({ + "avg_logprob": Schema.optionalKey( + Schema.Number.annotate({ "description": "Average log probability of the segment", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "compression_ratio": Schema.optionalKey( + Schema.Number.annotate({ "description": "Compression ratio of the segment", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "end": Schema.Number.annotate({ "description": "Segment end time in seconds", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "id": Schema.Number.annotate({ "description": "Segment index within the transcript" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "no_speech_prob": Schema.optionalKey( + Schema.Number.annotate({ "description": "Probability the segment contains no speech", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "seek": Schema.optionalKey( + Schema.Number.annotate({ "description": "Seek offset of the segment" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "speaker": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Speaker index for the segment, present when the provider returns diarization data" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "start": Schema.Number.annotate({ "description": "Segment start time in seconds", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ "description": "Temperature used for the segment", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "text": Schema.String.annotate({ "description": "Transcribed text of the segment" }), + "tokens": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({ + "description": "Token IDs of the segment" + }) + ) +}).annotate({ + "description": "A timestamped transcript segment, returned when response_format is verbose_json", + "identifier": "STTSegment" +}) +export type STTUsage = { + readonly "cost"?: number + readonly "input_tokens"?: number + readonly "output_tokens"?: number + readonly "seconds"?: number + readonly "total_tokens"?: number } -export const AnthropicCitationCharLocationParam = Schema.Struct({ - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "document_title": Schema.Union([Schema.String, Schema.Null]), - "end_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "start_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("char_location") -}).annotate({ "identifier": "AnthropicCitationCharLocationParam" }) -export type AnthropicCitationContentBlockLocation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_block_index": number - readonly "file_id": string | null - readonly "start_block_index": number - readonly "type": "content_block_location" +export const STTUsage = Schema.Struct({ + "cost": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total cost of the request in USD", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "input_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of input tokens billed for this request" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "output_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Number of output tokens generated" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "seconds": Schema.optionalKey( + Schema.Number.annotate({ "description": "Duration of the input audio in seconds", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "total_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Total number of tokens used (input + output)" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ) +}).annotate({ "description": "Aggregated usage statistics for the request", "identifier": "STTUsage" }) +export type STTWord = { + readonly "end": number + readonly "speaker"?: number + readonly "start": number + readonly "word": string } -export const AnthropicCitationContentBlockLocation = Schema.Struct({ - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "document_title": Schema.Union([Schema.String, Schema.Null]), - "end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "file_id": Schema.Union([Schema.String, Schema.Null]), - "start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("content_block_location") -}).annotate({ "identifier": "AnthropicCitationContentBlockLocation" }) -export type AnthropicCitationContentBlockLocationParam = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_block_index": number - readonly "start_block_index": number - readonly "type": "content_block_location" +export const STTWord = Schema.Struct({ + "end": Schema.Number.annotate({ "description": "Word end time in seconds", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "speaker": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Speaker index for the word, present when the provider returns diarization data" + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "start": Schema.Number.annotate({ "description": "Word start time in seconds", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "word": Schema.String.annotate({ "description": "The transcribed word" }) +}).annotate({ + "description": "A timestamped word, returned when the provider includes word-level timestamps", + "identifier": "STTWord" +}) +export type ConflictResponseErrorData = { + readonly "code": number + readonly "message": string + readonly "metadata"?: { readonly [x: string]: Schema.Json } | null } -export const AnthropicCitationContentBlockLocationParam = Schema.Struct({ - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "document_title": Schema.Union([Schema.String, Schema.Null]), - "end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("content_block_location") -}).annotate({ "identifier": "AnthropicCitationContentBlockLocationParam" }) -export type AnthropicCitationPageLocation = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_page_number": number - readonly "file_id": string | null - readonly "start_page_number": number - readonly "type": "page_location" +export const ConflictResponseErrorData = Schema.Struct({ + "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "message": Schema.String, + "metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ) +}).annotate({ "description": "Error data for ConflictResponse", "identifier": "ConflictResponseErrorData" }) +export type UnifiedBenchmarkPricing = { + readonly "completion": string + readonly "prompt": string + readonly [x: string]: Schema.Json +} | null +export const UnifiedBenchmarkPricing = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "completion": Schema.String.annotate({ "description": "Cost per output token (USD, decimal string)." }), + "prompt": Schema.String.annotate({ "description": "Cost per input token (USD, decimal string)." }) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ + "description": "OpenRouter pricing per token for this model. Null if pricing is unavailable.", + "identifier": "UnifiedBenchmarkPricing" +}) +export type UnifiedBenchmarksORItem = { + readonly "accuracy": number + readonly "accuracy_stddev": number | null + readonly "avg_cost_per_task": number | null + readonly "benchmark_type": "gpqa_diamond" | "tau_bench_verified_airline" + readonly "display_name": string + readonly "last_run_timestamp": string + readonly "model_permaslug": string + readonly "source": "openrouter" + readonly "total_tasks": number } -export const AnthropicCitationPageLocation = Schema.Struct({ - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "document_title": Schema.Union([Schema.String, Schema.Null]), - "end_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "file_id": Schema.Union([Schema.String, Schema.Null]), - "start_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("page_location") -}).annotate({ "identifier": "AnthropicCitationPageLocation" }) -export type AnthropicCitationPageLocationParam = { - readonly "cited_text": string - readonly "document_index": number - readonly "document_title": string | null - readonly "end_page_number": number - readonly "start_page_number": number - readonly "type": "page_location" -} -export const AnthropicCitationPageLocationParam = Schema.Struct({ - "cited_text": Schema.String, - "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "document_title": Schema.Union([Schema.String, Schema.Null]), - "end_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "start_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("page_location") -}).annotate({ "identifier": "AnthropicCitationPageLocationParam" }) -export type Objects_1 = { readonly "enabled": boolean; readonly [x: string]: Schema.Json } -export const Objects_1 = Schema.StructWithRest(Schema.Struct({ "enabled": Schema.Boolean }), [ - Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) -]) -export type AnthropicCitationSearchResultLocation = { - readonly "cited_text": string - readonly "end_block_index": number - readonly "search_result_index": number - readonly "source": string - readonly "start_block_index": number - readonly "title": string | null - readonly "type": "search_result_location" -} -export const AnthropicCitationSearchResultLocation = Schema.Struct({ - "cited_text": Schema.String, - "end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "search_result_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "source": Schema.String, - "start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "title": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("search_result_location") -}).annotate({ "identifier": "AnthropicCitationSearchResultLocation" }) -export type AnthropicCitationSearchResultLocationParam = { - readonly "cited_text": string - readonly "end_block_index": number - readonly "search_result_index": number - readonly "source": string - readonly "start_block_index": number - readonly "title": string | null - readonly "type": "search_result_location" -} -export const AnthropicCitationSearchResultLocationParam = Schema.Struct({ - "cited_text": Schema.String, - "end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "search_result_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "source": Schema.String, - "start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "title": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("search_result_location") -}).annotate({ "identifier": "AnthropicCitationSearchResultLocationParam" }) -export type AnthropicCitationWebSearchResultLocation = { - readonly "cited_text": string - readonly "encrypted_index": string - readonly "title": string | null - readonly "type": "web_search_result_location" - readonly "url": string -} -export const AnthropicCitationWebSearchResultLocation = Schema.Struct({ - "cited_text": Schema.String, - "encrypted_index": Schema.String, - "title": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("web_search_result_location"), - "url": Schema.String -}).annotate({ "identifier": "AnthropicCitationWebSearchResultLocation" }) -export type AnthropicCitationWebSearchResultLocationParam = { - readonly "cited_text": string - readonly "encrypted_index": string - readonly "title": string | null - readonly "type": "web_search_result_location" - readonly "url": string -} -export const AnthropicCitationWebSearchResultLocationParam = Schema.Struct({ - "cited_text": Schema.String, - "encrypted_index": Schema.String, - "title": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("web_search_result_location"), - "url": Schema.String -}).annotate({ "identifier": "AnthropicCitationWebSearchResultLocationParam" }) -export type AnthropicCodeExecution20250825Caller = { - readonly "tool_id": string - readonly "type": "code_execution_20250825" +export const UnifiedBenchmarksORItem = Schema.Struct({ + "accuracy": Schema.Number.annotate({ + "description": "Aggregate accuracy score from 0 to 1. Higher is better.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "accuracy_stddev": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Standard deviation of run accuracy, or null for a single run.", "format": "double" }), + "avg_cost_per_task": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Average cost per task in USD, or null if unavailable.", "format": "double" }), + "benchmark_type": Schema.Literals(["gpqa_diamond", "tau_bench_verified_airline"]).annotate({ + "description": "OpenRouter benchmark evaluation type." + }), + "display_name": Schema.String.annotate({ "description": "Human-readable model name." }), + "last_run_timestamp": Schema.String.annotate({ "description": "Timestamp of the most recent public benchmark run." }), + "model_permaslug": Schema.String.annotate({ "description": "Stable OpenRouter model identifier." }), + "source": Schema.Literal("openrouter").annotate({ "description": "Benchmark source discriminator." }), + "total_tasks": Schema.Number.annotate({ "description": "Total benchmark tasks across runs." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "UnifiedBenchmarksORItem" }) +export type UnifiedBenchmarksMeta = { + readonly "as_of": string + readonly "citation": string | null + readonly "model_count": number + readonly "source": "artificial-analysis" | "design-arena" | "openrouter" | null + readonly "source_url": string | null + readonly "task_type": string | null + readonly "version": "v1" } -export const AnthropicCodeExecution20250825Caller = Schema.Struct({ - "tool_id": Schema.String, - "type": Schema.Literal("code_execution_20250825") -}).annotate({ "identifier": "AnthropicCodeExecution20250825Caller" }) -export type AnthropicCodeExecution20260120Caller = { - readonly "tool_id": string - readonly "type": "code_execution_20260120" +export const UnifiedBenchmarksMeta = Schema.Struct({ + "as_of": Schema.String.annotate({ "description": "ISO-8601 timestamp of when this data was last updated." }), + "citation": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "Required attribution when republishing this data, or null when results span multiple sources (attribute each item individually by its `source` discriminator)." + }), + "model_count": Schema.Number.annotate({ "description": "Number of unique models in the response." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "source": Schema.Union([ + Schema.Literal("artificial-analysis"), + Schema.Literal("design-arena"), + Schema.Literal("openrouter"), + Schema.Null + ]).annotate({ "description": "The source filter applied, or null when all sources are returned." }), + "source_url": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "URL of the upstream data source, or null when results span multiple sources." + }), + "task_type": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The task_type filter applied, or null if showing all." + }), + "version": Schema.Literal("v1").annotate({ "description": "Dataset version." }) +}).annotate({ "identifier": "UnifiedBenchmarksMeta" }) +export type BYOKProviderSlug = + | "ai21" + | "aion-labs" + | "akashml" + | "alibaba" + | "amazon-bedrock" + | "amazon-nova" + | "ambient" + | "anthropic" + | "arcee-ai" + | "atlas-cloud" + | "avian" + | "azure" + | "baidu" + | "baseten" + | "black-forest-labs" + | "byteplus" + | "cerebras" + | "chutes" + | "cirrascale" + | "clarifai" + | "cloudflare" + | "cohere" + | "coreweave" + | "crusoe" + | "darkbloom" + | "decart" + | "deepgram" + | "deepinfra" + | "deepseek" + | "dekallm" + | "digitalocean" + | "featherless" + | "fireworks" + | "fish-audio" + | "friendli" + | "gmicloud" + | "google-ai-studio" + | "google-vertex" + | "groq" + | "heygen" + | "inception" + | "inceptron" + | "inferact-vllm" + | "inference-net" + | "infermatic" + | "inflection" + | "io-net" + | "ionstream" + | "krea" + | "liquid" + | "mancer" + | "mara" + | "meta" + | "minimax" + | "mistral" + | "modal" + | "modelrun" + | "modular" + | "moonshotai" + | "morph" + | "ncompass" + | "nebius" + | "nex-agi" + | "nextbit" + | "novita" + | "nvidia" + | "open-inference" + | "openai" + | "parasail" + | "perceptron" + | "perplexity" + | "phala" + | "poolside" + | "quiver" + | "recraft" + | "reka" + | "relace" + | "runway" + | "sail-research" + | "sakana" + | "sakana-ai" + | "sambanova" + | "seed" + | "siliconflow" + | "sourceful" + | "stepfun" + | "streamlake" + | "switchpoint" + | "tencent" + | "tenstorrent" + | "thinkingmachines" + | "together" + | "upstage" + | "venice" + | "wafer" + | "wandb" + | "wandb-legacy" + | "xai" + | "xiaomi" + | "z-ai" +export const BYOKProviderSlug = Schema.Literals([ + "ai21", + "aion-labs", + "akashml", + "alibaba", + "amazon-bedrock", + "amazon-nova", + "ambient", + "anthropic", + "arcee-ai", + "atlas-cloud", + "avian", + "azure", + "baidu", + "baseten", + "black-forest-labs", + "byteplus", + "cerebras", + "chutes", + "cirrascale", + "clarifai", + "cloudflare", + "cohere", + "coreweave", + "crusoe", + "darkbloom", + "decart", + "deepgram", + "deepinfra", + "deepseek", + "dekallm", + "digitalocean", + "featherless", + "fireworks", + "fish-audio", + "friendli", + "gmicloud", + "google-ai-studio", + "google-vertex", + "groq", + "heygen", + "inception", + "inceptron", + "inferact-vllm", + "inference-net", + "infermatic", + "inflection", + "io-net", + "ionstream", + "krea", + "liquid", + "mancer", + "mara", + "meta", + "minimax", + "mistral", + "modal", + "modelrun", + "modular", + "moonshotai", + "morph", + "ncompass", + "nebius", + "nex-agi", + "nextbit", + "novita", + "nvidia", + "open-inference", + "openai", + "parasail", + "perceptron", + "perplexity", + "phala", + "poolside", + "quiver", + "recraft", + "reka", + "relace", + "runway", + "sail-research", + "sakana", + "sakana-ai", + "sambanova", + "seed", + "siliconflow", + "sourceful", + "stepfun", + "streamlake", + "switchpoint", + "tencent", + "tenstorrent", + "thinkingmachines", + "together", + "upstage", + "venice", + "wafer", + "wandb", + "wandb-legacy", + "xai", + "xiaomi", + "z-ai" +]).annotate({ + "description": + "The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`).", + "identifier": "BYOKProviderSlug" +}) +export type DeleteBYOKKeyResponse = { readonly "deleted": true } +export const DeleteBYOKKeyResponse = Schema.Struct({ + "deleted": Schema.Literal(true).annotate({ "description": "Confirmation that the BYOK credential was deleted." }) +}).annotate({ "identifier": "DeleteBYOKKeyResponse" }) +export type UpdateBYOKKeyRequest = { + readonly "allowed_models"?: ReadonlyArray | null + readonly "allowed_user_ids"?: ReadonlyArray | null + readonly "disabled"?: boolean + readonly "is_fallback"?: boolean + readonly "key"?: string + readonly "name"?: string | null } -export const AnthropicCodeExecution20260120Caller = Schema.Struct({ - "tool_id": Schema.String, - "type": Schema.Literal("code_execution_20260120") -}).annotate({ "identifier": "AnthropicCodeExecution20260120Caller" }) -export type AnthropicCodeExecutionOutput = { readonly "file_id": string; readonly "type": "code_execution_output" } -export const AnthropicCodeExecutionOutput = Schema.Struct({ - "file_id": Schema.String, - "type": Schema.Literal("code_execution_output") -}).annotate({ "identifier": "AnthropicCodeExecutionOutput" }) -export type AnthropicCompactionBlock = { readonly "content": string | null; readonly "type": "compaction" } -export const AnthropicCompactionBlock = Schema.Struct({ - "content": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("compaction") -}).annotate({ "identifier": "AnthropicCompactionBlock" }) -export type AnthropicContainer = { - readonly "expires_at": string - readonly "id": string - readonly [x: string]: Schema.Json -} | null -export const AnthropicContainer = Schema.Union([ - Schema.StructWithRest(Schema.Struct({ "expires_at": Schema.String, "id": Schema.String }), [ +export const UpdateBYOKKeyRequest = Schema.Struct({ + "allowed_models": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) + ), + Schema.Null + ]).annotate({ + "description": "Optional allowlist of model slugs this credential may be used for. `null` means no restriction." + }) + ), + "allowed_user_ids": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) + ), + Schema.Null + ]).annotate({ + "description": "Optional allowlist of user IDs that may use this credential. `null` means no restriction." + }) + ), + "disabled": Schema.optionalKey(Schema.Boolean.annotate({ "description": "Whether this credential is disabled." })), + "is_fallback": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried." + }) + ), + "key": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A new raw provider API key to rotate the credential in-place. The previous key material is overwritten and the masked label is regenerated. Encrypted at rest and never returned in API responses." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ), + "name": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })), + Schema.Null + ]).annotate({ "description": "Optional human-readable name for the credential." }) + ) +}).annotate({ "identifier": "UpdateBYOKKeyRequest" }) +export type MetadataLevel = "disabled" | "enabled" +export const MetadataLevel = Schema.Literals(["disabled", "enabled"]).annotate({ + "description": "Opt-in level for surfacing routing metadata on the response under `openrouter_metadata`.", + "identifier": "MetadataLevel" +}) +export type AnthropicCacheControlTtl = "5m" | "1h" +export const AnthropicCacheControlTtl = Schema.Literals(["5m", "1h"]).annotate({ + "identifier": "AnthropicCacheControlTtl" +}) +export type ChatDebugOptions = { readonly "echo_upstream_body"?: boolean } +export const ChatDebugOptions = 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)", + "identifier": "ChatDebugOptions" +}) +export type ImageConfig = {} +export const ImageConfig = 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.", + "identifier": "ImageConfig" +}) +export type PromptCacheBreakpoint = { readonly "mode": "explicit"; readonly [x: string]: Schema.Json } | null +export const PromptCacheBreakpoint = Schema.Union([ + Schema.StructWithRest(Schema.Struct({ "mode": Schema.Literal("explicit") }), [ Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) ]), Schema.Null -]).annotate({ "identifier": "AnthropicContainer" }) -export type AnthropicContainerUpload = { readonly "file_id": string; readonly "type": "container_upload" } -export const AnthropicContainerUpload = Schema.Struct({ - "file_id": Schema.String, - "type": Schema.Literal("container_upload") -}).annotate({ "identifier": "AnthropicContainerUpload" }) -export type AnthropicDirectCaller = { readonly "type": "direct" } -export const AnthropicDirectCaller = Schema.Struct({ "type": Schema.Literal("direct") }).annotate({ - "identifier": "AnthropicDirectCaller" -}) -export type AnthropicFileDocumentSource = { readonly "file_id": string; readonly "type": "file" } -export const AnthropicFileDocumentSource = Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("file") }) - .annotate({ "identifier": "AnthropicFileDocumentSource" }) -export type AnthropicImageMimeType = "image/jpeg" | "image/png" | "image/gif" | "image/webp" -export const AnthropicImageMimeType = Schema.Literals(["image/jpeg", "image/png", "image/gif", "image/webp"]).annotate({ - "identifier": "AnthropicImageMimeType" +]).annotate({ + "description": + "Marks an explicit prompt-cache boundary on this content block (OpenAI-style). Everything through the block carrying this marker is part of the candidate cached prefix. Supported natively by OpenAI GPT-5.6 and newer; on providers that use Anthropic-style `cache_control`, OpenRouter converts the marker to that format automatically.", + "identifier": "PromptCacheBreakpoint" }) -export type Objects_2 = { readonly "type": "input_tokens"; readonly "value": number; readonly [x: string]: Schema.Json } -export const Objects_2 = Schema.StructWithRest( - Schema.Struct({ - "type": Schema.Literal("input_tokens"), - "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type AnthropicInputTokensTrigger = { readonly "type": "input_tokens"; readonly "value": number } -export const AnthropicInputTokensTrigger = Schema.Struct({ - "type": Schema.Literal("input_tokens"), - "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "identifier": "AnthropicInputTokensTrigger" }) -export type Objects_3 = { - readonly "ephemeral_1h_input_tokens"?: number - readonly "ephemeral_5m_input_tokens"?: number - readonly [x: string]: Schema.Json +export type ChatContentImage = { + readonly "image_url": { readonly "detail"?: "auto" | "low" | "high" | "original"; readonly "url": string } + readonly "type": "image_url" } -export const Objects_3 = Schema.StructWithRest( - Schema.Struct({ - "ephemeral_1h_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +export const ChatContentImage = Schema.Struct({ + "image_url": Schema.Struct({ + "detail": Schema.optionalKey( + Schema.Literals(["auto", "low", "high", "original"]).annotate({ + "description": + "Image detail level for vision models. `original` is an OpenRouter extension (not in the OpenAI Chat Completions spec) requesting true original-resolution media; it is downgraded to `high` for providers that lack an original-resolution tier." + }) ), - "ephemeral_5m_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - ) + "url": Schema.String.annotate({ "description": "URL of the image (data: URLs supported)" }) }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type AnthropicOutputTokensDetails = - | { readonly "thinking_tokens": number; readonly [x: string]: Schema.Json } - | null -export const AnthropicOutputTokensDetails = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ "thinking_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ "identifier": "AnthropicOutputTokensDetails" }) -export type AnthropicPlainTextSource = { - readonly "data": string - readonly "media_type": "text/plain" - readonly "type": "text" + "type": Schema.Literal("image_url") +}).annotate({ "description": "Image content part for vision models", "identifier": "ChatContentImage" }) +export type ChatContentAudio = { + readonly "input_audio": { readonly "data": string; readonly "format": string } + readonly "type": "input_audio" } -export const AnthropicPlainTextSource = Schema.Struct({ - "data": Schema.String, - "media_type": Schema.Literal("text/plain"), - "type": Schema.Literal("text") -}).annotate({ "identifier": "AnthropicPlainTextSource" }) -export type AnthropicRedactedThinkingBlock = { readonly "data": string; readonly "type": "redacted_thinking" } -export const AnthropicRedactedThinkingBlock = Schema.Struct({ - "data": Schema.String, - "type": Schema.Literal("redacted_thinking") -}).annotate({ "identifier": "AnthropicRedactedThinkingBlock" }) -export type AnthropicRefusalStopDetails = { - readonly "category": "cyber" | "bio" | null - readonly "explanation": string | null - readonly "type": "refusal" - readonly [x: string]: Schema.Json -} | null -export const AnthropicRefusalStopDetails = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "category": Schema.Union([Schema.Literal("cyber"), Schema.Literal("bio"), Schema.Null]), - "explanation": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("refusal") - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ "description": "Structured information about a refusal", "identifier": "AnthropicRefusalStopDetails" }) -export type AnthropicServerToolErrorCode = - | "invalid_tool_input" - | "unavailable" - | "too_many_requests" - | "execution_time_exceeded" -export const AnthropicServerToolErrorCode = Schema.Literals([ - "invalid_tool_input", - "unavailable", - "too_many_requests", - "execution_time_exceeded" -]).annotate({ "identifier": "AnthropicServerToolErrorCode" }) -export type AnthropicServerToolUsage = { - readonly "web_fetch_requests": number - readonly "web_search_requests": number - readonly [x: string]: Schema.Json -} | null -export const AnthropicServerToolUsage = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "web_fetch_requests": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "web_search_requests": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ "identifier": "AnthropicServerToolUsage" }) -export type AnthropicServiceTier = "standard" | "priority" | "batch" | null -export const AnthropicServiceTier = Schema.Union([ - Schema.Literal("standard"), - Schema.Literal("priority"), - Schema.Literal("batch"), - Schema.Null -]).annotate({ "identifier": "AnthropicServiceTier" }) -export type AnthropicSpeed = "fast" | "standard" | null -export const AnthropicSpeed = Schema.Union([Schema.Literal("fast"), Schema.Literal("standard"), Schema.Null]).annotate({ - "identifier": "AnthropicSpeed" -}) -export type AnthropicTextEditorCodeExecutionCreateResult = { - readonly "is_file_update": boolean - readonly "type": "text_editor_code_execution_create_result" -} -export const AnthropicTextEditorCodeExecutionCreateResult = Schema.Struct({ - "is_file_update": Schema.Boolean, - "type": Schema.Literal("text_editor_code_execution_create_result") -}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionCreateResult" }) -export type AnthropicTextEditorCodeExecutionStrReplaceResult = { - readonly "lines": ReadonlyArray | null - readonly "new_lines": number | null - readonly "new_start": number | null - readonly "old_lines": number | null - readonly "old_start": number | null - readonly "type": "text_editor_code_execution_str_replace_result" -} -export const AnthropicTextEditorCodeExecutionStrReplaceResult = Schema.Struct({ - "lines": Schema.Union([Schema.Array(Schema.String), Schema.Null]), - "new_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), - "new_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), - "old_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), - "old_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), - "type": Schema.Literal("text_editor_code_execution_str_replace_result") -}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionStrReplaceResult" }) -export type AnthropicTextEditorCodeExecutionToolResultError = { - readonly "error_code": - | "invalid_tool_input" - | "unavailable" - | "too_many_requests" - | "execution_time_exceeded" - | "file_not_found" - readonly "error_message": string | null - readonly "type": "text_editor_code_execution_tool_result_error" -} -export const AnthropicTextEditorCodeExecutionToolResultError = Schema.Struct({ - "error_code": Schema.Literals([ - "invalid_tool_input", - "unavailable", - "too_many_requests", - "execution_time_exceeded", - "file_not_found" - ]), - "error_message": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("text_editor_code_execution_tool_result_error") -}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionToolResultError" }) -export type AnthropicTextEditorCodeExecutionViewResult = { - readonly "content": string - readonly "file_type": "text" | "image" | "pdf" - readonly "num_lines": number | null - readonly "start_line": number | null - readonly "total_lines": number | null - readonly "type": "text_editor_code_execution_view_result" -} -export const AnthropicTextEditorCodeExecutionViewResult = Schema.Struct({ - "content": Schema.String, - "file_type": Schema.Literals(["text", "image", "pdf"]), - "num_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), - "start_line": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), - "total_lines": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]), - "type": Schema.Literal("text_editor_code_execution_view_result") -}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionViewResult" }) -export type AnthropicThinkingBlock = { - readonly "signature": string - readonly "thinking": string - readonly "type": "thinking" -} -export const AnthropicThinkingBlock = Schema.Struct({ - "signature": Schema.String, - "thinking": Schema.String, - "type": Schema.Literal("thinking") -}).annotate({ "identifier": "AnthropicThinkingBlock" }) -export type AnthropicThinkingDisplay = "summarized" | "omitted" | null -export const AnthropicThinkingDisplay = Schema.Union([ - Schema.Literal("summarized"), - Schema.Literal("omitted"), - Schema.Null -]).annotate({ "identifier": "AnthropicThinkingDisplay" }) -export type AnthropicThinkingTurns = { readonly "type": "thinking_turns"; readonly "value": number } -export const AnthropicThinkingTurns = Schema.Struct({ - "type": Schema.Literal("thinking_turns"), - "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "identifier": "AnthropicThinkingTurns" }) -export type AnthropicToolReference = { readonly "tool_name": string; readonly "type": "tool_reference" } -export const AnthropicToolReference = Schema.Struct({ - "tool_name": Schema.String, - "type": Schema.Literal("tool_reference") -}).annotate({ "identifier": "AnthropicToolReference" }) -export type AnthropicToolUsesKeep = { readonly "type": "tool_uses"; readonly "value": number } -export const AnthropicToolUsesKeep = Schema.Struct({ - "type": Schema.Literal("tool_uses"), - "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "identifier": "AnthropicToolUsesKeep" }) -export type AnthropicToolUsesTrigger = { readonly "type": "tool_uses"; readonly "value": number } -export const AnthropicToolUsesTrigger = Schema.Struct({ - "type": Schema.Literal("tool_uses"), - "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "identifier": "AnthropicToolUsesTrigger" }) -export type AnthropicUrlImageSource = { readonly "type": "url"; readonly "url": string } -export const AnthropicUrlImageSource = Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }).annotate({ - "identifier": "AnthropicUrlImageSource" -}) -export type AnthropicUrlPdfSource = { readonly "type": "url"; readonly "url": string } -export const AnthropicUrlPdfSource = Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }).annotate({ - "identifier": "AnthropicUrlPdfSource" -}) -export type AnthropicWebFetchToolResultError = { - 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": "web_fetch_tool_result_error" -} -export const AnthropicWebFetchToolResultError = Schema.Struct({ - "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" - ]), - "type": Schema.Literal("web_fetch_tool_result_error") -}).annotate({ "identifier": "AnthropicWebFetchToolResultError" }) -export type AnthropicWebSearchResult = { - readonly "encrypted_content": string - readonly "page_age": string | null - readonly "title": string - readonly "type": "web_search_result" - readonly "url": string -} -export const AnthropicWebSearchResult = Schema.Struct({ - "encrypted_content": Schema.String, - "page_age": Schema.Union([Schema.String, Schema.Null]), - "title": Schema.String, - "type": Schema.Literal("web_search_result"), - "url": Schema.String -}).annotate({ "identifier": "AnthropicWebSearchResult" }) -export type AnthropicWebSearchResultBlockParam = { - readonly "encrypted_content": string - readonly "page_age"?: string | null - readonly "title": string - readonly "type": "web_search_result" - readonly "url": string -} -export const AnthropicWebSearchResultBlockParam = Schema.Struct({ - "encrypted_content": Schema.String, - "page_age": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "title": Schema.String, - "type": Schema.Literal("web_search_result"), - "url": Schema.String -}).annotate({ "identifier": "AnthropicWebSearchResultBlockParam" }) -export type AnthropicWebSearchToolResultError = { - readonly "error_code": - | "invalid_tool_input" - | "unavailable" - | "max_uses_exceeded" - | "too_many_requests" - | "query_too_long" - | "request_too_large" - readonly "type": "web_search_tool_result_error" -} -export const AnthropicWebSearchToolResultError = Schema.Struct({ - "error_code": Schema.Literals([ - "invalid_tool_input", - "unavailable", - "max_uses_exceeded", - "too_many_requests", - "query_too_long", - "request_too_large" - ]), - "type": Schema.Literal("web_search_tool_result_error") -}).annotate({ "identifier": "AnthropicWebSearchToolResultError" }) -export type Objects_4 = { - readonly "city"?: string | null - readonly "country"?: string | null - readonly "region"?: string | null - readonly "timezone"?: string | null - readonly "type": "approximate" - readonly [x: string]: Schema.Json -} -export const Objects_4 = Schema.StructWithRest( - Schema.Struct({ - "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("approximate") +export const ChatContentAudio = Schema.Struct({ + "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." + }) }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type ApiErrorType = - | "context_length_exceeded" - | "max_tokens_exceeded" - | "token_limit_exceeded" - | "string_too_long" - | "authentication" - | "permission_denied" - | "payment_required" - | "rate_limit_exceeded" - | "provider_overloaded" - | "provider_unavailable" - | "invalid_request" - | "invalid_prompt" - | "not_found" - | "precondition_failed" - | "payload_too_large" - | "unprocessable" - | "content_policy_violation" - | "refusal" - | "invalid_image" - | "image_too_large" - | "image_too_small" - | "unsupported_image_format" - | "image_not_found" - | "image_download_failed" - | "server" - | "timeout" - | "unmapped" -export const ApiErrorType = Schema.Literals([ - "context_length_exceeded", - "max_tokens_exceeded", - "token_limit_exceeded", - "string_too_long", - "authentication", - "permission_denied", - "payment_required", - "rate_limit_exceeded", - "provider_overloaded", - "provider_unavailable", - "invalid_request", - "invalid_prompt", - "not_found", - "precondition_failed", - "payload_too_large", - "unprocessable", - "content_policy_violation", - "refusal", - "invalid_image", - "image_too_large", - "image_too_small", - "unsupported_image_format", - "image_not_found", - "image_download_failed", - "server", - "timeout", - "unmapped" -]).annotate({ - "description": "Canonical OpenRouter error type, stable across all API formats", - "identifier": "ApiErrorType" -}) -export type ApplyPatchCallOperationDiffDeltaEvent = { - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.apply_patch_call_operation_diff.delta" -} -export const ApplyPatchCallOperationDiffDeltaEvent = Schema.Struct({ - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.apply_patch_call_operation_diff.delta") -}).annotate({ - "description": "Incremental chunk of `operation.diff` for an `apply_patch_call`. Matches OpenAI's streaming shape.", - "identifier": "ApplyPatchCallOperationDiffDeltaEvent" -}) -export type ApplyPatchCallOperationDiffDoneEvent = { - readonly "diff": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.apply_patch_call_operation_diff.done" -} -export const ApplyPatchCallOperationDiffDoneEvent = Schema.Struct({ - "diff": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.apply_patch_call_operation_diff.done") + "type": Schema.Literal("input_audio") }).annotate({ - "description": "Emitted when `operation.diff` streaming completes for an `apply_patch_call`.", - "identifier": "ApplyPatchCallOperationDiffDoneEvent" + "description": "Audio input content part. Supported audio formats vary by provider.", + "identifier": "ChatContentAudio" }) -export type ApplyPatchCallOutputItem = { - readonly "call_id": string - readonly "id"?: string | null - readonly "output"?: string | null - readonly "status": "completed" | "failed" - readonly "type": "apply_patch_call_output" +export type Legacy_ChatContentVideoInput = { readonly "url": string } +export const Legacy_ChatContentVideoInput = Schema.Struct({ + "url": Schema.String.annotate({ "description": "URL of the video (data: URLs supported)" }) +}).annotate({ "description": "Video input object", "identifier": "Legacy_ChatContentVideoInput" }) +export type ChatContentVideoInput = { readonly "url": string } +export const ChatContentVideoInput = Schema.Struct({ + "url": Schema.String.annotate({ "description": "URL of the video (data: URLs supported)" }) +}).annotate({ "description": "Video input object", "identifier": "ChatContentVideoInput" }) +export type ChatContentFile = { + readonly "file": { readonly "file_data"?: string; readonly "file_id"?: string; readonly "filename"?: string } + readonly "type": "file" } -export const ApplyPatchCallOutputItem = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "output": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "status": Schema.Literals(["completed", "failed"]), - "type": Schema.Literal("apply_patch_call_output") -}).annotate({ - "description": - "The client's echo of an `apply_patch_call` after applying the patch. `output` is an optional human-readable log; `status` is `completed` when the patch was applied successfully, `failed` otherwise.", - "identifier": "ApplyPatchCallOutputItem" -}) -export type ApplyPatchCallStatus = "in_progress" | "completed" -export const ApplyPatchCallStatus = Schema.Literals(["in_progress", "completed"]).annotate({ - "description": "Lifecycle state of an `apply_patch_call` output item.", - "identifier": "ApplyPatchCallStatus" -}) -export type ApplyPatchCreateFileOperation = { - readonly "diff": string - readonly "path": string - readonly "type": "create_file" +export const ChatContentFile = Schema.Struct({ + "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" })) + }), + "type": Schema.Literal("file") +}).annotate({ "description": "File content part for document processing", "identifier": "ChatContentFile" }) +export type ChatAudioOutput = { + readonly "data"?: string + readonly "expires_at"?: number + readonly "id"?: string + readonly "transcript"?: string } -export const ApplyPatchCreateFileOperation = Schema.Struct({ - "diff": Schema.String, - "path": Schema.String, - "type": Schema.Literal("create_file") -}).annotate({ - "description": - "The `create_file` variant of an `apply_patch_call.operation`. Carries a V4A diff describing the new file contents.", - "identifier": "ApplyPatchCreateFileOperation" -}) -export type ApplyPatchDeleteFileOperation = { readonly "path": string; readonly "type": "delete_file" } -export const ApplyPatchDeleteFileOperation = Schema.Struct({ - "path": Schema.String, - "type": Schema.Literal("delete_file") -}).annotate({ - "description": - "The `delete_file` variant of an `apply_patch_call.operation`. Identifies the file to remove; no diff is required.", - "identifier": "ApplyPatchDeleteFileOperation" -}) -export type ApplyPatchEngineEnum = "auto" | "native" | "openrouter" -export const ApplyPatchEngineEnum = Schema.Literals(["auto", "native", "openrouter"]).annotate({ - "description": - "Which apply_patch engine to use. \"auto\" (default) uses native passthrough when the endpoint advertises native apply_patch support, otherwise falls back to OpenRouter's HITL validator. \"native\" forces native passthrough — when the endpoint does not support native, the request falls back to HITL. \"openrouter\" always runs the HITL validator. Native passthrough streams the diff incrementally via `apply_patch_call_operation_diff.delta` events; HITL buffers the diff for atomic delivery as a single delta.", - "identifier": "ApplyPatchEngineEnum" -}) -export type ApplyPatchServerTool = { readonly "type": "apply_patch" } -export const ApplyPatchServerTool = Schema.Struct({ "type": Schema.Literal("apply_patch") }).annotate({ - "description": "Apply patch tool configuration", - "identifier": "ApplyPatchServerTool" -}) -export type ApplyPatchUpdateFileOperation = { - readonly "diff": string - readonly "path": string - readonly "type": "update_file" +export const ChatAudioOutput = Schema.Struct({ + "data": Schema.optionalKey(Schema.String.annotate({ "description": "Base64 encoded audio data" })), + "expires_at": Schema.optionalKey( + Schema.Number.annotate({ "description": "Audio expiration timestamp" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "id": Schema.optionalKey(Schema.String.annotate({ "description": "Audio output identifier" })), + "transcript": Schema.optionalKey(Schema.String.annotate({ "description": "Audio transcript" })) +}).annotate({ "description": "Audio output data or reference", "identifier": "ChatAudioOutput" }) +export type ReasoningFormat = + | "unknown" + | "openai-responses-v1" + | "azure-openai-responses-v1" + | "bedrock-openai-responses-v1" + | "xai-responses-v1" + | "meta-responses-v1" + | "anthropic-claude-v1" + | "google-gemini-v1" + | null +export const ReasoningFormat = Schema.Union([ + Schema.Literal("unknown"), + Schema.Literal("openai-responses-v1"), + Schema.Literal("azure-openai-responses-v1"), + Schema.Literal("bedrock-openai-responses-v1"), + Schema.Literal("xai-responses-v1"), + Schema.Literal("meta-responses-v1"), + Schema.Literal("anthropic-claude-v1"), + Schema.Literal("google-gemini-v1"), + Schema.Null +]).annotate({ "identifier": "ReasoningFormat" }) +export type ChatToolCall = { + readonly "function": { readonly "arguments": string; readonly "name": string } + readonly "id": string + readonly "type": "function" } -export const ApplyPatchUpdateFileOperation = Schema.Struct({ - "diff": Schema.String, - "path": Schema.String, - "type": Schema.Literal("update_file") -}).annotate({ - "description": - "The `update_file` variant of an `apply_patch_call.operation`. Carries a V4A diff describing edits to an existing file.", - "identifier": "ApplyPatchUpdateFileOperation" +export const ChatToolCall = Schema.Struct({ + "function": Schema.Struct({ + "arguments": Schema.String.annotate({ "description": "Function arguments as JSON string" }), + "name": Schema.String.annotate({ "description": "Function name to call" }) + }), + "id": Schema.String.annotate({ "description": "Tool call identifier" }), + "type": Schema.Literal("function") +}).annotate({ "description": "Tool call made by the assistant", "identifier": "ChatToolCall" }) +export type ModelName = string +export const ModelName = Schema.String.annotate({ + "description": "Model to use for completion", + "identifier": "ModelName" }) -export type AppRankingsItem = { - readonly "app_id": number - readonly "app_name": string - readonly "rank": number - readonly "total_requests": number - readonly "total_tokens": string -} -export const AppRankingsItem = Schema.Struct({ - "app_id": Schema.Number.annotate({ "description": "Stable numeric identifier of the app on OpenRouter." }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "app_name": Schema.String.annotate({ "description": "Public display name of the app." }), - "rank": Schema.Number.annotate({ - "description": "1-based position of the app within this response, per the requested `sort`." - }).check(Schema.isInt().annotate({ "expected": "an integer" })), - "total_requests": Schema.Number.annotate({ - "description": "Number of requests attributed to the app inside the date window." - }).check(Schema.isInt().annotate({ "expected": "an integer" })), - "total_tokens": Schema.String.annotate({ - "description": - "Sum of `prompt_tokens + completion_tokens` attributed to the app inside the date window, returned as a decimal string so 64-bit values are not truncated." - }) -}).annotate({ "identifier": "AppRankingsItem" }) -export type AutoBetaRouterPlugin = { +export type AutoRouterPlugin = { readonly "allowed_models"?: ReadonlyArray readonly "cost_quality_tradeoff"?: number + readonly "cost_tier"?: "low" | "medium" | "high" | "xhigh" | "max" readonly "enabled"?: boolean - readonly "id": "auto-beta-router" + readonly "excluded_models"?: ReadonlyArray + readonly "id": "auto-router" + readonly "pin_model"?: boolean } -export const AutoBetaRouterPlugin = Schema.Struct({ +export const AutoRouterPlugin = Schema.Struct({ "allowed_models": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": - "List of model patterns to filter which models the auto-beta-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list." + "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, every model ranked for the classified task type is a candidate, falling back to a default model set when rankings are unavailable." }) ), "cost_quality_tradeoff": Schema.optionalKey( Schema.Number.annotate({ "description": - "Balances routing between cost and quality on a 0-10 scale. The auto-beta-router ranks models for the classified task type by community spend share, then filters candidates by their average cost per generation for that task. Higher values favor cheaper models: 10 keeps only models around the cheapest 10th percentile, while 0 permits models up to the 90th percentile for cost. Defaults to 9." + "Deprecated: Use cost_tier instead. Balances routing between cost and quality on a 0-10 scale. The auto-router ranks models for the classified task type by community spend share, then filters candidates by their average cost per generation for that task. Higher values favor cheaper models: 10 keeps only models around the cheapest 10th percentile, while 0 permits models up to the 90th percentile for cost. Defaults to 9 when no cost setting is provided. It remains supported and retains ceiling behavior, but cost_tier takes precedence when both are provided." }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ).check(Schema.isLessThanOrEqualTo(10).annotate({ "expected": "a value less than or equal to 10" })) ), + "cost_tier": Schema.optionalKey( + Schema.Literals(["low", "medium", "high", "xhigh", "max"]).annotate({ + "description": + "Named cost/quality setting. Tiers select cost-percentile bands: low = [0, 20), medium = [20, 40), high = [40, 60), xhigh = [60, 80), and max = [80, 100]. Takes precedence over the deprecated numeric cost_quality_tradeoff when both are provided." + }) + ), "enabled": Schema.optionalKey( Schema.Boolean.annotate({ - "description": "Set to false to disable the auto-beta-router plugin for this request. Defaults to true." + "description": "Set to false to disable the auto-router plugin for this request. Defaults to true." }) ), - "id": Schema.Literal("auto-beta-router") -}).annotate({ "identifier": "AutoBetaRouterPlugin" }) -export type AutoRouterPlugin = { - readonly "allowed_models"?: ReadonlyArray - readonly "cost_quality_tradeoff"?: number - readonly "enabled"?: boolean - readonly "id": "auto-router" - readonly "pin_model"?: boolean + "excluded_models": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "List of model patterns to exclude from auto-router selection. Supports wildcards (e.g., \"meta-llama/*\" excludes all Llama models). Applied after allowed_models, so an excluded pattern always wins over an allowed one." + }) + ), + "id": Schema.Literal("auto-router"), + "pin_model": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "When true, reuses the model from the most recent assistant message's `model` attribute for subsequent turns. Defaults to false." + }) + ) +}).annotate({ "identifier": "AutoRouterPlugin" }) +export type AutoBetaRouterPlugin = { + readonly "allowed_models"?: ReadonlyArray + readonly "cost_quality_tradeoff"?: number + readonly "cost_tier"?: "low" | "medium" | "high" | "xhigh" | "max" + readonly "enabled"?: boolean + readonly "excluded_models"?: ReadonlyArray + readonly "id": "auto-beta-router" } -export const AutoRouterPlugin = Schema.Struct({ +export const AutoBetaRouterPlugin = Schema.Struct({ "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." + "List of model patterns to filter which models the auto-beta-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, every model ranked for the classified task type is a candidate, falling back to a default model set when rankings are unavailable." }) ), "cost_quality_tradeoff": Schema.optionalKey( Schema.Number.annotate({ "description": - "Controls cost vs. quality routing tradeoff (0–10). 0 = pure quality (best model regardless of cost), 10 = maximize for cost (cheapest model wins). Intermediate values blend quality and cost signals continuously. Defaults to 7." + "Deprecated: Use cost_tier instead. Balances routing between cost and quality on a 0-10 scale. The auto-beta-router ranks models for the classified task type by community spend share, then filters candidates by their average cost per generation for that task. Higher values favor cheaper models: 10 keeps only models around the cheapest 10th percentile, while 0 permits models up to the 90th percentile for cost. Defaults to 9 when no cost setting is provided. It remains supported and retains ceiling behavior, but cost_tier takes precedence when both are provided." }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) ).check(Schema.isLessThanOrEqualTo(10).annotate({ "expected": "a value less than or equal to 10" })) ), + "cost_tier": Schema.optionalKey( + Schema.Literals(["low", "medium", "high", "xhigh", "max"]).annotate({ + "description": + "Named cost/quality setting. For auto-beta-router, tiers select cost-percentile bands: low = [0, 20), medium = [20, 40), high = [40, 60), xhigh = [60, 80), and max = [80, 100]. Takes precedence over the deprecated numeric cost_quality_tradeoff when both are provided." + }) + ), "enabled": Schema.optionalKey( Schema.Boolean.annotate({ - "description": "Set to false to disable the auto-router plugin for this request. Defaults to true." + "description": "Set to false to disable the auto-beta-router plugin for this request. Defaults to true." }) ), - "id": Schema.Literal("auto-router"), - "pin_model": Schema.optionalKey( - Schema.Boolean.annotate({ + "excluded_models": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "When true, reuses the model from the most recent assistant message's `model` attribute for subsequent turns. Defaults to false." + "List of model patterns to exclude from auto-beta-router selection. Supports wildcards (e.g., \"meta-llama/*\" excludes all Llama models). Applied after allowed_models, so an excluded pattern always wins over an allowed one." }) + ), + "id": Schema.Literal("auto-beta-router") +}).annotate({ "identifier": "AutoBetaRouterPlugin" }) +export type ModerationPlugin = { readonly "id": "moderation" } +export const ModerationPlugin = Schema.Struct({ "id": Schema.Literal("moderation") }).annotate({ + "identifier": "ModerationPlugin" +}) +export type WebSearchEngine = "native" | "exa" | "firecrawl" | "parallel" | "perplexity" +export const WebSearchEngine = Schema.Literals(["native", "exa", "firecrawl", "parallel", "perplexity"]).annotate({ + "description": "The search engine to use for web search.", + "identifier": "WebSearchEngine" +}) +export type WebSearchMode = + | "instant" + | "fast" + | "auto" + | "deep-lite" + | "deep" + | "deep-reasoning" + | "turbo" + | "basic" + | "advanced" +export const WebSearchMode = Schema.Literals([ + "instant", + "fast", + "auto", + "deep-lite", + "deep", + "deep-reasoning", + "turbo", + "basic", + "advanced" +]).annotate({ + "description": + "Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo (default), basic, and advanced. Modes unsupported by the selected engine are ignored.", + "identifier": "WebSearchMode" +}) +export type WebFetchPlugin = { + readonly "allowed_domains"?: ReadonlyArray + readonly "blocked_domains"?: ReadonlyArray + readonly "id": "web-fetch" + readonly "max_content_tokens"?: number + readonly "max_uses"?: number +} +export const WebFetchPlugin = Schema.Struct({ + "allowed_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "Only fetch from these domains." }) + ), + "blocked_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "Never fetch from these domains." }) + ), + "id": Schema.Literal("web-fetch"), + "max_content_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Maximum content length in approximate tokens. Content exceeding this limit is truncated." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "max_uses": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Maximum number of web fetches per request. Once exceeded, the tool returns an error." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ) -}).annotate({ "identifier": "AutoRouterPlugin" }) -export type BadGatewayResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +}).annotate({ "identifier": "WebFetchPlugin" }) +export type PDFParserEngine = "mistral-ocr" | "native" | "cloudflare-ai" | "pdf-text" +export const PDFParserEngine = Schema.Union([ + Schema.Literals(["mistral-ocr", "native", "cloudflare-ai"]), + Schema.Literal("pdf-text") +]).annotate({ + "description": + "The engine to use for parsing PDF files. \"pdf-text\" is deprecated and automatically redirected to \"cloudflare-ai\".", + "identifier": "PDFParserEngine" +}) +export type ResponseHealingPlugin = { readonly "enabled"?: boolean; readonly "id": "response-healing" } +export const ResponseHealingPlugin = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the response-healing plugin for this request. Defaults to true." + }) + ), + "id": Schema.Literal("response-healing") +}).annotate({ "identifier": "ResponseHealingPlugin" }) +export type ContextCompressionEngine = "middle-out" +export const ContextCompressionEngine = Schema.Literal("middle-out").annotate({ + "description": "The compression engine to use. Defaults to \"middle-out\".", + "identifier": "ContextCompressionEngine" +}) +export type ParetoRouterPlugin = { + readonly "enabled"?: boolean + readonly "id": "pareto-router" + readonly "max_price"?: number + readonly "min_coding_score"?: number + readonly "price_source"?: "prompt" | "weighted_avg" } -export const BadGatewayResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) +export const ParetoRouterPlugin = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the pareto-router plugin for this request. Defaults to true." + }) + ), + "id": Schema.Literal("pareto-router"), + "max_price": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum input price in USD per million tokens. When set, quality-tier selection (min_coding_score) is bypassed: the router computes the Pareto frontier over the top coding models and routes to the best-scoring frontier model priced at or below this cap, falling back through cheaper frontier models, then non-frontier models. Enforced against the price source given by price_source. Returns 404 when no candidate satisfies the cap.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ) + ), + "min_coding_score": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Minimum coding quality score between 0 and 1. Maps to internal quality tiers: >= 0.66 → high (top coding models), >= 0.33 → medium (strong modern flagships), < 0.33 → low (capable coders above the median). Omit to default to the highest tier (equivalent to >= 0.66). Not used when max_price is set (price-based selection takes over).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) + ), + "price_source": Schema.optionalKey( + Schema.Literals(["prompt", "weighted_avg"]).annotate({ + "description": + "Price source for the Pareto frontier cost axis and for enforcing max_price. \"prompt\" uses catalog list price (endpoint.pricing.prompt). \"weighted_avg\" uses traffic-weighted effective input price from ClickHouse, falling back to prompt price for models without traffic data. Defaults to \"prompt\"." + }) ) -}).annotate({ "description": "Error data for BadGatewayResponse", "identifier": "BadGatewayResponseErrorData" }) -export type BadRequestResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +}).annotate({ "identifier": "ParetoRouterPlugin" }) +export type FusionPlugin = { + readonly "analysis_models"?: ReadonlyArray + readonly "enabled"?: boolean + readonly "id": "fusion" + readonly "max_tool_calls"?: number + readonly "model"?: string + readonly "preset"?: "general-high" | "general-budget" | "general-fast" + readonly "tools"?: ReadonlyArray<{ readonly "parameters"?: {}; readonly "type": string }> } -export const BadRequestResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) +export const FusionPlugin = Schema.Struct({ + "analysis_models": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Slugs of models to run in parallel as the \"expert panel\" the analyst analyzes. Each model receives the same user prompt with web_search + web_fetch enabled. Capped at 8 models to bound cost amplification. When omitted, defaults to the Quality preset from the /labs/fusion UI (~anthropic/claude-opus-latest, ~openai/gpt-latest, ~google/gemini-pro-latest)." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(8).annotate({ "expected": "a value with a length of at most 8" }) + ) + ), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the fusion plugin for this request. Defaults to true." + }) + ), + "id": Schema.Literal("fusion"), + "max_tool_calls": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of tool-calling steps each panelist (analysis model) and the analyst model may take during their agentic web-research loop. Models with web_search/web_fetch enabled iterate until they produce a text response or hit this ceiling. Defaults to 4. Capped at 16." + }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) + ).check(Schema.isLessThanOrEqualTo(16).annotate({ "expected": "a value less than or equal to 16" })) + ), + "model": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Slug of the model that performs both the analyst step (with web_search + web_fetch) and the final synthesis. When omitted, defaults to the first model in the Quality preset." + }) + ), + "preset": Schema.optionalKey( + Schema.Literals(["general-high", "general-budget", "general-fast"]).annotate({ + "description": + "A curated OpenRouter fusion preset (slugs follow `-`, e.g. `general-high`). Expands server-side into the preset's analysis_models panel and analyst model, so callers never name individual models. Explicitly provided `analysis_models` / `model` take precedence." + }) + ), + "tools": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "parameters": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": "Optional configuration forwarded as the tool's `parameters` object." + }) + ), + "type": Schema.String.annotate({ + "description": "Server tool type identifier (e.g. \"openrouter:web_search\", \"openrouter:web_fetch\")." + }) + })).annotate({ + "description": + "Server tools available to panelist and analyst inner calls. Each entry uses the same `{ type, parameters? }` shorthand as the outer Chat Completions request. When omitted, defaults to `[{ type: \"openrouter:web_search\" }, { type: \"openrouter:web_fetch\" }]`. Pass an empty array to disable tools entirely (panelists answer from parametric knowledge only)." + }).check(Schema.isMaxLength(8).annotate({ "expected": "a value with a length of at most 8" })) ) -}).annotate({ "description": "Error data for BadRequestResponse", "identifier": "BadRequestResponseErrorData" }) -export type BaseCustomToolCallInputDeltaEvent = { - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.custom_tool_call_input.delta" +}).annotate({ "identifier": "FusionPlugin" }) +export type PredictionContentText = { readonly "text": string; readonly "type": "text" } +export const PredictionContentText = Schema.Struct({ "text": Schema.String, "type": Schema.Literal("text") }).annotate({ + "description": "Text content part for a predicted output.", + "identifier": "PredictionContentText" +}) +export type PromptCacheOptions = { + readonly "mode": "explicit" + readonly "ttl"?: string | null + readonly [x: string]: Schema.Json +} | null +export const PromptCacheOptions = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "mode": Schema.Literal("explicit"), + "ttl": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ + "description": + "Request-level prompt-cache controls. `mode: \"explicit\"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer.", + "identifier": "PromptCacheOptions" +}) +export type ProviderName = + | "Modal" + | "AkashML" + | "AI21" + | "AionLabs" + | "Alibaba" + | "Ambient" + | "Baidu" + | "Amazon Bedrock" + | "Amazon Nova" + | "Anthropic" + | "Arcee AI" + | "AtlasCloud" + | "Avian" + | "Azure" + | "BaseTen" + | "BytePlus" + | "Black Forest Labs" + | "Cerebras" + | "Chutes" + | "Cirrascale" + | "Claude Platform on AWS" + | "Clarifai" + | "Cloudflare" + | "Cohere" + | "CoreWeave" + | "Crucible" + | "Crusoe" + | "Darkbloom" + | "Decart" + | "Deepgram" + | "DeepInfra" + | "DeepSeek" + | "DekaLLM" + | "DigitalOcean" + | "Featherless" + | "Fireworks" + | "Fish Audio" + | "Friendli" + | "GMICloud" + | "Google" + | "Google AI Studio" + | "Groq" + | "HeyGen" + | "Inception" + | "Inceptron" + | "InferenceNet" + | "Ionstream" + | "Infermatic" + | "Io Net" + | "Inferact vLLM" + | "Inflection" + | "Liquid" + | "Mara" + | "Mancer 2" + | "Meta" + | "Minimax" + | "ModelRun" + | "Mistral" + | "Modular" + | "Moonshot AI" + | "Morph" + | "VoyageAI by MongoDB" + | "NCompass" + | "Nebius" + | "Nex AGI" + | "NextBit" + | "Novita" + | "Nvidia" + | "OpenAI" + | "OpenInference" + | "Parasail" + | "Poolside" + | "Perceptron" + | "Perplexity" + | "Phala" + | "Recraft" + | "Reka" + | "Relace" + | "Sail Research" + | "Sakana AI" + | "SambaNova" + | "Seed" + | "SiliconFlow" + | "Sourceful" + | "StepFun" + | "Stealth" + | "StreamLake" + | "Switchpoint" + | "Tencent" + | "Tenstorrent" + | "Thinking Machines" + | "Together" + | "Upstage" + | "Venice" + | "Wafer" + | "WandB" + | "Quiver" + | "Krea" + | "Runway" + | "Xiaomi" + | "xAI" + | "Z.AI" + | "FakeProvider" +export const ProviderName = Schema.Literals([ + "Modal", + "AkashML", + "AI21", + "AionLabs", + "Alibaba", + "Ambient", + "Baidu", + "Amazon Bedrock", + "Amazon Nova", + "Anthropic", + "Arcee AI", + "AtlasCloud", + "Avian", + "Azure", + "BaseTen", + "BytePlus", + "Black Forest Labs", + "Cerebras", + "Chutes", + "Cirrascale", + "Claude Platform on AWS", + "Clarifai", + "Cloudflare", + "Cohere", + "CoreWeave", + "Crucible", + "Crusoe", + "Darkbloom", + "Decart", + "Deepgram", + "DeepInfra", + "DeepSeek", + "DekaLLM", + "DigitalOcean", + "Featherless", + "Fireworks", + "Fish Audio", + "Friendli", + "GMICloud", + "Google", + "Google AI Studio", + "Groq", + "HeyGen", + "Inception", + "Inceptron", + "InferenceNet", + "Ionstream", + "Infermatic", + "Io Net", + "Inferact vLLM", + "Inflection", + "Liquid", + "Mara", + "Mancer 2", + "Meta", + "Minimax", + "ModelRun", + "Mistral", + "Modular", + "Moonshot AI", + "Morph", + "VoyageAI by MongoDB", + "NCompass", + "Nebius", + "Nex AGI", + "NextBit", + "Novita", + "Nvidia", + "OpenAI", + "OpenInference", + "Parasail", + "Poolside", + "Perceptron", + "Perplexity", + "Phala", + "Recraft", + "Reka", + "Relace", + "Sail Research", + "Sakana AI", + "SambaNova", + "Seed", + "SiliconFlow", + "Sourceful", + "StepFun", + "Stealth", + "StreamLake", + "Switchpoint", + "Tencent", + "Tenstorrent", + "Thinking Machines", + "Together", + "Upstage", + "Venice", + "Wafer", + "WandB", + "Quiver", + "Krea", + "Runway", + "Xiaomi", + "xAI", + "Z.AI", + "FakeProvider" +]).annotate({ "identifier": "ProviderName" }) +export type PercentileLatencyCutoffs = { + readonly "p50"?: number | null + readonly "p75"?: number | null + readonly "p90"?: number | null + readonly "p99"?: number | null } -export const BaseCustomToolCallInputDeltaEvent = Schema.Struct({ - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.custom_tool_call_input.delta") +export const PercentileLatencyCutoffs = Schema.Struct({ + "p50": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Maximum p50 latency (seconds)", "format": "double" }) + ), + "p75": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Maximum p75 latency (seconds)", "format": "double" }) + ), + "p90": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Maximum p90 latency (seconds)", "format": "double" }) + ), + "p99": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Maximum p99 latency (seconds)", "format": "double" }) + ) }).annotate({ - "description": - "Event emitted when a custom tool call's freeform input is being streamed. Mirrors `response.function_call_arguments.delta` but for `custom` tools whose input is opaque text rather than JSON arguments.", - "identifier": "BaseCustomToolCallInputDeltaEvent" + "description": "Percentile-based latency cutoffs. All specified cutoffs must be met for an endpoint to be preferred.", + "identifier": "PercentileLatencyCutoffs" }) -export type BaseCustomToolCallInputDoneEvent = { - readonly "input": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.custom_tool_call_input.done" +export type PercentileThroughputCutoffs = { + readonly "p50"?: number | null + readonly "p75"?: number | null + readonly "p90"?: number | null + readonly "p99"?: number | null } -export const BaseCustomToolCallInputDoneEvent = Schema.Struct({ - "input": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.custom_tool_call_input.done") +export const PercentileThroughputCutoffs = Schema.Struct({ + "p50": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Minimum p50 throughput (tokens/sec)", "format": "double" }) + ), + "p75": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Minimum p75 throughput (tokens/sec)", "format": "double" }) + ), + "p90": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Minimum p90 throughput (tokens/sec)", "format": "double" }) + ), + "p99": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Minimum p99 throughput (tokens/sec)", "format": "double" }) + ) }).annotate({ "description": - "Event emitted when a custom tool call's freeform input streaming is complete. Mirrors `response.function_call_arguments.done` but for `custom` tools.", - "identifier": "BaseCustomToolCallInputDoneEvent" + "Percentile-based throughput cutoffs. All specified cutoffs must be met for an endpoint to be preferred.", + "identifier": "PercentileThroughputCutoffs" }) -export type BaseErrorEvent = { - readonly "code": string | null - readonly "message": string - readonly "param": string | null - readonly "sequence_number": number - readonly "type": "error" +export type Quantization = + | "int4" + | "int8" + | "fp4" + | "mxfp4" + | "nvfp4" + | "fp6" + | "fp8" + | "mxfp8" + | "fp16" + | "bf16" + | "fp32" + | "unknown" +export const Quantization = Schema.Literals([ + "int4", + "int8", + "fp4", + "mxfp4", + "nvfp4", + "fp6", + "fp8", + "mxfp8", + "fp16", + "bf16", + "fp32", + "unknown" +]).annotate({ "identifier": "Quantization" }) +export type ProviderSort = "price" | "throughput" | "latency" | "exacto" +export const ProviderSort = Schema.Literals(["price", "throughput", "latency", "exacto"]).annotate({ + "description": "The provider sorting strategy (price, throughput, latency)", + "identifier": "ProviderSort" +}) +export type ProviderSortConfig = { + readonly "by"?: "price" | "throughput" | "latency" | "exacto" | null + readonly "partition"?: "model" | "none" | null } -export const BaseErrorEvent = Schema.Struct({ - "code": Schema.Union([Schema.String, Schema.Null]), - "message": Schema.String, - "param": Schema.Union([Schema.String, Schema.Null]), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("error") -}).annotate({ "description": "Event emitted when an error occurs during streaming", "identifier": "BaseErrorEvent" }) -export type BaseFunctionCallArgsDeltaEvent = { - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.function_call_arguments.delta" -} -export const BaseFunctionCallArgsDeltaEvent = Schema.Struct({ - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.function_call_arguments.delta") +export const ProviderSortConfig = Schema.Struct({ + "by": Schema.optionalKey( + Schema.Union([ + Schema.Literal("price"), + Schema.Literal("throughput"), + Schema.Literal("latency"), + Schema.Literal("exacto"), + Schema.Null + ]).annotate({ "description": "The provider sorting strategy (price, throughput, latency)" }) + ), + "partition": Schema.optionalKey( + Schema.Union([Schema.Literal("model"), Schema.Literal("none"), Schema.Null]).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": "Event emitted when function call arguments are being streamed", - "identifier": "BaseFunctionCallArgsDeltaEvent" + "description": "The provider sorting strategy (price, throughput, latency)", + "identifier": "ProviderSortConfig" }) -export type BaseFunctionCallArgsDoneEvent = { - readonly "arguments": string - readonly "item_id": string +export type ChatReasoningSummaryVerbosityEnum = "auto" | "concise" | "detailed" | null +export const ChatReasoningSummaryVerbosityEnum = Schema.Union([ + Schema.Literal("auto"), + Schema.Literal("concise"), + Schema.Literal("detailed"), + Schema.Null +]).annotate({ "identifier": "ChatReasoningSummaryVerbosityEnum" }) +export type ChatFormatTextConfig = { readonly "type": "text" } +export const ChatFormatTextConfig = Schema.Struct({ "type": Schema.Literal("text") }).annotate({ + "description": "Default text response format", + "identifier": "ChatFormatTextConfig" +}) +export type ChatFormatJsonObjectConfig = { readonly "type": "json_object" } +export const ChatFormatJsonObjectConfig = Schema.Struct({ "type": Schema.Literal("json_object") }).annotate({ + "description": "JSON object response format", + "identifier": "ChatFormatJsonObjectConfig" +}) +export type ChatJsonSchemaConfig = { + readonly "description"?: string readonly "name": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.function_call_arguments.done" + readonly "schema"?: {} + readonly "strict"?: boolean | null } -export const BaseFunctionCallArgsDoneEvent = Schema.Struct({ - "arguments": Schema.String, - "item_id": Schema.String, - "name": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.function_call_arguments.done") +export const ChatJsonSchemaConfig = Schema.Struct({ + "description": Schema.optionalKey(Schema.String.annotate({ "description": "Schema description for the model" })), + "name": Schema.String.annotate({ "description": "Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)" }) + .check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "schema": Schema.optionalKey(Schema.Struct({}).annotate({ "description": "JSON Schema object" })), + "strict": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ "description": "Enable strict schema adherence" }) + ) +}).annotate({ "description": "JSON Schema configuration object", "identifier": "ChatJsonSchemaConfig" }) +export type ChatFormatGrammarConfig = { readonly "grammar": string; readonly "type": "grammar" } +export const ChatFormatGrammarConfig = Schema.Struct({ + "grammar": Schema.String.annotate({ "description": "Custom grammar for text generation" }), + "type": Schema.Literal("grammar") +}).annotate({ "description": "Custom grammar response format", "identifier": "ChatFormatGrammarConfig" }) +export type ChatFormatPythonConfig = { readonly "type": "python" } +export const ChatFormatPythonConfig = Schema.Struct({ "type": Schema.Literal("python") }).annotate({ + "description": "Python code response format", + "identifier": "ChatFormatPythonConfig" +}) +export type DeprecatedRoute = "fallback" | "sort" | null +export const DeprecatedRoute = Schema.Union([Schema.Literal("fallback"), Schema.Literal("sort"), Schema.Null]).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\").", + "identifier": "DeprecatedRoute" + } +) +export type StopServerToolsWhenStepCountIs = { readonly "step_count": number; readonly "type": "step_count_is" } +export const StopServerToolsWhenStepCountIs = Schema.Struct({ + "step_count": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("step_count_is") }).annotate({ - "description": "Event emitted when function call arguments streaming is complete", - "identifier": "BaseFunctionCallArgsDoneEvent" + "description": "Stop after the agent loop has executed this many steps.", + "identifier": "StopServerToolsWhenStepCountIs" }) -export type BaseReasoningDeltaEvent = { - readonly "content_index": number - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.reasoning_text.delta" -} -export const BaseReasoningDeltaEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.reasoning_text.delta") +export type StopServerToolsWhenHasToolCall = { readonly "tool_name": string; readonly "type": "has_tool_call" } +export const StopServerToolsWhenHasToolCall = Schema.Struct({ + "tool_name": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "type": Schema.Literal("has_tool_call") }).annotate({ - "description": "Event emitted when reasoning text delta is streamed", - "identifier": "BaseReasoningDeltaEvent" + "description": "Stop after a tool with this name has been called.", + "identifier": "StopServerToolsWhenHasToolCall" }) -export type BaseReasoningDoneEvent = { - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "text": string - readonly "type": "response.reasoning_text.done" -} -export const BaseReasoningDoneEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "text": Schema.String, - "type": Schema.Literal("response.reasoning_text.done") +export type StopServerToolsWhenMaxTokensUsed = { readonly "max_tokens": number; readonly "type": "max_tokens_used" } +export const StopServerToolsWhenMaxTokensUsed = Schema.Struct({ + "max_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("max_tokens_used") }).annotate({ - "description": "Event emitted when reasoning text streaming is complete", - "identifier": "BaseReasoningDoneEvent" + "description": "Stop once cumulative token usage across the loop exceeds this threshold.", + "identifier": "StopServerToolsWhenMaxTokensUsed" }) -export type BaseReasoningSummaryTextDeltaEvent = { - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "summary_index": number - readonly "type": "response.reasoning_summary_text.delta" -} -export const BaseReasoningSummaryTextDeltaEvent = Schema.Struct({ - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.reasoning_summary_text.delta") +export type StopServerToolsWhenMaxCost = { readonly "max_cost_in_dollars": number; readonly "type": "max_cost" } +export const StopServerToolsWhenMaxCost = Schema.Struct({ + "max_cost_in_dollars": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "type": Schema.Literal("max_cost") }).annotate({ - "description": "Event emitted when reasoning summary text delta is streamed", - "identifier": "BaseReasoningSummaryTextDeltaEvent" + "description": "Stop once cumulative cost across the loop exceeds this dollar threshold.", + "identifier": "StopServerToolsWhenMaxCost" }) -export type BaseReasoningSummaryTextDoneEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "summary_index": number - readonly "text": string - readonly "type": "response.reasoning_summary_text.done" -} -export const BaseReasoningSummaryTextDoneEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "text": Schema.String, - "type": Schema.Literal("response.reasoning_summary_text.done") +export type StopServerToolsWhenFinishReasonIs = { readonly "reason": string; readonly "type": "finish_reason_is" } +export const StopServerToolsWhenFinishReasonIs = Schema.Struct({ + "reason": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "type": Schema.Literal("finish_reason_is") }).annotate({ - "description": "Event emitted when reasoning summary text streaming is complete", - "identifier": "BaseReasoningSummaryTextDoneEvent" + "description": "Stop when the upstream model emits this finish reason (e.g. `length`).", + "identifier": "StopServerToolsWhenFinishReasonIs" }) -export type BaseRefusalDeltaEvent = { - readonly "content_index": number - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.refusal.delta" -} -export const BaseRefusalDeltaEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.refusal.delta") -}).annotate({ "description": "Event emitted when a refusal delta is streamed", "identifier": "BaseRefusalDeltaEvent" }) -export type BaseRefusalDoneEvent = { - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "refusal": string - readonly "sequence_number": number - readonly "type": "response.refusal.done" +export type ChatStreamOptions = { readonly "include_usage"?: boolean; readonly [x: string]: Schema.Json } | null +export const ChatStreamOptions = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "include_usage": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Deprecated: This field has no effect. Full usage details are always included." + }) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "description": "Streaming configuration options", "identifier": "ChatStreamOptions" }) +export type ChatNamedToolChoice = { readonly "function": { readonly "name": string }; readonly "type": "function" } +export const ChatNamedToolChoice = Schema.Struct({ + "function": Schema.Struct({ "name": Schema.String.annotate({ "description": "Function name to call" }) }), + "type": Schema.Literal("function") +}).annotate({ "description": "Named tool choice for specific function", "identifier": "ChatNamedToolChoice" }) +export type ChatServerToolChoice = { readonly "type": string } +export const ChatServerToolChoice = Schema.Struct({ + "type": Schema.String.annotate({ + "description": + "OpenRouter server-tool type to force (e.g. `openrouter:web_search`, `web_search`, `web_search_preview`)." + }) +}).annotate({ + "description": + "OpenRouter extension: force a specific server tool by naming it directly in `tool_choice.type` instead of wrapping it in `{ type: \"function\", function: { name } }`.", + "identifier": "ChatServerToolChoice" +}) +export type AdvisorReasoning = { + readonly "effort"?: "max" | "xhigh" | "high" | "medium" | "low" | "minimal" | "none" + readonly "max_tokens"?: number } -export const BaseRefusalDoneEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "refusal": Schema.String, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.refusal.done") -}).annotate({ "description": "Event emitted when refusal streaming is complete", "identifier": "BaseRefusalDoneEvent" }) +export const AdvisorReasoning = Schema.Struct({ + "effort": Schema.optionalKey( + Schema.Literals(["max", "xhigh", "high", "medium", "low", "minimal", "none"]).annotate({ + "description": "Reasoning effort level for the advisor call." + }) + ), + "max_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Maximum number of reasoning tokens the advisor may use." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ) +}).annotate({ + "description": + "Reasoning configuration forwarded to the advisor call. Use this to control reasoning effort and token budget for models that support extended thinking.", + "identifier": "AdvisorReasoning" +}) +export type AdvisorNestedTool = { readonly "parameters"?: {}; readonly "type": string } +export const AdvisorNestedTool = Schema.Struct({ + "parameters": Schema.optionalKey(Schema.Struct({})), + "type": Schema.String +}).annotate({ + "description": + "A tool made available to the advisor sub-agent. Only OpenRouter server tools (e.g. openrouter:web_search) are supported; function tools are rejected because the advisor has no way to execute them. The advisor tool may not list itself.", + "identifier": "AdvisorNestedTool" +}) export type BashServerToolEngine = "auto" | "native" | "openrouter" export const BashServerToolEngine = Schema.Literals(["auto", "native", "openrouter"]).annotate({ "description": "Which bash engine to use. \"openrouter\" runs commands server-side in the OpenRouter sandbox. \"auto\" (default) and \"native\" use native passthrough, returning the tool call to your application to run client-side; OpenRouter does not execute the commands.", "identifier": "BashServerToolEngine" }) -export type BooleanCapability = { readonly "type": "boolean" } -export const BooleanCapability = Schema.Struct({ "type": Schema.Literal("boolean") }).annotate({ - "description": "A supported-or-not flag. Present means the parameter is accepted.", - "identifier": "BooleanCapability" +export type ContainerAutoEnvironment = { readonly "type": "container_auto" } +export const ContainerAutoEnvironment = Schema.Struct({ "type": Schema.Literal("container_auto") }).annotate({ + "description": "An OpenRouter-managed, auto-provisioned ephemeral container.", + "identifier": "ContainerAutoEnvironment" }) -export type BulkAddWorkspaceMembersRequest = { readonly "user_ids": ReadonlyArray } -export const BulkAddWorkspaceMembersRequest = Schema.Struct({ - "user_ids": Schema.Array(Schema.String).annotate({ - "description": - "List of user IDs to add to the workspace. Members are assigned the same role they hold in the organization." +export type ContainerReferenceEnvironment = { readonly "container_id": string; readonly "type": "container_reference" } +export const ContainerReferenceEnvironment = Schema.Struct({ + "container_id": Schema.String.annotate({ + "description": "Identifier of an existing container to reuse (max 20 characters)." }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( - Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) - ) -}).annotate({ "identifier": "BulkAddWorkspaceMembersRequest" }) -export type BulkAssignKeysRequest = { readonly "key_hashes": ReadonlyArray } -export const BulkAssignKeysRequest = Schema.Struct({ - "key_hashes": Schema.Array( - Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) - ).annotate({ "description": "Array of API key hashes to assign to the guardrail" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) -}).annotate({ "identifier": "BulkAssignKeysRequest" }) -export type BulkAssignKeysResponse = { readonly "assigned_count": number } -export const BulkAssignKeysResponse = Schema.Struct({ - "assigned_count": Schema.Number.annotate({ "description": "Number of keys successfully assigned" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ "identifier": "BulkAssignKeysResponse" }) -export type BulkAssignMembersRequest = { readonly "member_user_ids": ReadonlyArray } -export const BulkAssignMembersRequest = Schema.Struct({ - "member_user_ids": Schema.Array( - Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) - ).annotate({ "description": "Array of member user IDs to assign to the guardrail" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" }) + ).check(Schema.isPattern(new RegExp("^[\\w-]+$")).annotate({ "expected": "a string matching the RegExp ^[\\w-]+$" })), + "type": Schema.Literal("container_reference") +}).annotate({ + "description": "Reference to a previously created container to reuse.", + "identifier": "ContainerReferenceEnvironment" +}) +export type SandboxSleepAfterSeconds = number +export const SandboxSleepAfterSeconds = Schema.Number.annotate({ + "description": + "How long (in seconds) the container stays warm after its last command before sleeping, freeing its capacity slot. Idle-based: each command renews the timer. Defaults to 900 (15 minutes); capped at 2592000 (30 days)." +}).check(Schema.isInt().annotate({ "expected": "an integer", "identifier": "SandboxSleepAfterSeconds" })) +export type DatetimeServerToolConfig = { readonly "timezone"?: string } +export const DatetimeServerToolConfig = Schema.Struct({ + "timezone": Schema.optionalKey( + Schema.String.annotate({ "description": "IANA timezone name (e.g. \"America/New_York\"). Defaults to UTC." }) ) -}).annotate({ "identifier": "BulkAssignMembersRequest" }) -export type BulkAssignMembersResponse = { readonly "assigned_count": number } -export const BulkAssignMembersResponse = Schema.Struct({ - "assigned_count": Schema.Number.annotate({ "description": "Number of members successfully assigned" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) +}).annotate({ + "description": "Configuration for the openrouter:datetime server tool", + "identifier": "DatetimeServerToolConfig" +}) +export type FilesServerToolConfig = {} +export const FilesServerToolConfig = Schema.Struct({}).annotate({ + "description": "Configuration for the openrouter:files server tool", + "identifier": "FilesServerToolConfig" +}) +export type ImageGenerationServerToolConfig = { readonly "model"?: string } +export const ImageGenerationServerToolConfig = Schema.Struct({ + "model": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Which image generation model to use (e.g. \"openai/gpt-5-image\"). Defaults to \"openai/gpt-5-image\"." + }) ) -}).annotate({ "identifier": "BulkAssignMembersResponse" }) -export type BulkRemoveWorkspaceMembersRequest = { readonly "user_ids": ReadonlyArray } -export const BulkRemoveWorkspaceMembersRequest = Schema.Struct({ - "user_ids": Schema.Array(Schema.String).annotate({ "description": "List of user IDs to remove from the workspace" }) - .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( - Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) +}).annotate({ + "description": + "Configuration for the openrouter:image_generation server tool. Accepts all image_config params (aspect_ratio, quality, size, background, output_format, output_compression, moderation, etc.) plus a model field.", + "identifier": "ImageGenerationServerToolConfig" +}) +export type SearchModelsServerToolConfig = { readonly "max_results"?: number } +export const SearchModelsServerToolConfig = Schema.Struct({ + "max_results": Schema.optionalKey( + Schema.Number.annotate({ "description": "Maximum number of models to return. Defaults to 5, max 20." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "identifier": "BulkRemoveWorkspaceMembersRequest" }) -export type BulkRemoveWorkspaceMembersResponse = { readonly "removed_count": number } -export const BulkRemoveWorkspaceMembersResponse = Schema.Struct({ - "removed_count": Schema.Number.annotate({ "description": "Number of members removed" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ "identifier": "BulkRemoveWorkspaceMembersResponse" }) -export type BulkUnassignKeysRequest = { readonly "key_hashes": ReadonlyArray } -export const BulkUnassignKeysRequest = Schema.Struct({ - "key_hashes": Schema.Array( - Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) - ).annotate({ "description": "Array of API key hashes to unassign from the guardrail" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) -}).annotate({ "identifier": "BulkUnassignKeysRequest" }) -export type BulkUnassignKeysResponse = { readonly "unassigned_count": number } -export const BulkUnassignKeysResponse = Schema.Struct({ - "unassigned_count": Schema.Number.annotate({ "description": "Number of keys successfully unassigned" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ "identifier": "BulkUnassignKeysResponse" }) -export type BulkUnassignMembersRequest = { readonly "member_user_ids": ReadonlyArray } -export const BulkUnassignMembersRequest = Schema.Struct({ - "member_user_ids": Schema.Array( - Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) - ).annotate({ "description": "Array of member user IDs to unassign from the guardrail" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ) -}).annotate({ "identifier": "BulkUnassignMembersRequest" }) -export type BulkUnassignMembersResponse = { readonly "unassigned_count": number } -export const BulkUnassignMembersResponse = Schema.Struct({ - "unassigned_count": Schema.Number.annotate({ "description": "Number of members successfully unassigned" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) +}).annotate({ + "description": "Configuration for the openrouter:experimental__search_models server tool", + "identifier": "SearchModelsServerToolConfig" +}) +export type SubagentReasoning = { + readonly "effort"?: "max" | "xhigh" | "high" | "medium" | "low" | "minimal" | "none" + readonly "max_tokens"?: number +} +export const SubagentReasoning = Schema.Struct({ + "effort": Schema.optionalKey( + Schema.Literals(["max", "xhigh", "high", "medium", "low", "minimal", "none"]).annotate({ + "description": "Reasoning effort level for the subagent call." + }) + ), + "max_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of reasoning tokens the subagent may use. Accepted and validated but not yet forwarded to the subagent call." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ) -}).annotate({ "identifier": "BulkUnassignMembersResponse" }) -export type BYOKProviderSlug = - | "ai21" - | "aion-labs" - | "akashml" - | "alibaba" - | "amazon-bedrock" - | "amazon-nova" - | "ambient" - | "anthropic" - | "arcee-ai" - | "atlas-cloud" - | "avian" - | "azure" - | "baidu" - | "baseten" - | "black-forest-labs" - | "byteplus" - | "cerebras" - | "chutes" - | "cirrascale" - | "clarifai" - | "cloudflare" - | "cohere" - | "coreweave" - | "crusoe" - | "darkbloom" - | "decart" - | "deepgram" - | "deepinfra" - | "deepseek" - | "dekallm" - | "digitalocean" - | "featherless" - | "fireworks" - | "fish-audio" - | "friendli" - | "gmicloud" - | "google-ai-studio" - | "google-vertex" - | "groq" - | "heygen" - | "inception" - | "inceptron" - | "inferact-vllm" - | "inference-net" - | "infermatic" - | "inflection" - | "io-net" - | "ionstream" - | "krea" - | "liquid" - | "mancer" - | "mara" - | "meta" - | "minimax" - | "mistral" - | "modelrun" - | "modular" - | "moonshotai" - | "morph" - | "ncompass" - | "nebius" - | "nex-agi" - | "nextbit" - | "novita" - | "nvidia" - | "open-inference" - | "openai" - | "parasail" - | "perceptron" - | "perplexity" - | "phala" - | "poolside" - | "quiver" - | "recraft" - | "reka" - | "relace" - | "runway" - | "sail-research" - | "sakana" - | "sambanova" - | "seed" - | "siliconflow" - | "sourceful" - | "stepfun" - | "streamlake" - | "switchpoint" - | "tencent" - | "tenstorrent" - | "together" - | "upstage" - | "venice" - | "wafer" - | "wandb" - | "xai" - | "xiaomi" - | "z-ai" -export const BYOKProviderSlug = Schema.Literals([ - "ai21", - "aion-labs", - "akashml", - "alibaba", - "amazon-bedrock", - "amazon-nova", - "ambient", - "anthropic", - "arcee-ai", - "atlas-cloud", - "avian", - "azure", - "baidu", - "baseten", - "black-forest-labs", - "byteplus", - "cerebras", - "chutes", - "cirrascale", - "clarifai", - "cloudflare", - "cohere", - "coreweave", - "crusoe", - "darkbloom", - "decart", - "deepgram", - "deepinfra", - "deepseek", - "dekallm", - "digitalocean", - "featherless", - "fireworks", - "fish-audio", - "friendli", - "gmicloud", - "google-ai-studio", - "google-vertex", - "groq", - "heygen", - "inception", - "inceptron", - "inferact-vllm", - "inference-net", - "infermatic", - "inflection", - "io-net", - "ionstream", - "krea", - "liquid", - "mancer", - "mara", - "meta", - "minimax", - "mistral", - "modelrun", - "modular", - "moonshotai", - "morph", - "ncompass", - "nebius", - "nex-agi", - "nextbit", - "novita", - "nvidia", - "open-inference", - "openai", - "parasail", - "perceptron", - "perplexity", - "phala", - "poolside", - "quiver", - "recraft", - "reka", - "relace", - "runway", - "sail-research", - "sakana", - "sambanova", - "seed", - "siliconflow", - "sourceful", - "stepfun", - "streamlake", - "switchpoint", - "tencent", - "tenstorrent", - "together", - "upstage", - "venice", - "wafer", - "wandb", - "xai", - "xiaomi", - "z-ai" -]).annotate({ +}).annotate({ "description": - "The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`).", - "identifier": "BYOKProviderSlug" + "Reasoning configuration forwarded to the subagent call. Use this to control reasoning effort and token budget for models that support extended thinking.", + "identifier": "SubagentReasoning" }) -export type ChatAssistantImages = ReadonlyArray<{ readonly "image_url": { readonly "url": string } }> -export const ChatAssistantImages = Schema.Array( - Schema.Struct({ - "image_url": Schema.Struct({ - "url": Schema.String.annotate({ "description": "URL or base64-encoded data of the generated image" }) - }) +export type SubagentNestedTool = { readonly "parameters"?: {}; readonly "type": string } +export const SubagentNestedTool = Schema.Struct({ + "parameters": Schema.optionalKey(Schema.Struct({})), + "type": Schema.String +}).annotate({ + "description": + "A tool made available to the subagent. Only OpenRouter server tools (e.g. openrouter:web_search) are supported; function tools are rejected because the worker has no way to execute them. The subagent tool may not list itself.", + "identifier": "SubagentNestedTool" +}) +export type WebFetchEngineEnum = "auto" | "native" | "openrouter" | "exa" | "parallel" | "firecrawl" +export const WebFetchEngineEnum = Schema.Literals(["auto", "native", "openrouter", "exa", "parallel", "firecrawl"]) + .annotate({ + "description": + "Which fetch engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in fetch. \"exa\" uses Exa Contents API. \"openrouter\" uses direct HTTP fetch. \"firecrawl\" uses Firecrawl scrape (requires BYOK). \"parallel\" uses the Parallel extract API.", + "identifier": "WebFetchEngineEnum" }) -).annotate({ "description": "Generated images from image generation models", "identifier": "ChatAssistantImages" }) -export type ChatAudioOutput = { - readonly "data"?: string - readonly "expires_at"?: number - readonly "id"?: string - readonly "transcript"?: string -} -export const ChatAudioOutput = Schema.Struct({ - "data": Schema.optionalKey(Schema.String.annotate({ "description": "Base64 encoded audio data" })), - "expires_at": Schema.optionalKey( - Schema.Number.annotate({ "description": "Audio expiration timestamp" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - ), - "id": Schema.optionalKey(Schema.String.annotate({ "description": "Audio output identifier" })), - "transcript": Schema.optionalKey(Schema.String.annotate({ "description": "Audio transcript" })) -}).annotate({ "description": "Audio output data or reference", "identifier": "ChatAudioOutput" }) -export type ChatContentAudio = { - readonly "input_audio": { readonly "data": string; readonly "format": string } - readonly "type": "input_audio" +export type WebSearchEngineEnum = "native" | "exa" | "parallel" | "firecrawl" | "perplexity" | "auto" +export const WebSearchEngineEnum = Schema.Literals(["native", "exa", "parallel", "firecrawl", "perplexity", "auto"]) + .annotate({ + "description": + "Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API. \"perplexity\" uses the Perplexity Search API (raw ranked results).", + "identifier": "WebSearchEngineEnum" + }) +export type SearchQualityLevel = "low" | "medium" | "high" +export const SearchQualityLevel = Schema.Literals(["low", "medium", "high"]).annotate({ + "description": + "How much context to retrieve per result. Applies to Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, pins a fixed per-result character cap (low=5,000, medium=15,000, high=30,000); when omitted, Exa picks an adaptive size per query and document (typically ~2,000–4,000 characters per result). For Parallel, controls the total characters across all results; when omitted, Parallel uses its own default size. For Perplexity, maps directly to the Search API's native search_context_size parameter. Overridden by `max_characters` when both are set.", + "identifier": "SearchQualityLevel" +}) +export type WebSearchUserLocationServerTool = { + readonly "city"?: string | null + readonly "country"?: string | null + readonly "region"?: string | null + readonly "timezone"?: string | null + readonly "type"?: "approximate" } -export const ChatContentAudio = Schema.Struct({ - "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." - }) - }), - "type": Schema.Literal("input_audio") +export const WebSearchUserLocationServerTool = Schema.Struct({ + "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.optionalKey(Schema.Literal("approximate")) }).annotate({ - "description": "Audio input content part. Supported audio formats vary by provider.", - "identifier": "ChatContentAudio" + "description": "Approximate user location for location-biased results.", + "identifier": "WebSearchUserLocationServerTool" }) -export type ChatContentFile = { - readonly "file": { readonly "file_data"?: string; readonly "file_id"?: string; readonly "filename"?: string } - readonly "type": "file" -} -export const ChatContentFile = Schema.Struct({ - "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" })) - }), - "type": Schema.Literal("file") -}).annotate({ "description": "File content part for document processing", "identifier": "ChatContentFile" }) -export type ChatContentImage = { - readonly "image_url": { readonly "detail"?: "auto" | "low" | "high" | "original"; readonly "url": string } - readonly "type": "image_url" +export type TraceConfig = { + readonly "generation_name"?: string + readonly "parent_span_id"?: string + readonly "span_name"?: string + readonly "trace_id"?: string + readonly "trace_name"?: string } -export const ChatContentImage = Schema.Struct({ - "image_url": Schema.Struct({ - "detail": Schema.optionalKey( - Schema.Literals(["auto", "low", "high", "original"]).annotate({ - "description": - "Image detail level for vision models. `original` is an OpenRouter extension (not in the OpenAI Chat Completions spec) requesting true original-resolution media; it is downgraded to `high` for providers that lack an original-resolution tier." - }) - ), - "url": Schema.String.annotate({ "description": "URL of the image (data: URLs supported)" }) - }), - "type": Schema.Literal("image_url") -}).annotate({ "description": "Image content part for vision models", "identifier": "ChatContentImage" }) -export type ChatContentVideoInput = { readonly "url": string } -export const ChatContentVideoInput = Schema.Struct({ - "url": Schema.String.annotate({ "description": "URL of the video (data: URLs supported)" }) -}).annotate({ "description": "Video input object", "identifier": "ChatContentVideoInput" }) -export type ChatDebugOptions = { readonly "echo_upstream_body"?: boolean } -export const ChatDebugOptions = 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." - }) - ) +export const TraceConfig = Schema.Struct({ + "generation_name": Schema.optionalKey(Schema.String), + "parent_span_id": Schema.optionalKey(Schema.String), + "span_name": Schema.optionalKey(Schema.String), + "trace_id": Schema.optionalKey(Schema.String), + "trace_name": Schema.optionalKey(Schema.String) }).annotate({ - "description": "Debug options for inspecting request transformations (streaming only)", - "identifier": "ChatDebugOptions" + "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.", + "identifier": "TraceConfig" }) export type ChatFinishReasonEnum = "tool_calls" | "stop" | "length" | "content_filter" | "error" | null export const ChatFinishReasonEnum = Schema.Union([ @@ -1550,94 +2081,6 @@ export const ChatFinishReasonEnum = Schema.Union([ Schema.Literal("error"), Schema.Null ]).annotate({ "identifier": "ChatFinishReasonEnum" }) -export type ChatFormatGrammarConfig = { readonly "grammar": string; readonly "type": "grammar" } -export const ChatFormatGrammarConfig = Schema.Struct({ - "grammar": Schema.String.annotate({ "description": "Custom grammar for text generation" }), - "type": Schema.Literal("grammar") -}).annotate({ "description": "Custom grammar response format", "identifier": "ChatFormatGrammarConfig" }) -export type ChatFormatJsonObjectConfig = { readonly "type": "json_object" } -export const ChatFormatJsonObjectConfig = Schema.Struct({ "type": Schema.Literal("json_object") }).annotate({ - "description": "JSON object response format", - "identifier": "ChatFormatJsonObjectConfig" -}) -export type ChatFormatPythonConfig = { readonly "type": "python" } -export const ChatFormatPythonConfig = Schema.Struct({ "type": Schema.Literal("python") }).annotate({ - "description": "Python code response format", - "identifier": "ChatFormatPythonConfig" -}) -export type ChatFormatTextConfig = { readonly "type": "text" } -export const ChatFormatTextConfig = Schema.Struct({ "type": Schema.Literal("text") }).annotate({ - "description": "Default text response format", - "identifier": "ChatFormatTextConfig" -}) -export type ChatJsonSchemaConfig = { - readonly "description"?: string - readonly "name": string - readonly "schema"?: {} - readonly "strict"?: boolean | null -} -export const ChatJsonSchemaConfig = Schema.Struct({ - "description": Schema.optionalKey(Schema.String.annotate({ "description": "Schema description for the model" })), - "name": Schema.String.annotate({ "description": "Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)" }) - .check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), - "schema": Schema.optionalKey(Schema.Struct({}).annotate({ "description": "JSON Schema object" })), - "strict": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ "description": "Enable strict schema adherence" }) - ) -}).annotate({ "description": "JSON Schema configuration object", "identifier": "ChatJsonSchemaConfig" }) -export type ChatNamedToolChoice = { readonly "function": { readonly "name": string }; readonly "type": "function" } -export const ChatNamedToolChoice = Schema.Struct({ - "function": Schema.Struct({ "name": Schema.String.annotate({ "description": "Function name to call" }) }), - "type": Schema.Literal("function") -}).annotate({ "description": "Named tool choice for specific function", "identifier": "ChatNamedToolChoice" }) -export type ChatReasoningSummaryVerbosityEnum = "auto" | "concise" | "detailed" | null -export const ChatReasoningSummaryVerbosityEnum = Schema.Union([ - Schema.Literal("auto"), - Schema.Literal("concise"), - Schema.Literal("detailed"), - Schema.Null -]).annotate({ "identifier": "ChatReasoningSummaryVerbosityEnum" }) -export type ChatServerToolChoice = { readonly "type": string } -export const ChatServerToolChoice = Schema.Struct({ - "type": Schema.String.annotate({ - "description": - "OpenRouter server-tool type to force (e.g. `openrouter:web_search`, `web_search`, `web_search_preview`)." - }) -}).annotate({ - "description": - "OpenRouter extension: force a specific server tool by naming it directly in `tool_choice.type` instead of wrapping it in `{ type: \"function\", function: { name } }`.", - "identifier": "ChatServerToolChoice" -}) -export type Objects_6 = { readonly "include_usage"?: boolean; readonly [x: string]: Schema.Json } -export const Objects_6 = Schema.StructWithRest( - Schema.Struct({ - "include_usage": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Deprecated: This field has no effect. Full usage details are always included." - }) - ) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type ChatStreamToolCall = { - readonly "function"?: { readonly "arguments"?: string; readonly "name"?: string | null } - readonly "id"?: string | null - readonly "index": number - readonly "type"?: "function" | null -} -export const ChatStreamToolCall = Schema.Struct({ - "function": Schema.optionalKey( - Schema.Struct({ - "arguments": Schema.optionalKey(Schema.String.annotate({ "description": "Function arguments as JSON string" })), - "name": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) - }).annotate({ "description": "Function call details" }) - ), - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "index": Schema.Number.annotate({ "description": "Tool call index in the array" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "type": Schema.optionalKey(Schema.Union([Schema.Literal("function"), Schema.Null])) -}).annotate({ "description": "Tool call delta for streaming responses", "identifier": "ChatStreamToolCall" }) export type ChatTokenLogprob = { readonly "bytes": ReadonlyArray | null readonly "logprob": number @@ -1666,1010 +2109,269 @@ export const ChatTokenLogprob = Schema.Struct({ "token": Schema.String })).annotate({ "description": "Top alternative tokens with probabilities" }) }).annotate({ "description": "Token log probability information", "identifier": "ChatTokenLogprob" }) -export type ChatToolCall = { - readonly "function": { readonly "arguments": string; readonly "name": string } - readonly "id": string - readonly "type": "function" +export type RouterAttempt = { readonly "model": string; readonly "provider": string; readonly "status": number } +export const RouterAttempt = Schema.Struct({ + "model": Schema.String, + "provider": Schema.String, + "status": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "RouterAttempt" }) +export type EndpointInfo = { readonly "model": string; readonly "provider": string; readonly "selected": boolean } +export const EndpointInfo = Schema.Struct({ + "model": Schema.String, + "provider": Schema.String, + "selected": Schema.Boolean +}).annotate({ "identifier": "EndpointInfo" }) +export type RouterParams = { + readonly "quality_floor"?: number + readonly "throughput_floor"?: number + readonly "version_group"?: string } -export const ChatToolCall = Schema.Struct({ - "function": Schema.Struct({ - "arguments": Schema.String.annotate({ "description": "Function arguments as JSON string" }), - "name": Schema.String.annotate({ "description": "Function name to call" }) - }), - "id": Schema.String.annotate({ "description": "Tool call identifier" }), - "type": Schema.Literal("function") -}).annotate({ "description": "Tool call made by the assistant", "identifier": "ChatToolCall" }) -export type Union_ = { - readonly "accepted_prediction_tokens"?: number | null - readonly "audio_tokens"?: number | null - readonly "reasoning_tokens"?: number | null - readonly "rejected_prediction_tokens"?: number | null +export const RouterParams = Schema.Struct({ + "quality_floor": Schema.optionalKey( + Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "throughput_floor": Schema.optionalKey( + Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "version_group": Schema.optionalKey(Schema.String) +}).annotate({ "identifier": "RouterParams" }) +export type PipelineStageType = "guardrail" | "plugin" | "server_tools" | "response_healing" | "context_compression" +export const PipelineStageType = Schema.Literals([ + "guardrail", + "plugin", + "server_tools", + "response_healing", + "context_compression" +]).annotate({ + "description": + "Categorical kind of a pipeline stage. Multiple plugins can share a type (e.g. all guardrail-level plugins emit `guardrail`); the `name` field disambiguates which plugin emitted it.", + "identifier": "PipelineStageType" +}) +export type RoutingStrategy = + | "direct" + | "auto" + | "free" + | "latest" + | "alias" + | "fallback" + | "pareto" + | "bodybuilder" + | "fusion" +export const RoutingStrategy = Schema.Literals([ + "direct", + "auto", + "free", + "latest", + "alias", + "fallback", + "pareto", + "bodybuilder", + "fusion" +]).annotate({ "identifier": "RoutingStrategy" }) +export type CostDetails = { + readonly "upstream_inference_completions_cost": number + readonly "upstream_inference_cost"?: number | null + readonly "upstream_inference_prompt_cost": number readonly [x: string]: Schema.Json } | null -export const Union_ = Schema.Union([ +export const CostDetails = Schema.Union([ Schema.StructWithRest( Schema.Struct({ - "accepted_prediction_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Accepted prediction tokens" }) - ), - "audio_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Tokens used for audio output" }) + "upstream_inference_completions_cost": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) ), - "reasoning_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Tokens used for reasoning" }) + "upstream_inference_cost": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) ), - "rejected_prediction_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Rejected prediction tokens" }) + "upstream_inference_prompt_cost": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) ) }), [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] ), Schema.Null -]).annotate({ "description": "Detailed completion token usage" }) -export type Union_1 = { - readonly "audio_tokens"?: number - readonly "cache_write_tokens"?: number - readonly "cached_tokens"?: number - readonly "video_tokens"?: number +]).annotate({ "description": "Breakdown of upstream inference costs", "identifier": "CostDetails" }) +export type ServerToolUseDetails = { + readonly "tool_calls_executed"?: number | null + readonly "tool_calls_requested"?: number | null + readonly "web_search_requests"?: number | null readonly [x: string]: Schema.Json } | null -export const Union_1 = Schema.Union([ +export const ServerToolUseDetails = Schema.Union([ Schema.StructWithRest( Schema.Struct({ - "audio_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Audio input tokens" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - ), - "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.isInt().annotate({ "expected": "an integer" })) + "tool_calls_executed": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Number of OpenRouter server tool calls that executed and produced a result." }) ), - "cached_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Cached prompt tokens" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) + "tool_calls_requested": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ + "description": + "Total number of OpenRouter server-orchestrated tool calls the model requested, across all tool types. Provider-native tools (e.g. native web search) are not counted here." + }) ), - "video_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Video input tokens" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) + "web_search_requests": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ + "description": + "Number of web searches performed by server-side tools. For server-orchestrated tool calls a web search is also counted in tool_calls_requested; provider-native web search may report web_search_requests only. Do not sum the two." + }) ) }), [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] ), Schema.Null -]).annotate({ "description": "Detailed prompt token usage" }) -export type CodeInterpreterServerTool = { - readonly "container": string | { - readonly "file_ids"?: ReadonlyArray - readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g" | null - readonly "type": "auto" - } - readonly "type": "code_interpreter" -} -export const CodeInterpreterServerTool = Schema.Struct({ - "container": Schema.Union([ - Schema.String, - Schema.Struct({ - "file_ids": Schema.optionalKey(Schema.Array(Schema.String)), - "memory_limit": Schema.optionalKey( - Schema.Union([ - Schema.Literal("1g"), - Schema.Literal("4g"), - Schema.Literal("16g"), - Schema.Literal("64g"), - Schema.Null - ]) - ), - "type": Schema.Literal("auto") - }) - ]), - "type": Schema.Literal("code_interpreter") -}).annotate({ "description": "Code interpreter tool configuration", "identifier": "CodeInterpreterServerTool" }) -export type CodexLocalShellTool = { readonly "type": "local_shell" } -export const CodexLocalShellTool = Schema.Struct({ "type": Schema.Literal("local_shell") }).annotate({ - "description": "Local shell tool configuration", - "identifier": "CodexLocalShellTool" +]).annotate({ + "description": "Usage for server-side tool execution (e.g., web search)", + "identifier": "ServerToolUseDetails" }) -export type CompactionItem = { - readonly "encrypted_content": string +export type ChatStreamToolCall = { + readonly "function"?: { readonly "arguments"?: string; readonly "name"?: string | null } readonly "id"?: string | null - readonly "type": "compaction" + readonly "index": number + readonly "type"?: "function" | null } -export const CompactionItem = Schema.Struct({ - "encrypted_content": Schema.String, +export const ChatStreamToolCall = Schema.Struct({ + "function": Schema.optionalKey( + Schema.Struct({ + "arguments": Schema.optionalKey(Schema.String.annotate({ "description": "Function arguments as JSON string" })), + "name": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + }).annotate({ "description": "Function call details" }) + ), "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("compaction") -}).annotate({ "description": "A context compaction marker with encrypted summary", "identifier": "CompactionItem" }) -export type CompoundFilter = { readonly "filters": ReadonlyArray<{}>; readonly "type": "and" | "or" } -export const CompoundFilter = Schema.Struct({ - "filters": Schema.Array(Schema.Struct({})), - "type": Schema.Literals(["and", "or"]) -}).annotate({ - "description": "A compound filter that combines multiple comparison or compound filters", - "identifier": "CompoundFilter" -}) -export type ComputerUseServerTool = { - readonly "display_height": number - readonly "display_width": number - readonly "environment": "windows" | "mac" | "linux" | "ubuntu" | "browser" - readonly "type": "computer_use_preview" -} -export const ComputerUseServerTool = Schema.Struct({ - "display_height": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "display_width": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "environment": Schema.Literals(["windows", "mac", "linux", "ubuntu", "browser"]), - "type": Schema.Literal("computer_use_preview") -}).annotate({ "description": "Computer use preview tool configuration", "identifier": "ComputerUseServerTool" }) -export type ConflictResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null -} -export const ConflictResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ "description": "Error data for ConflictResponse", "identifier": "ConflictResponseErrorData" }) -export type ContainerAutoEnvironment = { readonly "type": "container_auto" } -export const ContainerAutoEnvironment = Schema.Struct({ "type": Schema.Literal("container_auto") }).annotate({ - "description": "An OpenRouter-managed, auto-provisioned ephemeral container.", - "identifier": "ContainerAutoEnvironment" -}) -export type ContainerReferenceEnvironment = { readonly "container_id": string; readonly "type": "container_reference" } -export const ContainerReferenceEnvironment = Schema.Struct({ - "container_id": Schema.String.annotate({ - "description": "Identifier of an existing container to reuse (max 20 characters)." - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( - Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" }) - ).check(Schema.isPattern(new RegExp("^[\\w-]+$")).annotate({ "expected": "a string matching the RegExp ^[\\w-]+$" })), - "type": Schema.Literal("container_reference") -}).annotate({ - "description": "Reference to a previously created container to reuse.", - "identifier": "ContainerReferenceEnvironment" -}) -export type ContentFilterAction = "redact" | "block" | "flag" -export const ContentFilterAction = Schema.Literals(["redact", "block", "flag"]).annotate({ - "description": "Action taken when the pattern matches", - "identifier": "ContentFilterAction" -}) -export type ContentFilterBuiltinAction = "redact" | "block" | "flag" -export const ContentFilterBuiltinAction = Schema.Literals(["redact", "block", "flag"]).annotate({ - "description": "Action taken when the builtin filter triggers", - "identifier": "ContentFilterBuiltinAction" -}) -export type ContentFilterBuiltinSlug = - | "email" - | "phone" - | "ssn" - | "credit-card" - | "ip-address" - | "person-name" - | "address" - | "regex-prompt-injection" -export const ContentFilterBuiltinSlug = Schema.Literals([ - "email", - "phone", - "ssn", - "credit-card", - "ip-address", - "person-name", - "address", - "regex-prompt-injection" -]).annotate({ "description": "The builtin filter identifier", "identifier": "ContentFilterBuiltinSlug" }) -export type ContentPartAudio = { readonly "audio_url": { readonly "url": string }; readonly "type": "audio_url" } -export const ContentPartAudio = Schema.Struct({ - "audio_url": Schema.Struct({ "url": Schema.String }), - "type": Schema.Literal("audio_url") -}).annotate({ "identifier": "ContentPartAudio" }) -export type ContentPartImage = { readonly "image_url": { readonly "url": string }; readonly "type": "image_url" } -export const ContentPartImage = Schema.Struct({ - "image_url": Schema.Struct({ "url": Schema.String }), - "type": Schema.Literal("image_url") -}).annotate({ "identifier": "ContentPartImage" }) -export type ContentPartVideo = { readonly "type": "video_url"; readonly "video_url": { readonly "url": string } } -export const ContentPartVideo = Schema.Struct({ - "type": Schema.Literal("video_url"), - "video_url": Schema.Struct({ "url": Schema.String }) -}).annotate({ "identifier": "ContentPartVideo" }) -export type ContextCompactionItem = { - readonly "encrypted_content"?: string | null - readonly "id"?: string | null - readonly "type": "context_compaction" -} -export const ContextCompactionItem = Schema.Struct({ - "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("context_compaction") -}).annotate({ - "description": "A context compaction marker with an optional encrypted summary", - "identifier": "ContextCompactionItem" -}) -export type ContextCompressionEngine = "middle-out" -export const ContextCompressionEngine = Schema.Literal("middle-out").annotate({ - "description": "The compression engine to use. Defaults to \"middle-out\".", - "identifier": "ContextCompressionEngine" -}) -export type Objects_8 = { - readonly "upstream_inference_completions_cost": number - readonly "upstream_inference_cost"?: number | null - readonly "upstream_inference_prompt_cost": number - readonly [x: string]: Schema.Json -} -export const Objects_8 = Schema.StructWithRest( - Schema.Struct({ - "upstream_inference_completions_cost": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "upstream_inference_cost": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "upstream_inference_prompt_cost": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type CreateWorkspaceRequest = { - readonly "default_image_model"?: string | null - readonly "default_provider_sort"?: string | null - readonly "default_text_model"?: string | null - readonly "description"?: string | null - readonly "io_logging_api_key_ids"?: ReadonlyArray | null - readonly "io_logging_sampling_rate"?: number - readonly "is_data_discount_logging_enabled"?: boolean - readonly "is_observability_broadcast_enabled"?: boolean - readonly "is_observability_io_logging_enabled"?: boolean - readonly "name": string - readonly "slug": string -} -export const CreateWorkspaceRequest = Schema.Struct({ - "default_image_model": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Default image model for this workspace" }) - ), - "default_provider_sort": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Default provider sort preference (price, throughput, latency, exacto)" - }) - ), - "default_text_model": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Default text model for this workspace" }) - ), - "description": Schema.optionalKey( - Schema.Union([ - Schema.String.check(Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" })), - Schema.Null - ]).annotate({ "description": "Description of the workspace" }) - ), - "io_logging_api_key_ids": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - Schema.Null - ]).annotate({ "description": "Optional array of API key IDs to filter I/O logging" }) - ), - "io_logging_sampling_rate": Schema.optionalKey( - Schema.Number.annotate({ "description": "Sampling rate for I/O logging (0.0001-1)", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "is_data_discount_logging_enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether data discount logging is enabled" }) - ), - "is_observability_broadcast_enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether broadcast is enabled" }) - ), - "is_observability_io_logging_enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether private logging is enabled" }) - ), - "name": Schema.String.annotate({ "description": "Name for the new workspace" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ).check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })), - "slug": Schema.String.annotate({ - "description": - "URL-friendly slug (lowercase alphanumeric segments separated by single hyphens, no leading/trailing hyphens)" - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( - Schema.isMaxLength(50).annotate({ "expected": "a value with a length of at most 50" }) - ).check( - Schema.isPattern(new RegExp("^[a-z0-9]+(?:-[a-z0-9]+)*$")).annotate({ - "expected": "a string matching the RegExp ^[a-z0-9]+(?:-[a-z0-9]+)*$" - }) - ) -}).annotate({ "identifier": "CreateWorkspaceRequest" }) -export type CustomTool = { - readonly "description"?: string - readonly "format"?: { readonly "type": "text" } | { - readonly "definition": string - readonly "syntax": "lark" | "regex" - readonly "type": "grammar" - } - readonly "name": string - readonly "type": "custom" -} -export const CustomTool = Schema.Struct({ - "description": Schema.optionalKey(Schema.String), - "format": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ "type": Schema.Literal("text") }), - Schema.Struct({ - "definition": Schema.String, - "syntax": Schema.Literals(["lark", "regex"]), - "type": Schema.Literal("grammar") - }) - ]) - ), - "name": Schema.String, - "type": Schema.Literal("custom") -}).annotate({ "description": "Custom tool configuration", "identifier": "CustomTool" }) -export type CustomToolCallInputDeltaEvent = { - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.custom_tool_call_input.delta" -} -export const CustomToolCallInputDeltaEvent = Schema.Struct({ - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.custom_tool_call_input.delta") -}).annotate({ - "description": - "Event emitted when a custom tool call's freeform input is being streamed. Mirrors `response.function_call_arguments.delta` but for `custom` tools whose input is opaque text rather than JSON arguments.", - "identifier": "CustomToolCallInputDeltaEvent" -}) -export type CustomToolCallInputDoneEvent = { - readonly "input": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.custom_tool_call_input.done" -} -export const CustomToolCallInputDoneEvent = Schema.Struct({ - "input": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.custom_tool_call_input.done") -}).annotate({ - "description": - "Event emitted when a custom tool call's freeform input streaming is complete. Mirrors `response.function_call_arguments.done` but for `custom` tools.", - "identifier": "CustomToolCallInputDoneEvent" -}) -export type CustomToolCallItem = { - readonly "call_id": string - readonly "id"?: string - readonly "input": string - readonly "name": string - readonly "namespace"?: string - readonly "type": "custom_tool_call" -} -export const CustomToolCallItem = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), - "input": Schema.String, - "name": Schema.String, - "namespace": Schema.optionalKey( - Schema.String.annotate({ - "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" - }) + "index": Schema.Number.annotate({ "description": "Tool call index in the array" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "type": Schema.Literal("custom_tool_call") -}).annotate({ - "description": - "A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI's `apply_patch` whose payload is opaque text rather than JSON arguments.", - "identifier": "CustomToolCallItem" -}) -export type DABenchmarkEntry = { - readonly "arena": string - readonly "category": string - readonly "elo": number - readonly "rank": number - readonly "win_rate": number -} -export const DABenchmarkEntry = Schema.Struct({ - "arena": Schema.String.annotate({ "description": "Arena type (e.g. models, builders, agents)" }), - "category": Schema.String.annotate({ - "description": "Category within the arena (e.g. website, gamedev, uicomponent)" - }), - "elo": Schema.Number.annotate({ "description": "ELO rating from head-to-head arena battles", "format": "double" }) - .check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "rank": Schema.Number.annotate({ - "description": "Rank position within this arena+category among models available on OpenRouter (1 = highest ELO)" - }).check(Schema.isInt().annotate({ "expected": "an integer" })), - "win_rate": Schema.Number.annotate({ "description": "Win rate percentage in arena battles", "format": "double" }) - .check(Schema.isFinite().annotate({ "expected": "a finite number" })) -}).annotate({ - "description": "A single Design Arena benchmark entry for a specific arena+category", - "identifier": "DABenchmarkEntry" -}) -export type DatetimeServerToolConfig = { readonly "timezone"?: string } -export const DatetimeServerToolConfig = Schema.Struct({ - "timezone": Schema.optionalKey( - Schema.String.annotate({ "description": "IANA timezone name (e.g. \"America/New_York\"). Defaults to UTC." }) - ) -}).annotate({ - "description": "Configuration for the openrouter:datetime server tool", - "identifier": "DatetimeServerToolConfig" -}) -export type DebugEvent = { - readonly "debug": { - readonly "echo_upstream_body"?: {} - readonly "timings"?: { - readonly "epoch_ms": number - readonly "event": "adapter_request" | "upstream_headers_received" | "first_token_received" | "upstream_body_ended" - readonly "start_ms": number - } - } - readonly "sequence_number": number - readonly "type": "response.debug" -} -export const DebugEvent = Schema.Struct({ - "debug": Schema.Struct({ - "echo_upstream_body": Schema.optionalKey(Schema.Struct({})), - "timings": Schema.optionalKey(Schema.Struct({ - "epoch_ms": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "event": Schema.Literals([ - "adapter_request", - "upstream_headers_received", - "first_token_received", - "upstream_body_ended" - ]), - "start_ms": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - })) - }), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.debug") -}).annotate({ - "description": - "Debug event emitted when debug.echo_upstream_body is true. Contains the transformed upstream request body or timing milestones.", - "identifier": "DebugEvent" + "type": Schema.optionalKey(Schema.Union([Schema.Literal("function"), Schema.Null])) +}).annotate({ "description": "Tool call delta for streaming responses", "identifier": "ChatStreamToolCall" }) +export type ApiErrorType = + | "context_length_exceeded" + | "max_tokens_exceeded" + | "token_limit_exceeded" + | "string_too_long" + | "authentication" + | "permission_denied" + | "payment_required" + | "rate_limit_exceeded" + | "provider_overloaded" + | "provider_unavailable" + | "invalid_request" + | "invalid_prompt" + | "not_found" + | "precondition_failed" + | "payload_too_large" + | "unprocessable" + | "content_policy_violation" + | "refusal" + | "invalid_image" + | "image_too_large" + | "image_too_small" + | "unsupported_image_format" + | "image_not_found" + | "image_download_failed" + | "server" + | "timeout" + | "unmapped" +export const ApiErrorType = Schema.Literals([ + "context_length_exceeded", + "max_tokens_exceeded", + "token_limit_exceeded", + "string_too_long", + "authentication", + "permission_denied", + "payment_required", + "rate_limit_exceeded", + "provider_overloaded", + "provider_unavailable", + "invalid_request", + "invalid_prompt", + "not_found", + "precondition_failed", + "payload_too_large", + "unprocessable", + "content_policy_violation", + "refusal", + "invalid_image", + "image_too_large", + "image_too_small", + "unsupported_image_format", + "image_not_found", + "image_download_failed", + "server", + "timeout", + "unmapped" +]).annotate({ + "description": "Canonical OpenRouter error type, stable across all API formats", + "identifier": "ApiErrorType" }) -export type DefaultParameters = { - readonly "frequency_penalty"?: number | null - readonly "presence_penalty"?: number | null - readonly "repetition_penalty"?: number | null - readonly "temperature"?: number | null - readonly "top_k"?: number | null - readonly "top_p"?: number | null -} | null -export const DefaultParameters = Schema.Union([ - Schema.Struct({ - "frequency_penalty": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "presence_penalty": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "repetition_penalty": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "temperature": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "top_k": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "top_p": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ) - }), - Schema.Null -]).annotate({ "description": "Default parameters for this model", "identifier": "DefaultParameters" }) -export type DeleteBYOKKeyResponse = { readonly "deleted": true } -export const DeleteBYOKKeyResponse = Schema.Struct({ - "deleted": Schema.Literal(true).annotate({ "description": "Confirmation that the BYOK credential was deleted." }) -}).annotate({ "identifier": "DeleteBYOKKeyResponse" }) -export type DeleteGuardrailResponse = { readonly "deleted": true } -export const DeleteGuardrailResponse = Schema.Struct({ - "deleted": Schema.Literal(true).annotate({ "description": "Confirmation that the guardrail was deleted" }) -}).annotate({ "identifier": "DeleteGuardrailResponse" }) -export type DeleteObservabilityDestinationResponse = { readonly "deleted": true } -export const DeleteObservabilityDestinationResponse = Schema.Struct({ - "deleted": Schema.Literal(true).annotate({ "description": "Always `true` on success." }) -}).annotate({ "identifier": "DeleteObservabilityDestinationResponse" }) -export type DeleteWorkspaceBudgetResponse = { readonly "deleted": true } -export const DeleteWorkspaceBudgetResponse = Schema.Struct({ - "deleted": Schema.Literal(true).annotate({ - "description": "Confirmation that the budget was deleted (or did not exist)" - }) -}).annotate({ "identifier": "DeleteWorkspaceBudgetResponse" }) -export type DeleteWorkspaceResponse = { readonly "deleted": true } -export const DeleteWorkspaceResponse = Schema.Struct({ - "deleted": Schema.Literal(true).annotate({ "description": "Confirmation that the workspace was deleted" }) -}).annotate({ "identifier": "DeleteWorkspaceResponse" }) -export type DeprecatedRoute = "fallback" | "sort" | null -export const DeprecatedRoute = Schema.Union([Schema.Literal("fallback"), Schema.Literal("sort"), Schema.Null]).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\").", - "identifier": "DeprecatedRoute" - } -) -export type EdgeNetworkTimeoutResponseErrorData = { +export type PayloadTooLargeResponseErrorData = { readonly "code": number readonly "message": string readonly "metadata"?: { readonly [x: string]: Schema.Json } | null } -export const EdgeNetworkTimeoutResponseErrorData = Schema.Struct({ +export const PayloadTooLargeResponseErrorData = Schema.Struct({ "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), "message": Schema.String, "metadata": Schema.optionalKey( Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ) }).annotate({ - "description": "Error data for EdgeNetworkTimeoutResponse", - "identifier": "EdgeNetworkTimeoutResponseErrorData" -}) -export type EndpointInfo = { readonly "model": string; readonly "provider": string; readonly "selected": boolean } -export const EndpointInfo = Schema.Struct({ - "model": Schema.String, - "provider": Schema.String, - "selected": Schema.Boolean -}).annotate({ "identifier": "EndpointInfo" }) -export type EndpointStatus = 0 | -1 | -2 | -3 | -5 | -10 -export const EndpointStatus = Schema.Literals([0, -1, -2, -3, -5, -10]).annotate({ "identifier": "EndpointStatus" }) -export type EnumCapability = { readonly "type": "enum"; readonly "values": ReadonlyArray } -export const EnumCapability = Schema.Struct({ "type": Schema.Literal("enum"), "values": Schema.Array(Schema.String) }) - .annotate({ - "description": "A parameter that accepts one of a discrete set of string values.", - "identifier": "EnumCapability" - }) -export type ErrorEvent = { - readonly "code": string | null - readonly "message": string - readonly "param": string | null - readonly "sequence_number": number - readonly "type": "error" -} -export const ErrorEvent = Schema.Struct({ - "code": Schema.Union([Schema.String, Schema.Null]), - "message": Schema.String, - "param": Schema.Union([Schema.String, Schema.Null]), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("error") -}).annotate({ "description": "Event emitted when an error occurs during streaming", "identifier": "ErrorEvent" }) -export type FileCitation = { - readonly "file_id": string - readonly "filename": string - readonly "index": number - readonly "type": "file_citation" -} -export const FileCitation = Schema.Struct({ - "file_id": Schema.String, - "filename": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("file_citation") -}).annotate({ "identifier": "FileCitation" }) -export type FileDeleteResponse = { readonly "id": string; readonly "type": "file_deleted" } -export const FileDeleteResponse = Schema.Struct({ "id": Schema.String, "type": Schema.Literal("file_deleted") }) - .annotate({ "description": "Confirmation that a file was deleted.", "identifier": "FileDeleteResponse" }) -export type FileMetadata = { - readonly "created_at": string - readonly "downloadable": boolean - readonly "filename": string - readonly "id": string - readonly "mime_type": string - readonly "size_bytes": number - readonly "type": "file" -} -export const FileMetadata = Schema.Struct({ - "created_at": Schema.String, - "downloadable": Schema.Boolean, - "filename": Schema.String, - "id": Schema.String, - "mime_type": Schema.String, - "size_bytes": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("file") -}).annotate({ "description": "Metadata describing a stored file.", "identifier": "FileMetadata" }) -export type FilePath = { readonly "file_id": string; readonly "index": number; readonly "type": "file_path" } -export const FilePath = Schema.Struct({ - "file_id": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("file_path") -}).annotate({ "identifier": "FilePath" }) -export type FilesServerToolConfig = {} -export const FilesServerToolConfig = Schema.Struct({}).annotate({ - "description": "Configuration for the openrouter:files server tool", - "identifier": "FilesServerToolConfig" + "description": "Error data for PayloadTooLargeResponse", + "identifier": "PayloadTooLargeResponseErrorData" }) -export type ForbiddenResponseErrorData = { +export type UnprocessableEntityResponseErrorData = { readonly "code": number readonly "message": string readonly "metadata"?: { readonly [x: string]: Schema.Json } | null } -export const ForbiddenResponseErrorData = Schema.Struct({ +export const UnprocessableEntityResponseErrorData = Schema.Struct({ "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), "message": Schema.String, "metadata": Schema.optionalKey( Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ) -}).annotate({ "description": "Error data for ForbiddenResponse", "identifier": "ForbiddenResponseErrorData" }) -export type FormatJsonObjectConfig = { readonly "type": "json_object" } -export const FormatJsonObjectConfig = Schema.Struct({ "type": Schema.Literal("json_object") }).annotate({ - "description": "JSON object response format", - "identifier": "FormatJsonObjectConfig" +}).annotate({ + "description": "Error data for UnprocessableEntityResponse", + "identifier": "UnprocessableEntityResponseErrorData" }) -export type FormatJsonSchemaConfig = { - readonly "description"?: string - readonly "name": string - readonly "schema": {} - readonly "strict"?: boolean | null - readonly "type": "json_schema" -} -export const FormatJsonSchemaConfig = Schema.Struct({ - "description": Schema.optionalKey(Schema.String), - "name": Schema.String, - "schema": Schema.Struct({}), - "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "type": Schema.Literal("json_schema") -}).annotate({ "description": "JSON schema constrained response format", "identifier": "FormatJsonSchemaConfig" }) -export type FormatTextConfig = { readonly "type": "text" } -export const FormatTextConfig = Schema.Struct({ "type": Schema.Literal("text") }).annotate({ - "description": "Plain text response format", - "identifier": "FormatTextConfig" -}) -export type FrameImage = { - readonly "image_url": { readonly "url": string } - readonly "type": "image_url" - readonly "frame_type": "first_frame" | "last_frame" -} -export const FrameImage = Schema.Struct({ - "image_url": Schema.Struct({ "url": Schema.String }), - "type": Schema.Literal("image_url"), - "frame_type": Schema.Literals(["first_frame", "last_frame"]).annotate({ - "description": "Whether this image represents the first or last frame of the video" - }) -}).annotate({ "identifier": "FrameImage" }) -export type FunctionCallArgsDeltaEvent = { - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.function_call_arguments.delta" -} -export const FunctionCallArgsDeltaEvent = Schema.Struct({ - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.function_call_arguments.delta") -}).annotate({ - "description": "Event emitted when function call arguments are being streamed", - "identifier": "FunctionCallArgsDeltaEvent" -}) -export type FunctionCallArgsDoneEvent = { - readonly "arguments": string - readonly "item_id": string - readonly "name": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.function_call_arguments.done" -} -export const FunctionCallArgsDoneEvent = Schema.Struct({ - "arguments": Schema.String, - "item_id": Schema.String, - "name": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.function_call_arguments.done") -}).annotate({ - "description": "Event emitted when function call arguments streaming is complete", - "identifier": "FunctionCallArgsDoneEvent" -}) -export type FunctionTool = { - readonly "description"?: string | null - readonly "name": string - readonly "parameters": { readonly [x: string]: Schema.Json } | null - readonly "strict"?: boolean | null - readonly "type": "function" -} -export const FunctionTool = Schema.Struct({ - "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "name": Schema.String, - "parameters": Schema.Union([ - Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), - Schema.Null - ]), - "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "type": Schema.Literal("function") -}).annotate({ "description": "Function tool definition", "identifier": "FunctionTool" }) -export type Arrays_1 = ReadonlyArray -export const Arrays_1 = Schema.Array(Schema.String) -export type Arrays_2 = ReadonlyArray -export const Arrays_2 = Schema.Array(Schema.String) -export type Arrays_3 = ReadonlyArray< - { - readonly "stances": ReadonlyArray<{ readonly "model": string; readonly "stance": string }> - readonly "topic": string - } -> -export const Arrays_3 = Schema.Array( - Schema.Struct({ - "stances": Schema.Array(Schema.Struct({ "model": Schema.String, "stance": Schema.String })), - "topic": Schema.String - }) -) -export type Arrays_4 = ReadonlyArray<{ readonly "models": ReadonlyArray; readonly "point": string }> -export const Arrays_4 = Schema.Array(Schema.Struct({ "models": Schema.Array(Schema.String), "point": Schema.String })) -export type Arrays_5 = ReadonlyArray<{ readonly "insight": string; readonly "model": string }> -export const Arrays_5 = Schema.Array(Schema.Struct({ "insight": Schema.String, "model": Schema.String })) -export type FusionCallAnalysisInProgressEvent = { - readonly "item_id": string - readonly "judge_model": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.fusion_call.analysis.in_progress" -} -export const FusionCallAnalysisInProgressEvent = Schema.Struct({ - "item_id": Schema.String, - "judge_model": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.fusion_call.analysis.in_progress") -}).annotate({ - "description": "Emitted when the fusion judge starts producing the structured analysis.", - "identifier": "FusionCallAnalysisInProgressEvent" -}) -export type FusionCallCompletedEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.fusion_call.completed" -} -export const FusionCallCompletedEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.fusion_call.completed") -}).annotate({ - "description": "Emitted when the openrouter:fusion tool call finishes.", - "identifier": "FusionCallCompletedEvent" -}) -export type FusionCallInProgressEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.fusion_call.in_progress" -} -export const FusionCallInProgressEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.fusion_call.in_progress") -}).annotate({ - "description": "Emitted when an openrouter:fusion tool call begins executing.", - "identifier": "FusionCallInProgressEvent" -}) -export type FusionCallPanelAddedEvent = { - readonly "item_id": string - readonly "model": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.fusion_call.panel.added" -} -export const FusionCallPanelAddedEvent = Schema.Struct({ - "item_id": Schema.String, - "model": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.fusion_call.panel.added") -}).annotate({ - "description": "Emitted when a fusion analysis-panel model starts.", - "identifier": "FusionCallPanelAddedEvent" -}) -export type FusionCallPanelCompletedEvent = { - readonly "content": string - readonly "item_id": string - readonly "model": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.fusion_call.panel.completed" -} -export const FusionCallPanelCompletedEvent = Schema.Struct({ - "content": Schema.String, - "item_id": Schema.String, - "model": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.fusion_call.panel.completed") -}).annotate({ - "description": "Emitted when a fusion panel model finishes with its full content.", - "identifier": "FusionCallPanelCompletedEvent" -}) -export type FusionCallPanelDeltaEvent = { - readonly "delta": string - readonly "item_id": string - readonly "model": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.fusion_call.panel.delta" -} -export const FusionCallPanelDeltaEvent = Schema.Struct({ - "delta": Schema.String, - "item_id": Schema.String, - "model": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.fusion_call.panel.delta") -}).annotate({ - "description": "Incremental content token from a fusion panel model.", - "identifier": "FusionCallPanelDeltaEvent" -}) -export type FusionCallPanelFailedEvent = { - readonly "error": string - readonly "item_id": string - readonly "model": string - readonly "output_index": number - readonly "sequence_number": number - readonly "status_code"?: number - readonly "type": "response.fusion_call.panel.failed" -} -export const FusionCallPanelFailedEvent = Schema.Struct({ - "error": Schema.String, - "item_id": Schema.String, - "model": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "status_code": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "type": Schema.Literal("response.fusion_call.panel.failed") -}).annotate({ "description": "Emitted when a fusion panel model fails.", "identifier": "FusionCallPanelFailedEvent" }) -export type FusionCallPanelReasoningDeltaEvent = { - readonly "delta": string - readonly "item_id": string - readonly "model": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.fusion_call.panel.reasoning.delta" -} -export const FusionCallPanelReasoningDeltaEvent = Schema.Struct({ - "delta": Schema.String, - "item_id": Schema.String, - "model": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.fusion_call.panel.reasoning.delta") -}).annotate({ - "description": "Incremental reasoning token from a fusion panel model.", - "identifier": "FusionCallPanelReasoningDeltaEvent" -}) -export type FusionPlugin = { - readonly "analysis_models"?: ReadonlyArray - readonly "enabled"?: boolean - readonly "id": "fusion" - readonly "max_tool_calls"?: number - readonly "model"?: string - readonly "preset"?: "general-high" | "general-budget" | "general-fast" - readonly "tools"?: ReadonlyArray<{ readonly "parameters"?: {}; readonly "type": string }> -} -export const FusionPlugin = Schema.Struct({ - "analysis_models": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ - "description": - "Slugs of models to run in parallel as the \"expert panel\" the judge analyzes. Each model receives the same user prompt with web_search + web_fetch enabled. Capped at 8 models to bound cost amplification. When omitted, defaults to the Quality preset from the /labs/fusion UI (~anthropic/claude-opus-latest, ~openai/gpt-latest, ~google/gemini-pro-latest)." - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( - Schema.isMaxLength(8).annotate({ "expected": "a value with a length of at most 8" }) - ) - ), - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the fusion plugin for this request. Defaults to true." - }) - ), - "id": Schema.Literal("fusion"), - "max_tool_calls": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Maximum number of tool-calling steps each panelist (analysis model) and the judge model may take during their agentic web-research loop. Models with web_search/web_fetch enabled iterate until they produce a text response or hit this ceiling. Defaults to 8. Capped at 16." - }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( - Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) - ).check(Schema.isLessThanOrEqualTo(16).annotate({ "expected": "a value less than or equal to 16" })) - ), - "model": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Slug of the model that performs both the judge step (with web_search + web_fetch) and the final synthesis. When omitted, defaults to the first model in the Quality preset." - }) - ), - "preset": Schema.optionalKey( - Schema.Literals(["general-high", "general-budget", "general-fast"]).annotate({ - "description": - "A curated OpenRouter fusion preset (slugs follow `-`, e.g. `general-high`). Expands server-side into the preset's analysis_models panel and judge model, so callers never name individual models. Explicitly provided `analysis_models` / `model` take precedence." - }) - ), - "tools": Schema.optionalKey( - Schema.Array(Schema.Struct({ - "parameters": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": "Optional configuration forwarded as the tool's `parameters` object." - }) - ), - "type": Schema.String.annotate({ - "description": "Server tool type identifier (e.g. \"openrouter:web_search\", \"openrouter:web_fetch\")." - }) - })).annotate({ - "description": - "Server tools available to panelist and judge inner calls. Each entry uses the same `{ type, parameters? }` shorthand as the outer Chat Completions request. When omitted, defaults to `[{ type: \"openrouter:web_search\" }, { type: \"openrouter:web_fetch\" }]`. Pass an empty array to disable tools entirely (panelists answer from parametric knowledge only)." - }).check(Schema.isMaxLength(8).annotate({ "expected": "a value with a length of at most 8" })) - ) -}).annotate({ "identifier": "FusionPlugin" }) -export type Arrays_6 = ReadonlyArray -export const Arrays_6 = Schema.Array(Schema.String).annotate({ - "description": - "Slugs of models to run in parallel as the analysis panel. Each model receives the user prompt with openrouter:web_search and openrouter:web_fetch enabled, then a judge model summarizes the collective output into structured analysis JSON. Capped at 8 models to bound cost amplification. Defaults to the Quality preset from /labs/fusion." -}).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( - Schema.isMaxLength(8).annotate({ "expected": "a value with a length of at most 8" }) -) -export type Objects_9 = { - readonly "effort"?: "max" | "xhigh" | "high" | "medium" | "low" | "minimal" | "none" - readonly "max_tokens"?: number +export type TaskClassificationModel = { + readonly "id": string + readonly "tag_token_share": number + readonly "tag_usage_share": number } -export const Objects_9 = Schema.Struct({ - "effort": Schema.optionalKey( - Schema.Literals(["max", "xhigh", "high", "medium", "low", "minimal", "none"]).annotate({ - "description": "Reasoning effort level for panelist and judge inner calls." - }) - ), - "max_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Maximum number of reasoning tokens each panelist and judge model may use. Helps bound cost when models allocate too much budget to chain-of-thought." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ) -}).annotate({ - "description": - "Reasoning configuration forwarded to panelist and judge inner calls. Use this to control reasoning effort and token budget for models that support extended thinking." -}) -export type Arrays_7 = ReadonlyArray<{ readonly "parameters"?: {}; readonly "type": string }> -export const Arrays_7 = Schema.Array(Schema.Struct({ - "parameters": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Optional configuration forwarded as the tool's `parameters` object." }) - ), - "type": Schema.String.annotate({ - "description": "Server tool type identifier (e.g. \"openrouter:web_search\", \"openrouter:web_fetch\")." - }) -})).annotate({ - "description": - "Server tools available to panelist and judge inner calls. Each entry uses the same `{ type, parameters? }` shorthand as the outer Chat Completions request. When omitted, defaults to `[{ type: \"openrouter:web_search\" }, { type: \"openrouter:web_fetch\" }]`. Pass an empty array to disable tools entirely (panelists answer from parametric knowledge only)." -}).check(Schema.isMaxLength(8).annotate({ "expected": "a value with a length of at most 8" })) -export type FusionSource = { readonly "title": string; readonly "url": string } -export const FusionSource = Schema.Struct({ - "title": Schema.String.annotate({ "description": "Title of the retrieved web page." }), - "url": Schema.String.annotate({ - "description": "URL of the web page a panel or the judge retrieved during the run." - }) -}).annotate({ "description": "A web page retrieved via web search during a fusion run.", "identifier": "FusionSource" }) -export type GenerationContentData = { - readonly "input": { readonly "prompt": string } | { readonly "messages": ReadonlyArray } - readonly "output": { readonly "completion": string | null; readonly "reasoning": string | null } +export const TaskClassificationModel = Schema.Struct({ + "id": Schema.String.annotate({ "description": "Model identifier (permaslug)." }), + "tag_token_share": Schema.Number.annotate({ + "description": + "Fraction of this classification's sampled token volume attributed to this model (0–1). Sums to ≤1 across the returned models (only top-N are included and unattributed requests are excluded).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "tag_usage_share": Schema.Number.annotate({ + "description": + "Fraction of this classification's sampled requests attributed to this model (0–1). Sums to ≤1 across the returned models (only top-N are included and unattributed requests are excluded).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) +}).annotate({ "identifier": "TaskClassificationModel" }) +export type TaskClassificationMacroCategory = { + readonly "key": string + readonly "label": string + readonly "token_share": number + readonly "usage_share": number } -export const GenerationContentData = Schema.Struct({ - "input": Schema.Union([ - Schema.Struct({ "prompt": Schema.String }), - Schema.Struct({ "messages": Schema.Array(Schema.Json.annotate({ "expected": "JSON value" })) }) - ]).annotate({ "description": "The input to the generation — either a prompt string or an array of messages" }), - "output": Schema.Struct({ - "completion": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The completion output" }), - "reasoning": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Reasoning/thinking output, if any" - }) - }).annotate({ "description": "The output from the generation" }) -}).annotate({ "description": "Stored prompt and completion content", "identifier": "GenerationContentData" }) +export const TaskClassificationMacroCategory = Schema.Struct({ + "key": Schema.String.annotate({ "description": "Macro-category identifier." }), + "label": Schema.String.annotate({ "description": "Human-readable label for the macro-category." }), + "token_share": Schema.Number.annotate({ + "description": "Combined token share of all classifications in this macro-category (0–1).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "usage_share": Schema.Number.annotate({ + "description": "Combined usage share of all classifications in this macro-category (0–1).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) +}).annotate({ "identifier": "TaskClassificationMacroCategory" }) export type GoneResponseErrorData = { readonly "code": number readonly "message": string @@ -2682,373 +2384,79 @@ export const GoneResponseErrorData = Schema.Struct({ Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ) }).annotate({ "description": "Error data for GoneResponse", "identifier": "GoneResponseErrorData" }) -export type GuardrailInterval = "daily" | "weekly" | "monthly" | null -export const GuardrailInterval = Schema.Union([ - Schema.Literal("daily"), - Schema.Literal("weekly"), - Schema.Literal("monthly"), - Schema.Null -]).annotate({ - "description": "Interval at which the limit resets (daily, weekly, monthly)", - "identifier": "GuardrailInterval" -}) -export type ImageConfig = {} -export const ImageConfig = 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.", - "identifier": "ImageConfig" -}) -export type ImageGenCallCompletedEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.image_generation_call.completed" -} -export const ImageGenCallCompletedEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.image_generation_call.completed") -}).annotate({ "description": "Image generation call completed", "identifier": "ImageGenCallCompletedEvent" }) -export type ImageGenCallGeneratingEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.image_generation_call.generating" +export type AppRankingsItem = { + readonly "app_id": number + readonly "app_name": string + readonly "rank": number + readonly "total_requests": number + readonly "total_tokens": string } -export const ImageGenCallGeneratingEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.image_generation_call.generating") -}).annotate({ "description": "Image generation call is generating", "identifier": "ImageGenCallGeneratingEvent" }) -export type ImageGenCallInProgressEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.image_generation_call.in_progress" +export const AppRankingsItem = Schema.Struct({ + "app_id": Schema.Number.annotate({ "description": "Stable numeric identifier of the app on OpenRouter." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "app_name": Schema.String.annotate({ "description": "Public display name of the app." }), + "rank": Schema.Number.annotate({ + "description": "1-based position of the app within this response, per the requested `sort`." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "total_requests": Schema.Number.annotate({ + "description": "Number of requests attributed to the app inside the date window." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "total_tokens": Schema.String.annotate({ + "description": + "Sum of `prompt_tokens + completion_tokens` attributed to the app inside the date window, returned as a decimal string so 64-bit values are not truncated." + }) +}).annotate({ "identifier": "AppRankingsItem" }) +export type RankingsDailyMeta = { + readonly "as_of": string + readonly "end_date": string + readonly "start_date": string + readonly "version": "v1" } -export const ImageGenCallInProgressEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.image_generation_call.in_progress") -}).annotate({ "description": "Image generation call in progress", "identifier": "ImageGenCallInProgressEvent" }) -export type ImageGenCallPartialImageEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "partial_image_b64": string - readonly "partial_image_index": number - readonly "sequence_number": number - readonly "type": "response.image_generation_call.partial_image" +export const RankingsDailyMeta = Schema.Struct({ + "as_of": Schema.String.annotate({ + "description": + "ISO-8601 timestamp of when the response was generated. Reflects data-freshness because the underlying materialized view continuously ingests upstream events." + }), + "end_date": Schema.String.annotate({ "description": "Resolved end of the date window (UTC, inclusive)." }), + "start_date": Schema.String.annotate({ "description": "Resolved start of the date window (UTC, inclusive)." }), + "version": Schema.Literal("v1").annotate({ + "description": "Dataset version. Field names and grain are stable for the life of `v1`." + }) +}).annotate({ "identifier": "RankingsDailyMeta" }) +export type RankingsDailyItem = { + readonly "date": string + readonly "model_permaslug": string + readonly "total_tokens": string } -export const ImageGenCallPartialImageEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "partial_image_b64": Schema.String, - "partial_image_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.image_generation_call.partial_image") +export const RankingsDailyItem = Schema.Struct({ + "date": Schema.String.annotate({ "description": "UTC calendar date the row is aggregated over (YYYY-MM-DD)." }), + "model_permaslug": Schema.String.annotate({ + "description": + "Model variant permaslug (e.g. `openai/gpt-4o-2024-05-13`, `openai/gpt-4o-2024-05-13:free`). Non-default variants include a `:variant` suffix and are ranked as their own entry. The reserved value `other` denotes the aggregated row covering every model outside the daily top 50 for that date — always sorted last within its date." + }), + "total_tokens": Schema.String.annotate({ + "description": + "Sum of `prompt_tokens + completion_tokens` for the day, returned as a decimal string so 64-bit values are not truncated." + }) +}).annotate({ "identifier": "RankingsDailyItem" }) +export type MultimodalMedia = { readonly "data": string; readonly "format"?: string } +export const MultimodalMedia = Schema.Struct({ "data": Schema.String, "format": Schema.optionalKey(Schema.String) }) + .annotate({ "identifier": "MultimodalMedia" }) +export type ModelAliasTarget = { readonly "name": string; readonly "slug": string } +export const ModelAliasTarget = Schema.Struct({ + "name": Schema.String.annotate({ "description": "Human-readable name of the concrete model targeted by this alias" }), + "slug": Schema.String.annotate({ + "description": "Routable model ID of the concrete target, matching that model row's id" + }) }).annotate({ - "description": "Image generation call with partial image", - "identifier": "ImageGenCallPartialImageEvent" + "description": "Concrete model targeted by this tilde-latest alias, when applicable", + "identifier": "ModelAliasTarget" }) -export type ImageGenerationServerTool = { - readonly "background"?: "transparent" | "opaque" | "auto" - readonly "input_fidelity"?: "high" | "low" | null - readonly "input_image_mask"?: { readonly "file_id"?: string; readonly "image_url"?: string } - readonly "model"?: string - 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"?: string - readonly "type": "image_generation" -} -export const ImageGenerationServerTool = Schema.Struct({ - "background": Schema.optionalKey(Schema.Literals(["transparent", "opaque", "auto"])), - "input_fidelity": Schema.optionalKey(Schema.Union([Schema.Literal("high"), Schema.Literal("low"), Schema.Null])), - "input_image_mask": Schema.optionalKey( - Schema.Struct({ "file_id": Schema.optionalKey(Schema.String), "image_url": Schema.optionalKey(Schema.String) }) - ), - "model": Schema.optionalKey(Schema.String), - "moderation": Schema.optionalKey(Schema.Literals(["auto", "low"])), - "output_compression": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "output_format": Schema.optionalKey(Schema.Literals(["png", "webp", "jpeg"])), - "partial_images": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "quality": Schema.optionalKey(Schema.Literals(["low", "medium", "high", "auto"])), - "size": Schema.optionalKey(Schema.String), - "type": Schema.Literal("image_generation") -}).annotate({ "description": "Image generation tool configuration", "identifier": "ImageGenerationServerTool" }) -export type ImageGenerationServerToolConfig = { readonly "model"?: string } -export const ImageGenerationServerToolConfig = Schema.Struct({ - "model": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Which image generation model to use (e.g. \"openai/gpt-5-image\"). Defaults to \"openai/gpt-5-image\"." - }) - ) -}).annotate({ - "description": - "Configuration for the openrouter:image_generation server tool. Accepts all image_config params (aspect_ratio, quality, size, background, output_format, output_compression, moderation, etc.) plus a model field.", - "identifier": "ImageGenerationServerToolConfig" +export type InputModality = "text" | "image" | "file" | "audio" | "video" +export const InputModality = Schema.Literals(["text", "image", "file", "audio", "video"]).annotate({ + "identifier": "InputModality" }) -export type ImageGenerationStatus = "in_progress" | "completed" | "generating" | "failed" -export const ImageGenerationStatus = Schema.Literals(["in_progress", "completed", "generating", "failed"]).annotate({ - "identifier": "ImageGenerationStatus" -}) -export type Union_6 = { - readonly "audio_tokens"?: number | null - readonly "image_tokens"?: number | null - readonly "reasoning_tokens"?: number | null - readonly [x: string]: Schema.Json -} | null -export const Union_6 = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "audio_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Tokens generated by the model for audio output." }) - ), - "image_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Tokens generated by the model for image output." }) - ), - "reasoning_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Tokens generated by the model for reasoning." }) - ) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]) -export type Union_8 = { - readonly "audio_tokens"?: number | null - readonly "cache_write_tokens"?: number | null - readonly "cached_tokens"?: number | null - readonly "file_tokens"?: number | null - readonly "video_tokens"?: number | null - readonly [x: string]: Schema.Json -} | null -export const Union_8 = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "audio_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Tokens used for input audio." }) - ), - "cache_write_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ - "description": - "Tokens written to cache. Only returned for models with explicit caching and cache write pricing." - }) - ), - "cached_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Tokens cached by the endpoint." }) - ), - "file_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Tokens used for input files/documents." }) - ), - "video_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Tokens used for input video." }) - ) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ "description": "Breakdown of tokens used in the prompt." }) -export type Union_9 = { - readonly "tool_calls_executed"?: number | null - readonly "tool_calls_requested"?: number | null - readonly "web_search_requests"?: number | null - readonly [x: string]: Schema.Json -} | null -export const Union_9 = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "tool_calls_executed": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "Number of OpenRouter server tool calls that executed and produced a result." }) - ), - "tool_calls_requested": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ - "description": - "Total number of OpenRouter server-orchestrated tool calls the model requested, across all tool types. Provider-native tools (e.g. native web search) are not counted here." - }) - ), - "web_search_requests": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ - "description": - "Number of web searches performed by server-side tools. For server-orchestrated tool calls a web search is also counted in tool_calls_requested; provider-native web search may report web_search_requests only. Do not sum the two." - }) - ) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ "description": "Usage for server-side tool execution (e.g., web search)" }) -export type ImageGenPartialImageEvent = { - readonly "b64_json": string - readonly "partial_image_index": number - readonly "type": "image_generation.partial_image" -} -export const ImageGenPartialImageEvent = Schema.Struct({ - "b64_json": Schema.String.annotate({ "description": "Base64-encoded partial image data" }), - "partial_image_index": Schema.Number.annotate({ - "description": "0-based index indicating which partial image this is in the sequence" - }).check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("image_generation.partial_image").annotate({ "description": "The event type" }) -}).annotate({ - "description": "Emitted when a partial image becomes available during streaming generation", - "identifier": "ImageGenPartialImageEvent" -}) -export type ImageGenStreamErrorEvent = { - readonly "error": { - readonly "code"?: string | null - readonly "message": string - readonly "param"?: string | null - readonly "type"?: string | null - } - readonly "type": "error" -} -export const ImageGenStreamErrorEvent = Schema.Struct({ - "error": Schema.Struct({ - "code": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Provider error code, when supplied" }) - ), - "message": Schema.String.annotate({ "description": "Provider error message" }), - "param": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Request parameter associated with the error, when supplied" - }) - ), - "type": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Provider error type, when supplied" }) - ) - }).annotate({ "description": "Provider error details" }), - "type": Schema.Literal("error").annotate({ "description": "The event type" }) -}).annotate({ - "description": "Emitted when streaming generation fails after the SSE response starts", - "identifier": "ImageGenStreamErrorEvent" -}) -export type ImageGenTextChunkEvent = { - readonly "phase": "content" | "reasoning" | "draft" - readonly "text": string - readonly "type": "image_generation.text_chunk" -} -export const ImageGenTextChunkEvent = Schema.Struct({ - "phase": Schema.Literals(["content", "reasoning", "draft"]).annotate({ - "description": - "The generation phase this chunk belongs to. `content` is the renderable output; `reasoning` and `draft` are intermediate provider phases." - }), - "text": Schema.String.annotate({ - "description": "A text fragment of the image being generated (e.g. partial SVG markup)" - }), - "type": Schema.Literal("image_generation.text_chunk").annotate({ "description": "The event type" }) -}).annotate({ - "description": - "Emitted when a text chunk becomes available during streaming generation of text-based formats (e.g. SVG)", - "identifier": "ImageGenTextChunkEvent" -}) -export type ImageInputModality = "text" | "image" | "file" | "audio" | "video" -export const ImageInputModality = Schema.Literals(["text", "image", "file", "audio", "video"]).annotate({ - "identifier": "ImageInputModality" -}) -export type ImageOutputModality = - | "text" - | "image" - | "embeddings" - | "audio" - | "video" - | "rerank" - | "speech" - | "transcription" -export const ImageOutputModality = Schema.Literals([ - "text", - "image", - "embeddings", - "audio", - "video", - "rerank", - "speech", - "transcription" -]).annotate({ "identifier": "ImageOutputModality" }) -export type ImagePricingEntry = { - readonly "billable": "output_image" | "input_image" | "input_font" | "input_reference" | "input_text" - readonly "cost_usd": number - readonly "unit": "image" | "megapixel" | "token" - readonly "variant"?: string -} -export const ImagePricingEntry = Schema.Struct({ - "billable": Schema.Literals(["output_image", "input_image", "input_font", "input_reference", "input_text"]), - "cost_usd": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "unit": Schema.Literals(["image", "megapixel", "token"]), - "variant": Schema.optionalKey(Schema.String) -}).annotate({ "description": "One billable pricing line for an image provider.", "identifier": "ImagePricingEntry" }) -export type IncompleteDetails = { - readonly "reason"?: "max_output_tokens" | "content_filter" - readonly [x: string]: Schema.Json -} | null -export const IncompleteDetails = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ "reason": Schema.optionalKey(Schema.Literals(["max_output_tokens", "content_filter"])) }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ "identifier": "IncompleteDetails" }) -export type InputAudio = { - readonly "input_audio": { readonly "data": string; readonly "format": "mp3" | "wav" } - readonly "type": "input_audio" -} -export const InputAudio = Schema.Struct({ - "input_audio": Schema.Struct({ "data": Schema.String, "format": Schema.Literals(["mp3", "wav"]) }), - "type": Schema.Literal("input_audio") -}).annotate({ "description": "Audio input content item", "identifier": "InputAudio" }) -export type InputFile = { - readonly "file_data"?: string - readonly "file_id"?: string | null - readonly "file_url"?: string - readonly "filename"?: string - readonly "type": "input_file" -} -export const InputFile = Schema.Struct({ - "file_data": Schema.optionalKey(Schema.String), - "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "file_url": Schema.optionalKey(Schema.String), - "filename": Schema.optionalKey(Schema.String), - "type": Schema.Literal("input_file") -}).annotate({ "description": "File input content item", "identifier": "InputFile" }) -export type InputImage = { - readonly "detail": "auto" | "high" | "low" | "original" - readonly "image_url"?: string | null - readonly "type": "input_image" -} -export const InputImage = Schema.Struct({ - "detail": Schema.Literals(["auto", "high", "low", "original"]), - "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("input_image") -}).annotate({ "description": "Image input content item", "identifier": "InputImage" }) -export type InputModality = "text" | "image" | "file" | "audio" | "video" -export const InputModality = Schema.Literals(["text", "image", "file", "audio", "video"]).annotate({ - "identifier": "InputModality" -}) -export type InputVideo = { readonly "type": "input_video"; readonly "video_url": string } -export const InputVideo = Schema.Struct({ - "type": Schema.Literal("input_video"), - "video_url": Schema.String.annotate({ - "description": "A base64 data URL or remote URL that resolves to a video file" - }) -}).annotate({ "description": "Video input content item", "identifier": "InputVideo" }) export type InstructType = | "none" | "airoboros" @@ -3098,286 +2506,17 @@ export const InstructType = Schema.Union([ Schema.Literal("qwen3"), Schema.Null ]).annotate({ "description": "Instruction format type", "identifier": "InstructType" }) -export type InternalServerResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null -} -export const InternalServerResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ "description": "Error data for InternalServerResponse", "identifier": "InternalServerResponseErrorData" }) -export type ItemReferenceItem = { readonly "id": string; readonly "type": "item_reference" } -export const ItemReferenceItem = Schema.Struct({ "id": Schema.String, "type": Schema.Literal("item_reference") }) - .annotate({ "description": "A reference to a previous response item by ID", "identifier": "ItemReferenceItem" }) -export type KeyAssignment = { - readonly "assigned_by": string | null - readonly "created_at": string - readonly "guardrail_id": string - readonly "id": string - readonly "key_hash": string - readonly "key_label": string - readonly "key_name": string -} -export const KeyAssignment = Schema.Struct({ - "assigned_by": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "User ID of who made the assignment" - }), - "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the assignment was created" }), - "guardrail_id": Schema.String.annotate({ "description": "ID of the guardrail", "format": "uuid" }), - "id": Schema.String.annotate({ "description": "Unique identifier for the assignment", "format": "uuid" }), - "key_hash": Schema.String.annotate({ "description": "Hash of the assigned API key" }), - "key_label": Schema.String.annotate({ "description": "Label of the API key" }), - "key_name": Schema.String.annotate({ "description": "Name of the API key" }) -}).annotate({ "identifier": "KeyAssignment" }) -export type Legacy_ChatContentVideoInput = { readonly "url": string } -export const Legacy_ChatContentVideoInput = Schema.Struct({ - "url": Schema.String.annotate({ "description": "URL of the video (data: URLs supported)" }) -}).annotate({ "description": "Video input object", "identifier": "Legacy_ChatContentVideoInput" }) -export type McpApprovalRequestItem = { - readonly "arguments": string - readonly "id": string - readonly "name": string - readonly "server_label": string - readonly "type": "mcp_approval_request" -} -export const McpApprovalRequestItem = Schema.Struct({ - "arguments": Schema.String, - "id": Schema.String, - "name": Schema.String, - "server_label": Schema.String, - "type": Schema.Literal("mcp_approval_request") -}).annotate({ "description": "Request for approval to execute an MCP tool", "identifier": "McpApprovalRequestItem" }) -export type McpApprovalResponseItem = { - readonly "approval_request_id": string - readonly "approve": boolean - readonly "id"?: string | null - readonly "reason"?: string | null - readonly "type": "mcp_approval_response" -} -export const McpApprovalResponseItem = Schema.Struct({ - "approval_request_id": Schema.String, - "approve": Schema.Boolean, - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "reason": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("mcp_approval_response") -}).annotate({ "description": "User response to an MCP tool approval request", "identifier": "McpApprovalResponseItem" }) -export type McpCallItem = { - readonly "arguments": string - readonly "error"?: string | null - readonly "id": string - readonly "name": string - readonly "output"?: string | null - readonly "server_label": string - readonly "type": "mcp_call" -} -export const McpCallItem = Schema.Struct({ - "arguments": Schema.String, - "error": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "id": Schema.String, - "name": Schema.String, - "output": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "server_label": Schema.String, - "type": Schema.Literal("mcp_call") -}).annotate({ "description": "An MCP tool call with its output or error", "identifier": "McpCallItem" }) -export type McpListToolsItem = { - readonly "error"?: string | null - readonly "id": string - readonly "server_label": string - readonly "tools": ReadonlyArray< - { - readonly "annotations"?: Schema.Json - readonly "description"?: string | null - readonly "input_schema": {} - readonly "name": string - } - > - readonly "type": "mcp_list_tools" -} -export const McpListToolsItem = Schema.Struct({ - "error": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "id": Schema.String, - "server_label": Schema.String, - "tools": Schema.Array( - Schema.Struct({ - "annotations": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), - "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "input_schema": Schema.Struct({}), - "name": Schema.String - }) - ), - "type": Schema.Literal("mcp_list_tools") -}).annotate({ "description": "List of available MCP tools from a server", "identifier": "McpListToolsItem" }) -export type McpServerTool = { - readonly "allowed_tools"?: ReadonlyArray | { - readonly "read_only"?: boolean - readonly "tool_names"?: ReadonlyArray - } | null - 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 [x: string]: string } | null - readonly "require_approval"?: - | { - readonly "always"?: { readonly "tool_names"?: ReadonlyArray } - readonly "never"?: { readonly "tool_names"?: ReadonlyArray } - } - | "always" - | "never" - | null - readonly "server_description"?: string - readonly "server_label": string - readonly "server_url"?: string - readonly "type": "mcp" -} -export const McpServerTool = Schema.Struct({ - "allowed_tools": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String), - Schema.Struct({ - "read_only": Schema.optionalKey(Schema.Boolean), - "tool_names": Schema.optionalKey(Schema.Array(Schema.String)) - }), - Schema.Null - ]) - ), - "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.Union([Schema.Record(Schema.String, Schema.String), Schema.Null])), - "require_approval": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "always": Schema.optionalKey(Schema.Struct({ "tool_names": Schema.optionalKey(Schema.Array(Schema.String)) })), - "never": Schema.optionalKey(Schema.Struct({ "tool_names": Schema.optionalKey(Schema.Array(Schema.String)) })) - }), - Schema.Literal("always"), - Schema.Literal("never"), - Schema.Null - ]) - ), - "server_description": Schema.optionalKey(Schema.String), - "server_label": Schema.String, - "server_url": Schema.optionalKey(Schema.String), - "type": Schema.Literal("mcp") -}).annotate({ "description": "MCP (Model Context Protocol) tool configuration", "identifier": "McpServerTool" }) -export type MemberAssignment = { - readonly "assigned_by": string | null - readonly "created_at": string - readonly "guardrail_id": string - readonly "id": string - readonly "organization_id": string - readonly "user_id": string -} -export const MemberAssignment = Schema.Struct({ - "assigned_by": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "User ID of who made the assignment" - }), - "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the assignment was created" }), - "guardrail_id": Schema.String.annotate({ "description": "ID of the guardrail", "format": "uuid" }), - "id": Schema.String.annotate({ "description": "Unique identifier for the assignment", "format": "uuid" }), - "organization_id": Schema.String.annotate({ "description": "Organization ID" }), - "user_id": Schema.String.annotate({ "description": "Clerk user ID of the assigned member" }) -}).annotate({ "identifier": "MemberAssignment" }) -export type MessagesAdvisorToolResultBlock = { - readonly "content": {} - readonly "tool_use_id": string - readonly "type": "advisor_tool_result" -} -export const MessagesAdvisorToolResultBlock = Schema.Struct({ - "content": Schema.Struct({}), - "tool_use_id": Schema.String, - "type": Schema.Literal("advisor_tool_result") -}).annotate({ - "description": - "Advisor tool result from a prior assistant turn, replayed back to the model on the next turn. Mirrors the block Anthropic returns in assistant content when the `advisor_20260301` tool runs.", - "identifier": "MessagesAdvisorToolResultBlock" -}) -export type MessagesContentBlockStopEvent = { readonly "index": number; readonly "type": "content_block_stop" } -export const MessagesContentBlockStopEvent = Schema.Struct({ - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("content_block_stop") -}).annotate({ - "description": "Event sent when a content block is complete", - "identifier": "MessagesContentBlockStopEvent" -}) -export type MessagesFallbackParam = { readonly "model": string } -export const MessagesFallbackParam = Schema.Struct({ "model": Schema.String }).annotate({ - "description": - "Fallback model to try when the primary model fails or refuses. Only the `model` field is supported; per-attempt overrides are rejected.", - "identifier": "MessagesFallbackParam" -}) -export type Union_10 = - | { readonly "schema": {}; readonly "type": "json_schema"; readonly [x: string]: Schema.Json } - | null -export const Union_10 = Schema.Union([ - Schema.StructWithRest(Schema.Struct({ "schema": Schema.Struct({}), "type": Schema.Literal("json_schema") }), [ - Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) - ]), - Schema.Null -]).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)." -}) -export type Union_11 = { - readonly "remaining"?: number | null - readonly "total": number - readonly "type": "tokens" - readonly [x: string]: Schema.Json -} | null -export const Union_11 = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "remaining": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( - Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) - ), - Schema.Null - ]) - ), - "total": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( - Schema.isGreaterThanOrEqualTo(20000).annotate({ "expected": "a value greater than or equal to 20000" }) - ), - "type": Schema.Literal("tokens") - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ - "description": - "Task budget for an agentic turn. The model sees a countdown of remaining tokens and uses it to prioritize work and wind down gracefully. Advisory — does not enforce a hard cap." -}) -export type MessagesPingEvent = { readonly "type": "ping" } -export const MessagesPingEvent = Schema.Struct({ "type": Schema.Literal("ping") }).annotate({ - "description": "Keep-alive ping event", - "identifier": "MessagesPingEvent" -}) -export type MetadataLevel = "disabled" | "enabled" -export const MetadataLevel = Schema.Literals(["disabled", "enabled"]).annotate({ - "description": "Opt-in level for surfacing routing metadata on the response under `openrouter_metadata`.", - "identifier": "MetadataLevel" -}) +export type OutputModality = "text" | "image" | "embeddings" | "audio" | "video" | "rerank" | "speech" | "transcription" +export const OutputModality = Schema.Literals([ + "text", + "image", + "embeddings", + "audio", + "video", + "rerank", + "speech", + "transcription" +]).annotate({ "identifier": "OutputModality" }) export type ModelGroup = | "Router" | "Media" @@ -3421,604 +2560,250 @@ export const ModelGroup = Schema.Literals([ "RWKV", "Qwen3" ]).annotate({ "description": "Tokenizer type used by the model", "identifier": "ModelGroup" }) -export type ModelLinks = { readonly "details": string } -export const ModelLinks = Schema.Struct({ - "details": Schema.String.annotate({ "description": "URL for the model details/endpoints API" }) -}).annotate({ "description": "Related API endpoints and resources for this model.", "identifier": "ModelLinks" }) -export type ModelName = string -export const ModelName = Schema.String.annotate({ - "description": "Model to use for completion", - "identifier": "ModelName" -}) -export type ModelsCountResponse = { readonly "data": { readonly "count": number } } -export const ModelsCountResponse = Schema.Struct({ - "data": Schema.Struct({ - "count": Schema.Number.annotate({ "description": "Total number of available models" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - }).annotate({ "description": "Model count data" }) -}).annotate({ "description": "Model count data", "identifier": "ModelsCountResponse" }) -export type ModerationPlugin = { readonly "id": "moderation" } -export const ModerationPlugin = Schema.Struct({ "id": Schema.Literal("moderation") }).annotate({ - "identifier": "ModerationPlugin" +export type AABenchmarkEntry = { + readonly "agentic_index": number | null + readonly "coding_index": number | null + readonly "intelligence_index": number | null +} +export const AABenchmarkEntry = Schema.Struct({ + "agentic_index": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Artificial Analysis Agentic Index score", "format": "double" }), + "coding_index": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Artificial Analysis Coding Index score", "format": "double" }), + "intelligence_index": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Artificial Analysis Intelligence Index score", "format": "double" }) +}).annotate({ "description": "Artificial Analysis benchmark index scores.", "identifier": "AABenchmarkEntry" }) +export type DABenchmarkEntry = { + readonly "arena": string + readonly "category": string + readonly "elo": number + readonly "rank": number + readonly "win_rate": number +} +export const DABenchmarkEntry = Schema.Struct({ + "arena": Schema.String.annotate({ "description": "Arena type (e.g. models, builders, agents)" }), + "category": Schema.String.annotate({ + "description": "Category within the arena (e.g. website, gamedev, uicomponent)" + }), + "elo": Schema.Number.annotate({ "description": "ELO rating from head-to-head arena battles", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "rank": Schema.Number.annotate({ + "description": "Rank position within this arena+category among models available on OpenRouter (1 = highest ELO)" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "win_rate": Schema.Number.annotate({ "description": "Win rate percentage in arena battles", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })) +}).annotate({ + "description": "A single Design Arena benchmark entry for a specific arena+category", + "identifier": "DABenchmarkEntry" }) -export type MultimodalMedia = { readonly "data": string; readonly "format"?: string } -export const MultimodalMedia = Schema.Struct({ "data": Schema.String, "format": Schema.optionalKey(Schema.String) }) - .annotate({ "identifier": "MultimodalMedia" }) -export type NamespaceFunctionTool = { - readonly "allowed_callers"?: ReadonlyArray<"direct" | "programmatic"> | null - readonly "defer_loading"?: boolean - readonly "description"?: string | null - readonly "name": string - readonly "output_schema"?: { readonly [x: string]: Schema.Json } | null - readonly "parameters"?: { readonly [x: string]: Schema.Json } | null - readonly "strict"?: boolean | null - readonly "type": "function" +export type DefaultParameters = { + readonly "frequency_penalty"?: number | null + readonly "presence_penalty"?: number | null + readonly "repetition_penalty"?: number | null + readonly "temperature"?: number | null + readonly "top_k"?: number | null + readonly "top_p"?: number | null +} | null +export const DefaultParameters = Schema.Union([ + Schema.Struct({ + "frequency_penalty": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ), + "presence_penalty": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ), + "repetition_penalty": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ), + "temperature": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ), + "top_k": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ), + "top_p": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ) + }), + Schema.Null +]).annotate({ "description": "Default parameters for this model", "identifier": "DefaultParameters" }) +export type ModelLinks = { readonly "details": string } +export const ModelLinks = Schema.Struct({ + "details": Schema.String.annotate({ "description": "URL for the model details/endpoints API" }) +}).annotate({ "description": "Related API endpoints and resources for this model.", "identifier": "ModelLinks" }) +export type PerRequestLimits = { + readonly "completion_tokens": number + readonly "prompt_tokens": number + readonly [x: string]: Schema.Json +} | null +export const PerRequestLimits = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "completion_tokens": Schema.Number.annotate({ "description": "Maximum completion tokens per request" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "prompt_tokens": Schema.Number.annotate({ "description": "Maximum prompt tokens per request" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "description": "Per-request token limits", "identifier": "PerRequestLimits" }) +export type PricingOverride = { + readonly "audio"?: string + readonly "completion"?: string + readonly "input_audio_cache"?: string + readonly "input_cache_read"?: string + readonly "input_cache_write"?: string + readonly "input_cache_write_1h"?: string + readonly "min_prompt_tokens"?: number + readonly "prompt"?: string + readonly "utc_end"?: number + readonly "utc_start"?: number } -export const NamespaceFunctionTool = Schema.Struct({ - "allowed_callers": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.Literals(["direct", "programmatic"])), Schema.Null]) +export const PricingOverride = Schema.Struct({ + "audio": Schema.optionalKey( + Schema.String.annotate({ "description": "Overridden price in USD per audio input token" }) ), - "defer_loading": Schema.optionalKey(Schema.Boolean), - "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "name": Schema.String, - "output_schema": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + "completion": Schema.optionalKey( + Schema.String.annotate({ "description": "Overridden price in USD per token for completion (output) generation" }) ), - "parameters": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + "input_audio_cache": Schema.optionalKey( + Schema.String.annotate({ "description": "Overridden price in USD per cached audio input token" }) ), - "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "type": Schema.Literal("function") -}).annotate({ "description": "A function tool grouped inside a namespace tool", "identifier": "NamespaceFunctionTool" }) -export type NotFoundResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null -} -export const NotFoundResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ "description": "Error data for NotFoundResponse", "identifier": "NotFoundResponseErrorData" }) -export type ObservabilityFilterRuleGroup = { - readonly "logic"?: "and" | "or" - readonly "rules": ReadonlyArray< - { - readonly "field": - | "model" - | "provider" - | "session_id" - | "user_id" - | "api_key_name" - | "finish_reason" - | "input" - | "output" - | "total_cost" - | "total_tokens" - | "prompt_tokens" - | "completion_tokens" - readonly "operator": - | "equals" - | "not_equals" - | "contains" - | "not_contains" - | "regex" - | "starts_with" - | "ends_with" - | "gt" - | "lt" - | "gte" - | "lte" - | "exists" - | "not_exists" - readonly "value"?: string | number - } - > -} -export const ObservabilityFilterRuleGroup = Schema.Struct({ - "logic": Schema.optionalKey(Schema.Literals(["and", "or"])), - "rules": Schema.Array(Schema.Struct({ - "field": Schema.Literals([ - "model", - "provider", - "session_id", - "user_id", - "api_key_name", - "finish_reason", - "input", - "output", - "total_cost", - "total_tokens", - "prompt_tokens", - "completion_tokens" - ]), - "operator": Schema.Literals([ - "equals", - "not_equals", - "contains", - "not_contains", - "regex", - "starts_with", - "ends_with", - "gt", - "lt", - "gte", - "lte", - "exists", - "not_exists" - ]), - "value": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))]) - ) - })) -}).annotate({ "identifier": "ObservabilityFilterRuleGroup" }) -export type OpenAIResponseCustomToolCall = { - readonly "call_id": string - readonly "id"?: string - readonly "input": string - readonly "name": string - readonly "namespace"?: string - readonly "type": "custom_tool_call" -} -export const OpenAIResponseCustomToolCall = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), - "input": Schema.String, - "name": Schema.String, - "namespace": Schema.optionalKey( - Schema.String.annotate({ - "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" - }) + "input_cache_read": Schema.optionalKey( + Schema.String.annotate({ "description": "Overridden price in USD per cached input token (read)" }) ), - "type": Schema.Literal("custom_tool_call") -}).annotate({ "identifier": "OpenAIResponseCustomToolCall" }) -export type OpenAIResponsesImageGenCallCompleted = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.image_generation_call.completed" -} -export const OpenAIResponsesImageGenCallCompleted = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.image_generation_call.completed") -}).annotate({ "identifier": "OpenAIResponsesImageGenCallCompleted" }) -export type OpenAIResponsesImageGenCallGenerating = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.image_generation_call.generating" -} -export const OpenAIResponsesImageGenCallGenerating = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.image_generation_call.generating") -}).annotate({ "identifier": "OpenAIResponsesImageGenCallGenerating" }) -export type OpenAIResponsesImageGenCallInProgress = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.image_generation_call.in_progress" -} -export const OpenAIResponsesImageGenCallInProgress = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.image_generation_call.in_progress") -}).annotate({ "identifier": "OpenAIResponsesImageGenCallInProgress" }) -export type OpenAIResponsesImageGenCallPartialImage = { - readonly "item_id": string - readonly "output_index": number - readonly "partial_image_b64": string - readonly "partial_image_index": number - readonly "sequence_number": number - readonly "type": "response.image_generation_call.partial_image" -} -export const OpenAIResponsesImageGenCallPartialImage = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "partial_image_b64": Schema.String, - "partial_image_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.image_generation_call.partial_image") -}).annotate({ "identifier": "OpenAIResponsesImageGenCallPartialImage" }) -export type OpenAIResponsesRefusalContent = { readonly "refusal": string; readonly "type": "refusal" } -export const OpenAIResponsesRefusalContent = Schema.Struct({ - "refusal": Schema.String, - "type": Schema.Literal("refusal") -}).annotate({ "identifier": "OpenAIResponsesRefusalContent" }) -export type OpenAIResponsesResponseStatus = - | "completed" - | "incomplete" - | "in_progress" - | "failed" - | "cancelled" - | "queued" -export const OpenAIResponsesResponseStatus = Schema.Literals([ - "completed", - "incomplete", - "in_progress", - "failed", - "cancelled", - "queued" -]).annotate({ "identifier": "OpenAIResponsesResponseStatus" }) -export type OpenAIResponsesSearchCompleted = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.web_search_call.completed" -} -export const OpenAIResponsesSearchCompleted = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.web_search_call.completed") -}).annotate({ "identifier": "OpenAIResponsesSearchCompleted" }) -export type Objects_11 = { readonly "name": string; readonly "type": "function" } -export const Objects_11 = Schema.Struct({ "name": Schema.String, "type": Schema.Literal("function") }) -export type Objects_12 = { readonly "type": "web_search_preview_2025_03_11" | "web_search_preview" } -export const Objects_12 = Schema.Struct({ - "type": Schema.Literals(["web_search_preview_2025_03_11", "web_search_preview"]) -}) -export type Objects_13 = { readonly "type": "apply_patch" } -export const Objects_13 = Schema.Struct({ "type": Schema.Literal("apply_patch") }) -export type Objects_14 = { readonly "type": "shell" } -export const Objects_14 = Schema.Struct({ "type": Schema.Literal("shell") }) -export type OpenAIResponsesTruncation = "auto" | "disabled" | null -export const OpenAIResponsesTruncation = Schema.Union([Schema.Literal("auto"), Schema.Literal("disabled"), Schema.Null]) - .annotate({ "identifier": "OpenAIResponsesTruncation" }) -export type Objects_15 = { readonly "cache_write_tokens"?: number | null; readonly "cached_tokens": number } -export const Objects_15 = Schema.Struct({ - "cache_write_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + "input_cache_write": Schema.optionalKey( + Schema.String.annotate({ "description": "Overridden price in USD per cache-write token" }) ), - "cached_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}) -export type Objects_16 = { readonly "reasoning_tokens": number } -export const Objects_16 = Schema.Struct({ - "reasoning_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}) -export type OpenAIResponsesWebSearchCallInProgress = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.web_search_call.in_progress" -} -export const OpenAIResponsesWebSearchCallInProgress = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.web_search_call.in_progress") -}).annotate({ "identifier": "OpenAIResponsesWebSearchCallInProgress" }) -export type OpenAIResponsesWebSearchCallSearching = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.web_search_call.searching" -} -export const OpenAIResponsesWebSearchCallSearching = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.web_search_call.searching") -}).annotate({ "identifier": "OpenAIResponsesWebSearchCallSearching" }) -export type OpenResponsesTopLogprobs = { - readonly "bytes"?: ReadonlyArray - readonly "logprob"?: number - readonly "token"?: string -} -export const OpenResponsesTopLogprobs = Schema.Struct({ - "bytes": Schema.optionalKey(Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })))), - "logprob": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + "input_cache_write_1h": Schema.optionalKey( + Schema.String.annotate({ "description": "Overridden price in USD per 1-hour cache-write token" }) ), - "token": Schema.optionalKey(Schema.String) -}).annotate({ "description": "Alternative token with its log probability", "identifier": "OpenResponsesTopLogprobs" }) -export type ORAnthropicStopReason = - | "end_turn" - | "max_tokens" - | "stop_sequence" - | "tool_use" - | "pause_turn" - | "refusal" - | "compaction" - | null -export const ORAnthropicStopReason = Schema.Union([ - Schema.Literal("end_turn"), - Schema.Literal("max_tokens"), - Schema.Literal("stop_sequence"), - Schema.Literal("tool_use"), - Schema.Literal("pause_turn"), - Schema.Literal("refusal"), - Schema.Literal("compaction"), - Schema.Null -]).annotate({ "identifier": "ORAnthropicStopReason" }) -export type OutputComputerCallItem = { - readonly "action"?: Schema.Json - readonly "call_id": string - readonly "id"?: string - readonly "pending_safety_checks": ReadonlyArray< - { readonly "code": string; readonly "id": string; readonly "message": string } - > - readonly "status": "completed" | "incomplete" | "in_progress" - readonly "type": "computer_call" -} -export const OutputComputerCallItem = Schema.Struct({ - "action": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), - "pending_safety_checks": Schema.Array( - Schema.Struct({ "code": Schema.String, "id": Schema.String, "message": Schema.String }) + "min_prompt_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Condition: the entry applies when the total prompt tokens of a request are strictly greater than this threshold", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), - "status": Schema.Literals(["completed", "incomplete", "in_progress"]), - "type": Schema.Literal("computer_call") -}).annotate({ "identifier": "OutputComputerCallItem" }) -export type OutputCustomToolCallItem = { - readonly "call_id": string - readonly "id"?: string - readonly "input": string - readonly "name": string - readonly "namespace"?: string - readonly "type": "custom_tool_call" -} -export const OutputCustomToolCallItem = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), - "input": Schema.String, - "name": Schema.String, - "namespace": Schema.optionalKey( - Schema.String.annotate({ - "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" - }) + "prompt": Schema.optionalKey( + Schema.String.annotate({ "description": "Overridden price in USD per token for prompt (input) processing" }) ), - "type": Schema.Literal("custom_tool_call") + "utc_end": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Condition: exclusive end of a daily UTC time window as an HHMM clock number (e.g. 400 = 04:00)", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "utc_start": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Condition: inclusive start of a daily UTC time window as an HHMM clock number (e.g. 100 = 01:00, 1030 = 10:30). The entry applies while the current UTC time is inside the half-open window [utc_start, utc_end), which may wrap past midnight (utc_start > utc_end).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) }).annotate({ "description": - "A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI's `apply_patch` whose payload is opaque text rather than JSON arguments.", - "identifier": "OutputCustomToolCallItem" + "A conditional override of the base pricing. An entry applies only when all of its condition fields (e.g. min_prompt_tokens, or the utc_start/utc_end time window) match the request; among applicable entries, later entries win per price key; price keys absent from an entry inherit the base price.", + "identifier": "PricingOverride" }) -export type OutputFunctionCallItem = { - readonly "arguments": string - readonly "call_id": string - readonly "id"?: string - readonly "name": string - readonly "namespace"?: string - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "type": "function_call" +export type ReasoningEffort = "max" | "xhigh" | "high" | "medium" | "low" | "minimal" | "none" | null +export const ReasoningEffort = Schema.Union([ + Schema.Literal("max"), + Schema.Literal("xhigh"), + Schema.Literal("high"), + Schema.Literal("medium"), + Schema.Literal("low"), + Schema.Literal("minimal"), + Schema.Literal("none"), + Schema.Null +]).annotate({ "identifier": "ReasoningEffort" }) +export type Parameter = + | "temperature" + | "top_p" + | "top_k" + | "min_p" + | "top_a" + | "frequency_penalty" + | "presence_penalty" + | "repetition_penalty" + | "max_tokens" + | "max_completion_tokens" + | "logit_bias" + | "logprobs" + | "top_logprobs" + | "prediction" + | "seed" + | "response_format" + | "structured_outputs" + | "stop" + | "tools" + | "tool_choice" + | "parallel_tool_calls" + | "include_reasoning" + | "reasoning" + | "reasoning_effort" + | "web_search_options" + | "verbosity" +export const Parameter = Schema.Literals([ + "temperature", + "top_p", + "top_k", + "min_p", + "top_a", + "frequency_penalty", + "presence_penalty", + "repetition_penalty", + "max_tokens", + "max_completion_tokens", + "logit_bias", + "logprobs", + "top_logprobs", + "prediction", + "seed", + "response_format", + "structured_outputs", + "stop", + "tools", + "tool_choice", + "parallel_tool_calls", + "include_reasoning", + "reasoning", + "reasoning_effort", + "web_search_options", + "verbosity" +]).annotate({ "identifier": "Parameter" }) +export type TopProviderInfo = { + readonly "context_length"?: number | null + readonly "is_moderated": boolean + readonly "max_completion_tokens"?: number | null } -export const OutputFunctionCallItem = Schema.Struct({ - "arguments": Schema.String, - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), - "name": Schema.String, - "namespace": Schema.optionalKey( - Schema.String.annotate({ - "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" - }) - ), - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "type": Schema.Literal("function_call") -}).annotate({ "identifier": "OutputFunctionCallItem" }) -export type OutputItemCustomToolCall = { - readonly "call_id": string - readonly "id"?: string - readonly "input": string - readonly "name": string - readonly "namespace"?: string - readonly "type": "custom_tool_call" -} -export const OutputItemCustomToolCall = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), - "input": Schema.String, - "name": Schema.String, - "namespace": Schema.optionalKey( - Schema.String.annotate({ - "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" - }) - ), - "type": Schema.Literal("custom_tool_call") -}).annotate({ "identifier": "OutputItemCustomToolCall" }) -export type OutputItemFunctionCall = { - readonly "arguments": string - readonly "call_id": string - readonly "id"?: string - readonly "name": string - readonly "namespace"?: string - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "type": "function_call" -} -export const OutputItemFunctionCall = Schema.Struct({ - "arguments": Schema.String, - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), - "name": Schema.String, - "namespace": Schema.optionalKey( - Schema.String.annotate({ - "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" - }) - ), - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "type": Schema.Literal("function_call") -}).annotate({ "identifier": "OutputItemFunctionCall" }) -export type OutputModality = "text" | "image" | "embeddings" | "audio" | "video" | "rerank" | "speech" | "transcription" -export const OutputModality = Schema.Literals([ - "text", - "image", - "embeddings", - "audio", - "video", - "rerank", - "speech", - "transcription" -]).annotate({ "identifier": "OutputModality" }) -export type OutputModalityEnum = "text" | "image" -export const OutputModalityEnum = Schema.Literals(["text", "image"]).annotate({ "identifier": "OutputModalityEnum" }) -export type Parameter = - | "temperature" - | "top_p" - | "top_k" - | "min_p" - | "top_a" - | "frequency_penalty" - | "presence_penalty" - | "repetition_penalty" - | "max_tokens" - | "max_completion_tokens" - | "logit_bias" - | "logprobs" - | "top_logprobs" - | "prediction" - | "seed" - | "response_format" - | "structured_outputs" - | "stop" - | "tools" - | "tool_choice" - | "parallel_tool_calls" - | "include_reasoning" - | "reasoning" - | "reasoning_effort" - | "web_search_options" - | "verbosity" -export const Parameter = Schema.Literals([ - "temperature", - "top_p", - "top_k", - "min_p", - "top_a", - "frequency_penalty", - "presence_penalty", - "repetition_penalty", - "max_tokens", - "max_completion_tokens", - "logit_bias", - "logprobs", - "top_logprobs", - "prediction", - "seed", - "response_format", - "structured_outputs", - "stop", - "tools", - "tool_choice", - "parallel_tool_calls", - "include_reasoning", - "reasoning", - "reasoning_effort", - "web_search_options", - "verbosity" -]).annotate({ "identifier": "Parameter" }) -export type ParetoRouterPlugin = { - readonly "enabled"?: boolean - readonly "id": "pareto-router" - readonly "max_price"?: number - readonly "min_coding_score"?: number - readonly "price_source"?: "prompt" | "weighted_avg" -} -export const ParetoRouterPlugin = Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the pareto-router plugin for this request. Defaults to true." +export const TopProviderInfo = Schema.Struct({ + "context_length": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "description": "Context length from the top provider" }) ), - "id": Schema.Literal("pareto-router"), - "max_price": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Maximum input price in USD per million tokens. When set, quality-tier selection (min_coding_score) is bypassed: the router computes the Pareto frontier over the top coding models and routes to the best-scoring frontier model priced at or below this cap, falling back through cheaper frontier models, then non-frontier models. Enforced against the price source given by price_source. Returns 404 when no candidate satisfies the cap.", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( - Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) - ) - ), - "min_coding_score": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Minimum coding quality score between 0 and 1. Maps to internal quality tiers: >= 0.66 → high (top coding models), >= 0.33 → medium (strong modern flagships), < 0.33 → low (capable coders above the median). Omit to default to the highest tier (equivalent to >= 0.66). Not used when max_price is set (price-based selection takes over).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })).check( - Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) - ).check(Schema.isLessThanOrEqualTo(1).annotate({ "expected": "a value less than or equal to 1" })) - ), - "price_source": Schema.optionalKey( - Schema.Literals(["prompt", "weighted_avg"]).annotate({ - "description": - "Price source for the Pareto frontier cost axis and for enforcing max_price. \"prompt\" uses catalog list price (endpoint.pricing.prompt). \"weighted_avg\" uses traffic-weighted effective input price from ClickHouse, falling back to prompt price for models without traffic data. Defaults to \"prompt\"." + "is_moderated": Schema.Boolean.annotate({ "description": "Whether the top provider moderates content" }), + "max_completion_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "description": "Maximum completion tokens from the top provider" }) ) -}).annotate({ "identifier": "ParetoRouterPlugin" }) -export type PayloadTooLargeResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null -} -export const PayloadTooLargeResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ - "description": "Error data for PayloadTooLargeResponse", - "identifier": "PayloadTooLargeResponseErrorData" -}) -export type PaymentRequiredResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null -} -export const PaymentRequiredResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ - "description": "Error data for PaymentRequiredResponse", - "identifier": "PaymentRequiredResponseErrorData" -}) -export type PDFParserEngine = "mistral-ocr" | "native" | "cloudflare-ai" | "pdf-text" -export const PDFParserEngine = Schema.Union([ - Schema.Literals(["mistral-ocr", "native", "cloudflare-ai"]), - Schema.Literal("pdf-text") -]).annotate({ - "description": - "The engine to use for parsing PDF files. \"pdf-text\" is deprecated and automatically redirected to \"cloudflare-ai\".", - "identifier": "PDFParserEngine" -}) -export type PercentileLatencyCutoffs = { - readonly "p50"?: number | null - readonly "p75"?: number | null - readonly "p90"?: number | null - readonly "p99"?: number | null -} -export const PercentileLatencyCutoffs = Schema.Struct({ - "p50": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Maximum p50 latency (seconds)", "format": "double" }) - ), - "p75": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Maximum p75 latency (seconds)", "format": "double" }) - ), - "p90": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Maximum p90 latency (seconds)", "format": "double" }) - ), - "p99": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Maximum p99 latency (seconds)", "format": "double" }) - ) -}).annotate({ - "description": "Percentile-based latency cutoffs. All specified cutoffs must be met for an endpoint to be preferred.", - "identifier": "PercentileLatencyCutoffs" -}) +}).annotate({ "description": "Information about the top provider for this model", "identifier": "TopProviderInfo" }) export type PercentileStats = { readonly "p50": number readonly "p75": number @@ -4050,674 +2835,128 @@ export const PercentileStats = Schema.Union([ "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.", "identifier": "PercentileStats" }) -export type PercentileThroughputCutoffs = { - readonly "p50"?: number | null - readonly "p75"?: number | null - readonly "p90"?: number | null - readonly "p99"?: number | null -} -export const PercentileThroughputCutoffs = Schema.Struct({ - "p50": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Minimum p50 throughput (tokens/sec)", "format": "double" }) - ), - "p75": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Minimum p75 throughput (tokens/sec)", "format": "double" }) - ), - "p90": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Minimum p90 throughput (tokens/sec)", "format": "double" }) - ), - "p99": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Minimum p99 throughput (tokens/sec)", "format": "double" }) - ) -}).annotate({ - "description": - "Percentile-based throughput cutoffs. All specified cutoffs must be met for an endpoint to be preferred.", - "identifier": "PercentileThroughputCutoffs" -}) -export type PerRequestLimits = { - readonly "completion_tokens": number - readonly "prompt_tokens": number - readonly [x: string]: Schema.Json -} | null -export const PerRequestLimits = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "completion_tokens": Schema.Number.annotate({ "description": "Maximum completion tokens per request" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "prompt_tokens": Schema.Number.annotate({ "description": "Maximum prompt tokens per request" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ "description": "Per-request token limits", "identifier": "PerRequestLimits" }) -export type PipelineStageType = "guardrail" | "plugin" | "server_tools" | "response_healing" | "context_compression" -export const PipelineStageType = Schema.Literals([ - "guardrail", - "plugin", - "server_tools", - "response_healing", - "context_compression" -]).annotate({ +export type EndpointStatus = 0 | -1 | -2 | -3 | -5 | -10 +export const EndpointStatus = Schema.Literals([0, -1, -2, -3, -5, -10]).annotate({ "identifier": "EndpointStatus" }) +export type FileProvider = "openai" | "anthropic" +export const FileProvider = Schema.Literals(["openai", "anthropic"]).annotate({ "description": - "Categorical kind of a pipeline stage. Multiple plugins can share a type (e.g. all guardrail-level plugins emit `guardrail`); the `name` field disambiguates which plugin emitted it.", - "identifier": "PipelineStageType" -}) -export type PredictionContentText = { readonly "text": string; readonly "type": "text" } -export const PredictionContentText = Schema.Struct({ "text": Schema.String, "type": Schema.Literal("text") }).annotate({ - "description": "Text content part for a predicted output.", - "identifier": "PredictionContentText" + "Store or read this file on the named provider using your own API key for it. Omit to use OpenRouter storage.", + "identifier": "FileProvider" }) -export type PresetDesignatedVersion = { - readonly "config": {} +export type OpenRouterFile = { + readonly "_shape": "openrouter" readonly "created_at": string - readonly "creator_id": string + readonly "downloadable": boolean + readonly "filename": string readonly "id": string - readonly "preset_id": string - readonly "system_prompt": string | null - readonly "updated_at": string - readonly "version": number - readonly [x: string]: Schema.Json -} | null -export const PresetDesignatedVersion = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "config": Schema.Struct({}), - "created_at": Schema.String, - "creator_id": Schema.String, - "id": Schema.String, - "preset_id": Schema.String, - "system_prompt": Schema.Union([Schema.String, Schema.Null]), - "updated_at": Schema.String, - "version": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ - "description": "A specific version of a preset, containing config and optional system prompt.", - "identifier": "PresetDesignatedVersion" -}) -export type PresetStatus = "active" | "disabled" | "archived" -export const PresetStatus = Schema.Literals(["active", "disabled", "archived"]).annotate({ - "description": "The status of a preset.", - "identifier": "PresetStatus" -}) -export type Objects_18 = { - readonly "city"?: string | null - readonly "country"?: string | null - readonly "region"?: string | null - readonly "timezone"?: string | null - readonly "type": "approximate" - readonly [x: string]: Schema.Json -} -export const Objects_18 = Schema.StructWithRest( - Schema.Struct({ - "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("approximate") - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type PricingOverride = { - readonly "audio"?: string - readonly "completion"?: string - readonly "input_audio_cache"?: string - readonly "input_cache_read"?: string - readonly "input_cache_write"?: string - readonly "input_cache_write_1h"?: string - readonly "min_prompt_tokens"?: number - readonly "prompt"?: string - readonly "utc_end"?: number - readonly "utc_start"?: number + readonly "mime_type": string + readonly "size_bytes": number + readonly "type": "file" } -export const PricingOverride = Schema.Struct({ - "audio": Schema.optionalKey( - Schema.String.annotate({ "description": "Overridden price in USD per audio input token" }) - ), - "completion": Schema.optionalKey( - Schema.String.annotate({ "description": "Overridden price in USD per token for completion (output) generation" }) - ), - "input_audio_cache": Schema.optionalKey( - Schema.String.annotate({ "description": "Overridden price in USD per cached audio input token" }) - ), - "input_cache_read": Schema.optionalKey( - Schema.String.annotate({ "description": "Overridden price in USD per cached input token (read)" }) - ), - "input_cache_write": Schema.optionalKey( - Schema.String.annotate({ "description": "Overridden price in USD per cache-write token" }) - ), - "input_cache_write_1h": Schema.optionalKey( - Schema.String.annotate({ "description": "Overridden price in USD per 1-hour cache-write token" }) - ), - "min_prompt_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Condition: the entry applies when the total prompt tokens of a request are strictly greater than this threshold", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "prompt": Schema.optionalKey( - Schema.String.annotate({ "description": "Overridden price in USD per token for prompt (input) processing" }) - ), - "utc_end": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Condition: exclusive end of a daily UTC time window as an HHMM clock number (e.g. 400 = 04:00)", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "utc_start": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Condition: inclusive start of a daily UTC time window as an HHMM clock number (e.g. 100 = 01:00, 1030 = 10:30). The entry applies while the current UTC time is inside the half-open window [utc_start, utc_end), which may wrap past midnight (utc_start > utc_end).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ) +export const OpenRouterFile = Schema.Struct({ + "_shape": Schema.Literal("openrouter"), + "created_at": Schema.String, + "downloadable": Schema.Boolean, + "filename": Schema.String, + "id": Schema.String, + "mime_type": Schema.String, + "size_bytes": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("file") }).annotate({ - "description": - "A conditional override of the base pricing. An entry applies only when all of its condition fields (e.g. min_prompt_tokens, or the utc_start/utc_end time window) match the request; among applicable entries, later entries win per price key; price keys absent from an entry inherit the base price.", - "identifier": "PricingOverride" + "description": "A stored file in the OpenRouter superset shape: Anthropic-shaped, plus OpenRouter-only fields.", + "identifier": "OpenRouterFile" }) -export type Objects_19 = { readonly "mode": "explicit"; readonly [x: string]: Schema.Json } -export const Objects_19 = Schema.StructWithRest(Schema.Struct({ "mode": Schema.Literal("explicit") }), [ - Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) -]) -export type Objects_20 = { - readonly "mode": "explicit" - readonly "ttl"?: string | null - readonly [x: string]: Schema.Json +export type OpenAIFile = { + readonly "_shape": "openai" + readonly "bytes": number + readonly "created_at": number + readonly "filename": string + readonly "id": string + readonly "object": "file" + readonly "purpose": + | "assistants" + | "batch" + | "fine-tune" + | "vision" + | "user_data" + | "evals" + | "assistants_output" + | "batch_output" + | "fine-tune-results" + readonly "status": "processed" +} +export const OpenAIFile = Schema.Struct({ + "_shape": Schema.Literal("openai"), + "bytes": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "created_at": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "filename": Schema.String, + "id": Schema.String, + "object": Schema.Literal("file"), + "purpose": Schema.Literals([ + "assistants", + "batch", + "fine-tune", + "vision", + "user_data", + "evals", + "assistants_output", + "batch_output", + "fine-tune-results" + ]), + "status": Schema.Literal("processed") +}).annotate({ "description": "A stored file in OpenAI's Files API shape.", "identifier": "OpenAIFile" }) +export type AnthropicFile = { + readonly "_shape": "anthropic" + readonly "created_at": string + readonly "downloadable": boolean + readonly "filename": string + readonly "id": string + readonly "mime_type": string + readonly "size_bytes": number + readonly "type": "file" } -export const Objects_20 = Schema.StructWithRest( - Schema.Struct({ - "mode": Schema.Literal("explicit"), - "ttl": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type PromptInjectionScanScope = "user_only" | "all_messages" -export const PromptInjectionScanScope = Schema.Literals(["user_only", "all_messages"]).annotate({ - "description": - "Which message roles to scan for prompt injection. Only applies to the regex-prompt-injection builtin. Defaults to all_messages.", - "identifier": "PromptInjectionScanScope" -}) -export type ProviderName = - | "AkashML" - | "AI21" - | "AionLabs" - | "Alibaba" - | "Ambient" - | "Baidu" - | "Amazon Bedrock" - | "Amazon Nova" - | "Anthropic" - | "Arcee AI" - | "AtlasCloud" - | "Avian" - | "Azure" - | "BaseTen" - | "BytePlus" - | "Black Forest Labs" - | "Cerebras" - | "Chutes" - | "Cirrascale" - | "Clarifai" - | "Cloudflare" - | "Cohere" - | "CoreWeave" - | "Crucible" - | "Crusoe" - | "Darkbloom" - | "Decart" - | "Deepgram" - | "DeepInfra" - | "DeepSeek" - | "DekaLLM" - | "DigitalOcean" - | "Featherless" - | "Fireworks" - | "Fish Audio" - | "Friendli" - | "GMICloud" - | "Google" - | "Google AI Studio" - | "Groq" - | "HeyGen" - | "Inception" - | "Inceptron" - | "InferenceNet" - | "Ionstream" - | "Infermatic" - | "Io Net" - | "Inferact vLLM" - | "Inflection" - | "Liquid" - | "Mara" - | "Mancer 2" - | "Meta" - | "Minimax" - | "ModelRun" - | "Mistral" - | "Modular" - | "Moonshot AI" - | "Morph" - | "NCompass" - | "Nebius" - | "Nex AGI" - | "NextBit" - | "Novita" - | "Nvidia" - | "OpenAI" - | "OpenInference" - | "Parasail" - | "Poolside" - | "Perceptron" - | "Perplexity" - | "Phala" - | "Recraft" - | "Reka" - | "Relace" - | "Sail Research" - | "Sakana AI" - | "SambaNova" - | "Seed" - | "SiliconFlow" - | "Sourceful" - | "StepFun" - | "Stealth" - | "StreamLake" - | "Switchpoint" - | "Tencent" - | "Tenstorrent" - | "Together" - | "Upstage" - | "Venice" - | "Wafer" - | "WandB" - | "Quiver" - | "Krea" - | "Runway" - | "Xiaomi" - | "xAI" - | "Z.AI" - | "FakeProvider" -export const ProviderName = Schema.Literals([ - "AkashML", - "AI21", - "AionLabs", - "Alibaba", - "Ambient", - "Baidu", - "Amazon Bedrock", - "Amazon Nova", - "Anthropic", - "Arcee AI", - "AtlasCloud", - "Avian", - "Azure", - "BaseTen", - "BytePlus", - "Black Forest Labs", - "Cerebras", - "Chutes", - "Cirrascale", - "Clarifai", - "Cloudflare", - "Cohere", - "CoreWeave", - "Crucible", - "Crusoe", - "Darkbloom", - "Decart", - "Deepgram", - "DeepInfra", - "DeepSeek", - "DekaLLM", - "DigitalOcean", - "Featherless", - "Fireworks", - "Fish Audio", - "Friendli", - "GMICloud", - "Google", - "Google AI Studio", - "Groq", - "HeyGen", - "Inception", - "Inceptron", - "InferenceNet", - "Ionstream", - "Infermatic", - "Io Net", - "Inferact vLLM", - "Inflection", - "Liquid", - "Mara", - "Mancer 2", - "Meta", - "Minimax", - "ModelRun", - "Mistral", - "Modular", - "Moonshot AI", - "Morph", - "NCompass", - "Nebius", - "Nex AGI", - "NextBit", - "Novita", - "Nvidia", - "OpenAI", - "OpenInference", - "Parasail", - "Poolside", - "Perceptron", - "Perplexity", - "Phala", - "Recraft", - "Reka", - "Relace", - "Sail Research", - "Sakana AI", - "SambaNova", - "Seed", - "SiliconFlow", - "Sourceful", - "StepFun", - "Stealth", - "StreamLake", - "Switchpoint", - "Tencent", - "Tenstorrent", - "Together", - "Upstage", - "Venice", - "Wafer", - "WandB", - "Quiver", - "Krea", - "Runway", - "Xiaomi", - "xAI", - "Z.AI", - "FakeProvider" -]).annotate({ "identifier": "ProviderName" }) -export type Objects_21 = {} -export const Objects_21 = Schema.Struct({}) -export type Objects_22 = {} -export const Objects_22 = Schema.Struct({}) -export type Objects_23 = {} -export const Objects_23 = Schema.Struct({}) -export type Objects_24 = {} -export const Objects_24 = Schema.Struct({}) -export type Objects_25 = {} -export const Objects_25 = Schema.Struct({}) -export type Objects_26 = {} -export const Objects_26 = Schema.Struct({}) -export type Objects_27 = {} -export const Objects_27 = Schema.Struct({}) -export type Objects_28 = {} -export const Objects_28 = Schema.Struct({}) -export type Objects_29 = {} -export const Objects_29 = Schema.Struct({}) -export type Objects_30 = {} -export const Objects_30 = Schema.Struct({}) -export type Objects_31 = {} -export const Objects_31 = Schema.Struct({}) -export type Objects_32 = {} -export const Objects_32 = Schema.Struct({}) -export type Objects_33 = {} -export const Objects_33 = Schema.Struct({}) -export type Objects_34 = {} -export const Objects_34 = Schema.Struct({}) -export type Objects_35 = {} -export const Objects_35 = Schema.Struct({}) -export type Objects_36 = {} -export const Objects_36 = Schema.Struct({}) -export type Objects_37 = {} -export const Objects_37 = Schema.Struct({}) -export type Objects_38 = {} -export const Objects_38 = Schema.Struct({}) -export type Objects_39 = {} -export const Objects_39 = Schema.Struct({}) -export type Objects_40 = {} -export const Objects_40 = Schema.Struct({}) -export type Objects_41 = {} -export const Objects_41 = Schema.Struct({}) -export type Objects_42 = {} -export const Objects_42 = Schema.Struct({}) -export type Objects_43 = {} -export const Objects_43 = Schema.Struct({}) -export type Objects_44 = {} -export const Objects_44 = Schema.Struct({}) -export type Objects_45 = {} -export const Objects_45 = Schema.Struct({}) -export type Objects_46 = {} -export const Objects_46 = Schema.Struct({}) -export type Objects_47 = {} -export const Objects_47 = Schema.Struct({}) -export type Objects_48 = {} -export const Objects_48 = Schema.Struct({}) -export type Objects_49 = {} -export const Objects_49 = Schema.Struct({}) -export type Objects_50 = {} -export const Objects_50 = Schema.Struct({}) -export type Objects_51 = {} -export const Objects_51 = Schema.Struct({}) -export type Objects_52 = {} -export const Objects_52 = Schema.Struct({}) -export type Objects_53 = {} -export const Objects_53 = Schema.Struct({}) -export type Objects_54 = {} -export const Objects_54 = Schema.Struct({}) -export type Objects_55 = {} -export const Objects_55 = Schema.Struct({}) -export type Objects_56 = {} -export const Objects_56 = Schema.Struct({}) -export type Objects_57 = {} -export const Objects_57 = Schema.Struct({}) -export type Objects_58 = {} -export const Objects_58 = Schema.Struct({}) -export type Objects_59 = {} -export const Objects_59 = Schema.Struct({}) -export type Objects_60 = {} -export const Objects_60 = Schema.Struct({}) -export type Objects_61 = {} -export const Objects_61 = Schema.Struct({}) -export type Objects_62 = {} -export const Objects_62 = Schema.Struct({}) -export type Objects_63 = {} -export const Objects_63 = Schema.Struct({}) -export type Objects_64 = {} -export const Objects_64 = Schema.Struct({}) -export type Objects_65 = {} -export const Objects_65 = Schema.Struct({}) -export type Objects_66 = {} -export const Objects_66 = Schema.Struct({}) -export type Objects_67 = {} -export const Objects_67 = Schema.Struct({}) -export type Objects_68 = {} -export const Objects_68 = Schema.Struct({}) -export type Objects_69 = {} -export const Objects_69 = Schema.Struct({}) -export type Objects_70 = {} -export const Objects_70 = Schema.Struct({}) -export type Objects_71 = {} -export const Objects_71 = Schema.Struct({}) -export type Objects_72 = {} -export const Objects_72 = Schema.Struct({}) -export type Objects_73 = {} -export const Objects_73 = Schema.Struct({}) -export type Objects_74 = {} -export const Objects_74 = Schema.Struct({}) -export type Objects_75 = {} -export const Objects_75 = Schema.Struct({}) -export type Objects_76 = {} -export const Objects_76 = Schema.Struct({}) -export type Objects_77 = {} -export const Objects_77 = Schema.Struct({}) -export type Objects_78 = {} -export const Objects_78 = Schema.Struct({}) -export type Objects_79 = {} -export const Objects_79 = Schema.Struct({}) -export type Objects_80 = {} -export const Objects_80 = Schema.Struct({}) -export type Objects_81 = {} -export const Objects_81 = Schema.Struct({}) -export type Objects_82 = {} -export const Objects_82 = Schema.Struct({}) -export type Objects_83 = {} -export const Objects_83 = Schema.Struct({}) -export type Objects_84 = {} -export const Objects_84 = Schema.Struct({}) -export type Objects_85 = {} -export const Objects_85 = Schema.Struct({}) -export type Objects_86 = {} -export const Objects_86 = Schema.Struct({}) -export type Objects_87 = {} -export const Objects_87 = Schema.Struct({}) -export type Objects_88 = {} -export const Objects_88 = Schema.Struct({}) -export type Objects_89 = {} -export const Objects_89 = Schema.Struct({}) -export type Objects_90 = {} -export const Objects_90 = Schema.Struct({}) -export type Objects_91 = {} -export const Objects_91 = Schema.Struct({}) -export type Objects_92 = {} -export const Objects_92 = Schema.Struct({}) -export type Objects_93 = {} -export const Objects_93 = Schema.Struct({}) -export type Objects_94 = {} -export const Objects_94 = Schema.Struct({}) -export type Objects_95 = {} -export const Objects_95 = Schema.Struct({}) -export type Objects_96 = {} -export const Objects_96 = Schema.Struct({}) -export type Objects_97 = {} -export const Objects_97 = Schema.Struct({}) -export type Objects_98 = {} -export const Objects_98 = Schema.Struct({}) -export type Objects_99 = {} -export const Objects_99 = Schema.Struct({}) -export type Objects_100 = {} -export const Objects_100 = Schema.Struct({}) -export type Objects_101 = {} -export const Objects_101 = Schema.Struct({}) -export type Objects_102 = {} -export const Objects_102 = Schema.Struct({}) -export type Objects_103 = {} -export const Objects_103 = Schema.Struct({}) -export type Objects_104 = {} -export const Objects_104 = Schema.Struct({}) -export type Objects_105 = {} -export const Objects_105 = Schema.Struct({}) -export type Objects_106 = {} -export const Objects_106 = Schema.Struct({}) -export type Objects_107 = {} -export const Objects_107 = Schema.Struct({}) -export type Objects_108 = {} -export const Objects_108 = Schema.Struct({}) -export type Objects_109 = {} -export const Objects_109 = Schema.Struct({}) -export type Objects_110 = {} -export const Objects_110 = Schema.Struct({}) -export type Objects_111 = {} -export const Objects_111 = Schema.Struct({}) -export type Objects_112 = {} -export const Objects_112 = Schema.Struct({}) -export type Objects_113 = {} -export const Objects_113 = Schema.Struct({}) -export type Objects_114 = {} -export const Objects_114 = Schema.Struct({}) -export type Objects_115 = {} -export const Objects_115 = Schema.Struct({}) -export type Objects_116 = {} -export const Objects_116 = Schema.Struct({}) -export type Objects_117 = {} -export const Objects_117 = Schema.Struct({}) -export type Objects_118 = {} -export const Objects_118 = Schema.Struct({}) -export type Objects_119 = {} -export const Objects_119 = Schema.Struct({}) -export type Objects_120 = {} -export const Objects_120 = Schema.Struct({}) -export type Objects_121 = {} -export const Objects_121 = Schema.Struct({}) -export type Objects_122 = {} -export const Objects_122 = Schema.Struct({}) -export type Objects_123 = {} -export const Objects_123 = Schema.Struct({}) -export type Objects_124 = {} -export const Objects_124 = Schema.Struct({}) -export type Objects_125 = {} -export const Objects_125 = Schema.Struct({}) -export type Objects_126 = {} -export const Objects_126 = Schema.Struct({}) -export type Objects_127 = {} -export const Objects_127 = Schema.Struct({}) -export type Objects_128 = {} -export const Objects_128 = Schema.Struct({}) -export type Objects_129 = {} -export const Objects_129 = Schema.Struct({}) -export type Objects_130 = {} -export const Objects_130 = Schema.Struct({}) -export type Objects_131 = {} -export const Objects_131 = Schema.Struct({}) -export type Objects_132 = {} -export const Objects_132 = Schema.Struct({}) -export type Objects_133 = {} -export const Objects_133 = Schema.Struct({}) -export type Objects_134 = {} -export const Objects_134 = Schema.Struct({}) -export type Objects_135 = {} -export const Objects_135 = Schema.Struct({}) -export type Objects_136 = {} -export const Objects_136 = Schema.Struct({}) -export type Objects_137 = {} -export const Objects_137 = Schema.Struct({}) -export type Objects_138 = {} -export const Objects_138 = Schema.Struct({}) -export type Objects_139 = {} -export const Objects_139 = Schema.Struct({}) -export type Objects_140 = {} -export const Objects_140 = Schema.Struct({}) -export type Objects_141 = {} -export const Objects_141 = Schema.Struct({}) -export type Objects_142 = {} -export const Objects_142 = Schema.Struct({}) -export type Objects_143 = {} -export const Objects_143 = Schema.Struct({}) -export type Objects_144 = {} -export const Objects_144 = Schema.Struct({}) -export type Objects_145 = {} -export const Objects_145 = Schema.Struct({}) -export type Objects_146 = {} -export const Objects_146 = Schema.Struct({}) -export type Objects_147 = {} -export const Objects_147 = Schema.Struct({}) -export type ProviderOverloadedResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +export const AnthropicFile = Schema.Struct({ + "_shape": Schema.Literal("anthropic"), + "created_at": Schema.String, + "downloadable": Schema.Boolean, + "filename": Schema.String, + "id": Schema.String, + "mime_type": Schema.String, + "size_bytes": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("file") +}).annotate({ "description": "A stored file in Anthropic's Files API shape.", "identifier": "AnthropicFile" }) +export type OpenRouterFileDeleted = { + readonly "_shape": "openrouter" + readonly "id": string + readonly "type": "file_deleted" } -export const ProviderOverloadedResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ - "description": "Error data for ProviderOverloadedResponse", - "identifier": "ProviderOverloadedResponseErrorData" -}) +export const OpenRouterFileDeleted = Schema.Struct({ + "_shape": Schema.Literal("openrouter"), + "id": Schema.String, + "type": Schema.Literal("file_deleted") +}).annotate({ "description": "Deletion result in the OpenRouter shape.", "identifier": "OpenRouterFileDeleted" }) +export type OpenAIFileDeleted = { + readonly "_shape": "openai" + readonly "deleted": true + readonly "id": string + readonly "object": "file" +} +export const OpenAIFileDeleted = Schema.Struct({ + "_shape": Schema.Literal("openai"), + "deleted": Schema.Literal(true), + "id": Schema.String, + "object": Schema.Literal("file") +}).annotate({ "description": "Deletion result in OpenAI's shape.", "identifier": "OpenAIFileDeleted" }) +export type AnthropicFileDeleted = { + readonly "_shape": "anthropic" + readonly "id": string + readonly "type": "file_deleted" +} +export const AnthropicFileDeleted = Schema.Struct({ + "_shape": Schema.Literal("anthropic"), + "id": Schema.String, + "type": Schema.Literal("file_deleted") +}).annotate({ "description": "Deletion result in Anthropic's shape.", "identifier": "AnthropicFileDeleted" }) export type ProviderResponse = { readonly "endpoint_id"?: string readonly "id"?: string @@ -4772,6 +3011,7 @@ export type ProviderResponse = { | "Cerebras" | "Chutes" | "Cirrascale" + | "Claude Platform on AWS" | "Clarifai" | "Cloudflare" | "Cohere" @@ -4812,6 +3052,7 @@ export type ProviderResponse = { | "Modular" | "Moonshot AI" | "Morph" + | "VoyageAI by MongoDB" | "NCompass" | "Nebius" | "Nex AGI" @@ -4840,6 +3081,7 @@ export type ProviderResponse = { | "Switchpoint" | "Tencent" | "Tenstorrent" + | "Thinking Machines" | "Together" | "Upstage" | "Venice" @@ -4916,6 +3158,7 @@ export const ProviderResponse = Schema.Struct({ "Cerebras", "Chutes", "Cirrascale", + "Claude Platform on AWS", "Clarifai", "Cloudflare", "Cohere", @@ -4956,6 +3199,7 @@ export const ProviderResponse = Schema.Struct({ "Modular", "Moonshot AI", "Morph", + "VoyageAI by MongoDB", "NCompass", "Nebius", "Nex AGI", @@ -4984,6 +3228,7 @@ export const ProviderResponse = Schema.Struct({ "Switchpoint", "Tencent", "Tenstorrent", + "Thinking Machines", "Together", "Upstage", "Venice", @@ -5010,4657 +3255,3555 @@ export const ProviderResponse = Schema.Struct({ "description": "Details of a provider response for a generation attempt", "identifier": "ProviderResponse" }) -export type ProviderSort = "price" | "throughput" | "latency" | "exacto" -export const ProviderSort = Schema.Literals(["price", "throughput", "latency", "exacto"]).annotate({ - "description": "The provider sorting strategy (price, throughput, latency)", - "identifier": "ProviderSort" -}) -export type ProviderSortConfig = { - readonly "by"?: "price" | "throughput" | "latency" | "exacto" | null - readonly "partition"?: "model" | "none" | null +export type GenerationContentData = { + readonly "input": { readonly "prompt": string } | { readonly "messages": ReadonlyArray } + readonly "output": { readonly "completion": string | null; readonly "reasoning": string | null } } -export const ProviderSortConfig = Schema.Struct({ - "by": Schema.optionalKey( - Schema.Union([ - Schema.Literal("price"), - Schema.Literal("throughput"), - Schema.Literal("latency"), - Schema.Literal("exacto"), - Schema.Null - ]).annotate({ "description": "The provider sorting strategy (price, throughput, latency)" }) - ), - "partition": Schema.optionalKey( - Schema.Union([Schema.Literal("model"), Schema.Literal("none"), Schema.Null]).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." +export const GenerationContentData = Schema.Struct({ + "input": Schema.Union([ + Schema.Struct({ "prompt": Schema.String }), + Schema.Struct({ "messages": Schema.Array(Schema.Json.annotate({ "expected": "JSON value" })) }) + ]).annotate({ "description": "The input to the generation — either a prompt string or an array of messages" }), + "output": Schema.Struct({ + "completion": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "The completion output" }), + "reasoning": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Reasoning/thinking output, if any" }) + }).annotate({ "description": "The output from the generation" }) +}).annotate({ "description": "Stored prompt and completion content", "identifier": "GenerationContentData" }) +export type SubmitGenerationFeedbackRequest = { + readonly "category": + | "latency" + | "incoherence" + | "incorrect_response" + | "formatting" + | "billing" + | "api_error" + | "other" + readonly "comment"?: string + readonly "generation_id": string +} +export const SubmitGenerationFeedbackRequest = Schema.Struct({ + "category": Schema.Literals([ + "latency", + "incoherence", + "incorrect_response", + "formatting", + "billing", + "api_error", + "other" + ]).annotate({ "description": "The category of feedback being reported" }), + "comment": Schema.optionalKey( + Schema.String.annotate({ "description": "An optional free-text comment describing the feedback" }).check( + Schema.isMaxLength(1000).annotate({ "expected": "a value with a length of at most 1000" }) + ) + ), + "generation_id": Schema.String.annotate({ "description": "The generation to submit feedback on" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ) }).annotate({ - "description": "The provider sorting strategy (price, throughput, latency)", - "identifier": "ProviderSortConfig" + "description": "Structured feedback about a specific generation", + "identifier": "SubmitGenerationFeedbackRequest" }) -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"]) - .annotate({ "identifier": "Quantization" }) -export type RangeCapability = { readonly "max": number; readonly "min": number; readonly "type": "range" } -export const RangeCapability = Schema.Struct({ - "max": Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "min": Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("range") +export type SubmitGenerationFeedbackResponse = { readonly "data": { readonly "success": true } } +export const SubmitGenerationFeedbackResponse = Schema.Struct({ + "data": Schema.Struct({ + "success": Schema.Literal(true).annotate({ "description": "Whether the feedback was recorded" }) + }) }).annotate({ - "description": "A parameter that accepts any value within an inclusive numeric range.", - "identifier": "RangeCapability" + "description": "Confirmation that the feedback was recorded", + "identifier": "SubmitGenerationFeedbackResponse" }) -export type RankingsDailyItem = { - readonly "date": string - readonly "model_permaslug": string - readonly "total_tokens": string +export type ContentFilterBuiltinAction = "redact" | "block" | "flag" +export const ContentFilterBuiltinAction = Schema.Literals(["redact", "block", "flag"]).annotate({ + "description": "Action taken when the builtin filter triggers", + "identifier": "ContentFilterBuiltinAction" +}) +export type PromptInjectionScanScope = "user_only" | "all_messages" +export const PromptInjectionScanScope = Schema.Literals(["user_only", "all_messages"]).annotate({ + "description": + "Which message roles to scan for prompt injection. Only applies to the regex-prompt-injection builtin. Defaults to all_messages.", + "identifier": "PromptInjectionScanScope" +}) +export type ContentFilterBuiltinSlug = + | "email" + | "phone" + | "ssn" + | "credit-card" + | "ip-address" + | "person-name" + | "address" + | "regex-prompt-injection" +export const ContentFilterBuiltinSlug = Schema.Literals([ + "email", + "phone", + "ssn", + "credit-card", + "ip-address", + "person-name", + "address", + "regex-prompt-injection" +]).annotate({ "description": "The builtin filter identifier", "identifier": "ContentFilterBuiltinSlug" }) +export type ContentFilterAction = "redact" | "block" | "flag" +export const ContentFilterAction = Schema.Literals(["redact", "block", "flag"]).annotate({ + "description": "Action taken when the pattern matches", + "identifier": "ContentFilterAction" +}) +export type GuardrailInterval = "daily" | "weekly" | "monthly" | null +export const GuardrailInterval = Schema.Union([ + Schema.Literal("daily"), + Schema.Literal("weekly"), + Schema.Literal("monthly"), + Schema.Null +]).annotate({ + "description": "Interval at which the limit resets (daily, weekly, monthly)", + "identifier": "GuardrailInterval" +}) +export type DeleteGuardrailResponse = { readonly "deleted": true } +export const DeleteGuardrailResponse = Schema.Struct({ + "deleted": Schema.Literal(true).annotate({ "description": "Confirmation that the guardrail was deleted" }) +}).annotate({ "identifier": "DeleteGuardrailResponse" }) +export type KeyAssignment = { + readonly "assigned_by": string | null + readonly "created_at": string + readonly "guardrail_id": string + readonly "id": string + readonly "key_hash": string + readonly "key_label": string + readonly "key_name": string } -export const RankingsDailyItem = Schema.Struct({ - "date": Schema.String.annotate({ "description": "UTC calendar date the row is aggregated over (YYYY-MM-DD)." }), - "model_permaslug": Schema.String.annotate({ - "description": - "Model variant permaslug (e.g. `openai/gpt-4o-2024-05-13`, `openai/gpt-4o-2024-05-13:free`). Non-default variants include a `:variant` suffix and are ranked as their own entry. The reserved value `other` denotes the aggregated row covering every model outside the daily top 50 for that date — always sorted last within its date." +export const KeyAssignment = Schema.Struct({ + "assigned_by": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "User ID of who made the assignment" }), - "total_tokens": Schema.String.annotate({ - "description": - "Sum of `prompt_tokens + completion_tokens` for the day, returned as a decimal string so 64-bit values are not truncated." - }) -}).annotate({ "identifier": "RankingsDailyItem" }) -export type RankingsDailyMeta = { - readonly "as_of": string - readonly "end_date": string - readonly "start_date": string - readonly "version": "v1" + "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the assignment was created" }), + "guardrail_id": Schema.String.annotate({ "description": "ID of the guardrail", "format": "uuid" }), + "id": Schema.String.annotate({ "description": "Unique identifier for the assignment", "format": "uuid" }), + "key_hash": Schema.String.annotate({ "description": "Hash of the assigned API key" }), + "key_label": Schema.String.annotate({ "description": "Label of the API key" }), + "key_name": Schema.String.annotate({ "description": "Name of the API key" }) +}).annotate({ "identifier": "KeyAssignment" }) +export type BulkAssignKeysRequest = { readonly "key_hashes": ReadonlyArray } +export const BulkAssignKeysRequest = Schema.Struct({ + "key_hashes": Schema.Array( + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ).annotate({ "description": "Array of API key hashes to assign to the guardrail" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ "identifier": "BulkAssignKeysRequest" }) +export type BulkAssignKeysResponse = { readonly "assigned_count": number } +export const BulkAssignKeysResponse = Schema.Struct({ + "assigned_count": Schema.Number.annotate({ "description": "Number of keys successfully assigned" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "BulkAssignKeysResponse" }) +export type BulkUnassignKeysRequest = { readonly "key_hashes": ReadonlyArray } +export const BulkUnassignKeysRequest = Schema.Struct({ + "key_hashes": Schema.Array( + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ).annotate({ "description": "Array of API key hashes to unassign from the guardrail" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ "identifier": "BulkUnassignKeysRequest" }) +export type BulkUnassignKeysResponse = { readonly "unassigned_count": number } +export const BulkUnassignKeysResponse = Schema.Struct({ + "unassigned_count": Schema.Number.annotate({ "description": "Number of keys successfully unassigned" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "BulkUnassignKeysResponse" }) +export type MemberAssignment = { + readonly "assigned_by": string | null + readonly "created_at": string + readonly "guardrail_id": string + readonly "id": string + readonly "organization_id": string + readonly "user_id": string } -export const RankingsDailyMeta = Schema.Struct({ - "as_of": Schema.String.annotate({ - "description": - "ISO-8601 timestamp of when the response was generated. Reflects data-freshness because the underlying materialized view continuously ingests upstream events." +export const MemberAssignment = Schema.Struct({ + "assigned_by": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "User ID of who made the assignment" }), - "end_date": Schema.String.annotate({ "description": "Resolved end of the date window (UTC, inclusive)." }), - "start_date": Schema.String.annotate({ "description": "Resolved start of the date window (UTC, inclusive)." }), - "version": Schema.Literal("v1").annotate({ - "description": "Dataset version. Field names and grain are stable for the life of `v1`." - }) -}).annotate({ "identifier": "RankingsDailyMeta" }) -export type ReasoningContext = "auto" | "all_turns" | "current_turn" | null -export const ReasoningContext = Schema.Union([ - Schema.Literal("auto"), - Schema.Literal("all_turns"), - Schema.Literal("current_turn"), + "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the assignment was created" }), + "guardrail_id": Schema.String.annotate({ "description": "ID of the guardrail", "format": "uuid" }), + "id": Schema.String.annotate({ "description": "Unique identifier for the assignment", "format": "uuid" }), + "organization_id": Schema.String.annotate({ "description": "Organization ID" }), + "user_id": Schema.String.annotate({ "description": "Clerk user ID of the assigned member" }) +}).annotate({ "identifier": "MemberAssignment" }) +export type BulkAssignMembersRequest = { readonly "member_user_ids": ReadonlyArray } +export const BulkAssignMembersRequest = Schema.Struct({ + "member_user_ids": Schema.Array( + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ).annotate({ "description": "Array of member user IDs to assign to the guardrail" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ "identifier": "BulkAssignMembersRequest" }) +export type BulkAssignMembersResponse = { readonly "assigned_count": number } +export const BulkAssignMembersResponse = Schema.Struct({ + "assigned_count": Schema.Number.annotate({ "description": "Number of members successfully assigned" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "BulkAssignMembersResponse" }) +export type BulkUnassignMembersRequest = { readonly "member_user_ids": ReadonlyArray } +export const BulkUnassignMembersRequest = Schema.Struct({ + "member_user_ids": Schema.Array( + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ).annotate({ "description": "Array of member user IDs to unassign from the guardrail" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ "identifier": "BulkUnassignMembersRequest" }) +export type BulkUnassignMembersResponse = { readonly "unassigned_count": number } +export const BulkUnassignMembersResponse = Schema.Struct({ + "unassigned_count": Schema.Number.annotate({ "description": "Number of members successfully unassigned" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "BulkUnassignMembersResponse" }) +export type ContentPartImage = { readonly "image_url": { readonly "url": string }; readonly "type": "image_url" } +export const ContentPartImage = Schema.Struct({ + "image_url": Schema.Struct({ "url": Schema.String }), + "type": Schema.Literal("image_url") +}).annotate({ "identifier": "ContentPartImage" }) +export type AnthropicCacheCreation = { + readonly "ephemeral_1h_input_tokens": number + readonly "ephemeral_5m_input_tokens": number + readonly [x: string]: Schema.Json +} | null +export const AnthropicCacheCreation = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "ephemeral_1h_input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "ephemeral_5m_input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), Schema.Null -]).annotate({ - "description": - "Controls which reasoning is available to the model. `auto` uses the model default (same as omitting); `all_turns` includes reasoning from earlier turns passed in input; `current_turn` limits to the current turn only. Only supported by OpenAI GPT-5.6 and newer.", - "identifier": "ReasoningContext" +]).annotate({ "identifier": "AnthropicCacheCreation" }) +export type AnthropicIterationCacheCreation = { + readonly "ephemeral_1h_input_tokens"?: number + readonly "ephemeral_5m_input_tokens"?: number + readonly [x: string]: Schema.Json +} | null +export const AnthropicIterationCacheCreation = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "ephemeral_1h_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "ephemeral_5m_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "identifier": "AnthropicIterationCacheCreation" }) +export type AnthropicSpeed = "fast" | "standard" | null +export const AnthropicSpeed = Schema.Union([Schema.Literal("fast"), Schema.Literal("standard"), Schema.Null]).annotate({ + "identifier": "AnthropicSpeed" }) -export type ReasoningDeltaEvent = { - readonly "content_index": number - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.reasoning_text.delta" +export type ImageGenPartialImageEvent = { + readonly "b64_json": string + readonly "partial_image_index": number + readonly "type": "image_generation.partial_image" } -export const ReasoningDeltaEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.reasoning_text.delta") +export const ImageGenPartialImageEvent = Schema.Struct({ + "b64_json": Schema.String.annotate({ "description": "Base64-encoded partial image data" }), + "partial_image_index": Schema.Number.annotate({ + "description": "0-based index indicating which partial image this is in the sequence" + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("image_generation.partial_image").annotate({ "description": "The event type" }) }).annotate({ - "description": "Event emitted when reasoning text delta is streamed", - "identifier": "ReasoningDeltaEvent" + "description": "Emitted when a partial image becomes available during streaming generation", + "identifier": "ImageGenPartialImageEvent" }) -export type ReasoningDoneEvent = { - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number +export type ImageGenTextChunkEvent = { + readonly "phase": "content" | "reasoning" | "draft" readonly "text": string - readonly "type": "response.reasoning_text.done" + readonly "type": "image_generation.text_chunk" } -export const ReasoningDoneEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "text": Schema.String, - "type": Schema.Literal("response.reasoning_text.done") +export const ImageGenTextChunkEvent = Schema.Struct({ + "phase": Schema.Literals(["content", "reasoning", "draft"]).annotate({ + "description": + "The generation phase this chunk belongs to. `content` is the renderable output; `reasoning` and `draft` are intermediate provider phases." + }), + "text": Schema.String.annotate({ + "description": "A text fragment of the image being generated (e.g. partial SVG markup)" + }), + "type": Schema.Literal("image_generation.text_chunk").annotate({ "description": "The event type" }) }).annotate({ - "description": "Event emitted when reasoning text streaming is complete", - "identifier": "ReasoningDoneEvent" + "description": + "Emitted when a text chunk becomes available during streaming generation of text-based formats (e.g. SVG)", + "identifier": "ImageGenTextChunkEvent" }) -export type ReasoningEffort = "max" | "xhigh" | "high" | "medium" | "low" | "minimal" | "none" | null -export const ReasoningEffort = Schema.Union([ - Schema.Literal("max"), - Schema.Literal("xhigh"), - Schema.Literal("high"), - Schema.Literal("medium"), - Schema.Literal("low"), - Schema.Literal("minimal"), - Schema.Literal("none"), - Schema.Null -]).annotate({ "identifier": "ReasoningEffort" }) -export type ReasoningFormat = - | "unknown" - | "openai-responses-v1" - | "azure-openai-responses-v1" - | "xai-responses-v1" - | "meta-responses-v1" - | "anthropic-claude-v1" - | "google-gemini-v1" - | null -export const ReasoningFormat = Schema.Union([ - Schema.Literal("unknown"), - Schema.Literal("openai-responses-v1"), - Schema.Literal("azure-openai-responses-v1"), - Schema.Literal("xai-responses-v1"), - Schema.Literal("meta-responses-v1"), - Schema.Literal("anthropic-claude-v1"), - Schema.Literal("google-gemini-v1"), - Schema.Null -]).annotate({ "identifier": "ReasoningFormat" }) -export type ReasoningMode = "standard" | "pro" | null -export const ReasoningMode = Schema.Union([Schema.Literal("standard"), Schema.Literal("pro"), Schema.Null]).annotate({ - "description": - "Selects the reasoning mode. `standard` is the default; `pro` engages deeper reasoning on models that support it, billed at standard token rates. Only supported by OpenAI GPT-5.6 and newer.", - "identifier": "ReasoningMode" -}) -export type ReasoningSummaryText = { readonly "text": string; readonly "type": "summary_text" } -export const ReasoningSummaryText = Schema.Struct({ "text": Schema.String, "type": Schema.Literal("summary_text") }) - .annotate({ "identifier": "ReasoningSummaryText" }) -export type ReasoningSummaryTextDeltaEvent = { - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "summary_index": number - readonly "type": "response.reasoning_summary_text.delta" +export type ImageGenStreamErrorEvent = { + readonly "error": { + readonly "code"?: string | null + readonly "message": string + readonly "param"?: string | null + readonly "type"?: string | null + } + readonly "type": "error" } -export const ReasoningSummaryTextDeltaEvent = Schema.Struct({ - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.reasoning_summary_text.delta") +export const ImageGenStreamErrorEvent = Schema.Struct({ + "error": Schema.Struct({ + "code": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Provider error code, when supplied" }) + ), + "message": Schema.String.annotate({ "description": "Provider error message" }), + "param": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Request parameter associated with the error, when supplied" + }) + ), + "type": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Provider error type, when supplied" }) + ) + }).annotate({ "description": "Provider error details" }), + "type": Schema.Literal("error").annotate({ "description": "The event type" }) }).annotate({ - "description": "Event emitted when reasoning summary text delta is streamed", - "identifier": "ReasoningSummaryTextDeltaEvent" + "description": "Emitted when streaming generation fails after the SSE response starts", + "identifier": "ImageGenStreamErrorEvent" }) -export type ReasoningSummaryTextDoneEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "summary_index": number - readonly "text": string - readonly "type": "response.reasoning_summary_text.done" -} -export const ReasoningSummaryTextDoneEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "text": Schema.String, - "type": Schema.Literal("response.reasoning_summary_text.done") -}).annotate({ - "description": "Event emitted when reasoning summary text streaming is complete", - "identifier": "ReasoningSummaryTextDoneEvent" +export type ImageInputModality = "text" | "image" | "file" | "audio" | "video" +export const ImageInputModality = Schema.Literals(["text", "image", "file", "audio", "video"]).annotate({ + "identifier": "ImageInputModality" }) -export type ReasoningSummaryVerbosity = "auto" | "concise" | "detailed" | null -export const ReasoningSummaryVerbosity = Schema.Union([ - Schema.Literal("auto"), - Schema.Literal("concise"), - Schema.Literal("detailed"), - Schema.Null -]).annotate({ "identifier": "ReasoningSummaryVerbosity" }) -export type ReasoningTextContent = { readonly "text": string; readonly "type": "reasoning_text" } -export const ReasoningTextContent = Schema.Struct({ "text": Schema.String, "type": Schema.Literal("reasoning_text") }) - .annotate({ "identifier": "ReasoningTextContent" }) -export type RefusalDeltaEvent = { - readonly "content_index": number - readonly "delta": string - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.refusal.delta" -} -export const RefusalDeltaEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "delta": Schema.String, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.refusal.delta") -}).annotate({ "description": "Event emitted when a refusal delta is streamed", "identifier": "RefusalDeltaEvent" }) -export type RefusalDoneEvent = { - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "refusal": string - readonly "sequence_number": number - readonly "type": "response.refusal.done" -} -export const RefusalDoneEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "refusal": Schema.String, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.refusal.done") -}).annotate({ "description": "Event emitted when refusal streaming is complete", "identifier": "RefusalDoneEvent" }) -export type Objects_149 = { readonly [x: string]: string } -export const Objects_149 = Schema.Record( - Schema.String, - Schema.String.check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })) -) -export type RequestTimeoutResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +export type ImageOutputModality = + | "text" + | "image" + | "embeddings" + | "audio" + | "video" + | "rerank" + | "speech" + | "transcription" +export const ImageOutputModality = Schema.Literals([ + "text", + "image", + "embeddings", + "audio", + "video", + "rerank", + "speech", + "transcription" +]).annotate({ "identifier": "ImageOutputModality" }) +export type SupportedParameters = {} +export const SupportedParameters = Schema.Struct({}).annotate({ + "description": + "Union of supported parameters across every endpoint of this model. Coarse discovery aid; the definitive per-endpoint set is behind the endpoints URL.", + "identifier": "SupportedParameters" +}) +export type ImagePricingEntry = { + readonly "billable": "output_image" | "input_image" | "input_font" | "input_reference" | "input_text" + readonly "cost_usd": number + readonly "unit": "image" | "megapixel" | "token" + readonly "variant"?: string } -export const RequestTimeoutResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ "description": "Error data for RequestTimeoutResponse", "identifier": "RequestTimeoutResponseErrorData" }) -export type ResponseHealingPlugin = { readonly "enabled"?: boolean; readonly "id": "response-healing" } -export const ResponseHealingPlugin = Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the response-healing plugin for this request. Defaults to true." - }) +export const ImagePricingEntry = Schema.Struct({ + "billable": Schema.Literals(["output_image", "input_image", "input_font", "input_reference", "input_text"]), + "cost_usd": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) ), - "id": Schema.Literal("response-healing") -}).annotate({ "identifier": "ResponseHealingPlugin" }) -export type ResponseIncludesEnum = - | "file_search_call.results" - | "message.input_image.image_url" - | "computer_call_output.output.image_url" - | "reasoning.encrypted_content" - | "code_interpreter_call.outputs" -export const ResponseIncludesEnum = Schema.Literals([ - "file_search_call.results", - "message.input_image.image_url", - "computer_call_output.output.image_url", - "reasoning.encrypted_content", - "code_interpreter_call.outputs" -]).annotate({ "identifier": "ResponseIncludesEnum" }) -export type ResponsesErrorField = { - readonly "code": - | "server_error" - | "rate_limit_exceeded" - | "invalid_prompt" - | "vector_store_timeout" - | "invalid_image" - | "invalid_image_format" - | "invalid_base64_image" - | "invalid_image_url" - | "image_too_large" - | "image_too_small" - | "image_parse_error" - | "image_content_policy_violation" - | "invalid_image_mode" - | "image_file_too_large" - | "unsupported_image_media_type" - | "empty_image_file" - | "failed_to_download_image" - | "image_file_not_found" - | "bio_policy" - readonly "message": string + "unit": Schema.Literals(["image", "megapixel", "token"]), + "variant": Schema.optionalKey(Schema.String) +}).annotate({ "description": "One billable pricing line for an image provider.", "identifier": "ImagePricingEntry" }) +export type AnthropicInputTokensClearAtLeast = { + readonly "type": "input_tokens" + readonly "value": number readonly [x: string]: Schema.Json } | null -export const ResponsesErrorField = Schema.Union([ +export const AnthropicInputTokensClearAtLeast = Schema.Union([ Schema.StructWithRest( Schema.Struct({ - "code": Schema.Literals([ - "server_error", - "rate_limit_exceeded", - "invalid_prompt", - "vector_store_timeout", - "invalid_image", - "invalid_image_format", - "invalid_base64_image", - "invalid_image_url", - "image_too_large", - "image_too_small", - "image_parse_error", - "image_content_policy_violation", - "invalid_image_mode", - "image_file_too_large", - "unsupported_image_media_type", - "empty_image_file", - "failed_to_download_image", - "image_file_not_found", - "bio_policy" - ]), - "message": Schema.String + "type": Schema.Literal("input_tokens"), + "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) }), [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] ), Schema.Null -]).annotate({ "description": "Error information returned from the API", "identifier": "ResponsesErrorField" }) -export type RouterAttempt = { readonly "model": string; readonly "provider": string; readonly "status": number } -export const RouterAttempt = Schema.Struct({ - "model": Schema.String, - "provider": Schema.String, - "status": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "identifier": "RouterAttempt" }) -export type RouterParams = { - readonly "quality_floor"?: number - readonly "throughput_floor"?: number - readonly "version_group"?: string -} -export const RouterParams = Schema.Struct({ - "quality_floor": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "throughput_floor": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "version_group": Schema.optionalKey(Schema.String) -}).annotate({ "identifier": "RouterParams" }) -export type RoutingStrategy = - | "direct" - | "auto" - | "free" - | "latest" - | "alias" - | "fallback" - | "pareto" - | "bodybuilder" - | "fusion" -export const RoutingStrategy = Schema.Literals([ - "direct", - "auto", - "free", - "latest", - "alias", - "fallback", - "pareto", - "bodybuilder", - "fusion" -]).annotate({ "identifier": "RoutingStrategy" }) -export type SandboxSleepAfterSeconds = number -export const SandboxSleepAfterSeconds = Schema.Number.annotate({ - "description": - "How long (in seconds) the container stays warm after its last command before sleeping, freeing its capacity slot. Idle-based: each command renews the timer. Defaults to 900 (15 minutes); capped at 2592000 (30 days)." -}).check(Schema.isInt().annotate({ "expected": "an integer", "identifier": "SandboxSleepAfterSeconds" })) -export type SearchContextSizeEnum = "low" | "medium" | "high" -export const SearchContextSizeEnum = Schema.Literals(["low", "medium", "high"]).annotate({ - "description": "Size of the search context for web search tools", - "identifier": "SearchContextSizeEnum" -}) -export type SearchModelsServerToolConfig = { readonly "max_results"?: number } -export const SearchModelsServerToolConfig = Schema.Struct({ - "max_results": Schema.optionalKey( - Schema.Number.annotate({ "description": "Maximum number of models to return. Defaults to 5, max 20." }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - ) -}).annotate({ - "description": "Configuration for the openrouter:experimental__search_models server tool", - "identifier": "SearchModelsServerToolConfig" -}) -export type SearchQualityLevel = "low" | "medium" | "high" -export const SearchQualityLevel = Schema.Literals(["low", "medium", "high"]).annotate({ +]).annotate({ "identifier": "AnthropicInputTokensClearAtLeast" }) +export type AnthropicToolUsesKeep = { readonly "type": "tool_uses"; readonly "value": number } +export const AnthropicToolUsesKeep = Schema.Struct({ + "type": Schema.Literal("tool_uses"), + "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "AnthropicToolUsesKeep" }) +export type AnthropicInputTokensTrigger = { readonly "type": "input_tokens"; readonly "value": number } +export const AnthropicInputTokensTrigger = Schema.Struct({ + "type": Schema.Literal("input_tokens"), + "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "AnthropicInputTokensTrigger" }) +export type AnthropicToolUsesTrigger = { readonly "type": "tool_uses"; readonly "value": number } +export const AnthropicToolUsesTrigger = Schema.Struct({ + "type": Schema.Literal("tool_uses"), + "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "AnthropicToolUsesTrigger" }) +export type AnthropicThinkingTurns = { readonly "type": "thinking_turns"; readonly "value": number } +export const AnthropicThinkingTurns = Schema.Struct({ + "type": Schema.Literal("thinking_turns"), + "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "AnthropicThinkingTurns" }) +export type MessagesFallbackParam = { readonly "model": string } +export const MessagesFallbackParam = Schema.Struct({ "model": Schema.String }).annotate({ "description": - "How much context to retrieve per result. Applies to Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, pins a fixed per-result character cap (low=5,000, medium=15,000, high=30,000); when omitted, Exa picks an adaptive size per query and document (typically ~2,000–4,000 characters per result). For Parallel, controls the total characters across all results; when omitted, Parallel uses its own default size. For Perplexity, maps directly to the Search API's native search_context_size parameter. Overridden by `max_characters` when both are set.", - "identifier": "SearchQualityLevel" + "Fallback model to try when the primary model fails or refuses. Only the `model` field is supported; per-attempt overrides are rejected.", + "identifier": "MessagesFallbackParam" }) -export type Objects_150 = { - readonly "tool_calls_executed"?: number | null - readonly "tool_calls_requested"?: number | null - readonly "web_search_requests"?: number | null - readonly [x: string]: Schema.Json +export type AnthropicCitationCharLocationParam = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_char_index": number + readonly "start_char_index": number + readonly "type": "char_location" } -export const Objects_150 = Schema.StructWithRest( - Schema.Struct({ - "tool_calls_executed": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ - "description": "Number of OpenRouter server tool calls that executed and produced a result." - }) - ), - "tool_calls_requested": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ - "description": - "Total number of OpenRouter server-orchestrated tool calls the model requested, across all tool types. Provider-native tools (e.g. native web search) are not counted here." - }) - ), - "web_search_requests": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ - "description": - "Number of web searches performed by server-side tools. For server-orchestrated tool calls a web search is also counted in tool_calls_requested; provider-native web search may report web_search_requests only. Do not sum the two." - }) - ) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type ServiceTier = "auto" | "default" | "flex" | "priority" | "scale" | null -export const ServiceTier = Schema.Union([ - Schema.Literal("auto"), - Schema.Literal("default"), - Schema.Literal("flex"), - Schema.Literal("priority"), - Schema.Literal("scale"), - Schema.Null -]).annotate({ "identifier": "ServiceTier" }) -export type ServiceUnavailableResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +export const AnthropicCitationCharLocationParam = Schema.Struct({ + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "document_title": Schema.Union([Schema.String, Schema.Null]), + "end_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("char_location") +}).annotate({ "identifier": "AnthropicCitationCharLocationParam" }) +export type AnthropicCitationPageLocationParam = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_page_number": number + readonly "start_page_number": number + readonly "type": "page_location" } -export const ServiceUnavailableResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ - "description": "Error data for ServiceUnavailableResponse", - "identifier": "ServiceUnavailableResponseErrorData" +export const AnthropicCitationPageLocationParam = Schema.Struct({ + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "document_title": Schema.Union([Schema.String, Schema.Null]), + "end_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("page_location") +}).annotate({ "identifier": "AnthropicCitationPageLocationParam" }) +export type AnthropicCitationContentBlockLocationParam = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_block_index": number + readonly "start_block_index": number + readonly "type": "content_block_location" +} +export const AnthropicCitationContentBlockLocationParam = Schema.Struct({ + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "document_title": Schema.Union([Schema.String, Schema.Null]), + "end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("content_block_location") +}).annotate({ "identifier": "AnthropicCitationContentBlockLocationParam" }) +export type AnthropicCitationWebSearchResultLocationParam = { + readonly "cited_text": string + readonly "encrypted_index": string + readonly "title": string | null + readonly "type": "web_search_result_location" + readonly "url": string +} +export const AnthropicCitationWebSearchResultLocationParam = Schema.Struct({ + "cited_text": Schema.String, + "encrypted_index": Schema.String, + "title": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.Literal("web_search_result_location"), + "url": Schema.String +}).annotate({ "identifier": "AnthropicCitationWebSearchResultLocationParam" }) +export type AnthropicCitationSearchResultLocationParam = { + readonly "cited_text": string + readonly "end_block_index": number + readonly "search_result_index": number + readonly "source": string + readonly "start_block_index": number + readonly "title": string | null + readonly "type": "search_result_location" +} +export const AnthropicCitationSearchResultLocationParam = Schema.Struct({ + "cited_text": Schema.String, + "end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "search_result_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "source": Schema.String, + "start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "title": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.Literal("search_result_location") +}).annotate({ "identifier": "AnthropicCitationSearchResultLocationParam" }) +export type AnthropicImageMimeType = "image/jpeg" | "image/png" | "image/gif" | "image/webp" +export const AnthropicImageMimeType = Schema.Literals(["image/jpeg", "image/png", "image/gif", "image/webp"]).annotate({ + "identifier": "AnthropicImageMimeType" }) -export type ShellCallStatus = "in_progress" | "completed" | "incomplete" -export const ShellCallStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "description": "Status of a shell call or its output.", - "identifier": "ShellCallStatus" +export type AnthropicUrlImageSource = { readonly "type": "url"; readonly "url": string } +export const AnthropicUrlImageSource = Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }).annotate({ + "identifier": "AnthropicUrlImageSource" }) -export type ShellServerTool = { readonly "type": "shell" } -export const ShellServerTool = Schema.Struct({ "type": Schema.Literal("shell") }).annotate({ - "description": "Shell tool configuration", - "identifier": "ShellServerTool" +export type AnthropicBase64PdfSource = { + readonly "data": string + readonly "media_type": "application/pdf" + readonly "type": "base64" +} +export const AnthropicBase64PdfSource = Schema.Struct({ + "data": Schema.String, + "media_type": Schema.Literal("application/pdf"), + "type": Schema.Literal("base64") +}).annotate({ "identifier": "AnthropicBase64PdfSource" }) +export type AnthropicPlainTextSource = { + readonly "data": string + readonly "media_type": "text/plain" + readonly "type": "text" +} +export const AnthropicPlainTextSource = Schema.Struct({ + "data": Schema.String, + "media_type": Schema.Literal("text/plain"), + "type": Schema.Literal("text") +}).annotate({ "identifier": "AnthropicPlainTextSource" }) +export type AnthropicUrlPdfSource = { readonly "type": "url"; readonly "url": string } +export const AnthropicUrlPdfSource = Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }).annotate({ + "identifier": "AnthropicUrlPdfSource" }) -export type ShellServerToolEngine = "auto" | "openrouter" -export const ShellServerToolEngine = Schema.Literals(["auto", "openrouter"]).annotate({ +export type AnthropicFileDocumentSource = { readonly "file_id": string; readonly "type": "file" } +export const AnthropicFileDocumentSource = Schema.Struct({ "file_id": Schema.String, "type": Schema.Literal("file") }) + .annotate({ "identifier": "AnthropicFileDocumentSource" }) +export type AnthropicWebSearchResultBlockParam = { + readonly "encrypted_content": string + readonly "page_age"?: string | null + readonly "title": string + readonly "type": "web_search_result" + readonly "url": string +} +export const AnthropicWebSearchResultBlockParam = Schema.Struct({ + "encrypted_content": Schema.String, + "page_age": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "title": Schema.String, + "type": Schema.Literal("web_search_result"), + "url": Schema.String +}).annotate({ "identifier": "AnthropicWebSearchResultBlockParam" }) +export type MessagesAdvisorToolResultBlock = { + readonly "content": {} + readonly "tool_use_id": string + readonly "type": "advisor_tool_result" +} +export const MessagesAdvisorToolResultBlock = Schema.Struct({ + "content": Schema.Struct({}), + "tool_use_id": Schema.String, + "type": Schema.Literal("advisor_tool_result") +}).annotate({ "description": - "Which shell engine to use. \"openrouter\" runs commands server-side in the OpenRouter sandbox. \"auto\" (default) keeps the provider's native hosted shell when available (OpenAI); on other providers the call is routed to the OpenRouter sandbox.", - "identifier": "ShellServerToolEngine" + "Advisor tool result from a prior assistant turn, replayed back to the model on the next turn. Mirrors the block Anthropic returns in assistant content when the `advisor_20260301` tool runs.", + "identifier": "MessagesAdvisorToolResultBlock" }) -export type StopServerToolsWhenFinishReasonIs = { readonly "reason": string; readonly "type": "finish_reason_is" } -export const StopServerToolsWhenFinishReasonIs = Schema.Struct({ - "reason": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), - "type": Schema.Literal("finish_reason_is") +export type MessagesShellToolResultBlock = { + readonly "content": {} + readonly "tool_use_id": string + readonly "type": "openrouter_shell_tool_result" +} +export const MessagesShellToolResultBlock = Schema.Struct({ + "content": Schema.Struct({}), + "tool_use_id": Schema.String, + "type": Schema.Literal("openrouter_shell_tool_result") }).annotate({ - "description": "Stop when the upstream model emits this finish reason (e.g. `length`).", - "identifier": "StopServerToolsWhenFinishReasonIs" + "description": + "Output of an `openrouter:shell` call from a prior assistant turn. Accepted on replay and dropped before the provider request — Anthropic has no equivalent block.", + "identifier": "MessagesShellToolResultBlock" }) -export type StopServerToolsWhenHasToolCall = { readonly "tool_name": string; readonly "type": "has_tool_call" } -export const StopServerToolsWhenHasToolCall = Schema.Struct({ - "tool_name": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "type": Schema.Literal("has_tool_call") -}).annotate({ - "description": "Stop after a tool with this name has been called.", - "identifier": "StopServerToolsWhenHasToolCall" -}) -export type StopServerToolsWhenMaxCost = { readonly "max_cost_in_dollars": number; readonly "type": "max_cost" } -export const StopServerToolsWhenMaxCost = Schema.Struct({ - "max_cost_in_dollars": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "type": Schema.Literal("max_cost") -}).annotate({ - "description": "Stop once cumulative cost across the loop exceeds this dollar threshold.", - "identifier": "StopServerToolsWhenMaxCost" -}) -export type StopServerToolsWhenMaxTokensUsed = { readonly "max_tokens": number; readonly "type": "max_tokens_used" } -export const StopServerToolsWhenMaxTokensUsed = Schema.Struct({ - "max_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("max_tokens_used") -}).annotate({ - "description": "Stop once cumulative token usage across the loop exceeds this threshold.", - "identifier": "StopServerToolsWhenMaxTokensUsed" -}) -export type StopServerToolsWhenStepCountIs = { readonly "step_count": number; readonly "type": "step_count_is" } -export const StopServerToolsWhenStepCountIs = Schema.Struct({ - "step_count": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("step_count_is") -}).annotate({ - "description": "Stop after the agent loop has executed this many steps.", - "identifier": "StopServerToolsWhenStepCountIs" -}) -export type StreamLogprob = { - readonly "bytes"?: ReadonlyArray - readonly "logprob": number - readonly "token": string - readonly "top_logprobs"?: ReadonlyArray< - { readonly "bytes"?: ReadonlyArray; readonly "logprob"?: number; readonly "token"?: string } - > -} -export const StreamLogprob = Schema.Struct({ - "bytes": Schema.optionalKey(Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "token": Schema.String, - "top_logprobs": Schema.optionalKey(Schema.Array( - Schema.Struct({ - "bytes": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) - ), - "logprob": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "token": Schema.optionalKey(Schema.String) - }).annotate({ "description": "Alternative token with its log probability" }) - )) -}).annotate({ "description": "Log probability information for a token", "identifier": "StreamLogprob" }) -export type StreamLogprobTopLogprob = { - readonly "bytes"?: ReadonlyArray - readonly "logprob"?: number - readonly "token"?: string -} -export const StreamLogprobTopLogprob = Schema.Struct({ - "bytes": Schema.optionalKey(Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })))), - "logprob": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "token": Schema.optionalKey(Schema.String) -}).annotate({ "description": "Alternative token with its log probability", "identifier": "StreamLogprobTopLogprob" }) -export type STTInputAudio = { readonly "data": string; readonly "format": string } -export const STTInputAudio = Schema.Struct({ - "data": Schema.String.annotate({ "description": "Base64-encoded audio data (raw bytes, not a data URI)" }), - "format": Schema.String.annotate({ - "description": "Audio format (e.g., wav, mp3, flac, m4a, ogg, webm, aac). Supported formats vary by provider." - }) -}).annotate({ "description": "Base64-encoded audio to transcribe", "identifier": "STTInputAudio" }) -export type STTSegment = { - readonly "avg_logprob"?: number - readonly "compression_ratio"?: number - readonly "end": number - readonly "id": number - readonly "no_speech_prob"?: number - readonly "seek"?: number - readonly "start": number - readonly "temperature"?: number - readonly "text": string - readonly "tokens"?: ReadonlyArray -} -export const STTSegment = Schema.Struct({ - "avg_logprob": Schema.optionalKey( - Schema.Number.annotate({ "description": "Average log probability of the segment", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "compression_ratio": Schema.optionalKey( - Schema.Number.annotate({ "description": "Compression ratio of the segment", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "end": Schema.Number.annotate({ "description": "Segment end time in seconds", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "id": Schema.Number.annotate({ "description": "Segment index within the transcript" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "no_speech_prob": Schema.optionalKey( - Schema.Number.annotate({ "description": "Probability the segment contains no speech", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "seek": Schema.optionalKey( - Schema.Number.annotate({ "description": "Seek offset of the segment" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - ), - "start": Schema.Number.annotate({ "description": "Segment start time in seconds", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ "description": "Temperature used for the segment", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "text": Schema.String.annotate({ "description": "Transcribed text of the segment" }), - "tokens": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({ - "description": "Token IDs of the segment" - }) - ) -}).annotate({ - "description": "A timestamped transcript segment, returned when response_format is verbose_json", - "identifier": "STTSegment" -}) -export type STTTimestampGranularity = "word" | "segment" -export const STTTimestampGranularity = Schema.Literals(["word", "segment"]).annotate({ - "description": "A timestamp detail level for verbose_json transcription responses.", - "identifier": "STTTimestampGranularity" -}) -export type STTUsage = { - readonly "cost"?: number - readonly "input_tokens"?: number - readonly "output_tokens"?: number - readonly "seconds"?: number - readonly "total_tokens"?: number -} -export const STTUsage = Schema.Struct({ - "cost": Schema.optionalKey( - Schema.Number.annotate({ "description": "Total cost of the request in USD", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "input_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of input tokens billed for this request" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - ), - "output_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Number of output tokens generated" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - ), - "seconds": Schema.optionalKey( - Schema.Number.annotate({ "description": "Duration of the input audio in seconds", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "total_tokens": Schema.optionalKey( - Schema.Number.annotate({ "description": "Total number of tokens used (input + output)" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - ) -}).annotate({ "description": "Aggregated usage statistics for the request", "identifier": "STTUsage" }) -export type STTWord = { - readonly "end": number - readonly "speaker"?: number - readonly "start": number - readonly "word": string +export type MessagesBashToolResultBlock = { + readonly "content": {} + readonly "tool_use_id": string + readonly "type": "openrouter_bash_tool_result" } -export const STTWord = Schema.Struct({ - "end": Schema.Number.annotate({ "description": "Word end time in seconds", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "speaker": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Zero-based speaker index for the word, present when the provider returns speaker diarization" - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ), - "start": Schema.Number.annotate({ "description": "Word start time in seconds", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "word": Schema.String.annotate({ "description": "The transcribed word" }) -}).annotate({ - "description": "A timestamped word, returned when the provider includes word-level timestamps", - "identifier": "STTWord" -}) -export type SubagentNestedTool = { readonly "parameters"?: {}; readonly "type": string } -export const SubagentNestedTool = Schema.Struct({ - "parameters": Schema.optionalKey(Schema.Struct({})), - "type": Schema.String +export const MessagesBashToolResultBlock = Schema.Struct({ + "content": Schema.Struct({}), + "tool_use_id": Schema.String, + "type": Schema.Literal("openrouter_bash_tool_result") }).annotate({ "description": - "A tool made available to the subagent. Only OpenRouter server tools (e.g. openrouter:web_search) are supported; function tools are rejected because the worker has no way to execute them. The subagent tool may not list itself.", - "identifier": "SubagentNestedTool" + "Output of a sandbox-executed `openrouter:bash` call from a prior assistant turn. Accepted on replay and dropped before the provider request — Anthropic has no equivalent block.", + "identifier": "MessagesBashToolResultBlock" }) -export type SubagentReasoning = { - readonly "effort"?: "max" | "xhigh" | "high" | "medium" | "low" | "minimal" | "none" - readonly "max_tokens"?: number +export type MessagesOutputConfig = { + readonly "effort"?: "low" | "medium" | "high" | "xhigh" | "max" | null + readonly "format"?: + | { readonly "schema": {}; readonly "type": "json_schema"; readonly [x: string]: Schema.Json } + | null + readonly "task_budget"?: { + readonly "remaining"?: number | null + readonly "total": number + readonly "type": "tokens" + readonly [x: string]: Schema.Json + } | null } -export const SubagentReasoning = Schema.Struct({ +export const MessagesOutputConfig = Schema.Struct({ "effort": Schema.optionalKey( - Schema.Literals(["max", "xhigh", "high", "medium", "low", "minimal", "none"]).annotate({ - "description": "Reasoning effort level for the subagent call." + Schema.Union([ + Schema.Literal("low"), + Schema.Literal("medium"), + Schema.Literal("high"), + Schema.Literal("xhigh"), + Schema.Literal("max"), + Schema.Null + ]).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`, `xhigh`, or `max`." }) ), - "max_tokens": Schema.optionalKey( - Schema.Number.annotate({ + "format": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest(Schema.Struct({ "schema": Schema.Struct({}), "type": Schema.Literal("json_schema") }), [ + Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) + ]), + Schema.Null + ]).annotate({ "description": - "Maximum number of reasoning tokens the subagent may use. Accepted and validated but not yet forwarded to the subagent call." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ) -}).annotate({ - "description": - "Reasoning configuration forwarded to the subagent call. Use this to control reasoning effort and token budget for models that support extended thinking.", - "identifier": "SubagentReasoning" -}) -export type SubmitGenerationFeedbackRequest = { - readonly "category": - | "latency" - | "incoherence" - | "incorrect_response" - | "formatting" - | "billing" - | "api_error" - | "other" - readonly "comment"?: string - readonly "generation_id": string -} -export const SubmitGenerationFeedbackRequest = Schema.Struct({ - "category": Schema.Literals([ - "latency", - "incoherence", - "incorrect_response", - "formatting", - "billing", - "api_error", - "other" - ]).annotate({ "description": "The category of feedback being reported" }), - "comment": Schema.optionalKey( - Schema.String.annotate({ "description": "An optional free-text comment describing the feedback" }).check( - Schema.isMaxLength(1000).annotate({ "expected": "a value with a length of at most 1000" }) - ) + "A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)." + }) ), - "generation_id": Schema.String.annotate({ "description": "The generation to submit feedback on" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) -}).annotate({ - "description": "Structured feedback about a specific generation", - "identifier": "SubmitGenerationFeedbackRequest" -}) -export type SubmitGenerationFeedbackResponse = { readonly "data": { readonly "success": true } } -export const SubmitGenerationFeedbackResponse = Schema.Struct({ - "data": Schema.Struct({ - "success": Schema.Literal(true).annotate({ "description": "Whether the feedback was recorded" }) - }) -}).annotate({ - "description": "Confirmation that the feedback was recorded", - "identifier": "SubmitGenerationFeedbackResponse" -}) -export type SupportedParameters = {} -export const SupportedParameters = Schema.Struct({}).annotate({ - "description": - "Union of supported parameters across every endpoint of this model. Coarse discovery aid; the definitive per-endpoint set is behind the endpoints URL.", - "identifier": "SupportedParameters" -}) -export type TaskClassificationMacroCategory = { - readonly "key": string - readonly "label": string - readonly "token_share": number - readonly "usage_share": number -} -export const TaskClassificationMacroCategory = Schema.Struct({ - "key": Schema.String.annotate({ "description": "Macro-category identifier." }), - "label": Schema.String.annotate({ "description": "Human-readable label for the macro-category." }), - "token_share": Schema.Number.annotate({ - "description": "Combined token share of all classifications in this macro-category (0–1).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "usage_share": Schema.Number.annotate({ - "description": "Combined usage share of all classifications in this macro-category (0–1).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) -}).annotate({ "identifier": "TaskClassificationMacroCategory" }) -export type TaskClassificationModel = { - readonly "id": string - readonly "tag_token_share": number - readonly "tag_usage_share": number -} -export const TaskClassificationModel = Schema.Struct({ - "id": Schema.String.annotate({ "description": "Model identifier (permaslug)." }), - "tag_token_share": Schema.Number.annotate({ - "description": - "Fraction of this classification's sampled token volume attributed to this model (0–1). Sums to ≤1 across the returned models (only top-N are included and unattributed requests are excluded).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "tag_usage_share": Schema.Number.annotate({ - "description": - "Fraction of this classification's sampled requests attributed to this model (0–1). Sums to ≤1 across the returned models (only top-N are included and unattributed requests are excluded).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) -}).annotate({ "identifier": "TaskClassificationModel" }) -export type TextDeltaEvent = { - readonly "content_index": number - readonly "delta": string - readonly "item_id": string - readonly "logprobs": ReadonlyArray< - { - readonly "bytes"?: ReadonlyArray - readonly "logprob": number - readonly "token": string - readonly "top_logprobs"?: ReadonlyArray< - { readonly "bytes"?: ReadonlyArray; readonly "logprob"?: number; readonly "token"?: string } - > - } - > - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.output_text.delta" -} -export const TextDeltaEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "delta": Schema.String, - "item_id": Schema.String, - "logprobs": Schema.Array( - Schema.Struct({ - "bytes": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) - ), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "token": Schema.String, - "top_logprobs": Schema.optionalKey(Schema.Array( + "task_budget": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest( Schema.Struct({ - "bytes": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) + "remaining": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]) ), - "logprob": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) + "total": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(20000).annotate({ "expected": "a value greater than or equal to 20000" }) ), - "token": Schema.optionalKey(Schema.String) - }).annotate({ "description": "Alternative token with its log probability" }) - )) - }).annotate({ "description": "Log probability information for a token" }) - ), - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.output_text.delta") -}).annotate({ "description": "Event emitted when a text delta is streamed", "identifier": "TextDeltaEvent" }) -export type TextDoneEvent = { - readonly "content_index": number - readonly "item_id": string - readonly "logprobs": ReadonlyArray< - { - readonly "bytes"?: ReadonlyArray - readonly "logprob": number - readonly "token": string - readonly "top_logprobs"?: ReadonlyArray< - { readonly "bytes"?: ReadonlyArray; readonly "logprob"?: number; readonly "token"?: string } - > - } - > - readonly "output_index": number - readonly "sequence_number": number - readonly "text": string - readonly "type": "response.output_text.done" -} -export const TextDoneEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "logprobs": Schema.Array( - Schema.Struct({ - "bytes": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) - ), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) + "type": Schema.Literal("tokens") + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] ), - "token": Schema.String, - "top_logprobs": Schema.optionalKey(Schema.Array( - Schema.Struct({ - "bytes": Schema.optionalKey( - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) - ), - "logprob": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "token": Schema.optionalKey(Schema.String) - }).annotate({ "description": "Alternative token with its log probability" }) - )) - }).annotate({ "description": "Log probability information for a token" }) - ), - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "text": Schema.String, - "type": Schema.Literal("response.output_text.done") -}).annotate({ "description": "Event emitted when text streaming is complete", "identifier": "TextDoneEvent" }) -export type ToolCallStatus = "in_progress" | "completed" | "incomplete" -export const ToolCallStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ - "identifier": "ToolCallStatus" -}) -export type ToolChoiceAllowed = { - readonly "mode": "auto" | "required" - readonly "tools": ReadonlyArray<{}> - readonly "type": "allowed_tools" -} -export const ToolChoiceAllowed = Schema.Struct({ - "mode": Schema.Literals(["auto", "required"]), - "tools": Schema.Array(Schema.Struct({})), - "type": Schema.Literal("allowed_tools") -}).annotate({ - "description": "Constrains the model to a pre-defined set of allowed tools", - "identifier": "ToolChoiceAllowed" -}) -export type TooManyRequestsResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null -} -export const TooManyRequestsResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ - "description": "Error data for TooManyRequestsResponse", - "identifier": "TooManyRequestsResponseErrorData" -}) -export type TopProviderInfo = { - readonly "context_length"?: number | null - readonly "is_moderated": boolean - readonly "max_completion_tokens"?: number | null -} -export const TopProviderInfo = Schema.Struct({ - "context_length": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ - "description": "Context length from the top provider" - }) - ), - "is_moderated": Schema.Boolean.annotate({ "description": "Whether the top provider moderates content" }), - "max_completion_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ - "description": "Maximum completion tokens from the top provider" + Schema.Null + ]).annotate({ + "description": + "Task budget for an agentic turn. The model sees a countdown of remaining tokens and uses it to prioritize work and wind down gracefully. Advisory — does not enforce a hard cap." }) ) -}).annotate({ "description": "Information about the top provider for this model", "identifier": "TopProviderInfo" }) -export type TraceConfig = { - readonly "generation_name"?: string - readonly "parent_span_id"?: string - readonly "span_name"?: string - readonly "trace_id"?: string - readonly "trace_name"?: string -} -export const TraceConfig = Schema.Struct({ - "generation_name": Schema.optionalKey(Schema.String), - "parent_span_id": Schema.optionalKey(Schema.String), - "span_name": Schema.optionalKey(Schema.String), - "trace_id": Schema.optionalKey(Schema.String), - "trace_name": 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.", - "identifier": "TraceConfig" -}) -export type Truncation = "auto" | "disabled" | null -export const Truncation = Schema.Union([Schema.Literal("auto"), Schema.Literal("disabled"), Schema.Null]).annotate({ - "identifier": "Truncation" + "Configuration for controlling output behavior. Supports the effort parameter and structured output format.", + "identifier": "MessagesOutputConfig" }) -export type UnauthorizedResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null -} -export const UnauthorizedResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ "description": "Error data for UnauthorizedResponse", "identifier": "UnauthorizedResponseErrorData" }) -export type UnifiedBenchmarkPricing = { - readonly "completion": string - readonly "prompt": string +export type AnthropicThinkingDisplay = "summarized" | "omitted" | null +export const AnthropicThinkingDisplay = Schema.Union([ + Schema.Literal("summarized"), + Schema.Literal("omitted"), + Schema.Null +]).annotate({ "identifier": "AnthropicThinkingDisplay" }) +export type AnthropicWebSearchToolUserLocation = { + readonly "city"?: string | null + readonly "country"?: string | null + readonly "region"?: string | null + readonly "timezone"?: string | null + readonly "type": "approximate" readonly [x: string]: Schema.Json } | null -export const UnifiedBenchmarkPricing = Schema.Union([ +export const AnthropicWebSearchToolUserLocation = Schema.Union([ Schema.StructWithRest( Schema.Struct({ - "completion": Schema.String.annotate({ "description": "Cost per output token (USD, decimal string)." }), - "prompt": Schema.String.annotate({ "description": "Cost per input token (USD, decimal string)." }) + "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("approximate") }), [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] ), Schema.Null -]).annotate({ - "description": "OpenRouter pricing per token for this model. Null if pricing is unavailable.", - "identifier": "UnifiedBenchmarkPricing" +]).annotate({ "identifier": "AnthropicWebSearchToolUserLocation" }) +export type AnthropicAllowedCallers = ReadonlyArray<"direct" | "code_execution_20250825" | "code_execution_20260120"> +export const AnthropicAllowedCallers = Schema.Array( + Schema.Literals(["direct", "code_execution_20250825", "code_execution_20260120"]) +).annotate({ "identifier": "AnthropicAllowedCallers" }) +export type ShellServerToolEngine = "auto" | "openrouter" +export const ShellServerToolEngine = Schema.Literals(["auto", "openrouter"]).annotate({ + "description": + "Which shell engine to use. \"openrouter\" runs commands server-side in the OpenRouter sandbox. \"auto\" (default) keeps the provider's native hosted shell when available (OpenAI); on other providers the call is routed to the OpenRouter sandbox.", + "identifier": "ShellServerToolEngine" }) -export type UnifiedBenchmarksMeta = { - readonly "as_of": string - readonly "citation": string | null - readonly "model_count": number - readonly "source": "artificial-analysis" | "design-arena" | null - readonly "source_url": string | null - readonly "task_type": string | null - readonly "version": "v1" +export type AnthropicContainer = { + readonly "expires_at": string + readonly "id": string + readonly [x: string]: Schema.Json +} | null +export const AnthropicContainer = Schema.Union([ + Schema.StructWithRest(Schema.Struct({ "expires_at": Schema.String, "id": Schema.String }), [ + Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) + ]), + Schema.Null +]).annotate({ "identifier": "AnthropicContainer" }) +export type AnthropicCitationCharLocation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_char_index": number + readonly "file_id": string | null + readonly "start_char_index": number + readonly "type": "char_location" } -export const UnifiedBenchmarksMeta = Schema.Struct({ - "as_of": Schema.String.annotate({ "description": "ISO-8601 timestamp of when this data was last updated." }), - "citation": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "Required attribution when republishing this data, or null when results span multiple sources (attribute each item individually by its `source` discriminator)." - }), - "model_count": Schema.Number.annotate({ "description": "Number of unique models in the response." }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "source": Schema.Union([Schema.Literal("artificial-analysis"), Schema.Literal("design-arena"), Schema.Null]).annotate( - { "description": "The source filter applied, or null when all sources are returned." } - ), - "source_url": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "URL of the upstream data source, or null when results span multiple sources." - }), - "task_type": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The task_type filter applied, or null if showing all." - }), - "version": Schema.Literal("v1").annotate({ "description": "Dataset version." }) -}).annotate({ "identifier": "UnifiedBenchmarksMeta" }) -export type UnprocessableEntityResponseErrorData = { - readonly "code": number - readonly "message": string - readonly "metadata"?: { readonly [x: string]: Schema.Json } | null +export const AnthropicCitationCharLocation = Schema.Struct({ + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "document_title": Schema.Union([Schema.String, Schema.Null]), + "end_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "file_id": Schema.Union([Schema.String, Schema.Null]), + "start_char_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("char_location") +}).annotate({ "identifier": "AnthropicCitationCharLocation" }) +export type AnthropicCitationPageLocation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_page_number": number + readonly "file_id": string | null + readonly "start_page_number": number + readonly "type": "page_location" } -export const UnprocessableEntityResponseErrorData = Schema.Struct({ - "code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "message": Schema.String, - "metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ) -}).annotate({ - "description": "Error data for UnprocessableEntityResponse", - "identifier": "UnprocessableEntityResponseErrorData" +export const AnthropicCitationPageLocation = Schema.Struct({ + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "document_title": Schema.Union([Schema.String, Schema.Null]), + "end_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "file_id": Schema.Union([Schema.String, Schema.Null]), + "start_page_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("page_location") +}).annotate({ "identifier": "AnthropicCitationPageLocation" }) +export type AnthropicCitationContentBlockLocation = { + readonly "cited_text": string + readonly "document_index": number + readonly "document_title": string | null + readonly "end_block_index": number + readonly "file_id": string | null + readonly "start_block_index": number + readonly "type": "content_block_location" +} +export const AnthropicCitationContentBlockLocation = Schema.Struct({ + "cited_text": Schema.String, + "document_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "document_title": Schema.Union([Schema.String, Schema.Null]), + "end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "file_id": Schema.Union([Schema.String, Schema.Null]), + "start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("content_block_location") +}).annotate({ "identifier": "AnthropicCitationContentBlockLocation" }) +export type AnthropicCitationWebSearchResultLocation = { + readonly "cited_text": string + readonly "encrypted_index": string + readonly "title": string | null + readonly "type": "web_search_result_location" + readonly "url": string +} +export const AnthropicCitationWebSearchResultLocation = Schema.Struct({ + "cited_text": Schema.String, + "encrypted_index": Schema.String, + "title": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.Literal("web_search_result_location"), + "url": Schema.String +}).annotate({ "identifier": "AnthropicCitationWebSearchResultLocation" }) +export type AnthropicCitationSearchResultLocation = { + readonly "cited_text": string + readonly "end_block_index": number + readonly "search_result_index": number + readonly "source": string + readonly "start_block_index": number + readonly "title": string | null + readonly "type": "search_result_location" +} +export const AnthropicCitationSearchResultLocation = Schema.Struct({ + "cited_text": Schema.String, + "end_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "search_result_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "source": Schema.String, + "start_block_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "title": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.Literal("search_result_location") +}).annotate({ "identifier": "AnthropicCitationSearchResultLocation" }) +export type AnthropicDirectCaller = { readonly "type": "direct" } +export const AnthropicDirectCaller = Schema.Struct({ "type": Schema.Literal("direct") }).annotate({ + "identifier": "AnthropicDirectCaller" }) -export type UpdateBYOKKeyRequest = { - readonly "allowed_models"?: ReadonlyArray | null - readonly "allowed_user_ids"?: ReadonlyArray | null - readonly "disabled"?: boolean - readonly "is_fallback"?: boolean - readonly "key"?: string - readonly "name"?: string | null +export type AnthropicCodeExecution20250825Caller = { + readonly "tool_id": string + readonly "type": "code_execution_20250825" } -export const UpdateBYOKKeyRequest = Schema.Struct({ - "allowed_models": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) - ), - Schema.Null - ]).annotate({ - "description": "Optional allowlist of model slugs this credential may be used for. `null` means no restriction." - }) - ), - "allowed_user_ids": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) - ), - Schema.Null - ]).annotate({ - "description": "Optional allowlist of user IDs that may use this credential. `null` means no restriction." - }) - ), - "disabled": Schema.optionalKey(Schema.Boolean.annotate({ "description": "Whether this credential is disabled." })), - "is_fallback": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried." - }) - ), - "key": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A new raw provider API key to rotate the credential in-place. The previous key material is overwritten and the masked label is regenerated. Encrypted at rest and never returned in API responses." - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) - ), - "name": Schema.optionalKey( - Schema.Union([ - Schema.String.check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })), - Schema.Null - ]).annotate({ "description": "Optional human-readable name for the credential." }) - ) -}).annotate({ "identifier": "UpdateBYOKKeyRequest" }) -export type UpdateWorkspaceRequest = { - readonly "default_image_model"?: string | null - readonly "default_provider_sort"?: string | null - readonly "default_text_model"?: string | null - readonly "description"?: string | null - readonly "io_logging_api_key_ids"?: ReadonlyArray | null - readonly "io_logging_sampling_rate"?: number - readonly "is_data_discount_logging_enabled"?: boolean - readonly "is_observability_broadcast_enabled"?: boolean - readonly "is_observability_io_logging_enabled"?: boolean - readonly "name"?: string - readonly "slug"?: string +export const AnthropicCodeExecution20250825Caller = Schema.Struct({ + "tool_id": Schema.String, + "type": Schema.Literal("code_execution_20250825") +}).annotate({ "identifier": "AnthropicCodeExecution20250825Caller" }) +export type AnthropicCodeExecution20260120Caller = { + readonly "tool_id": string + readonly "type": "code_execution_20260120" } -export const UpdateWorkspaceRequest = Schema.Struct({ - "default_image_model": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Default image model for this workspace" }) - ), - "default_provider_sort": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Default provider sort preference (price, throughput, latency, exacto)" - }) - ), - "default_text_model": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Default text model for this workspace" }) - ), - "description": Schema.optionalKey( - Schema.Union([ - Schema.String.check(Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" })), - Schema.Null - ]).annotate({ "description": "New description for the workspace" }) - ), - "io_logging_api_key_ids": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - Schema.Null - ]).annotate({ "description": "Optional array of API key IDs to filter I/O logging" }) - ), - "io_logging_sampling_rate": Schema.optionalKey( - Schema.Number.annotate({ "description": "Sampling rate for I/O logging (0.0001-1)", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "is_data_discount_logging_enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether data discount logging is enabled" }) - ), - "is_observability_broadcast_enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether broadcast is enabled" }) - ), - "is_observability_io_logging_enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether private logging is enabled" }) - ), - "name": Schema.optionalKey( - Schema.String.annotate({ "description": "New name for the workspace" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ).check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })) - ), - "slug": Schema.optionalKey( - Schema.String.annotate({ - "description": - "New URL-friendly slug (lowercase alphanumeric segments separated by single hyphens, no leading/trailing hyphens)" - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( - Schema.isMaxLength(50).annotate({ "expected": "a value with a length of at most 50" }) - ).check( - Schema.isPattern(new RegExp("^[a-z0-9]+(?:-[a-z0-9]+)*$")).annotate({ - "expected": "a string matching the RegExp ^[a-z0-9]+(?:-[a-z0-9]+)*$" - }) - ) - ) -}).annotate({ "identifier": "UpdateWorkspaceRequest" }) -export type UpsertWorkspaceBudgetRequest = { readonly "limit_usd": number } -export const UpsertWorkspaceBudgetRequest = Schema.Struct({ - "limit_usd": Schema.Number.annotate({ - "description": "Spending limit in USD. Must be greater than 0.", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) -}).annotate({ "identifier": "UpsertWorkspaceBudgetRequest" }) -export type URLCitation = { - readonly "content"?: string - readonly "end_index": number - readonly "start_index": number +export const AnthropicCodeExecution20260120Caller = Schema.Struct({ + "tool_id": Schema.String, + "type": Schema.Literal("code_execution_20260120") +}).annotate({ "identifier": "AnthropicCodeExecution20260120Caller" }) +export type AnthropicThinkingBlock = { + readonly "signature": string + readonly "thinking": string + readonly "type": "thinking" +} +export const AnthropicThinkingBlock = Schema.Struct({ + "signature": Schema.String, + "thinking": Schema.String, + "type": Schema.Literal("thinking") +}).annotate({ "identifier": "AnthropicThinkingBlock" }) +export type AnthropicRedactedThinkingBlock = { readonly "data": string; readonly "type": "redacted_thinking" } +export const AnthropicRedactedThinkingBlock = Schema.Struct({ + "data": Schema.String, + "type": Schema.Literal("redacted_thinking") +}).annotate({ "identifier": "AnthropicRedactedThinkingBlock" }) +export type AnthropicWebSearchResult = { + readonly "encrypted_content": string + readonly "page_age": string | null readonly "title": string - readonly "type": "url_citation" + readonly "type": "web_search_result" readonly "url": string } -export const URLCitation = Schema.Struct({ - "content": Schema.optionalKey(Schema.String), - "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), +export const AnthropicWebSearchResult = Schema.Struct({ + "encrypted_content": Schema.String, + "page_age": Schema.Union([Schema.String, Schema.Null]), "title": Schema.String, - "type": Schema.Literal("url_citation"), + "type": Schema.Literal("web_search_result"), "url": Schema.String -}).annotate({ "identifier": "URLCitation" }) -export type VideoGenerationUsage = { readonly "cost"?: number | null; readonly "is_byok"?: boolean } -export const VideoGenerationUsage = Schema.Struct({ - "cost": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "The cost of the video generation in USD.", "format": "double" }) - ), - "is_byok": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether the request was made using a Bring Your Own Key configuration." }) - ) -}).annotate({ - "description": "Usage and cost information for the video generation. Available once the job has completed.", - "identifier": "VideoGenerationUsage" -}) -export type VideoModel = { - readonly "allowed_passthrough_parameters": ReadonlyArray - readonly "canonical_slug": string - readonly "created": number - readonly "description"?: string - readonly "generate_audio": boolean | null - readonly "hugging_face_id"?: string | null - readonly "id": string - readonly "name": string - readonly "pricing_skus"?: { readonly [x: string]: string } | null - readonly "seed": boolean | null - readonly "supported_aspect_ratios": - | ReadonlyArray<"16:9" | "9:16" | "1:1" | "4:3" | "3:4" | "3:2" | "2:3" | "21:9" | "9:21"> - | null - readonly "supported_durations": ReadonlyArray | null - readonly "supported_frame_images": ReadonlyArray<"first_frame" | "last_frame"> | null - readonly "supported_resolutions": ReadonlyArray<"480p" | "720p" | "1080p" | "1K" | "2K" | "4K"> | null - readonly "supported_sizes": - | ReadonlyArray< - | "480x480" - | "480x640" - | "480x720" - | "480x854" - | "480x1120" - | "640x480" - | "720x480" - | "720x720" - | "720x960" - | "720x1080" - | "720x1280" - | "720x1680" - | "854x480" - | "960x720" - | "1080x720" - | "1080x1080" - | "1080x1440" - | "1080x1620" - | "1080x1920" - | "1080x2520" - | "1120x480" - | "1280x720" - | "1440x1080" - | "1620x1080" - | "1680x720" - | "1920x1080" - | "2160x2160" - | "2160x2880" - | "2160x3240" - | "2160x3840" - | "2160x5040" - | "2520x1080" - | "2880x2160" - | "3240x2160" - | "3840x2160" - | "5040x2160" - > - | null -} -export const VideoModel = Schema.Struct({ - "allowed_passthrough_parameters": Schema.Array(Schema.String).annotate({ - "description": "List of parameters that are allowed to be passed through to the provider" - }), - "canonical_slug": Schema.String.annotate({ "description": "Canonical slug for the model" }), - "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "description": Schema.optionalKey(Schema.String.annotate({ "description": "Description of the model" })), - "generate_audio": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": "Whether the model supports generating audio alongside video" - }), - "hugging_face_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Hugging Face model identifier, if applicable" - }) - ), - "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), - "name": Schema.String.annotate({ "description": "Display name of the model" }), - "pricing_skus": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]).annotate({ - "description": "Pricing SKUs with provider prefix stripped, values as strings" - }) - ), - "seed": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": "Whether the model supports deterministic generation via seed parameter" - }), - "supported_aspect_ratios": Schema.Union([ - Schema.Array(Schema.Literals(["16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9", "9:21"])), - Schema.Null - ]).annotate({ "description": "Supported output aspect ratios" }), - "supported_durations": Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - Schema.Null - ]).annotate({ "description": "Supported video durations in seconds" }), - "supported_frame_images": Schema.Union([Schema.Array(Schema.Literals(["first_frame", "last_frame"])), Schema.Null]) - .annotate({ "description": "Supported frame image types (e.g. first_frame, last_frame)" }), - "supported_resolutions": Schema.Union([ - Schema.Array(Schema.Literals(["480p", "720p", "1080p", "1K", "2K", "4K"])), - Schema.Null - ]).annotate({ "description": "Supported output resolutions" }), - "supported_sizes": Schema.Union([ - Schema.Array( - Schema.Literals([ - "480x480", - "480x640", - "480x720", - "480x854", - "480x1120", - "640x480", - "720x480", - "720x720", - "720x960", - "720x1080", - "720x1280", - "720x1680", - "854x480", - "960x720", - "1080x720", - "1080x1080", - "1080x1440", - "1080x1620", - "1080x1920", - "1080x2520", - "1120x480", - "1280x720", - "1440x1080", - "1620x1080", - "1680x720", - "1920x1080", - "2160x2160", - "2160x2880", - "2160x3240", - "2160x3840", - "2160x5040", - "2520x1080", - "2880x2160", - "3240x2160", - "3840x2160", - "5040x2160" - ]) - ), - Schema.Null - ]).annotate({ "description": "Supported output sizes (width x height)" }) -}).annotate({ "identifier": "VideoModel" }) -export type WebFetchEngineEnum = "auto" | "native" | "openrouter" | "exa" | "parallel" | "firecrawl" -export const WebFetchEngineEnum = Schema.Literals(["auto", "native", "openrouter", "exa", "parallel", "firecrawl"]) - .annotate({ - "description": - "Which fetch engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in fetch. \"exa\" uses Exa Contents API. \"openrouter\" uses direct HTTP fetch. \"firecrawl\" uses Firecrawl scrape (requires BYOK). \"parallel\" uses the Parallel extract API.", - "identifier": "WebFetchEngineEnum" - }) -export type WebFetchPlugin = { - readonly "allowed_domains"?: ReadonlyArray - readonly "blocked_domains"?: ReadonlyArray - readonly "id": "web-fetch" - readonly "max_content_tokens"?: number - readonly "max_uses"?: number +}).annotate({ "identifier": "AnthropicWebSearchResult" }) +export type AnthropicWebSearchToolResultError = { + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "max_uses_exceeded" + | "too_many_requests" + | "query_too_long" + | "request_too_large" + readonly "type": "web_search_tool_result_error" } -export const WebFetchPlugin = Schema.Struct({ - "allowed_domains": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ "description": "Only fetch from these domains." }) - ), - "blocked_domains": Schema.optionalKey( - Schema.Array(Schema.String).annotate({ "description": "Never fetch from these domains." }) - ), - "id": Schema.Literal("web-fetch"), - "max_content_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Maximum content length in approximate tokens. Content exceeding this limit is truncated." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ), - "max_uses": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Maximum number of web fetches per request. Once exceeded, the tool returns an error." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ) -}).annotate({ "identifier": "WebFetchPlugin" }) -export type Arrays_13 = ReadonlyArray -export const Arrays_13 = Schema.Array(Schema.String).annotate({ "description": "Only fetch from these domains." }) -export type Arrays_14 = ReadonlyArray -export const Arrays_14 = Schema.Array(Schema.String).annotate({ "description": "Never fetch from these domains." }) -export type WebSearchCallCompletedEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.web_search_call.completed" +export const AnthropicWebSearchToolResultError = Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "max_uses_exceeded", + "too_many_requests", + "query_too_long", + "request_too_large" + ]), + "type": Schema.Literal("web_search_tool_result_error") +}).annotate({ "identifier": "AnthropicWebSearchToolResultError" }) +export type AnthropicWebFetchToolResultError = { + 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": "web_fetch_tool_result_error" } -export const WebSearchCallCompletedEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.web_search_call.completed") -}).annotate({ "description": "Web search call completed", "identifier": "WebSearchCallCompletedEvent" }) -export type WebSearchCallInProgressEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.web_search_call.in_progress" +export const AnthropicWebFetchToolResultError = Schema.Struct({ + "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" + ]), + "type": Schema.Literal("web_fetch_tool_result_error") +}).annotate({ "identifier": "AnthropicWebFetchToolResultError" }) +export type AnthropicCitationsConfig = { readonly "enabled": boolean; readonly [x: string]: Schema.Json } | null +export const AnthropicCitationsConfig = Schema.Union([ + Schema.StructWithRest(Schema.Struct({ "enabled": Schema.Boolean }), [ + Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) + ]), + Schema.Null +]).annotate({ "identifier": "AnthropicCitationsConfig" }) +export type AnthropicServerToolErrorCode = + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" +export const AnthropicServerToolErrorCode = Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded" +]).annotate({ "identifier": "AnthropicServerToolErrorCode" }) +export type AnthropicCodeExecutionOutput = { readonly "file_id": string; readonly "type": "code_execution_output" } +export const AnthropicCodeExecutionOutput = Schema.Struct({ + "file_id": Schema.String, + "type": Schema.Literal("code_execution_output") +}).annotate({ "identifier": "AnthropicCodeExecutionOutput" }) +export type AnthropicBashCodeExecutionToolResultError = { + 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" } -export const WebSearchCallInProgressEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.web_search_call.in_progress") -}).annotate({ "description": "Web search call in progress", "identifier": "WebSearchCallInProgressEvent" }) -export type WebSearchCallSearchingEvent = { - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.web_search_call.searching" +export const AnthropicBashCodeExecutionToolResultError = 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") +}).annotate({ "identifier": "AnthropicBashCodeExecutionToolResultError" }) +export type AnthropicBashCodeExecutionOutput = { + readonly "file_id": string + readonly "type": "bash_code_execution_output" } -export const WebSearchCallSearchingEvent = Schema.Struct({ - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.web_search_call.searching") -}).annotate({ "description": "Web search call is searching", "identifier": "WebSearchCallSearchingEvent" }) -export type Arrays_15 = ReadonlyArray -export const Arrays_15 = Schema.Array(Schema.String).annotate({ - "description": - "Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains." -}) -export type Arrays_16 = ReadonlyArray -export const Arrays_16 = Schema.Array(Schema.String).annotate({ - "description": - "Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, and xAI. Not supported with OpenAI (silently ignored). Cannot be used with allowed_domains." -}) -export type Objects_152 = { - readonly "allowed_domains"?: ReadonlyArray | null - readonly "excluded_domains"?: ReadonlyArray | null - readonly [x: string]: Schema.Json +export const AnthropicBashCodeExecutionOutput = Schema.Struct({ + "file_id": Schema.String, + "type": Schema.Literal("bash_code_execution_output") +}).annotate({ "identifier": "AnthropicBashCodeExecutionOutput" }) +export type AnthropicTextEditorCodeExecutionToolResultError = { + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "too_many_requests" + | "execution_time_exceeded" + | "file_not_found" + readonly "error_message": string | null + readonly "type": "text_editor_code_execution_tool_result_error" } -export const Objects_152 = Schema.StructWithRest( - Schema.Struct({ - "allowed_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), - "excluded_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type WebSearchEngine = "native" | "exa" | "firecrawl" | "parallel" | "perplexity" -export const WebSearchEngine = Schema.Literals(["native", "exa", "firecrawl", "parallel", "perplexity"]).annotate({ - "description": "The search engine to use for web search.", - "identifier": "WebSearchEngine" -}) -export type WebSearchEngineEnum = "native" | "exa" | "parallel" | "firecrawl" | "perplexity" | "auto" -export const WebSearchEngineEnum = Schema.Literals(["native", "exa", "parallel", "firecrawl", "perplexity", "auto"]) - .annotate({ - "description": - "Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API. \"perplexity\" uses the Perplexity Search API (raw ranked results).", - "identifier": "WebSearchEngineEnum" - }) -export type Arrays_17 = ReadonlyArray -export const Arrays_17 = Schema.Array(Schema.String).annotate({ - "description": - "Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains." -}) -export type Arrays_18 = ReadonlyArray -export const Arrays_18 = Schema.Array(Schema.String).annotate({ - "description": - "Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, and xAI. Not supported with OpenAI (silently ignored). Cannot be used with allowed_domains." -}) -export type WebSearchSource = { readonly "type": "url"; readonly "url": string } -export const WebSearchSource = Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }).annotate({ - "identifier": "WebSearchSource" -}) -export type WebSearchStatus = "completed" | "searching" | "in_progress" | "failed" -export const WebSearchStatus = Schema.Literals(["completed", "searching", "in_progress", "failed"]).annotate({ - "identifier": "WebSearchStatus" -}) -export type Objects_153 = { - readonly "city"?: string | null - readonly "country"?: string | null - readonly "region"?: string | null - readonly "timezone"?: string | null - readonly "type"?: "approximate" - readonly [x: string]: Schema.Json +export const AnthropicTextEditorCodeExecutionToolResultError = Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "too_many_requests", + "execution_time_exceeded", + "file_not_found" + ]), + "error_message": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.Literal("text_editor_code_execution_tool_result_error") +}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionToolResultError" }) +export type AnthropicTextEditorCodeExecutionViewResult = { + readonly "content": string + readonly "file_type": "text" | "image" | "pdf" + readonly "num_lines": number | null + readonly "start_line": number | null + readonly "total_lines": number | null + readonly "type": "text_editor_code_execution_view_result" } -export const Objects_153 = Schema.StructWithRest( - Schema.Struct({ - "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.optionalKey(Schema.Literal("approximate")) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type WebSearchUserLocationServerTool = { - readonly "city"?: string | null - readonly "country"?: string | null - readonly "region"?: string | null - readonly "timezone"?: string | null - readonly "type"?: "approximate" +export const AnthropicTextEditorCodeExecutionViewResult = Schema.Struct({ + "content": Schema.String, + "file_type": Schema.Literals(["text", "image", "pdf"]), + "num_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), + "start_line": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), + "total_lines": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "type": Schema.Literal("text_editor_code_execution_view_result") +}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionViewResult" }) +export type AnthropicTextEditorCodeExecutionCreateResult = { + readonly "is_file_update": boolean + readonly "type": "text_editor_code_execution_create_result" } -export const WebSearchUserLocationServerTool = Schema.Struct({ - "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.optionalKey(Schema.Literal("approximate")) -}).annotate({ - "description": "Approximate user location for location-biased results.", - "identifier": "WebSearchUserLocationServerTool" -}) -export type Workspace = { - readonly "created_at": string - readonly "created_by": string | null - readonly "default_guardrail_id": string - readonly "default_image_model": string | null - readonly "default_provider_sort": string | null - readonly "default_text_model": string | null - readonly "description": string | null - readonly "id": string - readonly "io_logging_api_key_ids": ReadonlyArray | null - readonly "io_logging_sampling_rate": number - readonly "is_data_discount_logging_enabled": boolean - readonly "is_observability_broadcast_enabled": boolean - readonly "is_observability_io_logging_enabled": boolean - readonly "name": string - readonly "slug": string - readonly "updated_at": string | null +export const AnthropicTextEditorCodeExecutionCreateResult = Schema.Struct({ + "is_file_update": Schema.Boolean, + "type": Schema.Literal("text_editor_code_execution_create_result") +}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionCreateResult" }) +export type AnthropicTextEditorCodeExecutionStrReplaceResult = { + readonly "lines": ReadonlyArray | null + readonly "new_lines": number | null + readonly "new_start": number | null + readonly "old_lines": number | null + readonly "old_start": number | null + readonly "type": "text_editor_code_execution_str_replace_result" } -export const Workspace = Schema.Struct({ - "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the workspace was created" }), - "created_by": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "User ID of the workspace creator" - }), - "default_guardrail_id": Schema.String.annotate({ - "description": "Deterministic ID of the workspace's implicitly-created default guardrail", - "format": "uuid" - }), - "default_image_model": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Default image model for this workspace" - }), - "default_provider_sort": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Default provider sort preference (price, throughput, latency, exacto)" - }), - "default_text_model": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Default text model for this workspace" - }), - "description": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Description of the workspace" }), - "id": Schema.String.annotate({ "description": "Unique identifier for the workspace", "format": "uuid" }), - "io_logging_api_key_ids": Schema.Union([ - Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - Schema.Null - ]).annotate({ - "description": "Optional array of API key IDs to filter I/O logging. Null means all keys are logged." - }), - "io_logging_sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for I/O logging (0.0001-1). 1 means 100% of requests are logged.", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "is_data_discount_logging_enabled": Schema.Boolean.annotate({ - "description": "Whether data discount logging is enabled for this workspace" - }), - "is_observability_broadcast_enabled": Schema.Boolean.annotate({ - "description": "Whether broadcast is enabled for this workspace" - }), - "is_observability_io_logging_enabled": Schema.Boolean.annotate({ - "description": "Whether private logging is enabled for this workspace" - }), - "name": Schema.String.annotate({ "description": "Name of the workspace" }), - "slug": Schema.String.annotate({ "description": "URL-friendly slug for the workspace" }), - "updated_at": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "ISO 8601 timestamp of when the workspace was last updated" - }) -}).annotate({ "identifier": "Workspace" }) -export type WorkspaceBudget = { - readonly "created_at": string - readonly "id": string - readonly "limit_usd": number - readonly "reset_interval": "daily" | "weekly" | "monthly" | null - readonly "updated_at": string - readonly "workspace_id": string +export const AnthropicTextEditorCodeExecutionStrReplaceResult = Schema.Struct({ + "lines": Schema.Union([Schema.Array(Schema.String), Schema.Null]), + "new_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), + "new_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), + "old_lines": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), + "old_start": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]), + "type": Schema.Literal("text_editor_code_execution_str_replace_result") +}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionStrReplaceResult" }) +export type AnthropicToolReference = { readonly "tool_name": string; readonly "type": "tool_reference" } +export const AnthropicToolReference = Schema.Struct({ + "tool_name": Schema.String, + "type": Schema.Literal("tool_reference") +}).annotate({ "identifier": "AnthropicToolReference" }) +export type AnthropicContainerUpload = { readonly "file_id": string; readonly "type": "container_upload" } +export const AnthropicContainerUpload = Schema.Struct({ + "file_id": Schema.String, + "type": Schema.Literal("container_upload") +}).annotate({ "identifier": "AnthropicContainerUpload" }) +export type AnthropicCompactionBlock = { + readonly "content": string | null + readonly "encrypted_content"?: string | null + readonly "type": "compaction" } -export const WorkspaceBudget = Schema.Struct({ - "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the budget was created" }), - "id": Schema.String.annotate({ "description": "Unique identifier for the budget", "format": "uuid" }), - "limit_usd": Schema.Number.annotate({ "description": "Spending limit in USD for this interval", "format": "double" }) - .check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "reset_interval": Schema.Union([ - Schema.Literal("daily"), - Schema.Literal("weekly"), - Schema.Literal("monthly"), - Schema.Null - ]).annotate({ "description": "Interval at which spend resets. Null means a lifetime (one-time) budget." }), - "updated_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the budget was last updated" }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace the budget belongs to", - "format": "uuid" - }) -}).annotate({ "identifier": "WorkspaceBudget" }) -export type WorkspaceBudgetInterval = "daily" | "weekly" | "monthly" | "lifetime" -export const WorkspaceBudgetInterval = Schema.Literals(["daily", "weekly", "monthly", "lifetime"]).annotate({ - "description": "Budget reset interval. Use \"lifetime\" for a one-time budget that never resets.", - "identifier": "WorkspaceBudgetInterval" -}) -export type WorkspaceMember = { - readonly "created_at": string - readonly "id": string - readonly "role": "admin" | "member" - readonly "user_id": string - readonly "workspace_id": string +export const AnthropicCompactionBlock = Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Null]), + "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("compaction") +}).annotate({ "identifier": "AnthropicCompactionBlock" }) +export type AnthropicAdvisorToolResult = { + readonly "content": {} + readonly "tool_use_id": string + readonly "type": "advisor_tool_result" } -export const WorkspaceMember = Schema.Struct({ - "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the membership was created" }), - "id": Schema.String.annotate({ "description": "Unique identifier for the workspace membership", "format": "uuid" }), - "role": Schema.Literals(["admin", "member"]).annotate({ "description": "Role of the member in the workspace" }), - "user_id": Schema.String.annotate({ "description": "Clerk user ID of the member" }), - "workspace_id": Schema.String.annotate({ "description": "ID of the workspace", "format": "uuid" }) -}).annotate({ "identifier": "WorkspaceMember" }) -export type ActivityResponse = { readonly "data": ReadonlyArray } -export const ActivityResponse = Schema.Struct({ - "data": Schema.Array(ActivityItem).annotate({ "description": "List of activity items" }) -}).annotate({ "identifier": "ActivityResponse" }) -export type Arrays_ = ReadonlyArray -export const Arrays_ = Schema.Array(AdvisorNestedTool).annotate({ - "description": - "Tools the advisor sub-agent may use while forming its advice. The advisor runs as an agentic sub-agent over these tools, then returns its text. Only OpenRouter server tools are supported — function tools are rejected — and the list must not include the advisor tool itself." -}) -export type AnthropicBashCodeExecutionResult = { - readonly "content": ReadonlyArray - readonly "return_code": number - readonly "stderr": string - readonly "stdout": string - readonly "type": "bash_code_execution_result" +export const AnthropicAdvisorToolResult = Schema.Struct({ + "content": Schema.Struct({}), + "tool_use_id": Schema.String, + "type": Schema.Literal("advisor_tool_result") +}).annotate({ "identifier": "AnthropicAdvisorToolResult" }) +export type ORAnthropicShellToolResult = { + readonly "content": {} + readonly "tool_use_id": string + readonly "type": "openrouter_shell_tool_result" } -export const AnthropicBashCodeExecutionResult = Schema.Struct({ - "content": Schema.Array(AnthropicBashCodeExecutionOutput), - "return_code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "stderr": Schema.String, - "stdout": Schema.String, - "type": Schema.Literal("bash_code_execution_result") -}).annotate({ "identifier": "AnthropicBashCodeExecutionResult" }) -export type AnthropicCacheControlDirective = { readonly "ttl"?: AnthropicCacheControlTtl; readonly "type": "ephemeral" } -export const AnthropicCacheControlDirective = Schema.Struct({ - "ttl": Schema.optionalKey(AnthropicCacheControlTtl), - "type": Schema.Literal("ephemeral") +export const ORAnthropicShellToolResult = Schema.Struct({ + "content": Schema.Struct({}), + "tool_use_id": Schema.String, + "type": Schema.Literal("openrouter_shell_tool_result") }).annotate({ - "description": - "Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.", - "identifier": "AnthropicCacheControlDirective" + "description": "Output of an `openrouter:shell` call executed in the OpenRouter sandbox", + "identifier": "ORAnthropicShellToolResult" }) -export type ChatContentCacheControl = { readonly "ttl"?: AnthropicCacheControlTtl; readonly "type": "ephemeral" } -export const ChatContentCacheControl = Schema.Struct({ - "ttl": Schema.optionalKey(AnthropicCacheControlTtl), - "type": Schema.Literal("ephemeral") +export type ORAnthropicBashToolResult = { + readonly "content": {} + readonly "tool_use_id": string + readonly "type": "openrouter_bash_tool_result" +} +export const ORAnthropicBashToolResult = Schema.Struct({ + "content": Schema.Struct({}), + "tool_use_id": Schema.String, + "type": Schema.Literal("openrouter_bash_tool_result") }).annotate({ - "description": - "Anthropic-style cache breakpoint for the content part. Interchangeable with the OpenAI-style `prompt_cache_breakpoint` marker: OpenRouter converts between the two based on the provider serving the request.", - "identifier": "ChatContentCacheControl" -}) -export type AnthropicCacheCreation = Objects_ | null -export const AnthropicCacheCreation = Schema.Union([Objects_, Schema.Null]).annotate({ - "identifier": "AnthropicCacheCreation" -}) -export type AnthropicCitationsConfig = Objects_1 | null -export const AnthropicCitationsConfig = Schema.Union([Objects_1, Schema.Null]).annotate({ - "identifier": "AnthropicCitationsConfig" + "description": "Output of an `openrouter:bash` call executed in the OpenRouter sandbox (`engine: 'openrouter'`)", + "identifier": "ORAnthropicBashToolResult" }) -export type AnthropicTextCitation = - | AnthropicCitationCharLocation - | AnthropicCitationPageLocation - | AnthropicCitationContentBlockLocation - | AnthropicCitationWebSearchResultLocation - | AnthropicCitationSearchResultLocation -export const AnthropicTextCitation = Schema.Union([ - AnthropicCitationCharLocation, - AnthropicCitationPageLocation, - AnthropicCitationContentBlockLocation, - AnthropicCitationWebSearchResultLocation, - AnthropicCitationSearchResultLocation -], { mode: "oneOf" }).annotate({ "identifier": "AnthropicTextCitation" }) -export type MessagesContentBlockDeltaEvent = { - readonly "delta": - | { readonly "text": string; readonly "type": "text_delta" } - | { readonly "partial_json": string; readonly "type": "input_json_delta" } - | { readonly "thinking": string; readonly "type": "thinking_delta" } - | { readonly "signature": string; readonly "type": "signature_delta" } - | { - readonly "citation": - | AnthropicCitationCharLocation - | AnthropicCitationPageLocation - | AnthropicCitationContentBlockLocation - | AnthropicCitationWebSearchResultLocation - | AnthropicCitationSearchResultLocation - readonly "type": "citations_delta" - } - | { readonly "content": string | null; readonly "type": "compaction_delta" } - readonly "index": number - readonly "type": "content_block_delta" -} -export const MessagesContentBlockDeltaEvent = Schema.Struct({ - "delta": Schema.Union([ - Schema.Struct({ "text": Schema.String, "type": Schema.Literal("text_delta") }), - Schema.Struct({ "partial_json": Schema.String, "type": Schema.Literal("input_json_delta") }), - Schema.Struct({ "thinking": Schema.String, "type": Schema.Literal("thinking_delta") }), - Schema.Struct({ "signature": Schema.String, "type": Schema.Literal("signature_delta") }), +export type AnthropicRefusalStopDetails = { + readonly "category": "cyber" | "bio" | null + readonly "explanation": string | null + readonly "type": "refusal" + readonly [x: string]: Schema.Json +} | null +export const AnthropicRefusalStopDetails = Schema.Union([ + Schema.StructWithRest( Schema.Struct({ - "citation": Schema.Union([ - AnthropicCitationCharLocation, - AnthropicCitationPageLocation, - AnthropicCitationContentBlockLocation, - AnthropicCitationWebSearchResultLocation, - AnthropicCitationSearchResultLocation - ], { mode: "oneOf" }), - "type": Schema.Literal("citations_delta") + "category": Schema.Union([Schema.Literal("cyber"), Schema.Literal("bio"), Schema.Null]), + "explanation": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.Literal("refusal") }), - Schema.Struct({ "content": Schema.Union([Schema.String, Schema.Null]), "type": Schema.Literal("compaction_delta") }) - ], { mode: "oneOf" }), - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("content_block_delta") -}).annotate({ - "description": "Event sent when content is added to a content block", - "identifier": "MessagesContentBlockDeltaEvent" -}) -export type AnthropicCodeExecutionResult = { - readonly "content": ReadonlyArray - readonly "return_code": number - readonly "stderr": string - readonly "stdout": string - readonly "type": "code_execution_result" -} -export const AnthropicCodeExecutionResult = Schema.Struct({ - "content": Schema.Array(AnthropicCodeExecutionOutput), - "return_code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "stderr": Schema.String, - "stdout": Schema.String, - "type": Schema.Literal("code_execution_result") -}).annotate({ "identifier": "AnthropicCodeExecutionResult" }) -export type AnthropicEncryptedCodeExecutionResult = { - readonly "content": ReadonlyArray - readonly "encrypted_stdout": string - readonly "return_code": number - readonly "stderr": string - readonly "type": "encrypted_code_execution_result" -} -export const AnthropicEncryptedCodeExecutionResult = Schema.Struct({ - "content": Schema.Array(AnthropicCodeExecutionOutput), - "encrypted_stdout": Schema.String, - "return_code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "stderr": Schema.String, - "type": Schema.Literal("encrypted_code_execution_result") -}).annotate({ "identifier": "AnthropicEncryptedCodeExecutionResult" }) -export type AnthropicCaller = - | AnthropicDirectCaller - | AnthropicCodeExecution20250825Caller - | AnthropicCodeExecution20260120Caller -export const AnthropicCaller = Schema.Union([ - AnthropicDirectCaller, - AnthropicCodeExecution20250825Caller, - AnthropicCodeExecution20260120Caller -], { mode: "oneOf" }).annotate({ "identifier": "AnthropicCaller" }) -export type ORAnthropicNullableCaller = - | AnthropicDirectCaller - | AnthropicCodeExecution20250825Caller - | AnthropicCodeExecution20260120Caller - | null -export const ORAnthropicNullableCaller = Schema.Union([ - AnthropicDirectCaller, - AnthropicCodeExecution20250825Caller, - AnthropicCodeExecution20260120Caller, + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), Schema.Null -], { mode: "oneOf" }).annotate({ "identifier": "ORAnthropicNullableCaller" }) -export type AnthropicBase64ImageSource = { - readonly "data": string - readonly "media_type": AnthropicImageMimeType - readonly "type": "base64" +]).annotate({ "description": "Structured information about a refusal", "identifier": "AnthropicRefusalStopDetails" }) +export type ORAnthropicStopReason = + | "end_turn" + | "max_tokens" + | "model_context_window_exceeded" + | "stop_sequence" + | "tool_use" + | "pause_turn" + | "refusal" + | "compaction" + | null +export const ORAnthropicStopReason = Schema.Union([ + Schema.Literal("end_turn"), + Schema.Literal("max_tokens"), + Schema.Literal("model_context_window_exceeded"), + Schema.Literal("stop_sequence"), + Schema.Literal("tool_use"), + Schema.Literal("pause_turn"), + Schema.Literal("refusal"), + Schema.Literal("compaction"), + Schema.Null +]).annotate({ "identifier": "ORAnthropicStopReason" }) +export type AnthropicOutputTokensDetails = + | { readonly "thinking_tokens": number; readonly [x: string]: Schema.Json } + | null +export const AnthropicOutputTokensDetails = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ "thinking_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "identifier": "AnthropicOutputTokensDetails" }) +export type AnthropicServerToolUsage = { + readonly "web_fetch_requests": number + readonly "web_search_requests": number + readonly [x: string]: Schema.Json +} | null +export const AnthropicServerToolUsage = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "web_fetch_requests": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "web_search_requests": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "identifier": "AnthropicServerToolUsage" }) +export type AnthropicServiceTier = "standard" | "priority" | "batch" | null +export const AnthropicServiceTier = Schema.Union([ + Schema.Literal("standard"), + Schema.Literal("priority"), + Schema.Literal("batch"), + Schema.Null +]).annotate({ "identifier": "AnthropicServiceTier" }) +export type MessagesContentBlockStopEvent = { readonly "index": number; readonly "type": "content_block_stop" } +export const MessagesContentBlockStopEvent = Schema.Struct({ + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("content_block_stop") +}).annotate({ + "description": "Event sent when a content block is complete", + "identifier": "MessagesContentBlockStopEvent" +}) +export type MessagesPingEvent = { readonly "type": "ping" } +export const MessagesPingEvent = Schema.Struct({ "type": Schema.Literal("ping") }).annotate({ + "description": "Keep-alive ping event", + "identifier": "MessagesPingEvent" +}) +export type ModelsCountResponse = { readonly "data": { readonly "count": number } } +export const ModelsCountResponse = Schema.Struct({ + "data": Schema.Struct({ + "count": Schema.Number.annotate({ "description": "Total number of available models" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }).annotate({ "description": "Model count data" }) +}).annotate({ "description": "Model count data", "identifier": "ModelsCountResponse" }) +export type ObservabilityFilterRuleGroup = { + readonly "logic"?: "and" | "or" + readonly "rules": ReadonlyArray< + { + readonly "field": + | "model" + | "provider" + | "session_id" + | "user_id" + | "api_key_name" + | "finish_reason" + | "input" + | "output" + | "total_cost" + | "total_tokens" + | "prompt_tokens" + | "completion_tokens" + readonly "operator": + | "equals" + | "not_equals" + | "contains" + | "not_contains" + | "regex" + | "starts_with" + | "ends_with" + | "gt" + | "lt" + | "gte" + | "lte" + | "exists" + | "not_exists" + readonly "value"?: string | number + } + > } -export const AnthropicBase64ImageSource = Schema.Struct({ - "data": Schema.String, - "media_type": AnthropicImageMimeType, - "type": Schema.Literal("base64") -}).annotate({ "identifier": "AnthropicBase64ImageSource" }) -export type AnthropicInputTokensClearAtLeast = Objects_2 | null -export const AnthropicInputTokensClearAtLeast = Schema.Union([Objects_2, Schema.Null]).annotate({ - "identifier": "AnthropicInputTokensClearAtLeast" +export const ObservabilityFilterRuleGroup = Schema.Struct({ + "logic": Schema.optionalKey(Schema.Literals(["and", "or"])), + "rules": Schema.Array(Schema.Struct({ + "field": Schema.Literals([ + "model", + "provider", + "session_id", + "user_id", + "api_key_name", + "finish_reason", + "input", + "output", + "total_cost", + "total_tokens", + "prompt_tokens", + "completion_tokens" + ]), + "operator": Schema.Literals([ + "equals", + "not_equals", + "contains", + "not_contains", + "regex", + "starts_with", + "ends_with", + "gt", + "lt", + "gte", + "lte", + "exists", + "not_exists" + ]), + "value": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))]) + ) + })) +}).annotate({ "identifier": "ObservabilityFilterRuleGroup" }) +export type DeleteObservabilityDestinationResponse = { readonly "deleted": true } +export const DeleteObservabilityDestinationResponse = Schema.Struct({ + "deleted": Schema.Literal(true).annotate({ "description": "Always `true` on success." }) +}).annotate({ "identifier": "DeleteObservabilityDestinationResponse" }) +export type PresetStatus = "active" | "disabled" | "archived" +export const PresetStatus = Schema.Literals(["active", "disabled", "archived"]).annotate({ + "description": "The status of a preset.", + "identifier": "PresetStatus" }) -export type AnthropicIterationCacheCreation = Objects_3 | null -export const AnthropicIterationCacheCreation = Schema.Union([Objects_3, Schema.Null]).annotate({ - "identifier": "AnthropicIterationCacheCreation" +export type PresetDesignatedVersion = { + readonly "config": {} + readonly "created_at": string + readonly "creator_id": string + readonly "id": string + readonly "preset_id": string + readonly "system_prompt": string | null + readonly "updated_at": string + readonly "version": number + readonly [x: string]: Schema.Json +} | null +export const PresetDesignatedVersion = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "config": Schema.Struct({}), + "created_at": Schema.String, + "creator_id": Schema.String, + "id": Schema.String, + "preset_id": Schema.String, + "system_prompt": Schema.Union([Schema.String, Schema.Null]), + "updated_at": Schema.String, + "version": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ + "description": "A specific version of a preset, containing config and optional system prompt.", + "identifier": "PresetDesignatedVersion" }) -export type AnthropicCodeExecutionToolResultError = { - readonly "error_code": AnthropicServerToolErrorCode - readonly "type": "code_execution_tool_result_error" +export type ResponseIncludesEnum = + | "file_search_call.results" + | "message.input_image.image_url" + | "computer_call_output.output.image_url" + | "reasoning.encrypted_content" + | "code_interpreter_call.outputs" +export const ResponseIncludesEnum = Schema.Literals([ + "file_search_call.results", + "message.input_image.image_url", + "computer_call_output.output.image_url", + "reasoning.encrypted_content", + "code_interpreter_call.outputs" +]).annotate({ "identifier": "ResponseIncludesEnum" }) +export type ReasoningSummaryText = { readonly "text": string; readonly "type": "summary_text" } +export const ReasoningSummaryText = Schema.Struct({ "text": Schema.String, "type": Schema.Literal("summary_text") }) + .annotate({ "identifier": "ReasoningSummaryText" }) +export type InputFile = { + readonly "file_data"?: string + readonly "file_id"?: string | null + readonly "file_url"?: string + readonly "filename"?: string + readonly "type": "input_file" } -export const AnthropicCodeExecutionToolResultError = Schema.Struct({ - "error_code": AnthropicServerToolErrorCode, - "type": Schema.Literal("code_execution_tool_result_error") -}).annotate({ "identifier": "AnthropicCodeExecutionToolResultError" }) -export type AnthropicToolSearchResultError = { - readonly "error_code": AnthropicServerToolErrorCode - readonly "error_message": string | null - readonly "type": "tool_search_tool_result_error" +export const InputFile = Schema.Struct({ + "file_data": Schema.optionalKey(Schema.String), + "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "file_url": Schema.optionalKey(Schema.String), + "filename": Schema.optionalKey(Schema.String), + "type": Schema.Literal("input_file") +}).annotate({ "description": "File input content item", "identifier": "InputFile" }) +export type InputAudio = { + readonly "input_audio": { readonly "data": string; readonly "format": "mp3" | "wav" } + readonly "type": "input_audio" } -export const AnthropicToolSearchResultError = Schema.Struct({ - "error_code": AnthropicServerToolErrorCode, - "error_message": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("tool_search_tool_result_error") -}).annotate({ "identifier": "AnthropicToolSearchResultError" }) -export type AnthropicTextEditorCodeExecutionContent = - | AnthropicTextEditorCodeExecutionToolResultError - | AnthropicTextEditorCodeExecutionViewResult - | AnthropicTextEditorCodeExecutionCreateResult - | AnthropicTextEditorCodeExecutionStrReplaceResult -export const AnthropicTextEditorCodeExecutionContent = Schema.Union([ - AnthropicTextEditorCodeExecutionToolResultError, - AnthropicTextEditorCodeExecutionViewResult, - AnthropicTextEditorCodeExecutionCreateResult, - AnthropicTextEditorCodeExecutionStrReplaceResult -], { mode: "oneOf" }).annotate({ "identifier": "AnthropicTextEditorCodeExecutionContent" }) -export type AnthropicToolSearchResult = { - readonly "tool_references": ReadonlyArray - readonly "type": "tool_search_tool_search_result" +export const InputAudio = Schema.Struct({ + "input_audio": Schema.Struct({ "data": Schema.String, "format": Schema.Literals(["mp3", "wav"]) }), + "type": Schema.Literal("input_audio") +}).annotate({ "description": "Audio input content item", "identifier": "InputAudio" }) +export type InputVideo = { readonly "type": "input_video"; readonly "video_url": string } +export const InputVideo = Schema.Struct({ + "type": Schema.Literal("input_video"), + "video_url": Schema.String.annotate({ + "description": "A base64 data URL or remote URL that resolves to a video file" + }) +}).annotate({ "description": "Video input content item", "identifier": "InputVideo" }) +export type ToolCallStatus = "in_progress" | "completed" | "incomplete" +export const ToolCallStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "identifier": "ToolCallStatus" +}) +export type ApplyPatchCreateFileOperation = { + readonly "diff": string + readonly "path": string + readonly "type": "create_file" } -export const AnthropicToolSearchResult = Schema.Struct({ - "tool_references": Schema.Array(AnthropicToolReference), - "type": Schema.Literal("tool_search_tool_search_result") -}).annotate({ "identifier": "AnthropicToolSearchResult" }) -export type AnthropicWebSearchToolUserLocation = Objects_4 | null -export const AnthropicWebSearchToolUserLocation = Schema.Union([Objects_4, Schema.Null]).annotate({ - "identifier": "AnthropicWebSearchToolUserLocation" +export const ApplyPatchCreateFileOperation = Schema.Struct({ + "diff": Schema.String, + "path": Schema.String, + "type": Schema.Literal("create_file") +}).annotate({ + "description": + "The `create_file` variant of an `apply_patch_call.operation`. Carries a V4A diff describing the new file contents.", + "identifier": "ApplyPatchCreateFileOperation" }) -export type MessagesErrorDetail = { - readonly "error_type"?: ApiErrorType - readonly "message": string - readonly "type": string +export type ApplyPatchUpdateFileOperation = { + readonly "diff": string + readonly "path": string + readonly "type": "update_file" } -export const MessagesErrorDetail = Schema.Struct({ - "error_type": Schema.optionalKey(ApiErrorType), - "message": Schema.String, - "type": Schema.String -}).annotate({ "identifier": "MessagesErrorDetail" }) -export type ApplyPatchServerToolConfig = { readonly "engine"?: ApplyPatchEngineEnum } -export const ApplyPatchServerToolConfig = Schema.Struct({ "engine": Schema.optionalKey(ApplyPatchEngineEnum) }) - .annotate({ - "description": "Configuration for the openrouter:apply_patch server tool", - "identifier": "ApplyPatchServerToolConfig" - }) -export type ApplyPatchCallOperation = - | ApplyPatchCreateFileOperation - | ApplyPatchUpdateFileOperation - | ApplyPatchDeleteFileOperation -export const ApplyPatchCallOperation = Schema.Union([ - ApplyPatchCreateFileOperation, - ApplyPatchUpdateFileOperation, - ApplyPatchDeleteFileOperation -], { mode: "oneOf" }).annotate({ +export const ApplyPatchUpdateFileOperation = Schema.Struct({ + "diff": Schema.String, + "path": Schema.String, + "type": Schema.Literal("update_file") +}).annotate({ "description": - "The patch operation requested by an `apply_patch_call`. `create_file` and `update_file` carry a V4A diff; `delete_file` omits it.", - "identifier": "ApplyPatchCallOperation" + "The `update_file` variant of an `apply_patch_call.operation`. Carries a V4A diff describing edits to an existing file.", + "identifier": "ApplyPatchUpdateFileOperation" +}) +export type ApplyPatchDeleteFileOperation = { readonly "path": string; readonly "type": "delete_file" } +export const ApplyPatchDeleteFileOperation = Schema.Struct({ + "path": Schema.String, + "type": Schema.Literal("delete_file") +}).annotate({ + "description": + "The `delete_file` variant of an `apply_patch_call.operation`. Identifies the file to remove; no diff is required.", + "identifier": "ApplyPatchDeleteFileOperation" +}) +export type ApplyPatchCallStatus = "in_progress" | "completed" +export const ApplyPatchCallStatus = Schema.Literals(["in_progress", "completed"]).annotate({ + "description": "Lifecycle state of an `apply_patch_call` output item.", + "identifier": "ApplyPatchCallStatus" }) -export type OutputItemApplyPatchCall = { +export type ApplyPatchCallOutputItem = { readonly "call_id": string - readonly "created_by"?: string - readonly "id": string - readonly "operation": ApplyPatchCreateFileOperation | ApplyPatchUpdateFileOperation | ApplyPatchDeleteFileOperation - readonly "status": "in_progress" | "completed" - readonly "type": "apply_patch_call" + readonly "id"?: string | null + readonly "output"?: string | null + readonly "status": "completed" | "failed" + readonly "type": "apply_patch_call_output" } -export const OutputItemApplyPatchCall = Schema.Struct({ +export const ApplyPatchCallOutputItem = Schema.Struct({ "call_id": Schema.String, - "created_by": Schema.optionalKey(Schema.String), - "id": Schema.String, - "operation": Schema.Union([ - ApplyPatchCreateFileOperation, - ApplyPatchUpdateFileOperation, - ApplyPatchDeleteFileOperation - ], { mode: "oneOf" }), - "status": Schema.Literals(["in_progress", "completed"]), - "type": Schema.Literal("apply_patch_call") -}).annotate({ "identifier": "OutputItemApplyPatchCall" }) -export type BadGatewayResponse = { - readonly "error": BadGatewayResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "output": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "status": Schema.Literals(["completed", "failed"]), + "type": Schema.Literal("apply_patch_call_output") +}).annotate({ + "description": + "The client's echo of an `apply_patch_call` after applying the patch. `output` is an optional human-readable log; `status` is `completed` when the patch was applied successfully, `failed` otherwise.", + "identifier": "ApplyPatchCallOutputItem" +}) +export type FileCitation = { + readonly "file_id": string + readonly "filename": string + readonly "index": number + readonly "type": "file_citation" } -export const BadGatewayResponse = Schema.Struct({ - "error": BadGatewayResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) +export const FileCitation = Schema.Struct({ + "file_id": Schema.String, + "filename": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("file_citation") +}).annotate({ "identifier": "FileCitation" }) +export type URLCitation = { + readonly "content"?: string + readonly "end_index": number + readonly "start_index": number + readonly "title": string + readonly "type": "url_citation" + readonly "url": string +} +export const URLCitation = Schema.Struct({ + "content": Schema.optionalKey(Schema.String), + "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "title": Schema.String, + "type": Schema.Literal("url_citation"), + "url": Schema.String +}).annotate({ "identifier": "URLCitation" }) +export type FilePath = { readonly "file_id": string; readonly "index": number; readonly "type": "file_path" } +export const FilePath = Schema.Struct({ + "file_id": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("file_path") +}).annotate({ "identifier": "FilePath" }) +export type OutputFunctionCallItem = { + readonly "arguments": string + readonly "call_id": string + readonly "id"?: string + readonly "name": string + readonly "namespace"?: string + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "type": "function_call" +} +export const OutputFunctionCallItem = Schema.Struct({ + "arguments": Schema.String, + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.String), + "name": Schema.String, + "namespace": Schema.optionalKey( + Schema.String.annotate({ + "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" + }) ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ "description": "Bad Gateway - Provider/upstream API failure", "identifier": "BadGatewayResponse" }) -export type BadRequestResponse = { - readonly "error": BadRequestResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "type": Schema.Literal("function_call") +}).annotate({ "identifier": "OutputFunctionCallItem" }) +export type OutputCustomToolCallItem = { + readonly "call_id": string + readonly "id"?: string + readonly "input": string + readonly "name": string + readonly "namespace"?: string + readonly "type": "custom_tool_call" } -export const BadRequestResponse = Schema.Struct({ - "error": BadRequestResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) +export const OutputCustomToolCallItem = Schema.Struct({ + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.String), + "input": Schema.String, + "name": Schema.String, + "namespace": Schema.optionalKey( + Schema.String.annotate({ + "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" + }) ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + "type": Schema.Literal("custom_tool_call") }).annotate({ - "description": "Bad Request - Invalid request parameters or malformed input", - "identifier": "BadRequestResponse" + "description": + "A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI's `apply_patch` whose payload is opaque text rather than JSON arguments.", + "identifier": "OutputCustomToolCallItem" }) -export type BYOKKey = { - readonly "allowed_api_key_hashes": ReadonlyArray | null - readonly "allowed_models": ReadonlyArray | null - readonly "allowed_user_ids": ReadonlyArray | null - readonly "created_at": string - readonly "disabled": boolean - readonly "id": string - readonly "is_fallback": boolean - readonly "label": string - readonly "name"?: string | null - readonly "provider": BYOKProviderSlug - readonly "sort_order": number - readonly "workspace_id": string +export type WebSearchSource = { readonly "type": "url"; readonly "url": string } +export const WebSearchSource = Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String }).annotate({ + "identifier": "WebSearchSource" +}) +export type WebSearchStatus = "completed" | "searching" | "in_progress" | "failed" +export const WebSearchStatus = Schema.Literals(["completed", "searching", "in_progress", "failed"]).annotate({ + "identifier": "WebSearchStatus" +}) +export type ImageGenerationStatus = "in_progress" | "completed" | "generating" | "failed" +export const ImageGenerationStatus = Schema.Literals(["in_progress", "completed", "generating", "failed"]).annotate({ + "identifier": "ImageGenerationStatus" +}) +export type OutputComputerCallItem = { + readonly "action"?: Schema.Json + readonly "call_id": string + readonly "id"?: string + readonly "pending_safety_checks": ReadonlyArray< + { readonly "code": string; readonly "id": string; readonly "message": string } + > + readonly "status": "completed" | "incomplete" | "in_progress" + readonly "type": "computer_call" } -export const BYOKKey = Schema.Struct({ - "allowed_api_key_hashes": Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) - ), - Schema.Null - ]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction." - }), - "allowed_models": Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) - ), - Schema.Null - ]).annotate({ - "description": "Optional allowlist of model slugs this credential may be used for. `null` means no restriction." - }), - "allowed_user_ids": Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) - ), - Schema.Null - ]).annotate({ - "description": "Optional allowlist of user IDs that may use this credential. `null` means no restriction." - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the credential was created." }), - "disabled": Schema.Boolean.annotate({ "description": "Whether this credential is currently disabled." }), - "id": Schema.String.annotate({ - "description": "Stable public identifier for this BYOK credential.", - "format": "uuid" - }), - "is_fallback": Schema.Boolean.annotate({ - "description": - "Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried." - }), - "label": Schema.String.annotate({ - "description": "Short masked snippet of the key (e.g. the first/last few characters) used to identify it in the UI." - }), - "name": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Optional human-readable name for the credential." - }) +export const OutputComputerCallItem = Schema.Struct({ + "action": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.String), + "pending_safety_checks": Schema.Array( + Schema.Struct({ "code": Schema.String, "id": Schema.String, "message": Schema.String }) ), - "provider": BYOKProviderSlug, - "sort_order": Schema.Number.annotate({ - "description": "Position within the provider — credentials are tried in ascending sort order." - }).check(Schema.isInt().annotate({ "expected": "an integer" })), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this credential belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "BYOKKey" }) -export type CreateBYOKKeyRequest = { - readonly "allowed_models"?: ReadonlyArray | null - readonly "allowed_user_ids"?: ReadonlyArray | null - readonly "disabled"?: boolean - readonly "is_fallback"?: boolean - readonly "key": string - readonly "name"?: string | null - readonly "provider": BYOKProviderSlug - readonly "workspace_id"?: string + "status": Schema.Literals(["completed", "incomplete", "in_progress"]), + "type": Schema.Literal("computer_call") +}).annotate({ "identifier": "OutputComputerCallItem" }) +export type FusionAnalysisResult = { + readonly "blind_spots": ReadonlyArray + readonly "consensus": ReadonlyArray + readonly "contradictions": ReadonlyArray< + { + readonly "stances": ReadonlyArray<{ readonly "model": string; readonly "stance": string }> + readonly "topic": string + } + > + readonly "partial_coverage": ReadonlyArray<{ readonly "models": ReadonlyArray; readonly "point": string }> + readonly "unique_insights": ReadonlyArray<{ readonly "insight": string; readonly "model": string }> } -export const CreateBYOKKeyRequest = Schema.Struct({ - "allowed_models": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) - ), - Schema.Null - ]).annotate({ - "description": "Optional allowlist of model slugs this credential may be used for. `null` means no restriction." - }) - ), - "allowed_user_ids": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) - ), - Schema.Null - ]).annotate({ - "description": "Optional allowlist of user IDs that may use this credential. `null` means no restriction." - }) - ), - "disabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether this credential should be created in a disabled state." }) - ), - "is_fallback": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": - "Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried." +export const FusionAnalysisResult = Schema.Struct({ + "blind_spots": Schema.Array(Schema.String), + "consensus": Schema.Array(Schema.String), + "contradictions": Schema.Array( + Schema.Struct({ + "stances": Schema.Array(Schema.Struct({ "model": Schema.String, "stance": Schema.String })), + "topic": Schema.String }) ), - "key": Schema.String.annotate({ - "description": - "The raw provider API key or credential. This value is encrypted at rest and never returned in API responses." - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), - "name": Schema.optionalKey( - Schema.Union([ - Schema.String.check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })), - Schema.Null - ]).annotate({ "description": "Optional human-readable name for the credential." }) - ), - "provider": BYOKProviderSlug, - "workspace_id": Schema.optionalKey( - Schema.String.annotate({ - "description": "Optional workspace ID. Defaults to the authenticated entity's default workspace.", - "format": "uuid" - }) - ) -}).annotate({ "identifier": "CreateBYOKKeyRequest" }) -export type ChatContentVideo = { readonly "type": "video_url"; readonly "video_url": ChatContentVideoInput } -export const ChatContentVideo = Schema.Struct({ - "type": Schema.Literal("video_url"), - "video_url": ChatContentVideoInput -}).annotate({ "description": "Video input content part", "identifier": "ChatContentVideo" }) -export type ChatFormatJsonSchemaConfig = { - readonly "json_schema": ChatJsonSchemaConfig - readonly "type": "json_schema" -} -export const ChatFormatJsonSchemaConfig = Schema.Struct({ - "json_schema": ChatJsonSchemaConfig, - "type": Schema.Literal("json_schema") + "partial_coverage": Schema.Array(Schema.Struct({ "models": Schema.Array(Schema.String), "point": Schema.String })), + "unique_insights": Schema.Array(Schema.Struct({ "insight": Schema.String, "model": Schema.String })) }).annotate({ - "description": "JSON Schema response format for structured outputs", - "identifier": "ChatFormatJsonSchemaConfig" -}) -export type ChatToolChoice = "none" | "auto" | "required" | ChatNamedToolChoice | ChatServerToolChoice -export const ChatToolChoice = Schema.Union([ - Schema.Literal("none"), - Schema.Literal("auto"), - Schema.Literal("required"), - ChatNamedToolChoice, - ChatServerToolChoice -]).annotate({ "description": "Tool choice configuration", "identifier": "ChatToolChoice" }) -export type ChatStreamOptions = Objects_6 | null -export const ChatStreamOptions = Schema.Union([Objects_6, Schema.Null]).annotate({ - "description": "Streaming configuration options", - "identifier": "ChatStreamOptions" + "description": "Structured analysis produced by the fusion analyst model.", + "identifier": "FusionAnalysisResult" }) -export type Objects_7 = { - readonly "content": ReadonlyArray | null - readonly "refusal"?: ReadonlyArray | null - readonly [x: string]: Schema.Json -} -export const Objects_7 = Schema.StructWithRest( - Schema.Struct({ - "content": Schema.Union([Schema.Array(ChatTokenLogprob), Schema.Null]).annotate({ - "description": "Log probabilities for content tokens" - }), - "refusal": Schema.optionalKey( - Schema.Union([Schema.Array(ChatTokenLogprob), Schema.Null]).annotate({ - "description": "Log probabilities for refusal tokens" - }) - ) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type FileSearchServerTool = { - readonly "filters"?: - | { - readonly "key": string - readonly "type": "eq" | "ne" | "gt" | "gte" | "lt" | "lte" - readonly "value": string | number | boolean | ReadonlyArray +export type FusionSource = { readonly "title": string; readonly "url": string } +export const FusionSource = Schema.Struct({ + "title": Schema.String.annotate({ "description": "Title of the retrieved web page." }), + "url": Schema.String.annotate({ + "description": "URL of the web page a panel or the analyst retrieved during the run." + }) +}).annotate({ "description": "A web page retrieved via web search during a fusion run.", "identifier": "FusionSource" }) +export type McpListToolsItem = { + readonly "error"?: string | null + readonly "id": string + readonly "server_label": string + readonly "tools": ReadonlyArray< + { + readonly "annotations"?: Schema.Json + readonly "description"?: string | null + readonly "input_schema": {} + readonly "name": string } - | CompoundFilter - | null - readonly "max_num_results"?: number - readonly "ranking_options"?: { - readonly "ranker"?: "auto" | "default-2024-11-15" - readonly "score_threshold"?: number - } - readonly "type": "file_search" - readonly "vector_store_ids": ReadonlyArray + > + readonly "type": "mcp_list_tools" } -export const FileSearchServerTool = Schema.Struct({ - "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.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - Schema.Boolean, - Schema.Array( - Schema.Union([ - Schema.String, - Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ]) - ) - ]) - }), - CompoundFilter, - Schema.Null - ])), - "max_num_results": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "ranking_options": Schema.optionalKey( +export const McpListToolsItem = Schema.Struct({ + "error": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "id": Schema.String, + "server_label": Schema.String, + "tools": Schema.Array( Schema.Struct({ - "ranker": Schema.optionalKey(Schema.Literals(["auto", "default-2024-11-15"])), - "score_threshold": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ) + "annotations": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), + "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "input_schema": Schema.Struct({}), + "name": Schema.String }) ), - "type": Schema.Literal("file_search"), - "vector_store_ids": Schema.Array(Schema.String) -}).annotate({ "description": "File search tool configuration", "identifier": "FileSearchServerTool" }) -export type ConflictResponse = { - readonly "error": ConflictResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null -} -export const ConflictResponse = Schema.Struct({ - "error": ConflictResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ - "description": "Conflict - Resource conflict or concurrent modification", - "identifier": "ConflictResponse" -}) -export type BashServerToolEnvironment = ContainerAutoEnvironment | ContainerReferenceEnvironment -export const BashServerToolEnvironment = Schema.Union([ContainerAutoEnvironment, ContainerReferenceEnvironment], { - mode: "oneOf" -}).annotate({ - "description": "Execution environment for the bash server tool.", - "identifier": "BashServerToolEnvironment" -}) -export type ShellServerToolEnvironment = ContainerAutoEnvironment | ContainerReferenceEnvironment -export const ShellServerToolEnvironment = Schema.Union([ContainerAutoEnvironment, ContainerReferenceEnvironment], { - mode: "oneOf" -}).annotate({ - "description": - "Server-side execution environment for the shell tool. Only container-backed environments are supported; \"local\" shells are not.", - "identifier": "ShellServerToolEnvironment" -}) -export type ContentFilterEntry = { - readonly "action": ContentFilterAction - readonly "label"?: string | null - readonly "pattern": string + "type": Schema.Literal("mcp_list_tools") +}).annotate({ "description": "List of available MCP tools from a server", "identifier": "McpListToolsItem" }) +export type McpApprovalRequestItem = { + readonly "arguments": string + readonly "id": string + readonly "name": string + readonly "server_label": string + readonly "type": "mcp_approval_request" } -export const ContentFilterEntry = Schema.Struct({ - "action": ContentFilterAction, - "label": Schema.optionalKey( - Schema.Union([ - Schema.String.check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })), - Schema.Null - ]).annotate({ "description": "Optional label used in redaction placeholders or error messages" }) - ), - "pattern": Schema.String.annotate({ "description": "A regex pattern to match against request content" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) -}).annotate({ - "description": "A custom regex content filter that scans request messages for matching patterns.", - "identifier": "ContentFilterEntry" -}) -export type InputReference = ContentPartImage | ContentPartAudio | ContentPartVideo -export const InputReference = Schema.Union([ContentPartImage, ContentPartAudio, ContentPartVideo], { mode: "oneOf" }) - .annotate({ - "description": - "A reference asset used to guide video generation. Image references are supported by all providers; audio and video references are only honored by providers that support them (currently BytePlus Seedance 2.0).", - "identifier": "InputReference" - }) -export type ContextCompressionPlugin = { - readonly "enabled"?: boolean - readonly "engine"?: ContextCompressionEngine - readonly "id": "context-compression" +export const McpApprovalRequestItem = Schema.Struct({ + "arguments": Schema.String, + "id": Schema.String, + "name": Schema.String, + "server_label": Schema.String, + "type": Schema.Literal("mcp_approval_request") +}).annotate({ "description": "Request for approval to execute an MCP tool", "identifier": "McpApprovalRequestItem" }) +export type McpApprovalResponseItem = { + readonly "approval_request_id": string + readonly "approve": boolean + readonly "id"?: string | null + readonly "reason"?: string | null + readonly "type": "mcp_approval_response" } -export const ContextCompressionPlugin = Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the context-compression plugin for this request. Defaults to true." - }) - ), - "engine": Schema.optionalKey(ContextCompressionEngine), - "id": Schema.Literal("context-compression") -}).annotate({ "identifier": "ContextCompressionPlugin" }) -export type CostDetails = Objects_8 | null -export const CostDetails = Schema.Union([Objects_8, Schema.Null]).annotate({ - "description": "Breakdown of upstream inference costs", - "identifier": "CostDetails" -}) -export type Arrays_9 = ReadonlyArray -export const Arrays_9 = Schema.Array(DABenchmarkEntry).annotate({ - "description": "Design Arena ELO rankings across arena+category pairs." -}) -export type DatetimeServerTool = { - readonly "parameters"?: DatetimeServerToolConfig - readonly "type": "openrouter:datetime" +export const McpApprovalResponseItem = Schema.Struct({ + "approval_request_id": Schema.String, + "approve": Schema.Boolean, + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "reason": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("mcp_approval_response") +}).annotate({ "description": "User response to an MCP tool approval request", "identifier": "McpApprovalResponseItem" }) +export type McpCallItem = { + readonly "arguments": string + readonly "error"?: string | null + readonly "id": string + readonly "name": string + readonly "output"?: string | null + readonly "server_label": string + readonly "type": "mcp_call" } -export const DatetimeServerTool = Schema.Struct({ - "parameters": Schema.optionalKey(DatetimeServerToolConfig), - "type": Schema.Literal("openrouter:datetime") -}).annotate({ - "description": "OpenRouter built-in server tool: returns the current date and time", - "identifier": "DatetimeServerTool" -}) -export type EdgeNetworkTimeoutResponse = { - readonly "error": EdgeNetworkTimeoutResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null +export const McpCallItem = Schema.Struct({ + "arguments": Schema.String, + "error": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "id": Schema.String, + "name": Schema.String, + "output": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "server_label": Schema.String, + "type": Schema.Literal("mcp_call") +}).annotate({ "description": "An MCP tool call with its output or error", "identifier": "McpCallItem" }) +export type CustomToolCallItem = { + readonly "call_id": string + readonly "id"?: string + readonly "input": string + readonly "name": string + readonly "namespace"?: string + readonly "type": "custom_tool_call" } -export const EdgeNetworkTimeoutResponse = Schema.Struct({ - "error": EdgeNetworkTimeoutResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) +export const CustomToolCallItem = Schema.Struct({ + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.String), + "input": Schema.String, + "name": Schema.String, + "namespace": Schema.optionalKey( + Schema.String.annotate({ + "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" + }) ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ - "description": "Infrastructure Timeout - Provider request timed out at edge network", - "identifier": "EdgeNetworkTimeoutResponse" -}) -export type EndpointsMetadata = { readonly "available": ReadonlyArray; readonly "total": number } -export const EndpointsMetadata = Schema.Struct({ - "available": Schema.Array(EndpointInfo), - "total": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "identifier": "EndpointsMetadata" }) -export type FileListResponse = { - readonly "cursor": string | null - readonly "data": ReadonlyArray - readonly "first_id": string | null - readonly "has_more": boolean - readonly "last_id": string | null -} -export const FileListResponse = Schema.Struct({ - "cursor": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Opaque cursor for the next page; null when there are no more results." - }), - "data": Schema.Array(FileMetadata), - "first_id": Schema.Union([Schema.String, Schema.Null]), - "has_more": Schema.Boolean, - "last_id": Schema.Union([Schema.String, Schema.Null]) -}).annotate({ - "description": "A page of files belonging to the requesting workspace.", - "identifier": "FileListResponse" -}) -export type FilesServerTool = { readonly "parameters"?: FilesServerToolConfig; readonly "type": "openrouter:files" } -export const FilesServerTool = Schema.Struct({ - "parameters": Schema.optionalKey(FilesServerToolConfig), - "type": Schema.Literal("openrouter:files") + "type": Schema.Literal("custom_tool_call") }).annotate({ "description": - "OpenRouter built-in server tool: read, write, edit, and list workspace files via the Files API. Requires the `x-openrouter-file-ids: openrouter` request header.", - "identifier": "FilesServerTool" + "A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI's `apply_patch` whose payload is opaque text rather than JSON arguments.", + "identifier": "CustomToolCallItem" }) -export type ForbiddenResponse = { - readonly "error": ForbiddenResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null +export type CompactionItem = { + readonly "encrypted_content": string + readonly "id"?: string | null + readonly "type": "compaction" } -export const ForbiddenResponse = Schema.Struct({ - "error": ForbiddenResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ - "description": "Forbidden - Authentication successful but insufficient permissions", - "identifier": "ForbiddenResponse" -}) -export type Formats = FormatTextConfig | FormatJsonObjectConfig | FormatJsonSchemaConfig -export const Formats = Schema.Union([FormatTextConfig, FormatJsonObjectConfig, FormatJsonSchemaConfig]).annotate({ - "description": "Text response format configuration", - "identifier": "Formats" -}) -export type FusionAnalysisResult = { - readonly "blind_spots": Arrays_1 - readonly "consensus": Arrays_2 - readonly "contradictions": Arrays_3 - readonly "partial_coverage": Arrays_4 - readonly "unique_insights": Arrays_5 +export const CompactionItem = Schema.Struct({ + "encrypted_content": Schema.String, + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("compaction") +}).annotate({ "description": "A context compaction marker with encrypted summary", "identifier": "CompactionItem" }) +export type ContextCompactionItem = { + readonly "encrypted_content"?: string | null + readonly "id"?: string | null + readonly "type": "context_compaction" } -export const FusionAnalysisResult = Schema.Struct({ - "blind_spots": Arrays_1, - "consensus": Arrays_2, - "contradictions": Arrays_3, - "partial_coverage": Arrays_4, - "unique_insights": Arrays_5 +export const ContextCompactionItem = Schema.Struct({ + "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("context_compaction") }).annotate({ - "description": "Structured analysis produced by the fusion judge model.", - "identifier": "FusionAnalysisResult" + "description": "A context compaction marker with an optional encrypted summary", + "identifier": "ContextCompactionItem" }) -export type GenerationContentResponse = { readonly "data": GenerationContentData } -export const GenerationContentResponse = Schema.Struct({ "data": GenerationContentData }).annotate({ - "description": "Stored prompt and completion content for a generation", - "identifier": "GenerationContentResponse" +export type ItemReferenceItem = { readonly "id": string; readonly "type": "item_reference" } +export const ItemReferenceItem = Schema.Struct({ "id": Schema.String, "type": Schema.Literal("item_reference") }) + .annotate({ "description": "A reference to a previous response item by ID", "identifier": "ItemReferenceItem" }) +export type WebSearchDomainFilter = { + readonly "allowed_domains"?: ReadonlyArray | null + readonly "blocked_domains"?: ReadonlyArray | null + readonly "excluded_domains"?: ReadonlyArray | null + readonly [x: string]: Schema.Json +} | null +export const WebSearchDomainFilter = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "allowed_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), + "blocked_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), + "excluded_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "identifier": "WebSearchDomainFilter" }) +export type SearchContextSizeEnum = "low" | "medium" | "high" +export const SearchContextSizeEnum = Schema.Literals(["low", "medium", "high"]).annotate({ + "description": "Size of the search context for web search tools", + "identifier": "SearchContextSizeEnum" }) -export type GoneResponse = { - readonly "error": GoneResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null -} -export const GoneResponse = Schema.Struct({ - "error": GoneResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) +export type Preview_WebSearchUserLocation = { + readonly "city"?: string | null + readonly "country"?: string | null + readonly "region"?: string | null + readonly "timezone"?: string | null + readonly "type": "approximate" + readonly [x: string]: Schema.Json +} | null +export const Preview_WebSearchUserLocation = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("approximate") + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + Schema.Null +]).annotate({ "identifier": "Preview_WebSearchUserLocation" }) +export type WebSearchUserLocation = { + readonly "city"?: string | null + readonly "country"?: string | null + readonly "region"?: string | null + readonly "timezone"?: string | null + readonly "type"?: "approximate" + readonly [x: string]: Schema.Json +} | null +export const WebSearchUserLocation = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.optionalKey(Schema.Literal("approximate")) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "description": "User location information for web search", "identifier": "WebSearchUserLocation" }) +export type CompoundFilter = { readonly "filters": ReadonlyArray<{}>; readonly "type": "and" | "or" } +export const CompoundFilter = Schema.Struct({ + "filters": Schema.Array(Schema.Struct({})), + "type": Schema.Literals(["and", "or"]) }).annotate({ - "description": "Gone - Endpoint has been permanently removed or deprecated", - "identifier": "GoneResponse" + "description": "A compound filter that combines multiple comparison or compound filters", + "identifier": "CompoundFilter" }) -export type ImageGenerationServerTool_OpenRouter = { - readonly "parameters"?: ImageGenerationServerToolConfig - readonly "type": "openrouter:image_generation" +export type ComputerUseServerTool = { + readonly "display_height": number + readonly "display_width": number + readonly "environment": "windows" | "mac" | "linux" | "ubuntu" | "browser" + readonly "type": "computer_use_preview" } -export const ImageGenerationServerTool_OpenRouter = Schema.Struct({ - "parameters": Schema.optionalKey(ImageGenerationServerToolConfig), - "type": Schema.Literal("openrouter:image_generation") -}).annotate({ - "description": "OpenRouter built-in server tool: generates images from text prompts using an image generation model", - "identifier": "ImageGenerationServerTool_OpenRouter" -}) -export type OutputImageGenerationCallItem = { - readonly "id": string - readonly "result"?: string | null - readonly "status": ImageGenerationStatus - readonly "type": "image_generation_call" - readonly "prompt"?: string -} -export const OutputImageGenerationCallItem = Schema.Struct({ - "id": Schema.String, - "result": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "status": ImageGenerationStatus, - "type": Schema.Literal("image_generation_call"), - "prompt": Schema.optionalKey( - Schema.String.annotate({ "description": "The prompt (possibly rewritten) that the image was generated from." }) - ) -}).annotate({ "identifier": "OutputImageGenerationCallItem" }) -export type OutputItemImageGenerationCall = { - readonly "id": string - readonly "result"?: string | null - readonly "status": ImageGenerationStatus - readonly "type": "image_generation_call" +export const ComputerUseServerTool = Schema.Struct({ + "display_height": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "display_width": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "environment": Schema.Literals(["windows", "mac", "linux", "ubuntu", "browser"]), + "type": Schema.Literal("computer_use_preview") +}).annotate({ "description": "Computer use preview tool configuration", "identifier": "ComputerUseServerTool" }) +export type CodeInterpreterServerTool = { + readonly "container": string | { + readonly "file_ids"?: ReadonlyArray + readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g" | null + readonly "type": "auto" + } + readonly "type": "code_interpreter" } -export const OutputItemImageGenerationCall = Schema.Struct({ - "id": Schema.String, - "result": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "status": ImageGenerationStatus, - "type": Schema.Literal("image_generation_call") -}).annotate({ "identifier": "OutputItemImageGenerationCall" }) -export type ImageModelArchitecture = { - readonly "input_modalities": ReadonlyArray - readonly "output_modalities": ReadonlyArray +export const CodeInterpreterServerTool = Schema.Struct({ + "container": Schema.Union([ + Schema.String, + Schema.Struct({ + "file_ids": Schema.optionalKey(Schema.Array(Schema.String)), + "memory_limit": Schema.optionalKey( + Schema.Union([ + Schema.Literal("1g"), + Schema.Literal("4g"), + Schema.Literal("16g"), + Schema.Literal("64g"), + Schema.Null + ]) + ), + "type": Schema.Literal("auto") + }) + ]), + "type": Schema.Literal("code_interpreter") +}).annotate({ "description": "Code interpreter tool configuration", "identifier": "CodeInterpreterServerTool" }) +export type McpServerTool = { + readonly "allowed_tools"?: ReadonlyArray | { + readonly "read_only"?: boolean + readonly "tool_names"?: ReadonlyArray + } | null + 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 [x: string]: string } | null + readonly "require_approval"?: + | { + readonly "always"?: { readonly "tool_names"?: ReadonlyArray } + readonly "never"?: { readonly "tool_names"?: ReadonlyArray } + } + | "always" + | "never" + | null + readonly "server_description"?: string + readonly "server_label": string + readonly "server_url"?: string + readonly "type": "mcp" } -export const ImageModelArchitecture = Schema.Struct({ - "input_modalities": Schema.Array(ImageInputModality).annotate({ "description": "Supported input modalities" }), - "output_modalities": Schema.Array(ImageOutputModality).annotate({ "description": "Supported output modalities" }) -}).annotate({ "identifier": "ImageModelArchitecture" }) -export type InternalServerResponse = { - readonly "error": InternalServerResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null +export const McpServerTool = Schema.Struct({ + "allowed_tools": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String), + Schema.Struct({ + "read_only": Schema.optionalKey(Schema.Boolean), + "tool_names": Schema.optionalKey(Schema.Array(Schema.String)) + }), + Schema.Null + ]) + ), + "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.Union([Schema.Record(Schema.String, Schema.String), Schema.Null])), + "require_approval": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "always": Schema.optionalKey(Schema.Struct({ "tool_names": Schema.optionalKey(Schema.Array(Schema.String)) })), + "never": Schema.optionalKey(Schema.Struct({ "tool_names": Schema.optionalKey(Schema.Array(Schema.String)) })) + }), + Schema.Literal("always"), + Schema.Literal("never"), + Schema.Null + ]) + ), + "server_description": Schema.optionalKey(Schema.String), + "server_label": Schema.String, + "server_url": Schema.optionalKey(Schema.String), + "type": Schema.Literal("mcp") +}).annotate({ "description": "MCP (Model Context Protocol) tool configuration", "identifier": "McpServerTool" }) +export type ImageGenerationServerTool = { + readonly "background"?: "transparent" | "opaque" | "auto" + readonly "input_fidelity"?: "high" | "low" | null + readonly "input_image_mask"?: { readonly "file_id"?: string; readonly "image_url"?: string } + readonly "model"?: string + 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"?: string + readonly "type": "image_generation" } -export const InternalServerResponse = Schema.Struct({ - "error": InternalServerResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) +export const ImageGenerationServerTool = Schema.Struct({ + "background": Schema.optionalKey(Schema.Literals(["transparent", "opaque", "auto"])), + "input_fidelity": Schema.optionalKey(Schema.Union([Schema.Literal("high"), Schema.Literal("low"), Schema.Null])), + "input_image_mask": Schema.optionalKey( + Schema.Struct({ "file_id": Schema.optionalKey(Schema.String), "image_url": Schema.optionalKey(Schema.String) }) ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ - "description": "Internal Server Error - Unexpected server error", - "identifier": "InternalServerResponse" + "model": Schema.optionalKey(Schema.String), + "moderation": Schema.optionalKey(Schema.Literals(["auto", "low"])), + "output_compression": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "output_format": Schema.optionalKey(Schema.Literals(["png", "webp", "jpeg"])), + "partial_images": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "quality": Schema.optionalKey(Schema.Literals(["low", "medium", "high", "auto"])), + "size": Schema.optionalKey(Schema.String), + "type": Schema.Literal("image_generation") +}).annotate({ "description": "Image generation tool configuration", "identifier": "ImageGenerationServerTool" }) +export type CodexLocalShellTool = { readonly "type": "local_shell" } +export const CodexLocalShellTool = Schema.Struct({ "type": Schema.Literal("local_shell") }).annotate({ + "description": "Local shell tool configuration", + "identifier": "CodexLocalShellTool" }) -export type ListKeyAssignmentsResponse = { - readonly "data": ReadonlyArray - readonly "total_count": number -} -export const ListKeyAssignmentsResponse = Schema.Struct({ - "data": Schema.Array(KeyAssignment).annotate({ "description": "List of key assignments" }), - "total_count": Schema.Number.annotate({ "description": "Total number of key assignments for this guardrail" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ "identifier": "ListKeyAssignmentsResponse" }) -export type Legacy_ChatContentVideo = { - readonly "type": "input_video" - readonly "video_url": Legacy_ChatContentVideoInput -} -export const Legacy_ChatContentVideo = Schema.Struct({ - "type": Schema.Literal("input_video"), - "video_url": Legacy_ChatContentVideoInput -}).annotate({ - "description": "Video input content part (legacy format - deprecated)", - "identifier": "Legacy_ChatContentVideo" +export type ShellServerTool = { readonly "type": "shell" } +export const ShellServerTool = Schema.Struct({ "type": Schema.Literal("shell") }).annotate({ + "description": "Shell tool configuration", + "identifier": "ShellServerTool" }) -export type ListMemberAssignmentsResponse = { - readonly "data": ReadonlyArray - readonly "total_count": number -} -export const ListMemberAssignmentsResponse = Schema.Struct({ - "data": Schema.Array(MemberAssignment).annotate({ "description": "List of member assignments" }), - "total_count": Schema.Number.annotate({ "description": "Total number of member assignments" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ "identifier": "ListMemberAssignmentsResponse" }) -export type MessagesOutputConfig = { - readonly "effort"?: "low" | "medium" | "high" | "xhigh" | "max" | null - readonly "format"?: Union_10 - readonly "task_budget"?: Union_11 +export type ApplyPatchServerTool = { readonly "type": "apply_patch" } +export const ApplyPatchServerTool = Schema.Struct({ "type": Schema.Literal("apply_patch") }).annotate({ + "description": "Apply patch tool configuration", + "identifier": "ApplyPatchServerTool" +}) +export type CustomTool = { + readonly "description"?: string + readonly "format"?: { readonly "type": "text" } | { + readonly "definition": string + readonly "syntax": "lark" | "regex" + readonly "type": "grammar" + } + readonly "name": string + readonly "type": "custom" } -export const MessagesOutputConfig = Schema.Struct({ - "effort": Schema.optionalKey( +export const CustomTool = Schema.Struct({ + "description": Schema.optionalKey(Schema.String), + "format": Schema.optionalKey( Schema.Union([ - Schema.Literal("low"), - Schema.Literal("medium"), - Schema.Literal("high"), - Schema.Literal("xhigh"), - Schema.Literal("max"), - Schema.Null - ]).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`, `xhigh`, or `max`." - }) + Schema.Struct({ "type": Schema.Literal("text") }), + Schema.Struct({ + "definition": Schema.String, + "syntax": Schema.Literals(["lark", "regex"]), + "type": Schema.Literal("grammar") + }) + ]) ), - "format": Schema.optionalKey(Union_10), - "task_budget": Schema.optionalKey(Union_11) -}).annotate({ - "description": - "Configuration for controlling output behavior. Supports the effort parameter and structured output format.", - "identifier": "MessagesOutputConfig" -}) -export type ChatModelNames = ReadonlyArray -export const ChatModelNames = Schema.Array( - Schema.suspend((): Schema.Codec => ModelName).annotate({ - "description": "Available OpenRouter chat completion models" - }) -).annotate({ "description": "Models to use for completion", "identifier": "ChatModelNames" }) -export type ContentPartInputAudio = { readonly "input_audio": MultimodalMedia; readonly "type": "input_audio" } -export const ContentPartInputAudio = Schema.Struct({ - "input_audio": MultimodalMedia, - "type": Schema.Literal("input_audio") -}).annotate({ "identifier": "ContentPartInputAudio" }) -export type ContentPartInputFile = { readonly "input_file": MultimodalMedia; readonly "type": "input_file" } -export const ContentPartInputFile = Schema.Struct({ - "input_file": MultimodalMedia, - "type": Schema.Literal("input_file") -}).annotate({ "identifier": "ContentPartInputFile" }) -export type ContentPartInputVideo = { readonly "input_video": MultimodalMedia; readonly "type": "input_video" } -export const ContentPartInputVideo = Schema.Struct({ - "input_video": MultimodalMedia, - "type": Schema.Literal("input_video") -}).annotate({ "identifier": "ContentPartInputVideo" }) -export type NamespaceTool = { - readonly "description": string + "name": Schema.String, + "type": Schema.Literal("custom") +}).annotate({ "description": "Custom tool configuration", "identifier": "CustomTool" }) +export type NamespaceFunctionTool = { + readonly "allowed_callers"?: ReadonlyArray<"direct" | "programmatic"> | null + readonly "defer_loading"?: boolean + readonly "description"?: string | null readonly "name": string - readonly "tools": ReadonlyArray - readonly "type": "namespace" + readonly "output_schema"?: { readonly [x: string]: Schema.Json } | null + readonly "parameters"?: { readonly [x: string]: Schema.Json } | null + readonly "strict"?: boolean | null + readonly "type": "function" } -export const NamespaceTool = Schema.Struct({ - "description": Schema.String, +export const NamespaceFunctionTool = Schema.Struct({ + "allowed_callers": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.Literals(["direct", "programmatic"])), Schema.Null]) + ), + "defer_loading": Schema.optionalKey(Schema.Boolean), + "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), "name": Schema.String, - "tools": Schema.Array(Schema.Union([NamespaceFunctionTool, CustomTool])), - "type": Schema.Literal("namespace") -}).annotate({ "description": "Groups function/custom tools under a shared namespace", "identifier": "NamespaceTool" }) -export type NotFoundResponse = { - readonly "error": NotFoundResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null -} -export const NotFoundResponse = Schema.Struct({ - "error": NotFoundResponseErrorData, - "openrouter_metadata": Schema.optionalKey( + "output_schema": Schema.optionalKey( Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ "description": "Not Found - Resource does not exist", "identifier": "NotFoundResponse" }) -export type ObservabilityFilterRulesConfig = { - readonly "enabled"?: boolean - readonly "groups": ReadonlyArray - readonly [x: string]: Schema.Json -} | null -export const ObservabilityFilterRulesConfig = Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "enabled": Schema.optionalKey(Schema.Boolean), - "groups": Schema.Array(ObservabilityFilterRuleGroup) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null -]).annotate({ - "description": "Optional structured filter rules controlling which events are forwarded.", - "identifier": "ObservabilityFilterRulesConfig" -}) -export type Objects_10 = { - readonly "enabled"?: boolean - readonly "groups": ReadonlyArray - readonly [x: string]: Schema.Json -} -export const Objects_10 = Schema.StructWithRest( - Schema.Struct({ - "enabled": Schema.optionalKey(Schema.Boolean), - "groups": Schema.Array(ObservabilityFilterRuleGroup) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type OpenAIResponsesUsage = { - readonly "input_tokens": number - readonly "input_tokens_details": Objects_15 - readonly "output_tokens": number - readonly "output_tokens_details": Objects_16 - readonly "total_tokens": number -} -export const OpenAIResponsesUsage = Schema.Struct({ - "input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "input_tokens_details": Objects_15, - "output_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "output_tokens_details": Objects_16, - "total_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "identifier": "OpenAIResponsesUsage" }) -export type OpenResponsesLogProbs = { - readonly "bytes"?: ReadonlyArray - readonly "logprob": number - readonly "token": string - readonly "top_logprobs"?: ReadonlyArray -} -export const OpenResponsesLogProbs = Schema.Struct({ - "bytes": Schema.optionalKey(Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "token": Schema.String, - "top_logprobs": Schema.optionalKey(Schema.Array(OpenResponsesTopLogprobs)) -}).annotate({ "description": "Log probability information for a token", "identifier": "OpenResponsesLogProbs" }) -export type ModelArchitecture = { - readonly "input_modalities": ReadonlyArray - readonly "instruct_type"?: InstructType - readonly "modality": string | null - readonly "output_modalities": ReadonlyArray - readonly "tokenizer"?: ModelGroup -} -export const ModelArchitecture = Schema.Struct({ - "input_modalities": Schema.Array(InputModality).annotate({ "description": "Supported input modalities" }), - "instruct_type": Schema.optionalKey(InstructType), - "modality": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Primary modality of the model" }), - "output_modalities": Schema.Array(OutputModality).annotate({ "description": "Supported output modalities" }), - "tokenizer": Schema.optionalKey(ModelGroup) -}).annotate({ "description": "Model architecture information", "identifier": "ModelArchitecture" }) -export type PayloadTooLargeResponse = { - readonly "error": PayloadTooLargeResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null -} -export const PayloadTooLargeResponse = Schema.Struct({ - "error": PayloadTooLargeResponseErrorData, - "openrouter_metadata": Schema.optionalKey( + "parameters": Schema.optionalKey( Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ - "description": "Payload Too Large - Request payload exceeds size limits", - "identifier": "PayloadTooLargeResponse" + "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "type": Schema.Literal("function") +}).annotate({ "description": "A function tool grouped inside a namespace tool", "identifier": "NamespaceFunctionTool" }) +export type ApplyPatchEngineEnum = "auto" | "native" | "openrouter" +export const ApplyPatchEngineEnum = Schema.Literals(["auto", "native", "openrouter"]).annotate({ + "description": + "Which apply_patch engine to use. \"auto\" (default) uses native passthrough when the endpoint advertises native apply_patch support, otherwise falls back to OpenRouter's HITL validator. \"native\" forces native passthrough — when the endpoint does not support native, the request falls back to HITL. \"openrouter\" always runs the HITL validator. Native passthrough streams the diff incrementally via `apply_patch_call_operation_diff.delta` events; HITL buffers the diff for atomic delivery as a single delta.", + "identifier": "ApplyPatchEngineEnum" }) -export type PaymentRequiredResponse = { - readonly "error": PaymentRequiredResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null -} -export const PaymentRequiredResponse = Schema.Struct({ - "error": PaymentRequiredResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) +export type RequestMetadata = { readonly [x: string]: string } | null +export const RequestMetadata = Schema.Union([ + Schema.Record( + Schema.String, + Schema.String.check(Schema.isMaxLength(512).annotate({ "expected": "a value with a length of at most 512" })) ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ - "description": "Payment Required - Insufficient credits or quota to complete request", - "identifier": "PaymentRequiredResponse" -}) -export type PDFParserOptions = { readonly "engine"?: PDFParserEngine } -export const PDFParserOptions = Schema.Struct({ "engine": Schema.optionalKey(PDFParserEngine) }).annotate({ - "description": "Options for PDF parsing.", - "identifier": "PDFParserOptions" -}) -export type PreferredMaxLatency = number | PercentileLatencyCutoffs | null -export const PreferredMaxLatency = Schema.Union([ - Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - PercentileLatencyCutoffs, 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.", - "identifier": "PreferredMaxLatency" + "Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.", + "identifier": "RequestMetadata" }) -export type PreferredMinThroughput = number | PercentileThroughputCutoffs | null -export const PreferredMinThroughput = Schema.Union([ - Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - PercentileThroughputCutoffs, +export type OutputModalityEnum = "text" | "image" +export const OutputModalityEnum = Schema.Literals(["text", "image"]).annotate({ "identifier": "OutputModalityEnum" }) +export type InputImage = { + readonly "detail": "auto" | "high" | "low" | "original" + readonly "image_url"?: string | null + readonly "type": "input_image" +} +export const InputImage = Schema.Struct({ + "detail": Schema.Literals(["auto", "high", "low", "original"]), + "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("input_image") +}).annotate({ "description": "Image input content item", "identifier": "InputImage" }) +export type ReasoningContext = "auto" | "all_turns" | "current_turn" | null +export const ReasoningContext = Schema.Union([ + Schema.Literal("auto"), + Schema.Literal("all_turns"), + Schema.Literal("current_turn"), 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.", - "identifier": "PreferredMinThroughput" + "Controls which reasoning is available to the model. `auto` uses the model default (same as omitting); `all_turns` includes reasoning from earlier turns passed in input; `current_turn` limits to the current turn only. Only supported by OpenAI GPT-5.6 and newer.", + "identifier": "ReasoningContext" }) -export type PipelineStage = { - readonly "cost_usd"?: number | null - readonly "data"?: {} - readonly "guardrail_id"?: string - readonly "guardrail_scope"?: string +export type ReasoningMode = "standard" | "pro" | null +export const ReasoningMode = Schema.Union([Schema.Literal("standard"), Schema.Literal("pro"), Schema.Null]).annotate({ + "description": + "Selects the reasoning mode. `standard` is the default; `pro` engages deeper reasoning on models that support it, billed at standard token rates. Only supported by OpenAI GPT-5.6 and newer.", + "identifier": "ReasoningMode" +}) +export type ReasoningSummaryVerbosity = "auto" | "concise" | "detailed" | null +export const ReasoningSummaryVerbosity = Schema.Union([ + Schema.Literal("auto"), + Schema.Literal("concise"), + Schema.Literal("detailed"), + Schema.Null +]).annotate({ "identifier": "ReasoningSummaryVerbosity" }) +export type FormatTextConfig = { readonly "type": "text" } +export const FormatTextConfig = Schema.Struct({ "type": Schema.Literal("text") }).annotate({ + "description": "Plain text response format", + "identifier": "FormatTextConfig" +}) +export type FormatJsonObjectConfig = { readonly "type": "json_object" } +export const FormatJsonObjectConfig = Schema.Struct({ "type": Schema.Literal("json_object") }).annotate({ + "description": "JSON object response format", + "identifier": "FormatJsonObjectConfig" +}) +export type FormatJsonSchemaConfig = { + readonly "description"?: string readonly "name": string - readonly "summary"?: string - readonly "type": PipelineStageType + readonly "schema": {} + readonly "strict"?: boolean | null + readonly "type": "json_schema" } -export const PipelineStage = Schema.Struct({ - "cost_usd": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "data": Schema.optionalKey(Schema.Struct({})), - "guardrail_id": Schema.optionalKey(Schema.String), - "guardrail_scope": Schema.optionalKey(Schema.String), +export const FormatJsonSchemaConfig = Schema.Struct({ + "description": Schema.optionalKey(Schema.String), "name": Schema.String, - "summary": Schema.optionalKey(Schema.String), - "type": PipelineStageType -}).annotate({ "identifier": "PipelineStage" }) -export type Objects_17 = { - readonly "content": string | ReadonlyArray - readonly "type": "content" - readonly [x: string]: Schema.Json + "schema": Schema.Struct({}), + "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "type": Schema.Literal("json_schema") +}).annotate({ "description": "JSON schema constrained response format", "identifier": "FormatJsonSchemaConfig" }) +export type ToolChoiceAllowed = { + readonly "mode": "auto" | "required" + readonly "tools": ReadonlyArray<{}> + readonly "type": "allowed_tools" } -export const Objects_17 = Schema.StructWithRest( - Schema.Struct({ - "content": Schema.Union([Schema.String, Schema.Array(PredictionContentText)]), - "type": Schema.Literal("content") - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type GetPresetVersionResponse = { readonly "data": PresetDesignatedVersion } -export const GetPresetVersionResponse = Schema.Struct({ "data": PresetDesignatedVersion }).annotate({ - "description": "A single version of a preset.", - "identifier": "GetPresetVersionResponse" +export const ToolChoiceAllowed = Schema.Struct({ + "mode": Schema.Literals(["auto", "required"]), + "tools": Schema.Array(Schema.Struct({})), + "type": Schema.Literal("allowed_tools") +}).annotate({ + "description": "Constrains the model to a pre-defined set of allowed tools", + "identifier": "ToolChoiceAllowed" }) -export type ListPresetVersionsResponse = { - readonly "data": ReadonlyArray - readonly "total_count": number -} -export const ListPresetVersionsResponse = Schema.Struct({ - "data": Schema.Array(PresetDesignatedVersion), - "total_count": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "description": "A paginated list of preset versions.", "identifier": "ListPresetVersionsResponse" }) -export type Preset = { - readonly "created_at": string - readonly "creator_user_id": string | null - readonly "description": string | null - readonly "designated_version_id": string | null - readonly "id": string - readonly "name": string - readonly "slug": string - readonly "status": PresetStatus - readonly "status_updated_at": string | null - readonly "updated_at": string - readonly "workspace_id": string | null -} -export const Preset = Schema.Struct({ - "created_at": Schema.String, - "creator_user_id": Schema.Union([Schema.String, Schema.Null]), - "description": Schema.Union([Schema.String, Schema.Null]), - "designated_version_id": Schema.Union([Schema.String, Schema.Null]), - "id": Schema.String, - "name": Schema.String, - "slug": Schema.String, - "status": PresetStatus, - "status_updated_at": Schema.Union([Schema.String, Schema.Null]), - "updated_at": Schema.String, - "workspace_id": Schema.Union([Schema.String, Schema.Null]) -}).annotate({ "description": "A preset without version details.", "identifier": "Preset" }) -export type PresetWithDesignatedVersion = { - readonly "created_at": string - readonly "creator_user_id": string | null - readonly "description": string | null - readonly "designated_version_id": string | null - readonly "id": string +export type OpenAIResponsesTruncation = "auto" | "disabled" | null +export const OpenAIResponsesTruncation = Schema.Union([Schema.Literal("auto"), Schema.Literal("disabled"), Schema.Null]) + .annotate({ "identifier": "OpenAIResponsesTruncation" }) +export type ResponsesErrorField = { + readonly "code": + | "server_error" + | "rate_limit_exceeded" + | "invalid_prompt" + | "vector_store_timeout" + | "invalid_image" + | "invalid_image_format" + | "invalid_base64_image" + | "invalid_image_url" + | "image_too_large" + | "image_too_small" + | "image_parse_error" + | "image_content_policy_violation" + | "invalid_image_mode" + | "image_file_too_large" + | "unsupported_image_media_type" + | "empty_image_file" + | "failed_to_download_image" + | "image_file_not_found" + | "bio_policy" + | "data_residency_mismatch" + readonly "message": string + readonly [x: string]: Schema.Json +} | null +export const ResponsesErrorField = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "code": Schema.Literals([ + "server_error", + "rate_limit_exceeded", + "invalid_prompt", + "vector_store_timeout", + "invalid_image", + "invalid_image_format", + "invalid_base64_image", + "invalid_image_url", + "image_too_large", + "image_too_small", + "image_parse_error", + "image_content_policy_violation", + "invalid_image_mode", + "image_file_too_large", + "unsupported_image_media_type", + "empty_image_file", + "failed_to_download_image", + "image_file_not_found", + "bio_policy", + "data_residency_mismatch" + ]), + "message": Schema.String + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "description": "Error information returned from the API", "identifier": "ResponsesErrorField" }) +export type IncompleteDetails = { + readonly "reason"?: "max_output_tokens" | "content_filter" + readonly [x: string]: Schema.Json +} | null +export const IncompleteDetails = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ "reason": Schema.optionalKey(Schema.Literals(["max_output_tokens", "content_filter"])) }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "identifier": "IncompleteDetails" }) +export type OpenAIResponsesRefusalContent = { readonly "refusal": string; readonly "type": "refusal" } +export const OpenAIResponsesRefusalContent = Schema.Struct({ + "refusal": Schema.String, + "type": Schema.Literal("refusal") +}).annotate({ "identifier": "OpenAIResponsesRefusalContent" }) +export type OpenAIResponseCustomToolCall = { + readonly "call_id": string + readonly "id"?: string + readonly "input": string readonly "name": string - readonly "slug": string - readonly "status": PresetStatus - readonly "status_updated_at": string | null - readonly "updated_at": string - readonly "workspace_id": string | null - readonly "designated_version": PresetDesignatedVersion + readonly "namespace"?: string + readonly "type": "custom_tool_call" } -export const PresetWithDesignatedVersion = Schema.Struct({ - "created_at": Schema.String, - "creator_user_id": Schema.Union([Schema.String, Schema.Null]), - "description": Schema.Union([Schema.String, Schema.Null]), - "designated_version_id": Schema.Union([Schema.String, Schema.Null]), - "id": Schema.String, +export const OpenAIResponseCustomToolCall = Schema.Struct({ + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.String), + "input": Schema.String, "name": Schema.String, - "slug": Schema.String, - "status": PresetStatus, - "status_updated_at": Schema.Union([Schema.String, Schema.Null]), - "updated_at": Schema.String, - "workspace_id": Schema.Union([Schema.String, Schema.Null]), - "designated_version": PresetDesignatedVersion -}).annotate({ - "description": "A preset with its currently designated version.", - "identifier": "PresetWithDesignatedVersion" -}) -export type Preview_WebSearchUserLocation = Objects_18 | null -export const Preview_WebSearchUserLocation = Schema.Union([Objects_18, Schema.Null]).annotate({ - "identifier": "Preview_WebSearchUserLocation" -}) -export type PublicPricing = { - readonly "audio"?: string - readonly "audio_output"?: string - readonly "completion": string - readonly "discount"?: number - readonly "image"?: string - readonly "image_output"?: string - readonly "image_token"?: string - readonly "input_audio_cache"?: string - readonly "input_cache_read"?: string - readonly "input_cache_write"?: string - readonly "input_cache_write_1h"?: string - readonly "internal_reasoning"?: string - readonly "overrides"?: ReadonlyArray - readonly "prompt": string - readonly "request"?: string - readonly "web_search"?: string -} -export const PublicPricing = Schema.Struct({ - "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per audio input token" })), - "audio_output": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per audio output token" })), - "completion": Schema.String.annotate({ "description": "Price in USD per token for completion (output) generation" }), - "discount": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Fractional discount applied to this endpoint's pricing; the price is multiplied by (1 - discount) (0 = no discount, 1 = free)", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "image": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per input image" })), - "image_output": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per output image" })), - "image_token": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per image token" })), - "input_audio_cache": Schema.optionalKey( - Schema.String.annotate({ "description": "Price in USD per cached audio input token" }) - ), - "input_cache_read": Schema.optionalKey( - Schema.String.annotate({ "description": "Price in USD per cached input token (read)" }) - ), - "input_cache_write": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Price per cache-write token, in USD per token. For providers with multiple cache TTLs (e.g. Anthropic), this is the default (5-minute) cache-write rate." - }) - ), - "input_cache_write_1h": Schema.optionalKey( + "namespace": Schema.optionalKey( Schema.String.annotate({ - "description": - "Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic." - }) - ), - "internal_reasoning": Schema.optionalKey( - Schema.String.annotate({ "description": "Price in USD per internal reasoning token" }) - ), - "overrides": Schema.optionalKey( - Schema.Array(PricingOverride).annotate({ - "description": - "Conditional overrides of the base pricing (e.g. long-context or time-based pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens, or the utc_start/utc_end time window) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions." + "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" }) ), - "prompt": Schema.String.annotate({ "description": "Price in USD per token for prompt (input) processing" }), - "request": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per request" })), - "web_search": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per web search" })) -}).annotate({ "description": "Pricing information for the model", "identifier": "PublicPricing" }) -export type PromptCacheBreakpoint = Objects_19 | null -export const PromptCacheBreakpoint = Schema.Union([Objects_19, Schema.Null]).annotate({ - "description": - "Marks an explicit prompt-cache boundary on this content block (OpenAI-style). Everything through the block carrying this marker is part of the candidate cached prefix. Supported natively by OpenAI GPT-5.6 and newer; on providers that use Anthropic-style `cache_control`, OpenRouter converts the marker to that format automatically.", - "identifier": "PromptCacheBreakpoint" + "type": Schema.Literal("custom_tool_call") +}).annotate({ "identifier": "OpenAIResponseCustomToolCall" }) +export type ReasoningTextContent = { readonly "text": string; readonly "type": "reasoning_text" } +export const ReasoningTextContent = Schema.Struct({ "text": Schema.String, "type": Schema.Literal("reasoning_text") }) + .annotate({ "identifier": "ReasoningTextContent" }) +export type ShellCallStatus = "in_progress" | "completed" | "incomplete" +export const ShellCallStatus = Schema.Literals(["in_progress", "completed", "incomplete"]).annotate({ + "description": "Status of a shell call or its output.", + "identifier": "ShellCallStatus" }) -export type PromptCacheOptions = Objects_20 | null -export const PromptCacheOptions = Schema.Union([Objects_20, Schema.Null]).annotate({ - "description": - "Request-level prompt-cache controls. `mode: \"explicit\"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer.", - "identifier": "PromptCacheOptions" +export type OpenAIResponsesResponseStatus = + | "completed" + | "incomplete" + | "in_progress" + | "failed" + | "cancelled" + | "queued" +export const OpenAIResponsesResponseStatus = Schema.Literals([ + "completed", + "incomplete", + "in_progress", + "failed", + "cancelled", + "queued" +]).annotate({ "identifier": "OpenAIResponsesResponseStatus" }) +export type Truncation = "auto" | "disabled" | null +export const Truncation = Schema.Union([Schema.Literal("auto"), Schema.Literal("disabled"), Schema.Null]).annotate({ + "identifier": "Truncation" }) -export type ContentFilterBuiltinEntry = { - readonly "action": ContentFilterBuiltinAction - readonly "label"?: string - readonly "scan_scope"?: PromptInjectionScanScope - readonly "slug": ContentFilterBuiltinSlug +export type ErrorEvent = { + readonly "code": string | null + readonly "message": string + readonly "param": string | null + readonly "sequence_number": number + readonly "type": "error" } -export const ContentFilterBuiltinEntry = Schema.Struct({ - "action": ContentFilterBuiltinAction, - "label": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Read-only, system-assigned redaction placeholder derived from the slug (e.g. \"[EMAIL]\", \"[PHONE]\"). Not settable by the caller." - }).check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })) +export const ErrorEvent = Schema.Struct({ + "code": Schema.Union([Schema.String, Schema.Null]), + "message": Schema.String, + "param": Schema.Union([Schema.String, Schema.Null]), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("error") +}).annotate({ "description": "Event emitted when an error occurs during streaming", "identifier": "ErrorEvent" }) +export type TextDeltaEvent = { + readonly "content_index": number + readonly "delta": string + readonly "item_id": string + readonly "logprobs": ReadonlyArray< + { + readonly "bytes"?: ReadonlyArray + readonly "logprob": number + readonly "token": string + readonly "top_logprobs"?: ReadonlyArray< + { readonly "bytes"?: ReadonlyArray; readonly "logprob"?: number; readonly "token"?: string } + > + } + > + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.output_text.delta" +} +export const TextDeltaEvent = Schema.Struct({ + "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String, + "item_id": Schema.String, + "logprobs": Schema.Array( + Schema.Struct({ + "bytes": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) + ), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String, + "top_logprobs": Schema.optionalKey(Schema.Array( + Schema.Struct({ + "bytes": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) + ), + "logprob": Schema.optionalKey( + Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "token": Schema.optionalKey(Schema.String) + }).annotate({ "description": "Alternative token with its log probability" }) + )) + }).annotate({ "description": "Log probability information for a token" }) ), - "scan_scope": Schema.optionalKey(PromptInjectionScanScope), - "slug": ContentFilterBuiltinSlug -}).annotate({ - "description": - "A builtin content filter entry. Builtin filters include PII detectors and the regex-based prompt injection detector.", - "identifier": "ContentFilterBuiltinEntry" -}) -export type ContentFilterBuiltinEntryInput = { - readonly "action": ContentFilterBuiltinAction - readonly "label"?: string - readonly "scan_scope"?: PromptInjectionScanScope - readonly "slug": ContentFilterBuiltinSlug + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.output_text.delta") +}).annotate({ "description": "Event emitted when a text delta is streamed", "identifier": "TextDeltaEvent" }) +export type TextDoneEvent = { + readonly "content_index": number + readonly "item_id": string + readonly "logprobs": ReadonlyArray< + { + readonly "bytes"?: ReadonlyArray + readonly "logprob": number + readonly "token": string + readonly "top_logprobs"?: ReadonlyArray< + { readonly "bytes"?: ReadonlyArray; readonly "logprob"?: number; readonly "token"?: string } + > + } + > + readonly "output_index": number + readonly "sequence_number": number + readonly "text": string + readonly "type": "response.output_text.done" } -export const ContentFilterBuiltinEntryInput = Schema.Struct({ - "action": ContentFilterBuiltinAction, - "label": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Deprecated: labels are system-assigned and cannot be set by the caller. Accepted for backward compatibility but silently ignored." - }).check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })) +export const TextDoneEvent = Schema.Struct({ + "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String, + "logprobs": Schema.Array( + Schema.Struct({ + "bytes": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) + ), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String, + "top_logprobs": Schema.optionalKey(Schema.Array( + Schema.Struct({ + "bytes": Schema.optionalKey( + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) + ), + "logprob": Schema.optionalKey( + Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "token": Schema.optionalKey(Schema.String) + }).annotate({ "description": "Alternative token with its log probability" }) + )) + }).annotate({ "description": "Log probability information for a token" }) ), - "scan_scope": Schema.optionalKey(PromptInjectionScanScope), - "slug": ContentFilterBuiltinSlug + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "text": Schema.String, + "type": Schema.Literal("response.output_text.done") +}).annotate({ "description": "Event emitted when text streaming is complete", "identifier": "TextDoneEvent" }) +export type RefusalDeltaEvent = { + readonly "content_index": number + readonly "delta": string + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.refusal.delta" +} +export const RefusalDeltaEvent = Schema.Struct({ + "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String, + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.refusal.delta") +}).annotate({ "description": "Event emitted when a refusal delta is streamed", "identifier": "RefusalDeltaEvent" }) +export type RefusalDoneEvent = { + readonly "content_index": number + readonly "item_id": string + readonly "output_index": number + readonly "refusal": string + readonly "sequence_number": number + readonly "type": "response.refusal.done" +} +export const RefusalDoneEvent = Schema.Struct({ + "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "refusal": Schema.String, + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.refusal.done") +}).annotate({ "description": "Event emitted when refusal streaming is complete", "identifier": "RefusalDoneEvent" }) +export type FunctionCallArgsDeltaEvent = { + readonly "delta": string + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.function_call_arguments.delta" +} +export const FunctionCallArgsDeltaEvent = Schema.Struct({ + "delta": Schema.String, + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.function_call_arguments.delta") }).annotate({ - "description": - "A builtin content filter entry for create/update requests. Labels are system-assigned and cannot be set by the caller.", - "identifier": "ContentFilterBuiltinEntryInput" -}) -export type Union_2 = ReadonlyArray | null -export const Union_2 = Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." + "description": "Event emitted when function call arguments are being streamed", + "identifier": "FunctionCallArgsDeltaEvent" }) -export type Union_3 = ReadonlyArray | null -export const Union_3 = Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." +export type FunctionCallArgsDoneEvent = { + readonly "arguments": string + readonly "item_id": string + readonly "name": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.function_call_arguments.done" +} +export const FunctionCallArgsDoneEvent = Schema.Struct({ + "arguments": Schema.String, + "item_id": Schema.String, + "name": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.function_call_arguments.done") +}).annotate({ + "description": "Event emitted when function call arguments streaming is complete", + "identifier": "FunctionCallArgsDoneEvent" }) -export type Union_4 = ReadonlyArray | null -export const Union_4 = Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." +export type ReasoningDeltaEvent = { + readonly "content_index": number + readonly "delta": string + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.reasoning_text.delta" +} +export const ReasoningDeltaEvent = Schema.Struct({ + "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "delta": Schema.String, + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.reasoning_text.delta") +}).annotate({ + "description": "Event emitted when reasoning text delta is streamed", + "identifier": "ReasoningDeltaEvent" }) -export type ProviderOptions = { - readonly "01ai"?: Objects_21 - readonly "ai21"?: Objects_22 - readonly "aion-labs"?: Objects_23 - readonly "akashml"?: Objects_24 - readonly "alibaba"?: Objects_25 - readonly "amazon-bedrock"?: Objects_26 - readonly "amazon-nova"?: Objects_27 - readonly "ambient"?: Objects_28 - readonly "anthropic"?: Objects_29 - readonly "anyscale"?: Objects_30 - readonly "arcee-ai"?: Objects_31 - readonly "atlas-cloud"?: Objects_32 - readonly "atoma"?: Objects_33 - readonly "avian"?: Objects_34 - readonly "azure"?: Objects_35 - readonly "baidu"?: Objects_36 - readonly "baseten"?: Objects_37 - readonly "black-forest-labs"?: Objects_38 - readonly "byteplus"?: Objects_39 - readonly "centml"?: Objects_40 - readonly "cerebras"?: Objects_41 - readonly "chutes"?: Objects_42 - readonly "cirrascale"?: Objects_43 - readonly "clarifai"?: Objects_44 - readonly "cloudflare"?: Objects_45 - readonly "cohere"?: Objects_46 - readonly "coreweave"?: Objects_47 - readonly "crofai"?: Objects_48 - readonly "crucible"?: Objects_49 - readonly "crusoe"?: Objects_50 - readonly "darkbloom"?: Objects_51 - readonly "decart"?: Objects_52 - readonly "deepgram"?: Objects_53 - readonly "deepinfra"?: Objects_54 - readonly "deepseek"?: Objects_55 - readonly "dekallm"?: Objects_56 - readonly "digitalocean"?: Objects_57 - readonly "enfer"?: Objects_58 - readonly "fake-provider"?: Objects_59 - readonly "featherless"?: Objects_60 - readonly "fireworks"?: Objects_61 - readonly "fish-audio"?: Objects_62 - readonly "friendli"?: Objects_63 - readonly "gmicloud"?: Objects_64 - readonly "google-ai-studio"?: Objects_65 - readonly "google-vertex"?: Objects_66 - readonly "gopomelo"?: Objects_67 - readonly "groq"?: Objects_68 - readonly "heygen"?: Objects_69 - readonly "huggingface"?: Objects_70 - readonly "hyperbolic"?: Objects_71 - readonly "hyperbolic-quantized"?: Objects_72 - readonly "inception"?: Objects_73 - readonly "inceptron"?: Objects_74 - readonly "inferact-vllm"?: Objects_75 - readonly "inference-net"?: Objects_76 - readonly "infermatic"?: Objects_77 - readonly "inflection"?: Objects_78 - readonly "inocloud"?: Objects_79 - readonly "io-net"?: Objects_80 - readonly "ionstream"?: Objects_81 - readonly "klusterai"?: Objects_82 - readonly "krea"?: Objects_83 - readonly "lambda"?: Objects_84 - readonly "lepton"?: Objects_85 - readonly "liquid"?: Objects_86 - readonly "lynn"?: Objects_87 - readonly "lynn-private"?: Objects_88 - readonly "mancer"?: Objects_89 - readonly "mancer-old"?: Objects_90 - readonly "mara"?: Objects_91 - readonly "meta"?: Objects_92 - readonly "minimax"?: Objects_93 - readonly "mistral"?: Objects_94 - readonly "modal"?: Objects_95 - readonly "modelrun"?: Objects_96 - readonly "modular"?: Objects_97 - readonly "moonshotai"?: Objects_98 - readonly "morph"?: Objects_99 - readonly "ncompass"?: Objects_100 - readonly "nebius"?: Objects_101 - readonly "nex-agi"?: Objects_102 - readonly "nextbit"?: Objects_103 - readonly "nineteen"?: Objects_104 - readonly "novita"?: Objects_105 - readonly "nvidia"?: Objects_106 - readonly "octoai"?: Objects_107 - readonly "open-inference"?: Objects_108 - readonly "openai"?: Objects_109 - readonly "parasail"?: Objects_110 - readonly "perceptron"?: Objects_111 - readonly "perplexity"?: Objects_112 - readonly "phala"?: Objects_113 - readonly "poolside"?: Objects_114 - readonly "quiver"?: Objects_115 - readonly "recraft"?: Objects_116 - readonly "recursal"?: Objects_117 - readonly "reflection"?: Objects_118 - readonly "reka"?: Objects_119 - readonly "relace"?: Objects_120 - readonly "replicate"?: Objects_121 - readonly "runway"?: Objects_122 - readonly "sail-research"?: Objects_123 - readonly "sakana"?: Objects_124 - readonly "sambanova"?: Objects_125 - readonly "sambanova-cloaked"?: Objects_126 - readonly "seed"?: Objects_127 - readonly "sf-compute"?: Objects_128 - readonly "siliconflow"?: Objects_129 - readonly "sourceful"?: Objects_130 - readonly "stealth"?: Objects_131 - readonly "stepfun"?: Objects_132 - readonly "streamlake"?: Objects_133 - readonly "switchpoint"?: Objects_134 - readonly "targon"?: Objects_135 - readonly "tencent"?: Objects_136 - readonly "tenstorrent"?: Objects_137 - readonly "together"?: Objects_138 - readonly "together-lite"?: Objects_139 - readonly "ubicloud"?: Objects_140 - readonly "upstage"?: Objects_141 - readonly "venice"?: Objects_142 - readonly "wafer"?: Objects_143 - readonly "wandb"?: Objects_144 - readonly "xai"?: Objects_145 - readonly "xiaomi"?: Objects_146 - readonly "z-ai"?: Objects_147 +export type ReasoningDoneEvent = { + readonly "content_index": number + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "text": string + readonly "type": "response.reasoning_text.done" } -export const ProviderOptions = Schema.Struct({ - "01ai": Schema.optionalKey(Objects_21), - "ai21": Schema.optionalKey(Objects_22), - "aion-labs": Schema.optionalKey(Objects_23), - "akashml": Schema.optionalKey(Objects_24), - "alibaba": Schema.optionalKey(Objects_25), - "amazon-bedrock": Schema.optionalKey(Objects_26), - "amazon-nova": Schema.optionalKey(Objects_27), - "ambient": Schema.optionalKey(Objects_28), - "anthropic": Schema.optionalKey(Objects_29), - "anyscale": Schema.optionalKey(Objects_30), - "arcee-ai": Schema.optionalKey(Objects_31), - "atlas-cloud": Schema.optionalKey(Objects_32), - "atoma": Schema.optionalKey(Objects_33), - "avian": Schema.optionalKey(Objects_34), - "azure": Schema.optionalKey(Objects_35), - "baidu": Schema.optionalKey(Objects_36), - "baseten": Schema.optionalKey(Objects_37), - "black-forest-labs": Schema.optionalKey(Objects_38), - "byteplus": Schema.optionalKey(Objects_39), - "centml": Schema.optionalKey(Objects_40), - "cerebras": Schema.optionalKey(Objects_41), - "chutes": Schema.optionalKey(Objects_42), - "cirrascale": Schema.optionalKey(Objects_43), - "clarifai": Schema.optionalKey(Objects_44), - "cloudflare": Schema.optionalKey(Objects_45), - "cohere": Schema.optionalKey(Objects_46), - "coreweave": Schema.optionalKey(Objects_47), - "crofai": Schema.optionalKey(Objects_48), - "crucible": Schema.optionalKey(Objects_49), - "crusoe": Schema.optionalKey(Objects_50), - "darkbloom": Schema.optionalKey(Objects_51), - "decart": Schema.optionalKey(Objects_52), - "deepgram": Schema.optionalKey(Objects_53), - "deepinfra": Schema.optionalKey(Objects_54), - "deepseek": Schema.optionalKey(Objects_55), - "dekallm": Schema.optionalKey(Objects_56), - "digitalocean": Schema.optionalKey(Objects_57), - "enfer": Schema.optionalKey(Objects_58), - "fake-provider": Schema.optionalKey(Objects_59), - "featherless": Schema.optionalKey(Objects_60), - "fireworks": Schema.optionalKey(Objects_61), - "fish-audio": Schema.optionalKey(Objects_62), - "friendli": Schema.optionalKey(Objects_63), - "gmicloud": Schema.optionalKey(Objects_64), - "google-ai-studio": Schema.optionalKey(Objects_65), - "google-vertex": Schema.optionalKey(Objects_66), - "gopomelo": Schema.optionalKey(Objects_67), - "groq": Schema.optionalKey(Objects_68), - "heygen": Schema.optionalKey(Objects_69), - "huggingface": Schema.optionalKey(Objects_70), - "hyperbolic": Schema.optionalKey(Objects_71), - "hyperbolic-quantized": Schema.optionalKey(Objects_72), - "inception": Schema.optionalKey(Objects_73), - "inceptron": Schema.optionalKey(Objects_74), - "inferact-vllm": Schema.optionalKey(Objects_75), - "inference-net": Schema.optionalKey(Objects_76), - "infermatic": Schema.optionalKey(Objects_77), - "inflection": Schema.optionalKey(Objects_78), - "inocloud": Schema.optionalKey(Objects_79), - "io-net": Schema.optionalKey(Objects_80), - "ionstream": Schema.optionalKey(Objects_81), - "klusterai": Schema.optionalKey(Objects_82), - "krea": Schema.optionalKey(Objects_83), - "lambda": Schema.optionalKey(Objects_84), - "lepton": Schema.optionalKey(Objects_85), - "liquid": Schema.optionalKey(Objects_86), - "lynn": Schema.optionalKey(Objects_87), - "lynn-private": Schema.optionalKey(Objects_88), - "mancer": Schema.optionalKey(Objects_89), - "mancer-old": Schema.optionalKey(Objects_90), - "mara": Schema.optionalKey(Objects_91), - "meta": Schema.optionalKey(Objects_92), - "minimax": Schema.optionalKey(Objects_93), - "mistral": Schema.optionalKey(Objects_94), - "modal": Schema.optionalKey(Objects_95), - "modelrun": Schema.optionalKey(Objects_96), - "modular": Schema.optionalKey(Objects_97), - "moonshotai": Schema.optionalKey(Objects_98), - "morph": Schema.optionalKey(Objects_99), - "ncompass": Schema.optionalKey(Objects_100), - "nebius": Schema.optionalKey(Objects_101), - "nex-agi": Schema.optionalKey(Objects_102), - "nextbit": Schema.optionalKey(Objects_103), - "nineteen": Schema.optionalKey(Objects_104), - "novita": Schema.optionalKey(Objects_105), - "nvidia": Schema.optionalKey(Objects_106), - "octoai": Schema.optionalKey(Objects_107), - "open-inference": Schema.optionalKey(Objects_108), - "openai": Schema.optionalKey(Objects_109), - "parasail": Schema.optionalKey(Objects_110), - "perceptron": Schema.optionalKey(Objects_111), - "perplexity": Schema.optionalKey(Objects_112), - "phala": Schema.optionalKey(Objects_113), - "poolside": Schema.optionalKey(Objects_114), - "quiver": Schema.optionalKey(Objects_115), - "recraft": Schema.optionalKey(Objects_116), - "recursal": Schema.optionalKey(Objects_117), - "reflection": Schema.optionalKey(Objects_118), - "reka": Schema.optionalKey(Objects_119), - "relace": Schema.optionalKey(Objects_120), - "replicate": Schema.optionalKey(Objects_121), - "runway": Schema.optionalKey(Objects_122), - "sail-research": Schema.optionalKey(Objects_123), - "sakana": Schema.optionalKey(Objects_124), - "sambanova": Schema.optionalKey(Objects_125), - "sambanova-cloaked": Schema.optionalKey(Objects_126), - "seed": Schema.optionalKey(Objects_127), - "sf-compute": Schema.optionalKey(Objects_128), - "siliconflow": Schema.optionalKey(Objects_129), - "sourceful": Schema.optionalKey(Objects_130), - "stealth": Schema.optionalKey(Objects_131), - "stepfun": Schema.optionalKey(Objects_132), - "streamlake": Schema.optionalKey(Objects_133), - "switchpoint": Schema.optionalKey(Objects_134), - "targon": Schema.optionalKey(Objects_135), - "tencent": Schema.optionalKey(Objects_136), - "tenstorrent": Schema.optionalKey(Objects_137), - "together": Schema.optionalKey(Objects_138), - "together-lite": Schema.optionalKey(Objects_139), - "ubicloud": Schema.optionalKey(Objects_140), - "upstage": Schema.optionalKey(Objects_141), - "venice": Schema.optionalKey(Objects_142), - "wafer": Schema.optionalKey(Objects_143), - "wandb": Schema.optionalKey(Objects_144), - "xai": Schema.optionalKey(Objects_145), - "xiaomi": Schema.optionalKey(Objects_146), - "z-ai": Schema.optionalKey(Objects_147) +export const ReasoningDoneEvent = Schema.Struct({ + "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "text": Schema.String, + "type": Schema.Literal("response.reasoning_text.done") }).annotate({ - "description": - "Provider-specific options keyed by provider slug. Only options for the matched provider are forwarded; the rest are ignored. Unrecognized keys are silently dropped.", - "identifier": "ProviderOptions" + "description": "Event emitted when reasoning text streaming is complete", + "identifier": "ReasoningDoneEvent" }) -export type ProviderOverloadedResponse = { - readonly "error": ProviderOverloadedResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null +export type ReasoningSummaryTextDeltaEvent = { + readonly "delta": string + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "summary_index": number + readonly "type": "response.reasoning_summary_text.delta" } -export const ProviderOverloadedResponse = Schema.Struct({ - "error": ProviderOverloadedResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +export const ReasoningSummaryTextDeltaEvent = Schema.Struct({ + "delta": Schema.String, + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.reasoning_summary_text.delta") }).annotate({ - "description": "Provider Overloaded - Provider is temporarily overloaded", - "identifier": "ProviderOverloadedResponse" + "description": "Event emitted when reasoning summary text delta is streamed", + "identifier": "ReasoningSummaryTextDeltaEvent" }) -export type GenerationResponse = { - readonly "data": { - readonly "api_type": "completions" | "embeddings" | "rerank" | "tts" | "stt" | "video" | "image" | null - readonly "app_id": number | null - readonly "cache_discount": number | null - readonly "cancelled": boolean | null - readonly "created_at": string - readonly "data_region": "global" | "europe" - readonly "external_user": string | null - readonly "finish_reason": string | null - readonly "generation_time": number | null - readonly "http_referer": string | null - readonly "id": string - readonly "is_byok": boolean - readonly "latency": number | null - readonly "model": string - readonly "moderation_latency": number | null - readonly "native_finish_reason": string | null - readonly "native_tokens_cached": number | null - readonly "native_tokens_completion": number | null - readonly "native_tokens_completion_images": number | null - readonly "native_tokens_prompt": number | null - readonly "native_tokens_reasoning": number | null - readonly "num_fetches": number | null - readonly "num_input_audio_prompt": number | null - readonly "num_media_completion": number | null - readonly "num_media_prompt": number | null - readonly "num_search_results": number | null - readonly "origin": string - readonly "preset_id": string | null - readonly "provider_name": string | null - readonly "provider_responses": ReadonlyArray | null - readonly "request_id"?: string | null - readonly "response_cache_source_id"?: string | null - readonly "router": string | null - readonly "service_tier": string | null - readonly "session_id"?: string | null - readonly "streamed": boolean | null - readonly "tokens_completion": number | null - readonly "tokens_prompt": number | null - readonly "total_cost": number - readonly "upstream_id": string | null - readonly "upstream_inference_cost": number | null - readonly "usage": number - readonly "user_agent": string | null - readonly "web_search_engine": string | null - } -} -export const GenerationResponse = Schema.Struct({ - "data": Schema.Struct({ - "api_type": Schema.Union([ - Schema.Literal("completions"), - Schema.Literal("embeddings"), - Schema.Literal("rerank"), - Schema.Literal("tts"), - Schema.Literal("stt"), - Schema.Literal("video"), - Schema.Literal("image"), - Schema.Null - ]).annotate({ "description": "Type of API used for the generation" }), - "app_id": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - .annotate({ "description": "ID of the app that made the request" }), - "cache_discount": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "description": "Discount applied due to caching", "format": "double" }), - "cancelled": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": "Whether the generation was cancelled" - }), - "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the generation was created" }), - "data_region": Schema.Literals(["global", "europe"]).annotate({ - "description": - "The data region this generation was routed through. 'europe' for EU-routed requests, 'global' otherwise." - }), - "external_user": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "External user identifier" }), - "finish_reason": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Reason the generation finished" - }), - "generation_time": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "description": "Time taken for generation in milliseconds", "format": "double" }), - "http_referer": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Referer header from the request" - }), - "id": Schema.String.annotate({ "description": "Unique identifier for the generation" }), - "is_byok": Schema.Boolean.annotate({ "description": "Whether this used bring-your-own-key" }), - "latency": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "description": "Total latency in milliseconds", "format": "double" }), - "model": Schema.String.annotate({ "description": "Model used for the generation" }), - "moderation_latency": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "description": "Moderation latency in milliseconds", "format": "double" }), - "native_finish_reason": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Native finish reason as reported by provider" - }), - "native_tokens_cached": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Native cached tokens as reported by provider" }), - "native_tokens_completion": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Native completion tokens as reported by provider" }), - "native_tokens_completion_images": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Native completion image tokens as reported by provider" }), - "native_tokens_prompt": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Native prompt tokens as reported by provider" }), - "native_tokens_reasoning": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Native reasoning tokens as reported by provider" }), - "num_fetches": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Number of web fetches performed" }), - "num_input_audio_prompt": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Number of audio inputs in the prompt" }), - "num_media_completion": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Number of media items in the completion" }), - "num_media_prompt": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Number of media items in the prompt" }), - "num_search_results": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Number of search results included" }), - "origin": Schema.String.annotate({ "description": "Origin URL of the request" }), - "preset_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "ID of the preset used for this generation, null if no preset was used" - }), - "provider_name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Name of the provider that served the request" - }), - "provider_responses": Schema.Union([Schema.Array(ProviderResponse), Schema.Null]).annotate({ - "description": "List of provider responses for this generation, including fallback attempts" - }), - "request_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Unique identifier grouping all generations from a single API request" - }) - ), - "response_cache_source_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "If this generation was served from response cache, contains the original generation ID. Null otherwise." - }) - ), - "router": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Router used for the request (e.g., openrouter/auto)" - }), - "service_tier": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "Service tier the upstream provider reported running this request on, or null if it did not report one." - }), - "session_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Session identifier grouping multiple generations in the same session" - }) - ), - "streamed": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": "Whether the response was streamed" - }), - "tokens_completion": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Number of tokens in the completion" }), - "tokens_prompt": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Number of tokens in the prompt" }), - "total_cost": Schema.Number.annotate({ "description": "Total cost of the generation in USD", "format": "double" }) - .check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "upstream_id": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Upstream provider's identifier for this generation" - }), - "upstream_inference_cost": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "description": "Cost charged by the upstream provider", "format": "double" }), - "usage": Schema.Number.annotate({ "description": "Usage amount in USD", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "user_agent": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "User-Agent header from the request" - }), - "web_search_engine": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The resolved web search engine used for this generation (e.g. exa, firecrawl, parallel)" - }) - }).annotate({ "description": "Generation data" }) -}).annotate({ "description": "Generation response", "identifier": "GenerationResponse" }) -export type Union_5 = ProviderSort | ProviderSortConfig | null -export const Union_5 = Schema.Union([ProviderSort, ProviderSortConfig, Schema.Null]).annotate({ - "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." -}) -export type PublicEndpoint = { - readonly "context_length": number - readonly "latency_last_30m": PercentileStats - readonly "max_completion_tokens": number | null - readonly "max_prompt_tokens": number | null - readonly "model_id": string - readonly "model_name": string - readonly "name": string - readonly "pricing": { - readonly "audio"?: string - readonly "audio_output"?: string - readonly "completion": string - readonly "discount"?: number - readonly "image"?: string - readonly "image_output"?: string - readonly "image_token"?: string - readonly "input_audio_cache"?: string - readonly "input_cache_read"?: string - readonly "input_cache_write"?: string - readonly "input_cache_write_1h"?: string - readonly "internal_reasoning"?: string - readonly "overrides"?: ReadonlyArray - readonly "prompt": string - readonly "request"?: string - readonly "web_search"?: string - } - readonly "provider_name": ProviderName - readonly "quantization": Quantization | null - readonly "status"?: EndpointStatus - readonly "supported_parameters": ReadonlyArray - readonly "supports_implicit_caching": boolean - readonly "tag": string - readonly "throughput_last_30m": PercentileStats - readonly "uptime_last_1d": number | null - readonly "uptime_last_30m": number | null - readonly "uptime_last_5m": number | null +export type ReasoningSummaryTextDoneEvent = { + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "summary_index": number + readonly "text": string + readonly "type": "response.reasoning_summary_text.done" } -export const PublicEndpoint = Schema.Struct({ - "context_length": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "latency_last_30m": PercentileStats, - "max_completion_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]), - "max_prompt_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]), - "model_id": Schema.String.annotate({ "description": "The unique identifier for the model (permaslug)" }), - "model_name": Schema.String, - "name": Schema.String, - "pricing": Schema.Struct({ - "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per audio input token" })), - "audio_output": Schema.optionalKey( - Schema.String.annotate({ "description": "Price in USD per audio output token" }) - ), - "completion": Schema.String.annotate({ - "description": "Price in USD per token for completion (output) generation" - }), - "discount": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Fractional discount applied to this endpoint's pricing; the price is multiplied by (1 - discount) (0 = no discount, 1 = free)", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "image": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per input image" })), - "image_output": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per output image" })), - "image_token": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per image token" })), - "input_audio_cache": Schema.optionalKey( - Schema.String.annotate({ "description": "Price in USD per cached audio input token" }) - ), - "input_cache_read": Schema.optionalKey( - Schema.String.annotate({ "description": "Price in USD per cached input token (read)" }) - ), - "input_cache_write": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Price per cache-write token, in USD per token. For providers with multiple cache TTLs (e.g. Anthropic), this is the default (5-minute) cache-write rate." - }) - ), - "input_cache_write_1h": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic." - }) - ), - "internal_reasoning": Schema.optionalKey( - Schema.String.annotate({ "description": "Price in USD per internal reasoning token" }) - ), - "overrides": Schema.optionalKey( - Schema.Array(PricingOverride).annotate({ - "description": - "Conditional overrides of the base pricing (e.g. long-context or time-based pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens, or the utc_start/utc_end time window) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions." - }) - ), - "prompt": Schema.String.annotate({ "description": "Price in USD per token for prompt (input) processing" }), - "request": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per request" })), - "web_search": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per web search" })) - }), - "provider_name": ProviderName, - "quantization": Schema.Union([Quantization, Schema.Null]), - "status": Schema.optionalKey(EndpointStatus), - "supported_parameters": Schema.Array(Parameter), - "supports_implicit_caching": Schema.Boolean, - "tag": Schema.String, - "throughput_last_30m": Schema.suspend((): Schema.Codec => PercentileStats).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." - }), - "uptime_last_1d": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ - "description": - "Uptime percentage over the last 1 day, calculated as successful requests / (successful + error requests) * 100. Rate-limited requests are excluded. Returns null if insufficient data.", - "format": "double" - }), - "uptime_last_30m": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "format": "double" }), - "uptime_last_5m": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ - "description": - "Uptime percentage over the last 5 minutes, calculated as successful requests / (successful + error requests) * 100. Rate-limited requests are excluded. Returns null if insufficient data.", - "format": "double" - }) -}).annotate({ "description": "Information about a specific model endpoint", "identifier": "PublicEndpoint" }) -export type CapabilityDescriptor = EnumCapability | RangeCapability | BooleanCapability -export const CapabilityDescriptor = Schema.Union([EnumCapability, RangeCapability, BooleanCapability], { - mode: "oneOf" +export const ReasoningSummaryTextDoneEvent = Schema.Struct({ + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "text": Schema.String, + "type": Schema.Literal("response.reasoning_summary_text.done") }).annotate({ - "description": "A typed descriptor for one supported request parameter.", - "identifier": "CapabilityDescriptor" + "description": "Event emitted when reasoning summary text streaming is complete", + "identifier": "ReasoningSummaryTextDoneEvent" }) -export type AppRankingsResponse = { - readonly "data": ReadonlyArray - readonly "meta": RankingsDailyMeta -} -export const AppRankingsResponse = Schema.Struct({ - "data": Schema.Array(AppRankingsItem).annotate({ - "description": - "Apps ranked per the requested `sort`, re-numbered 1..N after category filtering. `popular` sorts by `total_tokens` descending; `trending` sorts by absolute excess token growth descending and may return fewer than `limit` rows when few apps are growing." - }), - "meta": RankingsDailyMeta -}).annotate({ "identifier": "AppRankingsResponse" }) -export type RankingsDailyResponse = { - readonly "data": ReadonlyArray - readonly "meta": RankingsDailyMeta +export type ImageGenCallInProgressEvent = { + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.image_generation_call.in_progress" } -export const RankingsDailyResponse = Schema.Struct({ - "data": Schema.Array(RankingsDailyItem).annotate({ - "description": - "Up to 51 rows per day — the top 50 public models by `total_tokens` for each UTC calendar date in the window, plus one aggregated `other` row summing every model outside that top 50 (omitted when the long tail is empty). Rows are sorted by `date` ascending, then by `total_tokens` descending, with `other` pinned last within its date. Ties between real models break alphabetically on `model_permaslug` so the order is stable across requests." - }), - "meta": RankingsDailyMeta -}).annotate({ "identifier": "RankingsDailyResponse" }) -export type Union_12 = ReadonlyArray | null -export const Union_12 = Schema.Union([Schema.Array(ReasoningEffort), Schema.Null]).annotate({ - "description": - "Allowed reasoning effort values for this model, in descending effort order (highest first). Null means no allowlist — all gateway effort values are accepted." -}) -export type ReasoningDetailEncrypted = { - readonly "data": string - readonly "format"?: ReasoningFormat - readonly "id"?: string | null - readonly "index"?: number - readonly "type": "reasoning.encrypted" +export const ImageGenCallInProgressEvent = Schema.Struct({ + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.image_generation_call.in_progress") +}).annotate({ "description": "Image generation call in progress", "identifier": "ImageGenCallInProgressEvent" }) +export type ImageGenCallGeneratingEvent = { + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.image_generation_call.generating" } -export const ReasoningDetailEncrypted = Schema.Struct({ - "data": Schema.String, - "format": Schema.optionalKey(ReasoningFormat), - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "index": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "type": Schema.Literal("reasoning.encrypted") -}).annotate({ "description": "Reasoning detail encrypted schema", "identifier": "ReasoningDetailEncrypted" }) -export type ReasoningDetailServerToolCall = { - readonly "arguments": string - readonly "format"?: ReasoningFormat - readonly "id"?: string | null - readonly "index"?: number - readonly "result": string - readonly "tool_call_id"?: string | null - readonly "tool_name": string - readonly "type": "reasoning.server_tool_call" +export const ImageGenCallGeneratingEvent = Schema.Struct({ + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.image_generation_call.generating") +}).annotate({ "description": "Image generation call is generating", "identifier": "ImageGenCallGeneratingEvent" }) +export type ImageGenCallPartialImageEvent = { + readonly "item_id": string + readonly "output_index": number + readonly "partial_image_b64": string + readonly "partial_image_index": number + readonly "sequence_number": number + readonly "type": "response.image_generation_call.partial_image" } -export const ReasoningDetailServerToolCall = Schema.Struct({ - "arguments": Schema.String, - "format": Schema.optionalKey(ReasoningFormat), - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "index": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "result": Schema.String, - "tool_call_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "tool_name": Schema.String, - "type": Schema.Literal("reasoning.server_tool_call") +export const ImageGenCallPartialImageEvent = Schema.Struct({ + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "partial_image_b64": Schema.String, + "partial_image_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.image_generation_call.partial_image") }).annotate({ - "description": - "Record of an OpenRouter server-tool invocation (e.g. openrouter:fusion), carried in reasoning_details so a prior tool call can be rehydrated into a later turn of the same conversation.", - "identifier": "ReasoningDetailServerToolCall" + "description": "Image generation call with partial image", + "identifier": "ImageGenCallPartialImageEvent" }) -export type ReasoningDetailSummary = { - readonly "format"?: ReasoningFormat - readonly "id"?: string | null - readonly "index"?: number - readonly "summary": string - readonly "type": "reasoning.summary" -} -export const ReasoningDetailSummary = Schema.Struct({ - "format": Schema.optionalKey(ReasoningFormat), - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "index": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "summary": Schema.String, - "type": Schema.Literal("reasoning.summary") -}).annotate({ "description": "Reasoning detail summary schema", "identifier": "ReasoningDetailSummary" }) -export type ReasoningDetailText = { - readonly "format"?: ReasoningFormat - readonly "id"?: string | null - readonly "index"?: number - readonly "signature"?: string | null - readonly "text"?: string | null - readonly "type": "reasoning.text" +export type ImageGenCallCompletedEvent = { + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.image_generation_call.completed" } -export const ReasoningDetailText = Schema.Struct({ - "format": Schema.optionalKey(ReasoningFormat), - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "index": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "signature": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "text": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("reasoning.text") -}).annotate({ "description": "Reasoning detail text schema", "identifier": "ReasoningDetailText" }) -export type BaseReasoningSummaryPartAddedEvent = { +export const ImageGenCallCompletedEvent = Schema.Struct({ + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.image_generation_call.completed") +}).annotate({ "description": "Image generation call completed", "identifier": "ImageGenCallCompletedEvent" }) +export type WebSearchCallInProgressEvent = { readonly "item_id": string readonly "output_index": number - readonly "part": ReasoningSummaryText readonly "sequence_number": number - readonly "summary_index": number - readonly "type": "response.reasoning_summary_part.added" + readonly "type": "response.web_search_call.in_progress" } -export const BaseReasoningSummaryPartAddedEvent = Schema.Struct({ +export const WebSearchCallInProgressEvent = Schema.Struct({ "item_id": Schema.String, "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "part": ReasoningSummaryText, "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.reasoning_summary_part.added") -}).annotate({ - "description": "Event emitted when a reasoning summary part is added", - "identifier": "BaseReasoningSummaryPartAddedEvent" -}) -export type BaseReasoningSummaryPartDoneEvent = { + "type": Schema.Literal("response.web_search_call.in_progress") +}).annotate({ "description": "Web search call in progress", "identifier": "WebSearchCallInProgressEvent" }) +export type WebSearchCallSearchingEvent = { readonly "item_id": string readonly "output_index": number - readonly "part": ReasoningSummaryText readonly "sequence_number": number - readonly "summary_index": number - readonly "type": "response.reasoning_summary_part.done" + readonly "type": "response.web_search_call.searching" } -export const BaseReasoningSummaryPartDoneEvent = Schema.Struct({ +export const WebSearchCallSearchingEvent = Schema.Struct({ "item_id": Schema.String, "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "part": ReasoningSummaryText, "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.reasoning_summary_part.done") -}).annotate({ - "description": "Event emitted when a reasoning summary part is complete", - "identifier": "BaseReasoningSummaryPartDoneEvent" -}) -export type OutputReasoningItem = { - readonly "content"?: ReadonlyArray<{ readonly "text": string; readonly "type": "reasoning_text" }> - readonly "encrypted_content"?: string | null - readonly "id": string - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "summary": ReadonlyArray - readonly "type": "reasoning" - readonly "format"?: ReasoningFormat - readonly "signature"?: string | null + "type": Schema.Literal("response.web_search_call.searching") +}).annotate({ "description": "Web search call is searching", "identifier": "WebSearchCallSearchingEvent" }) +export type WebSearchCallCompletedEvent = { + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.web_search_call.completed" } -export const OutputReasoningItem = Schema.Struct({ - "content": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.Struct({ "text": Schema.String, "type": Schema.Literal("reasoning_text") }))]) - ), - "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "id": Schema.String, - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "summary": Schema.Array(ReasoningSummaryText), - "type": Schema.Literal("reasoning"), - "format": Schema.optionalKey(ReasoningFormat), - "signature": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "A signature for the reasoning content, used for verification" - }) - ) -}).annotate({ "description": "An output item containing reasoning", "identifier": "OutputReasoningItem" }) -export type ReasoningItem = { - readonly "content"?: ReadonlyArray<{ readonly "text": string; readonly "type": "reasoning_text" }> - readonly "encrypted_content"?: string | null - readonly "id": string - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "summary": ReadonlyArray - readonly "type": "reasoning" - readonly "format"?: ReasoningFormat - readonly "signature"?: string | null +export const WebSearchCallCompletedEvent = Schema.Struct({ + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.web_search_call.completed") +}).annotate({ "description": "Web search call completed", "identifier": "WebSearchCallCompletedEvent" }) +export type CustomToolCallInputDeltaEvent = { + readonly "delta": string + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.custom_tool_call_input.delta" } -export const ReasoningItem = Schema.Struct({ - "content": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.Struct({ "text": Schema.String, "type": Schema.Literal("reasoning_text") }))]) - ), - "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "id": Schema.String, - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "summary": Schema.Array(ReasoningSummaryText), - "type": Schema.Literal("reasoning"), - "format": Schema.optionalKey(ReasoningFormat), - "signature": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +export const CustomToolCallInputDeltaEvent = Schema.Struct({ + "delta": Schema.String, + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.custom_tool_call_input.delta") }).annotate({ - "description": "Reasoning output item with signature and format extensions", - "identifier": "ReasoningItem" + "description": + "Event emitted when a custom tool call's freeform input is being streamed. Mirrors `response.function_call_arguments.delta` but for `custom` tools whose input is opaque text rather than JSON arguments.", + "identifier": "CustomToolCallInputDeltaEvent" }) -export type ReasoningSummaryPartAddedEvent = { +export type CustomToolCallInputDoneEvent = { + readonly "input": string readonly "item_id": string readonly "output_index": number - readonly "part": ReasoningSummaryText readonly "sequence_number": number - readonly "summary_index": number - readonly "type": "response.reasoning_summary_part.added" + readonly "type": "response.custom_tool_call_input.done" } -export const ReasoningSummaryPartAddedEvent = Schema.Struct({ +export const CustomToolCallInputDoneEvent = Schema.Struct({ + "input": Schema.String, "item_id": Schema.String, "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "part": ReasoningSummaryText, "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.reasoning_summary_part.added") + "type": Schema.Literal("response.custom_tool_call_input.done") }).annotate({ - "description": "Event emitted when a reasoning summary part is added", - "identifier": "ReasoningSummaryPartAddedEvent" + "description": + "Event emitted when a custom tool call's freeform input streaming is complete. Mirrors `response.function_call_arguments.done` but for `custom` tools.", + "identifier": "CustomToolCallInputDoneEvent" }) -export type ReasoningSummaryPartDoneEvent = { +export type ApplyPatchCallOperationDiffDeltaEvent = { + readonly "delta": string readonly "item_id": string readonly "output_index": number - readonly "part": ReasoningSummaryText readonly "sequence_number": number - readonly "summary_index": number - readonly "type": "response.reasoning_summary_part.done" + readonly "type": "response.apply_patch_call_operation_diff.delta" } -export const ReasoningSummaryPartDoneEvent = Schema.Struct({ +export const ApplyPatchCallOperationDiffDeltaEvent = Schema.Struct({ + "delta": Schema.String, "item_id": Schema.String, "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "part": ReasoningSummaryText, "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.reasoning_summary_part.done") + "type": Schema.Literal("response.apply_patch_call_operation_diff.delta") }).annotate({ - "description": "Event emitted when a reasoning summary part is complete", - "identifier": "ReasoningSummaryPartDoneEvent" + "description": "Incremental chunk of `operation.diff` for an `apply_patch_call`. Matches OpenAI's streaming shape.", + "identifier": "ApplyPatchCallOperationDiffDeltaEvent" }) -export type Objects_5 = { - readonly "context"?: ReasoningContext - readonly "effort"?: ReasoningEffort - readonly "mode"?: ReasoningMode - readonly "summary"?: ReasoningSummaryVerbosity - readonly [x: string]: Schema.Json -} -export const Objects_5 = Schema.StructWithRest( - Schema.Struct({ - "context": Schema.optionalKey(ReasoningContext), - "effort": Schema.optionalKey(ReasoningEffort), - "mode": Schema.optionalKey(ReasoningMode), - "summary": Schema.optionalKey(ReasoningSummaryVerbosity) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type Union_13 = { - readonly "context"?: ReasoningContext - readonly "effort"?: ReasoningEffort - readonly "mode"?: ReasoningMode - readonly "summary"?: ReasoningSummaryVerbosity - readonly "enabled"?: boolean | null - readonly "max_tokens"?: number | null -} -export const Union_13 = Schema.Union([Schema.Struct({ - "context": Schema.optionalKey(ReasoningContext), - "effort": Schema.optionalKey(ReasoningEffort), - "mode": Schema.optionalKey(ReasoningMode), - "summary": Schema.optionalKey(ReasoningSummaryVerbosity), - "enabled": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "max_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ) -})]) -export type OutputItemReasoning = { - readonly "content"?: ReadonlyArray - readonly "encrypted_content"?: string | null - readonly "id": string - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "summary": ReadonlyArray - readonly "type": "reasoning" +export type ApplyPatchCallOperationDiffDoneEvent = { + readonly "diff": string + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.apply_patch_call_operation_diff.done" } -export const OutputItemReasoning = Schema.Struct({ - "content": Schema.optionalKey(Schema.Array(ReasoningTextContent)), - "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "id": Schema.String, - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "summary": Schema.Array(ReasoningSummaryText), - "type": Schema.Literal("reasoning") -}).annotate({ "identifier": "OutputItemReasoning" }) -export type RequestMetadata = Objects_149 | null -export const RequestMetadata = Schema.Union([Objects_149, Schema.Null]).annotate({ - "description": - "Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.", - "identifier": "RequestMetadata" +export const ApplyPatchCallOperationDiffDoneEvent = Schema.Struct({ + "diff": Schema.String, + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.apply_patch_call_operation_diff.done") +}).annotate({ + "description": "Emitted when `operation.diff` streaming completes for an `apply_patch_call`.", + "identifier": "ApplyPatchCallOperationDiffDoneEvent" }) -export type RequestTimeoutResponse = { - readonly "error": RequestTimeoutResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null +export type FusionCallInProgressEvent = { + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.fusion_call.in_progress" } -export const RequestTimeoutResponse = Schema.Struct({ - "error": RequestTimeoutResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +export const FusionCallInProgressEvent = Schema.Struct({ + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.fusion_call.in_progress") }).annotate({ - "description": "Request Timeout - Operation exceeded time limit", - "identifier": "RequestTimeoutResponse" + "description": "Emitted when an openrouter:fusion tool call begins executing.", + "identifier": "FusionCallInProgressEvent" }) -export type Arrays_10 = ReadonlyArray -export const Arrays_10 = Schema.Array(RouterAttempt) -export type ChatSearchModelsServerTool = { - readonly "parameters"?: SearchModelsServerToolConfig - readonly "type": "openrouter:experimental__search_models" +export type FusionCallPanelAddedEvent = { + readonly "item_id": string + readonly "model": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.fusion_call.panel.added" } -export const ChatSearchModelsServerTool = Schema.Struct({ - "parameters": Schema.optionalKey(SearchModelsServerToolConfig), - "type": Schema.Literal("openrouter:experimental__search_models") +export const FusionCallPanelAddedEvent = Schema.Struct({ + "item_id": Schema.String, + "model": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.fusion_call.panel.added") }).annotate({ - "description": "OpenRouter built-in server tool: searches and filters AI models available on OpenRouter", - "identifier": "ChatSearchModelsServerTool" + "description": "Emitted when a fusion analysis-panel model starts.", + "identifier": "FusionCallPanelAddedEvent" }) -export type MessagesSearchModelsServerTool = { - readonly "parameters"?: SearchModelsServerToolConfig - readonly "type": "openrouter:experimental__search_models" +export type FusionCallPanelDeltaEvent = { + readonly "delta": string + readonly "item_id": string + readonly "model": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.fusion_call.panel.delta" } -export const MessagesSearchModelsServerTool = Schema.Struct({ - "parameters": Schema.optionalKey(SearchModelsServerToolConfig), - "type": Schema.Literal("openrouter:experimental__search_models") +export const FusionCallPanelDeltaEvent = Schema.Struct({ + "delta": Schema.String, + "item_id": Schema.String, + "model": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.fusion_call.panel.delta") }).annotate({ - "description": "OpenRouter built-in server tool: searches and filters AI models available on OpenRouter", - "identifier": "MessagesSearchModelsServerTool" + "description": "Incremental content token from a fusion panel model.", + "identifier": "FusionCallPanelDeltaEvent" }) -export type SearchModelsServerTool_OpenRouter = { - readonly "parameters"?: SearchModelsServerToolConfig - readonly "type": "openrouter:experimental__search_models" +export type FusionCallPanelReasoningDeltaEvent = { + readonly "delta": string + readonly "item_id": string + readonly "model": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.fusion_call.panel.reasoning.delta" } -export const SearchModelsServerTool_OpenRouter = Schema.Struct({ - "parameters": Schema.optionalKey(SearchModelsServerToolConfig), - "type": Schema.Literal("openrouter:experimental__search_models") +export const FusionCallPanelReasoningDeltaEvent = Schema.Struct({ + "delta": Schema.String, + "item_id": Schema.String, + "model": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.fusion_call.panel.reasoning.delta") }).annotate({ - "description": "OpenRouter built-in server tool: searches and filters AI models available on OpenRouter", - "identifier": "SearchModelsServerTool_OpenRouter" + "description": "Incremental reasoning token from a fusion panel model.", + "identifier": "FusionCallPanelReasoningDeltaEvent" }) -export type ServerToolUseDetails = Objects_150 | null -export const ServerToolUseDetails = Schema.Union([Objects_150, Schema.Null]).annotate({ - "description": "Usage for server-side tool execution (e.g., web search)", - "identifier": "ServerToolUseDetails" +export type FusionCallPanelCompletedEvent = { + readonly "content": string + readonly "item_id": string + readonly "model": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.fusion_call.panel.completed" +} +export const FusionCallPanelCompletedEvent = Schema.Struct({ + "content": Schema.String, + "item_id": Schema.String, + "model": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.fusion_call.panel.completed") +}).annotate({ + "description": "Emitted when a fusion panel model finishes with its full content.", + "identifier": "FusionCallPanelCompletedEvent" }) -export type ServiceUnavailableResponse = { - readonly "error": ServiceUnavailableResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null +export type FusionCallPanelFailedEvent = { + readonly "error": string + readonly "item_id": string + readonly "model": string + readonly "output_index": number + readonly "sequence_number": number + readonly "status_code"?: number + readonly "type": "response.fusion_call.panel.failed" } -export const ServiceUnavailableResponse = Schema.Struct({ - "error": ServiceUnavailableResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +export const FusionCallPanelFailedEvent = Schema.Struct({ + "error": Schema.String, + "item_id": Schema.String, + "model": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "status_code": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "type": Schema.Literal("response.fusion_call.panel.failed") +}).annotate({ "description": "Emitted when a fusion panel model fails.", "identifier": "FusionCallPanelFailedEvent" }) +export type FusionCallAnalysisInProgressEvent = { + readonly "analyst_model": string + readonly "item_id": string + readonly "judge_model": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.fusion_call.analysis.in_progress" +} +export const FusionCallAnalysisInProgressEvent = Schema.Struct({ + "analyst_model": Schema.String.annotate({ "description": "Slug of the model producing the structured analysis." }), + "item_id": Schema.String, + "judge_model": Schema.String.annotate({ + "description": + "Deprecated alias of `analyst_model`, kept so existing consumers keep working. Always carries the same value. Use `analyst_model`." + }), + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.fusion_call.analysis.in_progress") }).annotate({ - "description": "Service Unavailable - Service temporarily unavailable", - "identifier": "ServiceUnavailableResponse" + "description": "Emitted when the fusion analyst starts producing the structured analysis.", + "identifier": "FusionCallAnalysisInProgressEvent" }) -export type OutputShellCallItem = { - readonly "action"?: { - readonly "commands": ReadonlyArray - readonly "max_output_length": number | null - readonly "timeout_ms": number | null - } - readonly "call_id": string - readonly "id": string - readonly "status": ShellCallStatus - readonly "type": "shell_call" +export type FusionCallCompletedEvent = { + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.fusion_call.completed" } -export const OutputShellCallItem = Schema.Struct({ - "action": Schema.optionalKey(Schema.Struct({ - "commands": Schema.Array(Schema.String), - "max_output_length": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]), - "timeout_ms": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]) - })), - "call_id": Schema.String, - "id": Schema.String, - "status": ShellCallStatus, - "type": Schema.Literal("shell_call") +export const FusionCallCompletedEvent = Schema.Struct({ + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.fusion_call.completed") }).annotate({ - "description": - "A native `shell_call` output item matching OpenAI's Responses API shape. Emitted for the sandbox-backed `shell` tool.", - "identifier": "OutputShellCallItem" + "description": "Emitted when the openrouter:fusion tool call finishes.", + "identifier": "FusionCallCompletedEvent" }) -export type OutputShellCallOutputItem = { - readonly "call_id": string - readonly "id": string - readonly "max_output_length"?: number | null - readonly "output": ReadonlyArray< - { - readonly "outcome": { readonly "exit_code": number; readonly "type": "exit" } | { readonly "type": "timeout" } - readonly "stderr": string - readonly "stdout": string +export type DebugEvent = { + readonly "debug": { + readonly "echo_upstream_body"?: {} + readonly "timings"?: { + readonly "epoch_ms": number + readonly "event": "adapter_request" | "upstream_headers_received" | "first_token_received" | "upstream_body_ended" + readonly "start_ms": number } - > - readonly "status": ShellCallStatus - readonly "type": "shell_call_output" + } + readonly "sequence_number": number + readonly "type": "response.debug" } -export const OutputShellCallOutputItem = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.String, - "max_output_length": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "output": Schema.Array(Schema.Struct({ - "outcome": Schema.Union([ - Schema.Struct({ - "exit_code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("exit") - }), - Schema.Struct({ "type": Schema.Literal("timeout") }) - ], { mode: "oneOf" }), - "stderr": Schema.String, - "stdout": Schema.String - })), - "status": ShellCallStatus, - "type": Schema.Literal("shell_call_output") +export const DebugEvent = Schema.Struct({ + "debug": Schema.Struct({ + "echo_upstream_body": Schema.optionalKey(Schema.Struct({})), + "timings": Schema.optionalKey(Schema.Struct({ + "epoch_ms": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "event": Schema.Literals([ + "adapter_request", + "upstream_headers_received", + "first_token_received", + "upstream_body_ended" + ]), + "start_ms": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + })) + }), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.debug") }).annotate({ "description": - "A native `shell_call_output` item matching OpenAI's Responses API shape. Carries per-command stdout, stderr, and the exit/timeout outcome.", - "identifier": "OutputShellCallOutputItem" -}) -export type StopServerToolsWhenCondition = - | StopServerToolsWhenStepCountIs - | StopServerToolsWhenHasToolCall - | StopServerToolsWhenMaxTokensUsed - | StopServerToolsWhenMaxCost - | StopServerToolsWhenFinishReasonIs -export const StopServerToolsWhenCondition = Schema.Union([ - StopServerToolsWhenStepCountIs, - StopServerToolsWhenHasToolCall, - StopServerToolsWhenMaxTokensUsed, - StopServerToolsWhenMaxCost, - StopServerToolsWhenFinishReasonIs -], { mode: "oneOf" }).annotate({ - "description": "A single condition that, when met, halts the server-tool agent loop.", - "identifier": "StopServerToolsWhenCondition" + "Debug event emitted when debug.echo_upstream_body is true. Contains the transformed upstream request body or timing milestones.", + "identifier": "DebugEvent" }) -export type STTResponse = { - readonly "duration"?: number - readonly "language"?: string - readonly "segments"?: ReadonlyArray - readonly "task"?: string - readonly "text": string - readonly "usage"?: STTUsage - readonly "words"?: ReadonlyArray +export type ScimGroupMapping = { + readonly "created_at": string + readonly "id": string + readonly "organization_id": string + readonly "role": "admin" | "member" + readonly "scim_group_id": string + readonly "updated_at": string + readonly "workspace_id": string } -export const STTResponse = Schema.Struct({ - "duration": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Duration of the input audio in seconds, present when response_format is verbose_json", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "language": Schema.optionalKey( - Schema.String.annotate({ - "description": "Detected or forced language, present when response_format is verbose_json" - }) - ), - "segments": Schema.optionalKey( - Schema.Array(STTSegment).annotate({ - "description": "Timestamped transcript segments, present when response_format is verbose_json" - }) - ), - "task": Schema.optionalKey( - Schema.String.annotate({ "description": "The task performed, present when response_format is verbose_json" }) - ), - "text": Schema.String.annotate({ "description": "The transcribed text" }), - "usage": Schema.optionalKey(STTUsage), - "words": Schema.optionalKey( - Schema.Array(STTWord).annotate({ - "description": "Timestamped words, present when the provider returns word-level timestamps" - }) - ) -}).annotate({ - "description": "STT response containing transcribed text and optional usage statistics", - "identifier": "STTResponse" +export const ScimGroupMapping = Schema.Struct({ + "created_at": Schema.String, + "id": Schema.String.annotate({ "format": "uuid" }), + "organization_id": Schema.String, + "role": Schema.Literals(["admin", "member"]), + "scim_group_id": Schema.String.annotate({ "format": "uuid" }), + "updated_at": Schema.String, + "workspace_id": Schema.String.annotate({ "format": "uuid" }) +}).annotate({ "identifier": "ScimGroupMapping" }) +export type CreateScimGroupMappingRequest = { + readonly "role": "admin" | "member" + readonly "scim_group_id": string + readonly "workspace_id": string +} +export const CreateScimGroupMappingRequest = Schema.Struct({ + "role": Schema.Literals(["admin", "member"]), + "scim_group_id": Schema.String.annotate({ "format": "uuid" }), + "workspace_id": Schema.String.annotate({ "format": "uuid" }) +}).annotate({ "identifier": "CreateScimGroupMappingRequest" }) +export type DeleteScimGroupMappingResponse = { readonly "deleted": true } +export const DeleteScimGroupMappingResponse = Schema.Struct({ "deleted": Schema.Literal(true) }).annotate({ + "identifier": "DeleteScimGroupMappingResponse" }) -export type Arrays_12 = ReadonlyArray -export const Arrays_12 = Schema.Array(SubagentNestedTool).annotate({ - "description": - "Tools the subagent may use while executing a delegated task. The subagent runs as an agentic sub-agent over these tools, then returns its outcome. Only OpenRouter server tools are supported — function tools are rejected — and the list must not include the subagent tool itself." +export type UpdateScimGroupMappingRequest = { readonly "role": "admin" | "member" } +export const UpdateScimGroupMappingRequest = Schema.Struct({ "role": Schema.Literals(["admin", "member"]) }).annotate({ + "identifier": "UpdateScimGroupMappingRequest" }) -export type ImageEndpoint = { - readonly "allowed_passthrough_parameters": ReadonlyArray - readonly "pricing": ReadonlyArray - readonly "provider_name": string - readonly "provider_slug": string - readonly "provider_tag": string | null - readonly "supported_parameters": SupportedParameters - readonly "supports_streaming": boolean +export type ScimGroup = { + readonly "created_at": string + readonly "display_name": string + readonly "external_id": string | null + readonly "id": string + readonly "organization_id": string + readonly "updated_at": string } -export const ImageEndpoint = Schema.Struct({ - "allowed_passthrough_parameters": Schema.Array(Schema.String).annotate({ - "description": "Provider-specific options accepted under provider.options[provider_slug]." - }), - "pricing": Schema.Array(ImagePricingEntry).annotate({ "description": "Billable pricing lines for this endpoint." }), - "provider_name": Schema.String.annotate({ "description": "Provider display name" }), - "provider_slug": Schema.String.annotate({ "description": "Provider slug" }), - "provider_tag": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Provider tag for request-side selection" - }), - "supported_parameters": Schema.suspend((): Schema.Codec => SupportedParameters).annotate({ - "description": "The definitive set of parameters this endpoint accepts for this model." - }), - "supports_streaming": Schema.Boolean.annotate({ - "description": "Whether this endpoint supports native SSE streaming (`stream: true` in the request)." - }) -}).annotate({ "description": "An endpoint that serves a given image model.", "identifier": "ImageEndpoint" }) -export type TaskClassificationItem = { - readonly "category_token_share": number - readonly "category_usage_share": number - readonly "display_name": string - readonly "macro_category": string - readonly "models": ReadonlyArray - readonly "tag": string - readonly "token_share": number - readonly "usage_share": number +export const ScimGroup = Schema.Struct({ + "created_at": Schema.String, + "display_name": Schema.String, + "external_id": Schema.Union([Schema.String, Schema.Null]), + "id": Schema.String.annotate({ "format": "uuid" }), + "organization_id": Schema.String, + "updated_at": Schema.String +}).annotate({ "identifier": "ScimGroup" }) +export type FrameImage = { + readonly "image_url": { readonly "url": string } + readonly "type": "image_url" + readonly "frame_type": "first_frame" | "last_frame" } -export const TaskClassificationItem = Schema.Struct({ - "category_token_share": Schema.Number.annotate({ - "description": - "Fraction of this classification's token volume within its macro-category (0–1). Sums to 1 across all classifications sharing the same `macro_category`.", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "category_usage_share": Schema.Number.annotate({ - "description": - "Fraction of this classification's usage within its macro-category (0–1). Sums to 1 across all classifications sharing the same `macro_category`.", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "display_name": Schema.String.annotate({ "description": "Human-readable label for the classification." }), - "macro_category": Schema.String.annotate({ - "description": "Coarse grouping derived from the tag prefix: `code`, `data`, `agent`, or `general`." - }), - "models": Schema.Array(TaskClassificationModel).annotate({ - "description": - "Top models for this classification by request volume, sorted descending. Each entry reports the model's share of this classification's requests and tokens." - }), - "tag": Schema.String.annotate({ - "description": "Classification tag identifier (e.g. `code:general_impl`, `agent:web_search`)." - }), - "token_share": Schema.Number.annotate({ - "description": - "Fraction of classified sampled token volume (prompt + completion) attributed to this classification (0–1). The unclassified `other` bucket is excluded from the denominator.", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "usage_share": Schema.Number.annotate({ - "description": - "Fraction of classified sampled requests attributed to this classification (0–1). The unclassified `other` bucket is excluded from the denominator.", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) -}).annotate({ "identifier": "TaskClassificationItem" }) -export type CodeInterpreterCallItem = { - readonly "code": string | null - readonly "container_id": string +export const FrameImage = Schema.Struct({ + "image_url": Schema.Struct({ "url": Schema.String }), + "type": Schema.Literal("image_url"), + "frame_type": Schema.Literals(["first_frame", "last_frame"]).annotate({ + "description": "Whether this image represents the first or last frame of the video" + }) +}).annotate({ "identifier": "FrameImage" }) +export type ContentPartAudio = { readonly "audio_url": { readonly "url": string }; readonly "type": "audio_url" } +export const ContentPartAudio = Schema.Struct({ + "audio_url": Schema.Struct({ "url": Schema.String }), + "type": Schema.Literal("audio_url") +}).annotate({ "identifier": "ContentPartAudio" }) +export type ContentPartVideo = { readonly "type": "video_url"; readonly "video_url": { readonly "url": string } } +export const ContentPartVideo = Schema.Struct({ + "type": Schema.Literal("video_url"), + "video_url": Schema.Struct({ "url": Schema.String }) +}).annotate({ "identifier": "ContentPartVideo" }) +export type VideoGenerationUsage = { readonly "cost"?: number | null; readonly "is_byok"?: boolean } +export const VideoGenerationUsage = Schema.Struct({ + "cost": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "The cost of the video generation in USD.", "format": "double" }) + ), + "is_byok": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether the request was made using a Bring Your Own Key configuration." }) + ) +}).annotate({ + "description": "Usage and cost information for the video generation. Available once the job has completed.", + "identifier": "VideoGenerationUsage" +}) +export type VideoModel = { + readonly "allowed_passthrough_parameters": ReadonlyArray + readonly "canonical_slug": string + readonly "created": number + readonly "description"?: string + readonly "generate_audio": boolean | null + readonly "hugging_face_id"?: string | null readonly "id": string - readonly "outputs": + readonly "name": string + readonly "pricing_skus"?: { readonly [x: string]: string } | null + readonly "seed": boolean | null + readonly "supported_aspect_ratios": + | ReadonlyArray<"16:9" | "9:16" | "1:1" | "4:3" | "3:4" | "3:2" | "2:3" | "21:9" | "9:21"> + | null + readonly "supported_durations": ReadonlyArray | null + readonly "supported_frame_images": ReadonlyArray<"first_frame" | "last_frame"> | null + readonly "supported_resolutions": ReadonlyArray<"480p" | "720p" | "768p" | "1080p" | "1K" | "2K" | "4K"> | null + readonly "supported_sizes": | ReadonlyArray< - { readonly "type": "image"; readonly "url": string } | { readonly "logs": string; readonly "type": "logs" } + | "480x480" + | "480x640" + | "480x720" + | "480x854" + | "480x1120" + | "560x752" + | "640x480" + | "640x640" + | "720x480" + | "720x720" + | "720x960" + | "720x1080" + | "720x1280" + | "720x1680" + | "752x560" + | "768x768" + | "768x1024" + | "768x1152" + | "768x1366" + | "768x1792" + | "834x1112" + | "854x480" + | "960x720" + | "960x960" + | "992x432" + | "1024x768" + | "1080x720" + | "1080x1080" + | "1080x1440" + | "1080x1620" + | "1080x1920" + | "1080x2520" + | "1112x834" + | "1120x480" + | "1152x768" + | "1280x720" + | "1366x768" + | "1440x1080" + | "1440x1440" + | "1440x1920" + | "1440x2160" + | "1440x2560" + | "1440x3360" + | "1470x630" + | "1620x1080" + | "1680x720" + | "1792x768" + | "1920x1080" + | "1920x1440" + | "2160x1440" + | "2160x2160" + | "2160x2880" + | "2160x3240" + | "2160x3840" + | "2160x5040" + | "2520x1080" + | "2560x1440" + | "2880x2160" + | "3240x2160" + | "3360x1440" + | "3840x2160" + | "5040x2160" > | null - readonly "status": ToolCallStatus - readonly "type": "code_interpreter_call" } -export const CodeInterpreterCallItem = Schema.Struct({ - "code": Schema.Union([Schema.String, Schema.Null]), - "container_id": Schema.String, - "id": Schema.String, - "outputs": Schema.Union([ +export const VideoModel = Schema.Struct({ + "allowed_passthrough_parameters": Schema.Array(Schema.String).annotate({ + "description": "List of parameters that are allowed to be passed through to the provider" + }), + "canonical_slug": Schema.String.annotate({ "description": "Canonical slug for the model" }), + "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "description": Schema.optionalKey(Schema.String.annotate({ "description": "Description of the model" })), + "generate_audio": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether the model supports generating audio alongside video" + }), + "hugging_face_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Hugging Face model identifier, if applicable" + }) + ), + "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), + "name": Schema.String.annotate({ "description": "Display name of the model" }), + "pricing_skus": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]).annotate({ + "description": "Pricing SKUs with provider prefix stripped, values as strings" + }) + ), + "seed": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether the model supports deterministic generation via seed parameter" + }), + "supported_aspect_ratios": Schema.Union([ + Schema.Array(Schema.Literals(["16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9", "9:21"])), + Schema.Null + ]).annotate({ "description": "Supported output aspect ratios" }), + "supported_durations": Schema.Union([ + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + Schema.Null + ]).annotate({ "description": "Supported video durations in seconds" }), + "supported_frame_images": Schema.Union([Schema.Array(Schema.Literals(["first_frame", "last_frame"])), Schema.Null]) + .annotate({ "description": "Supported frame image types (e.g. first_frame, last_frame)" }), + "supported_resolutions": Schema.Union([ + Schema.Array(Schema.Literals(["480p", "720p", "768p", "1080p", "1K", "2K", "4K"])), + Schema.Null + ]).annotate({ "description": "Supported output resolutions" }), + "supported_sizes": Schema.Union([ Schema.Array( - Schema.Union([ - Schema.Struct({ "type": Schema.Literal("image"), "url": Schema.String }), - Schema.Struct({ "logs": Schema.String, "type": Schema.Literal("logs") }) + Schema.Literals([ + "480x480", + "480x640", + "480x720", + "480x854", + "480x1120", + "560x752", + "640x480", + "640x640", + "720x480", + "720x720", + "720x960", + "720x1080", + "720x1280", + "720x1680", + "752x560", + "768x768", + "768x1024", + "768x1152", + "768x1366", + "768x1792", + "834x1112", + "854x480", + "960x720", + "960x960", + "992x432", + "1024x768", + "1080x720", + "1080x1080", + "1080x1440", + "1080x1620", + "1080x1920", + "1080x2520", + "1112x834", + "1120x480", + "1152x768", + "1280x720", + "1366x768", + "1440x1080", + "1440x1440", + "1440x1920", + "1440x2160", + "1440x2560", + "1440x3360", + "1470x630", + "1620x1080", + "1680x720", + "1792x768", + "1920x1080", + "1920x1440", + "2160x1440", + "2160x2160", + "2160x2880", + "2160x3240", + "2160x3840", + "2160x5040", + "2520x1080", + "2560x1440", + "2880x2160", + "3240x2160", + "3360x1440", + "3840x2160", + "5040x2160" ]) ), Schema.Null - ]), - "status": ToolCallStatus, - "type": Schema.Literal("code_interpreter_call") -}).annotate({ - "description": "A code interpreter execution call with outputs", - "identifier": "CodeInterpreterCallItem" -}) -export type FunctionCallItem = { - readonly "arguments": string - readonly "call_id": string + ]).annotate({ "description": "Supported output sizes (width x height)" }) +}).annotate({ "identifier": "VideoModel" }) +export type Workspace = { + readonly "created_at": string + readonly "created_by": string | null + readonly "default_guardrail_id": string + readonly "default_image_model": string | null + readonly "default_provider_sort": string | null + readonly "default_text_model": string | null + readonly "description": string | null readonly "id": string + readonly "include_byok_in_budgets"?: boolean + readonly "io_logging_api_key_ids": ReadonlyArray | null + readonly "io_logging_sampling_rate": number + readonly "is_data_discount_logging_enabled": boolean + readonly "is_observability_broadcast_enabled": boolean + readonly "is_observability_io_logging_enabled": boolean readonly "name": string - readonly "namespace"?: string - readonly "status"?: ToolCallStatus - readonly "type": "function_call" + readonly "slug": string + readonly "updated_at": string | null } -export const FunctionCallItem = Schema.Struct({ - "arguments": Schema.String, - "call_id": Schema.String, - "id": Schema.String, - "name": Schema.String, - "namespace": Schema.optionalKey( - Schema.String.annotate({ - "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" +export const Workspace = Schema.Struct({ + "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the workspace was created" }), + "created_by": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "User ID of the workspace creator" + }), + "default_guardrail_id": Schema.String.annotate({ + "description": + "Deterministic ID derived from the workspace ID. The default guardrail is materialized when its configuration is first written.", + "format": "uuid" + }), + "default_image_model": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Default image model for this workspace" + }), + "default_provider_sort": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Default provider sort preference (price, throughput, latency, exacto)" + }), + "default_text_model": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Default text model for this workspace" + }), + "description": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Description of the workspace" }), + "id": Schema.String.annotate({ "description": "Unique identifier for the workspace", "format": "uuid" }), + "include_byok_in_budgets": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether BYOK (bring-your-own-key) spend counts toward this workspace's budgets. Set it via the workspace budget endpoints." }) ), - "status": Schema.optionalKey(ToolCallStatus), - "type": Schema.Literal("function_call") -}).annotate({ "description": "A function call initiated by the model", "identifier": "FunctionCallItem" }) -export type LocalShellCallItem = { - readonly "action": { - readonly "command": ReadonlyArray - readonly "env": {} - readonly "timeout_ms"?: number | null - readonly "type": "exec" - readonly "user"?: string | null - readonly "working_directory"?: string | null - } - readonly "call_id": string - readonly "id": string - readonly "status": ToolCallStatus - readonly "type": "local_shell_call" -} -export const LocalShellCallItem = Schema.Struct({ - "action": Schema.Struct({ - "command": Schema.Array(Schema.String), - "env": Schema.Struct({}), - "timeout_ms": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "type": Schema.Literal("exec"), - "user": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "working_directory": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + "io_logging_api_key_ids": Schema.Union([ + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + Schema.Null + ]).annotate({ + "description": "Optional array of API key IDs to filter I/O logging. Null means all keys are logged." }), - "call_id": Schema.String, - "id": Schema.String, - "status": ToolCallStatus, - "type": Schema.Literal("local_shell_call") -}).annotate({ "description": "A local shell command execution call", "identifier": "LocalShellCallItem" }) -export type LocalShellCallOutputItem = { - readonly "id": string - readonly "output": string - readonly "status"?: ToolCallStatus | null - readonly "type": "local_shell_call_output" -} -export const LocalShellCallOutputItem = Schema.Struct({ - "id": Schema.String, - "output": Schema.String, - "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), - "type": Schema.Literal("local_shell_call_output") -}).annotate({ "description": "Output from a local shell command execution", "identifier": "LocalShellCallOutputItem" }) -export type OpenAIResponseFunctionToolCall = { - readonly "arguments": string - readonly "call_id": string - readonly "id"?: string + "io_logging_sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for I/O logging (0.0001-1). 1 means 100% of requests are logged.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "is_data_discount_logging_enabled": Schema.Boolean.annotate({ + "description": "Whether data discount logging is enabled for this workspace" + }), + "is_observability_broadcast_enabled": Schema.Boolean.annotate({ + "description": "Whether broadcast is enabled for this workspace" + }), + "is_observability_io_logging_enabled": Schema.Boolean.annotate({ + "description": "Whether private logging is enabled for this workspace" + }), + "name": Schema.String.annotate({ "description": "Name of the workspace" }), + "slug": Schema.String.annotate({ "description": "URL-friendly slug for the workspace" }), + "updated_at": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "ISO 8601 timestamp of when the workspace was last updated" + }) +}).annotate({ "identifier": "Workspace" }) +export type CreateWorkspaceRequest = { + readonly "default_image_model"?: string | null + readonly "default_provider_sort"?: string | null + readonly "default_text_model"?: string | null + readonly "description"?: string | null + readonly "io_logging_api_key_ids"?: ReadonlyArray | null + readonly "io_logging_sampling_rate"?: number + readonly "is_data_discount_logging_enabled"?: boolean + readonly "is_observability_broadcast_enabled"?: boolean + readonly "is_observability_io_logging_enabled"?: boolean readonly "name": string - readonly "namespace"?: string - readonly "status"?: ToolCallStatus - readonly "type": "function_call" + readonly "slug": string } -export const OpenAIResponseFunctionToolCall = Schema.Struct({ - "arguments": Schema.String, - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), - "name": Schema.String, - "namespace": Schema.optionalKey( - Schema.String.annotate({ - "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" - }) +export const CreateWorkspaceRequest = Schema.Struct({ + "default_image_model": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Default image model for this workspace" }) ), - "status": Schema.optionalKey(ToolCallStatus), - "type": Schema.Literal("function_call") -}).annotate({ "identifier": "OpenAIResponseFunctionToolCall" }) -export type OutputAdvisorServerToolItem = { - readonly "advice"?: string - readonly "error"?: string - readonly "id"?: string - readonly "instance_name"?: string - readonly "model"?: string - readonly "prompt"?: string - readonly "status": ToolCallStatus - readonly "type": "openrouter:advisor" -} -export const OutputAdvisorServerToolItem = Schema.Struct({ - "advice": Schema.optionalKey( - Schema.String.annotate({ - "description": "The advisor model's response (the advice text returned to the executor)." + "default_provider_sort": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Default provider sort preference (price, throughput, latency, exacto)" }) ), - "error": Schema.optionalKey( - Schema.String.annotate({ "description": "Error message when the advisor call did not produce advice." }) + "default_text_model": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Default text model for this workspace" }) ), - "id": Schema.optionalKey(Schema.String), - "instance_name": Schema.optionalKey(Schema.String.annotate({ - "description": - "Provider-safe function name of the specific advisor instance that produced this item (e.g. `openrouter_advisor__1`). Present only when more than one advisor tool is configured; omitted for the default single advisor. Echo this field back unchanged so the advisor's cross-request memory stays namespaced to the correct instance. This identity is positional: it is derived from the index of the advisor entry in the request `tools` array, so clients must keep the order of advisor tool entries stable across requests in a conversation. Reordering or inserting advisor entries shifts these names and causes each advisor's cross-request memory to be attributed to the wrong instance." - })), - "model": Schema.optionalKey( - Schema.String.annotate({ "description": "Slug of the advisor model that was consulted." }) + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" })), + Schema.Null + ]).annotate({ "description": "Description of the workspace" }) ), - "prompt": Schema.optionalKey( - Schema.String.annotate({ "description": "The prompt the executor sent to the advisor." }) + "io_logging_api_key_ids": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + Schema.Null + ]).annotate({ "description": "Optional array of API key IDs to filter I/O logging" }) ), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:advisor") -}).annotate({ - "description": "An openrouter:advisor server tool output item", - "identifier": "OutputAdvisorServerToolItem" -}) -export type OutputBashServerToolItem = { - readonly "arguments"?: string - readonly "call_id"?: string - readonly "command"?: string - readonly "exitCode"?: number - readonly "id"?: string - readonly "status": ToolCallStatus - readonly "stderr"?: string - readonly "stdout"?: string - readonly "type": "openrouter:bash" -} -export const OutputBashServerToolItem = Schema.Struct({ - "arguments": Schema.optionalKey( - Schema.String.annotate({ "description": "The raw tool-call arguments string as emitted by the model." }) + "io_logging_sampling_rate": Schema.optionalKey( + Schema.Number.annotate({ "description": "Sampling rate for I/O logging (0.0001-1)", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) ), - "call_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The model-generated tool call id from the originating turn." }) + "is_data_discount_logging_enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether data discount logging is enabled" }) ), - "command": Schema.optionalKey(Schema.String), - "exitCode": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "id": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "stderr": Schema.optionalKey(Schema.String), - "stdout": Schema.optionalKey(Schema.String), - "type": Schema.Literal("openrouter:bash") -}).annotate({ "description": "An openrouter:bash server tool output item", "identifier": "OutputBashServerToolItem" }) -export type OutputBrowserUseServerToolItem = { - readonly "action"?: string - readonly "id"?: string - readonly "screenshotB64"?: string - readonly "status": ToolCallStatus - readonly "type": "openrouter:browser_use" + "is_observability_broadcast_enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether broadcast is enabled" }) + ), + "is_observability_io_logging_enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether private logging is enabled" }) + ), + "name": Schema.String.annotate({ "description": "Name for the new workspace" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })), + "slug": Schema.String.annotate({ + "description": + "URL-friendly slug (lowercase alphanumeric segments separated by single hyphens, no leading/trailing hyphens)" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(50).annotate({ "expected": "a value with a length of at most 50" }) + ).check( + Schema.isPattern(new RegExp("^[a-z0-9]+(?:-[a-z0-9]+)*$")).annotate({ + "expected": "a string matching the RegExp ^[a-z0-9]+(?:-[a-z0-9]+)*$" + }) + ) +}).annotate({ "identifier": "CreateWorkspaceRequest" }) +export type DeleteWorkspaceResponse = { readonly "deleted": true } +export const DeleteWorkspaceResponse = Schema.Struct({ + "deleted": Schema.Literal(true).annotate({ "description": "Confirmation that the workspace was deleted" }) +}).annotate({ "identifier": "DeleteWorkspaceResponse" }) +export type UpdateWorkspaceRequest = { + readonly "default_image_model"?: string | null + readonly "default_provider_sort"?: string | null + readonly "default_text_model"?: string | null + readonly "description"?: string | null + readonly "io_logging_api_key_ids"?: ReadonlyArray | null + readonly "io_logging_sampling_rate"?: number + readonly "is_data_discount_logging_enabled"?: boolean + readonly "is_observability_broadcast_enabled"?: boolean + readonly "is_observability_io_logging_enabled"?: boolean + readonly "name"?: string + readonly "slug"?: string } -export const OutputBrowserUseServerToolItem = Schema.Struct({ - "action": Schema.optionalKey(Schema.String), - "id": Schema.optionalKey(Schema.String), - "screenshotB64": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:browser_use") -}).annotate({ - "description": "An openrouter:browser_use server tool output item", - "identifier": "OutputBrowserUseServerToolItem" -}) -export type OutputCodeInterpreterCallItem = { - readonly "code": string | null - readonly "container_id": string +export const UpdateWorkspaceRequest = Schema.Struct({ + "default_image_model": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Default image model for this workspace" }) + ), + "default_provider_sort": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Default provider sort preference (price, throughput, latency, exacto)" + }) + ), + "default_text_model": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Default text model for this workspace" }) + ), + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(500).annotate({ "expected": "a value with a length of at most 500" })), + Schema.Null + ]).annotate({ "description": "New description for the workspace" }) + ), + "io_logging_api_key_ids": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + Schema.Null + ]).annotate({ "description": "Optional array of API key IDs to filter I/O logging" }) + ), + "io_logging_sampling_rate": Schema.optionalKey( + Schema.Number.annotate({ "description": "Sampling rate for I/O logging (0.0001-1)", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ), + "is_data_discount_logging_enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether data discount logging is enabled" }) + ), + "is_observability_broadcast_enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether broadcast is enabled" }) + ), + "is_observability_io_logging_enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether private logging is enabled" }) + ), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "New name for the workspace" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })) + ), + "slug": Schema.optionalKey( + Schema.String.annotate({ + "description": + "New URL-friendly slug (lowercase alphanumeric segments separated by single hyphens, no leading/trailing hyphens)" + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(50).annotate({ "expected": "a value with a length of at most 50" }) + ).check( + Schema.isPattern(new RegExp("^[a-z0-9]+(?:-[a-z0-9]+)*$")).annotate({ + "expected": "a string matching the RegExp ^[a-z0-9]+(?:-[a-z0-9]+)*$" + }) + ) + ) +}).annotate({ "identifier": "UpdateWorkspaceRequest" }) +export type WorkspaceBudget = { + readonly "created_at": string readonly "id": string - readonly "outputs": - | ReadonlyArray< - { readonly "type": "image"; readonly "url": string } | { readonly "logs": string; readonly "type": "logs" } - > - | null - readonly "status": ToolCallStatus - readonly "type": "code_interpreter_call" + readonly "limit_usd": number + readonly "reset_interval": "daily" | "weekly" | "monthly" | null + readonly "updated_at": string + readonly "workspace_id": string } -export const OutputCodeInterpreterCallItem = Schema.Struct({ - "code": Schema.Union([Schema.String, Schema.Null]), - "container_id": Schema.String, - "id": Schema.String, - "outputs": Schema.Union([ - Schema.Array( - Schema.Union([ - Schema.Struct({ "type": Schema.Literal("image"), "url": Schema.String }), - Schema.Struct({ "logs": Schema.String, "type": Schema.Literal("logs") }) - ]) - ), +export const WorkspaceBudget = Schema.Struct({ + "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the budget was created" }), + "id": Schema.String.annotate({ "description": "Unique identifier for the budget", "format": "uuid" }), + "limit_usd": Schema.Number.annotate({ "description": "Spending limit in USD for this interval", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "reset_interval": Schema.Union([ + Schema.Literal("daily"), + Schema.Literal("weekly"), + Schema.Literal("monthly"), Schema.Null - ]), - "status": ToolCallStatus, - "type": Schema.Literal("code_interpreter_call") + ]).annotate({ "description": "Interval at which spend resets. Null means a lifetime (one-time) budget." }), + "updated_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the budget was last updated" }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace the budget belongs to", + "format": "uuid" + }) +}).annotate({ "identifier": "WorkspaceBudget" }) +export type UpsertWorkspaceBudgetRequest = { + readonly "include_byok_in_budgets"?: boolean + readonly "limit_usd": number +} +export const UpsertWorkspaceBudgetRequest = Schema.Struct({ + "include_byok_in_budgets": Schema.optionalKey(Schema.Boolean.annotate({ + "description": + "Whether to include BYOK (bring-your-own-key) spend when enforcing the workspace's budgets. This is a workspace-wide setting: it applies to every budget interval (daily, weekly, monthly, and lifetime), not just the interval being upserted in this request. Omit to leave the current setting unchanged." + })), + "limit_usd": Schema.Number.annotate({ + "description": "Spending limit in USD. Must be greater than 0.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) +}).annotate({ "identifier": "UpsertWorkspaceBudgetRequest" }) +export type DeleteWorkspaceBudgetResponse = { readonly "deleted": true } +export const DeleteWorkspaceBudgetResponse = Schema.Struct({ + "deleted": Schema.Literal(true).annotate({ + "description": "Confirmation that the budget was deleted (or did not exist)" + }) +}).annotate({ "identifier": "DeleteWorkspaceBudgetResponse" }) +export type WorkspaceMember = { + readonly "created_at": string + readonly "id": string + readonly "role": "admin" | "member" + readonly "user_id": string + readonly "workspace_id": string +} +export const WorkspaceMember = Schema.Struct({ + "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the membership was created" }), + "id": Schema.String.annotate({ "description": "Unique identifier for the workspace membership", "format": "uuid" }), + "role": Schema.Literals(["admin", "member"]).annotate({ "description": "Role of the member in the workspace" }), + "user_id": Schema.String.annotate({ "description": "Clerk user ID of the member" }), + "workspace_id": Schema.String.annotate({ "description": "ID of the workspace", "format": "uuid" }) +}).annotate({ "identifier": "WorkspaceMember" }) +export type BulkAddWorkspaceMembersRequest = { readonly "user_ids": ReadonlyArray } +export const BulkAddWorkspaceMembersRequest = Schema.Struct({ + "user_ids": Schema.Array(Schema.String).annotate({ + "description": + "List of user IDs to add to the workspace. Members are assigned the same role they hold in the organization." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) + ) +}).annotate({ "identifier": "BulkAddWorkspaceMembersRequest" }) +export type BulkRemoveWorkspaceMembersRequest = { readonly "user_ids": ReadonlyArray } +export const BulkRemoveWorkspaceMembersRequest = Schema.Struct({ + "user_ids": Schema.Array(Schema.String).annotate({ "description": "List of user IDs to remove from the workspace" }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) + ) +}).annotate({ "identifier": "BulkRemoveWorkspaceMembersRequest" }) +export type BulkRemoveWorkspaceMembersResponse = { readonly "removed_count": number } +export const BulkRemoveWorkspaceMembersResponse = Schema.Struct({ + "removed_count": Schema.Number.annotate({ "description": "Number of members removed" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "BulkRemoveWorkspaceMembersResponse" }) +export type ActivityResponse = { readonly "data": ReadonlyArray } +export const ActivityResponse = Schema.Struct({ + "data": Schema.Array(ActivityItem).annotate({ "description": "List of activity items" }) +}).annotate({ "identifier": "ActivityResponse" }) +export type BadRequestResponse = { + readonly "error": BadRequestResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null +} +export const BadRequestResponse = Schema.Struct({ + "error": BadRequestResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ), + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": "A code interpreter execution call with outputs", - "identifier": "OutputCodeInterpreterCallItem" + "description": "Bad Request - Invalid request parameters or malformed input", + "identifier": "BadRequestResponse" }) -export type OutputCodeInterpreterServerToolItem = { - readonly "code"?: string - readonly "exitCode"?: number - readonly "id"?: string - readonly "language"?: string - readonly "status": ToolCallStatus - readonly "stderr"?: string - readonly "stdout"?: string - readonly "type": "openrouter:code_interpreter" +export type UnauthorizedResponse = { + readonly "error": UnauthorizedResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null } -export const OutputCodeInterpreterServerToolItem = Schema.Struct({ - "code": Schema.optionalKey(Schema.String), - "exitCode": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "id": Schema.optionalKey(Schema.String), - "language": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "stderr": Schema.optionalKey(Schema.String), - "stdout": Schema.optionalKey(Schema.String), - "type": Schema.Literal("openrouter:code_interpreter") +export const UnauthorizedResponse = Schema.Struct({ + "error": UnauthorizedResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ), + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": "An openrouter:code_interpreter server tool output item", - "identifier": "OutputCodeInterpreterServerToolItem" + "description": "Unauthorized - Authentication required or invalid credentials", + "identifier": "UnauthorizedResponse" }) -export type OutputDatetimeItem = { - readonly "datetime": string - readonly "id"?: string - readonly "status": ToolCallStatus - readonly "timezone": string - readonly "type": "openrouter:datetime" -} -export const OutputDatetimeItem = Schema.Struct({ - "datetime": Schema.String.annotate({ "description": "ISO 8601 datetime string" }), - "id": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "timezone": Schema.String.annotate({ "description": "IANA timezone name" }), - "type": Schema.Literal("openrouter:datetime") -}).annotate({ "description": "An openrouter:datetime server tool output item", "identifier": "OutputDatetimeItem" }) -export type OutputFileSearchServerToolItem = { - readonly "id"?: string - readonly "queries"?: ReadonlyArray - readonly "status": ToolCallStatus - readonly "type": "openrouter:file_search" +export type ForbiddenResponse = { + readonly "error": ForbiddenResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null } -export const OutputFileSearchServerToolItem = Schema.Struct({ - "id": Schema.optionalKey(Schema.String), - "queries": Schema.optionalKey(Schema.Array(Schema.String)), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:file_search") +export const ForbiddenResponse = Schema.Struct({ + "error": ForbiddenResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ), + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": "An openrouter:file_search server tool output item", - "identifier": "OutputFileSearchServerToolItem" + "description": "Forbidden - Authentication successful but insufficient permissions", + "identifier": "ForbiddenResponse" }) -export type OutputFilesServerToolItem = { - readonly "error"?: string - readonly "file_id"?: string - readonly "filename"?: string - readonly "id"?: string - readonly "operation"?: string - readonly "result"?: string - readonly "status": ToolCallStatus - readonly "type": "openrouter:files" +export type NotFoundResponse = { + readonly "error": NotFoundResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null } -export const OutputFilesServerToolItem = Schema.Struct({ - "error": Schema.optionalKey( - Schema.String.annotate({ "description": "Error message when the file operation failed." }) +export const NotFoundResponse = Schema.Struct({ + "error": NotFoundResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "file_id": Schema.optionalKey( - Schema.String.annotate({ "description": "The target file id supplied in the tool-call arguments." }) + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +}).annotate({ "description": "Not Found - Resource does not exist", "identifier": "NotFoundResponse" }) +export type InternalServerResponse = { + readonly "error": InternalServerResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null +} +export const InternalServerResponse = Schema.Struct({ + "error": InternalServerResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "filename": Schema.optionalKey( - Schema.String.annotate({ "description": "The target filename supplied in the tool-call arguments." }) + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +}).annotate({ + "description": "Internal Server Error - Unexpected server error", + "identifier": "InternalServerResponse" +}) +export type RequestTimeoutResponse = { + readonly "error": RequestTimeoutResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null +} +export const RequestTimeoutResponse = Schema.Struct({ + "error": RequestTimeoutResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "id": Schema.optionalKey(Schema.String), - "operation": Schema.optionalKey( - Schema.String.annotate({ "description": "The file operation performed (list, read, write, or edit)." }) + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +}).annotate({ + "description": "Request Timeout - Operation exceeded time limit", + "identifier": "RequestTimeoutResponse" +}) +export type SpeechInputReferenceAudio = { + readonly "input_audio": SpeechInputReferenceAudioInput + readonly "type": "input_audio" +} +export const SpeechInputReferenceAudio = Schema.Struct({ + "input_audio": SpeechInputReferenceAudioInput, + "type": Schema.Literal("input_audio") +}).annotate({ + "description": "Reference audio input for stateless voice cloning", + "identifier": "SpeechInputReferenceAudio" +}) +export type PaymentRequiredResponse = { + readonly "error": PaymentRequiredResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null +} +export const PaymentRequiredResponse = Schema.Struct({ + "error": PaymentRequiredResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "result": Schema.optionalKey( - Schema.String.annotate({ "description": "JSON-serialized result of the file operation." }) + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +}).annotate({ + "description": "Payment Required - Insufficient credits or quota to complete request", + "identifier": "PaymentRequiredResponse" +}) +export type TooManyRequestsResponse = { + readonly "error": TooManyRequestsResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null +} +export const TooManyRequestsResponse = Schema.Struct({ + "error": TooManyRequestsResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:files") -}).annotate({ "description": "An openrouter:files server tool output item", "identifier": "OutputFilesServerToolItem" }) -export type OutputImageGenerationServerToolItem = { - readonly "id"?: string - readonly "imageB64"?: string - readonly "imageUrl"?: string - readonly "prompt"?: string - readonly "result"?: string | null - readonly "revisedPrompt"?: string - readonly "status": ToolCallStatus - readonly "type": "openrouter:image_generation" + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +}).annotate({ "description": "Too Many Requests - Rate limit exceeded", "identifier": "TooManyRequestsResponse" }) +export type BadGatewayResponse = { + readonly "error": BadGatewayResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null } -export const OutputImageGenerationServerToolItem = Schema.Struct({ - "id": Schema.optionalKey(Schema.String), - "imageB64": Schema.optionalKey(Schema.String), - "imageUrl": Schema.optionalKey(Schema.String), - "prompt": Schema.optionalKey( - Schema.String.annotate({ "description": "The prompt (possibly rewritten) that the image was generated from." }) +export const BadGatewayResponse = Schema.Struct({ + "error": BadGatewayResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "result": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "The generated image as a base64-encoded string or URL, matching OpenAI image_generation_call format" - }) + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +}).annotate({ "description": "Bad Gateway - Provider/upstream API failure", "identifier": "BadGatewayResponse" }) +export type ServiceUnavailableResponse = { + readonly "error": ServiceUnavailableResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null +} +export const ServiceUnavailableResponse = Schema.Struct({ + "error": ServiceUnavailableResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "revisedPrompt": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:image_generation") + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": "An openrouter:image_generation server tool output item", - "identifier": "OutputImageGenerationServerToolItem" + "description": "Service Unavailable - Service temporarily unavailable", + "identifier": "ServiceUnavailableResponse" }) -export type OutputMcpServerToolItem = { - readonly "id"?: string - readonly "serverLabel"?: string - readonly "status": ToolCallStatus - readonly "toolName"?: string - readonly "type": "openrouter:mcp" -} -export const OutputMcpServerToolItem = Schema.Struct({ - "id": Schema.optionalKey(Schema.String), - "serverLabel": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "toolName": Schema.optionalKey(Schema.String), - "type": Schema.Literal("openrouter:mcp") -}).annotate({ "description": "An openrouter:mcp server tool output item", "identifier": "OutputMcpServerToolItem" }) -export type OutputMemoryServerToolItem = { - readonly "action"?: "read" | "write" | "delete" - readonly "id"?: string - readonly "key"?: string - readonly "status": ToolCallStatus - readonly "type": "openrouter:memory" - readonly "value"?: Schema.Json +export type EdgeNetworkTimeoutResponse = { + readonly "error": EdgeNetworkTimeoutResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null } -export const OutputMemoryServerToolItem = Schema.Struct({ - "action": Schema.optionalKey(Schema.Literals(["read", "write", "delete"])), - "id": Schema.optionalKey(Schema.String), - "key": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:memory"), - "value": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })) +export const EdgeNetworkTimeoutResponse = Schema.Struct({ + "error": EdgeNetworkTimeoutResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ), + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": "An openrouter:memory server tool output item", - "identifier": "OutputMemoryServerToolItem" + "description": "Infrastructure Timeout - Provider request timed out at edge network", + "identifier": "EdgeNetworkTimeoutResponse" }) -export type OutputSearchModelsServerToolItem = { - readonly "arguments"?: string - readonly "id"?: string - readonly "query"?: string - readonly "status": ToolCallStatus - readonly "type": "openrouter:experimental__search_models" +export type ProviderOverloadedResponse = { + readonly "error": ProviderOverloadedResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null } -export const OutputSearchModelsServerToolItem = Schema.Struct({ - "arguments": Schema.optionalKey( - Schema.String.annotate({ - "description": "The JSON arguments submitted to the search tool (e.g. {\"query\":\"Claude\"})" - }) +export const ProviderOverloadedResponse = Schema.Struct({ + "error": ProviderOverloadedResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), - "id": Schema.optionalKey(Schema.String), - "query": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:experimental__search_models") + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": "An openrouter:experimental__search_models server tool output item", - "identifier": "OutputSearchModelsServerToolItem" + "description": "Provider Overloaded - Provider is temporarily overloaded", + "identifier": "ProviderOverloadedResponse" }) -export type OutputSubagentServerToolItem = { - readonly "error"?: string - readonly "id"?: string - readonly "instance_name"?: string - readonly "model"?: string - readonly "name"?: string - readonly "outcome"?: string - readonly "status": ToolCallStatus - readonly "task_description"?: string - readonly "task_name"?: string - readonly "type": "openrouter:subagent" +export type STTRequest = { + readonly "input_audio": STTInputAudio + readonly "language"?: string + readonly "model": string + readonly "provider"?: { readonly "options"?: ProviderOptions } + readonly "response_format"?: "json" | "verbose_json" + readonly "temperature"?: number + readonly "timestamp_granularities"?: ReadonlyArray } -export const OutputSubagentServerToolItem = Schema.Struct({ - "error": Schema.optionalKey( - Schema.String.annotate({ "description": "Error message when the subagent task did not produce an outcome." }) - ), - "id": Schema.optionalKey(Schema.String), - "instance_name": Schema.optionalKey(Schema.String.annotate({ - "description": - "Provider-safe function name of the specific subagent instance that produced this item (e.g. `openrouter_subagent__1`). Present only on items from non-default instances — the second and later subagent entries in the request `tools` array. The first (default) instance omits it, even when multiple subagents are configured. When a replayed item echoes this field back, the transcript rehydrates the call under that instance's tool. This identity is positional: it is derived from the index of the subagent entry in the request `tools` array, so keep the order of subagent entries stable across requests in a conversation." - })), - "model": Schema.optionalKey( - Schema.String.annotate({ "description": "Slug of the worker model that executed the task." }) - ), - "name": Schema.optionalKey( +export const STTRequest = Schema.Struct({ + "input_audio": STTInputAudio, + "language": Schema.optionalKey( Schema.String.annotate({ - "description": - "Configured name of the subagent that executed the task (the `name` on its tool entry). Present only for named subagents; omitted for an unnamed (default) subagent." + "description": "ISO-639-1 language code (e.g., \"en\", \"ja\"). Auto-detected if omitted." }) ), - "outcome": Schema.optionalKey( - Schema.String.annotate({ - "description": "The worker model's result (the outcome text returned to the delegating model)." + "model": Schema.String.annotate({ "description": "STT model identifier" }), + "provider": Schema.optionalKey( + Schema.Struct({ "options": Schema.optionalKey(ProviderOptions) }).annotate({ + "description": "Provider-specific passthrough configuration" }) ), - "status": ToolCallStatus, - "task_description": Schema.optionalKey( - Schema.String.annotate({ "description": "The task description the delegating model sent to the worker." }) + "response_format": Schema.optionalKey( + Schema.Literals(["json", "verbose_json"]).annotate({ + "description": + "Output format. \"json\" (default) returns { text, usage }. \"verbose_json\" additionally returns task, language, duration, and segment-level timestamps; only supported by OpenAI-compatible providers." + }) ), - "task_name": Schema.optionalKey( - Schema.String.annotate({ "description": "The short task identifier the delegating model supplied." }) + "temperature": Schema.optionalKey( + Schema.Number.annotate({ "description": "Sampling temperature for transcription", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) ), - "type": Schema.Literal("openrouter:subagent") -}).annotate({ - "description": "An openrouter:subagent server tool output item", - "identifier": "OutputSubagentServerToolItem" -}) -export type OutputTextEditorServerToolItem = { - readonly "command"?: "view" | "create" | "str_replace" | "insert" - readonly "filePath"?: string - readonly "id"?: string - readonly "status": ToolCallStatus - readonly "type": "openrouter:text_editor" -} -export const OutputTextEditorServerToolItem = Schema.Struct({ - "command": Schema.optionalKey(Schema.Literals(["view", "create", "str_replace", "insert"])), - "filePath": Schema.optionalKey(Schema.String), - "id": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:text_editor") -}).annotate({ - "description": "An openrouter:text_editor server tool output item", - "identifier": "OutputTextEditorServerToolItem" -}) -export type OutputToolSearchServerToolItem = { - readonly "id"?: string - readonly "query"?: string - readonly "status": ToolCallStatus - readonly "type": "openrouter:tool_search" -} -export const OutputToolSearchServerToolItem = Schema.Struct({ - "id": Schema.optionalKey(Schema.String), - "query": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:tool_search") -}).annotate({ - "description": "An openrouter:tool_search server tool output item", - "identifier": "OutputToolSearchServerToolItem" -}) -export type OutputWebFetchServerToolItem = { - readonly "content"?: string - readonly "error"?: string - readonly "httpStatus"?: number - readonly "id"?: string - readonly "status": ToolCallStatus - readonly "title"?: string - readonly "type": "openrouter:web_fetch" - readonly "url"?: string -} -export const OutputWebFetchServerToolItem = Schema.Struct({ - "content": Schema.optionalKey(Schema.String), - "error": Schema.optionalKey(Schema.String.annotate({ "description": "The error message if the fetch failed." })), - "httpStatus": Schema.optionalKey( - Schema.Number.annotate({ "description": "The HTTP status code returned by the upstream URL fetch." }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - ), - "id": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "title": Schema.optionalKey(Schema.String), - "type": Schema.Literal("openrouter:web_fetch"), - "url": Schema.optionalKey(Schema.String) -}).annotate({ - "description": "An openrouter:web_fetch server tool output item", - "identifier": "OutputWebFetchServerToolItem" -}) -export type OutputWebSearchServerToolItem = { - readonly "action"?: { - readonly "query": string - readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> - readonly "type": "search" - } - readonly "id"?: string - readonly "status": ToolCallStatus - readonly "type": "openrouter:web_search" -} -export const OutputWebSearchServerToolItem = Schema.Struct({ - "action": Schema.optionalKey( - Schema.Struct({ - "query": Schema.String, - "sources": Schema.optionalKey( - Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) - ), - "type": Schema.Literal("search") - }).annotate({ + "timestamp_granularities": Schema.optionalKey( + Schema.Array(STTTimestampGranularity).annotate({ "description": - "The search action performed, matching OpenAI web_search_call.action shape. Includes the query the model issued and optional source URLs returned by the search provider." + "Timestamp detail levels to include when response_format is \"verbose_json\". \"segment\" returns segment-level timestamps; \"word\" additionally returns word-level timestamps in the words array. Ignored unless response_format is \"verbose_json\"." }) - ), - "id": Schema.optionalKey(Schema.String), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:web_search") + ) }).annotate({ - "description": "An openrouter:web_search server tool output item", - "identifier": "OutputWebSearchServerToolItem" + "description": "Speech-to-text request input. Accepts a JSON body with input_audio containing base64-encoded audio.", + "identifier": "STTRequest" }) -export type ShellCallItem = { - readonly "action": { - readonly "commands": ReadonlyArray - readonly "max_output_length"?: number | null - readonly "timeout_ms"?: number | null - } - readonly "call_id": string - readonly "environment"?: Schema.Json - readonly "id"?: string | null - readonly "status"?: ToolCallStatus | null - readonly "type": "shell_call" -} -export const ShellCallItem = Schema.Struct({ - "action": Schema.Struct({ - "commands": Schema.Array(Schema.String), - "max_output_length": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "timeout_ms": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ) - }), - "call_id": Schema.String, - "environment": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), - "type": Schema.Literal("shell_call") -}).annotate({ "description": "A shell command execution call (newer variant)", "identifier": "ShellCallItem" }) -export type ShellCallOutputItem = { - readonly "call_id": string - readonly "id"?: string | null - readonly "max_output_length"?: number | null - readonly "output": ReadonlyArray< - { readonly "content"?: string | null; readonly "exit_code"?: number | null; readonly "type": string } - > - readonly "status"?: ToolCallStatus | null - readonly "type": "shell_call_output" +export type STTResponse = { + readonly "duration"?: number + readonly "language"?: string + readonly "segments"?: ReadonlyArray + readonly "task"?: string + readonly "text": string + readonly "usage"?: STTUsage + readonly "words"?: ReadonlyArray } -export const ShellCallOutputItem = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "max_output_length": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) +export const STTResponse = Schema.Struct({ + "duration": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Duration of the input audio in seconds, present when response_format is verbose_json", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), - "output": Schema.Array( - Schema.Struct({ - "content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "exit_code": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "type": Schema.String + "language": Schema.optionalKey( + Schema.String.annotate({ + "description": "Detected or forced language, present when response_format is verbose_json" }) ), - "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), - "type": Schema.Literal("shell_call_output") + "segments": Schema.optionalKey( + Schema.Array(STTSegment).annotate({ + "description": "Timestamped transcript segments, present when response_format is verbose_json" + }) + ), + "task": Schema.optionalKey( + Schema.String.annotate({ "description": "The task performed, present when response_format is verbose_json" }) + ), + "text": Schema.String.annotate({ "description": "The transcribed text" }), + "usage": Schema.optionalKey(STTUsage), + "words": Schema.optionalKey( + Schema.Array(STTWord).annotate({ + "description": "Timestamped words, present when the provider returns word-level timestamps" + }) + ) }).annotate({ - "description": "Output from a shell command execution (newer variant)", - "identifier": "ShellCallOutputItem" + "description": "STT response containing transcribed text and optional usage statistics", + "identifier": "STTResponse" }) -export type OpenAIResponsesToolChoice = - | "auto" - | "none" - | "required" - | Objects_11 - | Objects_12 - | ToolChoiceAllowed - | Objects_13 - | Objects_14 -export const OpenAIResponsesToolChoice = Schema.Union([ - Schema.Literal("auto"), - Schema.Literal("none"), - Schema.Literal("required"), - Objects_11, - Objects_12, - ToolChoiceAllowed, - Objects_13, - Objects_14 -]).annotate({ "identifier": "OpenAIResponsesToolChoice" }) -export type TooManyRequestsResponse = { - readonly "error": TooManyRequestsResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null -} -export const TooManyRequestsResponse = Schema.Struct({ - "error": TooManyRequestsResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ "description": "Too Many Requests - Rate limit exceeded", "identifier": "TooManyRequestsResponse" }) -export type UnauthorizedResponse = { - readonly "error": UnauthorizedResponseErrorData +export type ConflictResponse = { + readonly "error": ConflictResponseErrorData readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null readonly "user_id"?: string | null } -export const UnauthorizedResponse = Schema.Struct({ - "error": UnauthorizedResponseErrorData, +export const ConflictResponse = Schema.Struct({ + "error": ConflictResponseErrorData, "openrouter_metadata": Schema.optionalKey( Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) ), "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": "Unauthorized - Authentication required or invalid credentials", - "identifier": "UnauthorizedResponse" + "description": "Conflict - Resource conflict or concurrent modification", + "identifier": "ConflictResponse" }) export type UnifiedBenchmarksAAItem = { readonly "agentic_index": number | null @@ -9754,364 +6897,632 @@ export const UnifiedBenchmarksDAItem = Schema.Struct({ Schema.isFinite().annotate({ "expected": "a finite number" }) ) }).annotate({ "identifier": "UnifiedBenchmarksDAItem" }) -export type UnprocessableEntityResponse = { - readonly "error": UnprocessableEntityResponseErrorData - readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null - readonly "user_id"?: string | null -} -export const UnprocessableEntityResponse = Schema.Struct({ - "error": UnprocessableEntityResponseErrorData, - "openrouter_metadata": Schema.optionalKey( - Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) - ), - "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ - "description": "Unprocessable Entity - Semantic validation failure", - "identifier": "UnprocessableEntityResponse" -}) -export type OpenAIResponsesAnnotation = FileCitation | URLCitation | FilePath -export const OpenAIResponsesAnnotation = Schema.Union([FileCitation, URLCitation, FilePath]).annotate({ - "identifier": "OpenAIResponsesAnnotation" -}) -export type VideoGenerationResponse = { - readonly "error"?: string - readonly "generation_id"?: string +export type BYOKKey = { + readonly "allowed_api_key_hashes": ReadonlyArray | null + readonly "allowed_models": ReadonlyArray | null + readonly "allowed_user_ids": ReadonlyArray | null + readonly "created_at": string + readonly "disabled": boolean readonly "id": string - readonly "polling_url": string - readonly "status": "pending" | "in_progress" | "completed" | "failed" | "cancelled" | "expired" - readonly "unsigned_urls"?: ReadonlyArray - readonly "usage"?: VideoGenerationUsage + readonly "is_fallback": boolean + readonly "label": string + readonly "name"?: string | null + readonly "provider": BYOKProviderSlug + readonly "sort_order": number + readonly "workspace_id": string | null } -export const VideoGenerationResponse = Schema.Struct({ - "error": Schema.optionalKey(Schema.String), - "generation_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "The generation ID associated with this video generation job. Available once the job has been processed." +export const BYOKKey = Schema.Struct({ + "allowed_api_key_hashes": Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) + ), + Schema.Null + ]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction." + }), + "allowed_models": Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) + ), + Schema.Null + ]).annotate({ + "description": "Optional allowlist of model slugs this credential may be used for. `null` means no restriction." + }), + "allowed_user_ids": Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) + ), + Schema.Null + ]).annotate({ + "description": "Optional allowlist of user IDs that may use this credential. `null` means no restriction." + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the credential was created." }), + "disabled": Schema.Boolean.annotate({ "description": "Whether this credential is currently disabled." }), + "id": Schema.String.annotate({ + "description": "Stable public identifier for this BYOK credential.", + "format": "uuid" + }), + "is_fallback": Schema.Boolean.annotate({ + "description": + "Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried." + }), + "label": Schema.String.annotate({ + "description": "Short masked snippet of the key (e.g. the first/last few characters) used to identify it in the UI." + }), + "name": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Optional human-readable name for the credential." }) ), - "id": Schema.String, - "polling_url": Schema.String, - "status": Schema.Literals(["pending", "in_progress", "completed", "failed", "cancelled", "expired"]), - "unsigned_urls": Schema.optionalKey(Schema.Array(Schema.String)), - "usage": Schema.optionalKey(VideoGenerationUsage) -}).annotate({ "identifier": "VideoGenerationResponse" }) -export type VideoModelsListResponse = { readonly "data": ReadonlyArray } -export const VideoModelsListResponse = Schema.Struct({ "data": Schema.Array(VideoModel) }).annotate({ - "identifier": "VideoModelsListResponse" -}) -export type WebFetchServerToolConfig = { - readonly "allowed_domains"?: Arrays_13 - readonly "blocked_domains"?: Arrays_14 - readonly "engine"?: WebFetchEngineEnum - readonly "max_content_tokens"?: number - readonly "max_uses"?: number -} -export const WebFetchServerToolConfig = Schema.Struct({ - "allowed_domains": Schema.optionalKey(Arrays_13), - "blocked_domains": Schema.optionalKey(Arrays_14), - "engine": Schema.optionalKey(WebFetchEngineEnum), - "max_content_tokens": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Maximum content length in approximate tokens. Content exceeding this limit is truncated." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ), - "max_uses": Schema.optionalKey( - Schema.Number.annotate({ - "description": "Maximum number of web fetches per request. Once exceeded, the tool returns an error." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ) -}).annotate({ - "description": "Configuration for the openrouter:web_fetch server tool", - "identifier": "WebFetchServerToolConfig" -}) -export type WebSearchDomainFilter = Objects_152 | null -export const WebSearchDomainFilter = Schema.Union([Objects_152, Schema.Null]).annotate({ - "identifier": "WebSearchDomainFilter" -}) -export type WebSearchPlugin = { - readonly "enabled"?: boolean - readonly "engine"?: WebSearchEngine - readonly "exclude_domains"?: ReadonlyArray - readonly "id": "web" - readonly "include_domains"?: ReadonlyArray - readonly "max_results"?: number - readonly "max_uses"?: number - readonly "search_prompt"?: string - readonly "user_location"?: { - readonly "city"?: string | null - readonly "country"?: string | null - readonly "region"?: string | null - readonly "timezone"?: string | null - readonly "type": "approximate" - readonly [x: string]: Schema.Json - } + "provider": BYOKProviderSlug, + "sort_order": Schema.Number.annotate({ + "description": "Position within the provider — credentials are tried in ascending sort order." + }).check(Schema.isInt().annotate({ "expected": "an integer" })), + "workspace_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "The workspace this credential is scoped to, or `null` when it is global — usable across every workspace in the account. A `null` value does not mean the default workspace.", + "format": "uuid" + }) +}).annotate({ "identifier": "BYOKKey" }) +export type CreateBYOKKeyRequest = { + readonly "allowed_models"?: ReadonlyArray | null + readonly "allowed_user_ids"?: ReadonlyArray | null + readonly "disabled"?: boolean + readonly "is_fallback"?: boolean + readonly "key": string + readonly "name"?: string | null + readonly "provider": BYOKProviderSlug + readonly "workspace_id"?: string } -export const WebSearchPlugin = Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the web-search plugin for this request. Defaults to true." +export const CreateBYOKKeyRequest = Schema.Struct({ + "allowed_models": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) + ), + Schema.Null + ]).annotate({ + "description": "Optional allowlist of model slugs this credential may be used for. `null` means no restriction." }) ), - "engine": Schema.optionalKey(WebSearchEngine), - "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\")." + "allowed_user_ids": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" }) + ), + Schema.Null + ]).annotate({ + "description": "Optional allowlist of user IDs that may use this credential. `null` means no restriction." }) ), - "id": Schema.Literal("web"), - "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\")." - }) + "disabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this credential should be created in a disabled state." }) ), - "max_results": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "max_uses": Schema.optionalKey( - Schema.Number.annotate({ + "is_fallback": Schema.optionalKey( + Schema.Boolean.annotate({ "description": - "Maximum number of times the model can invoke web search in a single turn. Passed through to native providers that support it (e.g. Anthropic)." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) + "Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried." + }) ), - "search_prompt": Schema.optionalKey(Schema.String), - "user_location": Schema.optionalKey( + "key": Schema.String.annotate({ + "description": + "The raw provider API key or credential. This value is encrypted at rest and never returned in API responses." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "name": Schema.optionalKey( Schema.Union([ - Schema.StructWithRest( - Schema.Struct({ - "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("approximate") - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ).annotate({ - "description": - "Approximate user location for location-biased search results. Passed through to native providers that support it (e.g. Anthropic)." - }) - ]).annotate({ "description": "User location information for web search" }) + Schema.String.check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })), + Schema.Null + ]).annotate({ "description": "Optional human-readable name for the credential." }) + ), + "provider": BYOKProviderSlug, + "workspace_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Optional workspace ID to scope the credential to. When omitted, the credential is created in the account's default workspace; if that default has been deleted, the request returns a 400 and you must pass `workspace_id` explicitly.", + "format": "uuid" + }) ) -}).annotate({ "identifier": "WebSearchPlugin" }) -export type OutputFileSearchCallItem = { - readonly "id": string - readonly "queries": ReadonlyArray - readonly "status": WebSearchStatus - readonly "type": "file_search_call" -} -export const OutputFileSearchCallItem = Schema.Struct({ - "id": Schema.String, - "queries": Schema.Array(Schema.String), - "status": WebSearchStatus, - "type": Schema.Literal("file_search_call") -}).annotate({ "identifier": "OutputFileSearchCallItem" }) -export type OutputItemFileSearchCall = { - readonly "id": string - readonly "queries": ReadonlyArray - readonly "status": WebSearchStatus - readonly "type": "file_search_call" -} -export const OutputItemFileSearchCall = Schema.Struct({ - "id": Schema.String, - "queries": Schema.Array(Schema.String), - "status": WebSearchStatus, - "type": Schema.Literal("file_search_call") -}).annotate({ "identifier": "OutputItemFileSearchCall" }) -export type OutputItemWebSearchCall = { - readonly "action"?: - | { - readonly "queries"?: ReadonlyArray - readonly "query": string - readonly "sources"?: ReadonlyArray - readonly "type": "search" - } - | { readonly "type": "open_page"; readonly "url"?: string | null } - | { readonly "pattern": string; readonly "type": "find_in_page"; readonly "url": string } - readonly "id": string - readonly "status": WebSearchStatus - readonly "type": "web_search_call" +}).annotate({ "identifier": "CreateBYOKKeyRequest" }) +export type AnthropicCacheControlDirective = { readonly "ttl"?: AnthropicCacheControlTtl; readonly "type": "ephemeral" } +export const AnthropicCacheControlDirective = Schema.Struct({ + "ttl": Schema.optionalKey(AnthropicCacheControlTtl), + "type": Schema.Literal("ephemeral") +}).annotate({ + "description": + "Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.", + "identifier": "AnthropicCacheControlDirective" +}) +export type ChatContentCacheControl = { readonly "ttl"?: AnthropicCacheControlTtl; readonly "type": "ephemeral" } +export const ChatContentCacheControl = Schema.Struct({ + "ttl": Schema.optionalKey(AnthropicCacheControlTtl), + "type": Schema.Literal("ephemeral") +}).annotate({ + "description": + "Anthropic-style cache breakpoint for the content part. Interchangeable with the OpenAI-style `prompt_cache_breakpoint` marker: OpenRouter converts between the two based on the provider serving the request.", + "identifier": "ChatContentCacheControl" +}) +export type InputText = { + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint + readonly "text": string + readonly "type": "input_text" } -export const OutputItemWebSearchCall = Schema.Struct({ - "action": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "queries": Schema.optionalKey(Schema.Array(Schema.String)), - "query": Schema.String, - "sources": Schema.optionalKey(Schema.Array(WebSearchSource)), - "type": Schema.Literal("search") - }), - Schema.Struct({ - "type": Schema.Literal("open_page"), - "url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) - }), - Schema.Struct({ "pattern": Schema.String, "type": Schema.Literal("find_in_page"), "url": Schema.String }) - ], { mode: "oneOf" }) - ), - "id": Schema.String, - "status": WebSearchStatus, - "type": Schema.Literal("web_search_call") -}).annotate({ "identifier": "OutputItemWebSearchCall" }) -export type OutputWebSearchCallItem = { - readonly "action"?: - | { - readonly "queries"?: ReadonlyArray - readonly "query": string - readonly "sources"?: ReadonlyArray - readonly "type": "search" - } - | { readonly "type": "open_page"; readonly "url"?: string | null } - | { readonly "pattern": string; readonly "type": "find_in_page"; readonly "url": string } - readonly "id": string - readonly "status": WebSearchStatus - readonly "type": "web_search_call" +export const InputText = Schema.Struct({ + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), + "text": Schema.String, + "type": Schema.Literal("input_text") +}).annotate({ "description": "Text input content item", "identifier": "InputText" }) +export type CustomToolCallOutputItem = { + readonly "call_id": string + readonly "id"?: string + readonly "output": + | string + | ReadonlyArray< + { + readonly "prompt_cache_breakpoint"?: { readonly "mode": "explicit"; readonly [x: string]: Schema.Json } | null + readonly "text": string + readonly "type": "input_text" + } | { + readonly "detail": "auto" | "high" | "low" | "original" + readonly "image_url"?: string | null + readonly "type": never + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint + readonly "text": string + } | { + readonly "file_data"?: string + readonly "file_id"?: string | null + readonly "file_url"?: string + readonly "filename"?: string + readonly "type": never + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint + readonly "text": string + } | { + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint + readonly "text": string + readonly "type": never + readonly "detail": "auto" | "high" | "low" | "original" + readonly "image_url"?: string | null + } | { + readonly "detail": "auto" | "high" | "low" | "original" + readonly "image_url"?: string | null + readonly "type": "input_image" + } | { + readonly "file_data"?: string + readonly "file_id"?: string | null + readonly "file_url"?: string + readonly "filename"?: string + readonly "type": never + readonly "detail": "auto" | "high" | "low" | "original" + readonly "image_url"?: string | null + } | { + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint + readonly "text": string + readonly "type": never + readonly "file_data"?: string + readonly "file_id"?: string | null + readonly "file_url"?: string + readonly "filename"?: string + } | { + readonly "detail": "auto" | "high" | "low" | "original" + readonly "image_url"?: string | null + readonly "type": never + readonly "file_data"?: string + readonly "file_id"?: string | null + readonly "file_url"?: string + readonly "filename"?: string + } | { + readonly "file_data"?: string + readonly "file_id"?: string | null + readonly "file_url"?: string + readonly "filename"?: string + readonly "type": "input_file" + } + > + readonly "type": "custom_tool_call_output" } -export const OutputWebSearchCallItem = Schema.Struct({ - "action": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "queries": Schema.optionalKey(Schema.Array(Schema.String)), - "query": Schema.String, - "sources": Schema.optionalKey(Schema.Array(WebSearchSource)), - "type": Schema.Literal("search") - }), - Schema.Struct({ - "type": Schema.Literal("open_page"), - "url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) - }), - Schema.Struct({ "pattern": Schema.String, "type": Schema.Literal("find_in_page"), "url": Schema.String }) - ], { mode: "oneOf" }) - ), - "id": Schema.String, - "status": WebSearchStatus, - "type": Schema.Literal("web_search_call") -}).annotate({ "identifier": "OutputWebSearchCallItem" }) -export type WebSearchUserLocation = Objects_153 | null -export const WebSearchUserLocation = Schema.Union([Objects_153, Schema.Null]).annotate({ - "description": "User location information for web search", - "identifier": "WebSearchUserLocation" +export const CustomToolCallOutputItem = Schema.Struct({ + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.String), + "output": Schema.Union([ + Schema.Union([Schema.String]), + Schema.Union([Schema.Array(Schema.Union([ + Schema.Union([ + Schema.Struct({ + "prompt_cache_breakpoint": Schema.optionalKey( + Schema.Union([ + Schema.Union([ + Schema.StructWithRest(Schema.Struct({ "mode": Schema.Literal("explicit") }), [ + Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) + ]) + ]).annotate({ + "description": + "Marks an explicit prompt-cache boundary on this content block (OpenAI-style). Everything through the block carrying this marker is part of the candidate cached prefix. Supported natively by OpenAI GPT-5.6 and newer; on providers that use Anthropic-style `cache_control`, OpenRouter converts the marker to that format automatically." + }), + Schema.Union([Schema.Null]).annotate({ + "description": + "Marks an explicit prompt-cache boundary on this content block (OpenAI-style). Everything through the block carrying this marker is part of the candidate cached prefix. Supported natively by OpenAI GPT-5.6 and newer; on providers that use Anthropic-style `cache_control`, OpenRouter converts the marker to that format automatically." + }) + ]).annotate({ + "description": + "Marks an explicit prompt-cache boundary on this content block (OpenAI-style). Everything through the block carrying this marker is part of the candidate cached prefix. Supported natively by OpenAI GPT-5.6 and newer; on providers that use Anthropic-style `cache_control`, OpenRouter converts the marker to that format automatically." + }) + ), + "text": Schema.String, + "type": Schema.Literal("input_text") + }).annotate({ "description": "Text input content item" }), + Schema.Struct({ + "detail": Schema.Literals(["auto", "high", "low", "original"]), + "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Never, + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), + "text": Schema.String + }).annotate({ "description": "Text input content item" }), + Schema.Struct({ + "file_data": Schema.optionalKey(Schema.String), + "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "file_url": Schema.optionalKey(Schema.String), + "filename": Schema.optionalKey(Schema.String), + "type": Schema.Never, + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), + "text": Schema.String + }).annotate({ "description": "Text input content item" }) + ], { mode: "oneOf" }), + Schema.Union([ + Schema.Struct({ + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), + "text": Schema.String, + "type": Schema.Never, + "detail": Schema.Literals(["auto", "high", "low", "original"]), + "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + }).annotate({ "description": "Image input content item" }), + Schema.Struct({ + "detail": Schema.Union([ + Schema.Literal("auto"), + Schema.Literal("high"), + Schema.Literal("low"), + Schema.Literal("original") + ]), + "image_url": Schema.optionalKey(Schema.Union([Schema.Union([Schema.String]), Schema.Union([Schema.Null])])), + "type": Schema.Literal("input_image") + }).annotate({ "description": "Image input content item" }), + Schema.Struct({ + "file_data": Schema.optionalKey(Schema.String), + "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "file_url": Schema.optionalKey(Schema.String), + "filename": Schema.optionalKey(Schema.String), + "type": Schema.Never, + "detail": Schema.Literals(["auto", "high", "low", "original"]), + "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + }).annotate({ "description": "Image input content item" }) + ], { mode: "oneOf" }), + Schema.Union([ + Schema.Struct({ + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), + "text": Schema.String, + "type": Schema.Never, + "file_data": Schema.optionalKey(Schema.String), + "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "file_url": Schema.optionalKey(Schema.String), + "filename": Schema.optionalKey(Schema.String) + }).annotate({ "description": "File input content item" }), + Schema.Struct({ + "detail": Schema.Literals(["auto", "high", "low", "original"]), + "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Never, + "file_data": Schema.optionalKey(Schema.String), + "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "file_url": Schema.optionalKey(Schema.String), + "filename": Schema.optionalKey(Schema.String) + }).annotate({ "description": "File input content item" }), + Schema.Struct({ + "file_data": Schema.optionalKey(Schema.String), + "file_id": Schema.optionalKey(Schema.Union([Schema.Union([Schema.String]), Schema.Union([Schema.Null])])), + "file_url": Schema.optionalKey(Schema.String), + "filename": Schema.optionalKey(Schema.String), + "type": Schema.Literal("input_file") + }).annotate({ "description": "File input content item" }) + ], { mode: "oneOf" }) + ], { mode: "oneOf" }))]) + ]), + "type": Schema.Literal("custom_tool_call_output") +}).annotate({ + "description": + "The output from a custom (freeform-grammar) tool call execution. Mirrors `function_call_output` but is matched to a `custom_tool_call` rather than a `function_call`.", + "identifier": "CustomToolCallOutputItem" }) -export type WebSearchConfig = { - readonly "allowed_domains"?: Arrays_15 - readonly "engine"?: WebSearchEngineEnum - readonly "excluded_domains"?: Arrays_16 - readonly "max_characters"?: number +export type Legacy_ChatContentVideo = { + readonly "type": "input_video" + readonly "video_url": Legacy_ChatContentVideoInput +} +export const Legacy_ChatContentVideo = Schema.Struct({ + "type": Schema.Literal("input_video"), + "video_url": Legacy_ChatContentVideoInput +}).annotate({ + "description": "Video input content part (legacy format - deprecated)", + "identifier": "Legacy_ChatContentVideo" +}) +export type ChatContentVideo = { readonly "type": "video_url"; readonly "video_url": ChatContentVideoInput } +export const ChatContentVideo = Schema.Struct({ + "type": Schema.Literal("video_url"), + "video_url": ChatContentVideoInput +}).annotate({ "description": "Video input content part", "identifier": "ChatContentVideo" }) +export type ReasoningDetailSummary = { + readonly "format"?: ReasoningFormat + readonly "id"?: string | null + readonly "index"?: number + readonly "summary": string + readonly "type": "reasoning.summary" +} +export const ReasoningDetailSummary = Schema.Struct({ + "format": Schema.optionalKey(ReasoningFormat), + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "index": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "summary": Schema.String, + "type": Schema.Literal("reasoning.summary") +}).annotate({ "description": "Reasoning detail summary schema", "identifier": "ReasoningDetailSummary" }) +export type ReasoningDetailEncrypted = { + readonly "data": string + readonly "format"?: ReasoningFormat + readonly "id"?: string | null + readonly "index"?: number + readonly "type": "reasoning.encrypted" +} +export const ReasoningDetailEncrypted = Schema.Struct({ + "data": Schema.String, + "format": Schema.optionalKey(ReasoningFormat), + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "index": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "type": Schema.Literal("reasoning.encrypted") +}).annotate({ "description": "Reasoning detail encrypted schema", "identifier": "ReasoningDetailEncrypted" }) +export type ReasoningDetailText = { + readonly "format"?: ReasoningFormat + readonly "id"?: string | null + readonly "index"?: number + readonly "signature"?: string | null + readonly "text"?: string | null + readonly "type": "reasoning.text" +} +export const ReasoningDetailText = Schema.Struct({ + "format": Schema.optionalKey(ReasoningFormat), + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "index": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "signature": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "text": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("reasoning.text") +}).annotate({ "description": "Reasoning detail text schema", "identifier": "ReasoningDetailText" }) +export type ReasoningDetailServerToolCall = { + readonly "arguments": string + readonly "format"?: ReasoningFormat + readonly "id"?: string | null + readonly "index"?: number + readonly "result": string + readonly "tool_call_id"?: string | null + readonly "tool_name": string + readonly "type": "reasoning.server_tool_call" +} +export const ReasoningDetailServerToolCall = Schema.Struct({ + "arguments": Schema.String, + "format": Schema.optionalKey(ReasoningFormat), + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "index": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "result": Schema.String, + "tool_call_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "tool_name": Schema.String, + "type": Schema.Literal("reasoning.server_tool_call") +}).annotate({ + "description": + "Record of an OpenRouter server-tool invocation (e.g. openrouter:fusion), carried in reasoning_details so a prior tool call can be rehydrated into a later turn of the same conversation.", + "identifier": "ReasoningDetailServerToolCall" +}) +export type ChatModelNames = ReadonlyArray +export const ChatModelNames = Schema.Array( + Schema.suspend((): Schema.Codec => ModelName).annotate({ + "description": "Available OpenRouter chat completion models" + }) +).annotate({ "description": "Models to use for completion", "identifier": "ChatModelNames" }) +export type WebSearchPlugin = { + readonly "enabled"?: boolean + readonly "engine"?: WebSearchEngine + readonly "exclude_domains"?: ReadonlyArray + readonly "id": "web" + readonly "include_domains"?: ReadonlyArray readonly "max_results"?: number - readonly "max_total_results"?: number - readonly "search_context_size"?: SearchQualityLevel - readonly "user_location"?: WebSearchUserLocationServerTool + readonly "max_uses"?: number + readonly "mode"?: WebSearchMode + readonly "search_prompt"?: string + readonly "user_location"?: { + readonly "city"?: string | null + readonly "country"?: string | null + readonly "region"?: string | null + readonly "timezone"?: string | null + readonly "type": "approximate" + readonly [x: string]: Schema.Json + } } -export const WebSearchConfig = Schema.Struct({ - "allowed_domains": Schema.optionalKey(Arrays_15), - "engine": Schema.optionalKey(WebSearchEngineEnum), - "excluded_domains": Schema.optionalKey(Arrays_16), - "max_characters": Schema.optionalKey( - Schema.Number.annotate({ +export const WebSearchPlugin = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the web-search plugin for this request. Defaults to true." + }) + ), + "engine": Schema.optionalKey(WebSearchEngine), + "exclude_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity)." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) + "A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")." + }) ), - "max_results": Schema.optionalKey( - Schema.Number.annotate({ + "id": Schema.Literal("web"), + "include_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) + "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_total_results": Schema.optionalKey( + "max_results": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "max_uses": Schema.optionalKey( Schema.Number.annotate({ "description": - "Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops. Defaults to 50 when not specified." + "Maximum number of times the model can invoke web search in a single turn. Passed through to native providers that support it (e.g. Anthropic)." }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "search_context_size": Schema.optionalKey(SearchQualityLevel), - "user_location": Schema.optionalKey(WebSearchUserLocationServerTool) -}).annotate({ "identifier": "WebSearchConfig" }) -export type WebSearchServerToolConfig = { - readonly "allowed_domains"?: Arrays_17 - readonly "engine"?: WebSearchEngineEnum - readonly "excluded_domains"?: Arrays_18 - readonly "max_characters"?: number - readonly "max_results"?: number - readonly "max_total_results"?: number - readonly "search_context_size"?: SearchQualityLevel - readonly "user_location"?: WebSearchUserLocationServerTool + "mode": Schema.optionalKey(WebSearchMode), + "search_prompt": Schema.optionalKey(Schema.String), + "user_location": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "city": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "country": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "region": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "timezone": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("approximate") + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ).annotate({ + "description": + "Approximate user location for location-biased search results. Passed through to native providers that support it (e.g. Anthropic)." + }) + ]).annotate({ "description": "User location information for web search" }) + ) +}).annotate({ "identifier": "WebSearchPlugin" }) +export type PDFParserOptions = { readonly "engine"?: PDFParserEngine } +export const PDFParserOptions = Schema.Struct({ "engine": Schema.optionalKey(PDFParserEngine) }).annotate({ + "description": "Options for PDF parsing.", + "identifier": "PDFParserOptions" +}) +export type ContextCompressionPlugin = { + readonly "enabled"?: boolean + readonly "engine"?: ContextCompressionEngine + readonly "id": "context-compression" } -export const WebSearchServerToolConfig = Schema.Struct({ - "allowed_domains": Schema.optionalKey(Arrays_17), - "engine": Schema.optionalKey(WebSearchEngineEnum), - "excluded_domains": Schema.optionalKey(Arrays_18), - "max_characters": Schema.optionalKey( - Schema.Number.annotate({ +export const ContextCompressionPlugin = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the context-compression plugin for this request. Defaults to true." + }) + ), + "engine": Schema.optionalKey(ContextCompressionEngine), + "id": Schema.Literal("context-compression") +}).annotate({ "identifier": "ContextCompressionPlugin" }) +export type Prediction = { + readonly "content": string | ReadonlyArray + readonly "type": "content" + readonly [x: string]: Schema.Json +} | null +export const Prediction = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Array(PredictionContentText)]), + "type": Schema.Literal("content") + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ + "description": + "Static predicted output content. Supported models can use this to reduce latency when much of the response is known in advance.", + "identifier": "Prediction" +}) +export type PreferredMaxLatency = number | PercentileLatencyCutoffs | null +export const PreferredMaxLatency = Schema.Union([ + Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + PercentileLatencyCutoffs, + 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.", + "identifier": "PreferredMaxLatency" +}) +export type PreferredMinThroughput = number | PercentileThroughputCutoffs | null +export const PreferredMinThroughput = Schema.Union([ + Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + PercentileThroughputCutoffs, + 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.", + "identifier": "PreferredMinThroughput" +}) +export type ImageGenerationProviderPreferences = { + readonly "allow_fallbacks"?: boolean | null + readonly "ignore"?: ReadonlyArray | null + readonly "only"?: ReadonlyArray | null + readonly "options"?: ProviderOptions + readonly "order"?: ReadonlyArray | null + readonly "sort"?: ProviderSort | ProviderSortConfig | null +} +export const ImageGenerationProviderPreferences = Schema.Struct({ + "allow_fallbacks": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ "description": - "Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity)." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) + "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" + }) ), - "max_results": Schema.optionalKey( - Schema.Number.annotate({ + "ignore": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), Schema.Null]).annotate({ "description": - "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) + "List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request." + }) ), - "max_total_results": Schema.optionalKey( - Schema.Number.annotate({ + "only": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), Schema.Null]).annotate({ "description": - "Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops. Defaults to 50 when not specified." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) + "List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request." + }) ), - "search_context_size": Schema.optionalKey(SearchQualityLevel), - "user_location": Schema.optionalKey(WebSearchUserLocationServerTool) + "options": Schema.optionalKey(ProviderOptions), + "order": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." + }) + ), + "sort": Schema.optionalKey( + Schema.Union([ProviderSort, ProviderSortConfig, Schema.Null]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }) + ) }).annotate({ - "description": "Configuration for the openrouter:web_search server tool", - "identifier": "WebSearchServerToolConfig" + "description": "Provider routing preferences and provider-specific passthrough configuration.", + "identifier": "ImageGenerationProviderPreferences" }) -export type CreateWorkspaceResponse = { readonly "data": Workspace } -export const CreateWorkspaceResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => Workspace).annotate({ "description": "The created workspace" }) -}).annotate({ "identifier": "CreateWorkspaceResponse" }) -export type GetWorkspaceResponse = { readonly "data": Workspace } -export const GetWorkspaceResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => Workspace).annotate({ "description": "The workspace" }) -}).annotate({ "identifier": "GetWorkspaceResponse" }) -export type ListWorkspacesResponse = { readonly "data": ReadonlyArray; readonly "total_count": number } -export const ListWorkspacesResponse = Schema.Struct({ - "data": Schema.Array(Workspace).annotate({ "description": "List of workspaces" }), - "total_count": Schema.Number.annotate({ "description": "Total number of workspaces" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ "identifier": "ListWorkspacesResponse" }) -export type UpdateWorkspaceResponse = { readonly "data": Workspace } -export const UpdateWorkspaceResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => Workspace).annotate({ "description": "The updated workspace" }) -}).annotate({ "identifier": "UpdateWorkspaceResponse" }) -export type ListWorkspaceBudgetsResponse = { readonly "data": ReadonlyArray } -export const ListWorkspaceBudgetsResponse = Schema.Struct({ - "data": Schema.Array(WorkspaceBudget).annotate({ "description": "List of budgets configured for the workspace" }) -}).annotate({ "identifier": "ListWorkspaceBudgetsResponse" }) -export type UpsertWorkspaceBudgetResponse = { readonly "data": WorkspaceBudget } -export const UpsertWorkspaceBudgetResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => WorkspaceBudget).annotate({ - "description": "The created or updated budget" - }) -}).annotate({ "identifier": "UpsertWorkspaceBudgetResponse" }) -export type BulkAddWorkspaceMembersResponse = { - readonly "added_count": number - readonly "data": ReadonlyArray -} -export const BulkAddWorkspaceMembersResponse = Schema.Struct({ - "added_count": Schema.Number.annotate({ "description": "Number of workspace memberships created or updated" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "data": Schema.Array(WorkspaceMember).annotate({ "description": "List of added workspace memberships" }) -}).annotate({ "identifier": "BulkAddWorkspaceMembersResponse" }) -export type ListWorkspaceMembersResponse = { - readonly "data": ReadonlyArray - readonly "total_count": number +export type ChatFormatJsonSchemaConfig = { + readonly "json_schema": ChatJsonSchemaConfig + readonly "type": "json_schema" } -export const ListWorkspaceMembersResponse = Schema.Struct({ - "data": Schema.Array(WorkspaceMember).annotate({ "description": "List of workspace members" }), - "total_count": Schema.Number.annotate({ "description": "Total number of members in the workspace" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ "identifier": "ListWorkspaceMembersResponse" }) +export const ChatFormatJsonSchemaConfig = Schema.Struct({ + "json_schema": ChatJsonSchemaConfig, + "type": Schema.Literal("json_schema") +}).annotate({ + "description": "JSON Schema response format for structured outputs", + "identifier": "ChatFormatJsonSchemaConfig" +}) +export type StopServerToolsWhenCondition = + | StopServerToolsWhenStepCountIs + | StopServerToolsWhenHasToolCall + | StopServerToolsWhenMaxTokensUsed + | StopServerToolsWhenMaxCost + | StopServerToolsWhenFinishReasonIs +export const StopServerToolsWhenCondition = Schema.Union([ + StopServerToolsWhenStepCountIs, + StopServerToolsWhenHasToolCall, + StopServerToolsWhenMaxTokensUsed, + StopServerToolsWhenMaxCost, + StopServerToolsWhenFinishReasonIs +], { mode: "oneOf" }).annotate({ + "description": "A single condition that, when met, halts the server-tool agent loop.", + "identifier": "StopServerToolsWhenCondition" +}) +export type ChatToolChoice = "none" | "auto" | "required" | ChatNamedToolChoice | ChatServerToolChoice +export const ChatToolChoice = Schema.Union([ + Schema.Literal("none"), + Schema.Literal("auto"), + Schema.Literal("required"), + ChatNamedToolChoice, + ChatServerToolChoice +]).annotate({ "description": "Tool choice configuration", "identifier": "ChatToolChoice" }) export type AdvisorServerToolConfig = { readonly "forward_transcript"?: boolean readonly "instructions"?: string @@ -10122,7 +7533,7 @@ export type AdvisorServerToolConfig = { readonly "reasoning"?: AdvisorReasoning readonly "stream"?: boolean readonly "temperature"?: number - readonly "tools"?: Arrays_ + readonly "tools"?: ReadonlyArray } export const AdvisorServerToolConfig = Schema.Struct({ "forward_transcript": Schema.optionalKey(Schema.Boolean.annotate({ @@ -10179,1773 +7590,1727 @@ export const AdvisorServerToolConfig = Schema.Struct({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), - "tools": Schema.optionalKey(Arrays_) + "tools": Schema.optionalKey( + Schema.Array(AdvisorNestedTool).annotate({ + "description": + "Tools the advisor sub-agent may use while forming its advice. The advisor runs as an agentic sub-agent over these tools, then returns its text. Only OpenRouter server tools are supported — function tools are rejected — and the list must not include the advisor tool itself." + }) + ) }).annotate({ "description": "Configuration for one openrouter:advisor server tool entry.", "identifier": "AdvisorServerToolConfig" }) -export type AnthropicBashCodeExecutionContent = - | AnthropicBashCodeExecutionToolResultError - | AnthropicBashCodeExecutionResult -export const AnthropicBashCodeExecutionContent = Schema.Union([ - AnthropicBashCodeExecutionToolResultError, - AnthropicBashCodeExecutionResult -], { mode: "oneOf" }).annotate({ "identifier": "AnthropicBashCodeExecutionContent" }) -export type AnthropicTextBlockParam = { - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "citations"?: - | ReadonlyArray< - | AnthropicCitationCharLocationParam - | AnthropicCitationPageLocationParam - | AnthropicCitationContentBlockLocationParam - | AnthropicCitationWebSearchResultLocationParam - | AnthropicCitationSearchResultLocationParam - > - | null - readonly "text": string - readonly "type": "text" +export type BashServerToolEnvironment = ContainerAutoEnvironment | ContainerReferenceEnvironment +export const BashServerToolEnvironment = Schema.Union([ContainerAutoEnvironment, ContainerReferenceEnvironment], { + mode: "oneOf" +}).annotate({ + "description": "Execution environment for the bash server tool.", + "identifier": "BashServerToolEnvironment" +}) +export type ShellServerToolEnvironment = ContainerAutoEnvironment | ContainerReferenceEnvironment +export const ShellServerToolEnvironment = Schema.Union([ContainerAutoEnvironment, ContainerReferenceEnvironment], { + mode: "oneOf" +}).annotate({ + "description": + "Server-side execution environment for the shell tool. Only container-backed environments are supported; \"local\" shells are not.", + "identifier": "ShellServerToolEnvironment" +}) +export type DatetimeServerTool = { + readonly "parameters"?: DatetimeServerToolConfig + readonly "type": "openrouter:datetime" } -export const AnthropicTextBlockParam = Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "citations": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([ - AnthropicCitationCharLocationParam, - AnthropicCitationPageLocationParam, - AnthropicCitationContentBlockLocationParam, - AnthropicCitationWebSearchResultLocationParam, - AnthropicCitationSearchResultLocationParam - ], { mode: "oneOf" }) - ), - Schema.Null - ]) - ), - "text": Schema.String, - "type": Schema.Literal("text") -}).annotate({ "identifier": "AnthropicTextBlockParam" }) -export type AnthropicToolSearchToolBm25 = { - readonly "allowed_callers"?: AnthropicAllowedCallers - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "defer_loading"?: boolean - readonly "name": "tool_search_tool_bm25" - readonly "strict"?: boolean - readonly "type": "tool_search_tool_bm25_20251119" | "tool_search_tool_bm25" +export const DatetimeServerTool = Schema.Struct({ + "parameters": Schema.optionalKey(DatetimeServerToolConfig), + "type": Schema.Literal("openrouter:datetime") +}).annotate({ + "description": "OpenRouter built-in server tool: returns the current date and time", + "identifier": "DatetimeServerTool" +}) +export type FilesServerTool = { readonly "parameters"?: FilesServerToolConfig; readonly "type": "openrouter:files" } +export const FilesServerTool = Schema.Struct({ + "parameters": Schema.optionalKey(FilesServerToolConfig), + "type": Schema.Literal("openrouter:files") +}).annotate({ + "description": + "OpenRouter built-in server tool: read, write, edit, and list workspace files via the Files API. Requires an authenticated request; files come from the API key's workspace (or the default workspace for keys without one).", + "identifier": "FilesServerTool" +}) +export type ImageGenerationServerTool_OpenRouter = { + readonly "parameters"?: ImageGenerationServerToolConfig + readonly "type": "openrouter:image_generation" } -export const AnthropicToolSearchToolBm25 = Schema.Struct({ - "allowed_callers": Schema.optionalKey(AnthropicAllowedCallers), - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "defer_loading": Schema.optionalKey(Schema.Boolean), - "name": Schema.Literal("tool_search_tool_bm25"), - "strict": Schema.optionalKey(Schema.Boolean), - "type": Schema.Literals(["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]) -}).annotate({ "identifier": "AnthropicToolSearchToolBm25" }) -export type AnthropicToolSearchToolRegex = { - readonly "allowed_callers"?: AnthropicAllowedCallers - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "defer_loading"?: boolean - readonly "name": "tool_search_tool_regex" - readonly "strict"?: boolean - readonly "type": "tool_search_tool_regex_20251119" | "tool_search_tool_regex" +export const ImageGenerationServerTool_OpenRouter = Schema.Struct({ + "parameters": Schema.optionalKey(ImageGenerationServerToolConfig), + "type": Schema.Literal("openrouter:image_generation") +}).annotate({ + "description": "OpenRouter built-in server tool: generates images from text prompts using an image generation model", + "identifier": "ImageGenerationServerTool_OpenRouter" +}) +export type ChatSearchModelsServerTool = { + readonly "parameters"?: SearchModelsServerToolConfig + readonly "type": "openrouter:experimental__search_models" } -export const AnthropicToolSearchToolRegex = Schema.Struct({ - "allowed_callers": Schema.optionalKey(AnthropicAllowedCallers), - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "defer_loading": Schema.optionalKey(Schema.Boolean), - "name": Schema.Literal("tool_search_tool_regex"), - "strict": Schema.optionalKey(Schema.Boolean), - "type": Schema.Literals(["tool_search_tool_regex_20251119", "tool_search_tool_regex"]) -}).annotate({ "identifier": "AnthropicToolSearchToolRegex" }) -export type FusionServerToolConfig = { - readonly "analysis_models"?: Arrays_6 - readonly "cache_control"?: AnthropicCacheControlDirective +export const ChatSearchModelsServerTool = Schema.Struct({ + "parameters": Schema.optionalKey(SearchModelsServerToolConfig), + "type": Schema.Literal("openrouter:experimental__search_models") +}).annotate({ + "description": "OpenRouter built-in server tool: searches and filters AI models available on OpenRouter", + "identifier": "ChatSearchModelsServerTool" +}) +export type MessagesSearchModelsServerTool = { + readonly "parameters"?: SearchModelsServerToolConfig + readonly "type": "openrouter:experimental__search_models" +} +export const MessagesSearchModelsServerTool = Schema.Struct({ + "parameters": Schema.optionalKey(SearchModelsServerToolConfig), + "type": Schema.Literal("openrouter:experimental__search_models") +}).annotate({ + "description": "OpenRouter built-in server tool: searches and filters AI models available on OpenRouter", + "identifier": "MessagesSearchModelsServerTool" +}) +export type SearchModelsServerTool_OpenRouter = { + readonly "parameters"?: SearchModelsServerToolConfig + readonly "type": "openrouter:experimental__search_models" +} +export const SearchModelsServerTool_OpenRouter = Schema.Struct({ + "parameters": Schema.optionalKey(SearchModelsServerToolConfig), + "type": Schema.Literal("openrouter:experimental__search_models") +}).annotate({ + "description": "OpenRouter built-in server tool: searches and filters AI models available on OpenRouter", + "identifier": "SearchModelsServerTool_OpenRouter" +}) +export type SubagentServerToolConfig = { + readonly "instructions"?: string readonly "max_completion_tokens"?: number readonly "max_tool_calls"?: number readonly "model"?: string - readonly "reasoning"?: Objects_9 + readonly "name"?: string + readonly "reasoning"?: SubagentReasoning readonly "temperature"?: number - readonly "tools"?: Arrays_7 + readonly "tools"?: ReadonlyArray } -export const FusionServerToolConfig = Schema.Struct({ - "analysis_models": Schema.optionalKey(Arrays_6), - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), +export const SubagentServerToolConfig = Schema.Struct({ + "instructions": Schema.optionalKey( + Schema.String.annotate({ + "description": + "System instructions for the subagent. When omitted, the subagent responds with no system prompt of its own." + }) + ), "max_completion_tokens": Schema.optionalKey( Schema.Number.annotate({ "description": - "Maximum number of output tokens (including reasoning tokens) each panelist and the judge model may produce per inner call. Controls the total output budget so reasoning-heavy models like GPT-5.5 do not exhaust their token allowance before producing visible text. When omitted, panelists default to 32000 and the judge to 20000." + "Maximum number of output tokens (including reasoning) the subagent may produce. When omitted, the provider's default applies." }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "max_tool_calls": Schema.optionalKey( Schema.Number.annotate({ "description": - "Maximum number of tool-calling steps each panelist (analysis model) and the judge model may take during their agentic web-research loop. Models with web_search/web_fetch enabled iterate until they produce a text response or hit this ceiling. Defaults to 8. Capped at 16." + "Maximum number of tool-calling steps the subagent may take during its agentic loop. Capped at 25. Only relevant when the subagent is given tools. Accepted and validated but not yet enforced on the subagent call." }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) - ).check(Schema.isLessThanOrEqualTo(16).annotate({ "expected": "a value less than or equal to 16" })) + ).check(Schema.isLessThanOrEqualTo(25).annotate({ "expected": "a value less than or equal to 25" })) ), "model": Schema.optionalKey( Schema.String.annotate({ "description": - "Slug of the judge model that produces the structured analysis JSON. Defaults to the model used in the outer API request." + "Slug of the model that executes delegated tasks (any OpenRouter model). Typically a smaller, cheaper, faster model than the one delegating. When omitted, the model from the outer API request is used. The subagent tool itself cannot be the subagent model." }) ), - "reasoning": Schema.optionalKey(Objects_9), + "name": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Optional name for this subagent. The model sees one tool per named subagent (and one default for an unnamed entry). Names must be unique across subagent entries. Letters, digits, spaces, underscores, and dashes; trimmed; 1–64 chars." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) + ).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9 _-]+$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9 _-]+$" + }) + ) + ), + "reasoning": Schema.optionalKey(SubagentReasoning), "temperature": Schema.optionalKey( Schema.Number.annotate({ "description": - "Temperature forwarded to panelist inner calls. The judge always runs at temperature 0 regardless of this value. When omitted, the provider's default applies.", + "Sampling temperature forwarded to the subagent call. When omitted, the provider's default applies.", "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), - "tools": Schema.optionalKey(Arrays_7) + "tools": Schema.optionalKey( + Schema.Array(SubagentNestedTool).annotate({ + "description": + "Tools the subagent may use while executing a delegated task. The subagent runs as an agentic sub-agent over these tools, then returns its outcome. Only OpenRouter server tools are supported — function tools are rejected — and the list must not include the subagent tool itself." + }) + ) }).annotate({ - "description": "Configuration for the openrouter:fusion server tool.", - "identifier": "FusionServerToolConfig" + "description": "Configuration for one openrouter:subagent server tool entry.", + "identifier": "SubagentServerToolConfig" }) -export type AnthropicUsage = { - readonly "cache_creation": AnthropicCacheCreation - readonly "cache_creation_input_tokens": number | null - readonly "cache_read_input_tokens": number | null - readonly "inference_geo": string | null - readonly "input_tokens": number - readonly "output_tokens": number - readonly "output_tokens_details": AnthropicOutputTokensDetails - readonly "server_tool_use": AnthropicServerToolUsage - readonly "service_tier": AnthropicServiceTier -} -export const AnthropicUsage = Schema.Struct({ - "cache_creation": AnthropicCacheCreation, - "cache_creation_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]), - "cache_read_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]), - "inference_geo": Schema.Union([Schema.String, Schema.Null]), - "input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "output_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "output_tokens_details": AnthropicOutputTokensDetails, - "server_tool_use": AnthropicServerToolUsage, - "service_tier": AnthropicServiceTier -}).annotate({ "identifier": "AnthropicUsage" }) -export type AnthropicDocumentBlock = { - readonly "citations"?: AnthropicCitationsConfig - readonly "source": AnthropicBase64PdfSource | AnthropicPlainTextSource - readonly "title": string | null - readonly "type": "document" -} -export const AnthropicDocumentBlock = Schema.Struct({ - "citations": Schema.optionalKey(AnthropicCitationsConfig), - "source": Schema.Union([AnthropicBase64PdfSource, AnthropicPlainTextSource]), - "title": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("document") -}).annotate({ "identifier": "AnthropicDocumentBlock" }) -export type AnthropicTextBlock = { - readonly "citations": ReadonlyArray | null - readonly "text": string - readonly "type": "text" -} -export const AnthropicTextBlock = Schema.Struct({ - "citations": Schema.Union([Schema.Array(AnthropicTextCitation), Schema.Null]), - "text": Schema.String, - "type": Schema.Literal("text") -}).annotate({ "identifier": "AnthropicTextBlock" }) -export type AnthropicToolUseBlock = { - readonly "caller": AnthropicCaller - readonly "id": string - readonly "input"?: Schema.Json - readonly "name": string - readonly "type": "tool_use" -} -export const AnthropicToolUseBlock = Schema.Struct({ - "caller": AnthropicCaller, - "id": Schema.String, - "input": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), - "name": Schema.String, - "type": Schema.Literal("tool_use") -}).annotate({ "identifier": "AnthropicToolUseBlock" }) -export type AnthropicWebSearchToolResult = { - readonly "caller": AnthropicCaller - readonly "content": ReadonlyArray | AnthropicWebSearchToolResultError - readonly "tool_use_id": string - readonly "type": "web_search_tool_result" -} -export const AnthropicWebSearchToolResult = Schema.Struct({ - "caller": AnthropicCaller, - "content": Schema.Union([Schema.Array(AnthropicWebSearchResult), AnthropicWebSearchToolResultError]), - "tool_use_id": Schema.String, - "type": Schema.Literal("web_search_tool_result") -}).annotate({ "identifier": "AnthropicWebSearchToolResult" }) -export type ORAnthropicServerToolUseBlock = { - readonly "caller"?: ORAnthropicNullableCaller - readonly "id": string - readonly "input"?: Schema.Json - readonly "name": string - readonly "type": "server_tool_use" -} -export const ORAnthropicServerToolUseBlock = Schema.Struct({ - "caller": Schema.optionalKey(ORAnthropicNullableCaller), - "id": Schema.String, - "input": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), - "name": Schema.String, - "type": Schema.Literal("server_tool_use") -}).annotate({ "identifier": "ORAnthropicServerToolUseBlock" }) -export type AnthropicImageBlockParam = { - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "source": AnthropicBase64ImageSource | AnthropicUrlImageSource - readonly "type": "image" -} -export const AnthropicImageBlockParam = Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "source": Schema.Union([AnthropicBase64ImageSource, AnthropicUrlImageSource], { mode: "oneOf" }), - "type": Schema.Literal("image") -}).annotate({ "identifier": "AnthropicImageBlockParam" }) -export type AnthropicAdvisorMessageUsageIteration = { - readonly "cache_creation"?: AnthropicIterationCacheCreation - readonly "cache_creation_input_tokens"?: number - readonly "cache_read_input_tokens"?: number - readonly "input_tokens"?: number - readonly "output_tokens"?: number - readonly "model": string - readonly "type": "advisor_message" +export type WebFetchServerToolConfig = { + readonly "allowed_domains"?: ReadonlyArray + readonly "blocked_domains"?: ReadonlyArray + readonly "engine"?: WebFetchEngineEnum + readonly "max_content_tokens"?: number + readonly "max_uses"?: number } -export const AnthropicAdvisorMessageUsageIteration = Schema.Struct({ - "cache_creation": Schema.optionalKey(AnthropicIterationCacheCreation), - "cache_creation_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +export const WebFetchServerToolConfig = Schema.Struct({ + "allowed_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "Only fetch from these domains." }) ), - "cache_read_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + "blocked_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": "Never fetch from these domains." }) ), - "input_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "model": Schema.String, - "type": Schema.Literal("advisor_message") -}).annotate({ "identifier": "AnthropicAdvisorMessageUsageIteration" }) -export type AnthropicBaseUsageIteration = { - readonly "cache_creation"?: AnthropicIterationCacheCreation - readonly "cache_creation_input_tokens"?: number - readonly "cache_read_input_tokens"?: number - readonly "input_tokens"?: number - readonly "output_tokens"?: number + "engine": Schema.optionalKey(WebFetchEngineEnum), + "max_content_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Maximum content length in approximate tokens. Content exceeding this limit is truncated." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "max_uses": Schema.optionalKey( + Schema.Number.annotate({ + "description": "Maximum number of web fetches per request. Once exceeded, the tool returns an error." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) +}).annotate({ + "description": "Configuration for the openrouter:web_fetch server tool", + "identifier": "WebFetchServerToolConfig" +}) +export type WebSearchConfig = { + readonly "allowed_domains"?: ReadonlyArray + readonly "engine"?: WebSearchEngineEnum + readonly "excluded_domains"?: ReadonlyArray + readonly "max_characters"?: number + readonly "max_results"?: number + readonly "max_total_results"?: number + readonly "max_uses"?: number + readonly "mode"?: WebSearchMode + readonly "search_context_size"?: SearchQualityLevel + readonly "user_location"?: WebSearchUserLocationServerTool } -export const AnthropicBaseUsageIteration = Schema.Struct({ - "cache_creation": Schema.optionalKey(AnthropicIterationCacheCreation), - "cache_creation_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +export const WebSearchConfig = Schema.Struct({ + "allowed_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains." + }) ), - "cache_read_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + "engine": Schema.optionalKey(WebSearchEngineEnum), + "excluded_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains." + }) ), - "input_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))) -}).annotate({ "identifier": "AnthropicBaseUsageIteration" }) -export type AnthropicCompactionUsageIteration = { - readonly "cache_creation"?: AnthropicIterationCacheCreation - readonly "cache_creation_input_tokens"?: number - readonly "cache_read_input_tokens"?: number - readonly "input_tokens"?: number - readonly "output_tokens"?: number - readonly "type": "compaction" -} -export const AnthropicCompactionUsageIteration = Schema.Struct({ - "cache_creation": Schema.optionalKey(AnthropicIterationCacheCreation), - "cache_creation_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + "max_characters": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity)." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "cache_read_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + "max_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "input_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "type": Schema.Literal("compaction") -}).annotate({ "identifier": "AnthropicCompactionUsageIteration" }) -export type AnthropicMessageUsageIteration = { - readonly "cache_creation"?: AnthropicIterationCacheCreation - readonly "cache_creation_input_tokens"?: number - readonly "cache_read_input_tokens"?: number - readonly "input_tokens"?: number - readonly "output_tokens"?: number - readonly "model"?: string - readonly "type": "message" -} -export const AnthropicMessageUsageIteration = Schema.Struct({ - "cache_creation": Schema.optionalKey(AnthropicIterationCacheCreation), - "cache_creation_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + "max_total_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops. Defaults to 50 when not specified." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "cache_read_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + "max_uses": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "input_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "model": Schema.optionalKey(Schema.String), - "type": Schema.Literal("message") -}).annotate({ "identifier": "AnthropicMessageUsageIteration" }) -export type AnthropicUnknownUsageIteration = { - readonly "cache_creation"?: AnthropicIterationCacheCreation - readonly "cache_creation_input_tokens"?: number - readonly "cache_read_input_tokens"?: number - readonly "input_tokens"?: number - readonly "output_tokens"?: number - readonly "type": string + "mode": Schema.optionalKey(WebSearchMode), + "search_context_size": Schema.optionalKey(SearchQualityLevel), + "user_location": Schema.optionalKey(WebSearchUserLocationServerTool) +}).annotate({ "identifier": "WebSearchConfig" }) +export type WebSearchServerToolConfig = { + readonly "allowed_domains"?: ReadonlyArray + readonly "engine"?: WebSearchEngineEnum + readonly "excluded_domains"?: ReadonlyArray + readonly "max_characters"?: number + readonly "max_results"?: number + readonly "max_total_results"?: number + readonly "max_uses"?: number + readonly "mode"?: WebSearchMode + readonly "search_context_size"?: SearchQualityLevel + readonly "user_location"?: WebSearchUserLocationServerTool } -export const AnthropicUnknownUsageIteration = Schema.Struct({ - "cache_creation": Schema.optionalKey(AnthropicIterationCacheCreation), - "cache_creation_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +export const WebSearchServerToolConfig = Schema.Struct({ + "allowed_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains." + }) ), - "cache_read_input_tokens": Schema.optionalKey( - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + "engine": Schema.optionalKey(WebSearchEngineEnum), + "excluded_domains": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ + "description": + "Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains." + }) ), - "input_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "type": Schema.String -}).annotate({ "identifier": "AnthropicUnknownUsageIteration" }) -export type AnthropicCodeExecutionContent = - | AnthropicCodeExecutionToolResultError - | AnthropicCodeExecutionResult - | AnthropicEncryptedCodeExecutionResult -export const AnthropicCodeExecutionContent = Schema.Union([ - AnthropicCodeExecutionToolResultError, - AnthropicCodeExecutionResult, - AnthropicEncryptedCodeExecutionResult -], { mode: "oneOf" }).annotate({ "identifier": "AnthropicCodeExecutionContent" }) -export type AnthropicTextEditorCodeExecutionToolResult = { - readonly "content": AnthropicTextEditorCodeExecutionContent - readonly "tool_use_id": string - readonly "type": "text_editor_code_execution_tool_result" -} -export const AnthropicTextEditorCodeExecutionToolResult = Schema.Struct({ - "content": AnthropicTextEditorCodeExecutionContent, - "tool_use_id": Schema.String, - "type": Schema.Literal("text_editor_code_execution_tool_result") -}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionToolResult" }) -export type AnthropicToolSearchContent = AnthropicToolSearchResultError | AnthropicToolSearchResult -export const AnthropicToolSearchContent = Schema.Union([AnthropicToolSearchResultError, AnthropicToolSearchResult], { - mode: "oneOf" -}).annotate({ "identifier": "AnthropicToolSearchContent" }) -export type MessagesErrorResponse = { readonly "error": MessagesErrorDetail; readonly "type": "error" } -export const MessagesErrorResponse = Schema.Struct({ "error": MessagesErrorDetail, "type": Schema.Literal("error") }) - .annotate({ "identifier": "MessagesErrorResponse" }) -export type ApplyPatchServerTool_OpenRouter = { - readonly "parameters"?: ApplyPatchServerToolConfig - readonly "type": "openrouter:apply_patch" -} -export const ApplyPatchServerTool_OpenRouter = Schema.Struct({ - "parameters": Schema.optionalKey(ApplyPatchServerToolConfig), - "type": Schema.Literal("openrouter:apply_patch") + "max_characters": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity)." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "max_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "max_total_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops. Defaults to 50 when not specified." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "max_uses": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "mode": Schema.optionalKey(WebSearchMode), + "search_context_size": Schema.optionalKey(SearchQualityLevel), + "user_location": Schema.optionalKey(WebSearchUserLocationServerTool) }).annotate({ - "description": - "OpenRouter built-in server tool: validates V4A diff patches for file operations (create, update, delete). Restricted to the Responses API.", - "identifier": "ApplyPatchServerTool_OpenRouter" + "description": "Configuration for the openrouter:web_search server tool", + "identifier": "WebSearchServerToolConfig" }) -export type ApplyPatchCallItem = { - readonly "call_id": string - readonly "id"?: string | null - readonly "operation": ApplyPatchCallOperation - readonly "status": ApplyPatchCallStatus - readonly "type": "apply_patch_call" +export type ChatTokenLogprobs = { + readonly "content": ReadonlyArray | null + readonly "refusal"?: ReadonlyArray | null + readonly [x: string]: Schema.Json +} | null +export const ChatTokenLogprobs = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "content": Schema.Union([Schema.Array(ChatTokenLogprob), Schema.Null]).annotate({ + "description": "Log probabilities for content tokens" + }), + "refusal": Schema.optionalKey( + Schema.Union([Schema.Array(ChatTokenLogprob), Schema.Null]).annotate({ + "description": "Log probabilities for refusal tokens" + }) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "description": "Log probabilities for the completion", "identifier": "ChatTokenLogprobs" }) +export type EndpointsMetadata = { readonly "available": ReadonlyArray; readonly "total": number } +export const EndpointsMetadata = Schema.Struct({ + "available": Schema.Array(EndpointInfo), + "total": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "EndpointsMetadata" }) +export type PipelineStage = { + readonly "cost_usd"?: number | null + readonly "data"?: {} + readonly "guardrail_id"?: string + readonly "guardrail_scope"?: string + readonly "name": string + readonly "summary"?: string + readonly "type": PipelineStageType } -export const ApplyPatchCallItem = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "operation": ApplyPatchCallOperation, - "status": ApplyPatchCallStatus, - "type": Schema.Literal("apply_patch_call") -}).annotate({ - "description": - "A tool call emitted by the model requesting a V4A patch operation. The client applies the patch and echoes an `apply_patch_call_output` on the next turn.", - "identifier": "ApplyPatchCallItem" -}) -export type OutputApplyPatchCallItem = { - readonly "call_id": string - readonly "id": string - readonly "operation": ApplyPatchCallOperation - readonly "status": ApplyPatchCallStatus - readonly "type": "apply_patch_call" +export const PipelineStage = Schema.Struct({ + "cost_usd": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ), + "data": Schema.optionalKey(Schema.Struct({})), + "guardrail_id": Schema.optionalKey(Schema.String), + "guardrail_scope": Schema.optionalKey(Schema.String), + "name": Schema.String, + "summary": Schema.optionalKey(Schema.String), + "type": PipelineStageType +}).annotate({ "identifier": "PipelineStage" }) +export type ChatUsage = { + readonly "completion_tokens": number + readonly "completion_tokens_details"?: { + readonly "accepted_prediction_tokens"?: number | null + readonly "audio_tokens"?: number | null + readonly "reasoning_tokens"?: number | null + readonly "rejected_prediction_tokens"?: number | null + readonly [x: string]: Schema.Json + } | null + readonly "cost"?: number | null + readonly "cost_details"?: CostDetails + readonly "is_byok"?: boolean + readonly "prompt_tokens": number + readonly "prompt_tokens_details"?: { + readonly "audio_tokens"?: number + readonly "cache_write_tokens"?: number + readonly "cached_tokens"?: number + readonly "video_tokens"?: number + readonly [x: string]: Schema.Json + } | null + readonly "server_tool_use_details"?: ServerToolUseDetails + readonly "total_tokens": number } -export const OutputApplyPatchCallItem = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.String, - "operation": ApplyPatchCallOperation, - "status": ApplyPatchCallStatus, - "type": Schema.Literal("apply_patch_call") -}).annotate({ - "description": - "A native `apply_patch_call` output item matching OpenAI's Responses API shape. Emitted when the client requested the `apply_patch` shorthand.", - "identifier": "OutputApplyPatchCallItem" -}) -export type OutputApplyPatchServerToolItem = { - readonly "call_id"?: string - readonly "id"?: string - readonly "operation"?: ApplyPatchCallOperation - readonly "status": ToolCallStatus - readonly "type": "openrouter:apply_patch" +export const ChatUsage = Schema.Struct({ + "completion_tokens": Schema.Number.annotate({ "description": "Number of tokens in the completion" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "completion_tokens_details": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "accepted_prediction_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Accepted prediction tokens" }) + ), + "audio_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Tokens used for audio output" }) + ), + "reasoning_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Tokens used for reasoning" }) + ), + "rejected_prediction_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Rejected prediction tokens" }) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ "description": "Detailed completion token usage" }) + ), + "cost": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Cost of the completion", "format": "double" }) + ), + "cost_details": Schema.optionalKey(CostDetails), + "is_byok": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether a request was made using a Bring Your Own Key configuration" }) + ), + "prompt_tokens": Schema.Number.annotate({ "description": "Number of tokens in the prompt" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "prompt_tokens_details": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "audio_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Audio input tokens" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "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.isInt().annotate({ "expected": "an integer" })) + ), + "cached_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Cached prompt tokens" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ), + "video_tokens": Schema.optionalKey( + Schema.Number.annotate({ "description": "Video input tokens" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ "description": "Detailed prompt token usage" }) + ), + "server_tool_use_details": Schema.optionalKey(ServerToolUseDetails), + "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "description": "Token usage statistics", "identifier": "ChatUsage" }) +export type MessagesErrorDetail = { + readonly "error_type"?: ApiErrorType + readonly "message": string + readonly "type": string } -export const OutputApplyPatchServerToolItem = Schema.Struct({ - "call_id": Schema.optionalKey(Schema.String), - "id": Schema.optionalKey(Schema.String), - "operation": Schema.optionalKey(ApplyPatchCallOperation), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:apply_patch") +export const MessagesErrorDetail = Schema.Struct({ + "error_type": Schema.optionalKey(ApiErrorType), + "message": Schema.String, + "type": Schema.String +}).annotate({ "identifier": "MessagesErrorDetail" }) +export type PayloadTooLargeResponse = { + readonly "error": PayloadTooLargeResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null +} +export const PayloadTooLargeResponse = Schema.Struct({ + "error": PayloadTooLargeResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ), + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": - "An openrouter:apply_patch server tool output item. The turn halts when validation succeeds so the client can apply the patch and echo an `apply_patch_call_output` on the next turn.", - "identifier": "OutputApplyPatchServerToolItem" -}) -export type CreateBYOKKeyResponse = { readonly "data": BYOKKey } -export const CreateBYOKKeyResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => BYOKKey).annotate({ - "description": "The created BYOK credential." - }) -}).annotate({ "identifier": "CreateBYOKKeyResponse" }) -export type GetBYOKKeyResponse = { readonly "data": BYOKKey } -export const GetBYOKKeyResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => BYOKKey).annotate({ "description": "The BYOK credential." }) -}).annotate({ "identifier": "GetBYOKKeyResponse" }) -export type ListBYOKKeysResponse = { readonly "data": ReadonlyArray; readonly "total_count": number } -export const ListBYOKKeysResponse = Schema.Struct({ - "data": Schema.Array(BYOKKey).annotate({ "description": "List of BYOK credentials." }), - "total_count": Schema.Number.annotate({ "description": "Total number of BYOK credentials matching the filters." }) - .check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "identifier": "ListBYOKKeysResponse" }) -export type UpdateBYOKKeyResponse = { readonly "data": BYOKKey } -export const UpdateBYOKKeyResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => BYOKKey).annotate({ - "description": "The updated BYOK credential." - }) -}).annotate({ "identifier": "UpdateBYOKKeyResponse" }) -export type ChatTokenLogprobs = Objects_7 | null -export const ChatTokenLogprobs = Schema.Union([Objects_7, Schema.Null]).annotate({ - "description": "Log probabilities for the completion", - "identifier": "ChatTokenLogprobs" + "description": "Payload Too Large - Request payload exceeds size limits", + "identifier": "PayloadTooLargeResponse" }) -export type BashServerToolConfig = { - readonly "engine"?: BashServerToolEngine - readonly "environment"?: BashServerToolEnvironment - readonly "sleep_after_seconds"?: SandboxSleepAfterSeconds +export type UnprocessableEntityResponse = { + readonly "error": UnprocessableEntityResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null } -export const BashServerToolConfig = Schema.Struct({ - "engine": Schema.optionalKey(BashServerToolEngine), - "environment": Schema.optionalKey(BashServerToolEnvironment), - "sleep_after_seconds": Schema.optionalKey(SandboxSleepAfterSeconds) +export const UnprocessableEntityResponse = Schema.Struct({ + "error": UnprocessableEntityResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ), + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": "Configuration for the openrouter:bash server tool", - "identifier": "BashServerToolConfig" + "description": "Unprocessable Entity - Semantic validation failure", + "identifier": "UnprocessableEntityResponse" }) -export type ShellServerToolConfig = { - readonly "engine"?: ShellServerToolEngine - readonly "environment"?: ShellServerToolEnvironment - readonly "sleep_after_seconds"?: SandboxSleepAfterSeconds +export type TaskClassificationItem = { + readonly "category_token_share": number + readonly "category_usage_share": number + readonly "display_name": string + readonly "macro_category": string + readonly "models": ReadonlyArray + readonly "tag": string + readonly "token_share": number + readonly "usage_share": number } -export const ShellServerToolConfig = Schema.Struct({ - "engine": Schema.optionalKey(ShellServerToolEngine), - "environment": Schema.optionalKey(ShellServerToolEnvironment), - "sleep_after_seconds": Schema.optionalKey(SandboxSleepAfterSeconds) +export const TaskClassificationItem = Schema.Struct({ + "category_token_share": Schema.Number.annotate({ + "description": + "Fraction of this classification's token volume within its macro-category (0–1). Sums to 1 across all classifications sharing the same `macro_category`.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "category_usage_share": Schema.Number.annotate({ + "description": + "Fraction of this classification's usage within its macro-category (0–1). Sums to 1 across all classifications sharing the same `macro_category`.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "display_name": Schema.String.annotate({ "description": "Human-readable label for the classification." }), + "macro_category": Schema.String.annotate({ + "description": "Coarse grouping derived from the tag prefix: `code`, `data`, `agent`, or `general`." + }), + "models": Schema.Array(TaskClassificationModel).annotate({ + "description": + "Top models for this classification by request volume, sorted descending. Each entry reports the model's share of this classification's requests and tokens." + }), + "tag": Schema.String.annotate({ + "description": "Classification tag identifier (e.g. `code:general_impl`, `agent:web_search`)." + }), + "token_share": Schema.Number.annotate({ + "description": + "Fraction of classified sampled token volume (prompt + completion) attributed to this classification (0–1). The unclassified `other` bucket is excluded from the denominator.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "usage_share": Schema.Number.annotate({ + "description": + "Fraction of classified sampled requests attributed to this classification (0–1). The unclassified `other` bucket is excluded from the denominator.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) +}).annotate({ "identifier": "TaskClassificationItem" }) +export type GoneResponse = { + readonly "error": GoneResponseErrorData + readonly "openrouter_metadata"?: { readonly [x: string]: Schema.Json } | null + readonly "user_id"?: string | null +} +export const GoneResponse = Schema.Struct({ + "error": GoneResponseErrorData, + "openrouter_metadata": Schema.optionalKey( + Schema.Union([Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), Schema.Null]) + ), + "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }).annotate({ - "description": "Configuration for the openrouter:shell server tool", - "identifier": "ShellServerToolConfig" + "description": "Gone - Endpoint has been permanently removed or deprecated", + "identifier": "GoneResponse" }) -export type ModelBenchmarks = { readonly "artificial_analysis"?: AABenchmarkEntry; readonly "design_arena": Arrays_9 } +export type AppRankingsResponse = { + readonly "data": ReadonlyArray + readonly "meta": RankingsDailyMeta +} +export const AppRankingsResponse = Schema.Struct({ + "data": Schema.Array(AppRankingsItem).annotate({ + "description": + "Apps ranked per the requested `sort`, re-numbered 1..N after category filtering. `popular` sorts by `total_tokens` descending; `trending` sorts by absolute excess token growth descending and may return fewer than `limit` rows when few apps are growing." + }), + "meta": RankingsDailyMeta +}).annotate({ "identifier": "AppRankingsResponse" }) +export type RankingsDailyResponse = { + readonly "data": ReadonlyArray + readonly "meta": RankingsDailyMeta +} +export const RankingsDailyResponse = Schema.Struct({ + "data": Schema.Array(RankingsDailyItem).annotate({ + "description": + "Up to 51 rows per day — the top 50 public models by `total_tokens` for each UTC calendar date in the window, plus one aggregated `other` row summing every model outside that top 50 (omitted when the long tail is empty). Rows are sorted by `date` ascending, then by `total_tokens` descending, with `other` pinned last within its date. Ties between real models break alphabetically on `model_permaslug` so the order is stable across requests." + }), + "meta": RankingsDailyMeta +}).annotate({ "identifier": "RankingsDailyResponse" }) +export type ContentPartInputAudio = { readonly "input_audio": MultimodalMedia; readonly "type": "input_audio" } +export const ContentPartInputAudio = Schema.Struct({ + "input_audio": MultimodalMedia, + "type": Schema.Literal("input_audio") +}).annotate({ "identifier": "ContentPartInputAudio" }) +export type ContentPartInputVideo = { readonly "input_video": MultimodalMedia; readonly "type": "input_video" } +export const ContentPartInputVideo = Schema.Struct({ + "input_video": MultimodalMedia, + "type": Schema.Literal("input_video") +}).annotate({ "identifier": "ContentPartInputVideo" }) +export type ContentPartInputFile = { readonly "input_file": MultimodalMedia; readonly "type": "input_file" } +export const ContentPartInputFile = Schema.Struct({ + "input_file": MultimodalMedia, + "type": Schema.Literal("input_file") +}).annotate({ "identifier": "ContentPartInputFile" }) +export type ModelArchitecture = { + readonly "input_modalities": ReadonlyArray + readonly "instruct_type"?: InstructType + readonly "modality": string | null + readonly "output_modalities": ReadonlyArray + readonly "tokenizer"?: ModelGroup +} +export const ModelArchitecture = Schema.Struct({ + "input_modalities": Schema.Array(InputModality).annotate({ "description": "Supported input modalities" }), + "instruct_type": Schema.optionalKey(InstructType), + "modality": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Primary modality of the model" }), + "output_modalities": Schema.Array(OutputModality).annotate({ "description": "Supported output modalities" }), + "tokenizer": Schema.optionalKey(ModelGroup) +}).annotate({ "description": "Model architecture information", "identifier": "ModelArchitecture" }) +export type ModelBenchmarks = { + readonly "artificial_analysis"?: AABenchmarkEntry + readonly "design_arena": ReadonlyArray +} export const ModelBenchmarks = Schema.Struct({ "artificial_analysis": Schema.optionalKey(AABenchmarkEntry), - "design_arena": Arrays_9 + "design_arena": Schema.Array(DABenchmarkEntry).annotate({ + "description": "Design Arena ELO rankings across arena+category pairs." + }) }).annotate({ "description": "Third-party benchmark rankings for this model. Omitted when no benchmark data is available.", "identifier": "ModelBenchmarks" }) -export type TextConfig = { readonly "format"?: Formats; readonly "verbosity"?: "high" | "low" | "medium" | null } -export const TextConfig = Schema.Struct({ - "format": Schema.optionalKey(Formats), - "verbosity": Schema.optionalKey( - Schema.Union([Schema.Literal("high"), Schema.Literal("low"), Schema.Literal("medium"), Schema.Null]) - ) -}).annotate({ "description": "Text output configuration including format and verbosity", "identifier": "TextConfig" }) -export type TextExtendedConfig = { - readonly "format"?: Formats - readonly "verbosity"?: "high" | "low" | "medium" | null -} -export const TextExtendedConfig = Schema.Struct({ - "format": Schema.optionalKey(Formats), - "verbosity": Schema.optionalKey( - Schema.Union([Schema.Literal("high"), Schema.Literal("low"), Schema.Literal("medium"), Schema.Union([Schema.Null])]) - ) -}).annotate({ - "description": "Text output configuration including format and verbosity", - "identifier": "TextExtendedConfig" -}) -export type FusionCallAnalysisCompletedEvent = { - readonly "analysis": FusionAnalysisResult - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.fusion_call.analysis.completed" -} -export const FusionCallAnalysisCompletedEvent = Schema.Struct({ - "analysis": FusionAnalysisResult, - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.fusion_call.analysis.completed") -}).annotate({ - "description": "Emitted when the fusion judge completes with the structured analysis.", - "identifier": "FusionCallAnalysisCompletedEvent" -}) -export type OutputFusionServerToolItem = { - readonly "analysis"?: FusionAnalysisResult - readonly "error"?: string - readonly "failed_models"?: ReadonlyArray< - { readonly "error": string; readonly "model": string; readonly "status_code"?: number } - > - readonly "failure_reason"?: string - readonly "id"?: string - readonly "responses"?: ReadonlyArray<{ readonly "content"?: string; readonly "model": string }> - readonly "sources"?: ReadonlyArray - readonly "status": ToolCallStatus - readonly "type": "openrouter:fusion" +export type PublicPricing = { + readonly "audio"?: string + readonly "audio_output"?: string + readonly "completion": string + readonly "discount"?: number + readonly "image"?: string + readonly "image_output"?: string + readonly "image_token"?: string + readonly "input_audio_cache"?: string + readonly "input_cache_read"?: string + readonly "input_cache_write"?: string + readonly "input_cache_write_1h"?: string + readonly "internal_reasoning"?: string + readonly "overrides"?: ReadonlyArray + readonly "prompt": string + readonly "request"?: string + readonly "web_search"?: string } -export const OutputFusionServerToolItem = Schema.Struct({ - "analysis": Schema.optionalKey(FusionAnalysisResult), - "error": Schema.optionalKey( - Schema.String.annotate({ "description": "Error message when the fusion run did not produce an analysis result." }) - ), - "failed_models": Schema.optionalKey( - Schema.Array(Schema.Struct({ - "error": Schema.String.annotate({ "description": "Error message describing why the model failed." }), - "model": Schema.String.annotate({ "description": "Slug of the analysis model that failed." }), - "status_code": Schema.optionalKey( - Schema.Number.annotate({ - "description": "HTTP status code from the upstream response, when available (e.g. 402, 429)." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ) - })).annotate({ +export const PublicPricing = Schema.Struct({ + "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per audio input token" })), + "audio_output": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per audio output token" })), + "completion": Schema.String.annotate({ "description": "Price in USD per token for completion (output) generation" }), + "discount": Schema.optionalKey( + Schema.Number.annotate({ "description": - "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." - }) + "Fractional discount applied to this endpoint's pricing; the price is multiplied by (1 - discount) (0 = no discount, 1 = free)", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "image": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per input image" })), + "image_output": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per output image" })), + "image_token": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per image token" })), + "input_audio_cache": Schema.optionalKey( + Schema.String.annotate({ "description": "Price in USD per cached audio input token" }) + ), + "input_cache_read": Schema.optionalKey( + Schema.String.annotate({ "description": "Price in USD per cached input token (read)" }) ), - "failure_reason": Schema.optionalKey( + "input_cache_write": Schema.optionalKey( Schema.String.annotate({ "description": - "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion." + "Price per cache-write token, in USD per token. For providers with multiple cache TTLs (e.g. Anthropic), this is the default (5-minute) cache-write rate." }) ), - "id": Schema.optionalKey(Schema.String), - "responses": Schema.optionalKey( - Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })).annotate({ + "input_cache_write_1h": Schema.optionalKey( + Schema.String.annotate({ "description": - "Analysis models that produced a response in this fusion run, with each model's full panel content." + "Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic." }) ), - "sources": Schema.optionalKey( - Schema.Array(FusionSource).annotate({ + "internal_reasoning": Schema.optionalKey( + Schema.String.annotate({ "description": "Price in USD per internal reasoning token" }) + ), + "overrides": Schema.optionalKey( + Schema.Array(PricingOverride).annotate({ "description": - "Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." + "Conditional overrides of the base pricing (e.g. long-context or time-based pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens, or the utc_start/utc_end time window) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions." }) ), - "status": ToolCallStatus, - "type": Schema.Literal("openrouter:fusion") -}).annotate({ - "description": "An openrouter:fusion server tool output item", - "identifier": "OutputFusionServerToolItem" -}) -export type ImageModelListItem = { - readonly "architecture": ImageModelArchitecture - readonly "created": number - readonly "description": string - readonly "endpoints": string - readonly "id": string - readonly "name": string - readonly "supported_parameters": SupportedParameters - readonly "supports_streaming": boolean + "prompt": Schema.String.annotate({ "description": "Price in USD per token for prompt (input) processing" }), + "request": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per request" })), + "web_search": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per web search" })) +}).annotate({ "description": "Pricing information for the model", "identifier": "PublicPricing" }) +export type ModelReasoning = { + readonly "default_effort"?: ReasoningEffort + readonly "default_enabled"?: boolean + readonly "mandatory": boolean + readonly "supported_efforts"?: ReadonlyArray | null + readonly "supports_max_tokens"?: boolean } -export const ImageModelListItem = Schema.Struct({ - "architecture": ImageModelArchitecture, - "created": Schema.Number.annotate({ "description": "Unix timestamp (seconds) of when the model was created" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) +export const ModelReasoning = Schema.Struct({ + "default_effort": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ReasoningEffort).annotate({ + "description": + "Default reasoning effort when the client enables reasoning without specifying effort. Maps to `reasoning.effort` in chat requests. When `\"none\"`, prefer omitting effort unless the user explicitly disables reasoning." + }) ), - "description": Schema.String, - "endpoints": Schema.String.annotate({ - "description": "Relative URL to the full per-endpoint records for this model" - }), - "id": Schema.String.annotate({ "description": "Model slug" }), - "name": Schema.String.annotate({ "description": "Display name" }), - "supported_parameters": SupportedParameters, - "supports_streaming": Schema.Boolean.annotate({ - "description": - "Whether any endpoint of this model supports native SSE streaming on the dedicated Image API (i.e. `stream: true` in the request). OR across endpoints." - }) -}).annotate({ "description": "A single image model in the discovery listing.", "identifier": "ImageModelListItem" }) -export type ObservabilityArizeDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "apiKey": string - readonly "baseUrl"?: string - readonly "headers"?: {} - readonly "modelId": string - readonly "spaceKey": string - } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "arize" - readonly "updated_at": string - readonly "workspace_id": string -} -export const ObservabilityArizeDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "apiKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "baseUrl": Schema.optionalKey(Schema.String), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) - ), - "modelId": Schema.String.annotate({ "description": "The name of the tracing project in Arize AX" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "spaceKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + "default_enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Default reasoning enabled state when the client does not set `reasoning.enabled`." + }) + ), + "mandatory": Schema.Boolean.annotate({ + "description": "When true, reasoning cannot be disabled and effort \"none\" is rejected." }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("arize"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityArizeDestination" }) -export type ObservabilityBraintrustDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "apiKey": string - readonly "baseUrl"?: string - readonly "headers"?: {} - readonly "projectId": string + "supported_efforts": Schema.optionalKey( + Schema.Union([Schema.Array(ReasoningEffort), Schema.Null]).annotate({ + "description": + "Allowed reasoning effort values for this model, in descending effort order (highest first). Null means no allowlist — all gateway effort values are accepted." + }) + ), + "supports_max_tokens": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Present and `true` when the model accepts `reasoning.max_tokens` in requests (Anthropic-style) instead of or in addition to `reasoning.effort`. Omitted otherwise." + }) + ) +}).annotate({ + "description": "Reasoning effort configuration. Omitted for non-reasoning models and dynamic router models.", + "identifier": "ModelReasoning" +}) +export type PublicEndpoint = { + readonly "context_length": number + readonly "latency_last_30m": PercentileStats + readonly "max_completion_tokens": number | null + readonly "max_prompt_tokens": number | null + readonly "model_id": string + readonly "model_name": string + readonly "name": string + readonly "pricing": { + readonly "audio"?: string + readonly "audio_output"?: string + readonly "completion": string + readonly "discount"?: number + readonly "image"?: string + readonly "image_output"?: string + readonly "image_token"?: string + readonly "input_audio_cache"?: string + readonly "input_cache_read"?: string + readonly "input_cache_write"?: string + readonly "input_cache_write_1h"?: string + readonly "internal_reasoning"?: string + readonly "overrides"?: ReadonlyArray + readonly "prompt": string + readonly "request"?: string + readonly "web_search"?: string } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "braintrust" - readonly "updated_at": string - readonly "workspace_id": string + readonly "provider_name": ProviderName + readonly "quantization": Quantization | null + readonly "status"?: EndpointStatus + readonly "supported_parameters": ReadonlyArray + readonly "supports_implicit_caching": boolean + readonly "supports_voice_cloning"?: boolean + readonly "tag": string + readonly "throughput_last_30m": PercentileStats + readonly "uptime_last_1d": number | null + readonly "uptime_last_30m": number | null + readonly "uptime_last_5m": number | null } -export const ObservabilityBraintrustDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "apiKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "baseUrl": Schema.optionalKey(Schema.String), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) +export const PublicEndpoint = Schema.Struct({ + "context_length": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "latency_last_30m": PercentileStats, + "max_completion_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "max_prompt_tokens": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "model_id": Schema.String.annotate({ "description": "The unique identifier for the model (permaslug)" }), + "model_name": Schema.String, + "name": Schema.String, + "pricing": Schema.Struct({ + "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per audio input token" })), + "audio_output": Schema.optionalKey( + Schema.String.annotate({ "description": "Price in USD per audio output token" }) ), - "projectId": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("braintrust"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityBraintrustDestination" }) -export type ObservabilityClickhouseDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "database": string - readonly "headers"?: {} - readonly "host": string - readonly "password": string - readonly "table"?: string - readonly "username": string - } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "clickhouse" - readonly "updated_at": string - readonly "workspace_id": string -} -export const ObservabilityClickhouseDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "database": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + "completion": Schema.String.annotate({ + "description": "Price in USD per token for completion (output) generation" + }), + "discount": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Fractional discount applied to this endpoint's pricing; the price is multiplied by (1 - discount) (0 = no discount, 1 = free)", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + "image": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per input image" })), + "image_output": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per output image" })), + "image_token": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per image token" })), + "input_audio_cache": Schema.optionalKey( + Schema.String.annotate({ "description": "Price in USD per cached audio input token" }) ), - "host": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), - "password": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + "input_cache_read": Schema.optionalKey( + Schema.String.annotate({ "description": "Price in USD per cached input token (read)" }) ), - "table": Schema.optionalKey(Schema.String), - "username": Schema.String.annotate({ - "description": "If you have not set a specific username in ClickHouse, simply type in 'default' below." - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("clickhouse"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityClickhouseDestination" }) -export type ObservabilityDatadogDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "apiKey": string - readonly "headers"?: {} - readonly "mlApp": string - readonly "url"?: string - } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "datadog" - readonly "updated_at": string - readonly "workspace_id": string -} -export const ObservabilityDatadogDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "apiKey": Schema.String.annotate({ - "description": "Datadog API key must have LLM Observability permissions. Create at: " - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + "input_cache_write": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Price per cache-write token, in USD per token. For providers with multiple cache TTLs (e.g. Anthropic), this is the default (5-minute) cache-write rate." + }) ), - "mlApp": Schema.String.annotate({ "description": "Name to identify your application in Datadog LLM Observability" }) - .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), - "url": Schema.optionalKey( + "input_cache_write_1h": Schema.optionalKey( Schema.String.annotate({ "description": - "Datadog API URL for your region (e.g., https://api.datadoghq.com, https://api.us3.datadoghq.com, https://api.datadoghq.eu)" + "Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic." }) - ) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("datadog"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityDatadogDestination" }) -export type ObservabilityGrafanaDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "apiKey": string - readonly "baseUrl"?: string - readonly "headers"?: {} - readonly "instanceId": string - } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "grafana" - readonly "updated_at": string - readonly "workspace_id": string -} -export const ObservabilityGrafanaDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "apiKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), - "baseUrl": Schema.optionalKey(Schema.String), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + "internal_reasoning": Schema.optionalKey( + Schema.String.annotate({ "description": "Price in USD per internal reasoning token" }) ), - "instanceId": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) + "overrides": Schema.optionalKey( + Schema.Array(PricingOverride).annotate({ + "description": + "Conditional overrides of the base pricing (e.g. long-context or time-based pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens, or the utc_start/utc_end time window) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions." + }) + ), + "prompt": Schema.String.annotate({ "description": "Price in USD per token for prompt (input) processing" }), + "request": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per request" })), + "web_search": Schema.optionalKey(Schema.String.annotate({ "description": "Price in USD per web search" })) }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." + "provider_name": ProviderName, + "quantization": Schema.Union([Quantization, Schema.Null]), + "status": Schema.optionalKey(EndpointStatus), + "supported_parameters": Schema.Array(Parameter), + "supports_implicit_caching": Schema.Boolean, + "supports_voice_cloning": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether this TTS endpoint accepts inline reference audio (`input_references`) for stateless voice cloning. Requests carrying reference audio are only routed to endpoints where this is true." + }) + ), + "tag": Schema.String, + "throughput_last_30m": Schema.suspend((): Schema.Codec => PercentileStats).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." }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + "uptime_last_1d": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ + "description": + "Uptime percentage over the last 1 day, calculated as successful requests / (successful + error requests) * 100. Rate-limited requests are excluded. Returns null if insufficient data.", + "format": "double" }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "uptime_last_30m": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "format": "double" }), + "uptime_last_5m": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ + "description": + "Uptime percentage over the last 5 minutes, calculated as successful requests / (successful + error requests) * 100. Rate-limited requests are excluded. Returns null if insufficient data.", "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("grafana"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" }) -}).annotate({ "identifier": "ObservabilityGrafanaDestination" }) -export type ObservabilityLangfuseDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "baseUrl"?: string - readonly "headers"?: {} - readonly "publicKey": string - readonly "secretKey": string - } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "langfuse" - readonly "updated_at": string - readonly "workspace_id": string +}).annotate({ "description": "Information about a specific model endpoint", "identifier": "PublicEndpoint" }) +export type OpenRouterFileList = { + readonly "_shape": "openrouter" + readonly "cursor": string | null + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "has_more": boolean + readonly "last_id": string | null } -export const ObservabilityLangfuseDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "baseUrl": Schema.optionalKey(Schema.String), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) - ), - "publicKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "secretKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." +export const OpenRouterFileList = Schema.Struct({ + "_shape": Schema.Literal("openrouter"), + "cursor": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Opaque cursor for the next page; null when there are no more results." }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("langfuse"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityLangfuseDestination" }) -export type ObservabilityLangsmithDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "apiKey": string - readonly "endpoint"?: string - readonly "headers"?: {} - readonly "project"?: string - readonly "workspaceId"?: string + "data": Schema.Array(OpenRouterFile), + "first_id": Schema.Union([Schema.String, Schema.Null]), + "has_more": Schema.Boolean, + "last_id": Schema.Union([Schema.String, Schema.Null]) +}).annotate({ "description": "A page of files in the OpenRouter shape.", "identifier": "OpenRouterFileList" }) +export type OpenAIFileList = { + readonly "_shape": "openai" + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "has_more": boolean + readonly "last_id": string | null + readonly "object": "list" +} +export const OpenAIFileList = Schema.Struct({ + "_shape": Schema.Literal("openai"), + "data": Schema.Array(OpenAIFile), + "first_id": Schema.Union([Schema.String, Schema.Null]), + "has_more": Schema.Boolean, + "last_id": Schema.Union([Schema.String, Schema.Null]), + "object": Schema.Literal("list") +}).annotate({ "description": "A page of files in OpenAI's shape.", "identifier": "OpenAIFileList" }) +export type AnthropicFileList = { + readonly "_shape": "anthropic" + readonly "data": ReadonlyArray + readonly "first_id": string | null + readonly "has_more": boolean + readonly "last_id": string | null +} +export const AnthropicFileList = Schema.Struct({ + "_shape": Schema.Literal("anthropic"), + "data": Schema.Array(AnthropicFile), + "first_id": Schema.Union([Schema.String, Schema.Null]), + "has_more": Schema.Boolean, + "last_id": Schema.Union([Schema.String, Schema.Null]) +}).annotate({ "description": "A page of files in Anthropic's shape.", "identifier": "AnthropicFileList" }) +export type FileResponse = OpenRouterFile | OpenAIFile | AnthropicFile +export const FileResponse = Schema.Union([OpenRouterFile, OpenAIFile, AnthropicFile], { mode: "oneOf" }).annotate({ + "description": "A stored file. The shape is negotiated per request — see the endpoint description.", + "identifier": "FileResponse" +}) +export type FileDeleteResponse = OpenRouterFileDeleted | OpenAIFileDeleted | AnthropicFileDeleted +export const FileDeleteResponse = Schema.Union([OpenRouterFileDeleted, OpenAIFileDeleted, AnthropicFileDeleted], { + mode: "oneOf" +}).annotate({ + "description": "Confirmation that a file was deleted, in the negotiated shape.", + "identifier": "FileDeleteResponse" +}) +export type GenerationResponse = { + readonly "data": { + readonly "api_type": "completions" | "embeddings" | "rerank" | "tts" | "stt" | "video" | "image" | null + readonly "app_id": number | null + readonly "cache_discount": number | null + readonly "cancelled": boolean | null + readonly "created_at": string + readonly "data_region": "global" | "europe" | "us" + readonly "external_user": string | null + readonly "finish_reason": string | null + readonly "generation_time": number | null + readonly "http_referer": string | null + readonly "id": string + readonly "is_byok": boolean + readonly "latency": number | null + readonly "model": string + readonly "moderation_latency": number | null + readonly "native_finish_reason": string | null + readonly "native_tokens_cached": number | null + readonly "native_tokens_completion": number | null + readonly "native_tokens_completion_images": number | null + readonly "native_tokens_prompt": number | null + readonly "native_tokens_reasoning": number | null + readonly "num_fetches": number | null + readonly "num_input_audio_prompt": number | null + readonly "num_media_completion": number | null + readonly "num_media_prompt": number | null + readonly "num_search_results": number | null + readonly "origin": string + readonly "preset_id": string | null + readonly "provider_name": string | null + readonly "provider_responses": ReadonlyArray | null + readonly "request_id"?: string | null + readonly "response_cache_source_id"?: string | null + readonly "router": string | null + readonly "service_tier": string | null + readonly "session_id"?: string | null + readonly "streamed": boolean | null + readonly "tokens_completion": number | null + readonly "tokens_prompt": number | null + readonly "total_cost": number + readonly "upstream_id": string | null + readonly "upstream_inference_cost": number | null + readonly "usage": number + readonly "user_agent": string | null + readonly "web_search_engine": string | null + readonly "workspace_id": string | null } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "langsmith" - readonly "updated_at": string - readonly "workspace_id": string } -export const ObservabilityLangsmithDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "apiKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "endpoint": Schema.optionalKey(Schema.String), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) +export const GenerationResponse = Schema.Struct({ + "data": Schema.Struct({ + "api_type": Schema.Union([ + Schema.Literal("completions"), + Schema.Literal("embeddings"), + Schema.Literal("rerank"), + Schema.Literal("tts"), + Schema.Literal("stt"), + Schema.Literal("video"), + Schema.Literal("image"), + Schema.Null + ]).annotate({ "description": "Type of API used for the generation" }), + "app_id": Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "ID of the app that made the request" }), + "cache_discount": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Discount applied due to caching", "format": "double" }), + "cancelled": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether the generation was cancelled" + }), + "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the generation was created" }), + "data_region": Schema.Literals(["global", "europe", "us"]).annotate({ + "description": "The data region this generation was routed through: 'global', 'europe', or 'us'." + }), + "external_user": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "External user identifier" }), + "finish_reason": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Reason the generation finished" + }), + "generation_time": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Time taken for generation in milliseconds", "format": "double" }), + "http_referer": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Referer header from the request" + }), + "id": Schema.String.annotate({ "description": "Unique identifier for the generation" }), + "is_byok": Schema.Boolean.annotate({ "description": "Whether this used bring-your-own-key" }), + "latency": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Total latency in milliseconds", "format": "double" }), + "model": Schema.String.annotate({ "description": "Model used for the generation" }), + "moderation_latency": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Moderation latency in milliseconds", "format": "double" }), + "native_finish_reason": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Native finish reason as reported by provider" + }), + "native_tokens_cached": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Native cached tokens as reported by provider" }), + "native_tokens_completion": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Native completion tokens as reported by provider" }), + "native_tokens_completion_images": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Native completion image tokens as reported by provider" }), + "native_tokens_prompt": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Native prompt tokens as reported by provider" }), + "native_tokens_reasoning": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Native reasoning tokens as reported by provider" }), + "num_fetches": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Number of web fetches performed" }), + "num_input_audio_prompt": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Number of audio inputs in the prompt" }), + "num_media_completion": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Number of media items in the completion" }), + "num_media_prompt": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Number of media items in the prompt" }), + "num_search_results": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Number of search results included" }), + "origin": Schema.String.annotate({ "description": "Origin URL of the request" }), + "preset_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "ID of the preset used for this generation, null if no preset was used" + }), + "provider_name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Name of the provider that served the request" + }), + "provider_responses": Schema.Union([Schema.Array(ProviderResponse), Schema.Null]).annotate({ + "description": "List of provider responses for this generation, including fallback attempts" + }), + "request_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Unique identifier grouping all generations from a single API request" + }) ), - "project": Schema.optionalKey( - Schema.String.annotate({ - "description": "The name for this project, such as pr-openrouter-demo. Defaults to \"main\" if not set." - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + "response_cache_source_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "If this generation was served from response cache, contains the original generation ID. Null otherwise." + }) ), - "workspaceId": Schema.optionalKey( - Schema.String.annotate({ - "description": "Required for org-scoped API keys. Find this in your LangSmith workspace settings." + "router": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Router used for the request (e.g., openrouter/auto)" + }), + "service_tier": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "Service tier the upstream provider reported running this request on, or null if it did not report one." + }), + "session_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Session identifier grouping multiple generations in the same session" }) - ) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("langsmith"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityLangsmithDestination" }) -export type ObservabilityNewrelicDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { readonly "headers"?: {}; readonly "licenseKey": string; readonly "region"?: "us" | "eu" } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "newrelic" - readonly "updated_at": string - readonly "workspace_id": string -} -export const ObservabilityNewrelicDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) ), - "licenseKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + "streamed": Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether the response was streamed" + }), + "tokens_completion": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Number of tokens in the completion" }), + "tokens_prompt": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Number of tokens in the prompt" }), + "total_cost": Schema.Number.annotate({ "description": "Total cost of the generation in USD", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "upstream_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Upstream provider's identifier for this generation" + }), + "upstream_inference_cost": Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "description": "Cost charged by the upstream provider", "format": "double" }), + "usage": Schema.Number.annotate({ "description": "Usage amount in USD", "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) ), - "region": Schema.optionalKey(Schema.Literals(["us", "eu"])) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("newrelic"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityNewrelicDestination" }) -export type ObservabilityOpikDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "apiKey": string - readonly "headers"?: {} - readonly "projectName": string - readonly "workspace": string - } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "opik" - readonly "updated_at": string - readonly "workspace_id": string + "user_agent": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "User-Agent header from the request" + }), + "web_search_engine": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The resolved web search engine used for this generation (e.g. exa, firecrawl, parallel)" + }), + "workspace_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "ID of the workspace this generation is attributed to. Null for accounts without workspaces. Generations created before workspace resolution existed are attributed to the account default workspace." + }) + }).annotate({ "description": "Generation data" }) +}).annotate({ "description": "Generation response", "identifier": "GenerationResponse" }) +export type GenerationContentResponse = { readonly "data": GenerationContentData } +export const GenerationContentResponse = Schema.Struct({ "data": GenerationContentData }).annotate({ + "description": "Stored prompt and completion content for a generation", + "identifier": "GenerationContentResponse" +}) +export type ContentFilterBuiltinEntry = { + readonly "action": ContentFilterBuiltinAction + readonly "label"?: string + readonly "scan_scope"?: PromptInjectionScanScope + readonly "slug": ContentFilterBuiltinSlug } -export const ObservabilityOpikDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "apiKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) - ), - "projectName": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "workspace": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("opik"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityOpikDestination" }) -export type ObservabilityOtelCollectorDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { readonly "endpoint": string; readonly "headers"?: {} } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "otel-collector" - readonly "updated_at": string - readonly "workspace_id": string +export const ContentFilterBuiltinEntry = Schema.Struct({ + "action": ContentFilterBuiltinAction, + "label": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Read-only, system-assigned redaction placeholder derived from the slug (e.g. \"[EMAIL]\", \"[PHONE]\"). Not settable by the caller." + }).check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })) + ), + "scan_scope": Schema.optionalKey(PromptInjectionScanScope), + "slug": ContentFilterBuiltinSlug +}).annotate({ + "description": + "A builtin content filter entry. Builtin filters include PII detectors and the regex-based prompt injection detector.", + "identifier": "ContentFilterBuiltinEntry" +}) +export type ContentFilterBuiltinEntryInput = { + readonly "action": ContentFilterBuiltinAction + readonly "label"?: string + readonly "scan_scope"?: PromptInjectionScanScope + readonly "slug": ContentFilterBuiltinSlug } -export const ObservabilityOtelCollectorDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "endpoint": Schema.String, - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "Custom HTTP headers as a JSON object. For Axiom, use {\"Authorization\": \"Bearer xaat-xxx\", \"X-Axiom-Dataset\": \"your-dataset\"}" - }) - ) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("otel-collector"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityOtelCollectorDestination" }) -export type ObservabilityPosthogDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { readonly "apiKey": string; readonly "endpoint"?: string; readonly "headers"?: {} } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "posthog" - readonly "updated_at": string - readonly "workspace_id": string +export const ContentFilterBuiltinEntryInput = Schema.Struct({ + "action": ContentFilterBuiltinAction, + "label": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Deprecated: labels are system-assigned and cannot be set by the caller. Accepted for backward compatibility but silently ignored." + }).check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })) + ), + "scan_scope": Schema.optionalKey(PromptInjectionScanScope), + "slug": ContentFilterBuiltinSlug +}).annotate({ + "description": + "A builtin content filter entry for create/update requests. Labels are system-assigned and cannot be set by the caller.", + "identifier": "ContentFilterBuiltinEntryInput" +}) +export type ContentFilterEntry = { + readonly "action": ContentFilterAction + readonly "label"?: string | null + readonly "pattern": string } -export const ObservabilityPosthogDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "apiKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "endpoint": Schema.optionalKey(Schema.String), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) - ) +export const ContentFilterEntry = Schema.Struct({ + "action": ContentFilterAction, + "label": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(100).annotate({ "expected": "a value with a length of at most 100" })), + Schema.Null + ]).annotate({ "description": "Optional label used in redaction placeholders or error messages" }) + ), + "pattern": Schema.String.annotate({ "description": "A regex pattern to match against request content" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) +}).annotate({ + "description": "A custom regex content filter that scans request messages for matching patterns.", + "identifier": "ContentFilterEntry" +}) +export type ListKeyAssignmentsResponse = { + readonly "data": ReadonlyArray + readonly "total_count": number +} +export const ListKeyAssignmentsResponse = Schema.Struct({ + "data": Schema.Array(KeyAssignment).annotate({ "description": "List of key assignments" }), + "total_count": Schema.Number.annotate({ "description": "Total number of key assignments for this guardrail" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "ListKeyAssignmentsResponse" }) +export type ListMemberAssignmentsResponse = { + readonly "data": ReadonlyArray + readonly "total_count": number +} +export const ListMemberAssignmentsResponse = Schema.Struct({ + "data": Schema.Array(MemberAssignment).annotate({ "description": "List of member assignments" }), + "total_count": Schema.Number.annotate({ "description": "Total number of member assignments" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "ListMemberAssignmentsResponse" }) +export type AnthropicCompactionUsageIteration = { + readonly "cache_creation"?: AnthropicIterationCacheCreation + readonly "cache_creation_input_tokens"?: number + readonly "cache_read_input_tokens"?: number + readonly "input_tokens"?: number + readonly "output_tokens"?: number + readonly "type": "compaction" +} +export const AnthropicCompactionUsageIteration = Schema.Struct({ + "cache_creation": Schema.optionalKey(AnthropicIterationCacheCreation), + "cache_creation_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "cache_read_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "input_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "type": Schema.Literal("compaction") +}).annotate({ "identifier": "AnthropicCompactionUsageIteration" }) +export type AnthropicMessageUsageIteration = { + readonly "cache_creation"?: AnthropicIterationCacheCreation + readonly "cache_creation_input_tokens"?: number + readonly "cache_read_input_tokens"?: number + readonly "input_tokens"?: number + readonly "output_tokens"?: number + readonly "model"?: string + readonly "type": "message" +} +export const AnthropicMessageUsageIteration = Schema.Struct({ + "cache_creation": Schema.optionalKey(AnthropicIterationCacheCreation), + "cache_creation_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "cache_read_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "input_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "model": Schema.optionalKey(Schema.String), + "type": Schema.Literal("message") +}).annotate({ "identifier": "AnthropicMessageUsageIteration" }) +export type AnthropicAdvisorMessageUsageIteration = { + readonly "cache_creation"?: AnthropicIterationCacheCreation + readonly "cache_creation_input_tokens"?: number + readonly "cache_read_input_tokens"?: number + readonly "input_tokens"?: number + readonly "output_tokens"?: number + readonly "model": string + readonly "type": "advisor_message" +} +export const AnthropicAdvisorMessageUsageIteration = Schema.Struct({ + "cache_creation": Schema.optionalKey(AnthropicIterationCacheCreation), + "cache_creation_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "cache_read_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "input_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "model": Schema.String, + "type": Schema.Literal("advisor_message") +}).annotate({ "identifier": "AnthropicAdvisorMessageUsageIteration" }) +export type AnthropicUnknownUsageIteration = { + readonly "cache_creation"?: AnthropicIterationCacheCreation + readonly "cache_creation_input_tokens"?: number + readonly "cache_read_input_tokens"?: number + readonly "input_tokens"?: number + readonly "output_tokens"?: number + readonly "type": string +} +export const AnthropicUnknownUsageIteration = Schema.Struct({ + "cache_creation": Schema.optionalKey(AnthropicIterationCacheCreation), + "cache_creation_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "cache_read_input_tokens": Schema.optionalKey( + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "input_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "output_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "type": Schema.String +}).annotate({ "identifier": "AnthropicUnknownUsageIteration" }) +export type ImageModelArchitecture = { + readonly "input_modalities": ReadonlyArray + readonly "output_modalities": ReadonlyArray +} +export const ImageModelArchitecture = Schema.Struct({ + "input_modalities": Schema.Array(ImageInputModality).annotate({ "description": "Supported input modalities" }), + "output_modalities": Schema.Array(ImageOutputModality).annotate({ "description": "Supported output modalities" }) +}).annotate({ "identifier": "ImageModelArchitecture" }) +export type ImageEndpoint = { + readonly "allowed_passthrough_parameters": ReadonlyArray + readonly "pricing": ReadonlyArray + readonly "provider_name": string + readonly "provider_slug": string + readonly "provider_tag": string | null + readonly "supported_parameters": SupportedParameters + readonly "supports_streaming": boolean +} +export const ImageEndpoint = Schema.Struct({ + "allowed_passthrough_parameters": Schema.Array(Schema.String).annotate({ + "description": "Provider-specific options accepted under provider.options[provider_slug]." }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." + "pricing": Schema.Array(ImagePricingEntry).annotate({ "description": "Billable pricing lines for this endpoint." }), + "provider_name": Schema.String.annotate({ "description": "Provider display name" }), + "provider_slug": Schema.String.annotate({ "description": "Provider slug" }), + "provider_tag": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Provider tag for request-side selection" }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + "supported_parameters": Schema.suspend((): Schema.Codec => SupportedParameters).annotate({ + "description": "The definitive set of parameters this endpoint accepts for this model." }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("posthog"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" + "supports_streaming": Schema.Boolean.annotate({ + "description": "Whether this endpoint supports native SSE streaming (`stream: true` in the request)." }) -}).annotate({ "identifier": "ObservabilityPosthogDestination" }) -export type ObservabilityRampDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { readonly "apiKey": string; readonly "baseUrl"?: string; readonly "headers"?: {} } +}).annotate({ "description": "An endpoint that serves a given image model.", "identifier": "ImageEndpoint" }) +export type AnthropicBase64ImageSource = { + readonly "data": string + readonly "media_type": AnthropicImageMimeType + readonly "type": "base64" +} +export const AnthropicBase64ImageSource = Schema.Struct({ + "data": Schema.String, + "media_type": AnthropicImageMimeType, + "type": Schema.Literal("base64") +}).annotate({ "identifier": "AnthropicBase64ImageSource" }) +export type AnthropicTextCitation = + | AnthropicCitationCharLocation + | AnthropicCitationPageLocation + | AnthropicCitationContentBlockLocation + | AnthropicCitationWebSearchResultLocation + | AnthropicCitationSearchResultLocation +export const AnthropicTextCitation = Schema.Union([ + AnthropicCitationCharLocation, + AnthropicCitationPageLocation, + AnthropicCitationContentBlockLocation, + AnthropicCitationWebSearchResultLocation, + AnthropicCitationSearchResultLocation +], { mode: "oneOf" }).annotate({ "identifier": "AnthropicTextCitation" }) +export type MessagesContentBlockDeltaEvent = { + readonly "delta": + | { readonly "text": string; readonly "type": "text_delta" } + | { readonly "partial_json": string; readonly "type": "input_json_delta" } + | { readonly "thinking": string; readonly "type": "thinking_delta" } + | { readonly "signature": string; readonly "type": "signature_delta" } + | { + readonly "citation": + | AnthropicCitationCharLocation + | AnthropicCitationPageLocation + | AnthropicCitationContentBlockLocation + | AnthropicCitationWebSearchResultLocation + | AnthropicCitationSearchResultLocation + readonly "type": "citations_delta" + } + | { + readonly "content": string | null + readonly "encrypted_content"?: string | null + readonly "type": "compaction_delta" + } + readonly "index": number + readonly "type": "content_block_delta" +} +export const MessagesContentBlockDeltaEvent = Schema.Struct({ + "delta": Schema.Union([ + Schema.Struct({ "text": Schema.String, "type": Schema.Literal("text_delta") }), + Schema.Struct({ "partial_json": Schema.String, "type": Schema.Literal("input_json_delta") }), + Schema.Struct({ "thinking": Schema.String, "type": Schema.Literal("thinking_delta") }), + Schema.Struct({ "signature": Schema.String, "type": Schema.Literal("signature_delta") }), + Schema.Struct({ + "citation": Schema.Union([ + AnthropicCitationCharLocation, + AnthropicCitationPageLocation, + AnthropicCitationContentBlockLocation, + AnthropicCitationWebSearchResultLocation, + AnthropicCitationSearchResultLocation + ], { mode: "oneOf" }), + "type": Schema.Literal("citations_delta") + }), + Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Null]), + "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("compaction_delta") + }) + ], { mode: "oneOf" }), + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("content_block_delta") +}).annotate({ + "description": "Event sent when content is added to a content block", + "identifier": "MessagesContentBlockDeltaEvent" +}) +export type AnthropicCaller = + | AnthropicDirectCaller + | AnthropicCodeExecution20250825Caller + | AnthropicCodeExecution20260120Caller +export const AnthropicCaller = Schema.Union([ + AnthropicDirectCaller, + AnthropicCodeExecution20250825Caller, + AnthropicCodeExecution20260120Caller +], { mode: "oneOf" }).annotate({ "identifier": "AnthropicCaller" }) +export type ORAnthropicNullableCaller = + | AnthropicDirectCaller + | AnthropicCodeExecution20250825Caller + | AnthropicCodeExecution20260120Caller + | null +export const ORAnthropicNullableCaller = Schema.Union([ + AnthropicDirectCaller, + AnthropicCodeExecution20250825Caller, + AnthropicCodeExecution20260120Caller, + Schema.Null +], { mode: "oneOf" }).annotate({ "identifier": "ORAnthropicNullableCaller" }) +export type AnthropicDocumentBlock = { + readonly "citations"?: AnthropicCitationsConfig + readonly "source": AnthropicBase64PdfSource | AnthropicPlainTextSource + readonly "title": string | null + readonly "type": "document" +} +export const AnthropicDocumentBlock = Schema.Struct({ + "citations": Schema.optionalKey(AnthropicCitationsConfig), + "source": Schema.Union([AnthropicBase64PdfSource, AnthropicPlainTextSource]), + "title": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.Literal("document") +}).annotate({ "identifier": "AnthropicDocumentBlock" }) +export type AnthropicCodeExecutionToolResultError = { + readonly "error_code": AnthropicServerToolErrorCode + readonly "type": "code_execution_tool_result_error" +} +export const AnthropicCodeExecutionToolResultError = Schema.Struct({ + "error_code": AnthropicServerToolErrorCode, + "type": Schema.Literal("code_execution_tool_result_error") +}).annotate({ "identifier": "AnthropicCodeExecutionToolResultError" }) +export type AnthropicToolSearchResultError = { + readonly "error_code": AnthropicServerToolErrorCode + readonly "error_message": string | null + readonly "type": "tool_search_tool_result_error" +} +export const AnthropicToolSearchResultError = Schema.Struct({ + "error_code": AnthropicServerToolErrorCode, + "error_message": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.Literal("tool_search_tool_result_error") +}).annotate({ "identifier": "AnthropicToolSearchResultError" }) +export type AnthropicCodeExecutionResult = { + readonly "content": ReadonlyArray + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "code_execution_result" +} +export const AnthropicCodeExecutionResult = Schema.Struct({ + "content": Schema.Array(AnthropicCodeExecutionOutput), + "return_code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "stderr": Schema.String, + "stdout": Schema.String, + "type": Schema.Literal("code_execution_result") +}).annotate({ "identifier": "AnthropicCodeExecutionResult" }) +export type AnthropicEncryptedCodeExecutionResult = { + readonly "content": ReadonlyArray + readonly "encrypted_stdout": string + readonly "return_code": number + readonly "stderr": string + readonly "type": "encrypted_code_execution_result" +} +export const AnthropicEncryptedCodeExecutionResult = Schema.Struct({ + "content": Schema.Array(AnthropicCodeExecutionOutput), + "encrypted_stdout": Schema.String, + "return_code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "stderr": Schema.String, + "type": Schema.Literal("encrypted_code_execution_result") +}).annotate({ "identifier": "AnthropicEncryptedCodeExecutionResult" }) +export type AnthropicBashCodeExecutionResult = { + readonly "content": ReadonlyArray + readonly "return_code": number + readonly "stderr": string + readonly "stdout": string + readonly "type": "bash_code_execution_result" +} +export const AnthropicBashCodeExecutionResult = Schema.Struct({ + "content": Schema.Array(AnthropicBashCodeExecutionOutput), + "return_code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "stderr": Schema.String, + "stdout": Schema.String, + "type": Schema.Literal("bash_code_execution_result") +}).annotate({ "identifier": "AnthropicBashCodeExecutionResult" }) +export type AnthropicTextEditorCodeExecutionContent = + | AnthropicTextEditorCodeExecutionToolResultError + | AnthropicTextEditorCodeExecutionViewResult + | AnthropicTextEditorCodeExecutionCreateResult + | AnthropicTextEditorCodeExecutionStrReplaceResult +export const AnthropicTextEditorCodeExecutionContent = Schema.Union([ + AnthropicTextEditorCodeExecutionToolResultError, + AnthropicTextEditorCodeExecutionViewResult, + AnthropicTextEditorCodeExecutionCreateResult, + AnthropicTextEditorCodeExecutionStrReplaceResult +], { mode: "oneOf" }).annotate({ "identifier": "AnthropicTextEditorCodeExecutionContent" }) +export type AnthropicToolSearchResult = { + readonly "tool_references": ReadonlyArray + readonly "type": "tool_search_tool_search_result" +} +export const AnthropicToolSearchResult = Schema.Struct({ + "tool_references": Schema.Array(AnthropicToolReference), + "type": Schema.Literal("tool_search_tool_search_result") +}).annotate({ "identifier": "AnthropicToolSearchResult" }) +export type ObservabilityFilterRulesConfig = { + readonly "enabled"?: boolean + readonly "groups": ReadonlyArray + readonly [x: string]: Schema.Json +} | null +export const ObservabilityFilterRulesConfig = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "enabled": Schema.optionalKey(Schema.Boolean), + "groups": Schema.Array(ObservabilityFilterRuleGroup) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ + "description": "Optional structured filter rules controlling which events are forwarded.", + "identifier": "ObservabilityFilterRulesConfig" +}) +export type ObservabilityFilterRulesConfigNullable = { + readonly "enabled"?: boolean + readonly "groups": ReadonlyArray + readonly [x: string]: Schema.Json +} | null +export const ObservabilityFilterRulesConfigNullable = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "enabled": Schema.optionalKey(Schema.Boolean), + "groups": Schema.Array(ObservabilityFilterRuleGroup) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ + "description": "Optional structured filter rules controlling which events are forwarded.", + "identifier": "ObservabilityFilterRulesConfigNullable" +}) +export type Preset = { readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "creator_user_id": string | null + readonly "description": string | null + readonly "designated_version_id": string | null readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "ramp" + readonly "name": string + readonly "slug": string + readonly "status": PresetStatus + readonly "status_updated_at": string | null readonly "updated_at": string - readonly "workspace_id": string + readonly "workspace_id": string | null } -export const ObservabilityRampDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "apiKey": Schema.String.annotate({ "description": "Generate this in your Ramp integration settings." }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "baseUrl": Schema.optionalKey(Schema.String), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to Ramp." }) - ) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("ramp"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityRampDestination" }) -export type ObservabilityS3Destination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "accessKeyId": string - readonly "bucketName": string - readonly "endpoint"?: string - readonly "headers"?: {} - readonly "pathTemplate"?: string - readonly "prefix"?: string - readonly "region"?: string - readonly "secretAccessKey": string - readonly "sessionToken"?: string - } +export const Preset = Schema.Struct({ + "created_at": Schema.String, + "creator_user_id": Schema.Union([Schema.String, Schema.Null]), + "description": Schema.Union([Schema.String, Schema.Null]), + "designated_version_id": Schema.Union([Schema.String, Schema.Null]), + "id": Schema.String, + "name": Schema.String, + "slug": Schema.String, + "status": PresetStatus, + "status_updated_at": Schema.Union([Schema.String, Schema.Null]), + "updated_at": Schema.String, + "workspace_id": Schema.Union([Schema.String, Schema.Null]) +}).annotate({ "description": "A preset without version details.", "identifier": "Preset" }) +export type PresetWithDesignatedVersion = { readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "creator_user_id": string | null + readonly "description": string | null + readonly "designated_version_id": string | null readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "s3" + readonly "name": string + readonly "slug": string + readonly "status": PresetStatus + readonly "status_updated_at": string | null readonly "updated_at": string - readonly "workspace_id": string + readonly "workspace_id": string | null + readonly "designated_version": PresetDesignatedVersion } -export const ObservabilityS3Destination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "accessKeyId": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "bucketName": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "endpoint": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Only for S3-compatible services like Cloudflare R2 (https://account-id.r2.cloudflarestorage.com) or MinIO. Leave blank for standard AWS S3.", - "format": "uri" - }) - ), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) - ), - "pathTemplate": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Template for S3 object path. The filename ({traceId}-{timestamp}.json) is automatically appended. Available variables: {prefix}, {date}, {year}, {month}, {day}, {apiKeyName}" - }) - ), - "prefix": Schema.optionalKey(Schema.String), - "region": Schema.optionalKey(Schema.String), - "secretAccessKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "sessionToken": Schema.optionalKey(Schema.String) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("s3"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityS3Destination" }) -export type ObservabilitySentryDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { readonly "dsn": string; readonly "headers"?: {}; readonly "otlpEndpoint": string } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "sentry" - readonly "updated_at": string - readonly "workspace_id": string -} -export const ObservabilitySentryDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "dsn": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) - .check( - Schema.isPattern(new RegExp("^https:\\/\\/([^:@]+)(?::[^@]*)?@([^/]+)(?:\\/[^/]+)*\\/(\\d+)\\/?$")).annotate({ - "expected": "a string matching the RegExp ^https:\\/\\/([^:@]+)(?::[^@]*)?@([^/]+)(?:\\/[^/]+)*\\/(\\d+)\\/?$" - }) - ), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) - ), - "otlpEndpoint": Schema.String - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("sentry"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilitySentryDestination" }) -export type ObservabilitySnowflakeDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "account": string - readonly "database"?: string - readonly "headers"?: {} - readonly "schema"?: string - readonly "table"?: string - readonly "token": string - readonly "warehouse"?: string - } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig - readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "snowflake" - readonly "updated_at": string - readonly "workspace_id": string +export const PresetWithDesignatedVersion = Schema.Struct({ + "created_at": Schema.String, + "creator_user_id": Schema.Union([Schema.String, Schema.Null]), + "description": Schema.Union([Schema.String, Schema.Null]), + "designated_version_id": Schema.Union([Schema.String, Schema.Null]), + "id": Schema.String, + "name": Schema.String, + "slug": Schema.String, + "status": PresetStatus, + "status_updated_at": Schema.Union([Schema.String, Schema.Null]), + "updated_at": Schema.String, + "workspace_id": Schema.Union([Schema.String, Schema.Null]), + "designated_version": PresetDesignatedVersion +}).annotate({ + "description": "A preset with its currently designated version.", + "identifier": "PresetWithDesignatedVersion" +}) +export type ListPresetVersionsResponse = { + readonly "data": ReadonlyArray + readonly "total_count": number } -export const ObservabilitySnowflakeDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "account": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "database": Schema.optionalKey(Schema.String), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) - ), - "schema": Schema.optionalKey(Schema.String), - "table": Schema.optionalKey(Schema.String), - "token": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), - "warehouse": Schema.optionalKey(Schema.String) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("snowflake"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilitySnowflakeDestination" }) -export type ObservabilityWeaveDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { - readonly "apiKey": string - readonly "baseUrl"?: string - readonly "entity": string - readonly "headers"?: {} - readonly "project": string - } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig +export const ListPresetVersionsResponse = Schema.Struct({ + "data": Schema.Array(PresetDesignatedVersion), + "total_count": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "description": "A paginated list of preset versions.", "identifier": "ListPresetVersionsResponse" }) +export type GetPresetVersionResponse = { readonly "data": PresetDesignatedVersion } +export const GetPresetVersionResponse = Schema.Struct({ "data": PresetDesignatedVersion }).annotate({ + "description": "A single version of a preset.", + "identifier": "GetPresetVersionResponse" +}) +export type ReasoningItem = { + readonly "content"?: ReadonlyArray<{ readonly "text": string; readonly "type": "reasoning_text" }> + readonly "encrypted_content"?: string | null readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "weave" - readonly "updated_at": string - readonly "workspace_id": string + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "summary": ReadonlyArray + readonly "type": "reasoning" + readonly "format"?: ReasoningFormat + readonly "signature"?: string | null } -export const ObservabilityWeaveDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "apiKey": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "baseUrl": Schema.optionalKey(Schema.String), - "entity": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "headers": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) - ), - "project": Schema.String.check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ) - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("weave"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityWeaveDestination" }) -export type ObservabilityWebhookDestination = { - readonly "api_key_hashes": ReadonlyArray | null - readonly "config": { readonly "headers"?: {}; readonly "method"?: "POST" | "PUT"; readonly "url": string } - readonly "created_at": string - readonly "enabled": boolean - readonly "filter_rules": ObservabilityFilterRulesConfig +export const ReasoningItem = Schema.Struct({ + "content": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.Struct({ "text": Schema.String, "type": Schema.Literal("reasoning_text") }))]) + ), + "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "id": Schema.String, + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "summary": Schema.Array(ReasoningSummaryText), + "type": Schema.Literal("reasoning"), + "format": Schema.optionalKey(ReasoningFormat), + "signature": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) +}).annotate({ + "description": "Reasoning output item with signature and format extensions", + "identifier": "ReasoningItem" +}) +export type OutputReasoningItem = { + readonly "content"?: ReadonlyArray<{ readonly "text": string; readonly "type": "reasoning_text" }> + readonly "encrypted_content"?: string | null readonly "id": string - readonly "name": string | null - readonly "privacy_mode": boolean - readonly "sampling_rate": number - readonly "type": "webhook" - readonly "updated_at": string - readonly "workspace_id": string + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "summary": ReadonlyArray + readonly "type": "reasoning" + readonly "format"?: ReasoningFormat + readonly "signature"?: string | null } -export const ObservabilityWebhookDestination = Schema.Struct({ - "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." - }), - "config": Schema.Struct({ - "headers": Schema.optionalKey(Schema.Struct({})), - "method": Schema.optionalKey(Schema.Literals(["POST", "PUT"])), - "url": Schema.String - }), - "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), - "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), - "filter_rules": ObservabilityFilterRulesConfig, - "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), - "name": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Human-readable name for the destination." - }), - "privacy_mode": Schema.Boolean.annotate({ - "description": "When true, request/response bodies are not forwarded to this destination — only metadata." - }), - "sampling_rate": Schema.Number.annotate({ - "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), - "type": Schema.Literal("webhook"), - "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), - "workspace_id": Schema.String.annotate({ - "description": "ID of the workspace this destination belongs to.", - "format": "uuid" - }) -}).annotate({ "identifier": "ObservabilityWebhookDestination" }) -export type ObservabilityFilterRulesConfigNullable = Objects_10 | null -export const ObservabilityFilterRulesConfigNullable = Schema.Union([Objects_10, Schema.Null]).annotate({ - "description": "Optional structured filter rules controlling which events are forwarded.", - "identifier": "ObservabilityFilterRulesConfigNullable" -}) -export type BaseTextDeltaEvent = { - readonly "content_index": number - readonly "delta": string +export const OutputReasoningItem = Schema.Struct({ + "content": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.Struct({ "text": Schema.String, "type": Schema.Literal("reasoning_text") }))]) + ), + "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "id": Schema.String, + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "summary": Schema.Array(ReasoningSummaryText), + "type": Schema.Literal("reasoning"), + "format": Schema.optionalKey(ReasoningFormat), + "signature": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "A signature for the reasoning content, used for verification" + }) + ) +}).annotate({ "description": "An output item containing reasoning", "identifier": "OutputReasoningItem" }) +export type ReasoningSummaryPartAddedEvent = { readonly "item_id": string - readonly "logprobs": ReadonlyArray readonly "output_index": number + readonly "part": ReasoningSummaryText readonly "sequence_number": number - readonly "type": "response.output_text.delta" + readonly "summary_index": number + readonly "type": "response.reasoning_summary_part.added" } -export const BaseTextDeltaEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "delta": Schema.String, +export const ReasoningSummaryPartAddedEvent = Schema.Struct({ "item_id": Schema.String, - "logprobs": Schema.Array(OpenResponsesLogProbs), "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "part": ReasoningSummaryText, "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.output_text.delta") -}).annotate({ "description": "Event emitted when a text delta is streamed", "identifier": "BaseTextDeltaEvent" }) -export type BaseTextDoneEvent = { - readonly "content_index": number + "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.reasoning_summary_part.added") +}).annotate({ + "description": "Event emitted when a reasoning summary part is added", + "identifier": "ReasoningSummaryPartAddedEvent" +}) +export type ReasoningSummaryPartDoneEvent = { readonly "item_id": string - readonly "logprobs": ReadonlyArray readonly "output_index": number + readonly "part": ReasoningSummaryText readonly "sequence_number": number - readonly "text": string - readonly "type": "response.output_text.done" + readonly "summary_index": number + readonly "type": "response.reasoning_summary_part.done" } -export const BaseTextDoneEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), +export const ReasoningSummaryPartDoneEvent = Schema.Struct({ "item_id": Schema.String, - "logprobs": Schema.Array(OpenResponsesLogProbs), "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "part": ReasoningSummaryText, "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "text": Schema.String, - "type": Schema.Literal("response.output_text.done") -}).annotate({ "description": "Event emitted when text streaming is complete", "identifier": "BaseTextDoneEvent" }) -export type FileParserPlugin = { - readonly "enabled"?: boolean - readonly "id": "file-parser" - readonly "pdf"?: PDFParserOptions -} -export const FileParserPlugin = Schema.Struct({ - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Set to false to disable the file-parser plugin for this request. Defaults to true." - }) - ), - "id": Schema.Literal("file-parser"), - "pdf": Schema.optionalKey(PDFParserOptions) -}).annotate({ "identifier": "FileParserPlugin" }) -export type Objects_148 = { - readonly "allow_fallbacks"?: boolean | null - readonly "data_collection"?: "deny" | "allow" | null - readonly "enforce_distillable_text"?: boolean | null - readonly "ignore"?: ReadonlyArray | null - readonly "max_price"?: { - readonly "audio"?: string - readonly "completion"?: string - readonly "image"?: string - readonly "prompt"?: string - readonly "request"?: string - } - readonly "only"?: ReadonlyArray | null - readonly "order"?: ReadonlyArray | null - readonly "preferred_max_latency"?: PreferredMaxLatency - readonly "preferred_min_throughput"?: PreferredMinThroughput - readonly "quantizations"?: ReadonlyArray | null - readonly "require_parameters"?: boolean | null - readonly "sort"?: ProviderSort | ProviderSortConfig | null - readonly "zdr"?: boolean | null + "summary_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.reasoning_summary_part.done") +}).annotate({ + "description": "Event emitted when a reasoning summary part is complete", + "identifier": "ReasoningSummaryPartDoneEvent" +}) +export type FunctionCallItem = { + readonly "arguments": string + readonly "call_id": string + readonly "id": string + readonly "name": string + readonly "namespace"?: string + readonly "status"?: ToolCallStatus + readonly "type": "function_call" } -export const Objects_148 = 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" - }) - ), - "data_collection": Schema.optionalKey( - Schema.Union([Schema.Literal("deny"), Schema.Literal("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." - }) - ), - "enforce_distillable_text": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).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." - }) - ), - "ignore": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." - }) - ), - "max_price": Schema.optionalKey( - Schema.Struct({ - "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Maximum price in USD per audio unit" })), - "completion": Schema.optionalKey( - Schema.String.annotate({ "description": "Maximum price in USD per million completion tokens" }) - ), - "image": Schema.optionalKey(Schema.String.annotate({ "description": "Maximum price in USD per image" })), - "prompt": Schema.optionalKey( - Schema.String.annotate({ "description": "Maximum price in USD per million prompt tokens" }) - ), - "request": Schema.optionalKey(Schema.String.annotate({ "description": "Maximum price in USD 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." - }) - ), - "only": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." - }) - ), - "order": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." - }) - ), - "preferred_max_latency": Schema.optionalKey(PreferredMaxLatency), - "preferred_min_throughput": Schema.optionalKey(PreferredMinThroughput), - "quantizations": Schema.optionalKey( - Schema.Union([Schema.Array(Quantization), Schema.Null]).annotate({ - "description": "A list of quantization levels to filter the provider by." - }) - ), - "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." - }) - ), - "sort": Schema.optionalKey( - Schema.Union([ProviderSort, ProviderSortConfig, Schema.Null]).annotate({ - "description": - "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." +export const FunctionCallItem = Schema.Struct({ + "arguments": Schema.String, + "call_id": Schema.String, + "id": Schema.String, + "name": Schema.String, + "namespace": Schema.optionalKey( + Schema.String.annotate({ + "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" }) ), - "zdr": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).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." - }) - ) -}) -export type Arrays_11 = ReadonlyArray -export const Arrays_11 = Schema.Array(PipelineStage) -export type Prediction = Objects_17 | null -export const Prediction = Schema.Union([Objects_17, Schema.Null]).annotate({ - "description": - "Static predicted output content. Supported models can use this to reduce latency when much of the response is known in advance.", - "identifier": "Prediction" -}) -export type ListPresetsResponse = { readonly "data": ReadonlyArray; readonly "total_count": number } -export const ListPresetsResponse = Schema.Struct({ - "data": Schema.Array(Preset), - "total_count": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) -}).annotate({ "description": "A paginated list of presets.", "identifier": "ListPresetsResponse" }) -export type CreatePresetFromInferenceResponse = { readonly "data": PresetWithDesignatedVersion } -export const CreatePresetFromInferenceResponse = Schema.Struct({ "data": PresetWithDesignatedVersion }).annotate({ - "description": "Response containing the created preset with its designated version.", - "identifier": "CreatePresetFromInferenceResponse" -}) -export type GetPresetResponse = { readonly "data": PresetWithDesignatedVersion } -export const GetPresetResponse = Schema.Struct({ "data": PresetWithDesignatedVersion }).annotate({ - "description": "A preset with its currently designated version.", - "identifier": "GetPresetResponse" -}) -export type ChatContentText = { - readonly "cache_control"?: ChatContentCacheControl - readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint - readonly "text": string - readonly "type": "text" -} -export const ChatContentText = Schema.Struct({ - "cache_control": Schema.optionalKey(ChatContentCacheControl), - "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), - "text": Schema.String, - "type": Schema.Literal("text") -}).annotate({ "description": "Text content part", "identifier": "ChatContentText" }) -export type CustomToolCallOutputItem = { + "status": Schema.optionalKey(ToolCallStatus), + "type": Schema.Literal("function_call") +}).annotate({ "description": "A function call initiated by the model", "identifier": "FunctionCallItem" }) +export type FunctionCallOutputItem = { readonly "call_id": string - readonly "id"?: string + readonly "id"?: string | null readonly "output": | string | ReadonlyArray< @@ -12009,11 +9374,12 @@ export type CustomToolCallOutputItem = { readonly "type": "input_file" } > - readonly "type": "custom_tool_call_output" + readonly "status"?: ToolCallStatus | null + readonly "type": "function_call_output" } -export const CustomToolCallOutputItem = Schema.Struct({ +export const FunctionCallOutputItem = Schema.Struct({ "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), "output": Schema.Union([ Schema.Union([Schema.String]), Schema.Union([Schema.Array(Schema.Union([ @@ -12115,1289 +9481,1971 @@ export const CustomToolCallOutputItem = Schema.Struct({ ], { mode: "oneOf" }) ], { mode: "oneOf" }))]) ]), - "type": Schema.Literal("custom_tool_call_output") -}).annotate({ - "description": - "The output from a custom (freeform-grammar) tool call execution. Mirrors `function_call_output` but is matched to a `custom_tool_call` rather than a `function_call`.", - "identifier": "CustomToolCallOutputItem" -}) -export type FunctionCallOutputItem = { - readonly "call_id": string - readonly "id"?: string | null - readonly "output": - | string + "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), + "type": Schema.Literal("function_call_output") +}).annotate({ "description": "The output from a function call execution", "identifier": "FunctionCallOutputItem" }) +export type OutputCodeInterpreterCallItem = { + readonly "code": string | null + readonly "container_id": string + readonly "id": string + readonly "outputs": | ReadonlyArray< - { - readonly "prompt_cache_breakpoint"?: { readonly "mode": "explicit"; readonly [x: string]: Schema.Json } | null - readonly "text": string - readonly "type": "input_text" - } | { - readonly "detail": "auto" | "high" | "low" | "original" - readonly "image_url"?: string | null - readonly "type": never - readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint - readonly "text": string - } | { - readonly "file_data"?: string - readonly "file_id"?: string | null - readonly "file_url"?: string - readonly "filename"?: string - readonly "type": never - readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint - readonly "text": string - } | { - readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint - readonly "text": string - readonly "type": never - readonly "detail": "auto" | "high" | "low" | "original" - readonly "image_url"?: string | null - } | { - readonly "detail": "auto" | "high" | "low" | "original" - readonly "image_url"?: string | null - readonly "type": "input_image" - } | { - readonly "file_data"?: string - readonly "file_id"?: string | null - readonly "file_url"?: string - readonly "filename"?: string - readonly "type": never - readonly "detail": "auto" | "high" | "low" | "original" - readonly "image_url"?: string | null - } | { - readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint - readonly "text": string - readonly "type": never - readonly "file_data"?: string - readonly "file_id"?: string | null - readonly "file_url"?: string - readonly "filename"?: string - } | { - readonly "detail": "auto" | "high" | "low" | "original" - readonly "image_url"?: string | null - readonly "type": never - readonly "file_data"?: string - readonly "file_id"?: string | null - readonly "file_url"?: string - readonly "filename"?: string - } | { - readonly "file_data"?: string - readonly "file_id"?: string | null - readonly "file_url"?: string - readonly "filename"?: string - readonly "type": "input_file" - } + { readonly "type": "image"; readonly "url": string } | { readonly "logs": string; readonly "type": "logs" } > - readonly "status"?: ToolCallStatus | null - readonly "type": "function_call_output" + | null + readonly "status": ToolCallStatus + readonly "type": "code_interpreter_call" } -export const FunctionCallOutputItem = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "output": Schema.Union([ - Schema.Union([Schema.String]), - Schema.Union([Schema.Array(Schema.Union([ - Schema.Union([ - Schema.Struct({ - "prompt_cache_breakpoint": Schema.optionalKey( - Schema.Union([ - Schema.Union([ - Schema.StructWithRest(Schema.Struct({ "mode": Schema.Literal("explicit") }), [ - Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) - ]) - ]).annotate({ - "description": - "Marks an explicit prompt-cache boundary on this content block (OpenAI-style). Everything through the block carrying this marker is part of the candidate cached prefix. Supported natively by OpenAI GPT-5.6 and newer; on providers that use Anthropic-style `cache_control`, OpenRouter converts the marker to that format automatically." - }), - Schema.Union([Schema.Null]).annotate({ - "description": - "Marks an explicit prompt-cache boundary on this content block (OpenAI-style). Everything through the block carrying this marker is part of the candidate cached prefix. Supported natively by OpenAI GPT-5.6 and newer; on providers that use Anthropic-style `cache_control`, OpenRouter converts the marker to that format automatically." - }) - ]).annotate({ - "description": - "Marks an explicit prompt-cache boundary on this content block (OpenAI-style). Everything through the block carrying this marker is part of the candidate cached prefix. Supported natively by OpenAI GPT-5.6 and newer; on providers that use Anthropic-style `cache_control`, OpenRouter converts the marker to that format automatically." - }) - ), - "text": Schema.String, - "type": Schema.Literal("input_text") - }).annotate({ "description": "Text input content item" }), - Schema.Struct({ - "detail": Schema.Literals(["auto", "high", "low", "original"]), - "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Never, - "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), - "text": Schema.String - }).annotate({ "description": "Text input content item" }), - Schema.Struct({ - "file_data": Schema.optionalKey(Schema.String), - "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "file_url": Schema.optionalKey(Schema.String), - "filename": Schema.optionalKey(Schema.String), - "type": Schema.Never, - "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), - "text": Schema.String - }).annotate({ "description": "Text input content item" }) - ], { mode: "oneOf" }), - Schema.Union([ - Schema.Struct({ - "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), - "text": Schema.String, - "type": Schema.Never, - "detail": Schema.Literals(["auto", "high", "low", "original"]), - "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) - }).annotate({ "description": "Image input content item" }), - Schema.Struct({ - "detail": Schema.Union([ - Schema.Literal("auto"), - Schema.Literal("high"), - Schema.Literal("low"), - Schema.Literal("original") - ]), - "image_url": Schema.optionalKey(Schema.Union([Schema.Union([Schema.String]), Schema.Union([Schema.Null])])), - "type": Schema.Literal("input_image") - }).annotate({ "description": "Image input content item" }), - Schema.Struct({ - "file_data": Schema.optionalKey(Schema.String), - "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "file_url": Schema.optionalKey(Schema.String), - "filename": Schema.optionalKey(Schema.String), - "type": Schema.Never, - "detail": Schema.Literals(["auto", "high", "low", "original"]), - "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) - }).annotate({ "description": "Image input content item" }) - ], { mode: "oneOf" }), +export const OutputCodeInterpreterCallItem = Schema.Struct({ + "code": Schema.Union([Schema.String, Schema.Null]), + "container_id": Schema.String, + "id": Schema.String, + "outputs": Schema.Union([ + Schema.Array( Schema.Union([ - Schema.Struct({ - "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), - "text": Schema.String, - "type": Schema.Never, - "file_data": Schema.optionalKey(Schema.String), - "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "file_url": Schema.optionalKey(Schema.String), - "filename": Schema.optionalKey(Schema.String) - }).annotate({ "description": "File input content item" }), - Schema.Struct({ - "detail": Schema.Literals(["auto", "high", "low", "original"]), - "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Never, - "file_data": Schema.optionalKey(Schema.String), - "file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "file_url": Schema.optionalKey(Schema.String), - "filename": Schema.optionalKey(Schema.String) - }).annotate({ "description": "File input content item" }), - Schema.Struct({ - "file_data": Schema.optionalKey(Schema.String), - "file_id": Schema.optionalKey(Schema.Union([Schema.Union([Schema.String]), Schema.Union([Schema.Null])])), - "file_url": Schema.optionalKey(Schema.String), - "filename": Schema.optionalKey(Schema.String), - "type": Schema.Literal("input_file") - }).annotate({ "description": "File input content item" }) - ], { mode: "oneOf" }) - ], { mode: "oneOf" }))]) + Schema.Struct({ "type": Schema.Literal("image"), "url": Schema.String }), + Schema.Struct({ "logs": Schema.String, "type": Schema.Literal("logs") }) + ]) + ), + Schema.Null ]), - "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), - "type": Schema.Literal("function_call_output") -}).annotate({ "description": "The output from a function call execution", "identifier": "FunctionCallOutputItem" }) -export type InputText = { - readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint - readonly "text": string - readonly "type": "input_text" + "status": ToolCallStatus, + "type": Schema.Literal("code_interpreter_call") +}).annotate({ + "description": "A code interpreter execution call with outputs", + "identifier": "OutputCodeInterpreterCallItem" +}) +export type OutputDatetimeItem = { + readonly "datetime": string + readonly "id"?: string + readonly "status": ToolCallStatus + readonly "timezone": string + readonly "type": "openrouter:datetime" } -export const InputText = Schema.Struct({ - "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), - "text": Schema.String, - "type": Schema.Literal("input_text") -}).annotate({ "description": "Text input content item", "identifier": "InputText" }) -export type Guardrail = { - readonly "allowed_models"?: ReadonlyArray | null - readonly "allowed_providers"?: ReadonlyArray | null - readonly "content_filter_builtins"?: ReadonlyArray | null - readonly "content_filters"?: ReadonlyArray | null - readonly "created_at": string - readonly "description"?: string | null - readonly "enforce_zdr"?: boolean | null - readonly "enforce_zdr_anthropic"?: boolean | null - readonly "enforce_zdr_google"?: boolean | null - readonly "enforce_zdr_openai"?: boolean | null - readonly "enforce_zdr_other"?: boolean | null - readonly "enforce_zdr_xai"?: boolean | null - readonly "id": string - readonly "ignored_models"?: ReadonlyArray | null - readonly "ignored_providers"?: ReadonlyArray | null - readonly "limit_usd"?: number | null - readonly "name": string - readonly "reset_interval"?: GuardrailInterval - readonly "updated_at"?: string | null - readonly "workspace_id": string +export const OutputDatetimeItem = Schema.Struct({ + "datetime": Schema.String.annotate({ "description": "ISO 8601 datetime string" }), + "id": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "timezone": Schema.String.annotate({ "description": "IANA timezone name" }), + "type": Schema.Literal("openrouter:datetime") +}).annotate({ "description": "An openrouter:datetime server tool output item", "identifier": "OutputDatetimeItem" }) +export type OutputWebSearchServerToolItem = { + readonly "action"?: { + readonly "query": string + readonly "sources"?: ReadonlyArray<{ readonly "type": "url"; readonly "url": string }> + readonly "type": "search" + } + readonly "id"?: string + readonly "status": ToolCallStatus + readonly "type": "openrouter:web_search" } -export const Guardrail = Schema.Struct({ - "allowed_models": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": "Array of model canonical_slugs (immutable identifiers)" - }) - ), - "allowed_providers": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "description": "List of allowed provider IDs" }) - ), - "content_filter_builtins": Schema.optionalKey( - Schema.Union([Schema.Array(ContentFilterBuiltinEntry), Schema.Null]).annotate({ - "description": - "Builtin content filters applied to requests. Includes PII detectors and the regex-based prompt injection detector." - }) - ), - "content_filters": Schema.optionalKey( - Schema.Union([Schema.Array(ContentFilterEntry), Schema.Null]).annotate({ - "description": "Custom regex content filters applied to request messages" - }) - ), - "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the guardrail was created" }), - "description": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Description of the guardrail" }) - ), - "enforce_zdr": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, enforce_zdr_xai, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request." - }) - ), - "enforce_zdr_anthropic": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided." - }) - ), - "enforce_zdr_google": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided." - }) - ), - "enforce_zdr_openai": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ +export const OutputWebSearchServerToolItem = Schema.Struct({ + "action": Schema.optionalKey( + Schema.Struct({ + "query": Schema.String, + "sources": Schema.optionalKey( + Schema.Array(Schema.Struct({ "type": Schema.Literal("url"), "url": Schema.String })) + ), + "type": Schema.Literal("search") + }).annotate({ "description": - "Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided." + "The search action performed, matching OpenAI web_search_call.action shape. Includes the query the model issued and optional source URLs returned by the search provider." }) ), - "enforce_zdr_other": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, Google, or xAI. Falls back to enforce_zdr when not provided." - }) + "id": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:web_search") +}).annotate({ + "description": "An openrouter:web_search server tool output item", + "identifier": "OutputWebSearchServerToolItem" +}) +export type OutputCodeInterpreterServerToolItem = { + readonly "code"?: string + readonly "exitCode"?: number + readonly "id"?: string + readonly "language"?: string + readonly "status": ToolCallStatus + readonly "stderr"?: string + readonly "stdout"?: string + readonly "type": "openrouter:code_interpreter" +} +export const OutputCodeInterpreterServerToolItem = Schema.Struct({ + "code": Schema.optionalKey(Schema.String), + "exitCode": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "id": Schema.optionalKey(Schema.String), + "language": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "stderr": Schema.optionalKey(Schema.String), + "stdout": Schema.optionalKey(Schema.String), + "type": Schema.Literal("openrouter:code_interpreter") +}).annotate({ + "description": "An openrouter:code_interpreter server tool output item", + "identifier": "OutputCodeInterpreterServerToolItem" +}) +export type OutputFileSearchServerToolItem = { + readonly "id"?: string + readonly "queries"?: ReadonlyArray + readonly "status": ToolCallStatus + readonly "type": "openrouter:file_search" +} +export const OutputFileSearchServerToolItem = Schema.Struct({ + "id": Schema.optionalKey(Schema.String), + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:file_search") +}).annotate({ + "description": "An openrouter:file_search server tool output item", + "identifier": "OutputFileSearchServerToolItem" +}) +export type OutputImageGenerationServerToolItem = { + readonly "id"?: string + readonly "imageB64"?: string + readonly "imageUrl"?: string + readonly "prompt"?: string + readonly "result"?: string | null + readonly "revisedPrompt"?: string + readonly "status": ToolCallStatus + readonly "type": "openrouter:image_generation" +} +export const OutputImageGenerationServerToolItem = Schema.Struct({ + "id": Schema.optionalKey(Schema.String), + "imageB64": Schema.optionalKey(Schema.String), + "imageUrl": Schema.optionalKey(Schema.String), + "prompt": Schema.optionalKey( + Schema.String.annotate({ "description": "The prompt (possibly rewritten) that the image was generated from." }) ), - "enforce_zdr_xai": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "result": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": - "Whether to enforce zero data retention for xAI models. Falls back to enforce_zdr when not provided." - }) - ), - "id": Schema.String.annotate({ "description": "Unique identifier for the guardrail", "format": "uuid" }), - "ignored_models": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": "Array of model canonical_slugs to exclude from routing" - }) - ), - "ignored_providers": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": "List of provider IDs to exclude from routing" + "The generated image as a base64-encoded string or URL, matching OpenAI image_generation_call format" }) ), - "limit_usd": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Spending limit in USD", "format": "double" }) + "revisedPrompt": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:image_generation") +}).annotate({ + "description": "An openrouter:image_generation server tool output item", + "identifier": "OutputImageGenerationServerToolItem" +}) +export type OutputBrowserUseServerToolItem = { + readonly "action"?: string + readonly "id"?: string + readonly "screenshotB64"?: string + readonly "status": ToolCallStatus + readonly "type": "openrouter:browser_use" +} +export const OutputBrowserUseServerToolItem = Schema.Struct({ + "action": Schema.optionalKey(Schema.String), + "id": Schema.optionalKey(Schema.String), + "screenshotB64": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:browser_use") +}).annotate({ + "description": "An openrouter:browser_use server tool output item", + "identifier": "OutputBrowserUseServerToolItem" +}) +export type OutputBashServerToolItem = { + readonly "arguments"?: string + readonly "call_id"?: string + readonly "command"?: string + readonly "exitCode"?: number + readonly "id"?: string + readonly "status": ToolCallStatus + readonly "stderr"?: string + readonly "stdout"?: string + readonly "type": "openrouter:bash" +} +export const OutputBashServerToolItem = Schema.Struct({ + "arguments": Schema.optionalKey( + Schema.String.annotate({ "description": "The raw tool-call arguments string as emitted by the model." }) ), - "name": Schema.String.annotate({ "description": "Name of the guardrail" }), - "reset_interval": Schema.optionalKey(GuardrailInterval), - "updated_at": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "ISO 8601 timestamp of when the guardrail was last updated" - }) + "call_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The model-generated tool call id from the originating turn." }) ), - "workspace_id": Schema.String.annotate({ "description": "The workspace ID this guardrail belongs to." }) -}).annotate({ "identifier": "Guardrail" }) -export type CreateGuardrailRequest = { - readonly "allowed_models"?: ReadonlyArray | null - readonly "allowed_providers"?: ReadonlyArray | null - readonly "content_filter_builtins"?: ReadonlyArray | null - readonly "content_filters"?: ReadonlyArray | null - readonly "description"?: string | null - readonly "enforce_zdr"?: boolean | null - readonly "enforce_zdr_anthropic"?: boolean | null - readonly "enforce_zdr_google"?: boolean | null - readonly "enforce_zdr_openai"?: boolean | null - readonly "enforce_zdr_other"?: boolean | null - readonly "enforce_zdr_xai"?: boolean | null - readonly "ignored_models"?: ReadonlyArray | null - readonly "ignored_providers"?: ReadonlyArray | null - readonly "limit_usd"?: number | null - readonly "name": string - readonly "reset_interval"?: GuardrailInterval - readonly "workspace_id"?: string + "command": Schema.optionalKey(Schema.String), + "exitCode": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "id": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "stderr": Schema.optionalKey(Schema.String), + "stdout": Schema.optionalKey(Schema.String), + "type": Schema.Literal("openrouter:bash") +}).annotate({ "description": "An openrouter:bash server tool output item", "identifier": "OutputBashServerToolItem" }) +export type OutputTextEditorServerToolItem = { + readonly "command"?: "view" | "create" | "str_replace" | "insert" + readonly "filePath"?: string + readonly "id"?: string + readonly "status": ToolCallStatus + readonly "type": "openrouter:text_editor" } -export const CreateGuardrailRequest = Schema.Struct({ - "allowed_models": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - Schema.Null - ]).annotate({ "description": "Array of model identifiers (slug or canonical_slug accepted)" }) +export const OutputTextEditorServerToolItem = Schema.Struct({ + "command": Schema.optionalKey(Schema.Literals(["view", "create", "str_replace", "insert"])), + "filePath": Schema.optionalKey(Schema.String), + "id": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:text_editor") +}).annotate({ + "description": "An openrouter:text_editor server tool output item", + "identifier": "OutputTextEditorServerToolItem" +}) +export type OutputWebFetchServerToolItem = { + readonly "content"?: string + readonly "error"?: string + readonly "httpStatus"?: number + readonly "id"?: string + readonly "status": ToolCallStatus + readonly "title"?: string + readonly "type": "openrouter:web_fetch" + readonly "url"?: string +} +export const OutputWebFetchServerToolItem = Schema.Struct({ + "content": Schema.optionalKey(Schema.String), + "error": Schema.optionalKey(Schema.String.annotate({ "description": "The error message if the fetch failed." })), + "httpStatus": Schema.optionalKey( + Schema.Number.annotate({ "description": "The HTTP status code returned by the upstream URL fetch." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) ), - "allowed_providers": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - Schema.Null - ]).annotate({ "description": "List of allowed provider IDs" }) - ), - "content_filter_builtins": Schema.optionalKey( - Schema.Union([Schema.Array(ContentFilterBuiltinEntryInput), Schema.Null]).annotate({ - "description": - "Builtin content filters to apply. Every builtin slug supports \"block\", \"redact\", and the detect-only \"flag\" action." - }) - ), - "content_filters": Schema.optionalKey( - Schema.Union([Schema.Array(ContentFilterEntry), Schema.Null]).annotate({ - "description": "Custom regex content filters to apply to request messages" - }) - ), - "description": Schema.optionalKey( - Schema.Union([ - Schema.String.check(Schema.isMaxLength(1000).annotate({ "expected": "a value with a length of at most 1000" })), - Schema.Null - ]).annotate({ "description": "Description of the guardrail" }) - ), - "enforce_zdr": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, enforce_zdr_xai, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request." - }) - ), - "enforce_zdr_anthropic": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided." - }) - ), - "enforce_zdr_google": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided." - }) - ), - "enforce_zdr_openai": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided." - }) - ), - "enforce_zdr_other": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, Google, or xAI. Falls back to enforce_zdr when not provided." + "id": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "title": Schema.optionalKey(Schema.String), + "type": Schema.Literal("openrouter:web_fetch"), + "url": Schema.optionalKey(Schema.String) +}).annotate({ + "description": "An openrouter:web_fetch server tool output item", + "identifier": "OutputWebFetchServerToolItem" +}) +export type OutputToolSearchServerToolItem = { + readonly "id"?: string + readonly "query"?: string + readonly "status": ToolCallStatus + readonly "type": "openrouter:tool_search" +} +export const OutputToolSearchServerToolItem = Schema.Struct({ + "id": Schema.optionalKey(Schema.String), + "query": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:tool_search") +}).annotate({ + "description": "An openrouter:tool_search server tool output item", + "identifier": "OutputToolSearchServerToolItem" +}) +export type OutputMemoryServerToolItem = { + readonly "action"?: "read" | "write" | "delete" + readonly "id"?: string + readonly "key"?: string + readonly "status": ToolCallStatus + readonly "type": "openrouter:memory" + readonly "value"?: Schema.Json +} +export const OutputMemoryServerToolItem = Schema.Struct({ + "action": Schema.optionalKey(Schema.Literals(["read", "write", "delete"])), + "id": Schema.optionalKey(Schema.String), + "key": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:memory"), + "value": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })) +}).annotate({ + "description": "An openrouter:memory server tool output item", + "identifier": "OutputMemoryServerToolItem" +}) +export type OutputMcpServerToolItem = { + readonly "id"?: string + readonly "serverLabel"?: string + readonly "status": ToolCallStatus + readonly "toolName"?: string + readonly "type": "openrouter:mcp" +} +export const OutputMcpServerToolItem = Schema.Struct({ + "id": Schema.optionalKey(Schema.String), + "serverLabel": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "toolName": Schema.optionalKey(Schema.String), + "type": Schema.Literal("openrouter:mcp") +}).annotate({ "description": "An openrouter:mcp server tool output item", "identifier": "OutputMcpServerToolItem" }) +export type OutputSearchModelsServerToolItem = { + readonly "arguments"?: string + readonly "id"?: string + readonly "query"?: string + readonly "status": ToolCallStatus + readonly "type": "openrouter:experimental__search_models" +} +export const OutputSearchModelsServerToolItem = Schema.Struct({ + "arguments": Schema.optionalKey( + Schema.String.annotate({ + "description": "The JSON arguments submitted to the search tool (e.g. {\"query\":\"Claude\"})" }) ), - "enforce_zdr_xai": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for xAI models. Falls back to enforce_zdr when not provided." + "id": Schema.optionalKey(Schema.String), + "query": Schema.optionalKey(Schema.String), + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:experimental__search_models") +}).annotate({ + "description": "An openrouter:experimental__search_models server tool output item", + "identifier": "OutputSearchModelsServerToolItem" +}) +export type OutputAdvisorServerToolItem = { + readonly "advice"?: string + readonly "error"?: string + readonly "id"?: string + readonly "instance_name"?: string + readonly "model"?: string + readonly "prompt"?: string + readonly "status": ToolCallStatus + readonly "type": "openrouter:advisor" +} +export const OutputAdvisorServerToolItem = Schema.Struct({ + "advice": Schema.optionalKey( + Schema.String.annotate({ + "description": "The advisor model's response (the advice text returned to the executor)." }) ), - "ignored_models": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - Schema.Null - ]).annotate({ - "description": "Array of model identifiers to exclude from routing (slug or canonical_slug accepted)" - }) + "error": Schema.optionalKey( + Schema.String.annotate({ "description": "Error message when the advisor call did not produce advice." }) ), - "ignored_providers": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - Schema.Null - ]).annotate({ "description": "List of provider IDs to exclude from routing" }) + "id": Schema.optionalKey(Schema.String), + "instance_name": Schema.optionalKey(Schema.String.annotate({ + "description": + "Provider-safe function name of the specific advisor instance that produced this item (e.g. `openrouter_advisor__1`). Present only when more than one advisor tool is configured; omitted for the default single advisor. Echo this field back unchanged so the advisor's cross-request memory stays namespaced to the correct instance. This identity is positional: it is derived from the index of the advisor entry in the request `tools` array, so clients must keep the order of advisor tool entries stable across requests in a conversation. Reordering or inserting advisor entries shifts these names and causes each advisor's cross-request memory to be attributed to the wrong instance." + })), + "model": Schema.optionalKey( + Schema.String.annotate({ "description": "Slug of the advisor model that was consulted." }) ), - "limit_usd": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Spending limit in USD", "format": "double" }) + "prompt": Schema.optionalKey( + Schema.String.annotate({ "description": "The prompt the executor sent to the advisor." }) ), - "name": Schema.String.annotate({ "description": "Name for the new guardrail" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ).check(Schema.isMaxLength(200).annotate({ "expected": "a value with a length of at most 200" })), - "reset_interval": Schema.optionalKey(GuardrailInterval), - "workspace_id": Schema.optionalKey( - Schema.String.annotate({ - "description": "The workspace to create the guardrail in. Defaults to the default workspace if not provided.", - "format": "uuid" - }) - ) -}).annotate({ "identifier": "CreateGuardrailRequest" }) -export type UpdateGuardrailRequest = { - readonly "allowed_models"?: ReadonlyArray | null - readonly "allowed_providers"?: ReadonlyArray | null - readonly "content_filter_builtins"?: ReadonlyArray | null - readonly "content_filters"?: ReadonlyArray | null - readonly "description"?: string | null - readonly "enforce_zdr"?: boolean | null - readonly "enforce_zdr_anthropic"?: boolean | null - readonly "enforce_zdr_google"?: boolean | null - readonly "enforce_zdr_openai"?: boolean | null - readonly "enforce_zdr_other"?: boolean | null - readonly "enforce_zdr_xai"?: boolean | null - readonly "ignored_models"?: ReadonlyArray | null - readonly "ignored_providers"?: ReadonlyArray | null - readonly "limit_usd"?: number | null + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:advisor") +}).annotate({ + "description": "An openrouter:advisor server tool output item", + "identifier": "OutputAdvisorServerToolItem" +}) +export type OutputSubagentServerToolItem = { + readonly "error"?: string + readonly "id"?: string + readonly "instance_name"?: string + readonly "model"?: string readonly "name"?: string - readonly "reset_interval"?: GuardrailInterval + readonly "outcome"?: string + readonly "status": ToolCallStatus + readonly "task_description"?: string + readonly "task_name"?: string + readonly "type": "openrouter:subagent" } -export const UpdateGuardrailRequest = Schema.Struct({ - "allowed_models": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - Schema.Null - ]).annotate({ "description": "Array of model identifiers (slug or canonical_slug accepted)" }) +export const OutputSubagentServerToolItem = Schema.Struct({ + "error": Schema.optionalKey( + Schema.String.annotate({ "description": "Error message when the subagent task did not produce an outcome." }) ), - "allowed_providers": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - Schema.Null - ]).annotate({ "description": "New list of allowed provider IDs" }) + "id": Schema.optionalKey(Schema.String), + "instance_name": Schema.optionalKey(Schema.String.annotate({ + "description": + "Provider-safe function name of the specific subagent instance that produced this item (e.g. `openrouter_subagent__1`). Present only on items from non-default instances — the second and later subagent entries in the request `tools` array. The first (default) instance omits it, even when multiple subagents are configured. When a replayed item echoes this field back, the transcript rehydrates the call under that instance's tool. This identity is positional: it is derived from the index of the subagent entry in the request `tools` array, so keep the order of subagent entries stable across requests in a conversation." + })), + "model": Schema.optionalKey( + Schema.String.annotate({ "description": "Slug of the worker model that executed the task." }) ), - "content_filter_builtins": Schema.optionalKey( - Schema.Union([Schema.Array(ContentFilterBuiltinEntryInput), Schema.Null]).annotate({ + "name": Schema.optionalKey( + Schema.String.annotate({ "description": - "Builtin content filters to apply. Set to null to remove. Every builtin slug supports \"block\", \"redact\", and the detect-only \"flag\" action." + "Configured name of the subagent that executed the task (the `name` on its tool entry). Present only for named subagents; omitted for an unnamed (default) subagent." }) ), - "content_filters": Schema.optionalKey( - Schema.Union([Schema.Array(ContentFilterEntry), Schema.Null]).annotate({ - "description": "Custom regex content filters to apply. Set to null to remove." + "outcome": Schema.optionalKey( + Schema.String.annotate({ + "description": "The worker model's result (the outcome text returned to the delegating model)." }) ), - "description": Schema.optionalKey( - Schema.Union([ - Schema.String.check(Schema.isMaxLength(1000).annotate({ "expected": "a value with a length of at most 1000" })), - Schema.Null - ]).annotate({ "description": "New description for the guardrail" }) + "status": ToolCallStatus, + "task_description": Schema.optionalKey( + Schema.String.annotate({ "description": "The task description the delegating model sent to the worker." }) ), - "enforce_zdr": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, enforce_zdr_xai, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request." - }) + "task_name": Schema.optionalKey( + Schema.String.annotate({ "description": "The short task identifier the delegating model supplied." }) ), - "enforce_zdr_anthropic": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided." - }) + "type": Schema.Literal("openrouter:subagent") +}).annotate({ + "description": "An openrouter:subagent server tool output item", + "identifier": "OutputSubagentServerToolItem" +}) +export type OutputFilesServerToolItem = { + readonly "error"?: string + readonly "file_id"?: string + readonly "filename"?: string + readonly "id"?: string + readonly "operation"?: string + readonly "result"?: string + readonly "status": ToolCallStatus + readonly "type": "openrouter:files" +} +export const OutputFilesServerToolItem = Schema.Struct({ + "error": Schema.optionalKey( + Schema.String.annotate({ "description": "Error message when the file operation failed." }) ), - "enforce_zdr_google": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided." - }) + "file_id": Schema.optionalKey( + Schema.String.annotate({ "description": "The target file id supplied in the tool-call arguments." }) ), - "enforce_zdr_openai": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided." - }) + "filename": Schema.optionalKey( + Schema.String.annotate({ "description": "The target filename supplied in the tool-call arguments." }) ), - "enforce_zdr_other": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, Google, or xAI. Falls back to enforce_zdr when not provided." - }) + "id": Schema.optionalKey(Schema.String), + "operation": Schema.optionalKey( + Schema.String.annotate({ "description": "The file operation performed (list, read, write, or edit)." }) ), - "enforce_zdr_xai": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ - "description": - "Whether to enforce zero data retention for xAI models. Falls back to enforce_zdr when not provided." - }) + "result": Schema.optionalKey( + Schema.String.annotate({ "description": "JSON-serialized result of the file operation." }) ), - "ignored_models": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - Schema.Null - ]).annotate({ - "description": "Array of model identifiers to exclude from routing (slug or canonical_slug accepted)" - }) + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:files") +}).annotate({ "description": "An openrouter:files server tool output item", "identifier": "OutputFilesServerToolItem" }) +export type LocalShellCallItem = { + readonly "action": { + readonly "command": ReadonlyArray + readonly "env": {} + readonly "timeout_ms"?: number | null + readonly "type": "exec" + readonly "user"?: string | null + readonly "working_directory"?: string | null + } + readonly "call_id": string + readonly "id": string + readonly "status": ToolCallStatus + readonly "type": "local_shell_call" +} +export const LocalShellCallItem = Schema.Struct({ + "action": Schema.Struct({ + "command": Schema.Array(Schema.String), + "env": Schema.Struct({}), + "timeout_ms": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ), + "type": Schema.Literal("exec"), + "user": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "working_directory": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + }), + "call_id": Schema.String, + "id": Schema.String, + "status": ToolCallStatus, + "type": Schema.Literal("local_shell_call") +}).annotate({ "description": "A local shell command execution call", "identifier": "LocalShellCallItem" }) +export type LocalShellCallOutputItem = { + readonly "id": string + readonly "output": string + readonly "status"?: ToolCallStatus | null + readonly "type": "local_shell_call_output" +} +export const LocalShellCallOutputItem = Schema.Struct({ + "id": Schema.String, + "output": Schema.String, + "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), + "type": Schema.Literal("local_shell_call_output") +}).annotate({ "description": "Output from a local shell command execution", "identifier": "LocalShellCallOutputItem" }) +export type ShellCallItem = { + readonly "action": { + readonly "commands": ReadonlyArray + readonly "max_output_length"?: number | null + readonly "timeout_ms"?: number | null + } + readonly "call_id": string + readonly "environment"?: Schema.Json + readonly "id"?: string | null + readonly "status"?: ToolCallStatus | null + readonly "type": "shell_call" +} +export const ShellCallItem = Schema.Struct({ + "action": Schema.Struct({ + "commands": Schema.Array(Schema.String), + "max_output_length": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ), + "timeout_ms": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ) + }), + "call_id": Schema.String, + "environment": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), + "type": Schema.Literal("shell_call") +}).annotate({ "description": "A shell command execution call (newer variant)", "identifier": "ShellCallItem" }) +export type ShellCallOutputItem = { + readonly "call_id": string + readonly "id"?: string | null + readonly "max_output_length"?: number | null + readonly "output": ReadonlyArray< + { readonly "content"?: string | null; readonly "exit_code"?: number | null; readonly "type": string } + > + readonly "status"?: ToolCallStatus | null + readonly "type": "shell_call_output" +} +export const ShellCallOutputItem = Schema.Struct({ + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "max_output_length": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) ), - "ignored_providers": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + "output": Schema.Array( + Schema.Struct({ + "content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "exit_code": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) ), - Schema.Null - ]).annotate({ "description": "List of provider IDs to exclude from routing" }) - ), - "limit_usd": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "New spending limit in USD", "format": "double" }) - ), - "name": Schema.optionalKey( - Schema.String.annotate({ "description": "New name for the guardrail" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ).check(Schema.isMaxLength(200).annotate({ "expected": "a value with a length of at most 200" })) - ), - "reset_interval": Schema.optionalKey(GuardrailInterval) -}).annotate({ "identifier": "UpdateGuardrailRequest" }) -export type SpeechRequest = { - readonly "input": string - readonly "model": string - readonly "provider"?: { readonly "options"?: ProviderOptions } - readonly "response_format"?: "mp3" | "pcm" - readonly "speed"?: number - readonly "voice": string -} -export const SpeechRequest = Schema.Struct({ - "input": Schema.String.annotate({ "description": "Text to synthesize" }), - "model": Schema.String.annotate({ "description": "TTS model identifier" }), - "provider": Schema.optionalKey( - Schema.Struct({ "options": Schema.optionalKey(ProviderOptions) }).annotate({ - "description": "Provider-specific passthrough configuration" + "type": Schema.String }) ), - "response_format": Schema.optionalKey( - Schema.Literals(["mp3", "pcm"]).annotate({ "description": "Audio output format" }) - ), - "speed": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Playback speed multiplier. Only used by models that support it (e.g. OpenAI TTS). Ignored by other providers.", - "format": "double" - }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "voice": Schema.String.annotate({ "description": "Voice identifier (provider-specific)." }) -}).annotate({ "description": "Text-to-speech request input", "identifier": "SpeechRequest" }) -export type STTRequest = { - readonly "input_audio": STTInputAudio - readonly "language"?: string - readonly "model": string - readonly "provider"?: { readonly "options"?: ProviderOptions } - readonly "response_format"?: "json" | "verbose_json" - readonly "temperature"?: number - readonly "timestamp_granularities"?: ReadonlyArray + "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), + "type": Schema.Literal("shell_call_output") +}).annotate({ + "description": "Output from a shell command execution (newer variant)", + "identifier": "ShellCallOutputItem" +}) +export type OpenAIResponseFunctionToolCall = { + readonly "arguments": string + readonly "call_id": string + readonly "id"?: string + readonly "name": string + readonly "namespace"?: string + readonly "status"?: ToolCallStatus + readonly "type": "function_call" } -export const STTRequest = Schema.Struct({ - "input_audio": STTInputAudio, - "language": Schema.optionalKey( +export const OpenAIResponseFunctionToolCall = Schema.Struct({ + "arguments": Schema.String, + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.String), + "name": Schema.String, + "namespace": Schema.optionalKey( Schema.String.annotate({ - "description": "ISO-639-1 language code (e.g., \"en\", \"ja\"). Auto-detected if omitted." - }) - ), - "model": Schema.String.annotate({ "description": "STT model identifier" }), - "provider": Schema.optionalKey( - Schema.Struct({ "options": Schema.optionalKey(ProviderOptions) }).annotate({ - "description": "Provider-specific passthrough configuration" - }) - ), - "response_format": Schema.optionalKey( - Schema.Literals(["json", "verbose_json"]).annotate({ - "description": - "Output format. \"json\" (default) returns { text, usage }. \"verbose_json\" additionally returns task, language, duration, and segment-level timestamps; only supported by OpenAI-compatible providers." + "description": "Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)" }) ), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ "description": "Sampling temperature for transcription", "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - ), - "timestamp_granularities": Schema.optionalKey( - Schema.Array(STTTimestampGranularity).annotate({ - "description": - "Timestamp detail levels to include when response_format is \"verbose_json\". \"segment\" returns segment-level timestamps; \"word\" additionally returns word-level timestamps in the words array. Ignored unless response_format is \"verbose_json\"." - }) + "status": Schema.optionalKey(ToolCallStatus), + "type": Schema.Literal("function_call") +}).annotate({ "identifier": "OpenAIResponseFunctionToolCall" }) +export type ApplyPatchCallOperation = + | ApplyPatchCreateFileOperation + | ApplyPatchUpdateFileOperation + | ApplyPatchDeleteFileOperation +export const ApplyPatchCallOperation = Schema.Union([ + ApplyPatchCreateFileOperation, + ApplyPatchUpdateFileOperation, + ApplyPatchDeleteFileOperation +], { mode: "oneOf" }).annotate({ + "description": + "The patch operation requested by an `apply_patch_call`. `create_file` and `update_file` carry a V4A diff; `delete_file` omits it.", + "identifier": "ApplyPatchCallOperation" +}) +export type OpenAIResponsesAnnotation = FileCitation | URLCitation | FilePath +export const OpenAIResponsesAnnotation = Schema.Union([FileCitation, URLCitation, FilePath]).annotate({ + "identifier": "OpenAIResponsesAnnotation" +}) +export type OutputWebSearchCallItem = { + readonly "action"?: + | { + readonly "queries"?: ReadonlyArray + readonly "query": string + readonly "sources"?: ReadonlyArray + readonly "type": "search" + } + | { readonly "type": "open_page"; readonly "url"?: string | null } + | { readonly "pattern": string; readonly "type": "find_in_page"; readonly "url": string } + readonly "id": string + readonly "status": WebSearchStatus + readonly "type": "web_search_call" +} +export const OutputWebSearchCallItem = Schema.Struct({ + "action": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "queries": Schema.optionalKey(Schema.Array(Schema.String)), + "query": Schema.String, + "sources": Schema.optionalKey(Schema.Array(WebSearchSource)), + "type": Schema.Literal("search") + }), + Schema.Struct({ + "type": Schema.Literal("open_page"), + "url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) + }), + Schema.Struct({ "pattern": Schema.String, "type": Schema.Literal("find_in_page"), "url": Schema.String }) + ], { mode: "oneOf" }) + ), + "id": Schema.String, + "status": WebSearchStatus, + "type": Schema.Literal("web_search_call") +}).annotate({ "identifier": "OutputWebSearchCallItem" }) +export type OutputFileSearchCallItem = { + readonly "id": string + readonly "queries": ReadonlyArray + readonly "status": WebSearchStatus + readonly "type": "file_search_call" +} +export const OutputFileSearchCallItem = Schema.Struct({ + "id": Schema.String, + "queries": Schema.Array(Schema.String), + "status": WebSearchStatus, + "type": Schema.Literal("file_search_call") +}).annotate({ "identifier": "OutputFileSearchCallItem" }) +export type OutputImageGenerationCallItem = { + readonly "id": string + readonly "result"?: string | null + readonly "status": ImageGenerationStatus + readonly "type": "image_generation_call" + readonly "prompt"?: string +} +export const OutputImageGenerationCallItem = Schema.Struct({ + "id": Schema.String, + "result": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "status": ImageGenerationStatus, + "type": Schema.Literal("image_generation_call"), + "prompt": Schema.optionalKey( + Schema.String.annotate({ "description": "The prompt (possibly rewritten) that the image was generated from." }) ) +}).annotate({ "identifier": "OutputImageGenerationCallItem" }) +export type OutputItemImageGenerationCall = { + readonly "id": string + readonly "result"?: string | null + readonly "status": ImageGenerationStatus + readonly "type": "image_generation_call" +} +export const OutputItemImageGenerationCall = Schema.Struct({ + "id": Schema.String, + "result": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "status": ImageGenerationStatus, + "type": Schema.Literal("image_generation_call") +}).annotate({ "identifier": "OutputItemImageGenerationCall" }) +export type FusionCallAnalysisCompletedEvent = { + readonly "analysis": FusionAnalysisResult + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.fusion_call.analysis.completed" +} +export const FusionCallAnalysisCompletedEvent = Schema.Struct({ + "analysis": FusionAnalysisResult, + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.fusion_call.analysis.completed") }).annotate({ - "description": "Speech-to-text request input. Accepts a JSON body with input_audio containing base64-encoded audio.", - "identifier": "STTRequest" + "description": "Emitted when the fusion analyst completes with the structured analysis.", + "identifier": "FusionCallAnalysisCompletedEvent" }) -export type VideoGenerationRequest = { - readonly "aspect_ratio"?: "16:9" | "9:16" | "1:1" | "4:3" | "3:4" | "3:2" | "2:3" | "21:9" | "9:21" - readonly "callback_url"?: string - readonly "duration"?: number - readonly "frame_images"?: ReadonlyArray - readonly "generate_audio"?: boolean - readonly "input_references"?: ReadonlyArray - readonly "model": string - readonly "prompt"?: string - readonly "provider"?: { readonly "options"?: ProviderOptions } - readonly "resolution"?: "480p" | "720p" | "1080p" | "1K" | "2K" | "4K" - readonly "seed"?: number - readonly "size"?: string +export type OutputFusionServerToolItem = { + readonly "analysis"?: FusionAnalysisResult + readonly "error"?: string + readonly "failed_models"?: ReadonlyArray< + { readonly "error": string; readonly "model": string; readonly "status_code"?: number } + > + readonly "failure_reason"?: string + readonly "id"?: string + readonly "responses"?: ReadonlyArray<{ readonly "content"?: string; readonly "model": string }> + readonly "sources"?: ReadonlyArray + readonly "status": ToolCallStatus + readonly "type": "openrouter:fusion" } -export const VideoGenerationRequest = Schema.Struct({ - "aspect_ratio": Schema.optionalKey( - Schema.Literals(["16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9", "9:21"]).annotate({ - "description": "Aspect ratio of the generated video" - }) +export const OutputFusionServerToolItem = Schema.Struct({ + "analysis": Schema.optionalKey(FusionAnalysisResult), + "error": Schema.optionalKey( + Schema.String.annotate({ "description": "Error message when the fusion run did not produce an analysis result." }) ), - "callback_url": Schema.optionalKey( - Schema.String.annotate({ + "failed_models": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "error": Schema.String.annotate({ "description": "Error message describing why the model failed." }), + "model": Schema.String.annotate({ "description": "Slug of the analysis model that failed." }), + "status_code": Schema.optionalKey( + Schema.Number.annotate({ + "description": "HTTP status code from the upstream response, when available (e.g. 402, 429)." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + })).annotate({ "description": - "URL to receive a webhook notification when the video generation job completes. Overrides the workspace-level default callback URL if set. Must be HTTPS.", - "format": "uri" + "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." }) ), - "duration": Schema.optionalKey( - Schema.Number.annotate({ "description": "Duration of the generated video in seconds" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })) - ), - "frame_images": Schema.optionalKey( - Schema.Array(FrameImage).annotate({ + "failure_reason": Schema.optionalKey(Schema.String.annotate({ + "description": + "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching." + })), + "id": Schema.optionalKey(Schema.String), + "responses": Schema.optionalKey( + Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })).annotate({ "description": - "Images to use as the first and/or last frame of the generated video. Each image must specify a frame_type of first_frame or last_frame." + "Analysis models that produced a response in this fusion run, with each model's full panel content." }) ), - "generate_audio": Schema.optionalKey( - Schema.Boolean.annotate({ + "sources": Schema.optionalKey( + Schema.Array(FusionSource).annotate({ "description": - "Whether to generate audio alongside the video. Defaults to the endpoint's generate_audio capability flag, false if not set." + "Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." }) ), - "input_references": Schema.optionalKey( - Schema.Array(InputReference).annotate({ + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:fusion") +}).annotate({ + "description": "An openrouter:fusion server tool output item", + "identifier": "OutputFusionServerToolItem" +}) +export type Preview_WebSearchServerTool = { + readonly "engine"?: WebSearchEngineEnum + readonly "filters"?: WebSearchDomainFilter + readonly "max_results"?: number + readonly "max_uses"?: number + readonly "mode"?: WebSearchMode + readonly "search_context_size"?: SearchContextSizeEnum + readonly "type": "web_search_preview" + readonly "user_location"?: Preview_WebSearchUserLocation +} +export const Preview_WebSearchServerTool = Schema.Struct({ + "engine": Schema.optionalKey(WebSearchEngineEnum), + "filters": Schema.optionalKey(WebSearchDomainFilter), + "max_results": Schema.optionalKey( + Schema.Number.annotate({ "description": - "Reference assets to guide video generation. Accepts image, audio, and video references. Audio and video references are only honored by providers that support them (currently BytePlus Seedance 2.0); other providers use image references and ignore the rest." - }) + "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "model": Schema.String, - "prompt": Schema.optionalKey( - Schema.String.annotate({ + "max_uses": Schema.optionalKey( + Schema.Number.annotate({ "description": - "Text prompt describing the video to generate. Optional for models that support generating a video from image input alone; required by all other models." - }) - ), - "provider": Schema.optionalKey( - Schema.Struct({ "options": Schema.optionalKey(ProviderOptions) }).annotate({ - "description": "Provider-specific passthrough configuration" - }) - ), - "resolution": Schema.optionalKey( - Schema.Literals(["480p", "720p", "1080p", "1K", "2K", "4K"]).annotate({ - "description": "Resolution of the generated video" - }) + "Maximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "seed": Schema.optionalKey( + "mode": Schema.optionalKey(WebSearchMode), + "search_context_size": Schema.optionalKey(SearchContextSizeEnum), + "type": Schema.Literal("web_search_preview"), + "user_location": Schema.optionalKey(Preview_WebSearchUserLocation) +}).annotate({ "description": "Web search preview tool configuration", "identifier": "Preview_WebSearchServerTool" }) +export type Preview_20250311_WebSearchServerTool = { + readonly "engine"?: WebSearchEngineEnum + readonly "filters"?: WebSearchDomainFilter + readonly "max_results"?: number + readonly "max_uses"?: number + readonly "mode"?: WebSearchMode + readonly "search_context_size"?: SearchContextSizeEnum + readonly "type": "web_search_preview_2025_03_11" + readonly "user_location"?: Preview_WebSearchUserLocation +} +export const Preview_20250311_WebSearchServerTool = Schema.Struct({ + "engine": Schema.optionalKey(WebSearchEngineEnum), + "filters": Schema.optionalKey(WebSearchDomainFilter), + "max_results": Schema.optionalKey( Schema.Number.annotate({ "description": - "If specified, the generation will sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed for all providers." + "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "size": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Exact pixel dimensions of the generated video in \"WIDTHxHEIGHT\" format (e.g. \"1280x720\"). Interchangeable with resolution + aspect_ratio." - }) - ) -}).annotate({ "identifier": "VideoGenerationRequest" }) -export type ImageGenerationProviderPreferences = { - readonly "allow_fallbacks"?: boolean | null - readonly "ignore"?: Union_2 - readonly "only"?: Union_3 - readonly "options"?: ProviderOptions - readonly "order"?: Union_4 - readonly "sort"?: Union_5 -} -export const ImageGenerationProviderPreferences = Schema.Struct({ - "allow_fallbacks": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "max_uses": Schema.optionalKey( + Schema.Number.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" - }) + "Maximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "ignore": Schema.optionalKey(Union_2), - "only": Schema.optionalKey(Union_3), - "options": Schema.optionalKey(ProviderOptions), - "order": Schema.optionalKey(Union_4), - "sort": Schema.optionalKey(Union_5) + "mode": Schema.optionalKey(WebSearchMode), + "search_context_size": Schema.optionalKey(SearchContextSizeEnum), + "type": Schema.Literal("web_search_preview_2025_03_11"), + "user_location": Schema.optionalKey(Preview_WebSearchUserLocation) }).annotate({ - "description": "Provider routing preferences and provider-specific passthrough configuration.", - "identifier": "ImageGenerationProviderPreferences" + "description": "Web search preview tool configuration (2025-03-11 version)", + "identifier": "Preview_20250311_WebSearchServerTool" }) -export type ListEndpointsResponse = { - readonly "architecture": { - readonly "input_modalities": ReadonlyArray<"text" | "image" | "file" | "audio" | "video"> - 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" - | null - readonly "modality": string | null - readonly "output_modalities": ReadonlyArray< - "text" | "image" | "embeddings" | "audio" | "video" | "rerank" | "speech" | "transcription" - > - readonly "tokenizer": - | "Router" - | "Media" - | "Other" - | "GPT" - | "Claude" - | "Gemini" - | "Gemma" - | "Grok" - | "Cohere" - | "Nova" - | "Qwen" - | "Yi" - | "DeepSeek" - | "Mistral" - | "Llama2" - | "Llama3" - | "Llama4" - | "PaLM" - | "RWKV" - | "Qwen3" - } - readonly "created": number - readonly "description": string - readonly "endpoints": ReadonlyArray - readonly "id": string - readonly "name": string +export type Legacy_WebSearchServerTool = { + readonly "engine"?: WebSearchEngineEnum + readonly "filters"?: WebSearchDomainFilter + readonly "max_results"?: number + readonly "max_uses"?: number + readonly "mode"?: WebSearchMode + readonly "search_context_size"?: SearchContextSizeEnum + readonly "type": "web_search" + readonly "user_location"?: WebSearchUserLocation } -export const ListEndpointsResponse = Schema.Struct({ - "architecture": Schema.Struct({ - "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" }), - "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" }), - Schema.Union([Schema.Null]).annotate({ "description": "Instruction format type" }) - ]).annotate({ "description": "Instruction format type" }), - "modality": Schema.Union([ - Schema.Union([Schema.String]).annotate({ "description": "Primary modality of the model" }), - Schema.Union([Schema.Null]).annotate({ "description": "Primary modality of the model" }) - ]).annotate({ "description": "Primary modality of the model" }), - "output_modalities": Schema.Array( - Schema.Union([ - Schema.Literal("text"), - Schema.Literal("image"), - Schema.Literal("embeddings"), - Schema.Literal("audio"), - Schema.Literal("video"), - Schema.Literal("rerank"), - Schema.Literal("speech"), - Schema.Literal("transcription") - ]) - ).annotate({ "description": "Supported output modalities" }), - "tokenizer": Schema.Union([ - Schema.Union([Schema.Literal("Router").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Media").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Other").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("GPT").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Claude").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Gemini").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Gemma").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Grok").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Cohere").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Nova").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Qwen").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Yi").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("DeepSeek").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Mistral").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Llama2").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Llama3").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Llama4").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("PaLM").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("RWKV").annotate({ "description": "Tokenizer type used by the model" })]), - Schema.Union([Schema.Literal("Qwen3").annotate({ "description": "Tokenizer type used by the model" })]) - ]).annotate({ "description": "Tokenizer type used by the model" }) - }).annotate({ "description": "Model architecture information" }), - "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) +export const Legacy_WebSearchServerTool = Schema.Struct({ + "engine": Schema.optionalKey(WebSearchEngineEnum), + "filters": Schema.optionalKey(WebSearchDomainFilter), + "max_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "description": Schema.String.annotate({ "description": "Description of the model" }), - "endpoints": Schema.Array(PublicEndpoint).annotate({ "description": "List of available endpoints for this model" }), - "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), - "name": Schema.String.annotate({ "description": "Display name of the model" }) -}).annotate({ "description": "List of available endpoints for a model", "identifier": "ListEndpointsResponse" }) -export type ModelReasoning = { - readonly "default_effort"?: ReasoningEffort - readonly "default_enabled"?: boolean - readonly "mandatory": boolean - readonly "supported_efforts"?: Union_12 - readonly "supports_max_tokens"?: boolean -} -export const ModelReasoning = Schema.Struct({ - "default_effort": Schema.optionalKey( - Schema.suspend((): Schema.Codec => ReasoningEffort).annotate({ + "max_uses": Schema.optionalKey( + Schema.Number.annotate({ "description": - "Default reasoning effort when the client enables reasoning without specifying effort. Maps to `reasoning.effort` in chat requests. When `\"none\"`, prefer omitting effort unless the user explicitly disables reasoning." - }) + "Maximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "default_enabled": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Default reasoning enabled state when the client does not set `reasoning.enabled`." - }) + "mode": Schema.optionalKey(WebSearchMode), + "search_context_size": Schema.optionalKey(SearchContextSizeEnum), + "type": Schema.Literal("web_search"), + "user_location": Schema.optionalKey(WebSearchUserLocation) +}).annotate({ "description": "Web search tool configuration", "identifier": "Legacy_WebSearchServerTool" }) +export type WebSearchServerTool = { + readonly "engine"?: WebSearchEngineEnum + readonly "filters"?: WebSearchDomainFilter + readonly "max_results"?: number + readonly "max_uses"?: number + readonly "mode"?: WebSearchMode + readonly "search_context_size"?: SearchContextSizeEnum + readonly "type": "web_search_2025_08_26" + readonly "user_location"?: WebSearchUserLocation +} +export const WebSearchServerTool = Schema.Struct({ + "engine": Schema.optionalKey(WebSearchEngineEnum), + "filters": Schema.optionalKey(WebSearchDomainFilter), + "max_results": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "mandatory": Schema.Boolean.annotate({ - "description": "When true, reasoning cannot be disabled and effort \"none\" is rejected." - }), - "supported_efforts": Schema.optionalKey(Union_12), - "supports_max_tokens": Schema.optionalKey( - Schema.Boolean.annotate({ + "max_uses": Schema.optionalKey( + Schema.Number.annotate({ "description": - "Present and `true` when the model accepts `reasoning.max_tokens` in requests (Anthropic-style) instead of or in addition to `reasoning.effort`. Omitted otherwise." - }) - ) + "Maximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "mode": Schema.optionalKey(WebSearchMode), + "search_context_size": Schema.optionalKey(SearchContextSizeEnum), + "type": Schema.Literal("web_search_2025_08_26"), + "user_location": Schema.optionalKey(WebSearchUserLocation) }).annotate({ - "description": "Reasoning effort configuration. Omitted for non-reasoning models and dynamic router models.", - "identifier": "ModelReasoning" -}) -export type ReasoningDetailUnion = - | ReasoningDetailSummary - | ReasoningDetailEncrypted - | ReasoningDetailText - | ReasoningDetailServerToolCall -export const ReasoningDetailUnion = Schema.Union([ - ReasoningDetailSummary, - ReasoningDetailEncrypted, - ReasoningDetailText, - ReasoningDetailServerToolCall -], { mode: "oneOf" }).annotate({ "description": "Reasoning detail union schema", "identifier": "ReasoningDetailUnion" }) -export type BaseReasoningConfig = Objects_5 | null -export const BaseReasoningConfig = Schema.Union([Objects_5, Schema.Null]).annotate({ - "identifier": "BaseReasoningConfig" -}) -export type ReasoningConfig = Union_13 | null -export const ReasoningConfig = Schema.Union([Union_13, Schema.Null]).annotate({ - "description": "Configuration for reasoning mode in the response", - "identifier": "ReasoningConfig" + "description": "Web search tool configuration (2025-08-26 version)", + "identifier": "WebSearchServerTool" }) -export type ChatUsage = { - readonly "completion_tokens": number - readonly "completion_tokens_details"?: Union_ - readonly "cost"?: number | null - readonly "cost_details"?: CostDetails - readonly "is_byok"?: boolean - readonly "prompt_tokens": number - readonly "prompt_tokens_details"?: Union_1 - readonly "server_tool_use_details"?: ServerToolUseDetails - readonly "total_tokens": number -} -export const ChatUsage = Schema.Struct({ - "completion_tokens": Schema.Number.annotate({ "description": "Number of tokens in the completion" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "completion_tokens_details": Schema.optionalKey(Union_), - "cost": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Cost of the completion", "format": "double" }) +export type FileSearchServerTool = { + readonly "filters"?: + | { + readonly "key": string + readonly "type": "eq" | "ne" | "gt" | "gte" | "lt" | "lte" + readonly "value": string | number | boolean | ReadonlyArray + } + | CompoundFilter + | null + readonly "max_num_results"?: number + readonly "ranking_options"?: { + readonly "ranker"?: "auto" | "default-2024-11-15" + readonly "score_threshold"?: number + } + readonly "type": "file_search" + readonly "vector_store_ids": ReadonlyArray +} +export const FileSearchServerTool = Schema.Struct({ + "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.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + Schema.Boolean, + Schema.Array( + Schema.Union([ + Schema.String, + Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ]) + ) + ]) + }), + CompoundFilter, + Schema.Null + ])), + "max_num_results": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "ranking_options": Schema.optionalKey( + Schema.Struct({ + "ranker": Schema.optionalKey(Schema.Literals(["auto", "default-2024-11-15"])), + "score_threshold": Schema.optionalKey( + Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + ) + }) ), - "cost_details": Schema.optionalKey(CostDetails), - "is_byok": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether a request was made using a Bring Your Own Key configuration" }) + "type": Schema.Literal("file_search"), + "vector_store_ids": Schema.Array(Schema.String) +}).annotate({ "description": "File search tool configuration", "identifier": "FileSearchServerTool" }) +export type NamespaceTool = { + readonly "description": string + readonly "name": string + readonly "tools": ReadonlyArray + readonly "type": "namespace" +} +export const NamespaceTool = Schema.Struct({ + "description": Schema.String, + "name": Schema.String, + "tools": Schema.Array(Schema.Union([NamespaceFunctionTool, CustomTool])), + "type": Schema.Literal("namespace") +}).annotate({ "description": "Groups function/custom tools under a shared namespace", "identifier": "NamespaceTool" }) +export type ApplyPatchServerToolConfig = { readonly "engine"?: ApplyPatchEngineEnum } +export const ApplyPatchServerToolConfig = Schema.Struct({ "engine": Schema.optionalKey(ApplyPatchEngineEnum) }) + .annotate({ + "description": "Configuration for the openrouter:apply_patch server tool", + "identifier": "ApplyPatchServerToolConfig" + }) +export type ReasoningConfig = { + readonly "context"?: ReasoningContext + readonly "effort"?: ReasoningEffort + readonly "mode"?: ReasoningMode + readonly "summary"?: ReasoningSummaryVerbosity + readonly "enabled"?: boolean | null + readonly "max_tokens"?: number | null +} | null +export const ReasoningConfig = Schema.Union([ + Schema.Union([Schema.Struct({ + "context": Schema.optionalKey(ReasoningContext), + "effort": Schema.optionalKey(ReasoningEffort), + "mode": Schema.optionalKey(ReasoningMode), + "summary": Schema.optionalKey(ReasoningSummaryVerbosity), + "enabled": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "max_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ) + })]), + Schema.Null +]).annotate({ "description": "Configuration for reasoning mode in the response", "identifier": "ReasoningConfig" }) +export type BaseReasoningConfig = { + readonly "context"?: ReasoningContext + readonly "effort"?: ReasoningEffort + readonly "mode"?: ReasoningMode + readonly "summary"?: ReasoningSummaryVerbosity + readonly [x: string]: Schema.Json +} | null +export const BaseReasoningConfig = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "context": Schema.optionalKey(ReasoningContext), + "effort": Schema.optionalKey(ReasoningEffort), + "mode": Schema.optionalKey(ReasoningMode), + "summary": Schema.optionalKey(ReasoningSummaryVerbosity) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] ), - "prompt_tokens": Schema.Number.annotate({ "description": "Number of tokens in the prompt" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) + Schema.Null +]).annotate({ "identifier": "BaseReasoningConfig" }) +export type Formats = FormatTextConfig | FormatJsonObjectConfig | FormatJsonSchemaConfig +export const Formats = Schema.Union([FormatTextConfig, FormatJsonObjectConfig, FormatJsonSchemaConfig]).annotate({ + "description": "Text response format configuration", + "identifier": "Formats" +}) +export type OpenAIResponsesToolChoice = + | "auto" + | "none" + | "required" + | { readonly "name": string; readonly "type": "function" } + | { readonly "type": "web_search_preview_2025_03_11" | "web_search_preview" } + | ToolChoiceAllowed + | { readonly "type": "apply_patch" } + | { readonly "type": "shell" } +export const OpenAIResponsesToolChoice = Schema.Union([ + Schema.Literal("auto"), + Schema.Literal("none"), + Schema.Literal("required"), + Schema.Struct({ "name": Schema.String, "type": Schema.Literal("function") }), + Schema.Struct({ "type": Schema.Literals(["web_search_preview_2025_03_11", "web_search_preview"]) }), + ToolChoiceAllowed, + Schema.Struct({ "type": Schema.Literal("apply_patch") }), + Schema.Struct({ "type": Schema.Literal("shell") }) +]).annotate({ "identifier": "OpenAIResponsesToolChoice" }) +export type OutputShellCallItem = { + readonly "action"?: { + readonly "commands": ReadonlyArray + readonly "max_output_length": number | null + readonly "timeout_ms": number | null + } + readonly "call_id": string + readonly "id": string + readonly "status": ShellCallStatus + readonly "type": "shell_call" +} +export const OutputShellCallItem = Schema.Struct({ + "action": Schema.optionalKey(Schema.Struct({ + "commands": Schema.Array(Schema.String), + "max_output_length": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]), + "timeout_ms": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]) + })), + "call_id": Schema.String, + "id": Schema.String, + "status": ShellCallStatus, + "type": Schema.Literal("shell_call") +}).annotate({ + "description": + "A native `shell_call` output item matching OpenAI's Responses API shape. Emitted for the sandbox-backed `shell` tool.", + "identifier": "OutputShellCallItem" +}) +export type OutputShellCallOutputItem = { + readonly "call_id": string + readonly "id": string + readonly "max_output_length"?: number | null + readonly "output": ReadonlyArray< + { + readonly "outcome": { readonly "exit_code": number; readonly "type": "exit" } | { readonly "type": "timeout" } + readonly "stderr": string + readonly "stdout": string + } + > + readonly "status": ShellCallStatus + readonly "type": "shell_call_output" +} +export const OutputShellCallOutputItem = Schema.Struct({ + "call_id": Schema.String, + "id": Schema.String, + "max_output_length": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) ), - "prompt_tokens_details": Schema.optionalKey(Union_1), - "server_tool_use_details": Schema.optionalKey(ServerToolUseDetails), - "total_tokens": Schema.Number.annotate({ "description": "Total number of tokens" }).check( + "output": Schema.Array(Schema.Struct({ + "outcome": Schema.Union([ + Schema.Struct({ + "exit_code": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("exit") + }), + Schema.Struct({ "type": Schema.Literal("timeout") }) + ], { mode: "oneOf" }), + "stderr": Schema.String, + "stdout": Schema.String + })), + "status": ShellCallStatus, + "type": Schema.Literal("shell_call_output") +}).annotate({ + "description": + "A native `shell_call_output` item matching OpenAI's Responses API shape. Carries per-command stdout, stderr, and the exit/timeout outcome.", + "identifier": "OutputShellCallOutputItem" +}) +export type ListScimGroupMappingsResponse = { + readonly "data": ReadonlyArray + readonly "total_count": number +} +export const ListScimGroupMappingsResponse = Schema.Struct({ + "data": Schema.Array(ScimGroupMapping), + "total_count": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "ListScimGroupMappingsResponse" }) +export type CreateScimGroupMappingResponse = { readonly "data": ScimGroupMapping } +export const CreateScimGroupMappingResponse = Schema.Struct({ "data": ScimGroupMapping }).annotate({ + "identifier": "CreateScimGroupMappingResponse" +}) +export type GetScimGroupMappingResponse = { readonly "data": ScimGroupMapping } +export const GetScimGroupMappingResponse = Schema.Struct({ "data": ScimGroupMapping }).annotate({ + "identifier": "GetScimGroupMappingResponse" +}) +export type UpdateScimGroupMappingResponse = { readonly "data": ScimGroupMapping } +export const UpdateScimGroupMappingResponse = Schema.Struct({ "data": ScimGroupMapping }).annotate({ + "identifier": "UpdateScimGroupMappingResponse" +}) +export type ListScimGroupsResponse = { readonly "data": ReadonlyArray; readonly "total_count": number } +export const ListScimGroupsResponse = Schema.Struct({ + "data": Schema.Array(ScimGroup), + "total_count": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "ListScimGroupsResponse" }) +export type InputReference = ContentPartImage | ContentPartAudio | ContentPartVideo +export const InputReference = Schema.Union([ContentPartImage, ContentPartAudio, ContentPartVideo], { mode: "oneOf" }) + .annotate({ + "description": + "A reference asset used to guide video generation. Image references are supported by all providers; audio and video references are only honored by providers that support them (including BytePlus Seedance generation 2 and newer).", + "identifier": "InputReference" + }) +export type VideoGenerationResponse = { + readonly "error"?: string + readonly "generation_id"?: string + readonly "id": string + readonly "polling_url": string + readonly "status": "pending" | "in_progress" | "completed" | "failed" | "cancelled" | "expired" + readonly "unsigned_urls"?: ReadonlyArray + readonly "usage"?: VideoGenerationUsage +} +export const VideoGenerationResponse = Schema.Struct({ + "error": Schema.optionalKey(Schema.String), + "generation_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The generation ID associated with this video generation job. Available once the job has been processed." + }) + ), + "id": Schema.String, + "polling_url": Schema.String, + "status": Schema.Literals(["pending", "in_progress", "completed", "failed", "cancelled", "expired"]), + "unsigned_urls": Schema.optionalKey(Schema.Array(Schema.String)), + "usage": Schema.optionalKey(VideoGenerationUsage) +}).annotate({ "identifier": "VideoGenerationResponse" }) +export type VideoModelsListResponse = { readonly "data": ReadonlyArray } +export const VideoModelsListResponse = Schema.Struct({ "data": Schema.Array(VideoModel) }).annotate({ + "identifier": "VideoModelsListResponse" +}) +export type ListWorkspacesResponse = { readonly "data": ReadonlyArray; readonly "total_count": number } +export const ListWorkspacesResponse = Schema.Struct({ + "data": Schema.Array(Workspace).annotate({ "description": "List of workspaces" }), + "total_count": Schema.Number.annotate({ "description": "Total number of workspaces" }).check( Schema.isInt().annotate({ "expected": "an integer" }) ) -}).annotate({ "description": "Token usage statistics", "identifier": "ChatUsage" }) -export type Usage = { - readonly "input_tokens": number - readonly "input_tokens_details": { readonly "cache_write_tokens"?: number | null; readonly "cached_tokens": number } - readonly "output_tokens": number - readonly "output_tokens_details": { readonly "reasoning_tokens": number } - readonly "total_tokens": number - readonly "cost"?: number | null - readonly "cost_details"?: { - readonly "upstream_inference_cost"?: number | null - readonly "upstream_inference_input_cost": number - readonly "upstream_inference_output_cost": number - } - readonly "is_byok"?: boolean - readonly "server_tool_use_details"?: ServerToolUseDetails -} | null -export const Usage = Schema.Union([ - Schema.Struct({ - "input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "input_tokens_details": Schema.Struct({ - "cache_write_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "cached_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - "output_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "output_tokens_details": Schema.Struct({ - "reasoning_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - "total_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "cost": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Cost of the completion", "format": "double" }) - ), - "cost_details": Schema.optionalKey(Schema.Struct({ - "upstream_inference_cost": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "upstream_inference_input_cost": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "upstream_inference_output_cost": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - })), - "is_byok": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether a request was made using a Bring Your Own Key configuration" }) - ), - "server_tool_use_details": Schema.optionalKey(ServerToolUseDetails) +}).annotate({ "identifier": "ListWorkspacesResponse" }) +export type CreateWorkspaceResponse = { readonly "data": Workspace } +export const CreateWorkspaceResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => Workspace).annotate({ "description": "The created workspace" }) +}).annotate({ "identifier": "CreateWorkspaceResponse" }) +export type GetWorkspaceResponse = { readonly "data": Workspace } +export const GetWorkspaceResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => Workspace).annotate({ "description": "The workspace" }) +}).annotate({ "identifier": "GetWorkspaceResponse" }) +export type UpdateWorkspaceResponse = { readonly "data": Workspace } +export const UpdateWorkspaceResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => Workspace).annotate({ "description": "The updated workspace" }) +}).annotate({ "identifier": "UpdateWorkspaceResponse" }) +export type ListWorkspaceBudgetsResponse = { + readonly "data": ReadonlyArray + readonly "include_byok_in_budgets"?: boolean +} +export const ListWorkspaceBudgetsResponse = Schema.Struct({ + "data": Schema.Array(WorkspaceBudget).annotate({ "description": "List of budgets configured for the workspace" }), + "include_byok_in_budgets": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether BYOK (bring-your-own-key) spend is included when enforcing the workspace's budgets. This is a workspace-wide setting that applies to all budget intervals (daily, weekly, monthly, and lifetime)." + }) + ) +}).annotate({ "identifier": "ListWorkspaceBudgetsResponse" }) +export type GetWorkspaceBudgetResponse = { + readonly "data": WorkspaceBudget + readonly "include_byok_in_budgets"?: boolean +} +export const GetWorkspaceBudgetResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => WorkspaceBudget).annotate({ + "description": "The budget for the requested interval" }), - Schema.Null -]).annotate({ "description": "Token usage information for the response", "identifier": "Usage" }) -export type StopServerToolsWhen = ReadonlyArray -export const StopServerToolsWhen = Schema.Array(StopServerToolsWhenCondition).annotate({ - "description": - "Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call." -}).check( - Schema.isMinLength(1).annotate({ - "expected": "a value with a length of at least 1", - "identifier": "StopServerToolsWhen" + "include_byok_in_budgets": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether BYOK (bring-your-own-key) spend is included when enforcing the workspace's budgets. This is a workspace-wide setting that applies to all budget intervals (daily, weekly, monthly, and lifetime)." + }) + ) +}).annotate({ "identifier": "GetWorkspaceBudgetResponse" }) +export type UpsertWorkspaceBudgetResponse = { + readonly "data": WorkspaceBudget + readonly "include_byok_in_budgets"?: boolean +} +export const UpsertWorkspaceBudgetResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => WorkspaceBudget).annotate({ + "description": "The created or updated budget" + }), + "include_byok_in_budgets": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether BYOK (bring-your-own-key) spend is included when enforcing the workspace's budgets. This is a workspace-wide setting that applies to all budget intervals (daily, weekly, monthly, and lifetime)." + }) + ) +}).annotate({ "identifier": "UpsertWorkspaceBudgetResponse" }) +export type ListWorkspaceMembersResponse = { + readonly "data": ReadonlyArray + readonly "total_count": number +} +export const ListWorkspaceMembersResponse = Schema.Struct({ + "data": Schema.Array(WorkspaceMember).annotate({ "description": "List of workspace members" }), + "total_count": Schema.Number.annotate({ "description": "Total number of members in the workspace" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "ListWorkspaceMembersResponse" }) +export type BulkAddWorkspaceMembersResponse = { + readonly "added_count": number + readonly "data": ReadonlyArray +} +export const BulkAddWorkspaceMembersResponse = Schema.Struct({ + "added_count": Schema.Number.annotate({ "description": "Number of workspace memberships created or updated" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "data": Schema.Array(WorkspaceMember).annotate({ "description": "List of added workspace memberships" }) +}).annotate({ "identifier": "BulkAddWorkspaceMembersResponse" }) +export type SpeechInputReference = SpeechInputReferenceAudio | SpeechInputReferenceText +export const SpeechInputReference = Schema.Union([SpeechInputReferenceAudio, SpeechInputReferenceText], { + mode: "oneOf" +}).annotate({ + "description": "Reference content part for stateless voice cloning", + "identifier": "SpeechInputReference" +}) +export type UnifiedBenchmarksResponse = { + readonly "data": ReadonlyArray + readonly "meta": UnifiedBenchmarksMeta +} +export const UnifiedBenchmarksResponse = Schema.Struct({ + "data": Schema.Array( + Schema.Union([UnifiedBenchmarksAAItem, UnifiedBenchmarksDAItem, UnifiedBenchmarksORItem], { mode: "oneOf" }) + ), + "meta": UnifiedBenchmarksMeta +}).annotate({ "identifier": "UnifiedBenchmarksResponse" }) +export type ListBYOKKeysResponse = { readonly "data": ReadonlyArray; readonly "total_count": number } +export const ListBYOKKeysResponse = Schema.Struct({ + "data": Schema.Array(BYOKKey).annotate({ "description": "List of BYOK credentials." }), + "total_count": Schema.Number.annotate({ "description": "Total number of BYOK credentials matching the filters." }) + .check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "identifier": "ListBYOKKeysResponse" }) +export type CreateBYOKKeyResponse = { readonly "data": BYOKKey } +export const CreateBYOKKeyResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => BYOKKey).annotate({ + "description": "The created BYOK credential." }) -) -export type SubagentServerToolConfig = { - readonly "instructions"?: string +}).annotate({ "identifier": "CreateBYOKKeyResponse" }) +export type GetBYOKKeyResponse = { readonly "data": BYOKKey } +export const GetBYOKKeyResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => BYOKKey).annotate({ "description": "The BYOK credential." }) +}).annotate({ "identifier": "GetBYOKKeyResponse" }) +export type UpdateBYOKKeyResponse = { readonly "data": BYOKKey } +export const UpdateBYOKKeyResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => BYOKKey).annotate({ + "description": "The updated BYOK credential." + }) +}).annotate({ "identifier": "UpdateBYOKKeyResponse" }) +export type FusionServerToolConfig = { + readonly "analysis_models"?: ReadonlyArray + readonly "cache_control"?: AnthropicCacheControlDirective readonly "max_completion_tokens"?: number readonly "max_tool_calls"?: number readonly "model"?: string - readonly "name"?: string - readonly "reasoning"?: SubagentReasoning + readonly "reasoning"?: { + readonly "effort"?: "max" | "xhigh" | "high" | "medium" | "low" | "minimal" | "none" + readonly "max_tokens"?: number + } readonly "temperature"?: number - readonly "tools"?: Arrays_12 + readonly "tools"?: ReadonlyArray<{ readonly "parameters"?: {}; readonly "type": string }> } -export const SubagentServerToolConfig = Schema.Struct({ - "instructions": Schema.optionalKey( - Schema.String.annotate({ +export const FusionServerToolConfig = Schema.Struct({ + "analysis_models": Schema.optionalKey( + Schema.Array(Schema.String).annotate({ "description": - "System instructions for the subagent. When omitted, the subagent responds with no system prompt of its own." - }) + "Slugs of models to run in parallel as the analysis panel. Each model receives the user prompt with openrouter:web_search and openrouter:web_fetch enabled, then an analyst model summarizes the collective output into structured analysis JSON. Capped at 8 models to bound cost amplification. Defaults to the Quality preset from /labs/fusion." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( + Schema.isMaxLength(8).annotate({ "expected": "a value with a length of at most 8" }) + ) ), + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), "max_completion_tokens": Schema.optionalKey( Schema.Number.annotate({ "description": - "Maximum number of output tokens (including reasoning) the subagent may produce. When omitted, the provider's default applies." + "Maximum number of output tokens (including reasoning tokens) each panelist and the analyst model may produce per inner call. Controls the total output budget so reasoning-heavy models like GPT-5.5 do not exhaust their token allowance before producing visible text. Defaults to 16000 when omitted." }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), "max_tool_calls": Schema.optionalKey( Schema.Number.annotate({ "description": - "Maximum number of tool-calling steps the subagent may take during its agentic loop. Capped at 25. Only relevant when the subagent is given tools. Accepted and validated but not yet enforced on the subagent call." + "Maximum number of tool-calling steps each panelist (analysis model) and the analyst model may take during their agentic web-research loop. Models with web_search/web_fetch enabled iterate until they produce a text response or hit this ceiling. Defaults to 4. Capped at 16." }).check(Schema.isInt().annotate({ "expected": "an integer" })).check( Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" }) - ).check(Schema.isLessThanOrEqualTo(25).annotate({ "expected": "a value less than or equal to 25" })) + ).check(Schema.isLessThanOrEqualTo(16).annotate({ "expected": "a value less than or equal to 16" })) ), "model": Schema.optionalKey( Schema.String.annotate({ "description": - "Slug of the model that executes delegated tasks (any OpenRouter model). Typically a smaller, cheaper, faster model than the one delegating. When omitted, the model from the outer API request is used. The subagent tool itself cannot be the subagent model." + "Slug of the analyst model that produces the structured analysis JSON. Defaults to the model used in the outer API request." }) ), - "name": Schema.optionalKey( - Schema.String.annotate({ + "reasoning": Schema.optionalKey( + Schema.Struct({ + "effort": Schema.optionalKey( + Schema.Literals(["max", "xhigh", "high", "medium", "low", "minimal", "none"]).annotate({ + "description": "Reasoning effort level for panelist and analyst inner calls." + }) + ), + "max_tokens": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of reasoning tokens each panelist and analyst model may use. Helps bound cost when models allocate too much budget to chain-of-thought." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ) + }).annotate({ "description": - "Optional name for this subagent. The model sees one tool per named subagent (and one default for an unnamed entry). Names must be unique across subagent entries. Letters, digits, spaces, underscores, and dashes; trimmed; 1–64 chars." - }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })).check( - Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" }) - ).check( - Schema.isPattern(new RegExp("^[a-zA-Z0-9 _-]+$")).annotate({ - "expected": "a string matching the RegExp ^[a-zA-Z0-9 _-]+$" - }) - ) + "Reasoning configuration forwarded to panelist and analyst inner calls. Use this to control reasoning effort and token budget for models that support extended thinking." + }) ), - "reasoning": Schema.optionalKey(SubagentReasoning), "temperature": Schema.optionalKey( Schema.Number.annotate({ "description": - "Sampling temperature forwarded to the subagent call. When omitted, the provider's default applies.", + "Temperature forwarded to panelist inner calls. The analyst always runs at temperature 0 regardless of this value. When omitted, the provider's default applies.", "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) ), - "tools": Schema.optionalKey(Arrays_12) + "tools": Schema.optionalKey( + Schema.Array(Schema.Struct({ + "parameters": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": "Optional configuration forwarded as the tool's `parameters` object." + }) + ), + "type": Schema.String.annotate({ + "description": "Server tool type identifier (e.g. \"openrouter:web_search\", \"openrouter:web_fetch\")." + }) + })).annotate({ + "description": + "Server tools available to panelist and analyst inner calls. Each entry uses the same `{ type, parameters? }` shorthand as the outer Chat Completions request. When omitted, defaults to `[{ type: \"openrouter:web_search\" }, { type: \"openrouter:web_fetch\" }]`. Pass an empty array to disable tools entirely (panelists answer from parametric knowledge only)." + }).check(Schema.isMaxLength(8).annotate({ "expected": "a value with a length of at most 8" })) + ) }).annotate({ - "description": "Configuration for one openrouter:subagent server tool entry.", - "identifier": "SubagentServerToolConfig" + "description": "Configuration for the openrouter:fusion server tool.", + "identifier": "FusionServerToolConfig" }) -export type ImageModelEndpointsResponse = { readonly "endpoints": ReadonlyArray; readonly "id": string } -export const ImageModelEndpointsResponse = Schema.Struct({ - "endpoints": Schema.Array(ImageEndpoint), - "id": Schema.String.annotate({ "description": "Model slug" }) +export type AnthropicTextBlockParam = { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "citations"?: + | ReadonlyArray< + | AnthropicCitationCharLocationParam + | AnthropicCitationPageLocationParam + | AnthropicCitationContentBlockLocationParam + | AnthropicCitationWebSearchResultLocationParam + | AnthropicCitationSearchResultLocationParam + > + | null + readonly "text": string + readonly "type": "text" +} +export const AnthropicTextBlockParam = Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "citations": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Union([ + AnthropicCitationCharLocationParam, + AnthropicCitationPageLocationParam, + AnthropicCitationContentBlockLocationParam, + AnthropicCitationWebSearchResultLocationParam, + AnthropicCitationSearchResultLocationParam + ], { mode: "oneOf" }) + ), + Schema.Null + ]) + ), + "text": Schema.String, + "type": Schema.Literal("text") +}).annotate({ "identifier": "AnthropicTextBlockParam" }) +export type MessagesToolAdditionBlock = { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "tool": { readonly "name": string; readonly "type": "tool_reference" } | { + readonly "name": string + readonly "server_name": string + readonly "type": "mcp_tool_reference" + } | { readonly "server_name": string; readonly "type": "mcp_toolset_reference" } + readonly "type": "tool_addition" +} +export const MessagesToolAdditionBlock = Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "tool": Schema.Union([ + Schema.Struct({ "name": Schema.String, "type": Schema.Literal("tool_reference") }), + Schema.Struct({ + "name": Schema.String, + "server_name": Schema.String, + "type": Schema.Literal("mcp_tool_reference") + }), + Schema.Struct({ "server_name": Schema.String, "type": Schema.Literal("mcp_toolset_reference") }) + ], { mode: "oneOf" }), + "type": Schema.Literal("tool_addition") }).annotate({ - "description": "The full per-endpoint records for an image model.", - "identifier": "ImageModelEndpointsResponse" + "description": + "Loads a previously deferred tool (declared in `tools` with `defer_loading: true`) mid-conversation without invalidating the prompt cache. Only valid in `role: \"system\"` messages. Not supported on Claude Sonnet 5 or models older than Claude Opus 4.8.", + "identifier": "MessagesToolAdditionBlock" }) -export type TaskClassificationResponse = { - readonly "data": { - readonly "as_of": string - readonly "classifications": ReadonlyArray - readonly "macro_categories": ReadonlyArray - readonly "window_days": number - } +export type MessagesToolRemovalBlock = { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "tool": { readonly "name": string; readonly "type": "tool_reference" } | { + readonly "name": string + readonly "server_name": string + readonly "type": "mcp_tool_reference" + } | { readonly "server_name": string; readonly "type": "mcp_toolset_reference" } + readonly "type": "tool_removal" } -export const TaskClassificationResponse = Schema.Struct({ - "data": Schema.Struct({ - "as_of": Schema.String.annotate({ - "description": - "UTC date (YYYY-MM-DD) of the window upper bound (yesterday). Data is exclusive of the current incomplete UTC day. This is the expected latest date in the snapshot; it does not confirm data presence for that date." - }), - "classifications": Schema.Array(TaskClassificationItem).annotate({ - "description": "Per-task classification market-share data, sorted by usage_share descending." - }), - "macro_categories": Schema.Array(TaskClassificationMacroCategory).annotate({ - "description": "Aggregate market-share data per macro-category (code, data, agent, general)." +export const MessagesToolRemovalBlock = Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "tool": Schema.Union([ + Schema.Struct({ "name": Schema.String, "type": Schema.Literal("tool_reference") }), + Schema.Struct({ + "name": Schema.String, + "server_name": Schema.String, + "type": Schema.Literal("mcp_tool_reference") }), - "window_days": Schema.Number.annotate({ "description": "Number of trailing days covered by this snapshot." }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) - }) -}).annotate({ "identifier": "TaskClassificationResponse" }) -export type UnifiedBenchmarksResponse = { - readonly "data": ReadonlyArray - readonly "meta": UnifiedBenchmarksMeta + Schema.Struct({ "server_name": Schema.String, "type": Schema.Literal("mcp_toolset_reference") }) + ], { mode: "oneOf" }), + "type": Schema.Literal("tool_removal") +}).annotate({ + "description": + "Removes a tool from the conversation mid-conversation without invalidating the prompt cache. Only valid in `role: \"system\"` messages. Not supported on Claude Sonnet 5 or models older than Claude Opus 4.8.", + "identifier": "MessagesToolRemovalBlock" +}) +export type AnthropicToolSearchToolBm25 = { + readonly "allowed_callers"?: AnthropicAllowedCallers + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "defer_loading"?: boolean + readonly "name": "tool_search_tool_bm25" + readonly "strict"?: boolean + readonly "type": "tool_search_tool_bm25_20251119" | "tool_search_tool_bm25" } -export const UnifiedBenchmarksResponse = Schema.Struct({ - "data": Schema.Array(Schema.Union([UnifiedBenchmarksAAItem, UnifiedBenchmarksDAItem], { mode: "oneOf" })), - "meta": UnifiedBenchmarksMeta -}).annotate({ "identifier": "UnifiedBenchmarksResponse" }) -export type AnnotationAddedEvent = { - readonly "annotation": OpenAIResponsesAnnotation - readonly "annotation_index": number - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.output_text.annotation.added" +export const AnthropicToolSearchToolBm25 = Schema.Struct({ + "allowed_callers": Schema.optionalKey(AnthropicAllowedCallers), + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "defer_loading": Schema.optionalKey(Schema.Boolean), + "name": Schema.Literal("tool_search_tool_bm25"), + "strict": Schema.optionalKey(Schema.Boolean), + "type": Schema.Literals(["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]) +}).annotate({ "identifier": "AnthropicToolSearchToolBm25" }) +export type AnthropicToolSearchToolRegex = { + readonly "allowed_callers"?: AnthropicAllowedCallers + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "defer_loading"?: boolean + readonly "name": "tool_search_tool_regex" + readonly "strict"?: boolean + readonly "type": "tool_search_tool_regex_20251119" | "tool_search_tool_regex" } -export const AnnotationAddedEvent = Schema.Struct({ - "annotation": OpenAIResponsesAnnotation, - "annotation_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.output_text.annotation.added") -}).annotate({ - "description": "Event emitted when a text annotation is added to output", - "identifier": "AnnotationAddedEvent" -}) -export type BaseAnnotationAddedEvent = { - readonly "annotation": OpenAIResponsesAnnotation - readonly "annotation_index": number - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.output_text.annotation.added" +export const AnthropicToolSearchToolRegex = Schema.Struct({ + "allowed_callers": Schema.optionalKey(AnthropicAllowedCallers), + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "defer_loading": Schema.optionalKey(Schema.Boolean), + "name": Schema.Literal("tool_search_tool_regex"), + "strict": Schema.optionalKey(Schema.Boolean), + "type": Schema.Literals(["tool_search_tool_regex_20251119", "tool_search_tool_regex"]) +}).annotate({ "identifier": "AnthropicToolSearchToolRegex" }) +export type ChatContentText = { + readonly "cache_control"?: ChatContentCacheControl + readonly "prompt_cache_breakpoint"?: PromptCacheBreakpoint + readonly "text": string + readonly "type": "text" } -export const BaseAnnotationAddedEvent = Schema.Struct({ - "annotation": OpenAIResponsesAnnotation, - "annotation_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.output_text.annotation.added") +export const ChatContentText = Schema.Struct({ + "cache_control": Schema.optionalKey(ChatContentCacheControl), + "prompt_cache_breakpoint": Schema.optionalKey(PromptCacheBreakpoint), + "text": Schema.String, + "type": Schema.Literal("text") +}).annotate({ "description": "Text content part", "identifier": "ChatContentText" }) +export type EasyInputMessage = { + readonly "content"?: + | ReadonlyArray< + | InputText + | { + readonly "detail": "auto" | "high" | "low" | "original" + readonly "image_url"?: string | null + readonly "type": "input_image" + } + | InputFile + | InputAudio + | InputVideo + > + | string + | null + readonly "phase"?: "commentary" | "final_answer" | null + readonly "role": "user" | "system" | "assistant" | "developer" + readonly "type"?: "message" +} +export const EasyInputMessage = Schema.Struct({ + "content": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Union([ + InputText, + Schema.Struct({ + "detail": Schema.Literals(["auto", "high", "low", "original"]), + "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("input_image") + }).annotate({ "description": "Image input content item" }), + InputFile, + InputAudio, + InputVideo + ], { mode: "oneOf" }) + ), + Schema.String, + Schema.Null + ]) + ), + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Null]).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." + }) + ), + "role": Schema.Literals(["user", "system", "assistant", "developer"]), + "type": Schema.optionalKey(Schema.Literal("message")) +}).annotate({ "identifier": "EasyInputMessage" }) +export type InputMessageItem = { + readonly "content"?: + | ReadonlyArray< + | InputText + | { + readonly "detail": "auto" | "high" | "low" | "original" + readonly "image_url"?: string | null + readonly "type": "input_image" + } + | InputFile + | InputAudio + | InputVideo + > + | null + readonly "id"?: string + readonly "role": "user" | "system" | "developer" + readonly "type"?: "message" +} +export const InputMessageItem = Schema.Struct({ + "content": Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Union([ + InputText, + Schema.Struct({ + "detail": Schema.Literals(["auto", "high", "low", "original"]), + "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("input_image") + }).annotate({ "description": "Image input content item" }), + InputFile, + InputAudio, + InputVideo + ], { mode: "oneOf" }) + ), + Schema.Null + ]) + ), + "id": Schema.optionalKey(Schema.String), + "role": Schema.Literals(["user", "system", "developer"]), + "type": Schema.optionalKey(Schema.Literal("message")) +}).annotate({ "identifier": "InputMessageItem" }) +export type AgentMessageItem = { + readonly "agent"?: { readonly "agent_name": string; readonly [x: string]: Schema.Json } | null + readonly "author": string + readonly "content": ReadonlyArray< + InputText | { + readonly "detail": "auto" | "high" | "low" | "original" + readonly "image_url"?: string | null + readonly "type": "input_image" + } | { readonly "encrypted_content": string; readonly "type": "encrypted_content" } + > + readonly "id"?: string | null + readonly "recipient": string + readonly "type": "agent_message" +} +export const AgentMessageItem = Schema.Struct({ + "agent": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest(Schema.Struct({ "agent_name": Schema.String }), [ + Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) + ]), + Schema.Null + ]) + ), + "author": Schema.String, + "content": Schema.Array( + Schema.Union([ + InputText, + Schema.Struct({ + "detail": Schema.Literals(["auto", "high", "low", "original"]), + "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("input_image") + }).annotate({ "description": "Image input content item" }), + Schema.Struct({ "encrypted_content": Schema.String, "type": Schema.Literal("encrypted_content") }) + ], { mode: "oneOf" }) + ), + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "recipient": Schema.String, + "type": Schema.Literal("agent_message") }).annotate({ - "description": "Event emitted when a text annotation is added to output", - "identifier": "BaseAnnotationAddedEvent" + "description": "A message routed between agents in a multi-agent session", + "identifier": "AgentMessageItem" }) -export type ResponseOutputText = { - readonly "annotations"?: ReadonlyArray - readonly "logprobs"?: ReadonlyArray< - { - readonly "bytes": ReadonlyArray - readonly "logprob": number - readonly "token": string - readonly "top_logprobs": ReadonlyArray< - { readonly "bytes": ReadonlyArray; readonly "logprob": number; readonly "token": string } - > - } - > - readonly "text": string - readonly "type": "output_text" +export type StoredPromptTemplate = { + readonly "id": string + readonly "variables"?: { readonly [x: string]: string | InputText | InputImage | InputFile } | null + readonly [x: string]: Schema.Json +} | null +export const StoredPromptTemplate = Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "id": Schema.String, + "variables": Schema.optionalKey( + Schema.Union([ + Schema.Record(Schema.String, Schema.Union([Schema.String, InputText, InputImage, InputFile])), + Schema.Null + ]) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null +]).annotate({ "identifier": "StoredPromptTemplate" }) +export type OpenAIResponseInputMessageItem = { + readonly "content": ReadonlyArray + readonly "id": string + readonly "role": "user" | "system" | "developer" + readonly "type"?: "message" } -export const ResponseOutputText = Schema.Struct({ - "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), - "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ - "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) +export const OpenAIResponseInputMessageItem = Schema.Struct({ + "content": Schema.Array(Schema.Union([InputText, InputImage, InputFile, InputAudio], { mode: "oneOf" })), + "id": Schema.String, + "role": Schema.Literals(["user", "system", "developer"]), + "type": Schema.optionalKey(Schema.Literal("message")) +}).annotate({ "identifier": "OpenAIResponseInputMessageItem" }) +export type OpenAIResponseFunctionToolCallOutput = { + readonly "call_id": string + readonly "id"?: string | null + readonly "output": string | ReadonlyArray + readonly "status"?: ToolCallStatus | null + readonly "type": "function_call_output" +} +export const OpenAIResponseFunctionToolCallOutput = Schema.Struct({ + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "output": Schema.Union([ + Schema.String, + Schema.Array(Schema.Union([InputText, InputImage, InputFile], { mode: "oneOf" })) + ]), + "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), + "type": Schema.Literal("function_call_output") +}).annotate({ "identifier": "OpenAIResponseFunctionToolCallOutput" }) +export type OpenAIResponseCustomToolCallOutput = { + readonly "call_id": string + readonly "id"?: string + readonly "output": string | ReadonlyArray + readonly "type": "custom_tool_call_output" +} +export const OpenAIResponseCustomToolCallOutput = Schema.Struct({ + "call_id": Schema.String, + "id": Schema.optionalKey(Schema.String), + "output": Schema.Union([ + Schema.String, + Schema.Array(Schema.Union([InputText, InputImage, InputFile], { mode: "oneOf" })) + ]), + "type": Schema.Literal("custom_tool_call_output") +}).annotate({ "identifier": "OpenAIResponseCustomToolCallOutput" }) +export type ReasoningDetailUnion = + | ReasoningDetailSummary + | ReasoningDetailEncrypted + | ReasoningDetailText + | ReasoningDetailServerToolCall +export const ReasoningDetailUnion = Schema.Union([ + ReasoningDetailSummary, + ReasoningDetailEncrypted, + ReasoningDetailText, + ReasoningDetailServerToolCall +], { mode: "oneOf" }).annotate({ "description": "Reasoning detail union schema", "identifier": "ReasoningDetailUnion" }) +export type FileParserPlugin = { + readonly "enabled"?: boolean + readonly "id": "file-parser" + readonly "pdf"?: PDFParserOptions +} +export const FileParserPlugin = Schema.Struct({ + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Set to false to disable the file-parser plugin for this request. Defaults to true." + }) + ), + "id": Schema.Literal("file-parser"), + "pdf": Schema.optionalKey(PDFParserOptions) +}).annotate({ "identifier": "FileParserPlugin" }) +export type ProviderPreferences = { + readonly "allow_fallbacks"?: boolean | null + readonly "data_collection"?: "deny" | "allow" | null + readonly "enforce_distillable_text"?: boolean | null + readonly "ignore"?: ReadonlyArray | null + readonly "max_price"?: { + readonly "audio"?: string + readonly "completion"?: string + readonly "image"?: string + readonly "prompt"?: string + readonly "request"?: string + } + readonly "only"?: ReadonlyArray | null + readonly "order"?: ReadonlyArray | null + readonly "preferred_max_latency"?: PreferredMaxLatency + readonly "preferred_min_throughput"?: PreferredMinThroughput + readonly "quantizations"?: ReadonlyArray | null + readonly "require_parameters"?: boolean | null + readonly "sort"?: ProviderSort | ProviderSortConfig | null + readonly "zdr"?: boolean | null +} | null +export const ProviderPreferences = 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" + }) ), - "token": Schema.String, - "top_logprobs": Schema.Array( + "data_collection": Schema.optionalKey( + Schema.Union([Schema.Literal("deny"), Schema.Literal("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." + }) + ), + "enforce_distillable_text": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).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." + }) + ), + "ignore": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." + }) + ), + "max_price": Schema.optionalKey( Schema.Struct({ - "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) + "audio": Schema.optionalKey(Schema.String.annotate({ "description": "Maximum price in USD per audio unit" })), + "completion": Schema.optionalKey( + Schema.String.annotate({ "description": "Maximum price in USD per million completion tokens" }) ), - "token": Schema.String + "image": Schema.optionalKey(Schema.String.annotate({ "description": "Maximum price in USD per image" })), + "prompt": Schema.optionalKey( + Schema.String.annotate({ "description": "Maximum price in USD per million prompt tokens" }) + ), + "request": Schema.optionalKey(Schema.String.annotate({ "description": "Maximum price in USD 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." + }) + ), + "only": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." + }) + ), + "order": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.Union([ProviderName, Schema.String])), 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." + }) + ), + "preferred_max_latency": Schema.optionalKey(PreferredMaxLatency), + "preferred_min_throughput": Schema.optionalKey(PreferredMinThroughput), + "quantizations": Schema.optionalKey( + Schema.Union([Schema.Array(Quantization), Schema.Null]).annotate({ + "description": "A list of quantization levels to filter the provider by." + }) + ), + "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." + }) + ), + "sort": Schema.optionalKey( + Schema.Union([ProviderSort, ProviderSortConfig, Schema.Null]).annotate({ + "description": + "The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed." + }) + ), + "zdr": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).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." }) ) - }))), - "text": Schema.String, - "type": Schema.Literal("output_text") -}).annotate({ "identifier": "ResponseOutputText" }) -export type WebFetchServerTool = { - readonly "parameters"?: WebFetchServerToolConfig - readonly "type": "openrouter:web_fetch" -} -export const WebFetchServerTool = Schema.Struct({ - "parameters": Schema.optionalKey(WebFetchServerToolConfig), - "type": Schema.Literal("openrouter:web_fetch") -}).annotate({ - "description": "OpenRouter built-in server tool: fetches full content from a URL (web page or PDF)", - "identifier": "WebFetchServerTool" + }), + Schema.Null +]).annotate({ + "description": "When multiple model providers are available, optionally indicate your routing preference.", + "identifier": "ProviderPreferences" }) -export type Preview_20250311_WebSearchServerTool = { - readonly "engine"?: WebSearchEngineEnum - readonly "filters"?: WebSearchDomainFilter - readonly "max_results"?: number - readonly "search_context_size"?: SearchContextSizeEnum - readonly "type": "web_search_preview_2025_03_11" - readonly "user_location"?: Preview_WebSearchUserLocation +export type ImageGenerationRequest = { + readonly "aspect_ratio"?: + | "1:1" + | "1:2" + | "1:4" + | "1:8" + | "2:1" + | "2:3" + | "3:2" + | "3:4" + | "4:1" + | "4:3" + | "4:5" + | "5:4" + | "8:1" + | "9:16" + | "16:9" + | "9:19.5" + | "19.5:9" + | "9:20" + | "20:9" + | "9:21" + | "21:9" + | "auto" + readonly "background"?: "auto" | "transparent" | "opaque" + readonly "input_references"?: ReadonlyArray + readonly "model": string + readonly "n"?: number + readonly "output_compression"?: number + readonly "output_format"?: "png" | "jpeg" | "webp" | "svg" + readonly "prompt": string + readonly "provider"?: ImageGenerationProviderPreferences + readonly "quality"?: "auto" | "low" | "medium" | "high" + readonly "resolution"?: "512" | "1K" | "2K" | "4K" + readonly "seed"?: number + readonly "size"?: string + readonly "stream"?: boolean } -export const Preview_20250311_WebSearchServerTool = Schema.Struct({ - "engine": Schema.optionalKey(WebSearchEngineEnum), - "filters": Schema.optionalKey(WebSearchDomainFilter), - "max_results": Schema.optionalKey( +export const ImageGenerationRequest = Schema.Struct({ + "aspect_ratio": Schema.optionalKey( + Schema.Literals([ + "1:1", + "1:2", + "1:4", + "1:8", + "2:1", + "2:3", + "3:2", + "3:4", + "4:1", + "4:3", + "4:5", + "5:4", + "8:1", + "9:16", + "16:9", + "9:19.5", + "19.5:9", + "9:20", + "20:9", + "9:21", + "21:9", + "auto" + ]).annotate({ + "description": "Normalized aspect ratio of the generated image. Providers clamp to their supported subset." + }) + ), + "background": Schema.optionalKey( + Schema.Literals(["auto", "transparent", "opaque"]).annotate({ + "description": "Background treatment. `transparent` requires an output_format that supports alpha (png or webp)." + }) + ), + "input_references": Schema.optionalKey( + Schema.Array(ContentPartImage).annotate({ + "description": "Reference images to guide image-to-image generation, as base64 data URLs or HTTP(S) URLs." + }).check(Schema.isMaxLength(16).annotate({ "expected": "a value with a length of at most 16" })) + ), + "model": Schema.String.annotate({ "description": "The image generation model to use" }), + "n": Schema.optionalKey( Schema.Number.annotate({ "description": - "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." + "Number of images to generate (1-10). Providers that only support single-image generation reject n > 1." }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "search_context_size": Schema.optionalKey(SearchContextSizeEnum), - "type": Schema.Literal("web_search_preview_2025_03_11"), - "user_location": Schema.optionalKey(Preview_WebSearchUserLocation) -}).annotate({ - "description": "Web search preview tool configuration (2025-03-11 version)", - "identifier": "Preview_20250311_WebSearchServerTool" -}) -export type Preview_WebSearchServerTool = { - readonly "engine"?: WebSearchEngineEnum - readonly "filters"?: WebSearchDomainFilter - readonly "max_results"?: number - readonly "search_context_size"?: SearchContextSizeEnum - readonly "type": "web_search_preview" - readonly "user_location"?: Preview_WebSearchUserLocation -} -export const Preview_WebSearchServerTool = Schema.Struct({ - "engine": Schema.optionalKey(WebSearchEngineEnum), - "filters": Schema.optionalKey(WebSearchDomainFilter), - "max_results": Schema.optionalKey( + "output_compression": Schema.optionalKey( Schema.Number.annotate({ "description": - "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." + "Compression level (0-100) for webp/jpeg output. Ignored for png and by providers without a compression knob." }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "search_context_size": Schema.optionalKey(SearchContextSizeEnum), - "type": Schema.Literal("web_search_preview"), - "user_location": Schema.optionalKey(Preview_WebSearchUserLocation) -}).annotate({ "description": "Web search preview tool configuration", "identifier": "Preview_WebSearchServerTool" }) -export type Legacy_WebSearchServerTool = { - readonly "engine"?: WebSearchEngineEnum - readonly "filters"?: WebSearchDomainFilter - readonly "max_results"?: number - readonly "search_context_size"?: SearchContextSizeEnum - readonly "type": "web_search" - readonly "user_location"?: WebSearchUserLocation -} -export const Legacy_WebSearchServerTool = Schema.Struct({ - "engine": Schema.optionalKey(WebSearchEngineEnum), - "filters": Schema.optionalKey(WebSearchDomainFilter), - "max_results": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) + "output_format": Schema.optionalKey( + Schema.Literals(["png", "jpeg", "webp", "svg"]).annotate({ + "description": + "Encoding of the returned image bytes. Most models produce raster formats (png, jpeg, webp). SVG is supported by vectorization models (e.g. Quiver) — the SVG markup is UTF-8 base64-encoded in `b64_json`." + }) ), - "search_context_size": Schema.optionalKey(SearchContextSizeEnum), - "type": Schema.Literal("web_search"), - "user_location": Schema.optionalKey(WebSearchUserLocation) -}).annotate({ "description": "Web search tool configuration", "identifier": "Legacy_WebSearchServerTool" }) -export type WebSearchServerTool = { - readonly "engine"?: WebSearchEngineEnum - readonly "filters"?: WebSearchDomainFilter - readonly "max_results"?: number - readonly "search_context_size"?: SearchContextSizeEnum - readonly "type": "web_search_2025_08_26" - readonly "user_location"?: WebSearchUserLocation -} -export const WebSearchServerTool = Schema.Struct({ - "engine": Schema.optionalKey(WebSearchEngineEnum), - "filters": Schema.optionalKey(WebSearchDomainFilter), - "max_results": Schema.optionalKey( + "prompt": Schema.String.annotate({ "description": "Text description of the desired image" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "provider": Schema.optionalKey(ImageGenerationProviderPreferences), + "quality": Schema.optionalKey( + Schema.Literals(["auto", "low", "medium", "high"]).annotate({ + "description": "Rendering quality. Providers without a quality knob ignore this." + }) + ), + "resolution": Schema.optionalKey( + Schema.Literals(["512", "1K", "2K", "4K"]).annotate({ + "description": + "Normalized resolution tier of the generated image. Concrete pixel dimensions are derived per-provider." + }) + ), + "seed": Schema.optionalKey( Schema.Number.annotate({ "description": - "Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped." + "If specified, the generation will sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed for all providers." }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), - "search_context_size": Schema.optionalKey(SearchContextSizeEnum), - "type": Schema.Literal("web_search_2025_08_26"), - "user_location": Schema.optionalKey(WebSearchUserLocation) + "size": Schema.optionalKey(Schema.String.annotate({ + "description": + "Optional. A convenience shorthand for output dimensions — pass a tier (\"2K\", \"4K\") or explicit pixels (\"2048x2048\") and we normalize it to the right dimensions for the chosen provider. A tier size is equivalent to setting `resolution` and combines with `aspect_ratio`. An explicit pixel size is authoritative: a mismatched `resolution` or `aspect_ratio` alongside it is rejected with a 400." + })), + "stream": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "If true, partial images are streamed as SSE events as they become available. Only supported by providers with native streaming (currently OpenAI). Non-streaming providers ignore this flag and return a buffered response." + }) + ) +}).annotate({ "description": "Image generation request input", "identifier": "ImageGenerationRequest" }) +export type StopServerToolsWhen = ReadonlyArray +export const StopServerToolsWhen = Schema.Array(StopServerToolsWhenCondition).annotate({ + "description": + "Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call." +}).check( + Schema.isMinLength(1).annotate({ + "expected": "a value with a length of at least 1", + "identifier": "StopServerToolsWhen" + }) +) +export type AdvisorServerTool_OpenRouter = { + readonly "parameters"?: AdvisorServerToolConfig + readonly "type": "openrouter:advisor" +} +export const AdvisorServerTool_OpenRouter = Schema.Struct({ + "parameters": Schema.optionalKey(AdvisorServerToolConfig), + "type": Schema.Literal("openrouter:advisor") }).annotate({ - "description": "Web search tool configuration (2025-08-26 version)", - "identifier": "WebSearchServerTool" + "description": + "OpenRouter built-in server tool: consults a higher-intelligence advisor model (any OpenRouter model) for guidance mid-generation and returns its response. The advisor may run as a sub-agent with its own tools. Include multiple entries to offer several named advisors; at most one entry may omit `name` to act as the default advisor.", + "identifier": "AdvisorServerTool_OpenRouter" +}) +export type BashServerToolConfig = { + readonly "engine"?: BashServerToolEngine + readonly "environment"?: BashServerToolEnvironment + readonly "sleep_after_seconds"?: SandboxSleepAfterSeconds +} +export const BashServerToolConfig = Schema.Struct({ + "engine": Schema.optionalKey(BashServerToolEngine), + "environment": Schema.optionalKey(BashServerToolEnvironment), + "sleep_after_seconds": Schema.optionalKey(SandboxSleepAfterSeconds) +}).annotate({ + "description": "Configuration for the openrouter:bash server tool", + "identifier": "BashServerToolConfig" +}) +export type ShellServerToolConfig = { + readonly "engine"?: ShellServerToolEngine + readonly "environment"?: ShellServerToolEnvironment + readonly "sleep_after_seconds"?: SandboxSleepAfterSeconds +} +export const ShellServerToolConfig = Schema.Struct({ + "engine": Schema.optionalKey(ShellServerToolEngine), + "environment": Schema.optionalKey(ShellServerToolEnvironment), + "sleep_after_seconds": Schema.optionalKey(SandboxSleepAfterSeconds) +}).annotate({ + "description": "Configuration for the openrouter:shell server tool", + "identifier": "ShellServerToolConfig" +}) +export type SubagentServerTool_OpenRouter = { + readonly "parameters"?: SubagentServerToolConfig + readonly "type": "openrouter:subagent" +} +export const SubagentServerTool_OpenRouter = Schema.Struct({ + "parameters": Schema.optionalKey(SubagentServerToolConfig), + "type": Schema.Literal("openrouter:subagent") +}).annotate({ + "description": + "OpenRouter built-in server tool: delegates self-contained tasks to a smaller, cheaper, faster worker model (any OpenRouter model) mid-generation and returns its outcome. The worker may run as a sub-agent with its own tools.", + "identifier": "SubagentServerTool_OpenRouter" +}) +export type WebFetchServerTool = { + readonly "parameters"?: WebFetchServerToolConfig + readonly "type": "openrouter:web_fetch" +} +export const WebFetchServerTool = Schema.Struct({ + "parameters": Schema.optionalKey(WebFetchServerToolConfig), + "type": Schema.Literal("openrouter:web_fetch") +}).annotate({ + "description": "OpenRouter built-in server tool: fetches full content from a URL (web page or PDF)", + "identifier": "WebFetchServerTool" +}) +export type OpenRouterWebSearchServerTool = { + readonly "parameters"?: WebSearchConfig + readonly "type": "openrouter:web_search" +} +export const OpenRouterWebSearchServerTool = Schema.Struct({ + "parameters": Schema.optionalKey(WebSearchConfig), + "type": Schema.Literal("openrouter:web_search") +}).annotate({ + "description": "OpenRouter built-in server tool: searches the web for current information", + "identifier": "OpenRouterWebSearchServerTool" }) export type ChatWebSearchShorthand = { readonly "allowed_domains"?: ReadonlyArray @@ -13406,6 +11454,8 @@ export type ChatWebSearchShorthand = { readonly "max_characters"?: number readonly "max_results"?: number readonly "max_total_results"?: number + readonly "max_uses"?: number + readonly "mode"?: WebSearchMode readonly "parameters"?: WebSearchConfig readonly "search_context_size"?: SearchQualityLevel readonly "type": "web_search" | "web_search_preview" | "web_search_preview_2025_03_11" | "web_search_2025_08_26" @@ -13422,7 +11472,7 @@ export const ChatWebSearchShorthand = Schema.Struct({ "excluded_domains": Schema.optionalKey( Schema.Array(Schema.String).annotate({ "description": - "Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, and xAI. Not supported with OpenAI (silently ignored). Cannot be used with allowed_domains." + "Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains." }) ), "max_characters": Schema.optionalKey( @@ -13443,6 +11493,13 @@ export const ChatWebSearchShorthand = Schema.Struct({ "Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops. Defaults to 50 when not specified." }).check(Schema.isInt().annotate({ "expected": "an integer" })) ), + "max_uses": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Maximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "mode": Schema.optionalKey(WebSearchMode), "parameters": Schema.optionalKey(WebSearchConfig), "search_context_size": Schema.optionalKey(SearchQualityLevel), "type": Schema.Literals([ @@ -13456,17 +11513,6 @@ export const ChatWebSearchShorthand = Schema.Struct({ "description": "Web search tool using OpenAI Responses API syntax. Automatically converted to openrouter:web_search.", "identifier": "ChatWebSearchShorthand" }) -export type OpenRouterWebSearchServerTool = { - readonly "parameters"?: WebSearchConfig - readonly "type": "openrouter:web_search" -} -export const OpenRouterWebSearchServerTool = Schema.Struct({ - "parameters": Schema.optionalKey(WebSearchConfig), - "type": Schema.Literal("openrouter:web_search") -}).annotate({ - "description": "OpenRouter built-in server tool: searches the web for current information", - "identifier": "OpenRouterWebSearchServerTool" -}) export type WebSearchServerTool_OpenRouter = { readonly "parameters"?: WebSearchServerToolConfig readonly "type": "openrouter:web_search" @@ -13478,111 +11524,692 @@ export const WebSearchServerTool_OpenRouter = Schema.Struct({ "description": "OpenRouter built-in server tool: searches the web for current information", "identifier": "WebSearchServerTool_OpenRouter" }) -export type AdvisorServerTool_OpenRouter = { - readonly "parameters"?: AdvisorServerToolConfig - readonly "type": "openrouter:advisor" -} -export const AdvisorServerTool_OpenRouter = Schema.Struct({ - "parameters": Schema.optionalKey(AdvisorServerToolConfig), - "type": Schema.Literal("openrouter:advisor") -}).annotate({ - "description": - "OpenRouter built-in server tool: consults a higher-intelligence advisor model (any OpenRouter model) for guidance mid-generation and returns its response. The advisor may run as a sub-agent with its own tools. Include multiple entries to offer several named advisors; at most one entry may omit `name` to act as the default advisor.", - "identifier": "AdvisorServerTool_OpenRouter" -}) -export type AnthropicBashCodeExecutionToolResult = { - readonly "content": AnthropicBashCodeExecutionContent - readonly "tool_use_id": string - readonly "type": "bash_code_execution_tool_result" +export type OpenRouterMetadata = { + readonly "attempt": number + readonly "attempts"?: ReadonlyArray + readonly "endpoints": EndpointsMetadata + readonly "is_byok": boolean + readonly "params"?: RouterParams + readonly "pipeline"?: ReadonlyArray + readonly "region": string | null + readonly "requested": string + readonly "strategy": RoutingStrategy + readonly "summary": string } -export const AnthropicBashCodeExecutionToolResult = Schema.Struct({ - "content": AnthropicBashCodeExecutionContent, - "tool_use_id": Schema.String, - "type": Schema.Literal("bash_code_execution_tool_result") -}).annotate({ "identifier": "AnthropicBashCodeExecutionToolResult" }) -export type AnthropicSearchResultBlockParam = { - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "citations"?: { readonly "enabled"?: boolean } - readonly "content": ReadonlyArray - readonly "source": string - readonly "title": string - readonly "type": "search_result" +export const OpenRouterMetadata = Schema.Struct({ + "attempt": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "attempts": Schema.optionalKey(Schema.Array(RouterAttempt)), + "endpoints": EndpointsMetadata, + "is_byok": Schema.Boolean, + "params": Schema.optionalKey(RouterParams), + "pipeline": Schema.optionalKey(Schema.Array(PipelineStage)), + "region": Schema.Union([Schema.String, Schema.Null]), + "requested": Schema.String, + "strategy": RoutingStrategy, + "summary": Schema.String +}).annotate({ "identifier": "OpenRouterMetadata" }) +export type MessagesErrorResponse = { readonly "error": MessagesErrorDetail; readonly "type": "error" } +export const MessagesErrorResponse = Schema.Struct({ "error": MessagesErrorDetail, "type": Schema.Literal("error") }) + .annotate({ "identifier": "MessagesErrorResponse" }) +export type TaskClassificationResponse = { + readonly "data": { + readonly "as_of": string + readonly "classifications": ReadonlyArray + readonly "macro_categories": ReadonlyArray + readonly "window_days": number + } } -export const AnthropicSearchResultBlockParam = Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "citations": Schema.optionalKey(Schema.Struct({ "enabled": Schema.optionalKey(Schema.Boolean) })), - "content": Schema.Array(AnthropicTextBlockParam), - "source": Schema.String, - "title": Schema.String, - "type": Schema.Literal("search_result") -}).annotate({ "identifier": "AnthropicSearchResultBlockParam" }) -export type FusionServerTool_OpenRouter = { - readonly "parameters"?: FusionServerToolConfig - readonly "type": "openrouter:fusion" +export const TaskClassificationResponse = Schema.Struct({ + "data": Schema.Struct({ + "as_of": Schema.String.annotate({ + "description": + "UTC date (YYYY-MM-DD) of the window upper bound (yesterday). Data is exclusive of the current incomplete UTC day. This is the expected latest date in the snapshot; it does not confirm data presence for that date." + }), + "classifications": Schema.Array(TaskClassificationItem).annotate({ + "description": "Per-task classification market-share data, sorted by usage_share descending." + }), + "macro_categories": Schema.Array(TaskClassificationMacroCategory).annotate({ + "description": "Aggregate market-share data per macro-category (code, data, agent, general)." + }), + "window_days": Schema.Number.annotate({ "description": "Number of trailing days covered by this snapshot." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) + }) +}).annotate({ "identifier": "TaskClassificationResponse" }) +export type Model = { + readonly "alias_target"?: ModelAliasTarget + readonly "architecture": ModelArchitecture + readonly "benchmarks"?: ModelBenchmarks + readonly "canonical_slug": string + readonly "context_length": number | null + readonly "created": number + readonly "default_parameters": DefaultParameters + readonly "description"?: string + readonly "expiration_date"?: string | null + readonly "hugging_face_id"?: string | null + readonly "id": string + readonly "knowledge_cutoff"?: string | null + readonly "links": ModelLinks + readonly "name": string + readonly "per_request_limits": PerRequestLimits + readonly "pricing": PublicPricing + readonly "reasoning"?: ModelReasoning + readonly "supported_parameters": ReadonlyArray + readonly "supported_voices": ReadonlyArray | null + readonly "top_provider": TopProviderInfo } -export const FusionServerTool_OpenRouter = Schema.Struct({ - "parameters": Schema.optionalKey(FusionServerToolConfig), - "type": Schema.Literal("openrouter:fusion") -}).annotate({ - "description": - "OpenRouter built-in server tool: fans out the user prompt to a panel of analysis models, then asks a judge model to summarize their collective output as structured JSON the outer model can synthesize from.", - "identifier": "FusionServerTool_OpenRouter" -}) -export type AnthropicWebFetchBlock = { - readonly "content": AnthropicDocumentBlock - readonly "retrieved_at": string | null - readonly "type": "web_fetch_result" - readonly "url": string +export const Model = Schema.Struct({ + "alias_target": Schema.optionalKey(ModelAliasTarget), + "architecture": ModelArchitecture, + "benchmarks": Schema.optionalKey(ModelBenchmarks), + "canonical_slug": Schema.String.annotate({ "description": "Canonical slug for the model" }), + "context_length": Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + Schema.Null + ]).annotate({ "description": "Maximum context length in tokens" }), + "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "default_parameters": DefaultParameters, + "description": Schema.optionalKey(Schema.String.annotate({ "description": "Description of the model" })), + "expiration_date": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "The date after which the model may be removed. ISO 8601 date string (YYYY-MM-DD) or null if no expiration." + }) + ), + "hugging_face_id": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Hugging Face model identifier, if applicable" + }) + ), + "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), + "knowledge_cutoff": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "The date up to which the model was trained on data. ISO 8601 date string (YYYY-MM-DD) or null if unknown." + }) + ), + "links": ModelLinks, + "name": Schema.String.annotate({ "description": "Display name of the model" }), + "per_request_limits": PerRequestLimits, + "pricing": PublicPricing, + "reasoning": Schema.optionalKey(ModelReasoning), + "supported_parameters": Schema.Array(Parameter).annotate({ + "description": "List of supported parameters for this model" + }), + "supported_voices": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": "List of supported voice identifiers for TTS models. Null for non-TTS models." + }), + "top_provider": TopProviderInfo +}).annotate({ "description": "Information about an AI model available on OpenRouter", "identifier": "Model" }) +export type ListEndpointsResponse = { + readonly "architecture": { + readonly "input_modalities": ReadonlyArray<"text" | "image" | "file" | "audio" | "video"> + 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" + | null + readonly "modality": string | null + readonly "output_modalities": ReadonlyArray< + "text" | "image" | "embeddings" | "audio" | "video" | "rerank" | "speech" | "transcription" + > + readonly "tokenizer": + | "Router" + | "Media" + | "Other" + | "GPT" + | "Claude" + | "Gemini" + | "Gemma" + | "Grok" + | "Cohere" + | "Nova" + | "Qwen" + | "Yi" + | "DeepSeek" + | "Mistral" + | "Llama2" + | "Llama3" + | "Llama4" + | "PaLM" + | "RWKV" + | "Qwen3" + } + readonly "created": number + readonly "description": string + readonly "endpoints": ReadonlyArray + readonly "id": string + readonly "name": string } -export const AnthropicWebFetchBlock = Schema.Struct({ - "content": AnthropicDocumentBlock, - "retrieved_at": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("web_fetch_result"), - "url": Schema.String -}).annotate({ "identifier": "AnthropicWebFetchBlock" }) -export type AnthropicDocumentBlockParam = { - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "citations"?: { readonly "enabled"?: boolean; readonly [x: string]: Schema.Json } | null - readonly "context"?: string | null - readonly "source": - | AnthropicBase64PdfSource - | AnthropicPlainTextSource - | { - readonly "content": string | ReadonlyArray - readonly "type": "content" - } - | AnthropicUrlPdfSource - | AnthropicFileDocumentSource - readonly "title"?: string | null - readonly "type": "document" +export const ListEndpointsResponse = Schema.Struct({ + "architecture": Schema.Struct({ + "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" }), + "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" }), + Schema.Union([Schema.Null]).annotate({ "description": "Instruction format type" }) + ]).annotate({ "description": "Instruction format type" }), + "modality": Schema.Union([ + Schema.Union([Schema.String]).annotate({ "description": "Primary modality of the model" }), + Schema.Union([Schema.Null]).annotate({ "description": "Primary modality of the model" }) + ]).annotate({ "description": "Primary modality of the model" }), + "output_modalities": Schema.Array( + Schema.Union([ + Schema.Literal("text"), + Schema.Literal("image"), + Schema.Literal("embeddings"), + Schema.Literal("audio"), + Schema.Literal("video"), + Schema.Literal("rerank"), + Schema.Literal("speech"), + Schema.Literal("transcription") + ]) + ).annotate({ "description": "Supported output modalities" }), + "tokenizer": Schema.Union([ + Schema.Union([Schema.Literal("Router").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Media").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Other").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("GPT").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Claude").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Gemini").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Gemma").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Grok").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Cohere").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Nova").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Qwen").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Yi").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("DeepSeek").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Mistral").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Llama2").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Llama3").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Llama4").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("PaLM").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("RWKV").annotate({ "description": "Tokenizer type used by the model" })]), + Schema.Union([Schema.Literal("Qwen3").annotate({ "description": "Tokenizer type used by the model" })]) + ]).annotate({ "description": "Tokenizer type used by the model" }) + }).annotate({ "description": "Model architecture information" }), + "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "description": Schema.String.annotate({ "description": "Description of the model" }), + "endpoints": Schema.Array(PublicEndpoint).annotate({ "description": "List of available endpoints for this model" }), + "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), + "name": Schema.String.annotate({ "description": "Display name of the model" }) +}).annotate({ "description": "List of available endpoints for a model", "identifier": "ListEndpointsResponse" }) +export type FileListResponse = OpenRouterFileList | OpenAIFileList | AnthropicFileList +export const FileListResponse = Schema.Union([OpenRouterFileList, OpenAIFileList, AnthropicFileList], { mode: "oneOf" }) + .annotate({ "description": "A page of files, in the negotiated shape.", "identifier": "FileListResponse" }) +export type Guardrail = { + readonly "allowed_models"?: ReadonlyArray | null + readonly "allowed_providers"?: ReadonlyArray | null + readonly "content_filter_builtins"?: ReadonlyArray | null + readonly "content_filters"?: ReadonlyArray | null + readonly "created_at": string + readonly "description"?: string | null + readonly "enable_free_model_publication"?: boolean | null + readonly "enable_free_model_training"?: boolean | null + readonly "enable_paid_model_training"?: boolean | null + readonly "enforce_zdr"?: boolean | null + readonly "enforce_zdr_anthropic"?: boolean | null + readonly "enforce_zdr_google"?: boolean | null + readonly "enforce_zdr_openai"?: boolean | null + readonly "enforce_zdr_other"?: boolean | null + readonly "enforce_zdr_xai"?: boolean | null + readonly "id": string + readonly "ignored_models"?: ReadonlyArray | null + readonly "ignored_providers"?: ReadonlyArray | null + readonly "include_byok_in_budgets": boolean + readonly "limit_usd"?: number | null + readonly "name": string + readonly "reset_interval"?: GuardrailInterval + readonly "updated_at"?: string | null + readonly "workspace_id": string | null } -export const AnthropicDocumentBlockParam = Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "citations": Schema.optionalKey( - Schema.Union([ - Schema.StructWithRest(Schema.Struct({ "enabled": Schema.optionalKey(Schema.Boolean) }), [ - Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) - ]), - Schema.Null - ]) +export const Guardrail = Schema.Struct({ + "allowed_models": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": "Array of model canonical_slugs (immutable identifiers)" + }) ), - "context": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "source": Schema.Union([ - AnthropicBase64PdfSource, - AnthropicPlainTextSource, - Schema.Struct({ - "content": Schema.Union([ - Schema.String, - Schema.Array(Schema.Union([AnthropicTextBlockParam, AnthropicImageBlockParam], { mode: "oneOf" })) - ]), - "type": Schema.Literal("content") - }), - AnthropicUrlPdfSource, - AnthropicFileDocumentSource - ], { mode: "oneOf" }), - "title": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("document") -}).annotate({ "identifier": "AnthropicDocumentBlockParam" }) + "allowed_providers": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ "description": "List of allowed provider IDs" }) + ), + "content_filter_builtins": Schema.optionalKey( + Schema.Union([Schema.Array(ContentFilterBuiltinEntry), Schema.Null]).annotate({ + "description": + "Builtin content filters applied to requests. Includes PII detectors and the regex-based prompt injection detector." + }) + ), + "content_filters": Schema.optionalKey( + Schema.Union([Schema.Array(ContentFilterEntry), Schema.Null]).annotate({ + "description": "Custom regex content filters applied to request messages" + }) + ), + "created_at": Schema.String.annotate({ "description": "ISO 8601 timestamp of when the guardrail was created" }), + "description": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "Description of the guardrail" }) + ), + "enable_free_model_publication": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether this guardrail allows free endpoints that publish prompts." + }) + ), + "enable_free_model_training": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether this guardrail allows free endpoints that train on request data." + }) + ), + "enable_paid_model_training": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether this guardrail allows paid endpoints that train on request data." + }) + ), + "enforce_zdr": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, enforce_zdr_xai, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request." + }) + ), + "enforce_zdr_anthropic": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_google": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_openai": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_other": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, Google, or xAI. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_xai": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for xAI models. Falls back to enforce_zdr when not provided." + }) + ), + "id": Schema.String.annotate({ "description": "Unique identifier for the guardrail", "format": "uuid" }), + "ignored_models": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": "Array of model canonical_slugs to exclude from routing" + }) + ), + "ignored_providers": Schema.optionalKey( + Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": "List of provider IDs to exclude from routing" + }) + ), + "include_byok_in_budgets": Schema.Boolean.annotate({ + "description": + "Whether BYOK (bring-your-own-key) inference spend counts toward this guardrail's limit_usd, in addition to OpenRouter credit spend." + }), + "limit_usd": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Spending limit in USD", "format": "double" }) + ), + "name": Schema.String.annotate({ "description": "Name of the guardrail" }), + "reset_interval": Schema.optionalKey(GuardrailInterval), + "updated_at": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "ISO 8601 timestamp of when the guardrail was last updated" + }) + ), + "workspace_id": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "The workspace this guardrail is scoped to, or `null` for an unscoped legacy guardrail predating workspaces. A `null` value does not mean the default workspace, and does not apply the guardrail across every workspace." + }) +}).annotate({ "identifier": "Guardrail" }) +export type CreateGuardrailRequest = { + readonly "allowed_models"?: ReadonlyArray | null + readonly "allowed_providers"?: ReadonlyArray | null + readonly "content_filter_builtins"?: ReadonlyArray | null + readonly "content_filters"?: ReadonlyArray | null + readonly "description"?: string | null + readonly "enable_free_model_publication"?: boolean | null + readonly "enable_free_model_training"?: boolean | null + readonly "enable_paid_model_training"?: boolean | null + readonly "enforce_zdr"?: boolean | null + readonly "enforce_zdr_anthropic"?: boolean | null + readonly "enforce_zdr_google"?: boolean | null + readonly "enforce_zdr_openai"?: boolean | null + readonly "enforce_zdr_other"?: boolean | null + readonly "enforce_zdr_xai"?: boolean | null + readonly "ignored_models"?: ReadonlyArray | null + readonly "ignored_providers"?: ReadonlyArray | null + readonly "include_byok_in_budgets"?: boolean + readonly "limit_usd"?: number | null + readonly "name": string + readonly "reset_interval"?: GuardrailInterval + readonly "workspace_id"?: string +} +export const CreateGuardrailRequest = Schema.Struct({ + "allowed_models": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]).annotate({ "description": "Array of model identifiers (slug or canonical_slug accepted)" }) + ), + "allowed_providers": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]).annotate({ "description": "List of allowed provider IDs" }) + ), + "content_filter_builtins": Schema.optionalKey( + Schema.Union([Schema.Array(ContentFilterBuiltinEntryInput), Schema.Null]).annotate({ + "description": + "Builtin content filters to apply. Every builtin slug supports \"block\", \"redact\", and the detect-only \"flag\" action." + }) + ), + "content_filters": Schema.optionalKey( + Schema.Union([Schema.Array(ContentFilterEntry), Schema.Null]).annotate({ + "description": "Custom regex content filters to apply to request messages" + }) + ), + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(1000).annotate({ "expected": "a value with a length of at most 1000" })), + Schema.Null + ]).annotate({ "description": "Description of the guardrail" }) + ), + "enable_free_model_publication": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether this guardrail allows free endpoints that publish prompts." + }) + ), + "enable_free_model_training": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether this guardrail allows free endpoints that train on request data." + }) + ), + "enable_paid_model_training": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether this guardrail allows paid endpoints that train on request data." + }) + ), + "enforce_zdr": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, enforce_zdr_xai, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request." + }) + ), + "enforce_zdr_anthropic": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_google": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_openai": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_other": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, Google, or xAI. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_xai": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for xAI models. Falls back to enforce_zdr when not provided." + }) + ), + "ignored_models": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]).annotate({ + "description": "Array of model identifiers to exclude from routing (slug or canonical_slug accepted)" + }) + ), + "ignored_providers": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]).annotate({ "description": "List of provider IDs to exclude from routing" }) + ), + "include_byok_in_budgets": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether BYOK (bring-your-own-key) inference spend counts toward this guardrail's limit_usd, in addition to OpenRouter credit spend. Defaults to false." + }) + ), + "limit_usd": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Spending limit in USD", "format": "double" }) + ), + "name": Schema.String.annotate({ "description": "Name for the new guardrail" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(200).annotate({ "expected": "a value with a length of at most 200" })), + "reset_interval": Schema.optionalKey(GuardrailInterval), + "workspace_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "The workspace to create the guardrail in. When omitted, the guardrail is created in the default workspace; if that default has been deleted, the request returns a 400 and you must pass `workspace_id` explicitly.", + "format": "uuid" + }) + ) +}).annotate({ "identifier": "CreateGuardrailRequest" }) +export type UpdateGuardrailRequest = { + readonly "allowed_models"?: ReadonlyArray | null + readonly "allowed_providers"?: ReadonlyArray | null + readonly "content_filter_builtins"?: ReadonlyArray | null + readonly "content_filters"?: ReadonlyArray | null + readonly "description"?: string | null + readonly "enable_free_model_publication"?: boolean | null + readonly "enable_free_model_training"?: boolean | null + readonly "enable_paid_model_training"?: boolean | null + readonly "enforce_zdr"?: boolean | null + readonly "enforce_zdr_anthropic"?: boolean | null + readonly "enforce_zdr_google"?: boolean | null + readonly "enforce_zdr_openai"?: boolean | null + readonly "enforce_zdr_other"?: boolean | null + readonly "enforce_zdr_xai"?: boolean | null + readonly "ignored_models"?: ReadonlyArray | null + readonly "ignored_providers"?: ReadonlyArray | null + readonly "include_byok_in_budgets"?: boolean + readonly "limit_usd"?: number | null + readonly "name"?: string + readonly "reset_interval"?: GuardrailInterval +} +export const UpdateGuardrailRequest = Schema.Struct({ + "allowed_models": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]).annotate({ "description": "Array of model identifiers (slug or canonical_slug accepted)" }) + ), + "allowed_providers": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]).annotate({ "description": "New list of allowed provider IDs" }) + ), + "content_filter_builtins": Schema.optionalKey( + Schema.Union([Schema.Array(ContentFilterBuiltinEntryInput), Schema.Null]).annotate({ + "description": + "Builtin content filters to apply. Set to null to remove. Every builtin slug supports \"block\", \"redact\", and the detect-only \"flag\" action." + }) + ), + "content_filters": Schema.optionalKey( + Schema.Union([Schema.Array(ContentFilterEntry), Schema.Null]).annotate({ + "description": "Custom regex content filters to apply. Set to null to remove." + }) + ), + "description": Schema.optionalKey( + Schema.Union([ + Schema.String.check(Schema.isMaxLength(1000).annotate({ "expected": "a value with a length of at most 1000" })), + Schema.Null + ]).annotate({ "description": "New description for the guardrail" }) + ), + "enable_free_model_publication": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether this guardrail allows free endpoints that publish prompts." + }) + ), + "enable_free_model_training": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether this guardrail allows free endpoints that train on request data." + }) + ), + "enable_paid_model_training": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": "Whether this guardrail allows paid endpoints that train on request data." + }) + ), + "enforce_zdr": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, enforce_zdr_xai, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request." + }) + ), + "enforce_zdr_anthropic": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_google": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_openai": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_other": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, Google, or xAI. Falls back to enforce_zdr when not provided." + }) + ), + "enforce_zdr_xai": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ + "description": + "Whether to enforce zero data retention for xAI models. Falls back to enforce_zdr when not provided." + }) + ), + "ignored_models": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]).annotate({ + "description": "Array of model identifiers to exclude from routing (slug or canonical_slug accepted)" + }) + ), + "ignored_providers": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + Schema.Null + ]).annotate({ "description": "List of provider IDs to exclude from routing" }) + ), + "include_byok_in_budgets": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Whether BYOK (bring-your-own-key) inference spend counts toward this guardrail's limit_usd, in addition to OpenRouter credit spend. Omit to leave unchanged." + }) + ), + "limit_usd": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "New spending limit in USD", "format": "double" }) + ), + "name": Schema.optionalKey( + Schema.String.annotate({ "description": "New name for the guardrail" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(200).annotate({ "expected": "a value with a length of at most 200" })) + ), + "reset_interval": Schema.optionalKey(GuardrailInterval) +}).annotate({ "identifier": "UpdateGuardrailRequest" }) export type AnthropicUsageIteration = | AnthropicCompactionUsageIteration | AnthropicMessageUsageIteration @@ -13594,90 +12221,1331 @@ export const AnthropicUsageIteration = Schema.Union([ AnthropicAdvisorMessageUsageIteration, AnthropicUnknownUsageIteration ]).annotate({ "identifier": "AnthropicUsageIteration" }) -export type AnthropicCodeExecutionToolResult = { - readonly "content": AnthropicCodeExecutionContent +export type ImageModelListItem = { + readonly "architecture": ImageModelArchitecture + readonly "created": number + readonly "description": string + readonly "endpoints": string + readonly "id": string + readonly "name": string + readonly "supported_parameters": SupportedParameters + readonly "supports_streaming": boolean +} +export const ImageModelListItem = Schema.Struct({ + "architecture": ImageModelArchitecture, + "created": Schema.Number.annotate({ "description": "Unix timestamp (seconds) of when the model was created" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "description": Schema.String, + "endpoints": Schema.String.annotate({ + "description": "Relative URL to the full per-endpoint records for this model" + }), + "id": Schema.String.annotate({ "description": "Model slug" }), + "name": Schema.String.annotate({ "description": "Display name" }), + "supported_parameters": SupportedParameters, + "supports_streaming": Schema.Boolean.annotate({ + "description": + "Whether any endpoint of this model supports native SSE streaming on the dedicated Image API (i.e. `stream: true` in the request). OR across endpoints." + }) +}).annotate({ "description": "A single image model in the discovery listing.", "identifier": "ImageModelListItem" }) +export type ImageModelEndpointsResponse = { readonly "endpoints": ReadonlyArray; readonly "id": string } +export const ImageModelEndpointsResponse = Schema.Struct({ + "endpoints": Schema.Array(ImageEndpoint), + "id": Schema.String.annotate({ "description": "Model slug" }) +}).annotate({ + "description": "The full per-endpoint records for an image model.", + "identifier": "ImageModelEndpointsResponse" +}) +export type AnthropicImageBlockParam = { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "source": AnthropicBase64ImageSource | AnthropicUrlImageSource + readonly "type": "image" +} +export const AnthropicImageBlockParam = Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "source": Schema.Union([AnthropicBase64ImageSource, AnthropicUrlImageSource], { mode: "oneOf" }), + "type": Schema.Literal("image") +}).annotate({ "identifier": "AnthropicImageBlockParam" }) +export type AnthropicTextBlock = { + readonly "citations": ReadonlyArray | null + readonly "text": string + readonly "type": "text" +} +export const AnthropicTextBlock = Schema.Struct({ + "citations": Schema.Union([Schema.Array(AnthropicTextCitation), Schema.Null]), + "text": Schema.String, + "type": Schema.Literal("text") +}).annotate({ "identifier": "AnthropicTextBlock" }) +export type AnthropicToolUseBlock = { + readonly "caller": AnthropicCaller + readonly "id": string + readonly "input"?: Schema.Json + readonly "name": string + readonly "type": "tool_use" +} +export const AnthropicToolUseBlock = Schema.Struct({ + "caller": AnthropicCaller, + "id": Schema.String, + "input": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), + "name": Schema.String, + "type": Schema.Literal("tool_use") +}).annotate({ "identifier": "AnthropicToolUseBlock" }) +export type AnthropicWebSearchToolResult = { + readonly "caller": AnthropicCaller + readonly "content": ReadonlyArray | AnthropicWebSearchToolResultError readonly "tool_use_id": string - readonly "type": "code_execution_tool_result" + readonly "type": "web_search_tool_result" +} +export const AnthropicWebSearchToolResult = Schema.Struct({ + "caller": AnthropicCaller, + "content": Schema.Union([Schema.Array(AnthropicWebSearchResult), AnthropicWebSearchToolResultError]), + "tool_use_id": Schema.String, + "type": Schema.Literal("web_search_tool_result") +}).annotate({ "identifier": "AnthropicWebSearchToolResult" }) +export type ORAnthropicServerToolUseBlock = { + readonly "caller"?: ORAnthropicNullableCaller + readonly "id": string + readonly "input"?: Schema.Json + readonly "name": string + readonly "type": "server_tool_use" +} +export const ORAnthropicServerToolUseBlock = Schema.Struct({ + "caller": Schema.optionalKey(ORAnthropicNullableCaller), + "id": Schema.String, + "input": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), + "name": Schema.String, + "type": Schema.Literal("server_tool_use") +}).annotate({ "identifier": "ORAnthropicServerToolUseBlock" }) +export type AnthropicWebFetchBlock = { + readonly "content": AnthropicDocumentBlock + readonly "retrieved_at": string | null + readonly "type": "web_fetch_result" + readonly "url": string +} +export const AnthropicWebFetchBlock = Schema.Struct({ + "content": AnthropicDocumentBlock, + "retrieved_at": Schema.Union([Schema.String, Schema.Null]), + "type": Schema.Literal("web_fetch_result"), + "url": Schema.String +}).annotate({ "identifier": "AnthropicWebFetchBlock" }) +export type AnthropicCodeExecutionContent = + | AnthropicCodeExecutionToolResultError + | AnthropicCodeExecutionResult + | AnthropicEncryptedCodeExecutionResult +export const AnthropicCodeExecutionContent = Schema.Union([ + AnthropicCodeExecutionToolResultError, + AnthropicCodeExecutionResult, + AnthropicEncryptedCodeExecutionResult +], { mode: "oneOf" }).annotate({ "identifier": "AnthropicCodeExecutionContent" }) +export type AnthropicBashCodeExecutionContent = + | AnthropicBashCodeExecutionToolResultError + | AnthropicBashCodeExecutionResult +export const AnthropicBashCodeExecutionContent = Schema.Union([ + AnthropicBashCodeExecutionToolResultError, + AnthropicBashCodeExecutionResult +], { mode: "oneOf" }).annotate({ "identifier": "AnthropicBashCodeExecutionContent" }) +export type AnthropicTextEditorCodeExecutionToolResult = { + readonly "content": AnthropicTextEditorCodeExecutionContent + readonly "tool_use_id": string + readonly "type": "text_editor_code_execution_tool_result" +} +export const AnthropicTextEditorCodeExecutionToolResult = Schema.Struct({ + "content": AnthropicTextEditorCodeExecutionContent, + "tool_use_id": Schema.String, + "type": Schema.Literal("text_editor_code_execution_tool_result") +}).annotate({ "identifier": "AnthropicTextEditorCodeExecutionToolResult" }) +export type AnthropicToolSearchContent = AnthropicToolSearchResultError | AnthropicToolSearchResult +export const AnthropicToolSearchContent = Schema.Union([AnthropicToolSearchResultError, AnthropicToolSearchResult], { + mode: "oneOf" +}).annotate({ "identifier": "AnthropicToolSearchContent" }) +export type ObservabilityArizeDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "apiKey": string + readonly "baseUrl"?: string + readonly "headers"?: {} + readonly "modelId": string + readonly "spaceKey": string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "arize" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityArizeDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "apiKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "baseUrl": Schema.optionalKey(Schema.String), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "modelId": Schema.String.annotate({ "description": "The name of the tracing project in Arize AX" }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "spaceKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("arize"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityArizeDestination" }) +export type ObservabilityBraintrustDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "apiKey": string + readonly "baseUrl"?: string + readonly "headers"?: {} + readonly "projectId": string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "braintrust" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityBraintrustDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "apiKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "baseUrl": Schema.optionalKey(Schema.String), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "projectId": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("braintrust"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityBraintrustDestination" }) +export type ObservabilityClickhouseDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "database": string + readonly "headers"?: {} + readonly "host": string + readonly "password": string + readonly "table"?: string + readonly "username": string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "clickhouse" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityClickhouseDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "database": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "host": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "password": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "table": Schema.optionalKey(Schema.String), + "username": Schema.String.annotate({ + "description": "If you have not set a specific username in ClickHouse, simply type in 'default' below." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("clickhouse"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityClickhouseDestination" }) +export type ObservabilityDatadogDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "apiKey": string + readonly "headers"?: {} + readonly "mlApp": string + readonly "url"?: string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "datadog" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityDatadogDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "apiKey": Schema.String.annotate({ + "description": "Datadog API key must have LLM Observability permissions. Create at: " + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "mlApp": Schema.String.annotate({ "description": "Name to identify your application in Datadog LLM Observability" }) + .check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "url": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Datadog API URL for your region (e.g., https://api.datadoghq.com, https://api.us3.datadoghq.com, https://api.datadoghq.eu)" + }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("datadog"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityDatadogDestination" }) +export type ObservabilityGrafanaDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "apiKey": string + readonly "baseUrl"?: string + readonly "headers"?: {} + readonly "instanceId": string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "grafana" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityGrafanaDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "apiKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "baseUrl": Schema.optionalKey(Schema.String), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "instanceId": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("grafana"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityGrafanaDestination" }) +export type ObservabilityLangfuseDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "baseUrl"?: string + readonly "headers"?: {} + readonly "publicKey": string + readonly "secretKey": string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "langfuse" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityLangfuseDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "baseUrl": Schema.optionalKey(Schema.String), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "publicKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "secretKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("langfuse"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityLangfuseDestination" }) +export type ObservabilityLangsmithDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "apiKey": string + readonly "endpoint"?: string + readonly "headers"?: {} + readonly "project"?: string + readonly "workspaceId"?: string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "langsmith" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityLangsmithDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "apiKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "endpoint": Schema.optionalKey(Schema.String), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "project": Schema.optionalKey( + Schema.String.annotate({ + "description": "The name for this project, such as pr-openrouter-demo. Defaults to \"main\" if not set." + }).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ), + "workspaceId": Schema.optionalKey( + Schema.String.annotate({ + "description": "Required for org-scoped API keys. Find this in your LangSmith workspace settings." + }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("langsmith"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityLangsmithDestination" }) +export type ObservabilityNewrelicDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { readonly "headers"?: {}; readonly "licenseKey": string; readonly "region"?: "us" | "eu" } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "newrelic" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityNewrelicDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "licenseKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "region": Schema.optionalKey(Schema.Literals(["us", "eu"])) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("newrelic"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityNewrelicDestination" }) +export type ObservabilityOpikDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "apiKey": string + readonly "headers"?: {} + readonly "projectName": string + readonly "workspace": string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "opik" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityOpikDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "apiKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "projectName": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "workspace": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("opik"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityOpikDestination" }) +export type ObservabilityOtelCollectorDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { readonly "endpoint": string; readonly "headers"?: {} } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "otel-collector" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityOtelCollectorDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "endpoint": Schema.String, + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": + "Custom HTTP headers as a JSON object. For Axiom, use {\"Authorization\": \"Bearer xaat-xxx\", \"X-Axiom-Dataset\": \"your-dataset\"}" + }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("otel-collector"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityOtelCollectorDestination" }) +export type ObservabilityPosthogDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { readonly "apiKey": string; readonly "endpoint"?: string; readonly "headers"?: {} } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "posthog" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityPosthogDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "apiKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "endpoint": Schema.optionalKey(Schema.String), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("posthog"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityPosthogDestination" }) +export type ObservabilityRampDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { readonly "apiKey": string; readonly "baseUrl"?: string; readonly "headers"?: {} } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "ramp" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityRampDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "apiKey": Schema.String.annotate({ "description": "Generate this in your Ramp integration settings." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "baseUrl": Schema.optionalKey(Schema.String), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to Ramp." }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("ramp"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityRampDestination" }) +export type ObservabilityS3Destination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "accessKeyId": string + readonly "bucketName": string + readonly "endpoint"?: string + readonly "headers"?: {} + readonly "pathTemplate"?: string + readonly "prefix"?: string + readonly "region"?: string + readonly "secretAccessKey": string + readonly "sessionToken"?: string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "s3" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilityS3Destination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "accessKeyId": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "bucketName": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "endpoint": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Only for S3-compatible services like Cloudflare R2 (https://account-id.r2.cloudflarestorage.com) or MinIO. Leave blank for standard AWS S3.", + "format": "uri" + }) + ), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "pathTemplate": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Template for S3 object path. The filename ({traceId}-{timestamp}.json) is automatically appended. Available variables: {prefix}, {date}, {year}, {month}, {day}, {apiKeyName}" + }) + ), + "prefix": Schema.optionalKey(Schema.String), + "region": Schema.optionalKey(Schema.String), + "secretAccessKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "sessionToken": Schema.optionalKey(Schema.String) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("s3"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityS3Destination" }) +export type ObservabilitySentryDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { readonly "dsn": string; readonly "headers"?: {}; readonly "otlpEndpoint": string } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "sentry" + readonly "updated_at": string + readonly "workspace_id": string +} +export const ObservabilitySentryDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "dsn": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + .check( + Schema.isPattern(new RegExp("^https:\\/\\/([^:@]+)(?::[^@]*)?@([^/]+)(?:\\/[^/]+)*\\/(\\d+)\\/?$")).annotate({ + "expected": "a string matching the RegExp ^https:\\/\\/([^:@]+)(?::[^@]*)?@([^/]+)(?:\\/[^/]+)*\\/(\\d+)\\/?$" + }) + ), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "otlpEndpoint": Schema.String + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("sentry"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilitySentryDestination" }) +export type ObservabilitySnowflakeDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "account": string + readonly "database"?: string + readonly "headers"?: {} + readonly "schema"?: string + readonly "table"?: string + readonly "token": string + readonly "warehouse"?: string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "snowflake" + readonly "updated_at": string + readonly "workspace_id": string } -export const AnthropicCodeExecutionToolResult = Schema.Struct({ - "content": AnthropicCodeExecutionContent, - "tool_use_id": Schema.String, - "type": Schema.Literal("code_execution_tool_result") -}).annotate({ "identifier": "AnthropicCodeExecutionToolResult" }) -export type AnthropicToolSearchToolResult = { - readonly "content": AnthropicToolSearchContent - readonly "tool_use_id": string - readonly "type": "tool_search_tool_result" +export const ObservabilitySnowflakeDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "account": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ).check(Schema.isMaxLength(255).annotate({ "expected": "a value with a length of at most 255" })).check( + Schema.isPattern(new RegExp("^[a-zA-Z0-9_]+(?:[.-][a-zA-Z0-9_]+)*$")).annotate({ + "expected": "a string matching the RegExp ^[a-zA-Z0-9_]+(?:[.-][a-zA-Z0-9_]+)*$" + }) + ), + "database": Schema.optionalKey(Schema.String), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "schema": Schema.optionalKey(Schema.String), + "table": Schema.optionalKey(Schema.String), + "token": Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + "warehouse": Schema.optionalKey(Schema.String) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("snowflake"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilitySnowflakeDestination" }) +export type ObservabilityWeaveDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { + readonly "apiKey": string + readonly "baseUrl"?: string + readonly "entity": string + readonly "headers"?: {} + readonly "project": string + } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "weave" + readonly "updated_at": string + readonly "workspace_id": string } -export const AnthropicToolSearchToolResult = Schema.Struct({ - "content": AnthropicToolSearchContent, - "tool_use_id": Schema.String, - "type": Schema.Literal("tool_search_tool_result") -}).annotate({ "identifier": "AnthropicToolSearchToolResult" }) -export type BashServerTool = { readonly "parameters"?: BashServerToolConfig; readonly "type": "openrouter:bash" } -export const BashServerTool = Schema.Struct({ - "parameters": Schema.optionalKey(BashServerToolConfig), - "type": Schema.Literal("openrouter:bash") -}).annotate({ - "description": "OpenRouter built-in server tool: runs shell commands server-side in a sandboxed container", - "identifier": "BashServerTool" -}) -export type ShellServerTool_OpenRouter = { - readonly "parameters"?: ShellServerToolConfig - readonly "type": "openrouter:shell" +export const ObservabilityWeaveDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "apiKey": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "baseUrl": Schema.optionalKey(Schema.String), + "entity": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "headers": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Custom HTTP headers to include in requests to this destination." }) + ), + "project": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("weave"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityWeaveDestination" }) +export type ObservabilityWebhookDestination = { + readonly "api_key_hashes": ReadonlyArray | null + readonly "broadcast_generation_cost": boolean + readonly "broadcast_generation_identity": boolean + readonly "broadcast_generation_request_context": boolean + readonly "config": { readonly "headers"?: {}; readonly "method"?: "POST" | "PUT"; readonly "url": string } + readonly "created_at": string + readonly "enabled": boolean + readonly "filter_rules": ObservabilityFilterRulesConfig + readonly "id": string + readonly "name": string | null + readonly "privacy_mode": boolean + readonly "sampling_rate": number + readonly "type": "webhook" + readonly "updated_at": string + readonly "workspace_id": string } -export const ShellServerTool_OpenRouter = Schema.Struct({ - "parameters": Schema.optionalKey(ShellServerToolConfig), - "type": Schema.Literal("openrouter:shell") -}).annotate({ - "description": - "OpenRouter built-in server tool: runs shell commands server-side in a sandboxed container (a sandbox-backed clone of OpenAI's hosted shell tool)", - "identifier": "ShellServerTool_OpenRouter" -}) -export type ImageModelsListResponse = { readonly "data": ReadonlyArray } -export const ImageModelsListResponse = Schema.Struct({ "data": Schema.Array(ImageModelListItem) }).annotate({ - "description": "List of image generation models.", - "identifier": "ImageModelsListResponse" -}) -export type ObservabilityDestination = - | ObservabilityArizeDestination - | ObservabilityBraintrustDestination - | ObservabilityClickhouseDestination - | ObservabilityDatadogDestination - | ObservabilityGrafanaDestination - | ObservabilityLangfuseDestination - | ObservabilityLangsmithDestination - | ObservabilityNewrelicDestination - | ObservabilityOpikDestination - | ObservabilityOtelCollectorDestination - | ObservabilityPosthogDestination - | ObservabilityRampDestination - | ObservabilityS3Destination - | ObservabilitySentryDestination - | ObservabilitySnowflakeDestination - | ObservabilityWeaveDestination - | ObservabilityWebhookDestination -export const ObservabilityDestination = Schema.Union([ - ObservabilityArizeDestination, - ObservabilityBraintrustDestination, - ObservabilityClickhouseDestination, - ObservabilityDatadogDestination, - ObservabilityGrafanaDestination, - ObservabilityLangfuseDestination, - ObservabilityLangsmithDestination, - ObservabilityNewrelicDestination, - ObservabilityOpikDestination, - ObservabilityOtelCollectorDestination, - ObservabilityPosthogDestination, - ObservabilityRampDestination, - ObservabilityS3Destination, - ObservabilitySentryDestination, - ObservabilitySnowflakeDestination, - ObservabilityWeaveDestination, - ObservabilityWebhookDestination -], { mode: "oneOf" }).annotate({ "identifier": "ObservabilityDestination" }) +export const ObservabilityWebhookDestination = Schema.Struct({ + "api_key_hashes": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) whose traffic is forwarded to this destination. `null` means all keys." + }), + "broadcast_generation_cost": Schema.Boolean.annotate({ + "description": "When true, include cost and billing generation metadata." + }), + "broadcast_generation_identity": Schema.Boolean.annotate({ + "description": "When true, include identity generation metadata." + }), + "broadcast_generation_request_context": Schema.Boolean.annotate({ + "description": "When true, include request-context generation metadata." + }), + "config": Schema.Struct({ + "headers": Schema.optionalKey(Schema.Struct({})), + "method": Schema.optionalKey(Schema.Literals(["POST", "PUT"])), + "url": Schema.String + }), + "created_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was created." }), + "enabled": Schema.Boolean.annotate({ "description": "Whether this destination is currently enabled." }), + "filter_rules": ObservabilityFilterRulesConfig, + "id": Schema.String.annotate({ "description": "Stable public identifier for this destination.", "format": "uuid" }), + "name": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "Human-readable name for the destination." + }), + "privacy_mode": Schema.Boolean.annotate({ + "description": "When true, request/response bodies are not forwarded to this destination — only metadata." + }), + "sampling_rate": Schema.Number.annotate({ + "description": "Sampling rate for events sent to this destination, between 0.0001 and 1 (1 = 100%).", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })), + "type": Schema.Literal("webhook"), + "updated_at": Schema.String.annotate({ "description": "ISO timestamp of when the destination was last updated." }), + "workspace_id": Schema.String.annotate({ + "description": "ID of the workspace this destination belongs to.", + "format": "uuid" + }) +}).annotate({ "identifier": "ObservabilityWebhookDestination" }) export type CreateObservabilityDestinationRequest = { readonly "api_key_hashes"?: ReadonlyArray | null + readonly "broadcast_generation_cost"?: boolean + readonly "broadcast_generation_identity"?: boolean + readonly "broadcast_generation_request_context"?: boolean readonly "config": {} readonly "enabled"?: boolean readonly "filter_rules"?: ObservabilityFilterRulesConfigNullable @@ -13708,573 +13576,459 @@ export const CreateObservabilityDestinationRequest = Schema.Struct({ "api_key_hashes": Schema.optionalKey( Schema.Union([ Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - Schema.Null - ]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes whose traffic is forwarded. `null` or omitted means all keys. Must contain at least one hash if provided." - }) - ), - "config": Schema.Struct({}).annotate({ - "description": "Provider-specific configuration. The shape depends on `type` and is validated server-side." - }), - "enabled": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether this destination should be enabled immediately." }) - ), - "filter_rules": Schema.optionalKey(ObservabilityFilterRulesConfigNullable), - "name": Schema.String.annotate({ "description": "Human-readable name for the destination." }), - "privacy_mode": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "When true, request/response bodies are not forwarded — only metadata." }) - ), - "sampling_rate": Schema.optionalKey( - Schema.Number.annotate({ "description": "Sampling rate between 0.0001 and 1 (1 = 100%).", "format": "double" }) - .check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "type": Schema.Literals([ - "arize", - "braintrust", - "clickhouse", - "datadog", - "grafana", - "langfuse", - "langsmith", - "newrelic", - "opik", - "otel-collector", - "posthog", - "ramp", - "s3", - "sentry", - "snowflake", - "weave", - "webhook" - ]).annotate({ "description": "The destination type. Only stable destination types are accepted." }), - "workspace_id": Schema.optionalKey( - Schema.String.annotate({ - "description": "Optional workspace ID. Defaults to the authenticated entity's default workspace.", - "format": "uuid" - }) - ) -}).annotate({ "identifier": "CreateObservabilityDestinationRequest" }) -export type UpdateObservabilityDestinationRequest = { - readonly "api_key_hashes"?: ReadonlyArray | null - readonly "config"?: {} - readonly "enabled"?: boolean - readonly "filter_rules"?: ObservabilityFilterRulesConfigNullable - readonly "name"?: string - readonly "privacy_mode"?: boolean - readonly "sampling_rate"?: number -} -export const UpdateObservabilityDestinationRequest = Schema.Struct({ - "api_key_hashes": Schema.optionalKey( - Schema.Union([ - Schema.Array(Schema.String).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - Schema.Null - ]).annotate({ - "description": - "Optional allowlist of OpenRouter API key hashes. `null` clears the filter (all keys). Omitting leaves the current value. Must contain at least one hash if provided." - }) - ), - "config": Schema.optionalKey( - Schema.Struct({}).annotate({ - "description": - "Provider-specific configuration fields to update. Masked values are ignored; unset fields keep their current value." - }) - ), - "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "description": "Whether the destination is enabled." })), - "filter_rules": Schema.optionalKey( - Schema.suspend((): Schema.Codec => ObservabilityFilterRulesConfigNullable) - .annotate({ - "description": "Optional structured filter rules. `null` clears the rules. Omitting keeps the current value." - }) - ), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "Human-readable name for the destination." })), - "privacy_mode": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "When true, request/response bodies are not forwarded — only metadata." }) - ), - "sampling_rate": Schema.optionalKey( - Schema.Number.annotate({ "description": "Sampling rate between 0.0001 and 1 (1 = 100%).", "format": "double" }) - .check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ) -}).annotate({ "identifier": "UpdateObservabilityDestinationRequest" }) -export type ProviderPreferences = Objects_148 | null -export const ProviderPreferences = Schema.Union([Objects_148, Schema.Null]).annotate({ - "description": "When multiple model providers are available, optionally indicate your routing preference.", - "identifier": "ProviderPreferences" -}) -export type OpenRouterMetadata = { - readonly "attempt": number - readonly "attempts"?: Arrays_10 - readonly "endpoints": EndpointsMetadata - readonly "is_byok": boolean - readonly "params"?: RouterParams - readonly "pipeline"?: Arrays_11 - readonly "region": string | null - readonly "requested": string - readonly "strategy": RoutingStrategy - readonly "summary": string -} -export const OpenRouterMetadata = Schema.Struct({ - "attempt": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "attempts": Schema.optionalKey(Arrays_10), - "endpoints": EndpointsMetadata, - "is_byok": Schema.Boolean, - "params": Schema.optionalKey(RouterParams), - "pipeline": Schema.optionalKey(Arrays_11), - "region": Schema.Union([Schema.String, Schema.Null]), - "requested": Schema.String, - "strategy": RoutingStrategy, - "summary": Schema.String -}).annotate({ "identifier": "OpenRouterMetadata" }) -export type ChatContentItems = - | ChatContentText - | ChatContentImage - | ChatContentAudio - | Legacy_ChatContentVideo - | ChatContentVideo - | ChatContentFile -export const ChatContentItems = Schema.Union([ - ChatContentText, - ChatContentImage, - ChatContentAudio, - Legacy_ChatContentVideo, - ChatContentVideo, - ChatContentFile -], { mode: "oneOf" }).annotate({ - "description": "Content part for chat completion messages", - "identifier": "ChatContentItems" -}) -export type ChatDeveloperMessage = { - readonly "content": string | ReadonlyArray - readonly "name"?: string - readonly "role": "developer" -} -export const ChatDeveloperMessage = Schema.Struct({ - "content": Schema.Union([Schema.String, Schema.Array(ChatContentText)]).annotate({ - "description": "Developer message content" - }), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the developer message" })), - "role": Schema.Literal("developer") -}).annotate({ "description": "Developer message", "identifier": "ChatDeveloperMessage" }) -export type ChatSystemMessage = { - readonly "content": string | ReadonlyArray - readonly "name"?: string - readonly "role": "system" -} -export const ChatSystemMessage = Schema.Struct({ - "content": Schema.Union([Schema.String, Schema.Array(ChatContentText)]).annotate({ - "description": "System message content" - }), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the system message" })), - "role": Schema.Literal("system") -}).annotate({ "description": "System message for setting behavior", "identifier": "ChatSystemMessage" }) -export type AgentMessageItem = { - readonly "agent"?: { readonly "agent_name": string; readonly [x: string]: Schema.Json } | null - readonly "author": string - readonly "content": ReadonlyArray< - InputText | { - readonly "detail": "auto" | "high" | "low" | "original" - readonly "image_url"?: string | null - readonly "type": "input_image" - } | { readonly "encrypted_content": string; readonly "type": "encrypted_content" } - > - readonly "id"?: string | null - readonly "recipient": string - readonly "type": "agent_message" -} -export const AgentMessageItem = Schema.Struct({ - "agent": Schema.optionalKey( - Schema.Union([ - Schema.StructWithRest(Schema.Struct({ "agent_name": Schema.String }), [ - Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) - ]), - Schema.Null - ]) - ), - "author": Schema.String, - "content": Schema.Array( - Schema.Union([ - InputText, - Schema.Struct({ - "detail": Schema.Literals(["auto", "high", "low", "original"]), - "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("input_image") - }).annotate({ "description": "Image input content item" }), - Schema.Struct({ "encrypted_content": Schema.String, "type": Schema.Literal("encrypted_content") }) - ], { mode: "oneOf" }) - ), - "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "recipient": Schema.String, - "type": Schema.Literal("agent_message") -}).annotate({ - "description": "A message routed between agents in a multi-agent session", - "identifier": "AgentMessageItem" -}) -export type EasyInputMessage = { - readonly "content"?: - | ReadonlyArray< - | InputText - | { - readonly "detail": "auto" | "high" | "low" | "original" - readonly "image_url"?: string | null - readonly "type": "input_image" - } - | InputFile - | InputAudio - | InputVideo - > - | string - | null - readonly "phase"?: "commentary" | "final_answer" | null - readonly "role": "user" | "system" | "assistant" | "developer" - readonly "type"?: "message" -} -export const EasyInputMessage = Schema.Struct({ - "content": Schema.optionalKey( - Schema.Union([ - Schema.Array( - Schema.Union([ - InputText, - Schema.Struct({ - "detail": Schema.Literals(["auto", "high", "low", "original"]), - "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("input_image") - }).annotate({ "description": "Image input content item" }), - InputFile, - InputAudio, - InputVideo - ], { mode: "oneOf" }) + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), - Schema.String, Schema.Null - ]) - ), - "phase": Schema.optionalKey( - Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Null]).annotate({ + ]).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." + "Optional allowlist of OpenRouter API key hashes whose traffic is forwarded. `null` or omitted means all keys. Must contain at least one hash if provided." }) ), - "role": Schema.Literals(["user", "system", "assistant", "developer"]), - "type": Schema.optionalKey(Schema.Literal("message")) -}).annotate({ "identifier": "EasyInputMessage" }) -export type InputMessageItem = { - readonly "content"?: - | ReadonlyArray< - | InputText - | { - readonly "detail": "auto" | "high" | "low" | "original" - readonly "image_url"?: string | null - readonly "type": "input_image" - } - | InputFile - | InputAudio - | InputVideo - > - | null - readonly "id"?: string - readonly "role": "user" | "system" | "developer" - readonly "type"?: "message" + "broadcast_generation_cost": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "When true, include cost and billing generation metadata." }) + ), + "broadcast_generation_identity": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "When true, include identity generation metadata." }) + ), + "broadcast_generation_request_context": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "When true, include request-context generation metadata." }) + ), + "config": Schema.Struct({}).annotate({ + "description": "Provider-specific configuration. The shape depends on `type` and is validated server-side." + }), + "enabled": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether this destination should be enabled immediately." }) + ), + "filter_rules": Schema.optionalKey(ObservabilityFilterRulesConfigNullable), + "name": Schema.String.annotate({ "description": "Human-readable name for the destination." }), + "privacy_mode": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "When true, request/response bodies are not forwarded — only metadata." }) + ), + "sampling_rate": Schema.optionalKey( + Schema.Number.annotate({ "description": "Sampling rate between 0.0001 and 1 (1 = 100%).", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "type": Schema.Literals([ + "arize", + "braintrust", + "clickhouse", + "datadog", + "grafana", + "langfuse", + "langsmith", + "newrelic", + "opik", + "otel-collector", + "posthog", + "ramp", + "s3", + "sentry", + "snowflake", + "weave", + "webhook" + ]).annotate({ "description": "The destination type. Only stable destination types are accepted." }), + "workspace_id": Schema.optionalKey( + Schema.String.annotate({ + "description": "Optional workspace ID. Defaults to the authenticated entity's default workspace.", + "format": "uuid" + }) + ) +}).annotate({ "identifier": "CreateObservabilityDestinationRequest" }) +export type UpdateObservabilityDestinationRequest = { + readonly "api_key_hashes"?: ReadonlyArray | null + readonly "broadcast_generation_cost"?: boolean + readonly "broadcast_generation_identity"?: boolean + readonly "broadcast_generation_request_context"?: boolean + readonly "config"?: {} + readonly "enabled"?: boolean + readonly "filter_rules"?: ObservabilityFilterRulesConfigNullable + readonly "name"?: string + readonly "privacy_mode"?: boolean + readonly "sampling_rate"?: number } -export const InputMessageItem = Schema.Struct({ - "content": Schema.optionalKey( +export const UpdateObservabilityDestinationRequest = Schema.Struct({ + "api_key_hashes": Schema.optionalKey( Schema.Union([ - Schema.Array( - Schema.Union([ - InputText, - Schema.Struct({ - "detail": Schema.Literals(["auto", "high", "low", "original"]), - "image_url": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "type": Schema.Literal("input_image") - }).annotate({ "description": "Image input content item" }), - InputFile, - InputAudio, - InputVideo - ], { mode: "oneOf" }) + Schema.Array(Schema.String).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) ), Schema.Null - ]) + ]).annotate({ + "description": + "Optional allowlist of OpenRouter API key hashes. `null` clears the filter (all keys). Omitting leaves the current value. Must contain at least one hash if provided." + }) ), - "id": Schema.optionalKey(Schema.String), - "role": Schema.Literals(["user", "system", "developer"]), - "type": Schema.optionalKey(Schema.Literal("message")) -}).annotate({ "identifier": "InputMessageItem" }) -export type OpenAIResponseCustomToolCallOutput = { - readonly "call_id": string - readonly "id"?: string - readonly "output": string | ReadonlyArray - readonly "type": "custom_tool_call_output" -} -export const OpenAIResponseCustomToolCallOutput = Schema.Struct({ - "call_id": Schema.String, - "id": Schema.optionalKey(Schema.String), - "output": Schema.Union([ - Schema.String, - Schema.Array(Schema.Union([InputText, InputImage, InputFile], { mode: "oneOf" })) - ]), - "type": Schema.Literal("custom_tool_call_output") -}).annotate({ "identifier": "OpenAIResponseCustomToolCallOutput" }) -export type OpenAIResponseFunctionToolCallOutput = { + "broadcast_generation_cost": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether to include cost and billing generation metadata." }) + ), + "broadcast_generation_identity": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether to include identity generation metadata." }) + ), + "broadcast_generation_request_context": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether to include request-context generation metadata." }) + ), + "config": Schema.optionalKey( + Schema.Struct({}).annotate({ + "description": + "Provider-specific configuration fields to update. Masked values are ignored; unset fields keep their current value." + }) + ), + "enabled": Schema.optionalKey(Schema.Boolean.annotate({ "description": "Whether the destination is enabled." })), + "filter_rules": Schema.optionalKey( + Schema.suspend((): Schema.Codec => ObservabilityFilterRulesConfigNullable) + .annotate({ + "description": "Optional structured filter rules. `null` clears the rules. Omitting keeps the current value." + }) + ), + "name": Schema.optionalKey(Schema.String.annotate({ "description": "Human-readable name for the destination." })), + "privacy_mode": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "When true, request/response bodies are not forwarded — only metadata." }) + ), + "sampling_rate": Schema.optionalKey( + Schema.Number.annotate({ "description": "Sampling rate between 0.0001 and 1 (1 = 100%).", "format": "double" }) + .check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ) +}).annotate({ "identifier": "UpdateObservabilityDestinationRequest" }) +export type ListPresetsResponse = { readonly "data": ReadonlyArray; readonly "total_count": number } +export const ListPresetsResponse = Schema.Struct({ + "data": Schema.Array(Preset), + "total_count": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) +}).annotate({ "description": "A paginated list of presets.", "identifier": "ListPresetsResponse" }) +export type GetPresetResponse = { readonly "data": PresetWithDesignatedVersion } +export const GetPresetResponse = Schema.Struct({ "data": PresetWithDesignatedVersion }).annotate({ + "description": "A preset with its currently designated version.", + "identifier": "GetPresetResponse" +}) +export type CreatePresetFromInferenceResponse = { readonly "data": PresetWithDesignatedVersion } +export const CreatePresetFromInferenceResponse = Schema.Struct({ "data": PresetWithDesignatedVersion }).annotate({ + "description": "Response containing the created preset with its designated version.", + "identifier": "CreatePresetFromInferenceResponse" +}) +export type ApplyPatchCallItem = { readonly "call_id": string readonly "id"?: string | null - readonly "output": string | ReadonlyArray - readonly "status"?: ToolCallStatus | null - readonly "type": "function_call_output" + readonly "operation": ApplyPatchCallOperation + readonly "status": ApplyPatchCallStatus + readonly "type": "apply_patch_call" } -export const OpenAIResponseFunctionToolCallOutput = Schema.Struct({ +export const ApplyPatchCallItem = Schema.Struct({ "call_id": Schema.String, "id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "output": Schema.Union([ - Schema.String, - Schema.Array(Schema.Union([InputText, InputImage, InputFile], { mode: "oneOf" })) - ]), - "status": Schema.optionalKey(Schema.Union([ToolCallStatus, Schema.Null])), - "type": Schema.Literal("function_call_output") -}).annotate({ "identifier": "OpenAIResponseFunctionToolCallOutput" }) -export type OpenAIResponseInputMessageItem = { - readonly "content": ReadonlyArray + "operation": ApplyPatchCallOperation, + "status": ApplyPatchCallStatus, + "type": Schema.Literal("apply_patch_call") +}).annotate({ + "description": + "A tool call emitted by the model requesting a V4A patch operation. The client applies the patch and echoes an `apply_patch_call_output` on the next turn.", + "identifier": "ApplyPatchCallItem" +}) +export type OutputApplyPatchServerToolItem = { + readonly "call_id"?: string + readonly "id"?: string + readonly "operation"?: ApplyPatchCallOperation + readonly "status": ToolCallStatus + readonly "type": "openrouter:apply_patch" +} +export const OutputApplyPatchServerToolItem = Schema.Struct({ + "call_id": Schema.optionalKey(Schema.String), + "id": Schema.optionalKey(Schema.String), + "operation": Schema.optionalKey(ApplyPatchCallOperation), + "status": ToolCallStatus, + "type": Schema.Literal("openrouter:apply_patch") +}).annotate({ + "description": + "An openrouter:apply_patch server tool output item. The turn halts when validation succeeds so the client can apply the patch and echo an `apply_patch_call_output` on the next turn.", + "identifier": "OutputApplyPatchServerToolItem" +}) +export type OutputApplyPatchCallItem = { + readonly "call_id": string readonly "id": string - readonly "role": "user" | "system" | "developer" - readonly "type"?: "message" + readonly "operation": ApplyPatchCallOperation + readonly "status": ApplyPatchCallStatus + readonly "type": "apply_patch_call" } -export const OpenAIResponseInputMessageItem = Schema.Struct({ - "content": Schema.Array(Schema.Union([InputText, InputImage, InputFile, InputAudio], { mode: "oneOf" })), +export const OutputApplyPatchCallItem = Schema.Struct({ + "call_id": Schema.String, "id": Schema.String, - "role": Schema.Literals(["user", "system", "developer"]), - "type": Schema.optionalKey(Schema.Literal("message")) -}).annotate({ "identifier": "OpenAIResponseInputMessageItem" }) -export type Objects_151 = { - readonly "id": string - readonly "variables"?: { readonly [x: string]: string | InputText | InputImage | InputFile } | null - readonly [x: string]: Schema.Json + "operation": ApplyPatchCallOperation, + "status": ApplyPatchCallStatus, + "type": Schema.Literal("apply_patch_call") +}).annotate({ + "description": + "A native `apply_patch_call` output item matching OpenAI's Responses API shape. Emitted when the client requested the `apply_patch` shorthand.", + "identifier": "OutputApplyPatchCallItem" +}) +export type ResponseOutputText = { + readonly "annotations"?: ReadonlyArray + readonly "logprobs"?: ReadonlyArray< + { + readonly "bytes": ReadonlyArray + readonly "logprob": number + readonly "token": string + readonly "top_logprobs": ReadonlyArray< + { readonly "bytes": ReadonlyArray; readonly "logprob": number; readonly "token": string } + > + } + > + readonly "text": string + readonly "type": "output_text" } -export const Objects_151 = Schema.StructWithRest( - Schema.Struct({ - "id": Schema.String, - "variables": Schema.optionalKey( - Schema.Union([ - Schema.Record(Schema.String, Schema.Union([Schema.String, InputText, InputImage, InputFile])), - Schema.Null - ]) +export const ResponseOutputText = Schema.Struct({ + "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), + "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String, + "top_logprobs": Schema.Array( + Schema.Struct({ + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String + }) ) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] -) -export type CreateGuardrailResponse = { readonly "data": Guardrail } -export const CreateGuardrailResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => Guardrail).annotate({ "description": "The created guardrail" }) -}).annotate({ "identifier": "CreateGuardrailResponse" }) -export type GetGuardrailResponse = { readonly "data": Guardrail } -export const GetGuardrailResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => Guardrail).annotate({ "description": "The guardrail" }) -}).annotate({ "identifier": "GetGuardrailResponse" }) -export type ListGuardrailsResponse = { readonly "data": ReadonlyArray; readonly "total_count": number } -export const ListGuardrailsResponse = Schema.Struct({ - "data": Schema.Array(Guardrail).annotate({ "description": "List of guardrails" }), - "total_count": Schema.Number.annotate({ "description": "Total number of guardrails" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) + }))), + "text": Schema.String, + "type": Schema.Literal("output_text") +}).annotate({ "identifier": "ResponseOutputText" }) +export type AnnotationAddedEvent = { + readonly "annotation": OpenAIResponsesAnnotation + readonly "annotation_index": number + readonly "content_index": number + readonly "item_id": string + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.output_text.annotation.added" +} +export const AnnotationAddedEvent = Schema.Struct({ + "annotation": OpenAIResponsesAnnotation, + "annotation_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.output_text.annotation.added") +}).annotate({ + "description": "Event emitted when a text annotation is added to output", + "identifier": "AnnotationAddedEvent" +}) +export type ApplyPatchServerTool_OpenRouter = { + readonly "parameters"?: ApplyPatchServerToolConfig + readonly "type": "openrouter:apply_patch" +} +export const ApplyPatchServerTool_OpenRouter = Schema.Struct({ + "parameters": Schema.optionalKey(ApplyPatchServerToolConfig), + "type": Schema.Literal("openrouter:apply_patch") +}).annotate({ + "description": + "OpenRouter built-in server tool: validates V4A diff patches for file operations (create, update, delete). Restricted to the Responses API.", + "identifier": "ApplyPatchServerTool_OpenRouter" +}) +export type TextExtendedConfig = { + readonly "format"?: Formats + readonly "verbosity"?: "high" | "low" | "medium" | null +} +export const TextExtendedConfig = Schema.Struct({ + "format": Schema.optionalKey(Formats), + "verbosity": Schema.optionalKey( + Schema.Union([Schema.Literal("high"), Schema.Literal("low"), Schema.Literal("medium"), Schema.Union([Schema.Null])]) ) -}).annotate({ "identifier": "ListGuardrailsResponse" }) -export type UpdateGuardrailResponse = { readonly "data": Guardrail } -export const UpdateGuardrailResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => Guardrail).annotate({ "description": "The updated guardrail" }) -}).annotate({ "identifier": "UpdateGuardrailResponse" }) -export type ImageGenerationRequest = { - readonly "aspect_ratio"?: - | "1:1" - | "1:2" - | "1:4" - | "1:8" - | "2:1" - | "2:3" - | "3:2" - | "3:4" - | "4:1" - | "4:3" - | "4:5" - | "5:4" - | "8:1" - | "9:16" - | "16:9" - | "9:19.5" - | "19.5:9" - | "9:20" - | "20:9" - | "9:21" - | "21:9" - | "auto" - readonly "background"?: "auto" | "transparent" | "opaque" - readonly "input_references"?: ReadonlyArray +}).annotate({ + "description": "Text output configuration including format and verbosity", + "identifier": "TextExtendedConfig" +}) +export type VideoGenerationRequest = { + readonly "aspect_ratio"?: "16:9" | "9:16" | "1:1" | "4:3" | "3:4" | "3:2" | "2:3" | "21:9" | "9:21" + readonly "callback_url"?: string + readonly "duration"?: number + readonly "frame_images"?: ReadonlyArray + readonly "generate_audio"?: boolean + readonly "input_references"?: ReadonlyArray readonly "model": string - readonly "n"?: number - readonly "output_compression"?: number - readonly "output_format"?: "png" | "jpeg" | "webp" | "svg" - readonly "prompt": string - readonly "provider"?: ImageGenerationProviderPreferences - readonly "quality"?: "auto" | "low" | "medium" | "high" - readonly "resolution"?: "512" | "1K" | "2K" | "4K" + readonly "prompt"?: string + readonly "provider"?: { readonly "options"?: ProviderOptions } + readonly "resolution"?: "480p" | "720p" | "768p" | "1080p" | "1K" | "2K" | "4K" readonly "seed"?: number readonly "size"?: string - readonly "stream"?: boolean } -export const ImageGenerationRequest = Schema.Struct({ +export const VideoGenerationRequest = Schema.Struct({ "aspect_ratio": Schema.optionalKey( - Schema.Literals([ - "1:1", - "1:2", - "1:4", - "1:8", - "2:1", - "2:3", - "3:2", - "3:4", - "4:1", - "4:3", - "4:5", - "5:4", - "8:1", - "9:16", - "16:9", - "9:19.5", - "19.5:9", - "9:20", - "20:9", - "9:21", - "21:9", - "auto" - ]).annotate({ - "description": "Normalized aspect ratio of the generated image. Providers clamp to their supported subset." - }) - ), - "background": Schema.optionalKey( - Schema.Literals(["auto", "transparent", "opaque"]).annotate({ - "description": "Background treatment. `transparent` requires an output_format that supports alpha (png or webp)." + Schema.Literals(["16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9", "9:21"]).annotate({ + "description": "Aspect ratio of the generated video" }) ), - "input_references": Schema.optionalKey( - Schema.Array(ContentPartImage).annotate({ - "description": "Reference images to guide image-to-image generation, as base64 data URLs or HTTP(S) URLs." - }).check(Schema.isMaxLength(16).annotate({ "expected": "a value with a length of at most 16" })) - ), - "model": Schema.String.annotate({ "description": "The image generation model to use" }), - "n": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Number of images to generate (1-10). Providers that only support single-image generation reject n > 1." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ), - "output_compression": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "Compression level (0-100) for webp/jpeg output. Ignored for png and by providers without a compression knob." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ), - "output_format": Schema.optionalKey( - Schema.Literals(["png", "jpeg", "webp", "svg"]).annotate({ + "callback_url": Schema.optionalKey( + Schema.String.annotate({ "description": - "Encoding of the returned image bytes. Most models produce raster formats (png, jpeg, webp). SVG is supported by vectorization models (e.g. Quiver) — the SVG markup is UTF-8 base64-encoded in `b64_json`." + "URL to receive a webhook notification when the video generation job completes. Overrides the workspace-level default callback URL if set. Must be HTTPS.", + "format": "uri" }) ), - "prompt": Schema.String.annotate({ "description": "Text description of the desired image" }).check( - Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) - ), - "provider": Schema.optionalKey(ImageGenerationProviderPreferences), - "quality": Schema.optionalKey( - Schema.Literals(["auto", "low", "medium", "high"]).annotate({ - "description": "Rendering quality. Providers without a quality knob ignore this." - }) + "duration": Schema.optionalKey( + Schema.Number.annotate({ "description": "Duration of the generated video in seconds" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })) ), - "resolution": Schema.optionalKey( - Schema.Literals(["512", "1K", "2K", "4K"]).annotate({ + "frame_images": Schema.optionalKey( + Schema.Array(FrameImage).annotate({ "description": - "Normalized resolution tier of the generated image. Concrete pixel dimensions are derived per-provider." + "Images to use as the first and/or last frame of the generated video. Each image must specify a frame_type of first_frame or last_frame." }) ), - "seed": Schema.optionalKey( - Schema.Number.annotate({ - "description": - "If specified, the generation will sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed for all providers." - }).check(Schema.isInt().annotate({ "expected": "an integer" })) - ), - "size": Schema.optionalKey(Schema.String.annotate({ - "description": - "Optional. A convenience shorthand for output dimensions — pass a tier (\"2K\", \"4K\") or explicit pixels (\"2048x2048\") and we normalize it to the right dimensions for the chosen provider. A tier size is equivalent to setting `resolution` and combines with `aspect_ratio`. An explicit pixel size is authoritative: a mismatched `resolution` or `aspect_ratio` alongside it is rejected with a 400." - })), - "stream": Schema.optionalKey( + "generate_audio": Schema.optionalKey( Schema.Boolean.annotate({ "description": - "If true, partial images are streamed as SSE events as they become available. Only supported by providers with native streaming (currently OpenAI). Non-streaming providers ignore this flag and return a buffered response." + "Whether to generate audio alongside the video. Defaults to the endpoint's generate_audio capability flag, false if not set." }) - ) -}).annotate({ "description": "Image generation request input", "identifier": "ImageGenerationRequest" }) -export type Model = { - readonly "architecture": ModelArchitecture - readonly "benchmarks"?: ModelBenchmarks - readonly "canonical_slug": string - readonly "context_length": number | null - readonly "created": number - readonly "default_parameters": DefaultParameters - readonly "description"?: string - readonly "expiration_date"?: string | null - readonly "hugging_face_id"?: string | null - readonly "id": string - readonly "knowledge_cutoff"?: string | null - readonly "links": ModelLinks - readonly "name": string - readonly "per_request_limits": PerRequestLimits - readonly "pricing": PublicPricing - readonly "reasoning"?: ModelReasoning - readonly "supported_parameters": ReadonlyArray - readonly "supported_voices": ReadonlyArray | null - readonly "top_provider": TopProviderInfo -} -export const Model = Schema.Struct({ - "architecture": ModelArchitecture, - "benchmarks": Schema.optionalKey(ModelBenchmarks), - "canonical_slug": Schema.String.annotate({ "description": "Canonical slug for the model" }), - "context_length": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]).annotate({ "description": "Maximum context length in tokens" }), - "created": Schema.Number.annotate({ "description": "Unix timestamp of when the model was created" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) ), - "default_parameters": DefaultParameters, - "description": Schema.optionalKey(Schema.String.annotate({ "description": "Description of the model" })), - "expiration_date": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ + "input_references": Schema.optionalKey( + Schema.Array(InputReference).annotate({ + "description": + "Reference assets to guide video generation. Accepts image, audio, and video references. Audio and video references are only honored by providers that support them (including BytePlus Seedance generation 2 and newer); other providers use image references and ignore the rest." + }) + ), + "model": Schema.String, + "prompt": 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." + "Text prompt describing the video to generate. Optional for models that support generating a video from image input alone; required by all other models." }) ), - "hugging_face_id": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "Hugging Face model identifier, if applicable" + "provider": Schema.optionalKey( + Schema.Struct({ "options": Schema.optionalKey(ProviderOptions) }).annotate({ + "description": "Provider-specific passthrough configuration" }) ), - "id": Schema.String.annotate({ "description": "Unique identifier for the model" }), - "knowledge_cutoff": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ + "resolution": Schema.optionalKey( + Schema.Literals(["480p", "720p", "768p", "1080p", "1K", "2K", "4K"]).annotate({ + "description": "Resolution of the generated video" + }) + ), + "seed": Schema.optionalKey( + Schema.Number.annotate({ "description": - "The date up to which the model was trained on data. ISO 8601 date string (YYYY-MM-DD) or null if unknown." + "If specified, the generation will sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed for all providers." + }).check(Schema.isInt().annotate({ "expected": "an integer" })) + ), + "size": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Exact pixel dimensions of the generated video in \"WIDTHxHEIGHT\" format (e.g. \"1280x720\"). Interchangeable with resolution + aspect_ratio." + }) + ) +}).annotate({ "identifier": "VideoGenerationRequest" }) +export type SpeechRequest = { + readonly "input": string + readonly "input_references"?: ReadonlyArray + readonly "model": string + readonly "provider"?: { readonly "options"?: ProviderOptions } + readonly "response_format"?: "mp3" | "pcm" + readonly "speed"?: number + readonly "voice"?: string +} +export const SpeechRequest = Schema.Struct({ + "input": Schema.String.annotate({ "description": "Text to synthesize" }), + "input_references": Schema.optionalKey( + Schema.Array(SpeechInputReference).annotate({ + "description": + "Reference content for stateless voice cloning: one `input_audio` part carrying the voice sample, optionally accompanied by one `text` part with its transcript. Only routed to endpoints that support voice cloning." }) ), - "links": ModelLinks, - "name": Schema.String.annotate({ "description": "Display name of the model" }), - "per_request_limits": PerRequestLimits, - "pricing": PublicPricing, - "reasoning": Schema.optionalKey(ModelReasoning), - "supported_parameters": Schema.Array(Parameter).annotate({ - "description": "List of supported parameters for this model" + "model": Schema.String.annotate({ "description": "TTS model identifier" }), + "provider": Schema.optionalKey( + Schema.Struct({ "options": Schema.optionalKey(ProviderOptions) }).annotate({ + "description": "Provider-specific passthrough configuration" + }) + ), + "response_format": Schema.optionalKey( + Schema.Literals(["mp3", "pcm"]).annotate({ "description": "Audio output format" }) + ), + "speed": Schema.optionalKey( + Schema.Number.annotate({ + "description": + "Playback speed multiplier. Only used by models that support it (e.g. OpenAI TTS). Ignored by other providers.", + "format": "double" + }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "voice": Schema.optionalKey( + Schema.String.annotate({ "description": "Voice identifier (provider-specific)." }).check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ) + ) +}).annotate({ "description": "Text-to-speech request input", "identifier": "SpeechRequest" }) +export type FusionServerTool_OpenRouter = { + readonly "parameters"?: FusionServerToolConfig + readonly "type": "openrouter:fusion" +} +export const FusionServerTool_OpenRouter = Schema.Struct({ + "parameters": Schema.optionalKey(FusionServerToolConfig), + "type": Schema.Literal("openrouter:fusion") +}).annotate({ + "description": + "OpenRouter built-in server tool: fans out the user prompt to a panel of analysis models, then asks an analyst model to summarize their collective output as structured JSON the outer model can synthesize from.", + "identifier": "FusionServerTool_OpenRouter" +}) +export type AnthropicSearchResultBlockParam = { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "citations"?: { readonly "enabled"?: boolean } + readonly "content": ReadonlyArray + readonly "source": string + readonly "title": string + readonly "type": "search_result" +} +export const AnthropicSearchResultBlockParam = Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "citations": Schema.optionalKey(Schema.Struct({ "enabled": Schema.optionalKey(Schema.Boolean) })), + "content": Schema.Array(AnthropicTextBlockParam), + "source": Schema.String, + "title": Schema.String, + "type": Schema.Literal("search_result") +}).annotate({ "identifier": "AnthropicSearchResultBlockParam" }) +export type ChatSystemMessage = { + readonly "content": string | ReadonlyArray + readonly "name"?: string + readonly "role": "system" +} +export const ChatSystemMessage = Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Array(ChatContentText)]).annotate({ + "description": "System message content" }), - "supported_voices": Schema.Union([Schema.Array(Schema.String), Schema.Null]).annotate({ - "description": "List of supported voice identifiers for TTS models. Null for non-TTS models." + "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the system message" })), + "role": Schema.Literal("system") +}).annotate({ "description": "System message for setting behavior", "identifier": "ChatSystemMessage" }) +export type ChatContentItems = + | ChatContentText + | ChatContentImage + | ChatContentAudio + | Legacy_ChatContentVideo + | ChatContentVideo + | ChatContentFile +export const ChatContentItems = Schema.Union([ + ChatContentText, + ChatContentImage, + ChatContentAudio, + Legacy_ChatContentVideo, + ChatContentVideo, + ChatContentFile +], { mode: "oneOf" }).annotate({ + "description": "Content part for chat completion messages", + "identifier": "ChatContentItems" +}) +export type ChatDeveloperMessage = { + readonly "content": string | ReadonlyArray + readonly "name"?: string + readonly "role": "developer" +} +export const ChatDeveloperMessage = Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Array(ChatContentText)]).annotate({ + "description": "Developer message content" }), - "top_provider": TopProviderInfo -}).annotate({ "description": "Information about an AI model available on OpenRouter", "identifier": "Model" }) + "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the developer message" })), + "role": Schema.Literal("developer") +}).annotate({ "description": "Developer message", "identifier": "ChatDeveloperMessage" }) export type ChatReasoningDetails = ReadonlyArray export const ChatReasoningDetails = Schema.Array(ReasoningDetailUnion).annotate({ "description": "Reasoning details for extended thinking models", @@ -14285,275 +14039,219 @@ export const ChatStreamReasoningDetails = Schema.Array(ReasoningDetailUnion).ann "description": "Reasoning details for extended thinking models", "identifier": "ChatStreamReasoningDetails" }) -export type SubagentServerTool_OpenRouter = { - readonly "parameters"?: SubagentServerToolConfig - readonly "type": "openrouter:subagent" -} -export const SubagentServerTool_OpenRouter = Schema.Struct({ - "parameters": Schema.optionalKey(SubagentServerToolConfig), - "type": Schema.Literal("openrouter:subagent") +export type BashServerTool = { readonly "parameters"?: BashServerToolConfig; readonly "type": "openrouter:bash" } +export const BashServerTool = Schema.Struct({ + "parameters": Schema.optionalKey(BashServerToolConfig), + "type": Schema.Literal("openrouter:bash") }).annotate({ - "description": - "OpenRouter built-in server tool: delegates self-contained tasks to a smaller, cheaper, faster worker model (any OpenRouter model) mid-generation and returns its outcome. The worker may run as a sub-agent with its own tools.", - "identifier": "SubagentServerTool_OpenRouter" + "description": "OpenRouter built-in server tool: runs shell commands server-side in a sandboxed container", + "identifier": "BashServerTool" }) -export type BaseContentPartAddedEvent = { - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "part": ResponseOutputText | OpenAIResponsesRefusalContent - readonly "sequence_number": number - readonly "type": "response.content_part.added" +export type ShellServerTool_OpenRouter = { + readonly "parameters"?: ShellServerToolConfig + readonly "type": "openrouter:shell" } -export const BaseContentPartAddedEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "part": Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent]), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.content_part.added") +export const ShellServerTool_OpenRouter = Schema.Struct({ + "parameters": Schema.optionalKey(ShellServerToolConfig), + "type": Schema.Literal("openrouter:shell") }).annotate({ - "description": "Event emitted when a new content part is added to an output item", - "identifier": "BaseContentPartAddedEvent" + "description": + "OpenRouter built-in server tool: runs shell commands server-side in a sandboxed container (a sandbox-backed clone of OpenAI's hosted shell tool)", + "identifier": "ShellServerTool_OpenRouter" }) -export type BaseContentPartDoneEvent = { - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "part": ResponseOutputText | OpenAIResponsesRefusalContent - readonly "sequence_number": number - readonly "type": "response.content_part.done" +export type MessagesStopEvent = { readonly "openrouter_metadata"?: OpenRouterMetadata; readonly "type": "message_stop" } +export const MessagesStopEvent = Schema.Struct({ + "openrouter_metadata": Schema.optionalKey(OpenRouterMetadata), + "type": Schema.Literal("message_stop") +}).annotate({ "description": "Event sent when the message is complete", "identifier": "MessagesStopEvent" }) +export type MessagesErrorEvent = { + readonly "error": { readonly "error_type"?: ApiErrorType; readonly "message": string; readonly "type": string } + readonly "openrouter_metadata"?: OpenRouterMetadata + readonly "type": "error" } -export const BaseContentPartDoneEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "part": Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent]), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.content_part.done") -}).annotate({ - "description": "Event emitted when a content part is complete", - "identifier": "BaseContentPartDoneEvent" +export const MessagesErrorEvent = Schema.Struct({ + "error": Schema.Struct({ + "error_type": Schema.optionalKey(ApiErrorType), + "message": Schema.String, + "type": Schema.String + }), + "openrouter_metadata": Schema.optionalKey(OpenRouterMetadata), + "type": Schema.Literal("error") +}).annotate({ "description": "Error event in the stream", "identifier": "MessagesErrorEvent" }) +export type ModelsListResponseData = ReadonlyArray +export const ModelsListResponseData = Schema.Array(Model).annotate({ + "description": "List of available models", + "identifier": "ModelsListResponseData" }) -export type ContentPartAddedEvent = { - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "part": ResponseOutputText | ReasoningTextContent | OpenAIResponsesRefusalContent - readonly "sequence_number": number - readonly "type": "response.content_part.added" -} -export const ContentPartAddedEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "part": Schema.Union([ResponseOutputText, ReasoningTextContent, OpenAIResponsesRefusalContent]), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.content_part.added") -}).annotate({ - "description": "Event emitted when a new content part is added to an output item", - "identifier": "ContentPartAddedEvent" +export type ModelResponse = { readonly "data": Model } +export const ModelResponse = Schema.Struct({ "data": Model }).annotate({ + "description": "Single model response", + "identifier": "ModelResponse" }) -export type ContentPartDoneEvent = { - readonly "content_index": number - readonly "item_id": string - readonly "output_index": number - readonly "part": ResponseOutputText | ReasoningTextContent | OpenAIResponsesRefusalContent - readonly "sequence_number": number - readonly "type": "response.content_part.done" -} -export const ContentPartDoneEvent = Schema.Struct({ - "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "item_id": Schema.String, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "part": Schema.Union([ResponseOutputText, ReasoningTextContent, OpenAIResponsesRefusalContent]), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.content_part.done") -}).annotate({ "description": "Event emitted when a content part is complete", "identifier": "ContentPartDoneEvent" }) -export type OutputMessage = { - readonly "content": ReadonlyArray - readonly "id": string - readonly "phase"?: "commentary" | "final_answer" | null - readonly "role": "assistant" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "type": "message" +export type ListGuardrailsResponse = { readonly "data": ReadonlyArray; readonly "total_count": number } +export const ListGuardrailsResponse = Schema.Struct({ + "data": Schema.Array(Guardrail).annotate({ "description": "List of guardrails" }), + "total_count": Schema.Number.annotate({ "description": "Total number of guardrails" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "ListGuardrailsResponse" }) +export type CreateGuardrailResponse = { readonly "data": Guardrail } +export const CreateGuardrailResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => Guardrail).annotate({ "description": "The created guardrail" }) +}).annotate({ "identifier": "CreateGuardrailResponse" }) +export type GetGuardrailResponse = { readonly "data": Guardrail } +export const GetGuardrailResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => Guardrail).annotate({ "description": "The guardrail" }) +}).annotate({ "identifier": "GetGuardrailResponse" }) +export type UpdateGuardrailResponse = { readonly "data": Guardrail } +export const UpdateGuardrailResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => Guardrail).annotate({ "description": "The updated guardrail" }) +}).annotate({ "identifier": "UpdateGuardrailResponse" }) +export type ImageGenerationUsage = { + readonly "cache_creation"?: AnthropicCacheCreation + readonly "completion_tokens": number + readonly "completion_tokens_details"?: { + readonly "audio_tokens"?: number | null + readonly "image_tokens"?: number | null + readonly "reasoning_tokens"?: number | null + readonly [x: string]: Schema.Json + } | null + readonly "cost"?: number | null + readonly "cost_details"?: CostDetails + readonly "is_byok"?: boolean + readonly "iterations"?: ReadonlyArray | null + readonly "prompt_tokens": number + readonly "prompt_tokens_details"?: { + readonly "audio_tokens"?: number | null + readonly "cache_write_tokens"?: number | null + readonly "cached_tokens"?: number | null + readonly "file_tokens"?: number | null + readonly "video_tokens"?: number | null + readonly [x: string]: Schema.Json + } | null + readonly "server_tool_use"?: { + readonly "tool_calls_executed"?: number | null + readonly "tool_calls_requested"?: number | null + readonly "web_search_requests"?: number | null + readonly [x: string]: Schema.Json + } | null + readonly "service_tier"?: string | null + readonly "speed"?: AnthropicSpeed + readonly "total_tokens": number } -export const OutputMessage = Schema.Struct({ - "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), - "id": Schema.String, - "phase": Schema.optionalKey( - Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Null]).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 const ImageGenerationUsage = Schema.Struct({ + "cache_creation": Schema.optionalKey(AnthropicCacheCreation), + "completion_tokens": Schema.Number.annotate({ "description": "The tokens generated" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) ), - "role": Schema.Literal("assistant"), - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "type": Schema.Literal("message") -}).annotate({ "identifier": "OutputMessage" }) -export type OutputMessageItem = { - readonly "content": ReadonlyArray - readonly "id": string - readonly "phase"?: "commentary" | "final_answer" | null - readonly "role": "assistant" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "type": "message" -} -export const OutputMessageItem = Schema.Struct({ - "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), - "id": Schema.String, - "phase": Schema.optionalKey( - Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Null]).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." - }) + "completion_tokens_details": Schema.optionalKey(Schema.Union([ + Schema.StructWithRest( + Schema.Struct({ + "audio_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Tokens generated by the model for audio output." }) + ), + "image_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Tokens generated by the model for image output." }) + ), + "reasoning_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Tokens generated by the model for reasoning." }) + ) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ])), + "cost": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Cost of the completion", "format": "double" }) ), - "role": Schema.Literal("assistant"), - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "type": Schema.Literal("message") -}).annotate({ "description": "An output message item", "identifier": "OutputMessageItem" }) -export type AnthropicWebFetchContent = AnthropicWebFetchToolResultError | AnthropicWebFetchBlock -export const AnthropicWebFetchContent = Schema.Union([AnthropicWebFetchToolResultError, AnthropicWebFetchBlock], { - mode: "oneOf" -}).annotate({ "identifier": "AnthropicWebFetchContent" }) -export type MessagesMessageParam = { - readonly "content": - | string - | ReadonlyArray< - | AnthropicTextBlockParam - | AnthropicImageBlockParam - | AnthropicDocumentBlockParam - | { - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "id": string - readonly "input"?: Schema.Json - readonly "name": string - readonly "type": "tool_use" - } - | { - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "content"?: - | string - | ReadonlyArray< - | AnthropicTextBlockParam - | AnthropicImageBlockParam - | { readonly "tool_name": string; readonly "type": "tool_reference" } - | AnthropicSearchResultBlockParam - | AnthropicDocumentBlockParam - > - readonly "is_error"?: boolean - readonly "tool_use_id": string - readonly "type": "tool_result" - } - | { readonly "signature": string; readonly "thinking": string; readonly "type": "thinking" } - | { readonly "data": string; readonly "type": "redacted_thinking" } - | { - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "id": string - readonly "input"?: Schema.Json - readonly "name": string - readonly "type": "server_tool_use" - } - | { - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "content": ReadonlyArray | { - readonly "error_code": - | "invalid_tool_input" - | "unavailable" - | "max_uses_exceeded" - | "too_many_requests" - | "query_too_long" - readonly "type": "web_search_tool_result_error" - } - readonly "tool_use_id": string - readonly "type": "web_search_tool_result" - } - | AnthropicSearchResultBlockParam - | { - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "content": string | null - readonly "type": "compaction" - } - | MessagesAdvisorToolResultBlock - > - readonly "role": "user" | "assistant" | "system" -} -export const MessagesMessageParam = Schema.Struct({ - "content": Schema.Union([ - Schema.String, - Schema.Array( - Schema.Union([ - AnthropicTextBlockParam, - AnthropicImageBlockParam, - AnthropicDocumentBlockParam, - Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "id": Schema.String, - "input": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), - "name": Schema.String, - "type": Schema.Literal("tool_use") - }), + "cost_details": Schema.optionalKey(CostDetails), + "is_byok": Schema.optionalKey( + Schema.Boolean.annotate({ "description": "Whether a request was made using a Bring Your Own Key configuration" }) + ), + "iterations": Schema.optionalKey(Schema.Union([Schema.Array(AnthropicUsageIteration), Schema.Null])), + "prompt_tokens": Schema.Number.annotate({ "description": "Including images, input audio, and tools if any" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "prompt_tokens_details": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest( Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "content": Schema.optionalKey( - Schema.Union([ - Schema.String, - Schema.Array( - Schema.Union([ - AnthropicTextBlockParam, - AnthropicImageBlockParam, - Schema.Struct({ "tool_name": Schema.String, "type": Schema.Literal("tool_reference") }), - AnthropicSearchResultBlockParam, - AnthropicDocumentBlockParam - ]) - ) - ]) + "audio_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Tokens used for input audio." }) ), - "is_error": Schema.optionalKey(Schema.Boolean), - "tool_use_id": Schema.String, - "type": Schema.Literal("tool_result") - }), - Schema.Struct({ "signature": Schema.String, "thinking": Schema.String, "type": Schema.Literal("thinking") }), - Schema.Struct({ "data": Schema.String, "type": Schema.Literal("redacted_thinking") }), - Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "id": Schema.String, - "input": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), - "name": Schema.String, - "type": Schema.Literal("server_tool_use") - }), - Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "content": Schema.Union([ - Schema.Array(AnthropicWebSearchResultBlockParam), - Schema.Struct({ - "error_code": Schema.Literals([ - "invalid_tool_input", - "unavailable", - "max_uses_exceeded", - "too_many_requests", - "query_too_long" - ]), - "type": Schema.Literal("web_search_tool_result_error") - }) - ]), - "tool_use_id": Schema.String, - "type": Schema.Literal("web_search_tool_result") + "cache_write_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ + "description": + "Tokens written to cache. Only returned for models with explicit caching and cache write pricing." + }) + ), + "cached_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Tokens cached by the endpoint." }) + ), + "file_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Tokens used for input files/documents." }) + ), + "video_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ "description": "Tokens used for input video." }) + ) }), - AnthropicSearchResultBlockParam, + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ "description": "Breakdown of tokens used in the prompt." }) + ), + "server_tool_use": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest( Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "content": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("compaction") + "tool_calls_executed": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ + "description": "Number of OpenRouter server tool calls that executed and produced a result." + }) + ), + "tool_calls_requested": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ + "description": + "Total number of OpenRouter server-orchestrated tool calls the model requested, across all tool types. Provider-native tools (e.g. native web search) are not counted here." + }) + ), + "web_search_requests": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + .annotate({ + "description": + "Number of web searches performed by server-side tools. For server-orchestrated tool calls a web search is also counted in tool_calls_requested; provider-native web search may report web_search_requests only. Do not sum the two." + }) + ) }), - MessagesAdvisorToolResultBlock - ], { mode: "oneOf" }) - ) - ]), - "role": Schema.Literals(["user", "assistant", "system"]) -}).annotate({ "description": "Anthropic message with OpenRouter extensions", "identifier": "MessagesMessageParam" }) -export type Union_7 = ReadonlyArray | null -export const Union_7 = Schema.Union([Schema.Array(AnthropicUsageIteration), Schema.Null]) + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), + Schema.Null + ]).annotate({ "description": "Usage for server-side tool execution (e.g., web search)" }) + ), + "service_tier": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The service tier used by the upstream provider for this request" + }) + ), + "speed": Schema.optionalKey(AnthropicSpeed), + "total_tokens": Schema.Number.annotate({ "description": "Sum of the above two fields" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ + "description": "Token and cost usage for the image generation request, when available", + "identifier": "ImageGenerationUsage" +}) export type MessagesDeltaEvent = { readonly "delta": { readonly "container": AnthropicContainer @@ -14617,53 +14315,214 @@ export const MessagesDeltaEvent = Schema.Struct({ "description": "Event sent when the message metadata changes (e.g., stop_reason)", "identifier": "MessagesDeltaEvent" }) -export type CreateObservabilityDestinationResponse = { readonly "data": ObservabilityDestination } -export const CreateObservabilityDestinationResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => ObservabilityDestination).annotate({ - "description": "The newly created observability destination." - }) -}).annotate({ "identifier": "CreateObservabilityDestinationResponse" }) -export type GetObservabilityDestinationResponse = { readonly "data": ObservabilityDestination } -export const GetObservabilityDestinationResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => ObservabilityDestination).annotate({ - "description": "The observability destination." - }) -}).annotate({ "identifier": "GetObservabilityDestinationResponse" }) -export type ListObservabilityDestinationsResponse = { - readonly "data": ReadonlyArray - readonly "total_count": number +export type ImageModelsListResponse = { readonly "data": ReadonlyArray } +export const ImageModelsListResponse = Schema.Struct({ "data": Schema.Array(ImageModelListItem) }).annotate({ + "description": "List of image generation models.", + "identifier": "ImageModelsListResponse" +}) +export type AnthropicDocumentBlockParam = { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "citations"?: { readonly "enabled"?: boolean; readonly [x: string]: Schema.Json } | null + readonly "context"?: string | null + readonly "source": + | AnthropicBase64PdfSource + | AnthropicPlainTextSource + | { + readonly "content": string | ReadonlyArray + readonly "type": "content" + } + | AnthropicUrlPdfSource + | AnthropicFileDocumentSource + readonly "title"?: string | null + readonly "type": "document" } -export const ListObservabilityDestinationsResponse = Schema.Struct({ - "data": Schema.Array(ObservabilityDestination).annotate({ "description": "List of observability destinations." }), - "total_count": Schema.Number.annotate({ "description": "Total number of destinations matching the filters." }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ "identifier": "ListObservabilityDestinationsResponse" }) -export type UpdateObservabilityDestinationResponse = { readonly "data": ObservabilityDestination } -export const UpdateObservabilityDestinationResponse = Schema.Struct({ - "data": Schema.suspend((): Schema.Codec => ObservabilityDestination).annotate({ - "description": "The updated observability destination." - }) -}).annotate({ "identifier": "UpdateObservabilityDestinationResponse" }) -export type MessagesErrorEvent = { - readonly "error": { readonly "error_type"?: ApiErrorType; readonly "message": string; readonly "type": string } - readonly "openrouter_metadata"?: OpenRouterMetadata - readonly "type": "error" +export const AnthropicDocumentBlockParam = Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "citations": Schema.optionalKey( + Schema.Union([ + Schema.StructWithRest(Schema.Struct({ "enabled": Schema.optionalKey(Schema.Boolean) }), [ + Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })) + ]), + Schema.Null + ]) + ), + "context": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "source": Schema.Union([ + AnthropicBase64PdfSource, + AnthropicPlainTextSource, + Schema.Struct({ + "content": Schema.Union([ + Schema.String, + Schema.Array(Schema.Union([AnthropicTextBlockParam, AnthropicImageBlockParam], { mode: "oneOf" })) + ]), + "type": Schema.Literal("content") + }), + AnthropicUrlPdfSource, + AnthropicFileDocumentSource + ], { mode: "oneOf" }), + "title": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("document") +}).annotate({ "identifier": "AnthropicDocumentBlockParam" }) +export type AnthropicWebFetchContent = AnthropicWebFetchToolResultError | AnthropicWebFetchBlock +export const AnthropicWebFetchContent = Schema.Union([AnthropicWebFetchToolResultError, AnthropicWebFetchBlock], { + mode: "oneOf" +}).annotate({ "identifier": "AnthropicWebFetchContent" }) +export type AnthropicCodeExecutionToolResult = { + readonly "content": AnthropicCodeExecutionContent + readonly "tool_use_id": string + readonly "type": "code_execution_tool_result" } -export const MessagesErrorEvent = Schema.Struct({ - "error": Schema.Struct({ - "error_type": Schema.optionalKey(ApiErrorType), - "message": Schema.String, - "type": Schema.String +export const AnthropicCodeExecutionToolResult = Schema.Struct({ + "content": AnthropicCodeExecutionContent, + "tool_use_id": Schema.String, + "type": Schema.Literal("code_execution_tool_result") +}).annotate({ "identifier": "AnthropicCodeExecutionToolResult" }) +export type AnthropicBashCodeExecutionToolResult = { + readonly "content": AnthropicBashCodeExecutionContent + readonly "tool_use_id": string + readonly "type": "bash_code_execution_tool_result" +} +export const AnthropicBashCodeExecutionToolResult = Schema.Struct({ + "content": AnthropicBashCodeExecutionContent, + "tool_use_id": Schema.String, + "type": Schema.Literal("bash_code_execution_tool_result") +}).annotate({ "identifier": "AnthropicBashCodeExecutionToolResult" }) +export type AnthropicToolSearchToolResult = { + readonly "content": AnthropicToolSearchContent + readonly "tool_use_id": string + readonly "type": "tool_search_tool_result" +} +export const AnthropicToolSearchToolResult = Schema.Struct({ + "content": AnthropicToolSearchContent, + "tool_use_id": Schema.String, + "type": Schema.Literal("tool_search_tool_result") +}).annotate({ "identifier": "AnthropicToolSearchToolResult" }) +export type ObservabilityDestination = + | ObservabilityArizeDestination + | ObservabilityBraintrustDestination + | ObservabilityClickhouseDestination + | ObservabilityDatadogDestination + | ObservabilityGrafanaDestination + | ObservabilityLangfuseDestination + | ObservabilityLangsmithDestination + | ObservabilityNewrelicDestination + | ObservabilityOpikDestination + | ObservabilityOtelCollectorDestination + | ObservabilityPosthogDestination + | ObservabilityRampDestination + | ObservabilityS3Destination + | ObservabilitySentryDestination + | ObservabilitySnowflakeDestination + | ObservabilityWeaveDestination + | ObservabilityWebhookDestination +export const ObservabilityDestination = Schema.Union([ + ObservabilityArizeDestination, + ObservabilityBraintrustDestination, + ObservabilityClickhouseDestination, + ObservabilityDatadogDestination, + ObservabilityGrafanaDestination, + ObservabilityLangfuseDestination, + ObservabilityLangsmithDestination, + ObservabilityNewrelicDestination, + ObservabilityOpikDestination, + ObservabilityOtelCollectorDestination, + ObservabilityPosthogDestination, + ObservabilityRampDestination, + ObservabilityS3Destination, + ObservabilitySentryDestination, + ObservabilitySnowflakeDestination, + ObservabilityWeaveDestination, + ObservabilityWebhookDestination +], { mode: "oneOf" }).annotate({ "identifier": "ObservabilityDestination" }) +export type OutputMessage = { + readonly "content": ReadonlyArray + readonly "id": string + readonly "phase"?: "commentary" | "final_answer" | null + readonly "role": "assistant" + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "type": "message" +} +export const OutputMessage = Schema.Struct({ + "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "id": Schema.String, + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Null]).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." + }) + ), + "role": Schema.Literal("assistant"), + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "type": Schema.Literal("message") +}).annotate({ "identifier": "OutputMessage" }) +export type OutputMessageItem = { + readonly "content": ReadonlyArray + readonly "id": string + readonly "phase"?: "commentary" | "final_answer" | null + readonly "role": "assistant" + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "type": "message" +} +export const OutputMessageItem = Schema.Struct({ + "content": Schema.Array(Schema.Union([ResponseOutputText, OpenAIResponsesRefusalContent])), + "id": Schema.String, + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Null]).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." + }) + ), + "role": Schema.Literal("assistant"), + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "type": Schema.Literal("message") +}).annotate({ "description": "An output message item", "identifier": "OutputMessageItem" }) +export type ContentPartAddedEvent = { + readonly "content_index": number + readonly "item_id": string + readonly "output_index": number + readonly "part": ResponseOutputText | ReasoningTextContent | OpenAIResponsesRefusalContent + readonly "sequence_number": number + readonly "type": "response.content_part.added" +} +export const ContentPartAddedEvent = Schema.Struct({ + "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "part": Schema.Union([ResponseOutputText, ReasoningTextContent, OpenAIResponsesRefusalContent]), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.content_part.added") +}).annotate({ + "description": "Event emitted when a new content part is added to an output item", + "identifier": "ContentPartAddedEvent" +}) +export type ContentPartDoneEvent = { + readonly "content_index": number + readonly "item_id": string + readonly "output_index": number + readonly "part": ResponseOutputText | ReasoningTextContent | OpenAIResponsesRefusalContent + readonly "sequence_number": number + readonly "type": "response.content_part.done" +} +export const ContentPartDoneEvent = Schema.Struct({ + "content_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "item_id": Schema.String, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "part": Schema.Union([ResponseOutputText, ReasoningTextContent, OpenAIResponsesRefusalContent]), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.content_part.done") +}).annotate({ "description": "Event emitted when a content part is complete", "identifier": "ContentPartDoneEvent" }) +export type ChatUserMessage = { + readonly "content": string | ReadonlyArray + readonly "name"?: string + readonly "role": "user" +} +export const ChatUserMessage = Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Array(ChatContentItems)]).annotate({ + "description": "User message content" }), - "openrouter_metadata": Schema.optionalKey(OpenRouterMetadata), - "type": Schema.Literal("error") -}).annotate({ "description": "Error event in the stream", "identifier": "MessagesErrorEvent" }) -export type MessagesStopEvent = { readonly "openrouter_metadata"?: OpenRouterMetadata; readonly "type": "message_stop" } -export const MessagesStopEvent = Schema.Struct({ - "openrouter_metadata": Schema.optionalKey(OpenRouterMetadata), - "type": Schema.Literal("message_stop") -}).annotate({ "description": "Event sent when the message is complete", "identifier": "MessagesStopEvent" }) + "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the user" })), + "role": Schema.Literal("user") +}).annotate({ "description": "User message", "identifier": "ChatUserMessage" }) export type ChatToolMessage = { readonly "content": string | ReadonlyArray readonly "role": "tool" @@ -14678,32 +14537,6 @@ export const ChatToolMessage = Schema.Struct({ "description": "ID of the assistant message tool call this message responds to" }) }).annotate({ "description": "Tool response message", "identifier": "ChatToolMessage" }) -export type ChatUserMessage = { - readonly "content": string | ReadonlyArray - readonly "name"?: string - readonly "role": "user" -} -export const ChatUserMessage = Schema.Struct({ - "content": Schema.Union([Schema.String, Schema.Array(ChatContentItems)]).annotate({ - "description": "User message content" - }), - "name": Schema.optionalKey(Schema.String.annotate({ "description": "Optional name for the user" })), - "role": Schema.Literal("user") -}).annotate({ "description": "User message", "identifier": "ChatUserMessage" }) -export type StoredPromptTemplate = Objects_151 | null -export const StoredPromptTemplate = Schema.Union([Objects_151, Schema.Null]).annotate({ - "identifier": "StoredPromptTemplate" -}) -export type ModelResponse = { readonly "data": Model } -export const ModelResponse = Schema.Struct({ "data": Model }).annotate({ - "description": "Single model response", - "identifier": "ModelResponse" -}) -export type ModelsListResponseData = ReadonlyArray -export const ModelsListResponseData = Schema.Array(Model).annotate({ - "description": "List of available models", - "identifier": "ModelsListResponseData" -}) export type ChatAssistantMessage = { readonly "audio"?: ChatAudioOutput readonly "content"?: string | ReadonlyArray | null @@ -14900,6 +14733,62 @@ export const ChatStreamDelta = Schema.Struct({ Schema.Null ])) }).annotate({ "description": "Delta changes in streaming response", "identifier": "ChatStreamDelta" }) +export type ChatFunctionTool = + | { + readonly "cache_control"?: ChatContentCacheControl + readonly "function": { + readonly "description"?: string + readonly "name": string + readonly "parameters"?: {} + readonly "strict"?: boolean | null + } + readonly "type": "function" + } + | AdvisorServerTool_OpenRouter + | BashServerTool + | DatetimeServerTool + | FilesServerTool + | FusionServerTool_OpenRouter + | ImageGenerationServerTool_OpenRouter + | ChatSearchModelsServerTool + | SubagentServerTool_OpenRouter + | WebFetchServerTool + | OpenRouterWebSearchServerTool + | ChatWebSearchShorthand +export const ChatFunctionTool = Schema.Union([ + Schema.Struct({ + "cache_control": Schema.optionalKey(ChatContentCacheControl), + "function": Schema.Struct({ + "description": Schema.optionalKey( + Schema.String.annotate({ "description": "Function description for the model" }) + ), + "name": Schema.String.annotate({ + "description": "Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)" + }).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), + "parameters": Schema.optionalKey( + Schema.Struct({}).annotate({ "description": "Function parameters as JSON Schema object" }) + ), + "strict": Schema.optionalKey( + Schema.Union([Schema.Boolean, Schema.Null]).annotate({ "description": "Enable strict schema adherence" }) + ) + }).annotate({ "description": "Function definition for tool calling" }), + "type": Schema.Literal("function") + }), + AdvisorServerTool_OpenRouter, + BashServerTool, + DatetimeServerTool, + FilesServerTool, + FusionServerTool_OpenRouter, + ImageGenerationServerTool_OpenRouter, + ChatSearchModelsServerTool, + SubagentServerTool_OpenRouter, + WebFetchServerTool, + OpenRouterWebSearchServerTool, + ChatWebSearchShorthand +]).annotate({ + "description": "Tool definition for function calling (regular function or OpenRouter built-in server tool)", + "identifier": "ChatFunctionTool" +}) export type AdditionalToolsItem = { readonly "id"?: string | null readonly "role": "unknown" | "user" | "assistant" | "system" | "critic" | "discriminator" | "developer" | "tool" @@ -14988,62 +14877,252 @@ export const AdditionalToolsItem = Schema.Struct({ "description": "Additional tools made available to the model at this point in the input", "identifier": "AdditionalToolsItem" }) -export type ChatFunctionTool = - | { - readonly "cache_control"?: ChatContentCacheControl - readonly "function": { - readonly "description"?: string - readonly "name": string - readonly "parameters"?: {} - readonly "strict"?: boolean | null - } - readonly "type": "function" - } - | AdvisorServerTool_OpenRouter - | BashServerTool - | DatetimeServerTool - | FilesServerTool - | FusionServerTool_OpenRouter - | ImageGenerationServerTool_OpenRouter - | ChatSearchModelsServerTool - | SubagentServerTool_OpenRouter - | WebFetchServerTool - | OpenRouterWebSearchServerTool - | ChatWebSearchShorthand -export const ChatFunctionTool = Schema.Union([ - Schema.Struct({ - "cache_control": Schema.optionalKey(ChatContentCacheControl), - "function": Schema.Struct({ - "description": Schema.optionalKey( - Schema.String.annotate({ "description": "Function description for the model" }) - ), - "name": Schema.String.annotate({ - "description": "Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)" - }).check(Schema.isMaxLength(64).annotate({ "expected": "a value with a length of at most 64" })), - "parameters": Schema.optionalKey( - Schema.Struct({}).annotate({ "description": "Function parameters as JSON Schema object" }) - ), - "strict": Schema.optionalKey( - Schema.Union([Schema.Boolean, Schema.Null]).annotate({ "description": "Enable strict schema adherence" }) - ) - }).annotate({ "description": "Function definition for tool calling" }), - "type": Schema.Literal("function") - }), - AdvisorServerTool_OpenRouter, - BashServerTool, - DatetimeServerTool, - FilesServerTool, - FusionServerTool_OpenRouter, - ImageGenerationServerTool_OpenRouter, - ChatSearchModelsServerTool, - SubagentServerTool_OpenRouter, - WebFetchServerTool, - OpenRouterWebSearchServerTool, - ChatWebSearchShorthand -]).annotate({ - "description": "Tool definition for function calling (regular function or OpenRouter built-in server tool)", - "identifier": "ChatFunctionTool" +export type ModelsListResponse = { + readonly "data": ModelsListResponseData + readonly "links": { readonly "next": string | null } + readonly "total_count": number +} +export const ModelsListResponse = Schema.Struct({ + "data": ModelsListResponseData, + "links": Schema.Struct({ + "next": Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "URL for the next page of results, or null if this is the last page" + }) + }).annotate({ "description": "Pagination links" }), + "total_count": Schema.Number.annotate({ "description": "Total number of models matching the query" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "description": "List of available models", "identifier": "ModelsListResponse" }) +export type ImageGenerationResponse = { + readonly "created": number + readonly "data": ReadonlyArray<{ readonly "b64_json": string; readonly "media_type"?: string }> + readonly "usage"?: ImageGenerationUsage +} +export const ImageGenerationResponse = Schema.Struct({ + "created": Schema.Number.annotate({ "description": "Unix timestamp (seconds) when the image was generated" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "data": Schema.Array(Schema.Struct({ + "b64_json": Schema.String.annotate({ "description": "Base64-encoded image bytes" }), + "media_type": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined." + }) + ) + })).annotate({ "description": "Generated images" }), + "usage": Schema.optionalKey(ImageGenerationUsage) +}).annotate({ "description": "Image generation response", "identifier": "ImageGenerationResponse" }) +export type ImageGenCompletedEvent = { + readonly "b64_json": string + readonly "created": number + readonly "media_type"?: string + readonly "type": "image_generation.completed" + readonly "usage"?: ImageGenerationUsage +} +export const ImageGenCompletedEvent = Schema.Struct({ + "b64_json": Schema.String.annotate({ "description": "Base64-encoded final image data" }), + "created": Schema.Number.annotate({ "description": "Unix timestamp (seconds) when the image was generated" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "media_type": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined." + }) + ), + "type": Schema.Literal("image_generation.completed").annotate({ "description": "The event type" }), + "usage": Schema.optionalKey(ImageGenerationUsage) +}).annotate({ + "description": "Emitted when generation completes and the final image is available", + "identifier": "ImageGenCompletedEvent" }) +export type MessagesMessageParam = { + readonly "content": + | string + | ReadonlyArray< + | AnthropicTextBlockParam + | AnthropicImageBlockParam + | AnthropicDocumentBlockParam + | { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "id": string + readonly "input"?: Schema.Json + readonly "name": string + readonly "type": "tool_use" + } + | { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "content"?: + | string + | ReadonlyArray< + | AnthropicTextBlockParam + | AnthropicImageBlockParam + | { readonly "tool_name": string; readonly "type": "tool_reference" } + | AnthropicSearchResultBlockParam + | AnthropicDocumentBlockParam + > + readonly "is_error"?: boolean + readonly "tool_use_id": string + readonly "type": "tool_result" + } + | { readonly "signature": string; readonly "thinking": string; readonly "type": "thinking" } + | { readonly "data": string; readonly "type": "redacted_thinking" } + | { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "id": string + readonly "input"?: Schema.Json + readonly "name": string + readonly "type": "server_tool_use" + } + | { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "content": ReadonlyArray | { + readonly "error_code": + | "invalid_tool_input" + | "unavailable" + | "max_uses_exceeded" + | "too_many_requests" + | "query_too_long" + readonly "type": "web_search_tool_result_error" + } + readonly "tool_use_id": string + readonly "type": "web_search_tool_result" + } + | AnthropicSearchResultBlockParam + | { + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "content": string | null + readonly "encrypted_content"?: string | null + readonly "type": "compaction" + } + | MessagesAdvisorToolResultBlock + | MessagesToolAdditionBlock + | MessagesToolRemovalBlock + | MessagesShellToolResultBlock + | MessagesBashToolResultBlock + > + readonly "role": "user" | "assistant" | "system" +} +export const MessagesMessageParam = Schema.Struct({ + "content": Schema.Union([ + Schema.String, + Schema.Array( + Schema.Union([ + AnthropicTextBlockParam, + AnthropicImageBlockParam, + AnthropicDocumentBlockParam, + Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "id": Schema.String, + "input": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), + "name": Schema.String, + "type": Schema.Literal("tool_use") + }), + Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "content": Schema.optionalKey( + Schema.Union([ + Schema.String, + Schema.Array( + Schema.Union([ + AnthropicTextBlockParam, + AnthropicImageBlockParam, + Schema.Struct({ "tool_name": Schema.String, "type": Schema.Literal("tool_reference") }), + AnthropicSearchResultBlockParam, + AnthropicDocumentBlockParam + ]) + ) + ]) + ), + "is_error": Schema.optionalKey(Schema.Boolean), + "tool_use_id": Schema.String, + "type": Schema.Literal("tool_result") + }), + Schema.Struct({ "signature": Schema.String, "thinking": Schema.String, "type": Schema.Literal("thinking") }), + Schema.Struct({ "data": Schema.String, "type": Schema.Literal("redacted_thinking") }), + Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "id": Schema.String, + "input": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), + "name": Schema.String, + "type": Schema.Literal("server_tool_use") + }), + Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "content": Schema.Union([ + Schema.Array(AnthropicWebSearchResultBlockParam), + Schema.Struct({ + "error_code": Schema.Literals([ + "invalid_tool_input", + "unavailable", + "max_uses_exceeded", + "too_many_requests", + "query_too_long" + ]), + "type": Schema.Literal("web_search_tool_result_error") + }) + ]), + "tool_use_id": Schema.String, + "type": Schema.Literal("web_search_tool_result") + }), + AnthropicSearchResultBlockParam, + Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "content": Schema.Union([Schema.String, Schema.Null]), + "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("compaction") + }), + MessagesAdvisorToolResultBlock, + MessagesToolAdditionBlock, + MessagesToolRemovalBlock, + MessagesShellToolResultBlock, + MessagesBashToolResultBlock + ], { mode: "oneOf" }) + ) + ]), + "role": Schema.Literals(["user", "assistant", "system"]) +}).annotate({ "description": "Anthropic message with OpenRouter extensions", "identifier": "MessagesMessageParam" }) +export type AnthropicWebFetchToolResult = { + readonly "caller": AnthropicCaller + readonly "content": AnthropicWebFetchContent + readonly "tool_use_id": string + readonly "type": "web_fetch_tool_result" +} +export const AnthropicWebFetchToolResult = Schema.Struct({ + "caller": AnthropicCaller, + "content": AnthropicWebFetchContent, + "tool_use_id": Schema.String, + "type": Schema.Literal("web_fetch_tool_result") +}).annotate({ "identifier": "AnthropicWebFetchToolResult" }) +export type ListObservabilityDestinationsResponse = { + readonly "data": ReadonlyArray + readonly "total_count": number +} +export const ListObservabilityDestinationsResponse = Schema.Struct({ + "data": Schema.Array(ObservabilityDestination).annotate({ "description": "List of observability destinations." }), + "total_count": Schema.Number.annotate({ "description": "Total number of destinations matching the filters." }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ) +}).annotate({ "identifier": "ListObservabilityDestinationsResponse" }) +export type CreateObservabilityDestinationResponse = { readonly "data": ObservabilityDestination } +export const CreateObservabilityDestinationResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => ObservabilityDestination).annotate({ + "description": "The newly created observability destination." + }) +}).annotate({ "identifier": "CreateObservabilityDestinationResponse" }) +export type GetObservabilityDestinationResponse = { readonly "data": ObservabilityDestination } +export const GetObservabilityDestinationResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => ObservabilityDestination).annotate({ + "description": "The observability destination." + }) +}).annotate({ "identifier": "GetObservabilityDestinationResponse" }) +export type UpdateObservabilityDestinationResponse = { readonly "data": ObservabilityDestination } +export const UpdateObservabilityDestinationResponse = Schema.Struct({ + "data": Schema.suspend((): Schema.Codec => ObservabilityDestination).annotate({ + "description": "The updated observability destination." + }) +}).annotate({ "identifier": "UpdateObservabilityDestinationResponse" }) export type BaseInputs = | string | ReadonlyArray< @@ -15090,67 +15169,6 @@ export const BaseInputs = Schema.Union([ ])), Schema.Null ]).annotate({ "identifier": "BaseInputs" }) -export type OutputItemAddedEvent = { - readonly "item": - | OutputMessage - | OutputItemReasoning - | OutputItemFunctionCall - | OutputItemCustomToolCall - | OutputItemWebSearchCall - | OutputItemFileSearchCall - | OutputItemImageGenerationCall - | OutputItemApplyPatchCall - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.output_item.added" -} -export const OutputItemAddedEvent = Schema.Struct({ - "item": Schema.Union([ - OutputMessage, - OutputItemReasoning, - OutputItemFunctionCall, - OutputItemCustomToolCall, - OutputItemWebSearchCall, - OutputItemFileSearchCall, - OutputItemImageGenerationCall, - OutputItemApplyPatchCall - ], { mode: "oneOf" }), - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.output_item.added") -}).annotate({ - "description": "Event emitted when a new output item is added to the response", - "identifier": "OutputItemAddedEvent" -}) -export type OutputItemDoneEvent = { - readonly "item": - | OutputMessage - | OutputItemReasoning - | OutputItemFunctionCall - | OutputItemCustomToolCall - | OutputItemWebSearchCall - | OutputItemFileSearchCall - | OutputItemImageGenerationCall - | OutputItemApplyPatchCall - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.output_item.done" -} -export const OutputItemDoneEvent = Schema.Struct({ - "item": Schema.Union([ - OutputMessage, - OutputItemReasoning, - OutputItemFunctionCall, - OutputItemCustomToolCall, - OutputItemWebSearchCall, - OutputItemFileSearchCall, - OutputItemImageGenerationCall, - OutputItemApplyPatchCall - ], { mode: "oneOf" }), - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.output_item.done") -}).annotate({ "description": "Event emitted when an output item is complete", "identifier": "OutputItemDoneEvent" }) export type OutputItems = | OutputMessageItem | OutputReasoningItem @@ -15214,18 +15232,487 @@ export const OutputItems = Schema.Union([ OutputFilesServerToolItem, OutputCustomToolCallItem ], { mode: "oneOf" }).annotate({ "description": "An output item from the response", "identifier": "OutputItems" }) -export type AnthropicWebFetchToolResult = { - readonly "caller": AnthropicCaller - readonly "content": AnthropicWebFetchContent - readonly "tool_use_id": string - readonly "type": "web_fetch_tool_result" +export type ChatMessages = + | ChatSystemMessage + | ChatUserMessage + | ChatDeveloperMessage + | ChatAssistantMessage + | ChatToolMessage +export const ChatMessages = Schema.Union([ + ChatSystemMessage, + ChatUserMessage, + ChatDeveloperMessage, + ChatAssistantMessage, + ChatToolMessage +], { mode: "oneOf" }).annotate({ + "description": "Chat completion message with role-based discrimination", + "identifier": "ChatMessages" +}) +export type ChatChoice = { + readonly "finish_reason": ChatFinishReasonEnum + readonly "index": number + readonly "logprobs"?: ChatTokenLogprobs + readonly "message": ChatAssistantMessage +} +export const ChatChoice = Schema.Struct({ + "finish_reason": ChatFinishReasonEnum, + "index": Schema.Number.annotate({ "description": "Choice index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "logprobs": Schema.optionalKey(ChatTokenLogprobs), + "message": ChatAssistantMessage +}).annotate({ "description": "Chat completion choice", "identifier": "ChatChoice" }) +export type ChatStreamChoice = { + readonly "delta": ChatStreamDelta + readonly "finish_reason"?: ChatFinishReasonEnum + readonly "index": number + readonly "logprobs"?: ChatTokenLogprobs +} +export const ChatStreamChoice = Schema.Struct({ + "delta": ChatStreamDelta, + "finish_reason": Schema.optionalKey(ChatFinishReasonEnum), + "index": Schema.Number.annotate({ "description": "Choice index" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "logprobs": Schema.optionalKey(ChatTokenLogprobs) +}).annotate({ "description": "Streaming completion choice chunk", "identifier": "ChatStreamChoice" }) +export type Inputs = + | string + | ReadonlyArray< + | ReasoningItem + | EasyInputMessage + | InputMessageItem + | FunctionCallItem + | FunctionCallOutputItem + | ApplyPatchCallItem + | ApplyPatchCallOutputItem + | { + readonly "content": ReadonlyArray< + { + readonly "annotations"?: ReadonlyArray< + { + readonly "file_id": string + readonly "filename": string + readonly "index": number + readonly "type": "file_citation" + } | { + readonly "content"?: string + readonly "end_index": number + readonly "start_index": number + readonly "title": string + readonly "type": never + readonly "url": string + readonly "file_id": string + readonly "filename": string + readonly "index": number + } | { + readonly "file_id": string + readonly "index": number + readonly "type": never + readonly "filename": string + } | { + readonly "file_id": string + readonly "filename": string + readonly "index": number + readonly "type": never + readonly "content"?: string + readonly "end_index": number + readonly "start_index": number + readonly "title": string + readonly "url": string + } | { + readonly "content"?: string + readonly "end_index": number + readonly "start_index": number + readonly "title": string + readonly "type": "url_citation" + readonly "url": string + } | { + readonly "file_id": string + readonly "index": number + readonly "type": never + readonly "content"?: string + readonly "end_index": number + readonly "start_index": number + readonly "title": string + readonly "url": string + } | { + readonly "file_id": string + readonly "filename": string + readonly "index": number + readonly "type": never + } | { + readonly "content"?: string + readonly "end_index": number + readonly "start_index": number + readonly "title": string + readonly "type": never + readonly "url": string + readonly "file_id": string + readonly "index": number + } | { readonly "file_id": string; readonly "index": number; readonly "type": "file_path" } + > + readonly "logprobs"?: ReadonlyArray< + { + readonly "bytes": ReadonlyArray + readonly "logprob": number + readonly "token": string + readonly "top_logprobs": ReadonlyArray< + { readonly "bytes": ReadonlyArray; readonly "logprob": number; readonly "token": string } + > + } + > + readonly "text": string + readonly "type": "output_text" + } | { + readonly "refusal": string + readonly "type": never + readonly "annotations"?: ReadonlyArray + readonly "logprobs"?: ReadonlyArray< + { + readonly "bytes": ReadonlyArray + readonly "logprob": number + readonly "token": string + readonly "top_logprobs": ReadonlyArray< + { readonly "bytes": ReadonlyArray; readonly "logprob": number; readonly "token": string } + > + } + > + readonly "text": string + } | { + readonly "annotations"?: ReadonlyArray + readonly "logprobs"?: ReadonlyArray< + { + readonly "bytes": ReadonlyArray + readonly "logprob": number + readonly "token": string + readonly "top_logprobs": ReadonlyArray< + { readonly "bytes": ReadonlyArray; readonly "logprob": number; readonly "token": string } + > + } + > + readonly "text": string + readonly "type": never + readonly "refusal": string + } | { readonly "refusal": string; readonly "type": "refusal" } + > + readonly "id": string + readonly "phase"?: "commentary" | "final_answer" | null + readonly "role": "assistant" + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "type": "message" + } + | { + readonly "content"?: ReadonlyArray<{ readonly "text": string; readonly "type": "reasoning_text" }> + readonly "encrypted_content"?: string | null + readonly "id": string + readonly "status"?: "completed" | "incomplete" | "in_progress" + readonly "summary": ReadonlyArray<{ readonly "text": string; readonly "type": "summary_text" }> + readonly "type": "reasoning" + readonly "format"?: ReasoningFormat + readonly "signature"?: string | null + } + | OutputFunctionCallItem + | OutputCustomToolCallItem + | OutputWebSearchCallItem + | OutputFileSearchCallItem + | OutputImageGenerationCallItem + | OutputCodeInterpreterCallItem + | OutputComputerCallItem + | OutputDatetimeItem + | OutputWebSearchServerToolItem + | OutputCodeInterpreterServerToolItem + | OutputFileSearchServerToolItem + | OutputImageGenerationServerToolItem + | OutputBrowserUseServerToolItem + | OutputBashServerToolItem + | OutputTextEditorServerToolItem + | OutputApplyPatchServerToolItem + | OutputWebFetchServerToolItem + | OutputToolSearchServerToolItem + | OutputMemoryServerToolItem + | OutputMcpServerToolItem + | OutputSearchModelsServerToolItem + | OutputFusionServerToolItem + | OutputAdvisorServerToolItem + | OutputSubagentServerToolItem + | OutputFilesServerToolItem + | LocalShellCallItem + | LocalShellCallOutputItem + | ShellCallItem + | ShellCallOutputItem + | McpListToolsItem + | McpApprovalRequestItem + | McpApprovalResponseItem + | McpCallItem + | CustomToolCallItem + | CustomToolCallOutputItem + | CompactionItem + | ContextCompactionItem + | ItemReferenceItem + | AdditionalToolsItem + | AgentMessageItem + > +export const Inputs = Schema.Union([ + Schema.String, + Schema.Array( + Schema.Union([ + ReasoningItem, + EasyInputMessage, + InputMessageItem, + FunctionCallItem, + FunctionCallOutputItem, + ApplyPatchCallItem, + ApplyPatchCallOutputItem, + Schema.Struct({ + "content": Schema.Union([Schema.Array(Schema.Union([ + Schema.Union([ + Schema.Struct({ + "annotations": Schema.optionalKey( + Schema.Array( + Schema.Union([ + Schema.Union([ + Schema.Struct({ + "file_id": Schema.String, + "filename": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("file_citation") + }), + Schema.Struct({ + "content": Schema.optionalKey(Schema.String), + "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "title": Schema.String, + "type": Schema.Never, + "url": Schema.String, + "file_id": Schema.String, + "filename": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + }), + Schema.Struct({ + "file_id": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Never, + "filename": Schema.String + }) + ]), + Schema.Union([ + Schema.Struct({ + "file_id": Schema.String, + "filename": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Never, + "content": Schema.optionalKey(Schema.String), + "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "title": Schema.String, + "url": Schema.String + }), + Schema.Struct({ + "content": Schema.optionalKey(Schema.String), + "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "title": Schema.String, + "type": Schema.Literal("url_citation"), + "url": Schema.String + }), + Schema.Struct({ + "file_id": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Never, + "content": Schema.optionalKey(Schema.String), + "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "title": Schema.String, + "url": Schema.String + }) + ]), + Schema.Union([ + Schema.Struct({ + "file_id": Schema.String, + "filename": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Never + }), + Schema.Struct({ + "content": Schema.optionalKey(Schema.String), + "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "title": Schema.String, + "type": Schema.Never, + "url": Schema.String, + "file_id": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + }), + Schema.Struct({ + "file_id": Schema.String, + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("file_path") + }) + ]) + ]) + ) + ), + "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String, + "top_logprobs": Schema.Array( + Schema.Struct({ + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String + }) + ) + }))), + "text": Schema.String, + "type": Schema.Literal("output_text") + }), + Schema.Struct({ + "refusal": Schema.String, + "type": Schema.Never, + "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), + "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String, + "top_logprobs": Schema.Array( + Schema.Struct({ + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String + }) + ) + }))), + "text": Schema.String + }) + ]), + Schema.Union([ + Schema.Struct({ + "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), + "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String, + "top_logprobs": Schema.Array( + Schema.Struct({ + "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "logprob": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "token": Schema.String + }) + ) + }))), + "text": Schema.String, + "type": Schema.Never, + "refusal": Schema.String + }), + Schema.Struct({ "refusal": Schema.String, "type": Schema.Literal("refusal") }) + ]) + ]))]), + "id": Schema.String, + "phase": Schema.optionalKey( + Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Null]).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." + }) + ), + "role": Schema.Literal("assistant"), + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "type": Schema.Literal("message") + }).annotate({ "description": "An output message item" }), + Schema.Struct({ + "content": Schema.optionalKey( + Schema.Union([ + Schema.Array(Schema.Struct({ "text": Schema.String, "type": Schema.Literal("reasoning_text") })) + ]) + ), + "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "id": Schema.String, + "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), + "summary": Schema.Union([ + Schema.Array(Schema.Struct({ "text": Schema.String, "type": Schema.Literal("summary_text") })) + ]), + "type": Schema.Literal("reasoning"), + "format": Schema.optionalKey(ReasoningFormat), + "signature": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "A signature for the reasoning content, used for verification" + }) + ) + }).annotate({ "description": "An output item containing reasoning" }), + OutputFunctionCallItem, + OutputCustomToolCallItem, + OutputWebSearchCallItem, + OutputFileSearchCallItem, + OutputImageGenerationCallItem, + OutputCodeInterpreterCallItem, + OutputComputerCallItem, + OutputDatetimeItem, + OutputWebSearchServerToolItem, + OutputCodeInterpreterServerToolItem, + OutputFileSearchServerToolItem, + OutputImageGenerationServerToolItem, + OutputBrowserUseServerToolItem, + OutputBashServerToolItem, + OutputTextEditorServerToolItem, + OutputApplyPatchServerToolItem, + OutputWebFetchServerToolItem, + OutputToolSearchServerToolItem, + OutputMemoryServerToolItem, + OutputMcpServerToolItem, + OutputSearchModelsServerToolItem, + OutputFusionServerToolItem, + OutputAdvisorServerToolItem, + OutputSubagentServerToolItem, + OutputFilesServerToolItem, + LocalShellCallItem, + LocalShellCallOutputItem, + ShellCallItem, + ShellCallOutputItem, + McpListToolsItem, + McpApprovalRequestItem, + McpApprovalResponseItem, + McpCallItem, + CustomToolCallItem, + CustomToolCallOutputItem, + CompactionItem, + ContextCompactionItem, + ItemReferenceItem, + AdditionalToolsItem, + AgentMessageItem + ]) + ) +]).annotate({ + "description": "Input for a response request - can be a string or array of items", + "identifier": "Inputs" +}) +export type ImageStreamingResponse = { + readonly "data": + | ImageGenPartialImageEvent + | ImageGenTextChunkEvent + | ImageGenCompletedEvent + | ImageGenStreamErrorEvent } -export const AnthropicWebFetchToolResult = Schema.Struct({ - "caller": AnthropicCaller, - "content": AnthropicWebFetchContent, - "tool_use_id": Schema.String, - "type": Schema.Literal("web_fetch_tool_result") -}).annotate({ "identifier": "AnthropicWebFetchToolResult" }) +export const ImageStreamingResponse = Schema.Struct({ + "data": Schema.Union([ + ImageGenPartialImageEvent, + ImageGenTextChunkEvent, + ImageGenCompletedEvent, + ImageGenStreamErrorEvent + ]) +}).annotate({ "identifier": "ImageStreamingResponse" }) export type MessagesRequest = { readonly "cache_control"?: AnthropicCacheControlDirective readonly "context_management"?: { @@ -15290,6 +15777,7 @@ export type MessagesRequest = { readonly "tools"?: ReadonlyArray< | { readonly "cache_control"?: AnthropicCacheControlDirective + readonly "defer_loading"?: boolean readonly "description"?: string readonly "input_schema": { readonly "properties"?: Schema.Json @@ -15347,6 +15835,7 @@ export type MessagesRequest = { | { readonly "type": string } | AnthropicToolSearchToolBm25 | AnthropicToolSearchToolRegex + | ShellServerTool_OpenRouter > readonly "top_k"?: number readonly "top_p"?: number @@ -15376,866 +15865,275 @@ export const MessagesRequest = Schema.Struct({ Schema.Union([ AnthropicThinkingTurns, Schema.Struct({ "type": Schema.Literal("all") }), - Schema.Literal("all") - ]) - ), - "type": Schema.Literal("clear_thinking_20251015") - }), - Schema.Struct({ - "instructions": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "pause_after_compaction": Schema.optionalKey(Schema.Boolean), - "trigger": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "type": Schema.Literal("input_tokens"), - "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - Schema.Null - ]) - ), - "type": Schema.Literal("compact_20260112") - }) - ], { mode: "oneOf" }))) - }), - [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] - ), - Schema.Null - ])), - "fallbacks": Schema.optionalKey( - Schema.Union([Schema.Array(MessagesFallbackParam), Schema.Null]).annotate({ - "description": - "Fallback models to try if the primary model fails or refuses, in order. Handled by OpenRouter multi-model routing rather than Anthropic server-side fallbacks; cannot be combined with `models`. Each entry accepts only `model`. Maximum of 3 entries." - }) - ), - "max_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "messages": Schema.Union([Schema.Array(MessagesMessageParam), Schema.Null]), - "metadata": Schema.optionalKey( - Schema.Struct({ "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }) - ), - "model": Schema.String, - "models": Schema.optionalKey(Schema.Array(Schema.String)), - "output_config": Schema.optionalKey(MessagesOutputConfig), - "plugins": Schema.optionalKey( - Schema.Array( - Schema.Union([ - AutoRouterPlugin, - AutoBetaRouterPlugin, - ModerationPlugin, - WebSearchPlugin, - WebFetchPlugin, - FileParserPlugin, - ResponseHealingPlugin, - ContextCompressionPlugin, - ParetoRouterPlugin, - FusionPlugin - ], { mode: "oneOf" }) - ).annotate({ "description": "Plugins you want to enable for this request, including their settings." }) - ), - "provider": Schema.optionalKey(ProviderPreferences), - "route": Schema.optionalKey(DeprecatedRoute), - "service_tier": Schema.optionalKey(Schema.String), - "session_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters." - }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) - ), - "speed": Schema.optionalKey( - Schema.suspend((): Schema.Codec => AnthropicSpeed).annotate({ - "description": - "Controls output generation speed. When set to `fast`, uses a higher-speed inference configuration at premium pricing. Defaults to `standard` when omitted." - }) - ), - "stop_sequences": Schema.optionalKey(Schema.Array(Schema.String)), - "stop_server_tools_when": Schema.optionalKey(StopServerToolsWhen), - "stream": Schema.optionalKey(Schema.Boolean), - "system": Schema.optionalKey(Schema.Union([Schema.String, Schema.Array(AnthropicTextBlockParam)])), - "temperature": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "thinking": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "budget_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "display": Schema.optionalKey(AnthropicThinkingDisplay), - "type": Schema.Literal("enabled") - }), - Schema.Struct({ "type": Schema.Literal("disabled") }), - Schema.Struct({ "display": Schema.optionalKey(AnthropicThinkingDisplay), "type": Schema.Literal("adaptive") }) - ], { mode: "oneOf" }) - ), - "tool_choice": Schema.optionalKey( - Schema.Union([ - Schema.Struct({ - "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean), - "type": Schema.Literal("auto") - }), - Schema.Struct({ "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean), "type": Schema.Literal("any") }), - Schema.Struct({ "type": Schema.Literal("none") }), - Schema.Struct({ - "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean), - "name": Schema.String, - "type": Schema.Literal("tool") - }) - ], { mode: "oneOf" }) - ), - "tools": Schema.optionalKey(Schema.Array(Schema.Union([ - Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "description": Schema.optionalKey(Schema.String), - "input_schema": Schema.Struct({ - "properties": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), - "required": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), - "type": Schema.optionalKey(Schema.String) - }), - "name": Schema.String, - "type": Schema.optionalKey(Schema.Literal("custom")) - }), - Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "name": Schema.Literal("bash"), - "type": Schema.Literal("bash_20250124") - }), - Schema.Struct({ - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "name": Schema.Literal("str_replace_editor"), - "type": Schema.Literal("text_editor_20250124") - }), - Schema.Struct({ - "allowed_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), - "blocked_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "name": Schema.Literal("web_search"), - "type": Schema.Literal("web_search_20250305"), - "user_location": Schema.optionalKey(AnthropicWebSearchToolUserLocation) - }), - Schema.Struct({ - "allowed_callers": Schema.optionalKey(AnthropicAllowedCallers), - "allowed_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), - "blocked_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "max_uses": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "name": Schema.Literal("web_search"), - "type": Schema.Literal("web_search_20260209"), - "user_location": Schema.optionalKey(AnthropicWebSearchToolUserLocation) - }), - Schema.Struct({ - "allowed_callers": Schema.optionalKey(AnthropicAllowedCallers), - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "caching": Schema.optionalKey(Schema.Union([AnthropicCacheControlDirective, Schema.Null])), - "defer_loading": Schema.optionalKey(Schema.Boolean), - "max_uses": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "model": Schema.String, - "name": Schema.Literal("advisor"), - "type": Schema.Literal("advisor_20260301") - }), - BashServerTool, - DatetimeServerTool, - ImageGenerationServerTool_OpenRouter, - MessagesSearchModelsServerTool, - WebFetchServerTool, - OpenRouterWebSearchServerTool, - Schema.Struct({ "type": Schema.String }), - AnthropicToolSearchToolBm25, - AnthropicToolSearchToolRegex - ]))), - "top_k": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "top_p": Schema.optionalKey( - Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) - ), - "trace": Schema.optionalKey(TraceConfig), - "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 256 characters." - }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) - ) -}).annotate({ "description": "Request schema for Anthropic Messages API endpoint", "identifier": "MessagesRequest" }) -export type ImageGenerationUsage = { - readonly "cache_creation"?: AnthropicCacheCreation - readonly "completion_tokens": number - readonly "completion_tokens_details"?: Union_6 - readonly "cost"?: number | null - readonly "cost_details"?: CostDetails - readonly "is_byok"?: boolean - readonly "iterations"?: Union_7 - readonly "prompt_tokens": number - readonly "prompt_tokens_details"?: Union_8 - readonly "server_tool_use"?: Union_9 - readonly "service_tier"?: string | null - readonly "speed"?: AnthropicSpeed - readonly "total_tokens": number -} -export const ImageGenerationUsage = Schema.Struct({ - "cache_creation": Schema.optionalKey(AnthropicCacheCreation), - "completion_tokens": Schema.Number.annotate({ "description": "The tokens generated" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "completion_tokens_details": Schema.optionalKey(Union_6), - "cost": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Cost of the completion", "format": "double" }) - ), - "cost_details": Schema.optionalKey(CostDetails), - "is_byok": Schema.optionalKey( - Schema.Boolean.annotate({ "description": "Whether a request was made using a Bring Your Own Key configuration" }) - ), - "iterations": Schema.optionalKey(Union_7), - "prompt_tokens": Schema.Number.annotate({ "description": "Including images, input audio, and tools if any" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "prompt_tokens_details": Schema.optionalKey(Union_8), - "server_tool_use": Schema.optionalKey(Union_9), - "service_tier": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The service tier used by the upstream provider for this request" - }) - ), - "speed": Schema.optionalKey(AnthropicSpeed), - "total_tokens": Schema.Number.annotate({ "description": "Sum of the above two fields" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ - "description": "Token and cost usage for the image generation request, when available", - "identifier": "ImageGenerationUsage" -}) -export type ModelsListResponse = { - readonly "data": ModelsListResponseData - readonly "links": { readonly "next": string | null } - readonly "total_count": number -} -export const ModelsListResponse = Schema.Struct({ - "data": ModelsListResponseData, - "links": Schema.Struct({ - "next": Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "URL for the next page of results, or null if this is the last page" - }) - }).annotate({ "description": "Pagination links" }), - "total_count": Schema.Number.annotate({ "description": "Total number of models matching the query" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ) -}).annotate({ "description": "List of available models", "identifier": "ModelsListResponse" }) -export type ChatChoice = { - readonly "finish_reason": ChatFinishReasonEnum - readonly "index": number - readonly "logprobs"?: ChatTokenLogprobs - readonly "message": ChatAssistantMessage -} -export const ChatChoice = Schema.Struct({ - "finish_reason": ChatFinishReasonEnum, - "index": Schema.Number.annotate({ "description": "Choice index" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "logprobs": Schema.optionalKey(ChatTokenLogprobs), - "message": ChatAssistantMessage -}).annotate({ "description": "Chat completion choice", "identifier": "ChatChoice" }) -export type ChatMessages = - | ChatSystemMessage - | ChatUserMessage - | ChatDeveloperMessage - | ChatAssistantMessage - | ChatToolMessage -export const ChatMessages = Schema.Union([ - ChatSystemMessage, - ChatUserMessage, - ChatDeveloperMessage, - ChatAssistantMessage, - ChatToolMessage -], { mode: "oneOf" }).annotate({ - "description": "Chat completion message with role-based discrimination", - "identifier": "ChatMessages" -}) -export type ChatStreamChoice = { - readonly "delta": ChatStreamDelta - readonly "finish_reason"?: ChatFinishReasonEnum - readonly "index": number - readonly "logprobs"?: ChatTokenLogprobs -} -export const ChatStreamChoice = Schema.Struct({ - "delta": ChatStreamDelta, - "finish_reason": Schema.optionalKey(ChatFinishReasonEnum), - "index": Schema.Number.annotate({ "description": "Choice index" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "logprobs": Schema.optionalKey(ChatTokenLogprobs) -}).annotate({ "description": "Streaming completion choice chunk", "identifier": "ChatStreamChoice" }) -export type Arrays_8 = ReadonlyArray< - | ReasoningItem - | EasyInputMessage - | InputMessageItem - | FunctionCallItem - | FunctionCallOutputItem - | ApplyPatchCallItem - | ApplyPatchCallOutputItem - | { - readonly "content": ReadonlyArray< - { - readonly "annotations"?: ReadonlyArray< - { - readonly "file_id": string - readonly "filename": string - readonly "index": number - readonly "type": "file_citation" - } | { - readonly "content"?: string - readonly "end_index": number - readonly "start_index": number - readonly "title": string - readonly "type": never - readonly "url": string - readonly "file_id": string - readonly "filename": string - readonly "index": number - } | { - readonly "file_id": string - readonly "index": number - readonly "type": never - readonly "filename": string - } | { - readonly "file_id": string - readonly "filename": string - readonly "index": number - readonly "type": never - readonly "content"?: string - readonly "end_index": number - readonly "start_index": number - readonly "title": string - readonly "url": string - } | { - readonly "content"?: string - readonly "end_index": number - readonly "start_index": number - readonly "title": string - readonly "type": "url_citation" - readonly "url": string - } | { - readonly "file_id": string - readonly "index": number - readonly "type": never - readonly "content"?: string - readonly "end_index": number - readonly "start_index": number - readonly "title": string - readonly "url": string - } | { - readonly "file_id": string - readonly "filename": string - readonly "index": number - readonly "type": never - } | { - readonly "content"?: string - readonly "end_index": number - readonly "start_index": number - readonly "title": string - readonly "type": never - readonly "url": string - readonly "file_id": string - readonly "index": number - } | { readonly "file_id": string; readonly "index": number; readonly "type": "file_path" } - > - readonly "logprobs"?: ReadonlyArray< - { - readonly "bytes": ReadonlyArray - readonly "logprob": number - readonly "token": string - readonly "top_logprobs": ReadonlyArray< - { readonly "bytes": ReadonlyArray; readonly "logprob": number; readonly "token": string } - > - } - > - readonly "text": string - readonly "type": "output_text" - } | { - readonly "refusal": string - readonly "type": never - readonly "annotations"?: ReadonlyArray - readonly "logprobs"?: ReadonlyArray< - { - readonly "bytes": ReadonlyArray - readonly "logprob": number - readonly "token": string - readonly "top_logprobs": ReadonlyArray< - { readonly "bytes": ReadonlyArray; readonly "logprob": number; readonly "token": string } - > - } - > - readonly "text": string - } | { - readonly "annotations"?: ReadonlyArray - readonly "logprobs"?: ReadonlyArray< - { - readonly "bytes": ReadonlyArray - readonly "logprob": number - readonly "token": string - readonly "top_logprobs": ReadonlyArray< - { readonly "bytes": ReadonlyArray; readonly "logprob": number; readonly "token": string } - > - } - > - readonly "text": string - readonly "type": never - readonly "refusal": string - } | { readonly "refusal": string; readonly "type": "refusal" } - > - readonly "id": string - readonly "phase"?: "commentary" | "final_answer" | null - readonly "role": "assistant" - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "type": "message" - } - | { - readonly "content"?: ReadonlyArray<{ readonly "text": string; readonly "type": "reasoning_text" }> - readonly "encrypted_content"?: string | null - readonly "id": string - readonly "status"?: "completed" | "incomplete" | "in_progress" - readonly "summary": ReadonlyArray<{ readonly "text": string; readonly "type": "summary_text" }> - readonly "type": "reasoning" - readonly "format"?: ReasoningFormat - readonly "signature"?: string | null - } - | OutputFunctionCallItem - | OutputCustomToolCallItem - | OutputWebSearchCallItem - | OutputFileSearchCallItem - | OutputImageGenerationCallItem - | OutputCodeInterpreterCallItem - | OutputComputerCallItem - | OutputDatetimeItem - | OutputWebSearchServerToolItem - | OutputCodeInterpreterServerToolItem - | OutputFileSearchServerToolItem - | OutputImageGenerationServerToolItem - | OutputBrowserUseServerToolItem - | OutputBashServerToolItem - | OutputTextEditorServerToolItem - | OutputApplyPatchServerToolItem - | OutputWebFetchServerToolItem - | OutputToolSearchServerToolItem - | OutputMemoryServerToolItem - | OutputMcpServerToolItem - | OutputSearchModelsServerToolItem - | OutputFusionServerToolItem - | OutputAdvisorServerToolItem - | OutputSubagentServerToolItem - | OutputFilesServerToolItem - | LocalShellCallItem - | LocalShellCallOutputItem - | ShellCallItem - | ShellCallOutputItem - | McpListToolsItem - | McpApprovalRequestItem - | McpApprovalResponseItem - | McpCallItem - | CustomToolCallItem - | CustomToolCallOutputItem - | CompactionItem - | ContextCompactionItem - | ItemReferenceItem - | AdditionalToolsItem - | AgentMessageItem -> -export const Arrays_8 = Schema.Array( - Schema.Union([ - ReasoningItem, - EasyInputMessage, - InputMessageItem, - FunctionCallItem, - FunctionCallOutputItem, - ApplyPatchCallItem, - ApplyPatchCallOutputItem, - Schema.Struct({ - "content": Schema.Union([Schema.Array(Schema.Union([ - Schema.Union([ - Schema.Struct({ - "annotations": Schema.optionalKey( - Schema.Array( - Schema.Union([ - Schema.Union([ - Schema.Struct({ - "file_id": Schema.String, - "filename": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("file_citation") - }), - Schema.Struct({ - "content": Schema.optionalKey(Schema.String), - "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "title": Schema.String, - "type": Schema.Never, - "url": Schema.String, - "file_id": Schema.String, - "filename": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - Schema.Struct({ - "file_id": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Never, - "filename": Schema.String - }) - ]), - Schema.Union([ - Schema.Struct({ - "file_id": Schema.String, - "filename": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Never, - "content": Schema.optionalKey(Schema.String), - "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "title": Schema.String, - "url": Schema.String - }), - Schema.Struct({ - "content": Schema.optionalKey(Schema.String), - "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "title": Schema.String, - "type": Schema.Literal("url_citation"), - "url": Schema.String - }), - Schema.Struct({ - "file_id": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Never, - "content": Schema.optionalKey(Schema.String), - "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "title": Schema.String, - "url": Schema.String - }) - ]), - Schema.Union([ - Schema.Struct({ - "file_id": Schema.String, - "filename": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Never - }), - Schema.Struct({ - "content": Schema.optionalKey(Schema.String), - "end_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "start_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "title": Schema.String, - "type": Schema.Never, - "url": Schema.String, - "file_id": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - Schema.Struct({ - "file_id": Schema.String, - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("file_path") - }) - ]) - ]) - ) - ), - "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ - "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "token": Schema.String, - "top_logprobs": Schema.Array( - Schema.Struct({ - "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "token": Schema.String - }) - ) - }))), - "text": Schema.String, - "type": Schema.Literal("output_text") - }), - Schema.Struct({ - "refusal": Schema.String, - "type": Schema.Never, - "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), - "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ - "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "token": Schema.String, - "top_logprobs": Schema.Array( - Schema.Struct({ - "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "token": Schema.String - }) - ) - }))), - "text": Schema.String - }) - ]), - Schema.Union([ - Schema.Struct({ - "annotations": Schema.optionalKey(Schema.Array(OpenAIResponsesAnnotation)), - "logprobs": Schema.optionalKey(Schema.Array(Schema.Struct({ - "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "token": Schema.String, - "top_logprobs": Schema.Array( - Schema.Struct({ - "bytes": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "logprob": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "token": Schema.String - }) - ) - }))), - "text": Schema.String, - "type": Schema.Never, - "refusal": Schema.String - }), - Schema.Struct({ "refusal": Schema.String, "type": Schema.Literal("refusal") }) - ]) - ]))]), - "id": Schema.String, - "phase": Schema.optionalKey( - Schema.Union([Schema.Literal("commentary"), Schema.Literal("final_answer"), Schema.Null]).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." - }) - ), - "role": Schema.Literal("assistant"), - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "type": Schema.Literal("message") - }).annotate({ "description": "An output message item" }), - Schema.Struct({ - "content": Schema.optionalKey( - Schema.Union([Schema.Array(Schema.Struct({ "text": Schema.String, "type": Schema.Literal("reasoning_text") }))]) - ), - "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "id": Schema.String, - "status": Schema.optionalKey(Schema.Literals(["completed", "incomplete", "in_progress"])), - "summary": Schema.Union([ - Schema.Array(Schema.Struct({ "text": Schema.String, "type": Schema.Literal("summary_text") })) - ]), - "type": Schema.Literal("reasoning"), - "format": Schema.optionalKey(ReasoningFormat), - "signature": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "A signature for the reasoning content, used for verification" - }) - ) - }).annotate({ "description": "An output item containing reasoning" }), - OutputFunctionCallItem, - OutputCustomToolCallItem, - OutputWebSearchCallItem, - OutputFileSearchCallItem, - OutputImageGenerationCallItem, - OutputCodeInterpreterCallItem, - OutputComputerCallItem, - OutputDatetimeItem, - OutputWebSearchServerToolItem, - OutputCodeInterpreterServerToolItem, - OutputFileSearchServerToolItem, - OutputImageGenerationServerToolItem, - OutputBrowserUseServerToolItem, - OutputBashServerToolItem, - OutputTextEditorServerToolItem, - OutputApplyPatchServerToolItem, - OutputWebFetchServerToolItem, - OutputToolSearchServerToolItem, - OutputMemoryServerToolItem, - OutputMcpServerToolItem, - OutputSearchModelsServerToolItem, - OutputFusionServerToolItem, - OutputAdvisorServerToolItem, - OutputSubagentServerToolItem, - OutputFilesServerToolItem, - LocalShellCallItem, - LocalShellCallOutputItem, - ShellCallItem, - ShellCallOutputItem, - McpListToolsItem, - McpApprovalRequestItem, - McpApprovalResponseItem, - McpCallItem, - CustomToolCallItem, - CustomToolCallOutputItem, - CompactionItem, - ContextCompactionItem, - ItemReferenceItem, - AdditionalToolsItem, - AgentMessageItem - ]) -) -export type BaseResponsesResult = { - readonly "background"?: boolean | null - readonly "completed_at": number | null - readonly "created_at": number - readonly "error": ResponsesErrorField - readonly "frequency_penalty": number | null - readonly "id": string - readonly "incomplete_details": IncompleteDetails - readonly "instructions": BaseInputs - readonly "max_output_tokens"?: number | null - readonly "max_tool_calls"?: number | null - readonly "metadata": RequestMetadata - readonly "model": string - readonly "object": "response" - readonly "output": ReadonlyArray< - | OutputMessage - | OutputItemReasoning - | OutputItemFunctionCall - | OutputItemCustomToolCall - | OutputItemWebSearchCall - | OutputItemFileSearchCall - | OutputItemImageGenerationCall - | OutputItemApplyPatchCall - > - readonly "output_text"?: string - readonly "parallel_tool_calls": boolean - readonly "presence_penalty": number | null - readonly "previous_response_id"?: string | null - readonly "prompt"?: StoredPromptTemplate - readonly "prompt_cache_key"?: string | null - readonly "prompt_cache_options"?: PromptCacheOptions - readonly "reasoning"?: BaseReasoningConfig - readonly "safety_identifier"?: string | null - readonly "service_tier"?: ServiceTier - readonly "status": OpenAIResponsesResponseStatus - readonly "store"?: boolean - readonly "temperature": number | null - readonly "text"?: TextConfig - readonly "tool_choice": OpenAIResponsesToolChoice - readonly "tools": ReadonlyArray< - | { - readonly "description"?: string | null - readonly "name": string - readonly "parameters": { readonly [x: string]: Schema.Json } | null - readonly "strict"?: boolean | null - readonly "type": "function" - } - | Preview_WebSearchServerTool - | Preview_20250311_WebSearchServerTool - | Legacy_WebSearchServerTool - | WebSearchServerTool - | FileSearchServerTool - | ComputerUseServerTool - | CodeInterpreterServerTool - | McpServerTool - | ImageGenerationServerTool - | CodexLocalShellTool - | ShellServerTool - | ApplyPatchServerTool - | CustomTool - | NamespaceTool - > - readonly "top_logprobs"?: number - readonly "top_p": number | null - readonly "truncation"?: Truncation - readonly "usage"?: OpenAIResponsesUsage - readonly "user"?: string | null -} -export const BaseResponsesResult = Schema.Struct({ - "background": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "completed_at": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]), - "created_at": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "error": ResponsesErrorField, - "frequency_penalty": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Literal("all") + ]) + ), + "type": Schema.Literal("clear_thinking_20251015") + }), + Schema.Struct({ + "instructions": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "pause_after_compaction": Schema.optionalKey(Schema.Boolean), + "trigger": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "type": Schema.Literal("input_tokens"), + "value": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + }), + Schema.Null + ]) + ), + "type": Schema.Literal("compact_20260112") + }) + ], { mode: "oneOf" }))) + }), + [Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))] + ), Schema.Null - ]).annotate({ "format": "double" }), - "id": Schema.String, - "incomplete_details": IncompleteDetails, - "instructions": BaseInputs, - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ])), + "fallbacks": Schema.optionalKey( + Schema.Union([Schema.Array(MessagesFallbackParam), Schema.Null]).annotate({ + "description": + "Fallback models to try if the primary model fails or refuses, in order. Handled by OpenRouter multi-model routing rather than Anthropic server-side fallbacks; cannot be combined with `models`. Each entry accepts only `model`. Maximum of 3 entries." + }) ), - "max_tool_calls": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + "max_tokens": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "messages": Schema.Union([Schema.Array(MessagesMessageParam), Schema.Null]), + "metadata": Schema.optionalKey( + Schema.Struct({ "user_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) }) ), - "metadata": RequestMetadata, "model": Schema.String, - "object": Schema.Literal("response"), - "output": Schema.Array( + "models": Schema.optionalKey(Schema.Array(Schema.String)), + "output_config": Schema.optionalKey(MessagesOutputConfig), + "plugins": Schema.optionalKey( + Schema.Array( + Schema.Union([ + AutoRouterPlugin, + AutoBetaRouterPlugin, + ModerationPlugin, + WebSearchPlugin, + WebFetchPlugin, + FileParserPlugin, + ResponseHealingPlugin, + ContextCompressionPlugin, + ParetoRouterPlugin, + FusionPlugin + ], { mode: "oneOf" }) + ).annotate({ "description": "Plugins you want to enable for this request, including their settings." }) + ), + "provider": Schema.optionalKey(ProviderPreferences), + "route": Schema.optionalKey(DeprecatedRoute), + "service_tier": Schema.optionalKey(Schema.String), + "session_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters." + }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) + ), + "speed": Schema.optionalKey( + Schema.suspend((): Schema.Codec => AnthropicSpeed).annotate({ + "description": + "Controls output generation speed. When set to `fast`, uses a higher-speed inference configuration at premium pricing. Defaults to `standard` when omitted." + }) + ), + "stop_sequences": Schema.optionalKey(Schema.Array(Schema.String)), + "stop_server_tools_when": Schema.optionalKey(StopServerToolsWhen), + "stream": Schema.optionalKey(Schema.Boolean), + "system": Schema.optionalKey(Schema.Union([Schema.String, Schema.Array(AnthropicTextBlockParam)])), + "temperature": Schema.optionalKey( + Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "thinking": Schema.optionalKey( Schema.Union([ - OutputMessage, - OutputItemReasoning, - OutputItemFunctionCall, - OutputItemCustomToolCall, - OutputItemWebSearchCall, - OutputItemFileSearchCall, - OutputItemImageGenerationCall, - OutputItemApplyPatchCall + Schema.Struct({ + "budget_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "display": Schema.optionalKey(AnthropicThinkingDisplay), + "type": Schema.Literal("enabled") + }), + Schema.Struct({ "type": Schema.Literal("disabled") }), + Schema.Struct({ "display": Schema.optionalKey(AnthropicThinkingDisplay), "type": Schema.Literal("adaptive") }) ], { mode: "oneOf" }) ), - "output_text": Schema.optionalKey(Schema.String), - "parallel_tool_calls": Schema.Boolean, - "presence_penalty": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "format": "double" }), - "previous_response_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "prompt": Schema.optionalKey(StoredPromptTemplate), - "prompt_cache_key": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "prompt_cache_options": Schema.optionalKey(PromptCacheOptions), - "reasoning": Schema.optionalKey(BaseReasoningConfig), - "safety_identifier": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "service_tier": Schema.optionalKey(ServiceTier), - "status": OpenAIResponsesResponseStatus, - "store": Schema.optionalKey(Schema.Boolean), - "temperature": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "format": "double" }), - "text": Schema.optionalKey(TextConfig), - "tool_choice": OpenAIResponsesToolChoice, - "tools": Schema.Array(Schema.Union([ + "tool_choice": Schema.optionalKey( + Schema.Union([ + Schema.Struct({ + "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean), + "type": Schema.Literal("auto") + }), + Schema.Struct({ "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean), "type": Schema.Literal("any") }), + Schema.Struct({ "type": Schema.Literal("none") }), + Schema.Struct({ + "disable_parallel_tool_use": Schema.optionalKey(Schema.Boolean), + "name": Schema.String, + "type": Schema.Literal("tool") + }) + ], { mode: "oneOf" }) + ), + "tools": Schema.optionalKey(Schema.Array(Schema.Union([ Schema.Struct({ - "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "defer_loading": Schema.optionalKey(Schema.Boolean), + "description": Schema.optionalKey(Schema.String), + "input_schema": Schema.Struct({ + "properties": Schema.optionalKey(Schema.Json.annotate({ "expected": "JSON value" })), + "required": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), + "type": Schema.optionalKey(Schema.String) + }), "name": Schema.String, - "parameters": Schema.Union([ - Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), - Schema.Null - ]), - "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "type": Schema.Literal("function") - }).annotate({ "description": "Function tool definition" }), - Preview_WebSearchServerTool, - Preview_20250311_WebSearchServerTool, - Legacy_WebSearchServerTool, - WebSearchServerTool, - FileSearchServerTool, - ComputerUseServerTool, - CodeInterpreterServerTool, - McpServerTool, - ImageGenerationServerTool, - CodexLocalShellTool, - ShellServerTool, - ApplyPatchServerTool, - CustomTool, - NamespaceTool - ], { mode: "oneOf" })), - "top_logprobs": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "top_p": Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "format": "double" }), - "truncation": Schema.optionalKey(Truncation), - "usage": Schema.optionalKey(OpenAIResponsesUsage), - "user": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])) -}).annotate({ "identifier": "BaseResponsesResult" }) + "type": Schema.optionalKey(Schema.Literal("custom")) + }), + Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "name": Schema.Literal("bash"), + "type": Schema.Literal("bash_20250124") + }), + Schema.Struct({ + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "name": Schema.Literal("str_replace_editor"), + "type": Schema.Literal("text_editor_20250124") + }), + Schema.Struct({ + "allowed_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), + "blocked_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "max_uses": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ), + "name": Schema.Literal("web_search"), + "type": Schema.Literal("web_search_20250305"), + "user_location": Schema.optionalKey(AnthropicWebSearchToolUserLocation) + }), + Schema.Struct({ + "allowed_callers": Schema.optionalKey(AnthropicAllowedCallers), + "allowed_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), + "blocked_domains": Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])), + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "max_uses": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ), + "name": Schema.Literal("web_search"), + "type": Schema.Literal("web_search_20260209"), + "user_location": Schema.optionalKey(AnthropicWebSearchToolUserLocation) + }), + Schema.Struct({ + "allowed_callers": Schema.optionalKey(AnthropicAllowedCallers), + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "caching": Schema.optionalKey(Schema.Union([AnthropicCacheControlDirective, Schema.Null])), + "defer_loading": Schema.optionalKey(Schema.Boolean), + "max_uses": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "model": Schema.String, + "name": Schema.Literal("advisor"), + "type": Schema.Literal("advisor_20260301") + }), + BashServerTool, + DatetimeServerTool, + ImageGenerationServerTool_OpenRouter, + MessagesSearchModelsServerTool, + WebFetchServerTool, + OpenRouterWebSearchServerTool, + Schema.Struct({ "type": Schema.String }), + AnthropicToolSearchToolBm25, + AnthropicToolSearchToolRegex, + ShellServerTool_OpenRouter + ]))), + "top_k": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "top_p": Schema.optionalKey( + Schema.Number.annotate({ "format": "double" }).check(Schema.isFinite().annotate({ "expected": "a finite number" })) + ), + "trace": Schema.optionalKey(TraceConfig), + "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 256 characters." + }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) + ) +}).annotate({ "description": "Request schema for Anthropic Messages API endpoint", "identifier": "MessagesRequest" }) +export type ORAnthropicContentBlock = + | AnthropicTextBlock + | AnthropicToolUseBlock + | AnthropicThinkingBlock + | AnthropicRedactedThinkingBlock + | ORAnthropicServerToolUseBlock + | AnthropicWebSearchToolResult + | AnthropicWebFetchToolResult + | AnthropicCodeExecutionToolResult + | AnthropicBashCodeExecutionToolResult + | AnthropicTextEditorCodeExecutionToolResult + | AnthropicToolSearchToolResult + | AnthropicContainerUpload + | AnthropicCompactionBlock + | AnthropicAdvisorToolResult + | ORAnthropicShellToolResult + | ORAnthropicBashToolResult +export const ORAnthropicContentBlock = Schema.Union([ + AnthropicTextBlock, + AnthropicToolUseBlock, + AnthropicThinkingBlock, + AnthropicRedactedThinkingBlock, + ORAnthropicServerToolUseBlock, + AnthropicWebSearchToolResult, + AnthropicWebFetchToolResult, + AnthropicCodeExecutionToolResult, + AnthropicBashCodeExecutionToolResult, + AnthropicTextEditorCodeExecutionToolResult, + AnthropicToolSearchToolResult, + AnthropicContainerUpload, + AnthropicCompactionBlock, + AnthropicAdvisorToolResult, + ORAnthropicShellToolResult, + ORAnthropicBashToolResult +], { mode: "oneOf" }).annotate({ "identifier": "ORAnthropicContentBlock" }) +export type MessagesContentBlockStartEvent = { + readonly "content_block": + | AnthropicTextBlock + | AnthropicToolUseBlock + | AnthropicThinkingBlock + | AnthropicRedactedThinkingBlock + | ORAnthropicServerToolUseBlock + | AnthropicWebSearchToolResult + | AnthropicWebFetchToolResult + | AnthropicCodeExecutionToolResult + | AnthropicBashCodeExecutionToolResult + | AnthropicTextEditorCodeExecutionToolResult + | AnthropicToolSearchToolResult + | AnthropicContainerUpload + | AnthropicCompactionBlock + | AnthropicAdvisorToolResult + | ORAnthropicShellToolResult + | ORAnthropicBashToolResult + | { readonly "content": string | null; readonly "encrypted_content"?: string | null; readonly "type": "compaction" } + readonly "index": number + readonly "type": "content_block_start" +} +export const MessagesContentBlockStartEvent = Schema.Struct({ + "content_block": Schema.Union([ + AnthropicTextBlock, + AnthropicToolUseBlock, + AnthropicThinkingBlock, + AnthropicRedactedThinkingBlock, + ORAnthropicServerToolUseBlock, + AnthropicWebSearchToolResult, + AnthropicWebFetchToolResult, + AnthropicCodeExecutionToolResult, + AnthropicBashCodeExecutionToolResult, + AnthropicTextEditorCodeExecutionToolResult, + AnthropicToolSearchToolResult, + AnthropicContainerUpload, + AnthropicCompactionBlock, + AnthropicAdvisorToolResult, + ORAnthropicShellToolResult, + ORAnthropicBashToolResult, + Schema.Struct({ + "content": Schema.Union([Schema.String, Schema.Null]), + "encrypted_content": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "type": Schema.Literal("compaction") + }) + ]), + "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("content_block_start") +}).annotate({ + "description": "Event sent when a new content block starts", + "identifier": "MessagesContentBlockStartEvent" +}) export type OpenResponsesResult = { readonly "background"?: boolean | null readonly "completed_at": number | null @@ -20163,12 +20061,10 @@ export const OpenResponsesResult = Schema.Struct({ "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." }) ), - "failure_reason": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion." - }) - ), + "failure_reason": Schema.optionalKey(Schema.String.annotate({ + "description": + "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching." + })), "id": Schema.String, "responses": Schema.optionalKey( Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })) @@ -20180,7 +20076,7 @@ export const OpenResponsesResult = Schema.Struct({ "sources": Schema.optionalKey( Schema.Array(FusionSource).annotate({ "description": - "Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." + "Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." }) ), "status": Schema.Union([ @@ -20839,12 +20735,10 @@ export const OpenResponsesResult = Schema.Struct({ "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." }) ), - "failure_reason": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion." - }) - ), + "failure_reason": Schema.optionalKey(Schema.String.annotate({ + "description": + "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching." + })), "id": Schema.String, "responses": Schema.optionalKey( Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })) @@ -20856,7 +20750,7 @@ export const OpenResponsesResult = Schema.Struct({ "sources": Schema.optionalKey( Schema.Array(FusionSource).annotate({ "description": - "Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." + "Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." }) ), "status": Schema.Union([ @@ -21601,12 +21495,10 @@ export const OpenResponsesResult = Schema.Struct({ "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." }) ), - "failure_reason": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion." - }) - ), + "failure_reason": Schema.optionalKey(Schema.String.annotate({ + "description": + "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching." + })), "id": Schema.optionalKey(Schema.String), "responses": Schema.optionalKey( Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })) @@ -21618,7 +21510,7 @@ export const OpenResponsesResult = Schema.Struct({ "sources": Schema.optionalKey( Schema.Array(FusionSource).annotate({ "description": - "Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." + "Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." }) ), "status": Schema.Union([ @@ -22307,12 +22199,10 @@ export const OpenResponsesResult = Schema.Struct({ "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." }) ), - "failure_reason": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion." - }) - ), + "failure_reason": Schema.optionalKey(Schema.String.annotate({ + "description": + "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching." + })), "id": Schema.optionalKey(Schema.String), "responses": Schema.optionalKey( Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })) @@ -22324,7 +22214,7 @@ export const OpenResponsesResult = Schema.Struct({ "sources": Schema.optionalKey( Schema.Array(FusionSource).annotate({ "description": - "Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." + "Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." }) ), "status": ToolCallStatus, @@ -23198,12 +23088,10 @@ export const OpenResponsesResult = Schema.Struct({ "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." }) ), - "failure_reason": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion." - }) - ), + "failure_reason": Schema.optionalKey(Schema.String.annotate({ + "description": + "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching." + })), "id": Schema.String, "responses": Schema.optionalKey( Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })) @@ -23215,7 +23103,7 @@ export const OpenResponsesResult = Schema.Struct({ "sources": Schema.optionalKey( Schema.Array(FusionSource).annotate({ "description": - "Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." + "Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." }) ), "status": Schema.Union([Schema.Literal("in_progress"), Schema.Literal("completed")]), @@ -23757,12 +23645,10 @@ export const OpenResponsesResult = Schema.Struct({ "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." }) ), - "failure_reason": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion." - }) - ), + "failure_reason": Schema.optionalKey(Schema.String.annotate({ + "description": + "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching." + })), "id": Schema.String, "responses": Schema.optionalKey( Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })) @@ -23774,7 +23660,7 @@ export const OpenResponsesResult = Schema.Struct({ "sources": Schema.optionalKey( Schema.Array(FusionSource).annotate({ "description": - "Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." + "Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." }) ), "status": Schema.Union([Schema.Literal("in_progress"), Schema.Literal("completed")]), @@ -24241,12 +24127,10 @@ export const OpenResponsesResult = Schema.Struct({ "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." }) ), - "failure_reason": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion." - }) - ), + "failure_reason": Schema.optionalKey(Schema.String.annotate({ + "description": + "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching." + })), "id": Schema.String, "responses": Schema.optionalKey( Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })) @@ -24258,7 +24142,7 @@ export const OpenResponsesResult = Schema.Struct({ "sources": Schema.optionalKey( Schema.Array(FusionSource).annotate({ "description": - "Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." + "Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." }) ), "status": Schema.Union([Schema.Literal("in_progress"), Schema.Literal("completed")]), @@ -24950,12 +24834,10 @@ export const OpenResponsesResult = Schema.Struct({ "Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel." }) ), - "failure_reason": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion." - }) - ), + "failure_reason": Schema.optionalKey(Schema.String.annotate({ + "description": + "Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching." + })), "id": Schema.String, "responses": Schema.optionalKey( Schema.Array(Schema.Struct({ "content": Schema.optionalKey(Schema.String), "model": Schema.String })) @@ -24967,7 +24849,7 @@ export const OpenResponsesResult = Schema.Struct({ "sources": Schema.optionalKey( Schema.Array(FusionSource).annotate({ "description": - "Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." + "Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source." }) ), "status": Schema.Union([Schema.Literal("in_progress"), Schema.Literal("completed")]), @@ -25230,221 +25112,74 @@ export const OpenResponsesResult = Schema.Struct({ ), "cached_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) }), - "output_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "output_tokens_details": Schema.Struct({ - "reasoning_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) - }), - "total_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "cost": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "description": "Cost of the completion", "format": "double" }) - ), - "cost_details": Schema.optionalKey(Schema.Struct({ - "upstream_inference_cost": Schema.optionalKey( - Schema.Union([ - Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), - Schema.Null - ]).annotate({ "format": "double" }) - ), - "upstream_inference_input_cost": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ), - "upstream_inference_output_cost": Schema.Number.annotate({ "format": "double" }).check( - Schema.isFinite().annotate({ "expected": "a finite number" }) - ) - })), - "is_byok": Schema.optionalKey( - Schema.Boolean.annotate({ - "description": "Whether a request was made using a Bring Your Own Key configuration" - }) - ), - "server_tool_use_details": Schema.optionalKey(ServerToolUseDetails) - })]).annotate({ "description": "Token usage information for the response" }) - ), - "user": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "error_type": Schema.optionalKey(ApiErrorType), - "openrouter_metadata": Schema.optionalKey(OpenRouterMetadata) -}).annotate({ - "description": "Complete non-streaming response from the Responses API", - "identifier": "OpenResponsesResult" -}) -export type StreamEventsResponseOutputItemAdded = { - readonly "item": OutputItems - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.output_item.added" -} -export const StreamEventsResponseOutputItemAdded = Schema.Struct({ - "item": OutputItems, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.output_item.added") -}).annotate({ - "description": "Event emitted when a new output item is added to the response", - "identifier": "StreamEventsResponseOutputItemAdded" -}) -export type StreamEventsResponseOutputItemDone = { - readonly "item": OutputItems - readonly "output_index": number - readonly "sequence_number": number - readonly "type": "response.output_item.done" -} -export const StreamEventsResponseOutputItemDone = Schema.Struct({ - "item": OutputItems, - "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.output_item.done") -}).annotate({ - "description": "Event emitted when an output item is complete", - "identifier": "StreamEventsResponseOutputItemDone" -}) -export type MessagesContentBlockStartEvent = { - readonly "content_block": - | AnthropicTextBlock - | AnthropicToolUseBlock - | AnthropicThinkingBlock - | AnthropicRedactedThinkingBlock - | ORAnthropicServerToolUseBlock - | AnthropicWebSearchToolResult - | AnthropicWebFetchToolResult - | AnthropicCodeExecutionToolResult - | AnthropicBashCodeExecutionToolResult - | AnthropicTextEditorCodeExecutionToolResult - | AnthropicToolSearchToolResult - | AnthropicContainerUpload - | AnthropicCompactionBlock - | AnthropicAdvisorToolResult - | { readonly "content": string | null; readonly "type": "compaction" } - readonly "index": number - readonly "type": "content_block_start" -} -export const MessagesContentBlockStartEvent = Schema.Struct({ - "content_block": Schema.Union([ - AnthropicTextBlock, - AnthropicToolUseBlock, - AnthropicThinkingBlock, - AnthropicRedactedThinkingBlock, - ORAnthropicServerToolUseBlock, - AnthropicWebSearchToolResult, - AnthropicWebFetchToolResult, - AnthropicCodeExecutionToolResult, - AnthropicBashCodeExecutionToolResult, - AnthropicTextEditorCodeExecutionToolResult, - AnthropicToolSearchToolResult, - AnthropicContainerUpload, - AnthropicCompactionBlock, - AnthropicAdvisorToolResult, - Schema.Struct({ "content": Schema.Union([Schema.String, Schema.Null]), "type": Schema.Literal("compaction") }) - ]), - "index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("content_block_start") -}).annotate({ - "description": "Event sent when a new content block starts", - "identifier": "MessagesContentBlockStartEvent" -}) -export type ORAnthropicContentBlock = - | AnthropicTextBlock - | AnthropicToolUseBlock - | AnthropicThinkingBlock - | AnthropicRedactedThinkingBlock - | ORAnthropicServerToolUseBlock - | AnthropicWebSearchToolResult - | AnthropicWebFetchToolResult - | AnthropicCodeExecutionToolResult - | AnthropicBashCodeExecutionToolResult - | AnthropicTextEditorCodeExecutionToolResult - | AnthropicToolSearchToolResult - | AnthropicContainerUpload - | AnthropicCompactionBlock - | AnthropicAdvisorToolResult -export const ORAnthropicContentBlock = Schema.Union([ - AnthropicTextBlock, - AnthropicToolUseBlock, - AnthropicThinkingBlock, - AnthropicRedactedThinkingBlock, - ORAnthropicServerToolUseBlock, - AnthropicWebSearchToolResult, - AnthropicWebFetchToolResult, - AnthropicCodeExecutionToolResult, - AnthropicBashCodeExecutionToolResult, - AnthropicTextEditorCodeExecutionToolResult, - AnthropicToolSearchToolResult, - AnthropicContainerUpload, - AnthropicCompactionBlock, - AnthropicAdvisorToolResult -], { mode: "oneOf" }).annotate({ "identifier": "ORAnthropicContentBlock" }) -export type ImageGenCompletedEvent = { - readonly "b64_json": string - readonly "created": number - readonly "media_type"?: string - readonly "type": "image_generation.completed" - readonly "usage"?: ImageGenerationUsage -} -export const ImageGenCompletedEvent = Schema.Struct({ - "b64_json": Schema.String.annotate({ "description": "Base64-encoded final image data" }), - "created": Schema.Number.annotate({ "description": "Unix timestamp (seconds) when the image was generated" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "media_type": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined." - }) + "output_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "output_tokens_details": Schema.Struct({ + "reasoning_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })) + }), + "total_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "cost": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "description": "Cost of the completion", "format": "double" }) + ), + "cost_details": Schema.optionalKey(Schema.Struct({ + "upstream_inference_cost": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), + Schema.Null + ]).annotate({ "format": "double" }) + ), + "upstream_inference_input_cost": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ), + "upstream_inference_output_cost": Schema.Number.annotate({ "format": "double" }).check( + Schema.isFinite().annotate({ "expected": "a finite number" }) + ) + })), + "is_byok": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": "Whether a request was made using a Bring Your Own Key configuration" + }) + ), + "server_tool_use_details": Schema.optionalKey(ServerToolUseDetails) + })]).annotate({ "description": "Token usage information for the response" }) ), - "type": Schema.Literal("image_generation.completed").annotate({ "description": "The event type" }), - "usage": Schema.optionalKey(ImageGenerationUsage) + "user": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "error_type": Schema.optionalKey(ApiErrorType), + "openrouter_metadata": Schema.optionalKey(OpenRouterMetadata) }).annotate({ - "description": "Emitted when generation completes and the final image is available", - "identifier": "ImageGenCompletedEvent" + "description": "Complete non-streaming response from the Responses API", + "identifier": "OpenResponsesResult" }) -export type ImageGenerationResponse = { - readonly "created": number - readonly "data": ReadonlyArray<{ readonly "b64_json": string; readonly "media_type"?: string }> - readonly "usage"?: ImageGenerationUsage +export type StreamEventsResponseOutputItemAdded = { + readonly "item": OutputItems + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.output_item.added" } -export const ImageGenerationResponse = Schema.Struct({ - "created": Schema.Number.annotate({ "description": "Unix timestamp (seconds) when the image was generated" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "data": Schema.Array(Schema.Struct({ - "b64_json": Schema.String.annotate({ "description": "Base64-encoded image bytes" }), - "media_type": Schema.optionalKey( - Schema.String.annotate({ - "description": - "Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined." - }) - ) - })).annotate({ "description": "Generated images" }), - "usage": Schema.optionalKey(ImageGenerationUsage) -}).annotate({ "description": "Image generation response", "identifier": "ImageGenerationResponse" }) -export type ChatResult = { - readonly "choices": ReadonlyArray - readonly "created": number - readonly "id": string - readonly "model": string - readonly "object": "chat.completion" - readonly "openrouter_metadata"?: OpenRouterMetadata - readonly "service_tier"?: string | null - readonly "system_fingerprint": string | null - readonly "usage"?: ChatUsage +export const StreamEventsResponseOutputItemAdded = Schema.Struct({ + "item": OutputItems, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.output_item.added") +}).annotate({ + "description": "Event emitted when a new output item is added to the response", + "identifier": "StreamEventsResponseOutputItemAdded" +}) +export type StreamEventsResponseOutputItemDone = { + readonly "item": OutputItems + readonly "output_index": number + readonly "sequence_number": number + readonly "type": "response.output_item.done" } -export const ChatResult = Schema.Struct({ - "choices": Schema.Array(ChatChoice).annotate({ "description": "List of completion choices" }), - "created": Schema.Number.annotate({ "description": "Unix timestamp of creation" }).check( - Schema.isInt().annotate({ "expected": "an integer" }) - ), - "id": Schema.String.annotate({ "description": "Unique completion identifier" }), - "model": Schema.String.annotate({ "description": "Model used for completion" }), - "object": Schema.Literal("chat.completion"), - "openrouter_metadata": Schema.optionalKey(OpenRouterMetadata), - "service_tier": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": "The service tier used by the upstream provider for this request" - }) - ), - "system_fingerprint": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "System fingerprint" }), - "usage": Schema.optionalKey(ChatUsage) -}).annotate({ "description": "Chat completion response", "identifier": "ChatResult" }) +export const StreamEventsResponseOutputItemDone = Schema.Struct({ + "item": OutputItems, + "output_index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.output_item.done") +}).annotate({ + "description": "Event emitted when an output item is complete", + "identifier": "StreamEventsResponseOutputItemDone" +}) export type ChatRequest = { readonly "cache_control"?: AnthropicCacheControlDirective readonly "debug"?: ChatDebugOptions @@ -25492,7 +25227,7 @@ export type ChatRequest = { | ChatFormatPythonConfig readonly "route"?: DeprecatedRoute readonly "seed"?: number | null - readonly "service_tier"?: "auto" | "default" | "flex" | "priority" | "scale" | null + readonly "service_tier"?: "auto" | "default" | "fast" | "flex" | "priority" | "scale" | null readonly "session_id"?: string readonly "stop"?: string | ReadonlyArray | null readonly "stop_server_tools_when"?: StopServerToolsWhen @@ -25653,11 +25388,15 @@ export const ChatRequest = Schema.Struct({ Schema.Union([ Schema.Literal("auto"), Schema.Literal("default"), + Schema.Literal("fast"), Schema.Literal("flex"), Schema.Literal("priority"), Schema.Literal("scale"), Schema.Null - ]).annotate({ "description": "The service tier to use for processing this request." }) + ]).annotate({ + "description": + "The service tier to use for processing this request. `fast` is accepted as an alias for `priority`." + }) ), "session_id": Schema.optionalKey( Schema.String.annotate({ @@ -25714,6 +25453,34 @@ export const ChatRequest = Schema.Struct({ "Per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account." })) }).annotate({ "description": "Chat completion request parameters", "identifier": "ChatRequest" }) +export type ChatResult = { + readonly "choices": ReadonlyArray + readonly "created": number + readonly "id": string + readonly "model": string + readonly "object": "chat.completion" + readonly "openrouter_metadata"?: OpenRouterMetadata + readonly "service_tier"?: string | null + readonly "system_fingerprint": string | null + readonly "usage"?: ChatUsage +} +export const ChatResult = Schema.Struct({ + "choices": Schema.Array(ChatChoice).annotate({ "description": "List of completion choices" }), + "created": Schema.Number.annotate({ "description": "Unix timestamp of creation" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ), + "id": Schema.String.annotate({ "description": "Unique completion identifier" }), + "model": Schema.String.annotate({ "description": "Model used for completion" }), + "object": Schema.Literal("chat.completion"), + "openrouter_metadata": Schema.optionalKey(OpenRouterMetadata), + "service_tier": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": "The service tier used by the upstream provider for this request" + }) + ), + "system_fingerprint": Schema.Union([Schema.String, Schema.Null]).annotate({ "description": "System fingerprint" }), + "usage": Schema.optionalKey(ChatUsage) +}).annotate({ "description": "Chat completion response", "identifier": "ChatResult" }) export type ChatStreamChunk = { readonly "choices": ReadonlyArray readonly "created": number @@ -25763,180 +25530,246 @@ export const ChatStreamChunk = Schema.Struct({ "system_fingerprint": Schema.optionalKey(Schema.String.annotate({ "description": "System fingerprint" })), "usage": Schema.optionalKey(ChatUsage) }).annotate({ "description": "Streaming chat completion chunk", "identifier": "ChatStreamChunk" }) -export type Inputs = string | Arrays_8 -export const Inputs = Schema.Union([Schema.String, Arrays_8]).annotate({ - "description": "Input for a response request - can be a string or array of items", - "identifier": "Inputs" -}) -export type CompletedEvent = { - readonly "response": BaseResponsesResult - readonly "sequence_number": number - readonly "type": "response.completed" -} -export const CompletedEvent = Schema.Struct({ - "response": BaseResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.completed") -}).annotate({ - "description": "Event emitted when a response has completed successfully", - "identifier": "CompletedEvent" -}) -export type CreatedEvent = { - readonly "response": BaseResponsesResult - readonly "sequence_number": number - readonly "type": "response.created" -} -export const CreatedEvent = Schema.Struct({ - "response": BaseResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.created") -}).annotate({ "description": "Event emitted when a response is created", "identifier": "CreatedEvent" }) -export type FailedEvent = { - readonly "response": BaseResponsesResult - readonly "sequence_number": number - readonly "type": "response.failed" -} -export const FailedEvent = Schema.Struct({ - "response": BaseResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.failed") -}).annotate({ "description": "Event emitted when a response has failed", "identifier": "FailedEvent" }) -export type IncompleteEvent = { - readonly "response": BaseResponsesResult - readonly "sequence_number": number - readonly "type": "response.incomplete" -} -export const IncompleteEvent = Schema.Struct({ - "response": BaseResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.incomplete") -}).annotate({ "description": "Event emitted when a response is incomplete", "identifier": "IncompleteEvent" }) -export type InProgressEvent = { - readonly "response": BaseResponsesResult - readonly "sequence_number": number - readonly "type": "response.in_progress" -} -export const InProgressEvent = Schema.Struct({ - "response": BaseResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.in_progress") -}).annotate({ "description": "Event emitted when a response is in progress", "identifier": "InProgressEvent" }) -export type OpenResponsesCreatedEvent = { - readonly "response": OpenResponsesResult - readonly "sequence_number": number - readonly "type": "response.created" -} -export const OpenResponsesCreatedEvent = Schema.Struct({ - "response": OpenResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.created") -}).annotate({ "description": "Event emitted when a response is created", "identifier": "OpenResponsesCreatedEvent" }) -export type OpenResponsesInProgressEvent = { - readonly "response": OpenResponsesResult - readonly "sequence_number": number - readonly "type": "response.in_progress" -} -export const OpenResponsesInProgressEvent = Schema.Struct({ - "response": OpenResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.in_progress") -}).annotate({ - "description": "Event emitted when a response is in progress", - "identifier": "OpenResponsesInProgressEvent" -}) -export type StreamEventsResponseCompleted = { - readonly "response": OpenResponsesResult - readonly "sequence_number": number - readonly "type": "response.completed" -} -export const StreamEventsResponseCompleted = Schema.Struct({ - "response": OpenResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.completed") -}).annotate({ - "description": "Event emitted when a response has completed successfully", - "identifier": "StreamEventsResponseCompleted" -}) -export type StreamEventsResponseFailed = { - readonly "response": OpenResponsesResult - readonly "sequence_number": number - readonly "type": "response.failed" -} -export const StreamEventsResponseFailed = Schema.Struct({ - "response": OpenResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.failed") -}).annotate({ "description": "Event emitted when a response has failed", "identifier": "StreamEventsResponseFailed" }) -export type StreamEventsResponseIncomplete = { - readonly "response": OpenResponsesResult - readonly "sequence_number": number - readonly "type": "response.incomplete" -} -export const StreamEventsResponseIncomplete = Schema.Struct({ - "response": OpenResponsesResult, - "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "type": Schema.Literal("response.incomplete") -}).annotate({ - "description": "Event emitted when a response is incomplete", - "identifier": "StreamEventsResponseIncomplete" -}) -export type BaseMessagesResult = { - readonly "container": AnthropicContainer - readonly "content": ReadonlyArray - readonly "id": string - readonly "model": string - readonly "role": "assistant" - readonly "stop_details": AnthropicRefusalStopDetails - readonly "stop_reason": ORAnthropicStopReason - readonly "stop_sequence": string | null - readonly "type": "message" - readonly "usage": { - readonly "cache_creation": AnthropicCacheCreation - readonly "cache_creation_input_tokens": number | null - readonly "cache_read_input_tokens": number | null - readonly "inference_geo": string | null - readonly "input_tokens": number - readonly "output_tokens": number - readonly "output_tokens_details": AnthropicOutputTokensDetails - readonly "server_tool_use": AnthropicServerToolUsage - readonly "service_tier": AnthropicServiceTier - readonly "iterations"?: ReadonlyArray - readonly "speed"?: AnthropicSpeed - } +export type ResponsesRequest = { + readonly "background"?: boolean | null + readonly "cache_control"?: AnthropicCacheControlDirective + readonly "debug"?: ChatDebugOptions + readonly "frequency_penalty"?: number | null + readonly "image_config"?: ImageConfig + readonly "include"?: ReadonlyArray | null + readonly "input"?: Inputs + readonly "instructions"?: string | null + readonly "max_output_tokens"?: number | null + readonly "max_tool_calls"?: number | null + readonly "metadata"?: RequestMetadata + readonly "modalities"?: ReadonlyArray + readonly "model"?: string + readonly "models"?: ReadonlyArray + readonly "parallel_tool_calls"?: boolean | null + readonly "plugins"?: ReadonlyArray< + | AutoRouterPlugin + | AutoBetaRouterPlugin + | ModerationPlugin + | WebSearchPlugin + | WebFetchPlugin + | FileParserPlugin + | ResponseHealingPlugin + | ContextCompressionPlugin + | ParetoRouterPlugin + | FusionPlugin + > + readonly "presence_penalty"?: number | null + readonly "previous_response_id"?: Schema.Json + readonly "prompt"?: StoredPromptTemplate + readonly "prompt_cache_key"?: string | null + readonly "prompt_cache_options"?: PromptCacheOptions + readonly "provider"?: ProviderPreferences + readonly "reasoning"?: ReasoningConfig + readonly "route"?: DeprecatedRoute + readonly "safety_identifier"?: string | null + readonly "service_tier"?: "auto" | "default" | "fast" | "flex" | "priority" | "scale" | null + readonly "session_id"?: string + readonly "stop_server_tools_when"?: StopServerToolsWhen + readonly "store"?: false + readonly "stream"?: boolean + readonly "temperature"?: number | null + readonly "text"?: TextExtendedConfig + readonly "tool_choice"?: OpenAIResponsesToolChoice + readonly "tools"?: ReadonlyArray< + | { + readonly "description"?: string | null + readonly "name": string + readonly "parameters": { readonly [x: string]: Schema.Json } | null + readonly "strict"?: boolean | null + readonly "type": "function" + } + | Preview_WebSearchServerTool + | Preview_20250311_WebSearchServerTool + | Legacy_WebSearchServerTool + | WebSearchServerTool + | FileSearchServerTool + | ComputerUseServerTool + | CodeInterpreterServerTool + | McpServerTool + | ImageGenerationServerTool + | CodexLocalShellTool + | ShellServerTool + | ApplyPatchServerTool + | CustomTool + | NamespaceTool + | AdvisorServerTool_OpenRouter + | SubagentServerTool_OpenRouter + | DatetimeServerTool + | FilesServerTool + | FusionServerTool_OpenRouter + | ImageGenerationServerTool_OpenRouter + | SearchModelsServerTool_OpenRouter + | WebFetchServerTool + | WebSearchServerTool_OpenRouter + | ApplyPatchServerTool_OpenRouter + | BashServerTool + | ShellServerTool_OpenRouter + > + readonly "top_k"?: number + readonly "top_logprobs"?: number | null + readonly "top_p"?: number | null + readonly "trace"?: TraceConfig + readonly "truncation"?: OpenAIResponsesTruncation + readonly "user"?: string } -export const BaseMessagesResult = Schema.Struct({ - "container": AnthropicContainer, - "content": Schema.Array(ORAnthropicContentBlock), - "id": Schema.String, - "model": Schema.String, - "role": Schema.Literal("assistant"), - "stop_details": AnthropicRefusalStopDetails, - "stop_reason": ORAnthropicStopReason, - "stop_sequence": Schema.Union([Schema.String, Schema.Null]), - "type": Schema.Literal("message"), - "usage": Schema.Struct({ - "cache_creation": AnthropicCacheCreation, - "cache_creation_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - Schema.Null - ]), - "cache_read_input_tokens": Schema.Union([ - Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), +export const ResponsesRequest = Schema.Struct({ + "background": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), + "debug": Schema.optionalKey(ChatDebugOptions), + "frequency_penalty": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ), + "image_config": Schema.optionalKey(ImageConfig), + "include": Schema.optionalKey(Schema.Union([Schema.Array(ResponseIncludesEnum), Schema.Null])), + "input": Schema.optionalKey(Inputs), + "instructions": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "max_output_tokens": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ), + "max_tool_calls": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ + "description": + "Maximum number of server-tool (e.g. `openrouter:web_search`) agent steps the model may take during a request. Defaults to 30, which is also the maximum. Ignored when `stop_server_tools_when` is set." + }) + ), + "metadata": Schema.optionalKey(RequestMetadata), + "modalities": Schema.optionalKey( + Schema.Array(OutputModalityEnum).annotate({ + "description": "Output modalities for the response. Supported values are \"text\" and \"image\"." + }) + ), + "model": Schema.optionalKey(Schema.String), + "models": Schema.optionalKey(Schema.Array(Schema.String)), + "parallel_tool_calls": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "plugins": Schema.optionalKey( + Schema.Array( + Schema.Union([ + AutoRouterPlugin, + AutoBetaRouterPlugin, + ModerationPlugin, + WebSearchPlugin, + WebFetchPlugin, + FileParserPlugin, + ResponseHealingPlugin, + ContextCompressionPlugin, + ParetoRouterPlugin, + FusionPlugin + ], { mode: "oneOf" }) + ).annotate({ "description": "Plugins you want to enable for this request, including their settings." }) + ), + "presence_penalty": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ), + "previous_response_id": Schema.optionalKey( + Schema.Json.annotate({ + "expected": "JSON value", + "description": + "Not supported. The Responses API is stateless: no responses are stored, so a previous response cannot be referenced. Requests with a non-null value are rejected with a 400 error. Send the full conversation history in `input` instead." + }) + ), + "prompt": Schema.optionalKey(StoredPromptTemplate), + "prompt_cache_key": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "prompt_cache_options": Schema.optionalKey(PromptCacheOptions), + "provider": Schema.optionalKey(ProviderPreferences), + "reasoning": Schema.optionalKey(ReasoningConfig), + "route": Schema.optionalKey(DeprecatedRoute), + "safety_identifier": Schema.optionalKey( + Schema.Union([Schema.String, Schema.Null]).annotate({ + "description": + "Recommended per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account." + }) + ), + "service_tier": Schema.optionalKey( + Schema.Union([ + Schema.Literal("auto"), + Schema.Literal("default"), + Schema.Literal("fast"), + Schema.Literal("flex"), + Schema.Literal("priority"), + Schema.Literal("scale"), Schema.Null - ]), - "inference_geo": Schema.Union([Schema.String, Schema.Null]), - "input_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "output_tokens": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), - "output_tokens_details": AnthropicOutputTokensDetails, - "server_tool_use": AnthropicServerToolUsage, - "service_tier": AnthropicServiceTier, - "iterations": Schema.optionalKey(Schema.Array(AnthropicUsageIteration)), - "speed": Schema.optionalKey(AnthropicSpeed) - }) -}).annotate({ - "description": "Base Anthropic Messages API response before OpenRouter extensions", - "identifier": "BaseMessagesResult" -}) + ]).annotate({ + "description": + "The service tier to use for processing this request. `fast` is accepted as an alias for `priority`." + }) + ), + "session_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters." + }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) + ), + "stop_server_tools_when": Schema.optionalKey(StopServerToolsWhen), + "store": Schema.optionalKey(Schema.Literal(false)), + "stream": Schema.optionalKey(Schema.Boolean), + "temperature": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ), + "text": Schema.optionalKey(TextExtendedConfig), + "tool_choice": Schema.optionalKey(OpenAIResponsesToolChoice), + "tools": Schema.optionalKey(Schema.Array(Schema.Union([ + Schema.Struct({ + "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), + "name": Schema.String, + "parameters": Schema.Union([ + Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), + Schema.Null + ]), + "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), + "type": Schema.Literal("function") + }).annotate({ "description": "Function tool definition" }), + Preview_WebSearchServerTool, + Preview_20250311_WebSearchServerTool, + Legacy_WebSearchServerTool, + WebSearchServerTool, + FileSearchServerTool, + ComputerUseServerTool, + CodeInterpreterServerTool, + McpServerTool, + ImageGenerationServerTool, + CodexLocalShellTool, + ShellServerTool, + ApplyPatchServerTool, + CustomTool, + NamespaceTool, + AdvisorServerTool_OpenRouter, + SubagentServerTool_OpenRouter, + DatetimeServerTool, + FilesServerTool, + FusionServerTool_OpenRouter, + ImageGenerationServerTool_OpenRouter, + SearchModelsServerTool_OpenRouter, + WebFetchServerTool, + WebSearchServerTool_OpenRouter, + ApplyPatchServerTool_OpenRouter, + BashServerTool, + ShellServerTool_OpenRouter + ]))), + "top_k": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), + "top_logprobs": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) + ), + "top_p": Schema.optionalKey( + Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) + .annotate({ "format": "double" }) + ), + "trace": Schema.optionalKey(TraceConfig), + "truncation": Schema.optionalKey(OpenAIResponsesTruncation), + "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 256 characters." + }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) + ) +}).annotate({ "description": "Request schema for Responses endpoint", "identifier": "ResponsesRequest" }) export type MessagesResult = { readonly "container": AnthropicContainer readonly "content": ReadonlyArray @@ -26860,6 +26693,7 @@ export type MessagesStartEvent = { | "Cerebras" | "Chutes" | "Cirrascale" + | "Claude Platform on AWS" | "Clarifai" | "Cloudflare" | "Cohere" @@ -26900,6 +26734,7 @@ export type MessagesStartEvent = { | "Modular" | "Moonshot AI" | "Morph" + | "VoyageAI by MongoDB" | "NCompass" | "Nebius" | "Nex AGI" @@ -26928,6 +26763,7 @@ export type MessagesStartEvent = { | "Switchpoint" | "Tencent" | "Tenstorrent" + | "Thinking Machines" | "Together" | "Upstage" | "Venice" @@ -27016,6 +26852,7 @@ export const MessagesStartEvent = Schema.Struct({ "Cerebras", "Chutes", "Cirrascale", + "Claude Platform on AWS", "Clarifai", "Cloudflare", "Cohere", @@ -27056,6 +26893,7 @@ export const MessagesStartEvent = Schema.Struct({ "Modular", "Moonshot AI", "Morph", + "VoyageAI by MongoDB", "NCompass", "Nebius", "Nex AGI", @@ -27084,6 +26922,7 @@ export const MessagesStartEvent = Schema.Struct({ "Switchpoint", "Tencent", "Tenstorrent", + "Thinking Machines", "Together", "Upstage", "Venice", @@ -27125,261 +26964,91 @@ export const MessagesStartEvent = Schema.Struct({ }), "type": Schema.Literal("message_start") }).annotate({ "description": "Event sent at the start of a streaming message", "identifier": "MessagesStartEvent" }) -export type ImageStreamingResponse = { - readonly "data": - | ImageGenPartialImageEvent - | ImageGenTextChunkEvent - | ImageGenCompletedEvent - | ImageGenStreamErrorEvent +export type OpenResponsesCreatedEvent = { + readonly "response": OpenResponsesResult + readonly "sequence_number": number + readonly "type": "response.created" } -export const ImageStreamingResponse = Schema.Struct({ - "data": Schema.Union([ - ImageGenPartialImageEvent, - ImageGenTextChunkEvent, - ImageGenCompletedEvent, - ImageGenStreamErrorEvent - ]) -}).annotate({ "identifier": "ImageStreamingResponse" }) +export const OpenResponsesCreatedEvent = Schema.Struct({ + "response": OpenResponsesResult, + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.created") +}).annotate({ "description": "Event emitted when a response is created", "identifier": "OpenResponsesCreatedEvent" }) +export type OpenResponsesInProgressEvent = { + readonly "response": OpenResponsesResult + readonly "sequence_number": number + readonly "type": "response.in_progress" +} +export const OpenResponsesInProgressEvent = Schema.Struct({ + "response": OpenResponsesResult, + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.in_progress") +}).annotate({ + "description": "Event emitted when a response is in progress", + "identifier": "OpenResponsesInProgressEvent" +}) +export type StreamEventsResponseCompleted = { + readonly "response": OpenResponsesResult + readonly "sequence_number": number + readonly "type": "response.completed" +} +export const StreamEventsResponseCompleted = Schema.Struct({ + "response": OpenResponsesResult, + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.completed") +}).annotate({ + "description": "Event emitted when a response has completed successfully", + "identifier": "StreamEventsResponseCompleted" +}) +export type StreamEventsResponseIncomplete = { + readonly "response": OpenResponsesResult + readonly "sequence_number": number + readonly "type": "response.incomplete" +} +export const StreamEventsResponseIncomplete = Schema.Struct({ + "response": OpenResponsesResult, + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.incomplete") +}).annotate({ + "description": "Event emitted when a response is incomplete", + "identifier": "StreamEventsResponseIncomplete" +}) +export type StreamEventsResponseFailed = { + readonly "response": OpenResponsesResult + readonly "sequence_number": number + readonly "type": "response.failed" +} +export const StreamEventsResponseFailed = Schema.Struct({ + "response": OpenResponsesResult, + "sequence_number": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), + "type": Schema.Literal("response.failed") +}).annotate({ "description": "Event emitted when a response has failed", "identifier": "StreamEventsResponseFailed" }) export type ChatStreamingResponse = { readonly "data": ChatStreamChunk } export const ChatStreamingResponse = Schema.Struct({ "data": ChatStreamChunk }).annotate({ "identifier": "ChatStreamingResponse" }) -export type ResponsesRequest = { - readonly "background"?: boolean | null - readonly "cache_control"?: AnthropicCacheControlDirective - readonly "debug"?: ChatDebugOptions - readonly "frequency_penalty"?: number | null - readonly "image_config"?: ImageConfig - readonly "include"?: ReadonlyArray | null - readonly "input"?: Inputs - readonly "instructions"?: string | null - readonly "max_output_tokens"?: number | null - readonly "max_tool_calls"?: number | null - readonly "metadata"?: RequestMetadata - readonly "modalities"?: ReadonlyArray - readonly "model"?: string - readonly "models"?: ReadonlyArray - readonly "parallel_tool_calls"?: boolean | null - readonly "plugins"?: ReadonlyArray< - | AutoRouterPlugin - | AutoBetaRouterPlugin - | ModerationPlugin - | WebSearchPlugin - | WebFetchPlugin - | FileParserPlugin - | ResponseHealingPlugin - | ContextCompressionPlugin - | ParetoRouterPlugin - | FusionPlugin - > - readonly "presence_penalty"?: number | null - readonly "previous_response_id"?: Schema.Json - readonly "prompt"?: StoredPromptTemplate - readonly "prompt_cache_key"?: string | null - readonly "prompt_cache_options"?: PromptCacheOptions - readonly "provider"?: ProviderPreferences - readonly "reasoning"?: ReasoningConfig - readonly "route"?: DeprecatedRoute - readonly "safety_identifier"?: string | null - readonly "service_tier"?: "auto" | "default" | "flex" | "priority" | "scale" | null - readonly "session_id"?: string - readonly "stop_server_tools_when"?: StopServerToolsWhen - readonly "store"?: false - readonly "stream"?: boolean - readonly "temperature"?: number | null - readonly "text"?: TextExtendedConfig - readonly "tool_choice"?: OpenAIResponsesToolChoice - readonly "tools"?: ReadonlyArray< - | { - readonly "description"?: string | null - readonly "name": string - readonly "parameters": { readonly [x: string]: Schema.Json } | null - readonly "strict"?: boolean | null - readonly "type": "function" - } - | Preview_WebSearchServerTool - | Preview_20250311_WebSearchServerTool - | Legacy_WebSearchServerTool - | WebSearchServerTool - | FileSearchServerTool - | ComputerUseServerTool - | CodeInterpreterServerTool - | McpServerTool - | ImageGenerationServerTool - | CodexLocalShellTool - | ShellServerTool - | ApplyPatchServerTool - | CustomTool - | NamespaceTool - | AdvisorServerTool_OpenRouter - | SubagentServerTool_OpenRouter - | DatetimeServerTool - | FilesServerTool - | FusionServerTool_OpenRouter - | ImageGenerationServerTool_OpenRouter - | SearchModelsServerTool_OpenRouter - | WebFetchServerTool - | WebSearchServerTool_OpenRouter - | ApplyPatchServerTool_OpenRouter - | BashServerTool - | ShellServerTool_OpenRouter - > - readonly "top_k"?: number - readonly "top_logprobs"?: number | null - readonly "top_p"?: number | null - readonly "trace"?: TraceConfig - readonly "truncation"?: OpenAIResponsesTruncation - readonly "user"?: string -} -export const ResponsesRequest = Schema.Struct({ - "background": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "cache_control": Schema.optionalKey(AnthropicCacheControlDirective), - "debug": Schema.optionalKey(ChatDebugOptions), - "frequency_penalty": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "image_config": Schema.optionalKey(ImageConfig), - "include": Schema.optionalKey(Schema.Union([Schema.Array(ResponseIncludesEnum), Schema.Null])), - "input": Schema.optionalKey(Inputs), - "instructions": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "max_output_tokens": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "max_tool_calls": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]).annotate({ - "description": - "Maximum number of server-tool (e.g. `openrouter:web_search`) agent steps the model may take during a request. Defaults to 30, which is also the maximum. Ignored when `stop_server_tools_when` is set." - }) - ), - "metadata": Schema.optionalKey(RequestMetadata), - "modalities": Schema.optionalKey( - Schema.Array(OutputModalityEnum).annotate({ - "description": "Output modalities for the response. Supported values are \"text\" and \"image\"." - }) - ), - "model": Schema.optionalKey(Schema.String), - "models": Schema.optionalKey(Schema.Array(Schema.String)), - "parallel_tool_calls": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "plugins": Schema.optionalKey( - Schema.Array( - Schema.Union([ - AutoRouterPlugin, - AutoBetaRouterPlugin, - ModerationPlugin, - WebSearchPlugin, - WebFetchPlugin, - FileParserPlugin, - ResponseHealingPlugin, - ContextCompressionPlugin, - ParetoRouterPlugin, - FusionPlugin - ], { mode: "oneOf" }) - ).annotate({ "description": "Plugins you want to enable for this request, including their settings." }) - ), - "presence_penalty": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "previous_response_id": Schema.optionalKey( - Schema.Json.annotate({ - "expected": "JSON value", - "description": - "Not supported. The Responses API is stateless: no responses are stored, so a previous response cannot be referenced. Requests with a non-null value are rejected with a 400 error. Send the full conversation history in `input` instead." - }) - ), - "prompt": Schema.optionalKey(StoredPromptTemplate), - "prompt_cache_key": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "prompt_cache_options": Schema.optionalKey(PromptCacheOptions), - "provider": Schema.optionalKey(ProviderPreferences), - "reasoning": Schema.optionalKey(ReasoningConfig), - "route": Schema.optionalKey(DeprecatedRoute), - "safety_identifier": Schema.optionalKey( - Schema.Union([Schema.String, Schema.Null]).annotate({ - "description": - "Recommended per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account." - }) - ), - "service_tier": Schema.optionalKey( - Schema.Union([ - Schema.Literal("auto"), - Schema.Literal("default"), - Schema.Literal("flex"), - Schema.Literal("priority"), - Schema.Literal("scale"), - Schema.Null - ]) - ), - "session_id": Schema.optionalKey( - Schema.String.annotate({ - "description": - "A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters." - }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) - ), - "stop_server_tools_when": Schema.optionalKey(StopServerToolsWhen), - "store": Schema.optionalKey(Schema.Literal(false)), - "stream": Schema.optionalKey(Schema.Boolean), - "temperature": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "text": Schema.optionalKey(TextExtendedConfig), - "tool_choice": Schema.optionalKey(OpenAIResponsesToolChoice), - "tools": Schema.optionalKey(Schema.Array(Schema.Union([ - Schema.Struct({ - "description": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), - "name": Schema.String, - "parameters": Schema.Union([ - Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })), - Schema.Null - ]), - "strict": Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])), - "type": Schema.Literal("function") - }).annotate({ "description": "Function tool definition" }), - Preview_WebSearchServerTool, - Preview_20250311_WebSearchServerTool, - Legacy_WebSearchServerTool, - WebSearchServerTool, - FileSearchServerTool, - ComputerUseServerTool, - CodeInterpreterServerTool, - McpServerTool, - ImageGenerationServerTool, - CodexLocalShellTool, - ShellServerTool, - ApplyPatchServerTool, - CustomTool, - NamespaceTool, - AdvisorServerTool_OpenRouter, - SubagentServerTool_OpenRouter, - DatetimeServerTool, - FilesServerTool, - FusionServerTool_OpenRouter, - ImageGenerationServerTool_OpenRouter, - SearchModelsServerTool_OpenRouter, - WebFetchServerTool, - WebSearchServerTool_OpenRouter, - ApplyPatchServerTool_OpenRouter, - BashServerTool, - ShellServerTool_OpenRouter - ]))), - "top_k": Schema.optionalKey(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))), - "top_logprobs": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })), Schema.Null]) - ), - "top_p": Schema.optionalKey( - Schema.Union([Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })), Schema.Null]) - .annotate({ "format": "double" }) - ), - "trace": Schema.optionalKey(TraceConfig), - "truncation": Schema.optionalKey(OpenAIResponsesTruncation), - "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 256 characters." - }).check(Schema.isMaxLength(256).annotate({ "expected": "a value with a length of at most 256" })) - ) -}).annotate({ "description": "Request schema for Responses endpoint", "identifier": "ResponsesRequest" }) +export type MessagesStreamEvents = + | MessagesStartEvent + | MessagesDeltaEvent + | MessagesStopEvent + | MessagesContentBlockStartEvent + | MessagesContentBlockDeltaEvent + | MessagesContentBlockStopEvent + | MessagesPingEvent + | MessagesErrorEvent +export const MessagesStreamEvents = Schema.Union([ + MessagesStartEvent, + MessagesDeltaEvent, + MessagesStopEvent, + MessagesContentBlockStartEvent, + MessagesContentBlockDeltaEvent, + MessagesContentBlockStopEvent, + MessagesPingEvent, + MessagesErrorEvent +], { mode: "oneOf" }).annotate({ + "description": "Union of all possible streaming events", + "identifier": "MessagesStreamEvents" +}) export type StreamEvents = | OpenResponsesCreatedEvent | OpenResponsesInProgressEvent @@ -27474,35 +27143,13 @@ export const StreamEvents: Schema.Schema = Schema.Union([ "description": "Union of all possible event types emitted during response streaming", "identifier": "StreamEvents" }) -export type MessagesStreamEvents = - | MessagesStartEvent - | MessagesDeltaEvent - | MessagesStopEvent - | MessagesContentBlockStartEvent - | MessagesContentBlockDeltaEvent - | MessagesContentBlockStopEvent - | MessagesPingEvent - | MessagesErrorEvent -export const MessagesStreamEvents = Schema.Union([ - MessagesStartEvent, - MessagesDeltaEvent, - MessagesStopEvent, - MessagesContentBlockStartEvent, - MessagesContentBlockDeltaEvent, - MessagesContentBlockStopEvent, - MessagesPingEvent, - MessagesErrorEvent -], { mode: "oneOf" }).annotate({ - "description": "Union of all possible streaming events", - "identifier": "MessagesStreamEvents" -}) +export type MessagesStreamingResponse = { readonly "data": MessagesStreamEvents; readonly "event": string } +export const MessagesStreamingResponse = Schema.Struct({ "data": MessagesStreamEvents, "event": Schema.String }) + .annotate({ "identifier": "MessagesStreamingResponse" }) export type ResponsesStreamingResponse = { readonly "data": StreamEvents } export const ResponsesStreamingResponse: Schema.Schema = Schema.Struct({ "data": StreamEvents }).annotate({ "identifier": "ResponsesStreamingResponse" }) -export type MessagesStreamingResponse = { readonly "data": MessagesStreamEvents; readonly "event": string } -export const MessagesStreamingResponse = Schema.Struct({ "data": MessagesStreamEvents, "event": Schema.String }) - .annotate({ "identifier": "MessagesStreamingResponse" }) // schemas export type GetUserActivityParams = { readonly "HTTP-Referer"?: string @@ -27511,6 +27158,8 @@ export type GetUserActivityParams = { readonly "date"?: string readonly "api_key_hash"?: string readonly "user_id"?: string + readonly "group_by"?: "workspace" + readonly "workspace_id"?: string } export const GetUserActivityParams = Schema.Struct({ "HTTP-Referer": Schema.optionalKey(Schema.String), @@ -27528,6 +27177,18 @@ export const GetUserActivityParams = Schema.Struct({ Schema.String.annotate({ "description": "Filter by org member user ID. Only applicable for organization accounts." }) + ), + "group_by": Schema.optionalKey( + Schema.Literal("workspace").annotate({ + "description": + "Set to 'workspace' to split each row per workspace and include `workspace_id` on every item. Omitted by default, in which case rows are aggregated across workspaces (by date, model, and endpoint) and `workspace_id` is not returned — preserving the historical response shape." + }) + ), + "workspace_id": Schema.optionalKey( + Schema.String.annotate({ + "description": + "Filter by workspace ID (UUID). Returns only activity attributed to that workspace. The workspace must belong to the authenticated account." + }) ) }) export type GetUserActivity200 = ActivityResponse @@ -27647,6 +27308,7 @@ export type QueryAnalyticsRequestJson = { readonly "filters"?: ReadonlyArray< { readonly "field": string + readonly "include_unset"?: boolean readonly "operator": string readonly "value": string | number | ReadonlyArray } @@ -27736,6 +27398,12 @@ export const QueryAnalyticsRequestJson = Schema.Struct({ "field": Schema.String.annotate({ "description": "Dimension to filter on. Use the /meta endpoint for available dimensions." }), + "include_unset": Schema.optionalKey( + Schema.Boolean.annotate({ + "description": + "Include rows where the dimension has no value. Applies only to the `in` and `not_in` operators and dimensions that have an unset bucket." + }) + ), "operator": Schema.String.annotate({ "description": "Filter operator" }), "value": Schema.Union([ Schema.String, @@ -27752,7 +27420,7 @@ export const QueryAnalyticsRequestJson = Schema.Struct({ ) ]).annotate({ "description": - "Filter value (scalar or array depending on operator). Several dimensions are enriched in responses (returned as human-readable labels), but filters must use the underlying ID: `api_key_id` — numeric ID (from generation metadata) or key hash (64-char hex from GET /api/v1/keys, resolved server-side); `user` — Clerk user ID (e.g. \"user_abc123\"), not the display name; `workspace` — workspace UUID, not the workspace name; `app` — numeric app ID, not the app title; `model` — permaslug (e.g. \"openai/gpt-4o\"), not the display name. Other dimensions (provider, origin, country, etc.) are not enriched and accept the value as returned." + "Filter value (scalar or array depending on operator). Several dimensions are enriched in responses (returned as human-readable labels), but filters must use the underlying ID: `api_key_id` — numeric ID (from generation metadata) or key hash (64-char hex from GET /api/v1/keys, resolved server-side); `user` — Clerk user ID (e.g. \"user_abc123\"), not the display name; `workspace` — workspace UUID, not the workspace name (filtering or grouping by the account default workspace also covers activity recorded before workspace resolution existed, which is attributed to that default workspace); `app` — numeric app ID, not the app title; `model` — permaslug (e.g. \"openai/gpt-4o\"), not the display name. Other dimensions (provider, origin, country, etc.) are not enriched and accept the value as returned." }) })).check(Schema.isMaxLength(20).annotate({ "expected": "a value with a length of at most 20" })) ), @@ -28065,7 +27733,7 @@ export type GetBenchmarksParams = { readonly "HTTP-Referer"?: string readonly "X-OpenRouter-Title"?: string readonly "X-OpenRouter-Categories"?: string - readonly "source"?: "artificial-analysis" | "design-arena" + readonly "source"?: "artificial-analysis" | "design-arena" | "openrouter" readonly "task_type"?: "coding" | "intelligence" | "agentic" readonly "arena"?: "models" | "builders" | "agents" readonly "category"?: string @@ -28076,7 +27744,7 @@ export const GetBenchmarksParams = Schema.Struct({ "X-OpenRouter-Title": Schema.optionalKey(Schema.String), "X-OpenRouter-Categories": Schema.optionalKey(Schema.String), "source": Schema.optionalKey( - Schema.Literals(["artificial-analysis", "design-arena"]).annotate({ + Schema.Literals(["artificial-analysis", "design-arena", "openrouter"]).annotate({ "description": "Benchmark source to query. Determines the shape of the returned items. When omitted, returns results from all sources." }) @@ -28179,6 +27847,7 @@ export type ListBYOKKeysParams = { | "meta" | "minimax" | "mistral" + | "modal" | "modelrun" | "modular" | "moonshotai" @@ -28203,6 +27872,7 @@ export type ListBYOKKeysParams = { | "runway" | "sail-research" | "sakana" + | "sakana-ai" | "sambanova" | "seed" | "siliconflow" @@ -28212,11 +27882,13 @@ export type ListBYOKKeysParams = { | "switchpoint" | "tencent" | "tenstorrent" + | "thinkingmachines" | "together" | "upstage" | "venice" | "wafer" | "wandb" + | "wandb-legacy" | "xai" | "xiaomi" | "z-ai" @@ -28242,7 +27914,8 @@ export const ListBYOKKeysParams = Schema.Struct({ ), "workspace_id": Schema.optionalKey( Schema.String.annotate({ - "description": "Optional workspace ID to filter by. Defaults to the authenticated entity's default workspace.", + "description": + "Optional workspace ID to filter by. When omitted, resolves to the account’s default workspace; if that default has been deleted, the request returns a 400 and you must pass `workspace_id` explicitly.", "format": "uuid" }) ), @@ -28303,6 +27976,7 @@ export const ListBYOKKeysParams = Schema.Struct({ "meta", "minimax", "mistral", + "modal", "modelrun", "modular", "moonshotai", @@ -28327,6 +28001,7 @@ export const ListBYOKKeysParams = Schema.Struct({ "runway", "sail-research", "sakana", + "sakana-ai", "sambanova", "seed", "siliconflow", @@ -28336,11 +28011,13 @@ export const ListBYOKKeysParams = Schema.Struct({ "switchpoint", "tencent", "tenstorrent", + "thinkingmachines", "together", "upstage", "venice", "wafer", "wandb", + "wandb-legacy", "xai", "xiaomi", "z-ai" @@ -28809,20 +28486,27 @@ export const CreateEmbeddingsRequestJson = Schema.Struct({ Schema.Literals(["float", "base64"]).annotate({ "description": "The format of the output embeddings" }) ), "input": Schema.Union([ - Schema.String, - Schema.Array(Schema.String), + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })), + Schema.Array( + Schema.String.check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) + ), Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" }))), Schema.Array(Schema.Array(Schema.Number.check(Schema.isFinite().annotate({ "expected": "a finite number" })))), Schema.Array(Schema.Struct({ "content": Schema.Array( Schema.Union([ - Schema.Struct({ "text": Schema.String, "type": Schema.Literal("text") }), + Schema.Struct({ + "text": Schema.String.check( + Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" }) + ), + "type": Schema.Literal("text") + }), Schema.Struct({ "image_url": Schema.Struct({ "url": Schema.String }), "type": Schema.Literal("image_url") }), ContentPartInputAudio, ContentPartInputVideo, ContentPartInputFile ], { mode: "oneOf" }) - ) + ).check(Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })) })) ]).annotate({ "description": "Text, token, or multimodal input(s) to embed" }), "input_type": Schema.optionalKey( @@ -29014,6 +28698,11 @@ export type ListFilesParams = { readonly "limit"?: number readonly "cursor"?: string readonly "workspace_id"?: string + readonly "provider"?: FileProvider + readonly "after"?: string + readonly "after_id"?: string + readonly "before_id"?: string + readonly "order"?: "asc" | "desc" } export const ListFilesParams = Schema.Struct({ "HTTP-Referer": Schema.optionalKey(Schema.String), @@ -29034,6 +28723,21 @@ export const ListFilesParams = Schema.Struct({ "description": "Workspace to scope the request to. Defaults to the caller’s default workspace.", "format": "uuid" }) + ), + "provider": Schema.optionalKey(FileProvider), + "after": Schema.optionalKey( + Schema.String.annotate({ "description": "OpenAI-style forward cursor: the id to list after." }) + ), + "after_id": Schema.optionalKey( + Schema.String.annotate({ "description": "Anthropic-style forward cursor: the id to list after." }) + ), + "before_id": Schema.optionalKey( + Schema.String.annotate({ "description": "Anthropic-style reverse cursor. Not supported by OpenRouter storage." }) + ), + "order": Schema.optionalKey( + Schema.Literals(["asc", "desc"]).annotate({ + "description": "Sort direction. Only `asc` is supported by OpenRouter storage." + }) ) }) export type ListFiles200 = FileListResponse @@ -29042,15 +28746,22 @@ export type ListFiles400 = BadRequestResponse export const ListFiles400 = BadRequestResponse export type ListFiles401 = UnauthorizedResponse export const ListFiles401 = UnauthorizedResponse +export type ListFiles403 = ForbiddenResponse +export const ListFiles403 = ForbiddenResponse export type ListFiles429 = TooManyRequestsResponse export const ListFiles429 = TooManyRequestsResponse export type ListFiles500 = InternalServerResponse export const ListFiles500 = InternalServerResponse +export type ListFiles502 = BadGatewayResponse +export const ListFiles502 = BadGatewayResponse +export type ListFiles503 = ServiceUnavailableResponse +export const ListFiles503 = ServiceUnavailableResponse export type UploadFileParams = { readonly "HTTP-Referer"?: string readonly "X-OpenRouter-Title"?: string readonly "X-OpenRouter-Categories"?: string readonly "workspace_id"?: string + readonly "provider"?: FileProvider } export const UploadFileParams = Schema.Struct({ "HTTP-Referer": Schema.optionalKey(Schema.String), @@ -29061,12 +28772,13 @@ export const UploadFileParams = Schema.Struct({ "description": "Workspace to scope the request to. Defaults to the caller’s default workspace.", "format": "uuid" }) - ) + ), + "provider": Schema.optionalKey(FileProvider) }) export type UploadFileRequestFormData = { readonly "file": string } export const UploadFileRequestFormData = Schema.Struct({ "file": Schema.String.annotate({ "format": "binary" }) }) -export type UploadFile200 = FileMetadata -export const UploadFile200 = FileMetadata +export type UploadFile200 = FileResponse +export const UploadFile200 = FileResponse export type UploadFile400 = BadRequestResponse export const UploadFile400 = BadRequestResponse export type UploadFile401 = UnauthorizedResponse @@ -29079,11 +28791,16 @@ export type UploadFile429 = TooManyRequestsResponse export const UploadFile429 = TooManyRequestsResponse export type UploadFile500 = InternalServerResponse export const UploadFile500 = InternalServerResponse +export type UploadFile502 = BadGatewayResponse +export const UploadFile502 = BadGatewayResponse +export type UploadFile503 = ServiceUnavailableResponse +export const UploadFile503 = ServiceUnavailableResponse export type GetFileMetadataParams = { readonly "HTTP-Referer"?: string readonly "X-OpenRouter-Title"?: string readonly "X-OpenRouter-Categories"?: string readonly "workspace_id"?: string + readonly "provider"?: FileProvider } export const GetFileMetadataParams = Schema.Struct({ "HTTP-Referer": Schema.optionalKey(Schema.String), @@ -29094,23 +28811,31 @@ export const GetFileMetadataParams = Schema.Struct({ "description": "Workspace to scope the request to. Defaults to the caller’s default workspace.", "format": "uuid" }) - ) + ), + "provider": Schema.optionalKey(FileProvider) }) -export type GetFileMetadata200 = FileMetadata -export const GetFileMetadata200 = FileMetadata +export type GetFileMetadata200 = FileResponse +export const GetFileMetadata200 = FileResponse export type GetFileMetadata401 = UnauthorizedResponse export const GetFileMetadata401 = UnauthorizedResponse +export type GetFileMetadata403 = ForbiddenResponse +export const GetFileMetadata403 = ForbiddenResponse export type GetFileMetadata404 = NotFoundResponse export const GetFileMetadata404 = NotFoundResponse export type GetFileMetadata429 = TooManyRequestsResponse export const GetFileMetadata429 = TooManyRequestsResponse export type GetFileMetadata500 = InternalServerResponse export const GetFileMetadata500 = InternalServerResponse +export type GetFileMetadata502 = BadGatewayResponse +export const GetFileMetadata502 = BadGatewayResponse +export type GetFileMetadata503 = ServiceUnavailableResponse +export const GetFileMetadata503 = ServiceUnavailableResponse export type DeleteFileParams = { readonly "HTTP-Referer"?: string readonly "X-OpenRouter-Title"?: string readonly "X-OpenRouter-Categories"?: string readonly "workspace_id"?: string + readonly "provider"?: FileProvider } export const DeleteFileParams = Schema.Struct({ "HTTP-Referer": Schema.optionalKey(Schema.String), @@ -29121,23 +28846,31 @@ export const DeleteFileParams = Schema.Struct({ "description": "Workspace to scope the request to. Defaults to the caller’s default workspace.", "format": "uuid" }) - ) + ), + "provider": Schema.optionalKey(FileProvider) }) export type DeleteFile200 = FileDeleteResponse export const DeleteFile200 = FileDeleteResponse export type DeleteFile401 = UnauthorizedResponse export const DeleteFile401 = UnauthorizedResponse +export type DeleteFile403 = ForbiddenResponse +export const DeleteFile403 = ForbiddenResponse export type DeleteFile404 = NotFoundResponse export const DeleteFile404 = NotFoundResponse export type DeleteFile429 = TooManyRequestsResponse export const DeleteFile429 = TooManyRequestsResponse export type DeleteFile500 = InternalServerResponse export const DeleteFile500 = InternalServerResponse +export type DeleteFile502 = BadGatewayResponse +export const DeleteFile502 = BadGatewayResponse +export type DeleteFile503 = ServiceUnavailableResponse +export const DeleteFile503 = ServiceUnavailableResponse export type DownloadFileContentParams = { readonly "HTTP-Referer"?: string readonly "X-OpenRouter-Title"?: string readonly "X-OpenRouter-Categories"?: string readonly "workspace_id"?: string + readonly "provider"?: FileProvider } export const DownloadFileContentParams = Schema.Struct({ "HTTP-Referer": Schema.optionalKey(Schema.String), @@ -29148,18 +28881,25 @@ export const DownloadFileContentParams = Schema.Struct({ "description": "Workspace to scope the request to. Defaults to the caller’s default workspace.", "format": "uuid" }) - ) + ), + "provider": Schema.optionalKey(FileProvider) }) export type DownloadFileContent400 = BadRequestResponse export const DownloadFileContent400 = BadRequestResponse export type DownloadFileContent401 = UnauthorizedResponse export const DownloadFileContent401 = UnauthorizedResponse +export type DownloadFileContent403 = ForbiddenResponse +export const DownloadFileContent403 = ForbiddenResponse export type DownloadFileContent404 = NotFoundResponse export const DownloadFileContent404 = NotFoundResponse export type DownloadFileContent429 = TooManyRequestsResponse export const DownloadFileContent429 = TooManyRequestsResponse export type DownloadFileContent500 = InternalServerResponse export const DownloadFileContent500 = InternalServerResponse +export type DownloadFileContent502 = BadGatewayResponse +export const DownloadFileContent502 = BadGatewayResponse +export type DownloadFileContent503 = ServiceUnavailableResponse +export const DownloadFileContent503 = ServiceUnavailableResponse export type GetGenerationParams = { readonly "HTTP-Referer"?: string readonly "X-OpenRouter-Title"?: string @@ -30890,6 +30630,8 @@ export type UpdateObservabilityDestination400 = BadRequestResponse export const UpdateObservabilityDestination400 = BadRequestResponse export type UpdateObservabilityDestination401 = UnauthorizedResponse export const UpdateObservabilityDestination401 = UnauthorizedResponse +export type UpdateObservabilityDestination403 = ForbiddenResponse +export const UpdateObservabilityDestination403 = ForbiddenResponse export type UpdateObservabilityDestination404 = NotFoundResponse export const UpdateObservabilityDestination404 = NotFoundResponse export type UpdateObservabilityDestination409 = ConflictResponse @@ -32381,6 +32123,165 @@ export type CreateResponses524 = EdgeNetworkTimeoutResponse export const CreateResponses524 = EdgeNetworkTimeoutResponse export type CreateResponses529 = ProviderOverloadedResponse export const CreateResponses529 = ProviderOverloadedResponse +export type ListScimGroupMappingsParams = { + readonly "HTTP-Referer"?: string + readonly "X-OpenRouter-Title"?: string + readonly "X-OpenRouter-Categories"?: string + readonly "offset"?: number | null + readonly "limit"?: number +} +export const ListScimGroupMappingsParams = Schema.Struct({ + "HTTP-Referer": Schema.optionalKey(Schema.String), + "X-OpenRouter-Title": Schema.optionalKey(Schema.String), + "X-OpenRouter-Categories": Schema.optionalKey(Schema.String), + "offset": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]).annotate({ "description": "Number of records to skip for pagination" }) + ), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "description": "Maximum number of records to return (max 100)" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })).check( + Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" }) + ) + ) +}) +export type ListScimGroupMappings200 = ListScimGroupMappingsResponse +export const ListScimGroupMappings200 = ListScimGroupMappingsResponse +export type ListScimGroupMappings401 = UnauthorizedResponse +export const ListScimGroupMappings401 = UnauthorizedResponse +export type ListScimGroupMappings404 = NotFoundResponse +export const ListScimGroupMappings404 = NotFoundResponse +export type ListScimGroupMappings500 = InternalServerResponse +export const ListScimGroupMappings500 = InternalServerResponse +export type CreateScimGroupMappingParams = { + readonly "HTTP-Referer"?: string + readonly "X-OpenRouter-Title"?: string + readonly "X-OpenRouter-Categories"?: string +} +export const CreateScimGroupMappingParams = Schema.Struct({ + "HTTP-Referer": Schema.optionalKey(Schema.String), + "X-OpenRouter-Title": Schema.optionalKey(Schema.String), + "X-OpenRouter-Categories": Schema.optionalKey(Schema.String) +}) +export type CreateScimGroupMappingRequestJson = CreateScimGroupMappingRequest +export const CreateScimGroupMappingRequestJson = CreateScimGroupMappingRequest +export type CreateScimGroupMapping201 = CreateScimGroupMappingResponse +export const CreateScimGroupMapping201 = CreateScimGroupMappingResponse +export type CreateScimGroupMapping400 = BadRequestResponse +export const CreateScimGroupMapping400 = BadRequestResponse +export type CreateScimGroupMapping401 = UnauthorizedResponse +export const CreateScimGroupMapping401 = UnauthorizedResponse +export type CreateScimGroupMapping404 = NotFoundResponse +export const CreateScimGroupMapping404 = NotFoundResponse +export type CreateScimGroupMapping409 = ConflictResponse +export const CreateScimGroupMapping409 = ConflictResponse +export type CreateScimGroupMapping500 = InternalServerResponse +export const CreateScimGroupMapping500 = InternalServerResponse +export type GetScimGroupMappingParams = { + readonly "HTTP-Referer"?: string + readonly "X-OpenRouter-Title"?: string + readonly "X-OpenRouter-Categories"?: string +} +export const GetScimGroupMappingParams = Schema.Struct({ + "HTTP-Referer": Schema.optionalKey(Schema.String), + "X-OpenRouter-Title": Schema.optionalKey(Schema.String), + "X-OpenRouter-Categories": Schema.optionalKey(Schema.String) +}) +export type GetScimGroupMapping200 = GetScimGroupMappingResponse +export const GetScimGroupMapping200 = GetScimGroupMappingResponse +export type GetScimGroupMapping401 = UnauthorizedResponse +export const GetScimGroupMapping401 = UnauthorizedResponse +export type GetScimGroupMapping404 = NotFoundResponse +export const GetScimGroupMapping404 = NotFoundResponse +export type GetScimGroupMapping500 = InternalServerResponse +export const GetScimGroupMapping500 = InternalServerResponse +export type DeleteScimGroupMappingParams = { + readonly "HTTP-Referer"?: string + readonly "X-OpenRouter-Title"?: string + readonly "X-OpenRouter-Categories"?: string + readonly "keep_members": "true" | "false" | boolean +} +export const DeleteScimGroupMappingParams = Schema.Struct({ + "HTTP-Referer": Schema.optionalKey(Schema.String), + "X-OpenRouter-Title": Schema.optionalKey(Schema.String), + "X-OpenRouter-Categories": Schema.optionalKey(Schema.String), + "keep_members": Schema.Union([Schema.Literals(["true", "false"]), Schema.Boolean]).annotate({ + "description": + "Required. Whether to keep workspace members after deleting the mapping. `false` **removes** the members this mapping granted access to; `true` deletes the mapping while leaving membership intact as manually-managed. There is deliberately no default — omitting it returns `400` so the destructive path cannot be reached by accident. Mirrors the dashboard, whose `DeleteMappingSchema.keepMembers` is likewise required." + }) +}) +export type DeleteScimGroupMapping200 = DeleteScimGroupMappingResponse +export const DeleteScimGroupMapping200 = DeleteScimGroupMappingResponse +export type DeleteScimGroupMapping400 = BadRequestResponse +export const DeleteScimGroupMapping400 = BadRequestResponse +export type DeleteScimGroupMapping401 = UnauthorizedResponse +export const DeleteScimGroupMapping401 = UnauthorizedResponse +export type DeleteScimGroupMapping404 = NotFoundResponse +export const DeleteScimGroupMapping404 = NotFoundResponse +export type DeleteScimGroupMapping500 = InternalServerResponse +export const DeleteScimGroupMapping500 = InternalServerResponse +export type UpdateScimGroupMappingParams = { + readonly "HTTP-Referer"?: string + readonly "X-OpenRouter-Title"?: string + readonly "X-OpenRouter-Categories"?: string +} +export const UpdateScimGroupMappingParams = Schema.Struct({ + "HTTP-Referer": Schema.optionalKey(Schema.String), + "X-OpenRouter-Title": Schema.optionalKey(Schema.String), + "X-OpenRouter-Categories": Schema.optionalKey(Schema.String) +}) +export type UpdateScimGroupMappingRequestJson = UpdateScimGroupMappingRequest +export const UpdateScimGroupMappingRequestJson = UpdateScimGroupMappingRequest +export type UpdateScimGroupMapping200 = UpdateScimGroupMappingResponse +export const UpdateScimGroupMapping200 = UpdateScimGroupMappingResponse +export type UpdateScimGroupMapping400 = BadRequestResponse +export const UpdateScimGroupMapping400 = BadRequestResponse +export type UpdateScimGroupMapping401 = UnauthorizedResponse +export const UpdateScimGroupMapping401 = UnauthorizedResponse +export type UpdateScimGroupMapping404 = NotFoundResponse +export const UpdateScimGroupMapping404 = NotFoundResponse +export type UpdateScimGroupMapping500 = InternalServerResponse +export const UpdateScimGroupMapping500 = InternalServerResponse +export type ListScimGroupsParams = { + readonly "HTTP-Referer"?: string + readonly "X-OpenRouter-Title"?: string + readonly "X-OpenRouter-Categories"?: string + readonly "offset"?: number | null + readonly "limit"?: number +} +export const ListScimGroupsParams = Schema.Struct({ + "HTTP-Referer": Schema.optionalKey(Schema.String), + "X-OpenRouter-Title": Schema.optionalKey(Schema.String), + "X-OpenRouter-Categories": Schema.optionalKey(Schema.String), + "offset": Schema.optionalKey( + Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })).check( + Schema.isGreaterThanOrEqualTo(0).annotate({ "expected": "a value greater than or equal to 0" }) + ), + Schema.Null + ]).annotate({ "description": "Number of records to skip for pagination" }) + ), + "limit": Schema.optionalKey( + Schema.Number.annotate({ "description": "Maximum number of records to return (max 100)" }).check( + Schema.isInt().annotate({ "expected": "an integer" }) + ).check(Schema.isGreaterThanOrEqualTo(1).annotate({ "expected": "a value greater than or equal to 1" })).check( + Schema.isLessThanOrEqualTo(100).annotate({ "expected": "a value less than or equal to 100" }) + ) + ) +}) +export type ListScimGroups200 = ListScimGroupsResponse +export const ListScimGroups200 = ListScimGroupsResponse +export type ListScimGroups401 = UnauthorizedResponse +export const ListScimGroups401 = UnauthorizedResponse +export type ListScimGroups404 = NotFoundResponse +export const ListScimGroups404 = NotFoundResponse +export type ListScimGroups500 = InternalServerResponse +export const ListScimGroups500 = InternalServerResponse export type CreateVideosParams = { readonly "HTTP-Referer"?: string readonly "X-OpenRouter-Title"?: string @@ -32607,6 +32508,26 @@ export type ListWorkspaceBudgets404 = NotFoundResponse export const ListWorkspaceBudgets404 = NotFoundResponse export type ListWorkspaceBudgets500 = InternalServerResponse export const ListWorkspaceBudgets500 = InternalServerResponse +export type GetWorkspaceBudgetParams = { + readonly "HTTP-Referer"?: string + readonly "X-OpenRouter-Title"?: string + readonly "X-OpenRouter-Categories"?: string +} +export const GetWorkspaceBudgetParams = Schema.Struct({ + "HTTP-Referer": Schema.optionalKey(Schema.String), + "X-OpenRouter-Title": Schema.optionalKey(Schema.String), + "X-OpenRouter-Categories": Schema.optionalKey(Schema.String) +}) +export type GetWorkspaceBudget200 = GetWorkspaceBudgetResponse +export const GetWorkspaceBudget200 = GetWorkspaceBudgetResponse +export type GetWorkspaceBudget400 = BadRequestResponse +export const GetWorkspaceBudget400 = BadRequestResponse +export type GetWorkspaceBudget401 = UnauthorizedResponse +export const GetWorkspaceBudget401 = UnauthorizedResponse +export type GetWorkspaceBudget404 = NotFoundResponse +export const GetWorkspaceBudget404 = NotFoundResponse +export type GetWorkspaceBudget500 = InternalServerResponse +export const GetWorkspaceBudget500 = InternalServerResponse export type UpsertWorkspaceBudgetParams = { readonly "HTTP-Referer"?: string readonly "X-OpenRouter-Title"?: string @@ -32641,6 +32562,8 @@ export const DeleteWorkspaceBudgetParams = Schema.Struct({ }) export type DeleteWorkspaceBudget200 = DeleteWorkspaceBudgetResponse export const DeleteWorkspaceBudget200 = DeleteWorkspaceBudgetResponse +export type DeleteWorkspaceBudget400 = BadRequestResponse +export const DeleteWorkspaceBudget400 = BadRequestResponse export type DeleteWorkspaceBudget401 = UnauthorizedResponse export const DeleteWorkspaceBudget401 = UnauthorizedResponse export type DeleteWorkspaceBudget404 = NotFoundResponse @@ -32836,7 +32759,9 @@ export const make = ( HttpClientRequest.setUrlParams({ "date": options?.params?.["date"] as any, "api_key_hash": options?.params?.["api_key_hash"] as any, - "user_id": options?.params?.["user_id"] as any + "user_id": options?.params?.["user_id"] as any, + "group_by": options?.params?.["group_by"] as any, + "workspace_id": options?.params?.["workspace_id"] as any }), HttpClientRequest.setHeaders({ "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, @@ -33277,7 +33202,12 @@ export const make = ( HttpClientRequest.setUrlParams({ "limit": options?.params?.["limit"] as any, "cursor": options?.params?.["cursor"] as any, - "workspace_id": options?.params?.["workspace_id"] as any + "workspace_id": options?.params?.["workspace_id"] as any, + "provider": options?.params?.["provider"] as any, + "after": options?.params?.["after"] as any, + "after_id": options?.params?.["after_id"] as any, + "before_id": options?.params?.["before_id"] as any, + "order": options?.params?.["order"] as any }), HttpClientRequest.setHeaders({ "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, @@ -33288,14 +33218,20 @@ export const make = ( "2xx": decodeSuccess(ListFiles200), "400": decodeError("ListFiles400", ListFiles400), "401": decodeError("ListFiles401", ListFiles401), + "403": decodeError("ListFiles403", ListFiles403), "429": decodeError("ListFiles429", ListFiles429), "500": decodeError("ListFiles500", ListFiles500), + "502": decodeError("ListFiles502", ListFiles502), + "503": decodeError("ListFiles503", ListFiles503), orElse: unexpectedStatus })) ), "uploadFile": (options) => HttpClientRequest.post(`/files`).pipe( - HttpClientRequest.setUrlParams({ "workspace_id": options.params?.["workspace_id"] as any }), + HttpClientRequest.setUrlParams({ + "workspace_id": options.params?.["workspace_id"] as any, + "provider": options.params?.["provider"] as any + }), HttpClientRequest.setHeaders({ "HTTP-Referer": options.params?.["HTTP-Referer"] ?? undefined, "X-OpenRouter-Title": options.params?.["X-OpenRouter-Title"] ?? undefined, @@ -33310,12 +33246,17 @@ export const make = ( "413": decodeError("UploadFile413", UploadFile413), "429": decodeError("UploadFile429", UploadFile429), "500": decodeError("UploadFile500", UploadFile500), + "502": decodeError("UploadFile502", UploadFile502), + "503": decodeError("UploadFile503", UploadFile503), orElse: unexpectedStatus })) ), "getFileMetadata": (fileId, options) => HttpClientRequest.get(`/files/${fileId}`).pipe( - HttpClientRequest.setUrlParams({ "workspace_id": options?.params?.["workspace_id"] as any }), + HttpClientRequest.setUrlParams({ + "workspace_id": options?.params?.["workspace_id"] as any, + "provider": options?.params?.["provider"] as any + }), HttpClientRequest.setHeaders({ "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, "X-OpenRouter-Title": options?.params?.["X-OpenRouter-Title"] ?? undefined, @@ -33324,15 +33265,21 @@ export const make = ( withResponse(options?.config)(HttpClientResponse.matchStatus({ "2xx": decodeSuccess(GetFileMetadata200), "401": decodeError("GetFileMetadata401", GetFileMetadata401), + "403": decodeError("GetFileMetadata403", GetFileMetadata403), "404": decodeError("GetFileMetadata404", GetFileMetadata404), "429": decodeError("GetFileMetadata429", GetFileMetadata429), "500": decodeError("GetFileMetadata500", GetFileMetadata500), + "502": decodeError("GetFileMetadata502", GetFileMetadata502), + "503": decodeError("GetFileMetadata503", GetFileMetadata503), orElse: unexpectedStatus })) ), "deleteFile": (fileId, options) => HttpClientRequest.delete(`/files/${fileId}`).pipe( - HttpClientRequest.setUrlParams({ "workspace_id": options?.params?.["workspace_id"] as any }), + HttpClientRequest.setUrlParams({ + "workspace_id": options?.params?.["workspace_id"] as any, + "provider": options?.params?.["provider"] as any + }), HttpClientRequest.setHeaders({ "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, "X-OpenRouter-Title": options?.params?.["X-OpenRouter-Title"] ?? undefined, @@ -33341,15 +33288,21 @@ export const make = ( withResponse(options?.config)(HttpClientResponse.matchStatus({ "2xx": decodeSuccess(DeleteFile200), "401": decodeError("DeleteFile401", DeleteFile401), + "403": decodeError("DeleteFile403", DeleteFile403), "404": decodeError("DeleteFile404", DeleteFile404), "429": decodeError("DeleteFile429", DeleteFile429), "500": decodeError("DeleteFile500", DeleteFile500), + "502": decodeError("DeleteFile502", DeleteFile502), + "503": decodeError("DeleteFile503", DeleteFile503), orElse: unexpectedStatus })) ), "downloadFileContent": (fileId, options) => HttpClientRequest.get(`/files/${fileId}/content`).pipe( - HttpClientRequest.setUrlParams({ "workspace_id": options?.params?.["workspace_id"] as any }), + HttpClientRequest.setUrlParams({ + "workspace_id": options?.params?.["workspace_id"] as any, + "provider": options?.params?.["provider"] as any + }), HttpClientRequest.setHeaders({ "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, "X-OpenRouter-Title": options?.params?.["X-OpenRouter-Title"] ?? undefined, @@ -33358,15 +33311,21 @@ export const make = ( withResponse(options?.config)(HttpClientResponse.matchStatus({ "400": decodeError("DownloadFileContent400", DownloadFileContent400), "401": decodeError("DownloadFileContent401", DownloadFileContent401), + "403": decodeError("DownloadFileContent403", DownloadFileContent403), "404": decodeError("DownloadFileContent404", DownloadFileContent404), "429": decodeError("DownloadFileContent429", DownloadFileContent429), "500": decodeError("DownloadFileContent500", DownloadFileContent500), + "502": decodeError("DownloadFileContent502", DownloadFileContent502), + "503": decodeError("DownloadFileContent503", DownloadFileContent503), orElse: unexpectedStatus })) ), "downloadFileContentStream": (fileId, options) => HttpClientRequest.get(`/files/${fileId}/content`).pipe( - HttpClientRequest.setUrlParams({ "workspace_id": options?.params?.["workspace_id"] as any }), + HttpClientRequest.setUrlParams({ + "workspace_id": options?.params?.["workspace_id"] as any, + "provider": options?.params?.["provider"] as any + }), HttpClientRequest.setHeaders({ "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, "X-OpenRouter-Title": options?.params?.["X-OpenRouter-Title"] ?? undefined, @@ -34049,6 +34008,7 @@ export const make = ( "2xx": decodeSuccess(UpdateObservabilityDestination200), "400": decodeError("UpdateObservabilityDestination400", UpdateObservabilityDestination400), "401": decodeError("UpdateObservabilityDestination401", UpdateObservabilityDestination401), + "403": decodeError("UpdateObservabilityDestination403", UpdateObservabilityDestination403), "404": decodeError("UpdateObservabilityDestination404", UpdateObservabilityDestination404), "409": decodeError("UpdateObservabilityDestination409", UpdateObservabilityDestination409), "500": decodeError("UpdateObservabilityDestination500", UpdateObservabilityDestination500), @@ -34287,6 +34247,111 @@ export const make = ( HttpClientRequest.bodyJsonUnsafe(options.payload), sseRequest(CreateResponses200Sse) ), + "listScimGroupMappings": (options) => + HttpClientRequest.get(`/scim/group-mappings`).pipe( + HttpClientRequest.setUrlParams({ + "offset": options?.params?.["offset"] as any, + "limit": options?.params?.["limit"] as any + }), + HttpClientRequest.setHeaders({ + "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, + "X-OpenRouter-Title": options?.params?.["X-OpenRouter-Title"] ?? undefined, + "X-OpenRouter-Categories": options?.params?.["X-OpenRouter-Categories"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(ListScimGroupMappings200), + "401": decodeError("ListScimGroupMappings401", ListScimGroupMappings401), + "404": decodeError("ListScimGroupMappings404", ListScimGroupMappings404), + "500": decodeError("ListScimGroupMappings500", ListScimGroupMappings500), + orElse: unexpectedStatus + })) + ), + "createScimGroupMapping": (options) => + HttpClientRequest.post(`/scim/group-mappings`).pipe( + HttpClientRequest.setHeaders({ + "HTTP-Referer": options.params?.["HTTP-Referer"] ?? undefined, + "X-OpenRouter-Title": options.params?.["X-OpenRouter-Title"] ?? undefined, + "X-OpenRouter-Categories": options.params?.["X-OpenRouter-Categories"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(CreateScimGroupMapping201), + "400": decodeError("CreateScimGroupMapping400", CreateScimGroupMapping400), + "401": decodeError("CreateScimGroupMapping401", CreateScimGroupMapping401), + "404": decodeError("CreateScimGroupMapping404", CreateScimGroupMapping404), + "409": decodeError("CreateScimGroupMapping409", CreateScimGroupMapping409), + "500": decodeError("CreateScimGroupMapping500", CreateScimGroupMapping500), + orElse: unexpectedStatus + })) + ), + "getScimGroupMapping": (id, options) => + HttpClientRequest.get(`/scim/group-mappings/${id}`).pipe( + HttpClientRequest.setHeaders({ + "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, + "X-OpenRouter-Title": options?.params?.["X-OpenRouter-Title"] ?? undefined, + "X-OpenRouter-Categories": options?.params?.["X-OpenRouter-Categories"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(GetScimGroupMapping200), + "401": decodeError("GetScimGroupMapping401", GetScimGroupMapping401), + "404": decodeError("GetScimGroupMapping404", GetScimGroupMapping404), + "500": decodeError("GetScimGroupMapping500", GetScimGroupMapping500), + orElse: unexpectedStatus + })) + ), + "deleteScimGroupMapping": (id, options) => + HttpClientRequest.delete(`/scim/group-mappings/${id}`).pipe( + HttpClientRequest.setUrlParams({ "keep_members": options.params["keep_members"] as any }), + HttpClientRequest.setHeaders({ + "HTTP-Referer": options.params["HTTP-Referer"] ?? undefined, + "X-OpenRouter-Title": options.params["X-OpenRouter-Title"] ?? undefined, + "X-OpenRouter-Categories": options.params["X-OpenRouter-Categories"] ?? undefined + }), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(DeleteScimGroupMapping200), + "400": decodeError("DeleteScimGroupMapping400", DeleteScimGroupMapping400), + "401": decodeError("DeleteScimGroupMapping401", DeleteScimGroupMapping401), + "404": decodeError("DeleteScimGroupMapping404", DeleteScimGroupMapping404), + "500": decodeError("DeleteScimGroupMapping500", DeleteScimGroupMapping500), + orElse: unexpectedStatus + })) + ), + "updateScimGroupMapping": (id, options) => + HttpClientRequest.patch(`/scim/group-mappings/${id}`).pipe( + HttpClientRequest.setHeaders({ + "HTTP-Referer": options.params?.["HTTP-Referer"] ?? undefined, + "X-OpenRouter-Title": options.params?.["X-OpenRouter-Title"] ?? undefined, + "X-OpenRouter-Categories": options.params?.["X-OpenRouter-Categories"] ?? undefined + }), + HttpClientRequest.bodyJsonUnsafe(options.payload), + withResponse(options.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(UpdateScimGroupMapping200), + "400": decodeError("UpdateScimGroupMapping400", UpdateScimGroupMapping400), + "401": decodeError("UpdateScimGroupMapping401", UpdateScimGroupMapping401), + "404": decodeError("UpdateScimGroupMapping404", UpdateScimGroupMapping404), + "500": decodeError("UpdateScimGroupMapping500", UpdateScimGroupMapping500), + orElse: unexpectedStatus + })) + ), + "listScimGroups": (options) => + HttpClientRequest.get(`/scim/groups`).pipe( + HttpClientRequest.setUrlParams({ + "offset": options?.params?.["offset"] as any, + "limit": options?.params?.["limit"] as any + }), + HttpClientRequest.setHeaders({ + "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, + "X-OpenRouter-Title": options?.params?.["X-OpenRouter-Title"] ?? undefined, + "X-OpenRouter-Categories": options?.params?.["X-OpenRouter-Categories"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(ListScimGroups200), + "401": decodeError("ListScimGroups401", ListScimGroups401), + "404": decodeError("ListScimGroups404", ListScimGroups404), + "500": decodeError("ListScimGroups500", ListScimGroups500), + orElse: unexpectedStatus + })) + ), "createVideos": (options) => HttpClientRequest.post(`/videos`).pipe( HttpClientRequest.setHeaders({ @@ -34452,6 +34517,22 @@ export const make = ( orElse: unexpectedStatus })) ), + "getWorkspaceBudget": (id, interval, options) => + HttpClientRequest.get(`/workspaces/${id}/budgets/${interval}`).pipe( + HttpClientRequest.setHeaders({ + "HTTP-Referer": options?.params?.["HTTP-Referer"] ?? undefined, + "X-OpenRouter-Title": options?.params?.["X-OpenRouter-Title"] ?? undefined, + "X-OpenRouter-Categories": options?.params?.["X-OpenRouter-Categories"] ?? undefined + }), + withResponse(options?.config)(HttpClientResponse.matchStatus({ + "2xx": decodeSuccess(GetWorkspaceBudget200), + "400": decodeError("GetWorkspaceBudget400", GetWorkspaceBudget400), + "401": decodeError("GetWorkspaceBudget401", GetWorkspaceBudget401), + "404": decodeError("GetWorkspaceBudget404", GetWorkspaceBudget404), + "500": decodeError("GetWorkspaceBudget500", GetWorkspaceBudget500), + orElse: unexpectedStatus + })) + ), "upsertWorkspaceBudget": (id, interval, options) => HttpClientRequest.put(`/workspaces/${id}/budgets/${interval}`).pipe( HttpClientRequest.setHeaders({ @@ -34478,6 +34559,7 @@ export const make = ( }), withResponse(options?.config)(HttpClientResponse.matchStatus({ "2xx": decodeSuccess(DeleteWorkspaceBudget200), + "400": decodeError("DeleteWorkspaceBudget400", DeleteWorkspaceBudget400), "401": decodeError("DeleteWorkspaceBudget401", DeleteWorkspaceBudget401), "404": decodeError("DeleteWorkspaceBudget404", DeleteWorkspaceBudget404), "500": decodeError("DeleteWorkspaceBudget500", DeleteWorkspaceBudget500), @@ -34546,7 +34628,7 @@ export const make = ( export interface OpenRouterClient { readonly httpClient: HttpClient.HttpClient /** - * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. [Management key](/docs/guides/overview/auth/management-api-keys) required. + * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. Pass `workspace_id` to scope the response to a single workspace. Pass `group_by=workspace` to split each row per workspace and include `workspace_id` on every item; by default rows are aggregated across workspaces and `workspace_id` is not returned. Activity recorded before workspace resolution existed is permanently attributed to the account default workspace (no backfill is possible). [Management key](/docs/guides/overview/auth/management-api-keys) required. */ readonly "getUserActivity": ( options: { @@ -34683,7 +34765,7 @@ export interface OpenRouterClient { | OpenRouterClientError<"CreateAuthKeysCode500", typeof CreateAuthKeysCode500.Type> > /** - * Unified benchmark endpoint that aggregates scores from multiple benchmark sources (Artificial Analysis, Design Arena). Filter by source to reproduce the exact shapes from the legacy per-source endpoints, or use task_type to find models suited for specific workloads. Authenticate with any valid OpenRouter API key. Rate-limited to 30 requests/minute per key and 500 requests/day per account. + * Unified benchmark endpoint that aggregates scores from multiple benchmark sources (Artificial Analysis, Design Arena, and OpenRouter's own tau-bench and GPQA evals). Filter by source to reproduce the exact shapes from the legacy per-source endpoints, or use task_type to find models suited for specific workloads. Authenticate with any valid OpenRouter API key. Rate-limited to 30 requests/minute per key and 500 requests/day per account. */ readonly "getBenchmarks": ( options: @@ -34714,7 +34796,7 @@ export interface OpenRouterClient { | OpenRouterClientError<"ListBYOKKeys500", typeof ListBYOKKeys500.Type> > /** - * Create a new bring-your-own-key (BYOK) provider credential. The raw key is encrypted at rest and never returned in API responses. Defaults to the authenticated entity's default workspace; use the `workspace_id` body field to scope to a different workspace. Treat the raw key as write-only; it is never returned after creation. [Management key](/docs/guides/overview/auth/management-api-keys) required. + * Create a new bring-your-own-key (BYOK) provider credential. The raw key is encrypted at rest and never returned in API responses. When `workspace_id` is omitted, the credential is created in the default workspace; if that default has been deleted, the request returns a 400 and you must pass `workspace_id` explicitly. Treat the raw key as write-only; it is never returned after creation. [Management key](/docs/guides/overview/auth/management-api-keys) required. */ readonly "createBYOKKey": ( options: { @@ -35051,11 +35133,14 @@ export interface OpenRouterClient { | SchemaError | OpenRouterClientError<"ListFiles400", typeof ListFiles400.Type> | OpenRouterClientError<"ListFiles401", typeof ListFiles401.Type> + | OpenRouterClientError<"ListFiles403", typeof ListFiles403.Type> | OpenRouterClientError<"ListFiles429", typeof ListFiles429.Type> | OpenRouterClientError<"ListFiles500", typeof ListFiles500.Type> + | OpenRouterClientError<"ListFiles502", typeof ListFiles502.Type> + | OpenRouterClientError<"ListFiles503", typeof ListFiles503.Type> > /** - * Uploads a file to be referenced in future API calls. The file is stored under the workspace of the authenticating API key. Maximum file size: 100 MB. + * Uploads a file to be referenced in future API calls. The file is stored under the workspace of the authenticating API key. Maximum file size: 100 MB; empty files are rejected. The file type is determined from the file contents — not the filename or the declared content type — and must be a PDF, a PNG/JPEG/GIF/WebP image, a DOCX/XLSX/PPTX document, an MP3/WAV/FLAC/OGG audio file, or UTF-8 text. Text is reported by its structure as `application/json`, `application/x-ndjson`, `text/csv`, `text/markdown`, or `text/plain`. */ readonly "uploadFile": ( options: { @@ -35073,6 +35158,8 @@ export interface OpenRouterClient { | OpenRouterClientError<"UploadFile413", typeof UploadFile413.Type> | OpenRouterClientError<"UploadFile429", typeof UploadFile429.Type> | OpenRouterClientError<"UploadFile500", typeof UploadFile500.Type> + | OpenRouterClientError<"UploadFile502", typeof UploadFile502.Type> + | OpenRouterClientError<"UploadFile503", typeof UploadFile503.Type> > /** * Retrieves metadata for a single file owned by the requesting workspace. @@ -35088,9 +35175,12 @@ export interface OpenRouterClient { | HttpClientError.HttpClientError | SchemaError | OpenRouterClientError<"GetFileMetadata401", typeof GetFileMetadata401.Type> + | OpenRouterClientError<"GetFileMetadata403", typeof GetFileMetadata403.Type> | OpenRouterClientError<"GetFileMetadata404", typeof GetFileMetadata404.Type> | OpenRouterClientError<"GetFileMetadata429", typeof GetFileMetadata429.Type> | OpenRouterClientError<"GetFileMetadata500", typeof GetFileMetadata500.Type> + | OpenRouterClientError<"GetFileMetadata502", typeof GetFileMetadata502.Type> + | OpenRouterClientError<"GetFileMetadata503", typeof GetFileMetadata503.Type> > /** * Deletes a file owned by the requesting workspace. Deletion is irreversible. @@ -35105,9 +35195,12 @@ export interface OpenRouterClient { | HttpClientError.HttpClientError | SchemaError | OpenRouterClientError<"DeleteFile401", typeof DeleteFile401.Type> + | OpenRouterClientError<"DeleteFile403", typeof DeleteFile403.Type> | OpenRouterClientError<"DeleteFile404", typeof DeleteFile404.Type> | OpenRouterClientError<"DeleteFile429", typeof DeleteFile429.Type> | OpenRouterClientError<"DeleteFile500", typeof DeleteFile500.Type> + | OpenRouterClientError<"DeleteFile502", typeof DeleteFile502.Type> + | OpenRouterClientError<"DeleteFile503", typeof DeleteFile503.Type> > /** * Downloads the raw bytes of a file. Only files created server-side are downloadable; uploaded files return 400. @@ -35124,9 +35217,12 @@ export interface OpenRouterClient { | SchemaError | OpenRouterClientError<"DownloadFileContent400", typeof DownloadFileContent400.Type> | OpenRouterClientError<"DownloadFileContent401", typeof DownloadFileContent401.Type> + | OpenRouterClientError<"DownloadFileContent403", typeof DownloadFileContent403.Type> | OpenRouterClientError<"DownloadFileContent404", typeof DownloadFileContent404.Type> | OpenRouterClientError<"DownloadFileContent429", typeof DownloadFileContent429.Type> | OpenRouterClientError<"DownloadFileContent500", typeof DownloadFileContent500.Type> + | OpenRouterClientError<"DownloadFileContent502", typeof DownloadFileContent502.Type> + | OpenRouterClientError<"DownloadFileContent503", typeof DownloadFileContent503.Type> > /** * Downloads the raw bytes of a file. Only files created server-side are downloadable; uploaded files return 400. @@ -35257,7 +35353,7 @@ export interface OpenRouterClient { | OpenRouterClientError<"DeleteGuardrail500", typeof DeleteGuardrail500.Type> > /** - * Update an existing guardrail. Collection fields use replace semantics: send the full desired set on every update. [Management key](/docs/guides/overview/auth/management-api-keys) required. + * Update an existing guardrail, or materialize an unconfigured workspace default guardrail. Collection fields use replace semantics: send the full desired set on every update. [Management key](/docs/guides/overview/auth/management-api-keys) required. */ readonly "updateGuardrail": ( id: string, @@ -35788,6 +35884,7 @@ export interface OpenRouterClient { | SchemaError | OpenRouterClientError<"UpdateObservabilityDestination400", typeof UpdateObservabilityDestination400.Type> | OpenRouterClientError<"UpdateObservabilityDestination401", typeof UpdateObservabilityDestination401.Type> + | OpenRouterClientError<"UpdateObservabilityDestination403", typeof UpdateObservabilityDestination403.Type> | OpenRouterClientError<"UpdateObservabilityDestination404", typeof UpdateObservabilityDestination404.Type> | OpenRouterClientError<"UpdateObservabilityDestination409", typeof UpdateObservabilityDestination409.Type> | OpenRouterClientError<"UpdateObservabilityDestination500", typeof UpdateObservabilityDestination500.Type> @@ -36031,6 +36128,107 @@ export interface OpenRouterClient { HttpClientError.HttpClientError | SchemaError | Sse.Retry | Sse.SseError, typeof CreateResponses200Sse.DecodingServices > + /** + * List SCIM group-to-workspace mappings for the organization. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + readonly "listScimGroupMappings": ( + options: { + readonly params?: typeof ListScimGroupMappingsParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenRouterClientError<"ListScimGroupMappings401", typeof ListScimGroupMappings401.Type> + | OpenRouterClientError<"ListScimGroupMappings404", typeof ListScimGroupMappings404.Type> + | OpenRouterClientError<"ListScimGroupMappings500", typeof ListScimGroupMappings500.Type> + > + /** + * Create a SCIM group-to-workspace role mapping. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + readonly "createScimGroupMapping": ( + options: { + readonly params?: typeof CreateScimGroupMappingParams.Encoded | undefined + readonly payload: typeof CreateScimGroupMappingRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenRouterClientError<"CreateScimGroupMapping400", typeof CreateScimGroupMapping400.Type> + | OpenRouterClientError<"CreateScimGroupMapping401", typeof CreateScimGroupMapping401.Type> + | OpenRouterClientError<"CreateScimGroupMapping404", typeof CreateScimGroupMapping404.Type> + | OpenRouterClientError<"CreateScimGroupMapping409", typeof CreateScimGroupMapping409.Type> + | OpenRouterClientError<"CreateScimGroupMapping500", typeof CreateScimGroupMapping500.Type> + > + /** + * Get a SCIM group-to-workspace mapping. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + readonly "getScimGroupMapping": ( + id: string, + options: { + readonly params?: typeof GetScimGroupMappingParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenRouterClientError<"GetScimGroupMapping401", typeof GetScimGroupMapping401.Type> + | OpenRouterClientError<"GetScimGroupMapping404", typeof GetScimGroupMapping404.Type> + | OpenRouterClientError<"GetScimGroupMapping500", typeof GetScimGroupMapping500.Type> + > + /** + * Delete a SCIM group-to-workspace mapping. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + readonly "deleteScimGroupMapping": ( + id: string, + options: { readonly params: typeof DeleteScimGroupMappingParams.Encoded; readonly config?: Config | undefined } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenRouterClientError<"DeleteScimGroupMapping400", typeof DeleteScimGroupMapping400.Type> + | OpenRouterClientError<"DeleteScimGroupMapping401", typeof DeleteScimGroupMapping401.Type> + | OpenRouterClientError<"DeleteScimGroupMapping404", typeof DeleteScimGroupMapping404.Type> + | OpenRouterClientError<"DeleteScimGroupMapping500", typeof DeleteScimGroupMapping500.Type> + > + /** + * Update a SCIM group mapping role. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + readonly "updateScimGroupMapping": ( + id: string, + options: { + readonly params?: typeof UpdateScimGroupMappingParams.Encoded | undefined + readonly payload: typeof UpdateScimGroupMappingRequestJson.Encoded + readonly config?: Config | undefined + } + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenRouterClientError<"UpdateScimGroupMapping400", typeof UpdateScimGroupMapping400.Type> + | OpenRouterClientError<"UpdateScimGroupMapping401", typeof UpdateScimGroupMapping401.Type> + | OpenRouterClientError<"UpdateScimGroupMapping404", typeof UpdateScimGroupMapping404.Type> + | OpenRouterClientError<"UpdateScimGroupMapping500", typeof UpdateScimGroupMapping500.Type> + > + /** + * List SCIM groups for the organization. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + readonly "listScimGroups": ( + options: + | { readonly params?: typeof ListScimGroupsParams.Encoded | undefined; readonly config?: Config | undefined } + | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenRouterClientError<"ListScimGroups401", typeof ListScimGroups401.Type> + | OpenRouterClientError<"ListScimGroups404", typeof ListScimGroups404.Type> + | OpenRouterClientError<"ListScimGroups500", typeof ListScimGroups500.Type> + > /** * Submits a video generation request and returns a polling URL to check status */ @@ -36206,7 +36404,26 @@ export interface OpenRouterClient { | OpenRouterClientError<"ListWorkspaceBudgets500", typeof ListWorkspaceBudgets500.Type> > /** - * Create or update the budget for a given interval. Budget limits must strictly decrease as the interval narrows (lifetime > monthly > weekly > daily). [Management key](/docs/guides/overview/auth/management-api-keys) required. + * Retrieve the budget for a given interval. [Management key](/docs/guides/overview/auth/management-api-keys) required. + */ + readonly "getWorkspaceBudget": ( + id: string, + interval: string, + options: { + readonly params?: typeof GetWorkspaceBudgetParams.Encoded | undefined + readonly config?: Config | undefined + } | undefined + ) => Effect.Effect< + WithOptionalResponse, + | HttpClientError.HttpClientError + | SchemaError + | OpenRouterClientError<"GetWorkspaceBudget400", typeof GetWorkspaceBudget400.Type> + | OpenRouterClientError<"GetWorkspaceBudget401", typeof GetWorkspaceBudget401.Type> + | OpenRouterClientError<"GetWorkspaceBudget404", typeof GetWorkspaceBudget404.Type> + | OpenRouterClientError<"GetWorkspaceBudget500", typeof GetWorkspaceBudget500.Type> + > + /** + * Create or update the budget for a given interval. Budget limits must strictly decrease as the interval narrows (lifetime > monthly > weekly > daily). The optional `include_byok_in_budgets` flag is a workspace-wide setting: when provided it applies to every budget interval for the workspace, not just the interval in this request. Note that a change made here is applied to budget enforcement immediately, but an already-open workspace settings page in the web dashboard may keep showing the previous value until it is reloaded. [Management key](/docs/guides/overview/auth/management-api-keys) required. */ readonly "upsertWorkspaceBudget": ( id: string, @@ -36239,6 +36456,7 @@ export interface OpenRouterClient { WithOptionalResponse, | HttpClientError.HttpClientError | SchemaError + | OpenRouterClientError<"DeleteWorkspaceBudget400", typeof DeleteWorkspaceBudget400.Type> | OpenRouterClientError<"DeleteWorkspaceBudget401", typeof DeleteWorkspaceBudget401.Type> | OpenRouterClientError<"DeleteWorkspaceBudget404", typeof DeleteWorkspaceBudget404.Type> | OpenRouterClientError<"DeleteWorkspaceBudget500", typeof DeleteWorkspaceBudget500.Type>