Send OpenRouter traces to Elastic
OpenRouter is a gateway that routes LLM requests across many model providers. OpenRouter Broadcast can send OpenTelemetry traces of every chat completion straight to Elastic. After an account admin adds Elastic as a destination in the OpenRouter console, one trace per request starts arriving in your Elastic project. You don't need to change your code or run an OpenTelemetry Collector.
Each request produces a parent span for the LLM generation plus one child span per upstream provider attempt. The spans follow the OpenTelemetry GenAI semantic conventions and are stored in Elastic in OTLP format.
Make sure you have the following:
- An admin role on the OpenRouter account whose API keys you want to broadcast. If someone else administers the account, give them the endpoint and API key from the next item.
- An Elastic Observability Serverless project or an Elastic Cloud Hosted deployment. On Elastic Cloud Hosted, the Elastic Cloud Managed OTLP Endpoint requires version 9.0 or later. The Elastic Cloud Managed OTLP Endpoint isn't available for self-managed, Elastic Cloud Enterprise, or Elastic Cloud on Kubernetes deployments.
- Your Elastic Cloud Managed OTLP Endpoint endpoint and an API key with the
event:writeprivilege for theapmapplication. To get both, follow the Find your endpoint and Create an API key steps in Quickstart: Send OTLP data to Elastic Serverless or Elastic Cloud Hosted.
Full step-by-step setup is in OpenRouter's guide: Broadcast — Elastic Observability.
-
Open the Observability settings
In the OpenRouter console, open Settings → Observability and select Elastic Observability from the destinations list.
-
Enter your Elastic endpoint and API key
Set the OTLP endpoint to your Elastic Cloud Managed OTLP Endpoint URL. Set the header
AuthorizationtoApiKey <your-api-key>(the wordApiKey, a space, then the encoded key). -
Test the connection
Select Test Connection and confirm the synthetic
Test Generationspan lands in Elastic Discover underservice.name: openrouter. Then save the destination.
OpenRouter's Broadcast has a Privacy Mode that strips prompt and completion content from the trace, keeping only metadata (model, tokens, latency, response id). Enable it from the same destination if you don't want message content to leave OpenRouter.
To verify Elastic is receiving spans without sending a real chat completion, use OpenRouter's Test Connection button at Settings → Observability → your Elastic destination. It fires a synthetic Test Generation span.
In Kibana Discover, run this ES|QL query to find the test span (and any real Broadcast span) by service.name:
FROM traces-*
| WHERE service.name == "openrouter"
The destination's delivery status in the OpenRouter console shows a healthy indicator once spans are being accepted. This can take about a minute after setup.
Traces land as OTLP spans under service.name: openrouter. Each span carries the request metadata (model, provider, tokens, cost, finish reason, response id) and the full conversation. You can reach them from:
- Discover: Query with ES|QL, then expand a row.
- Applications → Service inventory →
openrouter→ Transactions: Opens the request waterfall. Pick a transaction to view its details. - Applications → Traces: The list of root transactions.
In Kibana Discover, run this ES|QL query to sum input and output tokens by model. The name == "LLM Generation" filter restricts the query to the parent request spans, so child provider attempt spans aren't counted twice:
FROM traces-*
| WHERE service.name == "openrouter" AND name == "LLM Generation"
| STATS
input_tokens = SUM(attributes.gen_ai.usage.input_tokens),
output_tokens = SUM(attributes.gen_ai.usage.output_tokens)
BY attributes.gen_ai.request.model
- OpenRouter Broadcast documentation (OpenRouter documentation)
- Elastic Cloud Managed OTLP Endpoint reference
- LLM and agentic AI observability