@ai-sdk/gateway 3.0.32 → 3.0.34
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 +12 -0
- package/dist/index.d.mts +26 -4
- package/dist/index.d.ts +26 -4
- package/dist/index.js +157 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +201 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/gateway-fetch-metadata.ts +3 -1
- package/src/gateway-language-model-settings.ts +0 -1
- package/src/gateway-model-entry.ts +1 -1
- package/src/gateway-provider.ts +41 -1
- package/src/gateway-video-model-settings.ts +1 -0
- package/src/gateway-video-model.ts +167 -0
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/gateway
|
|
2
2
|
|
|
3
|
+
## 3.0.34
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4867635: feat (provider/gateway): add video generation support
|
|
8
|
+
|
|
9
|
+
## 3.0.33
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ae30443: fix(google): remove shut down `gemini-2.5-flash-image-preview`
|
|
14
|
+
|
|
3
15
|
## 3.0.32
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
1
|
+
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, Experimental_VideoModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-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' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | '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-
|
|
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-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' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | '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' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'moonshotai/kimi-k2.5' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | '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-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | (string & {});
|
|
6
|
+
|
|
7
|
+
type GatewayVideoModelId = 'google/veo-3.1-generate-001' | (string & {});
|
|
6
8
|
|
|
7
9
|
interface GatewayLanguageModelEntry {
|
|
8
10
|
/**
|
|
@@ -48,7 +50,7 @@ interface GatewayLanguageModelEntry {
|
|
|
48
50
|
/**
|
|
49
51
|
* Optional field to differentiate between model types.
|
|
50
52
|
*/
|
|
51
|
-
modelType?: 'language' | 'embedding' | 'image' | null;
|
|
53
|
+
modelType?: 'language' | 'embedding' | 'image' | 'video' | null;
|
|
52
54
|
}
|
|
53
55
|
type GatewayLanguageModelSpecification = Pick<LanguageModelV3, 'specificationVersion' | 'provider' | 'modelId'>;
|
|
54
56
|
|
|
@@ -352,6 +354,10 @@ declare const gatewayTools: {
|
|
|
352
354
|
|
|
353
355
|
interface GatewayProvider extends ProviderV3 {
|
|
354
356
|
(modelId: GatewayModelId): LanguageModelV3;
|
|
357
|
+
/**
|
|
358
|
+
* Creates a model for text generation.
|
|
359
|
+
*/
|
|
360
|
+
chat(modelId: GatewayModelId): LanguageModelV3;
|
|
355
361
|
/**
|
|
356
362
|
* Creates a model for text generation.
|
|
357
363
|
*/
|
|
@@ -364,6 +370,10 @@ interface GatewayProvider extends ProviderV3 {
|
|
|
364
370
|
* Returns credit information for the authenticated user.
|
|
365
371
|
*/
|
|
366
372
|
getCredits(): Promise<GatewayCreditsResponse>;
|
|
373
|
+
/**
|
|
374
|
+
* Creates a model for generating text embeddings.
|
|
375
|
+
*/
|
|
376
|
+
embedding(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
367
377
|
/**
|
|
368
378
|
* Creates a model for generating text embeddings.
|
|
369
379
|
*/
|
|
@@ -372,10 +382,22 @@ interface GatewayProvider extends ProviderV3 {
|
|
|
372
382
|
* @deprecated Use `embeddingModel` instead.
|
|
373
383
|
*/
|
|
374
384
|
textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
385
|
+
/**
|
|
386
|
+
* Creates a model for generating images.
|
|
387
|
+
*/
|
|
388
|
+
image(modelId: GatewayImageModelId): ImageModelV3;
|
|
375
389
|
/**
|
|
376
390
|
* Creates a model for generating images.
|
|
377
391
|
*/
|
|
378
392
|
imageModel(modelId: GatewayImageModelId): ImageModelV3;
|
|
393
|
+
/**
|
|
394
|
+
* Creates a model for generating videos.
|
|
395
|
+
*/
|
|
396
|
+
video(modelId: GatewayVideoModelId): Experimental_VideoModelV3;
|
|
397
|
+
/**
|
|
398
|
+
* Creates a model for generating videos.
|
|
399
|
+
*/
|
|
400
|
+
videoModel(modelId: GatewayVideoModelId): Experimental_VideoModelV3;
|
|
379
401
|
/**
|
|
380
402
|
* Gateway-specific tools executed server-side.
|
|
381
403
|
*/
|
|
@@ -574,4 +596,4 @@ declare class GatewayResponseError extends GatewayError {
|
|
|
574
596
|
static isInstance(error: unknown): error is GatewayResponseError;
|
|
575
597
|
}
|
|
576
598
|
|
|
577
|
-
export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayLanguageModelSpecification, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, GatewayResponseError, createGatewayProvider as createGateway, createGatewayProvider, gateway };
|
|
599
|
+
export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayLanguageModelSpecification, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, GatewayResponseError, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
1
|
+
import { LanguageModelV3, ProviderV3, EmbeddingModelV3, ImageModelV3, Experimental_VideoModelV3, TypeValidationError } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-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' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | '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-
|
|
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-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' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-exp' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | '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' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'moonshotai/kimi-k2.5' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | '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-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | (string & {});
|
|
6
|
+
|
|
7
|
+
type GatewayVideoModelId = 'google/veo-3.1-generate-001' | (string & {});
|
|
6
8
|
|
|
7
9
|
interface GatewayLanguageModelEntry {
|
|
8
10
|
/**
|
|
@@ -48,7 +50,7 @@ interface GatewayLanguageModelEntry {
|
|
|
48
50
|
/**
|
|
49
51
|
* Optional field to differentiate between model types.
|
|
50
52
|
*/
|
|
51
|
-
modelType?: 'language' | 'embedding' | 'image' | null;
|
|
53
|
+
modelType?: 'language' | 'embedding' | 'image' | 'video' | null;
|
|
52
54
|
}
|
|
53
55
|
type GatewayLanguageModelSpecification = Pick<LanguageModelV3, 'specificationVersion' | 'provider' | 'modelId'>;
|
|
54
56
|
|
|
@@ -352,6 +354,10 @@ declare const gatewayTools: {
|
|
|
352
354
|
|
|
353
355
|
interface GatewayProvider extends ProviderV3 {
|
|
354
356
|
(modelId: GatewayModelId): LanguageModelV3;
|
|
357
|
+
/**
|
|
358
|
+
* Creates a model for text generation.
|
|
359
|
+
*/
|
|
360
|
+
chat(modelId: GatewayModelId): LanguageModelV3;
|
|
355
361
|
/**
|
|
356
362
|
* Creates a model for text generation.
|
|
357
363
|
*/
|
|
@@ -364,6 +370,10 @@ interface GatewayProvider extends ProviderV3 {
|
|
|
364
370
|
* Returns credit information for the authenticated user.
|
|
365
371
|
*/
|
|
366
372
|
getCredits(): Promise<GatewayCreditsResponse>;
|
|
373
|
+
/**
|
|
374
|
+
* Creates a model for generating text embeddings.
|
|
375
|
+
*/
|
|
376
|
+
embedding(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
367
377
|
/**
|
|
368
378
|
* Creates a model for generating text embeddings.
|
|
369
379
|
*/
|
|
@@ -372,10 +382,22 @@ interface GatewayProvider extends ProviderV3 {
|
|
|
372
382
|
* @deprecated Use `embeddingModel` instead.
|
|
373
383
|
*/
|
|
374
384
|
textEmbeddingModel(modelId: GatewayEmbeddingModelId): EmbeddingModelV3;
|
|
385
|
+
/**
|
|
386
|
+
* Creates a model for generating images.
|
|
387
|
+
*/
|
|
388
|
+
image(modelId: GatewayImageModelId): ImageModelV3;
|
|
375
389
|
/**
|
|
376
390
|
* Creates a model for generating images.
|
|
377
391
|
*/
|
|
378
392
|
imageModel(modelId: GatewayImageModelId): ImageModelV3;
|
|
393
|
+
/**
|
|
394
|
+
* Creates a model for generating videos.
|
|
395
|
+
*/
|
|
396
|
+
video(modelId: GatewayVideoModelId): Experimental_VideoModelV3;
|
|
397
|
+
/**
|
|
398
|
+
* Creates a model for generating videos.
|
|
399
|
+
*/
|
|
400
|
+
videoModel(modelId: GatewayVideoModelId): Experimental_VideoModelV3;
|
|
379
401
|
/**
|
|
380
402
|
* Gateway-specific tools executed server-side.
|
|
381
403
|
*/
|
|
@@ -574,4 +596,4 @@ declare class GatewayResponseError extends GatewayError {
|
|
|
574
596
|
static isInstance(error: unknown): error is GatewayResponseError;
|
|
575
597
|
}
|
|
576
598
|
|
|
577
|
-
export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayLanguageModelSpecification, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, GatewayResponseError, createGatewayProvider as createGateway, createGatewayProvider, gateway };
|
|
599
|
+
export { GatewayAuthenticationError, type GatewayCreditsResponse, GatewayError, type GatewayErrorResponse, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayLanguageModelSpecification, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayModelId, GatewayModelNotFoundError, type GatewayProvider, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, GatewayResponseError, type GatewayVideoModelId, createGatewayProvider as createGateway, createGatewayProvider, gateway };
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(src_exports);
|
|
35
35
|
|
|
36
36
|
// src/gateway-provider.ts
|
|
37
|
-
var
|
|
37
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
38
38
|
|
|
39
39
|
// src/errors/as-gateway-error.ts
|
|
40
40
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -488,7 +488,7 @@ var gatewayAvailableModelsResponseSchema = (0, import_provider_utils4.lazySchema
|
|
|
488
488
|
provider: import_v44.z.string(),
|
|
489
489
|
modelId: import_v44.z.string()
|
|
490
490
|
}),
|
|
491
|
-
modelType: import_v44.z.enum(["
|
|
491
|
+
modelType: import_v44.z.enum(["embedding", "image", "language", "video"]).nullish()
|
|
492
492
|
})
|
|
493
493
|
)
|
|
494
494
|
})
|
|
@@ -847,11 +847,133 @@ var gatewayImageResponseSchema = import_v47.z.object({
|
|
|
847
847
|
providerMetadata: import_v47.z.record(import_v47.z.string(), providerMetadataEntrySchema).optional()
|
|
848
848
|
});
|
|
849
849
|
|
|
850
|
-
// src/
|
|
850
|
+
// src/gateway-video-model.ts
|
|
851
851
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
852
|
+
var import_v48 = require("zod/v4");
|
|
853
|
+
var GatewayVideoModel = class {
|
|
854
|
+
constructor(modelId, config) {
|
|
855
|
+
this.modelId = modelId;
|
|
856
|
+
this.config = config;
|
|
857
|
+
this.specificationVersion = "v3";
|
|
858
|
+
// Set a very large number to prevent client-side splitting of requests
|
|
859
|
+
this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
|
|
860
|
+
}
|
|
861
|
+
get provider() {
|
|
862
|
+
return this.config.provider;
|
|
863
|
+
}
|
|
864
|
+
async doGenerate({
|
|
865
|
+
prompt,
|
|
866
|
+
n,
|
|
867
|
+
aspectRatio,
|
|
868
|
+
resolution,
|
|
869
|
+
duration,
|
|
870
|
+
fps,
|
|
871
|
+
seed,
|
|
872
|
+
image,
|
|
873
|
+
providerOptions,
|
|
874
|
+
headers,
|
|
875
|
+
abortSignal
|
|
876
|
+
}) {
|
|
877
|
+
var _a8;
|
|
878
|
+
const resolvedHeaders = await (0, import_provider_utils8.resolve)(this.config.headers());
|
|
879
|
+
try {
|
|
880
|
+
const {
|
|
881
|
+
responseHeaders,
|
|
882
|
+
value: responseBody,
|
|
883
|
+
rawValue
|
|
884
|
+
} = await (0, import_provider_utils8.postJsonToApi)({
|
|
885
|
+
url: this.getUrl(),
|
|
886
|
+
headers: (0, import_provider_utils8.combineHeaders)(
|
|
887
|
+
resolvedHeaders,
|
|
888
|
+
headers != null ? headers : {},
|
|
889
|
+
this.getModelConfigHeaders(),
|
|
890
|
+
await (0, import_provider_utils8.resolve)(this.config.o11yHeaders)
|
|
891
|
+
),
|
|
892
|
+
body: {
|
|
893
|
+
prompt,
|
|
894
|
+
n,
|
|
895
|
+
...aspectRatio && { aspectRatio },
|
|
896
|
+
...resolution && { resolution },
|
|
897
|
+
...duration && { duration },
|
|
898
|
+
...fps && { fps },
|
|
899
|
+
...seed && { seed },
|
|
900
|
+
...providerOptions && { providerOptions },
|
|
901
|
+
...image && { image: maybeEncodeVideoFile(image) }
|
|
902
|
+
},
|
|
903
|
+
successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
|
|
904
|
+
gatewayVideoResponseSchema
|
|
905
|
+
),
|
|
906
|
+
failedResponseHandler: (0, import_provider_utils8.createJsonErrorResponseHandler)({
|
|
907
|
+
errorSchema: import_v48.z.any(),
|
|
908
|
+
errorToMessage: (data) => data
|
|
909
|
+
}),
|
|
910
|
+
...abortSignal && { abortSignal },
|
|
911
|
+
fetch: this.config.fetch
|
|
912
|
+
});
|
|
913
|
+
return {
|
|
914
|
+
videos: responseBody.videos,
|
|
915
|
+
warnings: (_a8 = responseBody.warnings) != null ? _a8 : [],
|
|
916
|
+
providerMetadata: responseBody.providerMetadata,
|
|
917
|
+
response: {
|
|
918
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
919
|
+
modelId: this.modelId,
|
|
920
|
+
headers: responseHeaders
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
} catch (error) {
|
|
924
|
+
throw asGatewayError(error, await parseAuthMethod(resolvedHeaders));
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
getUrl() {
|
|
928
|
+
return `${this.config.baseURL}/video-model`;
|
|
929
|
+
}
|
|
930
|
+
getModelConfigHeaders() {
|
|
931
|
+
return {
|
|
932
|
+
"ai-video-model-specification-version": "3",
|
|
933
|
+
"ai-model-id": this.modelId
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
function maybeEncodeVideoFile(file) {
|
|
938
|
+
if (file.type === "file" && file.data instanceof Uint8Array) {
|
|
939
|
+
return {
|
|
940
|
+
...file,
|
|
941
|
+
data: (0, import_provider_utils8.convertUint8ArrayToBase64)(file.data)
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
return file;
|
|
945
|
+
}
|
|
946
|
+
var providerMetadataEntrySchema2 = import_v48.z.object({
|
|
947
|
+
videos: import_v48.z.array(import_v48.z.unknown()).optional()
|
|
948
|
+
}).catchall(import_v48.z.unknown());
|
|
949
|
+
var gatewayVideoDataSchema = import_v48.z.union([
|
|
950
|
+
import_v48.z.object({
|
|
951
|
+
type: import_v48.z.literal("url"),
|
|
952
|
+
url: import_v48.z.string(),
|
|
953
|
+
mediaType: import_v48.z.string()
|
|
954
|
+
}),
|
|
955
|
+
import_v48.z.object({
|
|
956
|
+
type: import_v48.z.literal("base64"),
|
|
957
|
+
data: import_v48.z.string(),
|
|
958
|
+
mediaType: import_v48.z.string()
|
|
959
|
+
})
|
|
960
|
+
]);
|
|
961
|
+
var gatewayVideoResponseSchema = import_v48.z.object({
|
|
962
|
+
videos: import_v48.z.array(gatewayVideoDataSchema),
|
|
963
|
+
warnings: import_v48.z.array(
|
|
964
|
+
import_v48.z.object({
|
|
965
|
+
type: import_v48.z.literal("other"),
|
|
966
|
+
message: import_v48.z.string()
|
|
967
|
+
})
|
|
968
|
+
).optional(),
|
|
969
|
+
providerMetadata: import_v48.z.record(import_v48.z.string(), providerMetadataEntrySchema2).optional()
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
// src/tool/parallel-search.ts
|
|
973
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
852
974
|
var import_zod = require("zod");
|
|
853
|
-
var parallelSearchInputSchema = (0,
|
|
854
|
-
() => (0,
|
|
975
|
+
var parallelSearchInputSchema = (0, import_provider_utils9.lazySchema)(
|
|
976
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
855
977
|
import_zod.z.object({
|
|
856
978
|
objective: import_zod.z.string().describe(
|
|
857
979
|
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
@@ -886,8 +1008,8 @@ var parallelSearchInputSchema = (0, import_provider_utils8.lazySchema)(
|
|
|
886
1008
|
})
|
|
887
1009
|
)
|
|
888
1010
|
);
|
|
889
|
-
var parallelSearchOutputSchema = (0,
|
|
890
|
-
() => (0,
|
|
1011
|
+
var parallelSearchOutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
1012
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
891
1013
|
import_zod.z.union([
|
|
892
1014
|
// Success response
|
|
893
1015
|
import_zod.z.object({
|
|
@@ -918,7 +1040,7 @@ var parallelSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
|
918
1040
|
])
|
|
919
1041
|
)
|
|
920
1042
|
);
|
|
921
|
-
var parallelSearchToolFactory = (0,
|
|
1043
|
+
var parallelSearchToolFactory = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
|
|
922
1044
|
id: "gateway.parallel_search",
|
|
923
1045
|
inputSchema: parallelSearchInputSchema,
|
|
924
1046
|
outputSchema: parallelSearchOutputSchema
|
|
@@ -926,10 +1048,10 @@ var parallelSearchToolFactory = (0, import_provider_utils8.createProviderToolFac
|
|
|
926
1048
|
var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
927
1049
|
|
|
928
1050
|
// src/tool/perplexity-search.ts
|
|
929
|
-
var
|
|
1051
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
930
1052
|
var import_zod2 = require("zod");
|
|
931
|
-
var perplexitySearchInputSchema = (0,
|
|
932
|
-
() => (0,
|
|
1053
|
+
var perplexitySearchInputSchema = (0, import_provider_utils10.lazySchema)(
|
|
1054
|
+
() => (0, import_provider_utils10.zodSchema)(
|
|
933
1055
|
import_zod2.z.object({
|
|
934
1056
|
query: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.array(import_zod2.z.string())]).describe(
|
|
935
1057
|
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
@@ -970,8 +1092,8 @@ var perplexitySearchInputSchema = (0, import_provider_utils9.lazySchema)(
|
|
|
970
1092
|
})
|
|
971
1093
|
)
|
|
972
1094
|
);
|
|
973
|
-
var perplexitySearchOutputSchema = (0,
|
|
974
|
-
() => (0,
|
|
1095
|
+
var perplexitySearchOutputSchema = (0, import_provider_utils10.lazySchema)(
|
|
1096
|
+
() => (0, import_provider_utils10.zodSchema)(
|
|
975
1097
|
import_zod2.z.union([
|
|
976
1098
|
// Success response
|
|
977
1099
|
import_zod2.z.object({
|
|
@@ -1001,7 +1123,7 @@ var perplexitySearchOutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
|
1001
1123
|
])
|
|
1002
1124
|
)
|
|
1003
1125
|
);
|
|
1004
|
-
var perplexitySearchToolFactory = (0,
|
|
1126
|
+
var perplexitySearchToolFactory = (0, import_provider_utils10.createProviderToolFactoryWithOutputSchema)({
|
|
1005
1127
|
id: "gateway.perplexity_search",
|
|
1006
1128
|
inputSchema: perplexitySearchInputSchema,
|
|
1007
1129
|
outputSchema: perplexitySearchOutputSchema
|
|
@@ -1038,10 +1160,10 @@ async function getVercelRequestId() {
|
|
|
1038
1160
|
}
|
|
1039
1161
|
|
|
1040
1162
|
// src/gateway-provider.ts
|
|
1041
|
-
var
|
|
1163
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1042
1164
|
|
|
1043
1165
|
// src/version.ts
|
|
1044
|
-
var VERSION = true ? "3.0.
|
|
1166
|
+
var VERSION = true ? "3.0.34" : "0.0.0-test";
|
|
1045
1167
|
|
|
1046
1168
|
// src/gateway-provider.ts
|
|
1047
1169
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
@@ -1051,11 +1173,11 @@ function createGatewayProvider(options = {}) {
|
|
|
1051
1173
|
let metadataCache = null;
|
|
1052
1174
|
const cacheRefreshMillis = (_a8 = options.metadataCacheRefreshMillis) != null ? _a8 : 1e3 * 60 * 5;
|
|
1053
1175
|
let lastFetchTime = 0;
|
|
1054
|
-
const baseURL = (_b8 = (0,
|
|
1176
|
+
const baseURL = (_b8 = (0, import_provider_utils11.withoutTrailingSlash)(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
1055
1177
|
const getHeaders = async () => {
|
|
1056
1178
|
try {
|
|
1057
1179
|
const auth = await getGatewayAuthToken(options);
|
|
1058
|
-
return (0,
|
|
1180
|
+
return (0, import_provider_utils12.withUserAgentSuffix)(
|
|
1059
1181
|
{
|
|
1060
1182
|
Authorization: `Bearer ${auth.token}`,
|
|
1061
1183
|
"ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
|
|
@@ -1074,15 +1196,15 @@ function createGatewayProvider(options = {}) {
|
|
|
1074
1196
|
}
|
|
1075
1197
|
};
|
|
1076
1198
|
const createO11yHeaders = () => {
|
|
1077
|
-
const deploymentId = (0,
|
|
1199
|
+
const deploymentId = (0, import_provider_utils11.loadOptionalSetting)({
|
|
1078
1200
|
settingValue: void 0,
|
|
1079
1201
|
environmentVariableName: "VERCEL_DEPLOYMENT_ID"
|
|
1080
1202
|
});
|
|
1081
|
-
const environment = (0,
|
|
1203
|
+
const environment = (0, import_provider_utils11.loadOptionalSetting)({
|
|
1082
1204
|
settingValue: void 0,
|
|
1083
1205
|
environmentVariableName: "VERCEL_ENV"
|
|
1084
1206
|
});
|
|
1085
|
-
const region = (0,
|
|
1207
|
+
const region = (0, import_provider_utils11.loadOptionalSetting)({
|
|
1086
1208
|
settingValue: void 0,
|
|
1087
1209
|
environmentVariableName: "VERCEL_REGION"
|
|
1088
1210
|
});
|
|
@@ -1170,12 +1292,25 @@ function createGatewayProvider(options = {}) {
|
|
|
1170
1292
|
};
|
|
1171
1293
|
provider.embeddingModel = createEmbeddingModel;
|
|
1172
1294
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
1295
|
+
provider.videoModel = (modelId) => {
|
|
1296
|
+
return new GatewayVideoModel(modelId, {
|
|
1297
|
+
provider: "gateway",
|
|
1298
|
+
baseURL,
|
|
1299
|
+
headers: getHeaders,
|
|
1300
|
+
fetch: options.fetch,
|
|
1301
|
+
o11yHeaders: createO11yHeaders()
|
|
1302
|
+
});
|
|
1303
|
+
};
|
|
1304
|
+
provider.chat = provider.languageModel;
|
|
1305
|
+
provider.embedding = provider.embeddingModel;
|
|
1306
|
+
provider.image = provider.imageModel;
|
|
1307
|
+
provider.video = provider.videoModel;
|
|
1173
1308
|
provider.tools = gatewayTools;
|
|
1174
1309
|
return provider;
|
|
1175
1310
|
}
|
|
1176
1311
|
var gateway = createGatewayProvider();
|
|
1177
1312
|
async function getGatewayAuthToken(options) {
|
|
1178
|
-
const apiKey = (0,
|
|
1313
|
+
const apiKey = (0, import_provider_utils11.loadOptionalSetting)({
|
|
1179
1314
|
settingValue: options.apiKey,
|
|
1180
1315
|
environmentVariableName: "AI_GATEWAY_API_KEY"
|
|
1181
1316
|
});
|