@ai-sdk/deepseek 3.0.92 → 3.0.93

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.
@@ -59,36 +59,110 @@ export type DeepSeekLanguageModelEntry = ModelEntry & {
59
59
  };
60
60
  };
61
61
 
62
- // Preserve the provider page's model set and its image-input exception.
63
- const languageDefinitions = {
64
- 'deepseek-flash': { endpoints: ['chat', 'responses'], image: false },
65
- 'deepseek-v4-flash': { endpoints: ['chat'], image: false },
66
- 'deepseek-v4-pro': { endpoints: ['chat', 'responses'], image: false },
67
- 'deepseek-v4-flash-vision-exp': { endpoints: ['chat'], image: true },
68
- } as const;
62
+ type DeepSeekReasoningEffort = NonNullable<
63
+ DeepSeekLanguageModelChatOptions['reasoningEffort']
64
+ >;
69
65
 
66
+ /**
67
+ * One row of the language model matrix. Every capability that differs between
68
+ * models is one flat cell, and every listed model fills in every cell. Nothing
69
+ * is derived from the model ID.
70
+ *
71
+ * Facts that depend on each other share one cell, so a row cannot contradict
72
+ * itself: a cell is a single value, one of a fixed set of values, or the list
73
+ * of what the model supports.
74
+ *
75
+ * Facts about the serving endpoint (`DeepSeekEndpointOptions`) are not model
76
+ * capabilities and are not cells.
77
+ */
78
+ export type DeepSeekLanguageModelRow = {
79
+ /**
80
+ * The DeepSeek APIs whose model ID types list this model ID. It only types
81
+ * the model IDs and does not change a request.
82
+ */
83
+ endpoints: readonly ('chat' | 'responses')[];
84
+ /**
85
+ * `false`: nothing is documented for the model ID. Text and object
86
+ * generation, tools, log probabilities, and `userId` are then reported as
87
+ * `'unknown'`.
88
+ */
89
+ documented: boolean;
90
+ image: ModelCapability;
91
+ /**
92
+ * The thinking strengths the model accepts. `'unknown'`: it is not
93
+ * documented whether the model reasons. Its `thinking` and
94
+ * `reasoningEffort` options are then reported as `'unknown'`.
95
+ */
96
+ reasoningEfforts: 'unknown' | readonly DeepSeekReasoningEffort[];
97
+ /** Thinking is on unless the request turns it off. */
98
+ thinkingByDefault: boolean;
99
+ /**
100
+ * `true`: the V4 protocol, where every earlier assistant turn sends its
101
+ * `reasoning_content` back. `false`: reasoning of assistant turns before
102
+ * the last user message is dropped.
103
+ */
104
+ assistantHistory: boolean;
105
+ };
106
+
107
+ /**
108
+ * Language model matrix: model IDs by capability. To add a model, add a row
109
+ * and fill in every column.
110
+ */
111
+ const languageModelDefinitions = {
112
+ 'deepseek-flash': {
113
+ endpoints: ['chat', 'responses'],
114
+ documented: true,
115
+ image: false,
116
+ reasoningEfforts: ['low', 'high', 'max'],
117
+ thinkingByDefault: true,
118
+ assistantHistory: true,
119
+ },
120
+ 'deepseek-v4-flash': {
121
+ endpoints: ['chat'],
122
+ documented: true,
123
+ image: false,
124
+ reasoningEfforts: ['low', 'high', 'max'],
125
+ thinkingByDefault: true,
126
+ assistantHistory: true,
127
+ },
128
+ 'deepseek-v4-pro': {
129
+ endpoints: ['chat', 'responses'],
130
+ documented: true,
131
+ image: false,
132
+ reasoningEfforts: ['low', 'high', 'max'],
133
+ thinkingByDefault: true,
134
+ assistantHistory: true,
135
+ },
136
+ 'deepseek-v4-flash-vision-exp': {
137
+ endpoints: ['chat'],
138
+ documented: true,
139
+ image: true,
140
+ reasoningEfforts: ['low', 'high', 'max'],
141
+ thinkingByDefault: true,
142
+ assistantHistory: true,
143
+ },
144
+ } as const satisfies Record<string, DeepSeekLanguageModelRow>;
145
+
146
+ /** Maps a matrix row to its entry. Nothing here inspects the model ID. */
70
147
  function createLanguageModelEntry(
71
- modelId: string,
72
- image?: boolean,
148
+ row: DeepSeekLanguageModelRow,
73
149
  ): DeepSeekLanguageModelEntry {
74
- // Legacy aliases and pre-V4 IDs retain their previous protocol. Unknown IDs
75
- // inherit the current protocol, including assistant reasoning history.
76
- const assistantHistory =
77
- !/(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\.\d+)?)(?=[-/:.]|$)/.test(
78
- modelId,
79
- );
80
- const support = image != null ? true : 'unknown';
150
+ const support = row.documented ? true : 'unknown';
151
+ const reasoningSupport =
152
+ row.reasoningEfforts === 'unknown' ? 'unknown' : true;
81
153
  const language: LanguageCapabilities = {
82
154
  textGeneration: support,
83
- inputs: { image: image ?? 'unknown', audio: false },
155
+ inputs: { image: row.image, audio: false },
84
156
  objectGeneration: support,
85
157
  tools: { usage: support, streaming: support, strict: 'unknown' },
86
158
  reasoning: {
87
- support,
88
- ...(image != null ? { efforts: ['low', 'high', 'max'] } : {}),
159
+ support: reasoningSupport,
160
+ ...(row.reasoningEfforts !== 'unknown'
161
+ ? { efforts: row.reasoningEfforts }
162
+ : {}),
89
163
  configurable: true,
90
- enabledByDefault: modelId === 'deepseek-reasoner' || assistantHistory,
91
- assistantHistory,
164
+ enabledByDefault: row.thinkingByDefault,
165
+ assistantHistory: row.assistantHistory,
92
166
  },
93
167
  sampling: {
94
168
  temperature: { condition: 'Only effective when thinking is disabled.' },
@@ -122,12 +196,41 @@ function createLanguageModelEntry(
122
196
  export const deepseekModelCatalog: Readonly<
123
197
  Record<string, DeepSeekLanguageModelEntry>
124
198
  > = Object.fromEntries(
125
- Object.entries(languageDefinitions).map(([modelId, { image }]) => [
126
- modelId,
127
- createLanguageModelEntry(modelId, image),
128
- ]),
199
+ Object.entries<DeepSeekLanguageModelRow>(languageModelDefinitions).map(
200
+ ([modelId, row]) => [modelId, createLanguageModelEntry(row)],
201
+ ),
129
202
  );
130
203
 
204
+ // Legacy aliases and pre-V4 version IDs, used only for model IDs that are not
205
+ // listed in the matrix.
206
+ const unlistedModelsWithoutAssistantHistory =
207
+ /(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\.\d+)?)(?=[-/:.]|$)/;
208
+
209
+ /**
210
+ * Resolves a model ID that is not listed in the matrix to a row. This is the
211
+ * only place that looks at the model ID.
212
+ */
213
+ function getUnlistedLanguageModelRow(
214
+ modelId: string,
215
+ ): DeepSeekLanguageModelRow {
216
+ // Legacy aliases and pre-V4 IDs retain their previous protocol. Unknown IDs
217
+ // inherit the current protocol, including assistant reasoning history.
218
+ const assistantHistory = !unlistedModelsWithoutAssistantHistory.test(modelId);
219
+ return {
220
+ endpoints: [],
221
+ documented: false,
222
+ image: 'unknown',
223
+ reasoningEfforts: 'unknown',
224
+ thinkingByDefault: modelId === 'deepseek-reasoner' || assistantHistory,
225
+ assistantHistory,
226
+ };
227
+ }
228
+
229
+ /**
230
+ * Returns the entry of a model ID: from its row when it is listed, otherwise
231
+ * from the fallback for unlisted IDs. The serving endpoint's options are then
232
+ * applied on top.
233
+ */
131
234
  export function getDeepSeekLanguageModelEntry(
132
235
  modelId: string,
133
236
  endpoint: DeepSeekEndpointOptions = {},
@@ -137,7 +240,7 @@ export function getDeepSeekLanguageModelEntry(
137
240
  modelId,
138
241
  )
139
242
  ? deepseekModelCatalog[modelId]
140
- : createLanguageModelEntry(modelId);
243
+ : createLanguageModelEntry(getUnlistedLanguageModelRow(modelId));
141
244
  const { language } = entry.capabilities;
142
245
  return {
143
246
  ...entry,
@@ -169,10 +272,10 @@ export function getDeepSeekLanguageModelEntry(
169
272
  }
170
273
 
171
274
  type DeepSeekEndpointModelId<Endpoint extends 'chat' | 'responses'> = {
172
- [ModelId in keyof typeof languageDefinitions]: Endpoint extends (typeof languageDefinitions)[ModelId]['endpoints'][number]
275
+ [ModelId in keyof typeof languageModelDefinitions]: Endpoint extends (typeof languageModelDefinitions)[ModelId]['endpoints'][number]
173
276
  ? ModelId
174
277
  : never;
175
- }[keyof typeof languageDefinitions];
278
+ }[keyof typeof languageModelDefinitions];
176
279
 
177
280
  /** Known model IDs, derived from the declarations used to build the catalog. */
178
281
  export type DeepSeekModelIds = {