Reference

REST API Reference

Complete REST API reference for AI Cost Guard. Authentication, endpoints, request/response schemas, and rate limits.

Base URL

https://api.aicostguard.com/v1


Authentication

All requests require a Bearer token:

curl -H "Authorization: Bearer cg_your_key_here" \


  https://api.aicostguard.com/v1/costs


Rate Limits

Plan Requests/min Requests/day
Starter 60 10,000
Pro 300 100,000
Enterprise Custom Custom

Endpoints

POST /v1/track

Log a cost entry.

curl -X POST https://api.aicostguard.com/v1/track \


  -H "Authorization: Bearer cg_..." \


  -H "Content-Type: application/json" \


  -d '{


    "model": "gpt-4o",


    "provider": "openai",


    "inputTokens": 500,


    "outputTokens": 200,


    "latencyMs": 1200,


    "projectId": "proj_abc123",


    "metadata": { "feature": "chat", "userId": "user_123" }


  }'


GET /v1/costs

Query cost data.

Query Parameters:

Param Type Description
from string Start date (ISO 8601)
to string End date (ISO 8601)
groupBy string Group by: model, provider, project, feature
projectId string Filter by project
model string Filter by model

Response:

{


  "data": [


    {


      "model": "gpt-4o",


      "provider": "openai",


      "requests": 23400,


      "inputTokens": 11700000,


      "outputTokens": 4680000,


      "totalCost": 142.50,


      "avgLatencyMs": 980


    }


  ],


  "meta": { "from": "2026-03-01", "to": "2026-03-15" }


}


GET /v1/projects

List all projects.

POST /v1/budgets

Create a budget alert.

GET /v1/alerts

List active alerts.

GET /v1/models

List supported models with current pricing.

Response:

{


  "data": [


    {


      "id": "gpt-4o",


      "name": "GPT-4o",


      "provider": "openai",


      "inputPricePerMillion": 2.50,


      "outputPricePerMillion": 10.00,


      "contextWindow": 128000


    }


  ]


}


Webhooks

Configure webhooks in Dashboard → Settings → Webhooks.

Events: cost.tracked, budget.alert, budget.exceeded, anomaly.detected

{


  "event": "budget.alert",


  "data": {


    "budgetId": "budget_abc123",


    "name": "Production Daily",


    "threshold": 80,


    "currentSpend": 82.40,


    "limit": 100


  },


  "timestamp": "2026-03-15T14:30:00Z"


}