Skip to Content

How do I track LLM cost per release?

Rius splits LLM cost per release when you tag your runs with a version, and then compares cost per trace between two versions on the agent page. Set RIUS_MAIN_AGENT_VERSION for the prompt, tools and policy, or RIUS_SERVICE_VERSION for the build. The split shows in Versions, Compare and Drift in the console, and over MCP through the agent version tools.

How it works

Two things on your spans make the split work: a version, and the model and token usage that Rius prices.

  • The version. RIUS_MAIN_AGENT_VERSION names the agent definition, meaning its prompt, tools and policy. It is sent as rius.main_agent.version, the version the Agents page compares. RIUS_SERVICE_VERSION names the build or deploy and is sent as service.version. When traces carry both, you can switch the comparison between Agent version and Build.
  • The model and tokens. Rius prices each LLM span from gen_ai.request.model and the gen_ai.usage.* token counts, including cache reads and writes. A span that carries only gen_ai.response.model is not priced. Your instrumentation usually records these already.
  • No cost attribute. You never send a cost or a price. Rius computes it, and a cost attribute you send is ignored.

Cost is rolled up per trace, and each trace counts toward the version it ran under. Costs are list-price estimates in US dollars, so expect your invoice to differ. A call to a model with no catalog price has an empty cost, not zero, which lowers the averages for that version. See Track LLM and agent cost for how each call is priced.

Set it up

  1. Set the version in the environment of each release, before the process starts. Change the value every time you ship a new prompt, tool set or build:
RIUS_MAIN_AGENT_VERSION=prompt-v12 # the agent definition: prompt, tools, policy RIUS_SERVICE_VERSION=2026.09.29-a41f3c # the build or deploy
  1. Check that your LLM spans carry the model and token counts. If you followed the quickstart, the SDK integrations already record them. The cost guide lists what is needed for a call to be priced.
  2. Send traffic on both versions. The comparison counts only finished traces, and it warns when either side has fewer than 20 traces, because a small difference can be noise.
  3. Open the agent on the Agents page and pick a time window (15m, 1h, 1d, 7d or 30d). In Versions, Compare puts a base version next to another. By default it shows the two most recently introduced versions, with the older as the base. It lists traces, failed rate, cost per trace, latency and time to first token (p50), and tokens per trace, with the change.
  4. Open Drift to see cost per trace over time, with one point per minute, hour or UTC day depending on the window. Each trace counts in the bucket it started in, so you can see the cost shift from the day the new version shipped.
  5. Ask over MCP if you prefer. The tools agent_versions and compare_agent_versions let an agent query the version data. agent_traces_summary gives cost for one agent or service. Connect the Rius MCP server to your client and ask in plain language, for example which version of your agent costs more per trace.

If an agent reports no version, the agent page says so and names the variable to set.

What you get

  • Cost per trace for each version side by side, so you see whether a new prompt or model made runs more expensive.
  • A cost per trace chart over time in Drift, which shows when the change started.
  • Total cost and average cost per trace for each agent in the agents list and on the agent page.
  • The same version data over MCP, for an agent or script that checks each release.
  • A workspace-wide view of cost by model on Usage and cost, to see which model drives a change you found in a comparison. That page shows the period and the models, not versions.

When something else fits

  • If you want cost per customer instead of per release, use Users with user.id, or one workspace per customer, as the cost guide describes.
  • If you want a notification when cost per trace rises after a deploy, use a custom cost alert instead of checking the comparison by hand.
  • If you need exact billed amounts, use your provider’s invoice, since Rius shows list-price estimates.

Still stuck? Get help

Last updated on