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