The Message Batches API: many Messages requests processed asynchronously at half price.
{:ok, batch} =
Jibu.Batches.create(client, %{
requests: [%{custom_id: "a", params: %{model: "claude-opus-5-5", max_tokens: 1024, messages: messages}}]
})Poll get/2 until processing_status is "ended". Then read results/2.
Results arrive in any order. Match them by custom_id.
Results are the API's JSON with string keys. See the batches guide.
Summary
Functions
Cancels a batch. Requests already processed keep their results.
Creates a batch. The body is sent unchanged.
Deletes a batch that has ended.
Retrieves a batch, including its processing_status and request_counts.
Returns one page. query takes the API's parameters, such as :limit and :after_id.
Fetches the results of an ended batch and returns them as a lazily decoded stream of maps.
Streams all batches across pages, forward only. Raises Jibu.Error when a page fails.
Functions
@spec cancel(Req.Request.t(), String.t()) :: {:ok, map()} | {:error, Jibu.Error.t()}
Cancels a batch. Requests already processed keep their results.
@spec create(Req.Request.t(), map()) :: {:ok, map()} | {:error, Jibu.Error.t()}
Creates a batch. The body is sent unchanged.
@spec delete(Req.Request.t(), String.t()) :: {:ok, map()} | {:error, Jibu.Error.t()}
Deletes a batch that has ended.
@spec get(Req.Request.t(), String.t()) :: {:ok, map()} | {:error, Jibu.Error.t()}
Retrieves a batch, including its processing_status and request_counts.
@spec list(Req.Request.t(), keyword()) :: {:ok, map()} | {:error, Jibu.Error.t()}
Returns one page. query takes the API's parameters, such as :limit and :after_id.
@spec results(Req.Request.t(), String.t()) :: {:ok, Enumerable.t()} | {:error, Jibu.Error.t()}
Fetches the results of an ended batch and returns them as a lazily decoded stream of maps.
The whole JSONL body is held in memory while the stream is consumed.
@spec stream(Req.Request.t(), keyword()) :: Enumerable.t()
Streams all batches across pages, forward only. Raises Jibu.Error when a page fails.