Skip to content

OpenRouter

Use OpenRouter Broadcast to send model invocation data to Guance and inspect Token usage, cost, response time, and failed invocations.

Configuration

Prerequisites

You need permission to create LLM applications in the Guance workspace and permission to configure Observability in OpenRouter.

Create an LLM Application

In Guance, go to Agent Monitoring → LLM, create an application, select Langfuse as the integration type, and enter OpenRouter as the name. Record the service address, application ID, and Client Token shown on the access page.

Configure Broadcast

Join the application ID and Client Token with a colon, then encode the result with Base64:

printf '%s' '<Application ID>:<Client Token>' | base64 | tr -d '
'

In OpenRouter, go to Settings → Observability, enable Enable Broadcast, add a destination of type OpenTelemetry Collector, and enter the following settings.

Setting Value
Endpoint <Service address>/api/public/otel/v1/traces
Headers Authorization: Basic <Encoded result from the previous step>, x-langfuse-public-key: <Application ID>
Sampling rate Set to 100% when complete usage statistics are required
API Key filter Select the API Key to collect; select Global to collect all calls
Data options Enable cost and request-context options; disable Privacy Mode when input and output content is required

Click Test Connection and save after the test succeeds.

Verification

Make an OpenRouter model call, confirm that an invocation record appears in the corresponding LLM application, then import the accompanying dashboard and monitors.

Metrics

MetricName MetricDescribe Dimensions Unit
input_tokens Number of input Tokens model_name, status token
output_tokens Number of output Tokens model_name, status token
total_tokens Total number of Tokens model_name, status token
duration Model invocation duration model_name, status μs
model_name Model name model_name, status -
status Invocation status model_name, status -
trace_id Invocation Trace ID model_name, status -
trace.metadata.openrouter_generation.request_id OpenRouter request ID model_name, status -
trace.metadata.openrouter_generation.is_byok BYOK flag model_name, status -
trace.metadata.openrouter_generation.byok_usage_inference BYOK upstream inference cost model_name, status USD
gen_ai.usage.total_cost OpenRouter invocation cost model_name, status USD
trace.metadata.openrouter.provider_name Actual provider name model_name, status -
trace.metadata.provider_responses Provider response metadata model_name, status -

Feedback

Is this page helpful?