@ai-sdk/gateway 2.0.36 → 2.0.38
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +87 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/gateway
|
|
2
2
|
|
|
3
|
+
## 2.0.38
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8aac221: chore(provider/gateway): update gateway model settings files
|
|
8
|
+
|
|
9
|
+
## 2.0.37
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 3f04ffe: fix (provider/gateway): added custom error class and message for client side timeouts
|
|
14
|
+
|
|
3
15
|
## 2.0.36
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV2, ProviderV2, EmbeddingModelV2, ImageModelV2, TypeValida
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferValidator } 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-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | '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-opus-4.6' | '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-exp' | 'deepseek/deepseek-v3.2-exp-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-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | '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-opus-4.6' | '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-exp' | 'deepseek/deepseek-v3.2-exp-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-pro-preview' | 'google/gemini-3-pro-image' | 'google/gemini-3-flash' | 'inception/mercury-coder-small' | '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' | 'mistral/codestral' | 'mistral/devstral-small' | 'mistral/magistral-medium' | 'mistral/magistral-medium-2506' | 'mistral/magistral-small' | 'mistral/magistral-small-2506' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large' | 'mistral/mistral-medium' | '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' | '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-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat-latest' | '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/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-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-code-fast-1' | '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
6
|
|
|
7
7
|
interface GatewayLanguageModelEntry {
|
|
8
8
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV2, ProviderV2, EmbeddingModelV2, ImageModelV2, TypeValida
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction, InferValidator } 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-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | '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-opus-4.6' | '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-exp' | 'deepseek/deepseek-v3.2-exp-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-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | '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-opus-4.6' | '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-exp' | 'deepseek/deepseek-v3.2-exp-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-pro-preview' | 'google/gemini-3-pro-image' | 'google/gemini-3-flash' | 'inception/mercury-coder-small' | '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' | 'mistral/codestral' | 'mistral/devstral-small' | 'mistral/magistral-medium' | 'mistral/magistral-medium-2506' | 'mistral/magistral-small' | 'mistral/magistral-small-2506' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large' | 'mistral/mistral-medium' | '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' | '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-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat-latest' | '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/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-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-code-fast-1' | '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
6
|
|
|
7
7
|
interface GatewayLanguageModelEntry {
|
|
8
8
|
/**
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __export = (target, all) => {
|
|
7
|
-
for (var
|
|
8
|
-
__defProp(target,
|
|
7
|
+
for (var name8 in all)
|
|
8
|
+
__defProp(target, name8, { get: all[name8], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -324,22 +324,88 @@ var gatewayErrorResponseSchema = (0, import_provider_utils2.lazyValidator)(
|
|
|
324
324
|
)
|
|
325
325
|
);
|
|
326
326
|
|
|
327
|
+
// src/errors/gateway-timeout-error.ts
|
|
328
|
+
var name7 = "GatewayTimeoutError";
|
|
329
|
+
var marker8 = `vercel.ai.gateway.error.${name7}`;
|
|
330
|
+
var symbol8 = Symbol.for(marker8);
|
|
331
|
+
var _a8, _b8;
|
|
332
|
+
var GatewayTimeoutError = class _GatewayTimeoutError extends (_b8 = GatewayError, _a8 = symbol8, _b8) {
|
|
333
|
+
constructor({
|
|
334
|
+
message = "Request timed out",
|
|
335
|
+
statusCode = 408,
|
|
336
|
+
cause
|
|
337
|
+
} = {}) {
|
|
338
|
+
super({ message, statusCode, cause });
|
|
339
|
+
this[_a8] = true;
|
|
340
|
+
// used in isInstance
|
|
341
|
+
this.name = name7;
|
|
342
|
+
this.type = "timeout_error";
|
|
343
|
+
}
|
|
344
|
+
static isInstance(error) {
|
|
345
|
+
return GatewayError.hasMarker(error) && symbol8 in error;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Creates a helpful timeout error message with troubleshooting guidance
|
|
349
|
+
*/
|
|
350
|
+
static createTimeoutError({
|
|
351
|
+
originalMessage,
|
|
352
|
+
statusCode = 408,
|
|
353
|
+
cause
|
|
354
|
+
}) {
|
|
355
|
+
const message = `Gateway request timed out: ${originalMessage}
|
|
356
|
+
|
|
357
|
+
This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`;
|
|
358
|
+
return new _GatewayTimeoutError({
|
|
359
|
+
message,
|
|
360
|
+
statusCode,
|
|
361
|
+
cause
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
327
366
|
// src/errors/as-gateway-error.ts
|
|
328
|
-
function
|
|
329
|
-
|
|
367
|
+
function isTimeoutError(error) {
|
|
368
|
+
if (!(error instanceof Error)) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
const errorCode = error.code;
|
|
372
|
+
if (typeof errorCode === "string") {
|
|
373
|
+
const undiciTimeoutCodes = [
|
|
374
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
375
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
376
|
+
"UND_ERR_CONNECT_TIMEOUT"
|
|
377
|
+
];
|
|
378
|
+
return undiciTimeoutCodes.includes(errorCode);
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
async function asGatewayError(error, authMethod) {
|
|
383
|
+
var _a9;
|
|
330
384
|
if (GatewayError.isInstance(error)) {
|
|
331
385
|
return error;
|
|
332
386
|
}
|
|
387
|
+
if (isTimeoutError(error)) {
|
|
388
|
+
return GatewayTimeoutError.createTimeoutError({
|
|
389
|
+
originalMessage: error instanceof Error ? error.message : "Unknown error",
|
|
390
|
+
cause: error
|
|
391
|
+
});
|
|
392
|
+
}
|
|
333
393
|
if (import_provider.APICallError.isInstance(error)) {
|
|
334
|
-
|
|
394
|
+
if (error.cause && isTimeoutError(error.cause)) {
|
|
395
|
+
return GatewayTimeoutError.createTimeoutError({
|
|
396
|
+
originalMessage: error.message,
|
|
397
|
+
cause: error
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
return await createGatewayErrorFromResponse({
|
|
335
401
|
response: extractApiCallResponse(error),
|
|
336
|
-
statusCode: (
|
|
402
|
+
statusCode: (_a9 = error.statusCode) != null ? _a9 : 500,
|
|
337
403
|
defaultMessage: "Gateway request failed",
|
|
338
404
|
cause: error,
|
|
339
405
|
authMethod
|
|
340
406
|
});
|
|
341
407
|
}
|
|
342
|
-
return createGatewayErrorFromResponse({
|
|
408
|
+
return await createGatewayErrorFromResponse({
|
|
343
409
|
response: {},
|
|
344
410
|
statusCode: 500,
|
|
345
411
|
defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
|
|
@@ -638,7 +704,7 @@ var GatewayEmbeddingModel = class {
|
|
|
638
704
|
abortSignal,
|
|
639
705
|
providerOptions
|
|
640
706
|
}) {
|
|
641
|
-
var
|
|
707
|
+
var _a9;
|
|
642
708
|
const resolvedHeaders = await (0, import_provider_utils6.resolve)(this.config.headers());
|
|
643
709
|
try {
|
|
644
710
|
const {
|
|
@@ -669,7 +735,7 @@ var GatewayEmbeddingModel = class {
|
|
|
669
735
|
});
|
|
670
736
|
return {
|
|
671
737
|
embeddings: responseBody.embeddings,
|
|
672
|
-
usage: (
|
|
738
|
+
usage: (_a9 = responseBody.usage) != null ? _a9 : void 0,
|
|
673
739
|
providerMetadata: responseBody.providerMetadata,
|
|
674
740
|
response: { headers: responseHeaders, body: rawValue }
|
|
675
741
|
};
|
|
@@ -721,7 +787,7 @@ var GatewayImageModel = class {
|
|
|
721
787
|
headers,
|
|
722
788
|
abortSignal
|
|
723
789
|
}) {
|
|
724
|
-
var
|
|
790
|
+
var _a9, _b9, _c, _d;
|
|
725
791
|
const resolvedHeaders = await (0, import_provider_utils7.resolve)(this.config.headers());
|
|
726
792
|
try {
|
|
727
793
|
const {
|
|
@@ -757,7 +823,7 @@ var GatewayImageModel = class {
|
|
|
757
823
|
return {
|
|
758
824
|
images: responseBody.images,
|
|
759
825
|
// Always base64 strings from server
|
|
760
|
-
warnings: (
|
|
826
|
+
warnings: (_a9 = responseBody.warnings) != null ? _a9 : [],
|
|
761
827
|
providerMetadata: responseBody.providerMetadata,
|
|
762
828
|
response: {
|
|
763
829
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -766,14 +832,14 @@ var GatewayImageModel = class {
|
|
|
766
832
|
},
|
|
767
833
|
...responseBody.usage != null && {
|
|
768
834
|
usage: {
|
|
769
|
-
inputTokens: (
|
|
835
|
+
inputTokens: (_b9 = responseBody.usage.inputTokens) != null ? _b9 : void 0,
|
|
770
836
|
outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
|
|
771
837
|
totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
|
|
772
838
|
}
|
|
773
839
|
}
|
|
774
840
|
};
|
|
775
841
|
} catch (error) {
|
|
776
|
-
throw asGatewayError(error, await parseAuthMethod(resolvedHeaders));
|
|
842
|
+
throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders));
|
|
777
843
|
}
|
|
778
844
|
}
|
|
779
845
|
getUrl() {
|
|
@@ -995,25 +1061,25 @@ var gatewayTools = {
|
|
|
995
1061
|
var import_oidc = require("@vercel/oidc");
|
|
996
1062
|
var import_oidc2 = require("@vercel/oidc");
|
|
997
1063
|
async function getVercelRequestId() {
|
|
998
|
-
var
|
|
999
|
-
return (
|
|
1064
|
+
var _a9;
|
|
1065
|
+
return (_a9 = (0, import_oidc.getContext)().headers) == null ? void 0 : _a9["x-vercel-id"];
|
|
1000
1066
|
}
|
|
1001
1067
|
|
|
1002
1068
|
// src/gateway-provider.ts
|
|
1003
1069
|
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1004
1070
|
|
|
1005
1071
|
// src/version.ts
|
|
1006
|
-
var VERSION = true ? "2.0.
|
|
1072
|
+
var VERSION = true ? "2.0.38" : "0.0.0-test";
|
|
1007
1073
|
|
|
1008
1074
|
// src/gateway-provider.ts
|
|
1009
1075
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
1010
1076
|
function createGatewayProvider(options = {}) {
|
|
1011
|
-
var
|
|
1077
|
+
var _a9, _b9;
|
|
1012
1078
|
let pendingMetadata = null;
|
|
1013
1079
|
let metadataCache = null;
|
|
1014
|
-
const cacheRefreshMillis = (
|
|
1080
|
+
const cacheRefreshMillis = (_a9 = options.metadataCacheRefreshMillis) != null ? _a9 : 1e3 * 60 * 5;
|
|
1015
1081
|
let lastFetchTime = 0;
|
|
1016
|
-
const baseURL = (
|
|
1082
|
+
const baseURL = (_b9 = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _b9 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
1017
1083
|
const getHeaders = async () => {
|
|
1018
1084
|
const auth = await getGatewayAuthToken(options);
|
|
1019
1085
|
if (auth) {
|
|
@@ -1066,8 +1132,8 @@ function createGatewayProvider(options = {}) {
|
|
|
1066
1132
|
});
|
|
1067
1133
|
};
|
|
1068
1134
|
const getAvailableModels = async () => {
|
|
1069
|
-
var
|
|
1070
|
-
const now = (_c = (
|
|
1135
|
+
var _a10, _b10, _c;
|
|
1136
|
+
const now = (_c = (_b10 = (_a10 = options._internal) == null ? void 0 : _a10.currentDate) == null ? void 0 : _b10.call(_a10).getTime()) != null ? _c : Date.now();
|
|
1071
1137
|
if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
|
|
1072
1138
|
lastFetchTime = now;
|
|
1073
1139
|
pendingMetadata = new GatewayFetchMetadata({
|