Upload an image

A link to upload a large or local image to, and the link to send models.

POST

For an image too large to send inline, or one that isn't online. Ask for a link, PUT the image's bytes to upload_url with upload_headers, then send url as the image in any model call, or in input_references on POST /images.

The image goes straight to storage, so the 4 MB request limit doesn't apply. Its link works for 24 hours, then it's deleted. Uploads are free, up to 200 per agent a day, for an agent with credit. See Images.

Send your key as Authorization: Bearer binf_... or x-api-key.

Request body

The fields most calls use. Every other field of the OpenAI format is passed on as sent.

  • content_type"image/png" | "image/jpeg" | "image/webp" | "image/gif"Required

    The image's type. The upload must be this type.

  • sizeintegerRequired

    The image's exact size in bytes, up to 20 MB (20,971,520). The upload must be exactly this long.

Response

  • idstring

    The upload's id.

  • upload_urlstring

    Send the image's bytes here with a PUT and upload_headers, before upload_expires_at (10 minutes).

  • upload_method"PUT"

    Always PUT.

  • upload_headersobject

    Headers the PUT must carry: the Content-Type you named.

  • upload_expires_atstring

    When upload_url stops.

  • urlstring

    The image's link, to send as the image in any model call once uploaded.

  • expires_atstring

    When url stops working, 24 hours on. The image is deleted after.

Response headers

  • x-binference-call-idstring

    This call's id on your Calls page. Quote it when you contact us.

  • x-generation-idstring

    The model provider's id for the answer.

  • retry-afterinteger

    On a 429 or 503: whole seconds to wait before sending again.

  • retry-after-msinteger

    The same wait in milliseconds. The OpenAI and Anthropic SDKs read it.

Request
curl https://binference.io/api/v1/uploads \  -H "Authorization: Bearer $BINF_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "content_type": "image/png",    "size": 3400000  }'
Response
{  "object": "upload",  "id": "upl_BTSNzIeW9d7D_ShZQ8fJEQ",  "upload_url": "https://acct.r2.cloudflarestorage.com/binference-images/uploads/42/BTSNzIeW9d7D_ShZQ8fJEQ.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=600&X-Amz-Signature=...",  "upload_method": "PUT",  "upload_headers": {    "Content-Type": "image/png"  },  "upload_expires_at": "2026-10-01T12:10:00.000Z",  "url": "https://acct.r2.cloudflarestorage.com/binference-images/uploads/42/BTSNzIeW9d7D_ShZQ8fJEQ.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=86400&X-Amz-Signature=...",  "expires_at": "2026-10-02T12:00:00.000Z",  "content_type": "image/png",  "size": 3400000}