How do I switch from LangSmith to Rius when I trace LlamaIndex?
Rius traces LlamaIndex with its own llama-index integration, so you replace your LangSmith setup with one install and one init call. Your indexes and query engines stay as they are. Each query arrives as a nested trace of retrieval, embedding and model-call spans, with cost computed by Rius. The integration is Python only, and you can run both backends side by side until you cut over.
How it works
The LlamaIndex integration is one of the instrumentations the Rius SDK turns on when you call rius.init(). You do not wrap clients or decorate query code. Once the SDK is initialized, a query becomes a tree of typed spans:
- Retrieval steps are RETRIEVER spans. The retriever span’s output shows what the model was given to work with.
- Embedding calls are EMBEDDING spans.
- Synthesis model calls are LLM spans with the model, token usage and messages. Rius computes cost from the model and tokens, so you never send a cost value.
If the openai extra is installed too, a chat or completion call made through the OpenAI client appears as a second LLM span under the LlamaIndex span. Since glassflow-rius 1.1.1 the call is still counted once in tokens and cost, and the LlamaIndex span still shows the call’s total. Calls from MultiModalLLM models, embedding models and retrievers are not nested. Their OpenAI span starts a trace of its own, and MultiModalLLM calls are counted twice on any version.
The LlamaIndex integration is Python only. There is no integration for LlamaIndex.TS, so its query-engine and retriever structure is not captured. The OpenAI integration still traces provider calls made through the OpenAI client. See Integrations for the full support matrix.
Set it up
-
Create a Rius account and an API key. Keys start with
ri_. -
Install the instrumentation. The extra installs the instrumentation, not
llama-indexitself, so name the package for a fresh environment. A project that already uses LlamaIndex has it. Without it,init()logs aDependencyConflictand this integration stays off.pip install "glassflow-rius[llama-index]" llama-index export RIUS_API_KEY="ri_..." -
Call
rius.init()once at startup, before you build your query engines. Everything else stays as it is.import rius client = rius.init(service_name="my-agent") # build indexes and query engines exactly as before response = query_engine.query("What does Rius ingest?") # in a short-lived script, flush before the process exits client.flush() -
Remove the LangSmith pieces once you no longer want them to run. Unset
LANGSMITH_TRACINGand dropLANGSMITH_API_KEYandLANGSMITH_PROJECT. If your code uses LangSmith’s SDK helpers, swap them one to one:@traceablebecomes@rius.observe, and@traceable(name="Chat Pipeline")becomes@rius.observe(name="Chat Pipeline").@traceable(run_type="tool")becomes@rius.observe(kind=rius.SpanKind.TOOL), andrun_type="retriever"becomeskind=rius.SpanKind.RETRIEVER.wrap_openai(OpenAI())becomes a plainOpenAI(). Install theopenaiextra andinit()traces the library process-wide.
-
Map LangSmith threads to Rius sessions. A
thread_idin metadata becomes a scope that stampssession.idon every span started inside it, including auto-instrumented ones.with rius.session(thread_id): response = query_engine.query("What does Rius ingest?") -
Run one query and open the trace in the console. You should see the pipeline as nested spans, with the LLM leaf carrying model, tokens and cost.
The LangSmith migration guide has the full concept mapping and a cutover checklist.
What you get
- A nested trace per query. Retrieval, embedding and synthesis steps appear as typed spans, so you can see which documents the retriever returned before the model answered.
- Tokens and cost on each model call. Cost is a list-price estimate in US dollars, computed by Rius from the model and token counts.
- Sessions. Turns wrapped in
rius.session(thread_id)group together in the sessions view. - Controlled content. Retrieved document content and messages are content attributes that the privacy controls cover. Document ids and scores stay visible even with content stripped.
- A reversible move. You can run the Rius SDK in one service or environment while the rest keep reporting to LangSmith, compare trace counts, token totals and cost on real traffic, then cut over. The migration overview covers the general approach.
When something else fits
- Rius has no evaluation, datasets, feedback and annotation queues, or Prompt Hub and Playground. If your workflow depends on them, keep LangSmith for those pieces and use Rius for traces, cost and alerts.
- Existing LangSmith traces are not imported. Rius starts from the first span you send it, so keep LangSmith for history.
- If you cannot change code yet, LangSmith’s own OpenTelemetry export can send
@traceablecode to Rius as a bridge. Inputs, outputs and threads do not arrive that way, so move to the Rius SDK for content and sessions.