← home
RESEARCH · OPERATIONS

OpenTelemetry GenAI cost tracking.

Operations guide · 11 June 2026

By the LLM CFO team

OpenTelemetry GenAI semantic conventions define a standard set of attributes to track LLM requests: provider, model, token counts, and cache behavior. Using them as your telemetry foundation makes cost derivation, vendor swaps, and multi-provider reconciliation straightforward.

What the GenAI conventions are

OpenTelemetry's GenAI conventions are a published schema for instrumenting generative AI workloads. They define which span and event attributes to record so that LLM requests are observable across observability backends. Using them eliminates the need to invent your own token-tracking fields; instead, you write once to a standard and then export to any backend that understands the schema.

Key attributes for cost tracking

Deriving cost from attributes

Once you have these attributes in your spans, calculating cost becomes a lookup join:

  1. Build a price table. Keys are (provider, model, token_type), values are cost-per-million-tokens. Separate rows for input, output, cache-write, and cache-read to account for provider discounts.
  2. Join the span to the price table. Use gen_ai.system, gen_ai.response.model, and token type to look up the unit price.
  3. Apply token counts separately. Multiply gen_ai.usage.input_tokens by the input price, output_tokens by the output price, cache_creation_input_tokens by the cache-write price (usually identical to input), and cache_read_input_tokens by the cache-read price (OpenAI ~50% discount, Anthropic ~90% discount).
  4. Sum and emit. Total cost = (input_tokens × input_price) + (output_tokens × output_price) + (cache_creation_input_tokens × input_price) + (cache_read_input_tokens × cache_read_price).

Where to export these spans

Common pitfalls

Cost tracking rule: if your telemetry does not distinguish cache-read tokens from regular input tokens, your cost dashboard will systematically overstate the per-token expense and miss the largest optimization opportunity.

Integration with observability stacks

Most observability platforms (Datadog, New Relic, OpenTelemetry Protocol exporters) understand the GenAI conventions or have published mappings. Start by instrumenting your LLM client library to emit the attributes to an OpenTelemetry API collector, then export via OTLP to your chosen backend. If your backend does not natively understand the GenAI schema, define a simple transformation rule that maps the attributes to your internal cost model.

Related

← Back to llmcfo.com