Skip to main content
POST
/
v1
/
files
Upload a file
curl --request POST \
  --url https://api.infery.ai/v1/files \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: multipart/form-data' \
  --form file='@example-file' \
  --form purpose=assistants
{
  "id": "file_1hR9xTPZqK4mVLc2nJ7fY5wB",
  "object": "file",
  "bytes": 245192,
  "created_at": 1713204900,
  "filename": "report.pdf",
  "purpose": "assistants",
  "status": "processed"
}
Infery’s Files API mirrors OpenAI’s Files API exactly. Upload a file, get back a file_id, reference it in chat completions.

Upload

curl https://api.infery.ai/v1/files \
  -H "Authorization: Bearer $INFERY_API_KEY" \
  -F purpose=assistants \
  -F file=@./report.pdf
Response:
{
  "id": "file_1hR9xTPZqK4mVLc2nJ7fY5wB",
  "object": "file",
  "bytes": 245192,
  "created_at": 1713204900,
  "filename": "report.pdf",
  "purpose": "assistants",
  "status": "processed"
}

Purposes

purposeUsed for
assistantsGeneral-purpose attachment (most common)
visionImage inputs
user_dataPer-user documents (RAG, analysis)
batchBatch inference inputs (coming soon)

Reference in chat

{
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Summarise this"},
      {"type": "file", "file_id": "file_abc123..."}
    ]
  }]
}
The gateway resolves the id, fetches bytes from our storage, and injects them into the provider call as inline content. Workspace-scoped: you only see files uploaded to your own workspace.

Idempotency

Idempotency-Key: my-unique-request-2026-04-15
Same key within 24 h returns the original file_id instead of uploading twice. Key format: [A-Za-z0-9_.-:]{1,255}.

Security

  • MIME sniffing via magic bytes — we don’t trust Content-Type. Mismatch → 400.
  • Workspace isolation — cross-workspace lookup returns 404 (we don’t leak existence).
  • Private storage — GCS objects have Cache-Control: private, max-age=0. Download only via our signed proxy.
  • Size and count caps — plan-based, see Plans.
  • Filename sanitisation — basename stripped, control chars removed, max 255 chars.

Quotas

Your plan caps:
  • max_file_size_bytes — single upload
  • max_files_per_workspace — total count
  • max_storage_bytes_per_workspace — total size
Response headers show your current usage: X-Storage-Used-Bytes, X-Storage-Limit-Bytes, X-Files-Used, X-Files-Limit.

Authorizations

Authorization
string
header
required

API key in format: Bearer inf_***

Headers

Idempotency-Key
string

Same key within 24h returns the originally created file instead of uploading twice. Format: [A-Za-z0-9_.-:]{1,255}

Body

multipart/form-data
file
file
required

Binary file contents.

purpose
enum<string>
required

Intended use of the file.

Available options:
assistants,
vision,
user_data,
batch

Response

File uploaded successfully.

id
string
Example:

"file_1hR9xTPZqK4mVLc2nJ7fY5wB"

object
string
Example:

"file"

bytes
integer
Example:

245192

created_at
integer
Example:

1713204900

filename
string
Example:

"report.pdf"

purpose
enum<string>
Available options:
assistants,
vision,
user_data,
batch
Example:

"assistants"

status
string
Example:

"processed"