{"record":{"id":"1d5f58500f12b25d","repo":"vercel/ai","slug":"the-provider-does-not-support-file-uploads-make-s","errorCode":null,"errorMessage":"The provider does not support file uploads. Make sure it exposes a files() method.","messagePattern":"The provider does not support file uploads\\. Make sure it exposes a files\\(\\) method\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ai/src/upload-file/upload-file.ts","lineNumber":70,"sourceCode":"  const data: FilesV4UploadFileCallOptions['data'] =\n    dataArg instanceof Uint8Array || typeof dataArg === 'string'\n      ? { type: 'data', data: dataArg }\n      : dataArg;\n\n  const mediaType =\n    mediaTypeArg ??\n    (data.type === 'text'\n      ? 'text/plain'\n      : (detectMediaType({ data: data.data }) ??\n        (isLikelyText(data.data) ? 'text/plain' : 'application/octet-stream')));\n\n  const filesApi: FilesV4 =\n    'uploadFile' in api\n      ? api\n      : typeof api.files === 'function'\n        ? api.files()\n        : (() => {\n            throw new Error(\n              'The provider does not support file uploads. Make sure it exposes a files() method.',\n            );\n          })();\n\n  const result = await filesApi.uploadFile({\n    data,\n    mediaType,\n    filename,\n    providerOptions,\n  });\n\n  return new DefaultUploadFileResult({\n    providerReference: result.providerReference,\n    mediaType: result.mediaType,\n    filename: result.filename,\n    providerMetadata: result.providerMetadata,\n    warnings: result.warnings,\n  });","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/upload-file/upload-file.ts#L52-L88","documentation":"uploadFile (packages/ai/src/upload-file/upload-file.ts:70) resolves a FilesV4 API from the provider: it uses `api.uploadFile` directly if present, otherwise calls `api.files()`. If the provider object has neither an `uploadFile` method nor a callable `files()` method, it throws this Error. The provider model in use simply doesn't implement the file-upload capability.","triggerScenarios":"Calling `uploadFile({ api: someProvider, data, ... })` with a provider instance that lacks a `files()` factory method and an `uploadFile` method — i.e. a provider that hasn't implemented FilesV4 support.","commonSituations":"Using a provider package/version that predates files() support; passing a model (LanguageModel) instead of the provider instance; passing the wrong provider object to uploadFile; older pinned versions of a provider SDK.","solutions":["Pass the provider instance (e.g. `openai` itself), not a model or chat object — verify it exposes `files()`.","Upgrade the provider package to a version implementing FilesV4 (files() / uploadFile support).","Check `typeof provider.files === 'function'` before calling uploadFile and show a capability error otherwise.","Use a different provider that supports file uploads if this one cannot."],"exampleFix":"// before\nawait uploadFile({ api: openai('gpt-4o'), data }); // model, not provider\n// after\nawait uploadFile({ api: openai, data }); // provider exposing files()","handlingStrategy":"type-guard","validationCode":"function supportsFiles(api: unknown): api is { files(): FilesV4 } {\n  return api != null &&\n    (typeof (api as any).files === 'function' || 'uploadFile' in (api as any));\n}\nif (!supportsFiles(provider)) throw new Error('Provider does not support file uploads');","typeGuard":"function hasFilesApi(api: unknown): api is { files(): FilesV4 } | { uploadFile: FilesV4['uploadFile'] } {\n  return typeof api === 'object' && api !== null &&\n    ('uploadFile' in api || typeof (api as { files?: unknown }).files === 'function');\n}","tryCatchPattern":"try {\n  await uploadFile({ api: provider, data });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('does not support file uploads')) {\n    throw new Error(`${providerName} does not support file uploads; upgrade the provider package or choose another provider`);\n  }\n  throw e;\n}","preventionTips":["Pass the provider instance (e.g. `openai`), never a model, to uploadFile.","Check the provider's type against FilesV4 at compile time when possible.","Keep provider packages updated to versions with files() support.","Feature-detect `typeof provider.files === 'function'` in UI before offering upload."],"tags":["provider-capability","file-upload","typescript"],"backgroundTag":"unsupported-provider-capability","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}