Skip to main content

GenAI Span Attribute Reference

Last updated on

GenAI semantic conventions are the standard OpenTelemetry attribute names for AI calls. They are what allow Cloud & AI Cost Management (CACM) to read a span and calculate cost: the provider, the model, and the token counts all come from these fields. A span that lacks them is still a valid trace, but it cannot be priced.

This page lists the attributes CACM reads, which ones are required to price a call, and which ones improve accuracy or enable grouping.

GenAI semantic conventions required

CACM prices only spans that carry GenAI semantic-convention attributes. Standard HTTP, database, or function spans do not carry the model name or token counts needed for cost, so they appear in a trace but are never priced. Go to How AI Traces Work to understand how spans become cost.


Minimum Attributes for Pricing

If you can only send a subset of attributes, CACM needs at minimum the following to calculate cost:

AttributePurpose
gen_ai.provider.nameLLM provider (openai, anthropic, bedrock). The legacy gen_ai.system is also supported.
gen_ai.request.modelModel requested, matched against Harness pricing data.
gen_ai.usage.input_tokensInput tokens (priced).
gen_ai.usage.output_tokensOutput tokens (priced).

A span missing any of these cannot be priced. If you also want cost associated with a specific agent, set gen_ai.agent.name.


Full Attribute Reference

Each LLM span is expected to carry the following attributes. The four pricing-critical fields are marked in Minimum attributes for pricing; the rest improve pricing accuracy or enable grouping by service, session, tenant, and user.

AttributePurpose
service.nameApplication or service that made the call.
service.namespaceLogical grouping (domain, product area).
deployment.environment.nameEnvironment (production, staging, dev).
gen_ai.operation.nameOperation type (chat, embeddings, tool).
gen_ai.provider.nameLLM provider (openai, anthropic, bedrock).
gen_ai.request.modelModel requested.
gen_ai.response.modelModel that actually served the response.
gen_ai.response.idProvider response identifier.
gen_ai.conversation.idSession or conversation grouping.
gen_ai.request.max_tokensRequested token cap.
gen_ai.request.temperatureSampling temperature.
gen_ai.response.finish_reasonsWhy generation stopped.
gen_ai.usage.input_tokensInput tokens (priced).
gen_ai.usage.cache_read.input_tokensCached input tokens read (priced at cache-read rate).
gen_ai.usage.cache_creation.input_tokensInput tokens written to cache (priced at cache-write rate).
gen_ai.usage.output_tokensOutput tokens (priced).
gen_ai.usage.reasoning.output_tokensReasoning tokens (priced at reasoning rate).
gen_ai.input.messagesRaw prompt text.
gen_ai.output.messagesRaw response text.
tenant.idCustomer or tenant attribution.
user.idEnd-user attribution.

How Attributes Map to Cost and Grouping

The attributes fall into three roles:

  • Pricing inputs: gen_ai.provider.name, gen_ai.request.model, and the gen_ai.usage.* token counts. CACM prices a span as tokens times model price using these fields.
  • Accuracy refinements: the cache and reasoning token counts (gen_ai.usage.cache_read.input_tokens, gen_ai.usage.cache_creation.input_tokens, gen_ai.usage.reasoning.output_tokens) allow CACM to price at the correct per-token rate rather than the standard input/output rate.
  • Grouping dimensions: service.name, deployment.environment.name, gen_ai.conversation.id, gen_ai.agent.name, tenant.id, and user.id allow you to group and filter cost by service, environment, session, agent, tenant, and user in Cost Explorer.
Raw prompt and response text is optional

gen_ai.input.messages and gen_ai.output.messages carry the raw prompt and completion. They are useful for debugging but inflate span size. Disable payload capture if spans contain sensitive data or grow too large. Go to Set Up AI Cost Traces to reduce trace data volume.


Next Steps