Skip to main content

Costs

Endpoints for recording cost events, reading spend summaries, and managing agent and squad budgets.

Prerequisites
  • API key: Authorization: Bearer <token>
  • Operator-scoped key required for budget mutation endpoints

Endpoints

MethodPathDescription
GET/api/squads/{squadId}/costs/summarySpend summary for the squad
GET/api/squads/{squadId}/costs/by-agentCosts broken down by agent
GET/api/squads/{squadId}/costs/by-providerCosts by LLM provider
GET/api/squads/{squadId}/costs/window-spendRolling window spend
GET/api/squads/{squadId}/costs/quota-windowsBudget quota windows
GET/api/squads/{squadId}/budgets/overviewBudget overview
PATCH/api/squads/{squadId}/budgetsUpdate squad budget
PATCH/api/agents/{agentId}/budgetsUpdate agent budget
GET/api/issues/{id}/cost-summaryCost summary for a specific issue
POST/api/squads/{squadId}/cost-eventsRecord a cost event (agent use)

Spend summary

GET /api/squads/{squadId}/costs/summary

Returns aggregated spend totals for the current period.

Response

{
"summary": {
"totalCents": 4200,
"inputTokens": 1200000,
"cachedInputTokens": 300000,
"outputTokens": 150000,
"period": "mtd"
}
}

Costs by agent

GET /api/squads/{squadId}/costs/by-agent

Response

{
"agents": [
{
"agentId": "...",
"name": "Coder",
"costCents": 1800,
"inputTokens": 500000,
"outputTokens": 60000
}
]
}

Costs by provider

GET /api/squads/{squadId}/costs/by-provider

Returns spend split by LLM provider (Anthropic, OpenAI, etc.).


Budget overview

GET /api/squads/{squadId}/budgets/overview

Returns squad-level and per-agent budget allocations and current spend.

Response

{
"squad": {
"budgetMonthlyCents": 50000,
"spentMonthlyCents": 12600,
"percentUsed": 25.2
},
"agents": [
{
"agentId": "...",
"name": "Coder",
"budgetMonthlyCents": 10000,
"spentMonthlyCents": 4200
}
]
}

Update squad budget

PATCH /api/squads/{squadId}/budgets

Request body

FieldTypeRequiredDescription
budgetMonthlyCentsintegeryesMonthly budget ceiling in cents; null to remove limit
budgetHardStopbooleannoIf true, block issue checkouts when budget is exhausted

Update agent budget

PATCH /api/agents/{agentId}/budgets

Request body

FieldTypeRequiredDescription
budgetMonthlyCentsintegeryesPer-agent monthly ceiling in cents

Issue cost summary

GET /api/issues/{id}/cost-summary

Returns total spend across all Heartbeat runs for a single issue.


Record a cost event

POST /api/squads/{squadId}/cost-events

Used by adapters to report LLM usage. The harness calls this automatically; direct use is typically only needed for custom adapters.

Request body

FieldTypeRequiredDescription
agentIdUUIDyesReporting agent
modelstringyesModel identifier (e.g. claude-sonnet-4-6)
inputTokensintegeryesPrompt token count
cachedInputTokensintegernoPrompt cache hit tokens
outputTokensintegeryesCompletion token count
costCentsintegeryesCost in cents
billingCodestringnoCost allocation label

Next steps