How do I move my cost tracking from LangSmith to Rius?
Rius computes cost on its servers from the model name and token counts on each model call, so moving cost tracking from LangSmith means getting those two values onto your spans. For LangChain and LangGraph apps, install the Rius SDK with the langchain extra and call rius.init(). For @traceable and the OpenAI and Anthropic wrappers, swap them for @rius.observe and the Rius integrations. Rius has no custom model prices or negotiated discounts, so costs are list-price estimates.
How it works
In LangSmith, an LLM run carries the model and token usage. In Rius, the same step is a generation: a span with the model, token counts and cost. Rius prices each generation from the model and tokens, using LiteLLM’s public model-price catalog in US dollars. Cache reads and writes are priced at their own rates.
This changes what you do in code:
- You never send a cost value. Remove any code that attaches cost to a run. Rius computes it, and you never set a cost attribute.
- Auto-instrumentation supplies model and tokens.
rius.init()instruments the OpenAI and Anthropic libraries process-wide, and thelangchainextra hooks LangChain’s callbacks, the same hook LangSmith uses. The wrapperswrap_openaiandwrap_anthropichave no replacement, because you no longer need them. - Project becomes agent. Rius groups traces by agent, named by
service.name, which you set withservice_nameinrius.init(). Give each environment its own workspace and API key. - Threads become sessions.
with rius.session(thread_id):stampssession.idon every span in scope, so a conversation’s traces group together. - Costs are estimates. An unknown model gets an empty cost, not zero. Rius does not apply custom prices, or batch, flex, priority or long-context discounts, so totals can differ from your invoice or from custom prices you set in LangSmith.
Set it up
- Create a Rius workspace and API key. New organizations start with a trial of 30 days or 500,000 spans, whichever comes first, with no card.
- For a LangChain or LangGraph app, install the extra and swap the LangSmith environment for the Rius key:
pip install "glassflow-rius[langchain]"
# Before: LangSmith
export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY="lsv2_..."
export LANGSMITH_PROJECT="my-agent"
# After: Rius
export RIUS_API_KEY="ri_..."- Call
init()once at startup, then run your chains, agents and graphs as before:
import rius
client = rius.init(service_name="my-agent")- If you use
@traceable, replace it with@rius.observe, and dropwrap_openaiandwrap_anthropic. Installpip install "glassflow-rius[openai,anthropic]"so the integrations can trace those libraries.@traceable(name="Chat Pipeline")becomes@rius.observe(name="Chat Pipeline"). - If you trace a model call by hand today with
run_type="llm", check whether an integration already records it. A manual generation for a call an active integration also records counts its tokens and cost twice. Either delete the manual code, or pass an explicitinstrumentslist torius.init()that leaves that integration out. A manual generation must also set its own usage withset_usage(), or it carries no tokens and no cost. - In a short-lived Python script, call
client.flush()before it exits so every call is counted once. - Wrap each conversation turn in
rius.session(thread_id), and check that the turns group together. - Run both backends side by side. Leaving
LANGSMITH_TRACING=trueset keeps LangSmith’s callback tracer running next to Rius. After a few days, compare trace counts, token totals and cost. Then unsetLANGSMITH_TRACINGand revoke the LangSmith keys.
If you cannot change code yet, LangSmith’s own OpenTelemetry export can send to Rius. Model calls arrive as generations with model, token counts and cost, but content and threads do not. The LangSmith migration guide lists the exact variables and gaps. Treat that route as a bridge, then move to the SDK.
What you get
- Cost on each model call, priced from model and tokens, with cache reads and writes at their own rates.
- Usage and cost views: cost by model, tokens, error rate and time to first token over a range from 15 minutes to 30 days, or a custom range.
- Cost per user. Set a user with
rius.userand the Users page shows each end user’s traces, failures, cost and time to first token. - Cost per agent version, so you can compare two versions on cost per trace, failed rate, latency and tokens per trace.
- Cost alerts. Custom rules can fire on cost and tokens. To alert on model spend, filter by Model, or set Span kind to LLM, because tokens and cost sit only on model-call spans.
What does not carry over:
- Evaluators, datasets, experiments and feedback scores. If you tie cost to evaluation runs, keep those in LangSmith.
- Custom model prices and negotiated discounts.
- Historical data. Existing traces stay in LangSmith, and Rius starts from the first span you send.
When something else fits
If your cost reporting depends on custom prices, negotiated rates or discounts, Rius’s list-price estimates will not match it, so keep that reconciliation where it lives today. If evaluations, datasets or annotation queues are central to your workflow, run both backends and keep LangSmith for those pieces. For the full path-by-path walkthrough, see Migrate from LangSmith to Rius, or the overview at Migrate to Rius.