@ai-sdk/deepseek 1.0.68 → 1.0.69

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/deepseek
2
2
 
3
+ ## 1.0.69
4
+
5
+ ### Patch Changes
6
+
7
+ - 4ddb1fa: Prevent streaming tool calls from finalizing on parsable partial JSON. A tool call was treated as complete as soon as its accumulated arguments parsed as JSON, so a stream that sent valid JSON early and more argument text in later deltas ran the tool with truncated arguments. Tool calls are now finalized when the stream ends.
8
+
3
9
  ## 1.0.68
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -950,7 +950,7 @@ var DeepSeekChatLanguageModel = class {
950
950
  controller.enqueue({ type: "stream-start", warnings });
951
951
  },
952
952
  transform(chunk, controller) {
953
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
953
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
954
954
  if (options.includeRawChunks) {
955
955
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
956
956
  }
@@ -1083,19 +1083,6 @@ var DeepSeekChatLanguageModel = class {
1083
1083
  delta: toolCall2.function.arguments
1084
1084
  });
1085
1085
  }
1086
- if ((0, import_provider_utils5.isParsableJson)(toolCall2.function.arguments)) {
1087
- controller.enqueue({
1088
- type: "tool-input-end",
1089
- id: toolCall2.id
1090
- });
1091
- controller.enqueue({
1092
- type: "tool-call",
1093
- toolCallId: (_g = toolCall2.id) != null ? _g : (0, import_provider_utils5.generateId)(),
1094
- toolName: toolCall2.function.name,
1095
- input: toolCall2.function.arguments
1096
- });
1097
- toolCall2.hasFinished = true;
1098
- }
1099
1086
  }
1100
1087
  continue;
1101
1088
  }
@@ -1103,27 +1090,14 @@ var DeepSeekChatLanguageModel = class {
1103
1090
  if (toolCall.hasFinished) {
1104
1091
  continue;
1105
1092
  }
1106
- if (((_h = toolCallDelta.function) == null ? void 0 : _h.arguments) != null) {
1107
- toolCall.function.arguments += (_j = (_i = toolCallDelta.function) == null ? void 0 : _i.arguments) != null ? _j : "";
1093
+ if (((_g = toolCallDelta.function) == null ? void 0 : _g.arguments) != null) {
1094
+ toolCall.function.arguments += (_i = (_h = toolCallDelta.function) == null ? void 0 : _h.arguments) != null ? _i : "";
1108
1095
  }
1109
1096
  controller.enqueue({
1110
1097
  type: "tool-input-delta",
1111
1098
  id: toolCall.id,
1112
- delta: (_k = toolCallDelta.function.arguments) != null ? _k : ""
1099
+ delta: (_j = toolCallDelta.function.arguments) != null ? _j : ""
1113
1100
  });
1114
- if (((_l = toolCall.function) == null ? void 0 : _l.name) != null && ((_m = toolCall.function) == null ? void 0 : _m.arguments) != null && (0, import_provider_utils5.isParsableJson)(toolCall.function.arguments)) {
1115
- controller.enqueue({
1116
- type: "tool-input-end",
1117
- id: toolCall.id
1118
- });
1119
- controller.enqueue({
1120
- type: "tool-call",
1121
- toolCallId: (_n = toolCall.id) != null ? _n : (0, import_provider_utils5.generateId)(),
1122
- toolName: toolCall.function.name,
1123
- input: toolCall.function.arguments
1124
- });
1125
- toolCall.hasFinished = true;
1126
- }
1127
1101
  }
1128
1102
  }
1129
1103
  },
@@ -1148,6 +1122,7 @@ var DeepSeekChatLanguageModel = class {
1148
1122
  toolName: toolCall.function.name,
1149
1123
  input: toolCall.function.arguments
1150
1124
  });
1125
+ toolCall.hasFinished = true;
1151
1126
  }
1152
1127
  const cacheReadTokens = getDeepSeekCacheReadTokens(usage);
1153
1128
  controller.enqueue({
@@ -1194,7 +1169,7 @@ var DeepSeekChatLanguageModel = class {
1194
1169
  };
1195
1170
 
1196
1171
  // src/version.ts
1197
- var VERSION = true ? "1.0.68" : "0.0.0-test";
1172
+ var VERSION = true ? "1.0.69" : "0.0.0-test";
1198
1173
 
1199
1174
  // src/deepseek-provider.ts
1200
1175
  function createDeepSeek(options = {}) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/deepseek-provider.ts","../src/chat/deepseek-chat-language-model.ts","../src/chat/convert-to-deepseek-chat-messages.ts","../src/chat/deepseek-chat-options.ts","../src/chat/deepseek-file-part-options.ts","../src/chat/is-deepseek-v4-model.ts","../src/chat/deepseek-chat-api-types.ts","../src/chat/deepseek-prepare-tools.ts","../src/chat/get-response-metadata.ts","../src/chat/map-deepseek-finish-reason.ts","../src/version.ts"],"sourcesContent":["export { createDeepSeek, deepseek } from './deepseek-provider';\nexport type {\n DeepSeekProvider,\n DeepSeekProviderSettings,\n} from './deepseek-provider';\nexport { VERSION } from './version';\nexport type {\n DeepSeekAssistantMessageProviderOptions,\n DeepSeekChatOptions,\n DeepSeekMessageProviderOptions,\n} from './chat/deepseek-chat-options';\nexport type { DeepSeekErrorData } from './chat/deepseek-chat-api-types';\nexport type { DeepSeekFilePartProviderOptions } from './chat/deepseek-file-part-options';\n","import {\n type LanguageModelV2,\n type ProviderV2,\n NoSuchModelError,\n} from '@ai-sdk/provider';\nimport {\n type FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport type { DeepSeekChatModelId } from './chat/deepseek-chat-options';\nimport { DeepSeekChatLanguageModel } from './chat/deepseek-chat-language-model';\nimport { VERSION } from './version';\n\nexport interface DeepSeekProviderSettings {\n /**\n * DeepSeek API key.\n */\n apiKey?: string;\n\n /**\n * Base URL for the API calls.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface DeepSeekProvider extends ProviderV2 {\n /**\nCreates a DeepSeek model for text generation.\n*/\n (modelId: DeepSeekChatModelId): LanguageModelV2;\n\n /**\nCreates a DeepSeek model for text generation.\n*/\n languageModel(modelId: DeepSeekChatModelId): LanguageModelV2;\n\n /**\nCreates a DeepSeek chat model for text generation.\n*/\n chat(modelId: DeepSeekChatModelId): LanguageModelV2;\n}\n\nexport function createDeepSeek(\n options: DeepSeekProviderSettings = {},\n): DeepSeekProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL) ?? 'https://api.deepseek.com';\n\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPSEEK_API_KEY',\n description: 'DeepSeek API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/deepseek/${VERSION}`,\n );\n\n const createLanguageModel = (modelId: DeepSeekChatModelId) => {\n return new DeepSeekChatLanguageModel(modelId, {\n provider: `deepseek.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n supportsAssistantPrefixCompletion: baseURL.endsWith('/beta'),\n });\n };\n\n const provider = (modelId: DeepSeekChatModelId) =>\n createLanguageModel(modelId);\n\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const deepseek = createDeepSeek();\n","import {\n type APICallError,\n type LanguageModelV2,\n type LanguageModelV2CallWarning,\n type LanguageModelV2Content,\n type LanguageModelV2FinishReason,\n type LanguageModelV2StreamPart,\n InvalidResponseDataError,\n} from '@ai-sdk/provider';\nimport {\n type FetchFunction,\n type InferSchema,\n type ParseResult,\n type ResponseHandler,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n generateId,\n isParsableJson,\n parseProviderOptions,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport { convertToDeepSeekChatMessages } from './convert-to-deepseek-chat-messages';\nimport {\n type DeepSeekChatTokenUsage,\n deepseekChatChunkSchema,\n deepseekChatResponseSchema,\n deepSeekErrorSchema,\n type DeepSeekChatLogprob,\n} from './deepseek-chat-api-types';\nimport {\n type DeepSeekChatModelId,\n deepseekChatOptions,\n} from './deepseek-chat-options';\nimport { prepareTools } from './deepseek-prepare-tools';\nimport { getResponseMetadata } from './get-response-metadata';\nimport { isDeepSeekV4Model } from './is-deepseek-v4-model';\nimport { mapDeepSeekFinishReason } from './map-deepseek-finish-reason';\n\nexport type DeepSeekChatConfig = {\n provider: string;\n headers: () => Record<string, string | undefined>;\n url: (options: { modelId: string; path: string }) => string;\n fetch?: FetchFunction;\n supportsAssistantPrefixCompletion?: boolean;\n supportsPenaltySampling?: boolean;\n supportsThinking?: boolean;\n supportsStructuredOutputs?: boolean;\n};\n\nfunction getDeepSeekCacheReadTokens(\n usage: DeepSeekChatTokenUsage | undefined | null,\n): number | undefined {\n return (\n usage?.prompt_cache_hit_tokens ??\n usage?.prompt_tokens_details?.cached_tokens ??\n undefined\n );\n}\n\nfunction mapDeepSeekProviderReasoningEffort({\n reasoningEffort,\n warnings,\n}: {\n reasoningEffort: 'low' | 'medium' | 'high' | 'xhigh' | 'max';\n warnings: LanguageModelV2CallWarning[];\n}): 'low' | 'high' | 'max' {\n const mapped =\n reasoningEffort === 'medium'\n ? 'high'\n : reasoningEffort === 'xhigh'\n ? 'max'\n : reasoningEffort;\n\n if (mapped !== reasoningEffort) {\n warnings.push({\n type: 'other',\n message: `reasoningEffort \"${reasoningEffort}\" is not a canonical DeepSeek value. mapped to \"${mapped}\".`,\n });\n }\n\n return mapped;\n}\n\nexport class DeepSeekChatLanguageModel implements LanguageModelV2 {\n readonly specificationVersion = 'v2';\n\n readonly modelId: DeepSeekChatModelId;\n\n readonly supportedUrls = {\n 'image/*': [/^https?:\\/\\/.*$/],\n };\n\n private readonly config: DeepSeekChatConfig;\n private readonly failedResponseHandler: ResponseHandler<APICallError>;\n\n constructor(modelId: DeepSeekChatModelId, config: DeepSeekChatConfig) {\n this.modelId = modelId;\n this.config = config;\n\n this.failedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: deepSeekErrorSchema,\n errorToMessage: (error: InferSchema<typeof deepSeekErrorSchema>) =>\n error.error.message,\n });\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n private get providerOptionsName(): string {\n return this.config.provider.split('.')[0].trim();\n }\n\n private async getArgs({\n prompt,\n maxOutputTokens,\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n providerOptions,\n stopSequences,\n responseFormat,\n tools,\n toolChoice,\n seed,\n }: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const deepseekOptions =\n (await parseProviderOptions({\n provider: this.providerOptionsName,\n providerOptions,\n schema: deepseekChatOptions,\n })) ?? {};\n\n const supportsStructuredOutputs =\n this.config.supportsStructuredOutputs === true;\n const supportsPenaltySampling =\n this.config.supportsPenaltySampling === true;\n\n const { messages, warnings } = await convertToDeepSeekChatMessages({\n prompt,\n responseFormat,\n modelId: this.modelId,\n providerOptionsName: this.providerOptionsName,\n supportsAssistantPrefixCompletion:\n this.config.supportsAssistantPrefixCompletion,\n supportsStructuredOutputs,\n });\n const allWarnings = [...warnings];\n\n if (topK != null) {\n allWarnings.push({ type: 'unsupported-setting', setting: 'topK' });\n }\n\n if (seed != null) {\n allWarnings.push({ type: 'unsupported-setting', setting: 'seed' });\n }\n\n if (!supportsPenaltySampling && frequencyPenalty != null) {\n allWarnings.push({\n type: 'other',\n message:\n 'frequencyPenalty is deprecated by DeepSeek and has been omitted. Remove frequencyPenalty from the request.',\n });\n }\n\n if (!supportsPenaltySampling && presencePenalty != null) {\n allWarnings.push({\n type: 'other',\n message:\n 'presencePenalty is deprecated by DeepSeek and has been omitted. Remove presencePenalty from the request.',\n });\n }\n\n const {\n tools: deepseekTools,\n toolChoice: deepseekToolChoices,\n toolWarnings,\n } = prepareTools({\n tools,\n toolChoice,\n });\n allWarnings.push(...toolWarnings);\n\n const thinkingType = deepseekOptions.thinking?.type;\n if (thinkingType === 'adaptive') {\n allWarnings.push({\n type: 'other',\n message:\n 'thinking.type \"adaptive\" is not a canonical DeepSeek value. mapped to \"enabled\".',\n });\n }\n\n const thinking =\n this.config.supportsThinking === false\n ? undefined\n : thinkingType != null\n ? { type: thinkingType === 'adaptive' ? 'enabled' : thinkingType }\n : undefined;\n\n const isThinkingEnabled =\n this.config.supportsThinking !== false &&\n thinking?.type !== 'disabled' &&\n (thinking != null ||\n this.modelId === 'deepseek-reasoner' ||\n isDeepSeekV4Model(this.modelId));\n\n if (isThinkingEnabled && temperature != null) {\n allWarnings.push({\n type: 'unsupported-setting',\n setting: 'temperature',\n details:\n \"temperature has no effect when DeepSeek thinking is enabled. Set providerOptions.deepseek.thinking.type to 'disabled' to use temperature.\",\n });\n }\n\n if (isThinkingEnabled && topP != null) {\n allWarnings.push({\n type: 'unsupported-setting',\n setting: 'topP',\n details:\n \"topP has no effect when DeepSeek thinking is enabled. Set providerOptions.deepseek.thinking.type to 'disabled' to use topP.\",\n });\n }\n\n const reasoningEffort =\n deepseekOptions.reasoningEffort != null\n ? mapDeepSeekProviderReasoningEffort({\n reasoningEffort: deepseekOptions.reasoningEffort,\n warnings: allWarnings,\n })\n : undefined;\n\n return {\n args: {\n model: this.modelId,\n ...((deepseekOptions.logprobs === true ||\n deepseekOptions.topLogprobs != null) && { logprobs: true }),\n ...(deepseekOptions.topLogprobs != null && {\n top_logprobs: deepseekOptions.topLogprobs,\n }),\n max_tokens: maxOutputTokens,\n temperature: isThinkingEnabled ? undefined : temperature,\n top_p: isThinkingEnabled ? undefined : topP,\n frequency_penalty: supportsPenaltySampling\n ? frequencyPenalty\n : undefined,\n presence_penalty: supportsPenaltySampling ? presencePenalty : undefined,\n response_format:\n responseFormat?.type === 'json'\n ? supportsStructuredOutputs && responseFormat.schema != null\n ? {\n type: 'json_schema',\n json_schema: {\n schema: responseFormat.schema,\n strict: deepseekOptions.strictJsonSchema ?? true,\n name: responseFormat.name ?? 'response',\n description: responseFormat.description,\n },\n }\n : { type: 'json_object' }\n : undefined,\n stop: stopSequences,\n messages,\n tools: deepseekTools,\n tool_choice: deepseekToolChoices,\n thinking,\n ...(deepseekOptions.userId != null && {\n user_id: deepseekOptions.userId,\n }),\n ...(thinking?.type !== 'disabled' &&\n reasoningEffort != null && {\n reasoning_effort: reasoningEffort,\n }),\n },\n warnings: allWarnings,\n };\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { args, warnings } = await this.getArgs({ ...options });\n\n const {\n responseHeaders,\n value: responseBody,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.config.url({\n path: '/chat/completions',\n modelId: this.modelId,\n }),\n headers: combineHeaders(this.config.headers(), options.headers),\n body: args,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepseekChatResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const choice = responseBody.choices[0];\n const content: Array<LanguageModelV2Content> = [];\n\n // reasoning content (before text):\n const reasoning = choice.message.reasoning_content;\n if (reasoning != null && reasoning.length > 0) {\n content.push({\n type: 'reasoning',\n text: reasoning,\n });\n }\n\n // tool calls:\n if (choice.message.tool_calls != null) {\n for (const toolCall of choice.message.tool_calls) {\n content.push({\n type: 'tool-call',\n toolCallId: toolCall.id ?? generateId(),\n toolName: toolCall.function.name,\n input: toolCall.function.arguments!,\n });\n }\n }\n\n // text content:\n const text = choice.message.content;\n if (text != null && text.length > 0) {\n content.push({ type: 'text', text });\n }\n\n const cacheReadTokens = getDeepSeekCacheReadTokens(responseBody.usage);\n\n return {\n content,\n finishReason: mapDeepSeekFinishReason(choice.finish_reason),\n usage: {\n inputTokens: responseBody.usage?.prompt_tokens ?? undefined,\n outputTokens: responseBody.usage?.completion_tokens ?? undefined,\n totalTokens: responseBody.usage?.total_tokens ?? undefined,\n reasoningTokens:\n responseBody.usage?.completion_tokens_details?.reasoning_tokens ??\n undefined,\n cachedInputTokens: cacheReadTokens,\n },\n providerMetadata: {\n [this.providerOptionsName]: {\n promptCacheHitTokens: cacheReadTokens ?? null,\n promptCacheMissTokens:\n responseBody.usage?.prompt_cache_miss_tokens ?? null,\n ...(responseBody.object != null && {\n responseObject: responseBody.object,\n }),\n ...(choice.index != null && { choiceIndex: choice.index }),\n ...(choice.message.role != null && {\n messageRole: choice.message.role,\n }),\n ...(choice.message.tool_calls != null && {\n toolCallTypes: choice.message.tool_calls\n .map(toolCall => toolCall.type)\n .filter(type => type != null),\n }),\n ...(choice.logprobs != null && { logprobs: choice.logprobs }),\n ...(responseBody.system_fingerprint != null && {\n systemFingerprint: responseBody.system_fingerprint,\n }),\n },\n },\n request: { body: args },\n response: {\n ...getResponseMetadata(responseBody),\n headers: responseHeaders,\n body: rawResponse,\n },\n warnings,\n };\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const { args, warnings } = await this.getArgs({ ...options });\n\n const body = {\n ...args,\n stream: true,\n stream_options: { include_usage: true },\n };\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: this.config.url({\n path: '/chat/completions',\n modelId: this.modelId,\n }),\n headers: combineHeaders(this.config.headers(), options.headers),\n body,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n deepseekChatChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const toolCalls: Array<{\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n hasFinished: boolean;\n }> = [];\n\n let finishReason: LanguageModelV2FinishReason = 'unknown';\n let usage: DeepSeekChatTokenUsage | undefined = undefined;\n let systemFingerprint: string | undefined = undefined;\n let isFirstChunk = true;\n const providerOptionsName = this.providerOptionsName;\n let isActiveReasoning = false;\n let isActiveText = false;\n let responseObject: 'chat.completion.chunk' | undefined;\n let choiceIndex: number | undefined;\n let messageRole: 'assistant' | undefined;\n const toolCallTypes = new Map<number, 'function'>();\n const contentLogprobs: DeepSeekChatLogprob[] = [];\n const reasoningLogprobs: DeepSeekChatLogprob[] = [];\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<InferSchema<typeof deepseekChatChunkSchema>>,\n LanguageModelV2StreamPart\n >({\n start(controller) {\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n // Emit raw chunk if requested (before anything else)\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n // handle failed chunk parsing / validation:\n if (!chunk.success) {\n finishReason = 'error';\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n const value = chunk.value;\n\n // handle error chunks:\n if ('error' in value) {\n finishReason = 'error';\n controller.enqueue({ type: 'error', error: value.error.message });\n return;\n }\n\n if (isFirstChunk) {\n isFirstChunk = false;\n\n controller.enqueue({\n type: 'response-metadata',\n ...getResponseMetadata(value),\n });\n }\n\n if (value.usage != null) {\n usage = value.usage;\n }\n\n if (value.object != null) {\n responseObject = value.object;\n }\n\n // The fingerprint is repeated on stream chunks; keep the latest\n // non-null value in case it changes during the response.\n if (value.system_fingerprint != null) {\n systemFingerprint = value.system_fingerprint;\n }\n\n const choice = value.choices[0];\n\n if (choice?.index != null) {\n choiceIndex = choice.index;\n }\n\n if (choice?.finish_reason != null) {\n finishReason = mapDeepSeekFinishReason(choice.finish_reason);\n }\n\n if (choice?.logprobs?.content != null) {\n contentLogprobs.push(...choice.logprobs.content);\n }\n\n if (choice?.logprobs?.reasoning_content != null) {\n reasoningLogprobs.push(...choice.logprobs.reasoning_content);\n }\n\n if (choice?.delta == null) {\n return;\n }\n\n const delta = choice.delta;\n\n if (delta.role != null) {\n messageRole = delta.role;\n }\n\n // enqueue reasoning before text deltas:\n const reasoningContent = delta.reasoning_content;\n if (reasoningContent) {\n if (!isActiveReasoning) {\n controller.enqueue({\n type: 'reasoning-start',\n id: 'reasoning-0',\n });\n isActiveReasoning = true;\n }\n\n controller.enqueue({\n type: 'reasoning-delta',\n id: 'reasoning-0',\n delta: reasoningContent,\n });\n }\n\n if (delta.content) {\n if (!isActiveText) {\n controller.enqueue({ type: 'text-start', id: 'txt-0' });\n isActiveText = true;\n }\n\n // end reasoning when text starts:\n if (isActiveReasoning) {\n controller.enqueue({\n type: 'reasoning-end',\n id: 'reasoning-0',\n });\n isActiveReasoning = false;\n }\n\n controller.enqueue({\n type: 'text-delta',\n id: 'txt-0',\n delta: delta.content,\n });\n }\n\n if (delta.tool_calls != null && delta.tool_calls.length > 0) {\n // end reasoning when tool calls start:\n if (isActiveReasoning) {\n controller.enqueue({\n type: 'reasoning-end',\n id: 'reasoning-0',\n });\n isActiveReasoning = false;\n }\n\n for (const toolCallDelta of delta.tool_calls) {\n if (toolCallDelta.type != null) {\n toolCallTypes.set(toolCallDelta.index, toolCallDelta.type);\n }\n\n const index = toolCallDelta.index;\n\n if (toolCalls[index] == null) {\n if (toolCallDelta.id == null) {\n throw new InvalidResponseDataError({\n data: toolCallDelta,\n message: `Expected 'id' to be a string.`,\n });\n }\n\n if (toolCallDelta.function?.name == null) {\n throw new InvalidResponseDataError({\n data: toolCallDelta,\n message: `Expected 'function.name' to be a string.`,\n });\n }\n\n controller.enqueue({\n type: 'tool-input-start',\n id: toolCallDelta.id,\n toolName: toolCallDelta.function.name,\n });\n\n toolCalls[index] = {\n id: toolCallDelta.id,\n type: 'function',\n function: {\n name: toolCallDelta.function.name,\n arguments: toolCallDelta.function.arguments ?? '',\n },\n hasFinished: false,\n };\n\n const toolCall = toolCalls[index];\n\n if (\n toolCall.function?.name != null &&\n toolCall.function?.arguments != null\n ) {\n // send delta if the argument text has already started:\n if (toolCall.function.arguments.length > 0) {\n controller.enqueue({\n type: 'tool-input-delta',\n id: toolCall.id,\n delta: toolCall.function.arguments,\n });\n }\n\n // check if tool call is complete\n // (some providers send the full tool call in one chunk):\n if (isParsableJson(toolCall.function.arguments)) {\n controller.enqueue({\n type: 'tool-input-end',\n id: toolCall.id,\n });\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId: toolCall.id ?? generateId(),\n toolName: toolCall.function.name,\n input: toolCall.function.arguments,\n });\n toolCall.hasFinished = true;\n }\n }\n\n continue;\n }\n\n // existing tool call, merge if not finished\n const toolCall = toolCalls[index];\n\n if (toolCall.hasFinished) {\n continue;\n }\n\n if (toolCallDelta.function?.arguments != null) {\n toolCall.function!.arguments +=\n toolCallDelta.function?.arguments ?? '';\n }\n\n // send delta\n controller.enqueue({\n type: 'tool-input-delta',\n id: toolCall.id,\n delta: toolCallDelta.function.arguments ?? '',\n });\n\n // check if tool call is complete\n if (\n toolCall.function?.name != null &&\n toolCall.function?.arguments != null &&\n isParsableJson(toolCall.function.arguments)\n ) {\n controller.enqueue({\n type: 'tool-input-end',\n id: toolCall.id,\n });\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId: toolCall.id ?? generateId(),\n toolName: toolCall.function.name,\n input: toolCall.function.arguments,\n });\n toolCall.hasFinished = true;\n }\n }\n }\n },\n\n flush(controller) {\n if (isActiveReasoning) {\n controller.enqueue({ type: 'reasoning-end', id: 'reasoning-0' });\n }\n\n if (isActiveText) {\n controller.enqueue({ type: 'text-end', id: 'txt-0' });\n }\n\n // go through all tool calls and send the ones that are not finished\n for (const toolCall of toolCalls.filter(\n toolCall => !toolCall.hasFinished,\n )) {\n controller.enqueue({\n type: 'tool-input-end',\n id: toolCall.id,\n });\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId: toolCall.id ?? generateId(),\n toolName: toolCall.function.name,\n input: toolCall.function.arguments,\n });\n }\n\n const cacheReadTokens = getDeepSeekCacheReadTokens(usage);\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage: {\n inputTokens: usage?.prompt_tokens ?? undefined,\n outputTokens: usage?.completion_tokens ?? undefined,\n totalTokens: usage?.total_tokens ?? undefined,\n reasoningTokens:\n usage?.completion_tokens_details?.reasoning_tokens ??\n undefined,\n cachedInputTokens: cacheReadTokens,\n },\n providerMetadata: {\n [providerOptionsName]: {\n promptCacheHitTokens: cacheReadTokens ?? null,\n promptCacheMissTokens:\n usage?.prompt_cache_miss_tokens ?? null,\n ...(responseObject != null && { responseObject }),\n ...(choiceIndex != null && { choiceIndex }),\n ...(messageRole != null && { messageRole }),\n ...(toolCallTypes.size > 0 && {\n toolCallTypes: [...toolCallTypes.entries()]\n .sort(([left], [right]) => left - right)\n .map(([, type]) => type),\n }),\n ...((contentLogprobs.length > 0 ||\n reasoningLogprobs.length > 0) && {\n logprobs: {\n ...(contentLogprobs.length > 0 && {\n content: contentLogprobs,\n }),\n ...(reasoningLogprobs.length > 0 && {\n reasoning_content: reasoningLogprobs,\n }),\n },\n }),\n ...(systemFingerprint != null && { systemFingerprint }),\n },\n },\n });\n },\n }),\n ),\n request: { body },\n response: { headers: responseHeaders },\n };\n }\n}\n","import {\n InvalidPromptError,\n UnsupportedFunctionalityError,\n type LanguageModelV2CallOptions,\n type LanguageModelV2CallWarning,\n type LanguageModelV2Prompt,\n} from '@ai-sdk/provider';\nimport {\n stringifyWithBigIntAndCycles,\n secureJsonParse,\n convertToBase64,\n parseProviderOptions,\n} from '@ai-sdk/provider-utils';\nimport type {\n DeepSeekChatPrompt,\n DeepSeekContentPart,\n} from './deepseek-chat-api-types';\nimport { deepseekAssistantMessageProviderOptions } from './deepseek-chat-options';\nimport { deepseekFilePartProviderOptions } from './deepseek-file-part-options';\nimport { isDeepSeekV4Model } from './is-deepseek-v4-model';\n\nconst supportedImageMediaTypes = new Set([\n 'image/gif',\n 'image/jpeg',\n 'image/jpg',\n 'image/png',\n 'image/webp',\n]);\n\nfunction serializeDeepSeekToolCallArguments(input: unknown): string {\n if (typeof input === 'string') {\n try {\n secureJsonParse(input);\n return input;\n } catch {\n return JSON.stringify(input);\n }\n }\n return stringifyWithBigIntAndCycles(input);\n}\n\nexport async function convertToDeepSeekChatMessages({\n prompt,\n responseFormat,\n modelId,\n providerOptionsName = 'deepseek',\n supportsAssistantPrefixCompletion = false,\n supportsStructuredOutputs = false,\n}: {\n prompt: LanguageModelV2Prompt;\n responseFormat: LanguageModelV2CallOptions['responseFormat'];\n modelId: string;\n providerOptionsName?: string;\n supportsAssistantPrefixCompletion?: boolean;\n supportsStructuredOutputs?: boolean;\n}): Promise<{\n messages: DeepSeekChatPrompt;\n warnings: Array<LanguageModelV2CallWarning>;\n}> {\n const isDeepSeekV4 = isDeepSeekV4Model(modelId);\n const messages: DeepSeekChatPrompt = [];\n const warnings: Array<LanguageModelV2CallWarning> = [];\n\n // Inject system message if response format is JSON\n if (responseFormat?.type === 'json') {\n if (responseFormat.schema == null) {\n messages.push({\n role: 'system',\n content: 'Return JSON.',\n });\n } else if (!supportsStructuredOutputs) {\n messages.push({\n role: 'system',\n content:\n 'Return JSON that conforms to the following schema: ' +\n JSON.stringify(responseFormat.schema),\n });\n }\n }\n\n // TODO use findLastIndex once we use ES2023\n let lastUserMessageIndex = -1;\n for (let i = prompt.length - 1; i >= 0; i--) {\n if (prompt[i].role === 'user') {\n lastUserMessageIndex = i;\n break;\n }\n }\n\n let index = -1;\n for (const { role, content, providerOptions } of prompt) {\n index++;\n\n // The assistant schema extends the common message schema, so one parse\n // validates names for every role and the assistant-only prefix option.\n const deepseekMessageOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions,\n schema: deepseekAssistantMessageProviderOptions,\n });\n\n if (deepseekMessageOptions?.prefix === true && role !== 'assistant') {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek assistant prefix completion requires `prefix: true` on an assistant message.',\n });\n }\n\n switch (role) {\n case 'system': {\n messages.push({\n role: 'system',\n content,\n ...(deepseekMessageOptions?.name != null && {\n name: deepseekMessageOptions.name,\n }),\n });\n break;\n }\n\n case 'user': {\n const hasImagePart = content.some(\n part =>\n part.type === 'file' &&\n (part.mediaType === 'image' || part.mediaType.startsWith('image/')),\n );\n\n if (!hasImagePart) {\n let userContent = '';\n for (const part of content) {\n if (part.type === 'text') {\n userContent += part.text;\n } else {\n warnings.push({\n type: 'other',\n message: `Unsupported user message part type: ${part.type}`,\n });\n }\n }\n\n messages.push({\n role: 'user',\n content: userContent,\n ...(deepseekMessageOptions?.name != null && {\n name: deepseekMessageOptions.name,\n }),\n });\n break;\n }\n\n const userContent: Array<DeepSeekContentPart> = [];\n for (const part of content) {\n if (part.type === 'text') {\n userContent.push({ type: 'text', text: part.text });\n } else if (\n part.type === 'file' &&\n (part.mediaType === 'image' || part.mediaType.startsWith('image/'))\n ) {\n const filePartOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions: part.providerOptions,\n schema: deepseekFilePartProviderOptions,\n });\n\n const resolvedMediaType =\n part.mediaType === 'image' || part.mediaType === 'image/*'\n ? 'image/jpeg'\n : part.mediaType;\n\n if (!supportedImageMediaTypes.has(resolvedMediaType)) {\n throw new UnsupportedFunctionalityError({\n functionality: `DeepSeek image media type ${resolvedMediaType}`,\n message:\n 'DeepSeek supports JPEG, PNG, GIF, and WebP image inputs.',\n });\n }\n\n if (part.data instanceof URL) {\n const url = part.data.toString();\n\n if (url.length > 8192) {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek image URLs must not exceed 8192 characters.',\n });\n }\n\n if (filePartOptions?.fileData === true) {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek `fileData` image parts require inline data, not a URL.',\n });\n }\n\n userContent.push({\n type: 'image_url',\n image_url: {\n url,\n ...(filePartOptions?.imageDetail != null && {\n detail: filePartOptions.imageDetail,\n }),\n },\n });\n } else {\n const dataUrl = `data:${\n resolvedMediaType === 'image/jpg'\n ? 'image/jpeg'\n : resolvedMediaType\n };base64,${convertToBase64(part.data)}`;\n\n if (filePartOptions?.fileData === true) {\n if (filePartOptions.imageDetail != null) {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek `imageDetail` cannot be combined with `fileData`.',\n });\n }\n\n userContent.push({\n type: 'file',\n file_data: dataUrl,\n ...(part.filename != null && { filename: part.filename }),\n });\n } else {\n userContent.push({\n type: 'image_url',\n image_url: {\n url: dataUrl,\n ...(filePartOptions?.imageDetail != null && {\n detail: filePartOptions.imageDetail,\n }),\n },\n });\n }\n }\n } else {\n warnings.push({\n type: 'other',\n message: `Unsupported user message part type: ${part.type}`,\n });\n }\n }\n\n messages.push({\n role: 'user',\n content: userContent,\n ...(deepseekMessageOptions?.name != null && {\n name: deepseekMessageOptions.name,\n }),\n });\n\n break;\n }\n case 'assistant': {\n if (deepseekMessageOptions?.prefix === true) {\n if (index !== prompt.length - 1) {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek assistant prefix completion requires the prefixed assistant message to be the final message.',\n });\n }\n\n if (!supportsAssistantPrefixCompletion) {\n throw new UnsupportedFunctionalityError({\n functionality: 'DeepSeek assistant prefix completion',\n message:\n 'DeepSeek assistant prefix completion requires a beta base URL ending in `/beta`.',\n });\n }\n }\n\n let text = '';\n let reasoning: string | undefined;\n\n const toolCalls: Array<{\n id: string;\n type: 'function';\n function: { name: string; arguments: string };\n }> = [];\n\n for (const part of content) {\n switch (part.type) {\n case 'text': {\n text += part.text;\n break;\n }\n case 'reasoning': {\n // R1 must not receive prior reasoning; V4 requires it.\n if (index <= lastUserMessageIndex && !isDeepSeekV4) {\n break;\n }\n\n if (reasoning == null) {\n reasoning = part.text;\n } else {\n reasoning += part.text;\n }\n break;\n }\n case 'tool-call': {\n toolCalls.push({\n id: part.toolCallId,\n type: 'function',\n function: {\n name: part.toolName,\n arguments: serializeDeepSeekToolCallArguments(part.input),\n },\n });\n break;\n }\n }\n }\n\n // V4 demands the field on every assistant turn — back-fill an empty\n // string when the source message had no reasoning part at all.\n messages.push({\n role: 'assistant',\n content: text,\n ...(deepseekMessageOptions?.name != null && {\n name: deepseekMessageOptions.name,\n }),\n ...(deepseekMessageOptions?.prefix === true && {\n prefix: true,\n }),\n reasoning_content: reasoning ?? (isDeepSeekV4 ? '' : undefined),\n tool_calls: toolCalls.length > 0 ? toolCalls : undefined,\n });\n\n break;\n }\n\n case 'tool': {\n if (deepseekMessageOptions?.name != null) {\n warnings.push({\n type: 'other',\n message:\n 'DeepSeek does not support message names on tool messages. The name has been omitted.',\n });\n }\n\n for (const toolResponse of content) {\n const output = toolResponse.output;\n\n let contentValue: string;\n switch (output.type) {\n case 'text':\n case 'error-text':\n contentValue = output.value;\n break;\n case 'content':\n case 'json':\n case 'error-json':\n contentValue = stringifyWithBigIntAndCycles(output.value);\n break;\n }\n\n messages.push({\n role: 'tool',\n tool_call_id: toolResponse.toolCallId,\n content: contentValue,\n });\n }\n break;\n }\n\n default: {\n warnings.push({\n type: 'other',\n message: `Unsupported message role: ${role}`,\n });\n break;\n }\n }\n }\n\n return { messages, warnings };\n}\n","import {\n type InferSchema,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://api-docs.deepseek.com/quick_start/pricing\nexport type DeepSeekChatModelId =\n | 'deepseek-flash'\n | 'deepseek-v4-flash'\n | 'deepseek-v4-pro'\n | 'deepseek-v4-flash-vision-exp'\n // Retired aliases remain assignable through the string escape hatch, but are\n // intentionally omitted from first-class editor suggestions.\n | (string & {});\n\nfunction createDeepseekChatOptionsSchema() {\n return z.object({\n /**\n * Whether to return log probabilities for generated tokens.\n */\n logprobs: z.boolean().optional(),\n\n /**\n * Number of most likely tokens to return at each token position.\n *\n * Setting this option automatically enables `logprobs`.\n */\n topLogprobs: z.number().int().min(0).max(20).optional(),\n\n /**\n * An opaque identifier for the end user. DeepSeek uses this identifier for\n * content-safety tracing and request isolation.\n *\n * Must contain only ASCII letters, numbers, underscores, and hyphens, and\n * must be at most 512 characters long.\n */\n userId: z\n .string()\n .regex(/^[a-zA-Z0-9_-]+$/, 'userId must match /^[a-zA-Z0-9_-]+$/')\n .max(512, 'userId must be at most 512 characters long')\n .optional(),\n\n /**\n * Type of thinking to use. Defaults to `enabled`.\n */\n thinking: z\n .object({\n // `adaptive` is accepted at runtime for backwards compatibility and\n // mapped to `enabled`, but is intentionally excluded from the exported\n // provider options type.\n type: z.enum(['adaptive', 'enabled', 'disabled']).optional(),\n })\n .optional(),\n\n /**\n * Controls the thinking strength for DeepSeek V4 reasoning models.\n */\n // `medium` and `xhigh` are accepted at runtime for backwards compatibility\n // and mapped to canonical DeepSeek values, but are intentionally excluded\n // from the exported provider options type.\n reasoningEffort: z\n .enum(['low', 'medium', 'high', 'xhigh', 'max'])\n .optional(),\n\n /**\n * Whether to use strict JSON schema validation for structured outputs.\n * Only applies when the serving endpoint supports JSON schema response\n * formats (e.g. Azure). Defaults to `true`.\n */\n strictJsonSchema: z.boolean().optional(),\n });\n}\n\nlet chatOptionsSchema:\n | ReturnType<typeof createDeepseekChatOptionsSchema>\n | undefined;\n\nexport function getDeepseekChatOptionsSchema() {\n return (chatOptionsSchema ??= createDeepseekChatOptionsSchema());\n}\n\nexport const deepseekChatOptions = lazySchema(() =>\n zodSchema(getDeepseekChatOptionsSchema()),\n);\n\nexport type DeepSeekChatOptions = {\n /**\n * Whether to return log probabilities for generated tokens.\n */\n logprobs?: boolean;\n\n /**\n * Number of most likely tokens to return at each token position.\n *\n * Setting this option automatically enables `logprobs`.\n */\n topLogprobs?: number;\n\n /**\n * An opaque identifier for the end user. DeepSeek uses this identifier for\n * content-safety tracing and request isolation.\n *\n * Must contain only ASCII letters, numbers, underscores, and hyphens, and\n * must be at most 512 characters long.\n */\n userId?: string;\n\n /**\n * Controls whether thinking mode is enabled. Defaults to `enabled`.\n */\n thinking?: {\n type?: 'enabled' | 'disabled';\n };\n\n /**\n * Controls the thinking strength for DeepSeek V4 reasoning models.\n */\n reasoningEffort?: 'low' | 'high' | 'max';\n\n /**\n * Whether to use strict JSON schema validation for structured outputs.\n * Only applies when the serving endpoint supports JSON schema response\n * formats (e.g. Azure). Defaults to `true`.\n */\n strictJsonSchema?: boolean;\n};\n\nfunction createDeepseekMessageOptionsSchema() {\n return z.object({\n /**\n * The name of the participant represented by the message.\n *\n * Supported on system, user, and assistant messages.\n */\n name: z.string().optional(),\n });\n}\n\nlet messageOptionsSchema:\n | ReturnType<typeof createDeepseekMessageOptionsSchema>\n | undefined;\n\nexport function getDeepseekMessageOptionsSchema() {\n return (messageOptionsSchema ??= createDeepseekMessageOptionsSchema());\n}\n\nexport const deepseekMessageProviderOptions = lazySchema(() =>\n zodSchema(getDeepseekMessageOptionsSchema()),\n);\n\nexport type DeepSeekMessageProviderOptions = InferSchema<\n typeof deepseekMessageProviderOptions\n>;\n\nfunction createDeepseekAssistantMessageOptionsSchema() {\n return getDeepseekMessageOptionsSchema().extend({\n /**\n * Whether the assistant message content is a prefix that DeepSeek should\n * continue. This beta feature is only supported on the final assistant\n * message when using a beta base URL.\n */\n prefix: z.literal(true).optional(),\n });\n}\n\nlet assistantMessageOptionsSchema:\n | ReturnType<typeof createDeepseekAssistantMessageOptionsSchema>\n | undefined;\n\nexport function getDeepseekAssistantMessageOptionsSchema() {\n return (assistantMessageOptionsSchema ??=\n createDeepseekAssistantMessageOptionsSchema());\n}\n\nexport const deepseekAssistantMessageProviderOptions = lazySchema(() =>\n zodSchema(getDeepseekAssistantMessageOptionsSchema()),\n);\n\nexport type DeepSeekAssistantMessageProviderOptions = InferSchema<\n typeof deepseekAssistantMessageProviderOptions\n>;\n","import {\n type InferSchema,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const deepseekFilePartProviderOptions = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * Controls how DeepSeek processes an image sent as an `image_url` part.\n *\n * @see https://api-docs.deepseek.com/api/create-chat-completion/\n */\n imageDetail: z.enum(['low', 'high', 'original', 'auto']).optional(),\n\n /**\n * Sends inline image data as a DeepSeek `file` part using `file_data`\n * instead of an `image_url` data URL. When set, the file part's filename\n * is preserved.\n *\n * This option only applies to inline image data. It cannot be combined\n * with `imageDetail`.\n */\n fileData: z.literal(true).optional(),\n }),\n ),\n);\n\nexport type DeepSeekFilePartProviderOptions = InferSchema<\n typeof deepseekFilePartProviderOptions\n>;\n","/**\n * Whether a model id uses DeepSeek V4-or-newer behavior (thinking mode on by\n * default, `reasoning_content` required on every assistant turn).\n *\n * DeepSeek publishes V4 models under both versioned ids (`deepseek-v4-pro`,\n * `deepseek-v4-flash-*`) and unversioned aliases (`deepseek-flash`, currently\n * serving V4.1 Flash). Known legacy aliases and pre-V4 version IDs retain\n * their previous behavior; unrecognized IDs inherit the current protocol.\n */\nexport function isDeepSeekV4Model(modelId: string): boolean {\n return !/(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\\.\\d+)?)(?=[-/:.]|$)/.test(\n modelId,\n );\n}\n","import {\n type InferSchema,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport type DeepSeekChatPrompt = Array<DeepSeekMessage>;\n\nexport type DeepSeekMessage =\n | DeepSeekSystemMessage\n | DeepSeekUserMessage\n | DeepSeekAssistantMessage\n | DeepSeekToolMessage;\n\nexport interface DeepSeekSystemMessage {\n role: 'system';\n content: string;\n name?: string;\n}\n\nexport interface DeepSeekUserMessage {\n role: 'user';\n content: string | Array<DeepSeekContentPart>;\n name?: string;\n}\n\nexport type DeepSeekContentPart =\n | DeepSeekContentPartText\n | DeepSeekContentPartImage\n | DeepSeekContentPartFile;\n\nexport interface DeepSeekContentPartText {\n type: 'text';\n text: string;\n}\n\nexport interface DeepSeekContentPartImage {\n type: 'image_url';\n image_url: {\n url: string;\n detail?: 'low' | 'high' | 'original' | 'auto';\n };\n}\n\nexport interface DeepSeekContentPartFile {\n type: 'file';\n file_data: string;\n filename?: string;\n}\nexport interface DeepSeekAssistantMessage {\n role: 'assistant';\n content?: string | null;\n name?: string;\n prefix?: true;\n reasoning_content?: string;\n tool_calls?: Array<DeepSeekMessageToolCall>;\n}\n\nexport interface DeepSeekMessageToolCall {\n type: 'function';\n id: string;\n function: {\n arguments: string;\n name: string;\n };\n}\n\nexport interface DeepSeekToolMessage {\n role: 'tool';\n content: string;\n tool_call_id: string;\n}\n\nfunction createTokenUsageSchema() {\n return z\n .object({\n prompt_tokens: z.number().nullish(),\n completion_tokens: z.number().nullish(),\n prompt_cache_hit_tokens: z.number().nullish(),\n prompt_cache_miss_tokens: z.number().nullish(),\n total_tokens: z.number().nullish(),\n prompt_tokens_details: z\n .object({\n cached_tokens: z.number().nullish(),\n })\n .nullish(),\n completion_tokens_details: z\n .object({\n reasoning_tokens: z.number().nullish(),\n })\n .nullish(),\n })\n .nullish();\n}\n\nlet tokenUsageSchema: ReturnType<typeof createTokenUsageSchema> | undefined;\n\nfunction getTokenUsageSchema() {\n return (tokenUsageSchema ??= createTokenUsageSchema());\n}\n\nexport type DeepSeekChatTokenUsage = z.infer<\n ReturnType<typeof getTokenUsageSchema>\n>;\n\nfunction createDeepSeekErrorSchema() {\n return z.object({\n error: z.object({\n message: z.string(),\n type: z.string().nullish(),\n param: z.any().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n }),\n });\n}\n\nlet errorSchema: ReturnType<typeof createDeepSeekErrorSchema> | undefined;\n\nfunction getDeepSeekErrorSchema() {\n return (errorSchema ??= createDeepSeekErrorSchema());\n}\n\nexport const deepSeekErrorSchema = lazySchema(() =>\n zodSchema(getDeepSeekErrorSchema()),\n);\n\nexport type DeepSeekErrorData = InferSchema<typeof deepSeekErrorSchema>;\n\nfunction createDeepseekChatLogprobsSchema() {\n const deepseekChatLogprobSchema = z.object({\n token: z.string(),\n logprob: z.number(),\n bytes: z.array(z.number()).nullable(),\n top_logprobs: z.array(\n z.object({\n token: z.string(),\n logprob: z.number(),\n bytes: z.array(z.number()).nullable(),\n }),\n ),\n });\n\n return z\n .object({\n content: z.array(deepseekChatLogprobSchema).nullish(),\n reasoning_content: z.array(deepseekChatLogprobSchema).nullish(),\n })\n .nullish();\n}\n\nlet logprobsSchema:\n | ReturnType<typeof createDeepseekChatLogprobsSchema>\n | undefined;\n\nfunction getDeepseekChatLogprobsSchema() {\n return (logprobsSchema ??= createDeepseekChatLogprobsSchema());\n}\n\nexport type DeepSeekChatLogprob = NonNullable<\n NonNullable<\n z.infer<ReturnType<typeof getDeepseekChatLogprobsSchema>>\n >['content']\n>[number];\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nexport const deepseekChatResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string().nullish(),\n created: z.number().nullish(),\n model: z.string().nullish(),\n object: z.literal('chat.completion').nullish(),\n system_fingerprint: z.string().nullish(),\n choices: z.array(\n z.object({\n index: z.number().nullish(),\n message: z.object({\n role: z.literal('assistant').nullish(),\n content: z.string().nullish(),\n reasoning_content: z.string().nullish(),\n tool_calls: z\n .array(\n z.object({\n id: z.string().nullish(),\n type: z.literal('function').nullish(),\n function: z.object({\n name: z.string(),\n arguments: z.string(),\n }),\n }),\n )\n .nullish(),\n }),\n logprobs: getDeepseekChatLogprobsSchema(),\n finish_reason: z.string().nullish(),\n }),\n ),\n usage: getTokenUsageSchema(),\n }),\n ),\n);\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nexport const deepseekChatChunkSchema = lazySchema(() =>\n zodSchema(\n z.union([\n z.object({\n id: z.string().nullish(),\n created: z.number().nullish(),\n model: z.string().nullish(),\n object: z.literal('chat.completion.chunk').nullish(),\n system_fingerprint: z.string().nullish(),\n choices: z.array(\n z.object({\n index: z.number().nullish(),\n delta: z\n .object({\n role: z.enum(['assistant']).nullish(),\n content: z.string().nullish(),\n reasoning_content: z.string().nullish(),\n tool_calls: z\n .array(\n z.object({\n index: z.number(),\n id: z.string().nullish(),\n type: z.literal('function').nullish(),\n function: z.object({\n name: z.string().nullish(),\n arguments: z.string().nullish(),\n }),\n }),\n )\n .nullish(),\n })\n .nullish(),\n logprobs: getDeepseekChatLogprobsSchema(),\n finish_reason: z.string().nullish(),\n }),\n ),\n usage: getTokenUsageSchema(),\n }),\n getDeepSeekErrorSchema(),\n ]),\n ),\n);\n","import {\n type LanguageModelV2CallOptions,\n type LanguageModelV2CallWarning,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\n\nexport function prepareTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV2CallOptions['tools'];\n toolChoice?: LanguageModelV2CallOptions['toolChoice'];\n}): {\n tools:\n | undefined\n | Array<{\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n };\n }>;\n toolChoice:\n | { type: 'function'; function: { name: string } }\n | 'auto'\n | 'none'\n | 'required'\n | undefined;\n toolWarnings: LanguageModelV2CallWarning[];\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: LanguageModelV2CallWarning[] = [];\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const deepseekTools: Array<{\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n };\n }> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider-defined') {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool,\n });\n } else {\n deepseekTools.push({\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n },\n });\n }\n }\n\n if (toolChoice == null) {\n return { tools: deepseekTools, toolChoice: undefined, toolWarnings };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n case 'none':\n case 'required':\n return { tools: deepseekTools, toolChoice: type, toolWarnings };\n case 'tool':\n return {\n tools: deepseekTools,\n toolChoice: {\n type: 'function',\n function: { name: toolChoice.toolName },\n },\n toolWarnings,\n };\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","export function getResponseMetadata({\n id,\n model,\n created,\n}: {\n id?: string | undefined | null;\n created?: number | undefined | null;\n model?: string | undefined | null;\n}) {\n return {\n id: id ?? undefined,\n modelId: model ?? undefined,\n timestamp: created != null ? new Date(created * 1000) : undefined,\n };\n}\n","import type { LanguageModelV2FinishReason } from '@ai-sdk/provider';\n\nexport function mapDeepSeekFinishReason(\n finishReason: string | null | undefined,\n): LanguageModelV2FinishReason {\n switch (finishReason) {\n case 'stop':\n return 'stop';\n case 'length':\n return 'length';\n case 'content_filter':\n return 'content-filter';\n case 'tool_calls':\n return 'tool-calls';\n case 'insufficient_system_resource':\n return 'error';\n default:\n return 'unknown';\n }\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAIO;AACP,IAAAC,yBAKO;;;ACVP,IAAAC,mBAQO;AACP,IAAAC,yBAaO;;;ACtBP,sBAMO;AACP,IAAAC,yBAKO;;;ACZP,4BAIO;AACP,gBAAkB;AAYlB,SAAS,kCAAkC;AACzC,SAAO,YAAE,OAAO;AAAA;AAAA;AAAA;AAAA,IAId,UAAU,YAAE,QAAQ,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO/B,aAAa,YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAStD,QAAQ,YACL,OAAO,EACP,MAAM,oBAAoB,sCAAsC,EAChE,IAAI,KAAK,4CAA4C,EACrD,SAAS;AAAA;AAAA;AAAA;AAAA,IAKZ,UAAU,YACP,OAAO;AAAA;AAAA;AAAA;AAAA,MAIN,MAAM,YAAE,KAAK,CAAC,YAAY,WAAW,UAAU,CAAC,EAAE,SAAS;AAAA,IAC7D,CAAC,EACA,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQZ,iBAAiB,YACd,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E,KAAK;AAAA,MAChB,UAAU,EAAE,SAAS,gBAAgB;AAAA,IACvC;AAAA,EACF;AACF;;;ASnvBO,IAAM,UACX,OACI,WACA;;;AVkDC,SAAS,eACd,UAAoC,CAAC,GACnB;AAzDpB;AA0DE,QAAM,WACJ,sDAAqB,QAAQ,OAAO,MAApC,YAAyC;AAE3C,QAAM,aAAa,UACjB;AAAA,IACE;AAAA,MACE,eAAe,cAAU,mCAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,mBAAmB,OAAO;AAAA,EAC5B;AAEF,QAAM,sBAAsB,CAAC,YAAiC;AAC5D,WAAO,IAAI,0BAA0B,SAAS;AAAA,MAC5C,UAAU;AAAA,MACV,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,MACpC,SAAS;AAAA,MACT,OAAO,QAAQ;AAAA,MACf,mCAAmC,QAAQ,SAAS,OAAO;AAAA,IAC7D,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,YAChB,oBAAoB,OAAO;AAE7B,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAEhB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,kCAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AACA,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,kCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":["import_provider","import_provider_utils","import_provider","import_provider_utils","import_provider_utils","import_provider_utils","import_v4","userContent","import_provider_utils","import_v4","import_provider","toolCall"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/deepseek-provider.ts","../src/chat/deepseek-chat-language-model.ts","../src/chat/convert-to-deepseek-chat-messages.ts","../src/chat/deepseek-chat-options.ts","../src/chat/deepseek-file-part-options.ts","../src/chat/is-deepseek-v4-model.ts","../src/chat/deepseek-chat-api-types.ts","../src/chat/deepseek-prepare-tools.ts","../src/chat/get-response-metadata.ts","../src/chat/map-deepseek-finish-reason.ts","../src/version.ts"],"sourcesContent":["export { createDeepSeek, deepseek } from './deepseek-provider';\nexport type {\n DeepSeekProvider,\n DeepSeekProviderSettings,\n} from './deepseek-provider';\nexport { VERSION } from './version';\nexport type {\n DeepSeekAssistantMessageProviderOptions,\n DeepSeekChatOptions,\n DeepSeekMessageProviderOptions,\n} from './chat/deepseek-chat-options';\nexport type { DeepSeekErrorData } from './chat/deepseek-chat-api-types';\nexport type { DeepSeekFilePartProviderOptions } from './chat/deepseek-file-part-options';\n","import {\n type LanguageModelV2,\n type ProviderV2,\n NoSuchModelError,\n} from '@ai-sdk/provider';\nimport {\n type FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport type { DeepSeekChatModelId } from './chat/deepseek-chat-options';\nimport { DeepSeekChatLanguageModel } from './chat/deepseek-chat-language-model';\nimport { VERSION } from './version';\n\nexport interface DeepSeekProviderSettings {\n /**\n * DeepSeek API key.\n */\n apiKey?: string;\n\n /**\n * Base URL for the API calls.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface DeepSeekProvider extends ProviderV2 {\n /**\nCreates a DeepSeek model for text generation.\n*/\n (modelId: DeepSeekChatModelId): LanguageModelV2;\n\n /**\nCreates a DeepSeek model for text generation.\n*/\n languageModel(modelId: DeepSeekChatModelId): LanguageModelV2;\n\n /**\nCreates a DeepSeek chat model for text generation.\n*/\n chat(modelId: DeepSeekChatModelId): LanguageModelV2;\n}\n\nexport function createDeepSeek(\n options: DeepSeekProviderSettings = {},\n): DeepSeekProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL) ?? 'https://api.deepseek.com';\n\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPSEEK_API_KEY',\n description: 'DeepSeek API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/deepseek/${VERSION}`,\n );\n\n const createLanguageModel = (modelId: DeepSeekChatModelId) => {\n return new DeepSeekChatLanguageModel(modelId, {\n provider: `deepseek.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n supportsAssistantPrefixCompletion: baseURL.endsWith('/beta'),\n });\n };\n\n const provider = (modelId: DeepSeekChatModelId) =>\n createLanguageModel(modelId);\n\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const deepseek = createDeepSeek();\n","import {\n type APICallError,\n type LanguageModelV2,\n type LanguageModelV2CallWarning,\n type LanguageModelV2Content,\n type LanguageModelV2FinishReason,\n type LanguageModelV2StreamPart,\n InvalidResponseDataError,\n} from '@ai-sdk/provider';\nimport {\n type FetchFunction,\n type InferSchema,\n type ParseResult,\n type ResponseHandler,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n generateId,\n parseProviderOptions,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport { convertToDeepSeekChatMessages } from './convert-to-deepseek-chat-messages';\nimport {\n type DeepSeekChatTokenUsage,\n deepseekChatChunkSchema,\n deepseekChatResponseSchema,\n deepSeekErrorSchema,\n type DeepSeekChatLogprob,\n} from './deepseek-chat-api-types';\nimport {\n type DeepSeekChatModelId,\n deepseekChatOptions,\n} from './deepseek-chat-options';\nimport { prepareTools } from './deepseek-prepare-tools';\nimport { getResponseMetadata } from './get-response-metadata';\nimport { isDeepSeekV4Model } from './is-deepseek-v4-model';\nimport { mapDeepSeekFinishReason } from './map-deepseek-finish-reason';\n\nexport type DeepSeekChatConfig = {\n provider: string;\n headers: () => Record<string, string | undefined>;\n url: (options: { modelId: string; path: string }) => string;\n fetch?: FetchFunction;\n supportsAssistantPrefixCompletion?: boolean;\n supportsPenaltySampling?: boolean;\n supportsThinking?: boolean;\n supportsStructuredOutputs?: boolean;\n};\n\nfunction getDeepSeekCacheReadTokens(\n usage: DeepSeekChatTokenUsage | undefined | null,\n): number | undefined {\n return (\n usage?.prompt_cache_hit_tokens ??\n usage?.prompt_tokens_details?.cached_tokens ??\n undefined\n );\n}\n\nfunction mapDeepSeekProviderReasoningEffort({\n reasoningEffort,\n warnings,\n}: {\n reasoningEffort: 'low' | 'medium' | 'high' | 'xhigh' | 'max';\n warnings: LanguageModelV2CallWarning[];\n}): 'low' | 'high' | 'max' {\n const mapped =\n reasoningEffort === 'medium'\n ? 'high'\n : reasoningEffort === 'xhigh'\n ? 'max'\n : reasoningEffort;\n\n if (mapped !== reasoningEffort) {\n warnings.push({\n type: 'other',\n message: `reasoningEffort \"${reasoningEffort}\" is not a canonical DeepSeek value. mapped to \"${mapped}\".`,\n });\n }\n\n return mapped;\n}\n\nexport class DeepSeekChatLanguageModel implements LanguageModelV2 {\n readonly specificationVersion = 'v2';\n\n readonly modelId: DeepSeekChatModelId;\n\n readonly supportedUrls = {\n 'image/*': [/^https?:\\/\\/.*$/],\n };\n\n private readonly config: DeepSeekChatConfig;\n private readonly failedResponseHandler: ResponseHandler<APICallError>;\n\n constructor(modelId: DeepSeekChatModelId, config: DeepSeekChatConfig) {\n this.modelId = modelId;\n this.config = config;\n\n this.failedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: deepSeekErrorSchema,\n errorToMessage: (error: InferSchema<typeof deepSeekErrorSchema>) =>\n error.error.message,\n });\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n private get providerOptionsName(): string {\n return this.config.provider.split('.')[0].trim();\n }\n\n private async getArgs({\n prompt,\n maxOutputTokens,\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n providerOptions,\n stopSequences,\n responseFormat,\n tools,\n toolChoice,\n seed,\n }: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const deepseekOptions =\n (await parseProviderOptions({\n provider: this.providerOptionsName,\n providerOptions,\n schema: deepseekChatOptions,\n })) ?? {};\n\n const supportsStructuredOutputs =\n this.config.supportsStructuredOutputs === true;\n const supportsPenaltySampling =\n this.config.supportsPenaltySampling === true;\n\n const { messages, warnings } = await convertToDeepSeekChatMessages({\n prompt,\n responseFormat,\n modelId: this.modelId,\n providerOptionsName: this.providerOptionsName,\n supportsAssistantPrefixCompletion:\n this.config.supportsAssistantPrefixCompletion,\n supportsStructuredOutputs,\n });\n const allWarnings = [...warnings];\n\n if (topK != null) {\n allWarnings.push({ type: 'unsupported-setting', setting: 'topK' });\n }\n\n if (seed != null) {\n allWarnings.push({ type: 'unsupported-setting', setting: 'seed' });\n }\n\n if (!supportsPenaltySampling && frequencyPenalty != null) {\n allWarnings.push({\n type: 'other',\n message:\n 'frequencyPenalty is deprecated by DeepSeek and has been omitted. Remove frequencyPenalty from the request.',\n });\n }\n\n if (!supportsPenaltySampling && presencePenalty != null) {\n allWarnings.push({\n type: 'other',\n message:\n 'presencePenalty is deprecated by DeepSeek and has been omitted. Remove presencePenalty from the request.',\n });\n }\n\n const {\n tools: deepseekTools,\n toolChoice: deepseekToolChoices,\n toolWarnings,\n } = prepareTools({\n tools,\n toolChoice,\n });\n allWarnings.push(...toolWarnings);\n\n const thinkingType = deepseekOptions.thinking?.type;\n if (thinkingType === 'adaptive') {\n allWarnings.push({\n type: 'other',\n message:\n 'thinking.type \"adaptive\" is not a canonical DeepSeek value. mapped to \"enabled\".',\n });\n }\n\n const thinking =\n this.config.supportsThinking === false\n ? undefined\n : thinkingType != null\n ? { type: thinkingType === 'adaptive' ? 'enabled' : thinkingType }\n : undefined;\n\n const isThinkingEnabled =\n this.config.supportsThinking !== false &&\n thinking?.type !== 'disabled' &&\n (thinking != null ||\n this.modelId === 'deepseek-reasoner' ||\n isDeepSeekV4Model(this.modelId));\n\n if (isThinkingEnabled && temperature != null) {\n allWarnings.push({\n type: 'unsupported-setting',\n setting: 'temperature',\n details:\n \"temperature has no effect when DeepSeek thinking is enabled. Set providerOptions.deepseek.thinking.type to 'disabled' to use temperature.\",\n });\n }\n\n if (isThinkingEnabled && topP != null) {\n allWarnings.push({\n type: 'unsupported-setting',\n setting: 'topP',\n details:\n \"topP has no effect when DeepSeek thinking is enabled. Set providerOptions.deepseek.thinking.type to 'disabled' to use topP.\",\n });\n }\n\n const reasoningEffort =\n deepseekOptions.reasoningEffort != null\n ? mapDeepSeekProviderReasoningEffort({\n reasoningEffort: deepseekOptions.reasoningEffort,\n warnings: allWarnings,\n })\n : undefined;\n\n return {\n args: {\n model: this.modelId,\n ...((deepseekOptions.logprobs === true ||\n deepseekOptions.topLogprobs != null) && { logprobs: true }),\n ...(deepseekOptions.topLogprobs != null && {\n top_logprobs: deepseekOptions.topLogprobs,\n }),\n max_tokens: maxOutputTokens,\n temperature: isThinkingEnabled ? undefined : temperature,\n top_p: isThinkingEnabled ? undefined : topP,\n frequency_penalty: supportsPenaltySampling\n ? frequencyPenalty\n : undefined,\n presence_penalty: supportsPenaltySampling ? presencePenalty : undefined,\n response_format:\n responseFormat?.type === 'json'\n ? supportsStructuredOutputs && responseFormat.schema != null\n ? {\n type: 'json_schema',\n json_schema: {\n schema: responseFormat.schema,\n strict: deepseekOptions.strictJsonSchema ?? true,\n name: responseFormat.name ?? 'response',\n description: responseFormat.description,\n },\n }\n : { type: 'json_object' }\n : undefined,\n stop: stopSequences,\n messages,\n tools: deepseekTools,\n tool_choice: deepseekToolChoices,\n thinking,\n ...(deepseekOptions.userId != null && {\n user_id: deepseekOptions.userId,\n }),\n ...(thinking?.type !== 'disabled' &&\n reasoningEffort != null && {\n reasoning_effort: reasoningEffort,\n }),\n },\n warnings: allWarnings,\n };\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { args, warnings } = await this.getArgs({ ...options });\n\n const {\n responseHeaders,\n value: responseBody,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.config.url({\n path: '/chat/completions',\n modelId: this.modelId,\n }),\n headers: combineHeaders(this.config.headers(), options.headers),\n body: args,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepseekChatResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const choice = responseBody.choices[0];\n const content: Array<LanguageModelV2Content> = [];\n\n // reasoning content (before text):\n const reasoning = choice.message.reasoning_content;\n if (reasoning != null && reasoning.length > 0) {\n content.push({\n type: 'reasoning',\n text: reasoning,\n });\n }\n\n // tool calls:\n if (choice.message.tool_calls != null) {\n for (const toolCall of choice.message.tool_calls) {\n content.push({\n type: 'tool-call',\n toolCallId: toolCall.id ?? generateId(),\n toolName: toolCall.function.name,\n input: toolCall.function.arguments!,\n });\n }\n }\n\n // text content:\n const text = choice.message.content;\n if (text != null && text.length > 0) {\n content.push({ type: 'text', text });\n }\n\n const cacheReadTokens = getDeepSeekCacheReadTokens(responseBody.usage);\n\n return {\n content,\n finishReason: mapDeepSeekFinishReason(choice.finish_reason),\n usage: {\n inputTokens: responseBody.usage?.prompt_tokens ?? undefined,\n outputTokens: responseBody.usage?.completion_tokens ?? undefined,\n totalTokens: responseBody.usage?.total_tokens ?? undefined,\n reasoningTokens:\n responseBody.usage?.completion_tokens_details?.reasoning_tokens ??\n undefined,\n cachedInputTokens: cacheReadTokens,\n },\n providerMetadata: {\n [this.providerOptionsName]: {\n promptCacheHitTokens: cacheReadTokens ?? null,\n promptCacheMissTokens:\n responseBody.usage?.prompt_cache_miss_tokens ?? null,\n ...(responseBody.object != null && {\n responseObject: responseBody.object,\n }),\n ...(choice.index != null && { choiceIndex: choice.index }),\n ...(choice.message.role != null && {\n messageRole: choice.message.role,\n }),\n ...(choice.message.tool_calls != null && {\n toolCallTypes: choice.message.tool_calls\n .map(toolCall => toolCall.type)\n .filter(type => type != null),\n }),\n ...(choice.logprobs != null && { logprobs: choice.logprobs }),\n ...(responseBody.system_fingerprint != null && {\n systemFingerprint: responseBody.system_fingerprint,\n }),\n },\n },\n request: { body: args },\n response: {\n ...getResponseMetadata(responseBody),\n headers: responseHeaders,\n body: rawResponse,\n },\n warnings,\n };\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const { args, warnings } = await this.getArgs({ ...options });\n\n const body = {\n ...args,\n stream: true,\n stream_options: { include_usage: true },\n };\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: this.config.url({\n path: '/chat/completions',\n modelId: this.modelId,\n }),\n headers: combineHeaders(this.config.headers(), options.headers),\n body,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n deepseekChatChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const toolCalls: Array<{\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n hasFinished: boolean;\n }> = [];\n\n let finishReason: LanguageModelV2FinishReason = 'unknown';\n let usage: DeepSeekChatTokenUsage | undefined = undefined;\n let systemFingerprint: string | undefined = undefined;\n let isFirstChunk = true;\n const providerOptionsName = this.providerOptionsName;\n let isActiveReasoning = false;\n let isActiveText = false;\n let responseObject: 'chat.completion.chunk' | undefined;\n let choiceIndex: number | undefined;\n let messageRole: 'assistant' | undefined;\n const toolCallTypes = new Map<number, 'function'>();\n const contentLogprobs: DeepSeekChatLogprob[] = [];\n const reasoningLogprobs: DeepSeekChatLogprob[] = [];\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<InferSchema<typeof deepseekChatChunkSchema>>,\n LanguageModelV2StreamPart\n >({\n start(controller) {\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n // Emit raw chunk if requested (before anything else)\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n // handle failed chunk parsing / validation:\n if (!chunk.success) {\n finishReason = 'error';\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n const value = chunk.value;\n\n // handle error chunks:\n if ('error' in value) {\n finishReason = 'error';\n controller.enqueue({ type: 'error', error: value.error.message });\n return;\n }\n\n if (isFirstChunk) {\n isFirstChunk = false;\n\n controller.enqueue({\n type: 'response-metadata',\n ...getResponseMetadata(value),\n });\n }\n\n if (value.usage != null) {\n usage = value.usage;\n }\n\n if (value.object != null) {\n responseObject = value.object;\n }\n\n // The fingerprint is repeated on stream chunks; keep the latest\n // non-null value in case it changes during the response.\n if (value.system_fingerprint != null) {\n systemFingerprint = value.system_fingerprint;\n }\n\n const choice = value.choices[0];\n\n if (choice?.index != null) {\n choiceIndex = choice.index;\n }\n\n if (choice?.finish_reason != null) {\n finishReason = mapDeepSeekFinishReason(choice.finish_reason);\n }\n\n if (choice?.logprobs?.content != null) {\n contentLogprobs.push(...choice.logprobs.content);\n }\n\n if (choice?.logprobs?.reasoning_content != null) {\n reasoningLogprobs.push(...choice.logprobs.reasoning_content);\n }\n\n if (choice?.delta == null) {\n return;\n }\n\n const delta = choice.delta;\n\n if (delta.role != null) {\n messageRole = delta.role;\n }\n\n // enqueue reasoning before text deltas:\n const reasoningContent = delta.reasoning_content;\n if (reasoningContent) {\n if (!isActiveReasoning) {\n controller.enqueue({\n type: 'reasoning-start',\n id: 'reasoning-0',\n });\n isActiveReasoning = true;\n }\n\n controller.enqueue({\n type: 'reasoning-delta',\n id: 'reasoning-0',\n delta: reasoningContent,\n });\n }\n\n if (delta.content) {\n if (!isActiveText) {\n controller.enqueue({ type: 'text-start', id: 'txt-0' });\n isActiveText = true;\n }\n\n // end reasoning when text starts:\n if (isActiveReasoning) {\n controller.enqueue({\n type: 'reasoning-end',\n id: 'reasoning-0',\n });\n isActiveReasoning = false;\n }\n\n controller.enqueue({\n type: 'text-delta',\n id: 'txt-0',\n delta: delta.content,\n });\n }\n\n if (delta.tool_calls != null && delta.tool_calls.length > 0) {\n // end reasoning when tool calls start:\n if (isActiveReasoning) {\n controller.enqueue({\n type: 'reasoning-end',\n id: 'reasoning-0',\n });\n isActiveReasoning = false;\n }\n\n for (const toolCallDelta of delta.tool_calls) {\n if (toolCallDelta.type != null) {\n toolCallTypes.set(toolCallDelta.index, toolCallDelta.type);\n }\n\n const index = toolCallDelta.index;\n\n if (toolCalls[index] == null) {\n if (toolCallDelta.id == null) {\n throw new InvalidResponseDataError({\n data: toolCallDelta,\n message: `Expected 'id' to be a string.`,\n });\n }\n\n if (toolCallDelta.function?.name == null) {\n throw new InvalidResponseDataError({\n data: toolCallDelta,\n message: `Expected 'function.name' to be a string.`,\n });\n }\n\n controller.enqueue({\n type: 'tool-input-start',\n id: toolCallDelta.id,\n toolName: toolCallDelta.function.name,\n });\n\n toolCalls[index] = {\n id: toolCallDelta.id,\n type: 'function',\n function: {\n name: toolCallDelta.function.name,\n arguments: toolCallDelta.function.arguments ?? '',\n },\n hasFinished: false,\n };\n\n const toolCall = toolCalls[index];\n\n if (\n toolCall.function?.name != null &&\n toolCall.function?.arguments != null\n ) {\n // send delta if the argument text has already started:\n if (toolCall.function.arguments.length > 0) {\n controller.enqueue({\n type: 'tool-input-delta',\n id: toolCall.id,\n delta: toolCall.function.arguments,\n });\n }\n }\n\n continue;\n }\n\n // existing tool call, merge if not finished\n const toolCall = toolCalls[index];\n\n if (toolCall.hasFinished) {\n continue;\n }\n\n if (toolCallDelta.function?.arguments != null) {\n toolCall.function!.arguments +=\n toolCallDelta.function?.arguments ?? '';\n }\n\n // send delta\n controller.enqueue({\n type: 'tool-input-delta',\n id: toolCall.id,\n delta: toolCallDelta.function.arguments ?? '',\n });\n }\n }\n },\n\n flush(controller) {\n if (isActiveReasoning) {\n controller.enqueue({ type: 'reasoning-end', id: 'reasoning-0' });\n }\n\n if (isActiveText) {\n controller.enqueue({ type: 'text-end', id: 'txt-0' });\n }\n\n // go through all tool calls and send the ones that are not finished\n for (const toolCall of toolCalls.filter(\n toolCall => !toolCall.hasFinished,\n )) {\n controller.enqueue({\n type: 'tool-input-end',\n id: toolCall.id,\n });\n\n controller.enqueue({\n type: 'tool-call',\n toolCallId: toolCall.id ?? generateId(),\n toolName: toolCall.function.name,\n input: toolCall.function.arguments,\n });\n toolCall.hasFinished = true;\n }\n\n const cacheReadTokens = getDeepSeekCacheReadTokens(usage);\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage: {\n inputTokens: usage?.prompt_tokens ?? undefined,\n outputTokens: usage?.completion_tokens ?? undefined,\n totalTokens: usage?.total_tokens ?? undefined,\n reasoningTokens:\n usage?.completion_tokens_details?.reasoning_tokens ??\n undefined,\n cachedInputTokens: cacheReadTokens,\n },\n providerMetadata: {\n [providerOptionsName]: {\n promptCacheHitTokens: cacheReadTokens ?? null,\n promptCacheMissTokens:\n usage?.prompt_cache_miss_tokens ?? null,\n ...(responseObject != null && { responseObject }),\n ...(choiceIndex != null && { choiceIndex }),\n ...(messageRole != null && { messageRole }),\n ...(toolCallTypes.size > 0 && {\n toolCallTypes: [...toolCallTypes.entries()]\n .sort(([left], [right]) => left - right)\n .map(([, type]) => type),\n }),\n ...((contentLogprobs.length > 0 ||\n reasoningLogprobs.length > 0) && {\n logprobs: {\n ...(contentLogprobs.length > 0 && {\n content: contentLogprobs,\n }),\n ...(reasoningLogprobs.length > 0 && {\n reasoning_content: reasoningLogprobs,\n }),\n },\n }),\n ...(systemFingerprint != null && { systemFingerprint }),\n },\n },\n });\n },\n }),\n ),\n request: { body },\n response: { headers: responseHeaders },\n };\n }\n}\n","import {\n InvalidPromptError,\n UnsupportedFunctionalityError,\n type LanguageModelV2CallOptions,\n type LanguageModelV2CallWarning,\n type LanguageModelV2Prompt,\n} from '@ai-sdk/provider';\nimport {\n stringifyWithBigIntAndCycles,\n secureJsonParse,\n convertToBase64,\n parseProviderOptions,\n} from '@ai-sdk/provider-utils';\nimport type {\n DeepSeekChatPrompt,\n DeepSeekContentPart,\n} from './deepseek-chat-api-types';\nimport { deepseekAssistantMessageProviderOptions } from './deepseek-chat-options';\nimport { deepseekFilePartProviderOptions } from './deepseek-file-part-options';\nimport { isDeepSeekV4Model } from './is-deepseek-v4-model';\n\nconst supportedImageMediaTypes = new Set([\n 'image/gif',\n 'image/jpeg',\n 'image/jpg',\n 'image/png',\n 'image/webp',\n]);\n\nfunction serializeDeepSeekToolCallArguments(input: unknown): string {\n if (typeof input === 'string') {\n try {\n secureJsonParse(input);\n return input;\n } catch {\n return JSON.stringify(input);\n }\n }\n return stringifyWithBigIntAndCycles(input);\n}\n\nexport async function convertToDeepSeekChatMessages({\n prompt,\n responseFormat,\n modelId,\n providerOptionsName = 'deepseek',\n supportsAssistantPrefixCompletion = false,\n supportsStructuredOutputs = false,\n}: {\n prompt: LanguageModelV2Prompt;\n responseFormat: LanguageModelV2CallOptions['responseFormat'];\n modelId: string;\n providerOptionsName?: string;\n supportsAssistantPrefixCompletion?: boolean;\n supportsStructuredOutputs?: boolean;\n}): Promise<{\n messages: DeepSeekChatPrompt;\n warnings: Array<LanguageModelV2CallWarning>;\n}> {\n const isDeepSeekV4 = isDeepSeekV4Model(modelId);\n const messages: DeepSeekChatPrompt = [];\n const warnings: Array<LanguageModelV2CallWarning> = [];\n\n // Inject system message if response format is JSON\n if (responseFormat?.type === 'json') {\n if (responseFormat.schema == null) {\n messages.push({\n role: 'system',\n content: 'Return JSON.',\n });\n } else if (!supportsStructuredOutputs) {\n messages.push({\n role: 'system',\n content:\n 'Return JSON that conforms to the following schema: ' +\n JSON.stringify(responseFormat.schema),\n });\n }\n }\n\n // TODO use findLastIndex once we use ES2023\n let lastUserMessageIndex = -1;\n for (let i = prompt.length - 1; i >= 0; i--) {\n if (prompt[i].role === 'user') {\n lastUserMessageIndex = i;\n break;\n }\n }\n\n let index = -1;\n for (const { role, content, providerOptions } of prompt) {\n index++;\n\n // The assistant schema extends the common message schema, so one parse\n // validates names for every role and the assistant-only prefix option.\n const deepseekMessageOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions,\n schema: deepseekAssistantMessageProviderOptions,\n });\n\n if (deepseekMessageOptions?.prefix === true && role !== 'assistant') {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek assistant prefix completion requires `prefix: true` on an assistant message.',\n });\n }\n\n switch (role) {\n case 'system': {\n messages.push({\n role: 'system',\n content,\n ...(deepseekMessageOptions?.name != null && {\n name: deepseekMessageOptions.name,\n }),\n });\n break;\n }\n\n case 'user': {\n const hasImagePart = content.some(\n part =>\n part.type === 'file' &&\n (part.mediaType === 'image' || part.mediaType.startsWith('image/')),\n );\n\n if (!hasImagePart) {\n let userContent = '';\n for (const part of content) {\n if (part.type === 'text') {\n userContent += part.text;\n } else {\n warnings.push({\n type: 'other',\n message: `Unsupported user message part type: ${part.type}`,\n });\n }\n }\n\n messages.push({\n role: 'user',\n content: userContent,\n ...(deepseekMessageOptions?.name != null && {\n name: deepseekMessageOptions.name,\n }),\n });\n break;\n }\n\n const userContent: Array<DeepSeekContentPart> = [];\n for (const part of content) {\n if (part.type === 'text') {\n userContent.push({ type: 'text', text: part.text });\n } else if (\n part.type === 'file' &&\n (part.mediaType === 'image' || part.mediaType.startsWith('image/'))\n ) {\n const filePartOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions: part.providerOptions,\n schema: deepseekFilePartProviderOptions,\n });\n\n const resolvedMediaType =\n part.mediaType === 'image' || part.mediaType === 'image/*'\n ? 'image/jpeg'\n : part.mediaType;\n\n if (!supportedImageMediaTypes.has(resolvedMediaType)) {\n throw new UnsupportedFunctionalityError({\n functionality: `DeepSeek image media type ${resolvedMediaType}`,\n message:\n 'DeepSeek supports JPEG, PNG, GIF, and WebP image inputs.',\n });\n }\n\n if (part.data instanceof URL) {\n const url = part.data.toString();\n\n if (url.length > 8192) {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek image URLs must not exceed 8192 characters.',\n });\n }\n\n if (filePartOptions?.fileData === true) {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek `fileData` image parts require inline data, not a URL.',\n });\n }\n\n userContent.push({\n type: 'image_url',\n image_url: {\n url,\n ...(filePartOptions?.imageDetail != null && {\n detail: filePartOptions.imageDetail,\n }),\n },\n });\n } else {\n const dataUrl = `data:${\n resolvedMediaType === 'image/jpg'\n ? 'image/jpeg'\n : resolvedMediaType\n };base64,${convertToBase64(part.data)}`;\n\n if (filePartOptions?.fileData === true) {\n if (filePartOptions.imageDetail != null) {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek `imageDetail` cannot be combined with `fileData`.',\n });\n }\n\n userContent.push({\n type: 'file',\n file_data: dataUrl,\n ...(part.filename != null && { filename: part.filename }),\n });\n } else {\n userContent.push({\n type: 'image_url',\n image_url: {\n url: dataUrl,\n ...(filePartOptions?.imageDetail != null && {\n detail: filePartOptions.imageDetail,\n }),\n },\n });\n }\n }\n } else {\n warnings.push({\n type: 'other',\n message: `Unsupported user message part type: ${part.type}`,\n });\n }\n }\n\n messages.push({\n role: 'user',\n content: userContent,\n ...(deepseekMessageOptions?.name != null && {\n name: deepseekMessageOptions.name,\n }),\n });\n\n break;\n }\n case 'assistant': {\n if (deepseekMessageOptions?.prefix === true) {\n if (index !== prompt.length - 1) {\n throw new InvalidPromptError({\n prompt,\n message:\n 'DeepSeek assistant prefix completion requires the prefixed assistant message to be the final message.',\n });\n }\n\n if (!supportsAssistantPrefixCompletion) {\n throw new UnsupportedFunctionalityError({\n functionality: 'DeepSeek assistant prefix completion',\n message:\n 'DeepSeek assistant prefix completion requires a beta base URL ending in `/beta`.',\n });\n }\n }\n\n let text = '';\n let reasoning: string | undefined;\n\n const toolCalls: Array<{\n id: string;\n type: 'function';\n function: { name: string; arguments: string };\n }> = [];\n\n for (const part of content) {\n switch (part.type) {\n case 'text': {\n text += part.text;\n break;\n }\n case 'reasoning': {\n // R1 must not receive prior reasoning; V4 requires it.\n if (index <= lastUserMessageIndex && !isDeepSeekV4) {\n break;\n }\n\n if (reasoning == null) {\n reasoning = part.text;\n } else {\n reasoning += part.text;\n }\n break;\n }\n case 'tool-call': {\n toolCalls.push({\n id: part.toolCallId,\n type: 'function',\n function: {\n name: part.toolName,\n arguments: serializeDeepSeekToolCallArguments(part.input),\n },\n });\n break;\n }\n }\n }\n\n // V4 demands the field on every assistant turn — back-fill an empty\n // string when the source message had no reasoning part at all.\n messages.push({\n role: 'assistant',\n content: text,\n ...(deepseekMessageOptions?.name != null && {\n name: deepseekMessageOptions.name,\n }),\n ...(deepseekMessageOptions?.prefix === true && {\n prefix: true,\n }),\n reasoning_content: reasoning ?? (isDeepSeekV4 ? '' : undefined),\n tool_calls: toolCalls.length > 0 ? toolCalls : undefined,\n });\n\n break;\n }\n\n case 'tool': {\n if (deepseekMessageOptions?.name != null) {\n warnings.push({\n type: 'other',\n message:\n 'DeepSeek does not support message names on tool messages. The name has been omitted.',\n });\n }\n\n for (const toolResponse of content) {\n const output = toolResponse.output;\n\n let contentValue: string;\n switch (output.type) {\n case 'text':\n case 'error-text':\n contentValue = output.value;\n break;\n case 'content':\n case 'json':\n case 'error-json':\n contentValue = stringifyWithBigIntAndCycles(output.value);\n break;\n }\n\n messages.push({\n role: 'tool',\n tool_call_id: toolResponse.toolCallId,\n content: contentValue,\n });\n }\n break;\n }\n\n default: {\n warnings.push({\n type: 'other',\n message: `Unsupported message role: ${role}`,\n });\n break;\n }\n }\n }\n\n return { messages, warnings };\n}\n","import {\n type InferSchema,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://api-docs.deepseek.com/quick_start/pricing\nexport type DeepSeekChatModelId =\n | 'deepseek-flash'\n | 'deepseek-v4-flash'\n | 'deepseek-v4-pro'\n | 'deepseek-v4-flash-vision-exp'\n // Retired aliases remain assignable through the string escape hatch, but are\n // intentionally omitted from first-class editor suggestions.\n | (string & {});\n\nfunction createDeepseekChatOptionsSchema() {\n return z.object({\n /**\n * Whether to return log probabilities for generated tokens.\n */\n logprobs: z.boolean().optional(),\n\n /**\n * Number of most likely tokens to return at each token position.\n *\n * Setting this option automatically enables `logprobs`.\n */\n topLogprobs: z.number().int().min(0).max(20).optional(),\n\n /**\n * An opaque identifier for the end user. DeepSeek uses this identifier for\n * content-safety tracing and request isolation.\n *\n * Must contain only ASCII letters, numbers, underscores, and hyphens, and\n * must be at most 512 characters long.\n */\n userId: z\n .string()\n .regex(/^[a-zA-Z0-9_-]+$/, 'userId must match /^[a-zA-Z0-9_-]+$/')\n .max(512, 'userId must be at most 512 characters long')\n .optional(),\n\n /**\n * Type of thinking to use. Defaults to `enabled`.\n */\n thinking: z\n .object({\n // `adaptive` is accepted at runtime for backwards compatibility and\n // mapped to `enabled`, but is intentionally excluded from the exported\n // provider options type.\n type: z.enum(['adaptive', 'enabled', 'disabled']).optional(),\n })\n .optional(),\n\n /**\n * Controls the thinking strength for DeepSeek V4 reasoning models.\n */\n // `medium` and `xhigh` are accepted at runtime for backwards compatibility\n // and mapped to canonical DeepSeek values, but are intentionally excluded\n // from the exported provider options type.\n reasoningEffort: z\n .enum(['low', 'medium', 'high', 'xhigh', 'max'])\n .optional(),\n\n /**\n * Whether to use strict JSON schema validation for structured outputs.\n * Only applies when the serving endpoint supports JSON schema response\n * formats (e.g. Azure). Defaults to `true`.\n */\n strictJsonSchema: z.boolean().optional(),\n });\n}\n\nlet chatOptionsSchema:\n | ReturnType<typeof createDeepseekChatOptionsSchema>\n | undefined;\n\nexport function getDeepseekChatOptionsSchema() {\n return (chatOptionsSchema ??= createDeepseekChatOptionsSchema());\n}\n\nexport const deepseekChatOptions = lazySchema(() =>\n zodSchema(getDeepseekChatOptionsSchema()),\n);\n\nexport type DeepSeekChatOptions = {\n /**\n * Whether to return log probabilities for generated tokens.\n */\n logprobs?: boolean;\n\n /**\n * Number of most likely tokens to return at each token position.\n *\n * Setting this option automatically enables `logprobs`.\n */\n topLogprobs?: number;\n\n /**\n * An opaque identifier for the end user. DeepSeek uses this identifier for\n * content-safety tracing and request isolation.\n *\n * Must contain only ASCII letters, numbers, underscores, and hyphens, and\n * must be at most 512 characters long.\n */\n userId?: string;\n\n /**\n * Controls whether thinking mode is enabled. Defaults to `enabled`.\n */\n thinking?: {\n type?: 'enabled' | 'disabled';\n };\n\n /**\n * Controls the thinking strength for DeepSeek V4 reasoning models.\n */\n reasoningEffort?: 'low' | 'high' | 'max';\n\n /**\n * Whether to use strict JSON schema validation for structured outputs.\n * Only applies when the serving endpoint supports JSON schema response\n * formats (e.g. Azure). Defaults to `true`.\n */\n strictJsonSchema?: boolean;\n};\n\nfunction createDeepseekMessageOptionsSchema() {\n return z.object({\n /**\n * The name of the participant represented by the message.\n *\n * Supported on system, user, and assistant messages.\n */\n name: z.string().optional(),\n });\n}\n\nlet messageOptionsSchema:\n | ReturnType<typeof createDeepseekMessageOptionsSchema>\n | undefined;\n\nexport function getDeepseekMessageOptionsSchema() {\n return (messageOptionsSchema ??= createDeepseekMessageOptionsSchema());\n}\n\nexport const deepseekMessageProviderOptions = lazySchema(() =>\n zodSchema(getDeepseekMessageOptionsSchema()),\n);\n\nexport type DeepSeekMessageProviderOptions = InferSchema<\n typeof deepseekMessageProviderOptions\n>;\n\nfunction createDeepseekAssistantMessageOptionsSchema() {\n return getDeepseekMessageOptionsSchema().extend({\n /**\n * Whether the assistant message content is a prefix that DeepSeek should\n * continue. This beta feature is only supported on the final assistant\n * message when using a beta base URL.\n */\n prefix: z.literal(true).optional(),\n });\n}\n\nlet assistantMessageOptionsSchema:\n | ReturnType<typeof createDeepseekAssistantMessageOptionsSchema>\n | undefined;\n\nexport function getDeepseekAssistantMessageOptionsSchema() {\n return (assistantMessageOptionsSchema ??=\n createDeepseekAssistantMessageOptionsSchema());\n}\n\nexport const deepseekAssistantMessageProviderOptions = lazySchema(() =>\n zodSchema(getDeepseekAssistantMessageOptionsSchema()),\n);\n\nexport type DeepSeekAssistantMessageProviderOptions = InferSchema<\n typeof deepseekAssistantMessageProviderOptions\n>;\n","import {\n type InferSchema,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const deepseekFilePartProviderOptions = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * Controls how DeepSeek processes an image sent as an `image_url` part.\n *\n * @see https://api-docs.deepseek.com/api/create-chat-completion/\n */\n imageDetail: z.enum(['low', 'high', 'original', 'auto']).optional(),\n\n /**\n * Sends inline image data as a DeepSeek `file` part using `file_data`\n * instead of an `image_url` data URL. When set, the file part's filename\n * is preserved.\n *\n * This option only applies to inline image data. It cannot be combined\n * with `imageDetail`.\n */\n fileData: z.literal(true).optional(),\n }),\n ),\n);\n\nexport type DeepSeekFilePartProviderOptions = InferSchema<\n typeof deepseekFilePartProviderOptions\n>;\n","/**\n * Whether a model id uses DeepSeek V4-or-newer behavior (thinking mode on by\n * default, `reasoning_content` required on every assistant turn).\n *\n * DeepSeek publishes V4 models under both versioned ids (`deepseek-v4-pro`,\n * `deepseek-v4-flash-*`) and unversioned aliases (`deepseek-flash`, currently\n * serving V4.1 Flash). Known legacy aliases and pre-V4 version IDs retain\n * their previous behavior; unrecognized IDs inherit the current protocol.\n */\nexport function isDeepSeekV4Model(modelId: string): boolean {\n return !/(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\\.\\d+)?)(?=[-/:.]|$)/.test(\n modelId,\n );\n}\n","import {\n type InferSchema,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport type DeepSeekChatPrompt = Array<DeepSeekMessage>;\n\nexport type DeepSeekMessage =\n | DeepSeekSystemMessage\n | DeepSeekUserMessage\n | DeepSeekAssistantMessage\n | DeepSeekToolMessage;\n\nexport interface DeepSeekSystemMessage {\n role: 'system';\n content: string;\n name?: string;\n}\n\nexport interface DeepSeekUserMessage {\n role: 'user';\n content: string | Array<DeepSeekContentPart>;\n name?: string;\n}\n\nexport type DeepSeekContentPart =\n | DeepSeekContentPartText\n | DeepSeekContentPartImage\n | DeepSeekContentPartFile;\n\nexport interface DeepSeekContentPartText {\n type: 'text';\n text: string;\n}\n\nexport interface DeepSeekContentPartImage {\n type: 'image_url';\n image_url: {\n url: string;\n detail?: 'low' | 'high' | 'original' | 'auto';\n };\n}\n\nexport interface DeepSeekContentPartFile {\n type: 'file';\n file_data: string;\n filename?: string;\n}\nexport interface DeepSeekAssistantMessage {\n role: 'assistant';\n content?: string | null;\n name?: string;\n prefix?: true;\n reasoning_content?: string;\n tool_calls?: Array<DeepSeekMessageToolCall>;\n}\n\nexport interface DeepSeekMessageToolCall {\n type: 'function';\n id: string;\n function: {\n arguments: string;\n name: string;\n };\n}\n\nexport interface DeepSeekToolMessage {\n role: 'tool';\n content: string;\n tool_call_id: string;\n}\n\nfunction createTokenUsageSchema() {\n return z\n .object({\n prompt_tokens: z.number().nullish(),\n completion_tokens: z.number().nullish(),\n prompt_cache_hit_tokens: z.number().nullish(),\n prompt_cache_miss_tokens: z.number().nullish(),\n total_tokens: z.number().nullish(),\n prompt_tokens_details: z\n .object({\n cached_tokens: z.number().nullish(),\n })\n .nullish(),\n completion_tokens_details: z\n .object({\n reasoning_tokens: z.number().nullish(),\n })\n .nullish(),\n })\n .nullish();\n}\n\nlet tokenUsageSchema: ReturnType<typeof createTokenUsageSchema> | undefined;\n\nfunction getTokenUsageSchema() {\n return (tokenUsageSchema ??= createTokenUsageSchema());\n}\n\nexport type DeepSeekChatTokenUsage = z.infer<\n ReturnType<typeof getTokenUsageSchema>\n>;\n\nfunction createDeepSeekErrorSchema() {\n return z.object({\n error: z.object({\n message: z.string(),\n type: z.string().nullish(),\n param: z.any().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n }),\n });\n}\n\nlet errorSchema: ReturnType<typeof createDeepSeekErrorSchema> | undefined;\n\nfunction getDeepSeekErrorSchema() {\n return (errorSchema ??= createDeepSeekErrorSchema());\n}\n\nexport const deepSeekErrorSchema = lazySchema(() =>\n zodSchema(getDeepSeekErrorSchema()),\n);\n\nexport type DeepSeekErrorData = InferSchema<typeof deepSeekErrorSchema>;\n\nfunction createDeepseekChatLogprobsSchema() {\n const deepseekChatLogprobSchema = z.object({\n token: z.string(),\n logprob: z.number(),\n bytes: z.array(z.number()).nullable(),\n top_logprobs: z.array(\n z.object({\n token: z.string(),\n logprob: z.number(),\n bytes: z.array(z.number()).nullable(),\n }),\n ),\n });\n\n return z\n .object({\n content: z.array(deepseekChatLogprobSchema).nullish(),\n reasoning_content: z.array(deepseekChatLogprobSchema).nullish(),\n })\n .nullish();\n}\n\nlet logprobsSchema:\n | ReturnType<typeof createDeepseekChatLogprobsSchema>\n | undefined;\n\nfunction getDeepseekChatLogprobsSchema() {\n return (logprobsSchema ??= createDeepseekChatLogprobsSchema());\n}\n\nexport type DeepSeekChatLogprob = NonNullable<\n NonNullable<\n z.infer<ReturnType<typeof getDeepseekChatLogprobsSchema>>\n >['content']\n>[number];\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nexport const deepseekChatResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string().nullish(),\n created: z.number().nullish(),\n model: z.string().nullish(),\n object: z.literal('chat.completion').nullish(),\n system_fingerprint: z.string().nullish(),\n choices: z.array(\n z.object({\n index: z.number().nullish(),\n message: z.object({\n role: z.literal('assistant').nullish(),\n content: z.string().nullish(),\n reasoning_content: z.string().nullish(),\n tool_calls: z\n .array(\n z.object({\n id: z.string().nullish(),\n type: z.literal('function').nullish(),\n function: z.object({\n name: z.string(),\n arguments: z.string(),\n }),\n }),\n )\n .nullish(),\n }),\n logprobs: getDeepseekChatLogprobsSchema(),\n finish_reason: z.string().nullish(),\n }),\n ),\n usage: getTokenUsageSchema(),\n }),\n ),\n);\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nexport const deepseekChatChunkSchema = lazySchema(() =>\n zodSchema(\n z.union([\n z.object({\n id: z.string().nullish(),\n created: z.number().nullish(),\n model: z.string().nullish(),\n object: z.literal('chat.completion.chunk').nullish(),\n system_fingerprint: z.string().nullish(),\n choices: z.array(\n z.object({\n index: z.number().nullish(),\n delta: z\n .object({\n role: z.enum(['assistant']).nullish(),\n content: z.string().nullish(),\n reasoning_content: z.string().nullish(),\n tool_calls: z\n .array(\n z.object({\n index: z.number(),\n id: z.string().nullish(),\n type: z.literal('function').nullish(),\n function: z.object({\n name: z.string().nullish(),\n arguments: z.string().nullish(),\n }),\n }),\n )\n .nullish(),\n })\n .nullish(),\n logprobs: getDeepseekChatLogprobsSchema(),\n finish_reason: z.string().nullish(),\n }),\n ),\n usage: getTokenUsageSchema(),\n }),\n getDeepSeekErrorSchema(),\n ]),\n ),\n);\n","import {\n type LanguageModelV2CallOptions,\n type LanguageModelV2CallWarning,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\n\nexport function prepareTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV2CallOptions['tools'];\n toolChoice?: LanguageModelV2CallOptions['toolChoice'];\n}): {\n tools:\n | undefined\n | Array<{\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n };\n }>;\n toolChoice:\n | { type: 'function'; function: { name: string } }\n | 'auto'\n | 'none'\n | 'required'\n | undefined;\n toolWarnings: LanguageModelV2CallWarning[];\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: LanguageModelV2CallWarning[] = [];\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const deepseekTools: Array<{\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n };\n }> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider-defined') {\n toolWarnings.push({\n type: 'unsupported-tool',\n tool,\n });\n } else {\n deepseekTools.push({\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n },\n });\n }\n }\n\n if (toolChoice == null) {\n return { tools: deepseekTools, toolChoice: undefined, toolWarnings };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n case 'none':\n case 'required':\n return { tools: deepseekTools, toolChoice: type, toolWarnings };\n case 'tool':\n return {\n tools: deepseekTools,\n toolChoice: {\n type: 'function',\n function: { name: toolChoice.toolName },\n },\n toolWarnings,\n };\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","export function getResponseMetadata({\n id,\n model,\n created,\n}: {\n id?: string | undefined | null;\n created?: number | undefined | null;\n model?: string | undefined | null;\n}) {\n return {\n id: id ?? undefined,\n modelId: model ?? undefined,\n timestamp: created != null ? new Date(created * 1000) : undefined,\n };\n}\n","import type { LanguageModelV2FinishReason } from '@ai-sdk/provider';\n\nexport function mapDeepSeekFinishReason(\n finishReason: string | null | undefined,\n): LanguageModelV2FinishReason {\n switch (finishReason) {\n case 'stop':\n return 'stop';\n case 'length':\n return 'length';\n case 'content_filter':\n return 'content-filter';\n case 'tool_calls':\n return 'tool-calls';\n case 'insufficient_system_resource':\n return 'error';\n default:\n return 'unknown';\n }\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAIO;AACP,IAAAC,yBAKO;;;ACVP,IAAAC,mBAQO;AACP,IAAAC,yBAYO;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C;AAAA,EACF;AACF;;;AS9sBO,IAAM,UACX,OACI,WACA;;;AVkDC,SAAS,eACd,UAAoC,CAAC,GACnB;AAzDpB;AA0DE,QAAM,WACJ,sDAAqB,QAAQ,OAAO,MAApC,YAAyC;AAE3C,QAAM,aAAa,UACjB;AAAA,IACE;AAAA,MACE,eAAe,cAAU,mCAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,mBAAmB,OAAO;AAAA,EAC5B;AAEF,QAAM,sBAAsB,CAAC,YAAiC;AAC5D,WAAO,IAAI,0BAA0B,SAAS;AAAA,MAC5C,UAAU;AAAA,MACV,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,MACpC,SAAS;AAAA,MACT,OAAO,QAAQ;AAAA,MACf,mCAAmC,QAAQ,SAAS,OAAO;AAAA,IAC7D,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,YAChB,oBAAoB,OAAO;AAE7B,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAEhB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,kCAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AACA,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,kCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":["import_provider","import_provider_utils","import_provider","import_provider_utils","import_provider_utils","import_provider_utils","import_v4","userContent","import_provider_utils","import_v4","import_provider","toolCall"]}
package/dist/index.mjs CHANGED
@@ -18,7 +18,6 @@ import {
18
18
  createJsonErrorResponseHandler,
19
19
  createJsonResponseHandler,
20
20
  generateId,
21
- isParsableJson,
22
21
  parseProviderOptions as parseProviderOptions2,
23
22
  postJsonToApi
24
23
  } from "@ai-sdk/provider-utils";
@@ -958,7 +957,7 @@ var DeepSeekChatLanguageModel = class {
958
957
  controller.enqueue({ type: "stream-start", warnings });
959
958
  },
960
959
  transform(chunk, controller) {
961
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
960
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
962
961
  if (options.includeRawChunks) {
963
962
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
964
963
  }
@@ -1091,19 +1090,6 @@ var DeepSeekChatLanguageModel = class {
1091
1090
  delta: toolCall2.function.arguments
1092
1091
  });
1093
1092
  }
1094
- if (isParsableJson(toolCall2.function.arguments)) {
1095
- controller.enqueue({
1096
- type: "tool-input-end",
1097
- id: toolCall2.id
1098
- });
1099
- controller.enqueue({
1100
- type: "tool-call",
1101
- toolCallId: (_g = toolCall2.id) != null ? _g : generateId(),
1102
- toolName: toolCall2.function.name,
1103
- input: toolCall2.function.arguments
1104
- });
1105
- toolCall2.hasFinished = true;
1106
- }
1107
1093
  }
1108
1094
  continue;
1109
1095
  }
@@ -1111,27 +1097,14 @@ var DeepSeekChatLanguageModel = class {
1111
1097
  if (toolCall.hasFinished) {
1112
1098
  continue;
1113
1099
  }
1114
- if (((_h = toolCallDelta.function) == null ? void 0 : _h.arguments) != null) {
1115
- toolCall.function.arguments += (_j = (_i = toolCallDelta.function) == null ? void 0 : _i.arguments) != null ? _j : "";
1100
+ if (((_g = toolCallDelta.function) == null ? void 0 : _g.arguments) != null) {
1101
+ toolCall.function.arguments += (_i = (_h = toolCallDelta.function) == null ? void 0 : _h.arguments) != null ? _i : "";
1116
1102
  }
1117
1103
  controller.enqueue({
1118
1104
  type: "tool-input-delta",
1119
1105
  id: toolCall.id,
1120
- delta: (_k = toolCallDelta.function.arguments) != null ? _k : ""
1106
+ delta: (_j = toolCallDelta.function.arguments) != null ? _j : ""
1121
1107
  });
1122
- if (((_l = toolCall.function) == null ? void 0 : _l.name) != null && ((_m = toolCall.function) == null ? void 0 : _m.arguments) != null && isParsableJson(toolCall.function.arguments)) {
1123
- controller.enqueue({
1124
- type: "tool-input-end",
1125
- id: toolCall.id
1126
- });
1127
- controller.enqueue({
1128
- type: "tool-call",
1129
- toolCallId: (_n = toolCall.id) != null ? _n : generateId(),
1130
- toolName: toolCall.function.name,
1131
- input: toolCall.function.arguments
1132
- });
1133
- toolCall.hasFinished = true;
1134
- }
1135
1108
  }
1136
1109
  }
1137
1110
  },
@@ -1156,6 +1129,7 @@ var DeepSeekChatLanguageModel = class {
1156
1129
  toolName: toolCall.function.name,
1157
1130
  input: toolCall.function.arguments
1158
1131
  });
1132
+ toolCall.hasFinished = true;
1159
1133
  }
1160
1134
  const cacheReadTokens = getDeepSeekCacheReadTokens(usage);
1161
1135
  controller.enqueue({
@@ -1202,7 +1176,7 @@ var DeepSeekChatLanguageModel = class {
1202
1176
  };
1203
1177
 
1204
1178
  // src/version.ts
1205
- var VERSION = true ? "1.0.68" : "0.0.0-test";
1179
+ var VERSION = true ? "1.0.69" : "0.0.0-test";
1206
1180
 
1207
1181
  // src/deepseek-provider.ts
1208
1182
  function createDeepSeek(options = {}) {