Usage
Callpatch_anthropic_client() once after creating your Anthropic client. All subsequent client.messages.create() and client.messages.stream() calls are traced automatically — no changes to individual API calls are needed.
What gets traced
Eachmessages.create() or messages.stream() call produces one trace.
| Field | Source |
|---|---|
input | messages kwarg |
output | response.content[0].text (or streamed final message text) |
latencyMs | Wall-clock time of the API call |
model | model kwarg |
error | Exception message if the API call raises |
patch_anthropic_client() reference
| Parameter | Description |
|---|---|
client | The anthropic.Anthropic() instance to patch |
tracer | agentx.tracer from your AgentX instance |
name | Label shown in the AgentX UI for every trace |
metadata | Static key-value metadata attached to every trace |
session_id | Links traces from the same conversation thread |
patch_anthropic_client() on an already-patched client is a no-op — it is safe to call multiple times.

