Quick Start

Metrx Quick Start

Sign up, connect one agent, and see its calls and outcomes in Metrx.

Step 1: Sign Up

Create your account at app.metrxbot.com:

  • Click Sign Up
  • Use email, Google, or GitHub
  • Verify your email
  • Create your organization

Step 2: Choose a Template (Optional)

When you first log in, Metrx offers template options to jumpstart your setup:

  • Sales automation
  • Marketing analytics
  • Finance tracking
  • Customer support
  • Content generation
  • Data analysis
  • Research assistant
  • Custom (blank slate)

Select one or skip to start from scratch. Templates pre-configure common agent types and dashboards.

Step 3: Connect Your Agent

Create an API key in Settings → Security → API Keys (keys start with sk_live_). Every snippet below reads it from METRX_API_KEY. Choose one method:

Option A: Python SDK

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()

The package installs as metrxbot on PyPI but imports as metrx.

Option B: TypeScript SDK

npm install @metrxbot/sdk@0.7.0 @opentelemetry/api@1.9.1 @opentelemetry/sdk-trace-node@2.11.0 @opentelemetry/instrumentation@0.222.0 @opentelemetry/instrumentation-openai@0.20.0 openai@6.49.0
// metrx.ts: import this first, before anything imports "openai".
// Compile to CommonJS (tsc "module": "commonjs"). openai 7.x is not instrumented yet.
import { NodeTracerProvider, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { OpenAIInstrumentation } from '@opentelemetry/instrumentation-openai';
import { MetrxbotClient, MetrxbotSpanExporter, MetrxbotSpanProcessor } from '@metrxbot/sdk';
 
export const exporter = new MetrxbotSpanExporter({
  apiKey: process.env.METRX_API_KEY!,
  agentId: 'refund-triage',
});
 
const provider = new NodeTracerProvider({
  spanProcessors: [new MetrxbotSpanProcessor(), new SimpleSpanProcessor(exporter)],
});
provider.register();
registerInstrumentations({ instrumentations: [new OpenAIInstrumentation()] });
 
export const metrx = new MetrxbotClient({ apiKey: process.env.METRX_API_KEY! });
import { exporter, metrx } from './metrx';
import { task } from '@metrxbot/sdk';
import OpenAI from 'openai';
 
const client = new OpenAI();
 
export async function handleTicket() {
  return task(metrx, async (t) => {
    const reply = await client.chat.completions.create({
      model: 'gpt-4o-mini',
      messages: [{ role: 'user', content: 'Draft a reply to ticket 4821' }],
    });
    await exporter.forceFlush(); // send the span before the outcome
    t.setOutcome({ success: true });
    return reply;
  });
}

Tested with CommonJS output and openai 6.x. With openai 7.x or native ES modules the OpenAI instrumentation records no span yet.

Option C: OpenTelemetry

Node apps with OpenTelemetry need only environment variables:

export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://gateway.metrxbot.com/v1/traces"
export OTEL_EXPORTER_OTLP_PROTOCOL="http/json"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer%20${METRX_API_KEY}"
export OTEL_RESOURCE_ATTRIBUTES="service.name=refund-triage"
export OTEL_BSP_MAX_EXPORT_BATCH_SIZE="100"

Python and other protobuf exporters send through an OpenTelemetry Collector, because the Metrx receiver accepts JSON only. See OpenTelemetry.

Option D: Gateway Proxy (alternative)

Change your OpenAI client’s base URL so calls pass through Metrx. Your provider key goes in X-Provider-Key:

import os
from openai import OpenAI
 
client = OpenAI(
    api_key=os.environ["METRX_API_KEY"],  # Metrx key, sent as Authorization: Bearer
    base_url="https://gateway.metrxbot.com/v1",
    default_headers={
        "X-Provider-Key": os.environ["OPENAI_API_KEY"],
        "X-Agent-ID": "refund-triage",
    },
)
 
reply = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello"}],
)

Option E: AI IDE Setup

  1. Go to the onboarding flow
  2. Click “Set up with AI IDE”
  3. Select your IDE (Claude Code, Cursor, Windsurf, Gemini, etc.)
  4. Copy the generated prompt
  5. Paste into your IDE’s AI assistant for guided setup

Step 4: Verify Connection

Send a test request using your chosen method. Then:

  1. Open your Metrx dashboard at app.metrxbot.com
  2. Navigate to Events tab
  3. You should see your test request within seconds
  4. Click on it to view costs, latency, tokens, and model details

Step 5: Set Up Budgets (Optional)

Prevent unexpected costs with spending limits:

  1. Go to Settings → Budgets
  2. Click Create Budget
  3. Set:
    • Period: Daily or Monthly
    • Limit: Your maximum spend
    • Enforcement Mode:
      • alert_only: warnings only
      • soft_block: flag but allow requests
      • hard_block: reject requests
  4. Apply to an agent or your entire organization

Step 6: Configure Alerts (Optional)

Get notified of important events:

  1. Go to Settings → Alerts
  2. Select channels: Email, Slack, Telegram, or Webhook
  3. Enable alert types:
    • Cost spikes (50%+ increase)
    • High error rates (>5%)
    • Usage spikes (2x normal)
    • Idle agents (no calls in 7 days)
    • Budget warnings (80% of limit)
  4. Set thresholds and save

Example: Slack notifications for cost spikes.

Step 7: Explore the Dashboard

The main dashboard shows:

  • Cost Breakdown: By model, agent, day
  • ROI: Business outcomes vs. spending
  • Agent Topology: Network graph of agent interactions
  • Performance Metrics: Latency, error rates, token usage
  • Events Log: Complete history of LLM calls
  • Real-Time Updates: Data refreshes automatically

Step 8: Next Steps

Once your agents are connected, consider:

Log Business Outcomes

Track what matters: conversions, support tickets resolved, leads generated. The SDK snippets above already post one: t.set_outcome(...) (Python) or t.setOutcome(...) (TypeScript) inside a task records the result of that task. See Tasks, outcomes, contracts and scorecards for how outcomes feed the agent’s scorecard.

Connect Integrations

Link your CRM, payment processor, or other tools:

  • Stripe (for revenue tracking)
  • Calendly (for appointment data)
  • HubSpot (for sales pipeline)
  • Zapier (for workflows)

Invite Team Members

Go to Settings → Team and add collaborators to your organization.

Monitor Performance

Use the dashboard to:

  • Compare model efficiency
  • Find your most cost-effective agents
  • Optimize prompts for cheaper models
  • Track trends over time

Need help? See the Integration Guide for detailed examples or the API Reference for endpoint documentation.