Agentrics

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 header401 Unauthorized
Invalid / revoked key401 Unauthorized

Request body

Content-Type: application/json

FieldTypeDescription
providerrequired"openai" | "anthropic" | "google"The AI provider.
modelrequiredstringModel name, e.g. "gpt-4o-mini" or "claude-3-haiku-20240307".
inputTokensrequirednumberPrompt / input token count.
outputTokensrequirednumberCompletion / output token count.
agentIdstringStable identifier for the agent making the call.
agentNamestringDisplay name for the agent. Defaults to "default".
latencyMsnumberRound-trip latency in milliseconds.
successbooleanWhether the call succeeded. Defaults to true.
errorMessagestringError message if success is false.

Response

Returns 200 OK on success.

FieldTypeDescription
idstringThe ID of the created execution record.
costCentsnumberCalculated cost in cents (integer).
totalTokensnumberinputTokens + 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

StatusCause
401Missing, malformed, or invalid API key.
400Invalid JSON body, or missing required fields (provider, model, inputTokens, outputTokens).