ReqAnthropic.Batches (ReqAnthropic v0.2.1)

Copy Markdown View Source

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

cancel(id, opts \\ [])

@spec cancel(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}

create(opts)

@spec create(keyword()) ::
  {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}

delete(id, opts \\ [])

@spec delete(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}

get(id, opts \\ [])

@spec get(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}

list(opts \\ [])

@spec list(keyword()) ::
  {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}

results(id, opts \\ [])

@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.