Summary
The Anthropic Ruby SDK provides client.messages.batches for submitting multiple message requests for asynchronous Claude inference. This is a generative AI execution surface — each item in a batch runs the Claude model and produces a completion — but it is not instrumented. The SDK currently instruments the synchronous (messages.create) and streaming (messages.stream) paths for Anthropic, but not the batch path.
What is missing
The Messages Batch API (Anthropic::Resources::Messages::Batches) exposes these generative execution methods:
batches.create(requests: [...])
Submits up to 10,000 message requests for asynchronous processing. Each request item is a full MessagesCreateParams with a caller-provided custom_id. Returns a MessageBatch with a processing_status and a results_url.
batch = client.messages.batches.create(
requests: [
{ custom_id: "req-1", params: { model: "claude-opus-4-5", max_tokens: 1024, messages: [...] } },
{ custom_id: "req-2", params: { model: "claude-opus-4-5", max_tokens: 1024, messages: [...] } }
]
)
batches.results(batch_id)
Streams back the completed results once the batch finishes processing. Each result item contains a custom_id, a result type (succeeded, errored, expired), and for successes a full Message response object including content, usage tokens, model, and stop reason.
What instrumentation should capture
Because batch execution is asynchronous, tracing requires instrumenting both sides:
At submit time (batches.create):
- Each request item as input (messages, system prompt, model, max_tokens, tools, tool_choice, etc.)
- Batch-level metadata: total request count, model(s), custom IDs
At result time (batches.results):
- Each result item's output (content blocks, stop_reason)
- Per-item token metrics (input_tokens, output_tokens, cache tokens) from the Message usage object
- Per-item success/error status
A reasonable implementation is to emit one Braintrust span per batch result item when results are retrieved, carrying the original input from the corresponding custom_id request, matching the pattern the sync Messages integration already uses per-call.
Braintrust docs status
not_found — The Braintrust Anthropic integration docs at https://www.braintrust.dev/docs/integrations/ai-providers/anthropic and the Ruby SDK docs at https://www.braintrust.dev/docs do not mention batch API tracing. No Ruby-side batch instrumentation is documented anywhere in Braintrust's published docs.
Upstream sources
Local repo files inspected
lib/braintrust/contrib/anthropic/patcher.rb — defines MessagesPatcher and BetaMessagesPatcher; no BatchesPatcher
lib/braintrust/contrib/anthropic/instrumentation/messages.rb — wraps create() and stream() on Anthropic::Resources::Messages; no batches wrapper
lib/braintrust/contrib/anthropic/instrumentation/beta_messages.rb — wraps create() and stream() on beta messages; no batches wrapper
- Grep for
batches, MessageBatch, batch_id, custom_id across lib/braintrust/ returns zero matches
Summary
The Anthropic Ruby SDK provides
client.messages.batchesfor submitting multiple message requests for asynchronous Claude inference. This is a generative AI execution surface — each item in a batch runs the Claude model and produces a completion — but it is not instrumented. The SDK currently instruments the synchronous (messages.create) and streaming (messages.stream) paths for Anthropic, but not the batch path.What is missing
The Messages Batch API (
Anthropic::Resources::Messages::Batches) exposes these generative execution methods:batches.create(requests: [...])Submits up to 10,000 message requests for asynchronous processing. Each request item is a full
MessagesCreateParamswith a caller-providedcustom_id. Returns aMessageBatchwith aprocessing_statusand aresults_url.batches.results(batch_id)Streams back the completed results once the batch finishes processing. Each result item contains a
custom_id, a result type (succeeded,errored,expired), and for successes a fullMessageresponse object including content, usage tokens, model, and stop reason.What instrumentation should capture
Because batch execution is asynchronous, tracing requires instrumenting both sides:
At submit time (
batches.create):At result time (
batches.results):A reasonable implementation is to emit one Braintrust span per batch result item when results are retrieved, carrying the original input from the corresponding
custom_idrequest, matching the pattern the sync Messages integration already uses per-call.Braintrust docs status
not_found— The Braintrust Anthropic integration docs at https://www.braintrust.dev/docs/integrations/ai-providers/anthropic and the Ruby SDK docs at https://www.braintrust.dev/docs do not mention batch API tracing. No Ruby-side batch instrumentation is documented anywhere in Braintrust's published docs.Upstream sources
Anthropic::Resources::Messages::Batches: https://github.com/anthropics/anthropic-sdk-rubyLocal repo files inspected
lib/braintrust/contrib/anthropic/patcher.rb— definesMessagesPatcherandBetaMessagesPatcher; noBatchesPatcherlib/braintrust/contrib/anthropic/instrumentation/messages.rb— wrapscreate()andstream()onAnthropic::Resources::Messages; nobatcheswrapperlib/braintrust/contrib/anthropic/instrumentation/beta_messages.rb— wrapscreate()andstream()on beta messages; no batches wrapperbatches,MessageBatch,batch_id,custom_idacrosslib/braintrust/returns zero matches