Skip to main content
Raindrop automatically instruments the OpenRouter Agent SDK (@openrouter/agent) to capture events and traces for model calls, tool execution, and multi-turn agent loops.

Installation

Quick Start

Telemetry is finalized when the ModelResult is consumed with getText(), getResponse(), or a stream method.

Standalone callModel

If you import OpenRouter’s standalone callModel helper, wrap that function once and call the wrapped version:

What Gets Traced

  • Agent calls - input, output, model, response ID, response status, and token usage when OpenRouter returns it
  • Tool calls - client tool executions captured as ai.toolCall trace spans linked to the root event
  • Conversation grouping - pass convoId to group related agent calls
  • Errors - failed OpenRouter calls finalize an error event before re-throwing to your application
  • Signals and users - use the included signals.track and users.identify APIs alongside automatic events
Tool spans are linked to the root event so you can inspect the full execution path in the Trace tab.

Configuration

Projects

Route events to a specific project by passing its slug as projectId:
This sets the X-Raindrop-Project-Id header on every event. Omit it (or pass "default") to use your org’s default Production project, which is the existing behavior. Single-project orgs need nothing new.

Multiple projects in one process

To report to different projects from one process, create one createRaindropOpenRouterAgent(...) client per project and wrap a distinct OpenRouter client object with each. Each wrapped client ships under its own writeKey/X-Raindrop-Project-Id:
Wrap markers are client-agnostic: re-wrapping the same OpenRouter client object with a second Raindrop client is a silent no-op — the first wrapper keeps it and the second client’s project is never applied. Wrap a distinct OpenRouter client object per project.

Identify Users

Associate traits with a user for filtering and trajectories:

Track Signals

Attach feedback, labels, or other signals to the most recently captured event:

Flushing and Shutdown

Always call flush() or shutdown() before your process exits to ensure all telemetry is shipped:

Known Limitations

  • Creating a ModelResult without consuming it does not ship an event.
  • Client tool spans wrap the local tool execution function, so their timing reflects local tool runtime.
  • Server-executed OpenRouter tools are represented from response items when OpenRouter returns them after the provider response completes. Client function tools have the richest live trace data.