How do I query LLM cost per request over MCP?
Rius lets you query LLM cost per request over MCP by asking your client for individual runs and calls, which it fetches with the list_agent_traces and list_spans tools. A request can mean a whole run (one trace) or a single model call (one span), and you get the cost of each. Costs are list-price estimates in US dollars, and a call Rius could not price comes back empty, not as zero.
How it works
Rius prices every LLM span when it arrives, from the requested model (gen_ai.request.model) and its token counts, including prompt-cache reads and writes. Each call carries its own cost, and Rius adds the calls up per trace. Your MCP client reads that stored cost through the Rius MCP server. You never send a price.
Two tools cover “per request”, depending on what a request is to you:
- One run (a trace):
list_agent_traceslists individual runs. This is the one to use when a request is a user message or job that triggers a whole agent run, with several model and tool calls underneath. - One model call (a span):
list_spanslists individual calls. Use it when you want the cost of each LLM call, for example every call to one model.
To look inside a single run, the client opens it with get_agent_trace, which gives the span waterfall of that trace.
If you want a total instead of a list, the client uses agent_traces_summary for one agent or service, workspace_metrics_overview for the workspace total and cost by model, or list_users sorted by cost for the most expensive end users. Those answer “how much overall”, not “how much per request”.
The numbers match what the console shows: the Traces page lists cost per trace, and the Spans tab shows cost per call. See Exploring traces for that view.
Set it up
- Connect your client to the Rius MCP server. For Claude Code, run this once. The OAuth sign-in opens the first time a session uses the server:
claude mcp add --transport http rius https://mcp.eu.console.rius-glassflow.com/mcpIf you use the Rius plugin, it already registers this server as rius, so skip this step. Other clients are covered on the MCP page. For a job without a browser, use a read-scoped API key instead. Ingest keys cannot query.
-
Check the connection by asking: “Who am I in Rius, and which workspaces can I access?” The client should call
get_meand answer with your email and your workspaces. -
Ask for cost per request in plain language. Name the unit you care about and the scope. For example:
- “List my agent’s most recent runs with the cost of each.”
- “Show the individual LLM calls to gpt-4o this week with their cost.”
- “What did the most recent failed run cost, and which call cost the most?”
-
Narrow the question if the list is long. Give an agent or service name, a time window, a model, or a status such as failed. A trace’s status reads Error when any of its spans errored, so runs that retried and recovered are included. Ask for runs whose root span failed to see only genuine failures.
-
To dig into one expensive run, ask the client to open it. It fetches the trace with
get_agent_traceand reads cost per call from the spans.
The full price rules are in Track LLM and agent cost.
What you get
- Cost for each run or call. You get the cost of individual traces or spans in US dollars, so you can see which request was expensive instead of only a total.
- Cache-aware pricing. Cache reads and writes are priced at the provider’s cache rates. Model names are normalized first, so a provider prefix or a dated snapshot resolves to the same price.
- Empty means unpriced. If a model is not in the price catalog, or a span reported no token usage, its cost is empty, not zero. An unpriced call never looks free. The summary tools such as
agent_traces_summaryreport a total with nothing priced in it as $0.00, so treat that figure with care. - Estimates, not invoices. Rius applies each model’s standard list rates from LiteLLM’s public model-price catalog. It does not apply long-context tiers, batch, flex or priority pricing, or any discount you negotiated, so your provider invoice can differ.
- Fixed at write time. Cost is set on the span when it is written. A later price change does not rewrite past calls.
The tool calls you approve are logged with structural arguments only, such as the workspace and time window. Tool results are never stored.
When something else fits
- If you want to browse, sort and filter by cost visually, the Traces and Spans pages in the console do that, and a shared view hands a filtered list to a teammate without span content.
- If you want to be told when a request gets expensive instead of asking, set a cost alert. Cost is a per-trace metric in custom alerts, and your client can create the rule with
create_alert_rule.