Agent Quickstart
Connect your agent to Metrx in 60 seconds
Get real-time cost tracking, optimization recommendations, and business outcome attribution.
Sign up
Create a free Metrx account. Get your API key in 30 seconds.
Install SDK
Add Metrx to your agent via MCP, Python, TypeScript, or REST API.
Track & Measure
See costs, ROI, and optimization opportunities in your dashboard.
Choose your integration
3 ways to integrate
MMCP Server — Best for Claude & Compatible Agents
Use Metrx as an MCP server. 23 tools for cost optimization, budgets, experiments, leak detection, and attribution.
npx @metrxbot/mcp-serverOr add to your Claude Desktop config:
{
"mcpServers": {
"metrx": {
"command": "npx",
"args": ["@metrxbot/mcp-server"],
"env": {
"METRX_API_KEY": "your-api-key-here"
}
}
}
}PPython SDK — Best for Python Agents
Auto-instrument your LLM calls. Metrx patches OpenAI and Anthropic clients to track every token and dollar automatically.
pip install metrxInitialize in your code:
from metrx import Metrx
client = Metrx(api_key="your-api-key")
# Auto-instrument OpenAI, Anthropic, etc.
instrumented = client.instrument()
# Returns: ['openai', 'anthropic'] — all detected providers
# Your existing code works unchanged — costs are tracked automatically
from openai import OpenAI
openai = OpenAI()
response = openai.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello"}]
)
# ^ This call is now tracked by Metrx
# Log business outcomes to measure ROI
client.log_outcome(
outcome_type="deal_closed",
value_cents=10000
)TTypeScript SDK — Best for Node & Browser Agents
Route LLM calls through the Metrx gateway. Drop-in replacement for OpenAI and Anthropic clients with automatic cost tracking.
npm install @metrx/sdkInitialize in your code:
import { MetrxbotClient } from '@metrx/sdk';
const client = new MetrxbotClient({
apiKey: 'your-api-key',
defaultAgentId: 'my-support-agent'
});
// OpenAI-compatible chat — costs tracked automatically
const response = await client.chat({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello' }]
});
// Anthropic-compatible messages
const anthropicResponse = await client.messages({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello' }]
});
// Access cost metadata from response headers
console.log(response._meta?.costMicrocents);
console.log(response._meta?.latencyMs);What you get after integrating
Real-time Cost Dashboard
See every call, token, and dollar spent by your agent. Breakdown by model, method, and time period.
Optimization Recommendations
Automatic suggestions to reduce costs: model switching, prompt optimization, caching strategies.
ROI Attribution
Link agent costs to business outcomes. See revenue per agent, cost per customer, and true ROI.
Budget Controls
Set hard or soft spending limits per agent. Get alerts when approaching budget or anomalies detected.
Model Experiments
Run A/B tests comparing models. Measure cost vs quality tradeoffs automatically.
Cost Leak Detection
Automatic detection of duplicate calls, token-heavy patterns, and unusual spending anomalies.
API & Documentation
All SDKs and servers use the same underlying API. Full documentation available:
- API Reference — Complete REST API documentation
- Full Documentation — Guides, examples, and best practices