tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Anthropic Claude API > Claude Batch API

Claude Batch API

Author: Venkata Sudhakar

The Claude Batch API is designed for large-scale asynchronous processing where you have hundreds or thousands of items to process and do not need immediate responses. Instead of sending 10,000 invoice classifications one by one at real-time rates, you submit them all in one batch request, Claude processes them over up to 24 hours, and you retrieve results when complete. The cost is 50% lower than the standard API for the same model. This makes tasks that would be prohibitively expensive or rate-limited at real-time pricing perfectly affordable as nightly batch jobs.

A batch is a list of requests, each with a custom_id you assign for tracking and a standard messages API params object. Submit with client.beta.messages.batches.create(), receive a batch_id, then poll until processing_status is "ended". Results are matched back to your custom_ids. The Batch API supports all Claude models, system prompts, tools, and max_tokens - it is the exact same API surface as real-time, just asynchronous and half the price. Ideal for overnight ETL jobs, bulk document classification, and large-scale data enrichment.

The below example shows an accounts payable team processing supplier invoices overnight - classifying by department, extracting amounts, and flagging invoices needing manager approval - all in one batch at half the real-time cost.


Polling for batch completion then retrieving and displaying results,


It gives the following output,

Submitted 5 invoices
Batch ID: msgbatch_01XfGh7kLp2NqR5sWz9yTm3D
Status:  in_progress

Status: in_progress | Done: 3 | Remaining: 2
Status: ended       | Done: 5 | Remaining: 0

=== INVOICE CLASSIFICATION RESULTS ===
INV-001 -> IT         | Rs 124500  | AWS cloud infrastructure costs
INV-002 -> HR         | Rs 45000   | Job posting recruitment platform
INV-003 -> Admin      | Rs 285000  | Hotel conference offsite room  *** APPROVAL REQUIRED ***
INV-004 -> Marketing  | Rs 78000   | Adobe design software license
INV-005 -> Finance    | Rs 850000  | EY consulting risk assessment  *** APPROVAL REQUIRED ***

# 5,000 invoices in one batch = same code, 50% cheaper than real-time calls
# INV-003 and INV-005 flagged for manager approval automatically
# Results available in your DB by morning for the AP team to action at 9am

Batch API workflow for production: each night at 11pm, your ETL job fetches all unprocessed records from the database, builds the batch request list, submits to Claude, and stores the batch_id. At 6am, a second job retrieves results, writes them to the database, and sends a summary email to the relevant teams. The AP team arrives at 9am to a fully classified and flagged invoice queue with zero manual data entry. At 5,000 invoices per month using claude-haiku-4-5, the monthly AI processing cost is under Rs 500 - cheaper than one hour of manual data entry work.


 
  


  
bl  br