Skip to main content

Cost Summary

GET /cost/summary
Get aggregate cost data for your tenant.
ParameterTypeDefaultDescription
periodstringmonthday, week, month
fromstringStart of monthISO 8601 date
tostringTodayISO 8601 date
curl "https://api.meshai.dev/cost/summary?period=month&from=2026-03-01" \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
{
  "success": true,
  "data": {
    "total_cost_usd": 1245.67,
    "total_input_tokens": 15234000,
    "total_output_tokens": 4567000,
    "total_requests": 8923,
    "period": "month",
    "from": "2026-03-01T00:00:00Z",
    "to": "2026-03-17T23:59:59Z"
  }
}

Cost by Agent

GET /cost/by-agent
Break down costs per agent, sorted by cost descending.
curl "https://api.meshai.dev/cost/by-agent?from=2026-03-01&limit=10" \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
{
  "success": true,
  "data": [
    {
      "agent_id": "agt_abc123",
      "agent_name": "production-summarizer",
      "team": "support-team",
      "total_cost_usd": 456.78,
      "input_tokens": 5600000,
      "output_tokens": 1200000,
      "requests": 3400
    }
  ],
  "meta": { "total": 12, "page": 1, "limit": 10 }
}

Cost by Team

GET /cost/by-team
Break down costs per team.
curl "https://api.meshai.dev/cost/by-team?from=2026-03-01" \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
{
  "success": true,
  "data": [
    {
      "team": "support-team",
      "total_cost_usd": 645.23,
      "input_tokens": 7800000,
      "output_tokens": 2100000,
      "requests": 4500,
      "agent_count": 5
    },
    {
      "team": "sales-team",
      "total_cost_usd": 412.30,
      "input_tokens": 5200000,
      "output_tokens": 1500000,
      "requests": 2800,
      "agent_count": 3
    }
  ]
}

Cost by Model

GET /cost/by-model
Break down costs per model.
curl "https://api.meshai.dev/cost/by-model?from=2026-03-01" \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
{
  "success": true,
  "data": [
    {
      "model_provider": "openai",
      "model_name": "gpt-4o",
      "total_cost_usd": 890.12,
      "input_tokens": 10200000,
      "output_tokens": 3100000,
      "requests": 5800
    },
    {
      "model_provider": "anthropic",
      "model_name": "claude-sonnet-4-20250514",
      "total_cost_usd": 355.55,
      "input_tokens": 5034000,
      "output_tokens": 1467000,
      "requests": 3123
    }
  ]
}

Cost Time Series

GET /cost/timeseries
Get cost data as a time series for charting.
ParameterTypeDefaultDescription
granularitystringdayhour, day, week
fromstring30 days agoISO 8601 date
tostringTodayISO 8601 date
agent_idstringFilter to a specific agent
teamstringFilter to a specific team
curl "https://api.meshai.dev/cost/timeseries?granularity=day&from=2026-03-01" \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
{
  "success": true,
  "data": [
    {
      "timestamp": "2026-03-01T00:00:00Z",
      "cost_usd": 72.34,
      "input_tokens": 890000,
      "output_tokens": 267000,
      "requests": 520
    },
    {
      "timestamp": "2026-03-02T00:00:00Z",
      "cost_usd": 68.90,
      "input_tokens": 845000,
      "output_tokens": 251000,
      "requests": 498
    }
  ]
}