Inference Logoinference.sh

Files

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

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  -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/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.