Files
files
Methods
Create a file by uploading its content and optional metadata.
Example cURL request:
curl -X POST https://api.replicate.com/v1/files \
-H "Authorization: Token $REPLICATE_API_TOKEN" \
-H 'Content-Type: multipart/form-data' \
-F 'content=@/path/to/archive.zip;type=application/zip;filename=example.zip' \
-F 'metadata={"customer_reference_id": 123};type=application/json'
The request must include:
content
: The file content (required)type
: The content / MIME type for the file (defaults toapplication/octet-stream
)filename
: The filename (required, ≤ 255 bytes, valid UTF-8)metadata
: User-provided metadata associated with the file (defaults to{}
, must be valid JSON)
A unique, randomly-generated identifier for the file resource
A dictionary of checksums for the file keyed by the algorithm name
The content / MIME type of the file
When the file was created
When the file expires
Metadata provided by user when the file was created
The length of the file in bytes
A dictionary of URLs associated with the file resource
Delete a file. Once a file has been deleted, subsequent requests to the file resource return 404 Not found.
Example cURL request:
curl -X DELETE \
-H "Authorization: Token $REPLICATE_API_TOKEN" \
https://api.replicate.com/v1/files/cneqzikepnug6xezperrr4z55o
Download a file by providing the file owner, access expiry, and a valid signature.
Example cURL request:
curl -X GET "https://api.replicate.com/v1/files/cneqzikepnug6xezperrr4z55o/download?expiry=1708515345&owner=mattt&signature=zuoghqlrcnw8YHywkpaXQlHsVhWen%2FDZ4aal76dLiOo%3D"
Get the details of a file.
Example cURL request:
curl -s \
-H "Authorization: Token $REPLICATE_API_TOKEN" \
https://api.replicate.com/v1/files/cneqzikepnug6xezperrr4z55o
Get a paginated list of all files created by the user or organization associated with the provided API token.
Example cURL request:
curl -s \
-H "Authorization: Token $REPLICATE_API_TOKEN" \
https://api.replicate.com/v1/files
The response will be a paginated JSON array of file objects, sorted with the most recent file first.