Anthropic
Trace every Anthropic client call with Rius without touching your call sites.
Setup
Python
pip install "glassflow-rius[anthropic]" anthropicThe extra installs the instrumentation, not anthropic itself, so the
package is named here for a fresh environment. A project that already
calls Anthropic has it, and pip leaves it untouched. Without it, init()
logs a DependencyConflict and this integration stays off.
import rius
from anthropic import Anthropic
rius.init(api_key="ri_...", service_name="my-agent")
client = Anthropic() # use the client exactly as beforeWhat gets captured
Each messages.create call becomes an LLM-kind span carrying the model
(for example claude-haiku-4-5-20251001), input/output token usage from the
response including cache reads and writes, and the request/response
messages; cost is computed server-side from the model and tokens.
The SDK reassembles the messages into the GenAI message shape: text blocks
become text parts, tool calls become tool_call parts, and any other block
(an image or a reasoning block, say) is kept as a text part holding the block
serialized, so nothing is lost.
Anthropic takes the system prompt as a separate system parameter rather
than as a message; it lands as the leading system message of
gen_ai.input.messages, where the console and context attribution read it.
A failed call records error.type as the error class, such as
anthropic.NotFoundError. See
what the SDK normalizes.
Streaming
Token usage is captured on streamed calls too (Anthropic reports it in the
message lifecycle events). One gap to know about: unlike the Python OpenAI
integration, the Anthropic integration’s
OpenInference packages,
Python and TypeScript alike, do not record time to first
token, so it is not available for auto-instrumented Anthropic streams. If it
matters for a call, trace it as a manual generation
with record_first_token() instead.
Verify
Run one call, then open the trace in the console: the span shows the model,
token counts, and a cost. Wrap the call in
observe to see it nested inside
your agent’s run.
Prompt and response content is subject to your privacy controls, exactly like manual generations.