@ai-sdk/gateway 4.0.0-canary.104 → 4.0.0-canary.106

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/gateway
2
2
 
3
+ ## 4.0.0-canary.106
4
+
5
+ ### Patch Changes
6
+
7
+ - ca2cf45: fix(provider/gateway): map `forbidden` error responses to GatewayForbiddenError instead of GatewayInternalServerError
8
+
9
+ ## 4.0.0-canary.105
10
+
11
+ ### Patch Changes
12
+
13
+ - efec111: chore(provider/gateway): update gateway model settings files
14
+
3
15
  ## 4.0.0-canary.104
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { LanguageModelV4, ProviderV4, EmbeddingModelV4, ImageModelV4, Experiment
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/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-fable-5' | '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-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'moonshotai/kimi-k2.5' | 'moonshotai/kimi-k2.6' | '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-5v-turbo' | (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-fable-5' | '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' | '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-5v-turbo' | (string & {});
6
6
 
7
7
  /**
8
8
  * Shared WebSocket subprotocol contract for AI Gateway realtime auth.
@@ -677,9 +677,9 @@ type GatewayProviderOptions = {
677
677
  zeroDataRetention?: boolean;
678
678
  };
679
679
 
680
- declare const symbol$7: unique symbol;
680
+ declare const symbol$8: unique symbol;
681
681
  declare abstract class GatewayError extends Error {
682
- private readonly [symbol$7];
682
+ private readonly [symbol$8];
683
683
  abstract readonly name: string;
684
684
  abstract readonly type: string;
685
685
  readonly statusCode: number;
@@ -713,12 +713,12 @@ declare const gatewayErrorResponseSchema: _ai_sdk_provider_utils.LazySchema<{
713
713
  }>;
714
714
  type GatewayErrorResponse = InferSchema<typeof gatewayErrorResponseSchema>;
715
715
 
716
- declare const symbol$6: unique symbol;
716
+ declare const symbol$7: unique symbol;
717
717
  /**
718
718
  * Authentication failed - invalid API key or OIDC token
719
719
  */
720
720
  declare class GatewayAuthenticationError extends GatewayError {
721
- private readonly [symbol$6];
721
+ private readonly [symbol$7];
722
722
  readonly name = "GatewayAuthenticationError";
723
723
  readonly type = "authentication_error";
724
724
  constructor({ message, statusCode, cause, generationId, }?: {
@@ -741,14 +741,14 @@ declare class GatewayAuthenticationError extends GatewayError {
741
741
  }): GatewayAuthenticationError;
742
742
  }
743
743
 
744
- declare const symbol$5: unique symbol;
744
+ declare const symbol$6: unique symbol;
745
745
  /**
746
746
  * The request could not be fulfilled because a dependency it relied on was not
747
747
  * available on the credentials or provider used to serve it (HTTP 424). Not
748
748
  * retryable — the caller must change the request.
749
749
  */
750
750
  declare class GatewayFailedDependencyError extends GatewayError {
751
- private readonly [symbol$5];
751
+ private readonly [symbol$6];
752
752
  readonly name = "GatewayFailedDependencyError";
753
753
  readonly type = "failed_dependency";
754
754
  constructor({ message, statusCode, cause, generationId, }?: {
@@ -760,6 +760,24 @@ declare class GatewayFailedDependencyError extends GatewayError {
760
760
  static isInstance(error: unknown): error is GatewayFailedDependencyError;
761
761
  }
762
762
 
763
+ declare const symbol$5: unique symbol;
764
+ /**
765
+ * Forbidden - the request was rejected by policy (e.g. a routing rule),
766
+ * not an authentication failure.
767
+ */
768
+ declare class GatewayForbiddenError extends GatewayError {
769
+ private readonly [symbol$5];
770
+ readonly name = "GatewayForbiddenError";
771
+ readonly type = "forbidden";
772
+ constructor({ message, statusCode, cause, generationId, }?: {
773
+ message?: string;
774
+ statusCode?: number;
775
+ cause?: unknown;
776
+ generationId?: string;
777
+ });
778
+ static isInstance(error: unknown): error is GatewayForbiddenError;
779
+ }
780
+
763
781
  declare const symbol$4: unique symbol;
764
782
  /**
765
783
  * Internal server error from the Gateway
@@ -853,4 +871,4 @@ declare class GatewayResponseError extends GatewayError {
853
871
 
854
872
  declare const VERSION: string;
855
873
 
856
- export { GATEWAY_AUTH_SUBPROTOCOL_PREFIX, GATEWAY_REALTIME_SUBPROTOCOL, GATEWAY_TEAM_SUBPROTOCOL_PREFIX, GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, GatewayFailedDependencyError, 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 };
874
+ 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 };
package/dist/index.js CHANGED
@@ -15,17 +15,17 @@ function getGatewayRealtimeProtocols(token, options) {
15
15
  return protocols;
16
16
  }
17
17
  function getGatewayRealtimeAuthToken(secWebSocketProtocol) {
18
- var _a10;
19
- return ((_a10 = findProtocol(secWebSocketProtocol, GATEWAY_AUTH_SUBPROTOCOL_PREFIX)) == null ? void 0 : _a10.slice(
18
+ var _a11;
19
+ return ((_a11 = findProtocol(secWebSocketProtocol, GATEWAY_AUTH_SUBPROTOCOL_PREFIX)) == null ? void 0 : _a11.slice(
20
20
  GATEWAY_AUTH_SUBPROTOCOL_PREFIX.length
21
21
  )) || void 0;
22
22
  }
23
23
  function getGatewayRealtimeTeamIdOrSlug(secWebSocketProtocol) {
24
- var _a10;
25
- const encoded = (_a10 = findProtocol(
24
+ var _a11;
25
+ const encoded = (_a11 = findProtocol(
26
26
  secWebSocketProtocol,
27
27
  GATEWAY_TEAM_SUBPROTOCOL_PREFIX
28
- )) == null ? void 0 : _a10.slice(GATEWAY_TEAM_SUBPROTOCOL_PREFIX.length);
28
+ )) == null ? void 0 : _a11.slice(GATEWAY_TEAM_SUBPROTOCOL_PREFIX.length);
29
29
  if (!encoded) return void 0;
30
30
  try {
31
31
  return decodeSubprotocolValue(encoded) || void 0;
@@ -294,12 +294,35 @@ var GatewayFailedDependencyError = class extends (_b7 = GatewayError, _a7 = symb
294
294
  }
295
295
  };
296
296
 
297
- // src/errors/gateway-response-error.ts
298
- var name7 = "GatewayResponseError";
297
+ // src/errors/gateway-forbidden-error.ts
298
+ var name7 = "GatewayForbiddenError";
299
299
  var marker8 = `vercel.ai.gateway.error.${name7}`;
300
300
  var symbol8 = Symbol.for(marker8);
301
301
  var _a8, _b8;
302
- var GatewayResponseError = class extends (_b8 = GatewayError, _a8 = symbol8, _b8) {
302
+ var GatewayForbiddenError = class extends (_b8 = GatewayError, _a8 = symbol8, _b8) {
303
+ constructor({
304
+ message = "Forbidden",
305
+ statusCode = 403,
306
+ cause,
307
+ generationId
308
+ } = {}) {
309
+ super({ message, statusCode, cause, generationId });
310
+ this[_a8] = true;
311
+ // used in isInstance
312
+ this.name = name7;
313
+ this.type = "forbidden";
314
+ }
315
+ static isInstance(error) {
316
+ return GatewayError.hasMarker(error) && symbol8 in error;
317
+ }
318
+ };
319
+
320
+ // src/errors/gateway-response-error.ts
321
+ var name8 = "GatewayResponseError";
322
+ var marker9 = `vercel.ai.gateway.error.${name8}`;
323
+ var symbol9 = Symbol.for(marker9);
324
+ var _a9, _b9;
325
+ var GatewayResponseError = class extends (_b9 = GatewayError, _a9 = symbol9, _b9) {
303
326
  constructor({
304
327
  message = "Invalid response from Gateway",
305
328
  statusCode = 502,
@@ -309,15 +332,15 @@ var GatewayResponseError = class extends (_b8 = GatewayError, _a8 = symbol8, _b8
309
332
  generationId
310
333
  } = {}) {
311
334
  super({ message, statusCode, cause, generationId });
312
- this[_a8] = true;
335
+ this[_a9] = true;
313
336
  // used in isInstance
314
- this.name = name7;
337
+ this.name = name8;
315
338
  this.type = "response_error";
316
339
  this.response = response;
317
340
  this.validationError = validationError;
318
341
  }
319
342
  static isInstance(error) {
320
- return GatewayError.hasMarker(error) && symbol8 in error;
343
+ return GatewayError.hasMarker(error) && symbol9 in error;
321
344
  }
322
345
  };
323
346
 
@@ -334,7 +357,7 @@ async function createGatewayErrorFromResponse({
334
357
  cause,
335
358
  authMethod
336
359
  }) {
337
- var _a10;
360
+ var _a11;
338
361
  const parseResult = await safeValidateTypes({
339
362
  value: response,
340
363
  schema: gatewayErrorResponseSchema
@@ -353,7 +376,7 @@ async function createGatewayErrorFromResponse({
353
376
  const validatedResponse = parseResult.value;
354
377
  const errorType = validatedResponse.error.type;
355
378
  const message = validatedResponse.error.message;
356
- const generationId = (_a10 = validatedResponse.generationId) != null ? _a10 : void 0;
379
+ const generationId = (_a11 = validatedResponse.generationId) != null ? _a11 : void 0;
357
380
  switch (errorType) {
358
381
  case "authentication_error":
359
382
  return GatewayAuthenticationError.createContextualError({
@@ -404,6 +427,13 @@ async function createGatewayErrorFromResponse({
404
427
  cause,
405
428
  generationId
406
429
  });
430
+ case "forbidden":
431
+ return new GatewayForbiddenError({
432
+ message,
433
+ statusCode,
434
+ cause,
435
+ generationId
436
+ });
407
437
  default:
408
438
  return new GatewayInternalServerError({
409
439
  message,
@@ -443,11 +473,11 @@ function extractApiCallResponse(error) {
443
473
  }
444
474
 
445
475
  // src/errors/gateway-timeout-error.ts
446
- var name8 = "GatewayTimeoutError";
447
- var marker9 = `vercel.ai.gateway.error.${name8}`;
448
- var symbol9 = Symbol.for(marker9);
449
- var _a9, _b9;
450
- var GatewayTimeoutError = class _GatewayTimeoutError extends (_b9 = GatewayError, _a9 = symbol9, _b9) {
476
+ var name9 = "GatewayTimeoutError";
477
+ var marker10 = `vercel.ai.gateway.error.${name9}`;
478
+ var symbol10 = Symbol.for(marker10);
479
+ var _a10, _b10;
480
+ var GatewayTimeoutError = class _GatewayTimeoutError extends (_b10 = GatewayError, _a10 = symbol10, _b10) {
451
481
  constructor({
452
482
  message = "Request timed out",
453
483
  statusCode = 408,
@@ -455,13 +485,13 @@ var GatewayTimeoutError = class _GatewayTimeoutError extends (_b9 = GatewayError
455
485
  generationId
456
486
  } = {}) {
457
487
  super({ message, statusCode, cause, generationId });
458
- this[_a9] = true;
488
+ this[_a10] = true;
459
489
  // used in isInstance
460
- this.name = name8;
490
+ this.name = name9;
461
491
  this.type = "timeout_error";
462
492
  }
463
493
  static isInstance(error) {
464
- return GatewayError.hasMarker(error) && symbol9 in error;
494
+ return GatewayError.hasMarker(error) && symbol10 in error;
465
495
  }
466
496
  /**
467
497
  * Creates a helpful timeout error message with troubleshooting guidance
@@ -501,7 +531,7 @@ function isTimeoutError(error) {
501
531
  return false;
502
532
  }
503
533
  async function asGatewayError(error, authMethod) {
504
- var _a10;
534
+ var _a11;
505
535
  if (GatewayError.isInstance(error)) {
506
536
  return error;
507
537
  }
@@ -520,7 +550,7 @@ async function asGatewayError(error, authMethod) {
520
550
  }
521
551
  return await createGatewayErrorFromResponse({
522
552
  response: extractApiCallResponse(error),
523
- statusCode: (_a10 = error.statusCode) != null ? _a10 : 500,
553
+ statusCode: (_a11 = error.statusCode) != null ? _a11 : 500,
524
554
  defaultMessage: "Gateway request failed",
525
555
  cause: error,
526
556
  authMethod
@@ -1096,7 +1126,7 @@ var GatewayEmbeddingModel = class _GatewayEmbeddingModel {
1096
1126
  abortSignal,
1097
1127
  providerOptions
1098
1128
  }) {
1099
- var _a10, _b10;
1129
+ var _a11, _b11;
1100
1130
  const resolvedHeaders = this.config.headers ? await resolve5(this.config.headers) : void 0;
1101
1131
  try {
1102
1132
  const {
@@ -1127,10 +1157,10 @@ var GatewayEmbeddingModel = class _GatewayEmbeddingModel {
1127
1157
  });
1128
1158
  return {
1129
1159
  embeddings: responseBody.embeddings,
1130
- usage: (_a10 = responseBody.usage) != null ? _a10 : void 0,
1160
+ usage: (_a11 = responseBody.usage) != null ? _a11 : void 0,
1131
1161
  providerMetadata: responseBody.providerMetadata,
1132
1162
  response: { headers: responseHeaders, body: rawValue },
1133
- warnings: (_b10 = responseBody.warnings) != null ? _b10 : []
1163
+ warnings: (_b11 = responseBody.warnings) != null ? _b11 : []
1134
1164
  };
1135
1165
  } catch (error) {
1136
1166
  throw await asGatewayError(
@@ -1226,7 +1256,7 @@ var GatewayImageModel = class _GatewayImageModel {
1226
1256
  headers,
1227
1257
  abortSignal
1228
1258
  }) {
1229
- var _a10, _b10, _c, _d;
1259
+ var _a11, _b11, _c, _d;
1230
1260
  const resolvedHeaders = this.config.headers ? await resolve6(this.config.headers) : void 0;
1231
1261
  try {
1232
1262
  const { responseHeaders, value: responseBody } = await postJsonToApi3({
@@ -1262,7 +1292,7 @@ var GatewayImageModel = class _GatewayImageModel {
1262
1292
  return {
1263
1293
  images: responseBody.images,
1264
1294
  // Always base64 strings from server
1265
- warnings: (_a10 = responseBody.warnings) != null ? _a10 : [],
1295
+ warnings: (_a11 = responseBody.warnings) != null ? _a11 : [],
1266
1296
  providerMetadata: responseBody.providerMetadata,
1267
1297
  response: {
1268
1298
  timestamp: /* @__PURE__ */ new Date(),
@@ -1271,7 +1301,7 @@ var GatewayImageModel = class _GatewayImageModel {
1271
1301
  },
1272
1302
  ...responseBody.usage != null && {
1273
1303
  usage: {
1274
- inputTokens: (_b10 = responseBody.usage.inputTokens) != null ? _b10 : void 0,
1304
+ inputTokens: (_b11 = responseBody.usage.inputTokens) != null ? _b11 : void 0,
1275
1305
  outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
1276
1306
  totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
1277
1307
  }
@@ -1377,7 +1407,7 @@ var GatewayVideoModel = class {
1377
1407
  headers,
1378
1408
  abortSignal
1379
1409
  }) {
1380
- var _a10;
1410
+ var _a11;
1381
1411
  const resolvedHeaders = this.config.headers ? await resolve7(this.config.headers) : void 0;
1382
1412
  try {
1383
1413
  const { responseHeaders, value: responseBody } = await postJsonToApi4({
@@ -1473,7 +1503,7 @@ var GatewayVideoModel = class {
1473
1503
  });
1474
1504
  return {
1475
1505
  videos: responseBody.videos,
1476
- warnings: (_a10 = responseBody.warnings) != null ? _a10 : [],
1506
+ warnings: (_a11 = responseBody.warnings) != null ? _a11 : [],
1477
1507
  providerMetadata: responseBody.providerMetadata,
1478
1508
  response: {
1479
1509
  timestamp: /* @__PURE__ */ new Date(),
@@ -1587,7 +1617,7 @@ var GatewayRerankingModel = class {
1587
1617
  abortSignal,
1588
1618
  providerOptions
1589
1619
  }) {
1590
- var _a10;
1620
+ var _a11;
1591
1621
  const resolvedHeaders = this.config.headers ? await resolve8(this.config.headers) : void 0;
1592
1622
  try {
1593
1623
  const {
@@ -1622,7 +1652,7 @@ var GatewayRerankingModel = class {
1622
1652
  ranking: responseBody.ranking,
1623
1653
  providerMetadata: responseBody.providerMetadata,
1624
1654
  response: { headers: responseHeaders, body: rawValue },
1625
- warnings: (_a10 = responseBody.warnings) != null ? _a10 : []
1655
+ warnings: (_a11 = responseBody.warnings) != null ? _a11 : []
1626
1656
  };
1627
1657
  } catch (error) {
1628
1658
  throw await asGatewayError(
@@ -1706,7 +1736,7 @@ var GatewaySpeechModel = class {
1706
1736
  headers,
1707
1737
  abortSignal
1708
1738
  }) {
1709
- var _a10;
1739
+ var _a11;
1710
1740
  const resolvedHeaders = this.config.headers ? await resolve9(this.config.headers) : void 0;
1711
1741
  try {
1712
1742
  const {
@@ -1742,7 +1772,7 @@ var GatewaySpeechModel = class {
1742
1772
  });
1743
1773
  return {
1744
1774
  audio: responseBody.audio,
1745
- warnings: (_a10 = responseBody.warnings) != null ? _a10 : [],
1775
+ warnings: (_a11 = responseBody.warnings) != null ? _a11 : [],
1746
1776
  providerMetadata: responseBody.providerMetadata,
1747
1777
  response: {
1748
1778
  timestamp: /* @__PURE__ */ new Date(),
@@ -1822,7 +1852,7 @@ var GatewayTranscriptionModel = class {
1822
1852
  headers,
1823
1853
  abortSignal
1824
1854
  }) {
1825
- var _a10, _b10, _c, _d;
1855
+ var _a11, _b11, _c, _d;
1826
1856
  const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : void 0;
1827
1857
  try {
1828
1858
  const {
@@ -1854,8 +1884,8 @@ var GatewayTranscriptionModel = class {
1854
1884
  });
1855
1885
  return {
1856
1886
  text: responseBody.text,
1857
- segments: (_a10 = responseBody.segments) != null ? _a10 : [],
1858
- language: (_b10 = responseBody.language) != null ? _b10 : void 0,
1887
+ segments: (_a11 = responseBody.segments) != null ? _a11 : [],
1888
+ language: (_b11 = responseBody.language) != null ? _b11 : void 0,
1859
1889
  durationInSeconds: (_c = responseBody.durationInSeconds) != null ? _c : void 0,
1860
1890
  warnings: (_d = responseBody.warnings) != null ? _d : [],
1861
1891
  providerMetadata: responseBody.providerMetadata,
@@ -2163,22 +2193,22 @@ var gatewayTools = {
2163
2193
  import { getContext } from "@vercel/oidc";
2164
2194
  import { getVercelOidcToken } from "@vercel/oidc";
2165
2195
  async function getVercelRequestId() {
2166
- var _a10;
2167
- return (_a10 = getContext().headers) == null ? void 0 : _a10["x-vercel-id"];
2196
+ var _a11;
2197
+ return (_a11 = getContext().headers) == null ? void 0 : _a11["x-vercel-id"];
2168
2198
  }
2169
2199
 
2170
2200
  // src/version.ts
2171
- var VERSION = true ? "4.0.0-canary.104" : "0.0.0-test";
2201
+ var VERSION = true ? "4.0.0-canary.106" : "0.0.0-test";
2172
2202
 
2173
2203
  // src/gateway-provider.ts
2174
2204
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
2175
2205
  function createGateway(options = {}) {
2176
- var _a10, _b10;
2206
+ var _a11, _b11;
2177
2207
  let pendingMetadata = null;
2178
2208
  let metadataCache = null;
2179
- const cacheRefreshMillis = (_a10 = options.metadataCacheRefreshMillis) != null ? _a10 : 1e3 * 60 * 5;
2209
+ const cacheRefreshMillis = (_a11 = options.metadataCacheRefreshMillis) != null ? _a11 : 1e3 * 60 * 5;
2180
2210
  let lastFetchTime = 0;
2181
- const baseURL = (_b10 = withoutTrailingSlash(options.baseURL)) != null ? _b10 : "https://ai-gateway.vercel.sh/v4/ai";
2211
+ const baseURL = (_b11 = withoutTrailingSlash(options.baseURL)) != null ? _b11 : "https://ai-gateway.vercel.sh/v4/ai";
2182
2212
  const createAuthHeaders = (auth) => withUserAgentSuffix(
2183
2213
  {
2184
2214
  Authorization: `Bearer ${auth.token}`,
@@ -2251,8 +2281,8 @@ function createGateway(options = {}) {
2251
2281
  });
2252
2282
  };
2253
2283
  const getAvailableModels = async () => {
2254
- var _a11, _b11, _c;
2255
- const now = (_c = (_b11 = (_a11 = options._internal) == null ? void 0 : _a11.currentDate) == null ? void 0 : _b11.call(_a11).getTime()) != null ? _c : Date.now();
2284
+ var _a12, _b12, _c;
2285
+ const now = (_c = (_b12 = (_a12 = options._internal) == null ? void 0 : _a12.currentDate) == null ? void 0 : _b12.call(_a12).getTime()) != null ? _c : Date.now();
2256
2286
  if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
2257
2287
  lastFetchTime = now;
2258
2288
  pendingMetadata = new GatewayFetchMetadata({
@@ -2445,6 +2475,7 @@ export {
2445
2475
  GatewayAuthenticationError,
2446
2476
  GatewayError,
2447
2477
  GatewayFailedDependencyError,
2478
+ GatewayForbiddenError,
2448
2479
  GatewayInternalServerError,
2449
2480
  GatewayInvalidRequestError,
2450
2481
  GatewayModelNotFoundError,