Files & Batches
Retrieve Message Batch Results
Streams the results of a Message Batch as JSONL.
Overview
Stream the results of a Message Batch as JSONL, one line per request. Read the results after processing_status is ended. This is the same URL as results_url in the batch object.
Notes
- Each line is
{"custom_id": "...", "result": {...}}. Lines are in no fixed order; match each one bycustom_id. result.typeissucceeded(withmessage, the same body as a Create Message response),errored(witherror),canceled, orexpired.- In
message,modelis the model ID you sent in the request. - A batch that does not exist or was deleted returns
404. A batch that is not ready to be read yet can return409; retry later.
Request
curl -X GET "https://api.tokenlab.sh/v1/messages/batches/msgbatch_01ABC123/results" \
-H "x-api-key: sk-your-api-key" \
-H "anthropic-version: 2023-06-01"Response
{"custom_id":"request-1","result":{"type":"succeeded","message":{"id":"msg_abc123","type":"message","role":"assistant","content":[{"type":"text","text":"Hello! How can I help you today?"}],"model":"claude-sonnet-5","stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":9}}}}
{"custom_id":"request-2","result":{"type":"errored","error":{"type":"error","error":{"type":"invalid_request_error","message":"messages: at least one message is required"}}}}
{"custom_id":"request-3","result":{"type":"canceled"}}
{"custom_id":"request-4","result":{"type":"expired"}}Important fields
custom_idstring
The
custom_id you set on the request.result.typestring
succeeded, errored, canceled, or expired.result.messageobject
The message, when
result.type is succeeded.result.errorobject
The error, when
result.type is errored.Authorization
BearerAuth AuthorizationBearer <token>
API Key authentication. Create or manage API keys in Dashboard > API > API Keys.
In: header
Path Parameters
message_batch_id*string
Message batch identifier
Response
application/x-ndjson
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json