> ## Documentation Index
> Fetch the complete documentation index at: https://metrion.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start

> Get your first tracked AI request in under five minutes.

## Prerequisites

* A Metrion account ([sign up at metrion.dev](https://www.metrion.dev))
* An API key from at least one AI provider (Anthropic, OpenAI, Gemini, Mistral, or Grok)

<Steps>
  <Step title="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.
  </Step>

  <Step title="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:**

    | Mode                      | How 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 mode**     | You 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.
  </Step>

  <Step title="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/proxy`

    **OpenAI-compatible proxy endpoint:** `https://www.metrion.dev/api/proxy/openai/v1`

    <CodeGroup>
      ```typescript Anthropic — Node.js theme={null}
      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)
      ```

      ```python Anthropic — Python theme={null}
      import anthropic

      client = anthropic.Anthropic(
          api_key="sk-metrion-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          base_url="https://www.metrion.dev/api/proxy",
      )

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

      print(message.content)
      ```

      ```typescript OpenAI — Node.js theme={null}
      import OpenAI from 'openai'

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

      const message = await client.chat.completions.create({
        model: 'gpt-4o',
        max_tokens: 1024,
        messages: [{ role: 'user', content: 'Hello!' }],
      })

      console.log(message.choices[0].message.content)
      ```

      ```python OpenAI — Python theme={null}
      from openai import OpenAI

      client = OpenAI(
          api_key="sk-metrion-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          base_url="https://www.metrion.dev/api/proxy/openai/v1",
      )

      message = client.chat.completions.create(
          model="gpt-4o",
          max_tokens=1024,
          messages=[{"role": "user", "content": "Hello!"}],
      )

      print(message.choices[0].message.content)
      ```
    </CodeGroup>

    For Gemini, Mistral, and Grok, use the OpenAI SDK with the corresponding base URL:

    | Provider | Base URL                                       |
    | -------- | ---------------------------------------------- |
    | Gemini   | `https://www.metrion.dev/api/proxy/gemini/v1`  |
    | Mistral  | `https://www.metrion.dev/api/proxy/mistral/v1` |
    | Grok     | `https://www.metrion.dev/api/proxy/grok/v1`    |
  </Step>

  <Step title="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.
  </Step>
</Steps>

## 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.

<CodeGroup>
  ```typescript Node.js theme={null}
  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.
    },
  })
  ```

  ```python Python theme={null}
  client = anthropic.Anthropic(
      api_key="sk-metrion-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      base_url="https://www.metrion.dev/api/proxy",
      default_headers={"x-metrion-user": "user-123"},
  )
  ```
</CodeGroup>

<Tip>
  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.
</Tip>

<Note>
  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.
</Note>
