@ai-sdk/gateway 4.0.0-beta.39 → 4.0.0-beta.40

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,11 @@
1
1
  # @ai-sdk/gateway
2
2
 
3
+ ## 4.0.0-beta.40
4
+
5
+ ### Patch Changes
6
+
7
+ - 939171f: feat (provider/gateway): add reranking model support with `rerankingModel()` and `reranking()` methods
8
+
3
9
  ## 4.0.0-beta.39
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,9 +1,11 @@
1
- import { LanguageModelV4, ProviderV4, EmbeddingModelV4, ImageModelV4, Experimental_VideoModelV4, TypeValidationError } from '@ai-sdk/provider';
1
+ import { LanguageModelV4, ProviderV4, EmbeddingModelV4, ImageModelV4, Experimental_VideoModelV4, RerankingModelV4, 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
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' | 'alibaba/qwen3.6-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.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-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' | '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-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' | 'google/gemma-4-26b-a4b-it' | 'google/gemma-4-31b-it' | 'inception/mercury-2' | 'inception/mercury-coder-small' | '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' | '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-3-super-120b-a12b' | '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-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' | 'prime-intellect/intellect-3' | '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' | '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-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'xiaomi/mimo-v2-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
+ type GatewayRerankingModelId = 'cohere/rerank-v3.5' | (string & {});
8
+
7
9
  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 & {});
8
10
 
9
11
  interface GatewayLanguageModelEntry {
@@ -507,6 +509,14 @@ interface GatewayProvider extends ProviderV4 {
507
509
  * Creates a model for generating videos.
508
510
  */
509
511
  videoModel(modelId: GatewayVideoModelId): Experimental_VideoModelV4;
512
+ /**
513
+ * Creates a model for reranking documents.
514
+ */
515
+ reranking(modelId: GatewayRerankingModelId): RerankingModelV4;
516
+ /**
517
+ * Creates a model for reranking documents.
518
+ */
519
+ rerankingModel(modelId: GatewayRerankingModelId): RerankingModelV4;
510
520
  /**
511
521
  * Gateway-specific tools executed server-side.
512
522
  */
@@ -711,4 +721,4 @@ declare class GatewayResponseError extends GatewayError {
711
721
  static isInstance(error: unknown): error is GatewayResponseError;
712
722
  }
713
723
 
714
- export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, 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, GatewayResponseError, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
724
+ export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, 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 GatewayRerankingModelId, GatewayResponseError, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { LanguageModelV4, ProviderV4, EmbeddingModelV4, ImageModelV4, Experimental_VideoModelV4, TypeValidationError } from '@ai-sdk/provider';
1
+ import { LanguageModelV4, ProviderV4, EmbeddingModelV4, ImageModelV4, Experimental_VideoModelV4, RerankingModelV4, 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
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' | 'alibaba/qwen3.6-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.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-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' | '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-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' | 'google/gemma-4-26b-a4b-it' | 'google/gemma-4-31b-it' | 'inception/mercury-2' | 'inception/mercury-coder-small' | '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' | '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-3-super-120b-a12b' | '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-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' | 'prime-intellect/intellect-3' | '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' | '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-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'xiaomi/mimo-v2-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
+ type GatewayRerankingModelId = 'cohere/rerank-v3.5' | (string & {});
8
+
7
9
  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 & {});
8
10
 
9
11
  interface GatewayLanguageModelEntry {
@@ -507,6 +509,14 @@ interface GatewayProvider extends ProviderV4 {
507
509
  * Creates a model for generating videos.
508
510
  */
509
511
  videoModel(modelId: GatewayVideoModelId): Experimental_VideoModelV4;
512
+ /**
513
+ * Creates a model for reranking documents.
514
+ */
515
+ reranking(modelId: GatewayRerankingModelId): RerankingModelV4;
516
+ /**
517
+ * Creates a model for reranking documents.
518
+ */
519
+ rerankingModel(modelId: GatewayRerankingModelId): RerankingModelV4;
510
520
  /**
511
521
  * Gateway-specific tools executed server-side.
512
522
  */
@@ -711,4 +721,4 @@ declare class GatewayResponseError extends GatewayError {
711
721
  static isInstance(error: unknown): error is GatewayResponseError;
712
722
  }
713
723
 
714
- export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, 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, GatewayResponseError, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
724
+ export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, 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 GatewayRerankingModelId, GatewayResponseError, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ __export(index_exports, {
34
34
  module.exports = __toCommonJS(index_exports);
35
35
 
36
36
  // src/gateway-provider.ts
37
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
37
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
38
38
 
39
39
  // src/errors/as-gateway-error.ts
40
40
  var import_provider = require("@ai-sdk/provider");
@@ -1331,11 +1331,95 @@ var gatewayVideoEventSchema = import_v410.z.discriminatedUnion("type", [
1331
1331
  })
1332
1332
  ]);
1333
1333
 
1334
- // src/tool/parallel-search.ts
1334
+ // src/gateway-reranking-model.ts
1335
1335
  var import_provider_utils11 = require("@ai-sdk/provider-utils");
1336
- var import_zod = require("zod");
1337
- var parallelSearchInputSchema = (0, import_provider_utils11.lazySchema)(
1336
+ var import_v411 = require("zod/v4");
1337
+ var GatewayRerankingModel = class {
1338
+ constructor(modelId, config) {
1339
+ this.modelId = modelId;
1340
+ this.config = config;
1341
+ this.specificationVersion = "v4";
1342
+ }
1343
+ get provider() {
1344
+ return this.config.provider;
1345
+ }
1346
+ async doRerank({
1347
+ documents,
1348
+ query,
1349
+ topN,
1350
+ headers,
1351
+ abortSignal,
1352
+ providerOptions
1353
+ }) {
1354
+ const resolvedHeaders = await (0, import_provider_utils11.resolve)(this.config.headers());
1355
+ try {
1356
+ const {
1357
+ responseHeaders,
1358
+ value: responseBody,
1359
+ rawValue
1360
+ } = await (0, import_provider_utils11.postJsonToApi)({
1361
+ url: this.getUrl(),
1362
+ headers: (0, import_provider_utils11.combineHeaders)(
1363
+ resolvedHeaders,
1364
+ headers != null ? headers : {},
1365
+ this.getModelConfigHeaders(),
1366
+ await (0, import_provider_utils11.resolve)(this.config.o11yHeaders)
1367
+ ),
1368
+ body: {
1369
+ documents,
1370
+ query,
1371
+ ...topN != null ? { topN } : {},
1372
+ ...providerOptions ? { providerOptions } : {}
1373
+ },
1374
+ successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
1375
+ gatewayRerankingResponseSchema
1376
+ ),
1377
+ failedResponseHandler: (0, import_provider_utils11.createJsonErrorResponseHandler)({
1378
+ errorSchema: import_v411.z.any(),
1379
+ errorToMessage: (data) => data
1380
+ }),
1381
+ ...abortSignal && { abortSignal },
1382
+ fetch: this.config.fetch
1383
+ });
1384
+ return {
1385
+ ranking: responseBody.ranking,
1386
+ providerMetadata: responseBody.providerMetadata,
1387
+ response: { headers: responseHeaders, body: rawValue },
1388
+ warnings: []
1389
+ };
1390
+ } catch (error) {
1391
+ throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders));
1392
+ }
1393
+ }
1394
+ getUrl() {
1395
+ return `${this.config.baseURL}/reranking-model`;
1396
+ }
1397
+ getModelConfigHeaders() {
1398
+ return {
1399
+ "ai-reranking-model-specification-version": "4",
1400
+ "ai-model-id": this.modelId
1401
+ };
1402
+ }
1403
+ };
1404
+ var gatewayRerankingResponseSchema = (0, import_provider_utils11.lazySchema)(
1338
1405
  () => (0, import_provider_utils11.zodSchema)(
1406
+ import_v411.z.object({
1407
+ ranking: import_v411.z.array(
1408
+ import_v411.z.object({
1409
+ index: import_v411.z.number(),
1410
+ relevanceScore: import_v411.z.number()
1411
+ })
1412
+ ),
1413
+ providerMetadata: import_v411.z.record(import_v411.z.string(), import_v411.z.record(import_v411.z.string(), import_v411.z.unknown())).optional()
1414
+ })
1415
+ )
1416
+ );
1417
+
1418
+ // src/tool/parallel-search.ts
1419
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
1420
+ var import_zod = require("zod");
1421
+ var parallelSearchInputSchema = (0, import_provider_utils12.lazySchema)(
1422
+ () => (0, import_provider_utils12.zodSchema)(
1339
1423
  import_zod.z.object({
1340
1424
  objective: import_zod.z.string().describe(
1341
1425
  "Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
@@ -1370,8 +1454,8 @@ var parallelSearchInputSchema = (0, import_provider_utils11.lazySchema)(
1370
1454
  })
1371
1455
  )
1372
1456
  );
1373
- var parallelSearchOutputSchema = (0, import_provider_utils11.lazySchema)(
1374
- () => (0, import_provider_utils11.zodSchema)(
1457
+ var parallelSearchOutputSchema = (0, import_provider_utils12.lazySchema)(
1458
+ () => (0, import_provider_utils12.zodSchema)(
1375
1459
  import_zod.z.union([
1376
1460
  // Success response
1377
1461
  import_zod.z.object({
@@ -1402,7 +1486,7 @@ var parallelSearchOutputSchema = (0, import_provider_utils11.lazySchema)(
1402
1486
  ])
1403
1487
  )
1404
1488
  );
1405
- var parallelSearchToolFactory = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
1489
+ var parallelSearchToolFactory = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
1406
1490
  id: "gateway.parallel_search",
1407
1491
  inputSchema: parallelSearchInputSchema,
1408
1492
  outputSchema: parallelSearchOutputSchema
@@ -1410,10 +1494,10 @@ var parallelSearchToolFactory = (0, import_provider_utils11.createProviderToolFa
1410
1494
  var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
1411
1495
 
1412
1496
  // src/tool/perplexity-search.ts
1413
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
1497
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
1414
1498
  var import_zod2 = require("zod");
1415
- var perplexitySearchInputSchema = (0, import_provider_utils12.lazySchema)(
1416
- () => (0, import_provider_utils12.zodSchema)(
1499
+ var perplexitySearchInputSchema = (0, import_provider_utils13.lazySchema)(
1500
+ () => (0, import_provider_utils13.zodSchema)(
1417
1501
  import_zod2.z.object({
1418
1502
  query: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.array(import_zod2.z.string())]).describe(
1419
1503
  "Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
@@ -1454,8 +1538,8 @@ var perplexitySearchInputSchema = (0, import_provider_utils12.lazySchema)(
1454
1538
  })
1455
1539
  )
1456
1540
  );
1457
- var perplexitySearchOutputSchema = (0, import_provider_utils12.lazySchema)(
1458
- () => (0, import_provider_utils12.zodSchema)(
1541
+ var perplexitySearchOutputSchema = (0, import_provider_utils13.lazySchema)(
1542
+ () => (0, import_provider_utils13.zodSchema)(
1459
1543
  import_zod2.z.union([
1460
1544
  // Success response
1461
1545
  import_zod2.z.object({
@@ -1485,7 +1569,7 @@ var perplexitySearchOutputSchema = (0, import_provider_utils12.lazySchema)(
1485
1569
  ])
1486
1570
  )
1487
1571
  );
1488
- var perplexitySearchToolFactory = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
1572
+ var perplexitySearchToolFactory = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
1489
1573
  id: "gateway.perplexity_search",
1490
1574
  inputSchema: perplexitySearchInputSchema,
1491
1575
  outputSchema: perplexitySearchOutputSchema
@@ -1522,10 +1606,10 @@ async function getVercelRequestId() {
1522
1606
  }
1523
1607
 
1524
1608
  // src/gateway-provider.ts
1525
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
1609
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
1526
1610
 
1527
1611
  // src/version.ts
1528
- var VERSION = true ? "4.0.0-beta.39" : "0.0.0-test";
1612
+ var VERSION = true ? "4.0.0-beta.40" : "0.0.0-test";
1529
1613
 
1530
1614
  // src/gateway-provider.ts
1531
1615
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
@@ -1535,11 +1619,11 @@ function createGatewayProvider(options = {}) {
1535
1619
  let metadataCache = null;
1536
1620
  const cacheRefreshMillis = (_a9 = options.metadataCacheRefreshMillis) != null ? _a9 : 1e3 * 60 * 5;
1537
1621
  let lastFetchTime = 0;
1538
- const baseURL = (_b9 = (0, import_provider_utils13.withoutTrailingSlash)(options.baseURL)) != null ? _b9 : "https://ai-gateway.vercel.sh/v3/ai";
1622
+ const baseURL = (_b9 = (0, import_provider_utils14.withoutTrailingSlash)(options.baseURL)) != null ? _b9 : "https://ai-gateway.vercel.sh/v3/ai";
1539
1623
  const getHeaders = async () => {
1540
1624
  try {
1541
1625
  const auth = await getGatewayAuthToken(options);
1542
- return (0, import_provider_utils14.withUserAgentSuffix)(
1626
+ return (0, import_provider_utils15.withUserAgentSuffix)(
1543
1627
  {
1544
1628
  Authorization: `Bearer ${auth.token}`,
1545
1629
  "ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
@@ -1558,19 +1642,19 @@ function createGatewayProvider(options = {}) {
1558
1642
  }
1559
1643
  };
1560
1644
  const createO11yHeaders = () => {
1561
- const deploymentId = (0, import_provider_utils13.loadOptionalSetting)({
1645
+ const deploymentId = (0, import_provider_utils14.loadOptionalSetting)({
1562
1646
  settingValue: void 0,
1563
1647
  environmentVariableName: "VERCEL_DEPLOYMENT_ID"
1564
1648
  });
1565
- const environment = (0, import_provider_utils13.loadOptionalSetting)({
1649
+ const environment = (0, import_provider_utils14.loadOptionalSetting)({
1566
1650
  settingValue: void 0,
1567
1651
  environmentVariableName: "VERCEL_ENV"
1568
1652
  });
1569
- const region = (0, import_provider_utils13.loadOptionalSetting)({
1653
+ const region = (0, import_provider_utils14.loadOptionalSetting)({
1570
1654
  settingValue: void 0,
1571
1655
  environmentVariableName: "VERCEL_REGION"
1572
1656
  });
1573
- const projectId = (0, import_provider_utils13.loadOptionalSetting)({
1657
+ const projectId = (0, import_provider_utils14.loadOptionalSetting)({
1574
1658
  settingValue: void 0,
1575
1659
  environmentVariableName: "VERCEL_PROJECT_ID"
1576
1660
  });
@@ -1694,6 +1778,17 @@ function createGatewayProvider(options = {}) {
1694
1778
  o11yHeaders: createO11yHeaders()
1695
1779
  });
1696
1780
  };
1781
+ const createRerankingModel = (modelId) => {
1782
+ return new GatewayRerankingModel(modelId, {
1783
+ provider: "gateway",
1784
+ baseURL,
1785
+ headers: getHeaders,
1786
+ fetch: options.fetch,
1787
+ o11yHeaders: createO11yHeaders()
1788
+ });
1789
+ };
1790
+ provider.rerankingModel = createRerankingModel;
1791
+ provider.reranking = createRerankingModel;
1697
1792
  provider.chat = provider.languageModel;
1698
1793
  provider.embedding = provider.embeddingModel;
1699
1794
  provider.image = provider.imageModel;
@@ -1703,7 +1798,7 @@ function createGatewayProvider(options = {}) {
1703
1798
  }
1704
1799
  var gateway = createGatewayProvider();
1705
1800
  async function getGatewayAuthToken(options) {
1706
- const apiKey = (0, import_provider_utils13.loadOptionalSetting)({
1801
+ const apiKey = (0, import_provider_utils14.loadOptionalSetting)({
1707
1802
  settingValue: options.apiKey,
1708
1803
  environmentVariableName: "AI_GATEWAY_API_KEY"
1709
1804
  });