Files API
Upload
Upload a file
/v1/files
Upload a file to xAI's storage. Returns the file's metadata. Files can be referenced by ID anywhere a `file_id` is accepted (e.g. chat attachments). Maximum file size: 50 MB. Files are kept until you delete them, or until `expires_after` elapses if set at upload time.
Request Body
filestringThe file to upload. The filename from the multipart `Content-Disposition: filename=` header is recorded as the file's `filename`.
Response Body
bytesintegerThe size of the file, in bytes.
created_atintegerThe Unix timestamp (in seconds) for file creation time.
filenamestringThe name of the file.
idstringThe file identifier, which can be used in other API requests.
objectstringThe object type, which is always `file`. Only included for compatability.
purposestringThe intended purpose of the uploaded file. Only included for OAI compatability.
No parameters.{
"id": "file_a128090d-f0c9-4873-bd84-e499777e7417",
"object": "file",
"bytes": 12345,
"created_at": 1762345678,
"expires_at": 1762432078,
"filename": "document.pdf",
"purpose": ""
}No parameters.No response.Upload a file in chunks
/v1/files:uploadChunks
API endpoint for POST requests to /v1/files:uploadChunks.
No parameters.No response.Last updated:April 28, 2026