TokenLab

Files & Batches

Upload File

Upload a batch file, image reference, or Anthropic-format file.

POST
/v1/files

File Purposes

  • Batch files: use purpose=batch for /v1/batches.
  • Image/reference files: use purpose=user_data or purpose=vision for file-backed image requests.
  • Anthropic Files: add the anthropic-beta: files-api-2025-04-14 header.

Example

Request

cURL
curl -X POST "https://api.tokenlab.sh/v1/files" \
  -H "Authorization: Bearer sk-your-api-key" \
  -F "purpose=batch" \
  -F "file=@batch-input.jsonl;type=application/jsonl"

Image File Inputs

This same /v1/files route can upload image reference files for /v1/images/edits.

  • Use purpose=user_data or purpose=vision.
  • Optionally include model to select the image-edit model; it defaults to gpt-image-2.
  • The returned file_id is bound to the selected image-edit configuration and can be reused in images[].file_id.

Anthropic Files API Mode

  • Add anthropic-beta: files-api-2025-04-14 to use Anthropic Files.
  • In Anthropic mode, upload the original file directly and do not send purpose=batch.
  • The returned file_id is available only in the current Workspace and can be reused in /v1/messages requests.
  • If you plan to reference the uploaded file from Anthropic message content, keep using Anthropic-native headers (x-api-key, anthropic-version, and the beta header when required).

Response example

Response

200 OK
{
  "id": "file_abc123",
  "object": "file",
  "bytes": 32768,
  "created_at": 1706000000,
  "filename": "batch-input.jsonl",
  "purpose": "batch"
}

Important fields

idstring
File ID.
purposestring
Purpose assigned to the file. Uploads accept batch, user_data, or vision.
bytesinteger
File size in bytes.

Authorization

BearerAuth
AuthorizationBearer <token>

API Key authentication. Create or manage API keys in Dashboard > API > API Keys.

In: header

Headers

anthropic-beta?string

Include files-api-2025-04-14 to use Anthropic Files API mode.

Request Body

multipart/form-data

Response

application/json

application/json

application/json

application/json