Ingestion API Reference.
acost provides a high-performance REST API to track AI costs from any backend environment. No SDK required—just a simple POST request.
Configuration
Environment Variables
Store these keys in your secure backend configuration. Never expose your API key in client-side code.
ACOST_BASE_URL=https://tracker-acost.vercel.appACOST_API_KEY=acost_your_secret_key
Official Support
We provide high-precision tracking for the following providers.
OpenAI
Anthropic

OpenRouter
xAI

DeepSeek

Qwen

Xiaomi
Dual-Source Pricing
We track both official rates via PriceToken.ai and OpenRouter market rates. Our engine automatically switches to OpenRouter pricing if provider: "openrouter" is sent.
Custom Providers
You can use any provider, but we recommend sending a manual estimatedCost for unlisted vendors to ensure absolute accuracy.
Request Schema
Every event requires the following core fields for precise tracking.
| Field | Type | Status |
|---|---|---|
userIdUnique identifier for your application user. | string | Required |
modelExact model ID used (e.g. gpt-4o). | string | Required |
featureGrouping tag for your product features. | string | Required |
promptThe input text sent to the AI model. | string | Required |
responseContentThe generated text response from the model. | string | Required |
inputTokensPrompt token count. | number | Required |
outputTokensCompletion token count. | number | Required |
rawResponseFull provider JSON response (crucial for auditing). | object | Required |
providerAI vendor. Defaults to PriceToken.ai rates if omitted. | string | Optional |
latencyRequest duration in milliseconds. | number | Optional |
estimatedCostManual cost override. If omitted, acost will calculate this using model metadata. | number | Optional |
Payload Formats
Single Event
Pass a single object under the event key.
Batch (Up to 100)
Pass an array of objects under the events key.
Responses
Implementation Examples
Ready-to-use snippets for your backend environment.
curl -X POST https://tracker-acost.vercel.app \-H "Content-Type: application/json" \-H "x-api-key: acost_your_secret_key" \-d '{"event": {"userId": "user_123","model": "gpt-4o-mini","feature": "chat-answer","prompt": "What is the capital of France?","responseContent": "The capital of France is Paris.","inputTokens": 1200,"outputTokens": 280,"latency": 842,"rawResponse": { "id": "chatcmpl-123", "object": "chat.completion", "usage": { "prompt_tokens": 1200, "completion_tokens": 280, "total_tokens": 1480 } }}}'