Create file
POST/v1/files
Upload an image, a video or an audio clip (MP3, WAV, M4A or AAC) in one step:
POST its bytes as multipart/form-data (the file field). The server sniffs the
real type from the bytes (not the declared content-type), enforces the per-type
size ceiling, stores it, and returns the stored file — attach an image or a video
to a message later by its id, or pass any of them to a generation as input. The
file expires at its expires_at unless it is sent in a message or used by a
generation first.
Request
Responses
- 201
- 401
- 413
- 422
- 429
- 500
Successful Response
Authentication failed: the credential is missing, malformed, expired, or revoked.
invalid_token— The access token is invalid.project_disabled— This project is not active.token_expired— The access token has expired.user_disabled— This user is not active.
The request body is larger than the allowed limit.
file_too_large— The file exceeds the maximum allowed size.payload_too_large— The request body is too large.
A request value failed validation; the details array names each offending field.
unsupported_media_type— The media type is not supported.validation_failed— The request payload failed validation.
Either too many requests (a Retry-After header says when to retry) or the billing account is out of credits (no Retry-After — top up to continue); the code field tells the two apart.
rate_limited— Too many requests. Please slow down.
An unexpected server-side error occurred.
internal— An unexpected error occurred.