
Anthropic MessageBatch
CertifiedCreate, retrieve, or cancel an Anthropic Message Batch
Anthropic MessageBatch
Create, retrieve, or cancel an Anthropic Message Batch
Submits a batch of Messages API requests, retrieves one that already exists, or cancels it.
Retrieving returns status and request counts; once status is ended, it also returns the results URL.
Per-request outputs are written to internal storage (uri) unless fetchType is FETCH, FETCH_ONE, or NONE.
Repeat RETRIEVE from a LoopUntil task until status is ended.
Batches run asynchronously — most finish within an hour and all end within 24 hours — and are billed at half the real-time Messages API rate.
Refer to the Anthropic Console for an API key and the Message Batches guide for API behavior.
type: io.kestra.plugin.anthropic.MessageBatchExamples
Submit a message batch and retrieve it until processing ends.
id: anthropic_message_batch
namespace: company.team
tasks:
- id: create_batch
type: io.kestra.plugin.anthropic.MessageBatch
apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
mode: CREATE
requests:
- customId: capital-japan
model: claude-sonnet-4-6
maxTokens: 64
messages:
- type: USER
content: "What is the capital of Japan? Answer with one word and no punctuation."
- customId: capital-france
model: claude-sonnet-4-6
maxTokens: 64
messages:
- type: USER
content: "What is the capital of France? Answer with one word and no punctuation."
- id: wait_until_ended
type: io.kestra.plugin.core.flow.LoopUntil
condition: "{{ outputs.retrieve.status == 'ended' }}"
checkFrequency:
interval: PT30S
maxDuration: PT24H
tasks:
- id: retrieve
type: io.kestra.plugin.anthropic.MessageBatch
apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
mode: RETRIEVE
fetchType: STORE
batchId: "{{ outputs.create_batch.batchId }}"
retry:
type: constant
interval: PT30S
maxAttempts: 3
warningOnRetry: true
Cancel an in-progress message batch.
id: anthropic_cancel_message_batch
namespace: company.team
inputs:
- id: batchId
type: STRING
tasks:
- id: cancel_batch
type: io.kestra.plugin.anthropic.MessageBatch
apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
mode: CANCEL
batchId: "{{ inputs.batchId }}"
Properties
apiKey *string
Anthropic API Key
mode *string
CREATERETRIEVECANCELMode
CREATE submits requests and returns a batch id.
RETRIEVE reads status and request counts for a batchId. When status is ended, it also returns request results according to fetchType.
CANCEL asks Anthropic to stop a batch that has not ended yet.
assets
Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.
io.kestra.core.models.assets.AssetsDeclaration
IGNOREFAILWARNAsset failure behavior
Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.
Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.
The assets consumed as inputs.
io.kestra.core.models.assets.AssetIdentifier
1The assets produced as outputs.
io.kestra.plugin.ee.assets.Dataset
1150{}1150io.kestra.plugin.ee.assets.File
1150{}1150io.kestra.plugin.ee.assets.Table
1150{}1150io.kestra.plugin.ee.assets.VM
1150{}1150io.kestra.core.models.assets.External
1150{}1150io.kestra.core.models.assets.Custom
11501Custom asset type
{}1150batchId string
Batch ID
Required when mode is RETRIEVE or CANCEL. Use the batchId output of CREATE.
fetchType string
STORESTOREFETCHFETCH_ONENONEFetch type
How to return per-request results once status is ended. Ignored unless mode is RETRIEVE.
STORE (default) writes every row to Kestra internal storage as an ION file and sets uri and size.
FETCH returns every row on results.
FETCH_ONE returns only the first row on results.
NONE skips the download and returns status only.
A batch can hold 100,000 requests, so STORE avoids keeping the result file in memory and in the execution.
requests array
Requests
Required when mode is CREATE. Each item is one Messages API call. customId must be unique within the batch.
io.kestra.plugin.anthropic.MessageBatch-BatchRequest
^[a-zA-Z0-9_-]{1,64}$1Custom ID
Developer-provided id, unique within the batch. Letters, digits, '_' and '-' only, 1-64 characters. Sent unchanged. Results are not ordered, so match them on this id.
1Messages
Ordered chat turns for this request. Include at least one USER message.
io.kestra.plugin.anthropic.ChatCompletion-ChatMessage
ASSISTANTUSER1Model
Claude model for this request (for example, claude-sonnet-4-6).
>= 1Max tokens
Maximum tokens Anthropic can generate for this request. Defaults to 1024. Must be at least 1.
Prompt caching
Cache the longest cacheable prefix of this request. Cached tokens are billed at a reduced rate.
System prompt
Optional system instructions for this request.
>= 0<= 1Temperature
Sampling randomness from 0.0 to 1.0. Unset by default and only sent when provided.
>= 1Top K
Sample only from the top K tokens. Unset by default. Must be at least 1 when set.
>= 0<= 1Top P
Nucleus sampling cap from 0.0 to 1.0. Unset by default.
Outputs
batchId string
Batch ID
Anthropic id of the Message Batch.
requestCounts
Request counts
Tallies by status. Counts other than processing stay at zero until the whole batch ends.
io.kestra.plugin.anthropic.MessageBatch-RequestCounts
Canceled
Requests that were canceled.
Errored
Requests that failed.
Expired
Requests that expired before processing finished.
Processing
Requests still processing. This is the only non-zero tally until the batch ends.
Succeeded
Requests that completed successfully.
results array
Results
Per-request outputs. Set when fetchType is FETCH or FETCH_ONE and status is ended. Null for STORE, which writes uri instead. Match rows on customId; order is not guaranteed.
io.kestra.plugin.anthropic.MessageBatch-RequestResult
Cache creation input tokens
Tokens written to the prompt cache for this request.
Cache read input tokens
Tokens read from the prompt cache for this request.
Custom ID
The customId of the request this result belongs to.
Error message
Anthropic error message when the result type is errored.
Output text
Assistant text extracted from a succeeded message.
Raw response
JSON for the succeeded message, or for the error payload when the request errored.
Stop reason
Why the model stopped generating (for example, end_turn or max_tokens).
Result type
succeeded, errored, canceled, expired, or unknown.
resultsUrl string
Results URL
URL of the JSONL results file. Present once processing has ended.
size integer
Size
Number of result rows stored or returned. Set when mode is RETRIEVE, status is ended, and fetchType is not NONE.
status string
Status
Processing status: in_progress, canceling, or ended.
uri string
uriResults URI
Kestra internal storage URI of the ION results file. Set when fetchType is STORE and status is ended.
Metrics
usage.cache.creation.tokens counter
tokenTokens written to the prompt cache by succeeded requests whose results this RETRIEVE read. Emitted once, as a total.
usage.cache.read.tokens counter
tokenTokens read from the prompt cache by succeeded requests whose results this RETRIEVE read. Emitted once, as a total.
usage.input.tokens counter
tokenInput tokens consumed by succeeded requests whose results this RETRIEVE read. Emitted once, as a total.
usage.output.tokens counter
tokenOutput tokens generated by succeeded requests whose results this RETRIEVE read. Emitted once, as a total.