{"record":{"id":"8a31c3064b153699","repo":"vercel/ai","slug":"file-data-urls-in-assistant-messages-are-not-supp-8a31c3","errorCode":null,"errorMessage":"'File data URLs in assistant messages are not supported' functionality not supported.","messagePattern":"'File data URLs in assistant messages are not supported' functionality not supported\\.","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/google/src/convert-to-google-messages.ts","lineNumber":405,"sourceCode":"                    }\n                    case 'data': {\n                      return {\n                        inlineData: {\n                          mimeType: part.mediaType,\n                          data: convertToBase64(part.data.data),\n                        },\n                        thought: true,\n                        thoughtSignature,\n                      };\n                    }\n                  }\n                  break;\n                }\n\n                case 'file': {\n                  switch (part.data.type) {\n                    case 'url': {\n                      throw new UnsupportedFunctionalityError({\n                        functionality:\n                          'File data URLs in assistant messages are not supported',\n                      });\n                    }\n                    case 'reference': {\n                      if (isVertexLike) {\n                        throw new UnsupportedFunctionalityError({\n                          functionality: 'file parts with provider references',\n                        });\n                      }\n\n                      return {\n                        fileData: {\n                          mimeType: part.mediaType,\n                          fileUri: resolveProviderReference({\n                            reference: part.data.reference,\n                            provider: 'google',\n                          }),","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/google/src/convert-to-google-messages.ts#L387-L423","documentation":"Assistant messages containing a 'file' part whose data is a URL are not convertible to Google's content format, which requires file attachments in assistant turns as inline bytes. The converter throws UnsupportedFunctionalityError when it encounters a file part with `type: 'url'` inside an assistant message.","triggerScenarios":"An assistant message with a file part like `data: { type: 'url', url: 'https://...' }` in the prompt array passed to a Google Gemini/Vertex model via convertToGoogleMessages.","commonSituations":"Chat histories recorded from providers that return hosted file URLs (e.g. audio/image generation results); multi-provider agents sharing one persisted message log.","solutions":["Convert the URL to inline base64 data before sending: fetch the file and pass `{ type: 'data', mediaType, data }`.","Remove or downgrade the file part to plain text (e.g. include the URL as text) in assistant messages.","Persist files as bytes/base64 rather than hosted URLs when targeting Google."],"exampleFix":"// before\n{ role: 'assistant', content: [{ type: 'file', data: { type: 'url', url: 'https://cdn/x.png' } }] }\n// after\n{ role: 'assistant', content: [{ type: 'file', data: { type: 'data', mediaType: 'image/png', data: base64Png } }] }","handlingStrategy":"validation","validationCode":"async function assistantFileUrlsResolved(messages) {\n  const parts = messages.flatMap(m => m.role === 'assistant' && Array.isArray(m.content) ? m.content : []);\n  return parts.every(p => p.type !== 'file' || p.data?.type !== 'url');\n}","typeGuard":"function isDataFilePart(part) {\n  return part?.type === 'file' && part?.data?.type === 'data' && typeof part.data.data === 'string' && typeof part.data.mediaType === 'string';\n}","tryCatchPattern":"try {\n  await streamText({ model: googleModel, messages });\n} catch (e) {\n  if (e?.message?.includes('File data URLs in assistant messages are not supported')) {\n    // inline the URLs (fetch + base64) or drop those parts, then retry\n  } throw e;\n}","preventionTips":["Convert hosted file URLs to inline base64 at persistence time.","Remember: URL file parts are user-message-only on Google.","Write a converter that normalizes histories per provider before calls."],"tags":["google","assistant-messages","file-parts","messages"],"backgroundTag":"file-url-unsupported-in-assistant-message","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}