Welcome to Metrx — how your company manages the AI agents it employs. This documentation covers everything you need to understand, integrate with, and deploy Metrx.

Metrx is how a company manages the agents it employs — from any source you can export. Each agent gets a job contract, a scorecard against it, and a P&L: what it cost and what it produced. The platform includes:

  • SDKs (metrxbot for Python, @metrxbot/sdk for TypeScript): send each agent’s LLM calls and task outcomes from your own process
  • OpenTelemetry receiver: accepts OTLP/HTTP traces (JSON encoding) from an existing OpenTelemetry setup
  • Gateway (Cloudflare Worker): an optional LLM proxy that authenticates, calculates cost and logs each call it forwards
  • Web Dashboard (Next.js): insights, team management, billing, and outcome tracking
  • Background Workers: asynchronous event processing and data synchronization
  • MCP Server (@metrxbot/mcp-server): cost intelligence tools for AI agents via the Model Context Protocol
  • Enterprise Stack — Supabase (database), Clerk (auth), Stripe (billing)

Quick Navigation

For API Integration

For Infrastructure

For AI Agents (MCP)

  • MCP Server — Tools for cost tracking, optimization, budgets, experiments, and ROI

Additional Resources

  • Changelog — Release notes and version history

Getting Started

1. Get an API key

Sign up at app.metrxbot.com and create a key in Settings → Security → API Keys. Keys start with sk_live_; every snippet reads the key from METRX_API_KEY.

2. Connect your agent

The Python SDK, shown here, is the shortest path. Getting Started has the TypeScript SDK, OpenTelemetry, and the gateway proxy as the alternative.

pip install "metrxbot[openai]>=0.4.0"
export METRX_API_KEY=sk_live_...   # Settings -> Security -> API Keys
import os
from metrx import Metrx
from openai import OpenAI
 
m = Metrx(api_key=os.environ["METRX_API_KEY"], agent_key="refund-triage")
m.instrument()   # patches OpenAI/Anthropic CLASSES: clients you create before or after are tracked
 
client = OpenAI()
with m.task(task_id="ticket-4821") as t:   # any string id; non-UUID ids map to a deterministic UUIDv5 client-side
    reply = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": "Summarise ticket 4821"}],
    )
    t.set_outcome(success=True)
# short scripts flush at exit automatically; on serverless call m.flush()

3. Read the agent against its job

Each task’s LLM calls and its outcome land on one record. Write a job contract for the agent and its scorecard grades the measured figures against it: see Tasks, outcomes, contracts and scorecards.

Pricing

Start free. See metrxbot.com/pricing for current plans and the full feature comparison.

Core Concepts

API Key

Your authentication token for the Gateway. Treat it like a password. Never commit it to version control.

Organization

A workspace containing team members, agents, and billing settings.

Agent

A named LLM-powered system within your organization. Each agent tracks its own costs and outcomes.

Task

One unit of the agent’s work, identified by a task_id (a UUID) stamped on the LLM calls made for it.

Session

A conversation thread or workflow instance. Sessions group related LLM calls together.

Event

A single LLM call (chat completion, message, embedding). Events record input/output tokens, cost, latency, and status.

Outcome

The result of a task, posted for its task_id. Examples: “successfully handled customer inquiry”, “correctly identified fraud”, “generated valid code”. See Tasks, outcomes, contracts and scorecards.

Support

For help, visit:

Security & Privacy

Metrx uses industry-standard security practices:

  • API keys are hashed and cached in Cloudflare KV for sub-millisecond authentication
  • Data is encrypted at rest in Supabase using AES-256
  • Transport is TLS 1.3 only
  • Row-Level Security (RLS) ensures teams only access their data
  • Third-party integrations (OpenAI, Anthropic, etc.) never see your data except your requests

For questions about our security practices, contact security@metrxbot.com.

What Metrx stores, who processes it and how deletion works: What Metrx stores. How each number is computed: How Metrx counts.


Ready to integrate? Start with Getting Started.