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.

Required headers

Your SDK sets these headers automatically when you configure the api_key and base_url. You do not need to set them manually.
HeaderProviderValue
x-api-keyAnthropicYour Metrion token or Anthropic API key
AuthorizationOpenAI, Gemini, Mistral, GrokBearer <your-metrion-token-or-provider-key>
Content-TypeAllapplication/json

Metrion-specific headers

x-metrion-user

x-metrion-user
string
An identifier for the user, bot, or workflow that made the request. This value appears in the Requester column in your logs and can be used to filter by requester.Use any string that makes sense for your setup — a user ID, an agent name, or a workflow label.
This header is optional but strongly recommended when you run multiple users, agents, or workflows through the same Metrion token. What it enables:
  • Filter your logs by requester in the dashboard
  • Track costs per user, per agent, or per workflow
  • Identify which part of your system is responsible for a given request
If you run multiple AI agents or n8n workflows through Metrion, add x-metrion-user to each one with a distinct identifier. This makes it easy to pinpoint cost spikes or errors in your logs.
Examples:
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: "sk-metrion-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  baseURL: "https://www.metrion.dev/api/proxy",
  defaultHeaders: {
    "x-metrion-user": "user_123",
  },
});

x-metrion-cache

x-metrion-cache
string
Enable response caching for the request. Metrion hashes the request (model + message content) and stores the response. Identical future requests return the cached response instantly, with zero tokens consumed.Accepted values:
  • true — serve from cache if a match exists; cache the response on a miss
  • refresh — bypass the cache and always fetch a fresh response, then update the cache
Use Cache-Control: max-age=<seconds> alongside x-metrion-cache: true to control how long the cached response is retained (default: 7 days, maximum: 365 days). When a cached response is returned, the proxy sets x-metrion-cache: HIT on the response and records the request in your logs with a Cached badge — no tokens are billed for cached responses.
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: "sk-metrion-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  baseURL: "https://www.metrion.dev/api/proxy",
  defaultHeaders: {
    "x-metrion-cache": "true",
    "Cache-Control": "max-age=86400", // cache for 24 hours
  },
});
Use x-metrion-cache: true for repeated queries with identical prompts — classification tasks, fixed-input workflows, or test suites. Cached responses return in milliseconds and cost zero tokens.

Forwarded headers

Metrion forwards the standard provider headers required by each API. For Anthropic, the anthropic-version header is set server-side to a fixed, tested version — do not set it manually in your requests, as Metrion will override it.