Messages batch processing
Submit independent Anthropic-format items with stable application identifiers.
The compatible Message Batches interface stores each item and executes it through the ordinary Messages inference route. It is not a provider-native discounted batch submission. Use a persistent Model API credential; temporary browser sessions are not batch credentials.
Request: create
curl https://api.b2b-llm.com/v1/messages/batches \
-H "x-api-key: $B2B_API_KEY" -H 'anthropic-version: 2023-06-01' \
-H 'Content-Type: application/json' \
-d '{"requests":[{"custom_id":"invoice-summary-001","params":{"model":"claude-sonnet-4.6","max_tokens":256,"messages":[{"role":"user","content":"Summarize this invoice description."}]}}]}'
Response
{"id":"msgbatch_EXAMPLE","type":"message_batch","processing_status":"in_progress","request_counts":{"processing":1,"succeeded":0,"errored":0,"canceled":0,"expired":0},"results_url":null}
Read and control
GET /v1/messages/batches
GET /v1/messages/batches/BATCH_ID
POST /v1/messages/batches/BATCH_ID/cancel
GET /v1/messages/batches/BATCH_ID/results
Results are JSON Lines. Associate them by custom_id, not output order:
{"custom_id":"invoice-summary-001","result":{"type":"succeeded","message":{"type":"message","content":[{"type":"text","text":"The invoice covers scheduled service."}]}}}
Give every item a unique ID and do not enable streaming or nested async inside a batch. Cancellation prevents queued items from starting; already-running items can finish. Use the returned expiry and result URL rather than constructing storage assumptions.
Funding and accounting
Creating a company batch requires available funds and spending allowance and is bounded by storage/job/item quotas. Existing read/control operations can remain available at zero balance for a valid credential. Each item needs permission and available budget when execution starts; queued work can resume after a top-up or authorized limit adjustment. Execution is at-least-once after interruptions, so application tool side effects need their own idempotency.
Each executed item has a separate request record with its batch identity and snapshotted batch price coefficient. That coefficient belongs to the billing template and defaults to one. Official reference prices and resettable usage valuation are separate from the actual debit.