Skip to Content
Rius

How do I switch from Langfuse to Rius for tracing the Anthropic API?

Rius traces Anthropic client calls automatically once you install the anthropic extra and call rius.init(), so you replace your Langfuse setup with a short init and keep your call sites. Each messages.create call then arrives as a span with the model, token counts and a computed cost. You can send traces to both tools while you compare, then cut over. The general steps are in Migrate to Rius.

How it works

  • The Anthropic integration is switched on by init(). It instruments the Anthropic client library for the whole process, so you use the client exactly as before.
  • Your Langfuse tracing around those calls is what you replace. If you use the Langfuse SDK, you swap it for the Rius SDK, whose decorators, context managers and session scope have the same shape. If you send OpenTelemetry data from your own instrumentation to Langfuse, you can instead re-point the exporter. The Langfuse migration guide covers both paths.
  • With the Anthropic integration on, you usually do not need to port manual generation blocks one by one. The integration records the model call for you.
  • Cost is computed by Rius from the model and the token counts. You never send a cost value.
  • The integration is one of several client libraries and frameworks listed on the Integrations page. Setup details for this one are on the Anthropic integration page.

Set it up

  1. Create a Rius workspace and an API key. Keys start with ri_.

  2. Install the integration and initialize the SDK in Python. The extra installs the instrumentation, not the anthropic package, which your project already has.

    pip install "glassflow-rius[anthropic]" anthropic
    import rius from anthropic import Anthropic rius.init(api_key="ri_...", service_name="my-agent") client = Anthropic() # use the client exactly as before

    In TypeScript, install the instrumentation package (version 0.2.7 or newer, so cache tokens count correctly) and wait for ready:

    // npm install @arizeai/openinference-instrumentation-anthropic import { init } from '@glassflow-ai/rius' import Anthropic from '@anthropic-ai/sdk' const rius = init({ apiKey: 'ri_...', serviceName: 'my-agent' }) await rius.ready // resolves with the integrations that attached const client = new Anthropic()

    In a CommonJS app, require @anthropic-ai/sdk before init(), or the calls stay untraced.

  3. Replace the Langfuse parts around your Anthropic calls. Swap the Langfuse client setup for rius.init(...), and change @observe() to @rius.observe. Use with rius.session(session_id): where you used propagate_attributes(session_id=...), and with rius.user(user_id): for the user.

  4. Compare both tools first if you want. Keep Langfuse running, run the swapped SDK in one service while the rest still report to Langfuse, or add Rius as a second exporter in an OpenTelemetry Collector if you already use one.

  5. Check one trace in the console. The span for the call shows the model, token counts and a cost. Wrap the call in observe to see it nested inside your agent’s run.

  6. When Rius shows what you need, remove the Langfuse SDK or exporter and revoke the Langfuse keys.

What you get

  • One span for each messages.create call, with the model name, input and output tokens, cache reads and writes, and the request and response messages.
  • A cost for each call, computed from the model and tokens as a list-price estimate in US dollars.
  • The system prompt as the first system message of the input, since Anthropic takes it as a separate parameter.
  • Streamed calls with token usage. Time to first token is not recorded for auto-instrumented Anthropic streams. If you need it for a call, trace that call as a manual generation and use record_first_token().
  • Failed calls with error.type set to the error class, such as anthropic.NotFoundError.
  • Sessions and users, which carry over from Langfuse, with each user’s traces, failures and cost on the Users page.
  • Prompt and response content that follows your privacy controls, the same as manual generations.

When something else fits

  • Rius has no scores, evals, datasets or prompt management. If you rely on them in Langfuse, keep those workflows there and send traces to both tools.
  • Existing traces stay in Langfuse, because Rius starts from the first span you send. Rius is a managed service only, so a self-hosted setup does not carry over.

Still stuck? Get help

Last updated on