@ai-sdk/gateway 3.0.135 → 3.0.137
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 +16 -0
- package/dist/index.d.mts +25 -5
- package/dist/index.d.ts +25 -5
- package/dist/index.js +272 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +320 -59
- package/dist/index.mjs.map +1 -1
- package/docs/00-ai-gateway.mdx +34 -0
- package/package.json +1 -1
- package/src/gateway-language-model-settings.ts +1 -0
- package/src/gateway-model-entry.ts +2 -0
- package/src/gateway-provider.ts +50 -0
- package/src/gateway-speech-model-settings.ts +5 -0
- package/src/gateway-speech-model.ts +138 -0
- package/src/gateway-transcription-model-settings.ts +6 -0
- package/src/gateway-transcription-model.ts +148 -0
- package/src/gateway-video-model-settings.ts +1 -0
- package/src/index.ts +2 -0
- package/src/tool/parallel-search.ts +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/gateway
|
|
2
2
|
|
|
3
|
+
## 3.0.137
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 932c680: Clarify `parallel_search` `source_policy` field descriptions so the model emits
|
|
8
|
+
values the Parallel API accepts: `include_domains`/`exclude_domains` must be plain
|
|
9
|
+
hosts (no scheme/path/port), and `after_date` must be an ISO 8601 calendar date
|
|
10
|
+
formatted `YYYY-MM-DD`.
|
|
11
|
+
|
|
12
|
+
## 3.0.136
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 6ce12b0: Add Gateway speech and transcription model support.
|
|
17
|
+
- 4cb4414: Backport: chore(provider/gateway): update gateway model settings files
|
|
18
|
+
|
|
3
19
|
## 3.0.135
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, Experimental_VideoModelV3, RerankingModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
1
|
+
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, Experimental_VideoModelV3, RerankingModelV3, SpeechModelV3, TranscriptionModelV3, 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/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' | 'sakana/fugu-ultra' | '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 & {});
|
|
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' | 'sakana/fugu-ultra' | '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-5.2-fast' | 'zai/glm-5v-turbo' | (string & {});
|
|
6
6
|
|
|
7
7
|
type GatewayRerankingModelId = 'cohere/rerank-v3.5' | 'cohere/rerank-v4-fast' | 'cohere/rerank-v4-pro' | 'voyage/rerank-2.5' | 'voyage/rerank-2.5-lite' | (string & {});
|
|
8
8
|
|
|
9
|
-
type
|
|
9
|
+
type GatewaySpeechModelId = 'openai/tts-1' | 'openai/tts-1-hd' | 'xai/grok-tts' | (string & {});
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
type GatewayTranscriptionModelId = 'openai/gpt-4o-mini-transcribe' | 'openai/gpt-4o-transcribe' | 'openai/whisper-1' | 'xai/grok-stt' | (string & {});
|
|
12
|
+
|
|
13
|
+
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-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' | 'xai/grok-imagine-video-1.5-preview' | (string & {});
|
|
14
|
+
|
|
15
|
+
declare const KNOWN_MODEL_TYPES: readonly ["embedding", "image", "language", "reranking", "speech", "transcription", "video"];
|
|
12
16
|
type KnownModelType = (typeof KNOWN_MODEL_TYPES)[number];
|
|
13
17
|
interface GatewayLanguageModelEntry {
|
|
14
18
|
/**
|
|
@@ -519,6 +523,22 @@ interface GatewayProvider extends ProviderV3 {
|
|
|
519
523
|
* Creates a model for reranking documents.
|
|
520
524
|
*/
|
|
521
525
|
rerankingModel(modelId: GatewayRerankingModelId): RerankingModelV3;
|
|
526
|
+
/**
|
|
527
|
+
* Creates a model for text-to-speech generation.
|
|
528
|
+
*/
|
|
529
|
+
speech(modelId: GatewaySpeechModelId): SpeechModelV3;
|
|
530
|
+
/**
|
|
531
|
+
* Creates a model for text-to-speech generation.
|
|
532
|
+
*/
|
|
533
|
+
speechModel(modelId: GatewaySpeechModelId): SpeechModelV3;
|
|
534
|
+
/**
|
|
535
|
+
* Creates a model for audio transcription.
|
|
536
|
+
*/
|
|
537
|
+
transcription(modelId: GatewayTranscriptionModelId): TranscriptionModelV3;
|
|
538
|
+
/**
|
|
539
|
+
* Creates a model for audio transcription.
|
|
540
|
+
*/
|
|
541
|
+
transcriptionModel(modelId: GatewayTranscriptionModelId): TranscriptionModelV3;
|
|
522
542
|
/**
|
|
523
543
|
* Gateway-specific tools executed server-side.
|
|
524
544
|
*/
|
|
@@ -764,4 +784,4 @@ declare class GatewayResponseError extends GatewayError {
|
|
|
764
784
|
static isInstance(error: unknown): error is GatewayResponseError;
|
|
765
785
|
}
|
|
766
786
|
|
|
767
|
-
export { 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 GatewayRerankingModelId, GatewayResponseError, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
|
|
787
|
+
export { 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 GatewayRerankingModelId, GatewayResponseError, type GatewaySpeechModelId, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayTranscriptionModelId, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, Experimental_VideoModelV3, RerankingModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
1
|
+
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, Experimental_VideoModelV3, RerankingModelV3, SpeechModelV3, TranscriptionModelV3, 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/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' | 'sakana/fugu-ultra' | '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 & {});
|
|
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' | 'sakana/fugu-ultra' | '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-5.2-fast' | 'zai/glm-5v-turbo' | (string & {});
|
|
6
6
|
|
|
7
7
|
type GatewayRerankingModelId = 'cohere/rerank-v3.5' | 'cohere/rerank-v4-fast' | 'cohere/rerank-v4-pro' | 'voyage/rerank-2.5' | 'voyage/rerank-2.5-lite' | (string & {});
|
|
8
8
|
|
|
9
|
-
type
|
|
9
|
+
type GatewaySpeechModelId = 'openai/tts-1' | 'openai/tts-1-hd' | 'xai/grok-tts' | (string & {});
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
type GatewayTranscriptionModelId = 'openai/gpt-4o-mini-transcribe' | 'openai/gpt-4o-transcribe' | 'openai/whisper-1' | 'xai/grok-stt' | (string & {});
|
|
12
|
+
|
|
13
|
+
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-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' | 'xai/grok-imagine-video-1.5-preview' | (string & {});
|
|
14
|
+
|
|
15
|
+
declare const KNOWN_MODEL_TYPES: readonly ["embedding", "image", "language", "reranking", "speech", "transcription", "video"];
|
|
12
16
|
type KnownModelType = (typeof KNOWN_MODEL_TYPES)[number];
|
|
13
17
|
interface GatewayLanguageModelEntry {
|
|
14
18
|
/**
|
|
@@ -519,6 +523,22 @@ interface GatewayProvider extends ProviderV3 {
|
|
|
519
523
|
* Creates a model for reranking documents.
|
|
520
524
|
*/
|
|
521
525
|
rerankingModel(modelId: GatewayRerankingModelId): RerankingModelV3;
|
|
526
|
+
/**
|
|
527
|
+
* Creates a model for text-to-speech generation.
|
|
528
|
+
*/
|
|
529
|
+
speech(modelId: GatewaySpeechModelId): SpeechModelV3;
|
|
530
|
+
/**
|
|
531
|
+
* Creates a model for text-to-speech generation.
|
|
532
|
+
*/
|
|
533
|
+
speechModel(modelId: GatewaySpeechModelId): SpeechModelV3;
|
|
534
|
+
/**
|
|
535
|
+
* Creates a model for audio transcription.
|
|
536
|
+
*/
|
|
537
|
+
transcription(modelId: GatewayTranscriptionModelId): TranscriptionModelV3;
|
|
538
|
+
/**
|
|
539
|
+
* Creates a model for audio transcription.
|
|
540
|
+
*/
|
|
541
|
+
transcriptionModel(modelId: GatewayTranscriptionModelId): TranscriptionModelV3;
|
|
522
542
|
/**
|
|
523
543
|
* Gateway-specific tools executed server-side.
|
|
524
544
|
*/
|
|
@@ -764,4 +784,4 @@ declare class GatewayResponseError extends GatewayError {
|
|
|
764
784
|
static isInstance(error: unknown): error is GatewayResponseError;
|
|
765
785
|
}
|
|
766
786
|
|
|
767
|
-
export { 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 GatewayRerankingModelId, GatewayResponseError, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
|
|
787
|
+
export { 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 GatewayRerankingModelId, GatewayResponseError, type GatewaySpeechModelId, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayTranscriptionModelId, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/gateway-provider.ts
|
|
39
|
-
var
|
|
39
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
40
40
|
|
|
41
41
|
// src/errors/as-gateway-error.ts
|
|
42
42
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -562,6 +562,8 @@ var KNOWN_MODEL_TYPES = [
|
|
|
562
562
|
"image",
|
|
563
563
|
"language",
|
|
564
564
|
"reranking",
|
|
565
|
+
"speech",
|
|
566
|
+
"transcription",
|
|
565
567
|
"video"
|
|
566
568
|
];
|
|
567
569
|
|
|
@@ -1533,11 +1535,231 @@ var gatewayRerankingResponseSchema = (0, import_provider_utils11.lazySchema)(
|
|
|
1533
1535
|
)
|
|
1534
1536
|
);
|
|
1535
1537
|
|
|
1536
|
-
// src/
|
|
1538
|
+
// src/gateway-speech-model.ts
|
|
1537
1539
|
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1540
|
+
var import_v412 = require("zod/v4");
|
|
1541
|
+
var GatewaySpeechModel = class {
|
|
1542
|
+
constructor(modelId, config) {
|
|
1543
|
+
this.modelId = modelId;
|
|
1544
|
+
this.config = config;
|
|
1545
|
+
this.specificationVersion = "v3";
|
|
1546
|
+
}
|
|
1547
|
+
get provider() {
|
|
1548
|
+
return this.config.provider;
|
|
1549
|
+
}
|
|
1550
|
+
async doGenerate({
|
|
1551
|
+
text,
|
|
1552
|
+
voice,
|
|
1553
|
+
outputFormat,
|
|
1554
|
+
instructions,
|
|
1555
|
+
speed,
|
|
1556
|
+
language,
|
|
1557
|
+
providerOptions,
|
|
1558
|
+
headers,
|
|
1559
|
+
abortSignal
|
|
1560
|
+
}) {
|
|
1561
|
+
var _a11;
|
|
1562
|
+
const resolvedHeaders = await (0, import_provider_utils12.resolve)(this.config.headers());
|
|
1563
|
+
try {
|
|
1564
|
+
const {
|
|
1565
|
+
responseHeaders,
|
|
1566
|
+
value: responseBody,
|
|
1567
|
+
rawValue
|
|
1568
|
+
} = await (0, import_provider_utils12.postJsonToApi)({
|
|
1569
|
+
url: this.getUrl(),
|
|
1570
|
+
headers: (0, import_provider_utils12.combineHeaders)(
|
|
1571
|
+
resolvedHeaders,
|
|
1572
|
+
headers != null ? headers : {},
|
|
1573
|
+
this.getModelConfigHeaders(),
|
|
1574
|
+
await (0, import_provider_utils12.resolve)(this.config.o11yHeaders)
|
|
1575
|
+
),
|
|
1576
|
+
body: {
|
|
1577
|
+
text,
|
|
1578
|
+
...voice && { voice },
|
|
1579
|
+
...outputFormat && { outputFormat },
|
|
1580
|
+
...instructions && { instructions },
|
|
1581
|
+
...speed != null && { speed },
|
|
1582
|
+
...language && { language },
|
|
1583
|
+
...providerOptions && { providerOptions }
|
|
1584
|
+
},
|
|
1585
|
+
successfulResponseHandler: (0, import_provider_utils12.createJsonResponseHandler)(
|
|
1586
|
+
gatewaySpeechResponseSchema
|
|
1587
|
+
),
|
|
1588
|
+
failedResponseHandler: (0, import_provider_utils12.createJsonErrorResponseHandler)({
|
|
1589
|
+
errorSchema: import_v412.z.any(),
|
|
1590
|
+
errorToMessage: (data) => data
|
|
1591
|
+
}),
|
|
1592
|
+
...abortSignal && { abortSignal },
|
|
1593
|
+
fetch: this.config.fetch
|
|
1594
|
+
});
|
|
1595
|
+
return {
|
|
1596
|
+
audio: responseBody.audio,
|
|
1597
|
+
warnings: (_a11 = responseBody.warnings) != null ? _a11 : [],
|
|
1598
|
+
providerMetadata: responseBody.providerMetadata,
|
|
1599
|
+
response: {
|
|
1600
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
1601
|
+
modelId: this.modelId,
|
|
1602
|
+
headers: responseHeaders,
|
|
1603
|
+
body: rawValue
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
} catch (error) {
|
|
1607
|
+
throw await asGatewayError(
|
|
1608
|
+
error,
|
|
1609
|
+
await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {})
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
getUrl() {
|
|
1614
|
+
return `${this.config.baseURL}/speech-model`;
|
|
1615
|
+
}
|
|
1616
|
+
getModelConfigHeaders() {
|
|
1617
|
+
return {
|
|
1618
|
+
"ai-speech-model-specification-version": "3",
|
|
1619
|
+
"ai-model-id": this.modelId
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
var providerMetadataEntrySchema3 = import_v412.z.object({}).catchall(import_v412.z.unknown());
|
|
1624
|
+
var gatewaySpeechWarningSchema = import_v412.z.discriminatedUnion("type", [
|
|
1625
|
+
import_v412.z.object({
|
|
1626
|
+
type: import_v412.z.literal("unsupported"),
|
|
1627
|
+
feature: import_v412.z.string(),
|
|
1628
|
+
details: import_v412.z.string().optional()
|
|
1629
|
+
}),
|
|
1630
|
+
import_v412.z.object({
|
|
1631
|
+
type: import_v412.z.literal("compatibility"),
|
|
1632
|
+
feature: import_v412.z.string(),
|
|
1633
|
+
details: import_v412.z.string().optional()
|
|
1634
|
+
}),
|
|
1635
|
+
import_v412.z.object({
|
|
1636
|
+
type: import_v412.z.literal("other"),
|
|
1637
|
+
message: import_v412.z.string()
|
|
1638
|
+
})
|
|
1639
|
+
]);
|
|
1640
|
+
var gatewaySpeechResponseSchema = import_v412.z.object({
|
|
1641
|
+
audio: import_v412.z.string(),
|
|
1642
|
+
warnings: import_v412.z.array(gatewaySpeechWarningSchema).optional(),
|
|
1643
|
+
providerMetadata: import_v412.z.record(import_v412.z.string(), providerMetadataEntrySchema3).optional()
|
|
1644
|
+
});
|
|
1645
|
+
|
|
1646
|
+
// src/gateway-transcription-model.ts
|
|
1647
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
1648
|
+
var import_v413 = require("zod/v4");
|
|
1649
|
+
var GatewayTranscriptionModel = class {
|
|
1650
|
+
constructor(modelId, config) {
|
|
1651
|
+
this.modelId = modelId;
|
|
1652
|
+
this.config = config;
|
|
1653
|
+
this.specificationVersion = "v3";
|
|
1654
|
+
}
|
|
1655
|
+
get provider() {
|
|
1656
|
+
return this.config.provider;
|
|
1657
|
+
}
|
|
1658
|
+
async doGenerate({
|
|
1659
|
+
audio,
|
|
1660
|
+
mediaType,
|
|
1661
|
+
providerOptions,
|
|
1662
|
+
headers,
|
|
1663
|
+
abortSignal
|
|
1664
|
+
}) {
|
|
1665
|
+
var _a11, _b11, _c, _d;
|
|
1666
|
+
const resolvedHeaders = await (0, import_provider_utils13.resolve)(this.config.headers());
|
|
1667
|
+
try {
|
|
1668
|
+
const {
|
|
1669
|
+
responseHeaders,
|
|
1670
|
+
value: responseBody,
|
|
1671
|
+
rawValue
|
|
1672
|
+
} = await (0, import_provider_utils13.postJsonToApi)({
|
|
1673
|
+
url: this.getUrl(),
|
|
1674
|
+
headers: (0, import_provider_utils13.combineHeaders)(
|
|
1675
|
+
resolvedHeaders,
|
|
1676
|
+
headers != null ? headers : {},
|
|
1677
|
+
this.getModelConfigHeaders(),
|
|
1678
|
+
await (0, import_provider_utils13.resolve)(this.config.o11yHeaders)
|
|
1679
|
+
),
|
|
1680
|
+
body: {
|
|
1681
|
+
audio: audio instanceof Uint8Array ? (0, import_provider_utils13.convertUint8ArrayToBase64)(audio) : audio,
|
|
1682
|
+
mediaType,
|
|
1683
|
+
...providerOptions && { providerOptions }
|
|
1684
|
+
},
|
|
1685
|
+
successfulResponseHandler: (0, import_provider_utils13.createJsonResponseHandler)(
|
|
1686
|
+
gatewayTranscriptionResponseSchema
|
|
1687
|
+
),
|
|
1688
|
+
failedResponseHandler: (0, import_provider_utils13.createJsonErrorResponseHandler)({
|
|
1689
|
+
errorSchema: import_v413.z.any(),
|
|
1690
|
+
errorToMessage: (data) => data
|
|
1691
|
+
}),
|
|
1692
|
+
...abortSignal && { abortSignal },
|
|
1693
|
+
fetch: this.config.fetch
|
|
1694
|
+
});
|
|
1695
|
+
return {
|
|
1696
|
+
text: responseBody.text,
|
|
1697
|
+
segments: (_a11 = responseBody.segments) != null ? _a11 : [],
|
|
1698
|
+
language: (_b11 = responseBody.language) != null ? _b11 : void 0,
|
|
1699
|
+
durationInSeconds: (_c = responseBody.durationInSeconds) != null ? _c : void 0,
|
|
1700
|
+
warnings: (_d = responseBody.warnings) != null ? _d : [],
|
|
1701
|
+
providerMetadata: responseBody.providerMetadata,
|
|
1702
|
+
response: {
|
|
1703
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
1704
|
+
modelId: this.modelId,
|
|
1705
|
+
headers: responseHeaders,
|
|
1706
|
+
body: rawValue
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
} catch (error) {
|
|
1710
|
+
throw await asGatewayError(
|
|
1711
|
+
error,
|
|
1712
|
+
await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {})
|
|
1713
|
+
);
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
getUrl() {
|
|
1717
|
+
return `${this.config.baseURL}/transcription-model`;
|
|
1718
|
+
}
|
|
1719
|
+
getModelConfigHeaders() {
|
|
1720
|
+
return {
|
|
1721
|
+
"ai-transcription-model-specification-version": "3",
|
|
1722
|
+
"ai-model-id": this.modelId
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
var providerMetadataEntrySchema4 = import_v413.z.object({}).catchall(import_v413.z.unknown());
|
|
1727
|
+
var gatewayTranscriptionWarningSchema = import_v413.z.discriminatedUnion("type", [
|
|
1728
|
+
import_v413.z.object({
|
|
1729
|
+
type: import_v413.z.literal("unsupported"),
|
|
1730
|
+
feature: import_v413.z.string(),
|
|
1731
|
+
details: import_v413.z.string().optional()
|
|
1732
|
+
}),
|
|
1733
|
+
import_v413.z.object({
|
|
1734
|
+
type: import_v413.z.literal("compatibility"),
|
|
1735
|
+
feature: import_v413.z.string(),
|
|
1736
|
+
details: import_v413.z.string().optional()
|
|
1737
|
+
}),
|
|
1738
|
+
import_v413.z.object({
|
|
1739
|
+
type: import_v413.z.literal("other"),
|
|
1740
|
+
message: import_v413.z.string()
|
|
1741
|
+
})
|
|
1742
|
+
]);
|
|
1743
|
+
var gatewayTranscriptionResponseSchema = import_v413.z.object({
|
|
1744
|
+
text: import_v413.z.string(),
|
|
1745
|
+
segments: import_v413.z.array(
|
|
1746
|
+
import_v413.z.object({
|
|
1747
|
+
text: import_v413.z.string(),
|
|
1748
|
+
startSecond: import_v413.z.number(),
|
|
1749
|
+
endSecond: import_v413.z.number()
|
|
1750
|
+
})
|
|
1751
|
+
).optional(),
|
|
1752
|
+
language: import_v413.z.string().nullish(),
|
|
1753
|
+
durationInSeconds: import_v413.z.number().nullish(),
|
|
1754
|
+
warnings: import_v413.z.array(gatewayTranscriptionWarningSchema).optional(),
|
|
1755
|
+
providerMetadata: import_v413.z.record(import_v413.z.string(), providerMetadataEntrySchema4).optional()
|
|
1756
|
+
});
|
|
1757
|
+
|
|
1758
|
+
// src/tool/parallel-search.ts
|
|
1759
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
1538
1760
|
var import_zod = require("zod");
|
|
1539
|
-
var parallelSearchInputSchema = (0,
|
|
1540
|
-
() => (0,
|
|
1761
|
+
var parallelSearchInputSchema = (0, import_provider_utils14.lazySchema)(
|
|
1762
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
1541
1763
|
import_zod.z.object({
|
|
1542
1764
|
objective: import_zod.z.string().describe(
|
|
1543
1765
|
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
@@ -1552,10 +1774,14 @@ var parallelSearchInputSchema = (0, import_provider_utils12.lazySchema)(
|
|
|
1552
1774
|
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
1553
1775
|
),
|
|
1554
1776
|
source_policy: import_zod.z.object({
|
|
1555
|
-
include_domains: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
1556
|
-
|
|
1777
|
+
include_domains: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
1778
|
+
"Limit results to these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."
|
|
1779
|
+
),
|
|
1780
|
+
exclude_domains: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
1781
|
+
"Exclude results from these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."
|
|
1782
|
+
),
|
|
1557
1783
|
after_date: import_zod.z.string().optional().describe(
|
|
1558
|
-
"Only include results published after this date
|
|
1784
|
+
"Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time."
|
|
1559
1785
|
)
|
|
1560
1786
|
}).optional().describe(
|
|
1561
1787
|
"Source policy for controlling which domains to include/exclude and freshness."
|
|
@@ -1572,8 +1798,8 @@ var parallelSearchInputSchema = (0, import_provider_utils12.lazySchema)(
|
|
|
1572
1798
|
})
|
|
1573
1799
|
)
|
|
1574
1800
|
);
|
|
1575
|
-
var parallelSearchOutputSchema = (0,
|
|
1576
|
-
() => (0,
|
|
1801
|
+
var parallelSearchOutputSchema = (0, import_provider_utils14.lazySchema)(
|
|
1802
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
1577
1803
|
import_zod.z.union([
|
|
1578
1804
|
// Success response
|
|
1579
1805
|
import_zod.z.object({
|
|
@@ -1604,7 +1830,7 @@ var parallelSearchOutputSchema = (0, import_provider_utils12.lazySchema)(
|
|
|
1604
1830
|
])
|
|
1605
1831
|
)
|
|
1606
1832
|
);
|
|
1607
|
-
var parallelSearchToolFactory = (0,
|
|
1833
|
+
var parallelSearchToolFactory = (0, import_provider_utils14.createProviderToolFactoryWithOutputSchema)({
|
|
1608
1834
|
id: "gateway.parallel_search",
|
|
1609
1835
|
inputSchema: parallelSearchInputSchema,
|
|
1610
1836
|
outputSchema: parallelSearchOutputSchema
|
|
@@ -1612,10 +1838,10 @@ var parallelSearchToolFactory = (0, import_provider_utils12.createProviderToolFa
|
|
|
1612
1838
|
var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
1613
1839
|
|
|
1614
1840
|
// src/tool/perplexity-search.ts
|
|
1615
|
-
var
|
|
1841
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
1616
1842
|
var import_zod2 = require("zod");
|
|
1617
|
-
var perplexitySearchInputSchema = (0,
|
|
1618
|
-
() => (0,
|
|
1843
|
+
var perplexitySearchInputSchema = (0, import_provider_utils15.lazySchema)(
|
|
1844
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
1619
1845
|
import_zod2.z.object({
|
|
1620
1846
|
query: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.array(import_zod2.z.string())]).describe(
|
|
1621
1847
|
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
@@ -1656,8 +1882,8 @@ var perplexitySearchInputSchema = (0, import_provider_utils13.lazySchema)(
|
|
|
1656
1882
|
})
|
|
1657
1883
|
)
|
|
1658
1884
|
);
|
|
1659
|
-
var perplexitySearchOutputSchema = (0,
|
|
1660
|
-
() => (0,
|
|
1885
|
+
var perplexitySearchOutputSchema = (0, import_provider_utils15.lazySchema)(
|
|
1886
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
1661
1887
|
import_zod2.z.union([
|
|
1662
1888
|
// Success response
|
|
1663
1889
|
import_zod2.z.object({
|
|
@@ -1687,7 +1913,7 @@ var perplexitySearchOutputSchema = (0, import_provider_utils13.lazySchema)(
|
|
|
1687
1913
|
])
|
|
1688
1914
|
)
|
|
1689
1915
|
);
|
|
1690
|
-
var perplexitySearchToolFactory = (0,
|
|
1916
|
+
var perplexitySearchToolFactory = (0, import_provider_utils15.createProviderToolFactoryWithOutputSchema)({
|
|
1691
1917
|
id: "gateway.perplexity_search",
|
|
1692
1918
|
inputSchema: perplexitySearchInputSchema,
|
|
1693
1919
|
outputSchema: perplexitySearchOutputSchema
|
|
@@ -1724,7 +1950,7 @@ async function getVercelRequestId() {
|
|
|
1724
1950
|
}
|
|
1725
1951
|
|
|
1726
1952
|
// src/version.ts
|
|
1727
|
-
var VERSION = true ? "3.0.
|
|
1953
|
+
var VERSION = true ? "3.0.137" : "0.0.0-test";
|
|
1728
1954
|
|
|
1729
1955
|
// src/gateway-provider.ts
|
|
1730
1956
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
@@ -1734,11 +1960,11 @@ function createGatewayProvider(options = {}) {
|
|
|
1734
1960
|
let metadataCache = null;
|
|
1735
1961
|
const cacheRefreshMillis = (_a11 = options.metadataCacheRefreshMillis) != null ? _a11 : 1e3 * 60 * 5;
|
|
1736
1962
|
let lastFetchTime = 0;
|
|
1737
|
-
const baseURL = (_b11 = (0,
|
|
1963
|
+
const baseURL = (_b11 = (0, import_provider_utils16.withoutTrailingSlash)(options.baseURL)) != null ? _b11 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
1738
1964
|
const getHeaders = async () => {
|
|
1739
1965
|
try {
|
|
1740
1966
|
const auth = await getGatewayAuthToken(options);
|
|
1741
|
-
return (0,
|
|
1967
|
+
return (0, import_provider_utils16.withUserAgentSuffix)(
|
|
1742
1968
|
{
|
|
1743
1969
|
Authorization: `Bearer ${auth.token}`,
|
|
1744
1970
|
"ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
|
|
@@ -1757,19 +1983,19 @@ function createGatewayProvider(options = {}) {
|
|
|
1757
1983
|
}
|
|
1758
1984
|
};
|
|
1759
1985
|
const createO11yHeaders = () => {
|
|
1760
|
-
const deploymentId = (0,
|
|
1986
|
+
const deploymentId = (0, import_provider_utils16.loadOptionalSetting)({
|
|
1761
1987
|
settingValue: void 0,
|
|
1762
1988
|
environmentVariableName: "VERCEL_DEPLOYMENT_ID"
|
|
1763
1989
|
});
|
|
1764
|
-
const environment = (0,
|
|
1990
|
+
const environment = (0, import_provider_utils16.loadOptionalSetting)({
|
|
1765
1991
|
settingValue: void 0,
|
|
1766
1992
|
environmentVariableName: "VERCEL_ENV"
|
|
1767
1993
|
});
|
|
1768
|
-
const region = (0,
|
|
1994
|
+
const region = (0, import_provider_utils16.loadOptionalSetting)({
|
|
1769
1995
|
settingValue: void 0,
|
|
1770
1996
|
environmentVariableName: "VERCEL_REGION"
|
|
1771
1997
|
});
|
|
1772
|
-
const projectId = (0,
|
|
1998
|
+
const projectId = (0, import_provider_utils16.loadOptionalSetting)({
|
|
1773
1999
|
settingValue: void 0,
|
|
1774
2000
|
environmentVariableName: "VERCEL_PROJECT_ID"
|
|
1775
2001
|
});
|
|
@@ -1904,6 +2130,28 @@ function createGatewayProvider(options = {}) {
|
|
|
1904
2130
|
};
|
|
1905
2131
|
provider.rerankingModel = createRerankingModel;
|
|
1906
2132
|
provider.reranking = createRerankingModel;
|
|
2133
|
+
const createSpeechModel = (modelId) => {
|
|
2134
|
+
return new GatewaySpeechModel(modelId, {
|
|
2135
|
+
provider: "gateway",
|
|
2136
|
+
baseURL,
|
|
2137
|
+
headers: getHeaders,
|
|
2138
|
+
fetch: options.fetch,
|
|
2139
|
+
o11yHeaders: createO11yHeaders()
|
|
2140
|
+
});
|
|
2141
|
+
};
|
|
2142
|
+
provider.speechModel = createSpeechModel;
|
|
2143
|
+
provider.speech = createSpeechModel;
|
|
2144
|
+
const createTranscriptionModel = (modelId) => {
|
|
2145
|
+
return new GatewayTranscriptionModel(modelId, {
|
|
2146
|
+
provider: "gateway",
|
|
2147
|
+
baseURL,
|
|
2148
|
+
headers: getHeaders,
|
|
2149
|
+
fetch: options.fetch,
|
|
2150
|
+
o11yHeaders: createO11yHeaders()
|
|
2151
|
+
});
|
|
2152
|
+
};
|
|
2153
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
2154
|
+
provider.transcription = createTranscriptionModel;
|
|
1907
2155
|
provider.chat = provider.languageModel;
|
|
1908
2156
|
provider.embedding = provider.embeddingModel;
|
|
1909
2157
|
provider.image = provider.imageModel;
|
|
@@ -1913,7 +2161,7 @@ function createGatewayProvider(options = {}) {
|
|
|
1913
2161
|
}
|
|
1914
2162
|
var gateway = createGatewayProvider();
|
|
1915
2163
|
async function getGatewayAuthToken(options) {
|
|
1916
|
-
const apiKey = (0,
|
|
2164
|
+
const apiKey = (0, import_provider_utils16.loadOptionalSetting)({
|
|
1917
2165
|
settingValue: options.apiKey,
|
|
1918
2166
|
environmentVariableName: "AI_GATEWAY_API_KEY"
|
|
1919
2167
|
});
|