# OpenRouter Agent Tracing Reveals Costs, Failures, and Latency Gaps

> See an agent run end to end: connect tool activity with the model and provider events behind it. The traces can help teams identify faulty tool inputs, provider retries, and where time and cost accumulate.

**Source**: openrouter.ai | **Published**: 2026-12-02 | **Type**: article

## Key Facts

- Tracing linked all 98 calls across 27 runs to exact costs, enabling reliable spend audits.
- Agent spans caught bad tool arguments in all 9 failures; provider spans exposed causes agents miss.
- Three provider failures were recovered via retries, showing routing resilience can prevent run errors.
- Gemini’s 1,963.5 ms median first-token time was 2.6× DeepSeek’s 769 ms, revealing latency gaps.
- Privacy Mode retained cost and timing but leaked stop sequences, creating a residual data risk.

## Summary

OpenRouter has added agent tracing that joins an AI agent’s tool calls with the model generations and provider attempts behind them. In a test of 27 order-support runs, the combined traces matched all 98 model calls and their costs, exposed three provider failures that triggered retries, and showed that a 133-second model call was spent almost entirely waiting for a provider’s first token. For businesses deploying agents, the result is a clearer way to diagnose failures, measure latency and cost, and distinguish application problems from model-provider issues.

The system links timed spans—the individual steps in a run—into one trace using OpenTelemetry. An agent’s own code can record the run, model calls and tool calls; OpenRouter Broadcast adds spans for each model generation and provider attempt. Passing a trace ID and parent span ID with each request lets an observability backend place both sets of data in the same tree.

That division matters because neither side sees the whole process alone. Agent code can capture tool arguments, outputs and errors, but not which provider served a model call or whether OpenRouter retried after a failure. OpenRouter can report provider, timing, tokens and cost, but cannot see what happened inside the agent’s tools. In the test, the agent spans caught an invalid order number in all nine runs where the model omitted the required “ORD-” prefix; OpenRouter’s spans showed the additional model generation after the tool rejected it.

The test used three models—Gemini 3.8 Flash, Claude Haiku 5.5 and DeepSeek V4.1 Flash—and generated 98 calls at a total cost of $0.0227. Every call matched exactly one OpenRouter generation span, with the same cost reported by the SDK. Provider visibility also varied: Gemini calls went to Google Vertex AI or Google AI Studio, Haiku calls to Claude Platform on AWS, and DeepSeek calls across nine providers. That level of detail can help teams assess not just model choice but the infrastructure serving each request.

Latency data points to a practical competitive difference. Median provider time to first token was 1,963.5 milliseconds for Gemini, 1,177 milliseconds for Haiku and 769 milliseconds for DeepSeek. The agent’s measured call times were 498 to 700 milliseconds longer than OpenRouter’s generation spans, reflecting time outside OpenRouter, including the network trip. For operators, separating provider wait from application overhead makes performance tuning more targeted—and can inform decisions about routing, user experience and service-level expectations.

Tracing also raises a data-governance trade-off. OpenRouter’s Privacy Mode removes prompts, replies and error text before sending spans to a destination, while retaining tokens, cost, timing, model, provider and user ID. But model parameters, including stop sequences, and custom trace metadata remain; the test’s stop sequence appeared in the exported data. Businesses with strict data controls therefore need to review every field, not assume that prompt redaction makes a trace fully private.

As agent deployments grow, trace data could become an operational input to provider selection and cost controls, not just a debugging record. The next step for executives is to require teams to connect tool-level outcomes with provider-level performance and customer-level spend; without that joined view, organizations may optimize model latency while missing the tool failures, retries or data exposure that drive the real cost of an agent.

## Entities

- **Companies**: OpenRouter, Google, Anthropic, DeepSeek
- **Products**: OpenRouter Broadcast, OpenRouter Agent SDK, Gemini 3.8 Flash, Claude Haiku 5.5, DeepSeek V4.1 Flash, Jaeger, Langfuse, Datadog
- **Technologies**: agent tracing, OpenTelemetry, OpenTelemetry Protocol (OTLP), LLM observability, Privacy Mode, TypeScript, Webhooks
- **Organizations**: Google Vertex AI, Google AI Studio, Claude Platform on AWS, OpenTelemetry Collector

## Key Concepts

A trace links timed spans into a parent-child tree representing an agent run., Agent-owned spans capture model calls, tool calls, arguments, outputs, errors, and run outcomes., Broadcast spans capture model generations, provider attempts, provider identity, timing, tokens, and cost., Passing trace and parent span IDs lets agent and provider spans appear in one trace., Privacy Mode removes prompts, replies, and error text while retaining operational metadata., Provider-attempt spans reveal retries, failures, HTTP statuses, and provider-specific latency., Matching generation IDs and costs can validate that agent model-call spans align with provider records., Broadcast destinations support routing, sampling, and filtering traces.

## Definitions

- **Trace**: A record of one agent run, composed of linked spans that show the run’s steps and their relationships.
- **Span**: A timed record of one step, such as an agent run, model call, tool call, or provider attempt.
- **Provider-attempt span**: A child span that records an individual provider attempt, including its status and duration.
- **OpenTelemetry Protocol (OTLP)**: The format used to send telemetry spans to observability backends.
- **Privacy Mode**: A Broadcast destination setting that removes prompt, reply, and error text while retaining selected operational data such as tokens, cost, and timing.

## Use Cases

- Diagnose incorrect tool arguments and inspect tool outputs or errors across agent runs.
- Identify which provider served a model call and investigate provider retries or failures.
- Find latency bottlenecks, including time spent waiting for a provider’s first token.
- Compare agent-side model-call durations with provider-side generation and timing data.
- Track token usage and costs by customer using user IDs.
- Send traces to observability backends while limiting prompt and completion data exposure.

## Frequently Asked Questions

**How does agent tracing differ from ordinary logging?**

A log line records an event independently, while a trace links the timed steps of a run in parent-child order. This makes it easier to identify which step caused a problem and where time was spent.

**Can I combine my agent’s spans with OpenRouter’s provider spans?**

Yes. Send the run’s trace ID and parent span ID with each request so Broadcast can place its spans in the same trace. Both sides use OTLP, allowing the combined trace to be viewed in a compatible backend.

**Can I trace calls without using the OpenRouter Agent SDK?**

Yes. Any agent loop can create spans around its model and tool calls. Include the trace and parent span IDs in the request’s trace field to connect OpenRouter’s spans.

**Can I send traces without exposing prompts and replies?**

Yes. Enable Privacy Mode for a Broadcast destination to remove prompt, reply, and error text while retaining data such as tokens, cost, timing, and provider. Stop sequences and custom trace metadata are still exported, so ensure they do not contain sensitive information.

**Can I control which traces a Broadcast destination receives?**

Yes. Destinations support sampling rates, and sampling can keep or drop an entire session together when a session ID is supplied. You can also select or exclude API keys.

## Links

- [Read on Welcome.AI](https://welcome.ai/content/openrouter-agent-tracing-reveals-costs-failures-and-latency-gaps)
- [Original source](https://openrouter.ai/blog/tutorials/agent-tracing/)
- [OpenRouter](https://welcome.ai/company/openrouter): Featured company

---

Source: Welcome.AI | https://welcome.ai/content/openrouter-agent-tracing-reveals-costs-failures-and-latency-gaps