OpenRouter Broadcast: failed, costly and slow LLM requests as signals
Send OpenRouter's Broadcast traces to a Pulso webhook source and turn failed generations, expensive requests and slow responses into signals, with a report on what they cost.
OpenRouter routes your app’s LLM requests to the providers, and its Broadcast feature sends a trace of each one to wherever you point it. Point it at Pulso and the requests that need a look become signals: a model that keeps failing, a prompt that cost more than it should, a provider that takes a minute to answer, or no requests at all because something upstream broke.
Connect OpenRouter#
Add OpenRouter to Pulso to create a webhook source called OpenRouter; it shows these steps with the source’s URL and secret, then creates the monitors below that you pick, with their playbooks and a report. To start from scratch instead, create a webhook data source called OpenRouter.
- In OpenRouter, open Settings > Observability and turn on Enable Broadcast.
- Click the edit icon next to Webhook.
- Paste the source’s Endpoint URL,
https://hooks.pulso.run/webhooks/<id>/<token>, as the URL and leave the method as POST. - Paste
{"Authorization": "Bearer <secret>"}as Headers. The secret is the source’s Signing secret, under Signatures with the Bearer token scheme: Add to Pulso makes one up and refuses deliveries without it; from scratch, set a long random one there. - Turn on Privacy Mode to keep prompts and completions out of Pulso; the monitors only read the model, tokens, cost, timing and status. It also drops the error message, so leave it off if the signals should say why a request failed.
- Leave the Sampling rate at 1.0: a request left out of the sample never reaches Pulso, failed or not. To watch only some API keys, pick them under API key filtering.
- Click Test Connection, which sends an empty trace that Pulso accepts, and save.
Send a request through OpenRouter and its trace shows up under the source’s Recent events, one event per span.
What arrives#
Broadcast posts OpenTelemetry traces as OTLP/JSON, with each span’s attributes in a list of key/value pairs. Pulso turns every span into an event of its own and keys its attributes by name, so a monitor filters on attributes.gen_ai.request.model like any other column. A trace from OpenRouter’s example, trimmed:
{
"resourceSpans": [{
"resource": { "attributes": [{ "key": "service.name", "value": { "stringValue": "openrouter" } }] },
"scopeSpans": [{
"spans": [{
"traceId": "5b8efff798038103d269b633813fc60c",
"spanId": "eee19b7ec3c1b174",
"name": "chat",
"startTimeUnixNano": "1705312800000000000",
"endTimeUnixNano": "1705312801000000000",
"attributes": [
{ "key": "gen_ai.request.model", "value": { "stringValue": "openai/gpt-4" } },
{ "key": "gen_ai.usage.prompt_tokens", "value": { "intValue": "100" } },
{ "key": "gen_ai.usage.completion_tokens", "value": { "intValue": "50" } }
]
}]
}]
}]
}
Its monitors see these columns:
| Column | Value |
|---|---|
name |
chat |
root |
true, false for a span inside another, such as a provider attempt |
trace_id |
5b8efff798038103d269b633813fc60c |
span_id |
eee19b7ec3c1b174 |
parent_span_id |
the span it’s inside, when it isn’t the root |
start_time |
2024-01-15T10:00:00.000Z |
duration_ms |
1000.0 |
status.code |
unset, ok or error |
status.message |
why it failed, unless Privacy Mode is on |
attributes.gen_ai.request.model |
openai/gpt-4 |
attributes.gen_ai.usage.prompt_tokens |
100 |
attributes.gen_ai.usage.completion_tokens |
50 |
attributes.gen_ai.usage.total_cost |
the request’s cost in dollars |
attributes.user.id |
the request’s user, when your app sends one |
attributes.trace.metadata.<key> |
each key of the request’s metadata |
resource.service.name |
openrouter |
Integers come in as numbers, though OTLP sends them as strings.
Monitors to build#
Each one filters on root being true, so it looks at the request and not at the provider attempts inside it.
Failed requests#
- Filters:
rootis true,status.codeequalserror. - Uniq by:
trace_id, one signal per request. - Playbook: a task to check the model and the error, and whether the app should fall back to another model.
Expensive requests#
- Filters:
rootis true,attributes.gen_ai.usage.total_costgreater than1. - Uniq by:
trace_id. - Playbook: a task to find the prompt behind it, with
attributes.user.idand the tokens in its text.
Slow requests#
- Filters:
rootis true,duration_msgreater than60000. - Uniq by:
trace_id.
Heartbeat: requests stop arriving#
A heartbeat monitor on root being true, hourly with a grace period of 30 minutes, raises a signal when an hour goes by without a request: the app stopped calling the model, its key ran out of credits, or Broadcast was turned off. It only makes sense when your app sends requests around the clock; otherwise give it a custom schedule for the hours it does.
Limits#
- No signature. OpenRouter doesn’t sign Broadcast deliveries, so what keeps others out is a secret: the token in the URL, and the bearer token in the headers. Treat both as passwords.
- Delivery isn’t retried. Broadcast sends each trace once, after the request finishes, so a trace lost on the way doesn’t come back. Use the heartbeat for outages, not a count of signals.
- Attributes vary. Cost, identity and request context come only with the matching Additional generation metadata toggles, and each provider fills in a different set of usage attributes. Check a real trace under the source’s Recent events before filtering on one.
- Prompts are data. Without Privacy Mode,
attributes.span.inputandattributes.span.outputhold the prompt and the completion; they reach signal data like any other column.
Sources: OpenRouter’s Broadcast guide and its Webhook destination.
Add OpenRouter to Pulso: a webhook source, 4 monitors with their playbooks and a report, then these steps with the source's URL.
- OpenRouter failed requests
- OpenRouter requests over a dollar
- OpenRouter slow requests
- OpenRouter requests stop arriving
- Report: OpenRouter