vercel/ai · error · UnsupportedFunctionalityError

DeepSeek image media type ${resolvedMediaType}

Error message

DeepSeek image media type ${resolvedMediaType}

What it means

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).

Source

Thrown at packages/deepseek/src/chat/convert-to-deepseek-chat-messages.ts:174

            const filePartOptions = await parseProviderOptions({
              provider: providerOptionsName,
              providerOptions: part.providerOptions,
              schema: deepseekFilePartProviderOptions,
            });

            if (part.data.type === 'reference') {
              userContent.push({
                type: 'file',
                file_id: resolveProviderReference({
                  reference: part.data.reference,
                  provider: 'deepseek',
                }),
              });
            } else if (part.data.type === 'url' || part.data.type === 'data') {
              const resolvedMediaType = resolveFullMediaType({ part });

              if (!supportedImageMediaTypes.has(resolvedMediaType)) {
                throw new UnsupportedFunctionalityError({
                  functionality: `DeepSeek image media type ${resolvedMediaType}`,
                  message:
                    'DeepSeek supports JPEG, PNG, GIF, and WebP image inputs.',
                });
              }

              if (part.data.type === 'url') {
                const url = part.data.url.toString();

                if (url.length > 8192) {
                  throw new InvalidPromptError({
                    prompt,
                    message:
                      'DeepSeek image URLs must not exceed 8192 characters.',
                  });
                }

                if (filePartOptions?.fileData === true) {

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Convert the image to JPEG, PNG, GIF, or WebP before sending
  2. Serve the image in a supported format at the URL
  3. Explicitly set the part's mediaType to the actual supported type if it was mislabeled

Example fix

// before
{ type: 'image', image: new URL('https://cdn.example.com/photo.avif') }
// after
{ type: 'image', image: new URL('https://cdn.example.com/photo.webp') }
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(['image/jpeg','image/png','image/gif','image/webp']);
function isDeepseekSupportedImage(mediaType) { return SUPPORTED.has(mediaType); }
// check each image part's resolved media type before the call

Type guard

function isSupportedImageType(t: string): t is 'image/jpeg'|'image/png'|'image/gif'|'image/webp' {
  return ['image/jpeg','image/png','image/gif','image/webp'].includes(t);
}

Try / catch

try { await generateText(...); } catch (e) { if (UnsupportedFunctionalityError.isInstance(e) && e.functionality?.startsWith('DeepSeek image media type')) { /* convert image and retry */ } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/09d3757f8cee43cb. Report an issue: GitHub.