import {z} from 'zod' 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}; export type ResponseFormatText = {type: 'text'} | {[key: string]: unknown}; export type ResponseFormatTextJSONSchemaConfigParam = {name: string, schema: {[key: string]: unknown}, type: 'json_schema', description?: string | undefined, strict?: (boolean | null) | undefined} | {[key: string]: unknown}; export type ResponseFormatJSONObject = {type: 'json_object'} | {[key: string]: unknown}; export type ResponseTextConfigParam = {format?: (ResponseFormatText | ResponseFormatTextJSONSchemaConfigParam | ResponseFormatJSONObject) | undefined, verbosity?: ('low' | 'medium' | 'high' | null) | undefined} | {[key: string]: unknown}; export type ToolChoiceAllowedParam = {mode: 'auto' | 'required', tools: Array<{[key: string]: unknown}>, type: 'allowed_tools'} | {[key: string]: unknown}; export type ToolChoiceTypesParam = {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 ToolChoiceFunctionParam = {name: string, type: 'function'} | {[key: string]: unknown}; export type ToolChoiceMcpParam = {server_label: string, type: 'mcp', name?: (string | null) | undefined} | {[key: string]: unknown}; export type ToolChoiceCustomParam = {name: string, type: 'custom'} | {[key: string]: unknown}; export type ToolChoiceApplyPatchParam = {type: 'apply_patch'} | {[key: string]: unknown}; export type ToolChoiceShellParam = {type: 'shell'} | {[key: string]: unknown}; export type FunctionToolParam = {name: string, parameters: {[key: string]: unknown} | null, strict: boolean | null, type: 'function', defer_loading?: boolean | undefined, description?: (string | null) | undefined}; 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 FileSearchToolParam = {type: 'file_search', vector_store_ids: Array, filters?: (ComparisonFilter | CompoundFilter | null) | undefined, max_num_results?: number | undefined, ranking_options?: RankingOptions | undefined}; export type OpenaiTypesResponsesComputerToolParamComputerToolParam = {type: 'computer'}; export type ComputerUsePreviewToolParam = {display_height: number, display_width: number, environment: 'windows' | 'mac' | 'linux' | 'ubuntu' | 'browser', type: 'computer_use_preview'}; export type Filters = {allowed_domains?: (Array | null) | undefined} | {[key: string]: unknown}; export type OpenaiTypesResponsesWebSearchToolParamUserLocation = {city?: (string | null) | undefined, country?: (string | null) | undefined, region?: (string | null) | undefined, timezone?: (string | null) | undefined, type?: 'approximate' | undefined}; export type WebSearchToolParam = {type: 'web_search' | 'web_search_2025_08_26', filters?: (Filters | null) | undefined, search_context_size?: ('low' | 'medium' | 'high') | undefined, user_location?: (OpenaiTypesResponsesWebSearchToolParamUserLocation | null) | undefined}; 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-1.5' | 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?: ('1024x1024' | '1024x1536' | '1536x1024' | 'auto' | null) | undefined} | {[key: string]: unknown}; export type LocalShell = {type: 'local_shell'} | {[key: string]: unknown}; export type ContainerNetworkPolicyDisabledParam = {type: 'disabled'}; export type ContainerNetworkPolicyDomainSecretParam = {domain: string, name: string, value: string}; export type ContainerNetworkPolicyAllowlistParam = {allowed_domains: Array, type: 'allowlist', domain_secrets?: Array | undefined}; export type SkillReferenceParam = {skill_id: string, type: 'skill_reference', version?: string | undefined}; export type InlineSkillSourceParam = {data: string, media_type: 'application/zip', type: 'base64'}; export type InlineSkillParam = {description: string, name: string, source: InlineSkillSourceParam, type: 'inline'}; export type ContainerAutoParam = {type: 'container_auto', file_ids?: Array | undefined, memory_limit?: ('1g' | '4g' | '16g' | '64g' | null) | undefined, network_policy?: (ContainerNetworkPolicyDisabledParam | ContainerNetworkPolicyAllowlistParam) | undefined, skills?: (Array) | undefined}; export type LocalSkillParam = {description: string, name: string, path: string}; export type LocalEnvironmentParam = {type: 'local', skills?: Array | undefined}; export type ContainerReferenceParam = {container_id: string, type: 'container_reference'}; export type FunctionShellToolParam = {type: 'shell', environment?: (ContainerAutoParam | LocalEnvironmentParam | ContainerReferenceParam | null) | undefined}; export type Text = {type: 'text'} | {[key: string]: unknown}; export type Grammar = {definition: string, syntax: 'lark' | 'regex', type: 'grammar'} | {[key: string]: unknown}; export type CustomToolParam = {name: string, type: 'custom', defer_loading?: boolean | undefined, description?: string | undefined, format?: (Text | Grammar) | undefined}; 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 NamespaceToolParam = {description: string, name: string, tools: Array, type: 'namespace'}; export type ToolSearchToolParam = {type: 'tool_search', description?: (string | null) | undefined, execution?: ('server' | 'client') | undefined, parameters: unknown}; export type OpenaiTypesResponsesWebSearchPreviewToolParamUserLocation = {type: 'approximate', city?: (string | null) | undefined, country?: (string | null) | undefined, region?: (string | null) | undefined, timezone?: (string | null) | undefined}; export type WebSearchPreviewToolParam = {type: 'web_search_preview' | 'web_search_preview_2025_03_11', search_content_types?: (Array<'text' | 'image'>) | undefined, search_context_size?: ('low' | 'medium' | 'high') | undefined, user_location?: (OpenaiTypesResponsesWebSearchPreviewToolParamUserLocation | null) | undefined}; export type ApplyPatchToolParam = {type: 'apply_patch'}; export type LitellmTypesLlmsOpenaiComputerToolParam = {display_height: number, display_width: number, environment: 'mac' | 'windows' | 'ubuntu' | 'browser' | string, type: 'computer_use_preview' | string}; export type ShellToolParam = {type: 'shell' | string, environment: {[key: string]: unknown}}; export type PromptObject = {id: string, variables?: ({[key: string]: unknown} | null) | undefined, version?: (string | null) | undefined}; export type PromptCacheOptions = {mode?: ('implicit' | 'explicit') | undefined, ttl?: '30m' | undefined}; export type ResponsesAPIStreamOptions = {include_obfuscation?: boolean | undefined}; export type ContextManagementEntry = {type?: string | undefined, compact_threshold?: number | undefined}; export type ResponseInputTextParam = {text: string, type: 'input_text'}; export type ResponseInputImageParam = {detail: 'low' | 'high' | 'auto' | 'original', type: 'input_image', file_id?: (string | null) | undefined, image_url?: (string | null) | undefined}; export type ResponseInputFileParam = {type: 'input_file', detail?: ('low' | 'high') | undefined, file_data?: string | undefined, file_id?: (string | null) | undefined, file_url?: string | undefined, filename?: string | undefined}; export type EasyInputMessageParam = {content: string | Array, role: 'user' | 'assistant' | 'system' | 'developer', phase?: ('commentary' | 'final_answer' | null) | undefined, type?: 'message' | undefined}; export type Message = {content: Array, role: 'user' | 'system' | 'developer', status?: ('in_progress' | 'completed' | 'incomplete') | undefined, type?: 'message' | undefined}; 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 ResponseOutputTextParam = {annotations: Array, text: string, type: 'output_text', logprobs?: Array | undefined}; export type ResponseOutputRefusalParam = {refusal: string, type: 'refusal'}; export type ResponseOutputMessageParam = {id: string, content: Array, role: 'assistant', status: 'in_progress' | 'completed' | 'incomplete', type: 'message', phase?: ('commentary' | 'final_answer' | null) | undefined}; 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 ResponseFileSearchToolCallParam = {id: string, queries: Array, status: 'in_progress' | 'searching' | 'completed' | 'incomplete' | 'failed', type: 'file_search_call', results?: (Array | null) | undefined}; 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 ResponsesAPIRequestParamsActionDoubleClick = {keys: Array | null, type: 'double_click', x: number, y: number}; 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 ResponsesAPIRequestParamsDoubleClick = {keys: Array | null, type: 'double_click', x: number, y: number}; 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 ResponseComputerToolCallParam = {id: string, call_id: string, pending_safety_checks: Array, status: 'in_progress' | 'completed' | 'incomplete', type: 'computer_call', action?: (ActionClick | ResponsesAPIRequestParamsActionDoubleClick | ActionDrag | ActionKeypress | ActionMove | ActionScreenshot | ActionScroll | ActionType | ActionWait) | undefined, actions?: (Array) | undefined}; export type ResponseComputerToolCallOutputScreenshotParam = {type: 'computer_screenshot', file_id?: string | undefined, image_url?: string | undefined}; export type ComputerCallOutputAcknowledgedSafetyCheck = {id: string, code?: (string | null) | undefined, message?: (string | null) | undefined}; export type ComputerCallOutput = {call_id: string, output: ResponseComputerToolCallOutputScreenshotParam, type: 'computer_call_output', id?: (string | null) | undefined, acknowledged_safety_checks?: (Array | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined}; export type ActionSearchSource = {type: 'url', url: string} | {[key: string]: unknown}; export type ActionSearch = {query: string, type: 'search', queries?: (Array | 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 ResponseFunctionWebSearchParam = {id: string, action: ActionSearch | ActionOpenPage | ActionFind, status: 'in_progress' | 'searching' | 'completed' | 'failed', type: 'web_search_call'}; export type ResponseFunctionToolCallParam = {arguments: string, call_id: string, name: string, type: 'function_call', id?: string | undefined, namespace?: string | undefined, status?: ('in_progress' | 'completed' | 'incomplete') | undefined}; export type ResponseInputTextContentParam = {text: string, type: 'input_text'}; export type ResponseInputImageContentParam = {type: 'input_image', detail?: ('low' | 'high' | 'auto' | 'original' | null) | undefined, file_id?: (string | null) | undefined, image_url?: (string | null) | undefined}; export type ResponseInputFileContentParam = {type: 'input_file', detail?: ('low' | 'high') | undefined, file_data?: (string | null) | undefined, file_id?: (string | null) | undefined, file_url?: (string | null) | undefined, filename?: (string | null) | undefined}; export type FunctionCallOutput = {call_id: string, output: string | Array, type: 'function_call_output', id?: (string | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined}; export type ToolSearchCall = {arguments: unknown, type: 'tool_search_call', id?: (string | null) | undefined, call_id?: (string | null) | undefined, execution?: ('server' | 'client') | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined}; export type ResponseToolSearchOutputItemParamParam = {tools: Array, type: 'tool_search_output', id?: (string | null) | undefined, call_id?: (string | null) | undefined, execution?: ('server' | 'client') | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined}; export type Summary = {text: string, type: 'summary_text'} | {[key: string]: unknown}; export type Content = {text: string, type: 'reasoning_text'} | {[key: string]: unknown}; export type ResponseReasoningItemParam = {id: string, summary: Array, type: 'reasoning', content?: Array | undefined, encrypted_content?: (string | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete') | undefined}; export type ResponseCompactionItemParamParam = {encrypted_content: string, type: 'compaction', id?: (string | null) | undefined}; export type ResponsesAPIRequestParamsImageGenerationCall = {id: string, result: string | null, status: 'in_progress' | 'completed' | 'generating' | 'failed', type: 'image_generation_call'}; export type OutputLogs = {logs: string, type: 'logs'} | {[key: string]: unknown}; export type OutputImage = {type: 'image', url: string} | {[key: string]: unknown}; export type ResponseCodeInterpreterToolCallParam = {id: string, code: string | null, container_id: string, outputs: Array | null, status: 'in_progress' | 'completed' | 'incomplete' | 'interpreting' | 'failed', type: 'code_interpreter_call'}; 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}; export type ShellCall = {action: ShellCallAction, call_id: string, type: 'shell_call', id?: (string | null) | undefined, environment?: (LocalEnvironmentParam | ContainerReferenceParam | null) | undefined, status?: ('in_progress' | 'completed' | 'incomplete' | null) | undefined}; export type OutcomeTimeout = {type: 'timeout'}; export type OutcomeExit = {exit_code: number, type: 'exit'}; export type ResponseFunctionShellCallOutputContentParam = {outcome: OutcomeTimeout | OutcomeExit, stderr: string, stdout: string}; 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}; export type ApplyPatchCallOperationCreateFile = {diff: string, path: string, type: 'create_file'}; export type ApplyPatchCallOperationDeleteFile = {path: string, type: 'delete_file'}; export type ApplyPatchCallOperationUpdateFile = {diff: string, path: string, type: 'update_file'}; export type ApplyPatchCall = {call_id: string, operation: ApplyPatchCallOperationCreateFile | ApplyPatchCallOperationDeleteFile | ApplyPatchCallOperationUpdateFile, status: 'in_progress' | 'completed', type: 'apply_patch_call', id?: (string | null) | undefined}; export type ApplyPatchCallOutput = {call_id: string, status: 'completed' | 'failed', type: 'apply_patch_call_output', id?: (string | null) | undefined, output?: (string | null) | undefined}; 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 ResponsesAPIRequestParamsMcpApprovalResponse = {approval_request_id: string, approve: boolean, type: 'mcp_approval_response', id?: (string | null) | undefined, reason?: (string | null) | undefined}; 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 ResponseCustomToolCallOutputParam = {call_id: string, output: string | Array, type: 'custom_tool_call_output', id?: string | undefined}; export type ResponseCustomToolCallParam = {call_id: string, input: string, name: string, type: 'custom_tool_call', id?: string | undefined, namespace?: string | undefined}; export type ItemReference = {id: string, type?: ('item_reference' | null) | undefined}; export type CreateApiV1ResponsesArgs = {body: {include?: (Array<'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'> | null) | undefined, instructions?: (string | null) | undefined, max_output_tokens?: (number | null) | undefined, metadata?: ({[key: string]: unknown} | null) | undefined, parallel_tool_calls?: (boolean | null) | undefined, previous_response_id?: (string | null) | undefined, reasoning?: (Reasoning | null) | undefined, store?: (boolean | null) | undefined, background?: (boolean | null) | undefined, stream?: (boolean | null) | undefined, temperature?: (number | null) | undefined, text?: (ResponseTextConfigParam | null) | undefined, tool_choice?: ('none' | 'auto' | 'required' | ToolChoiceAllowedParam | ToolChoiceTypesParam | ToolChoiceFunctionParam | ToolChoiceMcpParam | ToolChoiceCustomParam | ToolChoiceApplyPatchParam | ToolChoiceShellParam | null) | undefined, tools?: (Array | null) | undefined, top_p?: (number | null) | undefined, truncation?: ('auto' | 'disabled' | null) | undefined, user?: (string | null) | undefined, service_tier?: (string | null) | undefined, safety_identifier?: (string | null) | undefined, prompt?: (PromptObject | null) | undefined, max_tool_calls?: (number | null) | undefined, prompt_cache_key?: (string | null) | undefined, prompt_cache_retention?: (string | null) | undefined, prompt_cache_options?: (PromptCacheOptions | null) | undefined, stream_options?: (ResponsesAPIStreamOptions | null) | undefined, top_logprobs?: (number | null) | undefined, partial_images?: (number | null) | undefined, context_management?: (Array | null) | undefined, input: string | Array, model: string}}; export type CreateApiV1ResponsesOptions = {baseUrl: string, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; 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({query: z.string(), type: z.literal("search"), queries: z.array(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-1.5"])]).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.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 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 mcpApprovalResponse = 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 genericResponseOutputItemContentAnnotation = z.object({type: z.string().nullable(), start_index: z.number().int().nullable(), end_index: z.number().int().nullable(), url: z.string().nullable(), title: z.string().nullable()}).and(z.record(z.string(), z.unknown())); export const outputText = z.object({type: z.string().nullable(), text: z.string().nullable(), annotations: z.array(genericResponseOutputItemContentAnnotation).nullable()}).and(z.record(z.string(), z.unknown())); export const genericResponseOutputItem = z.object({type: z.string(), id: z.string(), status: z.string(), role: z.string(), content: z.array(outputText), phase: z.enum(["commentary", "final_answer"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const outputCodeInterpreterCallLog = z.object({type: z.literal("logs"), logs: z.string()}).and(z.record(z.string(), z.unknown())); export const outputCodeInterpreterCall = z.object({type: z.literal("code_interpreter_call"), id: z.string(), code: z.string().nullable(), container_id: z.string().nullable(), status: z.enum(["in_progress", "completed", "incomplete", "failed"]), outputs: z.array(outputCodeInterpreterCallLog).nullable()}).and(z.record(z.string(), z.unknown())); export const outputFunctionToolCall = z.object({arguments: z.string().nullable(), call_id: z.string().nullable(), name: z.string().nullable(), type: z.string().nullable(), id: z.string().nullable(), status: z.enum(["in_progress", "completed", "incomplete"]), phase: z.enum(["commentary", "final_answer"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const outputImageGenerationCall = z.object({type: z.literal("image_generation_call"), id: z.string(), status: z.enum(["in_progress", "completed", "incomplete", "failed"]), result: z.string().nullable()}).and(z.record(z.string(), z.unknown())); export const customToolCallOutputItem = z.object({type: z.literal("custom_tool_call"), call_id: z.string(), id: z.string().nullable().optional(), name: z.string(), input: z.string(), status: z.enum(["in_progress", "completed", "incomplete"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const toolChoiceAllowedParam = 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 toolChoiceTypesParam = 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 toolChoiceFunctionParam = z.object({name: z.string(), type: z.literal("function")}).and(z.record(z.string(), z.unknown())); export const toolChoiceMcpParam = z.object({server_label: z.string(), type: z.literal("mcp"), name: z.string().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const toolChoiceCustomParam = z.object({name: z.string(), type: z.literal("custom")}).and(z.record(z.string(), z.unknown())); export const toolChoiceApplyPatchParam = z.object({type: z.literal("apply_patch")}).and(z.record(z.string(), z.unknown())); export const toolChoiceShellParam = z.object({type: z.literal("shell")}).and(z.record(z.string(), z.unknown())); export const responseFormatText = z.object({type: z.literal("text")}).and(z.record(z.string(), z.unknown())); export const responseFormatTextJSONSchemaConfigParam = z.object({name: z.string(), schema: z.record(z.string(), z.unknown()), type: z.literal("json_schema"), description: z.string().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 responseTextConfigParam = z.object({format: z.union([responseFormatText, responseFormatTextJSONSchemaConfigParam, responseFormatJSONObject]).optional(), verbosity: z.enum(["low", "medium", "high"]).nullable().optional()}).and(z.record(z.string(), z.unknown())); export const cachedTokensDetails = z.object({text_tokens: z.number().int().nullable().optional(), audio_tokens: z.number().int().nullable().optional(), image_tokens: z.number().int().nullable().optional()}); export const inputTokensDetails = z.object({audio_tokens: z.number().int().nullable().optional(), cached_tokens: z.number().int().optional(), cached_tokens_details: cachedTokensDetails.nullable().optional(), image_tokens: z.number().int().nullable().optional(), text_tokens: z.number().int().nullable().optional(), video_tokens: z.number().int().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const outputTokensDetails = z.object({audio_tokens: z.number().int().nullable().optional(), reasoning_tokens: z.number().int().nullable().optional(), text_tokens: z.number().int().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responseAPIUsage = z.object({input_tokens: z.number().int(), input_tokens_details: inputTokensDetails.nullable().optional(), output_tokens: z.number().int(), output_tokens_details: outputTokensDetails.nullable().optional(), total_tokens: z.number().int(), cost: z.number().nullable().optional()}).and(z.record(z.string(), z.unknown())); export const responsesAPIResponse = z.object({id: z.string(), created_at: z.number().int(), error: z.record(z.string(), z.unknown()).nullable().optional(), incomplete_details: incompleteDetails.nullable().optional(), instructions: z.string().nullable().optional(), metadata: z.record(z.string(), z.unknown()).nullable().optional(), model: z.string().nullable().optional(), object: z.string().nullable().optional(), output: z.union([z.array(z.union([responseOutputMessage, responseFileSearchToolCall, responseFunctionToolCall, responseFunctionToolCallOutputItem, responseFunctionWebSearch, responseComputerToolCall, responseComputerToolCallOutputItem, responseReasoningItem, responseToolSearchCall, responseToolSearchOutputItem, responseCompactionItem, imageGenerationCall, responseCodeInterpreterToolCall, localShellCall, localShellCallOutput, responseFunctionShellToolCall, responseFunctionShellToolCallOutput, responseApplyPatchToolCall, responseApplyPatchToolCallOutput, mcpCall, mcpListTools, mcpApprovalRequest, mcpApprovalResponse, responseCustomToolCall, responseCustomToolCallOutputItem, z.record(z.string(), z.unknown())])), z.array(z.union([genericResponseOutputItem, outputCodeInterpreterCall, outputFunctionToolCall, outputImageGenerationCall, responseFunctionToolCall, responseFunctionWebSearch, customToolCallOutputItem]))]), parallel_tool_calls: z.boolean().nullable().optional(), temperature: z.number().nullable().optional(), tool_choice: z.union([z.enum(["none", "auto", "required"]), toolChoiceAllowedParam, toolChoiceTypesParam, toolChoiceFunctionParam, toolChoiceMcpParam, toolChoiceCustomParam, toolChoiceApplyPatchParam, toolChoiceShellParam]).nullable().optional(), tools: z.union([z.array(z.union([functionTool, fileSearchTool, computerTool, computerUsePreviewTool, webSearchTool, mcp, codeInterpreter, imageGeneration, localShell, functionShellTool, customTool, namespaceTool, toolSearchTool, webSearchPreviewTool, applyPatchTool])), z.array(responseFunctionToolCall), z.array(z.record(z.string(), z.unknown()))]).nullable().optional(), top_p: z.number().nullable().optional(), max_output_tokens: z.number().int().nullable().optional(), previous_response_id: z.string().nullable().optional(), reasoning: z.record(z.string(), z.unknown()).nullable().optional(), status: z.string().nullable().optional(), text: z.union([responseTextConfigParam, z.record(z.string(), z.unknown())]).nullable().optional(), truncation: z.enum(["auto", "disabled"]).nullable().optional(), usage: responseAPIUsage.nullable().optional(), user: z.string().nullable().optional(), store: z.boolean().nullable().optional()}).and(z.record(z.string(), z.unknown())); 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 }; /** * Responses Api * * POST /v1/responses */ export const createApiV1Responses = async (args: CreateApiV1ResponsesArgs, options: CreateApiV1ResponsesOptions) => { const {baseUrl, fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (APIKeyHeader !== undefined) headers.set("x-litellm-api-key", APIKeyHeader) 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(responsesAPIResponse, await res.json()) };