@ai-sdk/gateway 4.0.0-beta.11 → 4.0.0-beta.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +762 -4
  2. package/dist/index.d.ts +449 -42
  3. package/dist/index.js +1554 -397
  4. package/dist/index.js.map +1 -1
  5. package/docs/00-ai-gateway.mdx +534 -61
  6. package/package.json +14 -14
  7. package/src/errors/as-gateway-error.ts +2 -1
  8. package/src/errors/create-gateway-error.ts +17 -3
  9. package/src/errors/gateway-authentication-error.ts +8 -5
  10. package/src/errors/gateway-error.ts +8 -0
  11. package/src/errors/gateway-failed-dependency-error.ts +35 -0
  12. package/src/errors/gateway-forbidden-error.ts +34 -0
  13. package/src/errors/gateway-response-error.ts +1 -1
  14. package/src/errors/index.ts +2 -0
  15. package/src/errors/parse-auth-method.ts +1 -2
  16. package/src/gateway-config.ts +1 -1
  17. package/src/gateway-embedding-model-settings.ts +1 -0
  18. package/src/gateway-embedding-model.ts +62 -15
  19. package/src/gateway-fetch-metadata.ts +51 -38
  20. package/src/gateway-generation-info.ts +149 -0
  21. package/src/gateway-headers.ts +3 -0
  22. package/src/gateway-image-model-settings.ts +8 -1
  23. package/src/gateway-image-model.ts +46 -21
  24. package/src/gateway-language-model-settings.ts +45 -26
  25. package/src/gateway-language-model.ts +72 -42
  26. package/src/gateway-model-entry.ts +15 -3
  27. package/src/gateway-provider-options.ts +50 -78
  28. package/src/gateway-provider.ts +296 -35
  29. package/src/gateway-realtime-auth.ts +126 -0
  30. package/src/gateway-realtime-model-settings.ts +1 -0
  31. package/src/gateway-realtime-model.ts +118 -0
  32. package/src/gateway-reranking-model-settings.ts +7 -0
  33. package/src/gateway-reranking-model.ts +142 -0
  34. package/src/gateway-speech-model-settings.ts +1 -0
  35. package/src/gateway-speech-model.ts +145 -0
  36. package/src/gateway-spend-report.ts +193 -0
  37. package/src/gateway-tools.ts +10 -0
  38. package/src/gateway-transcription-model-settings.ts +1 -0
  39. package/src/gateway-transcription-model.ts +155 -0
  40. package/src/gateway-video-model-settings.ts +4 -0
  41. package/src/gateway-video-model.ts +29 -19
  42. package/src/index.ts +30 -5
  43. package/src/tool/exa-search.ts +352 -0
  44. package/src/tool/parallel-search.ts +10 -11
  45. package/src/tool/perplexity-search.ts +10 -11
  46. package/dist/index.d.mts +0 -602
  47. package/dist/index.mjs +0 -1539
  48. package/dist/index.mjs.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,11 +1,74 @@
1
- import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, Experimental_VideoModelV3, TypeValidationError } from '@ai-sdk/provider';
1
+ import { LanguageModelV4, ProviderV4, EmbeddingModelV4, ImageModelV4, Experimental_VideoModelV4, RerankingModelV4, SpeechModelV4, TranscriptionModelV4, Experimental_RealtimeFactoryV4, TypeValidationError } from '@ai-sdk/provider';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
4
4
 
5
- type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'alibaba/qwen3.5-flash' | 'alibaba/qwen3.5-plus' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-opus-4.6' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'anthropic/claude-sonnet-4.6' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'google/gemini-3.1-flash-image-preview' | 'google/gemini-3.1-flash-lite-preview' | 'google/gemini-3.1-pro-preview' | 'inception/mercury-2' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | 'meituan/longcat-flash-thinking-2601' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'minimax/minimax-m2.5' | 'minimax/minimax-m2.5-highspeed' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'moonshotai/kimi-k2.5' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-4o-mini-search-preview' | 'openai/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-5.3-chat' | 'openai/gpt-5.3-codex' | 'openai/gpt-5.4' | 'openai/gpt-5.4-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-4.20-multi-agent-beta' | 'xai/grok-4.20-non-reasoning-beta' | 'xai/grok-4.20-reasoning-beta' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flash' | 'zai/glm-4.7-flashx' | 'zai/glm-5' | (string & {});
5
+ type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen-3.6-max-preview' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-235b-a22b-instruct' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'alibaba/qwen3.5-flash' | 'alibaba/qwen3.5-plus' | 'alibaba/qwen3.6-27b' | 'alibaba/qwen3.6-plus' | 'alibaba/qwen3.7-max' | 'alibaba/qwen3.7-plus' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-opus-4.6' | 'anthropic/claude-opus-4.7' | 'anthropic/claude-opus-4.8' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'anthropic/claude-sonnet-4.6' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-large-thinking' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-thinking' | 'deepseek/deepseek-v4-flash' | 'deepseek/deepseek-v4-pro' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'google/gemini-3.1-flash-image' | 'google/gemini-3.1-flash-image-preview' | 'google/gemini-3.1-flash-lite' | 'google/gemini-3.1-flash-lite-preview' | 'google/gemini-3.1-pro-preview' | 'google/gemini-3.5-flash' | 'google/gemma-4-26b-a4b-it' | 'google/gemma-4-31b-it' | 'inception/mercury-2' | 'inception/mercury-coder-small' | 'interfaze/interfaze-beta' | 'kwaipilot/kat-coder-pro-v1' | 'kwaipilot/kat-coder-pro-v2' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking-2601' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'minimax/minimax-m2.5' | 'minimax/minimax-m2.5-highspeed' | 'minimax/minimax-m2.7' | 'minimax/minimax-m2.7-highspeed' | 'minimax/minimax-m3' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-medium-3.5' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2.5' | 'moonshotai/kimi-k2.6' | 'moonshotai/kimi-k2.7-code' | 'moonshotai/kimi-k2.7-code-highspeed' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-3-super-120b-a12b' | 'nvidia/nemotron-3-ultra-550b-a55b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-4o-mini-search-preview' | 'openai/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-5.3-chat' | 'openai/gpt-5.3-codex' | 'openai/gpt-5.4' | 'openai/gpt-5.4-mini' | 'openai/gpt-5.4-nano' | 'openai/gpt-5.4-pro' | 'openai/gpt-5.5' | 'openai/gpt-5.5-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning-pro' | 'stepfun/step-3.5-flash' | 'stepfun/step-3.7-flash' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-4.20-multi-agent' | 'xai/grok-4.20-multi-agent-beta' | 'xai/grok-4.20-non-reasoning' | 'xai/grok-4.20-non-reasoning-beta' | 'xai/grok-4.20-reasoning' | 'xai/grok-4.20-reasoning-beta' | 'xai/grok-4.3' | 'xai/grok-build-0.1' | 'xiaomi/mimo-v2-flash' | 'xiaomi/mimo-v2-pro' | 'xiaomi/mimo-v2.5' | 'xiaomi/mimo-v2.5-pro' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | '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-5v-turbo' | (string & {});
6
6
 
7
- type GatewayVideoModelId = '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' | 'bytedance/seedance-v1.0-lite-i2v' | 'bytedance/seedance-v1.0-lite-t2v' | 'bytedance/seedance-v1.0-pro' | 'bytedance/seedance-v1.0-pro-fast' | 'bytedance/seedance-v1.5-pro' | 'google/veo-3.0-fast-generate-001' | 'google/veo-3.0-generate-001' | 'google/veo-3.1-fast-generate-001' | 'google/veo-3.1-generate-001' | '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-t2v' | 'xai/grok-imagine-video' | (string & {});
7
+ /**
8
+ * Shared WebSocket subprotocol contract for AI Gateway realtime auth.
9
+ *
10
+ * The browser `WebSocket` API cannot set request headers, so the Gateway auth
11
+ * (bearer) token is carried through the `Sec-WebSocket-Protocol` handshake
12
+ * instead of an `Authorization` header — the same workaround OpenAI uses for
13
+ * `openai-insecure-api-key.<token>`.
14
+ *
15
+ * This module is the single source of truth for that contract so the client and
16
+ * the Gateway server can't drift: the client encodes values with
17
+ * `getGatewayRealtimeProtocols`, and the Gateway server decodes them with
18
+ * `getGatewayRealtimeAuthToken` / `getGatewayRealtimeTeamIdOrSlug`.
19
+ *
20
+ * WebSocket subprotocol values must fit the RFC token grammar. The auth token is
21
+ * sent as-is, so callers must use tokens that are valid subprotocol tokens; the
22
+ * optional team scope is base64url-encoded by this module. Keep the complete
23
+ * `Sec-WebSocket-Protocol` header compact (target under an 8 KiB safe header
24
+ * budget) because intermediaries may reject large upgrade headers.
25
+ */
26
+ /**
27
+ * Marker subprotocol offered on every handshake so the Gateway can echo a
28
+ * negotiated subprotocol on the 101 response (some clients require the server to
29
+ * select one of the offered subprotocols).
30
+ */
31
+ declare const GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realtime.v1";
32
+ /** Subprotocol prefix that carries the Gateway auth (bearer) token. */
33
+ declare const GATEWAY_AUTH_SUBPROTOCOL_PREFIX = "ai-gateway-auth.";
34
+ /** Subprotocol prefix that carries optional Vercel team scoping. */
35
+ declare const GATEWAY_TEAM_SUBPROTOCOL_PREFIX = "ai-gateway-team.";
36
+ /**
37
+ * Client-side: build the WebSocket subprotocols that carry `token` to the
38
+ * Gateway. Pass the result as the second argument to `new WebSocket(url, ...)`.
39
+ */
40
+ declare function getGatewayRealtimeProtocols(token: string, options?: {
41
+ teamIdOrSlug?: string;
42
+ }): string[];
43
+ /**
44
+ * Server-side: extract the Gateway auth (bearer) token from a
45
+ * `Sec-WebSocket-Protocol` header value, or `undefined` when it is absent or
46
+ * empty. The Gateway upgrade handler turns this into an
47
+ * `Authorization: Bearer <token>` before its normal auth path.
48
+ *
49
+ * Accepts the raw header value (subprotocols are comma-separated and may carry
50
+ * surrounding whitespace).
51
+ */
52
+ declare function getGatewayRealtimeAuthToken(secWebSocketProtocol: string | null | undefined): string | undefined;
53
+ /**
54
+ * Server-side: extract the optional Vercel team ID or slug from the
55
+ * `Sec-WebSocket-Protocol` header value. Team scoping is base64url-encoded so
56
+ * arbitrary team slugs stay within the WebSocket subprotocol token grammar.
57
+ */
58
+ declare function getGatewayRealtimeTeamIdOrSlug(secWebSocketProtocol: string | null | undefined): string | undefined;
59
+
60
+ type GatewayRealtimeModelId = string & {};
61
+
62
+ type GatewayRerankingModelId = 'cohere/rerank-v3.5' | 'cohere/rerank-v4-fast' | 'cohere/rerank-v4-pro' | 'voyage/rerank-2.5' | 'voyage/rerank-2.5-lite' | (string & {});
63
+
64
+ type GatewaySpeechModelId = string & {};
65
+
66
+ type GatewayTranscriptionModelId = string & {};
67
+
68
+ type GatewayVideoModelId = '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' | 'bytedance/seedance-2.0' | 'bytedance/seedance-2.0-fast' | 'bytedance/seedance-v1.0-lite-i2v' | 'bytedance/seedance-v1.0-lite-t2v' | 'bytedance/seedance-v1.0-pro' | 'bytedance/seedance-v1.0-pro-fast' | 'bytedance/seedance-v1.5-pro' | 'google/veo-3.0-fast-generate-001' | 'google/veo-3.0-generate-001' | 'google/veo-3.1-fast-generate-001' | 'google/veo-3.1-generate-001' | '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' | 'xai/grok-imagine-video' | 'xai/grok-imagine-video-1.5-preview' | (string & {});
8
69
 
70
+ declare const KNOWN_MODEL_TYPES: readonly ["embedding", "image", "language", "reranking", "speech", "transcription", "video"];
71
+ type KnownModelType = (typeof KNOWN_MODEL_TYPES)[number];
9
72
  interface GatewayLanguageModelEntry {
10
73
  /**
11
74
  * The model id used by the remote provider in model settings and for specifying the
@@ -50,9 +113,9 @@ interface GatewayLanguageModelEntry {
50
113
  /**
51
114
  * Optional field to differentiate between model types.
52
115
  */
53
- modelType?: 'language' | 'embedding' | 'image' | 'video' | null;
116
+ modelType?: KnownModelType | null;
54
117
  }
55
- type GatewayLanguageModelSpecification = Pick<LanguageModelV3, 'specificationVersion' | 'provider' | 'modelId'>;
118
+ type GatewayLanguageModelSpecification = Pick<LanguageModelV4, 'specificationVersion' | 'provider' | 'modelId'>;
56
119
 
57
120
  interface GatewayFetchMetadataResponse {
58
121
  models: GatewayLanguageModelEntry[];
@@ -64,9 +127,108 @@ interface GatewayCreditsResponse {
64
127
  totalUsed: string;
65
128
  }
66
129
 
67
- type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-embedding-4b' | 'alibaba/qwen3-embedding-8b' | 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | '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' | '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' | (string & {});
130
+ interface GatewaySpendReportParams {
131
+ /** Start date in YYYY-MM-DD format (inclusive) */
132
+ startDate: string;
133
+ /** End date in YYYY-MM-DD format (inclusive) */
134
+ endDate: string;
135
+ /** Primary aggregation dimension. Defaults to 'day'. */
136
+ groupBy?: 'day' | 'user' | 'model' | 'tag' | 'provider' | 'credential_type';
137
+ /** Time granularity when groupBy is 'day'. */
138
+ datePart?: 'day' | 'hour';
139
+ /** Filter to a specific user's spend. */
140
+ userId?: string;
141
+ /** Filter to a specific model (e.g. 'anthropic/claude-sonnet-4.5'). */
142
+ model?: string;
143
+ /** Filter to a specific provider (e.g. 'anthropic'). */
144
+ provider?: string;
145
+ /** Filter to BYOK or system credentials. */
146
+ credentialType?: 'byok' | 'system';
147
+ /** Filter to requests with these tags. */
148
+ tags?: string[];
149
+ }
150
+ interface GatewaySpendReportRow {
151
+ /** Date string (present when groupBy is 'day') */
152
+ day?: string;
153
+ /** Hour timestamp (present when groupBy is 'day' and datePart is 'hour') */
154
+ hour?: string;
155
+ /** User identifier (present when groupBy is 'user') */
156
+ user?: string;
157
+ /** Model identifier (present when groupBy is 'model') */
158
+ model?: string;
159
+ /** Tag value (present when groupBy is 'tag') */
160
+ tag?: string;
161
+ /** Provider name (present when groupBy is 'provider') */
162
+ provider?: string;
163
+ /** Credential type (present when groupBy is 'credential_type') */
164
+ credentialType?: 'byok' | 'system';
165
+ /** Total cost in USD */
166
+ totalCost: number;
167
+ /** Market cost in USD */
168
+ marketCost?: number;
169
+ /** Number of input tokens */
170
+ inputTokens?: number;
171
+ /** Number of output tokens */
172
+ outputTokens?: number;
173
+ /** Number of cached input tokens */
174
+ cachedInputTokens?: number;
175
+ /** Number of cache creation input tokens */
176
+ cacheCreationInputTokens?: number;
177
+ /** Number of reasoning tokens */
178
+ reasoningTokens?: number;
179
+ /** Number of requests */
180
+ requestCount?: number;
181
+ }
182
+ interface GatewaySpendReportResponse {
183
+ results: GatewaySpendReportRow[];
184
+ }
185
+
186
+ interface GatewayGenerationInfoParams {
187
+ /** The generation ID to look up (format: gen_<ulid>) */
188
+ id: string;
189
+ }
190
+ interface GatewayGenerationInfo {
191
+ /** The generation ID */
192
+ id: string;
193
+ /** Total cost in USD */
194
+ totalCost: number;
195
+ /** Upstream inference cost in USD (BYOK only) */
196
+ upstreamInferenceCost: number;
197
+ /** Usage cost in USD (same as totalCost) */
198
+ usage: number;
199
+ /** ISO 8601 timestamp when the generation was created */
200
+ createdAt: string;
201
+ /** Model identifier */
202
+ model: string;
203
+ /** Whether BYOK credentials were used */
204
+ isByok: boolean;
205
+ /** Provider that served this generation */
206
+ providerName: string;
207
+ /** Whether streaming was used */
208
+ streamed: boolean;
209
+ /** Finish reason (e.g. 'stop') */
210
+ finishReason: string;
211
+ /** Time to first token in milliseconds */
212
+ latency: number;
213
+ /** Total generation time in milliseconds */
214
+ generationTime: number;
215
+ /** Number of prompt tokens */
216
+ promptTokens: number;
217
+ /** Number of completion tokens */
218
+ completionTokens: number;
219
+ /** Reasoning tokens used */
220
+ reasoningTokens: number;
221
+ /** Cached tokens used */
222
+ cachedTokens: number;
223
+ /** Cache creation input tokens */
224
+ cacheCreationTokens: number;
225
+ /** Billable web search calls */
226
+ billableWebSearchCalls: number;
227
+ }
228
+
229
+ type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-embedding-4b' | 'alibaba/qwen3-embedding-8b' | 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | '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' | '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' | (string & {});
68
230
 
69
- type GatewayImageModelId = 'bfl/flux-2-flex' | 'bfl/flux-2-klein-4b' | 'bfl/flux-2-klein-9b' | 'bfl/flux-2-max' | 'bfl/flux-2-pro' | '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' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'openai/gpt-image-1' | 'openai/gpt-image-1-mini' | 'openai/gpt-image-1.5' | 'prodia/flux-fast-schnell' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | 'recraft/recraft-v4' | 'recraft/recraft-v4-pro' | 'xai/grok-imagine-image' | 'xai/grok-imagine-image-pro' | (string & {});
231
+ type GatewayImageModelId = 'bfl/flux-2-flex' | 'bfl/flux-2-klein-4b' | 'bfl/flux-2-klein-9b' | 'bfl/flux-2-max' | 'bfl/flux-2-pro' | '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' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'openai/gpt-image-1' | 'openai/gpt-image-1-mini' | 'openai/gpt-image-1.5' | 'openai/gpt-image-2' | 'prodia/flux-fast-schnell' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | 'recraft/recraft-v4' | 'recraft/recraft-v4-pro' | 'recraft/recraft-v4.1' | 'recraft/recraft-v4.1-pro' | 'recraft/recraft-v4.1-utility' | 'recraft/recraft-v4.1-utility-pro' | 'xai/grok-imagine-image' | (string & {});
70
232
 
71
233
  interface PerplexitySearchConfig {
72
234
  /**
@@ -194,7 +356,7 @@ interface PerplexitySearchInput {
194
356
  search_recency_filter?: 'day' | 'week' | 'month' | 'year';
195
357
  }
196
358
  type PerplexitySearchOutput = PerplexitySearchResponse | PerplexitySearchError;
197
- declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig>;
359
+ declare const perplexitySearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<PerplexitySearchInput, PerplexitySearchOutput, PerplexitySearchConfig, {}>;
198
360
 
199
361
  interface ParallelSearchSourcePolicy {
200
362
  /**
@@ -327,12 +489,147 @@ interface ParallelSearchInput {
327
489
  };
328
490
  }
329
491
  type ParallelSearchOutput = ParallelSearchResponse | ParallelSearchError;
330
- declare const parallelSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<ParallelSearchInput, ParallelSearchOutput, ParallelSearchConfig>;
492
+ declare const parallelSearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<ParallelSearchInput, ParallelSearchOutput, ParallelSearchConfig, {}>;
493
+
494
+ type ExaSearchType = 'auto' | 'fast' | 'instant';
495
+ type ExaSearchCategory = 'company' | 'people' | 'research paper' | 'news' | 'personal site' | 'financial report';
496
+ type ExaTextSection = 'header' | 'navigation' | 'banner' | 'body' | 'sidebar' | 'footer' | 'metadata';
497
+ interface ExaSearchTextConfig {
498
+ maxCharacters?: number;
499
+ includeHtmlTags?: boolean;
500
+ verbosity?: 'compact' | 'standard' | 'full';
501
+ includeSections?: ExaTextSection[];
502
+ excludeSections?: ExaTextSection[];
503
+ }
504
+ interface ExaSearchHighlightsConfig {
505
+ query?: string;
506
+ maxCharacters?: number;
507
+ }
508
+ interface ExaSearchExtrasConfig {
509
+ links?: number;
510
+ imageLinks?: number;
511
+ }
512
+ interface ExaSearchContentsConfig {
513
+ text?: boolean | ExaSearchTextConfig;
514
+ highlights?: boolean | ExaSearchHighlightsConfig;
515
+ maxAgeHours?: number;
516
+ livecrawlTimeout?: number;
517
+ subpages?: number;
518
+ subpageTarget?: string | string[];
519
+ extras?: ExaSearchExtrasConfig;
520
+ }
521
+ interface ExaSearchConfig {
522
+ /**
523
+ * Default search method. Exa defaults to auto when omitted.
524
+ */
525
+ type?: ExaSearchType;
526
+ /**
527
+ * Default maximum number of results to return (1-100, default: 10).
528
+ */
529
+ numResults?: number;
530
+ /**
531
+ * Default category filter for result types.
532
+ */
533
+ category?: ExaSearchCategory;
534
+ /**
535
+ * Default two-letter ISO country code for location-aware search.
536
+ */
537
+ userLocation?: string;
538
+ /**
539
+ * Default domains to include or exclude.
540
+ */
541
+ includeDomains?: string[];
542
+ excludeDomains?: string[];
543
+ /**
544
+ * Default published date filters in ISO 8601 format.
545
+ */
546
+ startPublishedDate?: string;
547
+ endPublishedDate?: string;
548
+ /**
549
+ * Default content extraction controls.
550
+ */
551
+ contents?: ExaSearchContentsConfig;
552
+ }
553
+ interface ExaSearchResult {
554
+ title: string;
555
+ url: string;
556
+ id: string;
557
+ publishedDate?: string | null;
558
+ author?: string | null;
559
+ image?: string | null;
560
+ favicon?: string | null;
561
+ text?: string;
562
+ highlights?: string[];
563
+ highlightScores?: number[];
564
+ summary?: string;
565
+ subpages?: ExaSearchResult[];
566
+ extras?: {
567
+ links?: string[];
568
+ imageLinks?: string[];
569
+ };
570
+ }
571
+ interface ExaSearchResponse {
572
+ requestId: string;
573
+ searchType?: string;
574
+ resolvedSearchType?: string;
575
+ results: ExaSearchResult[];
576
+ costDollars?: {
577
+ total?: number;
578
+ search?: Record<string, number>;
579
+ };
580
+ }
581
+ interface ExaSearchError {
582
+ error: 'api_error' | 'rate_limit' | 'timeout' | 'invalid_input' | 'configuration_error' | 'execution_error' | 'unknown';
583
+ statusCode?: number;
584
+ message: string;
585
+ }
586
+ interface ExaSearchInput {
587
+ query: string;
588
+ type?: ExaSearchType;
589
+ num_results?: number;
590
+ category?: ExaSearchCategory;
591
+ user_location?: string;
592
+ include_domains?: string[];
593
+ exclude_domains?: string[];
594
+ start_published_date?: string;
595
+ end_published_date?: string;
596
+ contents?: {
597
+ text?: boolean | {
598
+ max_characters?: number;
599
+ include_html_tags?: boolean;
600
+ verbosity?: 'compact' | 'standard' | 'full';
601
+ include_sections?: ExaTextSection[];
602
+ exclude_sections?: ExaTextSection[];
603
+ };
604
+ highlights?: boolean | {
605
+ query?: string;
606
+ max_characters?: number;
607
+ };
608
+ max_age_hours?: number;
609
+ livecrawl_timeout?: number;
610
+ subpages?: number;
611
+ subpage_target?: string | string[];
612
+ extras?: {
613
+ links?: number;
614
+ image_links?: number;
615
+ };
616
+ };
617
+ }
618
+ type ExaSearchOutput = ExaSearchResponse | ExaSearchError;
619
+ declare const exaSearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<ExaSearchInput, ExaSearchOutput, ExaSearchConfig, {}>;
331
620
 
332
621
  /**
333
622
  * Gateway-specific provider-defined tools.
334
623
  */
335
624
  declare const gatewayTools: {
625
+ /**
626
+ * Search the web using Exa for current information and token-efficient
627
+ * excerpts optimized for agent workflows.
628
+ *
629
+ * Supports search type, category, domain, date, location, and content
630
+ * extraction controls.
631
+ */
632
+ exaSearch: (config?: ExaSearchConfig) => ReturnType<typeof exaSearchToolFactory>;
336
633
  /**
337
634
  * Search the web using Parallel AI's Search API for LLM-optimized excerpts.
338
635
  *
@@ -352,16 +649,16 @@ declare const gatewayTools: {
352
649
  perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType<typeof perplexitySearchToolFactory>;
353
650
  };
354
651
 
355
- interface GatewayProvider extends ProviderV3 {
356
- (modelId: GatewayModelId): LanguageModelV3;
652
+ interface GatewayProvider extends ProviderV4 {
653
+ (modelId: GatewayModelId): LanguageModelV4;
357
654
  /**
358
655
  * Creates a model for text generation.
359
656
  */
360
- chat(modelId: GatewayModelId): LanguageModelV3;
657
+ chat(modelId: GatewayModelId): LanguageModelV4;
361
658
  /**
362
659
  * Creates a model for text generation.
363
660
  */
364
- languageModel(modelId: GatewayModelId): LanguageModelV3;
661
+ languageModel(modelId: GatewayModelId): LanguageModelV4;
365
662
  /**
366
663
  * Returns available providers and models for use with the remote provider.
367
664
  */
@@ -370,34 +667,73 @@ interface GatewayProvider extends ProviderV3 {
370
667
  * Returns credit information for the authenticated user.
371
668
  */
372
669
  getCredits(): Promise<GatewayCreditsResponse>;
670
+ /**
671
+ * Returns a spend report with cost, token, and request count data,
672
+ * aggregated by the specified dimension.
673
+ */
674
+ getSpendReport(params: GatewaySpendReportParams): Promise<GatewaySpendReportResponse>;
675
+ /**
676
+ * Returns detailed information about a specific generation by its ID,
677
+ * including cost, token usage, latency, and provider details.
678
+ */
679
+ getGenerationInfo(params: GatewayGenerationInfoParams): Promise<GatewayGenerationInfo>;
373
680
  /**
374
681
  * Creates a model for generating text embeddings.
375
682
  */
376
- embedding(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
683
+ embedding(modelId: GatewayEmbeddingModelId): EmbeddingModelV4;
377
684
  /**
378
685
  * Creates a model for generating text embeddings.
379
686
  */
380
- embeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
687
+ embeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV4;
381
688
  /**
382
689
  * @deprecated Use `embeddingModel` instead.
383
690
  */
384
- textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
691
+ textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV4;
385
692
  /**
386
693
  * Creates a model for generating images.
387
694
  */
388
- image(modelId: GatewayImageModelId): ImageModelV3;
695
+ image(modelId: GatewayImageModelId): ImageModelV4;
389
696
  /**
390
697
  * Creates a model for generating images.
391
698
  */
392
- imageModel(modelId: GatewayImageModelId): ImageModelV3;
699
+ imageModel(modelId: GatewayImageModelId): ImageModelV4;
393
700
  /**
394
701
  * Creates a model for generating videos.
395
702
  */
396
- video(modelId: GatewayVideoModelId): Experimental_VideoModelV3;
703
+ video(modelId: GatewayVideoModelId): Experimental_VideoModelV4;
397
704
  /**
398
705
  * Creates a model for generating videos.
399
706
  */
400
- videoModel(modelId: GatewayVideoModelId): Experimental_VideoModelV3;
707
+ videoModel(modelId: GatewayVideoModelId): Experimental_VideoModelV4;
708
+ /**
709
+ * Creates a model for reranking documents.
710
+ */
711
+ reranking(modelId: GatewayRerankingModelId): RerankingModelV4;
712
+ /**
713
+ * Creates a model for reranking documents.
714
+ */
715
+ rerankingModel(modelId: GatewayRerankingModelId): RerankingModelV4;
716
+ /**
717
+ * Creates a model for text-to-speech generation.
718
+ */
719
+ speech(modelId: GatewaySpeechModelId): SpeechModelV4;
720
+ /**
721
+ * Creates a model for text-to-speech generation.
722
+ */
723
+ speechModel(modelId: GatewaySpeechModelId): SpeechModelV4;
724
+ /**
725
+ * Creates a model for audio transcription.
726
+ */
727
+ transcription(modelId: GatewayTranscriptionModelId): TranscriptionModelV4;
728
+ /**
729
+ * Creates a model for audio transcription.
730
+ */
731
+ transcriptionModel(modelId: GatewayTranscriptionModelId): TranscriptionModelV4;
732
+ /**
733
+ * Creates an experimental realtime model for bidirectional audio/text
734
+ * communication over WebSocket, normalized through the AI Gateway.
735
+ */
736
+ experimental_realtime: Experimental_RealtimeFactoryV4;
401
737
  /**
402
738
  * Gateway-specific tools executed server-side.
403
739
  */
@@ -405,13 +741,19 @@ interface GatewayProvider extends ProviderV3 {
405
741
  }
406
742
  interface GatewayProviderSettings {
407
743
  /**
408
- * The base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v1/ai`.
744
+ * The base URL prefix for API calls. Defaults to `https://ai-gateway.vercel.sh/v4/ai`.
409
745
  */
410
746
  baseURL?: string;
411
747
  /**
412
- * API key that is being sent using the `Authorization` header.
748
+ * API key or Vercel access token that is being sent using the `Authorization`
749
+ * header. It defaults to the `AI_GATEWAY_API_KEY` environment variable.
413
750
  */
414
751
  apiKey?: string;
752
+ /**
753
+ * Vercel team ID or slug to scope requests for access tokens that can access
754
+ * multiple teams.
755
+ */
756
+ teamIdOrSlug?: string;
415
757
  /**
416
758
  * Custom headers to include in the requests.
417
759
  */
@@ -429,36 +771,62 @@ interface GatewayProviderSettings {
429
771
  /**
430
772
  * Create a remote provider instance.
431
773
  */
432
- declare function createGatewayProvider(options?: GatewayProviderSettings): GatewayProvider;
774
+ declare function createGateway(options?: GatewayProviderSettings): GatewayProvider;
433
775
  declare const gateway: GatewayProvider;
434
776
 
435
- declare const gatewayLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
436
- only?: string[] | undefined;
437
- order?: string[] | undefined;
438
- user?: string | undefined;
439
- tags?: string[] | undefined;
440
- models?: string[] | undefined;
441
- byok?: Record<string, Record<string, unknown>[]> | undefined;
442
- zeroDataRetention?: boolean | undefined;
777
+ type GatewayProviderOptions = {
778
+ /**
779
+ * Service-owned options may be added by the Gateway without requiring an SDK
780
+ * release. The Gateway service validates and applies the runtime schema.
781
+ */
782
+ [key: string]: unknown;
783
+ /** Request-scoped BYOK credentials to use instead of cached credentials. */
784
+ byok?: Record<string, Array<Record<string, unknown>>>;
785
+ /** Enables automatic caching behavior when supported by the Gateway. */
786
+ caching?: 'auto';
787
+ /** Filter to providers that do not train on prompt data. */
788
+ disallowPromptTraining?: boolean;
789
+ /** Filter to providers that are HIPAA compliant with Vercel AI Gateway. */
790
+ hipaaCompliant?: boolean;
791
+ /** Array of model slugs specifying fallback models to use in order. */
792
+ models?: string[];
793
+ /** Array of provider slugs that are the only ones allowed to be used. */
794
+ only?: string[];
795
+ /** Array of provider slugs specifying the provider attempt order. */
796
+ order?: string[];
797
+ /** Per-provider timeouts for BYOK credentials in milliseconds. */
443
798
  providerTimeouts?: {
444
- byok?: Record<string, number> | undefined;
445
- } | undefined;
446
- }>;
447
- type GatewayLanguageModelOptions = InferSchema<typeof gatewayLanguageModelOptions>;
799
+ byok?: Record<string, number>;
800
+ };
801
+ /** Entity identifier against which quota is tracked. */
802
+ quotaEntityId?: string;
803
+ /** Unified service tier intent. */
804
+ serviceTier?: 'flex' | 'priority';
805
+ /** Sort providers by a performance or cost metric before routing. */
806
+ sort?: 'cost' | 'tps' | 'ttft';
807
+ /** User-specified tags for reporting and filtering usage. */
808
+ tags?: string[];
809
+ /** End-user identifier for spend tracking and attribution. */
810
+ user?: string;
811
+ /** Filter to providers with zero data retention agreements. */
812
+ zeroDataRetention?: boolean;
813
+ };
448
814
 
449
- declare const symbol$6: unique symbol;
815
+ declare const symbol$8: unique symbol;
450
816
  declare abstract class GatewayError extends Error {
451
- private readonly [symbol$6];
817
+ private readonly [symbol$8];
452
818
  abstract readonly name: string;
453
819
  abstract readonly type: string;
454
820
  readonly statusCode: number;
455
821
  readonly cause?: unknown;
456
822
  readonly generationId?: string;
457
- constructor({ message, statusCode, cause, generationId, }: {
823
+ readonly isRetryable: boolean;
824
+ constructor({ message, statusCode, cause, generationId, isRetryable, }: {
458
825
  message: string;
459
826
  statusCode?: number;
460
827
  cause?: unknown;
461
828
  generationId?: string;
829
+ isRetryable?: boolean;
462
830
  });
463
831
  /**
464
832
  * Checks if the given error is a Gateway Error.
@@ -480,12 +848,12 @@ declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazySchema<{
480
848
  }>;
481
849
  type GatewayErrorResponse = InferSchema<typeof gatewayErrorResponseSchema>;
482
850
 
483
- declare const symbol$5: unique symbol;
851
+ declare const symbol$7: unique symbol;
484
852
  /**
485
853
  * Authentication failed - invalid API key or OIDC token
486
854
  */
487
855
  declare class GatewayAuthenticationError extends GatewayError {
488
- private readonly [symbol$5];
856
+ private readonly [symbol$7];
489
857
  readonly name = "GatewayAuthenticationError";
490
858
  readonly type = "authentication_error";
491
859
  constructor({ message, statusCode, cause, generationId, }?: {
@@ -498,7 +866,7 @@ declare class GatewayAuthenticationError extends GatewayError {
498
866
  /**
499
867
  * Creates a contextual error message when authentication fails
500
868
  */
501
- static createContextualError({ apiKeyProvided, oidcTokenProvided, message, statusCode, cause, generationId, }: {
869
+ static createContextualError({ apiKeyProvided, oidcTokenProvided, statusCode, cause, generationId, }: {
502
870
  apiKeyProvided: boolean;
503
871
  oidcTokenProvided: boolean;
504
872
  message?: string;
@@ -508,6 +876,43 @@ declare class GatewayAuthenticationError extends GatewayError {
508
876
  }): GatewayAuthenticationError;
509
877
  }
510
878
 
879
+ declare const symbol$6: unique symbol;
880
+ /**
881
+ * The request could not be fulfilled because a dependency it relied on was not
882
+ * available on the credentials or provider used to serve it (HTTP 424). Not
883
+ * retryable — the caller must change the request.
884
+ */
885
+ declare class GatewayFailedDependencyError extends GatewayError {
886
+ private readonly [symbol$6];
887
+ readonly name = "GatewayFailedDependencyError";
888
+ readonly type = "failed_dependency";
889
+ constructor({ message, statusCode, cause, generationId, }?: {
890
+ message?: string;
891
+ statusCode?: number;
892
+ cause?: unknown;
893
+ generationId?: string;
894
+ });
895
+ static isInstance(error: unknown): error is GatewayFailedDependencyError;
896
+ }
897
+
898
+ declare const symbol$5: unique symbol;
899
+ /**
900
+ * Forbidden - the request was rejected by policy (e.g. a routing rule),
901
+ * not an authentication failure.
902
+ */
903
+ declare class GatewayForbiddenError extends GatewayError {
904
+ private readonly [symbol$5];
905
+ readonly name = "GatewayForbiddenError";
906
+ readonly type = "forbidden";
907
+ constructor({ message, statusCode, cause, generationId, }?: {
908
+ message?: string;
909
+ statusCode?: number;
910
+ cause?: unknown;
911
+ generationId?: string;
912
+ });
913
+ static isInstance(error: unknown): error is GatewayForbiddenError;
914
+ }
915
+
511
916
  declare const symbol$4: unique symbol;
512
917
  /**
513
918
  * Internal server error from the Gateway
@@ -599,4 +1004,6 @@ declare class GatewayResponseError extends GatewayError {
599
1004
  static isInstance(error: unknown): error is GatewayResponseError;
600
1005
  }
601
1006
 
602
- export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayLanguageModelOptions, type GatewayLanguageModelSpecification, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayLanguageModelOptions as GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, GatewayResponseError, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
1007
+ declare const VERSION: string;
1008
+
1009
+ export { GATEWAY_AUTH_SUBPROTOCOL_PREFIX, GATEWAY_REALTIME_SUBPROTOCOL, GATEWAY_TEAM_SUBPROTOCOL_PREFIX, GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, GatewayFailedDependencyError, GatewayForbiddenError, type GatewayGenerationInfo, type GatewayGenerationInfoParams, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayProviderOptions as GatewayLanguageModelOptions, type GatewayLanguageModelSpecification, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, type GatewayRealtimeModelId, type GatewayRerankingModelId, GatewayResponseError, type GatewaySpeechModelId, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayTranscriptionModelId, type GatewayVideoModelId, VERSION, createGateway, createGateway as createGatewayProvider, gateway, getGatewayRealtimeAuthToken, getGatewayRealtimeProtocols, getGatewayRealtimeTeamIdOrSlug };