Skip to main content
useFiles exposes ChatGPT’s optional file upload and download extensions without widget-state side effects.
File operations use the ChatGPT-only window.openai extension, not the MCP Apps bridge. Always check isSupported; other MCP Apps hosts may not provide these operations.

Usage

Signature

isSupported is true only when both window.openai.uploadFile and window.openai.getFileDownloadUrl are available. Calling either operation on an unsupported host rejects with a descriptive error.

Model context

useFiles does not read or update ChatGPT widget state. Uploading returns an opaque fileId, but does not automatically attach the file to future model turns. ui/update-model-context can send text or structured data, but placing a fileId in that data does not attach the uploaded file or grant the model access to its contents. If the model needs the file, pass it through an explicit tool flow that accepts a ChatGPT file reference.

Download URLs

getDownloadUrl returns a temporary URL. Store the stable fileId, not the URL, and request a fresh URL when the user needs to view or download the file.