Anthropic Claude
Examples use Python. Beakpoint works with any language that OpenTelemetry supports.
Required Anthropic Claude Attributes
Beakpoint requires the following cost calculation tags on traces from Anthropic Claude API calls.
For a complete, runnable example, see Quill — Beakpoint's reference application for multi-model LLM cost attribution. Quill's tracing.py shows the full OpenTelemetry setup, and analyzer.py demonstrates instrumented API calls.
Always Required Fields
Provide these fields on every Claude API span:
| Attribute Name | Example Value | Allowed Values |
|---|---|---|
gen_ai.system | anthropic | anthropic (required for direct Anthropic API calls; use bedrock or azure-ai for those platforms — see GenAI Cost Tracking) |
gen_ai.request.model | claude-sonnet-4-6 | Any valid Anthropic model name |
gen_ai.usage.input_tokens | 512 | Non-negative integer |
gen_ai.usage.output_tokens | 128 | Non-negative integer |
The Anthropic auto-instrumentor sets gen_ai.provider.name but not gen_ai.system. Add a custom SpanProcessor that copies gen_ai.provider.name to gen_ai.system on span start. See the _GenAiSystemProcessor in Quill for the implementation pattern, or the Track LLM Costs guide for step-by-step setup.
Optional Enrichment Attributes
These fields are optional but improve cost accuracy when provided:
| Attribute Name | Example Value | Description |
|---|---|---|
gen_ai.response.model | claude-sonnet-4-6-20250514 | The exact model version returned in the response. When present, overrides gen_ai.request.model for pricing lookups. |
gen_ai.usage.input_tokens.cache_creation | 256 | Tokens written to the prompt cache. Billed at a premium rate above standard input pricing. |
gen_ai.usage.input_tokens.cache_read | 128 | Tokens read from the prompt cache. Billed at a significantly reduced rate. Always pair with cache_creation when using prompt caching. |
gen_ai.provider.name | anthropic | Auto-set by the Anthropic instrumentor. Copy this to gen_ai.system via your SpanProcessor. |
cloud.provider | anthropic | Provider identification. Set automatically by the _GenAiSystemProcessor pattern. |
Supported Models
Use the following pricing rates (per 1M tokens, USD) to calculate Claude costs:
| Model | Input ($/M) | Cache Creation ($/M) | Cache Read ($/M) | Output ($/M) |
|---|---|---|---|---|
claude-sonnet-5 | $3.00 | $3.75 | $0.30 | $15.00 |
claude-sonnet-4-6 | $3.00 | $3.75 | $0.30 | $15.00 |
claude-sonnet-4 | $3.00 | $3.75 | $0.30 | $15.00 |
claude-opus-4 | $15.00 | $18.75 | $1.50 | $75.00 |
claude-haiku-4-5 | $0.80 | $1.00 | $0.08 | $4.00 |
claude-haiku-3-5 | $0.80 | $1.00 | $0.08 | $4.00 |
Prices reflect Anthropic list pricing and may change. Beakpoint keeps these rates up to date, but check the Anthropic pricing page for the latest figures. These same rates apply to Claude models accessed through AWS Bedrock and Azure AI Foundry.
Python Example
Use the opentelemetry-instrumentation-anthropic package with a custom SpanProcessor to set gen_ai.system. This example is adapted from Quill:
pip install opentelemetry-instrumentation-anthropic
from opentelemetry.instrumentation.anthropic import AnthropicInstrumentor
import anthropic
# Instrument before creating the client (see Track LLM Costs guide
# for the full TracerProvider setup including _GenAiSystemProcessor)
AnthropicInstrumentor().instrument()
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=4096,
system="You are a helpful assistant.",
messages=[{"role": "user", "content": "Hello!"}],
)
The instrumentation automatically sets gen_ai.provider.name, gen_ai.request.model, gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, and the optional cache token counters whenever they are available in the API response. The _GenAiSystemProcessor copies gen_ai.provider.name to gen_ai.system and cloud.provider.
For full setup instructions, including how to configure the OpenTelemetry exporter for Beakpoint, see the Track LLM Costs guide.