Skip to main content
GET
/
api
/
v1
/
costs
Cost Analytics
curl --request GET \
  --url https://api.example.com/api/v1/costs
{
  "summary": {
    "weekly_cost": {
      "value": 123,
      "trend_pct": 123
    }
  },
  "daily": [
    {
      "date": "<string>",
      "cost": 123
    }
  ],
  "hourly": [
    {
      "hour": "<string>",
      "cost": 123
    }
  ],
  "by_model": [
    {
      "model": "<string>",
      "tokens": 123,
      "share_pct": 123,
      "estimated_cost": 123
    }
  ]
}

Overview

The costs endpoint provides detailed cost analysis across time and models. It returns summary statistics, hourly/daily cost timeseries, and a breakdown of costs by model. Costs are calculated using model pricing data and token counts. Negative costs (invalid pricing) are sanitized to zero.

Authentication

Requires session authentication (cookie) or API key via X-API-Key header.

Query Parameters

range
string
default:"7d"
Time range for analytics. Valid values: 1h, 6h, 24h, 7d, 30dNote: Default is 7d for cost analytics (differs from other endpoints).
agent_name
string
Filter analytics to a specific agent. If omitted, returns data for all agents.

Response Schema

summary
object
Cost summary for the selected time range
daily
array
Daily cost timeseries
hourly
array
Hourly cost timeseries
by_model
array
Cost and token breakdown by model, ordered by token usage (highest first)

Example Request

cURL
curl -X GET "https://api.manifest.build/api/v1/costs?range=30d" \
  -H "X-API-Key: your-api-key"

Example Response

{
  "summary": {
    "weekly_cost": {
      "value": 12.48,
      "trend_pct": -8.5
    }
  },
  "daily": [
    {
      "date": "2026-02-03",
      "cost": 0.38
    },
    {
      "date": "2026-02-04",
      "cost": 0.42
    },
    {
      "date": "2026-02-05",
      "cost": 0.51
    },
    {
      "date": "2026-02-06",
      "cost": 0.39
    },
    {
      "date": "2026-02-07",
      "cost": 0.44
    },
    {
      "date": "2026-02-08",
      "cost": 0.36
    },
    {
      "date": "2026-02-09",
      "cost": 0.48
    }
  ],
  "hourly": [
    {
      "hour": "2026-02-09 00:00:00",
      "cost": 0.018
    },
    {
      "hour": "2026-02-09 01:00:00",
      "cost": 0.022
    },
    {
      "hour": "2026-02-09 02:00:00",
      "cost": 0.015
    }
  ],
  "by_model": [
    {
      "model": "claude-4.5-sonnet",
      "tokens": 3250000,
      "share_pct": 62.3,
      "estimated_cost": 8.12
    },
    {
      "model": "gpt-4o",
      "tokens": 1450000,
      "share_pct": 27.8,
      "estimated_cost": 3.18
    },
    {
      "model": "gemini-2.0-flash",
      "tokens": 520000,
      "share_pct": 9.9,
      "estimated_cost": 1.18
    }
  ]
}

Notes

  • Cost calculation: Costs are computed as (input_tokens * input_price + output_tokens * output_price) using model pricing from the model_pricing table.
  • Pricing data: Model prices are synced from Anthropic’s API and manually updated for other providers. Missing pricing results in null costs.
  • Cost sanitization: Negative costs (data errors) are treated as 0 and excluded from aggregations.
  • Both timeseries returned: Similar to /tokens, this endpoint returns both hourly and daily arrays in every response.
  • Caching: Responses are cached for 5 minutes (see DASHBOARD_CACHE_TTL_MS).
  • Multi-tenancy: Data is automatically filtered by authenticated user.
  • Default range: Unlike other analytics endpoints, costs default to 7d (weekly view).

Build docs developers (and LLMs) love