See the cost and usage of each agent that calls models through OpenRouter. OpenRouter sends a trace of every request to Mavvrik, so the only change to your code is adding the agent name to each request.
Before you start
-
Admin access to your OpenRouter organization.
-
You can create an agent connection in Mavvrik.
-
Access to the code that calls OpenRouter.
Step 1. Register the connection in Mavvrik
-
In Mavvrik, go to Agents and select + Agent.
-
Under Others, select OpenTelemetry.
-
Enter a Connection Name, for example
openrouter-prod, and select Next.
Step 2. Copy the endpoint and headers
-
Copy the Endpoint.
-
Copy the Headers. The
Authorizationvalue is a secret key; store it securely.
-
Set Agent ID attribute to
trace.metadata.agent_idand Agent name attribute totrace.metadata.agent_name.
-
Select Register.
Step 3. Add Mavvrik as a Broadcast destination in OpenRouter
-
In OpenRouter, open Settings → Observability and turn on Broadcast.
-
Find OpenTelemetry Collector and select Add Destination.
-
Fill in the form:
-
Name:
Mavvrik -
Endpoint: the endpoint from Step 2 followed by
/v1/traces -
Headers: the headers from Step 2, pasted as they are
-
-
Select Test Connection, then Add.
Step 4. Add the agent to each request
Add a trace object with agent_id and agent_name to every OpenRouter request:
"trace": { "agent_id": "support-bot", "agent_name": "Support Bot" }
Keep agent_id the same for an agent; a new value creates a new agent in Mavvrik. To see sessions and users too, see Sessions and users.
Step 5. Check your data
-
Run your agents through OpenRouter.
-
In Mavvrik, go to Agents → Others, open the connection and confirm your agents are listed by name.
-
Open Agent Cost, select the Reported view, and compare the total with OpenRouter for the same period.
Data usually appears within an hour, and always within 24 hours. Something missing? See Troubleshooting.