Batch inference

Files and Batch reference

The OpenAI-compatible batch surface, in beta.

Base URL and authentication

Base URL: https://api.reka.ai/v1. Use the same API key as Chat Completions: Authorization: Bearer $REKA_API_KEY. Files and batches belong to your account or organization.

Operations

MethodPathRequest and result
POST/v1/filesUpload a .jsonl file with purpose=batch.
GET/v1/filesList files. Filters: purpose, limit (1–10,000), order, after.
GET/v1/files/{file_id}File metadata.
GET/v1/files/{file_id}/contentDownload the file (JSONL).
DELETE/v1/files/{file_id}Delete a file.
POST/v1/batchesCreate a batch. Optional Idempotency-Key header.
GET/v1/batchesList batches, newest first. limit (1–100, default 20), after.
GET/v1/batches/{batch_id}Status, counts, usage and result file IDs.
POST/v1/batches/{batch_id}/cancelCancel a batch.

With an SDK, set the base URL to https://api.reka.ai/v1; the SDK adds the rest of each path.

OpenAI compatibility

The OpenAI Python and TypeScript SDKs work unchanged with the base URL above. Use a Reka model ID in each request.

SurfaceReka beta
Endpoint and models/v1/chat/completions, qwen3.8-27b or glm5.3-flash
SubmissionUpload a JSONL file, then create with input_file_id
Window and limits24h, 50,000 requests, 100,000,000 bytes
NotificationsPoll for status; no webhooks
CancellationSupported; finished rows are kept
Other endpointsResponses, Messages and Embeddings batches are not supported

Upload, inspect, list and delete files

Upload with multipart fields file and purpose=batch. Uploading does not start a batch.

Upload a file
curl -s https://api.reka.ai/v1/files \
  -H "Authorization: Bearer $REKA_API_KEY" \
  -F purpose=batch \
  -F file=@requests.jsonl
File object
{
  "id": "file-example",
  "object": "file",
  "bytes": 500,
  "created_at": 1800000000,
  "filename": "requests.jsonl",
  "purpose": "batch",
  "status": "processed",
  "status_details": null,
  "expires_at": 1802678400
}

expires_at is when the file is deleted, 31 days after upload. Result files have purpose batch_output.

Get a file
FILE_ID="file-example"  # your file ID

# Metadata
curl -s https://api.reka.ai/v1/files/$FILE_ID \
  -H "Authorization: Bearer $REKA_API_KEY"

# Content
curl -s https://api.reka.ai/v1/files/$FILE_ID/content \
  -H "Authorization: Bearer $REKA_API_KEY" \
  -o downloaded.jsonl

Filter with purpose=batch for your inputs; leave it out to include result files.

List recent input files
curl -s "https://api.reka.ai/v1/files?purpose=batch&limit=20&order=desc" \
  -H "Authorization: Bearer $REKA_API_KEY"
File list response
{
  "object": "list",
  "data": [
    {
      "id": "file-example",
      "object": "file",
      "bytes": 500,
      "created_at": 1800000000,
      "filename": "requests.jsonl",
      "purpose": "batch",
      "status": "processed",
      "status_details": null,
      "expires_at": 1802678400
    }
  ],
  "first_id": "file-example",
  "last_id": "file-example",
  "has_more": false
}

To page through a list, pass the previous page's last_id as after while has_more is true.

Delete a file
curl -s -X DELETE https://api.reka.ai/v1/files/$FILE_ID \
  -H "Authorization: Bearer $REKA_API_KEY"
Delete response
{
  "id": "file-example",
  "object": "file",
  "deleted": true
}

Deleting the input of an unfinished batch returns HTTP 409. Deleting a file never cancels a batch.

Create request

POST /v1/batches
{
  "input_file_id": "file-example",
  "endpoint": "/v1/chat/completions",
  "completion_window": "24h",
  "metadata": {
    "description": "nightly ticket classification"
  }
}
  • input_file_id: required, a file uploaded with purpose=batch.
  • endpoint: required, /v1/chat/completions.
  • completion_window: required, 24h from creation. Rows not finished by then expire.
  • metadata: optional, up to 16 string pairs (keys 64 characters, values 512).

Optional header Idempotency-Key (1–255 characters): a repeat create with the same key and body returns the original batch; a different body returns HTTP 409. See timeouts.

Input and feature limits

  • Up to 50,000 requests and 100 MB per file.
  • UTF-8 JSONL, one request per line, one model per file.
  • custom_id: unique in the file, up to 512 characters.
  • Each row: method: POST, url set to the batch endpoint, and a Chat Completions body.
  • Tools and structured outputs work as in Chat Completions. stream: true is rejected.

Problems with the file fail the batch and appear in errors.data with line numbers (first 100). Problems with one row go to the error file.

Statuses and result fields

StatusMeaning
validatingChecking the input file.
in_progressRunning rows.
finalizingWriting the result files.
cancellingCancel requested; rows already running finish.
completedDone. Some rows may have failed: check request_counts.
failedThe input file was invalid; see errors.
expiredThe 24-hour window ended. Finished rows are in the result files.
cancelledCancelled. Finished rows are in the result files.

request_counts has total, completed and failed rows. usage sums the tokens of successful rows. Timestamps are Unix seconds.

Each result line has a custom_id and either a response (status_code, request_id, body) or an error (code, message). Rows that never ran have code batch_cancelled or batch_expired. See reading results.

Retrieve, list and cancel batches

Create returns a Batch object in validating; retrieve returns the same object with its current state.

Completed Batch object
{
  "id": "batch_example",
  "object": "batch",
  "endpoint": "/v1/chat/completions",
  "model": "qwen3.8-27b",
  "input_file_id": "file-example",
  "completion_window": "24h",
  "status": "completed",
  "errors": null,
  "output_file_id": "file-output",
  "error_file_id": null,
  "created_at": 1800000000,
  "in_progress_at": 1800000001,
  "expires_at": 1800086400,
  "finalizing_at": 1800000010,
  "completed_at": 1800000011,
  "failed_at": null,
  "expired_at": null,
  "cancelling_at": null,
  "cancelled_at": null,
  "request_counts": {
    "total": 2,
    "completed": 2,
    "failed": 0
  },
  "usage": {
    "input_tokens": 40,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 4,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 44
  },
  "metadata": null
}

output_file_id and error_file_id are null when there is no file of that kind.

Get or list batches
BATCH_ID="batch_example"  # your batch ID

# One batch
curl -s https://api.reka.ai/v1/batches/$BATCH_ID \
  -H "Authorization: Bearer $REKA_API_KEY"

# Newest 20 batches
curl -s "https://api.reka.ai/v1/batches?limit=20" \
  -H "Authorization: Bearer $REKA_API_KEY"
Next page
curl -s "https://api.reka.ai/v1/batches?limit=20&after=batch_example" \
  -H "Authorization: Bearer $REKA_API_KEY"
Cancel a batch
curl -s -X POST https://api.reka.ai/v1/batches/$BATCH_ID/cancel \
  -H "Authorization: Bearer $REKA_API_KEY"

The batch moves to cancelling; rows already running finish. Cancelling a finished batch returns it unchanged.

Errors and retry behavior

Error response (HTTP 400)
{
  "error": {
    "message": "No such File object: file-example",
    "type": "validation_error",
    "code": null,
    "param": "input_file_id"
  }
}

API calls return errors in this shape. Problems found later are in batch.errors (the file) or the error file (one row).

HTTP responseAction
400 / 422Fix the request.
401 / 403401: check the API key. 403: the account has no credit left, or the key cannot use batch.
404The ID is wrong, deleted or owned by another account.
409Create: the idempotency key was used with a different body. Delete: the file is the input of an unfinished batch.
429 batch_queue_fullThe queue is full. Wait for Retry-After (currently 300 s), then create again.
Timeout / 5xxRetry. For create, reuse the same idempotency key.

Billing and file lifecycle

Batch costs 50% of the model's standard rates. See pricing.

CaseWhat to expect
Input and output tokens50% of the model's rates
Cached input50% of the cache-read rate
Reasoning tokensBilled as output tokens
Refusals and cut-off answersBilled like any answer
Cancelled or expired batchFinished rows are billed; rows that never ran are free
Price change while a batch runsEach row is billed at the batch rate when it runs
Invalid input or no accessFree: nothing ran

Example: qwen3.8-27b lists $0.20 input and $2.50 output per million tokens. One million of each costs $1.35 in a batch, against $2.70 live.

If your credit runs out, rows not yet started fail with HTTP 403. Files are deleted 31 days after upload.

Next steps