I trace Pydantic AI with LangSmith. How do I switch to Rius?
To switch from LangSmith, install glassflow-rius, call rius.init and Agent.instrument_all(True), and Rius traces your Pydantic AI agent from the framework’s own OpenTelemetry spans. You add no wrappers and no extra package. Each run arrives as an agent root span with a generation for every model request and a span for every tool call, and Rius computes the cost.
How it works
Pydantic AI is OpenTelemetry-native. It emits its own spans for agent runs, model requests and tool calls, so Rius does not need an instrumentation extra or wrappers for it.
rius.init()installs the global OpenTelemetry tracer provider.Agent.instrument_all(True)tells Pydantic AI to emit its spans through that provider.- Rius reads the framework’s OpenTelemetry GenAI attributes directly and computes cost on the server from the model and token counts.
The LangSmith concepts map across like this:
- A LangSmith project becomes an agent, named by
service_nameinrius.init(). Give each environment, such as production and staging, its own workspace and API key. - A run becomes a span, and a trace stays a trace.
- A thread becomes a session, set with
rius.session().
The Migrate from LangSmith guide covers the full concept table and the paths for LangChain and @traceable code. For a Pydantic AI agent you only need the steps below. The Pydantic AI integration page has the full recipe.
Set it up
- Create a Rius workspace and an API key. New organizations start on a trial of 30 days or 500,000 spans, whichever comes first, with no card.
- Install the SDK next to Pydantic AI. No extra is needed.
pip install glassflow-rius pydantic-ai- Add the Rius setup at startup, before you run the agent. Your agent definition and tools stay as they are.
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)- Replace your LangSmith thread id with a Rius session. Wrap each conversation turn in
rius.session()and reuse your conversation id. Every span started inside the scope carries it, including the framework’s spans. - Run both backends side by side for a while if you want to compare them. The migration guide shows how to send the same traces to both, and you cut over only when Rius shows what you need.
- Cut over. Remove the LangSmith tracing setup for this agent, such as the OpenTelemetry exporter that sent Pydantic AI’s spans to LangSmith and the
LANGSMITH_*variables, and revoke the LangSmith keys once nothing sends to them. - Verify with one request that calls a tool. Open the trace in the console and check for the
invoke_agentroot,chatgenerations with model, tokens and cost, andexecute_toolspans.
What you get
After the switch, a run that calls one tool looks like this:
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- Names from your code. Spans are named after your agent, your model and your tools, and tool calls appear with no wrapping.
- Tokens and cost on every model request. Rius computes cost from the model and token counts. Costs are list-price estimates in US dollars. Time to first token and reasoning tokens also show up, with
glassflow-rius1.0.1 and 1.0.2 or later. - Sessions. Turns scoped with
rius.session()group into one session, and you also get users, alerts and an MCP server for querying production traces. - Live agent view. With the SDK you see which agent processes are alive.
Two behaviours to expect. Successful spans arrive with an unset status, and the trace status still reads Ok. What the spans carry, such as prompts, completions and tool arguments, is controlled by Pydantic AI’s InstrumentationSettings (for example include_content), on top of the SDK’s own privacy controls.
When something else fits
- Rius has no evals, datasets, feedback queues, Prompt Hub or playground. If you depend on those in LangSmith, keep LangSmith for them and run both backends rather than cutting over completely.
- Existing traces stay in LangSmith, because Rius has no importer and starts from the first span you send. Rius is a hosted service only, so a self-hosted LangSmith setup has no equivalent.
- Other agents in your stack may use different frameworks. The integrations list shows which ones Rius traces, and Migrate to Rius covers the other routes.