@ai-sdk/gateway 3.0.144 → 3.0.145
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 +9 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +39 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/gateway-image-model.ts +7 -1
- package/src/gateway-speech-model.ts +8 -6
- package/src/gateway-transcription-model.ts +7 -2
- package/src/gateway-video-model-settings.ts +2 -0
- package/src/gateway-video-model.ts +7 -1
- package/src/map-gateway-warnings.ts +21 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/gateway",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.145",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@vercel/oidc": "3.2.0",
|
|
34
34
|
"@ai-sdk/provider": "3.0.13",
|
|
35
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
35
|
+
"@ai-sdk/provider-utils": "4.0.37"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "18.15.11",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"tsx": "4.19.2",
|
|
41
41
|
"typescript": "5.8.3",
|
|
42
42
|
"zod": "3.25.76",
|
|
43
|
-
"@
|
|
44
|
-
"@ai-
|
|
43
|
+
"@ai-sdk/test-server": "1.0.6",
|
|
44
|
+
"@vercel/ai-tsconfig": "0.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type Resolvable,
|
|
14
14
|
} from '@ai-sdk/provider-utils';
|
|
15
15
|
import { z } from 'zod/v4';
|
|
16
|
+
import { mapGatewayWarnings } from './map-gateway-warnings';
|
|
16
17
|
import type { GatewayConfig } from './gateway-config';
|
|
17
18
|
import { asGatewayError } from './errors';
|
|
18
19
|
import { parseAuthMethod } from './errors/parse-auth-method';
|
|
@@ -87,7 +88,7 @@ export class GatewayImageModel implements ImageModelV3 {
|
|
|
87
88
|
|
|
88
89
|
return {
|
|
89
90
|
images: responseBody.images, // Always base64 strings from server
|
|
90
|
-
warnings: responseBody.warnings
|
|
91
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
91
92
|
providerMetadata:
|
|
92
93
|
responseBody.providerMetadata as ImageModelV3ProviderMetadata,
|
|
93
94
|
response: {
|
|
@@ -147,6 +148,11 @@ const gatewayImageWarningSchema = z.discriminatedUnion('type', [
|
|
|
147
148
|
feature: z.string(),
|
|
148
149
|
details: z.string().optional(),
|
|
149
150
|
}),
|
|
151
|
+
z.object({
|
|
152
|
+
type: z.literal('deprecated'),
|
|
153
|
+
setting: z.string(),
|
|
154
|
+
message: z.string(),
|
|
155
|
+
}),
|
|
150
156
|
z.object({
|
|
151
157
|
type: z.literal('other'),
|
|
152
158
|
message: z.string(),
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SharedV3ProviderMetadata,
|
|
3
|
-
SharedV3Warning,
|
|
4
|
-
SpeechModelV3,
|
|
5
|
-
} from '@ai-sdk/provider';
|
|
1
|
+
import type { SharedV3ProviderMetadata, SpeechModelV3 } from '@ai-sdk/provider';
|
|
6
2
|
import {
|
|
7
3
|
combineHeaders,
|
|
8
4
|
createJsonErrorResponseHandler,
|
|
@@ -12,6 +8,7 @@ import {
|
|
|
12
8
|
type Resolvable,
|
|
13
9
|
} from '@ai-sdk/provider-utils';
|
|
14
10
|
import { z } from 'zod/v4';
|
|
11
|
+
import { mapGatewayWarnings } from './map-gateway-warnings';
|
|
15
12
|
import { asGatewayError } from './errors';
|
|
16
13
|
import { parseAuthMethod } from './errors/parse-auth-method';
|
|
17
14
|
import type { GatewayConfig } from './gateway-config';
|
|
@@ -80,7 +77,7 @@ export class GatewaySpeechModel implements SpeechModelV3 {
|
|
|
80
77
|
|
|
81
78
|
return {
|
|
82
79
|
audio: responseBody.audio,
|
|
83
|
-
warnings: (responseBody.warnings
|
|
80
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
84
81
|
providerMetadata:
|
|
85
82
|
responseBody.providerMetadata as SharedV3ProviderMetadata,
|
|
86
83
|
response: {
|
|
@@ -123,6 +120,11 @@ const gatewaySpeechWarningSchema = z.discriminatedUnion('type', [
|
|
|
123
120
|
feature: z.string(),
|
|
124
121
|
details: z.string().optional(),
|
|
125
122
|
}),
|
|
123
|
+
z.object({
|
|
124
|
+
type: z.literal('deprecated'),
|
|
125
|
+
setting: z.string(),
|
|
126
|
+
message: z.string(),
|
|
127
|
+
}),
|
|
126
128
|
z.object({
|
|
127
129
|
type: z.literal('other'),
|
|
128
130
|
message: z.string(),
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
SharedV3ProviderMetadata,
|
|
3
|
-
SharedV3Warning,
|
|
4
3
|
TranscriptionModelV3,
|
|
5
4
|
} from '@ai-sdk/provider';
|
|
6
5
|
import {
|
|
@@ -13,6 +12,7 @@ import {
|
|
|
13
12
|
type Resolvable,
|
|
14
13
|
} from '@ai-sdk/provider-utils';
|
|
15
14
|
import { z } from 'zod/v4';
|
|
15
|
+
import { mapGatewayWarnings } from './map-gateway-warnings';
|
|
16
16
|
import { asGatewayError } from './errors';
|
|
17
17
|
import { parseAuthMethod } from './errors/parse-auth-method';
|
|
18
18
|
import type { GatewayConfig } from './gateway-config';
|
|
@@ -79,7 +79,7 @@ export class GatewayTranscriptionModel implements TranscriptionModelV3 {
|
|
|
79
79
|
segments: responseBody.segments ?? [],
|
|
80
80
|
language: responseBody.language ?? undefined,
|
|
81
81
|
durationInSeconds: responseBody.durationInSeconds ?? undefined,
|
|
82
|
-
warnings: (responseBody.warnings
|
|
82
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
83
83
|
providerMetadata:
|
|
84
84
|
responseBody.providerMetadata as SharedV3ProviderMetadata,
|
|
85
85
|
response: {
|
|
@@ -122,6 +122,11 @@ const gatewayTranscriptionWarningSchema = z.discriminatedUnion('type', [
|
|
|
122
122
|
feature: z.string(),
|
|
123
123
|
details: z.string().optional(),
|
|
124
124
|
}),
|
|
125
|
+
z.object({
|
|
126
|
+
type: z.literal('deprecated'),
|
|
127
|
+
setting: z.string(),
|
|
128
|
+
message: z.string(),
|
|
129
|
+
}),
|
|
125
130
|
z.object({
|
|
126
131
|
type: z.literal('other'),
|
|
127
132
|
message: z.string(),
|
|
@@ -5,6 +5,8 @@ export type GatewayVideoModelId =
|
|
|
5
5
|
| 'alibaba/wan-v2.6-r2v'
|
|
6
6
|
| 'alibaba/wan-v2.6-r2v-flash'
|
|
7
7
|
| 'alibaba/wan-v2.6-t2v'
|
|
8
|
+
| 'alibaba/wan-v2.7-r2v'
|
|
9
|
+
| 'alibaba/wan-v2.7-t2v'
|
|
8
10
|
| 'bytedance/seedance-2.0'
|
|
9
11
|
| 'bytedance/seedance-2.0-fast'
|
|
10
12
|
| 'bytedance/seedance-v1.0-pro'
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
type Resolvable,
|
|
18
18
|
} from '@ai-sdk/provider-utils';
|
|
19
19
|
import { z } from 'zod/v4';
|
|
20
|
+
import { mapGatewayWarnings } from './map-gateway-warnings';
|
|
20
21
|
import type { GatewayConfig } from './gateway-config';
|
|
21
22
|
import { asGatewayError } from './errors';
|
|
22
23
|
import { parseAuthMethod } from './errors/parse-auth-method';
|
|
@@ -183,7 +184,7 @@ export class GatewayVideoModel implements Experimental_VideoModelV3 {
|
|
|
183
184
|
|
|
184
185
|
return {
|
|
185
186
|
videos: responseBody.videos,
|
|
186
|
-
warnings: responseBody.warnings
|
|
187
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
187
188
|
providerMetadata:
|
|
188
189
|
responseBody.providerMetadata as SharedV3ProviderMetadata,
|
|
189
190
|
response: {
|
|
@@ -249,6 +250,11 @@ const gatewayVideoWarningSchema = z.discriminatedUnion('type', [
|
|
|
249
250
|
feature: z.string(),
|
|
250
251
|
details: z.string().optional(),
|
|
251
252
|
}),
|
|
253
|
+
z.object({
|
|
254
|
+
type: z.literal('deprecated'),
|
|
255
|
+
setting: z.string(),
|
|
256
|
+
message: z.string(),
|
|
257
|
+
}),
|
|
252
258
|
z.object({
|
|
253
259
|
type: z.literal('other'),
|
|
254
260
|
message: z.string(),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SharedV3Warning } from '@ai-sdk/provider';
|
|
2
|
+
|
|
3
|
+
type GatewayResponseWarning =
|
|
4
|
+
| SharedV3Warning
|
|
5
|
+
| { type: 'deprecated'; setting: string; message: string };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Maps warnings from gateway responses to `SharedV3Warning`.
|
|
9
|
+
*
|
|
10
|
+
* The gateway backend can emit `deprecated` warnings, which the v3
|
|
11
|
+
* specification cannot represent — they are mapped to `other` warnings.
|
|
12
|
+
*/
|
|
13
|
+
export function mapGatewayWarnings(
|
|
14
|
+
warnings: Array<GatewayResponseWarning> | undefined,
|
|
15
|
+
): Array<SharedV3Warning> {
|
|
16
|
+
return (warnings ?? []).map(warning =>
|
|
17
|
+
warning.type === 'deprecated'
|
|
18
|
+
? { type: 'other', message: warning.message }
|
|
19
|
+
: warning,
|
|
20
|
+
);
|
|
21
|
+
}
|