GenAI Span Attribute Reference
The OpenTelemetry GenAI semantic-convention attributes Cloud & AI Cost Management reads from each span to price and attribute AI cost.
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.
Minimum Attributes for Pricing
If you can only send a subset of attributes, CACM needs at minimum the following to calculate cost:
gen_ai.provider.name
LLM provider (openai, anthropic, bedrock). The legacy gen_ai.system is also supported.
gen_ai.request.model
Model requested, matched against Harness pricing data.
gen_ai.usage.input_tokens
Input tokens (priced).
gen_ai.usage.output_tokens
Output 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.
service.name
Application or service that made the call.
service.namespace
Logical grouping (domain, product area).
deployment.environment.name
Environment (production, staging, dev).
gen_ai.operation.name
Operation type (chat, embeddings, tool).
gen_ai.provider.name
LLM provider (openai, anthropic, bedrock).
gen_ai.request.model
Model requested.
gen_ai.response.model
Model that actually served the response.
gen_ai.response.id
Provider response identifier.
gen_ai.agent.name
Agent name for cost grouping. Set this to attribute cost to a specific agent in Cost Explorer.
gen_ai.conversation.id
Session or conversation grouping.
gen_ai.request.max_tokens
Requested token cap.
gen_ai.request.temperature
Sampling temperature.
gen_ai.response.finish_reasons
Why generation stopped.
gen_ai.usage.input_tokens
Input tokens (priced).
gen_ai.usage.cache_read.input_tokens
Cached input tokens read (priced at cache-read rate).
gen_ai.usage.cache_creation.input_tokens
Input tokens written to cache (priced at cache-write rate).
gen_ai.usage.output_tokens
Output tokens (priced).
gen_ai.usage.reasoning.output_tokens
Reasoning tokens (priced at reasoning rate).
gen_ai.input.messages
Raw prompt text.
gen_ai.output.messages
Raw response text.
tenant.id
Customer or tenant attribution.
user.id
End-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 thegen_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, anduser.idallow you to group and filter cost by service, environment, session, agent, tenant, and user in Cost Explorer.
Next Steps
Go to Manual Instrumentation to emit these attributes from your application.
Go to Supported Providers and Frameworks to check which SDKs and frameworks emit these attributes natively.
Go to How AI Traces Work to understand how spans become cost.
Go to AI Cost Troubleshooting if traces appear without cost.
Go to the AI Cost Management FAQ to review common questions.
Last updated
Was this helpful?