Getting Started
Authentication
All API requests require authentication via a proxy key. Proxy keys scope access to specific providers, models, and organizations.
Bearer Token
Include your proxy key as a Bearer token in the Authorization header of every request.
Proxy keys start with mql_ and are scoped to your account or organization.
Keep keys secret
Authorization: Bearer mql_your_proxy_key_hereSDK Authentication
With the SDK, pass your key during initialization. All subsequent calls are automatically authenticated.
import Metriqual from '@metriqual/sdk';
const mql = new Metriqual({
apiKey: process.env.MQL_API_KEY!,
baseUrl: 'https://api.metriqual.com'
});from metriqual import MQL
mql = MQL(api_key="mql_your_proxy_key")
# Or use an environment variable (recommended)
# export MQL_API_KEY=mql_your_proxy_key
mql = MQL() # reads MQL_API_KEY from envCLI Authentication
Authenticate the CLI by logging in with your Metriqual account. Your credentials are stored locally for subsequent commands.
# Interactive login
mql auth login
# Check current auth status
mql auth status
# Logout
mql auth logoutCreating Proxy Keys
/v1/proxy-keysCreate proxy keys programmatically via the API. Keys can be scoped to specific providers, models, and have time-based validity.
Body Parameters
namestringrequiredA descriptive name for the key
provider_keysobjectbodyrequiredMap of provider name to API key (e.g. {"openai": "sk-..."})
allowed_modelsstring[]List of model IDs this key can access. Empty = all models.
valid_fromstringISO 8601 start date for key validity
valid_untilstringISO 8601 expiry date for key validity
curl -X POST https://api.metriqual.com/v1/proxy-keys \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "production-key",
"provider_keys": {
"openai": "sk-your-openai-key"
},
"allowed_models": ["gpt-4o", "gpt-4o-mini"]
}'{
"proxy_key": "mql_abc123def456",
"name": "production-key",
"is_active": true,
"created_at": "2025-01-15T10:30:00Z"
}Organization Keys
For team usage, create organization-scoped proxy keys. These require the x-org-id header on authenticated requests.
curl https://api.metriqual.com/v1/chat/completions \
-H "Authorization: Bearer mql_org_key_here" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Hi"}]}'Error Responses
Authentication failures return standard error objects:
{"error": "Invalid proxy key"}{"error": "Proxy key has been deactivated"}{"error": "Proxy key has expired. Valid until: 2025-01-01 00:00:00 UTC"}