
batch-processing
Message Batches API for Claude with 50% cost savings on bulk processing. Activate for batch jobs, JSONL processing, bulk analysis, and cost optimization.
- Installs
- 64
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/thelobbi/claude --skill batch-processing- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads batch-processing automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Batch Processing Skill
Leverage Anthropic's Message Batches API for 50% cost savings on bulk processing workloads.
When to Use This Skill
- Processing 10K+ documents
- Model evaluation and benchmarks
- ETL and data enrichment
- Training data generation
- Bulk content analysis
- Any non-time-sensitive workload
Cost Savings
| Processing Type | Cost |
|---|---|
| Standard API | 100% |
| Batch API | 50% |
Example: 1M tokens @ $3/1M = $3 (standard) vs $1.50 (batch)
Batch Lifecycle
Created → Processing → Ended (completed/failed/expired/canceled)
- Processing time: Up to 24 hours
- Results retention: 29 days
- Full feature support: Tools, vision, system prompts
Core Implementation
Step 1: Create JSONL File
import json
# Each line is a complete request
requests = [
{
"custom_id": "request-1",
"params": {
"model": "claude-sonnet-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize: Document 1..."}]
}
},
{
"custom_id": "request-2",
"params": {
"model": "claude-sonnet-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize: Document 2..."}]
}
}
]
# Write JSONL file
with open("batch_requests.jsonl", "w") as f:
for request in requests:
f.write(json.dumps(request) + "\n")
Step 2: Submit Batch
import anthropic
client = anthropic.Anthropic()
# Create batch from file
with open("batch_requests.jsonl", "rb") as f:
batch = client.beta.messages.batches.create(
requests=f
)
print(f"Batch ID: {batch.id}")
print(f"Status: {batch.processing_status}")
Step 3: Poll for Completion
import time
def wait_for_batch(client, batch_id, poll_interval=60):
"""Poll until batch completes"""
while True:
batch = client.beta.messages.batches.retrieve(batch_id)
if batch.processing_status == "ended":
print(f"Batch completed!")
print(f" Succeeded: {batch.request_counts.succeeded}")
print(f" Errored: {batch.request_counts.errored}")
print(f" Expired: {batch.request_counts.expired}")
return batch
print(f"Status: {batch.processing_status} - waiting...")
time.sleep(poll_interval)
Step 4: Stream Results
def process_results(client, batch_id):
"""Stream and process batch results"""
results = {}
for result in client.beta.messages.batches.results(batch_id):
custom_id = result.custom_id
if result.result.type == "succeeded":
message = result.result.message
results[custom_id] = {
"status": "success",
"content": message.content[0].text,
"usage": message.usage
}
elif result.result.type == "errored":
results[custom_id] = {
"status": "error",
"error": result.result.error
}
elif result.result.type == "expired":
results[custom_id] = {
"status": "expired"
}
return results
Complete Workflow
import anthropic
import json
import time
def run_batch_job(documents):
"""Complete batch processing workflow"""
client = anthropic.Anthropic()
# 1. Create requests
requests = []
for i, doc in enumerate(documents):
requests.append({
"custom_id": f"doc-{i}",
"params": {
"model": "claude-sonnet-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": f"Summarize: {doc}"}]
}
})
# 2. Write JSONL
with open("batch.jsonl", "w") as f:
for req in requests:
f.write(json.dumps(req) + "\n")
# 3. Submit batch
with open("batch.jsonl", "rb") as f:
batch = client.beta.messages.batches.create(requests=f)
print(f"Batch submitted: {batch.id}")
# 4. Wait for completion
while True:
batch = client.beta.messages.batches.retrieve(batch.id)
if batch.processing_status == "ended":
break
time.sleep(60)
# 5. Collect results
results = {}
for result in client.beta.messages.batches.results(batch.id):
if result.result.type == "succeeded":
results[result.custom_id] = result.result.message.content[0].text
return results
Error Handling
Retry Failed Requests
def retry_failed(client, original_batch_id):
"""Retry failed and expired requests"""
retry_requests = []
for result in client.beta.messages.batches.results(original_batch_id):
if result.result.type in ["errored", "expired"]:
# Re-create the request (you'll need to store original params)
retry_requests.append({
"custom_id": result.custom_id,
"params": get_original_params(result.custom_id) # Your implementation
})
if retry_requests:
# Write and submit retry batch
with open("retry.jsonl", "w") as f:
for req in retry_requests:
f.write(json.dumps(req) + "\n")
with open("retry.jsonl", "rb") as f:
return client.beta.messages.batches.create(requests=f)
return None
Error Types
| Result Type | Action |
|---|---|
succeeded | Process normally |
errored | Check error, may retry |
expired | Request took >24h, retry |
canceled | Batch was canceled |
API Reference
Endpoints
| Method | Endpoint | Purpose |
|---|---|---|
| POST | /v1/messages/batches | Create batch |
| GET | /v1/messages/batches/{id} | Get batch status |
| GET | /v1/messages/batches | List batches |
| POST | /v1/messages/batches/{id}/cancel | Cancel batch |
| GET | /v1/messages/batches/{id}/results | Stream results |
Request Format
{
"custom_id": "unique-identifier",
"params": {
"model": "claude-sonnet-5",
"max_tokens": 1024,
"system": "Optional system prompt",
"messages": [{"role": "user", "content": "..."}],
"tools": []
}
}
Best Practices
DO:
- Use for workloads >100 requests
- Include unique custom_id for tracking
- Store original params for retry logic
- Monitor batch status via polling
- Process results as streaming JSONL
DON'T:
- Use for time-sensitive requests
- Expect immediate results
- Forget to handle expired requests
- Ignore error results
Cost Optimization Tips
- Batch similar requests - Same model, similar prompts
- Combine with caching - Cache static context before batch
- Use appropriate model - Haiku for simple tasks, Sonnet for complex
- Optimize prompts - Shorter prompts = lower cost
Use Case: Document Processing
# Process 10,000 documents at 50% cost
documents = load_documents("data/*.txt") # 10K files
# Create batch with consistent format
requests = [{
"custom_id": doc.id,
"params": {
"model": "claude-haiku-4-5", # Cheapest for bulk
"max_tokens": 512,
"system": "Extract key information as JSON.",
"messages": [{"role": "user", "content": doc.content}]
}
} for doc in documents]
# Run batch job
results = run_batch_job(requests)
# Cost: ~50% of standard API!
See Also
- llm-integration - API basics
- prompt-caching - Cache context
- streaming - Real-time output
FAQ
What does the batch-processing skill do?
Message Batches API for Claude with 50% cost savings on bulk processing. Activate for batch jobs, JSONL processing, bulk analysis, and cost optimization.
How do I install batch-processing?
Run npx skills add https://github.com/thelobbi/claude --skill batch-processing in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/batch-processing/ (personal) or .claude/skills/batch-processing/ (project).
Which AI agents can use batch-processing?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is batch-processing safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains batch-processing?
It is published by thelobbi in thelobbi/claude. It has 64 recorded installs.
More from thelobbi/claude
vision-multimodal
thelobbi/claude
Vision and multimodal capabilities for Claude including image analysis, PDF processing, and document understanding. Activate for image input, base64 encoding, multiple images, and visual analysis.
design-system
thelobbi/claude
Open the skill to read its SKILL.md instructions.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.