import type { AIProviderConfig } from "../../../types/ai"; export type OpenRouterDataCollection = "allow" | "deny"; export type OpenRouterQuantization = "bf16" | "fp4" | "fp6" | "fp8" | "fp16" | "fp32" | "int4" | "int8" | "unknown"; export type OpenRouterSortStrategy = "latency" | "price" | "throughput"; export type OpenRouterSort = OpenRouterSortStrategy | { by: OpenRouterSortStrategy; partition?: "model" | "none"; }; export type OpenRouterPerformancePreference = number | { p50?: number; p75?: number; p90?: number; p99?: number; }; export type OpenRouterMaxPrice = { /** Maximum completion-token price in USD per million tokens. */ completion?: number; /** Maximum price in USD per image. */ image?: number; /** Maximum prompt-token price in USD per million tokens. */ prompt?: number; /** Maximum price in USD per request. */ request?: number; }; export type OpenRouterProviderRouting = { allowFallbacks?: boolean; dataCollection?: OpenRouterDataCollection; enforceDistillableText?: boolean; ignore?: readonly string[]; maxPrice?: OpenRouterMaxPrice; only?: readonly string[]; order?: readonly string[]; preferredMaxLatency?: OpenRouterPerformancePreference; preferredMinThroughput?: OpenRouterPerformancePreference; quantizations?: readonly OpenRouterQuantization[]; requireParameters?: boolean; sort?: OpenRouterSort; zdr?: boolean; }; export type OpenRouterServiceTier = "auto" | "default" | "flex" | "priority" | "fast"; export type OpenRouterResponseCache = { clear?: boolean; enabled: boolean; /** OpenRouter response-cache TTL in seconds (1-86400). */ ttlSeconds?: number; }; export type OpenRouterCacheControl = { type: "ephemeral"; ttl?: "5m" | "1h"; }; export type OpenRouterPromptCacheOptions = { mode: "explicit"; ttl?: string; }; export type OpenRouterReasoning = { context?: "all_turns" | "auto" | "current_turn"; effort?: "minimal" | "low" | "medium" | "high" | "max" | "xhigh"; enabled?: boolean; exclude?: boolean; maxTokens?: number; mode?: "pro"; summary?: "auto" | "concise" | "detailed"; }; export type OpenRouterTrace = Record & { generation_name?: string; parent_span_id?: string; span_name?: string; trace_id?: string; trace_name?: string; }; export type OpenRouterAudioOutput = { format: "wav" | "mp3" | "flac" | "opus" | "pcm16"; voice: string; }; export type OpenRouterAutoRouterCostTier = "low" | "medium" | "high" | "xhigh" | "max"; export type OpenRouterAutoRouterPlugin = { id: "auto-router"; /** Restrict Auto Router candidates; omitted means the full catalog. */ allowed_models?: readonly string[]; cost_tier?: OpenRouterAutoRouterCostTier; /** Legacy numeric control. When present, OpenRouter prioritizes it over cost_tier. */ cost_quality_tradeoff?: number; }; /** @deprecated OpenRouter recommends the `openrouter:web_search` server tool. */ export type OpenRouterWebSearchPlugin = { id: "web"; engine?: "native" | "exa" | "firecrawl" | "parallel" | "perplexity"; exclude_domains?: readonly string[]; include_domains?: readonly string[]; max_results?: number; search_prompt?: string; }; export type OpenRouterFusionPlugin = { id: "fusion"; analysis_models?: readonly string[]; enabled?: boolean; max_tool_calls?: number; model?: string; preset?: string; }; export type OpenRouterResponseHealingPlugin = { id: "response-healing"; }; export type OpenRouterPlugin = OpenRouterAutoRouterPlugin | OpenRouterFusionPlugin | OpenRouterResponseHealingPlugin | OpenRouterWebSearchPlugin | { id: string; [option: string]: unknown; }; export type OpenRouterWebSearchParameters = { allowed_domains?: readonly string[]; engine?: "auto" | "native" | "exa" | "firecrawl" | "parallel" | "perplexity"; excluded_domains?: readonly string[]; max_characters?: number; max_results?: number; max_total_results?: number; search_context_size?: "low" | "medium" | "high"; user_location?: { city?: string; country?: string; region?: string; timezone?: string; type: "approximate"; }; }; export type OpenRouterWebFetchParameters = { allowed_domains?: readonly string[]; blocked_domains?: readonly string[]; engine?: "auto" | "native" | "exa" | "openrouter" | "firecrawl" | "parallel"; max_content_tokens?: number; max_uses?: number; }; export type OpenRouterImageGenerationParameters = { aspect_ratio?: string; background?: string; model?: string; moderation?: string; output_compression?: number; output_format?: string; quality?: string; size?: string; }; export type OpenRouterSubagentParameters = { inherit_functions?: boolean; inherited_function_names?: readonly string[]; instructions?: string; max_completion_tokens?: number; max_tool_calls?: number; model?: string; name?: string; reasoning?: { effort?: OpenRouterReasoning["effort"]; max_tokens?: number; }; temperature?: number; tools?: readonly Exclude[]; }; export type OpenRouterAdvisorParameters = { forward_transcript?: boolean; instructions?: string; max_completion_tokens?: number; model?: string; name?: string; reasoning?: { effort?: string; max_tokens?: number; }; stream?: boolean; temperature?: number; }; export type OpenRouterFusionServerToolParameters = { analysis_models?: readonly string[]; cache_control?: OpenRouterCacheControl; max_completion_tokens?: number; max_tool_calls?: number; model?: string; reasoning?: { effort?: string; max_tokens?: number; }; temperature?: number; tools?: readonly OpenRouterServerTool[]; }; export type OpenRouterShellParameters = { engine?: "auto" | "openrouter"; environment?: { type: "container_auto"; } | { container_id: string; type: "container_reference"; }; sleep_after_seconds?: number; }; export type OpenRouterServerTool = { type: "openrouter:web_search"; parameters?: OpenRouterWebSearchParameters; } | { type: "openrouter:web_fetch"; parameters?: OpenRouterWebFetchParameters; } | { type: "openrouter:datetime"; parameters?: { timezone?: string; }; } | { type: "openrouter:image_generation"; parameters?: OpenRouterImageGenerationParameters; } | { type: "openrouter:apply_patch"; parameters?: { engine?: "auto" | "native" | "openrouter"; }; } | { type: "openrouter:subagent"; parameters: OpenRouterSubagentParameters; } | { type: "openrouter:advisor"; parameters?: OpenRouterAdvisorParameters; } | { type: "openrouter:fusion"; parameters?: OpenRouterFusionServerToolParameters; } | { type: "openrouter:shell"; parameters?: OpenRouterShellParameters; } | { type: "openrouter:experimental__search_models"; parameters?: { max_results?: number; }; }; export type OpenRouterRequestOptions = { /** Stream text and synthesized audio from an audio-output chat model. */ audioOutput?: OpenRouterAudioOutput; /** Automatic top-level prompt caching, including optional Anthropic TTL. */ cacheControl?: OpenRouterCacheControl; /** Future OpenRouter fields. Security-sensitive routing fields are rejected. */ extraBody?: Record; fallbackModels?: readonly string[]; includeReasoning?: boolean; maxToolCalls?: number; /** Native `/messages` server-tool definitions and replayable tool shapes. */ messagesTools?: readonly Record[]; plugins?: readonly OpenRouterPlugin[]; /** Stable cache identity used by compatible OpenAI-family models. */ promptCacheKey?: string; /** OpenAI explicit-cache mode and TTL. */ promptCacheOptions?: OpenRouterPromptCacheOptions; preset?: string; responseCache?: OpenRouterResponseCache; /** OpenRouter-native reasoning controls beyond the portable effort knob. */ reasoning?: OpenRouterReasoning; routerMetadata?: boolean; routing?: OpenRouterProviderRouting; serverTools?: readonly OpenRouterServerTool[]; serviceTier?: OpenRouterServiceTier; sessionId?: string; stopServerToolsWhen?: readonly Record[]; /** Metadata forwarded to configured OpenRouter Broadcast destinations. */ trace?: OpenRouterTrace; transforms?: readonly string[]; user?: string; verbosity?: "low" | "medium" | "high"; }; export type OpenRouterConfig = { /** * Local model policy. Entries are exact model IDs or namespace wildcards such * as `anthropic/*`. Requests outside the list fail before network access. */ allowedModels?: readonly string[]; /** Preset slugs deliberately approved for use with this provider. */ allowedPresets?: readonly string[]; /** * Inference-provider policy sent as OpenRouter's `provider.only`. When * `routing.only` is also set, every entry must be allowed by this policy. */ allowedProviders?: readonly string[]; apiKey?: string; /** Up to two OpenRouter marketplace categories. */ appCategories?: readonly string[]; /** Public application name used for optional OpenRouter attribution. */ appName?: string; /** Public application URL used for optional OpenRouter attribution. */ appUrl?: string; baseUrl?: string; fetch?: typeof globalThis.fetch; headers?: HeadersInit | (() => HeadersInit | Promise); /** Default OpenRouter request options, overridable per call. */ requestOptions?: OpenRouterRequestOptions; routing?: OpenRouterProviderRouting; tokenSource?: () => Promise | string; }; /** * OpenRouter provider for the shared AbsoluteJS AI contract. * * Uses the existing OpenAI-compatible streaming implementation while adding * OpenRouter attribution, typed provider routing, local model policy, provider * allowlists, cost metadata, and OpenRouter-specific error attribution. */ export declare const openrouter: (config: OpenRouterConfig) => AIProviderConfig; /** OpenRouter's stateless OpenAI-compatible Responses API provider skin. */ export declare const openrouterResponses: (config: OpenRouterConfig) => AIProviderConfig; /** OpenRouter provider using the native Anthropic Messages protocol skin. */ export declare const openrouterMessages: (config: OpenRouterConfig) => AIProviderConfig; export { createOpenRouterAuthorizationUrl, createOpenRouterClient, createOpenRouterKeyLinks, estimateOpenRouterCost, estimateOpenRouterModelCost, exchangeOpenRouterAuthCode, generateOpenRouterPKCE, openRouterModelMatchesRule, verifyOpenRouterWebhookSignature, } from "./openrouterClient"; export type { OpenRouterActivityItem, OpenRouterActivityQuery, OpenRouterAnalyticsMeta, OpenRouterAnalyticsQuery, OpenRouterAnalyticsResponse, OpenRouterAuthCodeExchangeRequest, OpenRouterAuthCodeExchangeResponse, OpenRouterAuthorizationUrlOptions, OpenRouterBatch, OpenRouterBatchEndpoint, OpenRouterBatchRequest, OpenRouterBatchResult, OpenRouterBatchStatus, OpenRouterChatRequest, OpenRouterChatResponse, OpenRouterClient, OpenRouterClientConfig, OpenRouterCostEstimate, OpenRouterCostUnits, OpenRouterCreateAuthCodeRequest, OpenRouterCreateAuthCodeResponse, OpenRouterCreateBatchRequest, OpenRouterCreateWorkspaceRequest, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterFile, OpenRouterFileList, OpenRouterHttpRequestOptions, OpenRouterImageModelEndpoint, OpenRouterImageModelEndpoints, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterImageStreamEvent, OpenRouterModel, OpenRouterModelList, OpenRouterModelQuery, OpenRouterPreset, OpenRouterPresetInferenceRequest, OpenRouterPresetResponse, OpenRouterPresetVersion, OpenRouterPresetVersionResponse, OpenRouterPricing, OpenRouterPricingKey, OpenRouterPKCE, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponsesRequest, OpenRouterSpeechRequest, OpenRouterTranscriptionRequest, OpenRouterTranscriptionResponse, OpenRouterTaskClassifications, OpenRouterVideoJob, OpenRouterVideoRequest, OpenRouterVideoWebhookEvent, OpenRouterWorkspace, OpenRouterWorkspaceBudget, OpenRouterWorkspaceBudgetInterval, OpenRouterWorkspaceMember, OpenRouterWorkspaceOptions, OpenRouterZdrEndpoint, } from "./openrouterClient";