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