@ai-sdk/gateway 3.0.98 → 3.0.100

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.
@@ -9,7 +9,11 @@ import {
9
9
  import { z } from 'zod/v4';
10
10
  import { asGatewayError } from './errors';
11
11
  import type { GatewayConfig } from './gateway-config';
12
- import type { GatewayLanguageModelEntry } from './gateway-model-entry';
12
+ import {
13
+ KNOWN_MODEL_TYPES,
14
+ type GatewayLanguageModelEntry,
15
+ type KnownModelType,
16
+ } from './gateway-model-entry';
13
17
 
14
18
  type GatewayFetchMetadataConfig = GatewayConfig;
15
19
 
@@ -75,41 +79,47 @@ export class GatewayFetchMetadata {
75
79
  const gatewayAvailableModelsResponseSchema = lazySchema(() =>
76
80
  zodSchema(
77
81
  z.object({
78
- models: z.array(
79
- z.object({
80
- id: z.string(),
81
- name: z.string(),
82
- description: z.string().nullish(),
83
- pricing: z
84
- .object({
85
- input: z.string(),
86
- output: z.string(),
87
- input_cache_read: z.string().nullish(),
88
- input_cache_write: z.string().nullish(),
89
- })
90
- .transform(
91
- ({ input, output, input_cache_read, input_cache_write }) => ({
92
- input,
93
- output,
94
- ...(input_cache_read
95
- ? { cachedInputTokens: input_cache_read }
96
- : {}),
97
- ...(input_cache_write
98
- ? { cacheCreationInputTokens: input_cache_write }
99
- : {}),
100
- }),
101
- )
102
- .nullish(),
103
- specification: z.object({
104
- specificationVersion: z.literal('v3'),
105
- provider: z.string(),
106
- modelId: z.string(),
82
+ models: z
83
+ .array(
84
+ z.object({
85
+ id: z.string(),
86
+ name: z.string(),
87
+ description: z.string().nullish(),
88
+ pricing: z
89
+ .object({
90
+ input: z.string(),
91
+ output: z.string(),
92
+ input_cache_read: z.string().nullish(),
93
+ input_cache_write: z.string().nullish(),
94
+ })
95
+ .transform(
96
+ ({ input, output, input_cache_read, input_cache_write }) => ({
97
+ input,
98
+ output,
99
+ ...(input_cache_read
100
+ ? { cachedInputTokens: input_cache_read }
101
+ : {}),
102
+ ...(input_cache_write
103
+ ? { cacheCreationInputTokens: input_cache_write }
104
+ : {}),
105
+ }),
106
+ )
107
+ .nullish(),
108
+ specification: z.object({
109
+ specificationVersion: z.literal('v3'),
110
+ provider: z.string(),
111
+ modelId: z.string(),
112
+ }),
113
+ modelType: z.string().nullish(),
107
114
  }),
108
- modelType: z
109
- .enum(['embedding', 'image', 'language', 'reranking', 'video'])
110
- .nullish(),
111
- }),
112
- ),
115
+ )
116
+ .transform(models =>
117
+ models.filter(
118
+ (m): m is typeof m & { modelType?: KnownModelType | null } =>
119
+ m.modelType == null ||
120
+ KNOWN_MODEL_TYPES.includes(m.modelType as KnownModelType),
121
+ ),
122
+ ),
113
123
  }),
114
124
  ),
115
125
  );
@@ -1,5 +1,15 @@
1
1
  import type { LanguageModelV3 } from '@ai-sdk/provider';
2
2
 
3
+ export const KNOWN_MODEL_TYPES = [
4
+ 'embedding',
5
+ 'image',
6
+ 'language',
7
+ 'reranking',
8
+ 'video',
9
+ ] as const;
10
+
11
+ export type KnownModelType = (typeof KNOWN_MODEL_TYPES)[number];
12
+
3
13
  export interface GatewayLanguageModelEntry {
4
14
  /**
5
15
  * The model id used by the remote provider in model settings and for specifying the
@@ -49,7 +59,7 @@ export interface GatewayLanguageModelEntry {
49
59
  /**
50
60
  * Optional field to differentiate between model types.
51
61
  */
52
- modelType?: 'language' | 'embedding' | 'image' | 'reranking' | 'video' | null;
62
+ modelType?: KnownModelType | null;
53
63
  }
54
64
 
55
65
  export type GatewayLanguageModelSpecification = Pick<
@@ -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
+ | 'bytedance/seedance-2.0'
9
+ | 'bytedance/seedance-2.0-fast'
8
10
  | 'bytedance/seedance-v1.0-lite-i2v'
9
11
  | 'bytedance/seedance-v1.0-lite-t2v'
10
12
  | 'bytedance/seedance-v1.0-pro'