Skip to main content

Prerequisites

  • A Metrion account (sign up at metrion.dev)
  • An API key from at least one AI provider (Anthropic, OpenAI, Gemini, Mistral, or Grok)
1

Get your Metrion token

After signing up, Metrion redirects you to the Integrate page. Your Metrion token is displayed at the top of the page:
Copy it — you’ll use it as the api_key / apiKey in your SDK. Keep it confidential.
2

Add your provider API key

On the Integrate page, select a provider from the dropdown and paste your provider API key. Metrion stores it encrypted. Once saved, the code block below unlocks automatically.Two authentication modes are available:Most users should use stored mode — it’s simpler and requires only one credential in your code.
3

Point your SDK at Metrion

Change two values in your existing SDK setup: the base_url / baseURL and the api_key / apiKey. Everything else stays the same.Anthropic proxy endpoint: https://www.metrion.dev/api/proxyOpenAI-compatible proxy endpoint: https://www.metrion.dev/api/proxy/openai/v1
For Gemini, Mistral, and Grok, use the OpenAI SDK with the corresponding base URL:
4

Make a request and check your dashboard

Run your code. Within a few seconds, the Integrate page detects your first request and confirms it was tracked. Then head to your Dashboard to see cost, tokens, and latency for that request.From this point on, every request your app makes through Metrion is recorded automatically — no further setup required.

Optional: track multiple users or bots

Add the x-metrion-user header to any request to attribute it to a specific user, agent, or service. The value appears in the Sources tab of your dashboard and in your logs.
Use x-metrion-user to separate costs between different bots, team members, or customers — especially useful in multi-agent pipelines where you want per-agent cost breakdowns.
Streaming is fully supported. Pass stream: true in your request body as you normally would. Metrion captures token counts from the final SSE chunk and logs them once the stream completes.