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.
Use Metrion as a proxy for xAI’s Grok models. Grok exposes an OpenAI-compatible API, so you can use the standard OpenAI SDK — only the baseURL changes.
Prerequisites
- A Metrion account with your
sk-metrion-xxx token (find it on the Integrate page)
- An xAI API key saved in Metrion’s Integrate page
Setup
Set baseURL to Metrion’s Grok proxy and pass your sk-metrion-xxx token as apiKey. Metrion injects your xAI key and forwards the request to https://api.x.ai/v1/chat/completions.
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: 'sk-metrion-xxx', // your Metrion token
baseURL: 'https://www.metrion.dev/api/proxy/grok',
})
from openai import OpenAI
client = OpenAI(
api_key="sk-metrion-xxx", # your Metrion token
base_url="https://www.metrion.dev/api/proxy/grok",
)
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: 'sk-metrion-xxx',
baseURL: 'https://www.metrion.dev/api/proxy/grok',
})
const message = await client.chat.completions.create({
model: 'grok-3',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, world!' }],
})
console.log(message.choices[0].message.content)
from openai import OpenAI
client = OpenAI(
api_key="sk-metrion-xxx",
base_url="https://www.metrion.dev/api/proxy/grok",
)
message = client.chat.completions.create(
model="grok-3",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, world!"}],
)
print(message.choices[0].message.content)
Direct HTTP
curl https://www.metrion.dev/api/proxy/grok/v1/chat/completions \
-H 'Authorization: Bearer sk-metrion-xxx' \
-H 'content-type: application/json' \
-d '{
"model": "grok-3",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello, world!"}]
}'
Supported models
| Model ID | Notes |
|---|
grok-3 | Most capable Grok model |
grok-3-mini | Fast and cost-efficient |
grok-2 | Previous generation flagship |
grok-2-mini | Lightweight previous generation |
Pass-through mode
To use your own xAI key without storing it in Metrion, pass it in Authorization: Bearer and identify your Metrion account with the x-metrion-token header:
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.XAI_API_KEY, // your xAI key directly
baseURL: 'https://www.metrion.dev/api/proxy/grok',
defaultHeaders: {
'x-metrion-token': 'sk-metrion-xxx', // identifies your Metrion account
},
})
In pass-through mode, your xAI key is forwarded directly to xAI’s API and is never stored by Metrion.
Track requests by user or service
Add the optional x-metrion-user header to tag individual requests. These labels appear in your Metrion logs and dashboards.
Use x-metrion-user to break down costs by team member, bot, or application — for example "x-metrion-user": "search-agent" or "x-metrion-user": "user-55".
const client = new OpenAI({
apiKey: 'sk-metrion-xxx',
baseURL: 'https://www.metrion.dev/api/proxy/grok',
defaultHeaders: {
'x-metrion-user': 'user-55',
},
})