{"record":{"id":"ff6576d99fcb7ac9","repo":"vercel/ai","slug":"file-parts-with-provider-references-ff6576","errorCode":null,"errorMessage":"file parts with provider references","messagePattern":"file parts with provider references","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/mistral/src/convert-to-mistral-chat-messages.ts","lineNumber":57,"sourceCode":"    switch (role) {\n      case 'system': {\n        messages.push({ role: 'system', content });\n        break;\n      }\n\n      case 'user': {\n        messages.push({\n          role: 'user',\n          content: content.map(part => {\n            switch (part.type) {\n              case 'text': {\n                return { type: 'text', text: part.text };\n              }\n\n              case 'file': {\n                switch (part.data.type) {\n                  case 'reference': {\n                    throw new UnsupportedFunctionalityError({\n                      functionality: 'file parts with provider references',\n                    });\n                  }\n                  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 {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/mistral/src/convert-to-mistral-chat-messages.ts#L39-L75","documentation":"Mistral chat models cannot consume file parts that reference files stored with a provider (provider references). convertToMistralChatMessages throws UnsupportedFunctionalityError when it encounters a 'file' part with data.type === 'reference'.","triggerScenarios":"Including a message part of type 'file' whose data is { type: 'reference' } in a prompt sent to a Mistral model via generateText/streamText.","commonSituations":"Reusing prompts built for OpenAI's file-reference uploads with Mistral; sharing prompt-building helpers across providers that support file references.","solutions":["Replace the reference with a url or base64 data file part.","Fetch the referenced file content yourself and pass it as binary data.","Strip reference-type file parts when targeting Mistral.","Use a provider that supports file references (e.g. OpenAI) for this request."],"exampleFix":"// before\n{ type: 'file', data: { type: 'reference', fileId: 'file-123' } }\n// after\n{ type: 'file', mediaType: 'application/pdf', data: { type: 'url', url: 'https://example.com/doc.pdf' } }","handlingStrategy":"validation","validationCode":"function usesProviderFileReference(messages: { content: unknown[] }[]): boolean {\n  return messages.some(m => (m.content as any[]).some(\n    p => p?.type === 'file' && p?.data?.type === 'reference'));\n}\nif (usesProviderFileReference(messages)) throw new Error('References unsupported by Mistral');","typeGuard":"function isFileReferencePart(part: unknown): part is { type: 'file'; data: { type: 'reference'; fileId: string } } {\n  return typeof part === 'object' && part !== null &&\n    (part as any).type === 'file' &&\n    (part as any).data?.type === 'reference';\n}","tryCatchPattern":"try {\n  await streamText({ model: mistral(modelId), messages });\n} catch (error) {\n  if (UnsupportedFunctionalityError.isInstance(error) &&\n      error.functionality.includes('provider references')) {\n    // rebuild prompt with url/data parts instead\n  } else {\n    throw error;\n  }\n}","preventionTips":["Never send file references built for OpenAI/other providers to Mistral.","Resolve references to bytes/URLs before provider dispatch.","Type prompts narrowly per provider to catch reference parts at compile time."],"tags":["mistral","unsupported-functionality","file-reference","prompt-conversion"],"backgroundTag":"unsupported-provider-functionality","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}