Skip to Content

I trace LangChain with Helicone. How do I switch to Rius?

Rius traces LangChain through its own integration: install the langchain extra, call init once, and your chains, tools, retrievers and model calls arrive as a nested trace. You then remove the Helicone async logger, or the Helicone base URL and headers on your model client. Your chain code stays as it is, and you can run both tools side by side before you cut over.

How it works

Helicone captures calls in one of two ways. The proxy logs each request as it passes through a Helicone base URL, and the async logger instruments your provider client in process. Rius works inside your process. Its LangChain integration hooks LangChain’s callback system, so anything that runs through it is traced: LCEL chains, agents and LangGraph nodes. Nothing sits between your code and the model provider.

The integration records one span per step, typed by what the step is:

  • Chains are CHAIN spans.
  • Tool invocations are TOOL spans.
  • Retrievers are RETRIEVER spans.
  • Model calls are LLM spans with the model, token usage and messages.

Nesting follows your chain structure, so a trace reads like your execution graph. Rius computes cost on its servers from the model and token counts, so you send no cost value.

The integration is available for Python and TypeScript. If you also install a client extra such as openai, LangChain’s chat model span wraps the client library’s span, and each model call is counted once in tokens and cost. The LangChain span still shows the run’s total. Text-completion models (BaseLLM subclasses such as langchain_openai.OpenAI) are still counted twice. Integrations lists every supported library and framework.

Set it up

  1. Install the SDK and the LangChain integration. The extra installs the instrumentation, not langchain itself, which your project already has. Without langchain in the environment, init() logs a DependencyConflict and the integration stays off.

    pip install "glassflow-rius[langchain]" langchain export RIUS_API_KEY="ri_..."

    In TypeScript, install @glassflow-ai/rius and @opentelemetry/api, then the instrumentation package. It also needs @langchain/core, which a LangChain.js application already has.

    npm install @arizeai/openinference-instrumentation-langchain
  2. Replace the Helicone setup with init(). If you use the async logger, swap its init() call for the Rius one and build and run your chains exactly as before.

    import rius rius.init(service_name="my-agent") # reads RIUS_API_KEY
    import { init } from '@glassflow-ai/rius' const rius = init({ serviceName: 'my-agent' }) // reads RIUS_API_KEY await rius.ready // wait until instrumentation is attached before the first call

    Remove the Helicone logger rather than running both in one process. Both register the process-wide OpenTelemetry tracer provider, and only the first registration is kept, so the instrumented calls reach only one tool. To compare backends, run the logger in one service and Rius in another.

  3. Decide about the gateway. If your model client points at a Helicone base URL and you rely on caching, rate limits or fallbacks, leave the base URL and Helicone-Auth header in place and add init() anyway. Rius patches the library in your process, so calls are traced whatever base URL the client uses. Use plain model names such as gpt-4o-mini, not the gateway’s gpt-4o-mini/openai form, or calls show tokens but no cost. This is also the side-by-side setup, so keep the base URL until you have compared both tools. If you no longer need the gateway after that, point the client back at the provider with its default base URL and your own provider key.

  4. Move your Helicone headers. Use a session scope for Helicone-Session-Id and a user scope for Helicone-User-Id. Replace Helicone-Property-* with span attributes on the span that wraps the work. In TypeScript, use withSession and withUser. Set capture_content=False in place of the omit-request and omit-response headers.

    with rius.user(request.user_id): with rius.session(session_id): chain.invoke(inputs) # your own chain and inputs
  5. Verify, then cut over. Run one chain that calls a model and open the trace in the console. You see the chain’s structure as nested spans, with the LLM leaf carrying model, tokens and cost. Compare request counts, token totals and cost with Helicone for a few days, then remove the Helicone base URL and headers you no longer need and revoke the Helicone key once nothing sends to it.

The Helicone migration guide has the full header mapping and a cutover checklist, and the LangChain integration page covers the integration in detail.

What you get

  • A trace per run that mirrors your LangChain graph, with typed spans for chains, tools, retrievers and model calls, not a flat list of LLM requests.
  • Model, input and output tokens and messages on each model call, with cost computed by Rius.
  • Sessions and per-user views from the scopes you set.
  • A safe cutover: with the gateway kept in place, Helicone logs each call on the network path while Rius traces it in your process, so you can compare request counts, token totals and cost on the same traffic. Rius records a response that Helicone serves from its cache like any other call, so Rius cost runs higher than Helicone’s by your cache-hit share.
  • Prompt and response content stays under your control through capture_content, which applies to the whole tree.

When something else fits

  • Rius is not a gateway, so caching, rate limits, retries and fallbacks stay with whatever serves them today. Keep the Helicone gateway for those, and Rius traces the calls either way.
  • Rius has no prompt management, scores, feedback, datasets or evals, and no import of Helicone history. Keep those workflows and past data in Helicone, and Rius starts from the first span you send.

Still stuck? Get help

Last updated on