Skip to main content

Documentation Index

Fetch the complete documentation index at: https://metrion.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

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:
sk-metrion-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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:
ModeHow it works
Stored mode (default)You store your provider key in Metrion. Use your sk-metrion-xxx token as the only credential in your SDK.
Pass-through modeYou manage your own provider key. Pass it directly as the bearer/api-key credential, and add x-metrion-token: sk-metrion-xxx as a separate header so Metrion can identify your account.
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
import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic({
  apiKey: 'sk-metrion-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  baseURL: 'https://www.metrion.dev/api/proxy',
})

const message = await client.messages.create({
  model: 'claude-sonnet-4-6',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello!' }],
})

console.log(message.content)
For Gemini, Mistral, and Grok, use the OpenAI SDK with the corresponding base URL:
ProviderBase URL
Geminihttps://www.metrion.dev/api/proxy/gemini/v1
Mistralhttps://www.metrion.dev/api/proxy/mistral/v1
Grokhttps://www.metrion.dev/api/proxy/grok/v1
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.
const client = new Anthropic({
  apiKey: 'sk-metrion-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  baseURL: 'https://www.metrion.dev/api/proxy',
  defaultHeaders: {
    'x-metrion-user': 'user-123',  // or 'bot-summarizer', 'agent-pipeline', etc.
  },
})
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.