Skip to content

API Reference

AgentWatch exposes a REST API for budget enforcement, dashboard analytics, and account management. The base URL is https://api.agent-watch.dev.

Authentication

All API requests require a Bearer token in the Authorization header:

Authorization: Bearer aw_live_sk_xxx-xxx-proj-yyy

For BYOK (Bring Your Own Key) proxy requests, combine your AgentWatch token with your provider key:

Authorization: Bearer aw_live_sk_xxx:sk-proj-your-openai-key

Proxy Routes

Route LLM requests through AgentWatch for budget enforcement.

MethodPathDescription
POST/v1/proxy/openaiProxy to OpenAI
POST/v1/proxy/anthropicProxy to Anthropic
POST/v1/proxy/groqProxy to Groq
POST/v1/proxy/geminiProxy to Google Gemini
POST/v1/proxy/xaiProxy to xAI (Grok)
POST/v1/proxy/azureProxy to Azure OpenAI
POST/v1/proxy/bedrockProxy to AWS Bedrock
POST/v1/proxy/mistralProxy to Mistral
POST/v1/proxy/cohereProxy to Cohere
POST/v1/proxy/xiaomiProxy to Xiaomi

Budget Headers

Add these headers to enforce budget limits on proxy requests:

HeaderDescriptionExample
X-AgentWatch-Session-IdUnique session identifiermy-session-123
X-AgentWatch-Session-Budget-UsdPer-session USD spending cap2.00

Example (Python)

python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.agent-watch.dev/v1/proxy/openai",
    api_key="aw_live_sk_xxx:sk-proj-your-openai-key",
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
    extra_headers={
        "X-AgentWatch-Session-Budget-Usd": "2.00",
        "X-AgentWatch-Session-Id": "my-session",
    }
)

Example (TypeScript)

typescript
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: "https://api.agent-watch.dev/v1/proxy/openai",
  apiKey: "aw_live_sk_xxx:sk-proj-your-openai-key",
});

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello" }],
}, {
  headers: {
    "X-AgentWatch-Session-Budget-Usd": "2.00",
    "X-AgentWatch-Session-Id": "my-session",
  }
});

Example (curl)

bash
curl https://api.agent-watch.dev/v1/proxy/openai/chat/completions \
  -H "Authorization: Bearer aw_live_sk_xxx:sk-proj-your-openai-key" \
  -H "Content-Type: application/json" \
  -H "X-AgentWatch-Session-Budget-Usd: 2.00" \
  -H "X-AgentWatch-Session-Id: my-session" \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'

Dashboard API

Analytics and management endpoints. All require authentication.

MethodPathDescription
GET/v1/dashboardDashboard HTML
GET/v1/dashboard/summarySpend summary (total, requests, sessions, error rate)
GET/v1/dashboard/spend-trendSpend over time (daily/weekly)
GET/v1/dashboard/sessionsSession cost breakdown
GET/v1/dashboard/providersPer-provider usage and latency
GET/v1/dashboard/teamsPer-team spend breakdown
GET/v1/dashboard/anomaliesDetected anomalies
GET/v1/dashboard/analytics/advancedAdvanced analytics
GET/v1/dashboard/agent-spendPer-agent spend data
GET/v1/dashboard/keysAPI key management
POST/v1/dashboard/keysGenerate new API key
DELETE/v1/dashboard/keysRevoke API key
GET/v1/dashboard/settingsAccount settings
POST/v1/dashboard/settingsUpdate settings
GET/v1/dashboard/audit_logsAudit log entries
GET/v1/dashboard/timelineGovernance timeline for a session

Authentication API

MethodPathDescription
POST/v1/auth/signupCreate account (email + password)
POST/v1/auth/loginSign in
GET/v1/auth/githubInitiate GitHub OAuth
GET/v1/auth/github/callbackGitHub OAuth callback

Payments API

MethodPathDescription
GET/v1/payments/public-keyRazorpay public key
POST/v1/payments/create-orderCreate payment order
POST/v1/payments/verifyVerify payment
GET/v1/promos/statusCheck promo code status
POST/v1/promos/validateValidate promo code
POST/v1/promos/redeemRedeem promo code

Rules API

Custom governance rules (Pro/Enterprise only).

MethodPathDescription
GET/v1/rulesList rules
POST/v1/rulesCreate rule
PUT/v1/rules/:idUpdate rule
DELETE/v1/rules/:idDelete rule

Error Responses

All errors return JSON:

json
{
  "error": {
    "message": "Missing or invalid AgentWatch bearer token.",
    "type": "agentwatch_proxy_error"
  }
}
StatusMeaning
400Bad request (invalid input)
401Authentication failed
402Budget exceeded (session or team cap hit)
403Forbidden (plan upgrade required)
404Not found
429Rate limited
500Internal server error

OpenAPI Spec

The full OpenAPI 3.0 spec is available at openapi.yaml.