useFiles produces a reference from a file the user supplies, by uploading a local file or picking one from ChatGPT’s library, and resolves any reference into a download URL the view or a tool can fetch.
Example
A shopper attaches a receipt, from their device or their ChatGPT library, and the view hands it to a tool that scans it.FileRef by hand: the hook returns camelCase fields, while FileRef wants snake_case with a required download_url.
Returns
useFiles returns three functions.
upload
File to the host and resolves with its FileMetadata, a reference to the stored file (the host never gives the view the bytes, only this handle):
getDownloadUrl
upload or selectFiles, or one delivered to the view through a tool’s output.
selectFiles
FileMetadata of the files the user authorizes for the app. The array is empty when the user picks nothing.
Handle Files
Move files in and out of your app across hosts
FileRef
The schema that passes a file reference to a tool
useCallTool
Forward an uploaded file into a tool call