Summary
The extract_anthropic_usage() function reads token counts from the Anthropic usage object but silently drops the service_tier and inference_geo fields. These fields are part of the Anthropic Messages API response's usage object, are present in the Anthropic Python SDK's Usage type, and Braintrust's Anthropic integration docs state that other SDKs capture them as metadata.
What is missing
Anthropic's Messages API returns two non-token fields inside the usage object:
"usage": {
"input_tokens": 200,
"output_tokens": 50,
"service_tier": "priority",
"inference_geo": "us-east-1"
}
service_tier ("standard" | "priority" | "batch") — which pricing tier processed the request. Priority tier costs more; batch tier is 50% cheaper. Missing this field means cost attribution may use wrong pricing assumptions.
inference_geo (string) — geographic region where inference ran. Relevant for data residency compliance and latency analysis.
Currently in src/extractors.rs:92-188, extract_anthropic_usage() reads the usage object and extracts only token-related fields (input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens, reasoning_tokens, output_tokens_details). Both service_tier and inference_geo are present in the same object but are not read.
The UsageMetrics return type (src/types.rs) is purely token-focused (Option<u32> fields), so there is currently no field to hold string-valued execution metadata. The fix would likely involve either expanding the extractor's return type or providing a separate metadata extraction path so these values can be logged to the span's metadata field.
Why this matters
- Cost accuracy: Braintrust calculates costs per span. Without
service_tier, priority-tier or batch-tier requests may be costed at standard rates.
- Compliance:
inference_geo tells users where their data was processed — important for regulated workloads.
Braintrust docs status
supported — The Braintrust Anthropic integration page states: "Metadata fields track service tier, inference geography, and ephemeral cache variants." Other Braintrust SDKs (TypeScript, Python, Go, Ruby, Java, .NET) capture these fields.
Upstream sources
Relationship to existing issues
Local files inspected
src/extractors.rs — extract_anthropic_usage() (lines 92-188) reads token fields from usage but does not read service_tier or inference_geo
src/types.rs — UsageMetrics struct has only Option<u32> fields; no support for string-valued execution metadata
- Full codebase grep for
service_tier, inference_geo — zero results
Summary
The
extract_anthropic_usage()function reads token counts from the Anthropicusageobject but silently drops theservice_tierandinference_geofields. These fields are part of the Anthropic Messages API response'susageobject, are present in the Anthropic Python SDK'sUsagetype, and Braintrust's Anthropic integration docs state that other SDKs capture them as metadata.What is missing
Anthropic's Messages API returns two non-token fields inside the
usageobject:service_tier("standard"|"priority"|"batch") — which pricing tier processed the request. Priority tier costs more; batch tier is 50% cheaper. Missing this field means cost attribution may use wrong pricing assumptions.inference_geo(string) — geographic region where inference ran. Relevant for data residency compliance and latency analysis.Currently in
src/extractors.rs:92-188,extract_anthropic_usage()reads theusageobject and extracts only token-related fields (input_tokens,output_tokens,cache_read_input_tokens,cache_creation_input_tokens,reasoning_tokens,output_tokens_details). Bothservice_tierandinference_geoare present in the same object but are not read.The
UsageMetricsreturn type (src/types.rs) is purely token-focused (Option<u32>fields), so there is currently no field to hold string-valued execution metadata. The fix would likely involve either expanding the extractor's return type or providing a separate metadata extraction path so these values can be logged to the span'smetadatafield.Why this matters
service_tier, priority-tier or batch-tier requests may be costed at standard rates.inference_geotells users where their data was processed — important for regulated workloads.Braintrust docs status
supported — The Braintrust Anthropic integration page states: "Metadata fields track service tier, inference geography, and ephemeral cache variants." Other Braintrust SDKs (TypeScript, Python, Go, Ruby, Java, .NET) capture these fields.
Upstream sources
Usagetype definesservice_tier: Optional[Literal["standard", "priority", "batch"]]andinference_geo: Optional[str]: https://github.com/anthropics/anthropic-sdk-python/blob/main/src/anthropic/types/usage.pyRelationship to existing issues
server_tool_usesub-object) — different fields within the sameusageobjectcache_creationsub-object) — different fields within the sameusageobjectLocal files inspected
src/extractors.rs—extract_anthropic_usage()(lines 92-188) reads token fields fromusagebut does not readservice_tierorinference_geosrc/types.rs—UsageMetricsstruct has onlyOption<u32>fields; no support for string-valued execution metadataservice_tier,inference_geo— zero results