import {z} from 'zod' export type Metadata = {[key: string]: string} | null; export type ServiceTier = 'auto' | 'default' | 'flex' | 'scale' | 'priority' | 'fast' | null; export type PromptCacheTTLEnum = '30m'; export type PromptCacheModeEnum = 'implicit' | 'explicit'; export type PromptCacheOptionsParam = {ttl?: PromptCacheTTLEnum | undefined, mode?: PromptCacheModeEnum | undefined}; export type ModelIdsResponses = 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' | '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 type ResponseFormatJsonSchemaSchema = {[key: string]: unknown}; export type TextResponseFormatConfiguration = {type: 'text'} | {type: 'json_schema', description?: string | undefined, name: string, schema: ResponseFormatJsonSchemaSchema, strict?: (boolean | null) | undefined} | {type: 'json_object'}; export type Verbosity = 'low' | 'medium' | 'high' | null; export type ResponseTextParam = {format?: TextResponseFormatConfiguration | undefined, verbosity?: Verbosity | undefined}; export type CallableToolAllowedCaller = 'direct' | 'programmatic'; export type RankerVersionType = 'auto' | 'default-2024-11-15'; export type HybridSearchOptions = {embedding_weight: number, text_weight: number}; export type RankingOptions = {ranker?: RankerVersionType | undefined, score_threshold?: number | undefined, hybrid_search?: HybridSearchOptions | undefined}; export type ComparisonFilter = {type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin', key: string, value: string | number | boolean | Array}; export type Filters = {type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin', key: string, value: string | number | boolean | Array} | {type: 'and' | 'or', filters: Array}; export type ComputerEnvironment = 'windows' | 'mac' | 'linux' | 'ubuntu' | 'browser'; export type WebSearchApproximateLocation = {type?: 'approximate' | undefined, country?: (string | null) | undefined, region?: (string | null) | undefined, city?: (string | null) | undefined, timezone?: (string | null) | undefined} | null; export type MCPToolFilter = {tool_names?: Array | undefined, read_only?: boolean | undefined}; export type ContainerMemoryLimit = '1g' | '4g' | '16g' | '64g'; export type ContainerNetworkPolicyDisabledParam = {type: 'disabled'}; export type ContainerNetworkPolicyDomainSecretParam = {domain: string, name: string, value: string}; export type ContainerNetworkPolicyAllowlistParam = {type: 'allowlist', allowed_domains: Array, domain_secrets?: Array | undefined}; export type AutoCodeInterpreterToolParam = {type: 'auto', file_ids?: Array | undefined, memory_limit?: (ContainerMemoryLimit | null) | undefined, network_policy?: (ContainerNetworkPolicyDisabledParam | ContainerNetworkPolicyAllowlistParam) | undefined}; export type InputFidelity = 'high' | 'low'; export type ImageGenActionEnum = 'generate' | 'edit' | 'auto'; export type SkillReferenceParam = {type: 'skill_reference', skill_id: string, version?: string | undefined}; export type InlineSkillSourceParam = {type: 'base64', media_type: 'application/zip', data: string}; export type InlineSkillParam = {type: 'inline', name: string, description: string, source: InlineSkillSourceParam}; export type ContainerAutoParam = {type: 'container_auto', file_ids?: Array | undefined, memory_limit?: (ContainerMemoryLimit | null) | undefined, network_policy?: (ContainerNetworkPolicyDisabledParam | ContainerNetworkPolicyAllowlistParam) | undefined, skills?: (Array) | undefined}; export type LocalSkillParam = {name: string, description: string, path: string}; export type LocalEnvironmentParam = {type: 'local', skills?: Array | undefined}; export type ContainerReferenceParam = {type: 'container_reference', container_id: string}; export type CustomTextFormatParam = {type: 'text'}; export type GrammarSyntax1 = 'lark' | 'regex'; export type CustomGrammarFormatParam = {type: 'grammar', syntax: GrammarSyntax1, definition: string}; export type EmptyModelParam = Record; export type FunctionToolParam = {name: string, description?: (string | null) | undefined, parameters?: (EmptyModelParam | null) | undefined, strict?: (boolean | null) | undefined, type: 'function', output_schema?: ({[key: string]: unknown} | null) | undefined, defer_loading?: boolean | undefined, allowed_callers?: (Array | null) | undefined}; export type CustomToolParam = {type: 'custom', name: string, description?: string | undefined, format?: (CustomTextFormatParam | CustomGrammarFormatParam) | undefined, defer_loading?: boolean | undefined, allowed_callers?: (Array | null) | undefined}; export type ToolSearchExecutionType = 'server' | 'client'; export type ApproximateLocation = {type: 'approximate', country?: (string | null) | undefined, region?: (string | null) | undefined, city?: (string | null) | undefined, timezone?: (string | null) | undefined}; export type SearchContextSize = 'low' | 'medium' | 'high'; export type SearchContentType = 'text' | 'image'; export type Tool = {type: 'function', name: string, description?: (string | null) | undefined, parameters: {[key: string]: unknown} | null, output_schema?: ({[key: string]: unknown} | null) | undefined, strict: boolean | null, defer_loading?: boolean | undefined, allowed_callers?: (Array | null) | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined} | {type: 'file_search', vector_store_ids: Array, max_num_results?: number | undefined, ranking_options?: RankingOptions | undefined, filters?: (Filters | null) | undefined} | {type: 'computer'} | {type: 'computer_use_preview', environment: ComputerEnvironment, display_width: number, display_height: number} | {type: 'web_search' | 'web_search_2025_08_26', filters?: ({allowed_domains?: (Array | null) | undefined} | null) | undefined, user_location?: WebSearchApproximateLocation | undefined, search_context_size?: ('low' | 'medium' | 'high') | undefined} | {type: 'mcp', server_label: string, server_url?: string | undefined, connector_id?: ('connector_dropbox' | 'connector_gmail' | 'connector_googlecalendar' | 'connector_googledrive' | 'connector_microsoftteams' | 'connector_outlookcalendar' | 'connector_outlookemail' | 'connector_sharepoint') | undefined, tunnel_id?: string | undefined, authorization?: string | undefined, server_description?: string | undefined, headers?: ({[key: string]: string} | null) | undefined, allowed_tools?: (Array | MCPToolFilter | null) | undefined, allowed_callers?: (Array | null) | undefined, require_approval?: ({always?: MCPToolFilter | undefined, never?: MCPToolFilter | undefined} | 'always' | 'never' | null) | undefined, defer_loading?: boolean | undefined} | {type: 'code_interpreter', container: string | AutoCodeInterpreterToolParam, allowed_callers?: (Array | null) | undefined} | {type: 'programmatic_tool_calling'} | {type: 'image_generation', model?: (string | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5') | undefined, quality?: ('low' | 'medium' | 'high' | 'auto') | undefined, size?: (string | '1024x1024' | '1024x1536' | '1536x1024' | 'auto') | undefined, output_format?: ('png' | 'webp' | 'jpeg') | undefined, output_compression?: number | undefined, moderation?: ('auto' | 'low') | undefined, background?: ('transparent' | 'opaque' | 'auto') | undefined, input_fidelity?: (InputFidelity | null) | undefined, input_image_mask?: ({image_url?: string | undefined, file_id?: string | undefined}) | undefined, partial_images?: number | undefined, action?: ImageGenActionEnum | undefined} | {type: 'local_shell'} | {type: 'shell', environment?: (ContainerAutoParam | LocalEnvironmentParam | ContainerReferenceParam | null) | undefined, allowed_callers?: (Array | null) | undefined} | {type: 'custom', name: string, description?: string | undefined, format?: (CustomTextFormatParam | CustomGrammarFormatParam) | undefined, defer_loading?: boolean | undefined, allowed_callers?: (Array | null) | undefined} | {type: 'namespace', name: string, description: string, tools: Array} | {type: 'tool_search', execution?: ToolSearchExecutionType | undefined, description?: (string | null) | undefined, parameters?: (EmptyModelParam | null) | undefined} | {type: 'web_search_preview' | 'web_search_preview_2025_03_11', user_location?: (ApproximateLocation | null) | undefined, search_context_size?: SearchContextSize | undefined, search_content_types?: Array | undefined} | {type: 'apply_patch', allowed_callers?: (Array | null) | undefined}; export type ToolsArray = Array; export type ToolChoiceParam = 'none' | 'auto' | 'required' | {type: 'allowed_tools', mode: 'auto' | 'required', tools: Array<{[key: string]: unknown}>} | {type: 'file_search' | 'web_search_preview' | 'computer' | 'computer_use_preview' | 'computer_use' | 'web_search_preview_2025_03_11' | 'image_generation' | 'code_interpreter'} | {type: 'function', name: string} | {type: 'mcp', server_label: string, name?: (string | null) | undefined} | {type: 'custom', name: string} | {type: 'programmatic_tool_calling'} | {type: 'apply_patch'} | {type: 'shell'}; export type PromptCacheBreakpointConfig = {mode: 'explicit'}; export type InputTextContent = {type: 'input_text', text: string, prompt_cache_breakpoint?: PromptCacheBreakpointConfig | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined}; export type ImageDetail = 'low' | 'high' | 'auto' | 'original'; export type InputImageContent = {type: 'input_image', image_url?: (string | null) | undefined, file_id?: (string | null) | undefined, detail: ImageDetail, prompt_cache_breakpoint?: PromptCacheBreakpointConfig | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined}; export type FileInputDetail = 'auto' | 'low' | 'high'; export type InputFileContent = {type: 'input_file', file_id?: (string | null) | undefined, filename?: string | undefined, file_data?: string | undefined, prompt_cache_breakpoint?: PromptCacheBreakpointConfig | undefined, file_url?: string | undefined, detail?: FileInputDetail | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined}; export type ResponsePromptVariables = {[key: string]: string | InputTextContent | InputImageContent | InputFileContent} | null; export type Prompt = {id: string, version?: (string | null) | undefined, variables?: ResponsePromptVariables | undefined} | null; export type ReasoningModeEnum = string | 'standard' | 'pro'; export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null; export type Reasoning = {mode?: ReasoningModeEnum | undefined, effort?: ReasoningEffort | undefined, summary?: ('auto' | 'concise' | 'detailed' | null) | undefined, context?: ('auto' | 'current_turn' | 'all_turns' | null) | undefined, generate_summary?: ('auto' | 'concise' | 'detailed' | null) | undefined}; export type InputContent = {type: 'input_text', text: string, prompt_cache_breakpoint?: PromptCacheBreakpointConfig | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined} | {type: 'input_image', image_url?: (string | null) | undefined, file_id?: (string | null) | undefined, detail: ImageDetail, prompt_cache_breakpoint?: PromptCacheBreakpointConfig | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined} | {type: 'input_file', file_id?: (string | null) | undefined, filename?: string | undefined, file_data?: string | undefined, prompt_cache_breakpoint?: PromptCacheBreakpointConfig | undefined, file_url?: string | undefined, detail?: FileInputDetail | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined}; export type InputMessageContentList = Array; export type MessagePhase = 'commentary' | 'final_answer'; export type InputMessage = {type?: 'message' | undefined, role: 'user' | 'system' | 'developer', status?: ('in_progress' | 'completed' | 'incomplete') | undefined, content: InputMessageContentList}; export type Annotation = {type: 'file_citation', file_id: string, index: number, filename: string} | {type: 'url_citation', url: string, start_index: number, end_index: number, title: string} | {type: 'container_file_citation', container_id: string, file_id: string, start_index: number, end_index: number, filename: string} | {type: 'file_path', file_id: string, index: number}; export type TopLogProb = {token: string, logprob: number, bytes: Array}; export type LogProb = {token: string, logprob: number, bytes: Array, top_logprobs: Array}; export type OutputMessageContent = {type: 'output_text', text: string, annotations: Array, logprobs: Array} | {type: 'refusal', refusal: string}; export type OutputMessage = {id: string, type: 'message', role: 'assistant', content: Array, phase?: (MessagePhase | null) | undefined, status: 'in_progress' | 'completed' | 'incomplete'}; export type VectorStoreFileAttributes = {[key: string]: string | number | boolean} | null; export type FileSearchToolCall = {id: string, type: 'file_search_call', status: 'in_progress' | 'searching' | 'completed' | 'incomplete' | 'failed', queries: Array, results?: (Array<{file_id?: string | undefined, text?: string | undefined, filename?: string | undefined, attributes?: VectorStoreFileAttributes | undefined, score?: number | undefined}> | null) | undefined}; export type ClickButtonType = 'left' | 'right' | 'wheel' | 'back' | 'forward'; export type CoordParam = {x: number, y: number}; export type ComputerAction = {type: 'click', button: ClickButtonType, x: number, y: number, keys?: (Array | null) | undefined} | {type: 'double_click', x: number, y: number, keys: Array | null} | {type: 'drag', path: Array, keys?: (Array | null) | undefined} | {type: 'keypress', keys: Array} | {type: 'move', x: number, y: number, keys?: (Array | null) | undefined} | {type: 'screenshot'} | {type: 'scroll', x: number, y: number, scroll_x: number, scroll_y: number, keys?: (Array | null) | undefined} | {type: 'type', text: string} | {type: 'wait'}; export type ComputerActionList = Array; export type ComputerCallSafetyCheckParam = {id: string, code?: (string | null) | undefined, message?: (string | null) | undefined}; export type ComputerToolCall = {type: 'computer_call', id: string, call_id: string, action?: ComputerAction | undefined, actions?: ComputerActionList | undefined, pending_safety_checks: Array, status: 'in_progress' | 'completed' | 'incomplete'}; export type ComputerScreenshotImage = {type: 'computer_screenshot', image_url?: string | undefined, file_id?: string | undefined}; export type FunctionCallItemStatus = 'in_progress' | 'completed' | 'incomplete'; export type ComputerCallOutputItemParam = {id?: (string | null) | undefined, call_id: string, type: 'computer_call_output', output: ComputerScreenshotImage, acknowledged_safety_checks?: (Array | null) | undefined, status?: (FunctionCallItemStatus | null) | undefined}; export type WebSearchToolCall = {id: string, type: 'web_search_call', status: 'in_progress' | 'searching' | 'completed' | 'failed', action: {type: 'search', query?: string | undefined, queries?: Array | undefined, sources?: Array<{type: 'url', url: string}> | undefined} | {type: 'open_page', url?: (string | null) | undefined} | {type: 'find_in_page', url: string, pattern: string}}; export type ToolCallCaller = {type: 'direct'} | {type: 'program', caller_id: string}; export type FunctionToolCall = {id?: string | undefined, type: 'function_call', call_id: string, caller?: (ToolCallCaller | null) | undefined, namespace?: string | undefined, name: string, arguments: string, status?: ('in_progress' | 'completed' | 'incomplete') | undefined}; export type PromptCacheBreakpointParam = {mode: 'explicit'}; export type InputTextContentParam = {type: 'input_text', text: string, prompt_cache_breakpoint?: (PromptCacheBreakpointParam | null) | undefined}; export type DetailEnum = 'low' | 'high' | 'auto' | 'original'; export type InputImageContentParamAutoParam = {type: 'input_image', image_url?: (string | null) | undefined, file_id?: (string | null) | undefined, detail?: (DetailEnum | null) | undefined, prompt_cache_breakpoint?: (PromptCacheBreakpointParam | null) | undefined}; export type FileDetailEnum = 'auto' | 'low' | 'high'; export type InputFileContentParam = {type: 'input_file', file_id?: (string | null) | undefined, filename?: (string | null) | undefined, file_data?: (string | null) | undefined, file_url?: (string | null) | undefined, detail?: FileDetailEnum | undefined, prompt_cache_breakpoint?: (PromptCacheBreakpointParam | null) | undefined}; export type ToolCallCallerParam = {type: 'direct'} | {type: 'program', caller_id: string}; export type FunctionCallOutputItemParam = {id?: (string | null) | undefined, call_id: string, type: 'function_call_output', output: string | Array, name?: (string | null) | undefined, caller?: (ToolCallCallerParam | null) | undefined, status?: (FunctionCallItemStatus | null) | undefined}; export type ToolSearchCallItemParam = {id?: (string | null) | undefined, call_id?: (string | null) | undefined, type: 'tool_search_call', execution?: ToolSearchExecutionType | undefined, arguments: EmptyModelParam, status?: (FunctionCallItemStatus | null) | undefined}; export type ToolSearchOutputItemParam = {id?: (string | null) | undefined, call_id?: (string | null) | undefined, type: 'tool_search_output', execution?: ToolSearchExecutionType | undefined, tools: Array, status?: (FunctionCallItemStatus | null) | undefined}; export type AdditionalToolsItemParam = {id?: (string | null) | undefined, type: 'additional_tools', role: 'developer', tools: Array}; export type SummaryTextContent = {type: 'summary_text', text: string}; export type ReasoningTextContent = {type: 'reasoning_text', text: string}; export type ReasoningItem = {type: 'reasoning', id: string, encrypted_content?: (string | null) | undefined, summary: Array, content?: Array | undefined, status?: ('in_progress' | 'completed' | 'incomplete') | undefined}; export type CompactionSummaryItemParam = {id?: (string | null) | undefined, type: 'compaction', encrypted_content: string}; export type ImageGenToolCall = {type: 'image_generation_call', id: string, status: 'in_progress' | 'completed' | 'generating' | 'failed', result: string | null}; export type CodeInterpreterOutputLogs = {type: 'logs', logs: string}; export type CodeInterpreterOutputImage = {type: 'image', url: string}; export type CodeInterpreterToolCall = {type: 'code_interpreter_call', id: string, status: 'in_progress' | 'completed' | 'incomplete' | 'interpreting' | 'failed', container_id: string, code: string | null, outputs: Array | null}; export type LocalShellExecAction = {type: 'exec', command: Array, timeout_ms?: (number | null) | undefined, working_directory?: (string | null) | undefined, env: {[key: string]: string}, user?: (string | null) | undefined}; export type LocalShellToolCall = {type: 'local_shell_call', id: string, call_id: string, action: LocalShellExecAction, status: 'in_progress' | 'completed' | 'incomplete'}; export type LocalShellToolCallOutput = {type: 'local_shell_call_output', id: string, output: string, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined}; export type FunctionShellActionParam = {commands: Array, timeout_ms?: (number | null) | undefined, max_output_length?: (number | null) | undefined}; export type FunctionShellCallItemStatus = 'in_progress' | 'completed' | 'incomplete'; export type FunctionShellCallItemParam = {id?: (string | null) | undefined, call_id: string, caller?: (ToolCallCallerParam | null) | undefined, type: 'shell_call', action: FunctionShellActionParam, status?: (FunctionShellCallItemStatus | null) | undefined, environment?: (LocalEnvironmentParam | ContainerReferenceParam | null) | undefined}; export type FunctionShellCallOutputOutcomeParam = {type: 'timeout'} | {type: 'exit', exit_code: number}; export type FunctionShellCallOutputContentParam = {stdout: string, stderr: string, outcome: FunctionShellCallOutputOutcomeParam}; export type FunctionShellCallOutputItemParam = {id?: (string | null) | undefined, call_id: string, caller?: (ToolCallCallerParam | null) | undefined, type: 'shell_call_output', output: Array, status?: (FunctionShellCallItemStatus | null) | undefined, max_output_length?: (number | null) | undefined}; export type ApplyPatchCallStatusParam = 'in_progress' | 'completed'; export type ApplyPatchOperationParam = {type: 'create_file', path: string, diff: string} | {type: 'delete_file', path: string} | {type: 'update_file', path: string, diff: string}; export type ApplyPatchToolCallItemParam = {type: 'apply_patch_call', id?: (string | null) | undefined, call_id: string, caller?: (ToolCallCallerParam | null) | undefined, status: ApplyPatchCallStatusParam, operation: ApplyPatchOperationParam}; export type ApplyPatchCallOutputStatusParam = 'completed' | 'failed'; export type ApplyPatchToolCallOutputItemParam = {type: 'apply_patch_call_output', id?: (string | null) | undefined, call_id: string, caller?: (ToolCallCallerParam | null) | undefined, status: ApplyPatchCallOutputStatusParam, output?: (string | null) | undefined}; export type MCPListToolsTool = {name: string, description?: (string | null) | undefined, input_schema: Record, annotations?: (Record | null) | undefined}; export type MCPListTools = {type: 'mcp_list_tools', id: string, server_label: string, tools: Array, error?: (string | null) | undefined}; export type MCPApprovalRequest = {type: 'mcp_approval_request', id: string, server_label: string, name: string, arguments: string}; export type MCPApprovalResponse = {type: 'mcp_approval_response', id?: (string | null) | undefined, approval_request_id: string, approve: boolean, reason?: (string | null) | undefined}; export type MCPToolCallStatus = 'in_progress' | 'completed' | 'incomplete' | 'calling' | 'failed'; export type MCPToolCall = {type: 'mcp_call', id: string, server_label: string, name: string, arguments: string, output?: (string | null) | undefined, error?: (string | null) | undefined, status?: MCPToolCallStatus | undefined, approval_request_id?: (string | null) | undefined}; export type FunctionAndCustomToolCallOutput = {type: 'input_text', text: string, prompt_cache_breakpoint?: PromptCacheBreakpointConfig | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined} | {type: 'input_image', image_url?: (string | null) | undefined, file_id?: (string | null) | undefined, detail: ImageDetail, prompt_cache_breakpoint?: PromptCacheBreakpointConfig | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined} | {type: 'input_file', file_id?: (string | null) | undefined, filename?: string | undefined, file_data?: string | undefined, prompt_cache_breakpoint?: PromptCacheBreakpointConfig | undefined, file_url?: string | undefined, detail?: FileInputDetail | undefined, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}) | undefined}; export type CustomToolCallOutput = {type: 'custom_tool_call_output', id?: string | undefined, call_id: string, caller?: (ToolCallCallerParam | null) | undefined, output: string | Array}; export type CustomToolCall = {type: 'custom_tool_call', id?: string | undefined, call_id: string, caller?: (ToolCallCaller | null) | undefined, namespace?: string | undefined, name: string, input: string}; export type ProgramOutputItemStatus = 'completed' | 'incomplete'; export type InputItem = {role: 'user' | 'assistant' | 'system' | 'developer', content: string | InputMessageContentList, phase?: (MessagePhase | null) | undefined, type?: 'message' | undefined} | InputMessage | OutputMessage | FileSearchToolCall | ComputerToolCall | ComputerCallOutputItemParam | WebSearchToolCall | FunctionToolCall | FunctionCallOutputItemParam | ToolSearchCallItemParam | ToolSearchOutputItemParam | AdditionalToolsItemParam | ReasoningItem | CompactionSummaryItemParam | ImageGenToolCall | CodeInterpreterToolCall | LocalShellToolCall | LocalShellToolCallOutput | FunctionShellCallItemParam | FunctionShellCallOutputItemParam | ApplyPatchToolCallItemParam | ApplyPatchToolCallOutputItemParam | MCPListTools | MCPApprovalRequest | MCPApprovalResponse | MCPToolCall | CustomToolCallOutput | CustomToolCall | {type: 'compaction_trigger'} | {type?: ('item_reference' | null) | undefined, id: string} | {id: string, type: 'program', call_id: string, code: string, fingerprint: string} | {id: string, type: 'program_output', call_id: string, result: string, status: ProgramOutputItemStatus}; export type InputParam = string | Array; 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 type ModerationMode = 'score' | 'block'; export type ModerationConfigParam = {mode: ModerationMode}; export type ModerationPolicyParam = {input?: (ModerationConfigParam | null) | undefined, output?: (ModerationConfigParam | null) | undefined}; export type ModerationParam = {model: string, policy?: (ModerationPolicyParam | null) | undefined}; export type ResponseStreamOptions = {include_obfuscation?: boolean | undefined} | null; export type ConversationParam = string | {id: string}; export type ContextManagementParam = {type: string, compact_threshold?: (number | null) | undefined}; export type CreateResponse = {metadata?: Metadata | undefined, top_logprobs?: (number | null) | undefined, temperature?: (number | null) | undefined, top_p?: (number | null) | undefined, user?: string | undefined, safety_identifier?: (string | null) | undefined, prompt_cache_key?: (string | null) | undefined, service_tier?: ServiceTier | undefined, prompt_cache_retention?: ('in_memory' | '24h' | null) | undefined, prompt_cache_options?: PromptCacheOptionsParam | undefined, previous_response_id?: (string | null) | undefined, model?: ModelIdsResponses | undefined, background?: (boolean | null) | undefined, max_tool_calls?: (number | null) | undefined, text?: ResponseTextParam | undefined, tools?: ToolsArray | undefined, tool_choice?: ToolChoiceParam | undefined, prompt?: Prompt | undefined, truncation?: ('auto' | 'disabled' | null) | undefined, reasoning?: (Reasoning | null) | undefined, input?: InputParam | undefined, include?: (Array | null) | undefined, parallel_tool_calls?: (boolean | null) | undefined, store?: (boolean | null) | undefined, instructions?: (string | null) | undefined, moderation?: (ModerationParam | null) | undefined, stream?: (boolean | null) | undefined, stream_options?: ResponseStreamOptions | undefined, conversation?: (ConversationParam | null) | undefined, context_management?: (Array | null) | undefined, max_output_tokens?: (number | null) | undefined, top_k?: number | undefined}; export type CreateApiV1ResponsesArgs = {body: CreateResponse}; export type CreateApiV1ResponsesOptions = {baseUrl?: string | undefined, gatewayBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const metadata = z.record(z.string(), z.string()).nullable(); export const serviceTier = z.enum(["auto", "default", "flex", "scale", "priority", "fast"]).nullable(); export const modelIdsResponses = z.union([z.string(), z.enum(["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"]), z.enum(["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 responseFormatJsonSchemaSchema = z.record(z.string(), z.unknown()); export const textResponseFormatConfiguration = z.union([z.object({type: z.literal("text")}), z.object({type: z.literal("json_schema"), description: z.string().optional(), name: z.string(), schema: responseFormatJsonSchemaSchema, strict: z.boolean().nullable().optional()}), z.object({type: z.literal("json_object")})]); export const verbosity = z.enum(["low", "medium", "high"]).nullable(); export const responseTextParam = z.object({format: textResponseFormatConfiguration.optional(), verbosity: verbosity.optional()}); export const callableToolAllowedCaller = z.enum(["direct", "programmatic"]); export const rankerVersionType = z.enum(["auto", "default-2024-11-15"]); export const hybridSearchOptions = z.object({embedding_weight: z.number(), text_weight: z.number()}); export const rankingOptions = z.object({ranker: rankerVersionType.optional(), score_threshold: z.number().optional(), hybrid_search: hybridSearchOptions.optional()}); export const comparisonFilter = z.object({type: z.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]), key: z.string(), value: z.union([z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number()]))])}); export const filters = z.union([z.object({type: z.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]), key: z.string(), value: z.union([z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number()]))])}), z.object({type: z.enum(["and", "or"]), filters: z.array(z.discriminatedUnion("type", [comparisonFilter, z.unknown()]))})]); export const computerEnvironment = z.enum(["windows", "mac", "linux", "ubuntu", "browser"]); export const webSearchApproximateLocation = z.object({type: z.literal("approximate").optional(), country: z.string().nullable().optional(), region: z.string().nullable().optional(), city: z.string().nullable().optional(), timezone: z.string().nullable().optional()}).nullable(); export const mCPToolFilter = z.object({tool_names: z.array(z.string()).optional(), read_only: z.boolean().optional()}); export const containerMemoryLimit = z.enum(["1g", "4g", "16g", "64g"]); export const containerNetworkPolicyDisabledParam = z.object({type: z.literal("disabled")}); export const containerNetworkPolicyDomainSecretParam = z.object({domain: z.string().min(1), name: z.string().min(1), value: z.string().min(1).max(10485760)}); export const containerNetworkPolicyAllowlistParam = z.object({type: z.literal("allowlist"), allowed_domains: z.array(z.string()), domain_secrets: z.array(containerNetworkPolicyDomainSecretParam).optional()}); export const autoCodeInterpreterToolParam = z.object({type: z.literal("auto"), file_ids: z.array(z.string()).optional(), memory_limit: containerMemoryLimit.nullable().optional(), network_policy: z.discriminatedUnion("type", [containerNetworkPolicyDisabledParam, containerNetworkPolicyAllowlistParam]).optional()}); export const inputFidelity = z.enum(["high", "low"]); export const imageGenActionEnum = z.enum(["generate", "edit", "auto"]); export const skillReferenceParam = z.object({type: z.literal("skill_reference"), skill_id: z.string().min(1).max(64), version: z.string().optional()}); export const inlineSkillSourceParam = z.object({type: z.literal("base64"), media_type: z.literal("application/zip"), data: z.string().min(1).max(70254592)}); export const inlineSkillParam = z.object({type: z.literal("inline"), name: z.string(), description: z.string(), source: inlineSkillSourceParam}); export const containerAutoParam = z.object({type: z.literal("container_auto"), file_ids: z.array(z.string()).optional(), memory_limit: containerMemoryLimit.nullable().optional(), network_policy: z.discriminatedUnion("type", [containerNetworkPolicyDisabledParam, containerNetworkPolicyAllowlistParam]).optional(), skills: z.array(z.discriminatedUnion("type", [skillReferenceParam, inlineSkillParam])).optional()}); export const localSkillParam = z.object({name: z.string(), description: z.string(), path: z.string()}); export const localEnvironmentParam = z.object({type: z.literal("local"), skills: z.array(localSkillParam).optional()}); export const containerReferenceParam = z.object({type: z.literal("container_reference"), container_id: z.string()}); export const customTextFormatParam = z.object({type: z.literal("text")}); export const grammarSyntax1 = z.enum(["lark", "regex"]); export const customGrammarFormatParam = z.object({type: z.literal("grammar"), syntax: grammarSyntax1, definition: z.string()}); export const emptyModelParam = z.object({}); export const functionToolParam = z.object({name: z.string().min(1).max(128), description: z.string().nullable().optional(), parameters: emptyModelParam.nullable().optional(), strict: z.boolean().nullable().optional(), type: z.literal("function"), output_schema: z.record(z.string(), z.unknown()).nullable().optional(), defer_loading: z.boolean().optional(), allowed_callers: z.array(callableToolAllowedCaller).nullable().optional()}); export const customToolParam = z.object({type: z.literal("custom"), name: z.string(), description: z.string().optional(), format: z.discriminatedUnion("type", [customTextFormatParam, customGrammarFormatParam]).optional(), defer_loading: z.boolean().optional(), allowed_callers: z.array(callableToolAllowedCaller).nullable().optional()}); export const toolSearchExecutionType = z.enum(["server", "client"]); export const approximateLocation = z.object({type: z.literal("approximate"), country: z.string().nullable().optional(), region: z.string().nullable().optional(), city: z.string().nullable().optional(), timezone: z.string().nullable().optional()}); export const searchContextSize = z.enum(["low", "medium", "high"]); export const searchContentType = z.enum(["text", "image"]); export const tool = z.discriminatedUnion("type", [z.object({type: z.literal("function"), name: z.string(), description: z.string().nullable().optional(), parameters: z.record(z.string(), z.unknown()).nullable(), output_schema: z.record(z.string(), z.unknown()).nullable().optional(), strict: z.boolean().nullable(), defer_loading: z.boolean().optional(), allowed_callers: z.array(callableToolAllowedCaller).nullable().optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()}), z.object({type: z.literal("file_search"), vector_store_ids: z.array(z.string()), max_num_results: z.number().int().optional(), ranking_options: rankingOptions.optional(), filters: filters.nullable().optional()}), z.object({type: z.literal("computer")}), z.object({type: z.literal("computer_use_preview"), environment: computerEnvironment, display_width: z.number().int(), display_height: z.number().int()}), z.object({type: z.enum(["web_search", "web_search_2025_08_26"]), filters: z.object({allowed_domains: z.array(z.string()).nullable().optional()}).nullable().optional(), user_location: webSearchApproximateLocation.optional(), search_context_size: z.enum(["low", "medium", "high"]).optional()}), z.object({type: z.literal("mcp"), server_label: z.string(), server_url: z.string().optional(), connector_id: z.enum(["connector_dropbox", "connector_gmail", "connector_googlecalendar", "connector_googledrive", "connector_microsoftteams", "connector_outlookcalendar", "connector_outlookemail", "connector_sharepoint"]).optional(), tunnel_id: z.string().optional(), authorization: z.string().optional(), server_description: z.string().optional(), headers: z.record(z.string(), z.string()).nullable().optional(), allowed_tools: z.union([z.array(z.string()), mCPToolFilter]).nullable().optional(), allowed_callers: z.array(callableToolAllowedCaller).nullable().optional(), require_approval: z.union([z.object({always: mCPToolFilter.optional(), never: mCPToolFilter.optional()}), z.enum(["always", "never"])]).nullable().optional(), defer_loading: z.boolean().optional()}), z.object({type: z.literal("code_interpreter"), container: z.union([z.string(), autoCodeInterpreterToolParam]), allowed_callers: z.array(callableToolAllowedCaller).nullable().optional()}), z.object({type: z.literal("programmatic_tool_calling")}), z.object({type: z.literal("image_generation"), model: z.union([z.string(), z.enum(["gpt-image-1", "gpt-image-1-mini", "gpt-image-1.5"])]).optional(), quality: z.enum(["low", "medium", "high", "auto"]).optional(), size: z.union([z.string(), z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"])]).optional(), output_format: z.enum(["png", "webp", "jpeg"]).optional(), output_compression: z.number().int().gte(0).lte(100).optional(), moderation: z.enum(["auto", "low"]).optional(), background: z.enum(["transparent", "opaque", "auto"]).optional(), input_fidelity: inputFidelity.nullable().optional(), input_image_mask: z.object({image_url: z.string().optional(), file_id: z.string().optional()}).optional(), partial_images: z.number().int().gte(0).lte(3).optional(), action: imageGenActionEnum.optional()}), z.object({type: z.literal("local_shell")}), z.object({type: z.literal("shell"), environment: z.union([containerAutoParam, localEnvironmentParam, containerReferenceParam]).nullable().optional(), allowed_callers: z.array(callableToolAllowedCaller).nullable().optional()}), z.object({type: z.literal("custom"), name: z.string(), description: z.string().optional(), format: z.discriminatedUnion("type", [customTextFormatParam, customGrammarFormatParam]).optional(), defer_loading: z.boolean().optional(), allowed_callers: z.array(callableToolAllowedCaller).nullable().optional()}), z.object({type: z.literal("namespace"), name: z.string().min(1), description: z.string().min(1), tools: z.array(z.discriminatedUnion("type", [functionToolParam, customToolParam]))}), z.object({type: z.literal("tool_search"), execution: toolSearchExecutionType.optional(), description: z.string().nullable().optional(), parameters: emptyModelParam.nullable().optional()}), z.object({type: z.enum(["web_search_preview", "web_search_preview_2025_03_11"]), user_location: approximateLocation.nullable().optional(), search_context_size: searchContextSize.optional(), search_content_types: z.array(searchContentType).optional()}), z.object({type: z.literal("apply_patch"), allowed_callers: z.array(callableToolAllowedCaller).nullable().optional()})]); export const toolsArray = z.array(tool); export const toolChoiceParam = z.union([z.enum(["none", "auto", "required"]), z.object({type: z.literal("allowed_tools"), mode: z.enum(["auto", "required"]), tools: z.array(z.record(z.string(), z.unknown()))}), z.object({type: z.enum(["file_search", "web_search_preview", "computer", "computer_use_preview", "computer_use", "web_search_preview_2025_03_11", "image_generation", "code_interpreter"])}), z.object({type: z.literal("function"), name: z.string()}), z.object({type: z.literal("mcp"), server_label: z.string(), name: z.string().nullable().optional()}), z.object({type: z.literal("custom"), name: z.string()}), z.object({type: z.literal("programmatic_tool_calling")}), z.object({type: z.literal("apply_patch")}), z.object({type: z.literal("shell")})]); export const promptCacheBreakpointConfig = z.object({mode: z.literal("explicit")}); export const inputTextContent = z.object({type: z.literal("input_text"), text: z.string(), prompt_cache_breakpoint: promptCacheBreakpointConfig.optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()}); export const imageDetail = z.enum(["low", "high", "auto", "original"]); export const inputImageContent = z.object({type: z.literal("input_image"), image_url: z.string().nullable().optional(), file_id: z.string().nullable().optional(), detail: imageDetail, prompt_cache_breakpoint: promptCacheBreakpointConfig.optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()}); export const fileInputDetail = z.enum(["auto", "low", "high"]); export const inputFileContent = z.object({type: z.literal("input_file"), file_id: z.string().nullable().optional(), filename: z.string().optional(), file_data: z.string().optional(), prompt_cache_breakpoint: promptCacheBreakpointConfig.optional(), file_url: z.string().optional(), detail: fileInputDetail.optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()}); export const responsePromptVariables = z.record(z.string(), z.union([z.string(), inputTextContent, inputImageContent, inputFileContent])).nullable(); export const prompt = z.object({id: z.string(), version: z.string().nullable().optional(), variables: responsePromptVariables.optional()}).nullable(); export const responseErrorCode = z.enum(["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 responseError = z.object({code: responseErrorCode, message: z.string()}).nullable(); export const annotation = z.discriminatedUnion("type", [z.object({type: z.literal("file_citation"), file_id: z.string(), index: z.number().int(), filename: z.string()}), z.object({type: z.literal("url_citation"), url: z.string(), start_index: z.number().int(), end_index: z.number().int(), title: z.string()}), z.object({type: z.literal("container_file_citation"), container_id: z.string(), file_id: z.string(), start_index: z.number().int(), end_index: z.number().int(), filename: z.string()}), z.object({type: z.literal("file_path"), file_id: z.string(), index: z.number().int()})]); export const topLogProb = z.object({token: z.string(), logprob: z.number(), bytes: z.array(z.number().int())}); export const logProb = z.object({token: z.string(), logprob: z.number(), bytes: z.array(z.number().int()), top_logprobs: z.array(topLogProb)}); export const outputMessageContent = z.discriminatedUnion("type", [z.object({type: z.literal("output_text"), text: z.string(), annotations: z.array(annotation), logprobs: z.array(logProb)}), z.object({type: z.literal("refusal"), refusal: z.string()})]); export const messagePhase = z.enum(["commentary", "final_answer"]); export const vectorStoreFileAttributes = z.record(z.string(), z.union([z.string().max(512), z.number(), z.boolean()])).nullable(); export const toolCallCaller = z.discriminatedUnion("type", [z.object({type: z.literal("direct")}), z.object({type: z.literal("program"), caller_id: z.string()})]); export const toolCallCallerParam = z.discriminatedUnion("type", [z.object({type: z.literal("direct")}), z.object({type: z.literal("program"), caller_id: z.string().min(1).max(64)})]); export const functionAndCustomToolCallOutput = z.discriminatedUnion("type", [z.object({type: z.literal("input_text"), text: z.string(), prompt_cache_breakpoint: promptCacheBreakpointConfig.optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()}), z.object({type: z.literal("input_image"), image_url: z.string().nullable().optional(), file_id: z.string().nullable().optional(), detail: imageDetail, prompt_cache_breakpoint: promptCacheBreakpointConfig.optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()}), z.object({type: z.literal("input_file"), file_id: z.string().nullable().optional(), filename: z.string().optional(), file_data: z.string().optional(), prompt_cache_breakpoint: promptCacheBreakpointConfig.optional(), file_url: z.string().optional(), detail: fileInputDetail.optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()})]); export const clickButtonType = z.enum(["left", "right", "wheel", "back", "forward"]); export const coordParam = z.object({x: z.number().int(), y: z.number().int()}); export const computerAction = z.discriminatedUnion("type", [z.object({type: z.literal("click"), button: clickButtonType, x: z.number().int(), y: z.number().int(), keys: z.array(z.string()).nullable().optional()}), z.object({type: z.literal("double_click"), x: z.number().int(), y: z.number().int(), keys: z.array(z.string()).nullable()}), z.object({type: z.literal("drag"), path: z.array(coordParam), keys: z.array(z.string()).nullable().optional()}), z.object({type: z.literal("keypress"), keys: z.array(z.string())}), z.object({type: z.literal("move"), x: z.number().int(), y: z.number().int(), keys: z.array(z.string()).nullable().optional()}), z.object({type: z.literal("screenshot")}), z.object({type: z.literal("scroll"), x: z.number().int(), y: z.number().int(), scroll_x: z.number().int(), scroll_y: z.number().int(), keys: z.array(z.string()).nullable().optional()}), z.object({type: z.literal("type"), text: z.string()}), z.object({type: z.literal("wait")})]); export const computerActionList = z.array(computerAction); export const computerCallSafetyCheckParam = z.object({id: z.string(), code: z.string().nullable().optional(), message: z.string().nullable().optional()}); export const computerScreenshotImage = z.object({type: z.literal("computer_screenshot"), image_url: z.string().optional(), file_id: z.string().optional()}); export const summaryTextContent = z.object({type: z.literal("summary_text"), text: z.string()}); export const reasoningTextContent = z.object({type: z.literal("reasoning_text"), text: z.string()}); export const programOutputStatus = z.enum(["completed", "incomplete"]); export const functionCallStatus = z.enum(["in_progress", "completed", "incomplete"]); export const functionCallOutputStatusEnum = z.enum(["in_progress", "completed", "incomplete"]); export const messageRole = z.enum(["unknown", "user", "assistant", "system", "critic", "discriminator", "developer", "tool"]); export const codeInterpreterOutputLogs = z.object({type: z.literal("logs"), logs: z.string()}); export const codeInterpreterOutputImage = z.object({type: z.literal("image"), url: z.string()}); export const localShellExecAction = z.object({type: z.literal("exec"), command: z.array(z.string()), timeout_ms: z.number().int().nullable().optional(), working_directory: z.string().nullable().optional(), env: z.record(z.string(), z.string()), user: z.string().nullable().optional()}); export const functionShellAction = z.object({commands: z.array(z.string()), timeout_ms: z.number().int().nullable(), max_output_length: z.number().int().nullable()}); export const functionShellCallStatus = z.enum(["in_progress", "completed", "incomplete"]); export const localEnvironmentResource = z.object({type: z.literal("local")}); export const containerReferenceResource = z.object({type: z.literal("container_reference"), container_id: z.string()}); export const functionShellCallOutputStatusEnum = z.enum(["in_progress", "completed", "incomplete"]); export const functionShellCallOutputTimeoutOutcome = z.object({type: z.literal("timeout")}); export const functionShellCallOutputExitOutcome = z.object({type: z.literal("exit"), exit_code: z.number().int()}); export const functionShellCallOutputContent = z.object({stdout: z.string(), stderr: z.string(), outcome: z.discriminatedUnion("type", [functionShellCallOutputTimeoutOutcome, functionShellCallOutputExitOutcome]), created_by: z.string().optional()}); export const applyPatchCallStatus = z.enum(["in_progress", "completed"]); export const applyPatchCreateFileOperation = z.object({type: z.literal("create_file"), path: z.string(), diff: z.string()}); export const applyPatchDeleteFileOperation = z.object({type: z.literal("delete_file"), path: z.string()}); export const applyPatchUpdateFileOperation = z.object({type: z.literal("update_file"), path: z.string(), diff: z.string()}); export const applyPatchCallOutputStatus = z.enum(["completed", "failed"]); export const mCPToolCallStatus = z.enum(["in_progress", "completed", "incomplete", "calling", "failed"]); export const mCPListToolsTool = z.object({name: z.string(), description: z.string().nullable().optional(), input_schema: z.object({}), annotations: z.object({}).nullable().optional()}); export const outputItem = z.discriminatedUnion("type", [z.object({id: z.string(), type: z.literal("message"), role: z.literal("assistant"), content: z.array(outputMessageContent), phase: messagePhase.nullable().optional(), status: z.enum(["in_progress", "completed", "incomplete"])}), z.object({id: z.string(), type: z.literal("file_search_call"), status: z.enum(["in_progress", "searching", "completed", "incomplete", "failed"]), queries: z.array(z.string()), results: z.array(z.object({file_id: z.string().optional(), text: z.string().optional(), filename: z.string().optional(), attributes: vectorStoreFileAttributes.optional(), score: z.number().optional()})).nullable().optional()}), z.object({id: z.string().optional(), type: z.literal("function_call"), call_id: z.string(), caller: toolCallCaller.nullable().optional(), namespace: z.string().optional(), name: z.string(), arguments: z.string(), status: z.enum(["in_progress", "completed", "incomplete"]).optional()}), z.object({id: z.string(), type: z.literal("function_call_output"), call_id: z.string(), name: z.string().optional(), namespace: z.string().optional(), caller: toolCallCallerParam.nullable().optional(), output: z.union([z.string(), z.array(functionAndCustomToolCallOutput)]), status: z.enum(["in_progress", "completed", "incomplete"]), created_by: z.string().optional()}), z.object({id: z.string(), type: z.literal("web_search_call"), status: z.enum(["in_progress", "searching", "completed", "failed"]), action: z.discriminatedUnion("type", [z.object({type: z.literal("search"), query: z.string().optional(), queries: z.array(z.string()).optional(), sources: z.array(z.object({type: z.literal("url"), url: z.string()})).optional()}), z.object({type: z.literal("open_page"), url: z.string().nullable().optional()}), z.object({type: z.literal("find_in_page"), url: z.string(), pattern: z.string()})])}), z.object({type: z.literal("computer_call"), id: z.string(), call_id: z.string(), action: computerAction.optional(), actions: computerActionList.optional(), pending_safety_checks: z.array(computerCallSafetyCheckParam), status: z.enum(["in_progress", "completed", "incomplete"])}), z.object({type: z.literal("computer_call_output"), id: z.string(), call_id: z.string(), acknowledged_safety_checks: z.array(computerCallSafetyCheckParam).optional(), output: computerScreenshotImage, status: z.enum(["completed", "incomplete"]), created_by: z.string().optional()}), z.object({type: z.literal("reasoning"), id: z.string(), encrypted_content: z.string().nullable().optional(), summary: z.array(summaryTextContent), content: z.array(reasoningTextContent).optional(), status: z.enum(["in_progress", "completed", "incomplete"]).optional()}), z.object({type: z.literal("program"), id: z.string(), call_id: z.string(), code: z.string(), fingerprint: z.string()}), z.object({type: z.literal("program_output"), id: z.string(), call_id: z.string(), result: z.string(), status: programOutputStatus}), z.object({type: z.literal("tool_search_call"), id: z.string(), call_id: z.string().nullable(), execution: toolSearchExecutionType, arguments: z.unknown(), status: functionCallStatus, created_by: z.string().optional()}), z.object({type: z.literal("tool_search_output"), id: z.string(), call_id: z.string().nullable(), execution: toolSearchExecutionType, tools: z.array(tool), status: functionCallOutputStatusEnum, created_by: z.string().optional()}), z.object({type: z.literal("additional_tools"), id: z.string(), role: messageRole, tools: z.array(tool)}), z.object({type: z.literal("compaction"), id: z.string(), encrypted_content: z.string(), created_by: z.string().optional()}), z.object({type: z.literal("image_generation_call"), id: z.string(), status: z.enum(["in_progress", "completed", "generating", "failed"]), result: z.string().nullable()}), z.object({type: z.literal("code_interpreter_call"), id: z.string(), status: z.enum(["in_progress", "completed", "incomplete", "interpreting", "failed"]), container_id: z.string(), code: z.string().nullable(), outputs: z.array(z.discriminatedUnion("type", [codeInterpreterOutputLogs, codeInterpreterOutputImage])).nullable()}), z.object({type: z.literal("local_shell_call"), id: z.string(), call_id: z.string(), action: localShellExecAction, status: z.enum(["in_progress", "completed", "incomplete"])}), z.object({type: z.literal("local_shell_call_output"), id: z.string(), output: z.string(), status: z.enum(["in_progress", "completed", "incomplete"]).nullable().optional()}), z.object({type: z.literal("shell_call"), id: z.string(), call_id: z.string(), caller: toolCallCaller.nullable().optional(), action: functionShellAction, status: functionShellCallStatus, environment: z.union([localEnvironmentResource, containerReferenceResource]).nullable(), created_by: z.string().optional()}), z.object({type: z.literal("shell_call_output"), id: z.string(), call_id: z.string(), caller: toolCallCaller.nullable().optional(), status: functionShellCallOutputStatusEnum, output: z.array(functionShellCallOutputContent), max_output_length: z.number().int().nullable(), created_by: z.string().optional()}), z.object({type: z.literal("apply_patch_call"), id: z.string(), call_id: z.string(), caller: toolCallCaller.nullable().optional(), status: applyPatchCallStatus, operation: z.discriminatedUnion("type", [applyPatchCreateFileOperation, applyPatchDeleteFileOperation, applyPatchUpdateFileOperation]), created_by: z.string().optional()}), z.object({type: z.literal("apply_patch_call_output"), id: z.string(), call_id: z.string(), caller: toolCallCaller.nullable().optional(), status: applyPatchCallOutputStatus, output: z.string().nullable().optional(), created_by: z.string().optional()}), z.object({type: z.literal("mcp_call"), id: z.string(), server_label: z.string(), name: z.string(), arguments: z.string(), output: z.string().nullable().optional(), error: z.string().nullable().optional(), status: mCPToolCallStatus.optional(), approval_request_id: z.string().nullable().optional()}), z.object({type: z.literal("mcp_list_tools"), id: z.string(), server_label: z.string(), tools: z.array(mCPListToolsTool), error: z.string().nullable().optional()}), z.object({type: z.literal("mcp_approval_request"), id: z.string(), server_label: z.string(), name: z.string(), arguments: z.string()}), z.object({type: z.literal("mcp_approval_response"), id: z.string(), approval_request_id: z.string(), approve: z.boolean(), reason: z.string().nullable().optional()}), z.object({type: z.literal("custom_tool_call"), id: z.string().optional(), call_id: z.string(), caller: toolCallCaller.nullable().optional(), namespace: z.string().optional(), name: z.string(), input: z.string()}), z.object({type: z.literal("custom_tool_call_output"), id: z.string(), call_id: z.string(), caller: toolCallCallerParam.nullable().optional(), output: z.union([z.string(), z.array(functionAndCustomToolCallOutput)]), status: functionCallOutputStatusEnum, created_by: z.string().optional()})]); export const reasoningModeEnum = z.union([z.string(), z.enum(["standard", "pro"])]); export const reasoningEffort = z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).nullable(); export const reasoning = z.object({mode: reasoningModeEnum.optional(), effort: reasoningEffort.optional(), summary: z.enum(["auto", "concise", "detailed"]).nullable().optional(), context: z.enum(["auto", "current_turn", "all_turns"]).nullable().optional(), generate_summary: z.enum(["auto", "concise", "detailed"]).nullable().optional()}); export const inputContent = z.discriminatedUnion("type", [z.object({type: z.literal("input_text"), text: z.string(), prompt_cache_breakpoint: promptCacheBreakpointConfig.optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()}), z.object({type: z.literal("input_image"), image_url: z.string().nullable().optional(), file_id: z.string().nullable().optional(), detail: imageDetail, prompt_cache_breakpoint: promptCacheBreakpointConfig.optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()}), z.object({type: z.literal("input_file"), file_id: z.string().nullable().optional(), filename: z.string().optional(), file_data: z.string().optional(), prompt_cache_breakpoint: promptCacheBreakpointConfig.optional(), file_url: z.string().optional(), detail: fileInputDetail.optional(), cache_control: z.object({ttl: z.enum(["5m", "1h"]).optional(), type: z.literal("ephemeral")}).optional()})]); export const inputMessageContentList = z.array(inputContent); export const inputMessage = z.object({type: z.literal("message").optional(), role: z.enum(["user", "system", "developer"]), status: z.enum(["in_progress", "completed", "incomplete"]).optional(), content: inputMessageContentList}); export const outputMessage = z.object({id: z.string(), type: z.literal("message"), role: z.literal("assistant"), content: z.array(outputMessageContent), phase: messagePhase.nullable().optional(), status: z.enum(["in_progress", "completed", "incomplete"])}); export const fileSearchToolCall = z.object({id: z.string(), type: z.literal("file_search_call"), status: z.enum(["in_progress", "searching", "completed", "incomplete", "failed"]), queries: z.array(z.string()), results: z.array(z.object({file_id: z.string().optional(), text: z.string().optional(), filename: z.string().optional(), attributes: vectorStoreFileAttributes.optional(), score: z.number().optional()})).nullable().optional()}); export const computerToolCall = z.object({type: z.literal("computer_call"), id: z.string(), call_id: z.string(), action: computerAction.optional(), actions: computerActionList.optional(), pending_safety_checks: z.array(computerCallSafetyCheckParam), status: z.enum(["in_progress", "completed", "incomplete"])}); export const functionCallItemStatus = z.enum(["in_progress", "completed", "incomplete"]); export const computerCallOutputItemParam = z.object({id: z.string().nullable().optional(), call_id: z.string().min(1).max(64), type: z.literal("computer_call_output"), output: computerScreenshotImage, acknowledged_safety_checks: z.array(computerCallSafetyCheckParam).nullable().optional(), status: functionCallItemStatus.nullable().optional()}); export const webSearchToolCall = z.object({id: z.string(), type: z.literal("web_search_call"), status: z.enum(["in_progress", "searching", "completed", "failed"]), action: z.discriminatedUnion("type", [z.object({type: z.literal("search"), query: z.string().optional(), queries: z.array(z.string()).optional(), sources: z.array(z.object({type: z.literal("url"), url: z.string()})).optional()}), z.object({type: z.literal("open_page"), url: z.string().nullable().optional()}), z.object({type: z.literal("find_in_page"), url: z.string(), pattern: z.string()})])}); export const functionToolCall = z.object({id: z.string().optional(), type: z.literal("function_call"), call_id: z.string(), caller: toolCallCaller.nullable().optional(), namespace: z.string().optional(), name: z.string(), arguments: z.string(), status: z.enum(["in_progress", "completed", "incomplete"]).optional()}); export const promptCacheBreakpointParam = z.object({mode: z.literal("explicit")}); export const inputTextContentParam = z.object({type: z.literal("input_text"), text: z.string().max(10485760), prompt_cache_breakpoint: promptCacheBreakpointParam.nullable().optional()}); export const detailEnum = z.enum(["low", "high", "auto", "original"]); export const inputImageContentParamAutoParam = z.object({type: z.literal("input_image"), image_url: z.string().max(20971520).nullable().optional(), file_id: z.string().nullable().optional(), detail: detailEnum.nullable().optional(), prompt_cache_breakpoint: promptCacheBreakpointParam.nullable().optional()}); export const fileDetailEnum = z.enum(["auto", "low", "high"]); export const inputFileContentParam = z.object({type: z.literal("input_file"), file_id: z.string().nullable().optional(), filename: z.string().nullable().optional(), file_data: z.string().max(73400320).nullable().optional(), file_url: z.string().nullable().optional(), detail: fileDetailEnum.optional(), prompt_cache_breakpoint: promptCacheBreakpointParam.nullable().optional()}); export const functionCallOutputItemParam = z.object({id: z.string().nullable().optional(), call_id: z.string().min(1).max(64), type: z.literal("function_call_output"), output: z.union([z.string().max(10485760), z.array(z.discriminatedUnion("type", [inputTextContentParam, inputImageContentParamAutoParam, inputFileContentParam]))]), name: z.string().min(1).max(128).nullable().optional(), caller: toolCallCallerParam.nullable().optional(), status: functionCallItemStatus.nullable().optional()}); export const toolSearchCallItemParam = z.object({id: z.string().nullable().optional(), call_id: z.string().min(1).max(64).nullable().optional(), type: z.literal("tool_search_call"), execution: toolSearchExecutionType.optional(), arguments: emptyModelParam, status: functionCallItemStatus.nullable().optional()}); export const toolSearchOutputItemParam = z.object({id: z.string().nullable().optional(), call_id: z.string().min(1).max(64).nullable().optional(), type: z.literal("tool_search_output"), execution: toolSearchExecutionType.optional(), tools: z.array(tool), status: functionCallItemStatus.nullable().optional()}); export const additionalToolsItemParam = z.object({id: z.string().nullable().optional(), type: z.literal("additional_tools"), role: z.literal("developer"), tools: z.array(tool)}); export const reasoningItem = z.object({type: z.literal("reasoning"), id: z.string(), encrypted_content: z.string().nullable().optional(), summary: z.array(summaryTextContent), content: z.array(reasoningTextContent).optional(), status: z.enum(["in_progress", "completed", "incomplete"]).optional()}); export const compactionSummaryItemParam = z.object({id: z.string().nullable().optional(), type: z.literal("compaction"), encrypted_content: z.string().max(10485760)}); export const imageGenToolCall = z.object({type: z.literal("image_generation_call"), id: z.string(), status: z.enum(["in_progress", "completed", "generating", "failed"]), result: z.string().nullable()}); export const codeInterpreterToolCall = z.object({type: z.literal("code_interpreter_call"), id: z.string(), status: z.enum(["in_progress", "completed", "incomplete", "interpreting", "failed"]), container_id: z.string(), code: z.string().nullable(), outputs: z.array(z.discriminatedUnion("type", [codeInterpreterOutputLogs, codeInterpreterOutputImage])).nullable()}); export const localShellToolCall = z.object({type: z.literal("local_shell_call"), id: z.string(), call_id: z.string(), action: localShellExecAction, status: z.enum(["in_progress", "completed", "incomplete"])}); export const localShellToolCallOutput = z.object({type: z.literal("local_shell_call_output"), id: z.string(), output: z.string(), status: z.enum(["in_progress", "completed", "incomplete"]).nullable().optional()}); export const functionShellActionParam = z.object({commands: z.array(z.string()), timeout_ms: z.number().int().nullable().optional(), max_output_length: z.number().int().nullable().optional()}); export const functionShellCallItemStatus = z.enum(["in_progress", "completed", "incomplete"]); export const functionShellCallItemParam = z.object({id: z.string().nullable().optional(), call_id: z.string().min(1).max(64), caller: toolCallCallerParam.nullable().optional(), type: z.literal("shell_call"), action: functionShellActionParam, status: functionShellCallItemStatus.nullable().optional(), environment: z.union([localEnvironmentParam, containerReferenceParam]).nullable().optional()}); export const functionShellCallOutputOutcomeParam = z.discriminatedUnion("type", [z.object({type: z.literal("timeout")}), z.object({type: z.literal("exit"), exit_code: z.number().int()})]); export const functionShellCallOutputContentParam = z.object({stdout: z.string().max(10485760), stderr: z.string().max(10485760), outcome: functionShellCallOutputOutcomeParam}); export const functionShellCallOutputItemParam = z.object({id: z.string().nullable().optional(), call_id: z.string().min(1).max(64), caller: toolCallCallerParam.nullable().optional(), type: z.literal("shell_call_output"), output: z.array(functionShellCallOutputContentParam), status: functionShellCallItemStatus.nullable().optional(), max_output_length: z.number().int().nullable().optional()}); export const applyPatchCallStatusParam = z.enum(["in_progress", "completed"]); export const applyPatchOperationParam = z.discriminatedUnion("type", [z.object({type: z.literal("create_file"), path: z.string().min(1), diff: z.string().max(10485760)}), z.object({type: z.literal("delete_file"), path: z.string().min(1)}), z.object({type: z.literal("update_file"), path: z.string().min(1), diff: z.string().max(10485760)})]); export const applyPatchToolCallItemParam = z.object({type: z.literal("apply_patch_call"), id: z.string().nullable().optional(), call_id: z.string().min(1).max(64), caller: toolCallCallerParam.nullable().optional(), status: applyPatchCallStatusParam, operation: applyPatchOperationParam}); export const applyPatchCallOutputStatusParam = z.enum(["completed", "failed"]); export const applyPatchToolCallOutputItemParam = z.object({type: z.literal("apply_patch_call_output"), id: z.string().nullable().optional(), call_id: z.string().min(1).max(64), caller: toolCallCallerParam.nullable().optional(), status: applyPatchCallOutputStatusParam, output: z.string().max(10485760).nullable().optional()}); export const mCPListTools = z.object({type: z.literal("mcp_list_tools"), id: z.string(), server_label: z.string(), tools: z.array(mCPListToolsTool), error: z.string().nullable().optional()}); export const mCPApprovalRequest = z.object({type: z.literal("mcp_approval_request"), id: z.string(), server_label: z.string(), name: z.string(), arguments: z.string()}); export const mCPApprovalResponse = z.object({type: z.literal("mcp_approval_response"), id: z.string().nullable().optional(), approval_request_id: z.string(), approve: z.boolean(), reason: z.string().nullable().optional()}); export const mCPToolCall = z.object({type: z.literal("mcp_call"), id: z.string(), server_label: z.string(), name: z.string(), arguments: z.string(), output: z.string().nullable().optional(), error: z.string().nullable().optional(), status: mCPToolCallStatus.optional(), approval_request_id: z.string().nullable().optional()}); export const customToolCallOutput = z.object({type: z.literal("custom_tool_call_output"), id: z.string().optional(), call_id: z.string(), caller: toolCallCallerParam.nullable().optional(), output: z.union([z.string(), z.array(functionAndCustomToolCallOutput)])}); export const customToolCall = z.object({type: z.literal("custom_tool_call"), id: z.string().optional(), call_id: z.string(), caller: toolCallCaller.nullable().optional(), namespace: z.string().optional(), name: z.string(), input: z.string()}); export const programOutputItemStatus = z.enum(["completed", "incomplete"]); export const inputItem = z.discriminatedUnion("type", [z.object({role: z.enum(["user", "assistant", "system", "developer"]), content: z.union([z.string(), inputMessageContentList]), phase: messagePhase.nullable().optional(), type: z.literal("message").optional()}), inputMessage, outputMessage, fileSearchToolCall, computerToolCall, computerCallOutputItemParam, webSearchToolCall, functionToolCall, functionCallOutputItemParam, toolSearchCallItemParam, toolSearchOutputItemParam, additionalToolsItemParam, reasoningItem, compactionSummaryItemParam, imageGenToolCall, codeInterpreterToolCall, localShellToolCall, localShellToolCallOutput, functionShellCallItemParam, functionShellCallOutputItemParam, applyPatchToolCallItemParam, applyPatchToolCallOutputItemParam, mCPListTools, mCPApprovalRequest, mCPApprovalResponse, mCPToolCall, customToolCallOutput, customToolCall, z.object({type: z.literal("compaction_trigger")}), z.object({type: z.literal("item_reference").nullable().optional(), id: z.string()}), z.object({id: z.string(), type: z.literal("program"), call_id: z.string().min(1).max(64), code: z.string().max(10485760), fingerprint: z.string().max(10485760)}), z.object({id: z.string(), type: z.literal("program_output"), call_id: z.string().min(1).max(64), result: z.string().max(10485760), status: programOutputItemStatus})]); export const responseUsage = z.object({input_tokens: z.number().int(), input_tokens_details: z.object({cached_tokens: z.number().int(), cache_write_tokens: z.number().int()}), output_tokens: z.number().int(), output_tokens_details: z.object({reasoning_tokens: z.number().int()}), total_tokens: z.number().int()}); export const promptCacheTTLEnum = z.literal("30m"); export const promptCacheModeEnum = z.enum(["implicit", "explicit"]); export const promptCacheOptions = z.object({ttl: promptCacheTTLEnum, mode: promptCacheModeEnum}); export const moderationInputType = z.enum(["text", "image"]); export const moderationResultBody = z.object({type: z.literal("moderation_result"), model: z.string(), flagged: z.boolean(), categories: z.record(z.string(), z.boolean()), category_scores: z.record(z.string(), z.number()), category_applied_input_types: z.record(z.string(), z.array(moderationInputType))}); export const moderationErrorBody = z.object({type: z.literal("error"), code: z.string(), message: z.string()}); export const moderation = z.object({input: z.discriminatedUnion("type", [moderationResultBody, moderationErrorBody]), output: z.discriminatedUnion("type", [moderationResultBody, moderationErrorBody])}); export const responseConversation = z.object({id: z.string()}); export const response = z.object({metadata: metadata, top_logprobs: z.number().int().gte(0).lte(20).nullable().optional(), temperature: z.number().gte(0).lte(2).nullable(), top_p: z.number().gte(0).lte(1).nullable(), user: z.string().nullable().optional(), safety_identifier: z.string().max(64).nullable().optional(), prompt_cache_key: z.string().nullable().optional(), service_tier: serviceTier.optional(), prompt_cache_retention: z.enum(["in_memory", "24h"]).nullable().optional(), previous_response_id: z.string().nullable().optional(), model: modelIdsResponses, background: z.boolean().nullable().optional(), max_tool_calls: z.number().int().nullable().optional(), text: responseTextParam.optional(), tools: toolsArray, tool_choice: toolChoiceParam, prompt: prompt.optional(), truncation: z.enum(["auto", "disabled"]).nullable().optional(), id: z.string(), object: z.literal("response"), status: z.enum(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]).optional(), created_at: z.number(), completed_at: z.number().nullable().optional(), error: responseError, incomplete_details: z.object({reason: z.enum(["max_output_tokens", "content_filter"]).optional()}).nullable(), output: z.array(outputItem), reasoning: reasoning.nullable().optional(), instructions: z.union([z.string(), z.array(inputItem)]).nullable(), output_text: z.string().nullable().optional(), usage: responseUsage.optional(), prompt_cache_options: promptCacheOptions.optional(), moderation: moderation.nullable().optional(), parallel_tool_calls: z.boolean(), conversation: responseConversation.nullable().optional(), max_output_tokens: z.number().int().nullable().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * /v1/responses * * POST /v1/responses */ export const createApiV1Responses = async (args: CreateApiV1ResponsesArgs, options?: CreateApiV1ResponsesOptions) => { const {baseUrl = "https://aihubmix.com", fetch: fetchFn = fetch, gatewayBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (gatewayBearer !== undefined) headers.set('authorization', `Bearer ${gatewayBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/responses${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(response, await res.json()) };