import { FetchFunction, InferSchema, Resolvable, WebSocketConstructor } from "@ai-sdk/provider-utils"; import { APICallError, EmbeddingModelV4, Experimental_BatchV4, Experimental_DecisionModelV4, Experimental_ExtractionModelV4, Experimental_RealtimeFactoryV4, Experimental_RealtimeFactoryV4GetTokenOptions, Experimental_RealtimeFactoryV4GetTokenResult, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerConnection, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4SessionConfig, Experimental_RealtimeModelV4SessionIntent, Experimental_StreamingSpeechModelV4, Experimental_VideoModelV4, ImageModelV4, JSONValue, LanguageModelV4, ProviderV4, RerankingModelV4, SpeechModelV4, TranscriptionModelV4, TypeValidationError } from "@ai-sdk/provider"; //#region src/gateway-model-catalog.d.ts declare const gatewayModelIds: { readonly language: readonly ["alibaba/qwen-3-14b", "alibaba/qwen-3-30b", "alibaba/qwen-3-32b", "alibaba/qwen3-coder-30b-a3b", "alibaba/qwen3-coder-next", "alibaba/qwen3-max-thinking", "alibaba/qwen3-next-80b-a3b-instruct", "alibaba/qwen3-vl-instruct", "alibaba/qwen3.5-flash", "alibaba/qwen3.5-plus", "alibaba/qwen3.6-27b", "alibaba/qwen3.6-35b-a3b", "alibaba/qwen3.6-plus", "alibaba/qwen3.7-flash", "alibaba/qwen3.7-max", "alibaba/qwen3.7-plus", "alibaba/qwen3.8-2.4t-a95b", "alibaba/qwen3.8-27b", "alibaba/qwen3.8-flash", "alibaba/qwen3.8-max", "alibaba/qwen3.8-max-0902", "alibaba/qwen3.8-max-prime", "alibaba/qwen3.8-omni-flash", "alibaba/qwen4-max", "amazon/nova-2-lite", "amazon/nova-lite", "amazon/nova-micro", "amazon/nova-pro", "anthropic/claude-fable-5", "anthropic/claude-fable-5-batch", "anthropic/claude-fable-5.1", "anthropic/claude-fable-5.1-batch", "anthropic/claude-fable-5.2", "anthropic/claude-fable-5.2-batch", "anthropic/claude-fable-5.2-fast", "anthropic/claude-haiku-4.5", "anthropic/claude-haiku-4.5-batch", "anthropic/claude-haiku-5.5", "anthropic/claude-haiku-5.5-batch", "anthropic/claude-opus-4.5", "anthropic/claude-opus-4.5-batch", "anthropic/claude-opus-4.6", "anthropic/claude-opus-4.6-batch", "anthropic/claude-opus-4.7", "anthropic/claude-opus-4.7-batch", "anthropic/claude-opus-4.8", "anthropic/claude-opus-4.8-batch", "anthropic/claude-opus-4.8-fast", "anthropic/claude-opus-5", "anthropic/claude-opus-5-batch", "anthropic/claude-opus-5-fast", "anthropic/claude-opus-5.5", "anthropic/claude-opus-5.5-batch", "anthropic/claude-opus-5.5-fast", "anthropic/claude-sonnet-4.5", "anthropic/claude-sonnet-4.5-batch", "anthropic/claude-sonnet-4.6", "anthropic/claude-sonnet-4.6-batch", "anthropic/claude-sonnet-5", "anthropic/claude-sonnet-5-batch", "anthropic/claude-sonnet-5.5", "anthropic/claude-sonnet-5.5-batch", "bytedance/seed-2.1-turbo", "callstack/apex", "cohere/command-a", "deepseek/deepseek-r1", "deepseek/deepseek-v3.1", "deepseek/deepseek-v3.2", "deepseek/deepseek-v3.2-thinking", "deepseek/deepseek-v4-flash", "deepseek/deepseek-v4-flash-0731", "deepseek/deepseek-v4-flash-vision-exp", "deepseek/deepseek-v4-pro", "deepseek/deepseek-v4-pro-0813", "deepseek/deepseek-v4.1-flash", "deepseek/deepseek-v4.1-flash-1017", "deepseek/deepseek-v4.1-flash-1017-fast", "deepseek/deepseek-v4.1-flash-1017-ultrafast", "deepseek/deepseek-v4.1-flash-fast", "elorian/glimpse", "fireworks/ember-1", "google/gemini-2.5-flash", "google/gemini-2.5-flash-batch", "google/gemini-2.5-flash-image", "google/gemini-2.5-flash-lite", "google/gemini-2.5-flash-lite-batch", "google/gemini-2.5-pro", "google/gemini-2.5-pro-batch", "google/gemini-3-flash", "google/gemini-3-flash-batch", "google/gemini-3-pro-image", "google/gemini-3.1-flash-image", "google/gemini-3.1-flash-lite", "google/gemini-3.1-flash-lite-batch", "google/gemini-3.1-flash-lite-image", "google/gemini-3.1-pro-preview", "google/gemini-3.1-pro-preview-batch", "google/gemini-3.5-flash", "google/gemini-3.5-flash-lite", "google/gemini-3.5-flash-lite-batch", "google/gemini-3.6-flash", "google/gemini-3.6-flash-batch", "google/gemini-3.7-flash", "google/gemini-3.8-flash", "google/gemini-4-argon", "google/gemini-4-carbon", "google/gemini-4-hydrogen", "google/gemini-4-neon", "google/gemini-nano-banana-2.1", "google/gemini-omni-1.2-flash", "google/gemini-omni-flash-preview", "google/gemma-4-26b-a4b-it", "google/gemma-4-31b-it", "humansand/ampersand-v0.1", "inception/mercury-3", "inclusionai/ling-3.0-flash", "inclusionai/ling-3.0-flash-fin", "inclusionai/ling-3.0-flash-sante", "inclusionai/ling-3.0-flash-vl", "inclusionai/ling-3.1-flash", "inclusionai/ling-3.1-flash-1019", "inference-net/schematron-v2-small", "inference-net/schematron-v2-turbo", "interfaze/interfaze-beta", "liquid/lfm2.5-24b-a2b", "meituan/longcat-2.5", "meta/llama-3.1-70b", "meta/llama-3.1-8b", "meta/llama-3.3-70b", "meta/llama-4-maverick", "meta/llama-4-scout", "meta/muse-ember", "meta/muse-glimmer-30b", "meta/muse-spark-1.1", "meta/muse-spark-1.2", "meta/muse-spark-1.2-contributor", "meta/muse-spark-1.3", "meta/muse-spark-1.3-contributor", "meta/muse-spark-open", "meta/muse-wonder-1.0", "minimax/minimax-m2.1", "minimax/minimax-m2.5", "minimax/minimax-m2.7", "minimax/minimax-m3", "minimax/minimax-m3.1-flash", "mistral/codestral", "mistral/ministral-14b", "mistral/ministral-3b", "mistral/ministral-8b", "mistral/mistral-large-3", "mistral/mistral-large-4", "mistral/mistral-medium-3.5", "mistral/mistral-nemo", "mistral/mistral-small", "mixedbread/toast-1", "moonshotai/kimi-k2", "moonshotai/kimi-k2.5", "moonshotai/kimi-k2.6", "moonshotai/kimi-k2.7-code", "moonshotai/kimi-k2.7-code-highspeed", "moonshotai/kimi-k3", "moonshotai/kimi-k3-fast", "moonshotai/kimi-k3.1-pro", "moonshotai/kimi-k3.1-pro-highspeed", "morph/morph-v3-fast", "morph/morph-v3-large", "nvidia/nemotron-3-super-120b-a12b", "nvidia/nemotron-3-ultra-550b-a55b", "nvidia/nemotron-3.5-lightning", "nvidia/nemotron-3.5-lightning-free", "nvidia/nemotron-3.5-super-vl", "nvidia/nemotron-nano-12b-v2-vl", "nvidia/nemotron-nano-9b-v2", "openai/gpt-4.1", "openai/gpt-4.1-batch", "openai/gpt-4.1-fast", "openai/gpt-4.1-mini", "openai/gpt-4.1-mini-batch", "openai/gpt-4.1-mini-fast", "openai/gpt-4.1-nano", "openai/gpt-4o", "openai/gpt-4o-batch", "openai/gpt-4o-fast", "openai/gpt-4o-mini", "openai/gpt-4o-mini-batch", "openai/gpt-4o-mini-fast", "openai/gpt-5", "openai/gpt-5-batch", "openai/gpt-5-codex", "openai/gpt-5-fast", "openai/gpt-5-mini", "openai/gpt-5-mini-batch", "openai/gpt-5-mini-fast", "openai/gpt-5-nano", "openai/gpt-5-nano-batch", "openai/gpt-5-pro", "openai/gpt-5-pro-batch", "openai/gpt-5.1-codex", "openai/gpt-5.1-codex-max", "openai/gpt-5.1-codex-mini", "openai/gpt-5.1-thinking", "openai/gpt-5.1-thinking-fast", "openai/gpt-5.2", "openai/gpt-5.2-batch", "openai/gpt-5.2-codex", "openai/gpt-5.2-fast", "openai/gpt-5.2-pro", "openai/gpt-5.3-codex", "openai/gpt-5.3-codex-fast", "openai/gpt-5.4", "openai/gpt-5.4-batch", "openai/gpt-5.4-fast", "openai/gpt-5.4-mini", "openai/gpt-5.4-mini-batch", "openai/gpt-5.4-mini-fast", "openai/gpt-5.4-nano", "openai/gpt-5.4-nano-batch", "openai/gpt-5.4-pro", "openai/gpt-5.5", "openai/gpt-5.5-batch", "openai/gpt-5.5-fast", "openai/gpt-5.5-pro", "openai/gpt-5.5-pro-batch", "openai/gpt-5.6-luna", "openai/gpt-5.6-luna-batch", "openai/gpt-5.6-luna-fast", "openai/gpt-5.6-sol", "openai/gpt-5.6-sol-batch", "openai/gpt-5.6-sol-fast", "openai/gpt-5.6-terra", "openai/gpt-5.6-terra-batch", "openai/gpt-5.6-terra-fast", "openai/gpt-6-astra", "openai/gpt-6-astra-batch", "openai/gpt-6-astra-fast", "openai/gpt-6-luna", "openai/gpt-6-luna-batch", "openai/gpt-6-luna-fast", "openai/gpt-6-sol", "openai/gpt-6-sol-batch", "openai/gpt-6-sol-fast", "openai/gpt-6.1-sol", "openai/gpt-6.1-sol-batch", "openai/gpt-6.1-sol-fast", "openai/gpt-6.1-terra", "openai/gpt-6.1-terra-fast", "openai/gpt-6.2-astra", "openai/gpt-6.2-astra-fast", "openai/gpt-6.2-sol", "openai/gpt-6.2-sol-fast", "openai/gpt-oss-120b", "openai/gpt-oss-20b", "openai/gpt-oss-safeguard-120b", "openai/gpt-oss-safeguard-20b", "openai/o1", "openai/o3", "openai/o3-fast", "openai/o3-mini", "openai/o3-pro", "openai/o4-mini", "paperinstruments/ultramarine-1-flash", "particle/particle-1", "perplexity/sonar", "quiverai/arrow-2", "quiverai/arrow-2-telos", "recursive/flint-v1.0", "reflection/beam", "reflection/beam-free", "sakana/fugu-max", "sakana/fugu-ultra", "sakana/fugu-ultra-v2", "sakana/namazu", "scaledown/scaledown-extract-1", "scaledown/scaledown-summarize-1", "spacexai/grok-4.20-multi-agent", "spacexai/grok-4.20-multi-agent-batch", "spacexai/grok-4.20-multi-agent-beta", "spacexai/grok-4.20-non-reasoning", "spacexai/grok-4.20-non-reasoning-batch", "spacexai/grok-4.20-non-reasoning-beta", "spacexai/grok-4.20-reasoning", "spacexai/grok-4.20-reasoning-batch", "spacexai/grok-4.20-reasoning-beta", "spacexai/grok-4.3", "spacexai/grok-4.3-batch", "spacexai/grok-4.5", "spacexai/grok-4.6", "spacexai/grok-4.7", "stealth/glyph-cluster", "stepfun/step-3.7-flash", "stepfun/step-5-preview", "tencent/hy-mt2-lite", "tencent/hy-mt2-plus", "tencent/hy-mt2-pro", "tencent/hy3", "tencent/hy4", "tencent/hy4-flash", "tencent/hy4-preview", "thinkingmachines/inkling", "thinkingmachines/inkling-2-small", "thinkingmachines/inkling-small", "xiaomi/mimo-v2.6-flash", "xiaomi/mimo-v2.6-pro", "xiaomi/mimo-v2.6-pro-ultraspeed", "zai/glm-4.5", "zai/glm-4.5-air", "zai/glm-4.5v", "zai/glm-4.6", "zai/glm-4.7", "zai/glm-4.7-flash", "zai/glm-4.7-flashx", "zai/glm-5", "zai/glm-5-turbo", "zai/glm-5.1", "zai/glm-5.2", "zai/glm-5.2-fast", "zai/glm-5.3", "zai/glm-5.3-fast", "zai/glm-5.3-flash", "zai/glm-5.3-flashx", "zai/glm-5.3-flashx-legal", "zai/glm-5v-turbo"]; readonly embedding: readonly ["alibaba/qwen3-embedding-0.6b", "alibaba/qwen3-embedding-4b", "alibaba/qwen3-embedding-8b", "amazon/titan-embed-text-v2", "cohere/embed-v4.0", "cohere/embed-v5.0-fast", "cohere/embed-v5.0-pro", "google/gemini-embedding-001", "google/gemini-embedding-2", "google/text-embedding-005", "google/text-multilingual-embedding-002", "mistral/codestral-embed", "mistral/mistral-embed", "openai/text-embedding-3-large", "openai/text-embedding-3-small", "openai/text-embedding-ada-002", "perplexity/pplx-embed-v1-0.6b", "perplexity/pplx-embed-v1-4b", "voyage/voyage-3-large", "voyage/voyage-3.5", "voyage/voyage-3.5-lite", "voyage/voyage-4", "voyage/voyage-4-large", "voyage/voyage-4-lite", "voyage/voyage-code-2", "voyage/voyage-code-3", "voyage/voyage-finance-2", "voyage/voyage-law-2"]; readonly decision: readonly ["baseten/elephant-1", "baseten/joey-1", "baseten/mammoth-1", "convaiinnovations/laya", "google/gemini-decision-1", "heygen/heygen-decision-1", "heygen/heygen-decision-1-turbo", "liquid/d1-ultra", "liquid/d1.2", "liquid/d1.2-ultra", "microsoft/decision-1.1", "microsoft/microsoft-decision-1", "modaic/mo", "nace-ai/drex-max-finance", "nace-ai/drex-max-v1.1", "nace-ai/drex-v2.0", "openai/gpt-6-luna-decisions", "parallel/parallel-decisions-fast", "perplexity/pplx-decider-flash-v1.2", "perplexity/pplx-decider-flash-v1.3", "perplexity/pplx-decider-v1.2", "perplexity/pplx-decider-v1.3", "scaledown/scaledown-classify-1", "typesafe-ai/jev", "typesafe-ai/jev-1.13.0", "typesafe-ai/jev-1.14.0"]; readonly extraction: readonly ["scaledown/extract-1"]; readonly image: readonly ["bfl/flux-2-flex", "bfl/flux-2-klein-4b", "bfl/flux-2-klein-9b", "bfl/flux-2-max", "bfl/flux-2-pro", "bfl/flux-3-image", "bfl/flux-3-image-klein", "bfl/flux-kontext-max", "bfl/flux-kontext-pro", "bfl/flux-pro-1.0-fill", "bfl/flux-pro-1.1", "bfl/flux-pro-1.1-ultra", "bytedance/seedream-4.0", "bytedance/seedream-4.5", "bytedance/seedream-5.0-lite", "bytedance/seedream-5.0-pro", "bytedance/seedream-5.5", "meta/muse-image-1.0", "microsoft/mai-image-2.6", "microsoft/mai-image-2.6-flash", "microsoft/mai-image-2.7", "microsoft/mai-image-2.7-flash", "minimax/minimax-h3-image", "minimax/minimax-h3-image-highspeed", "openai/gpt-image-1-mini", "openai/gpt-image-1.5", "openai/gpt-image-2", "openai/gpt-image-2.5-flare", "openai/gpt-image-2.5-sunburst", "openai/gpt-image-2.6-flare", "openai/gpt-image-2.6-sunburst", "recraft/recraft-v2", "recraft/recraft-v3", "recraft/recraft-v4", "recraft/recraft-v4-pro", "recraft/recraft-v4.1", "recraft/recraft-v4.1-flash", "recraft/recraft-v4.1-pro", "recraft/recraft-v4.1-utility", "recraft/recraft-v4.1-utility-pro", "spacexai/grok-imagine-image", "spacexai/grok-imagine-image-2.0", "topaz/wonder-3.5"]; readonly video: readonly ["alibaba/wan-v2.5-t2v-preview", "alibaba/wan-v2.6-i2v", "alibaba/wan-v2.6-i2v-flash", "alibaba/wan-v2.6-r2v", "alibaba/wan-v2.6-r2v-flash", "alibaba/wan-v2.6-t2v", "alibaba/wan-v2.7-r2v", "alibaba/wan-v2.7-t2v", "alibaba/wan-v3.0-video", "alibaba/wan-v3.0-video-prime", "bfl/flux-3-video", "bytedance/seedance-2.0", "bytedance/seedance-2.0-fast", "bytedance/seedance-2.0-mini", "bytedance/seedance-2.5", "bytedance/seedance-2.5-flash", "bytedance/seedance-v1.0-pro", "bytedance/seedance-v1.0-pro-fast", "google/veo-3.1-fast-generate-001", "google/veo-3.1-generate-001", "google/veo-3.1-lite-generate-001", "heygen/heygen-video-1", "klingai/kling-v2.5-turbo-i2v", "klingai/kling-v2.5-turbo-t2v", "klingai/kling-v2.6-i2v", "klingai/kling-v2.6-motion-control", "klingai/kling-v2.6-t2v", "klingai/kling-v3.0-i2v", "klingai/kling-v3.0-motion-control", "klingai/kling-v3.0-t2v", "minimax/minimax-h3", "minimax/minimax-h3-max", "spacexai/grok-imagine-video", "spacexai/grok-imagine-video-1.5", "spacexai/grok-imagine-video-1.5-lite", "topaz/proteus", "topaz/starlight-precise-2.6"]; readonly realtime: readonly ["elevenlabs/eleven-realtime-v1-max", "elevenlabs/eleven-realtime-v1-mini", "google/gemini-3.8-live", "google/gemini-3.8-live-extended-thinking", "openai/gpt-live-1", "openai/gpt-live-1.1", "openai/gpt-realtime-1.5", "openai/gpt-realtime-2", "openai/gpt-realtime-2.1", "openai/gpt-realtime-mini", "spacexai/grok-voice-3.0"]; readonly reranking: readonly ["cohere/rerank-v3.5", "cohere/rerank-v4-fast", "cohere/rerank-v4-pro", "cohere/rerank-v5-fast", "cohere/rerank-v5-pro", "voyage/rerank-2.5", "voyage/rerank-2.5-lite", "voyage/rerank-3", "voyage/rerank-3-lite"]; readonly speech: readonly ["elevenlabs/eleven-flash-v2", "elevenlabs/eleven-flash-v2.5", "elevenlabs/eleven-multilingual-v2", "elevenlabs/eleven-v3", "elevenlabs/eleven-v3-conversational", "elevenlabs/eleven-v4", "elevenlabs/eleven-v4-turbo", "elevenlabs/music-v2", "elevenlabs/music-v2.5", "elevenlabs/sound-effects-v2", "fish-audio/drama-3", "fish-audio/s1", "fish-audio/s2-pro", "fish-audio/s2.1-pro", "google/gemini-3.8-flash-lite-tts", "google/gemini-3.8-flash-tts", "microsoft/mai-voice-2", "microsoft/mai-voice-2-flash", "microsoft/mai-voice-2.1", "microsoft/mai-voice-2.1-flash", "mistral/voxtral-mini-tts-3", "openai/tts-1", "openai/tts-1-hd", "spacexai/grok-tts"]; readonly transcription: readonly ["elevenlabs/scribe-v2", "elevenlabs/scribe-v2-realtime", "fish-audio/transcribe-1", "google/gemini-3.5-transcribe", "google/gemini-3.5-transcribe-live", "microsoft/mai-transcribe-2", "microsoft/mai-transcribe-2-streaming", "mistral/voxtral-mini-transcribe-3", "mistral/voxtral-small-transcribe-3", "openai/gpt-4o-mini-transcribe", "openai/gpt-4o-transcribe", "openai/gpt-live-transcribe", "openai/gpt-realtime-whisper", "openai/gpt-transcribe", "openai/whisper-1", "spacexai/grok-stt"]; }; /** Known model IDs, derived from the catalog declarations. */ type GatewayModelIds = { [Type in keyof typeof gatewayModelIds]: (typeof gatewayModelIds)[Type][number]; }; //#endregion //#region src/gateway-decision-model-settings.d.ts type GatewayDecisionModelId = GatewayModelIds['decision'] | (string & {}); //#endregion //#region src/gateway-provider-options.d.ts /** * A condition on the primary model's answers. `QUESTION_ID` narrows * `question` to your question IDs. Without `question`, `confidenceBelow` * checks every Choice and Score question and `probabilityBetween` every * Boolean question. Groups nest at most five levels deep, which the SDK * checks at runtime. */ type DecisionFallbackCondition = ExclusiveCondition<{ question?: QUESTION_ID; confidenceBelow: number; }> | ExclusiveCondition<{ question?: QUESTION_ID; probabilityBetween: [number, number]; }> | ExclusiveCondition<{ any: DecisionFallbackConditionList; }> | ExclusiveCondition<{ all: DecisionFallbackConditionList; }> | ExclusiveCondition<{ atLeast: { count: number; conditions: DecisionFallbackConditionList; }; }>; type GatewayModelFallback = string | { model: string; when: DecisionFallbackCondition; }; type GatewayProviderOptions = { /** * Service-owned options may be added by the Gateway without requiring an SDK * release. The Gateway service validates and applies the runtime schema. */ [key: string]: unknown; /** Request-scoped BYOK credentials to use instead of cached credentials. */ byok?: Record>>; /** Enables automatic caching behavior when supported by the Gateway. */ caching?: 'auto'; /** * Experimental, image models only: decode large base64 images while reading * the response to reduce peak memory. Extracted images are returned as bytes; * if a result mixes extracted and small images, all are returned as bytes. * Defaults to false. Image models remove this client option from requests. */ experimental_streamingImageDecoding?: boolean; /** Filter to providers that do not train on prompt data. */ disallowPromptTraining?: boolean; /** * Route only to providers headquartered in these countries (ISO 3166-1 * alpha-2 codes, e.g. `['US', 'DE']`), or prefix every code with `!` to * exclude countries instead (e.g. `['!US']`). A list can't mix the two. */ headquarters?: string[]; /** * Restrict routing to provider models that satisfy every given entry. * * Entries are capability tags (`'implicit-caching'`, `'reasoning'`, * `'tool-use'`, `'vision'` (image input), `'structured-output'` * (schema-constrained output)) or weight-format conditions: * `'quantization:fp8'` requires the serving provider to report that weight * format, `'!quantization:fp8'` excludes it (providers with no recorded * format still pass an exclusion). Format values are an open space but must * match `[a-zA-Z0-9._-]{1,32}` and compare case-insensitively. Unknown * capability names are rejected by the Gateway with a 400. */ has?: Array<'implicit-caching' | 'reasoning' | 'structured-output' | 'tool-use' | 'vision' | `quantization:${string}` | `!quantization:${string}`>; /** * Idempotency key for `experimental_startBatch`: retries with the same * key replay the original batch instead of creating a duplicate. */ idempotencyKey?: string; /** * Fallback models to try in order. On decision requests, the first entry * can be a conditional `{ model, when }` fallback that reruns the decision * when `when` matches the primary answers. Other request types reject a * conditional entry. Pass your question IDs as `QUESTION_ID` to check the * `question` names in `when`. */ models?: GatewayModelFallbackList; /** Array of provider slugs that are the only ones allowed to be used. */ only?: string[]; /** Array of provider slugs specifying the provider attempt order. */ order?: string[]; /** Per-provider timeouts for BYOK credentials in milliseconds. */ providerTimeouts?: { byok?: Record; }; /** Entity identifier against which quota is tracked. */ quotaEntityId?: string; /** Unified service tier intent. */ serviceTier?: 'flex' | 'priority'; /** Sort providers by a performance or cost metric before routing. */ sort?: 'cost' | 'tps' | 'ttft'; /** User-specified tags for reporting and filtering usage. */ tags?: string[]; /** End-user identifier for spend tracking and attribution. */ user?: string; /** Filter to providers with zero data retention agreements. */ zeroDataRetention?: boolean; }; type DecisionFallbackConditionList = [DecisionFallbackCondition, ...DecisionFallbackCondition[]]; type ConditionKey = 'question' | 'confidenceBelow' | 'probabilityBetween' | 'any' | 'all' | 'atLeast'; type ExclusiveCondition = CONDITION & { [KEY in Exclude]?: never; }; type ConditionalGatewayModelFallback = Exclude, string>; type GatewayModelFallbackList = string[] | [ConditionalGatewayModelFallback, ...string[]]; //#endregion //#region src/gateway-embedding-model-settings.d.ts type GatewayEmbeddingModelId = GatewayModelIds['embedding'] | (string & {}); //#endregion //#region src/gateway-extraction-model-settings.d.ts type GatewayExtractionModelId = GatewayModelIds['extraction'] | (string & {}); //#endregion //#region src/gateway-image-model-settings.d.ts type GatewayImageModelId = GatewayModelIds['image'] | (string & {}); //#endregion //#region src/gateway-language-model-settings.d.ts type GatewayModelId = GatewayModelIds['language'] | (string & {}); //#endregion //#region src/gateway-realtime-auth.d.ts /** * Shared WebSocket subprotocol contract for AI Gateway realtime, streaming * transcription, and streaming speech auth. * * The browser `WebSocket` API cannot set request headers, so the Gateway auth * (bearer) token is carried through the `Sec-WebSocket-Protocol` handshake * instead of an `Authorization` header — the same workaround OpenAI uses for * `openai-insecure-api-key.`. * * This module is the single source of truth for that contract so the client and * the Gateway server can't drift: the client encodes values with * `getGatewayRealtimeProtocols` / `getGatewayTranscriptionProtocols` / * `getGatewaySpeechProtocols`, and the * Gateway server decodes them with `getGatewayRealtimeAuthToken` / * `getGatewayRealtimeTeamIdOrSlug`. * * WebSocket subprotocol values must fit the RFC token grammar. The auth token is * sent as-is, so callers must use tokens that are valid subprotocol tokens; the * optional team scope is base64url-encoded by this module. Keep the complete * `Sec-WebSocket-Protocol` header compact (target under an 8 KiB safe header * budget) because intermediaries may reject large upgrade headers. */ /** * Marker subprotocol offered on every realtime handshake so the Gateway can * echo a negotiated subprotocol on the 101 response (some clients require the * server to select one of the offered subprotocols). */ export declare const GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realtime.v1"; /** * Marker subprotocol for streaming transcription handshakes (same negotiation * purpose as `GATEWAY_REALTIME_SUBPROTOCOL`). */ export declare const GATEWAY_TRANSCRIPTION_SUBPROTOCOL = "ai-gateway-transcription.v1"; /** * Marker subprotocol for streaming speech handshakes (same negotiation * purpose as `GATEWAY_REALTIME_SUBPROTOCOL`). */ export declare const GATEWAY_SPEECH_SUBPROTOCOL = "ai-gateway-speech.v1"; /** Subprotocol prefix that carries the Gateway auth (bearer) token. */ export declare const GATEWAY_AUTH_SUBPROTOCOL_PREFIX = "ai-gateway-auth."; /** Subprotocol prefix that carries optional Vercel team scoping. */ export declare const GATEWAY_TEAM_SUBPROTOCOL_PREFIX = "ai-gateway-team."; /** * Client-side: build the WebSocket subprotocols that carry `token` to the * Gateway. Pass the result as the second argument to `new WebSocket(url, ...)`. */ export declare function getGatewayRealtimeProtocols(token: string, options?: { teamIdOrSlug?: string; }): string[]; /** * Client-side: `getGatewayRealtimeProtocols`, but with the streaming * transcription marker subprotocol. */ export declare function getGatewayTranscriptionProtocols(token: string, options?: { teamIdOrSlug?: string; }): string[]; /** * Client-side: `getGatewayRealtimeProtocols`, but with the streaming speech * marker subprotocol. */ export declare function getGatewaySpeechProtocols(token: string, options?: { teamIdOrSlug?: string; }): string[]; /** * Server-side: extract the Gateway auth (bearer) token from a * `Sec-WebSocket-Protocol` header value, or `undefined` when it is absent or * empty. The Gateway upgrade handler turns this into an * `Authorization: Bearer ` before its normal auth path. * * Accepts the raw header value (subprotocols are comma-separated and may carry * surrounding whitespace). */ export declare function getGatewayRealtimeAuthToken(secWebSocketProtocol: string | null | undefined): string | undefined; /** * Server-side: extract the optional Vercel team ID or slug from the * `Sec-WebSocket-Protocol` header value. Team scoping is base64url-encoded so * arbitrary team slugs stay within the WebSocket subprotocol token grammar. */ export declare function getGatewayRealtimeTeamIdOrSlug(secWebSocketProtocol: string | null | undefined): string | undefined; //#endregion //#region src/gateway-realtime-model-settings.d.ts type GatewayRealtimeModelId = GatewayModelIds['realtime'] | (string & {}); /** * Realtime model IDs that use the continuous Live API by default. Other IDs use * the realtime API unless `{ api: 'live' }` is passed. */ declare const gatewayLiveModelIds: readonly ["openai/gpt-live-1", "openai/gpt-live-1.1"]; type GatewayKnownLiveModelId = (typeof gatewayLiveModelIds)[number]; type GatewayRealtimeOptions = { /** Selects the Gateway API for the model ID, including for new Live models. */ api?: 'live' | 'realtime'; }; //#endregion //#region src/gateway-reranking-model-settings.d.ts type GatewayRerankingModelId = GatewayModelIds['reranking'] | (string & {}); //#endregion //#region src/gateway-speech-model-settings.d.ts type GatewaySpeechModelId = GatewayModelIds['speech'] | (string & {}); //#endregion //#region src/gateway-transcription-model-settings.d.ts type GatewayTranscriptionModelId = GatewayModelIds['transcription'] | (string & {}); //#endregion //#region src/gateway-video-model-settings.d.ts type GatewayVideoModelId = GatewayModelIds['video'] | (string & {}); //#endregion //#region src/gateway-model-entry.d.ts declare const KNOWN_MODEL_TYPES: readonly ["embedding", "decision", "evaluation", "extraction", "image", "language", "realtime", "reranking", "speech", "transcription", "video"]; type KnownModelType = (typeof KNOWN_MODEL_TYPES)[number]; interface GatewayLanguageModelEntry { /** * The model id used by the remote provider in model settings and for specifying the * intended model for text generation. */ id: string; /** * The display name of the model for presentation in user-facing contexts. */ name: string; /** * Optional description of the model. */ description?: string | null; /** * Optional pricing information for the model. */ pricing?: { /** * Cost per input token in USD. */ input: string; /** * Cost per output token in USD. */ output: string; /** * Cost per cached input token in USD. * Only present for providers/models that support prompt caching. */ cachedInputTokens?: string; /** * Cost per input token to create/write cache entries in USD. * Only present for providers/models that support prompt caching. */ cacheCreationInputTokens?: string; } | null; /** * Additional AI SDK language model specifications for the model. */ specification: GatewayLanguageModelSpecification; /** * Optional field to differentiate between model types. */ modelType?: KnownModelType | null; } type GatewayLanguageModelSpecification = Pick; //#endregion //#region src/gateway-fetch-metadata.d.ts interface GatewayFetchMetadataResponse { models: GatewayLanguageModelEntry[]; } interface GatewayCreditsResponse { /** The remaining gateway credit balance available for API usage */ balance: string; /** The total amount of gateway credits that have been consumed */ totalUsed: string; } //#endregion //#region src/gateway-spend-report.d.ts interface GatewaySpendReportParams { /** Start date in YYYY-MM-DD format (inclusive) */ startDate: string; /** End date in YYYY-MM-DD format (inclusive) */ endDate: string; /** Primary aggregation dimension. Defaults to 'day'. */ groupBy?: 'day' | 'user' | 'model' | 'tag' | 'provider' | 'credential_type'; /** Time granularity when groupBy is 'day'. */ datePart?: 'day' | 'hour'; /** Filter to a specific user's spend. */ userId?: string; /** Filter to a specific model (e.g. 'anthropic/claude-sonnet-4.5'). */ model?: string; /** Filter to a specific provider (e.g. 'anthropic'). */ provider?: string; /** Filter to BYOK or system credentials. */ credentialType?: 'byok' | 'system'; /** Filter to requests with these tags. */ tags?: string[]; } interface GatewaySpendReportRow { /** Date string (present when groupBy is 'day') */ day?: string; /** Hour timestamp (present when groupBy is 'day' and datePart is 'hour') */ hour?: string; /** User identifier (present when groupBy is 'user') */ user?: string; /** Model identifier (present when groupBy is 'model') */ model?: string; /** Tag value (present when groupBy is 'tag') */ tag?: string; /** Provider name (present when groupBy is 'provider') */ provider?: string; /** Credential type (present when groupBy is 'credential_type') */ credentialType?: 'byok' | 'system'; /** Total cost in USD */ totalCost: number; /** Market cost in USD */ marketCost?: number; /** Number of input tokens */ inputTokens?: number; /** Number of output tokens */ outputTokens?: number; /** Number of cached input tokens */ cachedInputTokens?: number; /** Number of cache creation input tokens */ cacheCreationInputTokens?: number; /** Number of reasoning tokens */ reasoningTokens?: number; /** Number of requests */ requestCount?: number; } interface GatewaySpendReportResponse { results: GatewaySpendReportRow[]; } //#endregion //#region src/gateway-generation-info.d.ts interface GatewayGenerationInfoParams { /** The generation ID to look up (format: gen_) */ id: string; } interface GatewayGenerationInfo { /** The generation ID */ id: string; /** Total cost in USD */ totalCost: number; /** Market cost in USD, excluding surcharges. Omitted when unavailable. */ marketCost?: number; /** Total surcharges applied in USD. Omitted when unavailable. */ surchargeCost?: number; /** Total amount debited in USD. Omitted when unavailable. */ gatewayCost?: number; /** Upstream inference cost in USD (BYOK only) */ upstreamInferenceCost: number; /** Usage cost in USD (same as totalCost) */ usage: number; /** ISO 8601 timestamp when the generation was created */ createdAt: string; /** Model identifier */ model: string; /** Whether BYOK credentials were used */ isByok: boolean; /** Provider that served this generation */ providerName: string; /** Whether streaming was used */ streamed: boolean; /** Finish reason (e.g. 'stop') */ finishReason: string; /** Time to first token in milliseconds */ latency: number; /** Total generation time in milliseconds */ generationTime: number; /** Number of prompt tokens */ promptTokens: number; /** Number of completion tokens */ completionTokens: number; /** Reasoning tokens used */ reasoningTokens: number; /** Cached tokens used */ cachedTokens: number; /** Cache creation input tokens */ cacheCreationTokens: number; /** Billable web search calls */ billableWebSearchCalls: number; } //#endregion //#region src/gateway-realtime-model-live.d.ts type GatewayRealtimeModelLiveConfig = { provider: string; baseURL: string; teamIdOrSlug?: string; getHeaders: () => Promise>; /** Mints a Live-bound client secret (`vcst_`) server-side. */ createClientSecret: (params: { modelId: string; expiresAfterSeconds?: number; routeKind: 'live'; }) => PromiseLike<{ token: string; expiresAt?: number; }>; }; /** * Live model backed by the AI Gateway. * * Live is a continuous conversation API: one `session-start` opens the * session, PCM audio streams in both directions, and `session-close` ends it * with final usage. The client speaks the Gateway's normalized Live protocol * on `/v4/ai/live-model`, and the Gateway runs the provider mapping * server-side, so server events arrive already normalized. */ declare class GatewayRealtimeModelLive implements Experimental_RealtimeModelV4 { readonly specificationVersion: "v4"; readonly capabilities: { readonly conversation: "continuous"; readonly transports: readonly ["websocket"]; readonly connections: readonly ["client-secret-websocket", "server-websocket"]; readonly startup: "session-start"; readonly finalization: "session-close"; }; readonly provider: string; readonly modelId: string; private readonly config; constructor(modelId: string, config: GatewayRealtimeModelLiveConfig); /** * Mints a short-lived client secret bound to this Live model. The browser * opens the Live WebSocket with it through the `ai-gateway-auth.` * subprotocol; the session configuration is sent later in `session-start`. */ doCreateClientSecret(options?: Experimental_RealtimeModelV4ClientSecretOptions): Promise; getWebSocketConfig(options: { token: string; url: string; }): { url: string; protocols?: string[]; }; getServerWebSocketConfig(options?: { intent?: Experimental_RealtimeModelV4SessionIntent; }): Promise; parseServerEvent(raw: unknown): Experimental_RealtimeModelV4ServerEvent; serializeClientEvent(event: Experimental_RealtimeModelV4ClientEvent, options?: { intent?: Experimental_RealtimeModelV4SessionIntent; }): unknown; buildSessionConfig(config: Experimental_RealtimeModelV4SessionConfig, options?: { intent?: Experimental_RealtimeModelV4SessionIntent; }): Experimental_RealtimeModelV4SessionConfig; private assertConversationIntent; } //#endregion //#region src/gateway-realtime-model.d.ts type GatewayRealtimeModelConfig = { provider: string; baseURL: string; teamIdOrSlug?: string; getHeaders: () => Promise>; /** * Mints a short-lived client secret (`vcst_`) for this model via the * Gateway's `/v1/realtime/client-secrets` endpoint. Implemented by the * provider because minting requires the long-lived Gateway credential * (API key / OIDC) and must run server-side. */ createClientSecret: (params: { modelId: string; expiresAfterSeconds?: number; }) => PromiseLike<{ token: string; expiresAt?: number; }>; }; /** * Realtime model backed by the AI Gateway. * * The Gateway normalizes realtime exactly like it normalizes every other * modality: the client speaks the normalized AI SDK realtime protocol and the * Gateway translates to and from the upstream provider server-side. This model * is therefore a thin identity codec over that normalized protocol — only the * connection and authentication are Gateway-specific. */ declare class GatewayRealtimeModel implements Experimental_RealtimeModelV4 { readonly specificationVersion: "v4"; readonly capabilities: { readonly conversation: "turn-based"; readonly transports: readonly ["websocket"]; readonly connections: readonly ["client-secret-websocket", "server-websocket"]; }; readonly provider: string; readonly modelId: string; private readonly config; constructor(modelId: string, config: GatewayRealtimeModelConfig); /** * Mints a single-use, short-lived client secret (`vcst_`) the browser uses to * open the realtime WebSocket without ever holding the long-lived Gateway * credential. The customer's server calls this (via * `gateway.experimental_realtime.getToken`) and hands the returned token to * the browser, which connects with it through the `ai-gateway-auth.` * subprotocol. `expiresAfterSeconds` is forwarded to the mint endpoint; * `sessionConfig` is intentionally unused here — it is applied later via the * normalized `session-update` event. */ doCreateClientSecret(options?: Experimental_RealtimeModelV4ClientSecretOptions): Promise; getWebSocketConfig(options: { token: string; url: string; }): { url: string; protocols?: string[]; }; getServerWebSocketConfig(options?: { intent?: Experimental_RealtimeModelV4SessionIntent; }): Promise; private assertConversationIntent; parseServerEvent(raw: unknown): Experimental_RealtimeModelV4ServerEvent; serializeClientEvent(event: Experimental_RealtimeModelV4ClientEvent, options?: { intent?: Experimental_RealtimeModelV4SessionIntent; }): unknown; buildSessionConfig(config: Experimental_RealtimeModelV4SessionConfig, options?: { intent?: Experimental_RealtimeModelV4SessionIntent; }): unknown; } //#endregion //#region src/tool/browserbase-fetch.d.ts type BrowserbaseFetchFormat = 'raw' | 'json' | 'markdown'; interface BrowserbaseFetchConfig { /** Whether to follow HTTP redirects (default: false). */ allowRedirects?: boolean; /** Whether to bypass TLS certificate verification (default: false). */ allowInsecureSsl?: boolean; /** Whether to route the request through Browserbase proxies (default: false). */ proxies?: boolean; /** Output format for the response content (default: raw). */ format?: BrowserbaseFetchFormat; /** * JSON Schema describing the desired response content. Only used when format * is json. */ schema?: Record; } interface BrowserbaseFetchInput { /** URL of the page to fetch. */ url: string; /** Whether to follow HTTP redirects. */ allow_redirects?: boolean; /** Whether to bypass TLS certificate verification. */ allow_insecure_ssl?: boolean; /** Whether to route the request through Browserbase proxies. */ proxies?: boolean; /** Output format for the response content. */ format?: BrowserbaseFetchFormat; /** * JSON Schema describing the desired response content. Only used when format * is json. */ schema?: Record; } interface BrowserbaseFetchResponse { /** Unique identifier for the fetch request. */ id: string; /** * Response body. Raw and markdown responses return strings; JSON extraction * returns an object matching the requested schema. */ content: string | Record; /** MIME type of the response. */ contentType: string; /** Character encoding of the response. */ encoding: string; /** Response headers from the fetched page. */ headers: Record; /** HTTP status code returned by the fetched page. */ statusCode: number; } interface BrowserbaseFetchError { error: 'api_error' | 'configuration_error' | 'execution_error' | 'invalid_input' | 'rate_limit' | 'timeout' | 'unknown'; statusCode?: number; message: string; } type BrowserbaseFetchOutput = BrowserbaseFetchError | BrowserbaseFetchResponse; declare const browserbaseFetchToolFactory: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory; //#endregion //#region src/tool/browserbase-search.d.ts interface BrowserbaseSearchConfig { /** * Default maximum number of results to return (1-25, default: 10). */ numResults?: number; } interface BrowserbaseSearchInput { /** * Web search query (1-200 characters). */ query: string; /** * Maximum number of results to return (1-25, default: 10). */ num_results?: number; } interface BrowserbaseSearchResult { /** Unique identifier for the result. */ id: string; /** Title of the search result. */ title: string; /** URL of the search result. */ url: string; /** Author of the content, when available. */ author?: string; /** Favicon URL, when available. */ favicon?: string; /** Image URL, when available. */ image?: string; /** Publication date in ISO 8601 format, when available. */ publishedDate?: string; } interface BrowserbaseSearchResponse { /** The search query that was executed. */ query: string; /** Unique identifier for the request. */ requestId: string; /** Search results. */ results: BrowserbaseSearchResult[]; } interface BrowserbaseSearchError { error: 'api_error' | 'configuration_error' | 'execution_error' | 'invalid_input' | 'rate_limit' | 'timeout' | 'unknown'; statusCode?: number; message: string; } type BrowserbaseSearchOutput = BrowserbaseSearchError | BrowserbaseSearchResponse; declare const browserbaseSearchToolFactory: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory; //#endregion //#region src/tool/gateway-tool-error.d.ts interface GatewayToolError { error: 'api_error' | 'configuration_error' | 'execution_error' | 'gateway_rate_limit' | 'invalid_input' | 'rate_limit' | 'timeout' | 'unknown' | 'unknown_tool'; message: string; statusCode?: number; retryAfter?: string; statusText?: string; } //#endregion //#region src/tool/deepseek-fetch.d.ts interface DeepSeekFetchConfig { /** Pin the target URL instead of allowing the model to choose it. */ url?: string; } interface DeepSeekFetchInput { url: string; } interface DeepSeekFetchResponse { title?: string | null; /** Page content as Markdown. */ content: string; } type DeepSeekFetchOutput = DeepSeekFetchResponse | GatewayToolError; declare const deepseekFetchToolFactory: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory; //#endregion //#region src/tool/deepseek-search.d.ts interface DeepSeekSearchConfig { /** Pin the query instead of allowing the model to choose it. */ query?: string; /** Maximum number of results, 1–50 (default: 10). */ count?: number; /** Include available page content (default: false). */ needContent?: boolean; /** Original question, 1–128 Unicode characters; null means absent. */ oriQuestion?: string | null; /** Developer-configured IP address for result localization. */ localization?: string; } interface DeepSeekSearchInput { query: string; count?: number; need_content?: boolean; ori_question?: string | null; } interface DeepSeekSearchResult { authority?: number | null; content?: string | null; date?: string | null; rerank_score?: number | null; site_icon?: string | null; site_name?: string | null; snippet?: string | null; summary?: string | null; title?: string | null; url?: string | null; } interface DeepSeekSearchResponse { results: DeepSeekSearchResult[]; } type DeepSeekSearchOutput = DeepSeekSearchResponse | GatewayToolError; declare const deepseekSearchToolFactory: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory; //#endregion //#region src/tool/exa-search.d.ts type ExaSearchType = 'auto' | 'fast' | 'instant'; type ExaSearchCategory = 'company' | 'people' | 'research paper' | 'news' | 'personal site' | 'financial report'; type ExaTextSection = 'header' | 'navigation' | 'banner' | 'body' | 'sidebar' | 'footer' | 'metadata'; interface ExaSearchTextConfig { maxCharacters?: number; includeHtmlTags?: boolean; verbosity?: 'compact' | 'standard' | 'full'; includeSections?: ExaTextSection[]; excludeSections?: ExaTextSection[]; } interface ExaSearchHighlightsConfig { query?: string; maxCharacters?: number; } interface ExaSearchExtrasConfig { links?: number; imageLinks?: number; } interface ExaSearchContentsConfig { text?: boolean | ExaSearchTextConfig; highlights?: boolean | ExaSearchHighlightsConfig; maxAgeHours?: number; livecrawlTimeout?: number; subpages?: number; subpageTarget?: string | string[]; extras?: ExaSearchExtrasConfig; } interface ExaSearchConfig { /** * Default search method. Exa defaults to auto when omitted. */ type?: ExaSearchType; /** * Default maximum number of results to return (1-100, default: 10). */ numResults?: number; /** * Default category filter for result types. */ category?: ExaSearchCategory; /** * Default two-letter ISO country code for location-aware search. */ userLocation?: string; /** * Default domains to include or exclude. */ includeDomains?: string[]; excludeDomains?: string[]; /** * Default published date filters in ISO 8601 format. */ startPublishedDate?: string; endPublishedDate?: string; /** * Default content extraction controls. */ contents?: ExaSearchContentsConfig; } interface ExaSearchResult { title: string; url: string; id: string; publishedDate?: string | null; author?: string | null; image?: string | null; favicon?: string | null; text?: string; highlights?: string[]; highlightScores?: number[]; summary?: string; subpages?: ExaSearchResult[]; extras?: { links?: string[]; imageLinks?: string[]; }; } interface ExaSearchResponse { requestId: string; searchType?: string; resolvedSearchType?: string; results: ExaSearchResult[]; costDollars?: { total?: number; search?: Record; }; } interface ExaSearchError { error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'configuration_error' | 'execution_error' | 'unknown'; statusCode?: number; message: string; } interface ExaSearchInput { query: string; type?: ExaSearchType; num_results?: number; category?: ExaSearchCategory; user_location?: string; include_domains?: string[]; exclude_domains?: string[]; start_published_date?: string; end_published_date?: string; contents?: { text?: boolean | { max_characters?: number; include_html_tags?: boolean; verbosity?: 'compact' | 'standard' | 'full'; include_sections?: ExaTextSection[]; exclude_sections?: ExaTextSection[]; }; highlights?: boolean | { query?: string; max_characters?: number; }; max_age_hours?: number; livecrawl_timeout?: number; subpages?: number; subpage_target?: string | string[]; extras?: { links?: number; image_links?: number; }; }; } type ExaSearchOutput = ExaSearchResponse | ExaSearchError; declare const exaSearchToolFactory: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory; //#endregion //#region src/tool/parallel-search.d.ts declare const parallelSearchModes: readonly ["turbo", "fast", "basic", "advanced", "one-shot", "agentic"]; /** * Search mode. `turbo` and `fast` trade excerpt depth for latency (`turbo` is * English and Japanese only), `basic` is balanced, `advanced` is the most thorough. * Deprecated: `one-shot` (runs as `basic`) and `agentic` (runs as `advanced`). */ type ParallelSearchMode = (typeof parallelSearchModes)[number]; interface ParallelSearchSourcePolicy { /** * Domains or domain/path prefixes to restrict results to. When set, * `excludeDomains` is ignored. Example: ['wikipedia.org', 'docs.python.org/3'] */ includeDomains?: string[]; /** * Domains or domain/path prefixes to exclude from results. * Example: ['reddit.com'] */ excludeDomains?: string[]; /** * Only include results published on or after this date (YYYY-MM-DD). * Example: '2024-01-01' */ afterDate?: string; } interface ParallelSearchExcerpts { /** * Maximum characters per result. */ maxCharsPerResult?: number; /** * Maximum total characters across all results. * @deprecated Use the top-level `maxCharsTotal` option instead. */ maxCharsTotal?: number; } interface ParallelSearchFetchPolicy { /** * Maximum age in seconds of cached content before a live fetch is attempted. * Minimum 600; lower values are raised to 600. */ maxAgeSeconds?: number; /** * Timeout in seconds for a live fetch when content is not cached. * The gateway caps it to stay within its own tool timeout. */ timeoutSeconds?: number; /** * Return an error instead of falling back to older cached content when a * live fetch fails or times out. Defaults to false. */ disableCacheFallback?: boolean; } interface ParallelSearchConfig { /** * Search mode. Defaults to `basic`. */ mode?: ParallelSearchMode; /** * Default maximum number of results to return (1-20). * Defaults to 10 if not specified. */ maxResults?: number; /** * Default source policy for controlling which domains to include/exclude. */ sourcePolicy?: ParallelSearchSourcePolicy; /** * Default excerpt configuration for controlling result length. */ excerpts?: ParallelSearchExcerpts; /** * Maximum total characters across all result excerpts. */ maxCharsTotal?: number; /** * Default fetch policy for controlling content freshness. */ fetchPolicy?: ParallelSearchFetchPolicy; /** * ISO 3166-1 alpha-2 country code to localize results, e.g. 'us'. * Invalid codes are ignored with a warning. */ location?: string; } interface ParallelSearchResult { /** URL of the search result */ url: string; /** Title of the page, if available */ title?: string | null; /** Publication date of the page (YYYY-MM-DD), if available */ publish_date?: string | null; /** Relevant excerpts from the page, formatted as markdown */ excerpts: string[]; } interface ParallelSearchWarning { /** Warning type, e.g. 'input_validation_warning'. New types may be added. */ type: string; /** Human-readable message */ message: string; /** Optional detail supporting the warning */ detail?: Record | null; } interface ParallelSearchUsage { /** Usage item name, e.g. 'sku_search' */ name: string; /** Count for the usage item */ count?: number; } interface ParallelSearchResponse { /** Unique identifier for this search request */ search_id: string; /** Search results, ordered by decreasing relevance */ results: ParallelSearchResult[]; /** Non-fatal issues with the request, such as an ignored `location` */ warnings?: ParallelSearchWarning[] | null; /** Usage reported by Parallel for this search */ usage?: ParallelSearchUsage[] | null; /** Session identifier shared by the searches made during one request */ session_id?: string; } type ParallelSearchError = GatewayToolError; interface ParallelSearchInput { /** * Natural-language description of the web research goal. * Include source or freshness guidance and broader context from the task. * Maximum 5000 characters. */ objective: string; /** * 2-3 concise keyword queries, 3-6 words each (max 5, 200 characters each). */ search_queries?: string[]; /** * Search mode. Defaults to `basic`. */ mode?: ParallelSearchMode; /** * Maximum number of results to return (1-20). * Defaults to 10 if not specified. */ max_results?: number; /** * Source policy for controlling which domains to include/exclude. */ source_policy?: { include_domains?: string[]; exclude_domains?: string[]; after_date?: string; }; /** * Excerpt configuration for controlling result length. */ excerpts?: { max_chars_per_result?: number; /** @deprecated Use the top-level `max_chars_total` instead. */ max_chars_total?: number; }; /** * Maximum total characters across all result excerpts. */ max_chars_total?: number; /** * Fetch policy for controlling content freshness. */ fetch_policy?: { max_age_seconds?: number; timeout_seconds?: number; disable_cache_fallback?: boolean; }; /** * ISO 3166-1 alpha-2 country code to localize results. */ location?: string; } type ParallelSearchOutput = ParallelSearchResponse | ParallelSearchError; declare const parallelSearchToolFactory: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory; //#endregion //#region src/tool/perplexity-search.d.ts interface PerplexitySearchConfig { /** * Default maximum number of search results to return (1-20, default: 10). */ maxResults?: number; /** * Default maximum tokens to extract per search result page (256-2048, default: 2048). */ maxTokensPerPage?: number; /** * Default maximum total tokens across all search results (default: 25000, max: 1000000). */ maxTokens?: number; /** * Default two-letter ISO 3166-1 alpha-2 country code for regional search results. * Examples: 'US', 'GB', 'FR' */ country?: string; /** * Default list of domains to include or exclude from search results (max 20). * To include: ['nature.com', 'science.org'] * To exclude: ['-example.com', '-spam.net'] */ searchDomainFilter?: string[]; /** * Default list of ISO 639-1 language codes to filter results (max 10, lowercase). * Examples: ['en', 'fr', 'de'] */ searchLanguageFilter?: string[]; /** * Default recency filter for results. * Cannot be combined with searchAfterDate/searchBeforeDate at runtime. */ searchRecencyFilter?: 'day' | 'week' | 'month' | 'year'; } interface PerplexitySearchResult { /** Title of the search result */ title: string; /** URL of the search result */ url: string; /** Text snippet/preview of the content */ snippet: string; /** Publication date of the content */ date?: string; /** Last updated date of the content */ lastUpdated?: string; } interface PerplexitySearchResponse { /** Array of search results */ results: PerplexitySearchResult[]; /** Unique identifier for this search request */ id: string; } interface PerplexitySearchError { /** Error type */ error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'unknown'; /** HTTP status code if applicable */ statusCode?: number; /** Human-readable error message */ message: string; } interface PerplexitySearchInput { /** * Search query (string) or multiple queries (array of up to 5 strings). * Multi-query searches return combined results from all queries. */ query: string | string[]; /** * Maximum number of search results to return (1-20, default: 10). */ max_results?: number; /** * Maximum number of tokens to extract per search result page (256-2048, default: 2048). */ max_tokens_per_page?: number; /** * Maximum total tokens across all search results (default: 25000, max: 1000000). */ max_tokens?: number; /** * Two-letter ISO 3166-1 alpha-2 country code for regional search results. * Examples: 'US', 'GB', 'FR' */ country?: string; /** * List of domains to include or exclude from search results (max 20). * To include: ['nature.com', 'science.org'] * To exclude: ['-example.com', '-spam.net'] */ search_domain_filter?: string[]; /** * List of ISO 639-1 language codes to filter results (max 10, lowercase). * Examples: ['en', 'fr', 'de'] */ search_language_filter?: string[]; /** * Include only results published after this date. * Format: 'MM/DD/YYYY' (e.g., '3/1/2025') * Cannot be used with search_recency_filter. */ search_after_date?: string; /** * Include only results published before this date. * Format: 'MM/DD/YYYY' (e.g., '3/15/2025') * Cannot be used with search_recency_filter. */ search_before_date?: string; /** * Include only results last updated after this date. * Format: 'MM/DD/YYYY' (e.g., '3/1/2025') * Cannot be used with search_recency_filter. */ last_updated_after_filter?: string; /** * Include only results last updated before this date. * Format: 'MM/DD/YYYY' (e.g., '3/15/2025') * Cannot be used with search_recency_filter. */ last_updated_before_filter?: string; /** * Filter results by relative time period. * Cannot be used with search_after_date or search_before_date. */ search_recency_filter?: 'day' | 'week' | 'month' | 'year'; } type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError; declare const perplexitySearchToolFactory: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory; //#endregion //#region src/tool/tako-search.d.ts type TakoSearchEffort = 'deep' | 'fast' | 'instant'; type TakoContentFormat = 'card_json' | 'csv' | 'json_compact' | 'json_records'; interface TakoDataSourceConfig { /** * Maximum number of data results to return (1-20). When includeContents is * true, each additional result adds its own data surcharge. */ count?: number; /** * Inline rows for each data result. This adds a data surcharge based on row * count and dataset source. To estimate cost, search with includeContents * disabled and inspect cards.content.export_pricing. This applies to every * returned card; limit sources.data.count and sources.data.maxRows to control * cost. */ includeContents?: boolean; /** Requested delivery mode for card data. Search cards are always inlined. */ mode?: 'inline' | 'url'; /** Serialization for inlined card data. */ contentFormat?: TakoContentFormat; /** * Maximum rows to inline per result. Omit to use the allowance in * cards.content.export_pricing. A data surcharge applies per 1,000 exported * rows; lower values reduce cost. */ maxRows?: number; /** Data Graph node IDs to prioritize. */ nodeIds?: string[]; /** Return only cards matching nodeIds. Requires at least one node ID. */ strict?: boolean; } interface TakoWebSourceConfig { /** Maximum number of web results to return (1-20). */ count?: number; /** Inline extracted web page text. This can add a data charge. */ includeContents?: boolean; /** Optional web-result category filter. */ category?: 'finance' | 'news' | 'sports'; /** Only return results from these bare domains. */ includeDomains?: string[]; /** Exclude results from these bare domains. */ excludeDomains?: string[]; /** Maximum characters in each web-result snippet. */ snippetMaxChars?: number; /** Include highlighted passages in web results. Defaults to true in AI Gateway. */ highlights?: boolean; /** Maximum extracted characters per web page when including contents. */ articleContentMaxChars?: number; /** Keep results published on or after this ISO date. */ publishedAfter?: string; /** Keep results published on or before this ISO date. */ publishedBefore?: string; } interface TakoSearchConfig { /** Search effort. fast is the default balanced option. */ effort?: TakoSearchEffort; /** Sources to search. Omit to search both curated data and the web. */ sources?: { data?: TakoDataSourceConfig; web?: TakoWebSourceConfig; }; /** End-user coordinates for localized results. */ location?: { latitude: number; longitude: number; }; /** ISO 3166-1 alpha-2 country code. */ countryCode?: string; /** BCP-47 locale. */ locale?: string; /** IANA timezone. */ timezone?: string; /** Settings that control card rendering. */ outputSettings?: { imageDarkMode?: boolean; /** Instant-effort only. */ forceRefresh?: boolean; }; /** Maximum related search suggestions to include (1-20). */ includeRelated?: number; /** * Serve per-unit-priced data, such as web traffic and SEO. Each such card adds * a charge, capped by maxVariableCostUsd. On by default; set false to opt out, * and those cards come back as placeholders. */ variableCost?: boolean; /** * Most one call can be charged in variable cost, in USD. Defaults to 0.25; * null removes the cap. Cards that don't fit come back as placeholders with * reason 'over_cap'. Can't be combined with variableCost: false. */ maxVariableCostUsd?: number | null; /** * Extra Tako request fields in snake_case, deep-merged into the body last. * Can't set fields this tool models; Tako rejects unknown keys (api_error). */ extraBody?: Record; } interface TakoSearchInput { query: string; effort?: TakoSearchEffort; sources?: { data?: { count?: number; include_contents?: boolean; mode?: 'inline' | 'url'; content_format?: TakoContentFormat; max_rows?: number; node_ids?: string[]; strict?: boolean; }; web?: { count?: number; include_contents?: boolean; category?: 'finance' | 'news' | 'sports'; include_domains?: string[]; exclude_domains?: string[]; snippet_max_chars?: number; highlights?: boolean; article_content_max_chars?: number; published_after?: string; published_before?: string; }; }; location?: { latitude: number; longitude: number; }; country_code?: string; locale?: string; timezone?: string; output_settings?: { image_dark_mode?: boolean; force_refresh?: boolean; }; include_related?: number; } type TakoDatasetCell = boolean | number | string | null; interface TakoResultContent { content_format?: TakoContentFormat | null; cost?: number; data?: string | null; records?: Array> | null; dataset?: { columns: Array<{ name: string; type: 'boolean' | 'date' | 'datetime' | 'number' | 'string'; unit?: string | null; }>; rows: TakoDatasetCell[][]; total_rows: number; truncated: boolean; ref: string; sources: Array<{ name: string; index?: 'data' | 'web'; }>; provenance?: 'query' | 'web_extraction'; } | null; card_data?: Record | null; card_data_schema?: Record | null; url?: string | null; expires_at?: string | null; total_rows?: number | null; truncated?: boolean; /** Distinct records per premium class (e.g. company_record) among delivered rows. */ premium_rows?: Record | null; /** Column header → 0-based delivered-row positions whose premium value was withheld. */ redacted_cells?: Record | null; /** Full set size when the card lists only a capped slice of it. */ total_matching?: number | null; export_pricing?: { baseline_usd: number; /** @deprecated Always 0, and Tako will stop sending it. */ free_rows?: number; max_rows_ceiling: number; row_cpm_usd: number; /** USD per 1,000 premium records by class, added to row_cpm_usd when premium. */ premium_row_cpm_usd?: Record | null; /** Upper bound on this card's variable-cost charge; set only for per-unit-priced sources. */ variable_cost_max_usd?: number | null; } | null; manifest?: Array<{ dtype?: 'boolean' | 'date' | 'datetime' | 'number' | 'string' | null; entity?: string | null; metric?: string | null; name?: string | null; unit?: string | null; }> | null; } interface TakoCard { card_id?: string | null; title?: string | null; description?: string | null; semantic_description?: string | null; webpage_url?: string | null; image_url?: string | null; embed_url?: string | null; sources?: Array<{ source_name?: string | null; source_description?: string | null; source_index: 'data' | 'web'; source_text?: string | null; url?: string | null; }> | null; methodologies?: Array<{ methodology_name: string | null; methodology_description: string | null; }> | null; source_indexes?: Array<'data' | 'web'> | null; card_type?: string | null; relevance?: 'High' | 'Low' | 'Medium' | null; /** Relevance to the query, 1.0-5.0. Null unless the account is entitled. */ relevance_score?: number | null; content?: TakoResultContent | null; exportable?: boolean; nodes?: Array<{ id: string; type: 'entity' | 'metric'; name: string; description?: string | null; }> | null; metric_definitions?: Array<{ name: string; definition: string; }> | null; data_freshness?: { coverage_end?: string | null; data_as_of?: string | null; last_updated?: string | null; } | null; /** * Set when Tako withholds the card's data: variable cost off or not served * (`not_served`), or over maxVariableCostUsd (`over_cap`). */ placeholder?: { withheld_source: string; reason?: 'not_served' | 'over_cap' | null; } | null; } interface TakoWebResult { title: string; url: string; snippet?: string | null; source_name?: string | null; publish_date?: string | null; content?: TakoResultContent | null; } interface TakoSearchResponse { request_id: string; cards?: TakoCard[]; web_results?: TakoWebResult[]; usage?: { total_cost_usd: number; compute?: { cost_usd: number; } | null; data?: { cost_usd: number; datasets: number; data_points?: number | null; } | null; variable_cost?: { cost_usd: number; } | null; } | null; related?: Array> | null; } type TakoSearchError = GatewayToolError; type TakoSearchOutput = TakoSearchError | TakoSearchResponse; declare const takoSearchToolFactory: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory; //#endregion //#region src/gateway-tools.d.ts /** * Gateway-specific provider-defined tools. */ declare const gatewayTools: { /** * Fetch page content using Browserbase's lightweight Fetch API. * * Supports raw, Markdown, and schema-driven JSON output as well as redirects, * proxy routing, and TLS controls. */ browserbaseFetch: (config?: BrowserbaseFetchConfig) => ReturnType; /** * Search the web using Browserbase's Search API for fast, structured results. * * Returns titles, URLs, and available publication metadata without requiring * a browser session. */ browserbaseSearch: (config?: BrowserbaseSearchConfig) => ReturnType; /** * Fetch a page as Markdown through DeepSeek's standalone Fetch API. * Executed by AI Gateway for any model, separate from native model web search. */ deepseekFetch: (config?: DeepSeekFetchConfig) => ReturnType; /** * Search the web through DeepSeek's standalone Search API. * Executed by AI Gateway for any model, separate from native model web search. */ deepseekSearch: (config?: DeepSeekSearchConfig) => ReturnType; /** * Search the web using Exa for current information and token-efficient * excerpts optimized for agent workflows. * * Supports search type, category, domain, date, location, and content * extraction controls. */ exaSearch: (config?: ExaSearchConfig) => ReturnType; /** * Search the web using Parallel AI's Search API for LLM-optimized excerpts. * * Takes a natural language objective and returns relevant excerpts, * replacing multiple keyword searches with a single call for broad * or complex queries. Supports different search types for depth vs * breadth tradeoffs. */ parallelSearch: (config?: ParallelSearchConfig) => ReturnType; /** * Search the web using Perplexity's Search API for real-time information, * news, research papers, and articles. * * Provides ranked search results with advanced filtering options including * domain, language, date range, and recency filters. */ perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType; /** * Search the web and Tako's curated knowledge graph in one call for * token-efficient web excerpts and structured data results grounded in * premium sources, each with an embed-ready visualization. * * Supports effort, per-source web and data controls, localization, and inline * contents for agents that need to reason over underlying data. */ takoSearch: (config?: TakoSearchConfig) => ReturnType; }; //#endregion //#region src/gateway-provider.d.ts interface GatewayProvider extends ProviderV4 { (modelId: GatewayModelId): LanguageModelV4; /** * Creates a model for text generation. */ chat(modelId: GatewayModelId): LanguageModelV4; /** * Creates a model for text generation. */ languageModel(modelId: GatewayModelId): LanguageModelV4; /** Returns a BatchV4 interface for processing batches with AI Gateway. */ experimental_batch(): Experimental_BatchV4<{ text: GatewayModelId; }>; /** * Returns available providers and models for use with the remote provider. */ getAvailableModels(): Promise; /** * Returns credit information for the authenticated user. */ getCredits(): Promise; /** * Returns a spend report with cost, token, and request count data, * aggregated by the specified dimension. */ getSpendReport(params: GatewaySpendReportParams): Promise; /** * Returns detailed information about a specific generation by its ID, * including cost, token usage, latency, and provider details. */ getGenerationInfo(params: GatewayGenerationInfoParams): Promise; /** * Creates a model for generating text embeddings. */ embedding(modelId: GatewayEmbeddingModelId): EmbeddingModelV4; /** * Creates a model for generating text embeddings. */ embeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV4; /** * @deprecated Use `embeddingModel` instead. */ textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV4; /** * Creates a model for generating images. */ image(modelId: GatewayImageModelId): ImageModelV4; /** * Creates a model for generating images. */ imageModel(modelId: GatewayImageModelId): ImageModelV4; /** * Creates a model for generating videos. */ video(modelId: GatewayVideoModelId): Experimental_VideoModelV4; /** * Creates a model for generating videos. */ videoModel(modelId: GatewayVideoModelId): Experimental_VideoModelV4; /** * Creates a model for reranking documents. */ reranking(modelId: GatewayRerankingModelId): RerankingModelV4; /** * Creates a model for reranking documents. */ rerankingModel(modelId: GatewayRerankingModelId): RerankingModelV4; /** * Creates a model for deciding answers to questions against shared state. */ decision(modelId: GatewayDecisionModelId): Experimental_DecisionModelV4; /** * Creates a model for deciding answers to questions against shared state. */ decisionModel(modelId: GatewayDecisionModelId): Experimental_DecisionModelV4; /** @deprecated Use `decisionModel` instead. */ evaluationModel(modelId: GatewayDecisionModelId): Experimental_DecisionModelV4 & { doEvaluate: Experimental_DecisionModelV4['doDecide']; }; /** @deprecated Use `decision` instead. */ evaluation(modelId: GatewayDecisionModelId): ReturnType; /** * Creates a model for extracting typed field values from shared state. */ extraction(modelId: GatewayExtractionModelId): Experimental_ExtractionModelV4; /** * Creates a model for extracting typed field values from shared state. */ extractionModel(modelId: GatewayExtractionModelId): Experimental_ExtractionModelV4; /** * Creates a model for text-to-speech generation. */ speech(modelId: GatewaySpeechModelId): SpeechModelV4; /** * Creates a model for text-to-speech generation. */ speechModel(modelId: GatewaySpeechModelId): SpeechModelV4; /** * Creates a model for audio transcription. */ transcription(modelId: GatewayTranscriptionModelId): TranscriptionModelV4; /** * Creates a model for audio transcription. */ transcriptionModel(modelId: GatewayTranscriptionModelId): TranscriptionModelV4; /** * Creates an experimental realtime model for bidirectional audio/text * communication over WebSocket, normalized through the AI Gateway. Known * Live model IDs return a continuous Live model; `{ api }` overrides routing. */ experimental_realtime: GatewayRealtimeFactory; /** * Experimental streaming-transcription entry point. Callable like * `transcription(modelId)`, plus `getToken` for minting a short-lived * client secret (`vcst_`) a browser can use to open the streaming * transcription WebSocket without holding the Gateway credential. */ experimental_transcription: GatewayTranscriptionFactory; /** * Experimental streaming-speech entry point. Callable like * `speech(modelId)`, plus `getToken` for minting a short-lived client * secret (`vcst_`) a browser can use to open the streaming speech * WebSocket without holding the Gateway credential. */ experimental_speech: GatewaySpeechFactory; /** * Gateway-specific tools executed server-side. */ tools: typeof gatewayTools; } /** * Realtime factory: returns a turn-based realtime model or, for Live model IDs * or `{ api: 'live' }`, a continuous Live model. `getToken` mints a client * secret bound to the matching Gateway WebSocket route. */ interface GatewayRealtimeFactory extends Experimental_RealtimeFactoryV4 { (modelId: string, options: { api: 'live'; }): GatewayRealtimeModelLive; (modelId: string, options: { api: 'realtime'; }): GatewayRealtimeModel; (modelId: GatewayKnownLiveModelId, options?: { api?: undefined; }): GatewayRealtimeModelLive; (modelId: GatewayRealtimeModelId, options?: GatewayRealtimeOptions): Experimental_RealtimeModelV4; getToken(options: Experimental_RealtimeFactoryV4GetTokenOptions & GatewayRealtimeOptions): Promise; } type GatewayTranscriptionFactoryGetTokenOptions = { model: GatewayTranscriptionModelId; /** Token lifetime in seconds. Gateway default is 60s (max 300s). */ expiresAfterSeconds?: number; }; type GatewayTranscriptionFactoryGetTokenResult = { /** The minted `vcst_` client secret. */ token: string; /** WebSocket URL of the streaming transcription surface for this model. */ url: string; /** Token expiry, epoch seconds. */ expiresAt?: number; }; /** * Streaming-transcription factory: callable like `transcription(modelId)`, * plus a server-side `getToken` that mints a transcription-bound short-lived * client secret (`vcst_`). The browser connects with * `createGateway({ apiKey: token }).transcription(modelId)` — the token rides * the same auth subprotocol an API key does, without exposing the credential. */ interface GatewayTranscriptionFactory { (modelId: GatewayTranscriptionModelId): TranscriptionModelV4; getToken(options: GatewayTranscriptionFactoryGetTokenOptions): Promise; } type GatewaySpeechFactoryGetTokenOptions = { model: GatewaySpeechModelId; /** Token lifetime in seconds. Gateway default is 60s (max 300s). */ expiresAfterSeconds?: number; }; type GatewaySpeechFactoryGetTokenResult = { /** The minted `vcst_` client secret. */ token: string; /** WebSocket URL of the streaming speech surface for this model. */ url: string; /** Token expiry, epoch seconds. */ expiresAt?: number; }; /** * Streaming-speech factory: callable like `speech(modelId)`, plus a * server-side `getToken` that mints a speech-bound short-lived client secret * (`vcst_`). The browser connects with * `createGateway({ apiKey: token }).speech(modelId)`; the token rides the * same auth subprotocol an API key does, without exposing the credential. */ interface GatewaySpeechFactory { (modelId: GatewaySpeechModelId): Experimental_StreamingSpeechModelV4; getToken(options: GatewaySpeechFactoryGetTokenOptions): Promise; } interface GatewayProviderSettings { /** Settings for downloading JSON Lines batch results. */ batchResultDownloads?: { /** Maximum UTF-8 bytes per row, excluding LF. Defaults to 64 MiB. */ maxLineBytes?: number; }; /** * The base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v4/ai`. */ baseURL?: string; /** * API key or Vercel access token that is being sent using the `Authorization` * header. It defaults to the `AI_GATEWAY_API_KEY` environment variable. * A callback is resolved before each request and must return a non-empty key. * * If neither `apiKey` nor `AI_GATEWAY_API_KEY` is set to a non-empty value, * the provider authenticates with the Vercel OIDC token instead, resolved for * each request. On Vercel deployments this requires no configuration. For * local development, run `vercel env pull` or `vercel dev` to get a token. * A non-empty configured API key is always used instead of OIDC, even if the * key is invalid. If no OIDC token is available either, requests fail with a * `GatewayAuthenticationError` ("No authentication provided"). */ apiKey?: Resolvable; /** * Vercel team ID or slug to scope requests for access tokens that can access * multiple teams. */ teamIdOrSlug?: string; /** * Custom headers to include in the requests. */ headers?: Record; /** * Custom fetch implementation. You can use it as a middleware to intercept requests, * or to provide a custom fetch implementation for e.g. testing. */ fetch?: FetchFunction; /** * Custom WebSocket implementation used for streaming transcription and * streaming speech. This is useful for testing or for runtimes without a * global WebSocket. A header-capable implementation is not required — * Gateway WebSocket auth is carried in the subprotocols. */ webSocket?: WebSocketConstructor; /** * How frequently to refresh the metadata cache in milliseconds. */ metadataCacheRefreshMillis?: number; } /** * Create a remote provider instance. */ export declare function createGateway(options?: GatewayProviderSettings): GatewayProvider; export declare const gateway: GatewayProvider; //#endregion //#region src/gateway-provider-metadata.d.ts /** * Metadata for an asynchronous AI Gateway job. */ type GatewayAsyncJobMetadata = { readonly jobId: string; readonly status: string; /** * Secret for verifying customer webhook deliveries. This is sensitive, * start-response-only metadata and must not be logged or forwarded. */ readonly webhookSigningSecret?: string; readonly [key: string]: JSONValue | undefined; }; /** * Shape of the inner `providerMetadata.gateway` object returned by AI Gateway * operations. * * Additional fields may be added without a package update. */ type GatewayProviderMetadata = { readonly asyncJob?: GatewayAsyncJobMetadata; readonly [key: string]: JSONValue | undefined; }; //#endregion //#region src/errors/gateway-error.d.ts declare const symbol$10: unique symbol; export declare abstract class GatewayError extends Error { private readonly [symbol$10]; abstract readonly name: string; abstract readonly type: string; readonly statusCode: number; readonly cause?: unknown; readonly generationId?: string; readonly isRetryable: boolean; constructor({ message, statusCode, cause, generationId, isRetryable }: { message: string; statusCode?: number; cause?: unknown; generationId?: string; isRetryable?: boolean; }); /** * Checks if the given error is a Gateway Error. * @param {unknown} error - The error to check. * @returns {boolean} True if the error is a Gateway Error, false otherwise. */ static isInstance(error: unknown): error is GatewayError; static hasMarker(error: unknown): error is GatewayError; } //#endregion //#region src/errors/create-gateway-error.d.ts declare const gatewayErrorResponseSchema: import("@ai-sdk/provider-utils").LazySchema<{ error: { message: string; type?: string | null | undefined; param?: unknown; code?: string | number | null | undefined; }; generationId?: string | null | undefined; }>; type GatewayErrorResponse = InferSchema; //#endregion //#region src/errors/gateway-access-policy-denied-error.d.ts declare const symbol$9: unique symbol; /** * Access policy denied - an AI Gateway access policy that applies to the * request does not allow the requested model or provider. */ export declare class GatewayAccessPolicyDeniedError extends GatewayError { private readonly [symbol$9]; readonly name = "GatewayAccessPolicyDeniedError"; readonly type = "access_policy_denied"; /** * IDs of the access policies that denied the request, when the gateway * includes them. */ readonly policyIds?: string[]; /** * Models the access policies removed, when the gateway includes them. */ readonly removedModels?: string[]; /** * Providers the access policies removed, when the gateway includes them. */ readonly removedProviders?: string[]; constructor({ message, statusCode, cause, generationId, policyIds, removedModels, removedProviders }?: { message?: string; statusCode?: number; cause?: unknown; generationId?: string; policyIds?: string[]; removedModels?: string[]; removedProviders?: string[]; }); static isInstance(error: unknown): error is GatewayAccessPolicyDeniedError; } //#endregion //#region src/errors/gateway-authentication-error.d.ts declare const symbol$8: unique symbol; /** * Authentication failed - invalid API key or OIDC token */ export declare class GatewayAuthenticationError extends GatewayError { private readonly [symbol$8]; readonly name = "GatewayAuthenticationError"; readonly type = "authentication_error"; constructor({ message, statusCode, cause, generationId }?: { message?: string; statusCode?: number; cause?: unknown; generationId?: string; }); static isInstance(error: unknown): error is GatewayAuthenticationError; /** * Creates a contextual error message when authentication fails */ static createContextualError({ apiKeyProvided, oidcTokenProvided, statusCode, cause, generationId }: { apiKeyProvided: boolean; oidcTokenProvided: boolean; message?: string; statusCode?: number; cause?: unknown; generationId?: string; }): GatewayAuthenticationError; } //#endregion //#region src/errors/gateway-failed-dependency-error.d.ts declare const symbol$7: unique symbol; /** * The request could not be fulfilled because a dependency it relied on was not * available on the credentials or provider used to serve it (HTTP 424). Not * retryable — the caller must change the request. */ export declare class GatewayFailedDependencyError extends GatewayError { private readonly [symbol$7]; readonly name = "GatewayFailedDependencyError"; readonly type = "failed_dependency"; constructor({ message, statusCode, cause, generationId }?: { message?: string; statusCode?: number; cause?: unknown; generationId?: string; }); static isInstance(error: unknown): error is GatewayFailedDependencyError; } //#endregion //#region src/errors/gateway-forbidden-error.d.ts declare const symbol$6: unique symbol; /** * Forbidden - the request was rejected by policy (e.g. a routing rule), * not an authentication failure. */ export declare class GatewayForbiddenError extends GatewayError { private readonly [symbol$6]; readonly name = "GatewayForbiddenError"; readonly type = "forbidden"; readonly ruleId?: string; constructor({ message, statusCode, cause, generationId, ruleId }?: { message?: string; statusCode?: number; cause?: unknown; generationId?: string; ruleId?: string; }); static isInstance(error: unknown): error is GatewayForbiddenError; } //#endregion //#region src/errors/gateway-internal-server-error.d.ts declare const symbol$5: unique symbol; /** * Internal server error from the Gateway */ export declare class GatewayInternalServerError extends GatewayError { private readonly [symbol$5]; readonly name = "GatewayInternalServerError"; readonly type = "internal_server_error"; constructor({ message, statusCode, cause, generationId }?: { message?: string; statusCode?: number; cause?: unknown; generationId?: string; }); static isInstance(error: unknown): error is GatewayInternalServerError; } //#endregion //#region src/errors/gateway-invalid-request-error.d.ts declare const symbol$4: unique symbol; /** * Invalid request - missing headers, malformed data, etc. */ export declare class GatewayInvalidRequestError extends GatewayError { private readonly [symbol$4]; readonly name = "GatewayInvalidRequestError"; readonly type = "invalid_request_error"; constructor({ message, statusCode, cause, generationId }?: { message?: string; statusCode?: number; cause?: unknown; generationId?: string; }); static isInstance(error: unknown): error is GatewayInvalidRequestError; } //#endregion //#region src/errors/gateway-model-not-found-error.d.ts declare const symbol$3: unique symbol; /** * Model not found or not available */ export declare class GatewayModelNotFoundError extends GatewayError { private readonly [symbol$3]; readonly name = "GatewayModelNotFoundError"; readonly type = "model_not_found"; readonly modelId?: string; constructor({ message, statusCode, modelId, cause, generationId }?: { message?: string; statusCode?: number; modelId?: string; cause?: unknown; generationId?: string; }); static isInstance(error: unknown): error is GatewayModelNotFoundError; } //#endregion //#region src/errors/gateway-not-found-error.d.ts declare const symbol$2: unique symbol; /** * Not found - the requested Gateway resource does not exist or is not * visible to the caller (e.g. an unknown async batch/video job id). * Distinct from `GatewayModelNotFoundError`, which is model-specific. */ export declare class GatewayNotFoundError extends GatewayError { private readonly [symbol$2]; readonly name = "GatewayNotFoundError"; readonly type = "not_found"; constructor({ message, statusCode, cause, generationId }?: { message?: string; statusCode?: number; cause?: unknown; generationId?: string; }); static isInstance(error: unknown): error is GatewayNotFoundError; } //#endregion //#region src/errors/gateway-rate-limit-error.d.ts declare const symbol$1: unique symbol; /** * Rate limit exceeded. */ export declare class GatewayRateLimitError extends GatewayError { private readonly [symbol$1]; readonly name = "GatewayRateLimitError"; readonly type = "rate_limit_exceeded"; constructor({ message, statusCode, cause, generationId }?: { message?: string; statusCode?: number; cause?: unknown; generationId?: string; }); static isInstance(error: unknown): error is GatewayRateLimitError; } //#endregion //#region src/errors/gateway-response-error.d.ts declare const symbol: unique symbol; /** * Gateway response parsing error */ export declare class GatewayResponseError extends GatewayError { private readonly [symbol]; readonly name = "GatewayResponseError"; readonly type = "response_error"; readonly response?: unknown; readonly validationError?: TypeValidationError; constructor({ message, statusCode, response, validationError, cause, generationId, isRetryable }?: { message?: string; statusCode?: number; response?: unknown; validationError?: TypeValidationError; cause?: unknown; generationId?: string; isRetryable?: boolean; }); static isInstance(error: unknown): error is GatewayResponseError; } //#endregion //#region src/version.d.ts export declare const VERSION: string; //#endregion //#region src/index.d.ts /** @deprecated Use `GatewayDecisionModelId` instead. */ export type GatewayEvaluationModelId = GatewayDecisionModelId; /** @deprecated Use `DecisionFallbackCondition` instead. */ export type EvaluationFallbackCondition = DecisionFallbackCondition; //#endregion export { type DecisionFallbackCondition, type GatewayAsyncJobMetadata, type GatewayCreditsResponse, type GatewayDecisionModelId, type GatewayEmbeddingModelId, type GatewayErrorResponse, type GatewayExtractionModelId, type GatewayGenerationInfo, type GatewayGenerationInfoParams, type GatewayImageModelId, type GatewayKnownLiveModelId, type GatewayLanguageModelEntry, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayProviderOptions as GatewayLanguageModelOptions, type GatewayProviderOptions, type GatewayLanguageModelSpecification, type GatewayModelFallback, type GatewayModelId, type GatewayProvider, type GatewayProviderMetadata, type GatewayProviderSettings, type GatewayRealtimeFactory, type GatewayRealtimeModelId, type GatewayRealtimeOptions, type GatewayRerankingModelId, type GatewaySpeechModelId, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayTranscriptionModelId, type GatewayVideoModelId, createGateway as createGatewayProvider }; //# sourceMappingURL=index.d.ts.map