import {z} from 'zod' export type ResponseInputText = {text: string, type: 'input_text'} | {[key: string]: unknown}; export type ResponseInputImage = {detail: 'low' | 'high' | 'auto' | 'original', type: 'input_image', file_id?: (string | null) | undefined, image_url?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseInputFile = {type: 'input_file', detail?: ('high' | 'low' | null) | undefined, file_data?: (string | null) | undefined, file_id?: (string | null) | undefined, file_url?: (string | null) | undefined, filename?: (string | null) | undefined} | {[key: string]: unknown}; export type EasyInputMessage = {content: string | Array, role: 'user' | 'assistant' | 'system' | 'developer', phase?: ('commentary' | 'final_answer' | null) | undefined, type?: ('message' | null) | undefined} | {[key: string]: unknown}; export type Message = {content: Array, role: 'user' | 'system' | 'developer', status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined, type?: ('message' | null) | undefined} | {[key: string]: unknown}; export type AnnotationFileCitation = {file_id: string, filename: string, index: number, type: 'file_citation'} | {[key: string]: unknown}; export type AnnotationURLCitation = {end_index: number, start_index: number, title: string, type: 'url_citation', url: string} | {[key: string]: unknown}; export type AnnotationContainerFileCitation = {container_id: string, end_index: number, file_id: string, filename: string, start_index: number, type: 'container_file_citation'} | {[key: string]: unknown}; export type AnnotationFilePath = {file_id: string, index: number, type: 'file_path'} | {[key: string]: unknown}; export type LogprobTopLogprob = {token: string, bytes: Array, logprob: number} | {[key: string]: unknown}; export type Logprob = {token: string, bytes: Array, logprob: number, top_logprobs: Array} | {[key: string]: unknown}; export type ResponseOutputText = {annotations: Array, text: string, type: 'output_text', logprobs?: (Array | null) | undefined} | {[key: string]: unknown}; export type ResponseOutputRefusal = {refusal: string, type: 'refusal'} | {[key: string]: unknown}; export type ResponseOutputMessage = {id: string, content: Array, role: 'assistant', status: 'in_progress' | 'completed' | 'incomplete', type: 'message', phase?: ('commentary' | 'final_answer' | null) | undefined} | {[key: string]: unknown}; export type Result = {attributes?: ({[key: string]: string | number | boolean} | null) | undefined, file_id?: (string | null) | undefined, filename?: (string | null) | undefined, score?: (number | null) | undefined, text?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseFileSearchToolCall = {id: string, queries: Array, status: 'in_progress' | 'searching' | 'completed' | 'incomplete' | 'failed', type: 'file_search_call', results?: (Array | null) | undefined} | {[key: string]: unknown}; export type PendingSafetyCheck = {id: string, code?: (string | null) | undefined, message?: (string | null) | undefined} | {[key: string]: unknown}; export type ActionClick = {button: 'left' | 'right' | 'wheel' | 'back' | 'forward', type: 'click', x: number, y: number, keys?: (Array | null) | undefined} | {[key: string]: unknown}; export type ActionDoubleClick = {keys?: (Array | null) | undefined, type: 'double_click', x: number, y: number} | {[key: string]: unknown}; export type ActionDragPath = {x: number, y: number} | {[key: string]: unknown}; export type ActionDrag = {path: Array, type: 'drag', keys?: (Array | null) | undefined} | {[key: string]: unknown}; export type ActionKeypress = {keys: Array, type: 'keypress'} | {[key: string]: unknown}; export type ActionMove = {type: 'move', x: number, y: number, keys?: (Array | null) | undefined} | {[key: string]: unknown}; export type ActionScreenshot = {type: 'screenshot'} | {[key: string]: unknown}; export type ActionScroll = {scroll_x: number, scroll_y: number, type: 'scroll', x: number, y: number, keys?: (Array | null) | undefined} | {[key: string]: unknown}; export type ActionType = {text: string, type: 'type'} | {[key: string]: unknown}; export type ActionWait = {type: 'wait'} | {[key: string]: unknown}; export type Click = {button: 'left' | 'right' | 'wheel' | 'back' | 'forward', type: 'click', x: number, y: number, keys?: (Array | null) | undefined} | {[key: string]: unknown}; export type DoubleClick = {keys?: (Array | null) | undefined, type: 'double_click', x: number, y: number} | {[key: string]: unknown}; export type DragPath = {x: number, y: number} | {[key: string]: unknown}; export type Drag = {path: Array, type: 'drag', keys?: (Array | null) | undefined} | {[key: string]: unknown}; export type Keypress = {keys: Array, type: 'keypress'} | {[key: string]: unknown}; export type Move = {type: 'move', x: number, y: number, keys?: (Array | null) | undefined} | {[key: string]: unknown}; export type Screenshot = {type: 'screenshot'} | {[key: string]: unknown}; export type Scroll = {scroll_x: number, scroll_y: number, type: 'scroll', x: number, y: number, keys?: (Array | null) | undefined} | {[key: string]: unknown}; export type Type = {text: string, type: 'type'} | {[key: string]: unknown}; export type Wait = {type: 'wait'} | {[key: string]: unknown}; export type ResponseComputerToolCall = {id: string, call_id: string, pending_safety_checks: Array, status: 'in_progress' | 'completed' | 'incomplete', type: 'computer_call', action?: (ActionClick | ActionDoubleClick | ActionDrag | ActionKeypress | ActionMove | ActionScreenshot | ActionScroll | ActionType | ActionWait | null) | undefined, actions?: (Array | null) | undefined} | {[key: string]: unknown}; export type ResponseComputerToolCallOutputScreenshot = {type: 'computer_screenshot', file_id?: (string | null) | undefined, image_url?: (string | null) | undefined} | {[key: string]: unknown}; export type ComputerCallOutputAcknowledgedSafetyCheck = {id: string, code?: (string | null) | undefined, message?: (string | null) | undefined} | {[key: string]: unknown}; export type ComputerCallOutput = {call_id: string, output: ResponseComputerToolCallOutputScreenshot, type: 'computer_call_output', id?: (string | null) | undefined, acknowledged_safety_checks?: (Array | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined} | {[key: string]: unknown}; export type ActionSearchSource = {type: 'url', url: string} | {[key: string]: unknown}; export type ActionSearch = {type: 'search', queries?: (Array | null) | undefined, query?: (string | null) | undefined, sources?: (Array | null) | undefined} | {[key: string]: unknown}; export type ActionOpenPage = {type: 'open_page', url?: (string | null) | undefined} | {[key: string]: unknown}; export type ActionFind = {pattern: string, type: 'find_in_page', url: string} | {[key: string]: unknown}; export type ResponseFunctionWebSearch = {id: string, action: ActionSearch | ActionOpenPage | ActionFind, status: 'in_progress' | 'searching' | 'completed' | 'failed', type: 'web_search_call'} | {[key: string]: unknown}; export type ResponseFunctionToolCall = {arguments: string, call_id: string, name: string, type: 'function_call', id?: (string | null) | undefined, namespace?: (string | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined} | {[key: string]: unknown}; export type ResponseInputTextContent = {text: string, type: 'input_text'} | {[key: string]: unknown}; export type ResponseInputImageContent = {type: 'input_image', detail?: ('low' | 'high' | 'auto' | 'original' | null) | undefined, file_id?: (string | null) | undefined, image_url?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseInputFileContent = {type: 'input_file', detail?: ('high' | 'low' | null) | undefined, file_data?: (string | null) | undefined, file_id?: (string | null) | undefined, file_url?: (string | null) | undefined, filename?: (string | null) | undefined} | {[key: string]: unknown}; export type FunctionCallOutput = {call_id: string, output: string | Array, type: 'function_call_output', id?: (string | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined} | {[key: string]: unknown}; export type ToolSearchCall = {arguments: unknown, type: 'tool_search_call', id?: (string | null) | undefined, call_id?: (string | null) | undefined, execution?: ('server' | 'client' | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined} | {[key: string]: unknown}; export type FunctionTool = {name: string, parameters?: ({[key: string]: unknown} | null) | undefined, strict?: (boolean | null) | undefined, type: 'function', defer_loading?: (boolean | null) | undefined, description?: (string | null) | undefined} | {[key: string]: unknown}; export type ComparisonFilter = {key: string, type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin', value: string | number | boolean | Array} | {[key: string]: unknown}; export type CompoundFilter = {filters: Array, type: 'and' | 'or'} | {[key: string]: unknown}; export type RankingOptionsHybridSearch = {embedding_weight: number, text_weight: number} | {[key: string]: unknown}; export type RankingOptions = {hybrid_search?: (RankingOptionsHybridSearch | null) | undefined, ranker?: ('auto' | 'default-2024-11-15' | null) | undefined, score_threshold?: (number | null) | undefined} | {[key: string]: unknown}; export type FileSearchTool = {type: 'file_search', vector_store_ids: Array, filters?: (ComparisonFilter | CompoundFilter | null) | undefined, max_num_results?: (number | null) | undefined, ranking_options?: (RankingOptions | null) | undefined} | {[key: string]: unknown}; export type ComputerTool = {type: 'computer'} | {[key: string]: unknown}; export type ComputerUsePreviewTool = {display_height: number, display_width: number, environment: 'windows' | 'mac' | 'linux' | 'ubuntu' | 'browser', type: 'computer_use_preview'} | {[key: string]: unknown}; export type Filters = {allowed_domains?: (Array | null) | undefined} | {[key: string]: unknown}; export type OpenaiTypesResponsesWebSearchToolUserLocation = {city?: (string | null) | undefined, country?: (string | null) | undefined, region?: (string | null) | undefined, timezone?: (string | null) | undefined, type?: ('approximate' | null) | undefined} | {[key: string]: unknown}; export type WebSearchTool = {type: 'web_search' | 'web_search_2025_08_26', filters?: (Filters | null) | undefined, search_context_size?: ('low' | 'medium' | 'high' | null) | undefined, user_location?: (OpenaiTypesResponsesWebSearchToolUserLocation | null) | undefined} | {[key: string]: unknown}; export type McpAllowedToolsMcpToolFilter = {read_only?: (boolean | null) | undefined, tool_names?: (Array | null) | undefined} | {[key: string]: unknown}; export type McpRequireApprovalMcpToolApprovalFilterAlways = {read_only?: (boolean | null) | undefined, tool_names?: (Array | null) | undefined} | {[key: string]: unknown}; export type McpRequireApprovalMcpToolApprovalFilterNever = {read_only?: (boolean | null) | undefined, tool_names?: (Array | null) | undefined} | {[key: string]: unknown}; export type McpRequireApprovalMcpToolApprovalFilter = {always?: (McpRequireApprovalMcpToolApprovalFilterAlways | null) | undefined, never?: (McpRequireApprovalMcpToolApprovalFilterNever | null) | undefined} | {[key: string]: unknown}; export type Mcp = {server_label: string, type: 'mcp', allowed_tools?: (Array | McpAllowedToolsMcpToolFilter | null) | undefined, authorization?: (string | null) | undefined, connector_id?: ('connector_dropbox' | 'connector_gmail' | 'connector_googlecalendar' | 'connector_googledrive' | 'connector_microsoftteams' | 'connector_outlookcalendar' | 'connector_outlookemail' | 'connector_sharepoint' | null) | undefined, defer_loading?: (boolean | null) | undefined, headers?: ({[key: string]: string} | null) | undefined, require_approval?: (McpRequireApprovalMcpToolApprovalFilter | 'always' | 'never' | null) | undefined, server_description?: (string | null) | undefined, server_url?: (string | null) | undefined} | {[key: string]: unknown}; export type ContainerNetworkPolicyDisabled = {type: 'disabled'} | {[key: string]: unknown}; export type ContainerNetworkPolicyDomainSecret = {domain: string, name: string, value: string} | {[key: string]: unknown}; export type ContainerNetworkPolicyAllowlist = {allowed_domains: Array, type: 'allowlist', domain_secrets?: (Array | null) | undefined} | {[key: string]: unknown}; export type CodeInterpreterContainerCodeInterpreterToolAuto = {type: 'auto', file_ids?: (Array | null) | undefined, memory_limit?: ('1g' | '4g' | '16g' | '64g' | null) | undefined, network_policy?: (ContainerNetworkPolicyDisabled | ContainerNetworkPolicyAllowlist | null) | undefined} | {[key: string]: unknown}; export type CodeInterpreter = {container: string | CodeInterpreterContainerCodeInterpreterToolAuto, type: 'code_interpreter'} | {[key: string]: unknown}; export type ImageGenerationInputImageMask = {file_id?: (string | null) | undefined, image_url?: (string | null) | undefined} | {[key: string]: unknown}; export type ImageGeneration = {type: 'image_generation', action?: ('generate' | 'edit' | 'auto' | null) | undefined, background?: ('transparent' | 'opaque' | 'auto' | null) | undefined, input_fidelity?: ('high' | 'low' | null) | undefined, input_image_mask?: (ImageGenerationInputImageMask | null) | undefined, model?: (string | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-2' | 'gpt-image-2-2026-04-21' | 'gpt-image-1.5' | 'chatgpt-image-latest' | null) | undefined, moderation?: ('auto' | 'low' | null) | undefined, output_compression?: (number | null) | undefined, output_format?: ('png' | 'webp' | 'jpeg' | null) | undefined, partial_images?: (number | null) | undefined, quality?: ('low' | 'medium' | 'high' | 'auto' | null) | undefined, size?: (string | '1024x1024' | '1024x1536' | '1536x1024' | 'auto' | null) | undefined} | {[key: string]: unknown}; export type LocalShell = {type: 'local_shell'} | {[key: string]: unknown}; export type SkillReference = {skill_id: string, type: 'skill_reference', version?: (string | null) | undefined} | {[key: string]: unknown}; export type InlineSkillSource = {data: string, media_type: 'application/zip', type: 'base64'} | {[key: string]: unknown}; export type InlineSkill = {description: string, name: string, source: InlineSkillSource, type: 'inline'} | {[key: string]: unknown}; export type ContainerAuto = {type: 'container_auto', file_ids?: (Array | null) | undefined, memory_limit?: ('1g' | '4g' | '16g' | '64g' | null) | undefined, network_policy?: (ContainerNetworkPolicyDisabled | ContainerNetworkPolicyAllowlist | null) | undefined, skills?: (Array | null) | undefined} | {[key: string]: unknown}; export type LocalSkill = {description: string, name: string, path: string} | {[key: string]: unknown}; export type LocalEnvironment = {type: 'local', skills?: (Array | null) | undefined} | {[key: string]: unknown}; export type ContainerReference = {container_id: string, type: 'container_reference'} | {[key: string]: unknown}; export type FunctionShellTool = {type: 'shell', environment?: (ContainerAuto | LocalEnvironment | ContainerReference | null) | undefined} | {[key: string]: unknown}; export type Text = {type: 'text'} | {[key: string]: unknown}; export type Grammar = {definition: string, syntax: 'lark' | 'regex', type: 'grammar'} | {[key: string]: unknown}; export type CustomTool = {name: string, type: 'custom', defer_loading?: (boolean | null) | undefined, description?: (string | null) | undefined, format?: (Text | Grammar | null) | undefined} | {[key: string]: unknown}; export type ToolFunction = {name: string, type: 'function', defer_loading?: (boolean | null) | undefined, description?: (string | null) | undefined, parameters: unknown, strict?: (boolean | null) | undefined} | {[key: string]: unknown}; export type NamespaceTool = {description: string, name: string, tools: Array, type: 'namespace'} | {[key: string]: unknown}; export type ToolSearchTool = {type: 'tool_search', description?: (string | null) | undefined, execution?: ('server' | 'client' | null) | undefined, parameters: unknown} | {[key: string]: unknown}; export type OpenaiTypesResponsesWebSearchPreviewToolUserLocation = {type: 'approximate', city?: (string | null) | undefined, country?: (string | null) | undefined, region?: (string | null) | undefined, timezone?: (string | null) | undefined} | {[key: string]: unknown}; export type WebSearchPreviewTool = {type: 'web_search_preview' | 'web_search_preview_2025_03_11', search_content_types?: (Array<'text' | 'image'> | null) | undefined, search_context_size?: ('low' | 'medium' | 'high' | null) | undefined, user_location?: (OpenaiTypesResponsesWebSearchPreviewToolUserLocation | null) | undefined} | {[key: string]: unknown}; export type ApplyPatchTool = {type: 'apply_patch'} | {[key: string]: unknown}; export type ResponseToolSearchOutputItemParam = {tools: Array, type: 'tool_search_output', id?: (string | null) | undefined, call_id?: (string | null) | undefined, execution?: ('server' | 'client' | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined} | {[key: string]: unknown}; export type OpenaiTypesResponsesResponseInputItemAdditionalTools = {role: 'developer', tools: Array, type: 'additional_tools', id?: (string | null) | undefined} | {[key: string]: unknown}; export type Summary = {text: string, type: 'summary_text'} | {[key: string]: unknown}; export type Content = {text: string, type: 'reasoning_text'} | {[key: string]: unknown}; export type ResponseReasoningItem = {id: string, summary: Array, type: 'reasoning', content?: (Array | null) | undefined, encrypted_content?: (string | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined} | {[key: string]: unknown}; export type ResponseCompactionItemParam = {encrypted_content: string, type: 'compaction', id?: (string | null) | undefined} | {[key: string]: unknown}; export type ImageGenerationCall = {id: string, result?: (string | null) | undefined, status: 'in_progress' | 'completed' | 'generating' | 'failed', type: 'image_generation_call'} | {[key: string]: unknown}; export type OutputLogs = {logs: string, type: 'logs'} | {[key: string]: unknown}; export type OutputImage = {type: 'image', url: string} | {[key: string]: unknown}; export type ResponseCodeInterpreterToolCall = {id: string, code?: (string | null) | undefined, container_id: string, outputs?: (Array | null) | undefined, status: 'in_progress' | 'completed' | 'incomplete' | 'interpreting' | 'failed', type: 'code_interpreter_call'} | {[key: string]: unknown}; export type LocalShellCallAction = {command: Array, env: {[key: string]: string}, type: 'exec', timeout_ms?: (number | null) | undefined, user?: (string | null) | undefined, working_directory?: (string | null) | undefined} | {[key: string]: unknown}; export type LocalShellCall = {id: string, action: LocalShellCallAction, call_id: string, status: 'in_progress' | 'completed' | 'incomplete', type: 'local_shell_call'} | {[key: string]: unknown}; export type LocalShellCallOutput = {id: string, output: string, type: 'local_shell_call_output', status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined} | {[key: string]: unknown}; export type ShellCallAction = {commands: Array, max_output_length?: (number | null) | undefined, timeout_ms?: (number | null) | undefined} | {[key: string]: unknown}; export type ShellCall = {action: ShellCallAction, call_id: string, type: 'shell_call', id?: (string | null) | undefined, environment?: (LocalEnvironment | ContainerReference | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined} | {[key: string]: unknown}; export type OutcomeTimeout = {type: 'timeout'} | {[key: string]: unknown}; export type OutcomeExit = {exit_code: number, type: 'exit'} | {[key: string]: unknown}; export type ResponseFunctionShellCallOutputContent = {outcome: OutcomeTimeout | OutcomeExit, stderr: string, stdout: string} | {[key: string]: unknown}; export type ShellCallOutput = {call_id: string, output: Array, type: 'shell_call_output', id?: (string | null) | undefined, max_output_length?: (number | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined} | {[key: string]: unknown}; export type ApplyPatchCallOperationCreateFile = {diff: string, path: string, type: 'create_file'} | {[key: string]: unknown}; export type ApplyPatchCallOperationDeleteFile = {path: string, type: 'delete_file'} | {[key: string]: unknown}; export type ApplyPatchCallOperationUpdateFile = {diff: string, path: string, type: 'update_file'} | {[key: string]: unknown}; export type ApplyPatchCall = {call_id: string, operation: ApplyPatchCallOperationCreateFile | ApplyPatchCallOperationDeleteFile | ApplyPatchCallOperationUpdateFile, status: 'in_progress' | 'completed', type: 'apply_patch_call', id?: (string | null) | undefined} | {[key: string]: unknown}; export type ApplyPatchCallOutput = {call_id: string, status: 'completed' | 'failed', type: 'apply_patch_call_output', id?: (string | null) | undefined, output?: (string | null) | undefined} | {[key: string]: unknown}; export type McpListToolsTool = {input_schema: unknown, name: string, annotations: unknown, description?: (string | null) | undefined} | {[key: string]: unknown}; export type McpListTools = {id: string, server_label: string, tools: Array, type: 'mcp_list_tools', error?: (string | null) | undefined} | {[key: string]: unknown}; export type McpApprovalRequest = {id: string, arguments: string, name: string, server_label: string, type: 'mcp_approval_request'} | {[key: string]: unknown}; export type OpenaiTypesResponsesResponseInputItemMcpApprovalResponse = {approval_request_id: string, approve: boolean, type: 'mcp_approval_response', id?: (string | null) | undefined, reason?: (string | null) | undefined} | {[key: string]: unknown}; export type McpCall = {id: string, arguments: string, name: string, server_label: string, type: 'mcp_call', approval_request_id?: (string | null) | undefined, error?: (string | null) | undefined, output?: (string | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | 'calling' | 'failed' | null) | undefined} | {[key: string]: unknown}; export type ResponseCustomToolCallOutput = {call_id: string, output: string | Array, type: 'custom_tool_call_output', id?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseCustomToolCall = {call_id: string, input: string, name: string, type: 'custom_tool_call', id?: (string | null) | undefined, namespace?: (string | null) | undefined} | {[key: string]: unknown}; export type CompactionTrigger = {type: 'compaction_trigger'} | {[key: string]: unknown}; export type ItemReference = {id: string, type?: ('item_reference' | null) | undefined} | {[key: string]: unknown}; export type ResponseFunctionToolCallOutputItem = {id: string, call_id: string, output: string | Array, status: 'in_progress' | 'completed' | 'incomplete', type: 'function_call_output', created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type AcknowledgedSafetyCheck = {id: string, code?: (string | null) | undefined, message?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseComputerToolCallOutputItem = {id: string, call_id: string, output: ResponseComputerToolCallOutputScreenshot, status: 'completed' | 'incomplete' | 'failed' | 'in_progress', type: 'computer_call_output', acknowledged_safety_checks?: (Array | null) | undefined, created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseToolSearchCall = {id: string, arguments: unknown, call_id?: (string | null) | undefined, execution: 'server' | 'client', status: 'in_progress' | 'completed' | 'incomplete', type: 'tool_search_call', created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseToolSearchOutputItem = {id: string, call_id?: (string | null) | undefined, execution: 'server' | 'client', status: 'in_progress' | 'completed' | 'incomplete', tools: Array, type: 'tool_search_output', created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type OpenaiTypesResponsesResponseOutputItemAdditionalTools = {id: string, role: 'unknown' | 'user' | 'assistant' | 'system' | 'critic' | 'discriminator' | 'developer' | 'tool', tools: Array, type: 'additional_tools'} | {[key: string]: unknown}; export type ResponseCompactionItem = {id: string, encrypted_content: string, type: 'compaction', created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type Action = {commands: Array, max_output_length?: (number | null) | undefined, timeout_ms?: (number | null) | undefined} | {[key: string]: unknown}; export type ResponseLocalEnvironment = {type: 'local'} | {[key: string]: unknown}; export type ResponseContainerReference = {container_id: string, type: 'container_reference'} | {[key: string]: unknown}; export type ResponseFunctionShellToolCall = {id: string, action: Action, call_id: string, environment?: (ResponseLocalEnvironment | ResponseContainerReference | null) | undefined, status: 'in_progress' | 'completed' | 'incomplete', type: 'shell_call', created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type OutputOutcomeTimeout = {type: 'timeout'} | {[key: string]: unknown}; export type OutputOutcomeExit = {exit_code: number, type: 'exit'} | {[key: string]: unknown}; export type Output = {outcome: OutputOutcomeTimeout | OutputOutcomeExit, stderr: string, stdout: string, created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseFunctionShellToolCallOutput = {id: string, call_id: string, max_output_length?: (number | null) | undefined, output: Array, status: 'in_progress' | 'completed' | 'incomplete', type: 'shell_call_output', created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type OperationCreateFile = {diff: string, path: string, type: 'create_file'} | {[key: string]: unknown}; export type OperationDeleteFile = {path: string, type: 'delete_file'} | {[key: string]: unknown}; export type OperationUpdateFile = {diff: string, path: string, type: 'update_file'} | {[key: string]: unknown}; export type ResponseApplyPatchToolCall = {id: string, call_id: string, operation: OperationCreateFile | OperationDeleteFile | OperationUpdateFile, status: 'in_progress' | 'completed', type: 'apply_patch_call', created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseApplyPatchToolCallOutput = {id: string, call_id: string, status: 'completed' | 'failed', type: 'apply_patch_call_output', created_by?: (string | null) | undefined, output?: (string | null) | undefined} | {[key: string]: unknown}; export type OpenaiTypesResponsesResponseOutputItemMcpApprovalResponse = {id: string, approval_request_id: string, approve: boolean, type: 'mcp_approval_response', reason?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponseCustomToolCallOutputItem = {call_id: string, output: string | Array, type: 'custom_tool_call_output', id: string, status: 'in_progress' | 'completed' | 'incomplete', created_by?: (string | null) | undefined} | {[key: string]: unknown}; export type ResponsePrompt = {id: string, variables?: ({[key: string]: string | ResponseInputText | ResponseInputImage | ResponseInputFile} | null) | undefined, version?: (string | null) | undefined} | {[key: string]: unknown}; export type Reasoning = {effort?: ('none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | null) | undefined, generate_summary?: ('auto' | 'concise' | 'detailed' | null) | undefined, summary?: ('auto' | 'concise' | 'detailed' | null) | undefined} | {[key: string]: unknown}; export type ServiceTier = 'auto' | 'default' | 'over-limit' | 'flex' | 'no-limit'; export type ResponseFormatText = {type: 'text'} | {[key: string]: unknown}; export type ResponseFormatTextJSONSchemaConfig = {name: string, schema: {[key: string]: unknown}, type: 'json_schema', description?: (string | null) | undefined, strict?: (boolean | null) | undefined} | {[key: string]: unknown}; export type ResponseFormatJSONObject = {type: 'json_object'} | {[key: string]: unknown}; export type ResponseTextConfig = {format?: (ResponseFormatText | ResponseFormatTextJSONSchemaConfig | ResponseFormatJSONObject | null) | undefined, verbosity?: ('low' | 'medium' | 'high' | null) | undefined} | {[key: string]: unknown}; export type ToolChoiceAllowed = {mode: 'auto' | 'required', tools: Array<{[key: string]: unknown}>, type: 'allowed_tools'} | {[key: string]: unknown}; export type ToolChoiceTypes = {type: 'file_search' | 'web_search_preview' | 'computer' | 'computer_use_preview' | 'computer_use' | 'web_search_preview_2025_03_11' | 'image_generation' | 'code_interpreter'} | {[key: string]: unknown}; export type ToolChoiceFunction = {name: string, type: 'function'} | {[key: string]: unknown}; export type ToolChoiceMcp = {server_label: string, type: 'mcp', name?: (string | null) | undefined} | {[key: string]: unknown}; export type ToolChoiceCustom = {name: string, type: 'custom'} | {[key: string]: unknown}; export type ToolChoiceApplyPatch = {type: 'apply_patch'} | {[key: string]: unknown}; export type ToolChoiceShell = {type: 'shell'} | {[key: string]: unknown}; export type CreateResponseRequest = {background?: (boolean | null) | undefined, include?: (Array<'code_interpreter_call.outputs' | 'computer_call_output.output.image_url' | 'file_search_call.results' | 'message.input_image.image_url' | 'message.output_text.logprobs' | 'reasoning.encrypted_content'> | null) | undefined, input: string | Array, instructions?: (string | null) | undefined, max_output_tokens?: (number | null) | undefined, max_tool_calls?: (number | null) | undefined, metadata?: ({[key: string]: string} | null) | undefined, model: string, parallel_tool_calls?: (boolean | null) | undefined, previous_response_id?: (string | null) | undefined, prompt?: (ResponsePrompt | null) | undefined, reasoning?: (Reasoning | null) | undefined, service_tier?: ServiceTier | undefined, store?: (boolean | null) | undefined, stream?: (boolean | null) | undefined, temperature?: (number | null) | undefined, text?: (ResponseTextConfig | null) | undefined, tool_choice?: ('none' | 'auto' | 'required' | ToolChoiceAllowed | ToolChoiceTypes | ToolChoiceFunction | ToolChoiceMcp | ToolChoiceCustom | ToolChoiceApplyPatch | ToolChoiceShell) | undefined, tools?: (Array) | undefined, top_logprobs?: (number | null) | undefined, top_p?: (number | null) | undefined, truncation?: ('auto' | 'disabled') | undefined, user?: (string | null) | undefined, prompt_cache_key?: (string | null) | undefined} | {[key: string]: unknown}; export type CreateApiV1ResponsesArgs = {ai_project_id?: (string | null) | undefined, body: CreateResponseRequest}; export type CreateApiV1ResponsesOptions = {baseUrl?: string | undefined, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const responseError = z.object({code: z.enum(["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"]), message: z.string()}).and(z.record(z.string(), z.unknown())); export const incompleteDetails = z.object({reason: z.enum(["max_output_tokens", "content_filter"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const annotationFileCitation = z.object({file_id: z.string(), filename: z.string(), index: z.number().int(), type: z.literal("file_citation")}).and(z.record(z.string(), z.unknown())); export const annotationURLCitation = z.object({end_index: z.number().int(), start_index: z.number().int(), title: z.string(), type: z.literal("url_citation"), url: z.string()}).and(z.record(z.string(), z.unknown())); export const annotationContainerFileCitation = z.object({container_id: z.string(), end_index: z.number().int(), file_id: z.string(), filename: z.string(), start_index: z.number().int(), type: z.literal("container_file_citation")}).and(z.record(z.string(), z.unknown())); export const annotationFilePath = z.object({file_id: z.string(), index: z.number().int(), type: z.literal("file_path")}).and(z.record(z.string(), z.unknown())); export const logprobTopLogprob = z.object({token: z.string(), bytes: z.array(z.number().int()), logprob: z.number()}).and(z.record(z.string(), z.unknown())); export const logprob = z.object({token: z.string(), bytes: z.array(z.number().int()), logprob: z.number(), top_logprobs: z.array(logprobTopLogprob)}).and(z.record(z.string(), z.unknown())); export const responseOutputText = z.object({annotations: z.array(z.union([annotationFileCitation, annotationURLCitation, annotationContainerFileCitation, annotationFilePath])), text: z.string(), type: z.literal("output_text"), logprobs: z.array(logprob).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseOutputRefusal = z.object({refusal: z.string(), type: z.literal("refusal")}).and(z.record(z.string(), z.unknown())); export const responseOutputMessage = z.object({id: z.string(), content: z.array(z.union([responseOutputText, responseOutputRefusal])), role: z.literal("assistant"), status: z.enum(["in_progress", "completed", "incomplete"]), type: z.literal("message"), phase: z.enum(["commentary", "final_answer"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const result = z.object({attributes: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).nullable().optional(), file_id: z.string().nullable().optional(), filename: z.string().nullable().optional(), score: z.number().nullable().optional(), text: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseFileSearchToolCall = z.object({id: z.string(), queries: z.array(z.string()), status: z.enum(["in_progress", "searching", "completed", "incomplete", "failed"]), type: z.literal("file_search_call"), results: z.array(result).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseFunctionToolCall = z.object({arguments: z.string(), call_id: z.string(), name: z.string(), type: z.literal("function_call"), id: z.string().nullable().optional(), namespace: z.string().nullable().optional(), status: z.enum(["in_progress", "completed", "incomplete"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseInputText = z.object({text: z.string(), type: z.literal("input_text")}).and(z.record(z.string(), z.unknown())); export const responseInputImage = z.object({detail: z.enum(["low", "high", "auto", "original"]), type: z.literal("input_image"), file_id: z.string().nullable().optional(), image_url: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseInputFile = z.object({type: z.literal("input_file"), detail: z.enum(["high", "low"]).nullable().optional(), file_data: z.string().nullable().optional(), file_id: z.string().nullable().optional(), file_url: z.string().nullable().optional(), filename: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseFunctionToolCallOutputItem = z.object({id: z.string(), call_id: z.string(), output: z.union([z.string(), z.array(z.union([responseInputText, responseInputImage, responseInputFile]))]), status: z.enum(["in_progress", "completed", "incomplete"]), type: z.literal("function_call_output"), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const actionSearchSource = z.object({type: z.literal("url"), url: z.string()}).and(z.record(z.string(), z.unknown())); export const actionSearch = z.object({type: z.literal("search"), queries: z.array(z.string()).nullable().optional(), query: z.string().nullable().optional(), sources: z.array(actionSearchSource).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const actionOpenPage = z.object({type: z.literal("open_page"), url: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const actionFind = z.object({pattern: z.string(), type: z.literal("find_in_page"), url: z.string()}).and(z.record(z.string(), z.unknown())); export const responseFunctionWebSearch = z.object({id: z.string(), action: z.union([actionSearch, actionOpenPage, actionFind]), status: z.enum(["in_progress", "searching", "completed", "failed"]), type: z.literal("web_search_call")}).and(z.record(z.string(), z.unknown())); export const pendingSafetyCheck = z.object({id: z.string(), code: z.string().nullable().optional(), message: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const actionClick = z.object({button: z.enum(["left", "right", "wheel", "back", "forward"]), type: z.literal("click"), x: z.number().int(), y: z.number().int(), keys: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const actionDoubleClick = z.object({keys: z.array(z.string()).nullable().optional(), type: z.literal("double_click"), x: z.number().int(), y: z.number().int()}).and(z.record(z.string(), z.unknown())); export const actionDragPath = z.object({x: z.number().int(), y: z.number().int()}).and(z.record(z.string(), z.unknown())); export const actionDrag = z.object({path: z.array(actionDragPath), type: z.literal("drag"), keys: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const actionKeypress = z.object({keys: z.array(z.string()), type: z.literal("keypress")}).and(z.record(z.string(), z.unknown())); export const actionMove = z.object({type: z.literal("move"), x: z.number().int(), y: z.number().int(), keys: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const actionScreenshot = z.object({type: z.literal("screenshot")}).and(z.record(z.string(), z.unknown())); export const actionScroll = z.object({scroll_x: z.number().int(), scroll_y: z.number().int(), type: z.literal("scroll"), x: z.number().int(), y: z.number().int(), keys: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const actionType = z.object({text: z.string(), type: z.literal("type")}).and(z.record(z.string(), z.unknown())); export const actionWait = z.object({type: z.literal("wait")}).and(z.record(z.string(), z.unknown())); export const click = z.object({button: z.enum(["left", "right", "wheel", "back", "forward"]), type: z.literal("click"), x: z.number().int(), y: z.number().int(), keys: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const doubleClick = z.object({keys: z.array(z.string()).nullable().optional(), type: z.literal("double_click"), x: z.number().int(), y: z.number().int()}).and(z.record(z.string(), z.unknown())); export const dragPath = z.object({x: z.number().int(), y: z.number().int()}).and(z.record(z.string(), z.unknown())); export const drag = z.object({path: z.array(dragPath), type: z.literal("drag"), keys: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const keypress = z.object({keys: z.array(z.string()), type: z.literal("keypress")}).and(z.record(z.string(), z.unknown())); export const move = z.object({type: z.literal("move"), x: z.number().int(), y: z.number().int(), keys: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const screenshot = z.object({type: z.literal("screenshot")}).and(z.record(z.string(), z.unknown())); export const scroll = z.object({scroll_x: z.number().int(), scroll_y: z.number().int(), type: z.literal("scroll"), x: z.number().int(), y: z.number().int(), keys: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const type = z.object({text: z.string(), type: z.literal("type")}).and(z.record(z.string(), z.unknown())); export const wait = z.object({type: z.literal("wait")}).and(z.record(z.string(), z.unknown())); export const responseComputerToolCall = z.object({id: z.string(), call_id: z.string(), pending_safety_checks: z.array(pendingSafetyCheck), status: z.enum(["in_progress", "completed", "incomplete"]), type: z.literal("computer_call"), action: z.union([actionClick, actionDoubleClick, actionDrag, actionKeypress, actionMove, actionScreenshot, actionScroll, actionType, actionWait]).nullable().optional(), actions: z.array(z.union([click, doubleClick, drag, keypress, move, screenshot, scroll, type, wait])).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseComputerToolCallOutputScreenshot = z.object({type: z.literal("computer_screenshot"), file_id: z.string().nullable().optional(), image_url: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const acknowledgedSafetyCheck = z.object({id: z.string(), code: z.string().nullable().optional(), message: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseComputerToolCallOutputItem = z.object({id: z.string(), call_id: z.string(), output: responseComputerToolCallOutputScreenshot, status: z.enum(["completed", "incomplete", "failed", "in_progress"]), type: z.literal("computer_call_output"), acknowledged_safety_checks: z.array(acknowledgedSafetyCheck).nullable().optional(), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const summary = z.object({text: z.string(), type: z.literal("summary_text")}).and(z.record(z.string(), z.unknown())); export const content = z.object({text: z.string(), type: z.literal("reasoning_text")}).and(z.record(z.string(), z.unknown())); export const responseReasoningItem = z.object({id: z.string(), summary: z.array(summary), type: z.literal("reasoning"), content: z.array(content).nullable().optional(), encrypted_content: z.string().nullable().optional(), status: z.enum(["in_progress", "completed", "incomplete"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseToolSearchCall = z.object({id: z.string(), arguments: z.unknown(), call_id: z.string().nullable().optional(), execution: z.enum(["server", "client"]), status: z.enum(["in_progress", "completed", "incomplete"]), type: z.literal("tool_search_call"), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const functionTool = z.object({name: z.string(), parameters: z.record(z.string(), z.unknown()).nullable().optional(), strict: z.boolean().nullable().optional(), type: z.literal("function"), defer_loading: z.boolean().nullable().optional(), description: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const comparisonFilter = z.object({key: z.string(), type: z.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]), value: z.union([z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number()]))])}).and(z.record(z.string(), z.unknown())); export const compoundFilter = z.object({filters: z.array(z.union([comparisonFilter, z.unknown()])), type: z.enum(["and", "or"])}).and(z.record(z.string(), z.unknown())); export const rankingOptionsHybridSearch = z.object({embedding_weight: z.number(), text_weight: z.number()}).and(z.record(z.string(), z.unknown())); export const rankingOptions = z.object({hybrid_search: rankingOptionsHybridSearch.nullable().optional(), ranker: z.enum(["auto", "default-2024-11-15"]).nullable().optional(), score_threshold: z.number().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const fileSearchTool = z.object({type: z.literal("file_search"), vector_store_ids: z.array(z.string()), filters: z.union([comparisonFilter, compoundFilter]).nullable().optional(), max_num_results: z.number().int().nullable().optional(), ranking_options: rankingOptions.nullable().optional()}).and(z.record(z.string(), z.unknown())); export const computerTool = z.object({type: z.literal("computer")}).and(z.record(z.string(), z.unknown())); export const computerUsePreviewTool = z.object({display_height: z.number().int(), display_width: z.number().int(), environment: z.enum(["windows", "mac", "linux", "ubuntu", "browser"]), type: z.literal("computer_use_preview")}).and(z.record(z.string(), z.unknown())); export const filters = z.object({allowed_domains: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const openaiTypesResponsesWebSearchToolUserLocation = z.object({city: z.string().nullable().optional(), country: z.string().nullable().optional(), region: z.string().nullable().optional(), timezone: z.string().nullable().optional(), type: z.literal("approximate").nullable().optional()}).and(z.record(z.string(), z.unknown())); export const webSearchTool = z.object({type: z.enum(["web_search", "web_search_2025_08_26"]), filters: filters.nullable().optional(), search_context_size: z.enum(["low", "medium", "high"]).nullable().optional(), user_location: openaiTypesResponsesWebSearchToolUserLocation.nullable().optional()}).and(z.record(z.string(), z.unknown())); export const mcpAllowedToolsMcpToolFilter = z.object({read_only: z.boolean().nullable().optional(), tool_names: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const mcpRequireApprovalMcpToolApprovalFilterAlways = z.object({read_only: z.boolean().nullable().optional(), tool_names: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const mcpRequireApprovalMcpToolApprovalFilterNever = z.object({read_only: z.boolean().nullable().optional(), tool_names: z.array(z.string()).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const mcpRequireApprovalMcpToolApprovalFilter = z.object({always: mcpRequireApprovalMcpToolApprovalFilterAlways.nullable().optional(), never: mcpRequireApprovalMcpToolApprovalFilterNever.nullable().optional()}).and(z.record(z.string(), z.unknown())); export const mcp = z.object({server_label: z.string(), type: z.literal("mcp"), allowed_tools: z.union([z.array(z.string()), mcpAllowedToolsMcpToolFilter]).nullable().optional(), authorization: z.string().nullable().optional(), connector_id: z.enum(["connector_dropbox", "connector_gmail", "connector_googlecalendar", "connector_googledrive", "connector_microsoftteams", "connector_outlookcalendar", "connector_outlookemail", "connector_sharepoint"]).nullable().optional(), defer_loading: z.boolean().nullable().optional(), headers: z.record(z.string(), z.string()).nullable().optional(), require_approval: z.union([mcpRequireApprovalMcpToolApprovalFilter, z.enum(["always", "never"])]).nullable().optional(), server_description: z.string().nullable().optional(), server_url: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const containerNetworkPolicyDisabled = z.object({type: z.literal("disabled")}).and(z.record(z.string(), z.unknown())); export const containerNetworkPolicyDomainSecret = z.object({domain: z.string(), name: z.string(), value: z.string()}).and(z.record(z.string(), z.unknown())); export const containerNetworkPolicyAllowlist = z.object({allowed_domains: z.array(z.string()), type: z.literal("allowlist"), domain_secrets: z.array(containerNetworkPolicyDomainSecret).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const codeInterpreterContainerCodeInterpreterToolAuto = z.object({type: z.literal("auto"), file_ids: z.array(z.string()).nullable().optional(), memory_limit: z.enum(["1g", "4g", "16g", "64g"]).nullable().optional(), network_policy: z.union([containerNetworkPolicyDisabled, containerNetworkPolicyAllowlist]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const codeInterpreter = z.object({container: z.union([z.string(), codeInterpreterContainerCodeInterpreterToolAuto]), type: z.literal("code_interpreter")}).and(z.record(z.string(), z.unknown())); export const imageGenerationInputImageMask = z.object({file_id: z.string().nullable().optional(), image_url: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const imageGeneration = z.object({type: z.literal("image_generation"), action: z.enum(["generate", "edit", "auto"]).nullable().optional(), background: z.enum(["transparent", "opaque", "auto"]).nullable().optional(), input_fidelity: z.enum(["high", "low"]).nullable().optional(), input_image_mask: imageGenerationInputImageMask.nullable().optional(), model: z.union([z.string(), z.enum(["gpt-image-1", "gpt-image-1-mini", "gpt-image-2", "gpt-image-2-2026-04-21", "gpt-image-1.5", "chatgpt-image-latest"])]).nullable().optional(), moderation: z.enum(["auto", "low"]).nullable().optional(), output_compression: z.number().int().nullable().optional(), output_format: z.enum(["png", "webp", "jpeg"]).nullable().optional(), partial_images: z.number().int().nullable().optional(), quality: z.enum(["low", "medium", "high", "auto"]).nullable().optional(), size: z.union([z.string(), z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"])]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const localShell = z.object({type: z.literal("local_shell")}).and(z.record(z.string(), z.unknown())); export const skillReference = z.object({skill_id: z.string(), type: z.literal("skill_reference"), version: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const inlineSkillSource = z.object({data: z.string(), media_type: z.literal("application/zip"), type: z.literal("base64")}).and(z.record(z.string(), z.unknown())); export const inlineSkill = z.object({description: z.string(), name: z.string(), source: inlineSkillSource, type: z.literal("inline")}).and(z.record(z.string(), z.unknown())); export const containerAuto = z.object({type: z.literal("container_auto"), file_ids: z.array(z.string()).nullable().optional(), memory_limit: z.enum(["1g", "4g", "16g", "64g"]).nullable().optional(), network_policy: z.union([containerNetworkPolicyDisabled, containerNetworkPolicyAllowlist]).nullable().optional(), skills: z.array(z.union([skillReference, inlineSkill])).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const localSkill = z.object({description: z.string(), name: z.string(), path: z.string()}).and(z.record(z.string(), z.unknown())); export const localEnvironment = z.object({type: z.literal("local"), skills: z.array(localSkill).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const containerReference = z.object({container_id: z.string(), type: z.literal("container_reference")}).and(z.record(z.string(), z.unknown())); export const functionShellTool = z.object({type: z.literal("shell"), environment: z.union([containerAuto, localEnvironment, containerReference]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const text = z.object({type: z.literal("text")}).and(z.record(z.string(), z.unknown())); export const grammar = z.object({definition: z.string(), syntax: z.enum(["lark", "regex"]), type: z.literal("grammar")}).and(z.record(z.string(), z.unknown())); export const customTool = z.object({name: z.string(), type: z.literal("custom"), defer_loading: z.boolean().nullable().optional(), description: z.string().nullable().optional(), format: z.union([text, grammar]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const toolFunction = z.object({name: z.string(), type: z.literal("function"), defer_loading: z.boolean().nullable().optional(), description: z.string().nullable().optional(), parameters: z.unknown(), strict: z.boolean().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const namespaceTool = z.object({description: z.string(), name: z.string(), tools: z.array(z.union([toolFunction, customTool])), type: z.literal("namespace")}).and(z.record(z.string(), z.unknown())); export const toolSearchTool = z.object({type: z.literal("tool_search"), description: z.string().nullable().optional(), execution: z.enum(["server", "client"]).nullable().optional(), parameters: z.unknown()}).and(z.record(z.string(), z.unknown())); export const openaiTypesResponsesWebSearchPreviewToolUserLocation = z.object({type: z.literal("approximate"), city: z.string().nullable().optional(), country: z.string().nullable().optional(), region: z.string().nullable().optional(), timezone: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const webSearchPreviewTool = z.object({type: z.enum(["web_search_preview", "web_search_preview_2025_03_11"]), search_content_types: z.array(z.enum(["text", "image"])).nullable().optional(), search_context_size: z.enum(["low", "medium", "high"]).nullable().optional(), user_location: openaiTypesResponsesWebSearchPreviewToolUserLocation.nullable().optional()}).and(z.record(z.string(), z.unknown())); export const applyPatchTool = z.object({type: z.literal("apply_patch")}).and(z.record(z.string(), z.unknown())); export const responseToolSearchOutputItem = z.object({id: z.string(), call_id: z.string().nullable().optional(), execution: z.enum(["server", "client"]), status: z.enum(["in_progress", "completed", "incomplete"]), tools: z.array(z.union([functionTool, fileSearchTool, computerTool, computerUsePreviewTool, webSearchTool, mcp, codeInterpreter, imageGeneration, localShell, functionShellTool, customTool, namespaceTool, toolSearchTool, webSearchPreviewTool, applyPatchTool])), type: z.literal("tool_search_output"), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const additionalToolsOutput = z.object({id: z.string(), role: z.enum(["unknown", "user", "assistant", "system", "critic", "discriminator", "developer", "tool"]), tools: z.array(z.union([functionTool, fileSearchTool, computerTool, computerUsePreviewTool, webSearchTool, mcp, codeInterpreter, imageGeneration, localShell, functionShellTool, customTool, namespaceTool, toolSearchTool, webSearchPreviewTool, applyPatchTool])), type: z.literal("additional_tools")}).and(z.record(z.string(), z.unknown())); export const responseCompactionItem = z.object({id: z.string(), encrypted_content: z.string(), type: z.literal("compaction"), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const imageGenerationCall = z.object({id: z.string(), result: z.string().nullable().optional(), status: z.enum(["in_progress", "completed", "generating", "failed"]), type: z.literal("image_generation_call")}).and(z.record(z.string(), z.unknown())); export const outputLogs = z.object({logs: z.string(), type: z.literal("logs")}).and(z.record(z.string(), z.unknown())); export const outputImage = z.object({type: z.literal("image"), url: z.string()}).and(z.record(z.string(), z.unknown())); export const responseCodeInterpreterToolCall = z.object({id: z.string(), code: z.string().nullable().optional(), container_id: z.string(), outputs: z.array(z.union([outputLogs, outputImage])).nullable().optional(), status: z.enum(["in_progress", "completed", "incomplete", "interpreting", "failed"]), type: z.literal("code_interpreter_call")}).and(z.record(z.string(), z.unknown())); export const localShellCallAction = z.object({command: z.array(z.string()), env: z.record(z.string(), z.string()), type: z.literal("exec"), timeout_ms: z.number().int().nullable().optional(), user: z.string().nullable().optional(), working_directory: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const localShellCall = z.object({id: z.string(), action: localShellCallAction, call_id: z.string(), status: z.enum(["in_progress", "completed", "incomplete"]), type: z.literal("local_shell_call")}).and(z.record(z.string(), z.unknown())); export const localShellCallOutput = z.object({id: z.string(), output: z.string(), type: z.literal("local_shell_call_output"), status: z.enum(["in_progress", "completed", "incomplete"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const action = z.object({commands: z.array(z.string()), max_output_length: z.number().int().nullable().optional(), timeout_ms: z.number().int().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseLocalEnvironment = z.object({type: z.literal("local")}).and(z.record(z.string(), z.unknown())); export const responseContainerReference = z.object({container_id: z.string(), type: z.literal("container_reference")}).and(z.record(z.string(), z.unknown())); export const responseFunctionShellToolCall = z.object({id: z.string(), action: action, call_id: z.string(), environment: z.union([responseLocalEnvironment, responseContainerReference]).nullable().optional(), status: z.enum(["in_progress", "completed", "incomplete"]), type: z.literal("shell_call"), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const outputOutcomeTimeout = z.object({type: z.literal("timeout")}).and(z.record(z.string(), z.unknown())); export const outputOutcomeExit = z.object({exit_code: z.number().int(), type: z.literal("exit")}).and(z.record(z.string(), z.unknown())); export const output = z.object({outcome: z.union([outputOutcomeTimeout, outputOutcomeExit]), stderr: z.string(), stdout: z.string(), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseFunctionShellToolCallOutput = z.object({id: z.string(), call_id: z.string(), max_output_length: z.number().int().nullable().optional(), output: z.array(output), status: z.enum(["in_progress", "completed", "incomplete"]), type: z.literal("shell_call_output"), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const operationCreateFile = z.object({diff: z.string(), path: z.string(), type: z.literal("create_file")}).and(z.record(z.string(), z.unknown())); export const operationDeleteFile = z.object({path: z.string(), type: z.literal("delete_file")}).and(z.record(z.string(), z.unknown())); export const operationUpdateFile = z.object({diff: z.string(), path: z.string(), type: z.literal("update_file")}).and(z.record(z.string(), z.unknown())); export const responseApplyPatchToolCall = z.object({id: z.string(), call_id: z.string(), operation: z.union([operationCreateFile, operationDeleteFile, operationUpdateFile]), status: z.enum(["in_progress", "completed"]), type: z.literal("apply_patch_call"), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseApplyPatchToolCallOutput = z.object({id: z.string(), call_id: z.string(), status: z.enum(["completed", "failed"]), type: z.literal("apply_patch_call_output"), created_by: z.string().nullable().optional(), output: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const mcpCall = z.object({id: z.string(), arguments: z.string(), name: z.string(), server_label: z.string(), type: z.literal("mcp_call"), approval_request_id: z.string().nullable().optional(), error: z.string().nullable().optional(), output: z.string().nullable().optional(), status: z.enum(["in_progress", "completed", "incomplete", "calling", "failed"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const mcpListToolsTool = z.object({input_schema: z.unknown(), name: z.string(), annotations: z.unknown(), description: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const mcpListTools = z.object({id: z.string(), server_label: z.string(), tools: z.array(mcpListToolsTool), type: z.literal("mcp_list_tools"), error: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const mcpApprovalRequest = z.object({id: z.string(), arguments: z.string(), name: z.string(), server_label: z.string(), type: z.literal("mcp_approval_request")}).and(z.record(z.string(), z.unknown())); export const mcpApprovalResponseOutput = z.object({id: z.string(), approval_request_id: z.string(), approve: z.boolean(), type: z.literal("mcp_approval_response"), reason: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseCustomToolCall = z.object({call_id: z.string(), input: z.string(), name: z.string(), type: z.literal("custom_tool_call"), id: z.string().nullable().optional(), namespace: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseCustomToolCallOutputItem = z.object({call_id: z.string(), output: z.union([z.string(), z.array(z.union([responseInputText, responseInputImage, responseInputFile]))]), type: z.literal("custom_tool_call_output"), id: z.string(), status: z.enum(["in_progress", "completed", "incomplete"]), created_by: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const toolChoiceAllowed = z.object({mode: z.enum(["auto", "required"]), tools: z.array(z.record(z.string(), z.unknown())), type: z.literal("allowed_tools")}).and(z.record(z.string(), z.unknown())); export const toolChoiceTypes = 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"])}).and(z.record(z.string(), z.unknown())); export const toolChoiceFunction = z.object({name: z.string(), type: z.literal("function")}).and(z.record(z.string(), z.unknown())); export const toolChoiceMcp = z.object({server_label: z.string(), type: z.literal("mcp"), name: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const toolChoiceCustom = z.object({name: z.string(), type: z.literal("custom")}).and(z.record(z.string(), z.unknown())); export const toolChoiceApplyPatch = z.object({type: z.literal("apply_patch")}).and(z.record(z.string(), z.unknown())); export const toolChoiceShell = z.object({type: z.literal("shell")}).and(z.record(z.string(), z.unknown())); export const responsePrompt = z.object({id: z.string(), variables: z.record(z.string(), z.union([z.string(), responseInputText, responseInputImage, responseInputFile])).nullable().optional(), version: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const reasoning = z.object({effort: z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).nullable().optional(), generate_summary: z.enum(["auto", "concise", "detailed"]).nullable().optional(), summary: z.enum(["auto", "concise", "detailed"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const serviceTier = z.enum(["auto", "default", "over-limit", "flex", "no-limit"]); export const responseFormatText = z.object({type: z.literal("text")}).and(z.record(z.string(), z.unknown())); export const responseFormatTextJSONSchemaConfig = z.object({name: z.string(), schema: z.record(z.string(), z.unknown()), type: z.literal("json_schema"), description: z.string().nullable().optional(), strict: z.boolean().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseFormatJSONObject = z.object({type: z.literal("json_object")}).and(z.record(z.string(), z.unknown())); export const responseTextConfig = z.object({format: z.union([responseFormatText, responseFormatTextJSONSchemaConfig, responseFormatJSONObject]).nullable().optional(), verbosity: z.enum(["low", "medium", "high"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const inputTokensDetails = z.object({cached_tokens: z.number().int(), input_tokens_per_turn: z.array(z.number().int()).optional(), cached_tokens_per_turn: z.array(z.number().int()).optional()}); export const outputTokensDetails = z.object({reasoning_tokens: z.number().int().optional(), tool_output_tokens: z.number().int().optional(), output_tokens_per_turn: z.array(z.number().int()).optional(), tool_output_tokens_per_turn: z.array(z.number().int()).optional()}); export const responseUsage = z.object({input_tokens: z.number().int(), input_tokens_details: inputTokensDetails, output_tokens: z.number().int(), output_tokens_details: outputTokensDetails, total_tokens: z.number().int()}); export const responsesResponse = z.object({id: z.string(), created_at: z.number().int(), error: responseError.nullable().optional(), incomplete_details: incompleteDetails.nullable().optional(), instructions: z.string().nullable().optional(), metadata: z.record(z.string(), z.string()).nullable().optional(), model: z.string(), object: z.literal("response").optional(), output: z.array(z.union([responseOutputMessage, responseFileSearchToolCall, responseFunctionToolCall, responseFunctionToolCallOutputItem, responseFunctionWebSearch, responseComputerToolCall, responseComputerToolCallOutputItem, responseReasoningItem, responseToolSearchCall, responseToolSearchOutputItem, additionalToolsOutput, responseCompactionItem, imageGenerationCall, responseCodeInterpreterToolCall, localShellCall, localShellCallOutput, responseFunctionShellToolCall, responseFunctionShellToolCallOutput, responseApplyPatchToolCall, responseApplyPatchToolCallOutput, mcpCall, mcpListTools, mcpApprovalRequest, mcpApprovalResponseOutput, responseCustomToolCall, responseCustomToolCallOutputItem])), parallel_tool_calls: z.boolean(), temperature: z.number(), tool_choice: z.union([z.enum(["none", "auto", "required"]), toolChoiceAllowed, toolChoiceTypes, toolChoiceFunction, toolChoiceMcp, toolChoiceCustom, toolChoiceApplyPatch, toolChoiceShell]), tools: z.array(z.union([functionTool, fileSearchTool, computerTool, computerUsePreviewTool, webSearchTool, mcp, codeInterpreter, imageGeneration, localShell, functionShellTool, customTool, namespaceTool, toolSearchTool, webSearchPreviewTool, applyPatchTool])), top_p: z.number(), background: z.boolean(), max_output_tokens: z.number().int(), max_tool_calls: z.number().int().nullable().optional(), previous_response_id: z.string().nullable().optional(), prompt: responsePrompt.nullable().optional(), reasoning: reasoning.nullable().optional(), service_tier: serviceTier, status: z.enum(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"]), text: responseTextConfig.nullable().optional(), top_logprobs: z.number().int().nullable().optional(), truncation: z.enum(["auto", "disabled"]), usage: responseUsage.nullable().optional(), user: z.string().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 }; /** * Create a response * * POST /v1/responses */ export const createApiV1Responses = async (args: CreateApiV1ResponsesArgs, options?: CreateApiV1ResponsesOptions) => { const {baseUrl = "https://api.tokenfactory.nebius.com", fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.ai_project_id != null) query.append("ai_project_id", String(args.ai_project_id)) if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) 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(responsesResponse, await res.json()) };