skip to content
superbot.gg

Get AI spend across apps

Part of Usage & spend, 8 operations. The overview covers keys, scopes and errors.

GET /v1/spend

AI spend across every app on the account over a window, by provider and day.

A caller key holding usage:read (Authorization: Bearer sbc_… or x-api-key: sbc_…), or a signed-in session.

Operation id getSpend in Usage & spend.

Query parameters

  • range string optional

    Window; default 30d. One of 30d, 90d, month, custom.

  • from string (date) optional

    YYYY-MM-DD, with range=custom.

  • to string (date) optional

    YYYY-MM-DD, with range=custom.

Response 200

The spend report.

application/json: Spend.

  • from string required
  • to string required
  • currency string required

    One of USD.

  • total_usd number required
  • tied_usd number required
  • estimated_usd number required
  • unpriced_models array of string required
  • providers array of object required
    13 fields
    • provider string required
    • label string required
    • total_usd number required
    • usage_usd number required
    • purchase_usd number required
    • measured_usd number required
    • estimated_usd number required
    • plan_usd number required
    • residual_usd number | null required
    • status string required

      One of caught_up, residual, estimate_only.

    • services array of object required
      2 fields
      • service string required
      • total_usd number required
    • unpriced_usage array of object required
      7 fields
      • service string required
      • sku string required
      • quantity number required
      • unit string required

        One of tokens, requests, acu, seat-month.

      • period_start string required
      • period_end string required
      • fresh_at string required
    • sources array of object required
      3 fields
      • source string required
      • fresh_at string | null required
      • status string required

        One of ok, stale, missing.

  • series array of object required
    2 fields
    • day string required
    • providers object required

Errors

StatusCodeWhat to change
400invalid_request

A parameter or body field is invalid; param names it and issues lists every problem.

401unauthorized

Send a live caller key or session as Authorization: Bearer … or x-api-key. No key yet: create one at /account/api, or sign a user in at /auth.md.

403insufficient_scope

The key lacks the scope in required_scopes; mint a key that holds it.

view .mdopenapi
Request

curl

curl -sS -X GET "https://superbot.gg/v1/spend" \
  -H "Authorization: Bearer $SUPERBOT_API_KEY"

JavaScript

const res = await fetch(`https://superbot.gg/v1/spend`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.SUPERBOT_API_KEY}`,
  },
});
console.log(res.status, await res.json());

Python

import os
import requests

res = requests.request(
    "GET",
    "https://superbot.gg/v1/spend",
    headers={
        "Authorization": f"Bearer {os.environ['SUPERBOT_API_KEY']}",
    },
)
print(res.status_code, res.json())
Response

200 The spend report.

{
  "from": "your-from",
  "to": "your-to",
  "currency": "USD",
  "total_usd": 0,
  "tied_usd": 0,
  "estimated_usd": 0,
  "unpriced_models": [
    "your-unpriced-models"
  ],
  "providers": [
    {
      "provider": "your-provider",
      "label": "your-label",
      "total_usd": 0,
      "usage_usd": 0,
      "purchase_usd": 0,
      "measured_usd": 0,
      "estimated_usd": 0,
      "plan_usd": 0,
      "residual_usd": 0,
      "status": "caught_up",
      "services": [
        {}
      ],
      "unpriced_usage": [
        {}
      ],
      "sources": [
        {}
      ]
    }
  ],
  "series": [
    {
      "day": "your-day",
      "providers": {}
    }
  ]
}

400 The request is malformed or a parameter is invalid; `param` names the field.

{
  "error": "invalid_request",
  "message": "A parameter or body field is invalid; param names it and issues lists every problem.",
  "doc_url": "https://superbot.gg/developers#errors-invalid_request",
  "request_id": "req_5f1c0a9e2b7d4c3a1e0f9b8d"
}

401 The bearer is missing, malformed or unknown.

{
  "error": "unauthorized",
  "message": "Send a live caller key or session as Authorization: Bearer … or x-api-key. No key yet: create one at /account/api, or sign a user in at /auth.md.",
  "doc_url": "https://superbot.gg/developers#errors-unauthorized",
  "request_id": "req_5f1c0a9e2b7d4c3a1e0f9b8d"
}

403 The key lacks a scope (insufficient_scope), is revoked, or may not call this route.

{
  "error": "insufficient_scope",
  "message": "The key lacks the scope in required_scopes; mint a key that holds it.",
  "doc_url": "https://superbot.gg/developers#errors-insufficient_scope",
  "request_id": "req_5f1c0a9e2b7d4c3a1e0f9b8d"
}