v4

latestOpenAPI 3.1.02026-08-0143190206.8 KB
v1

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.

post/v1/files

Response

Success

bytesinteger required

The size of the file, in bytes.

created_atinteger required

The Unix timestamp (in seconds) for file creation time.

expires_atinteger nullable

The Unix timestamp (in seconds) for file expiry time. null if file does not expire.

filenamestring required

The name of the file.

idstring required

The file identifier, which can be used in other API requests.

objectstring required

The object type, which is always file. Only included for compatability.

public_urlstring nullable

Public URL for the file. Only present when the file has an active public URL.

public_url_expires_atinteger nullable

Unix timestamp (seconds) when the public URL expires. Only present when the public URL has an independent expiry.

purposestring

The intended purpose of the uploaded file. Only included for OAI compatability.