I trace Pydantic AI with Helicone. How do I switch to Rius?
To switch from Helicone to Rius, install glassflow-rius, call rius.init() and Agent.instrument_all(True), and remove the Helicone base URL, headers or async logger. Pydantic AI emits its own OpenTelemetry spans, so agent runs, model requests and tool calls arrive in Rius with no wrappers, and Rius computes cost on the server. You then move your Helicone session, user and property values onto Rius sessions, users and span attributes.
How it works
Helicone captures calls on the network path, through a proxy base URL or the AI Gateway, or inside your process with its async logger. For Pydantic AI, Rius works from the framework’s own spans instead. rius.init() installs the global OpenTelemetry tracer provider, and Agent.instrument_all(True) tells Pydantic AI to emit its spans through it. No extra is needed on the SDK install. Rius reads the spans’ OpenTelemetry GenAI attributes and computes cost from the model and token counts, so you never send a cost value. Nothing sits between your code and the provider.
The Helicone values you send today move like this. Migrate from Helicone has the full mapping.
Helicone-Session-Idbecomesrius.session(id), which stampssession.idon every span in scope.Helicone-Session-Pathbecomes span nesting. A span started inside another span becomes its child.Helicone-User-Idbecomesrius.user(id), which stampsuser.id.Helicone-Property-*becomes span or resource attributes.Helicone-Omit-RequestandHelicone-Omit-Responsebecomecapture_content=False, which strips prompts and completions at export. For Pydantic AI, what the spans carry is also set by the framework’sInstrumentationSettings, for exampleinclude_content.
If you use the Helicone async logger, remove it rather than running both in one process. Both register the process-wide tracer provider, OpenTelemetry keeps only the first, and the calls reach only one tool.
Set it up
-
Install the SDK. Pydantic AI needs no extra.
pip install glassflow-rius pydantic-ai -
Add Rius at startup. If you use the async logger, remove it from this process. If you use the proxy, leave the Helicone base URL and
Helicone-Authheader in your model client setup for now: Pydantic AI’s spans are emitted in your process, so both tools see the same calls while you compare, and step 6 removes them.import rius from pydantic_ai import Agent rius.init(api_key="ri_...", service_name="my-agent") Agent.instrument_all(True) support_agent = Agent( "openai:gpt-5-mini", instructions="Answer support questions; check accounts with the tool.", ) @support_agent.tool_plain def account_status(email: str) -> str: """Fetch a customer's account standing by email.""" return lookup(email) with rius.session(conversation_id): result = support_agent.run_sync(ticket)Here
lookup,conversation_idandticketare your own code. Reuse your Helicone session id as the conversation id. -
Move users and properties. Wrap the work in a user scope and set per-request properties on the span that wraps it:
with rius.user(request.user_id): with rius.start_as_current_span("support_ticket") as span: span.set_attribute("app.ticket_id", ticket_id) result = support_agent.run_sync(ticket)Put per-deployment values such as app version or region on the resource with the standard
OTEL_RESOURCE_ATTRIBUTESvariable. -
While the gateway is in place, use plain model names such as
gpt-5-mini, not the gateway’smodel/providerform, or calls show tokens but no cost. With the async logger, compare backends by running the logger in one service and Rius in another. -
Verify one request that calls a tool. Open the trace in the console and check for the root span, the model generations with tokens and cost, and the tool span.
-
Cut over. Remove the Helicone base URL,
Helicone-*headers and async logger, and revoke the Helicone API key once nothing sends to it. If you use the AI Gateway with Helicone-managed provider keys or credits, switch to your own provider keys first, because Rius never holds provider keys.
The Pydantic AI integration page covers the setup in full, and Integrations lists the other frameworks and libraries. For the wider path from another tool, see Migrate to Rius.
What you get
Spans are named after your agents, models and tools, and tool calls appear without wrapping:
invoke_agent support_agent 6.0s
├─ chat gpt-5-mini 3.3s decides to call the tool
├─ execute_tool account_status 0ms
└─ chat gpt-5-mini 2.7s answers- The agent run is the root span, each model request is a generation with tokens and cost, and each tool call is its own span.
- Cost is a list-price estimate in US dollars, computed by Rius from the model and token counts.
- Time to first token (
glassflow-rius1.0.1 or later) and reasoning tokens (1.0.2 or later) show up for Pydantic AI runs. - Sessions from
rius.session()and users fromrius.user()group traces, and each user appears on the Users page with traces, failures and cost. - Successful spans arrive with an UNSET status rather than OK, and the trace status still reads Ok.
When something else fits
- Rius is not a gateway. If caching, rate limits, retries or fallbacks are load-bearing, keep the Helicone gateway and add Rius next to it first.
- Prompt management, scores, feedback, datasets and evals are not offered in Rius, so keep those workflows where they are today.
- There is no import of Helicone history. Existing traces stay in Helicone, and Rius starts from the first span you send.