Skip to Content

Anthropic

Trace every Anthropic client call with Rius without touching your call sites.

Setup

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

What gets captured

Each messages.create call becomes an LLM-kind span carrying the model (e.g. claude-haiku-4-5-20251001), input/output token usage from the response, and the request/response messages; cost is computed server-side from the model and tokens.

Streaming

Token usage is captured on streamed calls too (Anthropic reports it in the message lifecycle events). One gap to know about: unlike its OpenAI counterpart, the underlying OpenInference  Anthropic instrumentor emits no first-token event, so time to first token is not available for auto-instrumented Anthropic streams. If TTFT 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.

Last updated on