@ai-sdk/gateway 4.0.63 → 4.0.67
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 +38 -0
- package/dist/index.d.ts +44 -9
- package/dist/index.js +42 -96
- package/dist/index.js.map +1 -1
- package/docs/00-ai-gateway.mdx +196 -2
- package/package.json +7 -7
- package/src/gateway-language-model-batch.ts +29 -126
- package/src/gateway-language-model-settings.ts +4 -6
- package/src/gateway-provider-metadata.ts +27 -0
- package/src/gateway-video-model-settings.ts +1 -0
- package/src/index.ts +4 -0
- package/src/tool/tako-search.ts +25 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @ai-sdk/gateway
|
|
2
2
|
|
|
3
|
+
## 4.0.67
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0e7994c: chore(provider/gateway): update gateway model settings files
|
|
8
|
+
- Updated dependencies [3e125ba]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.32
|
|
10
|
+
|
|
11
|
+
## 4.0.66
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 81bebaf: Add GLM-5.3-Flash model support to the Z.AI provider and AI Gateway.
|
|
16
|
+
|
|
17
|
+
## 4.0.65
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 80227cf: chore(provider/gateway): update gateway model settings files
|
|
22
|
+
- a9782e1: fix: align batch result parsing, request counts, and lifecycle behavior across providers
|
|
23
|
+
- 5533946: Remove the internal-only `relevance_score` and `citation_number` fields from
|
|
24
|
+
published Tako Search response types and schemas. Code that reads either field
|
|
25
|
+
must be updated; Gateway responses still pass the values through at runtime,
|
|
26
|
+
but they are no longer typed. Also document data surcharge controls.
|
|
27
|
+
- Updated dependencies [a9782e1]
|
|
28
|
+
- Updated dependencies [35841f5]
|
|
29
|
+
- Updated dependencies [d2f3353]
|
|
30
|
+
- @ai-sdk/provider-utils@5.0.31
|
|
31
|
+
|
|
32
|
+
## 4.0.64
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- 591d25b: feat: add batch completion webhooks. `experimental_startTextBatch` accepts a `webhookUrl`, and the gateway provider registers it through the batch `callbackUrl` contract and exports typed async-job metadata. Direct Anthropic and OpenAI batch providers return an unsupported warning when the option is provided.
|
|
37
|
+
- Updated dependencies [591d25b]
|
|
38
|
+
- @ai-sdk/provider@4.0.8
|
|
39
|
+
- @ai-sdk/provider-utils@5.0.30
|
|
40
|
+
|
|
3
41
|
## 4.0.63
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageModelV4, ProviderV4, Experimental_BatchLanguageModelV4, EmbeddingModelV4, ImageModelV4, Experimental_VideoModelV4, RerankingModelV4, SpeechModelV4, TranscriptionModelV4, Experimental_RealtimeFactoryV4, TypeValidationError } from '@ai-sdk/provider';
|
|
1
|
+
import { LanguageModelV4, ProviderV4, Experimental_BatchLanguageModelV4, EmbeddingModelV4, ImageModelV4, Experimental_VideoModelV4, RerankingModelV4, SpeechModelV4, TranscriptionModelV4, Experimental_RealtimeFactoryV4, JSONValue, TypeValidationError } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, WebSocketConstructor, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-e
|
|
|
6
6
|
|
|
7
7
|
type GatewayImageModelId = 'bfl/flux-2-flex' | 'bfl/flux-2-klein-4b' | 'bfl/flux-2-klein-9b' | 'bfl/flux-2-max' | 'bfl/flux-2-pro' | 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'bytedance/seedream-4.0' | 'bytedance/seedream-4.5' | 'bytedance/seedream-5.0-lite' | 'bytedance/seedream-5.0-pro' | 'openai/gpt-image-1' | 'openai/gpt-image-1-mini' | 'openai/gpt-image-1.5' | 'openai/gpt-image-2' | 'prodia/flux-fast-schnell' | 'quiverai/arrow-1.1' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | 'recraft/recraft-v4' | 'recraft/recraft-v4-pro' | 'recraft/recraft-v4.1' | 'recraft/recraft-v4.1-pro' | 'recraft/recraft-v4.1-utility' | 'recraft/recraft-v4.1-utility-pro' | 'spacexai/grok-imagine-image' | 'spacexai/grok-imagine-image-2.0' | (string & {});
|
|
8
8
|
|
|
9
|
-
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-flash' | 'alibaba/qwen3.7-max' | 'alibaba/qwen3.7-plus' | 'alibaba/qwen3.8-2.4t-a95b' | 'alibaba/qwen3.8-27b' | 'alibaba/qwen3.8-max' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-fable-5' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-opus-4.6' | 'anthropic/claude-opus-4.7' | 'anthropic/claude-opus-4.8' | 'anthropic/claude-opus-4.8-fast' | 'anthropic/claude-opus-5' | 'anthropic/claude-opus-5-fast' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'anthropic/claude-sonnet-4.6' | 'anthropic/claude-sonnet-5' | 'arcee-ai/trinity-large-thinking' | '
|
|
9
|
+
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-flash' | 'alibaba/qwen3.7-max' | 'alibaba/qwen3.7-plus' | 'alibaba/qwen3.8-2.4t-a95b' | 'alibaba/qwen3.8-27b' | 'alibaba/qwen3.8-max' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-fable-5' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-opus-4.6' | 'anthropic/claude-opus-4.7' | 'anthropic/claude-opus-4.8' | 'anthropic/claude-opus-4.8-fast' | 'anthropic/claude-opus-5' | 'anthropic/claude-opus-5-fast' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'anthropic/claude-sonnet-4.6' | 'anthropic/claude-sonnet-5' | 'arcee-ai/trinity-large-thinking' | '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-flash-0731' | 'deepseek/deepseek-v4-flash-vision-exp' | 'deepseek/deepseek-v4-pro' | 'deepseek/deepseek-v4-pro-0813' | '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.1-flash-image' | 'google/gemini-3.1-flash-image-preview' | 'google/gemini-3.1-flash-lite' | 'google/gemini-3.1-flash-lite-image' | 'google/gemini-3.1-pro-preview' | 'google/gemini-3.5-flash' | 'google/gemini-3.5-flash-lite' | 'google/gemini-3.6-flash' | 'google/gemini-3.7-flash' | 'google/gemini-omni-flash-preview' | 'google/gemma-4-26b-a4b-it' | 'google/gemma-4-31b-it' | 'inception/mercury-2' | 'inception/mercury-coder-small' | 'inclusionai/ling-3.0-flash' | 'interfaze/interfaze-beta' | 'kwaipilot/kat-coder-air-v2.5' | 'kwaipilot/kat-coder-pro-v1' | 'kwaipilot/kat-coder-pro-v2' | 'kwaipilot/kat-coder-pro-v2.5' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'meta/muse-glimmer-30b' | 'meta/muse-spark-1.1' | 'meta/muse-spark-1.2' | 'meta/muse-spark-1.2-contributor' | '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-free' | 'minimax/minimax-m2.7-highspeed' | 'minimax/minimax-m3' | 'minimax/minimax-m3-free' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small-2' | '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' | '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' | 'moonshotai/kimi-k3' | 'moonshotai/kimi-k3-fast' | '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-3.5-lightning' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/gpt-3.5-turbo' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-fast' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-mini-fast' | 'openai/gpt-4.1-nano' | 'openai/gpt-4.1-nano-fast' | 'openai/gpt-4o' | 'openai/gpt-4o-fast' | 'openai/gpt-4o-mini' | 'openai/gpt-4o-mini-fast' | 'openai/gpt-5' | 'openai/gpt-5-codex' | 'openai/gpt-5-fast' | 'openai/gpt-5-mini' | 'openai/gpt-5-mini-fast' | '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-thinking' | 'openai/gpt-5.1-thinking-fast' | 'openai/gpt-5.2' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-fast' | 'openai/gpt-5.2-pro' | 'openai/gpt-5.3-codex' | 'openai/gpt-5.3-codex-fast' | 'openai/gpt-5.4' | 'openai/gpt-5.4-fast' | 'openai/gpt-5.4-mini' | 'openai/gpt-5.4-mini-fast' | 'openai/gpt-5.4-nano' | 'openai/gpt-5.4-pro' | 'openai/gpt-5.5' | 'openai/gpt-5.5-fast' | 'openai/gpt-5.5-pro' | 'openai/gpt-5.6-luna' | 'openai/gpt-5.6-luna-fast' | 'openai/gpt-5.6-sol' | 'openai/gpt-5.6-sol-fast' | 'openai/gpt-5.6-terra' | 'openai/gpt-5.6-terra-fast' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-120b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-fast' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'openai/o4-mini-fast' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning-pro' | 'poolside/laguna-s-2.1' | 'poolside/laguna-s-2.1-free' | 'sakana/fugu-ultra' | 'sakana/namazu' | 'spacexai/grok-4.1-fast-non-reasoning' | 'spacexai/grok-4.1-fast-reasoning' | 'spacexai/grok-4.20-multi-agent' | 'spacexai/grok-4.20-multi-agent-beta' | 'spacexai/grok-4.20-non-reasoning' | 'spacexai/grok-4.20-non-reasoning-beta' | 'spacexai/grok-4.20-reasoning' | 'spacexai/grok-4.20-reasoning-beta' | 'spacexai/grok-4.3' | 'spacexai/grok-4.5' | 'spacexai/grok-4.6' | 'spacexai/grok-build-0.1' | 'stepfun/step-3.5-flash' | 'stepfun/step-3.7-flash' | 'tencent/hy-mt2-lite' | 'tencent/hy-mt2-plus' | 'tencent/hy-mt2-pro' | 'tencent/hy3' | 'thinkingmachines/inkling' | 'thinkingmachines/inkling-small' | '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.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-5.3' | 'zai/glm-5.3-flash' | 'zai/glm-5v-turbo' | (string & {});
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Shared WebSocket subprotocol contract for AI Gateway realtime and streaming
|
|
@@ -83,7 +83,7 @@ type GatewaySpeechModelId = 'fish-audio/s1' | 'fish-audio/s1-free' | 'fish-audio
|
|
|
83
83
|
|
|
84
84
|
type GatewayTranscriptionModelId = 'fish-audio/transcribe-1' | 'fish-audio/transcribe-1-free' | 'openai/gpt-4o-mini-transcribe' | 'openai/gpt-4o-transcribe' | 'openai/gpt-realtime-whisper' | 'openai/whisper-1' | 'spacexai/grok-stt' | (string & {});
|
|
85
85
|
|
|
86
|
-
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' | 'alibaba/wan-v2.7-r2v' | 'alibaba/wan-v2.7-t2v' | 'bfl/flux-3-video' | 'bytedance/seedance-2.0' | 'bytedance/seedance-2.0-fast' | 'bytedance/seedance-2.0-mini' | 'bytedance/seedance-2.5' | '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' | 'google/veo-3.1-lite-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' | 'minimax/minimax-h3' | 'spacexai/grok-imagine-video' | 'spacexai/grok-imagine-video-1.5' | 'spacexai/grok-imagine-video-1.5-preview' | (string & {});
|
|
86
|
+
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' | 'alibaba/wan-v2.7-r2v' | 'alibaba/wan-v2.7-t2v' | 'alibaba/wan-v3.0-video' | 'bfl/flux-3-video' | 'bytedance/seedance-2.0' | 'bytedance/seedance-2.0-fast' | 'bytedance/seedance-2.0-mini' | 'bytedance/seedance-2.5' | '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' | 'google/veo-3.1-lite-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' | 'minimax/minimax-h3' | 'spacexai/grok-imagine-video' | 'spacexai/grok-imagine-video-1.5' | 'spacexai/grok-imagine-video-1.5-preview' | (string & {});
|
|
87
87
|
|
|
88
88
|
declare const KNOWN_MODEL_TYPES: readonly ["embedding", "image", "language", "realtime", "reranking", "speech", "transcription", "video"];
|
|
89
89
|
type KnownModelType = (typeof KNOWN_MODEL_TYPES)[number];
|
|
@@ -247,15 +247,28 @@ interface GatewayGenerationInfo {
|
|
|
247
247
|
type TakoSearchEffort = 'deep' | 'fast' | 'instant';
|
|
248
248
|
type TakoContentFormat = 'card_json' | 'csv' | 'json_compact' | 'json_records';
|
|
249
249
|
interface TakoDataSourceConfig {
|
|
250
|
-
/**
|
|
250
|
+
/**
|
|
251
|
+
* Maximum number of data results to return (1-20). When includeContents is
|
|
252
|
+
* true, each additional result adds its own data surcharge.
|
|
253
|
+
*/
|
|
251
254
|
count?: number;
|
|
252
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* Inline rows for each data result. This adds a data surcharge based on row
|
|
257
|
+
* count and dataset source. To estimate cost, search with includeContents
|
|
258
|
+
* disabled and inspect cards.content.export_pricing. This applies to every
|
|
259
|
+
* returned card; limit sources.data.count and sources.data.maxRows to control
|
|
260
|
+
* cost.
|
|
261
|
+
*/
|
|
253
262
|
includeContents?: boolean;
|
|
254
263
|
/** Requested delivery mode for card data. Search cards are always inlined. */
|
|
255
264
|
mode?: 'inline' | 'url';
|
|
256
265
|
/** Serialization for inlined card data. */
|
|
257
266
|
contentFormat?: TakoContentFormat;
|
|
258
|
-
/**
|
|
267
|
+
/**
|
|
268
|
+
* Maximum rows to inline per result. Omit to use the allowance in
|
|
269
|
+
* cards.content.export_pricing. A data surcharge applies per 1,000 exported
|
|
270
|
+
* rows; lower values reduce cost.
|
|
271
|
+
*/
|
|
259
272
|
maxRows?: number;
|
|
260
273
|
/** Data Graph node IDs to prioritize. */
|
|
261
274
|
nodeIds?: string[];
|
|
@@ -417,7 +430,6 @@ interface TakoCard {
|
|
|
417
430
|
relevance?: 'High' | 'Low' | 'Medium' | null;
|
|
418
431
|
content?: TakoResultContent | null;
|
|
419
432
|
exportable?: boolean;
|
|
420
|
-
relevance_score?: number | null;
|
|
421
433
|
nodes?: Array<{
|
|
422
434
|
id: string;
|
|
423
435
|
type: 'entity' | 'metric';
|
|
@@ -441,7 +453,6 @@ interface TakoWebResult {
|
|
|
441
453
|
source_name?: string | null;
|
|
442
454
|
publish_date?: string | null;
|
|
443
455
|
content?: TakoResultContent | null;
|
|
444
|
-
citation_number?: number | null;
|
|
445
456
|
}
|
|
446
457
|
interface TakoSearchResponse {
|
|
447
458
|
request_id: string;
|
|
@@ -1058,6 +1069,30 @@ interface GatewayProviderSettings {
|
|
|
1058
1069
|
declare function createGateway(options?: GatewayProviderSettings): GatewayProvider;
|
|
1059
1070
|
declare const gateway: GatewayProvider;
|
|
1060
1071
|
|
|
1072
|
+
/**
|
|
1073
|
+
* Metadata for an asynchronous AI Gateway job.
|
|
1074
|
+
*/
|
|
1075
|
+
type GatewayAsyncJobMetadata = {
|
|
1076
|
+
readonly jobId: string;
|
|
1077
|
+
readonly status: string;
|
|
1078
|
+
/**
|
|
1079
|
+
* Secret for verifying customer webhook deliveries. This is sensitive,
|
|
1080
|
+
* start-response-only metadata and must not be logged or forwarded.
|
|
1081
|
+
*/
|
|
1082
|
+
readonly webhookSigningSecret?: string;
|
|
1083
|
+
readonly [key: string]: JSONValue | undefined;
|
|
1084
|
+
};
|
|
1085
|
+
/**
|
|
1086
|
+
* Shape of the inner `providerMetadata.gateway` object returned by AI Gateway
|
|
1087
|
+
* operations.
|
|
1088
|
+
*
|
|
1089
|
+
* Additional fields may be added without a package update.
|
|
1090
|
+
*/
|
|
1091
|
+
type GatewayProviderMetadata = {
|
|
1092
|
+
readonly asyncJob?: GatewayAsyncJobMetadata;
|
|
1093
|
+
readonly [key: string]: JSONValue | undefined;
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1061
1096
|
type GatewayProviderOptions = {
|
|
1062
1097
|
/**
|
|
1063
1098
|
* Service-owned options may be added by the Gateway without requiring an SDK
|
|
@@ -1319,4 +1354,4 @@ declare class GatewayResponseError extends GatewayError {
|
|
|
1319
1354
|
|
|
1320
1355
|
declare const VERSION: string;
|
|
1321
1356
|
|
|
1322
|
-
export { GATEWAY_AUTH_SUBPROTOCOL_PREFIX, GATEWAY_REALTIME_SUBPROTOCOL, GATEWAY_TEAM_SUBPROTOCOL_PREFIX, GATEWAY_TRANSCRIPTION_SUBPROTOCOL, GatewayAuthenticationError, type GatewayCreditsResponse, type GatewayEmbeddingModelId, GatewayError, type GatewayErrorResponse, GatewayFailedDependencyError, GatewayForbiddenError, type GatewayGenerationInfo, type GatewayGenerationInfoParams, type GatewayImageModelId, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayProviderOptions as GatewayLanguageModelOptions, type GatewayLanguageModelSpecification, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayModelId, GatewayModelNotFoundError, GatewayNotFoundError, type GatewayProvider, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, type GatewayRealtimeModelId, type GatewayRerankingModelId, GatewayResponseError, type GatewaySpeechModelId, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayTranscriptionModelId, type GatewayVideoModelId, VERSION, createGateway, createGateway as createGatewayProvider, gateway, getGatewayRealtimeAuthToken, getGatewayRealtimeProtocols, getGatewayRealtimeTeamIdOrSlug, getGatewayTranscriptionProtocols };
|
|
1357
|
+
export { GATEWAY_AUTH_SUBPROTOCOL_PREFIX, GATEWAY_REALTIME_SUBPROTOCOL, GATEWAY_TEAM_SUBPROTOCOL_PREFIX, GATEWAY_TRANSCRIPTION_SUBPROTOCOL, type GatewayAsyncJobMetadata, GatewayAuthenticationError, type GatewayCreditsResponse, type GatewayEmbeddingModelId, GatewayError, type GatewayErrorResponse, GatewayFailedDependencyError, GatewayForbiddenError, type GatewayGenerationInfo, type GatewayGenerationInfoParams, type GatewayImageModelId, GatewayInternalServerError, GatewayInvalidRequestError, type GatewayLanguageModelEntry, type GatewayProviderOptions as GatewayLanguageModelOptions, type GatewayLanguageModelSpecification, type GatewayLanguageModelEntry as GatewayModelEntry, type GatewayModelId, GatewayModelNotFoundError, GatewayNotFoundError, type GatewayProvider, type GatewayProviderMetadata, type GatewayProviderOptions, type GatewayProviderSettings, GatewayRateLimitError, type GatewayRealtimeModelId, type GatewayRerankingModelId, GatewayResponseError, type GatewaySpeechModelId, type GatewaySpendReportParams, type GatewaySpendReportResponse, type GatewaySpendReportRow, type GatewayTranscriptionModelId, type GatewayVideoModelId, VERSION, createGateway, createGateway as createGatewayProvider, gateway, getGatewayRealtimeAuthToken, getGatewayRealtimeProtocols, getGatewayRealtimeTeamIdOrSlug, getGatewayTranscriptionProtocols };
|
package/dist/index.js
CHANGED
|
@@ -1007,16 +1007,14 @@ var gatewayGenerationInfoResponseSchema = lazySchema7(
|
|
|
1007
1007
|
);
|
|
1008
1008
|
|
|
1009
1009
|
// src/gateway-language-model-batch.ts
|
|
1010
|
-
import {
|
|
1011
|
-
APICallError as APICallError2
|
|
1012
|
-
} from "@ai-sdk/provider";
|
|
1013
1010
|
import {
|
|
1014
1011
|
combineHeaders as combineHeaders2,
|
|
1015
1012
|
convertAsyncIteratorToReadableStream,
|
|
1016
1013
|
createJsonErrorResponseHandler as createJsonErrorResponseHandler5,
|
|
1014
|
+
createJsonLinesResponseHandler,
|
|
1017
1015
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
1018
1016
|
getErrorMessage as getErrorMessage5,
|
|
1019
|
-
|
|
1017
|
+
normalizeBatchRequestCounts,
|
|
1020
1018
|
postJsonToApi as postJsonToApi2,
|
|
1021
1019
|
resolve as resolve5,
|
|
1022
1020
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
@@ -1232,7 +1230,8 @@ var GatewayBatchLanguageModel = class _GatewayBatchLanguageModel extends Gateway
|
|
|
1232
1230
|
requests,
|
|
1233
1231
|
providerOptions,
|
|
1234
1232
|
headers,
|
|
1235
|
-
abortSignal
|
|
1233
|
+
abortSignal,
|
|
1234
|
+
webhookUrl
|
|
1236
1235
|
}) {
|
|
1237
1236
|
var _a12;
|
|
1238
1237
|
const resolvedHeaders = this.config.headers ? await resolve5(this.config.headers) : void 0;
|
|
@@ -1249,6 +1248,7 @@ var GatewayBatchLanguageModel = class _GatewayBatchLanguageModel extends Gateway
|
|
|
1249
1248
|
idempotencyKey != null ? { "idempotency-key": idempotencyKey } : void 0
|
|
1250
1249
|
),
|
|
1251
1250
|
body: {
|
|
1251
|
+
...webhookUrl != null && { callbackUrl: webhookUrl },
|
|
1252
1252
|
modelId: this.modelId,
|
|
1253
1253
|
requests: requests.map((request) => ({
|
|
1254
1254
|
id: request.id,
|
|
@@ -1344,7 +1344,7 @@ var GatewayBatchLanguageModel = class _GatewayBatchLanguageModel extends Gateway
|
|
|
1344
1344
|
}) {
|
|
1345
1345
|
const resolvedHeaders = this.config.headers ? await resolve5(this.config.headers) : void 0;
|
|
1346
1346
|
try {
|
|
1347
|
-
const { value:
|
|
1347
|
+
const { value: lines } = await postJsonToApi2({
|
|
1348
1348
|
url: this.getBatchUrl("results"),
|
|
1349
1349
|
headers: combineHeaders2(
|
|
1350
1350
|
resolvedHeaders,
|
|
@@ -1353,24 +1353,9 @@ var GatewayBatchLanguageModel = class _GatewayBatchLanguageModel extends Gateway
|
|
|
1353
1353
|
await resolve5(this.config.o11yHeaders)
|
|
1354
1354
|
),
|
|
1355
1355
|
body: { batchId },
|
|
1356
|
-
successfulResponseHandler:
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
requestBodyValues
|
|
1360
|
-
}) => {
|
|
1361
|
-
if (response.body == null) {
|
|
1362
|
-
throw new APICallError2({
|
|
1363
|
-
message: "Batch results response body is empty",
|
|
1364
|
-
url,
|
|
1365
|
-
requestBodyValues,
|
|
1366
|
-
statusCode: response.status
|
|
1367
|
-
});
|
|
1368
|
-
}
|
|
1369
|
-
return {
|
|
1370
|
-
value: response.body,
|
|
1371
|
-
responseHeaders: Object.fromEntries([...response.headers])
|
|
1372
|
-
};
|
|
1373
|
-
},
|
|
1356
|
+
successfulResponseHandler: createJsonLinesResponseHandler(
|
|
1357
|
+
gatewayBatchItemResultLineSchema
|
|
1358
|
+
),
|
|
1374
1359
|
failedResponseHandler: createJsonErrorResponseHandler5({
|
|
1375
1360
|
errorSchema: z.any(),
|
|
1376
1361
|
errorToMessage: (data) => {
|
|
@@ -1382,7 +1367,7 @@ var GatewayBatchLanguageModel = class _GatewayBatchLanguageModel extends Gateway
|
|
|
1382
1367
|
fetch: this.config.fetch
|
|
1383
1368
|
});
|
|
1384
1369
|
return convertAsyncIteratorToReadableStream(
|
|
1385
|
-
|
|
1370
|
+
convertGatewayBatchResultLines(lines)
|
|
1386
1371
|
);
|
|
1387
1372
|
} catch (error) {
|
|
1388
1373
|
if (isAbortOrTimeoutError(error)) {
|
|
@@ -1435,7 +1420,13 @@ function isAbortOrTimeoutError(error) {
|
|
|
1435
1420
|
return error.name === "AbortError" || error.name === "TimeoutError";
|
|
1436
1421
|
}
|
|
1437
1422
|
function convertGatewayBatchStatus(body) {
|
|
1438
|
-
|
|
1423
|
+
var _a12, _b12, _c, _d;
|
|
1424
|
+
const requestCounts = normalizeBatchRequestCounts({
|
|
1425
|
+
total: (_a12 = body.requestCounts) == null ? void 0 : _a12.total,
|
|
1426
|
+
pending: (_b12 = body.requestCounts) == null ? void 0 : _b12.pending,
|
|
1427
|
+
completed: (_c = body.requestCounts) == null ? void 0 : _c.completed,
|
|
1428
|
+
failed: (_d = body.requestCounts) == null ? void 0 : _d.failed
|
|
1429
|
+
});
|
|
1439
1430
|
return {
|
|
1440
1431
|
status: body.status,
|
|
1441
1432
|
...body.rawStatus != null && { rawStatus: body.rawStatus },
|
|
@@ -1457,67 +1448,18 @@ function convertGatewayBatchStatus(body) {
|
|
|
1457
1448
|
}
|
|
1458
1449
|
};
|
|
1459
1450
|
}
|
|
1460
|
-
function
|
|
1461
|
-
if (counts == null || typeof counts.total !== "number" || typeof counts.pending !== "number" || typeof counts.completed !== "number" || typeof counts.failed !== "number") {
|
|
1462
|
-
return void 0;
|
|
1463
|
-
}
|
|
1464
|
-
return {
|
|
1465
|
-
total: counts.total,
|
|
1466
|
-
pending: counts.pending,
|
|
1467
|
-
completed: counts.completed,
|
|
1468
|
-
failed: counts.failed
|
|
1469
|
-
};
|
|
1470
|
-
}
|
|
1471
|
-
async function* parseGatewayBatchResultLines(stream) {
|
|
1472
|
-
const reader = stream.getReader();
|
|
1473
|
-
const decoder = new TextDecoder();
|
|
1474
|
-
let buffer = "";
|
|
1475
|
-
let finished = false;
|
|
1476
|
-
try {
|
|
1477
|
-
while (true) {
|
|
1478
|
-
const { done, value } = await reader.read();
|
|
1479
|
-
if (done) {
|
|
1480
|
-
finished = true;
|
|
1481
|
-
buffer += decoder.decode();
|
|
1482
|
-
break;
|
|
1483
|
-
}
|
|
1484
|
-
buffer += decoder.decode(value, { stream: true });
|
|
1485
|
-
let lineEnd = buffer.indexOf("\n");
|
|
1486
|
-
while (lineEnd !== -1) {
|
|
1487
|
-
const line = buffer.slice(0, lineEnd).replace(/\r$/, "");
|
|
1488
|
-
buffer = buffer.slice(lineEnd + 1);
|
|
1489
|
-
if (line.trim().length > 0) {
|
|
1490
|
-
yield await parseGatewayBatchResultLine(line);
|
|
1491
|
-
}
|
|
1492
|
-
lineEnd = buffer.indexOf("\n");
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
const finalLine = buffer.replace(/\r$/, "");
|
|
1496
|
-
if (finalLine.trim().length > 0) {
|
|
1497
|
-
yield await parseGatewayBatchResultLine(finalLine);
|
|
1498
|
-
}
|
|
1499
|
-
} finally {
|
|
1500
|
-
if (!finished) {
|
|
1501
|
-
await reader.cancel().catch(() => {
|
|
1502
|
-
});
|
|
1503
|
-
}
|
|
1504
|
-
reader.releaseLock();
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
async function parseGatewayBatchResultLine(line) {
|
|
1451
|
+
async function* convertGatewayBatchResultLines(lines) {
|
|
1508
1452
|
var _a12;
|
|
1509
|
-
const
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
if (response !== void 0 && typeof response.timestamp === "string") {
|
|
1517
|
-
response.timestamp = new Date(response.timestamp);
|
|
1453
|
+
for await (const line of lines) {
|
|
1454
|
+
const item = line;
|
|
1455
|
+
if (item.status === "succeeded") {
|
|
1456
|
+
const response = (_a12 = item.result) == null ? void 0 : _a12.response;
|
|
1457
|
+
if (response !== void 0 && typeof response.timestamp === "string") {
|
|
1458
|
+
response.timestamp = new Date(response.timestamp);
|
|
1459
|
+
}
|
|
1518
1460
|
}
|
|
1461
|
+
yield item;
|
|
1519
1462
|
}
|
|
1520
|
-
return item;
|
|
1521
1463
|
}
|
|
1522
1464
|
var gatewayBatchItemResultLineSchema = z.object({
|
|
1523
1465
|
id: z.string(),
|
|
@@ -1851,7 +1793,7 @@ var gatewayImageResponseSchema = z.object({
|
|
|
1851
1793
|
|
|
1852
1794
|
// src/gateway-video-model.ts
|
|
1853
1795
|
import {
|
|
1854
|
-
APICallError as
|
|
1796
|
+
APICallError as APICallError2,
|
|
1855
1797
|
getErrorMessage as getErrorMessage8
|
|
1856
1798
|
} from "@ai-sdk/provider";
|
|
1857
1799
|
import {
|
|
@@ -1895,7 +1837,7 @@ var GatewayVideoModel = class {
|
|
|
1895
1837
|
requestBodyValues
|
|
1896
1838
|
}) => {
|
|
1897
1839
|
if (response.body == null) {
|
|
1898
|
-
throw new
|
|
1840
|
+
throw new APICallError2({
|
|
1899
1841
|
message: "SSE response body is empty",
|
|
1900
1842
|
url,
|
|
1901
1843
|
requestBodyValues,
|
|
@@ -1910,7 +1852,7 @@ var GatewayVideoModel = class {
|
|
|
1910
1852
|
const { done, value: parseResult } = await reader.read();
|
|
1911
1853
|
reader.releaseLock();
|
|
1912
1854
|
if (done || !parseResult) {
|
|
1913
|
-
throw new
|
|
1855
|
+
throw new APICallError2({
|
|
1914
1856
|
message: "SSE stream ended without a data event",
|
|
1915
1857
|
url,
|
|
1916
1858
|
requestBodyValues,
|
|
@@ -1918,7 +1860,7 @@ var GatewayVideoModel = class {
|
|
|
1918
1860
|
});
|
|
1919
1861
|
}
|
|
1920
1862
|
if (!parseResult.success) {
|
|
1921
|
-
throw new
|
|
1863
|
+
throw new APICallError2({
|
|
1922
1864
|
message: "Failed to parse video SSE event",
|
|
1923
1865
|
cause: parseResult.error,
|
|
1924
1866
|
url,
|
|
@@ -1928,7 +1870,7 @@ var GatewayVideoModel = class {
|
|
|
1928
1870
|
}
|
|
1929
1871
|
const event = parseResult.value;
|
|
1930
1872
|
if (event.type === "error") {
|
|
1931
|
-
throw new
|
|
1873
|
+
throw new APICallError2({
|
|
1932
1874
|
message: event.message,
|
|
1933
1875
|
statusCode: event.statusCode,
|
|
1934
1876
|
url,
|
|
@@ -3218,13 +3160,19 @@ import {
|
|
|
3218
3160
|
zodSchema as zodSchema13
|
|
3219
3161
|
} from "@ai-sdk/provider-utils";
|
|
3220
3162
|
var takoDataSourceInputSchema = z.object({
|
|
3221
|
-
count: z.number().optional().describe(
|
|
3222
|
-
|
|
3163
|
+
count: z.number().optional().describe(
|
|
3164
|
+
"Maximum number of data results to return (1-20). When include_contents is true, each additional result adds its own data surcharge."
|
|
3165
|
+
),
|
|
3166
|
+
include_contents: z.boolean().optional().describe(
|
|
3167
|
+
"Inline rows for each data result. This adds a data surcharge based on row count and dataset source. To estimate cost, search with include_contents disabled and inspect cards.content.export_pricing. This applies to every returned card; limit sources.data.count and sources.data.max_rows to control cost."
|
|
3168
|
+
),
|
|
3223
3169
|
mode: z.enum(["inline", "url"]).optional().describe(
|
|
3224
3170
|
"Requested data delivery mode. Search card data is always inline."
|
|
3225
3171
|
),
|
|
3226
3172
|
content_format: z.enum(["card_json", "csv", "json_compact", "json_records"]).optional().describe("Serialization for inlined card data."),
|
|
3227
|
-
max_rows: z.number().optional().describe(
|
|
3173
|
+
max_rows: z.number().optional().describe(
|
|
3174
|
+
"Maximum rows to inline per result. Omit to use the allowance in cards.content.export_pricing. A data surcharge applies per 1,000 exported rows; lower values reduce cost."
|
|
3175
|
+
),
|
|
3228
3176
|
node_ids: z.array(z.string()).optional().describe("Data Graph node IDs to prioritize. Maximum 20."),
|
|
3229
3177
|
strict: z.boolean().optional().describe(
|
|
3230
3178
|
"Only return cards matching node_ids. Requires a non-empty node_ids."
|
|
@@ -3356,7 +3304,6 @@ var takoCardSchema = z.object({
|
|
|
3356
3304
|
relevance: z.enum(["High", "Low", "Medium"]).nullish(),
|
|
3357
3305
|
content: takoResultContentSchema.nullish(),
|
|
3358
3306
|
exportable: z.boolean().optional(),
|
|
3359
|
-
relevance_score: z.number().nullish(),
|
|
3360
3307
|
nodes: z.array(
|
|
3361
3308
|
z.object({
|
|
3362
3309
|
id: z.string(),
|
|
@@ -3378,8 +3325,7 @@ var takoWebResultSchema = z.object({
|
|
|
3378
3325
|
snippet: z.string().nullish(),
|
|
3379
3326
|
source_name: z.string().nullish(),
|
|
3380
3327
|
publish_date: z.string().nullish(),
|
|
3381
|
-
content: takoResultContentSchema.nullish()
|
|
3382
|
-
citation_number: z.number().nullish()
|
|
3328
|
+
content: takoResultContentSchema.nullish()
|
|
3383
3329
|
}).passthrough();
|
|
3384
3330
|
var takoSearchOutputSchema = lazySchema13(
|
|
3385
3331
|
() => zodSchema13(
|
|
@@ -3465,7 +3411,7 @@ async function getVercelRequestId() {
|
|
|
3465
3411
|
}
|
|
3466
3412
|
|
|
3467
3413
|
// src/version.ts
|
|
3468
|
-
var VERSION = true ? "4.0.
|
|
3414
|
+
var VERSION = true ? "4.0.67" : "0.0.0-test";
|
|
3469
3415
|
|
|
3470
3416
|
// src/gateway-provider.ts
|
|
3471
3417
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|