@openrouter/agent is OpenRouter’s agent toolkit package for agent loops.
Braintrust traces @openrouter/agent through auto-instrumentation or wrapOpenRouterAgent.
This guide covers manual instrumentation. For quicker setup, use auto-instrumentation.
Setup
Install the dependencies:.env
@openrouter/agent v0.1.2 and later.
Trace automatically
Braintrust can auto-instrumentOpenRouter.callModel() calls. This is the recommended setup for most projects.
Wrap an OpenRouter Agent client
If you prefer explicit instrumentation, wrap the client withwrapOpenRouterAgent.
callModel() span, token usage, and final response. When your agent loop invokes tools, those tool calls appear as child spans in the trace.