TokenLab

Management

Get API Key Billing

Returns aggregated billing breakdowns for a user API key.

GEThttps://api.tokenlab.sh/v1/management/api-keys/{keyId}/billing

Overview

Return total spend, request count, billable usage, and cost grouped by model, model maker, scene, and date.

Notes

  • Monetary fields are USD-only.

  • Workspace top-ups and invoices are not included.

Example

Supports the same model, model vendor, scene, and date filters as API key usage. Returns totals without pagination.

Request

cURL
curl -X GET "https://api.tokenlab.sh/v1/management/api-keys/key_abc123def456/billing?startDate=2026-07-01&endDate=2026-07-31" \
  -H "Authorization: Bearer mt-your-management-token"

Request / Response

This page provides the OpenAPI schema and copyable request examples. Send management requests from your terminal or client with a Management Token; direct sending is not available on this page.

Response example

Response

200 OK
{
  "api_key": {
    "id": "key_abc123def456",
    "name": "Backend Worker",
    "key_prefix": "sk-live...",
    "status": "active",
    "limit_amount": 500,
    "limit_amount_decimal": "500",
    "used_amount": 148.25,
    "used_amount_decimal": "148.25",
    "models": [
      "gpt-5.6-luna",
      "claude-3-7-sonnet"
    ],
    "expires_at": "2026-12-31T23:59:59.000Z",
    "last_used_at": "2026-07-08T03:12:45.000Z",
    "created_at": "2026-07-01T10:00:00.000Z",
    "delivery_policy": null
  },
  "summary": {
    "total_requests": 1,
    "total_cost": 0.0012,
    "total_cost_decimal": "0.0012",
    "total_prompt_tokens": 1000,
    "total_completion_tokens": 500,
    "total_tokens": 1500,
    "usage_unit_breakdown": [
      {
        "usage_unit": "per_token",
        "usage_quantity": 1500
      }
    ]
  },
  "breakdowns": {
    "by_model": [
      {
        "model": "gpt-5.6-luna",
        "logical_model": "gpt-5.6-luna",
        "model_vendor": "OpenAI",
        "requests": 1,
        "cost": 0.0012,
        "cost_decimal": "0.0012",
        "usage_quantity": 1500,
        "usage_quantity_decimal": "1500"
      }
    ],
    "by_logical_model": [
      {
        "model": "gpt-5.6-luna",
        "logical_model": "gpt-5.6-luna",
        "model_vendor": "OpenAI",
        "requests": 1,
        "cost": 0.0012,
        "cost_decimal": "0.0012",
        "usage_quantity": 1500,
        "usage_quantity_decimal": "1500"
      }
    ],
    "by_model_vendor": [
      {
        "model_vendor": "OpenAI",
        "requests": 1,
        "cost": 0.0012
      }
    ],
    "by_scene": [
      {
        "scene": "chat",
        "requests": 1,
        "cost": 0.0012,
        "cost_decimal": "0.0012"
      }
    ],
    "daily_cost": [
      {
        "date": "2026-07-08T00:00:00.000Z",
        "cost": 0.0012,
        "cost_decimal": "0.0012"
      }
    ]
  }
}

Important fields

api_keyobject
API key summary using the same fields as list/create/update responses.
summaryobject
Aggregated totals for the selected filters.
breakdownsobject
Aggregated breakdowns for the selected filters.
summary.total_requestsnumber
Total request count.
summary.total_costnumber
Total cost in USD as a JSON number for display.
summary.total_cost_decimalstring
Exact total cost in USD as a decimal string.
summary.total_prompt_tokensnumber
Total prompt tokens.
summary.total_completion_tokensnumber
Total completion tokens.
summary.total_tokensnumber
Total tokens.
summary.usage_unit_breakdownarray
Usage quantity grouped by usage unit.
breakdowns.by_modelarray
Breakdown by requested public model.
breakdowns.by_logical_modelarray
Breakdown by logical public model.
breakdowns.by_model_vendorarray
Breakdown by public model vendor.
breakdowns.by_scenearray
Breakdown by public request scene.
breakdowns.daily_costarray
Daily cost trend.

Authorization

ManagementTokenAuth
AuthorizationBearer <token>

Management token authentication. Create or manage Management Tokens in Dashboard > API > Management Tokens.

In: header

Path Parameters

keyId*string

Query Parameters

model?string

Filter by requested model name. Maximum length 100.

Lengthlength <= 100
modelVendor?string

Filter by public model vendor. Maximum length 100.

Lengthlength <= 100
scene?string

Filter by public request scene.

Value in

  • "chat"
  • "image"
  • "audio"
  • "video"
  • "embedding"
  • "rerank"
  • "translation"
  • "music"
  • "3d"
  • "realtime"
  • "systemone"
startDate?string
endDate?string

Response

application/json

application/json

application/json

application/json

application/json