Skip to main content

[BETA] Batches API

Covers Batches, Files

FeatureSupportedNotes
Supported ProvidersOpenAI, Azure, Vertex-
✨ Cost Tracking✅LiteLLM Enterprise only
Logging✅Works across all logging integrations

Quick Start​

  • Create File for Batch Completion

  • Create Batch Request

  • List Batches

  • Retrieve the Specific Batch and File Content

$ export OPENAI_API_KEY="sk-..."

$ litellm

# RUNNING on http://0.0.0.0:4000

Create File for Batch Completion

curl http://localhost:4000/v1/files \
-H "Authorization: Bearer sk-1234" \
-F purpose="batch" \
-F file="@mydata.jsonl"

Create Batch Request

curl http://localhost:4000/v1/batches \
-H "Authorization: Bearer sk-1234" \
-H "Content-Type: application/json" \
-d '{
"input_file_id": "file-abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}'

Retrieve the Specific Batch

curl http://localhost:4000/v1/batches/batch_abc123 \
-H "Authorization: Bearer sk-1234" \
-H "Content-Type: application/json" \

List Batches

curl http://localhost:4000/v1/batches \
-H "Authorization: Bearer sk-1234" \
-H "Content-Type: application/json" \

Supported Providers:​

Azure OpenAI​

OpenAI​

Vertex AI​

How Cost Tracking for Batches API Works​

LiteLLM tracks batch processing costs by logging two key events:

Event TypeDescriptionWhen it's Logged
acreate_batchInitial batch creationWhen batch request is submitted
batch_successFinal usage and costWhen batch processing completes

Cost calculation:

  • LiteLLM polls the batch status until completion
  • Upon completion, it aggregates usage and costs from all responses in the output file
  • Total token and response_cost reflect the combined metrics across all batch responses

Swagger API Reference​