OwlMetric uses different types of tokens depending on your integration method and providers. This guide explains how to manage them effectively.
Used when routing requests through OwlMetric's proxy infrastructure.
Format: pk_your_project_key_here
Usage: One per project, works with all providers
Security: Stored securely on OwlMetric servers
Used when tracking usage with the direct SDK method.
Format: pt_your_provider_tracking_token
Usage: One per provider per project
Security: Stored in your environment
Navigate to Project Settings
Generate Proxy API Key
pk_...)Add Provider API Keys
Environment Variables:
# Single proxy key for all providers
OWLMETRIC_API_KEY=pk_your_project_key_here
# Your provider keys (stored on OwlMetric)
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
GEMINI_API_KEY=your_google_key
Navigate to Project Settings
Generate Provider-Specific Tokens
pt_...)Environment Variables:
# Provider API keys (in your environment)
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
GEMINI_API_KEY=your_google_key
# OwlMetric tracking tokens (one per provider)
OWLMETRIC_OPENAI_TOKEN=pt_your_openai_tracking_token
OWLMETRIC_ANTHROPIC_TOKEN=pt_your_anthropic_tracking_token
OWLMETRIC_GEMINI_TOKEN=pt_your_gemini_tracking_token
You can have multiple projects using the same AI provider:
Project A:
OWLMETRIC_OPENAI_TOKEN=pt_project_a_openai_token
Project B:
OWLMETRIC_OPENAI_TOKEN=pt_project_b_openai_token
For different environments (dev, staging, prod):
# Development
OWLMETRIC_OPENAI_TOKEN=pt_dev_project_openai_token
# Staging
OWLMETRIC_OPENAI_TOKEN=pt_staging_project_openai_token
# Production
OWLMETRIC_OPENAI_TOKEN=pt_prod_project_openai_token
Always store tokens in environment variables, never in code:
// ✅ Good
const owlmetricToken = process.env.OWLMETRIC_OPENAI_TOKEN;
// ❌ Bad
const owlmetricToken = "pt_your_token_here";
Use .env files for local development:
# .env.local (Next.js)
OWLMETRIC_OPENAI_TOKEN=pt_your_token_here
# .env (Node.js)
OWLMETRIC_OPENAI_TOKEN=pt_your_token_here
Use your platform's environment variable system:
Vercel:
Heroku:
heroku config:set OWLMETRIC_OPENAI_TOKEN=pt_your_token_here
Docker:
ENV OWLMETRIC_OPENAI_TOKEN=pt_your_token_here
Generate New Token
Update Environment
Revoke Old Token
"Invalid API key"
"Token not found"
"Insufficient permissions"
Test SDK Token:
// Make a tracked request and check dashboard
const completion = await client.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: "test" }],
});
Tokens inherit the limits from your subscription plan:
If you have issues with token management: