{"record":{"id":"50640b953a39fe3f","repo":"vercel/ai","slug":"only-images-and-pdf-file-parts-are-supported","errorCode":null,"errorMessage":"Only images and PDF file parts are supported","messagePattern":"Only images and PDF file parts are supported","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/mistral/src/convert-to-mistral-chat-messages.ts","lineNumber":79,"sourceCode":"                  case 'text': {\n                    throw new UnsupportedFunctionalityError({\n                      functionality: 'text file parts',\n                    });\n                  }\n                  case 'url':\n                  case 'data': {\n                    const topLevel = getTopLevelMediaType(part.mediaType);\n\n                    if (topLevel === 'image') {\n                      return {\n                        type: 'image_url',\n                        image_url: formatFileUrl({ part }),\n                      };\n                    } else {\n                      if (part.data.type === 'data') {\n                        const fullMediaType = resolveFullMediaType({ part });\n                        if (fullMediaType !== 'application/pdf') {\n                          throw new UnsupportedFunctionalityError({\n                            functionality:\n                              'Only images and PDF file parts are supported',\n                          });\n                        }\n                      } else if (part.mediaType !== 'application/pdf') {\n                        throw new UnsupportedFunctionalityError({\n                          functionality:\n                            'Only images and PDF file parts are supported',\n                        });\n                      }\n\n                      return {\n                        type: 'document_url',\n                        document_url: formatFileUrl({ part }),\n                      };\n                    }\n                  }\n                }","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/mistral/src/convert-to-mistral-chat-messages.ts#L61-L97","documentation":"For inline (data) file parts, Mistral only accepts images and application/pdf. convertToMistralChatMessages resolves the full media type and throws UnsupportedFunctionalityError when a base64 data file part is not a PDF (and not an image, which is handled on another branch).","triggerScenarios":"Sending a file part with data.type === 'data' (base64) whose resolved media type is neither an image nor 'application/pdf' (e.g. application/msword, audio, zip) to a Mistral chat model.","commonSituations":"Attaching Word/Excel/CSV or audio files as base64 file parts; generic document-upload features routed to Mistral without media-type checks.","solutions":["Convert the document to PDF before sending it inline.","Send only images or PDFs as data file parts to Mistral.","Extract the text and send it as a text part instead.","Use a provider that supports the given media type."],"exampleFix":"// before\n{ type: 'file', mediaType: 'application/msword', data: { type: 'data', data: bytes } }\n// after: convert to PDF first\n{ type: 'file', mediaType: 'application/pdf', data: { type: 'data', data: pdfBytes } }","handlingStrategy":"validation","validationCode":"function isMistralInlineData(part: { type: string; mediaType: string; data: { type: string } }): boolean {\n  if (part.type !== 'file' || part.data.type !== 'data') return true;\n  return part.mediaType.startsWith('image/') || part.mediaType === 'application/pdf';\n}\n// assert before sending\ncontent.forEach(p => { if (!isMistralInlineData(p)) throw new Error('Convert to PDF or image for Mistral'); });","typeGuard":"function isMistralSupportedMediaType(mediaType: string): boolean {\n  return mediaType.startsWith('image/') || mediaType === 'application/pdf';\n}","tryCatchPattern":"try {\n  await generateText({ model: mistral(modelId), messages });\n} catch (error) {\n  if (UnsupportedFunctionalityError.isInstance(error) &&\n      error.functionality.includes('Only images and PDF')) {\n    // convert document to PDF, or extract text, then retry\n  } else {\n    throw error;\n  }\n}","preventionTips":["Restrict upload UIs to images and PDFs when targeting Mistral.","Convert office/audio/archive files to PDF or text upstream.","Assert media types in a shared prompt-validation helper."],"tags":["mistral","unsupported-functionality","media-type","file-part"],"backgroundTag":"unsupported-media-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}