import {z} from 'zod' export type AnthropicModel = string | 'claude-sonnet-5' | 'claude-fable-5' | 'claude-mythos-5' | 'claude-opus-5' | 'claude-opus-4-8' | 'claude-opus-4-7' | 'claude-mythos-preview' | 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-haiku-4-5' | 'claude-haiku-4-5-20251001' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-5' | 'claude-sonnet-4-5-20250929'; export type AnthropicCacheControlEphemeral = {ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'}; export type AnthropicRequestCharLocationCitation = {cited_text: string, document_index: number, document_title: string | null, end_char_index: number, start_char_index: number, type: 'char_location'}; export type AnthropicRequestPageLocationCitation = {cited_text: string, document_index: number, document_title: string | null, end_page_number: number, start_page_number: number, type: 'page_location'}; export type AnthropicRequestContentBlockLocationCitation = {cited_text: string, document_index: number, document_title: string | null, end_block_index: number, start_block_index: number, type: 'content_block_location'}; export type AnthropicRequestWebSearchResultLocationCitation = {cited_text: string, encrypted_index: string, title: string | null, type: 'web_search_result_location', url: string}; export type AnthropicRequestSearchResultLocationCitation = {cited_text: string, end_block_index: number, search_result_index: number, source: string, start_block_index: number, title: string | null, type: 'search_result_location'}; export type AnthropicBase64ImageSource = {data: string, media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp', type: 'base64'}; export type AnthropicURLImageSource = {type: 'url', url: string}; export type AnthropicFileImageSource = {file_id: string, type: 'file'}; export type AnthropicRequestImageTransformations = {oversized_image?: ('downsize' | 'error') | undefined}; export type AnthropicRequestCitationsConfig = {enabled?: boolean | undefined}; export type AnthropicBase64PDFSource = {data: string, media_type: 'application/pdf', type: 'base64'}; export type AnthropicPlainTextSource = {data: string, media_type: 'text/plain', type: 'text'}; export type AnthropicRequestTextBlock = {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: (Array | null) | undefined, text: string, type: 'text'}; export type AnthropicRequestImageBlock = {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, source: AnthropicBase64ImageSource | AnthropicURLImageSource | AnthropicFileImageSource, transformations?: (AnthropicRequestImageTransformations | null) | undefined, type: 'image'}; export type AnthropicContentBlockSource = {content: string | Array, type: 'content'}; export type AnthropicURLPDFSource = {type: 'url', url: string}; export type AnthropicFileDocumentSource = {file_id: string, type: 'file'}; export type AnthropicDirectCaller = {type: 'direct'}; export type AnthropicServerToolCaller = {tool_id: string, type: 'code_execution_20250825'}; export type AnthropicServerToolCaller20260120 = {tool_id: string, type: 'code_execution_20260120'}; export type AnthropicRequestSearchResultBlock = {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: AnthropicRequestCitationsConfig | undefined, content: Array, source: string, title: string, type: 'search_result'}; export type AnthropicRequestDocumentBlock = {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: (AnthropicRequestCitationsConfig | null) | undefined, context?: (string | null) | undefined, source: AnthropicBase64PDFSource | AnthropicPlainTextSource | AnthropicContentBlockSource | AnthropicURLPDFSource | AnthropicFileDocumentSource, title?: (string | null) | undefined, type: 'document'}; export type AnthropicRequestToolReferenceBlock = {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, tool_name: string, type: 'tool_reference'}; export type AnthropicBrowserStateChangeTabOpened = {tab_id: string, type: 'tab_opened'}; export type AnthropicBrowserStateChangeDownloadStarted = {download_id: string, type: 'download_started', url: string}; export type AnthropicBrowserStateChangeDownloadCompleted = {download_id: string, path?: (string | null) | undefined, size_bytes?: (number | null) | undefined, type: 'download_completed', url: string}; export type AnthropicBrowserStateChangeDownloadFailed = {download_id: string, error?: (string | null) | undefined, type: 'download_failed', url: string}; export type AnthropicBrowserStateTabEntry = {active?: boolean | undefined, tab_id: string, title: string, url: string}; export type AnthropicRequestBrowserStateBlock = {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, state_changes?: (Array | null) | undefined, tabs: Array, type: 'browser_state'}; export type AnthropicRequestWebSearchResultBlock = {encrypted_content: string, page_age?: (string | null) | undefined, title: string, type: 'web_search_result', url: string}; export type AnthropicWebSearchToolResultErrorCode = 'invalid_tool_input' | 'unavailable' | 'max_uses_exceeded' | 'too_many_requests' | 'query_too_long' | 'request_too_large'; export type AnthropicRequestWebSearchToolResultError = {error_code: AnthropicWebSearchToolResultErrorCode, type: 'web_search_tool_result_error'}; export type AnthropicWebFetchToolResultErrorCode = 'invalid_tool_input' | 'url_too_long' | 'url_not_allowed' | 'url_not_in_prior_context' | 'url_not_accessible' | 'unsupported_content_type' | 'too_many_requests' | 'max_uses_exceeded' | 'unavailable'; export type AnthropicRequestWebFetchToolResultError = {error_code: AnthropicWebFetchToolResultErrorCode, type: 'web_fetch_tool_result_error'}; export type AnthropicRequestWebFetchResultBlock = {content: AnthropicRequestDocumentBlock, retrieved_at?: (string | null) | undefined, type: 'web_fetch_result', url: string}; export type AnthropicCodeExecutionToolResultErrorCode = 'invalid_tool_input' | 'unavailable' | 'too_many_requests' | 'execution_time_exceeded'; export type AnthropicRequestCodeExecutionToolResultError = {error_code: AnthropicCodeExecutionToolResultErrorCode, type: 'code_execution_tool_result_error'}; export type AnthropicRequestCodeExecutionOutputBlock = {file_id: string, type: 'code_execution_output'}; export type AnthropicRequestCodeExecutionResultBlock = {content: Array, return_code: number, stderr: string, stdout: string, type: 'code_execution_result'}; export type AnthropicRequestEncryptedCodeExecutionResultBlock = {content: Array, encrypted_stdout: string, return_code: number, stderr: string, type: 'encrypted_code_execution_result'}; export type AnthropicBashCodeExecutionToolResultErrorCode = 'invalid_tool_input' | 'unavailable' | 'too_many_requests' | 'execution_time_exceeded' | 'output_file_too_large'; export type AnthropicRequestBashCodeExecutionToolResultError = {error_code: AnthropicBashCodeExecutionToolResultErrorCode, type: 'bash_code_execution_tool_result_error'}; export type AnthropicRequestBashCodeExecutionOutputBlock = {file_id: string, type: 'bash_code_execution_output'}; export type AnthropicRequestBashCodeExecutionResultBlock = {content: Array, return_code: number, stderr: string, stdout: string, type: 'bash_code_execution_result'}; export type AnthropicTextEditorCodeExecutionToolResultErrorCode = 'invalid_tool_input' | 'unavailable' | 'too_many_requests' | 'execution_time_exceeded' | 'file_not_found'; export type AnthropicRequestTextEditorCodeExecutionToolResultError = {error_code: AnthropicTextEditorCodeExecutionToolResultErrorCode, error_message?: (string | null) | undefined, type: 'text_editor_code_execution_tool_result_error'}; export type AnthropicRequestTextEditorCodeExecutionViewResultBlock = {content: string, file_type: 'text' | 'image' | 'pdf', num_lines?: (number | null) | undefined, start_line?: (number | null) | undefined, total_lines?: (number | null) | undefined, type: 'text_editor_code_execution_view_result'}; export type AnthropicRequestTextEditorCodeExecutionCreateResultBlock = {is_file_update: boolean, type: 'text_editor_code_execution_create_result'}; export type AnthropicRequestTextEditorCodeExecutionStrReplaceResultBlock = {lines?: (Array | null) | undefined, new_lines?: (number | null) | undefined, new_start?: (number | null) | undefined, old_lines?: (number | null) | undefined, old_start?: (number | null) | undefined, type: 'text_editor_code_execution_str_replace_result'}; export type AnthropicToolSearchToolResultErrorCode = 'invalid_tool_input' | 'unavailable' | 'too_many_requests' | 'execution_time_exceeded'; export type AnthropicRequestToolSearchToolResultError = {error_code: AnthropicToolSearchToolResultErrorCode, error_message?: (string | null) | undefined, type: 'tool_search_tool_result_error'}; export type AnthropicRequestToolSearchToolSearchResultBlock = {tool_references: Array, type: 'tool_search_tool_search_result'}; export type AnthropicInputContentBlock = {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: (Array | null) | undefined, text: string, type: 'text'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, source: AnthropicBase64ImageSource | AnthropicURLImageSource | AnthropicFileImageSource, transformations?: (AnthropicRequestImageTransformations | null) | undefined, type: 'image'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: (AnthropicRequestCitationsConfig | null) | undefined, context?: (string | null) | undefined, source: AnthropicBase64PDFSource | AnthropicPlainTextSource | AnthropicContentBlockSource | AnthropicURLPDFSource | AnthropicFileDocumentSource, title?: (string | null) | undefined, type: 'document'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: AnthropicRequestCitationsConfig | undefined, content: Array, source: string, title: string, type: 'search_result'} | {signature: string, thinking: string, type: 'thinking'} | {data: string, type: 'redacted_thinking'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, caller?: (AnthropicDirectCaller | AnthropicServerToolCaller | AnthropicServerToolCaller20260120) | undefined, id: string, input: {[key: string]: unknown}, name: string, toolset_name?: (string | null) | undefined, type: 'tool_use'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, content?: (string | Array) | undefined, is_error?: boolean | undefined, tool_use_id: string, toolset_name?: (string | null) | undefined, type: 'tool_result'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, caller?: (AnthropicDirectCaller | AnthropicServerToolCaller | AnthropicServerToolCaller20260120) | undefined, id: string, input: {[key: string]: unknown}, name: 'web_search' | 'web_fetch' | 'code_execution' | 'bash_code_execution' | 'text_editor_code_execution' | 'tool_search_tool_regex' | 'tool_search_tool_bm25', type: 'server_tool_use'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, caller?: (AnthropicDirectCaller | AnthropicServerToolCaller | AnthropicServerToolCaller20260120) | undefined, content: Array | AnthropicRequestWebSearchToolResultError, tool_use_id: string, type: 'web_search_tool_result'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, caller?: (AnthropicDirectCaller | AnthropicServerToolCaller | AnthropicServerToolCaller20260120) | undefined, content: AnthropicRequestWebFetchToolResultError | AnthropicRequestWebFetchResultBlock, tool_use_id: string, type: 'web_fetch_tool_result'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, content: AnthropicRequestCodeExecutionToolResultError | AnthropicRequestCodeExecutionResultBlock | AnthropicRequestEncryptedCodeExecutionResultBlock, tool_use_id: string, type: 'code_execution_tool_result'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, content: AnthropicRequestBashCodeExecutionToolResultError | AnthropicRequestBashCodeExecutionResultBlock, tool_use_id: string, type: 'bash_code_execution_tool_result'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, content: AnthropicRequestTextEditorCodeExecutionToolResultError | AnthropicRequestTextEditorCodeExecutionViewResultBlock | AnthropicRequestTextEditorCodeExecutionCreateResultBlock | AnthropicRequestTextEditorCodeExecutionStrReplaceResultBlock, tool_use_id: string, type: 'text_editor_code_execution_tool_result'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, content: AnthropicRequestToolSearchToolResultError | AnthropicRequestToolSearchToolSearchResultBlock, tool_use_id: string, type: 'tool_search_tool_result'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, file_id: string, type: 'container_upload'} | {cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, content: Array, type: 'mid_conv_system'}; export type AnthropicInputMessage = {content: string | Array, role: 'user' | 'assistant' | 'system'}; export type AnthropicSkillParams = {skill_id: string, type: 'anthropic' | 'custom', version?: string | undefined}; export type AnthropicMetadata = {user_id?: (string | null) | undefined}; export type AnthropicEffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max'; export type AnthropicJsonOutputFormat = {schema: {[key: string]: unknown}, type: 'json_schema'}; export type AnthropicOutputConfig = {effort?: (AnthropicEffortLevel | null) | undefined, format?: (AnthropicJsonOutputFormat | null) | undefined}; export type AnthropicThinkingDisplayMode = 'summarized' | 'omitted'; export type AnthropicThinkingConfigParam = {budget_tokens: number, display?: (AnthropicThinkingDisplayMode | null) | undefined, type: 'enabled'} | {type: 'disabled'} | {display?: (AnthropicThinkingDisplayMode | null) | undefined, type: 'adaptive'}; export type AnthropicToolChoice = {disable_parallel_tool_use?: boolean | undefined, type: 'auto'} | {disable_parallel_tool_use?: boolean | undefined, type: 'any'} | {disable_parallel_tool_use?: boolean | undefined, name: string, type: 'tool'} | {type: 'none'}; export type AnthropicInputSchema = {properties?: ({[key: string]: unknown} | null) | undefined, required?: (Array | null) | undefined, type: 'object'} | {[key: string]: unknown}; export type AnthropicAllowedCaller = 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'; export type AnthropicJsonValue = unknown; export type AnthropicTool = {type?: ('custom' | null) | undefined, description?: string | undefined, name: string, input_schema: AnthropicInputSchema, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, strict?: boolean | undefined, eager_input_streaming?: (boolean | null) | undefined, allowed_callers?: Array | undefined, defer_loading?: boolean | undefined, input_examples?: Array<{[key: string]: AnthropicJsonValue}> | undefined}; export type AnthropicBashTool20250124 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, input_examples?: Array<{[key: string]: AnthropicJsonValue}> | undefined, name: 'bash', strict?: boolean | undefined, type: 'bash_20250124'}; export type AnthropicCodeExecutionTool20250522 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, name: 'code_execution', strict?: boolean | undefined, type: 'code_execution_20250522'}; export type AnthropicCodeExecutionTool20250825 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, name: 'code_execution', strict?: boolean | undefined, type: 'code_execution_20250825'}; export type AnthropicCodeExecutionTool20260120 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, name: 'code_execution', strict?: boolean | undefined, type: 'code_execution_20260120'}; export type AnthropicCodeExecutionTool20260521 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, name: 'code_execution', strict?: boolean | undefined, type: 'code_execution_20260521'}; export type AnthropicBrowserCloseTabConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserDoubleClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserFileUploadConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserFindConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserFormInputConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserGetPageTextConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserHoldKeyConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserHoverConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserJavascriptExecConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserKeyConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserLeftClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserLeftClickDragConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserLeftMouseDownConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserLeftMouseUpConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserListTabsConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserMiddleClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserMouseMoveConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserNavigateConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserNewTabConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserReadConsoleConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserReadNetworkConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserReadPageConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserRightClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserScreenshotConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserScrollConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserScrollToConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserSwitchTabConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserTripleClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserTypeConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserWaitConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserZoomConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicBrowserToolsetConfigs = {close_tab?: (AnthropicBrowserCloseTabConfig | null) | undefined, double_click?: (AnthropicBrowserDoubleClickConfig | null) | undefined, file_upload?: (AnthropicBrowserFileUploadConfig | null) | undefined, find?: (AnthropicBrowserFindConfig | null) | undefined, form_input?: (AnthropicBrowserFormInputConfig | null) | undefined, get_page_text?: (AnthropicBrowserGetPageTextConfig | null) | undefined, hold_key?: (AnthropicBrowserHoldKeyConfig | null) | undefined, hover?: (AnthropicBrowserHoverConfig | null) | undefined, javascript_exec?: (AnthropicBrowserJavascriptExecConfig | null) | undefined, key?: (AnthropicBrowserKeyConfig | null) | undefined, left_click?: (AnthropicBrowserLeftClickConfig | null) | undefined, left_click_drag?: (AnthropicBrowserLeftClickDragConfig | null) | undefined, left_mouse_down?: (AnthropicBrowserLeftMouseDownConfig | null) | undefined, left_mouse_up?: (AnthropicBrowserLeftMouseUpConfig | null) | undefined, list_tabs?: (AnthropicBrowserListTabsConfig | null) | undefined, middle_click?: (AnthropicBrowserMiddleClickConfig | null) | undefined, mouse_move?: (AnthropicBrowserMouseMoveConfig | null) | undefined, navigate?: (AnthropicBrowserNavigateConfig | null) | undefined, new_tab?: (AnthropicBrowserNewTabConfig | null) | undefined, read_console?: (AnthropicBrowserReadConsoleConfig | null) | undefined, read_network?: (AnthropicBrowserReadNetworkConfig | null) | undefined, read_page?: (AnthropicBrowserReadPageConfig | null) | undefined, right_click?: (AnthropicBrowserRightClickConfig | null) | undefined, screenshot?: (AnthropicBrowserScreenshotConfig | null) | undefined, scroll?: (AnthropicBrowserScrollConfig | null) | undefined, scroll_to?: (AnthropicBrowserScrollToConfig | null) | undefined, switch_tab?: (AnthropicBrowserSwitchTabConfig | null) | undefined, triple_click?: (AnthropicBrowserTripleClickConfig | null) | undefined, type?: (AnthropicBrowserTypeConfig | null) | undefined, wait?: (AnthropicBrowserWaitConfig | null) | undefined, zoom?: (AnthropicBrowserZoomConfig | null) | undefined}; export type AnthropicBrowserToolset20260801 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, configs?: (AnthropicBrowserToolsetConfigs | null) | undefined, type: 'browser_toolset_20260801'}; export type AnthropicMemoryTool20250818 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, input_examples?: Array<{[key: string]: AnthropicJsonValue}> | undefined, name: 'memory', strict?: boolean | undefined, type: 'memory_20250818'}; export type AnthropicComputerCursorPositionConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerDoubleClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerHoldKeyConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerKeyConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerLeftClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerLeftClickDragConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerLeftMouseDownConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerLeftMouseUpConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerMiddleClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerMouseMoveConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerRightClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerScreenshotConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerScrollConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerTripleClickConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerTypeConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerWaitConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerZoomConfig = {defer_loading?: (boolean | null) | undefined, enabled?: (boolean | null) | undefined}; export type AnthropicComputerToolsetConfigs = {cursor_position?: (AnthropicComputerCursorPositionConfig | null) | undefined, double_click?: (AnthropicComputerDoubleClickConfig | null) | undefined, hold_key?: (AnthropicComputerHoldKeyConfig | null) | undefined, key?: (AnthropicComputerKeyConfig | null) | undefined, left_click?: (AnthropicComputerLeftClickConfig | null) | undefined, left_click_drag?: (AnthropicComputerLeftClickDragConfig | null) | undefined, left_mouse_down?: (AnthropicComputerLeftMouseDownConfig | null) | undefined, left_mouse_up?: (AnthropicComputerLeftMouseUpConfig | null) | undefined, middle_click?: (AnthropicComputerMiddleClickConfig | null) | undefined, mouse_move?: (AnthropicComputerMouseMoveConfig | null) | undefined, right_click?: (AnthropicComputerRightClickConfig | null) | undefined, screenshot?: (AnthropicComputerScreenshotConfig | null) | undefined, scroll?: (AnthropicComputerScrollConfig | null) | undefined, triple_click?: (AnthropicComputerTripleClickConfig | null) | undefined, type?: (AnthropicComputerTypeConfig | null) | undefined, wait?: (AnthropicComputerWaitConfig | null) | undefined, zoom?: (AnthropicComputerZoomConfig | null) | undefined}; export type AnthropicComputerToolset20260801 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, configs?: (AnthropicComputerToolsetConfigs | null) | undefined, type: 'computer_toolset_20260801'}; export type AnthropicTextEditor20250124 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, input_examples?: Array<{[key: string]: AnthropicJsonValue}> | undefined, name: 'str_replace_editor', strict?: boolean | undefined, type: 'text_editor_20250124'}; export type AnthropicTextEditor20250429 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, input_examples?: Array<{[key: string]: AnthropicJsonValue}> | undefined, name: 'str_replace_based_edit_tool', strict?: boolean | undefined, type: 'text_editor_20250429'}; export type AnthropicTextEditor20250728 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, input_examples?: Array<{[key: string]: AnthropicJsonValue}> | undefined, max_characters?: (number | null) | undefined, name: 'str_replace_based_edit_tool', strict?: boolean | undefined, type: 'text_editor_20250728'}; export type AnthropicUserLocation = {city?: (string | null) | undefined, country?: (string | null) | undefined, region?: (string | null) | undefined, timezone?: (string | null) | undefined, type: 'approximate'}; export type AnthropicWebSearchTool20250305 = {allowed_callers?: Array | undefined, allowed_domains?: (Array | null) | undefined, blocked_domains?: (Array | null) | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, max_uses?: (number | null) | undefined, name: 'web_search', strict?: boolean | undefined, type: 'web_search_20250305', user_location?: (AnthropicUserLocation | null) | undefined}; export type AnthropicWebFetchTool20250910 = {allowed_callers?: Array | undefined, allowed_domains?: (Array | null) | undefined, blocked_domains?: (Array | null) | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: (AnthropicRequestCitationsConfig | null) | undefined, defer_loading?: boolean | undefined, max_content_tokens?: (number | null) | undefined, max_uses?: (number | null) | undefined, name: 'web_fetch', strict?: boolean | undefined, type: 'web_fetch_20250910'}; export type AnthropicWebSearchTool20260209 = {allowed_callers?: Array | undefined, allowed_domains?: (Array | null) | undefined, blocked_domains?: (Array | null) | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, max_uses?: (number | null) | undefined, name: 'web_search', strict?: boolean | undefined, type: 'web_search_20260209', user_location?: (AnthropicUserLocation | null) | undefined}; export type AnthropicWebFetchTool20260209 = {allowed_callers?: Array | undefined, allowed_domains?: (Array | null) | undefined, blocked_domains?: (Array | null) | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: (AnthropicRequestCitationsConfig | null) | undefined, defer_loading?: boolean | undefined, max_content_tokens?: (number | null) | undefined, max_uses?: (number | null) | undefined, name: 'web_fetch', strict?: boolean | undefined, type: 'web_fetch_20260209'}; export type AnthropicWebFetchTool20260309 = {allowed_callers?: Array | undefined, allowed_domains?: (Array | null) | undefined, blocked_domains?: (Array | null) | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: (AnthropicRequestCitationsConfig | null) | undefined, defer_loading?: boolean | undefined, max_content_tokens?: (number | null) | undefined, max_uses?: (number | null) | undefined, name: 'web_fetch', strict?: boolean | undefined, type: 'web_fetch_20260309', use_cache?: boolean | undefined}; export type AnthropicWebSearchTool20260318 = {allowed_callers?: Array | undefined, allowed_domains?: (Array | null) | undefined, blocked_domains?: (Array | null) | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, max_uses?: (number | null) | undefined, name: 'web_search', response_inclusion?: ('full' | 'excluded') | undefined, strict?: boolean | undefined, type: 'web_search_20260318', user_location?: (AnthropicUserLocation | null) | undefined}; export type AnthropicWebFetchTool20260318 = {allowed_callers?: Array | undefined, allowed_domains?: (Array | null) | undefined, blocked_domains?: (Array | null) | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, citations?: (AnthropicRequestCitationsConfig | null) | undefined, defer_loading?: boolean | undefined, max_content_tokens?: (number | null) | undefined, max_uses?: (number | null) | undefined, name: 'web_fetch', response_inclusion?: ('full' | 'excluded') | undefined, strict?: boolean | undefined, type: 'web_fetch_20260318', use_cache?: boolean | undefined}; export type AnthropicToolSearchToolBM2520251119 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, name: 'tool_search_tool_bm25', strict?: boolean | undefined, type: 'tool_search_tool_bm25_20251119' | 'tool_search_tool_bm25'}; export type AnthropicToolSearchToolRegex20251119 = {allowed_callers?: Array | undefined, cache_control?: (AnthropicCacheControlEphemeral | null) | undefined, defer_loading?: boolean | undefined, name: 'tool_search_tool_regex', strict?: boolean | undefined, type: 'tool_search_tool_regex_20251119' | 'tool_search_tool_regex'}; export type AnthropicCreateMessageParams = {model: AnthropicModel, messages: Array, cache_control?: ({ttl?: ('5m' | '1h') | undefined, type: 'ephemeral'} | null) | undefined, container?: ({id?: (string | null) | undefined, skills?: (Array | null) | undefined} | string | null) | undefined, inference_geo?: (string | null) | undefined, max_tokens: number, metadata?: AnthropicMetadata | undefined, output_config?: AnthropicOutputConfig | undefined, service_tier?: ('auto' | 'standard_only') | undefined, stop_sequences?: Array | undefined, stream?: boolean | undefined, system?: (string | Array) | undefined, temperature?: number | undefined, thinking?: AnthropicThinkingConfigParam | undefined, tool_choice?: AnthropicToolChoice | undefined, tools?: (Array) | undefined, top_k?: number | undefined, top_p?: number | undefined}; export type CreateApiV1MessagesArgs = {'anthropic-version'?: string | undefined, 'anthropic-user-profile-id'?: string | undefined, body: AnthropicCreateMessageParams}; export type CreateApiV1MessagesOptions = {baseUrl?: string | undefined, gatewayAnthropicKey?: string | undefined, fetch?: typeof fetch | undefined}; export const anthropicResponseCharLocationCitation = z.object({cited_text: z.string(), document_index: z.number().int().gte(0), document_title: z.string().nullable(), end_char_index: z.number().int(), file_id: z.string().nullable(), start_char_index: z.number().int().gte(0), type: z.literal("char_location")}); export const anthropicResponsePageLocationCitation = z.object({cited_text: z.string(), document_index: z.number().int().gte(0), document_title: z.string().nullable(), end_page_number: z.number().int(), file_id: z.string().nullable(), start_page_number: z.number().int().gte(1), type: z.literal("page_location")}); export const anthropicResponseContentBlockLocationCitation = z.object({cited_text: z.string(), document_index: z.number().int().gte(0), document_title: z.string().nullable(), end_block_index: z.number().int(), file_id: z.string().nullable(), start_block_index: z.number().int().gte(0), type: z.literal("content_block_location")}); export const anthropicResponseWebSearchResultLocationCitation = z.object({cited_text: z.string(), encrypted_index: z.string(), title: z.string().max(512).nullable(), type: z.literal("web_search_result_location"), url: z.string()}); export const anthropicResponseSearchResultLocationCitation = z.object({cited_text: z.string(), end_block_index: z.number().int(), search_result_index: z.number().int().gte(0), source: z.string(), start_block_index: z.number().int().gte(0), title: z.string().nullable(), type: z.literal("search_result_location")}); export const anthropicDirectCaller = z.object({type: z.literal("direct")}); export const anthropicServerToolCaller = z.object({tool_id: z.string(), type: z.literal("code_execution_20250825")}); export const anthropicServerToolCaller20260120 = z.object({tool_id: z.string(), type: z.literal("code_execution_20260120")}); export const anthropicWebSearchToolResultErrorCode = z.enum(["invalid_tool_input", "unavailable", "max_uses_exceeded", "too_many_requests", "query_too_long", "request_too_large"]); export const anthropicResponseWebSearchToolResultError = z.object({error_code: anthropicWebSearchToolResultErrorCode, type: z.literal("web_search_tool_result_error")}); export const anthropicResponseWebSearchResultBlock = z.object({encrypted_content: z.string(), page_age: z.string().nullable(), title: z.string(), type: z.literal("web_search_result"), url: z.string()}); export const anthropicWebFetchToolResultErrorCode = z.enum(["invalid_tool_input", "url_too_long", "url_not_allowed", "url_not_in_prior_context", "url_not_accessible", "unsupported_content_type", "too_many_requests", "max_uses_exceeded", "unavailable"]); export const anthropicResponseWebFetchToolResultError = z.object({error_code: anthropicWebFetchToolResultErrorCode, type: z.literal("web_fetch_tool_result_error")}); export const anthropicResponseCitationsConfig = z.object({enabled: z.boolean()}); export const anthropicBase64PDFSource = z.object({data: z.string(), media_type: z.literal("application/pdf"), type: z.literal("base64")}); export const anthropicPlainTextSource = z.object({data: z.string(), media_type: z.literal("text/plain"), type: z.literal("text")}); export const anthropicResponseDocumentBlock = z.object({citations: anthropicResponseCitationsConfig.nullable(), source: z.discriminatedUnion("type", [anthropicBase64PDFSource, anthropicPlainTextSource]), title: z.string().nullable(), type: z.literal("document")}); export const anthropicResponseWebFetchResultBlock = z.object({content: anthropicResponseDocumentBlock, retrieved_at: z.string().nullable(), type: z.literal("web_fetch_result"), url: z.string()}); export const anthropicCodeExecutionToolResultErrorCode = z.enum(["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]); export const anthropicResponseCodeExecutionToolResultError = z.object({error_code: anthropicCodeExecutionToolResultErrorCode, type: z.literal("code_execution_tool_result_error")}); export const anthropicResponseCodeExecutionOutputBlock = z.object({file_id: z.string(), type: z.literal("code_execution_output")}); export const anthropicResponseCodeExecutionResultBlock = z.object({content: z.array(anthropicResponseCodeExecutionOutputBlock), return_code: z.number().int(), stderr: z.string(), stdout: z.string(), type: z.literal("code_execution_result")}); export const anthropicResponseEncryptedCodeExecutionResultBlock = z.object({content: z.array(anthropicResponseCodeExecutionOutputBlock), encrypted_stdout: z.string(), return_code: z.number().int(), stderr: z.string(), type: z.literal("encrypted_code_execution_result")}); export const anthropicBashCodeExecutionToolResultErrorCode = z.enum(["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded", "output_file_too_large"]); export const anthropicResponseBashCodeExecutionToolResultError = z.object({error_code: anthropicBashCodeExecutionToolResultErrorCode, type: z.literal("bash_code_execution_tool_result_error")}); export const anthropicResponseBashCodeExecutionOutputBlock = z.object({file_id: z.string(), type: z.literal("bash_code_execution_output")}); export const anthropicResponseBashCodeExecutionResultBlock = z.object({content: z.array(anthropicResponseBashCodeExecutionOutputBlock), return_code: z.number().int(), stderr: z.string(), stdout: z.string(), type: z.literal("bash_code_execution_result")}); export const anthropicTextEditorCodeExecutionToolResultErrorCode = z.enum(["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded", "file_not_found"]); export const anthropicResponseTextEditorCodeExecutionToolResultError = z.object({error_code: anthropicTextEditorCodeExecutionToolResultErrorCode, error_message: z.string().nullable(), type: z.literal("text_editor_code_execution_tool_result_error")}); export const anthropicResponseTextEditorCodeExecutionViewResultBlock = z.object({content: z.string(), file_type: z.enum(["text", "image", "pdf"]), num_lines: z.number().int().nullable(), start_line: z.number().int().nullable(), total_lines: z.number().int().nullable(), type: z.literal("text_editor_code_execution_view_result")}); export const anthropicResponseTextEditorCodeExecutionCreateResultBlock = z.object({is_file_update: z.boolean(), type: z.literal("text_editor_code_execution_create_result")}); export const anthropicResponseTextEditorCodeExecutionStrReplaceResultBlock = z.object({lines: z.array(z.string()).nullable(), new_lines: z.number().int().nullable(), new_start: z.number().int().nullable(), old_lines: z.number().int().nullable(), old_start: z.number().int().nullable(), type: z.literal("text_editor_code_execution_str_replace_result")}); export const anthropicToolSearchToolResultErrorCode = z.enum(["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]); export const anthropicResponseToolSearchToolResultError = z.object({error_code: anthropicToolSearchToolResultErrorCode, error_message: z.string().nullable(), type: z.literal("tool_search_tool_result_error")}); export const anthropicResponseToolReferenceBlock = z.object({tool_name: z.string().min(1).max(256), type: z.literal("tool_reference")}); export const anthropicResponseToolSearchToolSearchResultBlock = z.object({tool_references: z.array(anthropicResponseToolReferenceBlock), type: z.literal("tool_search_tool_search_result")}); export const anthropicContentBlock = z.discriminatedUnion("type", [z.object({citations: z.array(z.discriminatedUnion("type", [anthropicResponseCharLocationCitation, anthropicResponsePageLocationCitation, anthropicResponseContentBlockLocationCitation, anthropicResponseWebSearchResultLocationCitation, anthropicResponseSearchResultLocationCitation])).nullable().optional(), text: z.string().max(5000000), type: z.literal("text")}), z.object({signature: z.string(), thinking: z.string(), type: z.literal("thinking")}), z.object({data: z.string(), type: z.literal("redacted_thinking")}), z.object({caller: z.discriminatedUnion("type", [anthropicDirectCaller, anthropicServerToolCaller, anthropicServerToolCaller20260120]).optional(), id: z.string(), input: z.record(z.string(), z.unknown()), name: z.string().min(1), toolset_name: z.string().min(1).max(64).nullable().optional(), type: z.literal("tool_use")}), z.object({caller: z.discriminatedUnion("type", [anthropicDirectCaller, anthropicServerToolCaller, anthropicServerToolCaller20260120]).optional(), id: z.string(), input: z.record(z.string(), z.unknown()), name: z.enum(["web_search", "web_fetch", "code_execution", "bash_code_execution", "text_editor_code_execution", "tool_search_tool_regex", "tool_search_tool_bm25"]), type: z.literal("server_tool_use")}), z.object({caller: z.discriminatedUnion("type", [anthropicDirectCaller, anthropicServerToolCaller, anthropicServerToolCaller20260120]), content: z.union([anthropicResponseWebSearchToolResultError, z.array(anthropicResponseWebSearchResultBlock)]), tool_use_id: z.string(), type: z.literal("web_search_tool_result")}), z.object({caller: z.discriminatedUnion("type", [anthropicDirectCaller, anthropicServerToolCaller, anthropicServerToolCaller20260120]), content: z.union([anthropicResponseWebFetchToolResultError, anthropicResponseWebFetchResultBlock]), tool_use_id: z.string(), type: z.literal("web_fetch_tool_result")}), z.object({content: z.union([anthropicResponseCodeExecutionToolResultError, anthropicResponseCodeExecutionResultBlock, anthropicResponseEncryptedCodeExecutionResultBlock]), tool_use_id: z.string(), type: z.literal("code_execution_tool_result")}), z.object({content: z.union([anthropicResponseBashCodeExecutionToolResultError, anthropicResponseBashCodeExecutionResultBlock]), tool_use_id: z.string(), type: z.literal("bash_code_execution_tool_result")}), z.object({content: z.union([anthropicResponseTextEditorCodeExecutionToolResultError, anthropicResponseTextEditorCodeExecutionViewResultBlock, anthropicResponseTextEditorCodeExecutionCreateResultBlock, anthropicResponseTextEditorCodeExecutionStrReplaceResultBlock]), tool_use_id: z.string(), type: z.literal("text_editor_code_execution_tool_result")}), z.object({content: z.union([anthropicResponseToolSearchToolResultError, anthropicResponseToolSearchToolSearchResultBlock]), tool_use_id: z.string(), type: z.literal("tool_search_tool_result")}), z.object({file_id: z.string(), type: z.literal("container_upload")})]); export const anthropicModel = z.union([z.string(), z.literal("claude-sonnet-5"), z.literal("claude-fable-5"), z.literal("claude-mythos-5"), z.literal("claude-opus-5"), z.literal("claude-opus-4-8"), z.literal("claude-opus-4-7"), z.literal("claude-mythos-preview"), z.literal("claude-opus-4-6"), z.literal("claude-sonnet-4-6"), z.literal("claude-haiku-4-5"), z.literal("claude-haiku-4-5-20251001"), z.literal("claude-opus-4-5"), z.literal("claude-opus-4-5-20251101"), z.literal("claude-sonnet-4-5"), z.literal("claude-sonnet-4-5-20250929")]); export const anthropicStopReason = z.enum(["end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", "refusal", "model_context_window_exceeded"]); export const anthropicRefusalCategory = z.enum(["cyber", "bio", "frontier_llm", "reasoning_extraction", "general_harms"]); export const anthropicRefusalStopDetails = z.object({category: anthropicRefusalCategory.nullable(), explanation: z.string().nullable(), type: z.literal("refusal")}); export const anthropicCacheCreation = z.object({ephemeral_1h_input_tokens: z.number().int().gte(0), ephemeral_5m_input_tokens: z.number().int().gte(0)}); export const anthropicOutputTokensDetails = z.object({thinking_tokens: z.number().int().gte(0)}); export const anthropicServerToolUsage = z.object({web_fetch_requests: z.number().int().gte(0), web_search_requests: z.number().int().gte(0)}); export const anthropicUsage = z.object({cache_creation: anthropicCacheCreation.nullable(), cache_creation_input_tokens: z.number().int().gte(0).nullable(), cache_read_input_tokens: z.number().int().gte(0).nullable(), inference_geo: z.string().nullable().optional(), input_tokens: z.number().int().gte(0), output_tokens: z.number().int().gte(0), output_tokens_details: anthropicOutputTokensDetails.nullable(), server_tool_use: anthropicServerToolUsage.nullable().optional(), service_tier: z.enum(["standard", "priority", "batch"]).nullable()}); export const anthropicContainerSkill = z.object({skill_id: z.string().min(1).max(64), type: z.enum(["anthropic", "custom"]), version: z.string().min(1).max(64)}); export const anthropicContainer = z.object({expires_at: z.string(), id: z.string(), skills: z.array(anthropicContainerSkill).nullable()}); export const anthropicMessage = z.object({id: z.string(), type: z.literal("message"), role: z.literal("assistant"), content: z.array(anthropicContentBlock), model: anthropicModel, stop_reason: anthropicStopReason.nullable(), stop_sequence: z.string().nullable(), stop_details: anthropicRefusalStopDetails.nullable(), usage: anthropicUsage, container: anthropicContainer.nullable().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * /v1/messages * * POST /v1/messages * * Also accepts auth: gatewayBearer */ export const createApiV1Messages = async (args: CreateApiV1MessagesArgs, options?: CreateApiV1MessagesOptions) => { const {baseUrl = "https://aihubmix.com", fetch: fetchFn = fetch, gatewayAnthropicKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['anthropic-version'] != null) headers.set("anthropic-version", String(args['anthropic-version'])) if (args['anthropic-user-profile-id'] != null) headers.set("anthropic-user-profile-id", String(args['anthropic-user-profile-id'])) if (gatewayAnthropicKey !== undefined) headers.set("x-api-key", gatewayAnthropicKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/messages${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(anthropicMessage, await res.json()) };