API Reference
POST
/api/track
Record a single AI API execution. Used internally by the Agentrics SDKs — call this directly if you need to track usage from a language or framework without an official SDK.
Authentication
Pass your API key as a Bearer token in the Authorization header. Generate keys from Settings → API Keys.
Authorization: Bearer agntcs_sk_...| Missing header | 401 Unauthorized |
| Invalid / revoked key | 401 Unauthorized |
Request body
Content-Type: application/json
| Field | Type | Description |
|---|---|---|
providerrequired | "openai" | "anthropic" | "google" | The AI provider. |
modelrequired | string | Model name, e.g. "gpt-4o-mini" or "claude-3-haiku-20240307". |
inputTokensrequired | number | Prompt / input token count. |
outputTokensrequired | number | Completion / output token count. |
agentId | string | Stable identifier for the agent making the call. |
agentName | string | Display name for the agent. Defaults to "default". |
latencyMs | number | Round-trip latency in milliseconds. |
success | boolean | Whether the call succeeded. Defaults to true. |
errorMessage | string | Error message if success is false. |
Response
Returns 200 OK on success.
| Field | Type | Description |
|---|---|---|
id | string | The ID of the created execution record. |
costCents | number | Calculated cost in cents (integer). |
totalTokens | number | inputTokens + outputTokens. |
Example
Request
curl -X POST https://www.agentrics.io/api/track \
-H "Authorization: Bearer agntcs_sk_..." \
-H "Content-Type: application/json" \
-d '{
"provider": "anthropic",
"model": "claude-3-haiku-20240307",
"inputTokens": 312,
"outputTokens": 84,
"agentId": "support-classifier",
"agentName": "Support Classifier",
"latencyMs": 640,
"success": true
}'Response
{
"id": "clxyz1234abcd",
"costCents": 1,
"totalTokens": 396
}Error responses
| Status | Cause |
|---|---|
| 401 | Missing, malformed, or invalid API key. |
| 400 | Invalid JSON body, or missing required fields (provider, model, inputTokens, outputTokens). |