@ai-sdk/deepseek 3.0.86 → 3.0.87
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 +6 -0
- package/dist/index.d.ts +28 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +27 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +17 -5
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat/deepseek-chat-language-model-options.ts +2 -8
- package/src/deepseek-model-catalog.ts +19 -7
- package/src/responses/deepseek-responses-language-model-options.ts +2 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["supportedImageMediaTypes"],"sources":["../src/chat/deepseek-file-part-options.ts","../src/chat/deepseek-chat-language-model-options.ts","../src/deepseek-model-catalog.ts","../src/chat/is-deepseek-v4-model.ts","../src/chat/convert-to-deepseek-chat-messages.ts","../src/chat/convert-to-deepseek-usage.ts","../src/chat/deepseek-chat-api-types.ts","../src/chat/deepseek-prepare-tools.ts","../src/chat/map-deepseek-finish-reason.ts","../src/chat/deepseek-chat-language-model.ts","../src/files/deepseek-files-api.ts","../src/files/deepseek-files-options.ts","../src/files/deepseek-files.ts","../src/responses/convert-to-deepseek-responses-input.ts","../src/responses/convert-deepseek-responses-usage.ts","../src/responses/deepseek-responses-api.ts","../src/responses/deepseek-responses-language-model-options.ts","../src/responses/deepseek-responses-prepare-tools.ts","../src/responses/map-deepseek-responses-finish-reason.ts","../src/responses/deepseek-responses-language-model.ts","../src/tool/web-search.ts","../src/tool/index.ts","../src/version.ts","../src/deepseek-provider.ts"],"sourcesContent":["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","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 deepseekLanguageModelChatOptions = lazySchema(() =>\n zodSchema(getDeepseekChatOptionsSchema()),\n);\n\nexport type DeepSeekLanguageModelChatOptions = {\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 type {\n ModelCapabilities,\n ModelCapability,\n ModelEntry,\n ProviderOptionDefinition,\n ProviderOptionDefinitions,\n} from '@ai-sdk/provider';\nimport type { DeepSeekLanguageModelChatOptions } from './chat/deepseek-chat-language-model-options';\n\nexport const deepseekProviderOptions = {\n language: {\n logprobs: { description: 'Return token log probabilities.' },\n topLogprobs: {\n description: 'Number of token log probabilities to return.',\n },\n userId: { description: 'End-user identifier for request isolation.' },\n thinking: { description: 'Enable or disable thinking.' },\n reasoningEffort: { description: 'Thinking strength for reasoning models.' },\n strictJsonSchema: {\n description: 'Use strict JSON schema validation on supporting endpoints.',\n },\n } satisfies Record<\n keyof DeepSeekLanguageModelChatOptions,\n ProviderOptionDefinition\n >,\n} as const satisfies ProviderOptionDefinitions;\n\nexport type DeepSeekEndpointOptions = {\n supportsAssistantPrefixCompletion?: boolean;\n supportsStrictToolCalls?: boolean;\n supportsPenaltySampling?: boolean;\n supportsThinking?: boolean;\n supportsStructuredOutputs?: boolean;\n};\n\ntype LanguageCapabilities = NonNullable<ModelCapabilities['language']> & {\n textGeneration: ModelCapability;\n tools: NonNullable<ModelCapabilities['language']>['tools'] & {\n strict: boolean | 'unknown';\n };\n reasoning: NonNullable<ModelCapabilities['language']>['reasoning'] & {\n configurable: boolean;\n enabledByDefault: boolean;\n assistantHistory: boolean;\n };\n sampling: NonNullable<ModelCapabilities['language']>['sampling'] & {\n penalties: boolean;\n topK: false;\n seed: false;\n };\n structuredOutput: { jsonSchema: boolean };\n endpoints: { assistantPrefixCompletion: boolean };\n};\n\nexport type DeepSeekLanguageModelEntry = ModelEntry & {\n capabilities: { language: LanguageCapabilities };\n providerOptions: {\n language: Record<keyof DeepSeekLanguageModelChatOptions, ModelCapability>;\n };\n};\n\n// Preserve the provider page's model set and its image-input exception.\nconst languageDefinitions: Record<string, boolean> = {\n 'deepseek-flash': false,\n 'deepseek-v4-flash': false,\n 'deepseek-v4-pro': false,\n 'deepseek-v4-flash-vision-exp': true,\n};\n\nfunction createLanguageModelEntry(\n modelId: string,\n image?: boolean,\n): DeepSeekLanguageModelEntry {\n // Legacy aliases and pre-V4 IDs retain their previous protocol. Unknown IDs\n // inherit the current protocol, including assistant reasoning history.\n const assistantHistory =\n !/(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\\.\\d+)?)(?=[-/:.]|$)/.test(\n modelId,\n );\n const support = image != null ? true : 'unknown';\n const language: LanguageCapabilities = {\n textGeneration: support,\n inputs: { image: image ?? 'unknown', audio: false },\n objectGeneration: support,\n tools: { usage: support, streaming: support, strict: 'unknown' },\n reasoning: {\n support,\n ...(image != null ? { efforts: ['low', 'high', 'max'] } : {}),\n configurable: true,\n enabledByDefault: modelId === 'deepseek-reasoner' || assistantHistory,\n assistantHistory,\n },\n sampling: {\n temperature: { condition: 'Only effective when thinking is disabled.' },\n topP: { condition: 'Only effective when thinking is disabled.' },\n logprobs: support,\n penalties: false,\n topK: false,\n seed: false,\n },\n structuredOutput: { jsonSchema: false },\n endpoints: { assistantPrefixCompletion: false },\n };\n return {\n capabilities: { language },\n providerOptions: {\n language: {\n logprobs: language.sampling.logprobs,\n topLogprobs: language.sampling.logprobs,\n userId: support,\n thinking: language.reasoning.support,\n reasoningEffort: language.reasoning.support,\n strictJsonSchema: {\n condition:\n 'Requires a serving endpoint with JSON schema response formatting.',\n },\n },\n },\n };\n}\n\nexport const deepseekModelCatalog: Readonly<\n Record<string, DeepSeekLanguageModelEntry>\n> = Object.fromEntries(\n Object.entries(languageDefinitions).map(([modelId, image]) => [\n modelId,\n createLanguageModelEntry(modelId, image),\n ]),\n);\n\nexport function getDeepSeekLanguageModelEntry(\n modelId: string,\n endpoint: DeepSeekEndpointOptions = {},\n): DeepSeekLanguageModelEntry {\n const entry = Object.prototype.hasOwnProperty.call(\n deepseekModelCatalog,\n modelId,\n )\n ? deepseekModelCatalog[modelId]\n : createLanguageModelEntry(modelId);\n const { language } = entry.capabilities;\n return {\n ...entry,\n capabilities: {\n language: {\n ...language,\n tools: {\n ...language.tools,\n strict: endpoint.supportsStrictToolCalls ?? 'unknown',\n },\n reasoning: {\n ...language.reasoning,\n configurable: endpoint.supportsThinking !== false,\n },\n sampling: {\n ...language.sampling,\n penalties: endpoint.supportsPenaltySampling === true,\n },\n structuredOutput: {\n jsonSchema: endpoint.supportsStructuredOutputs === true,\n },\n endpoints: {\n assistantPrefixCompletion:\n endpoint.supportsAssistantPrefixCompletion === true,\n },\n },\n },\n };\n}\n","import { getDeepSeekLanguageModelEntry } from '../deepseek-model-catalog';\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 getDeepSeekLanguageModelEntry(modelId).capabilities.language.reasoning\n .assistantHistory;\n}\n","import {\n InvalidPromptError,\n UnsupportedFunctionalityError,\n type LanguageModelV4CallOptions,\n type LanguageModelV4FilePart,\n type LanguageModelV4Prompt,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n secureJsonParse,\n stringifyWithBigIntAndCycles,\n convertToBase64,\n getTopLevelMediaType,\n parseProviderOptions,\n resolveFullMediaType,\n resolveProviderReference,\n} from '@ai-sdk/provider-utils';\nimport type {\n DeepSeekChatPrompt,\n DeepSeekContentPart,\n DeepSeekToolMessage,\n} from './deepseek-chat-api-types';\nimport { deepseekFilePartProviderOptions } from './deepseek-file-part-options';\nimport { deepseekAssistantMessageProviderOptions } from './deepseek-chat-language-model-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 resolveDeepSeekImageMediaType(part: LanguageModelV4FilePart): string {\n const resolvedMediaType = resolveFullMediaType({ part });\n\n if (!supportedImageMediaTypes.has(resolvedMediaType)) {\n throw new UnsupportedFunctionalityError({\n functionality: `DeepSeek image media type ${resolvedMediaType}`,\n message: 'DeepSeek supports JPEG, PNG, GIF, and WebP image inputs.',\n });\n }\n\n return resolvedMediaType;\n}\n\nfunction validateDeepSeekImageUrl({\n url,\n prompt,\n}: {\n url: string;\n prompt: LanguageModelV4Prompt;\n}): void {\n if (url.length > 8192) {\n throw new InvalidPromptError({\n prompt,\n message: 'DeepSeek image URLs must not exceed 8192 characters.',\n });\n }\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: LanguageModelV4Prompt;\n responseFormat: LanguageModelV4CallOptions['responseFormat'];\n modelId: string;\n providerOptionsName?: string;\n supportsAssistantPrefixCompletion?: boolean;\n supportsStructuredOutputs?: boolean;\n}): Promise<{\n messages: DeepSeekChatPrompt;\n warnings: Array<SharedV4Warning>;\n}> {\n const isDeepSeekV4 = isDeepSeekV4Model(modelId);\n const messages: DeepSeekChatPrompt = [];\n const warnings: Array<SharedV4Warning> = [];\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 warnings.push({\n type: 'compatibility',\n feature: 'responseFormat JSON schema',\n details: 'JSON response schema is injected into the system message.',\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.data.type === 'reference' ||\n part.data.type === 'url' ||\n part.data.type === 'data') &&\n getTopLevelMediaType(part.mediaType) === '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: 'unsupported',\n feature: `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 getTopLevelMediaType(part.mediaType) === 'image'\n ) {\n const filePartOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions: part.providerOptions,\n schema: deepseekFilePartProviderOptions,\n });\n\n if (part.data.type === 'reference') {\n userContent.push({\n type: 'file',\n file_id: resolveProviderReference({\n reference: part.data.reference,\n provider: 'deepseek',\n }),\n });\n } else if (part.data.type === 'url' || part.data.type === 'data') {\n const resolvedMediaType = resolveDeepSeekImageMediaType(part);\n\n if (part.data.type === 'url') {\n const url = part.data.url.toString();\n\n validateDeepSeekImageUrl({ url, prompt });\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.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: 'unsupported',\n feature: `user message part type: ${part.type}`,\n });\n }\n } else {\n warnings.push({\n type: 'unsupported',\n feature: `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: 'unsupported',\n feature: 'message name on tool messages',\n });\n }\n\n for (const toolResponse of content) {\n if (toolResponse.type === 'tool-approval-response') {\n continue;\n }\n const output = toolResponse.output;\n\n let contentValue: DeepSeekToolMessage['content'];\n switch (output.type) {\n case 'text':\n case 'error-text':\n contentValue = output.value;\n break;\n case 'execution-denied':\n contentValue = output.reason ?? 'Tool call execution denied.';\n break;\n case 'json':\n case 'error-json':\n contentValue = stringifyWithBigIntAndCycles(output.value);\n break;\n case 'content': {\n const hasImagePart = output.value.some(\n part =>\n part.type === 'file' &&\n (part.data.type === 'reference' ||\n part.data.type === 'url' ||\n part.data.type === 'data') &&\n getTopLevelMediaType(part.mediaType) === 'image',\n );\n\n if (!hasImagePart) {\n contentValue = stringifyWithBigIntAndCycles(output.value);\n break;\n }\n\n contentValue = [];\n for (const part of output.value) {\n if (part.type === 'text') {\n contentValue.push({ type: 'text', text: part.text });\n } else if (\n part.type === 'file' &&\n (part.data.type === 'reference' ||\n part.data.type === 'url' ||\n part.data.type === 'data') &&\n getTopLevelMediaType(part.mediaType) === 'image'\n ) {\n if (part.data.type === 'reference') {\n contentValue.push({\n type: 'file',\n file_id: resolveProviderReference({\n reference: part.data.reference,\n provider: 'deepseek',\n }),\n });\n continue;\n }\n\n const filePartOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions: part.providerOptions,\n schema: deepseekFilePartProviderOptions,\n });\n const resolvedMediaType = resolveDeepSeekImageMediaType(part);\n let url: string;\n\n if (part.data.type === 'url') {\n url = part.data.url.toString();\n validateDeepSeekImageUrl({ url, prompt });\n } else {\n url = `data:${\n resolvedMediaType === 'image/jpg'\n ? 'image/jpeg'\n : resolvedMediaType\n };base64,${convertToBase64(part.data.data)}`;\n }\n\n contentValue.push({\n type: 'image_url',\n image_url: {\n url,\n ...(filePartOptions?.imageDetail != null && {\n detail: filePartOptions.imageDetail,\n }),\n },\n });\n } else {\n warnings.push({\n type: 'unsupported',\n feature: `tool result content part type: ${part.type}`,\n });\n }\n }\n break;\n }\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: 'unsupported',\n feature: `message role: ${role}`,\n });\n break;\n }\n }\n }\n\n return { messages, warnings };\n}\n","import type { LanguageModelV4Usage } from '@ai-sdk/provider';\nimport { createNullLanguageModelUsage } from '@ai-sdk/provider-utils';\n\nexport function convertDeepSeekUsage(\n usage:\n | {\n prompt_tokens?: number | null | undefined;\n completion_tokens?: number | null | undefined;\n prompt_cache_hit_tokens?: number | null | undefined;\n prompt_tokens_details?:\n | {\n cached_tokens?: number | null | undefined;\n }\n | null\n | undefined;\n completion_tokens_details?:\n | {\n reasoning_tokens?: number | null | undefined;\n }\n | null\n | undefined;\n }\n | undefined\n | null,\n): LanguageModelV4Usage {\n if (usage == null) {\n return createNullLanguageModelUsage();\n }\n\n const promptTokens = usage.prompt_tokens ?? 0;\n const completionTokens = usage.completion_tokens ?? 0;\n const cacheReadTokens =\n usage.prompt_cache_hit_tokens ??\n usage.prompt_tokens_details?.cached_tokens ??\n 0;\n const reasoningTokens =\n usage.completion_tokens_details?.reasoning_tokens ?? 0;\n\n return {\n inputTokens: {\n total: promptTokens,\n noCache: promptTokens - cacheReadTokens,\n cacheRead: cacheReadTokens,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: completionTokens,\n text: Math.max(0, completionTokens - reasoningTokens),\n reasoning: reasoningTokens,\n },\n raw: usage,\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 type DeepSeekContentPartFile =\n | {\n type: 'file';\n file_id: string;\n }\n | {\n type: 'file';\n file_data: string;\n filename?: string;\n };\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 | Array<DeepSeekContentPart>;\n tool_call_id: string;\n}\n\nexport interface DeepSeekFunctionTool {\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n strict?: boolean;\n };\n}\n\nexport type DeepSeekToolChoice =\n | { type: 'function'; function: { name: string } }\n | 'auto'\n | 'none'\n | 'required'\n | undefined;\n\n// Loose, nested objects included: the parsed value is returned as `usage.raw`.\nfunction createTokenUsageSchema() {\n return z\n .looseObject({\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 .looseObject({\n cached_tokens: z.number().nullish(),\n })\n .nullish(),\n completion_tokens_details: z\n .looseObject({\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 UnsupportedFunctionalityError,\n type LanguageModelV4CallOptions,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport type {\n DeepSeekFunctionTool,\n DeepSeekToolChoice,\n} from './deepseek-chat-api-types';\n\nexport function prepareTools({\n tools,\n toolChoice,\n supportsStrictToolCalls,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n toolChoice?: LanguageModelV4CallOptions['toolChoice'];\n supportsStrictToolCalls?: boolean;\n}): {\n tools: undefined | Array<DeepSeekFunctionTool>;\n toolChoice: DeepSeekToolChoice;\n toolWarnings: SharedV4Warning[];\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: SharedV4Warning[] = [];\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const functionTools = tools.filter(tool => tool.type === 'function');\n const hasStrictTool = functionTools.some(tool => tool.strict === true);\n\n if (hasStrictTool && supportsStrictToolCalls === false) {\n throw new UnsupportedFunctionalityError({\n functionality: 'DeepSeek strict tool calls',\n message:\n 'DeepSeek strict tool calls require a beta base URL ending in `/beta`.',\n });\n }\n\n if (\n hasStrictTool &&\n supportsStrictToolCalls === true &&\n functionTools.some(tool => tool.strict !== true)\n ) {\n throw new UnsupportedFunctionalityError({\n functionality: 'mixed DeepSeek strict and non-strict tool calls',\n message:\n 'DeepSeek strict mode requires every function tool in the request to set `strict: true`.',\n });\n }\n\n const deepseekTools: Array<DeepSeekFunctionTool> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider') {\n toolWarnings.push({\n type: 'unsupported',\n feature: `provider-defined tool ${tool.id}`,\n });\n } else {\n deepseekTools.push({\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n ...(tool.strict != null ? { strict: tool.strict } : {}),\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 return {\n tools: deepseekTools,\n toolChoice: undefined,\n toolWarnings: [\n ...toolWarnings,\n {\n type: 'unsupported',\n feature: `tool choice type: ${type}`,\n },\n ],\n };\n }\n }\n}\n","import type { LanguageModelV4FinishReason } from '@ai-sdk/provider';\n\nexport function mapDeepSeekFinishReason(\n finishReason: string | null | undefined,\n): LanguageModelV4FinishReason['unified'] {\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 'other';\n }\n}\n","import {\n InvalidResponseDataError,\n type APICallError,\n type LanguageModelV4,\n type LanguageModelV4CallOptions,\n type LanguageModelV4Content,\n type LanguageModelV4FinishReason,\n type LanguageModelV4GenerateResult,\n type LanguageModelV4StreamPart,\n type LanguageModelV4StreamResult,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolve,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n createProviderStreamError,\n generateId,\n isCustomReasoning,\n mapReasoningToProviderEffort,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n StreamingToolCallTracker,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n type InferSchema,\n type ParseResult,\n type ResponseHandler,\n} from '@ai-sdk/provider-utils';\nimport { convertToDeepSeekChatMessages } from './convert-to-deepseek-chat-messages';\nimport { convertDeepSeekUsage } from './convert-to-deepseek-usage';\nimport {\n deepseekChatChunkSchema,\n deepseekChatResponseSchema,\n deepSeekErrorSchema,\n type DeepSeekChatLogprob,\n type DeepSeekChatTokenUsage,\n} from './deepseek-chat-api-types';\nimport {\n deepseekLanguageModelChatOptions,\n type DeepSeekChatModelId,\n} from './deepseek-chat-language-model-options';\nimport { prepareTools } from './deepseek-prepare-tools';\nimport { getResponseMetadata } from './get-response-metadata';\nimport { mapDeepSeekFinishReason } from './map-deepseek-finish-reason';\nimport { getDeepSeekLanguageModelEntry } from '../deepseek-model-catalog';\n\nexport type DeepSeekChatConfig = {\n provider: string;\n headers?: Resolvable<Record<string, string | undefined>>;\n url: (options: { modelId: string; path: string }) => string;\n fetch?: FetchFunction;\n supportsAssistantPrefixCompletion?: boolean;\n supportsStrictToolCalls?: boolean;\n supportsPenaltySampling?: boolean;\n supportsThinking?: boolean;\n supportsStructuredOutputs?: boolean;\n};\n\nfunction createDeepSeekStreamError(\n error: {\n message: string;\n type?: string | null;\n code?: string | number | null;\n },\n data: unknown,\n) {\n const metadata = getDeepSeekStreamErrorMetadata(error);\n\n return createProviderStreamError({\n message: error.message,\n type: error.type ?? undefined,\n code: error.code ?? undefined,\n ...metadata,\n data,\n });\n}\n\nfunction getDeepSeekStreamErrorMetadata(error: {\n type?: string | null;\n code?: string | number | null;\n}): {\n statusCode?: number;\n isRetryable?: boolean;\n} {\n if (\n error.code === 'insufficient_quota' ||\n error.type === 'insufficient_quota'\n ) {\n return { statusCode: 429, isRetryable: false };\n }\n\n const explicitStatusCode = getHttpStatusCode(error.code);\n if (explicitStatusCode != null) {\n return {\n statusCode: explicitStatusCode,\n isRetryable: isRetryableStatusCode(explicitStatusCode),\n };\n }\n\n for (const discriminator of [error.code, error.type]) {\n switch (discriminator) {\n case 'rate_limit_exceeded':\n case 'rate_limit_error':\n return { statusCode: 429, isRetryable: true };\n case 'server_error':\n case 'api_error':\n case 'internal_server_error':\n return { statusCode: 500, isRetryable: true };\n case 'overloaded_error':\n case 'service_unavailable':\n return { statusCode: 503, isRetryable: true };\n case 'timeout':\n case 'timeout_error':\n return { statusCode: 504, isRetryable: true };\n case 'authentication_error':\n case 'invalid_api_key':\n return { statusCode: 401, isRetryable: false };\n case 'permission_error':\n return { statusCode: 403, isRetryable: false };\n case 'not_found_error':\n case 'model_not_found':\n return { statusCode: 404, isRetryable: false };\n case 'bad_request':\n case 'context_length_exceeded':\n case 'invalid_request_error':\n return { statusCode: 400, isRetryable: false };\n }\n }\n\n return {};\n}\n\nfunction getHttpStatusCode(value: unknown): number | undefined {\n const statusCode =\n typeof value === 'string' && /^\\d{3}$/.test(value) ? Number(value) : value;\n\n return typeof statusCode === 'number' &&\n Number.isInteger(statusCode) &&\n statusCode >= 400 &&\n statusCode <= 599\n ? statusCode\n : undefined;\n}\n\nfunction isRetryableStatusCode(statusCode: number): boolean {\n return (\n statusCode === 408 ||\n statusCode === 409 ||\n statusCode === 429 ||\n statusCode >= 500\n );\n}\n\nfunction mapDeepSeekProviderReasoningEffort({\n reasoningEffort,\n warnings,\n}: {\n reasoningEffort: 'low' | 'medium' | 'high' | 'xhigh' | 'max';\n warnings: SharedV4Warning[];\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: 'compatibility',\n feature: 'reasoningEffort',\n details: `reasoningEffort \"${reasoningEffort}\" is not a canonical DeepSeek value. mapped to \"${mapped}\".`,\n });\n }\n\n return mapped;\n}\n\nexport class DeepSeekChatLanguageModel implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\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 static [WORKFLOW_SERIALIZE](model: DeepSeekChatLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: DeepSeekChatModelId;\n config: DeepSeekChatConfig;\n }) {\n return new DeepSeekChatLanguageModel(options.modelId, options.config);\n }\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 reasoning,\n providerOptions,\n stopSequences,\n responseFormat,\n seed,\n toolChoice,\n tools,\n }: LanguageModelV4CallOptions) {\n const deepseekOptions =\n (await parseProviderOptions({\n provider: this.providerOptionsName,\n providerOptions,\n schema: deepseekLanguageModelChatOptions,\n })) ?? {};\n\n const { language: capabilities } = getDeepSeekLanguageModelEntry(\n this.modelId,\n this.config,\n ).capabilities;\n const supportsStructuredOutputs = capabilities.structuredOutput.jsonSchema;\n const supportsPenaltySampling = capabilities.sampling.penalties;\n\n const { messages, warnings } = await convertToDeepSeekChatMessages({\n prompt,\n responseFormat,\n modelId: this.modelId,\n providerOptionsName: this.providerOptionsName,\n supportsAssistantPrefixCompletion:\n capabilities.endpoints.assistantPrefixCompletion,\n supportsStructuredOutputs,\n });\n const allWarnings: SharedV4Warning[] = [...warnings];\n\n if (topK != null) {\n allWarnings.push({ type: 'unsupported', feature: 'topK' });\n }\n\n if (seed != null) {\n allWarnings.push({ type: 'unsupported', feature: 'seed' });\n }\n\n if (!supportsPenaltySampling && frequencyPenalty != null) {\n allWarnings.push({\n type: 'deprecated',\n setting: 'frequencyPenalty',\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: 'deprecated',\n setting: 'presencePenalty',\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 supportsStrictToolCalls:\n capabilities.tools.strict === 'unknown'\n ? undefined\n : capabilities.tools.strict,\n });\n\n const thinkingType = deepseekOptions.thinking?.type;\n if (thinkingType === 'adaptive') {\n allWarnings.push({\n type: 'compatibility',\n feature: 'thinking.type',\n details:\n 'thinking.type \"adaptive\" is not a canonical DeepSeek value. mapped to \"enabled\".',\n });\n }\n\n const thinking = !capabilities.reasoning.configurable\n ? undefined\n : thinkingType != null\n ? { type: thinkingType === 'adaptive' ? 'enabled' : thinkingType }\n : isCustomReasoning(reasoning)\n ? { type: reasoning === 'none' ? 'disabled' : 'enabled' }\n : undefined;\n\n const isThinkingEnabled =\n capabilities.reasoning.configurable &&\n thinking?.type !== 'disabled' &&\n (thinking != null || capabilities.reasoning.enabledByDefault);\n\n if (isThinkingEnabled && temperature != null) {\n allWarnings.push({\n type: 'unsupported',\n feature: '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',\n feature: '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 : isCustomReasoning(reasoning) && reasoning !== 'none'\n ? mapReasoningToProviderEffort({\n reasoning,\n effortMap: { low: 'low', high: 'high', max: 'max' },\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, ...toolWarnings],\n };\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\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(\n await resolve(this.config.headers),\n options.headers,\n ),\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 if (choice == null) {\n throw new InvalidResponseDataError({\n data: rawResponse,\n message: 'Response did not contain any choices.',\n });\n }\n\n const content: Array<LanguageModelV4Content> = [];\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 return {\n content,\n finishReason: {\n unified: mapDeepSeekFinishReason(choice.finish_reason),\n raw: choice.finish_reason ?? undefined,\n },\n usage: convertDeepSeekUsage(responseBody.usage),\n providerMetadata: {\n [this.providerOptionsName]: {\n promptCacheHitTokens: responseBody.usage?.prompt_cache_hit_tokens,\n promptCacheMissTokens: responseBody.usage?.prompt_cache_miss_tokens,\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: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\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(\n await resolve(this.config.headers),\n options.headers,\n ),\n body,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n deepseekChatChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n let toolCallTracker: StreamingToolCallTracker;\n\n // A clean end without the provider's completion signal is interrupted.\n let finishReason: LanguageModelV4FinishReason = {\n unified: 'interrupted',\n raw: undefined,\n };\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 LanguageModelV4StreamPart\n >({\n start(controller) {\n toolCallTracker = new StreamingToolCallTracker(controller, {\n generateId,\n });\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 = { unified: 'error', raw: undefined };\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 = { unified: 'error', raw: undefined };\n controller.enqueue({\n type: 'error',\n error: createDeepSeekStreamError(value.error, value),\n });\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 = {\n unified: mapDeepSeekFinishReason(choice.finish_reason),\n raw: choice.finish_reason,\n };\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 toolCallTracker.processDelta(toolCallDelta);\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 toolCallTracker.flush();\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage: convertDeepSeekUsage(usage),\n providerMetadata: {\n [providerOptionsName]: {\n promptCacheHitTokens:\n usage?.prompt_cache_hit_tokens ?? undefined,\n promptCacheMissTokens:\n usage?.prompt_cache_miss_tokens ?? undefined,\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 { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const deepSeekFilesResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string(),\n // These fields are required by DeepSeek's OpenAPI schema, but they are\n // not needed to construct the provider reference. Keep them nullish so\n // uploads remain resilient to incomplete responses while validating any\n // returned values precisely enough to avoid misleading metadata.\n object: z.literal('file').nullish(),\n bytes: z.number().int().nonnegative().nullish(),\n created_at: z.number().int().nonnegative().nullish(),\n filename: z.string().nullish(),\n purpose: z.literal('user_data').nullish(),\n expires_at: z.number().int().nonnegative().nullish(),\n }),\n ),\n);\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const deepSeekFilesOptionsSchema = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * Number of seconds after creation before the file expires.\n * Must be between 1 hour and 30 days.\n */\n expiresAfter: z.number().int().min(3600).max(2592000).optional(),\n }),\n ),\n);\n\nexport type DeepSeekFilesOptions = InferSchema<\n typeof deepSeekFilesOptionsSchema\n>;\n","import {\n InvalidArgumentError,\n type FilesV4,\n type FilesV4UploadFileCallOptions,\n type FilesV4UploadFileResult,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolve,\n combineHeaders,\n convertInlineFileDataToUint8Array,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n detectMediaType,\n parseProviderOptions,\n postFormDataToApi,\n type FetchFunction,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { deepSeekErrorSchema } from '../chat/deepseek-chat-api-types';\nimport { deepSeekFilesResponseSchema } from './deepseek-files-api';\nimport {\n deepSeekFilesOptionsSchema,\n type DeepSeekFilesOptions,\n} from './deepseek-files-options';\n\ninterface DeepSeekFilesConfig {\n provider: string;\n baseURL: string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n}\n\nconst deepSeekFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: deepSeekErrorSchema,\n errorToMessage: (error: InferSchema<typeof deepSeekErrorSchema>) =>\n error.error.message,\n});\n\nconst MAX_FILE_SIZE_BYTES = 64 * 1024 * 1024;\nconst MAX_FILENAME_LENGTH = 512;\n\nconst supportedMediaTypes = new Set([\n 'image/gif',\n 'image/jpeg',\n 'image/jpg',\n 'image/png',\n 'image/webp',\n]);\n\nconst genericMediaTypes = new Set([\n '',\n 'application/binary',\n 'application/octet-stream',\n 'binary/octet-stream',\n 'image',\n 'image/*',\n]);\n\nconst supportedFilenameExtensions = new Set([\n 'gif',\n 'jpeg',\n 'jpg',\n 'png',\n 'webp',\n]);\n\nexport class DeepSeekFiles implements FilesV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(private readonly config: DeepSeekFilesConfig) {}\n\n async uploadFile({\n data,\n mediaType,\n filename,\n abortSignal,\n headers,\n providerOptions,\n }: FilesV4UploadFileCallOptions): Promise<FilesV4UploadFileResult> {\n const deepSeekOptions = (await parseProviderOptions({\n provider: 'deepseek',\n providerOptions,\n schema: deepSeekFilesOptionsSchema,\n })) as DeepSeekFilesOptions | undefined;\n\n const fileBytes = convertInlineFileDataToUint8Array(data);\n validateFileUpload({ fileBytes, mediaType, filename });\n\n const blob = new Blob([fileBytes as Uint8Array<ArrayBuffer>], {\n type: mediaType,\n });\n\n const formData = new FormData();\n if (filename != null) {\n formData.append('file', blob, filename);\n } else {\n formData.append('file', blob);\n }\n formData.append('purpose', 'user_data');\n\n if (deepSeekOptions?.expiresAfter != null) {\n formData.append('expires_after[anchor]', 'created_at');\n formData.append(\n 'expires_after[seconds]',\n String(deepSeekOptions.expiresAfter),\n );\n }\n\n const { value: response } = await postFormDataToApi({\n url: `${this.config.baseURL}/files`,\n headers: combineHeaders(await resolve(this.config.headers), headers),\n formData,\n failedResponseHandler: deepSeekFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepSeekFilesResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n warnings: [],\n providerReference: { deepseek: response.id },\n ...((response.filename ?? filename)\n ? { filename: response.filename ?? filename }\n : {}),\n ...(mediaType != null ? { mediaType } : {}),\n providerMetadata: {\n deepseek: {\n ...(response.object != null ? { object: response.object } : {}),\n ...(response.filename != null ? { filename: response.filename } : {}),\n ...(response.purpose != null ? { purpose: response.purpose } : {}),\n ...(response.bytes != null ? { bytes: response.bytes } : {}),\n ...(response.created_at != null\n ? { createdAt: response.created_at }\n : {}),\n ...(response.expires_at != null\n ? { expiresAt: response.expires_at }\n : {}),\n },\n },\n };\n }\n}\n\nfunction validateFileUpload({\n fileBytes,\n mediaType,\n filename,\n}: {\n fileBytes: Uint8Array;\n mediaType: string;\n filename: string | undefined;\n}) {\n if (fileBytes.length > MAX_FILE_SIZE_BYTES) {\n throw new InvalidArgumentError({\n argument: 'data',\n message:\n `DeepSeek file uploads must not exceed 64 MiB ` +\n `(${MAX_FILE_SIZE_BYTES.toLocaleString('en-US')} bytes). ` +\n `Received ${fileBytes.length.toLocaleString('en-US')} bytes.`,\n });\n }\n\n if (filename != null) {\n const filenameLength = Array.from(filename).length;\n\n if (filenameLength > MAX_FILENAME_LENGTH) {\n throw new InvalidArgumentError({\n argument: 'filename',\n message:\n `DeepSeek filenames must not exceed ${MAX_FILENAME_LENGTH} characters. ` +\n `Received ${filenameLength} characters.`,\n });\n }\n }\n\n const normalizedMediaType = normalizeMediaType(mediaType);\n const detectedMediaType = detectMediaType({ data: fileBytes });\n\n if (\n detectedMediaType != null &&\n !supportedMediaTypes.has(detectedMediaType)\n ) {\n throw new InvalidArgumentError({\n argument: 'data',\n message:\n `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +\n `Detected unsupported file content type \"${detectedMediaType}\".`,\n });\n }\n\n if (supportedMediaTypes.has(normalizedMediaType)) {\n return;\n }\n\n if (!genericMediaTypes.has(normalizedMediaType)) {\n throw new InvalidArgumentError({\n argument: 'mediaType',\n message:\n `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +\n `Received unsupported media type \"${mediaType}\".`,\n });\n }\n\n if (detectedMediaType != null || hasSupportedFilenameExtension(filename)) {\n return;\n }\n\n throw new InvalidArgumentError({\n argument: 'mediaType',\n message:\n `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +\n `Provide a supported media type or a filename ending in ` +\n `.jpg, .jpeg, .png, .gif, or .webp. Received \"${mediaType}\".`,\n });\n}\n\nfunction normalizeMediaType(mediaType: string): string {\n return mediaType.split(';', 1)[0].trim().toLowerCase();\n}\n\nfunction hasSupportedFilenameExtension(filename: string | undefined): boolean {\n if (filename == null) {\n return false;\n }\n\n const extensionSeparatorIndex = filename.lastIndexOf('.');\n\n return (\n extensionSeparatorIndex !== -1 &&\n supportedFilenameExtensions.has(\n filename.slice(extensionSeparatorIndex + 1).toLowerCase(),\n )\n );\n}\n","import {\n InvalidPromptError,\n UnsupportedFunctionalityError,\n type LanguageModelV4FilePart,\n type LanguageModelV4Prompt,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n convertToBase64,\n getTopLevelMediaType,\n parseProviderOptions,\n resolveFullMediaType,\n resolveProviderReference,\n} from '@ai-sdk/provider-utils';\nimport { deepseekFilePartProviderOptions } from '../chat/deepseek-file-part-options';\nimport type {\n DeepSeekResponsesInput,\n DeepSeekResponsesInputContentPart,\n} from './deepseek-responses-api';\n\nexport async function convertToDeepSeekResponsesInput({\n prompt,\n providerOptionsName,\n}: {\n prompt: LanguageModelV4Prompt;\n providerOptionsName: string;\n}): Promise<{\n input: DeepSeekResponsesInput;\n inputWarnings: SharedV4Warning[];\n}> {\n const input: DeepSeekResponsesInput = [];\n const inputWarnings: SharedV4Warning[] = [];\n\n for (const message of prompt) {\n switch (message.role) {\n case 'system': {\n input.push({ role: 'system', content: message.content });\n break;\n }\n\n case 'user': {\n const content: Array<DeepSeekResponsesInputContentPart> = [];\n\n for (const part of message.content) {\n if (part.type === 'text') {\n content.push({ type: 'input_text', text: part.text });\n } else if (\n part.type === 'file' &&\n getTopLevelMediaType(part.mediaType) === 'image' &&\n part.data.type !== 'text'\n ) {\n content.push(\n await convertImagePart({ part, prompt, providerOptionsName }),\n );\n } else {\n inputWarnings.push({\n type: 'unsupported',\n feature: `user message part type: ${part.type}`,\n });\n }\n }\n\n input.push({ role: 'user', content });\n break;\n }\n\n case 'assistant': {\n for (const part of message.content) {\n switch (part.type) {\n case 'text': {\n if (part.text.length > 0) {\n input.push({ role: 'assistant', content: part.text });\n }\n break;\n }\n\n case 'reasoning': {\n const itemId = getStringOption(\n part.providerOptions?.[providerOptionsName]?.itemId,\n );\n input.push({\n type: 'reasoning',\n ...(itemId != null && { id: itemId }),\n content: [{ type: 'reasoning_text', text: part.text }],\n });\n break;\n }\n\n case 'tool-call': {\n if (part.providerExecuted) {\n const webSearchCall =\n part.providerOptions?.[providerOptionsName]?.webSearchCall;\n if (isWebSearchCallItem(webSearchCall)) {\n input.push(webSearchCall);\n }\n break;\n }\n\n input.push({\n type: 'function_call',\n call_id: part.toolCallId,\n name: part.toolName,\n arguments:\n typeof part.input === 'string'\n ? part.input\n : JSON.stringify(part.input),\n });\n break;\n }\n\n case 'tool-result': {\n break;\n }\n\n default: {\n inputWarnings.push({\n type: 'unsupported',\n feature: `assistant message part type: ${part.type}`,\n });\n }\n }\n }\n break;\n }\n\n case 'tool': {\n for (const part of message.content) {\n if (part.type === 'tool-approval-response') {\n continue;\n }\n\n const output = part.output;\n let value: string | Array<DeepSeekResponsesInputContentPart>;\n\n switch (output.type) {\n case 'text':\n case 'error-text':\n value = output.value;\n break;\n case 'execution-denied':\n value = output.reason ?? 'Tool call execution denied.';\n break;\n case 'json':\n case 'error-json':\n value = JSON.stringify(output.value);\n break;\n case 'content': {\n value = [];\n for (const item of output.value) {\n if (item.type === 'text') {\n value.push({ type: 'input_text', text: item.text });\n } else if (\n item.type === 'file' &&\n getTopLevelMediaType(item.mediaType) === 'image' &&\n item.data.type !== 'text'\n ) {\n value.push(\n await convertImagePart({\n part: item,\n prompt,\n providerOptionsName,\n }),\n );\n } else {\n inputWarnings.push({\n type: 'unsupported',\n feature: `tool result content part type: ${item.type}`,\n });\n }\n }\n break;\n }\n }\n\n input.push({\n type: 'function_call_output',\n call_id: part.toolCallId,\n output: value,\n });\n }\n break;\n }\n }\n }\n\n return { input, inputWarnings };\n}\n\nconst supportedImageMediaTypes = new Set([\n 'image/gif',\n 'image/jpeg',\n 'image/jpg',\n 'image/png',\n 'image/webp',\n]);\n\nasync function convertImagePart({\n part,\n prompt,\n providerOptionsName,\n}: {\n part: LanguageModelV4FilePart;\n prompt: LanguageModelV4Prompt;\n providerOptionsName: string;\n}): Promise<DeepSeekResponsesInputContentPart> {\n if (part.data.type === 'reference') {\n return {\n type: 'input_image',\n file_id: resolveProviderReference({\n reference: part.data.reference,\n provider: 'deepseek',\n }),\n };\n }\n\n const filePartOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions: part.providerOptions,\n schema: deepseekFilePartProviderOptions,\n });\n\n if (filePartOptions?.fileData === true) {\n throw new UnsupportedFunctionalityError({\n functionality: 'DeepSeek `fileData` image parts with the Responses API',\n });\n }\n\n const detail = filePartOptions?.imageDetail;\n\n if (part.data.type === 'url') {\n const url = part.data.url.toString();\n if (url.length > 8192) {\n throw new InvalidPromptError({\n prompt,\n message: 'DeepSeek image URLs must not exceed 8192 characters.',\n });\n }\n return {\n type: 'input_image',\n image_url: url,\n ...(detail != null && { detail }),\n };\n }\n\n if (part.data.type !== 'data') {\n throw new UnsupportedFunctionalityError({\n functionality: `DeepSeek image data type ${part.data.type}`,\n });\n }\n\n const mediaType = resolveFullMediaType({ part });\n if (!supportedImageMediaTypes.has(mediaType)) {\n throw new UnsupportedFunctionalityError({\n functionality: `DeepSeek image media type ${mediaType}`,\n message: 'DeepSeek supports JPEG, PNG, GIF, and WebP image inputs.',\n });\n }\n\n return {\n type: 'input_image',\n image_url: `data:${mediaType === 'image/jpg' ? 'image/jpeg' : mediaType};base64,${convertToBase64(part.data.data)}`,\n ...(detail != null && { detail }),\n };\n}\n\nfunction getStringOption(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction isWebSearchCallItem(\n value: unknown,\n): value is { type: 'web_search_call' } & Record<string, unknown> {\n return (\n typeof value === 'object' &&\n value != null &&\n !Array.isArray(value) &&\n (value as { type?: unknown }).type === 'web_search_call'\n );\n}\n","import type { LanguageModelV4Usage } from '@ai-sdk/provider';\nimport { createNullLanguageModelUsage } from '@ai-sdk/provider-utils';\nimport type { DeepSeekResponsesUsage } from './deepseek-responses-api';\n\nexport function convertDeepSeekResponsesUsage(\n usage: DeepSeekResponsesUsage | null | undefined,\n): LanguageModelV4Usage {\n if (usage == null) {\n return createNullLanguageModelUsage();\n }\n\n const inputTokens = usage.input_tokens ?? 0;\n const outputTokens = usage.output_tokens ?? 0;\n const cacheReadTokens = usage.input_tokens_details?.cached_tokens ?? 0;\n const reasoningTokens = usage.output_tokens_details?.reasoning_tokens ?? 0;\n\n return {\n inputTokens: {\n total: inputTokens,\n noCache: inputTokens - cacheReadTokens,\n cacheRead: cacheReadTokens,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: outputTokens,\n text: Math.max(0, outputTokens - reasoningTokens),\n reasoning: reasoningTokens,\n },\n raw: usage,\n };\n}\n\nexport function getDeepSeekServerToolUse(\n usage: DeepSeekResponsesUsage | null | undefined,\n): { toolSearch: number; toolFetch: number } | undefined {\n const serverToolUse = usage?.server_tool_use;\n if (serverToolUse == null) {\n return undefined;\n }\n return {\n toolSearch: serverToolUse.tool_search ?? 0,\n toolFetch: serverToolUse.tool_fetch ?? 0,\n };\n}\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport type DeepSeekResponsesInput = Array<DeepSeekResponsesInputItem>;\n\nexport type DeepSeekResponsesInputItem =\n | { role: 'system' | 'assistant'; content: string }\n | { role: 'user'; content: Array<DeepSeekResponsesInputContentPart> }\n | {\n type: 'function_call';\n call_id: string;\n name: string;\n arguments: string;\n }\n | {\n type: 'function_call_output';\n call_id: string;\n output: string | Array<DeepSeekResponsesInputContentPart>;\n }\n | {\n type: 'reasoning';\n id?: string;\n content: Array<{ type: 'reasoning_text'; text: string }>;\n }\n | ({ type: 'web_search_call' } & Record<string, unknown>);\n\nexport type DeepSeekResponsesInputContentPart =\n | { type: 'input_text'; text: string }\n | {\n type: 'input_image';\n image_url?: string;\n file_id?: string;\n detail?: 'low' | 'high' | 'original' | 'auto';\n };\n\nexport type DeepSeekResponsesTool =\n | {\n type: 'function';\n name: string;\n description?: string;\n parameters: unknown;\n }\n | { type: 'web_search' };\n\nexport type DeepSeekResponsesToolChoice =\n | 'auto'\n | 'none'\n | 'required'\n | { type: 'function'; name: string };\n\nexport type DeepSeekResponsesUsage = z.infer<\n ReturnType<typeof createUsageSchema>\n>;\n\nexport type DeepSeekResponsesOutputItem = z.infer<\n ReturnType<typeof createOutputItemSchema>\n>;\n\nexport type DeepSeekResponsesChunk = z.infer<\n ReturnType<typeof createChunkSchema>\n>;\n\nexport const deepseekResponsesResponseSchema = lazySchema(() =>\n zodSchema(createResponseSchema()),\n);\n\nexport const deepseekResponsesChunkSchema = lazySchema(() =>\n zodSchema(createChunkSchema()),\n);\n\nfunction createUsageSchema() {\n return z.object({\n input_tokens: z.number().nullish(),\n input_tokens_details: z\n .object({ cached_tokens: z.number().nullish() })\n .nullish(),\n output_tokens: z.number().nullish(),\n output_tokens_details: z\n .object({ reasoning_tokens: z.number().nullish() })\n .nullish(),\n total_tokens: z.number().nullish(),\n server_tool_use: z\n .object({\n tool_search: z.number().nullish(),\n tool_fetch: z.number().nullish(),\n })\n .nullish(),\n });\n}\n\nfunction createLogprobSchema() {\n return z.object({\n token: z.string(),\n logprob: z.number(),\n bytes: z.array(z.number()).nullish(),\n top_logprobs: z\n .array(\n z.object({\n token: z.string(),\n logprob: z.number(),\n bytes: z.array(z.number()).nullish(),\n }),\n )\n .nullish(),\n });\n}\n\nfunction createOutputItemSchema() {\n return z.union([\n z.object({\n type: z.literal('message'),\n id: z.string().nullish(),\n content: z\n .array(\n z.object({\n type: z.string(),\n text: z.string().nullish(),\n logprobs: z.array(createLogprobSchema()).nullish(),\n }),\n )\n .nullish(),\n }),\n z.object({\n type: z.literal('reasoning'),\n id: z.string().nullish(),\n content: z\n .array(z.object({ type: z.string(), text: z.string().nullish() }))\n .nullish(),\n }),\n z.object({\n type: z.literal('function_call'),\n id: z.string().nullish(),\n call_id: z.string(),\n name: z.string(),\n arguments: z.string().nullish(),\n }),\n z.looseObject({\n type: z.literal('web_search_call'),\n id: z.string(),\n status: z.string().nullish(),\n action: z.record(z.string(), z.unknown()).nullish(),\n }),\n z.looseObject({ type: z.string() }),\n ]);\n}\n\nfunction createResponseObjectSchema() {\n return z.object({\n id: z.string().nullish(),\n created_at: z.number().nullish(),\n model: z.string().nullish(),\n status: z.string().nullish(),\n error: z\n .object({\n code: z.string().nullish(),\n message: z.string().nullish(),\n })\n .nullish(),\n incomplete_details: z.object({ reason: z.string().nullish() }).nullish(),\n output: z.array(createOutputItemSchema()).nullish(),\n usage: createUsageSchema().nullish(),\n });\n}\n\nfunction createResponseSchema() {\n return createResponseObjectSchema();\n}\n\nfunction createChunkSchema() {\n const responseObject = createResponseObjectSchema();\n const outputItem = createOutputItemSchema();\n\n return z.union([\n z.object({\n type: z.enum(['response.created', 'response.in_progress']),\n response: responseObject,\n }),\n z.object({\n type: z.enum([\n 'response.completed',\n 'response.incomplete',\n 'response.failed',\n ]),\n response: responseObject,\n }),\n z.object({\n type: z.enum(['response.output_item.added', 'response.output_item.done']),\n output_index: z.number().nullish(),\n item: outputItem,\n }),\n z.object({\n type: z.literal('response.output_text.delta'),\n item_id: z.string(),\n delta: z.string(),\n logprobs: z.array(createLogprobSchema()).nullish(),\n }),\n z.object({\n type: z.literal('response.reasoning_text.delta'),\n item_id: z.string(),\n delta: z.string(),\n }),\n z.object({\n type: z.literal('response.function_call_arguments.delta'),\n item_id: z.string(),\n delta: z.string(),\n }),\n z.object({\n type: z.literal('error'),\n code: z.string().nullish(),\n message: z.string().nullish(),\n }),\n z.looseObject({ type: z.string() }),\n ]);\n}\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://api-docs.deepseek.com/api/create-response\nexport type DeepSeekResponsesModelId =\n | 'deepseek-flash'\n | 'deepseek-v4-pro'\n | (string & {});\n\nexport const deepseekLanguageModelResponsesOptions = lazySchema(() =>\n zodSchema(\n z.object({\n thinking: z\n .object({ type: z.enum(['enabled', 'disabled']).optional() })\n .optional(),\n reasoningEffort: z.enum(['low', 'high', 'max']).optional(),\n topLogprobs: z.number().int().min(0).max(20).optional(),\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);\n\nexport type DeepSeekLanguageModelResponsesOptions = {\n /**\n * Controls whether thinking mode is enabled. Thinking is enabled by default.\n */\n thinking?: {\n type?: 'enabled' | 'disabled';\n };\n\n /**\n * Controls the thinking strength when thinking is enabled.\n */\n reasoningEffort?: 'low' | 'high' | 'max';\n\n /**\n * Number of most likely tokens to return at each token position (0 to 20).\n * Log probabilities are returned in `providerMetadata.deepseek.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","import type {\n LanguageModelV4CallOptions,\n SharedV4Warning,\n} from '@ai-sdk/provider';\nimport type {\n DeepSeekResponsesTool,\n DeepSeekResponsesToolChoice,\n} from './deepseek-responses-api';\n\nexport function prepareDeepSeekResponsesTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n toolChoice?: LanguageModelV4CallOptions['toolChoice'];\n}): {\n tools: Array<DeepSeekResponsesTool> | undefined;\n toolChoice: DeepSeekResponsesToolChoice | undefined;\n toolWarnings: SharedV4Warning[];\n} {\n const toolWarnings: SharedV4Warning[] = [];\n\n if (tools == null || tools.length === 0) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const deepseekTools: Array<DeepSeekResponsesTool> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider') {\n if (tool.id === 'deepseek.web_search') {\n deepseekTools.push({ type: 'web_search' });\n } else {\n toolWarnings.push({\n type: 'unsupported',\n feature: `provider-defined tool ${tool.id}`,\n });\n }\n continue;\n }\n\n if (tool.strict != null) {\n toolWarnings.push({\n type: 'unsupported',\n feature: 'strict tool calls',\n details: 'The DeepSeek Responses API does not support strict mode.',\n });\n }\n\n deepseekTools.push({\n type: 'function',\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n });\n }\n\n if (toolChoice == null) {\n return { tools: deepseekTools, toolChoice: undefined, toolWarnings };\n }\n\n switch (toolChoice.type) {\n case 'auto':\n case 'none':\n case 'required':\n return {\n tools: deepseekTools,\n toolChoice: toolChoice.type,\n toolWarnings,\n };\n case 'tool': {\n const selected = tools.find(tool => tool.name === toolChoice.toolName);\n if (selected?.type === 'provider') {\n toolWarnings.push({\n type: 'unsupported',\n feature: `toolChoice for provider-defined tool ${selected.id}`,\n });\n return { tools: deepseekTools, toolChoice: undefined, toolWarnings };\n }\n return {\n tools: deepseekTools,\n toolChoice: { type: 'function', name: toolChoice.toolName },\n toolWarnings,\n };\n }\n }\n}\n","import type { LanguageModelV4FinishReason } from '@ai-sdk/provider';\n\nexport function mapDeepSeekResponsesFinishReason({\n status,\n incompleteReason,\n hasFunctionCall,\n}: {\n status: string | null | undefined;\n incompleteReason: string | null | undefined;\n hasFunctionCall: boolean;\n}): LanguageModelV4FinishReason['unified'] {\n switch (status) {\n case 'completed':\n return hasFunctionCall ? 'tool-calls' : 'stop';\n case 'incomplete':\n return incompleteReason === 'max_output_tokens'\n ? 'length'\n : incompleteReason === 'content_filter'\n ? 'content-filter'\n : 'other';\n case 'failed':\n return 'error';\n default:\n return 'other';\n }\n}\n","import {\n APICallError,\n type JSONObject,\n type LanguageModelV4,\n type LanguageModelV4CallOptions,\n type LanguageModelV4Content,\n type LanguageModelV4FinishReason,\n type LanguageModelV4GenerateResult,\n type LanguageModelV4StreamPart,\n type LanguageModelV4StreamResult,\n type SharedV4ProviderMetadata,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolve,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n createLanguageModelResponseMetadata,\n createProviderStreamError,\n isCustomReasoning,\n mapReasoningToProviderEffort,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n type InferSchema,\n type ParseResult,\n type ResponseHandler,\n} from '@ai-sdk/provider-utils';\nimport { deepSeekErrorSchema } from '../chat/deepseek-chat-api-types';\nimport { convertToDeepSeekResponsesInput } from './convert-to-deepseek-responses-input';\nimport {\n convertDeepSeekResponsesUsage,\n getDeepSeekServerToolUse,\n} from './convert-deepseek-responses-usage';\nimport {\n deepseekResponsesChunkSchema,\n deepseekResponsesResponseSchema,\n type DeepSeekResponsesOutputItem,\n type DeepSeekResponsesUsage,\n} from './deepseek-responses-api';\nimport {\n deepseekLanguageModelResponsesOptions,\n type DeepSeekResponsesModelId,\n} from './deepseek-responses-language-model-options';\nimport { prepareDeepSeekResponsesTools } from './deepseek-responses-prepare-tools';\nimport { mapDeepSeekResponsesFinishReason } from './map-deepseek-responses-finish-reason';\n\nexport type DeepSeekResponsesConfig = {\n provider: string;\n headers?: Resolvable<Record<string, string | undefined>>;\n url: (options: { modelId: string; path: string }) => string;\n fetch?: FetchFunction;\n};\n\nexport class DeepSeekResponsesLanguageModel implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly modelId: DeepSeekResponsesModelId;\n\n readonly supportedUrls = {\n 'image/*': [/^https?:\\/\\/.*$/],\n };\n\n private readonly config: DeepSeekResponsesConfig;\n private readonly failedResponseHandler: ResponseHandler<APICallError>;\n\n static [WORKFLOW_SERIALIZE](model: DeepSeekResponsesLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: DeepSeekResponsesModelId;\n config: DeepSeekResponsesConfig;\n }) {\n return new DeepSeekResponsesLanguageModel(options.modelId, options.config);\n }\n\n constructor(\n modelId: DeepSeekResponsesModelId,\n config: DeepSeekResponsesConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\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 stopSequences,\n seed,\n responseFormat,\n providerOptions,\n tools,\n toolChoice,\n reasoning,\n }: LanguageModelV4CallOptions) {\n const warnings: SharedV4Warning[] = [];\n\n const deepseekOptions =\n (await parseProviderOptions({\n provider: this.providerOptionsName,\n providerOptions,\n schema: deepseekLanguageModelResponsesOptions,\n })) ?? {};\n\n if (topK != null) {\n warnings.push({ type: 'unsupported', feature: 'topK' });\n }\n if (seed != null) {\n warnings.push({ type: 'unsupported', feature: 'seed' });\n }\n if (frequencyPenalty != null) {\n warnings.push({ type: 'unsupported', feature: 'frequencyPenalty' });\n }\n if (presencePenalty != null) {\n warnings.push({ type: 'unsupported', feature: 'presencePenalty' });\n }\n if (stopSequences != null && stopSequences.length > 0) {\n warnings.push({ type: 'unsupported', feature: 'stopSequences' });\n }\n\n const { input, inputWarnings } = await convertToDeepSeekResponsesInput({\n prompt,\n providerOptionsName: this.providerOptionsName,\n });\n warnings.push(...inputWarnings);\n\n const {\n tools: deepseekTools,\n toolChoice: deepseekToolChoice,\n toolWarnings,\n } = prepareDeepSeekResponsesTools({ tools, toolChoice });\n warnings.push(...toolWarnings);\n\n const webSearchToolName = tools?.find(\n tool => tool.type === 'provider' && tool.id === 'deepseek.web_search',\n )?.name;\n\n const effort =\n deepseekOptions.thinking?.type === 'disabled'\n ? 'none'\n : (deepseekOptions.reasoningEffort ??\n (isCustomReasoning(reasoning)\n ? reasoning === 'none'\n ? 'none'\n : mapReasoningToProviderEffort({\n reasoning,\n effortMap: {\n minimal: 'low',\n low: 'low',\n medium: 'high',\n high: 'high',\n xhigh: 'max',\n max: 'max',\n },\n warnings,\n })\n : undefined));\n\n return {\n args: {\n model: this.modelId,\n input,\n max_output_tokens: maxOutputTokens,\n temperature,\n top_p: topP,\n ...(deepseekOptions.topLogprobs != null && {\n top_logprobs: deepseekOptions.topLogprobs,\n }),\n ...(effort != null && { reasoning: { effort } }),\n ...(responseFormat?.type === 'json' && {\n text: {\n format:\n responseFormat.schema != null\n ? {\n type: 'json_schema',\n name: responseFormat.name ?? 'response',\n schema: responseFormat.schema,\n }\n : { type: 'json_object' },\n },\n }),\n tools: deepseekTools,\n tool_choice: deepseekToolChoice,\n ...(deepseekOptions.userId != null && { user: deepseekOptions.userId }),\n },\n warnings,\n webSearchToolName,\n };\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\n const { args, warnings, webSearchToolName } = await this.getArgs(options);\n const providerOptionsName = this.providerOptionsName;\n const url = this.config.url({ path: '/responses', modelId: this.modelId });\n\n const {\n responseHeaders,\n value: response,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n body: args,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepseekResponsesResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n if (response.status === 'failed' || response.error != null) {\n throw new APICallError({\n message: response.error?.message ?? 'DeepSeek response failed',\n url,\n requestBodyValues: args,\n responseHeaders,\n responseBody: JSON.stringify(rawResponse),\n data: rawResponse,\n ...getFailedResponseStatus(response.error?.code),\n });\n }\n\n const content: Array<LanguageModelV4Content> = [];\n const logprobs: unknown[] = [];\n let hasFunctionCall = false;\n\n for (const item of response.output ?? []) {\n switch (item.type) {\n case 'reasoning': {\n const reasoning = item as ReasoningItem;\n const text = joinText(reasoning.content);\n content.push({\n type: 'reasoning',\n text,\n ...(reasoning.id != null && {\n providerMetadata: {\n [providerOptionsName]: { itemId: reasoning.id },\n },\n }),\n });\n break;\n }\n\n case 'message': {\n const message = item as MessageItem;\n for (const part of message.content ?? []) {\n if (part.logprobs != null) {\n logprobs.push(...part.logprobs);\n }\n if (part.text != null && part.text.length > 0) {\n content.push({ type: 'text', text: part.text });\n }\n }\n break;\n }\n\n case 'function_call': {\n const call = item as FunctionCallItem;\n hasFunctionCall = true;\n content.push({\n type: 'tool-call',\n toolCallId: call.call_id,\n toolName: call.name,\n input: call.arguments ?? '',\n });\n break;\n }\n\n case 'web_search_call': {\n content.push(\n ...webSearchCallContent({\n item: item as WebSearchCallItem,\n toolName: webSearchToolName ?? 'web_search',\n providerOptionsName,\n }),\n );\n break;\n }\n }\n }\n\n return {\n content,\n finishReason: {\n unified: mapDeepSeekResponsesFinishReason({\n status: response.status,\n incompleteReason: response.incomplete_details?.reason,\n hasFunctionCall,\n }),\n raw:\n response.incomplete_details?.reason ?? response.status ?? undefined,\n },\n usage: convertDeepSeekResponsesUsage(response.usage),\n providerMetadata: buildProviderMetadata({\n providerOptionsName,\n responseId: response.id,\n usage: response.usage,\n logprobs,\n }),\n request: { body: args },\n response: {\n ...createLanguageModelResponseMetadata({\n id: response.id,\n model: response.model,\n created: response.created_at,\n }),\n headers: responseHeaders,\n body: rawResponse,\n },\n warnings,\n };\n }\n\n async doStream(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\n const { args, warnings, webSearchToolName } = await this.getArgs(options);\n const providerOptionsName = this.providerOptionsName;\n const body = { ...args, stream: true };\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: this.config.url({ path: '/responses', modelId: this.modelId }),\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n body,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n deepseekResponsesChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n let finishReason: LanguageModelV4FinishReason = {\n unified: 'interrupted',\n raw: undefined,\n };\n let usage: DeepSeekResponsesUsage | null | undefined;\n let responseId: string | null | undefined;\n let hasFunctionCall = false;\n const logprobs: unknown[] = [];\n const openText = new Set<string>();\n const openReasoning = new Set<string>();\n const functionCalls = new Map<\n string,\n { callId: string; toolName: string; arguments: string }\n >();\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<InferSchema<typeof deepseekResponsesChunkSchema>>,\n LanguageModelV4StreamPart\n >({\n start(controller) {\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n if (!chunk.success) {\n finishReason = { unified: 'error', raw: undefined };\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n\n const value = chunk.value as StreamChunk;\n\n switch (value.type) {\n case 'response.created': {\n const created = value as ResponseChunk;\n responseId = created.response.id;\n controller.enqueue({\n type: 'response-metadata',\n ...createLanguageModelResponseMetadata({\n id: created.response.id,\n model: created.response.model,\n created: created.response.created_at,\n }),\n });\n return;\n }\n\n case 'response.output_item.added': {\n const item = (value as OutputItemChunk).item;\n const itemId = getItemId(item);\n if (item.type === 'message' && itemId != null) {\n openText.add(itemId);\n controller.enqueue({ type: 'text-start', id: itemId });\n } else if (item.type === 'reasoning' && itemId != null) {\n openReasoning.add(itemId);\n controller.enqueue({\n type: 'reasoning-start',\n id: itemId,\n providerMetadata: {\n [providerOptionsName]: { itemId },\n },\n });\n } else if (item.type === 'function_call') {\n const call = item as FunctionCallItem;\n functionCalls.set(call.id ?? call.call_id, {\n callId: call.call_id,\n toolName: call.name,\n arguments: call.arguments ?? '',\n });\n controller.enqueue({\n type: 'tool-input-start',\n id: call.call_id,\n toolName: call.name,\n });\n }\n return;\n }\n\n case 'response.output_text.delta': {\n const delta = value as TextDeltaChunk;\n if (delta.logprobs != null) {\n logprobs.push(...delta.logprobs);\n }\n if (!openText.has(delta.item_id)) {\n openText.add(delta.item_id);\n controller.enqueue({ type: 'text-start', id: delta.item_id });\n }\n controller.enqueue({\n type: 'text-delta',\n id: delta.item_id,\n delta: delta.delta,\n });\n return;\n }\n\n case 'response.reasoning_text.delta': {\n const delta = value as TextDeltaChunk;\n if (!openReasoning.has(delta.item_id)) {\n openReasoning.add(delta.item_id);\n controller.enqueue({\n type: 'reasoning-start',\n id: delta.item_id,\n providerMetadata: {\n [providerOptionsName]: { itemId: delta.item_id },\n },\n });\n }\n controller.enqueue({\n type: 'reasoning-delta',\n id: delta.item_id,\n delta: delta.delta,\n });\n return;\n }\n\n case 'response.function_call_arguments.delta': {\n const delta = value as TextDeltaChunk;\n const call = functionCalls.get(delta.item_id);\n if (call == null) {\n return;\n }\n call.arguments += delta.delta;\n controller.enqueue({\n type: 'tool-input-delta',\n id: call.callId,\n delta: delta.delta,\n });\n return;\n }\n\n case 'response.output_item.done': {\n const item = (value as OutputItemChunk).item;\n const itemId = getItemId(item);\n if (item.type === 'message' && itemId != null) {\n if (openText.delete(itemId)) {\n controller.enqueue({ type: 'text-end', id: itemId });\n }\n } else if (item.type === 'reasoning' && itemId != null) {\n if (openReasoning.delete(itemId)) {\n controller.enqueue({\n type: 'reasoning-end',\n id: itemId,\n providerMetadata: {\n [providerOptionsName]: { itemId },\n },\n });\n }\n } else if (item.type === 'function_call') {\n const call = item as FunctionCallItem;\n const key = call.id ?? call.call_id;\n const tracked = functionCalls.get(key);\n functionCalls.delete(key);\n hasFunctionCall = true;\n if (tracked == null) {\n controller.enqueue({\n type: 'tool-input-start',\n id: call.call_id,\n toolName: call.name,\n });\n }\n controller.enqueue({\n type: 'tool-input-end',\n id: call.call_id,\n });\n controller.enqueue({\n type: 'tool-call',\n toolCallId: call.call_id,\n toolName: call.name,\n input: call.arguments ?? tracked?.arguments ?? '',\n });\n } else if (item.type === 'web_search_call') {\n for (const part of webSearchCallContent({\n item: item as WebSearchCallItem,\n toolName: webSearchToolName ?? 'web_search',\n providerOptionsName,\n })) {\n controller.enqueue(part);\n }\n }\n return;\n }\n\n case 'response.completed':\n case 'response.incomplete':\n case 'response.failed': {\n const done = value as ResponseChunk;\n usage = done.response.usage;\n responseId = done.response.id ?? responseId;\n finishReason = {\n unified: mapDeepSeekResponsesFinishReason({\n status: done.response.status,\n incompleteReason: done.response.incomplete_details?.reason,\n hasFunctionCall,\n }),\n raw:\n done.response.incomplete_details?.reason ??\n done.response.status ??\n undefined,\n };\n if (value.type === 'response.failed') {\n controller.enqueue({\n type: 'error',\n error: createProviderStreamError({\n message:\n done.response.error?.message ??\n 'DeepSeek response failed',\n type: 'response.failed',\n code: done.response.error?.code ?? undefined,\n ...getFailedResponseStatus(done.response.error?.code),\n data: value,\n }),\n });\n }\n return;\n }\n\n case 'error': {\n const error = value as ErrorChunk;\n finishReason = { unified: 'error', raw: undefined };\n controller.enqueue({\n type: 'error',\n error: createProviderStreamError({\n message: error.message ?? 'DeepSeek stream error',\n type: 'error',\n code: error.code ?? undefined,\n data: value,\n }),\n });\n }\n }\n },\n\n flush(controller) {\n for (const id of openReasoning) {\n controller.enqueue({ type: 'reasoning-end', id });\n }\n for (const id of openText) {\n controller.enqueue({ type: 'text-end', id });\n }\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage: convertDeepSeekResponsesUsage(usage),\n providerMetadata: buildProviderMetadata({\n providerOptionsName,\n responseId,\n usage,\n logprobs,\n }),\n });\n },\n }),\n ),\n request: { body },\n response: { headers: responseHeaders },\n };\n }\n}\n\ntype StreamChunk = InferSchema<typeof deepseekResponsesChunkSchema>;\n\ntype ResponseChunk = Extract<StreamChunk, { response: unknown }>;\n\ntype OutputItemChunk = Extract<StreamChunk, { item: unknown }>;\n\ntype TextDeltaChunk = Extract<\n StreamChunk,\n { type: 'response.output_text.delta' }\n>;\n\ntype ErrorChunk = Extract<StreamChunk, { type: 'error' }>;\n\ntype MessageItem = Extract<DeepSeekResponsesOutputItem, { type: 'message' }>;\n\ntype ReasoningItem = Extract<\n DeepSeekResponsesOutputItem,\n { type: 'reasoning' }\n>;\n\ntype FunctionCallItem = Extract<\n DeepSeekResponsesOutputItem,\n { type: 'function_call' }\n>;\n\ntype WebSearchCallItem = Extract<\n DeepSeekResponsesOutputItem,\n { type: 'web_search_call' }\n>;\n\nfunction getFailedResponseStatus(code: string | null | undefined): {\n statusCode: number;\n isRetryable: boolean;\n} {\n switch (code) {\n case 'rate_limit_exceeded':\n case 'rate_limit_error':\n return { statusCode: 429, isRetryable: true };\n case 'insufficient_quota':\n return { statusCode: 429, isRetryable: false };\n case 'authentication_error':\n case 'invalid_api_key':\n return { statusCode: 401, isRetryable: false };\n case 'permission_error':\n return { statusCode: 403, isRetryable: false };\n case 'bad_request':\n case 'context_length_exceeded':\n case 'invalid_request_error':\n return { statusCode: 400, isRetryable: false };\n case 'timeout':\n case 'timeout_error':\n return { statusCode: 504, isRetryable: true };\n default:\n return { statusCode: 500, isRetryable: true };\n }\n}\n\nfunction getItemId(item: DeepSeekResponsesOutputItem): string | undefined {\n return 'id' in item && typeof item.id === 'string' ? item.id : undefined;\n}\n\nfunction joinText(\n parts: Array<{ text?: string | null }> | null | undefined,\n): string {\n return (parts ?? []).map(part => part.text ?? '').join('');\n}\n\nfunction webSearchCallContent({\n item,\n toolName,\n providerOptionsName,\n}: {\n item: WebSearchCallItem;\n toolName: string;\n providerOptionsName: string;\n}): Array<\n Extract<LanguageModelV4Content, { type: 'tool-call' | 'tool-result' }>\n> {\n return [\n {\n type: 'tool-call',\n toolCallId: item.id,\n toolName,\n input: '{}',\n providerExecuted: true,\n providerMetadata: {\n [providerOptionsName]: { webSearchCall: item as JSONObject },\n },\n },\n {\n type: 'tool-result',\n toolCallId: item.id,\n toolName,\n result: {\n ...(item.status != null && { status: item.status }),\n ...(item.action != null && { action: item.action as JSONObject }),\n },\n },\n ];\n}\n\nfunction buildProviderMetadata({\n providerOptionsName,\n responseId,\n usage,\n logprobs,\n}: {\n providerOptionsName: string;\n responseId: string | null | undefined;\n usage: DeepSeekResponsesUsage | null | undefined;\n logprobs: unknown[];\n}): SharedV4ProviderMetadata {\n const serverToolUse = getDeepSeekServerToolUse(usage);\n return {\n [providerOptionsName]: {\n ...(responseId != null && { responseId }),\n ...(serverToolUse != null && { serverToolUse }),\n ...(logprobs.length > 0 && { logprobs: logprobs as JSONObject[] }),\n },\n };\n}\n","import {\n createProviderExecutedToolFactory,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const webSearchOutputSchema = lazySchema(() =>\n zodSchema(\n z.object({\n status: z.string().optional(),\n action: z.record(z.string(), z.unknown()).optional(),\n }),\n ),\n);\n\nconst webSearchToolFactory = createProviderExecutedToolFactory<\n {},\n {\n /**\n * Status of the server-side web search call.\n */\n status?: string;\n\n /**\n * The search action reported by DeepSeek, such as the query that was run.\n */\n action?: Record<string, unknown>;\n },\n {}\n>({\n id: 'deepseek.web_search',\n inputSchema: lazySchema(() => zodSchema(z.object({}))),\n outputSchema: webSearchOutputSchema,\n});\n\n/**\n * DeepSeek's server-side web search for the Responses API. DeepSeek runs the\n * searches and page reads during generation and adds the results to the\n * model context. Supported with `deepseek-v4-pro`.\n *\n * Successful searches and page reads are billed per operation and reported in\n * `usage.raw.server_tool_use` and `providerMetadata.deepseek.serverToolUse`.\n */\nexport const webSearch = (\n args: Parameters<typeof webSearchToolFactory>[0] = {},\n) => webSearchToolFactory(args);\n","import { webSearch } from './web-search';\n\nexport { webSearch };\n\nexport const deepseekTools = {\n webSearch,\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","import {\n type FilesV4,\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolveWith,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport type { DeepSeekChatModelId } from './chat/deepseek-chat-language-model-options';\nimport { DeepSeekChatLanguageModel } from './chat/deepseek-chat-language-model';\nimport { DeepSeekFiles } from './files/deepseek-files';\nimport { DeepSeekResponsesLanguageModel } from './responses/deepseek-responses-language-model';\nimport type { DeepSeekResponsesModelId } from './responses/deepseek-responses-language-model-options';\nimport { deepseekTools } from './tool';\nimport { VERSION } from './version';\n\nexport interface DeepSeekProviderSettings {\n /**\n * DeepSeek API key.\n * A function is called before each request and may return a promise.\n */\n apiKey?: Resolvable<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 ProviderV4 {\n /**\n * Creates a DeepSeek model for text generation.\n */\n (modelId: DeepSeekChatModelId): LanguageModelV4;\n\n /**\n * Creates a DeepSeek model for text generation.\n */\n languageModel(modelId: DeepSeekChatModelId): LanguageModelV4;\n\n /**\n * Creates a DeepSeek chat model for text generation.\n */\n chat(modelId: DeepSeekChatModelId): LanguageModelV4;\n\n /**\n * Creates a DeepSeek model that uses the Responses API. Supports\n * server-side tools such as `deepseek.tools.webSearch()`.\n */\n responses(modelId: DeepSeekResponsesModelId): LanguageModelV4;\n\n /**\n * DeepSeek server-side tools for use with the Responses API.\n */\n tools: typeof deepseekTools;\n\n /**\n * Creates a DeepSeek files interface for uploading images.\n */\n files(): FilesV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport function createDeepSeek(\n options: DeepSeekProviderSettings = {},\n): DeepSeekProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL ?? 'https://api.deepseek.com') ??\n 'https://api.deepseek.com';\n\n const getHeaders = () =>\n resolveWith(options.apiKey, apiKey =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey,\n environmentVariableName: 'DEEPSEEK_API_KEY',\n description: 'DeepSeek API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-deepseek/${VERSION}`,\n ),\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 supportsStrictToolCalls: baseURL.endsWith('/beta'),\n });\n };\n\n const createResponsesModel = (modelId: DeepSeekResponsesModelId) =>\n new DeepSeekResponsesLanguageModel(modelId, {\n provider: 'deepseek.responses',\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createFiles = () =>\n new DeepSeekFiles({\n provider: 'deepseek.files',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = (modelId: DeepSeekChatModelId) =>\n createLanguageModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n provider.responses = createResponsesModel;\n provider.tools = deepseekTools;\n provider.files = createFiles;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const deepSeek = createDeepSeek();\n"],"mappings":";;;;AAOA,MAAa,kCAAkC,iBAC7C,UACE,EAAE,OAAO;;;;;;CAMP,aAAa,EAAE,KAAK;EAAC;EAAO;EAAQ;EAAY;CAAM,CAAC,CAAC,CAAC,SAAS;;;;;;;;;CAUlE,UAAU,EAAE,QAAQ,IAAI,CAAC,CAAC,SAAS;AACrC,CAAC,CACH,CACF;;;ACXA,SAAS,kCAAkC;CACzC,OAAO,EAAE,OAAO;;;;EAId,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;EAO/B,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS;;;;;;;;EAStD,QAAQ,EACL,OAAO,CAAC,CACR,MAAM,oBAAoB,sCAAsC,CAAC,CACjE,IAAI,KAAK,4CAA4C,CAAC,CACtD,SAAS;;;;EAKZ,UAAU,EACP,OAAO,EAIN,MAAM,EAAE,KAAK;GAAC;GAAY;GAAW;EAAU,CAAC,CAAC,CAAC,SAAS,EAC7D,CAAC,CAAC,CACD,SAAS;;;;EAQZ,iBAAiB,EACd,KAAK;GAAC;GAAO;GAAU;GAAQ;GAAS;EAAK,CAAC,CAAC,CAC/C,SAAS;;;;;;EAOZ,kBAAkB,EAAE,QAAQ,CAAC,CAAC,SAAS;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AS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,OAAO;CAChB,SAAS,YAAY;CACrB,SAAS,QAAQ;CACjB,SAAS,QAAQ;CAEjB,SAAS,kBAAkB,YAAoB;EAC7C,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAiB,CAAC;CACrE;CACA,SAAS,qBAAqB,SAAS;CACvC,SAAS,cAAc,YAAoB;EACzC,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CACjE;CAEA,OAAO;AACT;AAEA,MAAa,WAAW,eAAe"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["supportedImageMediaTypes"],"sources":["../src/chat/deepseek-file-part-options.ts","../src/chat/deepseek-chat-language-model-options.ts","../src/deepseek-model-catalog.ts","../src/chat/is-deepseek-v4-model.ts","../src/chat/convert-to-deepseek-chat-messages.ts","../src/chat/convert-to-deepseek-usage.ts","../src/chat/deepseek-chat-api-types.ts","../src/chat/deepseek-prepare-tools.ts","../src/chat/map-deepseek-finish-reason.ts","../src/chat/deepseek-chat-language-model.ts","../src/files/deepseek-files-api.ts","../src/files/deepseek-files-options.ts","../src/files/deepseek-files.ts","../src/responses/convert-to-deepseek-responses-input.ts","../src/responses/convert-deepseek-responses-usage.ts","../src/responses/deepseek-responses-api.ts","../src/responses/deepseek-responses-language-model-options.ts","../src/responses/deepseek-responses-prepare-tools.ts","../src/responses/map-deepseek-responses-finish-reason.ts","../src/responses/deepseek-responses-language-model.ts","../src/tool/web-search.ts","../src/tool/index.ts","../src/version.ts","../src/deepseek-provider.ts"],"sourcesContent":["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","import {\n type InferSchema,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { DeepSeekModelIds } from '../deepseek-model-catalog';\n\n// https://api-docs.deepseek.com/quick_start/pricing\nexport type DeepSeekChatModelId = DeepSeekModelIds['chat'] | (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 deepseekLanguageModelChatOptions = lazySchema(() =>\n zodSchema(getDeepseekChatOptionsSchema()),\n);\n\nexport type DeepSeekLanguageModelChatOptions = {\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 type {\n ModelCapabilities,\n ModelCapability,\n ModelEntry,\n ProviderOptionDefinition,\n ProviderOptionDefinitions,\n} from '@ai-sdk/provider';\nimport type { DeepSeekLanguageModelChatOptions } from './chat/deepseek-chat-language-model-options';\n\nexport const deepseekProviderOptions = {\n language: {\n logprobs: { description: 'Return token log probabilities.' },\n topLogprobs: {\n description: 'Number of token log probabilities to return.',\n },\n userId: { description: 'End-user identifier for request isolation.' },\n thinking: { description: 'Enable or disable thinking.' },\n reasoningEffort: { description: 'Thinking strength for reasoning models.' },\n strictJsonSchema: {\n description: 'Use strict JSON schema validation on supporting endpoints.',\n },\n } satisfies Record<\n keyof DeepSeekLanguageModelChatOptions,\n ProviderOptionDefinition\n >,\n} as const satisfies ProviderOptionDefinitions;\n\nexport type DeepSeekEndpointOptions = {\n supportsAssistantPrefixCompletion?: boolean;\n supportsStrictToolCalls?: boolean;\n supportsPenaltySampling?: boolean;\n supportsThinking?: boolean;\n supportsStructuredOutputs?: boolean;\n};\n\ntype LanguageCapabilities = NonNullable<ModelCapabilities['language']> & {\n textGeneration: ModelCapability;\n tools: NonNullable<ModelCapabilities['language']>['tools'] & {\n strict: boolean | 'unknown';\n };\n reasoning: NonNullable<ModelCapabilities['language']>['reasoning'] & {\n configurable: boolean;\n enabledByDefault: boolean;\n assistantHistory: boolean;\n };\n sampling: NonNullable<ModelCapabilities['language']>['sampling'] & {\n penalties: boolean;\n topK: false;\n seed: false;\n };\n structuredOutput: { jsonSchema: boolean };\n endpoints: { assistantPrefixCompletion: boolean };\n};\n\nexport type DeepSeekLanguageModelEntry = ModelEntry & {\n capabilities: { language: LanguageCapabilities };\n providerOptions: {\n language: Record<keyof DeepSeekLanguageModelChatOptions, ModelCapability>;\n };\n};\n\n// Preserve the provider page's model set and its image-input exception.\nconst languageDefinitions = {\n 'deepseek-flash': { endpoints: ['chat', 'responses'], image: false },\n 'deepseek-v4-flash': { endpoints: ['chat'], image: false },\n 'deepseek-v4-pro': { endpoints: ['chat', 'responses'], image: false },\n 'deepseek-v4-flash-vision-exp': { endpoints: ['chat'], image: true },\n} as const;\n\nfunction createLanguageModelEntry(\n modelId: string,\n image?: boolean,\n): DeepSeekLanguageModelEntry {\n // Legacy aliases and pre-V4 IDs retain their previous protocol. Unknown IDs\n // inherit the current protocol, including assistant reasoning history.\n const assistantHistory =\n !/(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\\.\\d+)?)(?=[-/:.]|$)/.test(\n modelId,\n );\n const support = image != null ? true : 'unknown';\n const language: LanguageCapabilities = {\n textGeneration: support,\n inputs: { image: image ?? 'unknown', audio: false },\n objectGeneration: support,\n tools: { usage: support, streaming: support, strict: 'unknown' },\n reasoning: {\n support,\n ...(image != null ? { efforts: ['low', 'high', 'max'] } : {}),\n configurable: true,\n enabledByDefault: modelId === 'deepseek-reasoner' || assistantHistory,\n assistantHistory,\n },\n sampling: {\n temperature: { condition: 'Only effective when thinking is disabled.' },\n topP: { condition: 'Only effective when thinking is disabled.' },\n logprobs: support,\n penalties: false,\n topK: false,\n seed: false,\n },\n structuredOutput: { jsonSchema: false },\n endpoints: { assistantPrefixCompletion: false },\n };\n return {\n capabilities: { language },\n providerOptions: {\n language: {\n logprobs: language.sampling.logprobs,\n topLogprobs: language.sampling.logprobs,\n userId: support,\n thinking: language.reasoning.support,\n reasoningEffort: language.reasoning.support,\n strictJsonSchema: {\n condition:\n 'Requires a serving endpoint with JSON schema response formatting.',\n },\n },\n },\n };\n}\n\nexport const deepseekModelCatalog: Readonly<\n Record<string, DeepSeekLanguageModelEntry>\n> = Object.fromEntries(\n Object.entries(languageDefinitions).map(([modelId, { image }]) => [\n modelId,\n createLanguageModelEntry(modelId, image),\n ]),\n);\n\nexport function getDeepSeekLanguageModelEntry(\n modelId: string,\n endpoint: DeepSeekEndpointOptions = {},\n): DeepSeekLanguageModelEntry {\n const entry = Object.prototype.hasOwnProperty.call(\n deepseekModelCatalog,\n modelId,\n )\n ? deepseekModelCatalog[modelId]\n : createLanguageModelEntry(modelId);\n const { language } = entry.capabilities;\n return {\n ...entry,\n capabilities: {\n language: {\n ...language,\n tools: {\n ...language.tools,\n strict: endpoint.supportsStrictToolCalls ?? 'unknown',\n },\n reasoning: {\n ...language.reasoning,\n configurable: endpoint.supportsThinking !== false,\n },\n sampling: {\n ...language.sampling,\n penalties: endpoint.supportsPenaltySampling === true,\n },\n structuredOutput: {\n jsonSchema: endpoint.supportsStructuredOutputs === true,\n },\n endpoints: {\n assistantPrefixCompletion:\n endpoint.supportsAssistantPrefixCompletion === true,\n },\n },\n },\n };\n}\n\ntype DeepSeekEndpointModelId<Endpoint extends 'chat' | 'responses'> = {\n [ModelId in keyof typeof languageDefinitions]: Endpoint extends (typeof languageDefinitions)[ModelId]['endpoints'][number]\n ? ModelId\n : never;\n}[keyof typeof languageDefinitions];\n\n/** Known model IDs, derived from the declarations used to build the catalog. */\nexport type DeepSeekModelIds = {\n chat: DeepSeekEndpointModelId<'chat'>;\n responses: DeepSeekEndpointModelId<'responses'>;\n};\n","import { getDeepSeekLanguageModelEntry } from '../deepseek-model-catalog';\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 getDeepSeekLanguageModelEntry(modelId).capabilities.language.reasoning\n .assistantHistory;\n}\n","import {\n InvalidPromptError,\n UnsupportedFunctionalityError,\n type LanguageModelV4CallOptions,\n type LanguageModelV4FilePart,\n type LanguageModelV4Prompt,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n secureJsonParse,\n stringifyWithBigIntAndCycles,\n convertToBase64,\n getTopLevelMediaType,\n parseProviderOptions,\n resolveFullMediaType,\n resolveProviderReference,\n} from '@ai-sdk/provider-utils';\nimport type {\n DeepSeekChatPrompt,\n DeepSeekContentPart,\n DeepSeekToolMessage,\n} from './deepseek-chat-api-types';\nimport { deepseekFilePartProviderOptions } from './deepseek-file-part-options';\nimport { deepseekAssistantMessageProviderOptions } from './deepseek-chat-language-model-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 resolveDeepSeekImageMediaType(part: LanguageModelV4FilePart): string {\n const resolvedMediaType = resolveFullMediaType({ part });\n\n if (!supportedImageMediaTypes.has(resolvedMediaType)) {\n throw new UnsupportedFunctionalityError({\n functionality: `DeepSeek image media type ${resolvedMediaType}`,\n message: 'DeepSeek supports JPEG, PNG, GIF, and WebP image inputs.',\n });\n }\n\n return resolvedMediaType;\n}\n\nfunction validateDeepSeekImageUrl({\n url,\n prompt,\n}: {\n url: string;\n prompt: LanguageModelV4Prompt;\n}): void {\n if (url.length > 8192) {\n throw new InvalidPromptError({\n prompt,\n message: 'DeepSeek image URLs must not exceed 8192 characters.',\n });\n }\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: LanguageModelV4Prompt;\n responseFormat: LanguageModelV4CallOptions['responseFormat'];\n modelId: string;\n providerOptionsName?: string;\n supportsAssistantPrefixCompletion?: boolean;\n supportsStructuredOutputs?: boolean;\n}): Promise<{\n messages: DeepSeekChatPrompt;\n warnings: Array<SharedV4Warning>;\n}> {\n const isDeepSeekV4 = isDeepSeekV4Model(modelId);\n const messages: DeepSeekChatPrompt = [];\n const warnings: Array<SharedV4Warning> = [];\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 warnings.push({\n type: 'compatibility',\n feature: 'responseFormat JSON schema',\n details: 'JSON response schema is injected into the system message.',\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.data.type === 'reference' ||\n part.data.type === 'url' ||\n part.data.type === 'data') &&\n getTopLevelMediaType(part.mediaType) === '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: 'unsupported',\n feature: `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 getTopLevelMediaType(part.mediaType) === 'image'\n ) {\n const filePartOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions: part.providerOptions,\n schema: deepseekFilePartProviderOptions,\n });\n\n if (part.data.type === 'reference') {\n userContent.push({\n type: 'file',\n file_id: resolveProviderReference({\n reference: part.data.reference,\n provider: 'deepseek',\n }),\n });\n } else if (part.data.type === 'url' || part.data.type === 'data') {\n const resolvedMediaType = resolveDeepSeekImageMediaType(part);\n\n if (part.data.type === 'url') {\n const url = part.data.url.toString();\n\n validateDeepSeekImageUrl({ url, prompt });\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.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: 'unsupported',\n feature: `user message part type: ${part.type}`,\n });\n }\n } else {\n warnings.push({\n type: 'unsupported',\n feature: `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: 'unsupported',\n feature: 'message name on tool messages',\n });\n }\n\n for (const toolResponse of content) {\n if (toolResponse.type === 'tool-approval-response') {\n continue;\n }\n const output = toolResponse.output;\n\n let contentValue: DeepSeekToolMessage['content'];\n switch (output.type) {\n case 'text':\n case 'error-text':\n contentValue = output.value;\n break;\n case 'execution-denied':\n contentValue = output.reason ?? 'Tool call execution denied.';\n break;\n case 'json':\n case 'error-json':\n contentValue = stringifyWithBigIntAndCycles(output.value);\n break;\n case 'content': {\n const hasImagePart = output.value.some(\n part =>\n part.type === 'file' &&\n (part.data.type === 'reference' ||\n part.data.type === 'url' ||\n part.data.type === 'data') &&\n getTopLevelMediaType(part.mediaType) === 'image',\n );\n\n if (!hasImagePart) {\n contentValue = stringifyWithBigIntAndCycles(output.value);\n break;\n }\n\n contentValue = [];\n for (const part of output.value) {\n if (part.type === 'text') {\n contentValue.push({ type: 'text', text: part.text });\n } else if (\n part.type === 'file' &&\n (part.data.type === 'reference' ||\n part.data.type === 'url' ||\n part.data.type === 'data') &&\n getTopLevelMediaType(part.mediaType) === 'image'\n ) {\n if (part.data.type === 'reference') {\n contentValue.push({\n type: 'file',\n file_id: resolveProviderReference({\n reference: part.data.reference,\n provider: 'deepseek',\n }),\n });\n continue;\n }\n\n const filePartOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions: part.providerOptions,\n schema: deepseekFilePartProviderOptions,\n });\n const resolvedMediaType = resolveDeepSeekImageMediaType(part);\n let url: string;\n\n if (part.data.type === 'url') {\n url = part.data.url.toString();\n validateDeepSeekImageUrl({ url, prompt });\n } else {\n url = `data:${\n resolvedMediaType === 'image/jpg'\n ? 'image/jpeg'\n : resolvedMediaType\n };base64,${convertToBase64(part.data.data)}`;\n }\n\n contentValue.push({\n type: 'image_url',\n image_url: {\n url,\n ...(filePartOptions?.imageDetail != null && {\n detail: filePartOptions.imageDetail,\n }),\n },\n });\n } else {\n warnings.push({\n type: 'unsupported',\n feature: `tool result content part type: ${part.type}`,\n });\n }\n }\n break;\n }\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: 'unsupported',\n feature: `message role: ${role}`,\n });\n break;\n }\n }\n }\n\n return { messages, warnings };\n}\n","import type { LanguageModelV4Usage } from '@ai-sdk/provider';\nimport { createNullLanguageModelUsage } from '@ai-sdk/provider-utils';\n\nexport function convertDeepSeekUsage(\n usage:\n | {\n prompt_tokens?: number | null | undefined;\n completion_tokens?: number | null | undefined;\n prompt_cache_hit_tokens?: number | null | undefined;\n prompt_tokens_details?:\n | {\n cached_tokens?: number | null | undefined;\n }\n | null\n | undefined;\n completion_tokens_details?:\n | {\n reasoning_tokens?: number | null | undefined;\n }\n | null\n | undefined;\n }\n | undefined\n | null,\n): LanguageModelV4Usage {\n if (usage == null) {\n return createNullLanguageModelUsage();\n }\n\n const promptTokens = usage.prompt_tokens ?? 0;\n const completionTokens = usage.completion_tokens ?? 0;\n const cacheReadTokens =\n usage.prompt_cache_hit_tokens ??\n usage.prompt_tokens_details?.cached_tokens ??\n 0;\n const reasoningTokens =\n usage.completion_tokens_details?.reasoning_tokens ?? 0;\n\n return {\n inputTokens: {\n total: promptTokens,\n noCache: promptTokens - cacheReadTokens,\n cacheRead: cacheReadTokens,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: completionTokens,\n text: Math.max(0, completionTokens - reasoningTokens),\n reasoning: reasoningTokens,\n },\n raw: usage,\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 type DeepSeekContentPartFile =\n | {\n type: 'file';\n file_id: string;\n }\n | {\n type: 'file';\n file_data: string;\n filename?: string;\n };\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 | Array<DeepSeekContentPart>;\n tool_call_id: string;\n}\n\nexport interface DeepSeekFunctionTool {\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n strict?: boolean;\n };\n}\n\nexport type DeepSeekToolChoice =\n | { type: 'function'; function: { name: string } }\n | 'auto'\n | 'none'\n | 'required'\n | undefined;\n\n// Loose, nested objects included: the parsed value is returned as `usage.raw`.\nfunction createTokenUsageSchema() {\n return z\n .looseObject({\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 .looseObject({\n cached_tokens: z.number().nullish(),\n })\n .nullish(),\n completion_tokens_details: z\n .looseObject({\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 UnsupportedFunctionalityError,\n type LanguageModelV4CallOptions,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport type {\n DeepSeekFunctionTool,\n DeepSeekToolChoice,\n} from './deepseek-chat-api-types';\n\nexport function prepareTools({\n tools,\n toolChoice,\n supportsStrictToolCalls,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n toolChoice?: LanguageModelV4CallOptions['toolChoice'];\n supportsStrictToolCalls?: boolean;\n}): {\n tools: undefined | Array<DeepSeekFunctionTool>;\n toolChoice: DeepSeekToolChoice;\n toolWarnings: SharedV4Warning[];\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: SharedV4Warning[] = [];\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const functionTools = tools.filter(tool => tool.type === 'function');\n const hasStrictTool = functionTools.some(tool => tool.strict === true);\n\n if (hasStrictTool && supportsStrictToolCalls === false) {\n throw new UnsupportedFunctionalityError({\n functionality: 'DeepSeek strict tool calls',\n message:\n 'DeepSeek strict tool calls require a beta base URL ending in `/beta`.',\n });\n }\n\n if (\n hasStrictTool &&\n supportsStrictToolCalls === true &&\n functionTools.some(tool => tool.strict !== true)\n ) {\n throw new UnsupportedFunctionalityError({\n functionality: 'mixed DeepSeek strict and non-strict tool calls',\n message:\n 'DeepSeek strict mode requires every function tool in the request to set `strict: true`.',\n });\n }\n\n const deepseekTools: Array<DeepSeekFunctionTool> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider') {\n toolWarnings.push({\n type: 'unsupported',\n feature: `provider-defined tool ${tool.id}`,\n });\n } else {\n deepseekTools.push({\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n ...(tool.strict != null ? { strict: tool.strict } : {}),\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 return {\n tools: deepseekTools,\n toolChoice: undefined,\n toolWarnings: [\n ...toolWarnings,\n {\n type: 'unsupported',\n feature: `tool choice type: ${type}`,\n },\n ],\n };\n }\n }\n}\n","import type { LanguageModelV4FinishReason } from '@ai-sdk/provider';\n\nexport function mapDeepSeekFinishReason(\n finishReason: string | null | undefined,\n): LanguageModelV4FinishReason['unified'] {\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 'other';\n }\n}\n","import {\n InvalidResponseDataError,\n type APICallError,\n type LanguageModelV4,\n type LanguageModelV4CallOptions,\n type LanguageModelV4Content,\n type LanguageModelV4FinishReason,\n type LanguageModelV4GenerateResult,\n type LanguageModelV4StreamPart,\n type LanguageModelV4StreamResult,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolve,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n createProviderStreamError,\n generateId,\n isCustomReasoning,\n mapReasoningToProviderEffort,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n StreamingToolCallTracker,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n type InferSchema,\n type ParseResult,\n type ResponseHandler,\n} from '@ai-sdk/provider-utils';\nimport { convertToDeepSeekChatMessages } from './convert-to-deepseek-chat-messages';\nimport { convertDeepSeekUsage } from './convert-to-deepseek-usage';\nimport {\n deepseekChatChunkSchema,\n deepseekChatResponseSchema,\n deepSeekErrorSchema,\n type DeepSeekChatLogprob,\n type DeepSeekChatTokenUsage,\n} from './deepseek-chat-api-types';\nimport {\n deepseekLanguageModelChatOptions,\n type DeepSeekChatModelId,\n} from './deepseek-chat-language-model-options';\nimport { prepareTools } from './deepseek-prepare-tools';\nimport { getResponseMetadata } from './get-response-metadata';\nimport { mapDeepSeekFinishReason } from './map-deepseek-finish-reason';\nimport { getDeepSeekLanguageModelEntry } from '../deepseek-model-catalog';\n\nexport type DeepSeekChatConfig = {\n provider: string;\n headers?: Resolvable<Record<string, string | undefined>>;\n url: (options: { modelId: string; path: string }) => string;\n fetch?: FetchFunction;\n supportsAssistantPrefixCompletion?: boolean;\n supportsStrictToolCalls?: boolean;\n supportsPenaltySampling?: boolean;\n supportsThinking?: boolean;\n supportsStructuredOutputs?: boolean;\n};\n\nfunction createDeepSeekStreamError(\n error: {\n message: string;\n type?: string | null;\n code?: string | number | null;\n },\n data: unknown,\n) {\n const metadata = getDeepSeekStreamErrorMetadata(error);\n\n return createProviderStreamError({\n message: error.message,\n type: error.type ?? undefined,\n code: error.code ?? undefined,\n ...metadata,\n data,\n });\n}\n\nfunction getDeepSeekStreamErrorMetadata(error: {\n type?: string | null;\n code?: string | number | null;\n}): {\n statusCode?: number;\n isRetryable?: boolean;\n} {\n if (\n error.code === 'insufficient_quota' ||\n error.type === 'insufficient_quota'\n ) {\n return { statusCode: 429, isRetryable: false };\n }\n\n const explicitStatusCode = getHttpStatusCode(error.code);\n if (explicitStatusCode != null) {\n return {\n statusCode: explicitStatusCode,\n isRetryable: isRetryableStatusCode(explicitStatusCode),\n };\n }\n\n for (const discriminator of [error.code, error.type]) {\n switch (discriminator) {\n case 'rate_limit_exceeded':\n case 'rate_limit_error':\n return { statusCode: 429, isRetryable: true };\n case 'server_error':\n case 'api_error':\n case 'internal_server_error':\n return { statusCode: 500, isRetryable: true };\n case 'overloaded_error':\n case 'service_unavailable':\n return { statusCode: 503, isRetryable: true };\n case 'timeout':\n case 'timeout_error':\n return { statusCode: 504, isRetryable: true };\n case 'authentication_error':\n case 'invalid_api_key':\n return { statusCode: 401, isRetryable: false };\n case 'permission_error':\n return { statusCode: 403, isRetryable: false };\n case 'not_found_error':\n case 'model_not_found':\n return { statusCode: 404, isRetryable: false };\n case 'bad_request':\n case 'context_length_exceeded':\n case 'invalid_request_error':\n return { statusCode: 400, isRetryable: false };\n }\n }\n\n return {};\n}\n\nfunction getHttpStatusCode(value: unknown): number | undefined {\n const statusCode =\n typeof value === 'string' && /^\\d{3}$/.test(value) ? Number(value) : value;\n\n return typeof statusCode === 'number' &&\n Number.isInteger(statusCode) &&\n statusCode >= 400 &&\n statusCode <= 599\n ? statusCode\n : undefined;\n}\n\nfunction isRetryableStatusCode(statusCode: number): boolean {\n return (\n statusCode === 408 ||\n statusCode === 409 ||\n statusCode === 429 ||\n statusCode >= 500\n );\n}\n\nfunction mapDeepSeekProviderReasoningEffort({\n reasoningEffort,\n warnings,\n}: {\n reasoningEffort: 'low' | 'medium' | 'high' | 'xhigh' | 'max';\n warnings: SharedV4Warning[];\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: 'compatibility',\n feature: 'reasoningEffort',\n details: `reasoningEffort \"${reasoningEffort}\" is not a canonical DeepSeek value. mapped to \"${mapped}\".`,\n });\n }\n\n return mapped;\n}\n\nexport class DeepSeekChatLanguageModel implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\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 static [WORKFLOW_SERIALIZE](model: DeepSeekChatLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: DeepSeekChatModelId;\n config: DeepSeekChatConfig;\n }) {\n return new DeepSeekChatLanguageModel(options.modelId, options.config);\n }\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 reasoning,\n providerOptions,\n stopSequences,\n responseFormat,\n seed,\n toolChoice,\n tools,\n }: LanguageModelV4CallOptions) {\n const deepseekOptions =\n (await parseProviderOptions({\n provider: this.providerOptionsName,\n providerOptions,\n schema: deepseekLanguageModelChatOptions,\n })) ?? {};\n\n const { language: capabilities } = getDeepSeekLanguageModelEntry(\n this.modelId,\n this.config,\n ).capabilities;\n const supportsStructuredOutputs = capabilities.structuredOutput.jsonSchema;\n const supportsPenaltySampling = capabilities.sampling.penalties;\n\n const { messages, warnings } = await convertToDeepSeekChatMessages({\n prompt,\n responseFormat,\n modelId: this.modelId,\n providerOptionsName: this.providerOptionsName,\n supportsAssistantPrefixCompletion:\n capabilities.endpoints.assistantPrefixCompletion,\n supportsStructuredOutputs,\n });\n const allWarnings: SharedV4Warning[] = [...warnings];\n\n if (topK != null) {\n allWarnings.push({ type: 'unsupported', feature: 'topK' });\n }\n\n if (seed != null) {\n allWarnings.push({ type: 'unsupported', feature: 'seed' });\n }\n\n if (!supportsPenaltySampling && frequencyPenalty != null) {\n allWarnings.push({\n type: 'deprecated',\n setting: 'frequencyPenalty',\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: 'deprecated',\n setting: 'presencePenalty',\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 supportsStrictToolCalls:\n capabilities.tools.strict === 'unknown'\n ? undefined\n : capabilities.tools.strict,\n });\n\n const thinkingType = deepseekOptions.thinking?.type;\n if (thinkingType === 'adaptive') {\n allWarnings.push({\n type: 'compatibility',\n feature: 'thinking.type',\n details:\n 'thinking.type \"adaptive\" is not a canonical DeepSeek value. mapped to \"enabled\".',\n });\n }\n\n const thinking = !capabilities.reasoning.configurable\n ? undefined\n : thinkingType != null\n ? { type: thinkingType === 'adaptive' ? 'enabled' : thinkingType }\n : isCustomReasoning(reasoning)\n ? { type: reasoning === 'none' ? 'disabled' : 'enabled' }\n : undefined;\n\n const isThinkingEnabled =\n capabilities.reasoning.configurable &&\n thinking?.type !== 'disabled' &&\n (thinking != null || capabilities.reasoning.enabledByDefault);\n\n if (isThinkingEnabled && temperature != null) {\n allWarnings.push({\n type: 'unsupported',\n feature: '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',\n feature: '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 : isCustomReasoning(reasoning) && reasoning !== 'none'\n ? mapReasoningToProviderEffort({\n reasoning,\n effortMap: { low: 'low', high: 'high', max: 'max' },\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, ...toolWarnings],\n };\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\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(\n await resolve(this.config.headers),\n options.headers,\n ),\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 if (choice == null) {\n throw new InvalidResponseDataError({\n data: rawResponse,\n message: 'Response did not contain any choices.',\n });\n }\n\n const content: Array<LanguageModelV4Content> = [];\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 return {\n content,\n finishReason: {\n unified: mapDeepSeekFinishReason(choice.finish_reason),\n raw: choice.finish_reason ?? undefined,\n },\n usage: convertDeepSeekUsage(responseBody.usage),\n providerMetadata: {\n [this.providerOptionsName]: {\n promptCacheHitTokens: responseBody.usage?.prompt_cache_hit_tokens,\n promptCacheMissTokens: responseBody.usage?.prompt_cache_miss_tokens,\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: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\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(\n await resolve(this.config.headers),\n options.headers,\n ),\n body,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n deepseekChatChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n let toolCallTracker: StreamingToolCallTracker;\n\n // A clean end without the provider's completion signal is interrupted.\n let finishReason: LanguageModelV4FinishReason = {\n unified: 'interrupted',\n raw: undefined,\n };\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 LanguageModelV4StreamPart\n >({\n start(controller) {\n toolCallTracker = new StreamingToolCallTracker(controller, {\n generateId,\n });\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 = { unified: 'error', raw: undefined };\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 = { unified: 'error', raw: undefined };\n controller.enqueue({\n type: 'error',\n error: createDeepSeekStreamError(value.error, value),\n });\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 = {\n unified: mapDeepSeekFinishReason(choice.finish_reason),\n raw: choice.finish_reason,\n };\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 toolCallTracker.processDelta(toolCallDelta);\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 toolCallTracker.flush();\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage: convertDeepSeekUsage(usage),\n providerMetadata: {\n [providerOptionsName]: {\n promptCacheHitTokens:\n usage?.prompt_cache_hit_tokens ?? undefined,\n promptCacheMissTokens:\n usage?.prompt_cache_miss_tokens ?? undefined,\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 { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const deepSeekFilesResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string(),\n // These fields are required by DeepSeek's OpenAPI schema, but they are\n // not needed to construct the provider reference. Keep them nullish so\n // uploads remain resilient to incomplete responses while validating any\n // returned values precisely enough to avoid misleading metadata.\n object: z.literal('file').nullish(),\n bytes: z.number().int().nonnegative().nullish(),\n created_at: z.number().int().nonnegative().nullish(),\n filename: z.string().nullish(),\n purpose: z.literal('user_data').nullish(),\n expires_at: z.number().int().nonnegative().nullish(),\n }),\n ),\n);\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const deepSeekFilesOptionsSchema = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * Number of seconds after creation before the file expires.\n * Must be between 1 hour and 30 days.\n */\n expiresAfter: z.number().int().min(3600).max(2592000).optional(),\n }),\n ),\n);\n\nexport type DeepSeekFilesOptions = InferSchema<\n typeof deepSeekFilesOptionsSchema\n>;\n","import {\n InvalidArgumentError,\n type FilesV4,\n type FilesV4UploadFileCallOptions,\n type FilesV4UploadFileResult,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolve,\n combineHeaders,\n convertInlineFileDataToUint8Array,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n detectMediaType,\n parseProviderOptions,\n postFormDataToApi,\n type FetchFunction,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { deepSeekErrorSchema } from '../chat/deepseek-chat-api-types';\nimport { deepSeekFilesResponseSchema } from './deepseek-files-api';\nimport {\n deepSeekFilesOptionsSchema,\n type DeepSeekFilesOptions,\n} from './deepseek-files-options';\n\ninterface DeepSeekFilesConfig {\n provider: string;\n baseURL: string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n}\n\nconst deepSeekFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: deepSeekErrorSchema,\n errorToMessage: (error: InferSchema<typeof deepSeekErrorSchema>) =>\n error.error.message,\n});\n\nconst MAX_FILE_SIZE_BYTES = 64 * 1024 * 1024;\nconst MAX_FILENAME_LENGTH = 512;\n\nconst supportedMediaTypes = new Set([\n 'image/gif',\n 'image/jpeg',\n 'image/jpg',\n 'image/png',\n 'image/webp',\n]);\n\nconst genericMediaTypes = new Set([\n '',\n 'application/binary',\n 'application/octet-stream',\n 'binary/octet-stream',\n 'image',\n 'image/*',\n]);\n\nconst supportedFilenameExtensions = new Set([\n 'gif',\n 'jpeg',\n 'jpg',\n 'png',\n 'webp',\n]);\n\nexport class DeepSeekFiles implements FilesV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(private readonly config: DeepSeekFilesConfig) {}\n\n async uploadFile({\n data,\n mediaType,\n filename,\n abortSignal,\n headers,\n providerOptions,\n }: FilesV4UploadFileCallOptions): Promise<FilesV4UploadFileResult> {\n const deepSeekOptions = (await parseProviderOptions({\n provider: 'deepseek',\n providerOptions,\n schema: deepSeekFilesOptionsSchema,\n })) as DeepSeekFilesOptions | undefined;\n\n const fileBytes = convertInlineFileDataToUint8Array(data);\n validateFileUpload({ fileBytes, mediaType, filename });\n\n const blob = new Blob([fileBytes as Uint8Array<ArrayBuffer>], {\n type: mediaType,\n });\n\n const formData = new FormData();\n if (filename != null) {\n formData.append('file', blob, filename);\n } else {\n formData.append('file', blob);\n }\n formData.append('purpose', 'user_data');\n\n if (deepSeekOptions?.expiresAfter != null) {\n formData.append('expires_after[anchor]', 'created_at');\n formData.append(\n 'expires_after[seconds]',\n String(deepSeekOptions.expiresAfter),\n );\n }\n\n const { value: response } = await postFormDataToApi({\n url: `${this.config.baseURL}/files`,\n headers: combineHeaders(await resolve(this.config.headers), headers),\n formData,\n failedResponseHandler: deepSeekFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepSeekFilesResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n warnings: [],\n providerReference: { deepseek: response.id },\n ...((response.filename ?? filename)\n ? { filename: response.filename ?? filename }\n : {}),\n ...(mediaType != null ? { mediaType } : {}),\n providerMetadata: {\n deepseek: {\n ...(response.object != null ? { object: response.object } : {}),\n ...(response.filename != null ? { filename: response.filename } : {}),\n ...(response.purpose != null ? { purpose: response.purpose } : {}),\n ...(response.bytes != null ? { bytes: response.bytes } : {}),\n ...(response.created_at != null\n ? { createdAt: response.created_at }\n : {}),\n ...(response.expires_at != null\n ? { expiresAt: response.expires_at }\n : {}),\n },\n },\n };\n }\n}\n\nfunction validateFileUpload({\n fileBytes,\n mediaType,\n filename,\n}: {\n fileBytes: Uint8Array;\n mediaType: string;\n filename: string | undefined;\n}) {\n if (fileBytes.length > MAX_FILE_SIZE_BYTES) {\n throw new InvalidArgumentError({\n argument: 'data',\n message:\n `DeepSeek file uploads must not exceed 64 MiB ` +\n `(${MAX_FILE_SIZE_BYTES.toLocaleString('en-US')} bytes). ` +\n `Received ${fileBytes.length.toLocaleString('en-US')} bytes.`,\n });\n }\n\n if (filename != null) {\n const filenameLength = Array.from(filename).length;\n\n if (filenameLength > MAX_FILENAME_LENGTH) {\n throw new InvalidArgumentError({\n argument: 'filename',\n message:\n `DeepSeek filenames must not exceed ${MAX_FILENAME_LENGTH} characters. ` +\n `Received ${filenameLength} characters.`,\n });\n }\n }\n\n const normalizedMediaType = normalizeMediaType(mediaType);\n const detectedMediaType = detectMediaType({ data: fileBytes });\n\n if (\n detectedMediaType != null &&\n !supportedMediaTypes.has(detectedMediaType)\n ) {\n throw new InvalidArgumentError({\n argument: 'data',\n message:\n `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +\n `Detected unsupported file content type \"${detectedMediaType}\".`,\n });\n }\n\n if (supportedMediaTypes.has(normalizedMediaType)) {\n return;\n }\n\n if (!genericMediaTypes.has(normalizedMediaType)) {\n throw new InvalidArgumentError({\n argument: 'mediaType',\n message:\n `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +\n `Received unsupported media type \"${mediaType}\".`,\n });\n }\n\n if (detectedMediaType != null || hasSupportedFilenameExtension(filename)) {\n return;\n }\n\n throw new InvalidArgumentError({\n argument: 'mediaType',\n message:\n `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +\n `Provide a supported media type or a filename ending in ` +\n `.jpg, .jpeg, .png, .gif, or .webp. Received \"${mediaType}\".`,\n });\n}\n\nfunction normalizeMediaType(mediaType: string): string {\n return mediaType.split(';', 1)[0].trim().toLowerCase();\n}\n\nfunction hasSupportedFilenameExtension(filename: string | undefined): boolean {\n if (filename == null) {\n return false;\n }\n\n const extensionSeparatorIndex = filename.lastIndexOf('.');\n\n return (\n extensionSeparatorIndex !== -1 &&\n supportedFilenameExtensions.has(\n filename.slice(extensionSeparatorIndex + 1).toLowerCase(),\n )\n );\n}\n","import {\n InvalidPromptError,\n UnsupportedFunctionalityError,\n type LanguageModelV4FilePart,\n type LanguageModelV4Prompt,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n convertToBase64,\n getTopLevelMediaType,\n parseProviderOptions,\n resolveFullMediaType,\n resolveProviderReference,\n} from '@ai-sdk/provider-utils';\nimport { deepseekFilePartProviderOptions } from '../chat/deepseek-file-part-options';\nimport type {\n DeepSeekResponsesInput,\n DeepSeekResponsesInputContentPart,\n} from './deepseek-responses-api';\n\nexport async function convertToDeepSeekResponsesInput({\n prompt,\n providerOptionsName,\n}: {\n prompt: LanguageModelV4Prompt;\n providerOptionsName: string;\n}): Promise<{\n input: DeepSeekResponsesInput;\n inputWarnings: SharedV4Warning[];\n}> {\n const input: DeepSeekResponsesInput = [];\n const inputWarnings: SharedV4Warning[] = [];\n\n for (const message of prompt) {\n switch (message.role) {\n case 'system': {\n input.push({ role: 'system', content: message.content });\n break;\n }\n\n case 'user': {\n const content: Array<DeepSeekResponsesInputContentPart> = [];\n\n for (const part of message.content) {\n if (part.type === 'text') {\n content.push({ type: 'input_text', text: part.text });\n } else if (\n part.type === 'file' &&\n getTopLevelMediaType(part.mediaType) === 'image' &&\n part.data.type !== 'text'\n ) {\n content.push(\n await convertImagePart({ part, prompt, providerOptionsName }),\n );\n } else {\n inputWarnings.push({\n type: 'unsupported',\n feature: `user message part type: ${part.type}`,\n });\n }\n }\n\n input.push({ role: 'user', content });\n break;\n }\n\n case 'assistant': {\n for (const part of message.content) {\n switch (part.type) {\n case 'text': {\n if (part.text.length > 0) {\n input.push({ role: 'assistant', content: part.text });\n }\n break;\n }\n\n case 'reasoning': {\n const itemId = getStringOption(\n part.providerOptions?.[providerOptionsName]?.itemId,\n );\n input.push({\n type: 'reasoning',\n ...(itemId != null && { id: itemId }),\n content: [{ type: 'reasoning_text', text: part.text }],\n });\n break;\n }\n\n case 'tool-call': {\n if (part.providerExecuted) {\n const webSearchCall =\n part.providerOptions?.[providerOptionsName]?.webSearchCall;\n if (isWebSearchCallItem(webSearchCall)) {\n input.push(webSearchCall);\n }\n break;\n }\n\n input.push({\n type: 'function_call',\n call_id: part.toolCallId,\n name: part.toolName,\n arguments:\n typeof part.input === 'string'\n ? part.input\n : JSON.stringify(part.input),\n });\n break;\n }\n\n case 'tool-result': {\n break;\n }\n\n default: {\n inputWarnings.push({\n type: 'unsupported',\n feature: `assistant message part type: ${part.type}`,\n });\n }\n }\n }\n break;\n }\n\n case 'tool': {\n for (const part of message.content) {\n if (part.type === 'tool-approval-response') {\n continue;\n }\n\n const output = part.output;\n let value: string | Array<DeepSeekResponsesInputContentPart>;\n\n switch (output.type) {\n case 'text':\n case 'error-text':\n value = output.value;\n break;\n case 'execution-denied':\n value = output.reason ?? 'Tool call execution denied.';\n break;\n case 'json':\n case 'error-json':\n value = JSON.stringify(output.value);\n break;\n case 'content': {\n value = [];\n for (const item of output.value) {\n if (item.type === 'text') {\n value.push({ type: 'input_text', text: item.text });\n } else if (\n item.type === 'file' &&\n getTopLevelMediaType(item.mediaType) === 'image' &&\n item.data.type !== 'text'\n ) {\n value.push(\n await convertImagePart({\n part: item,\n prompt,\n providerOptionsName,\n }),\n );\n } else {\n inputWarnings.push({\n type: 'unsupported',\n feature: `tool result content part type: ${item.type}`,\n });\n }\n }\n break;\n }\n }\n\n input.push({\n type: 'function_call_output',\n call_id: part.toolCallId,\n output: value,\n });\n }\n break;\n }\n }\n }\n\n return { input, inputWarnings };\n}\n\nconst supportedImageMediaTypes = new Set([\n 'image/gif',\n 'image/jpeg',\n 'image/jpg',\n 'image/png',\n 'image/webp',\n]);\n\nasync function convertImagePart({\n part,\n prompt,\n providerOptionsName,\n}: {\n part: LanguageModelV4FilePart;\n prompt: LanguageModelV4Prompt;\n providerOptionsName: string;\n}): Promise<DeepSeekResponsesInputContentPart> {\n if (part.data.type === 'reference') {\n return {\n type: 'input_image',\n file_id: resolveProviderReference({\n reference: part.data.reference,\n provider: 'deepseek',\n }),\n };\n }\n\n const filePartOptions = await parseProviderOptions({\n provider: providerOptionsName,\n providerOptions: part.providerOptions,\n schema: deepseekFilePartProviderOptions,\n });\n\n if (filePartOptions?.fileData === true) {\n throw new UnsupportedFunctionalityError({\n functionality: 'DeepSeek `fileData` image parts with the Responses API',\n });\n }\n\n const detail = filePartOptions?.imageDetail;\n\n if (part.data.type === 'url') {\n const url = part.data.url.toString();\n if (url.length > 8192) {\n throw new InvalidPromptError({\n prompt,\n message: 'DeepSeek image URLs must not exceed 8192 characters.',\n });\n }\n return {\n type: 'input_image',\n image_url: url,\n ...(detail != null && { detail }),\n };\n }\n\n if (part.data.type !== 'data') {\n throw new UnsupportedFunctionalityError({\n functionality: `DeepSeek image data type ${part.data.type}`,\n });\n }\n\n const mediaType = resolveFullMediaType({ part });\n if (!supportedImageMediaTypes.has(mediaType)) {\n throw new UnsupportedFunctionalityError({\n functionality: `DeepSeek image media type ${mediaType}`,\n message: 'DeepSeek supports JPEG, PNG, GIF, and WebP image inputs.',\n });\n }\n\n return {\n type: 'input_image',\n image_url: `data:${mediaType === 'image/jpg' ? 'image/jpeg' : mediaType};base64,${convertToBase64(part.data.data)}`,\n ...(detail != null && { detail }),\n };\n}\n\nfunction getStringOption(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction isWebSearchCallItem(\n value: unknown,\n): value is { type: 'web_search_call' } & Record<string, unknown> {\n return (\n typeof value === 'object' &&\n value != null &&\n !Array.isArray(value) &&\n (value as { type?: unknown }).type === 'web_search_call'\n );\n}\n","import type { LanguageModelV4Usage } from '@ai-sdk/provider';\nimport { createNullLanguageModelUsage } from '@ai-sdk/provider-utils';\nimport type { DeepSeekResponsesUsage } from './deepseek-responses-api';\n\nexport function convertDeepSeekResponsesUsage(\n usage: DeepSeekResponsesUsage | null | undefined,\n): LanguageModelV4Usage {\n if (usage == null) {\n return createNullLanguageModelUsage();\n }\n\n const inputTokens = usage.input_tokens ?? 0;\n const outputTokens = usage.output_tokens ?? 0;\n const cacheReadTokens = usage.input_tokens_details?.cached_tokens ?? 0;\n const reasoningTokens = usage.output_tokens_details?.reasoning_tokens ?? 0;\n\n return {\n inputTokens: {\n total: inputTokens,\n noCache: inputTokens - cacheReadTokens,\n cacheRead: cacheReadTokens,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: outputTokens,\n text: Math.max(0, outputTokens - reasoningTokens),\n reasoning: reasoningTokens,\n },\n raw: usage,\n };\n}\n\nexport function getDeepSeekServerToolUse(\n usage: DeepSeekResponsesUsage | null | undefined,\n): { toolSearch: number; toolFetch: number } | undefined {\n const serverToolUse = usage?.server_tool_use;\n if (serverToolUse == null) {\n return undefined;\n }\n return {\n toolSearch: serverToolUse.tool_search ?? 0,\n toolFetch: serverToolUse.tool_fetch ?? 0,\n };\n}\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport type DeepSeekResponsesInput = Array<DeepSeekResponsesInputItem>;\n\nexport type DeepSeekResponsesInputItem =\n | { role: 'system' | 'assistant'; content: string }\n | { role: 'user'; content: Array<DeepSeekResponsesInputContentPart> }\n | {\n type: 'function_call';\n call_id: string;\n name: string;\n arguments: string;\n }\n | {\n type: 'function_call_output';\n call_id: string;\n output: string | Array<DeepSeekResponsesInputContentPart>;\n }\n | {\n type: 'reasoning';\n id?: string;\n content: Array<{ type: 'reasoning_text'; text: string }>;\n }\n | ({ type: 'web_search_call' } & Record<string, unknown>);\n\nexport type DeepSeekResponsesInputContentPart =\n | { type: 'input_text'; text: string }\n | {\n type: 'input_image';\n image_url?: string;\n file_id?: string;\n detail?: 'low' | 'high' | 'original' | 'auto';\n };\n\nexport type DeepSeekResponsesTool =\n | {\n type: 'function';\n name: string;\n description?: string;\n parameters: unknown;\n }\n | { type: 'web_search' };\n\nexport type DeepSeekResponsesToolChoice =\n | 'auto'\n | 'none'\n | 'required'\n | { type: 'function'; name: string };\n\nexport type DeepSeekResponsesUsage = z.infer<\n ReturnType<typeof createUsageSchema>\n>;\n\nexport type DeepSeekResponsesOutputItem = z.infer<\n ReturnType<typeof createOutputItemSchema>\n>;\n\nexport type DeepSeekResponsesChunk = z.infer<\n ReturnType<typeof createChunkSchema>\n>;\n\nexport const deepseekResponsesResponseSchema = lazySchema(() =>\n zodSchema(createResponseSchema()),\n);\n\nexport const deepseekResponsesChunkSchema = lazySchema(() =>\n zodSchema(createChunkSchema()),\n);\n\nfunction createUsageSchema() {\n return z.object({\n input_tokens: z.number().nullish(),\n input_tokens_details: z\n .object({ cached_tokens: z.number().nullish() })\n .nullish(),\n output_tokens: z.number().nullish(),\n output_tokens_details: z\n .object({ reasoning_tokens: z.number().nullish() })\n .nullish(),\n total_tokens: z.number().nullish(),\n server_tool_use: z\n .object({\n tool_search: z.number().nullish(),\n tool_fetch: z.number().nullish(),\n })\n .nullish(),\n });\n}\n\nfunction createLogprobSchema() {\n return z.object({\n token: z.string(),\n logprob: z.number(),\n bytes: z.array(z.number()).nullish(),\n top_logprobs: z\n .array(\n z.object({\n token: z.string(),\n logprob: z.number(),\n bytes: z.array(z.number()).nullish(),\n }),\n )\n .nullish(),\n });\n}\n\nfunction createOutputItemSchema() {\n return z.union([\n z.object({\n type: z.literal('message'),\n id: z.string().nullish(),\n content: z\n .array(\n z.object({\n type: z.string(),\n text: z.string().nullish(),\n logprobs: z.array(createLogprobSchema()).nullish(),\n }),\n )\n .nullish(),\n }),\n z.object({\n type: z.literal('reasoning'),\n id: z.string().nullish(),\n content: z\n .array(z.object({ type: z.string(), text: z.string().nullish() }))\n .nullish(),\n }),\n z.object({\n type: z.literal('function_call'),\n id: z.string().nullish(),\n call_id: z.string(),\n name: z.string(),\n arguments: z.string().nullish(),\n }),\n z.looseObject({\n type: z.literal('web_search_call'),\n id: z.string(),\n status: z.string().nullish(),\n action: z.record(z.string(), z.unknown()).nullish(),\n }),\n z.looseObject({ type: z.string() }),\n ]);\n}\n\nfunction createResponseObjectSchema() {\n return z.object({\n id: z.string().nullish(),\n created_at: z.number().nullish(),\n model: z.string().nullish(),\n status: z.string().nullish(),\n error: z\n .object({\n code: z.string().nullish(),\n message: z.string().nullish(),\n })\n .nullish(),\n incomplete_details: z.object({ reason: z.string().nullish() }).nullish(),\n output: z.array(createOutputItemSchema()).nullish(),\n usage: createUsageSchema().nullish(),\n });\n}\n\nfunction createResponseSchema() {\n return createResponseObjectSchema();\n}\n\nfunction createChunkSchema() {\n const responseObject = createResponseObjectSchema();\n const outputItem = createOutputItemSchema();\n\n return z.union([\n z.object({\n type: z.enum(['response.created', 'response.in_progress']),\n response: responseObject,\n }),\n z.object({\n type: z.enum([\n 'response.completed',\n 'response.incomplete',\n 'response.failed',\n ]),\n response: responseObject,\n }),\n z.object({\n type: z.enum(['response.output_item.added', 'response.output_item.done']),\n output_index: z.number().nullish(),\n item: outputItem,\n }),\n z.object({\n type: z.literal('response.output_text.delta'),\n item_id: z.string(),\n delta: z.string(),\n logprobs: z.array(createLogprobSchema()).nullish(),\n }),\n z.object({\n type: z.literal('response.reasoning_text.delta'),\n item_id: z.string(),\n delta: z.string(),\n }),\n z.object({\n type: z.literal('response.function_call_arguments.delta'),\n item_id: z.string(),\n delta: z.string(),\n }),\n z.object({\n type: z.literal('error'),\n code: z.string().nullish(),\n message: z.string().nullish(),\n }),\n z.looseObject({ type: z.string() }),\n ]);\n}\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { DeepSeekModelIds } from '../deepseek-model-catalog';\n\n// https://api-docs.deepseek.com/api/create-response\nexport type DeepSeekResponsesModelId =\n | DeepSeekModelIds['responses']\n | (string & {});\n\nexport const deepseekLanguageModelResponsesOptions = lazySchema(() =>\n zodSchema(\n z.object({\n thinking: z\n .object({ type: z.enum(['enabled', 'disabled']).optional() })\n .optional(),\n reasoningEffort: z.enum(['low', 'high', 'max']).optional(),\n topLogprobs: z.number().int().min(0).max(20).optional(),\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);\n\nexport type DeepSeekLanguageModelResponsesOptions = {\n /**\n * Controls whether thinking mode is enabled. Thinking is enabled by default.\n */\n thinking?: {\n type?: 'enabled' | 'disabled';\n };\n\n /**\n * Controls the thinking strength when thinking is enabled.\n */\n reasoningEffort?: 'low' | 'high' | 'max';\n\n /**\n * Number of most likely tokens to return at each token position (0 to 20).\n * Log probabilities are returned in `providerMetadata.deepseek.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","import type {\n LanguageModelV4CallOptions,\n SharedV4Warning,\n} from '@ai-sdk/provider';\nimport type {\n DeepSeekResponsesTool,\n DeepSeekResponsesToolChoice,\n} from './deepseek-responses-api';\n\nexport function prepareDeepSeekResponsesTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n toolChoice?: LanguageModelV4CallOptions['toolChoice'];\n}): {\n tools: Array<DeepSeekResponsesTool> | undefined;\n toolChoice: DeepSeekResponsesToolChoice | undefined;\n toolWarnings: SharedV4Warning[];\n} {\n const toolWarnings: SharedV4Warning[] = [];\n\n if (tools == null || tools.length === 0) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const deepseekTools: Array<DeepSeekResponsesTool> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider') {\n if (tool.id === 'deepseek.web_search') {\n deepseekTools.push({ type: 'web_search' });\n } else {\n toolWarnings.push({\n type: 'unsupported',\n feature: `provider-defined tool ${tool.id}`,\n });\n }\n continue;\n }\n\n if (tool.strict != null) {\n toolWarnings.push({\n type: 'unsupported',\n feature: 'strict tool calls',\n details: 'The DeepSeek Responses API does not support strict mode.',\n });\n }\n\n deepseekTools.push({\n type: 'function',\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n });\n }\n\n if (toolChoice == null) {\n return { tools: deepseekTools, toolChoice: undefined, toolWarnings };\n }\n\n switch (toolChoice.type) {\n case 'auto':\n case 'none':\n case 'required':\n return {\n tools: deepseekTools,\n toolChoice: toolChoice.type,\n toolWarnings,\n };\n case 'tool': {\n const selected = tools.find(tool => tool.name === toolChoice.toolName);\n if (selected?.type === 'provider') {\n toolWarnings.push({\n type: 'unsupported',\n feature: `toolChoice for provider-defined tool ${selected.id}`,\n });\n return { tools: deepseekTools, toolChoice: undefined, toolWarnings };\n }\n return {\n tools: deepseekTools,\n toolChoice: { type: 'function', name: toolChoice.toolName },\n toolWarnings,\n };\n }\n }\n}\n","import type { LanguageModelV4FinishReason } from '@ai-sdk/provider';\n\nexport function mapDeepSeekResponsesFinishReason({\n status,\n incompleteReason,\n hasFunctionCall,\n}: {\n status: string | null | undefined;\n incompleteReason: string | null | undefined;\n hasFunctionCall: boolean;\n}): LanguageModelV4FinishReason['unified'] {\n switch (status) {\n case 'completed':\n return hasFunctionCall ? 'tool-calls' : 'stop';\n case 'incomplete':\n return incompleteReason === 'max_output_tokens'\n ? 'length'\n : incompleteReason === 'content_filter'\n ? 'content-filter'\n : 'other';\n case 'failed':\n return 'error';\n default:\n return 'other';\n }\n}\n","import {\n APICallError,\n type JSONObject,\n type LanguageModelV4,\n type LanguageModelV4CallOptions,\n type LanguageModelV4Content,\n type LanguageModelV4FinishReason,\n type LanguageModelV4GenerateResult,\n type LanguageModelV4StreamPart,\n type LanguageModelV4StreamResult,\n type SharedV4ProviderMetadata,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolve,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n createLanguageModelResponseMetadata,\n createProviderStreamError,\n isCustomReasoning,\n mapReasoningToProviderEffort,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n type InferSchema,\n type ParseResult,\n type ResponseHandler,\n} from '@ai-sdk/provider-utils';\nimport { deepSeekErrorSchema } from '../chat/deepseek-chat-api-types';\nimport { convertToDeepSeekResponsesInput } from './convert-to-deepseek-responses-input';\nimport {\n convertDeepSeekResponsesUsage,\n getDeepSeekServerToolUse,\n} from './convert-deepseek-responses-usage';\nimport {\n deepseekResponsesChunkSchema,\n deepseekResponsesResponseSchema,\n type DeepSeekResponsesOutputItem,\n type DeepSeekResponsesUsage,\n} from './deepseek-responses-api';\nimport {\n deepseekLanguageModelResponsesOptions,\n type DeepSeekResponsesModelId,\n} from './deepseek-responses-language-model-options';\nimport { prepareDeepSeekResponsesTools } from './deepseek-responses-prepare-tools';\nimport { mapDeepSeekResponsesFinishReason } from './map-deepseek-responses-finish-reason';\n\nexport type DeepSeekResponsesConfig = {\n provider: string;\n headers?: Resolvable<Record<string, string | undefined>>;\n url: (options: { modelId: string; path: string }) => string;\n fetch?: FetchFunction;\n};\n\nexport class DeepSeekResponsesLanguageModel implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly modelId: DeepSeekResponsesModelId;\n\n readonly supportedUrls = {\n 'image/*': [/^https?:\\/\\/.*$/],\n };\n\n private readonly config: DeepSeekResponsesConfig;\n private readonly failedResponseHandler: ResponseHandler<APICallError>;\n\n static [WORKFLOW_SERIALIZE](model: DeepSeekResponsesLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: DeepSeekResponsesModelId;\n config: DeepSeekResponsesConfig;\n }) {\n return new DeepSeekResponsesLanguageModel(options.modelId, options.config);\n }\n\n constructor(\n modelId: DeepSeekResponsesModelId,\n config: DeepSeekResponsesConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\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 stopSequences,\n seed,\n responseFormat,\n providerOptions,\n tools,\n toolChoice,\n reasoning,\n }: LanguageModelV4CallOptions) {\n const warnings: SharedV4Warning[] = [];\n\n const deepseekOptions =\n (await parseProviderOptions({\n provider: this.providerOptionsName,\n providerOptions,\n schema: deepseekLanguageModelResponsesOptions,\n })) ?? {};\n\n if (topK != null) {\n warnings.push({ type: 'unsupported', feature: 'topK' });\n }\n if (seed != null) {\n warnings.push({ type: 'unsupported', feature: 'seed' });\n }\n if (frequencyPenalty != null) {\n warnings.push({ type: 'unsupported', feature: 'frequencyPenalty' });\n }\n if (presencePenalty != null) {\n warnings.push({ type: 'unsupported', feature: 'presencePenalty' });\n }\n if (stopSequences != null && stopSequences.length > 0) {\n warnings.push({ type: 'unsupported', feature: 'stopSequences' });\n }\n\n const { input, inputWarnings } = await convertToDeepSeekResponsesInput({\n prompt,\n providerOptionsName: this.providerOptionsName,\n });\n warnings.push(...inputWarnings);\n\n const {\n tools: deepseekTools,\n toolChoice: deepseekToolChoice,\n toolWarnings,\n } = prepareDeepSeekResponsesTools({ tools, toolChoice });\n warnings.push(...toolWarnings);\n\n const webSearchToolName = tools?.find(\n tool => tool.type === 'provider' && tool.id === 'deepseek.web_search',\n )?.name;\n\n const effort =\n deepseekOptions.thinking?.type === 'disabled'\n ? 'none'\n : (deepseekOptions.reasoningEffort ??\n (isCustomReasoning(reasoning)\n ? reasoning === 'none'\n ? 'none'\n : mapReasoningToProviderEffort({\n reasoning,\n effortMap: {\n minimal: 'low',\n low: 'low',\n medium: 'high',\n high: 'high',\n xhigh: 'max',\n max: 'max',\n },\n warnings,\n })\n : undefined));\n\n return {\n args: {\n model: this.modelId,\n input,\n max_output_tokens: maxOutputTokens,\n temperature,\n top_p: topP,\n ...(deepseekOptions.topLogprobs != null && {\n top_logprobs: deepseekOptions.topLogprobs,\n }),\n ...(effort != null && { reasoning: { effort } }),\n ...(responseFormat?.type === 'json' && {\n text: {\n format:\n responseFormat.schema != null\n ? {\n type: 'json_schema',\n name: responseFormat.name ?? 'response',\n schema: responseFormat.schema,\n }\n : { type: 'json_object' },\n },\n }),\n tools: deepseekTools,\n tool_choice: deepseekToolChoice,\n ...(deepseekOptions.userId != null && { user: deepseekOptions.userId }),\n },\n warnings,\n webSearchToolName,\n };\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\n const { args, warnings, webSearchToolName } = await this.getArgs(options);\n const providerOptionsName = this.providerOptionsName;\n const url = this.config.url({ path: '/responses', modelId: this.modelId });\n\n const {\n responseHeaders,\n value: response,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n body: args,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepseekResponsesResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n if (response.status === 'failed' || response.error != null) {\n throw new APICallError({\n message: response.error?.message ?? 'DeepSeek response failed',\n url,\n requestBodyValues: args,\n responseHeaders,\n responseBody: JSON.stringify(rawResponse),\n data: rawResponse,\n ...getFailedResponseStatus(response.error?.code),\n });\n }\n\n const content: Array<LanguageModelV4Content> = [];\n const logprobs: unknown[] = [];\n let hasFunctionCall = false;\n\n for (const item of response.output ?? []) {\n switch (item.type) {\n case 'reasoning': {\n const reasoning = item as ReasoningItem;\n const text = joinText(reasoning.content);\n content.push({\n type: 'reasoning',\n text,\n ...(reasoning.id != null && {\n providerMetadata: {\n [providerOptionsName]: { itemId: reasoning.id },\n },\n }),\n });\n break;\n }\n\n case 'message': {\n const message = item as MessageItem;\n for (const part of message.content ?? []) {\n if (part.logprobs != null) {\n logprobs.push(...part.logprobs);\n }\n if (part.text != null && part.text.length > 0) {\n content.push({ type: 'text', text: part.text });\n }\n }\n break;\n }\n\n case 'function_call': {\n const call = item as FunctionCallItem;\n hasFunctionCall = true;\n content.push({\n type: 'tool-call',\n toolCallId: call.call_id,\n toolName: call.name,\n input: call.arguments ?? '',\n });\n break;\n }\n\n case 'web_search_call': {\n content.push(\n ...webSearchCallContent({\n item: item as WebSearchCallItem,\n toolName: webSearchToolName ?? 'web_search',\n providerOptionsName,\n }),\n );\n break;\n }\n }\n }\n\n return {\n content,\n finishReason: {\n unified: mapDeepSeekResponsesFinishReason({\n status: response.status,\n incompleteReason: response.incomplete_details?.reason,\n hasFunctionCall,\n }),\n raw:\n response.incomplete_details?.reason ?? response.status ?? undefined,\n },\n usage: convertDeepSeekResponsesUsage(response.usage),\n providerMetadata: buildProviderMetadata({\n providerOptionsName,\n responseId: response.id,\n usage: response.usage,\n logprobs,\n }),\n request: { body: args },\n response: {\n ...createLanguageModelResponseMetadata({\n id: response.id,\n model: response.model,\n created: response.created_at,\n }),\n headers: responseHeaders,\n body: rawResponse,\n },\n warnings,\n };\n }\n\n async doStream(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\n const { args, warnings, webSearchToolName } = await this.getArgs(options);\n const providerOptionsName = this.providerOptionsName;\n const body = { ...args, stream: true };\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: this.config.url({ path: '/responses', modelId: this.modelId }),\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n body,\n failedResponseHandler: this.failedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n deepseekResponsesChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n let finishReason: LanguageModelV4FinishReason = {\n unified: 'interrupted',\n raw: undefined,\n };\n let usage: DeepSeekResponsesUsage | null | undefined;\n let responseId: string | null | undefined;\n let hasFunctionCall = false;\n const logprobs: unknown[] = [];\n const openText = new Set<string>();\n const openReasoning = new Set<string>();\n const functionCalls = new Map<\n string,\n { callId: string; toolName: string; arguments: string }\n >();\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<InferSchema<typeof deepseekResponsesChunkSchema>>,\n LanguageModelV4StreamPart\n >({\n start(controller) {\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n if (!chunk.success) {\n finishReason = { unified: 'error', raw: undefined };\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n\n const value = chunk.value as StreamChunk;\n\n switch (value.type) {\n case 'response.created': {\n const created = value as ResponseChunk;\n responseId = created.response.id;\n controller.enqueue({\n type: 'response-metadata',\n ...createLanguageModelResponseMetadata({\n id: created.response.id,\n model: created.response.model,\n created: created.response.created_at,\n }),\n });\n return;\n }\n\n case 'response.output_item.added': {\n const item = (value as OutputItemChunk).item;\n const itemId = getItemId(item);\n if (item.type === 'message' && itemId != null) {\n openText.add(itemId);\n controller.enqueue({ type: 'text-start', id: itemId });\n } else if (item.type === 'reasoning' && itemId != null) {\n openReasoning.add(itemId);\n controller.enqueue({\n type: 'reasoning-start',\n id: itemId,\n providerMetadata: {\n [providerOptionsName]: { itemId },\n },\n });\n } else if (item.type === 'function_call') {\n const call = item as FunctionCallItem;\n functionCalls.set(call.id ?? call.call_id, {\n callId: call.call_id,\n toolName: call.name,\n arguments: call.arguments ?? '',\n });\n controller.enqueue({\n type: 'tool-input-start',\n id: call.call_id,\n toolName: call.name,\n });\n }\n return;\n }\n\n case 'response.output_text.delta': {\n const delta = value as TextDeltaChunk;\n if (delta.logprobs != null) {\n logprobs.push(...delta.logprobs);\n }\n if (!openText.has(delta.item_id)) {\n openText.add(delta.item_id);\n controller.enqueue({ type: 'text-start', id: delta.item_id });\n }\n controller.enqueue({\n type: 'text-delta',\n id: delta.item_id,\n delta: delta.delta,\n });\n return;\n }\n\n case 'response.reasoning_text.delta': {\n const delta = value as TextDeltaChunk;\n if (!openReasoning.has(delta.item_id)) {\n openReasoning.add(delta.item_id);\n controller.enqueue({\n type: 'reasoning-start',\n id: delta.item_id,\n providerMetadata: {\n [providerOptionsName]: { itemId: delta.item_id },\n },\n });\n }\n controller.enqueue({\n type: 'reasoning-delta',\n id: delta.item_id,\n delta: delta.delta,\n });\n return;\n }\n\n case 'response.function_call_arguments.delta': {\n const delta = value as TextDeltaChunk;\n const call = functionCalls.get(delta.item_id);\n if (call == null) {\n return;\n }\n call.arguments += delta.delta;\n controller.enqueue({\n type: 'tool-input-delta',\n id: call.callId,\n delta: delta.delta,\n });\n return;\n }\n\n case 'response.output_item.done': {\n const item = (value as OutputItemChunk).item;\n const itemId = getItemId(item);\n if (item.type === 'message' && itemId != null) {\n if (openText.delete(itemId)) {\n controller.enqueue({ type: 'text-end', id: itemId });\n }\n } else if (item.type === 'reasoning' && itemId != null) {\n if (openReasoning.delete(itemId)) {\n controller.enqueue({\n type: 'reasoning-end',\n id: itemId,\n providerMetadata: {\n [providerOptionsName]: { itemId },\n },\n });\n }\n } else if (item.type === 'function_call') {\n const call = item as FunctionCallItem;\n const key = call.id ?? call.call_id;\n const tracked = functionCalls.get(key);\n functionCalls.delete(key);\n hasFunctionCall = true;\n if (tracked == null) {\n controller.enqueue({\n type: 'tool-input-start',\n id: call.call_id,\n toolName: call.name,\n });\n }\n controller.enqueue({\n type: 'tool-input-end',\n id: call.call_id,\n });\n controller.enqueue({\n type: 'tool-call',\n toolCallId: call.call_id,\n toolName: call.name,\n input: call.arguments ?? tracked?.arguments ?? '',\n });\n } else if (item.type === 'web_search_call') {\n for (const part of webSearchCallContent({\n item: item as WebSearchCallItem,\n toolName: webSearchToolName ?? 'web_search',\n providerOptionsName,\n })) {\n controller.enqueue(part);\n }\n }\n return;\n }\n\n case 'response.completed':\n case 'response.incomplete':\n case 'response.failed': {\n const done = value as ResponseChunk;\n usage = done.response.usage;\n responseId = done.response.id ?? responseId;\n finishReason = {\n unified: mapDeepSeekResponsesFinishReason({\n status: done.response.status,\n incompleteReason: done.response.incomplete_details?.reason,\n hasFunctionCall,\n }),\n raw:\n done.response.incomplete_details?.reason ??\n done.response.status ??\n undefined,\n };\n if (value.type === 'response.failed') {\n controller.enqueue({\n type: 'error',\n error: createProviderStreamError({\n message:\n done.response.error?.message ??\n 'DeepSeek response failed',\n type: 'response.failed',\n code: done.response.error?.code ?? undefined,\n ...getFailedResponseStatus(done.response.error?.code),\n data: value,\n }),\n });\n }\n return;\n }\n\n case 'error': {\n const error = value as ErrorChunk;\n finishReason = { unified: 'error', raw: undefined };\n controller.enqueue({\n type: 'error',\n error: createProviderStreamError({\n message: error.message ?? 'DeepSeek stream error',\n type: 'error',\n code: error.code ?? undefined,\n data: value,\n }),\n });\n }\n }\n },\n\n flush(controller) {\n for (const id of openReasoning) {\n controller.enqueue({ type: 'reasoning-end', id });\n }\n for (const id of openText) {\n controller.enqueue({ type: 'text-end', id });\n }\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage: convertDeepSeekResponsesUsage(usage),\n providerMetadata: buildProviderMetadata({\n providerOptionsName,\n responseId,\n usage,\n logprobs,\n }),\n });\n },\n }),\n ),\n request: { body },\n response: { headers: responseHeaders },\n };\n }\n}\n\ntype StreamChunk = InferSchema<typeof deepseekResponsesChunkSchema>;\n\ntype ResponseChunk = Extract<StreamChunk, { response: unknown }>;\n\ntype OutputItemChunk = Extract<StreamChunk, { item: unknown }>;\n\ntype TextDeltaChunk = Extract<\n StreamChunk,\n { type: 'response.output_text.delta' }\n>;\n\ntype ErrorChunk = Extract<StreamChunk, { type: 'error' }>;\n\ntype MessageItem = Extract<DeepSeekResponsesOutputItem, { type: 'message' }>;\n\ntype ReasoningItem = Extract<\n DeepSeekResponsesOutputItem,\n { type: 'reasoning' }\n>;\n\ntype FunctionCallItem = Extract<\n DeepSeekResponsesOutputItem,\n { type: 'function_call' }\n>;\n\ntype WebSearchCallItem = Extract<\n DeepSeekResponsesOutputItem,\n { type: 'web_search_call' }\n>;\n\nfunction getFailedResponseStatus(code: string | null | undefined): {\n statusCode: number;\n isRetryable: boolean;\n} {\n switch (code) {\n case 'rate_limit_exceeded':\n case 'rate_limit_error':\n return { statusCode: 429, isRetryable: true };\n case 'insufficient_quota':\n return { statusCode: 429, isRetryable: false };\n case 'authentication_error':\n case 'invalid_api_key':\n return { statusCode: 401, isRetryable: false };\n case 'permission_error':\n return { statusCode: 403, isRetryable: false };\n case 'bad_request':\n case 'context_length_exceeded':\n case 'invalid_request_error':\n return { statusCode: 400, isRetryable: false };\n case 'timeout':\n case 'timeout_error':\n return { statusCode: 504, isRetryable: true };\n default:\n return { statusCode: 500, isRetryable: true };\n }\n}\n\nfunction getItemId(item: DeepSeekResponsesOutputItem): string | undefined {\n return 'id' in item && typeof item.id === 'string' ? item.id : undefined;\n}\n\nfunction joinText(\n parts: Array<{ text?: string | null }> | null | undefined,\n): string {\n return (parts ?? []).map(part => part.text ?? '').join('');\n}\n\nfunction webSearchCallContent({\n item,\n toolName,\n providerOptionsName,\n}: {\n item: WebSearchCallItem;\n toolName: string;\n providerOptionsName: string;\n}): Array<\n Extract<LanguageModelV4Content, { type: 'tool-call' | 'tool-result' }>\n> {\n return [\n {\n type: 'tool-call',\n toolCallId: item.id,\n toolName,\n input: '{}',\n providerExecuted: true,\n providerMetadata: {\n [providerOptionsName]: { webSearchCall: item as JSONObject },\n },\n },\n {\n type: 'tool-result',\n toolCallId: item.id,\n toolName,\n result: {\n ...(item.status != null && { status: item.status }),\n ...(item.action != null && { action: item.action as JSONObject }),\n },\n },\n ];\n}\n\nfunction buildProviderMetadata({\n providerOptionsName,\n responseId,\n usage,\n logprobs,\n}: {\n providerOptionsName: string;\n responseId: string | null | undefined;\n usage: DeepSeekResponsesUsage | null | undefined;\n logprobs: unknown[];\n}): SharedV4ProviderMetadata {\n const serverToolUse = getDeepSeekServerToolUse(usage);\n return {\n [providerOptionsName]: {\n ...(responseId != null && { responseId }),\n ...(serverToolUse != null && { serverToolUse }),\n ...(logprobs.length > 0 && { logprobs: logprobs as JSONObject[] }),\n },\n };\n}\n","import {\n createProviderExecutedToolFactory,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const webSearchOutputSchema = lazySchema(() =>\n zodSchema(\n z.object({\n status: z.string().optional(),\n action: z.record(z.string(), z.unknown()).optional(),\n }),\n ),\n);\n\nconst webSearchToolFactory = createProviderExecutedToolFactory<\n {},\n {\n /**\n * Status of the server-side web search call.\n */\n status?: string;\n\n /**\n * The search action reported by DeepSeek, such as the query that was run.\n */\n action?: Record<string, unknown>;\n },\n {}\n>({\n id: 'deepseek.web_search',\n inputSchema: lazySchema(() => zodSchema(z.object({}))),\n outputSchema: webSearchOutputSchema,\n});\n\n/**\n * DeepSeek's server-side web search for the Responses API. DeepSeek runs the\n * searches and page reads during generation and adds the results to the\n * model context. Supported with `deepseek-v4-pro`.\n *\n * Successful searches and page reads are billed per operation and reported in\n * `usage.raw.server_tool_use` and `providerMetadata.deepseek.serverToolUse`.\n */\nexport const webSearch = (\n args: Parameters<typeof webSearchToolFactory>[0] = {},\n) => webSearchToolFactory(args);\n","import { webSearch } from './web-search';\n\nexport { webSearch };\n\nexport const deepseekTools = {\n webSearch,\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","import {\n type FilesV4,\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolveWith,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport type { DeepSeekChatModelId } from './chat/deepseek-chat-language-model-options';\nimport { DeepSeekChatLanguageModel } from './chat/deepseek-chat-language-model';\nimport { DeepSeekFiles } from './files/deepseek-files';\nimport { DeepSeekResponsesLanguageModel } from './responses/deepseek-responses-language-model';\nimport type { DeepSeekResponsesModelId } from './responses/deepseek-responses-language-model-options';\nimport { deepseekTools } from './tool';\nimport { VERSION } from './version';\n\nexport interface DeepSeekProviderSettings {\n /**\n * DeepSeek API key.\n * A function is called before each request and may return a promise.\n */\n apiKey?: Resolvable<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 ProviderV4 {\n /**\n * Creates a DeepSeek model for text generation.\n */\n (modelId: DeepSeekChatModelId): LanguageModelV4;\n\n /**\n * Creates a DeepSeek model for text generation.\n */\n languageModel(modelId: DeepSeekChatModelId): LanguageModelV4;\n\n /**\n * Creates a DeepSeek chat model for text generation.\n */\n chat(modelId: DeepSeekChatModelId): LanguageModelV4;\n\n /**\n * Creates a DeepSeek model that uses the Responses API. Supports\n * server-side tools such as `deepseek.tools.webSearch()`.\n */\n responses(modelId: DeepSeekResponsesModelId): LanguageModelV4;\n\n /**\n * DeepSeek server-side tools for use with the Responses API.\n */\n tools: typeof deepseekTools;\n\n /**\n * Creates a DeepSeek files interface for uploading images.\n */\n files(): FilesV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport function createDeepSeek(\n options: DeepSeekProviderSettings = {},\n): DeepSeekProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL ?? 'https://api.deepseek.com') ??\n 'https://api.deepseek.com';\n\n const getHeaders = () =>\n resolveWith(options.apiKey, apiKey =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey,\n environmentVariableName: 'DEEPSEEK_API_KEY',\n description: 'DeepSeek API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-deepseek/${VERSION}`,\n ),\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 supportsStrictToolCalls: baseURL.endsWith('/beta'),\n });\n };\n\n const createResponsesModel = (modelId: DeepSeekResponsesModelId) =>\n new DeepSeekResponsesLanguageModel(modelId, {\n provider: 'deepseek.responses',\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createFiles = () =>\n new DeepSeekFiles({\n provider: 'deepseek.files',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = (modelId: DeepSeekChatModelId) =>\n createLanguageModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n provider.responses = createResponsesModel;\n provider.tools = deepseekTools;\n provider.files = createFiles;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const deepSeek = createDeepSeek();\n"],"mappings":";;;;AAOA,MAAa,kCAAkC,iBAC7C,UACE,EAAE,OAAO;;;;;;CAMP,aAAa,EAAE,KAAK;EAAC;EAAO;EAAQ;EAAY;CAAM,CAAC,CAAC,CAAC,SAAS;;;;;;;;;CAUlE,UAAU,EAAE,QAAQ,IAAI,CAAC,CAAC,SAAS;AACrC,CAAC,CACH,CACF;;;ACjBA,SAAS,kCAAkC;CACzC,OAAO,EAAE,OAAO;;;;EAId,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;EAO/B,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS;;;;;;;;EAStD,QAAQ,EACL,OAAO,CAAC,CACR,MAAM,oBAAoB,sCAAsC,CAAC,CACjE,IAAI,KAAK,4CAA4C,CAAC,CACtD,SAAS;;;;EAKZ,UAAU,EACP,OAAO,EAIN,MAAM,EAAE,KAAK;GAAC;GAAY;GAAW;EAAU,CAAC,CAAC,CAAC,SAAS,EAC7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