Files

Upload files for use in tasks.

Upload responses return a bare file DTO when you send X-API-Version: 2 (recommended). See REST overview — API version.


Upload File

POST /files

Upload a file and get a URI for use in task inputs.

Request

Content-Type: multipart/form-data

FieldTypeRequiredDescription
filefileYesFile to upload
filenamestringNoCustom filename
content_typestringNoMIME type
publicbooleanNoMake publicly accessible
pathstringNoCustom storage path

Response

FieldTypeDescription
idstringFile ID
uristringFile URI for use in inputs
filenamestringFile name
content_typestringMIME type
sizenumberSize in bytes

Example:

json
1{2  "id": "file_abc123",3  "uri": "inf://files/abc123/image.png",4  "filename": "image.png",5  "content_type": "image/png",6  "size": 1024007}

cURL Example

bash
1curl -X POST https://api.inference.sh/files \2  -H "Authorization: Bearer inf_your_key" \3  -H "X-API-Version: 2" \4  -F "file=@/path/to/image.png" \5  -F "public=true"

CLI equivalent: belt file upload <path> (add --json for {filename, size, type, uri}; supports multiple paths in one command).


List Files

POST /files/list

Cursor-paginated list of files in your workspace. GET /files accepts the same query parameters.

Request body

FieldTypeDescription
limitnumberPage size (default 10)
cursorstringPagination cursor from a previous response
directionstringnext or prev
filtersarrayField filters (for example content_type with like operator)
searchobject{ "term", "fields" } for substring match (CLI --search / -q searches filename)

Response

Standard cursor list shape: items (array of file DTOs), has_next, has_previous, next_cursor, prev_cursor.

CLI equivalent: belt file list (add --json for the raw payload; --type image filters by MIME category; --search photo or -q avatar filters by filename).


Delete File

DELETE /files/{id}

Permanently delete a file by ID. Requires files:write scope.

CLI equivalent: belt file delete <id> (add --force to skip the confirmation prompt).


Using Uploaded Files

Use the returned uri in task inputs:

bash
1curl -X POST https://api.inference.sh/run \2  -H "Authorization: Bearer inf_your_key" \3  -H "X-API-Version: 2" \4  -H "Content-Type: application/json" \5  -H "X-API-Version: 2" \6  -d '{7    "app": "image-processor",8    "input": {9      "image": "inf://files/abc123/image.png"10    }11  }'

Supported Types

Common MIME types:

  • image/png, image/jpeg, image/webp
  • audio/mpeg, audio/wav
  • video/mp4
  • application/pdf
  • text/plain

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.