Upload files for use in tasks.
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:
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 -F "file=@/path/to/image.png" \4 -F "public=true"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 "Content-Type: application/json" \4 -d '{5 "app": "image-processor",6 "input": {7 "image": "inf://files/abc123/image.png"8 }9 }'Supported Types
Common MIME types:
image/png,image/jpeg,image/webpaudio/mpeg,audio/wavvideo/mp4application/pdftext/plain