@ai-sdk/deepseek 2.0.76 → 2.0.78

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
@@ -30,85 +30,124 @@ import {
30
30
  import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
31
31
 
32
32
  // src/chat/deepseek-chat-options.ts
33
+ import {
34
+ lazySchema,
35
+ zodSchema
36
+ } from "@ai-sdk/provider-utils";
33
37
  import { z } from "zod/v4";
34
- var deepseekLanguageModelOptions = z.object({
35
- /**
36
- * Whether to return log probabilities for generated tokens.
37
- */
38
- logprobs: z.boolean().optional(),
39
- /**
40
- * Number of most likely tokens to return at each token position.
41
- *
42
- * Setting this option automatically enables `logprobs`.
43
- */
44
- topLogprobs: z.number().int().min(0).max(20).optional(),
45
- /**
46
- * An opaque identifier for the end user. DeepSeek uses this identifier for
47
- * content-safety tracing and request isolation.
48
- *
49
- * Must contain only ASCII letters, numbers, underscores, and hyphens, and
50
- * must be at most 512 characters long.
51
- */
52
- 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(),
53
- /**
54
- * Type of thinking to use. Defaults to `enabled`.
55
- */
56
- thinking: z.object({
57
- // `adaptive` is accepted at runtime for backwards compatibility and
58
- // mapped to `enabled`, but is intentionally excluded from the exported
59
- // provider options type.
60
- type: z.enum(["adaptive", "enabled", "disabled"]).optional()
61
- }).optional(),
62
- /**
63
- * Controls the thinking strength for DeepSeek V4 reasoning models.
64
- */
65
- // `medium` and `xhigh` are accepted at runtime for backwards compatibility
66
- // and mapped to canonical DeepSeek values, but are intentionally excluded
67
- // from the exported provider options type.
68
- reasoningEffort: z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
69
- /**
70
- * Whether to use strict JSON schema validation for structured outputs.
71
- * Only applies when the serving endpoint supports JSON schema response
72
- * formats (e.g. Azure). Defaults to `true`.
73
- */
74
- strictJsonSchema: z.boolean().optional()
75
- });
76
- var deepseekMessageProviderOptions = z.object({
77
- /**
78
- * The name of the participant represented by the message.
79
- *
80
- * Supported on system, user, and assistant messages.
81
- */
82
- name: z.string().optional()
83
- });
84
- var deepseekAssistantMessageProviderOptions = deepseekMessageProviderOptions.extend({
85
- /**
86
- * Whether the assistant message content is a prefix that DeepSeek should
87
- * continue. This beta feature is only supported on the final assistant
88
- * message when using a beta base URL.
89
- */
90
- prefix: z.literal(true).optional()
91
- });
38
+ function createDeepseekChatOptionsSchema() {
39
+ return z.object({
40
+ /**
41
+ * Whether to return log probabilities for generated tokens.
42
+ */
43
+ logprobs: z.boolean().optional(),
44
+ /**
45
+ * Number of most likely tokens to return at each token position.
46
+ *
47
+ * Setting this option automatically enables `logprobs`.
48
+ */
49
+ topLogprobs: z.number().int().min(0).max(20).optional(),
50
+ /**
51
+ * An opaque identifier for the end user. DeepSeek uses this identifier for
52
+ * content-safety tracing and request isolation.
53
+ *
54
+ * Must contain only ASCII letters, numbers, underscores, and hyphens, and
55
+ * must be at most 512 characters long.
56
+ */
57
+ 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(),
58
+ /**
59
+ * Type of thinking to use. Defaults to `enabled`.
60
+ */
61
+ thinking: z.object({
62
+ // `adaptive` is accepted at runtime for backwards compatibility and
63
+ // mapped to `enabled`, but is intentionally excluded from the exported
64
+ // provider options type.
65
+ type: z.enum(["adaptive", "enabled", "disabled"]).optional()
66
+ }).optional(),
67
+ /**
68
+ * Controls the thinking strength for DeepSeek V4 reasoning models.
69
+ */
70
+ // `medium` and `xhigh` are accepted at runtime for backwards compatibility
71
+ // and mapped to canonical DeepSeek values, but are intentionally excluded
72
+ // from the exported provider options type.
73
+ reasoningEffort: z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
74
+ /**
75
+ * Whether to use strict JSON schema validation for structured outputs.
76
+ * Only applies when the serving endpoint supports JSON schema response
77
+ * formats (e.g. Azure). Defaults to `true`.
78
+ */
79
+ strictJsonSchema: z.boolean().optional()
80
+ });
81
+ }
82
+ var chatOptionsSchema;
83
+ function getDeepseekChatOptionsSchema() {
84
+ return chatOptionsSchema != null ? chatOptionsSchema : chatOptionsSchema = createDeepseekChatOptionsSchema();
85
+ }
86
+ var deepseekLanguageModelOptions = lazySchema(
87
+ () => zodSchema(getDeepseekChatOptionsSchema())
88
+ );
89
+ function createDeepseekMessageOptionsSchema() {
90
+ return z.object({
91
+ /**
92
+ * The name of the participant represented by the message.
93
+ *
94
+ * Supported on system, user, and assistant messages.
95
+ */
96
+ name: z.string().optional()
97
+ });
98
+ }
99
+ var messageOptionsSchema;
100
+ function getDeepseekMessageOptionsSchema() {
101
+ return messageOptionsSchema != null ? messageOptionsSchema : messageOptionsSchema = createDeepseekMessageOptionsSchema();
102
+ }
103
+ var deepseekMessageProviderOptions = lazySchema(
104
+ () => zodSchema(getDeepseekMessageOptionsSchema())
105
+ );
106
+ function createDeepseekAssistantMessageOptionsSchema() {
107
+ return getDeepseekMessageOptionsSchema().extend({
108
+ /**
109
+ * Whether the assistant message content is a prefix that DeepSeek should
110
+ * continue. This beta feature is only supported on the final assistant
111
+ * message when using a beta base URL.
112
+ */
113
+ prefix: z.literal(true).optional()
114
+ });
115
+ }
116
+ var assistantMessageOptionsSchema;
117
+ function getDeepseekAssistantMessageOptionsSchema() {
118
+ return assistantMessageOptionsSchema != null ? assistantMessageOptionsSchema : assistantMessageOptionsSchema = createDeepseekAssistantMessageOptionsSchema();
119
+ }
120
+ var deepseekAssistantMessageProviderOptions = lazySchema(
121
+ () => zodSchema(getDeepseekAssistantMessageOptionsSchema())
122
+ );
92
123
 
93
124
  // src/chat/deepseek-file-part-options.ts
125
+ import {
126
+ lazySchema as lazySchema2,
127
+ zodSchema as zodSchema2
128
+ } from "@ai-sdk/provider-utils";
94
129
  import { z as z2 } from "zod/v4";
95
- var deepseekFilePartProviderOptions = z2.object({
96
- /**
97
- * Controls how DeepSeek processes an image sent as an `image_url` part.
98
- *
99
- * @see https://api-docs.deepseek.com/api/create-chat-completion/
100
- */
101
- imageDetail: z2.enum(["low", "high", "original", "auto"]).optional(),
102
- /**
103
- * Sends inline image data as a DeepSeek `file` part using `file_data`
104
- * instead of an `image_url` data URL. When set, the file part's filename
105
- * is preserved.
106
- *
107
- * This option only applies to inline image data. It cannot be combined
108
- * with `imageDetail`.
109
- */
110
- fileData: z2.literal(true).optional()
111
- });
130
+ var deepseekFilePartProviderOptions = lazySchema2(
131
+ () => zodSchema2(
132
+ z2.object({
133
+ /**
134
+ * Controls how DeepSeek processes an image sent as an `image_url` part.
135
+ *
136
+ * @see https://api-docs.deepseek.com/api/create-chat-completion/
137
+ */
138
+ imageDetail: z2.enum(["low", "high", "original", "auto"]).optional(),
139
+ /**
140
+ * Sends inline image data as a DeepSeek `file` part using `file_data`
141
+ * instead of an `image_url` data URL. When set, the file part's filename
142
+ * is preserved.
143
+ *
144
+ * This option only applies to inline image data. It cannot be combined
145
+ * with `imageDetail`.
146
+ */
147
+ fileData: z2.literal(true).optional()
148
+ })
149
+ )
150
+ );
112
151
 
113
152
  // src/chat/is-deepseek-v4-model.ts
114
153
  function isDeepSeekV4Model(modelId) {
@@ -443,77 +482,105 @@ function convertDeepSeekUsage(usage) {
443
482
  }
444
483
 
445
484
  // src/chat/deepseek-chat-api-types.ts
446
- import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
485
+ import {
486
+ lazySchema as lazySchema3,
487
+ zodSchema as zodSchema3
488
+ } from "@ai-sdk/provider-utils";
447
489
  import { z as z3 } from "zod/v4";
448
- var tokenUsageSchema = z3.looseObject({
449
- prompt_tokens: z3.number().nullish(),
450
- completion_tokens: z3.number().nullish(),
451
- prompt_cache_hit_tokens: z3.number().nullish(),
452
- prompt_cache_miss_tokens: z3.number().nullish(),
453
- total_tokens: z3.number().nullish(),
454
- prompt_tokens_details: z3.looseObject({
455
- cached_tokens: z3.number().nullish()
456
- }).nullish(),
457
- completion_tokens_details: z3.looseObject({
458
- reasoning_tokens: z3.number().nullish()
459
- }).nullish()
460
- }).nullish();
461
- var deepSeekErrorSchema = z3.object({
462
- error: z3.object({
463
- message: z3.string(),
464
- type: z3.string().nullish(),
465
- param: z3.any().nullish(),
466
- code: z3.union([z3.string(), z3.number()]).nullish()
467
- })
468
- });
469
- var deepseekChatLogprobSchema = z3.object({
470
- token: z3.string(),
471
- logprob: z3.number(),
472
- bytes: z3.array(z3.number()).nullable(),
473
- top_logprobs: z3.array(
474
- z3.object({
475
- token: z3.string(),
476
- logprob: z3.number(),
477
- bytes: z3.array(z3.number()).nullable()
490
+ function createTokenUsageSchema() {
491
+ return z3.looseObject({
492
+ prompt_tokens: z3.number().nullish(),
493
+ completion_tokens: z3.number().nullish(),
494
+ prompt_cache_hit_tokens: z3.number().nullish(),
495
+ prompt_cache_miss_tokens: z3.number().nullish(),
496
+ total_tokens: z3.number().nullish(),
497
+ prompt_tokens_details: z3.looseObject({
498
+ cached_tokens: z3.number().nullish()
499
+ }).nullish(),
500
+ completion_tokens_details: z3.looseObject({
501
+ reasoning_tokens: z3.number().nullish()
502
+ }).nullish()
503
+ }).nullish();
504
+ }
505
+ var tokenUsageSchema;
506
+ function getTokenUsageSchema() {
507
+ return tokenUsageSchema != null ? tokenUsageSchema : tokenUsageSchema = createTokenUsageSchema();
508
+ }
509
+ function createDeepSeekErrorSchema() {
510
+ return z3.object({
511
+ error: z3.object({
512
+ message: z3.string(),
513
+ type: z3.string().nullish(),
514
+ param: z3.any().nullish(),
515
+ code: z3.union([z3.string(), z3.number()]).nullish()
478
516
  })
479
- )
480
- });
481
- var deepseekChatLogprobsSchema = z3.object({
482
- content: z3.array(deepseekChatLogprobSchema).nullish(),
483
- reasoning_content: z3.array(deepseekChatLogprobSchema).nullish()
484
- }).nullish();
485
- var deepseekChatResponseSchema = z3.object({
486
- id: z3.string().nullish(),
487
- created: z3.number().nullish(),
488
- model: z3.string().nullish(),
489
- object: z3.literal("chat.completion").nullish(),
490
- system_fingerprint: z3.string().nullish(),
491
- choices: z3.array(
517
+ });
518
+ }
519
+ var errorSchema;
520
+ function getDeepSeekErrorSchema() {
521
+ return errorSchema != null ? errorSchema : errorSchema = createDeepSeekErrorSchema();
522
+ }
523
+ var deepSeekErrorSchema = lazySchema3(
524
+ () => zodSchema3(getDeepSeekErrorSchema())
525
+ );
526
+ function createDeepseekChatLogprobsSchema() {
527
+ const deepseekChatLogprobSchema = z3.object({
528
+ token: z3.string(),
529
+ logprob: z3.number(),
530
+ bytes: z3.array(z3.number()).nullable(),
531
+ top_logprobs: z3.array(
532
+ z3.object({
533
+ token: z3.string(),
534
+ logprob: z3.number(),
535
+ bytes: z3.array(z3.number()).nullable()
536
+ })
537
+ )
538
+ });
539
+ return z3.object({
540
+ content: z3.array(deepseekChatLogprobSchema).nullish(),
541
+ reasoning_content: z3.array(deepseekChatLogprobSchema).nullish()
542
+ }).nullish();
543
+ }
544
+ var logprobsSchema;
545
+ function getDeepseekChatLogprobsSchema() {
546
+ return logprobsSchema != null ? logprobsSchema : logprobsSchema = createDeepseekChatLogprobsSchema();
547
+ }
548
+ var deepseekChatResponseSchema = lazySchema3(
549
+ () => zodSchema3(
492
550
  z3.object({
493
- index: z3.number().nullish(),
494
- message: z3.object({
495
- role: z3.literal("assistant").nullish(),
496
- content: z3.string().nullish(),
497
- reasoning_content: z3.string().nullish(),
498
- tool_calls: z3.array(
499
- z3.object({
500
- id: z3.string().nullish(),
501
- type: z3.literal("function").nullish(),
502
- function: z3.object({
503
- name: z3.string(),
504
- arguments: z3.string()
505
- })
506
- })
507
- ).nullish()
508
- }),
509
- logprobs: deepseekChatLogprobsSchema,
510
- finish_reason: z3.string().nullish()
551
+ id: z3.string().nullish(),
552
+ created: z3.number().nullish(),
553
+ model: z3.string().nullish(),
554
+ object: z3.literal("chat.completion").nullish(),
555
+ system_fingerprint: z3.string().nullish(),
556
+ choices: z3.array(
557
+ z3.object({
558
+ index: z3.number().nullish(),
559
+ message: z3.object({
560
+ role: z3.literal("assistant").nullish(),
561
+ content: z3.string().nullish(),
562
+ reasoning_content: z3.string().nullish(),
563
+ tool_calls: z3.array(
564
+ z3.object({
565
+ id: z3.string().nullish(),
566
+ type: z3.literal("function").nullish(),
567
+ function: z3.object({
568
+ name: z3.string(),
569
+ arguments: z3.string()
570
+ })
571
+ })
572
+ ).nullish()
573
+ }),
574
+ logprobs: getDeepseekChatLogprobsSchema(),
575
+ finish_reason: z3.string().nullish()
576
+ })
577
+ ),
578
+ usage: getTokenUsageSchema()
511
579
  })
512
- ),
513
- usage: tokenUsageSchema
514
- });
515
- var deepseekChatChunkSchema = lazySchema(
516
- () => zodSchema(
580
+ )
581
+ );
582
+ var deepseekChatChunkSchema = lazySchema3(
583
+ () => zodSchema3(
517
584
  z3.union([
518
585
  z3.object({
519
586
  id: z3.string().nullish(),
@@ -540,13 +607,13 @@ var deepseekChatChunkSchema = lazySchema(
540
607
  })
541
608
  ).nullish()
542
609
  }).nullish(),
543
- logprobs: deepseekChatLogprobsSchema,
610
+ logprobs: getDeepseekChatLogprobsSchema(),
544
611
  finish_reason: z3.string().nullish()
545
612
  })
546
613
  ),
547
- usage: tokenUsageSchema
614
+ usage: getTokenUsageSchema()
548
615
  }),
549
- deepSeekErrorSchema
616
+ getDeepSeekErrorSchema()
550
617
  ])
551
618
  )
552
619
  );
@@ -1160,7 +1227,7 @@ var DeepSeekChatLanguageModel = class {
1160
1227
  };
1161
1228
 
1162
1229
  // src/version.ts
1163
- var VERSION = true ? "2.0.76" : "0.0.0-test";
1230
+ var VERSION = true ? "2.0.78" : "0.0.0-test";
1164
1231
 
1165
1232
  // src/deepseek-provider.ts
1166
1233
  function createDeepSeek(options = {}) {