What instrumentation is missing
The Anthropic SDK (anthropic-sdk-go v1.23.0) exposes a Message Batches API for submitting multiple message requests for asynchronous batch processing. The anthropicRouter in trace/contrib/anthropic/traceanthropic.go only matches the exact path /v1/messages:
func anthropicRouter(cfg *middlewareConfig, path string) internal.MiddlewareTracer {
if path == "/v1/messages" {
return newMessagesTracer(cfg)
}
return nil
}
The Message Batches API paths are:
| Method |
Path |
Purpose |
POST |
/v1/messages/batches |
Submit a batch of message requests |
GET |
/v1/messages/batches/{id} |
Poll batch status |
GET |
/v1/messages/batches/{id}/results |
Stream back per-request results |
None of these match, so all batch LLM calls are silently untraced.
What could be traced
Batch creation (POST /v1/messages/batches): The request body is an array of requests[], each containing a custom_id and a full params object (model, messages, max_tokens, tools, etc.) — identical to the fields already captured by messagesTracer. A dedicated tracer could record:
braintrust.input_json: the array of message requests
braintrust.metadata: model, params from the first request (or per-request summary)
Batch results (GET /v1/messages/batches/{id}/results): The response body is an NDJSON stream where each line contains a custom_id and a full message result (including usage). This maps directly to the fields already parsed by parseUsageTokens().
Each entry in the results stream is structurally a complete Messages API response — the same token fields (input_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens) that parseUsageTokens() already handles.
SDK access point
// Create a batch
batch, err := client.Beta.Messages.Batches.New(ctx, anthropic.BetaMessageBatchNewParams{
Requests: []anthropic.BetaMessageBatchNewParamsRequests{...},
})
// Stream results
stream := client.Beta.Messages.Batches.ResultsStreaming(ctx, batch.ID)
for stream.Next() {
result := stream.Current() // BetaMessageBatchIndividualResponse
}
Braintrust docs status
unclear — The Braintrust Anthropic integration guide covers messages.create (including streaming, tool use, and prompt caching) but does not mention Message Batches. No evidence this surface is excluded by design.
Source: https://www.braintrust.dev/docs/integrations/ai-providers/anthropic
Upstream sources
Local repo files inspected
trace/contrib/anthropic/traceanthropic.go — anthropicRouter (line 105): exact-match on /v1/messages, no coverage for /v1/messages/batches or /v1/messages/batches/{id}/results
trace/contrib/anthropic/messages.go — messagesTracer and parseUsageTokens: reference pattern reusable for batch results
trace/contrib/anthropic/go.mod — anthropic-sdk-go v1.23.0 (Message Batches is available in this version)
trace/contrib/anthropic/traceanthropic_test.go — no batch-related tests
What instrumentation is missing
The Anthropic SDK (
anthropic-sdk-go v1.23.0) exposes a Message Batches API for submitting multiple message requests for asynchronous batch processing. TheanthropicRouterintrace/contrib/anthropic/traceanthropic.goonly matches the exact path/v1/messages:The Message Batches API paths are:
POST/v1/messages/batchesGET/v1/messages/batches/{id}GET/v1/messages/batches/{id}/resultsNone of these match, so all batch LLM calls are silently untraced.
What could be traced
Batch creation (
POST /v1/messages/batches): The request body is an array ofrequests[], each containing acustom_idand a fullparamsobject (model, messages, max_tokens, tools, etc.) — identical to the fields already captured bymessagesTracer. A dedicated tracer could record:braintrust.input_json: the array of message requestsbraintrust.metadata: model, params from the first request (or per-request summary)Batch results (
GET /v1/messages/batches/{id}/results): The response body is an NDJSON stream where each line contains acustom_idand a full message result (includingusage). This maps directly to the fields already parsed byparseUsageTokens().Each entry in the results stream is structurally a complete Messages API response — the same token fields (
input_tokens,output_tokens,cache_creation_input_tokens,cache_read_input_tokens) thatparseUsageTokens()already handles.SDK access point
Braintrust docs status
unclear — The Braintrust Anthropic integration guide covers
messages.create(including streaming, tool use, and prompt caching) but does not mention Message Batches. No evidence this surface is excluded by design.Source: https://www.braintrust.dev/docs/integrations/ai-providers/anthropic
Upstream sources
anthropic-sdk-gov1.23.0:client.Beta.Messages.BatchesLocal repo files inspected
trace/contrib/anthropic/traceanthropic.go—anthropicRouter(line 105): exact-match on/v1/messages, no coverage for/v1/messages/batchesor/v1/messages/batches/{id}/resultstrace/contrib/anthropic/messages.go—messagesTracerandparseUsageTokens: reference pattern reusable for batch resultstrace/contrib/anthropic/go.mod—anthropic-sdk-gov1.23.0 (Message Batches is available in this version)trace/contrib/anthropic/traceanthropic_test.go— no batch-related tests