Overview
Opsmatic tracks AI usage and cost from two sources:OpenClaw (automatic)
The OpenClaw daemon pushes token usage and costs with every heartbeat — no API calls needed. See the OpenClaw setup guide for how those costs are calculated.
Usage API (this page)
For n8n, Make.com, and custom workloads, your workflows report token usage and cost estimates themselves via
POST /v1/usage — typically from an HTTP Request node at the end of an AI workflow.Authentication & Permissions
All endpoints use a standard API key (Authorization: Bearer ops_...). The key needs:
| Operation | Required permission |
|---|---|
POST /v1/usage | usage: write |
GET /v1/usage, PUT /v1/usage | usage: read |
Push Usage Entries
Entry Fields
| Field | Type | Required | Description |
|---|---|---|---|
connection_id | string | Yes | The Opsmatic connection this usage belongs to (e.g. your n8n connection) |
entity | string | Yes | What consumed the usage — a model name (gpt-4o), service, or component |
usage_amount | number | Yes | The quantity consumed — token count for tokens entries |
usage_entity | tokens | custom | No | Defaults to tokens. Use custom with custom_name for non-token units (API calls, minutes, images) |
custom_name | string | With custom | Name of the custom unit being counted |
cost_cents | number | No | Cost estimate in cents (e.g. 12 = $0.12). Defaults to 0 |
workflow_id | string | No | The n8n/Make workflow that produced the usage |
execution_id | string | No | The specific execution, for per-run attribution |
metadata | object | No | Any extra context (model parameters, user, environment) |
Example — single entry
Example — batch
201 with the inserted entries. Validation failures return 400 with a per-index validation_errors array — in a batch, one invalid entry rejects the whole request, so fix and resend.
Reporting Token Usage from n8n
The recommended pattern: add an HTTP Request node after your AI/LLM node and map the token usage the node already exposes.Capture token counts from the AI node
Most n8n AI nodes (OpenAI, Anthropic, AI Agent) return token usage in their output — typically under
tokenUsage or usage with prompt/completion/total token counts. Check your node’s output panel for the exact path.Estimate the cost
Multiply tokens by your model’s rates. Example expression for GPT-4o (10/M output), producing cents:
Add an HTTP Request node
- Method: POST
- URL:
https://api.opsmatic.com/v1/usage - Authentication: Header Auth —
Authorization: Bearer YOUR_API_KEY - Body (JSON):
If your workflow calls multiple models, send a batch with one entry per model rather than a single summed entry — per-model attribution is lost once counts are merged.
Query Usage Entries
Query Parameters
| Parameter | Description |
|---|---|
connection_id | Filter to one connection |
workflow_id | Filter to one workflow |
execution_id | Filter to one execution |
entity | Filter by entity (e.g. gpt-4o) |
usage_entity | tokens or custom |
start_date / end_date | ISO timestamps bounding created_at |
limit | Page size, max 100 (default 50) |
offset | Pagination offset |
Aggregated Summaries
connection_id is required.
- Connection summary — pass
connection_idalone (optionallystart_date/end_date; defaults to the last 30 days) for totals across the connection. - Execution summary — pass
workflow_idandexecution_idfor the totals of a single run.
Related
OpenClaw Cost Tracking
Automatic token and cost monitoring for OpenClaw gateways, including budget alerts
API Introduction
Authentication, rate limits, and error handling for all API endpoints

