@ai-sdk/deepseek 1.0.62 → 1.0.64

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.
@@ -1,3 +1,95 @@
1
+ // src/chat/deepseek-chat-options.ts
2
+ import {
3
+ lazySchema,
4
+ zodSchema
5
+ } from "@ai-sdk/provider-utils";
6
+ import { z } from "zod/v4";
7
+ function createDeepseekChatOptionsSchema() {
8
+ return z.object({
9
+ /**
10
+ * Whether to return log probabilities for generated tokens.
11
+ */
12
+ logprobs: z.boolean().optional(),
13
+ /**
14
+ * Number of most likely tokens to return at each token position.
15
+ *
16
+ * Setting this option automatically enables `logprobs`.
17
+ */
18
+ topLogprobs: z.number().int().min(0).max(20).optional(),
19
+ /**
20
+ * An opaque identifier for the end user. DeepSeek uses this identifier for
21
+ * content-safety tracing and request isolation.
22
+ *
23
+ * Must contain only ASCII letters, numbers, underscores, and hyphens, and
24
+ * must be at most 512 characters long.
25
+ */
26
+ userId: z.string().regex(/^[a-zA-Z0-9_-]+$/, "userId must match /^[a-zA-Z0-9_-]+$/").max(512, "userId must be at most 512 characters long").optional(),
27
+ /**
28
+ * Type of thinking to use. Defaults to `enabled`.
29
+ */
30
+ thinking: z.object({
31
+ // `adaptive` is accepted at runtime for backwards compatibility and
32
+ // mapped to `enabled`, but is intentionally excluded from the exported
33
+ // provider options type.
34
+ type: z.enum(["adaptive", "enabled", "disabled"]).optional()
35
+ }).optional(),
36
+ /**
37
+ * Controls the thinking strength for DeepSeek V4 reasoning models.
38
+ */
39
+ // `medium` and `xhigh` are accepted at runtime for backwards compatibility
40
+ // and mapped to canonical DeepSeek values, but are intentionally excluded
41
+ // from the exported provider options type.
42
+ reasoningEffort: z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
43
+ /**
44
+ * Whether to use strict JSON schema validation for structured outputs.
45
+ * Only applies when the serving endpoint supports JSON schema response
46
+ * formats (e.g. Azure). Defaults to `true`.
47
+ */
48
+ strictJsonSchema: z.boolean().optional()
49
+ });
50
+ }
51
+ var chatOptionsSchema;
52
+ function getDeepseekChatOptionsSchema() {
53
+ return chatOptionsSchema != null ? chatOptionsSchema : chatOptionsSchema = createDeepseekChatOptionsSchema();
54
+ }
55
+ var deepseekChatOptions = lazySchema(
56
+ () => zodSchema(getDeepseekChatOptionsSchema())
57
+ );
58
+ function createDeepseekMessageOptionsSchema() {
59
+ return z.object({
60
+ /**
61
+ * The name of the participant represented by the message.
62
+ *
63
+ * Supported on system, user, and assistant messages.
64
+ */
65
+ name: z.string().optional()
66
+ });
67
+ }
68
+ var messageOptionsSchema;
69
+ function getDeepseekMessageOptionsSchema() {
70
+ return messageOptionsSchema != null ? messageOptionsSchema : messageOptionsSchema = createDeepseekMessageOptionsSchema();
71
+ }
72
+ var deepseekMessageProviderOptions = lazySchema(
73
+ () => zodSchema(getDeepseekMessageOptionsSchema())
74
+ );
75
+ function createDeepseekAssistantMessageOptionsSchema() {
76
+ return getDeepseekMessageOptionsSchema().extend({
77
+ /**
78
+ * Whether the assistant message content is a prefix that DeepSeek should
79
+ * continue. This beta feature is only supported on the final assistant
80
+ * message when using a beta base URL.
81
+ */
82
+ prefix: z.literal(true).optional()
83
+ });
84
+ }
85
+ var assistantMessageOptionsSchema;
86
+ function getDeepseekAssistantMessageOptionsSchema() {
87
+ return assistantMessageOptionsSchema != null ? assistantMessageOptionsSchema : assistantMessageOptionsSchema = createDeepseekAssistantMessageOptionsSchema();
88
+ }
89
+ var deepseekAssistantMessageProviderOptions = lazySchema(
90
+ () => zodSchema(getDeepseekAssistantMessageOptionsSchema())
91
+ );
92
+
1
93
  // src/chat/deepseek-chat-language-model.ts
2
94
  import {
3
95
  InvalidResponseDataError
@@ -20,90 +112,39 @@ import {
20
112
  } from "@ai-sdk/provider";
21
113
  import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
22
114
 
23
- // src/chat/deepseek-chat-options.ts
24
- import { z } from "zod/v4";
25
- var deepseekChatOptions = z.object({
26
- /**
27
- * Whether to return log probabilities for generated tokens.
28
- */
29
- logprobs: z.boolean().optional(),
30
- /**
31
- * Number of most likely tokens to return at each token position.
32
- *
33
- * Setting this option automatically enables `logprobs`.
34
- */
35
- topLogprobs: z.number().int().min(0).max(20).optional(),
36
- /**
37
- * An opaque identifier for the end user. DeepSeek uses this identifier for
38
- * content-safety tracing and request isolation.
39
- *
40
- * Must contain only ASCII letters, numbers, underscores, and hyphens, and
41
- * must be at most 512 characters long.
42
- */
43
- userId: z.string().regex(/^[a-zA-Z0-9_-]+$/, "userId must match /^[a-zA-Z0-9_-]+$/").max(512, "userId must be at most 512 characters long").optional(),
44
- /**
45
- * Type of thinking to use. Defaults to `enabled`.
46
- */
47
- thinking: z.object({
48
- // `adaptive` is accepted at runtime for backwards compatibility and
49
- // mapped to `enabled`, but is intentionally excluded from the exported
50
- // provider options type.
51
- type: z.enum(["adaptive", "enabled", "disabled"]).optional()
52
- }).optional(),
53
- /**
54
- * Controls the thinking strength for DeepSeek V4 reasoning models.
55
- */
56
- // `medium` and `xhigh` are accepted at runtime for backwards compatibility
57
- // and mapped to canonical DeepSeek values, but are intentionally excluded
58
- // from the exported provider options type.
59
- reasoningEffort: z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
60
- /**
61
- * Whether to use strict JSON schema validation for structured outputs.
62
- * Only applies when the serving endpoint supports JSON schema response
63
- * formats (e.g. Azure). Defaults to `true`.
64
- */
65
- strictJsonSchema: z.boolean().optional()
66
- });
67
- var deepseekMessageProviderOptions = z.object({
68
- /**
69
- * The name of the participant represented by the message.
70
- *
71
- * Supported on system, user, and assistant messages.
72
- */
73
- name: z.string().optional()
74
- });
75
- var deepseekAssistantMessageProviderOptions = deepseekMessageProviderOptions.extend({
76
- /**
77
- * Whether the assistant message content is a prefix that DeepSeek should
78
- * continue. This beta feature is only supported on the final assistant
79
- * message when using a beta base URL.
80
- */
81
- prefix: z.literal(true).optional()
82
- });
83
-
84
115
  // src/chat/deepseek-file-part-options.ts
116
+ import {
117
+ lazySchema as lazySchema2,
118
+ zodSchema as zodSchema2
119
+ } from "@ai-sdk/provider-utils";
85
120
  import { z as z2 } from "zod/v4";
86
- var deepseekFilePartProviderOptions = z2.object({
87
- /**
88
- * Controls how DeepSeek processes an image sent as an `image_url` part.
89
- *
90
- * @see https://api-docs.deepseek.com/api/create-chat-completion/
91
- */
92
- imageDetail: z2.enum(["low", "high", "original", "auto"]).optional(),
93
- /**
94
- * Sends inline image data as a DeepSeek `file` part using `file_data`
95
- * instead of an `image_url` data URL. When set, the file part's filename
96
- * is preserved.
97
- *
98
- * This option only applies to inline image data. It cannot be combined
99
- * with `imageDetail`.
100
- */
101
- fileData: z2.literal(true).optional()
102
- });
121
+ var deepseekFilePartProviderOptions = lazySchema2(
122
+ () => zodSchema2(
123
+ z2.object({
124
+ /**
125
+ * Controls how DeepSeek processes an image sent as an `image_url` part.
126
+ *
127
+ * @see https://api-docs.deepseek.com/api/create-chat-completion/
128
+ */
129
+ imageDetail: z2.enum(["low", "high", "original", "auto"]).optional(),
130
+ /**
131
+ * Sends inline image data as a DeepSeek `file` part using `file_data`
132
+ * instead of an `image_url` data URL. When set, the file part's filename
133
+ * is preserved.
134
+ *
135
+ * This option only applies to inline image data. It cannot be combined
136
+ * with `imageDetail`.
137
+ */
138
+ fileData: z2.literal(true).optional()
139
+ })
140
+ )
141
+ );
103
142
 
104
143
  // src/chat/is-deepseek-v4-model.ts
105
144
  function isDeepSeekV4Model(modelId) {
106
- return modelId.includes("deepseek-v4") || modelId.startsWith("deepseek-flash") || modelId.startsWith("deepseek-pro");
145
+ return !/(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\.\d+)?)(?=[-/:.]|$)/.test(
146
+ modelId
147
+ );
107
148
  }
108
149
 
109
150
  // src/chat/convert-to-deepseek-chat-messages.ts
@@ -381,77 +422,105 @@ async function convertToDeepSeekChatMessages({
381
422
  }
382
423
 
383
424
  // src/chat/deepseek-chat-api-types.ts
384
- import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
425
+ import {
426
+ lazySchema as lazySchema3,
427
+ zodSchema as zodSchema3
428
+ } from "@ai-sdk/provider-utils";
385
429
  import { z as z3 } from "zod/v4";
386
- var tokenUsageSchema = z3.object({
387
- prompt_tokens: z3.number().nullish(),
388
- completion_tokens: z3.number().nullish(),
389
- prompt_cache_hit_tokens: z3.number().nullish(),
390
- prompt_cache_miss_tokens: z3.number().nullish(),
391
- total_tokens: z3.number().nullish(),
392
- prompt_tokens_details: z3.object({
393
- cached_tokens: z3.number().nullish()
394
- }).nullish(),
395
- completion_tokens_details: z3.object({
396
- reasoning_tokens: z3.number().nullish()
397
- }).nullish()
398
- }).nullish();
399
- var deepSeekErrorSchema = z3.object({
400
- error: z3.object({
401
- message: z3.string(),
402
- type: z3.string().nullish(),
403
- param: z3.any().nullish(),
404
- code: z3.union([z3.string(), z3.number()]).nullish()
405
- })
406
- });
407
- var deepseekChatLogprobSchema = z3.object({
408
- token: z3.string(),
409
- logprob: z3.number(),
410
- bytes: z3.array(z3.number()).nullable(),
411
- top_logprobs: z3.array(
412
- z3.object({
413
- token: z3.string(),
414
- logprob: z3.number(),
415
- bytes: z3.array(z3.number()).nullable()
430
+ function createTokenUsageSchema() {
431
+ return z3.object({
432
+ prompt_tokens: z3.number().nullish(),
433
+ completion_tokens: z3.number().nullish(),
434
+ prompt_cache_hit_tokens: z3.number().nullish(),
435
+ prompt_cache_miss_tokens: z3.number().nullish(),
436
+ total_tokens: z3.number().nullish(),
437
+ prompt_tokens_details: z3.object({
438
+ cached_tokens: z3.number().nullish()
439
+ }).nullish(),
440
+ completion_tokens_details: z3.object({
441
+ reasoning_tokens: z3.number().nullish()
442
+ }).nullish()
443
+ }).nullish();
444
+ }
445
+ var tokenUsageSchema;
446
+ function getTokenUsageSchema() {
447
+ return tokenUsageSchema != null ? tokenUsageSchema : tokenUsageSchema = createTokenUsageSchema();
448
+ }
449
+ function createDeepSeekErrorSchema() {
450
+ return z3.object({
451
+ error: z3.object({
452
+ message: z3.string(),
453
+ type: z3.string().nullish(),
454
+ param: z3.any().nullish(),
455
+ code: z3.union([z3.string(), z3.number()]).nullish()
416
456
  })
417
- )
418
- });
419
- var deepseekChatLogprobsSchema = z3.object({
420
- content: z3.array(deepseekChatLogprobSchema).nullish(),
421
- reasoning_content: z3.array(deepseekChatLogprobSchema).nullish()
422
- }).nullish();
423
- var deepseekChatResponseSchema = z3.object({
424
- id: z3.string().nullish(),
425
- created: z3.number().nullish(),
426
- model: z3.string().nullish(),
427
- object: z3.literal("chat.completion").nullish(),
428
- system_fingerprint: z3.string().nullish(),
429
- choices: z3.array(
457
+ });
458
+ }
459
+ var errorSchema;
460
+ function getDeepSeekErrorSchema() {
461
+ return errorSchema != null ? errorSchema : errorSchema = createDeepSeekErrorSchema();
462
+ }
463
+ var deepSeekErrorSchema = lazySchema3(
464
+ () => zodSchema3(getDeepSeekErrorSchema())
465
+ );
466
+ function createDeepseekChatLogprobsSchema() {
467
+ const deepseekChatLogprobSchema = z3.object({
468
+ token: z3.string(),
469
+ logprob: z3.number(),
470
+ bytes: z3.array(z3.number()).nullable(),
471
+ top_logprobs: z3.array(
472
+ z3.object({
473
+ token: z3.string(),
474
+ logprob: z3.number(),
475
+ bytes: z3.array(z3.number()).nullable()
476
+ })
477
+ )
478
+ });
479
+ return z3.object({
480
+ content: z3.array(deepseekChatLogprobSchema).nullish(),
481
+ reasoning_content: z3.array(deepseekChatLogprobSchema).nullish()
482
+ }).nullish();
483
+ }
484
+ var logprobsSchema;
485
+ function getDeepseekChatLogprobsSchema() {
486
+ return logprobsSchema != null ? logprobsSchema : logprobsSchema = createDeepseekChatLogprobsSchema();
487
+ }
488
+ var deepseekChatResponseSchema = lazySchema3(
489
+ () => zodSchema3(
430
490
  z3.object({
431
- index: z3.number().nullish(),
432
- message: z3.object({
433
- role: z3.literal("assistant").nullish(),
434
- content: z3.string().nullish(),
435
- reasoning_content: z3.string().nullish(),
436
- tool_calls: z3.array(
437
- z3.object({
438
- id: z3.string().nullish(),
439
- type: z3.literal("function").nullish(),
440
- function: z3.object({
441
- name: z3.string(),
442
- arguments: z3.string()
443
- })
444
- })
445
- ).nullish()
446
- }),
447
- logprobs: deepseekChatLogprobsSchema,
448
- finish_reason: z3.string().nullish()
491
+ id: z3.string().nullish(),
492
+ created: z3.number().nullish(),
493
+ model: z3.string().nullish(),
494
+ object: z3.literal("chat.completion").nullish(),
495
+ system_fingerprint: z3.string().nullish(),
496
+ choices: z3.array(
497
+ z3.object({
498
+ index: z3.number().nullish(),
499
+ message: z3.object({
500
+ role: z3.literal("assistant").nullish(),
501
+ content: z3.string().nullish(),
502
+ reasoning_content: z3.string().nullish(),
503
+ tool_calls: z3.array(
504
+ z3.object({
505
+ id: z3.string().nullish(),
506
+ type: z3.literal("function").nullish(),
507
+ function: z3.object({
508
+ name: z3.string(),
509
+ arguments: z3.string()
510
+ })
511
+ })
512
+ ).nullish()
513
+ }),
514
+ logprobs: getDeepseekChatLogprobsSchema(),
515
+ finish_reason: z3.string().nullish()
516
+ })
517
+ ),
518
+ usage: getTokenUsageSchema()
449
519
  })
450
- ),
451
- usage: tokenUsageSchema
452
- });
453
- var deepseekChatChunkSchema = lazySchema(
454
- () => zodSchema(
520
+ )
521
+ );
522
+ var deepseekChatChunkSchema = lazySchema3(
523
+ () => zodSchema3(
455
524
  z3.union([
456
525
  z3.object({
457
526
  id: z3.string().nullish(),
@@ -478,13 +547,13 @@ var deepseekChatChunkSchema = lazySchema(
478
547
  })
479
548
  ).nullish()
480
549
  }).nullish(),
481
- logprobs: deepseekChatLogprobsSchema,
550
+ logprobs: getDeepseekChatLogprobsSchema(),
482
551
  finish_reason: z3.string().nullish()
483
552
  })
484
553
  ),
485
- usage: tokenUsageSchema
554
+ usage: getTokenUsageSchema()
486
555
  }),
487
- deepSeekErrorSchema
556
+ getDeepSeekErrorSchema()
488
557
  ])
489
558
  )
490
559
  );
@@ -1105,10 +1174,15 @@ var DeepSeekChatLanguageModel = class {
1105
1174
  };
1106
1175
  }
1107
1176
  };
1177
+
1178
+ // src/internal/index.ts
1179
+ var deepseekChatOptions2 = getDeepseekChatOptionsSchema();
1180
+ var deepseekMessageProviderOptions2 = getDeepseekMessageOptionsSchema();
1181
+ var deepseekAssistantMessageProviderOptions2 = getDeepseekAssistantMessageOptionsSchema();
1108
1182
  export {
1109
1183
  DeepSeekChatLanguageModel,
1110
- deepseekAssistantMessageProviderOptions,
1111
- deepseekChatOptions,
1112
- deepseekMessageProviderOptions
1184
+ deepseekAssistantMessageProviderOptions2 as deepseekAssistantMessageProviderOptions,
1185
+ deepseekChatOptions2 as deepseekChatOptions,
1186
+ deepseekMessageProviderOptions2 as deepseekMessageProviderOptions
1113
1187
  };
1114
1188
  //# sourceMappingURL=index.mjs.map