Opsmeter.io logo
Opsmeter.io
AI Cost & Inference Control
Integration docs

Implementation guide for AI cost control

Ship telemetry fast, keep attribution stable, and move from ingest to governance without changing your app network path.

Recommended path

Start with direct ingest, validate one stable payload shape, then harden budgets, retries, and incident workflows.

What this page answers
  • How to separate real traffic from demo or test telemetry.
  • Which mode settings keep dashboards and alerts trustworthy.
  • What to review before using shared budgets or anomaly checks.
QuickstartShip a first payload and validate required fields in minutes.Open guide
No-proxy telemetryKeep your app path unchanged while preserving request-level attribution.Review flow
OperationsSet budget posture, retry rules, and escalation checks for production.Harden runtime
Updated for 2026API v1 Read cost playbook npmPyPIGitHub

Implementation rhythm

5 minfirst ingest path
No proxyapp path unchanged
One schemaacross providers

Use quickstart for initial payloads, then operations docs to harden production workflows.

Data modes, demo endpoint, and cleanup

Every ingest row can be classified by dataMode and environment. If you do not send them, Opsmeter.io defaults to dataMode=real and environment=prod.

If you omit these fields, the Dashboard default filters can mix production and non-production rows. For clean metrics hygiene, mark all non-production traffic as test or demo.

FieldAllowed valuesRecommended default
dataModerealtestdemoreal
environmentprodstagingdevprod

Recommended combinations

Production traffic: dataMode=real, environment=prod

QA/Test traffic: dataMode=test, environment=staging|dev

Demo seed/button: dataMode=demo, environment=dev

A1

Classification fields

Use these fields to isolate production metrics from test/demo traffic.

{
  "externalRequestId": "req_2026_02_07_001",
  "provider": "openai",
  "model": "gpt-4o-mini",
  "promptVersion": "summarizer_v3",
  "endpointTag": "checkout.ai_summary",
  "inputTokens": 120,
  "outputTokens": 45,
  "totalTokens": 165,
  "latencyMs": 820,
  "status": "success",
  "dataMode": "real",
  "environment": "prod"
}
A2

Try demo data endpoint

POST /v1/ingest/demo always writes demo rows with dataMode=demo. Use it for workspace walkthroughs, then clean up from Overview: Manage demo data opens /settings#data-hygiene, and Clear my test data removes only your own test rows.

curl -X POST "https://api.opsmeter.io/v1/ingest/demo" \
  -H "X-API-Key: $AI_COST_API_KEY"

# all generated rows are stored as dataMode=demo
A3

Cleanup endpoints

Delete demo/test rows on demand: DELETE /v1/ingest/demo-data and DELETE /v1/ingest/test-data with scope=workspace|mine. Workspace scope requires Owner/Admin, mine scope is available for all roles.

# Owner/Admin: clear all demo rows in workspace
curl -X DELETE "https://api.opsmeter.io/v1/ingest/demo-data?scope=workspace" \
  -H "Authorization: Bearer $JWT"

# Any role: clear only my test rows
curl -X DELETE "https://api.opsmeter.io/v1/ingest/test-data?scope=mine" \
  -H "Authorization: Bearer $JWT"
A4

Analytics/export default behavior

Overview, top lists, prompt versions, exports, and budget signals are real-only by default. Include non-real traffic by sending explicit filters.

Retention still applies on top of these filters. See Retention & data lifecycle for raw-vs-summary rules and export truncation behavior.

# Dashboard/export defaults
# - dataMode omitted => real-only
# - environment omitted => all
# - exports include retention metadata headers:
#   X-Retention-Truncated, X-Retention-Available-From-Utc
# Include non-real data explicitly when needed:
GET /v1/dashboard/top-users?range=7d&dataMode=all&environment=staging

Demo data lifecycle

In Overview, click Try demo data to seed sample rows.

Analyze with filters using dataMode and environment.

From Overview, use Manage demo data (goes to /settings#data-hygiene) or Clear my test data.

Role access:Clear my test data = all roles. Workspace demo data cleanup = Owner/Admin.