{"record":{"id":"40dc1d5cad0506e3","repo":"vercel/ai","slug":"file-parts-with-provider-references-functionalit","errorCode":null,"errorMessage":"'file parts with provider references' functionality is not supported.","messagePattern":"'file parts with provider references' functionality is not supported\\.","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/google/src/convert-to-google-messages.ts","lineNumber":296,"sourceCode":"            case 'text': {\n              parts.push({ text: part.text });\n              break;\n            }\n\n            case 'file': {\n              switch (part.data.type) {\n                case 'url': {\n                  parts.push({\n                    fileData: {\n                      mimeType: resolveFullMediaType({ part }),\n                      fileUri: part.data.url.toString(),\n                    },\n                  });\n                  break;\n                }\n                case 'reference': {\n                  if (isVertexLike) {\n                    throw new UnsupportedFunctionalityError({\n                      functionality: 'file parts with provider references',\n                    });\n                  }\n\n                  parts.push({\n                    fileData: {\n                      mimeType: resolveFullMediaType({ part }),\n                      fileUri: resolveProviderReference({\n                        reference: part.data.reference,\n                        provider: 'google',\n                      }),\n                    },\n                  });\n                  break;\n                }\n                case 'text': {\n                  parts.push({\n                    inlineData: {","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/google/src/convert-to-google-messages.ts#L278-L314","documentation":"Provider-reference file parts (files referenced by a provider-specific ID/URI rather than inline data) are supported on Google's first-party Gemini API but not on Vertex AI endpoints. When converting a user file part of type 'reference' while running against a Vertex-like endpoint (isVertexLike), the converter throws UnsupportedFunctionalityError.","triggerScenarios":"Passing a user message file part with `data: { type: 'reference', ... }` (e.g. a Vertex/Google file reference) to a model created via the google-vertex provider, or to google provider configured in Vertex-like mode.","commonSituations":"Reusing Gemini-API message code that references uploaded Files against Vertex; caching file references from a previous Gemini call and replaying them through Vertex; mixing provider models in one agent with shared message history.","solutions":["Send the file as inline base64 data (`type: 'data'`) instead of a provider reference when using Vertex.","Upload the file to Vertex/Cloud Storage and pass a GCS URI via the Vertex-specific file data format.","Switch to the first-party Google provider (Google AI Studio endpoint) which supports file references."],"exampleFix":"// before\n{ role: 'user', content: [{ type: 'file', data: { type: 'reference', fileId: 'files/abc' } }] }\n// after\n{ role: 'user', content: [{ type: 'file', data: { type: 'data', mediaType: 'application/pdf', data: base64Pdf } }] }","handlingStrategy":"validation","validationCode":"function filePartsAreVertexSafe(messages) {\n  return messages.flatMap(m => Array.isArray(m.content) ? m.content : []).every(p =>\n    p.type !== 'file' || p.data?.type !== 'reference');\n}\n// run before sending to a Vertex model","typeGuard":"function isInlineDataFilePart(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    // convert references to inline base64 or GCS URIs and retry\n  } throw e;\n}","preventionTips":["Know your endpoint: Vertex does not accept Gemini Files-API references.","Resolve file references to bytes or GCS URIs before building messages.","Keep separate message-shaping code paths for Google AI vs Vertex."],"tags":["google","vertex","file-parts","messages"],"backgroundTag":"file-reference-unsupported-on-vertex","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}