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.

  1. In OpenRouter, open Settings > Observability and turn on Enable Broadcast.
  2. Click the edit icon next to Webhook.
  3. Paste the source’s Endpoint URL, https://hooks.pulso.run/webhooks/<id>/<token>, as the URL and leave the method as POST.
  4. 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.
  5. 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.
  6. 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.
  7. 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#

Expensive requests#

Slow requests#

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#

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.

Add to Pulso

See the monitors, their playbooks and the report