{"record":{"id":"09d3757f8cee43cb","repo":"vercel/ai","slug":"deepseek-image-media-type-resolvedmediatype","errorCode":null,"errorMessage":"DeepSeek image media type ${resolvedMediaType}","messagePattern":"DeepSeek image media type (.+?)","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/deepseek/src/chat/convert-to-deepseek-chat-messages.ts","lineNumber":174,"sourceCode":"            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 = resolveFullMediaType({ part });\n\n              if (!supportedImageMediaTypes.has(resolvedMediaType)) {\n                throw new UnsupportedFunctionalityError({\n                  functionality: `DeepSeek image media type ${resolvedMediaType}`,\n                  message:\n                    'DeepSeek supports JPEG, PNG, GIF, and WebP image inputs.',\n                });\n              }\n\n              if (part.data.type === 'url') {\n                const url = part.data.url.toString();\n\n                if (url.length > 8192) {\n                  throw new InvalidPromptError({\n                    prompt,\n                    message:\n                      'DeepSeek image URLs must not exceed 8192 characters.',\n                  });\n                }\n\n                if (filePartOptions?.fileData === true) {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/deepseek/src/chat/convert-to-deepseek-chat-messages.ts#L156-L192","documentation":"DeepSeek's chat API only accepts JPEG, PNG, GIF, and WebP image inputs. When converting an image part whose data is a URL or binary data, the SDK resolves the media type and throws UnsupportedFunctionalityError if it is not in supportedImageMediaTypes (e.g. image/avif, image/svg+xml, image/heic).","triggerScenarios":"Sending a file/image part to a DeepSeek model with data URL or URL whose resolved media type is outside {image/jpeg, image/png, image/gif, image/webp} — e.g. an AVIF or SVG image, or a part whose media type cannot be resolved to a supported value.","commonSituations":"Serving modern formats (AVIF/WebP) from an image CDN and WebP works but AVIF fails; attaching SVG assets from a design system; screenshots saved as HEIC from iOS devices; missing extension causing an unrecognized media type.","solutions":["Convert the image to JPEG, PNG, GIF, or WebP before sending","Serve the image in a supported format at the URL","Explicitly set the part's mediaType to the actual supported type if it was mislabeled"],"exampleFix":"// before\n{ type: 'image', image: new URL('https://cdn.example.com/photo.avif') }\n// after\n{ type: 'image', image: new URL('https://cdn.example.com/photo.webp') }","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['image/jpeg','image/png','image/gif','image/webp']);\nfunction isDeepseekSupportedImage(mediaType) { return SUPPORTED.has(mediaType); }\n// check each image part's resolved media type before the call","typeGuard":"function isSupportedImageType(t: string): t is 'image/jpeg'|'image/png'|'image/gif'|'image/webp' {\n  return ['image/jpeg','image/png','image/gif','image/webp'].includes(t);\n}","tryCatchPattern":"try { await generateText(...); } catch (e) { if (UnsupportedFunctionalityError.isInstance(e) && e.functionality?.startsWith('DeepSeek image media type')) { /* convert image and retry */ } throw e; }","preventionTips":["Normalize CDN image output to WebP/PNG/JPEG before sending to DeepSeek","Reject SVG/AVIF/HEIC uploads at ingest time","Map unknown media types to a safe default or transcode"],"tags":["deepseek","image","unsupported-media-type","multimodal"],"backgroundTag":"unsupported-media-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}