API Documentation

Quick Start

Get started in 3 steps: generate an API key, track your first LLM call, view your costs.

# 1. Get your API key

curl -X POST https://agentbill.avipilcer.com/api/v1/keys \
  -H "Content-Type: application/json" \
  -d '{"tier": "free"}'

# 2. Track an LLM API call

curl -X POST https://agentbill.avipilcer.com/api/v1/track \
  -H "Authorization: Bearer ab_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "code-reviewer",
    "provider": "anthropic",
    "model": "claude-3-sonnet",
    "inputTokens": 1500,
    "outputTokens": 800,
    "costUsd": 0.012,
    "projectId": "my-saas",
    "status": "success"
  }'

# 3. View your costs

curl https://agentbill.avipilcer.com/api/v1/costs \
  -H "Authorization: Bearer ab_YOUR_KEY"

Authentication

All API calls require an API key. Include it in one of these ways:

  • Authorization: Bearer ab_xxx(recommended)
  • X-API-Key: ab_xxx(alternative header)
  • ?api_key=ab_xxx(query parameter)

Endpoints

POST/api/v1/keys

Generate a new API key

{"tier": "free|starter|pro"}
POST/api/v1/trackAuth Required

Track an LLM API call

{"agentId", "provider", "model", "inputTokens", "outputTokens", "costUsd", "projectId", "status"}
GET/api/v1/costsAuth Required

Get cost breakdowns by agent, model, project

?project_id=x&start_date=x&end_date=x&format=summary|events
GET/api/v1/budgetsAuth Required

List all budget rules

?alerts=true
POST/api/v1/budgetsAuth Required

Create a budget rule

{"name", "limitUsd", "period", "projectId?", "agentId?", "action?", "webhookUrl?"}
GET/api/v1/optimizeAuth Required

Get cost optimization insights

?project_id=x
GET/api/v1/usageAuth Required

Check your API usage and limits

GET/api/v1/reportsAuth Required

Generate a cost report

?period=daily|weekly|monthly&project_id=x

Rate Limits

PlanTracked Calls/moProjectsData Retention
Free1,00017 days
Starter ($99/mo)10,000530 days
Pro ($249/mo)100,000Unlimited90 days