Query AI latency, traces, logs, and unit economics

Query live GenAI latency percentiles, token spend, traces, logs, and alerts across /v1/eval/metrics, /v1/metrics/query, and /v1/o11y/alerts.

You cannot optimize latency or unit economics in the dark. Hanzo tags every model, tool, and HTTP span by org and project so observability and billing share one source of truth.

Architecture & contract

/v1/eval/metrics summarizes GenAI spans (generations, tokens, cents, error rate, p50/p95 latency); /v1/metrics/* serves raw PromQL, log, and trace queries; /v1/o11y/alerts manages operational alerting.

Primary endpoint: GET /v1/eval/metrics · Status: shipped · Level: practitioner

Run it across all four surfaces

hanzo eval metrics
hanzo metrics health
hanzo o11y alerts list
import { Configuration, EvalApi, MetricsApi } from 'hanzoai';

const cfg = new Configuration({ accessToken: process.env.HANZO_API_KEY });
const [aiMetrics, health] = await Promise.all([
  new EvalApi(cfg).getEvalMetrics('24h'),
  new MetricsApi(cfg).getMetricsHealth(),
]);
console.log({ aiMetrics: aiMetrics.data, health: health.data });
import os
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import EvalApi, MetricsApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
print(EvalApi(client).get_eval_metrics(range="24h"))
print(MetricsApi(client).get_metrics_health())
curl -s "https://api.hanzo.ai/v1/eval/metrics?range=24h" \
  -H "Authorization: Bearer $HANZO_API_KEY" | jq '.'

curl -s https://api.hanzo.ai/v1/metrics/health \
  -H "Authorization: Bearer $HANZO_API_KEY" | jq '.'

curl -s https://api.hanzo.ai/v1/o11y/alerts \
  -H "Authorization: Bearer $HANZO_API_KEY" | jq '.'
curl -s -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "eval",
      "arguments": {"op": "get_eval_metrics", "input": {"range": "24h"}}
    }
  }'

Verify the outcome

  • Assert GET /v1/eval/metrics?range=24h reflects recent model calls with accurate per-model latency breakdowns.

Production guardrails

  • Alert on error_rate > 1% and p95_latency_ms regressions rather than average latency alone.

Next steps & Hanzo University

Was this page useful?
Broken link or missing step? Drop it in #docs on Discord or open a PR.
Last updated Nov 25, 2026