The Message Batches API: submit large volumes of Messages requests for asynchronous processing at a 50% discount.
ReqAnthropic.Batches.create(
requests: [
%{
custom_id: "req-1",
params: %{
model: "claude-haiku-4-5",
max_tokens: 256,
messages: [%{role: "user", content: "ping"}]
}
}
]
)Use results/2 to stream the JSONL results back as decoded maps.
Summary
Functions
Stream the results of a completed batch. The results endpoint returns newline-delimited JSON; each yielded element is a decoded map.
Functions
@spec cancel( String.t(), keyword() ) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}
@spec create(keyword()) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}
@spec delete( String.t(), keyword() ) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}
@spec get( String.t(), keyword() ) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}
@spec list(keyword()) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}
@spec results( String.t(), keyword() ) :: {:ok, Enumerable.t()} | {:error, term()}
Stream the results of a completed batch. The results endpoint returns newline-delimited JSON; each yielded element is a decoded map.