Skip to main content

How GenAI Cost Tracking Works

Beakpoint calculates per-request costs for Large Language Model (LLM) API calls automatically. If your application is instrumented with OpenTelemetry GenAI semantic conventions and sending spans to Beakpoint, costs are calculated regardless of whether the LLM is called directly, through AWS Bedrock, Azure OpenAI, or Azure AI Foundry.

This page explains the mechanics: how platforms are detected, how model names are resolved to pricing, and how costs are calculated.

Platform Detection

Beakpoint identifies the GenAI platform from span attributes. The primary signal is gen_ai.system (or its newer equivalent gen_ai.provider.name), with server.address used as a secondary signal for implicit Azure detection.

PlatformHow DetectedResolves To
OpenAI (direct)gen_ai.system = openaiopenai
Anthropic (direct)gen_ai.system = anthropicanthropic
AWS Bedrockgen_ai.system = aws.bedrockProvider extracted from model ID (see below)
Azure OpenAI (explicit)gen_ai.system = azure.ai.openaiopenai
Azure OpenAI (implicit)gen_ai.system = openai + server.address ending .openai.azure.comopenai
Azure AI Foundrygen_ai.system = azure.ai.inference or az.ai.inferenceProvider inferred from model name (see below)

gen_ai.system vs gen_ai.provider.name

OpenTelemetry semantic conventions v1.37.0+ introduced gen_ai.provider.name as the replacement for gen_ai.system. Beakpoint accepts both. When both are present, gen_ai.provider.name takes precedence.

Most auto-instrumentation libraries now set gen_ai.provider.name. If your library only sets gen_ai.system, that works too — see the Track LLM Costs guide if you need to backfill the newer attribute.

Model Name Normalization

Model IDs vary across platforms and SDK versions. Beakpoint normalizes them before looking up pricing:

NormalizationExampleResult
OpenAI date suffixes strippedgpt-5.4-mini-2026-01-15gpt-5.4-mini
Anthropic date suffixes strippedclaude-sonnet-4-20250514claude-sonnet-4
Bedrock version suffixes strippedanthropic.claude-sonnet-4-20250514-v1:0claude-sonnet-4
Bedrock cross-region prefixes strippedus.anthropic.claude-sonnet-4-v1:0claude-sonnet-4
Legacy Anthropic aliases resolvedclaude-3-5-sonnetclaude-sonnet-4

You never need to normalize model IDs yourself — pass the ID exactly as your SDK provides it.

AWS Bedrock Model ID Parsing

Bedrock model IDs follow a specific format: [region.]provider.model-name[-date]-v{version}[:{variant}]

The pricing engine automatically:

  1. Strips cross-region prefixesus., eu., apac., global., us-gov. — so us.anthropic.claude-sonnet-4-20250514-v1:0 resolves the same as anthropic.claude-sonnet-4-20250514-v1:0
  2. Extracts the provider — the segment before the first . (e.g. anthropic, amazon, meta, mistral, cohere)
  3. Strips version suffixes-v1:0, -v2:0, etc.
  4. Strips date suffixes-20250514, etc.
  5. Resolves to the canonical model — e.g. anthropic.claude-sonnet-4-20250514-v1:0 → provider anthropic, model claude-sonnet-4

Azure AI Foundry Provider Inference

Azure AI Foundry (AI Inference) is a multi-model gateway. Since gen_ai.system identifies the gateway rather than the underlying provider, Beakpoint infers the provider from the model name:

Model name patternResolved provider
Contains gpt, or starts with o1, o3, o4openai
Starts with claudeanthropic
Starts with mistral, codestral, ministral, pixtralmistral
Starts with meta-llama, llamameta
Starts with cohere, commandcohere
Starts with jamba, ai21ai21
Starts with phimicrosoft
Anything elseazure.ai.inference (fallback)

Cost Calculation

Once the platform is detected and the model ID is normalized, cost is calculated using per-million-token rates from Beakpoint's pricing tables:

cost = (input_tokens / 1,000,000 × input_price) + (output_tokens / 1,000,000 × output_price)

where input_price and output_price are per-million-token rates for the detected model.

For models that support prompt caching (Anthropic, OpenAI), cache token counters are applied at their respective rates when present.

Costs are calculated on the parent GenAI span — the one carrying gen_ai.request.model, gen_ai.usage.input_tokens, and gen_ai.usage.output_tokens. This prevents double-counting when child spans (e.g., retry logic) duplicate token counters.

Required Span Attributes

Across all platforms, the pricing engine reads these attributes:

AttributeRequired?Description
gen_ai.systemYes (or gen_ai.provider.name)Identifies the platform
gen_ai.request.modelYesModel ID as sent to the provider
gen_ai.usage.input_tokensYesInput/prompt token count
gen_ai.usage.output_tokensYesOutput/completion token count
gen_ai.response.modelOptionalFallback if gen_ai.request.model is absent
server.addressOptionalUsed for implicit Azure OpenAI and Azure AI Foundry detection

For platform-specific optional attributes (prompt cache tokens, reasoning tokens), see the reference pages under GenAI / LLM cost calculation tags.

Next Steps