{"record":{"id":"0af2a26997366736","repo":"vercel/ai","slug":"file-parts-with-provider-references-functionalit-0af2a2","errorCode":null,"errorMessage":"'file parts with provider references' functionality not supported.","messagePattern":"'file parts with provider references' functionality not supported\\.","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/google/src/convert-to-google-messages.ts","lineNumber":412,"sourceCode":"                        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                          }),\n                        },\n                        ...(providerOpts?.thought === true\n                          ? { thought: true }\n                          : {}),\n                        thoughtSignature,\n                      };\n                    }","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/google/src/convert-to-google-messages.ts#L394-L430","documentation":"Like error 335 but for assistant messages: file parts that use provider references (provider-specific file IDs) inside an assistant message are rejected when targeting Vertex-like Google endpoints (isVertexLike), because Vertex does not accept Gemini-API file references. The converter throws UnsupportedFunctionalityError.","triggerScenarios":"An assistant message containing a `file` part with `data: { type: 'reference', ... }` sent to a Google Vertex model via convertToGoogleMessages.","commonSituations":"Replaying Gemini-API assistant outputs (which contain Files API references) against Vertex; shared message stores across Google and Vertex deployments.","solutions":["Send the file as inline base64 data instead of a provider reference.","Upload to Cloud Storage and reference via the Vertex-supported GCS URI format.","Strip provider-reference file parts from history when routing to Vertex models."],"exampleFix":"// before\n{ role: 'assistant', content: [{ type: 'file', data: { type: 'reference', fileId: 'files/abc' } }] }\n// after\n{ role: 'assistant', content: [{ type: 'file', data: { type: 'data', mediaType: 'image/png', data: base64Png } }] }","handlingStrategy":"validation","validationCode":"function assistantFileRefsVertexSafe(messages) {\n  return messages.flatMap(m => m.role === 'assistant' && Array.isArray(m.content) ? m.content : [])\n    .every(p => p.type !== 'file' || p.data?.type !== 'reference');\n}\n// check when target is a Vertex model","typeGuard":"function isAssistantInlineDataFile(part) {\n  return part?.type === 'file' && part?.data?.type === 'data' && typeof part.data.data === 'string';\n}","tryCatchPattern":"try {\n  await streamText({ model: vertexModel, messages });\n} catch (e) {\n  if (e?.message?.includes('file parts with provider references')) {\n    // inline base64 or GCS URI, then retry\n  } throw e;\n}","preventionTips":["Never persist provider file IDs in cross-provider conversation logs.","Inline file bytes for assistant messages when routing to Vertex.","Feature-detect target endpoint (Vertex vs Gemini) before composing file parts."],"tags":["google","vertex","assistant-messages","file-parts"],"backgroundTag":"file-reference-unsupported-on-vertex","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}