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
| Field | Type | Required | Description |
|---|---|---|---|
file | file | Yes | File to upload |
filename | string | No | Custom filename |
content_type | string | No | MIME type |
public | boolean | No | Make publicly accessible |
path | string | No | Custom storage path |
Response
| Field | Type | Description |
|---|---|---|
id | string | File ID |
uri | string | File URI for use in inputs |
filename | string | File name |
content_type | string | MIME type |
size | number | Size in bytes |
Example:
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
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
| Field | Type | Description |
|---|---|---|
limit | number | Page size (default 10) |
cursor | string | Pagination cursor from a previous response |
direction | string | next or prev |
filters | array | Field filters (for example content_type with like operator) |
search | object | { "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:
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/webpaudio/mpeg,audio/wavvideo/mp4application/pdftext/plain