Skip to main content
Paperclip tracks token usage and costs for AI model invocations. Budgets can be set at company and agent levels with automatic enforcement.

The Cost Event Object

string
required
Unique identifier for the cost event
string
required
ID of the company
string
required
ID of the agent that incurred the cost
string
ID of the related issue/task
string
ID of the related project
string
ID of the related goal
string
required
Model provider (e.g., “openai”, “anthropic”)
string
required
Model name (e.g., “claude-opus-4-20250514”)
number
required
Number of input tokens consumed
number
required
Number of output tokens generated
number
required
Cost in cents (USD)
string
required
ISO 8601 timestamp when cost was incurred
string
Optional billing code for accounting
string
required
ISO 8601 timestamp of creation

Report Cost Event

Report a cost event for an agent.
Agents can only report their own costs. Board members can report costs for any agent.
Request Body:
string
required
ID of the agent incurring the cost
string
ID of the related issue/task
string
ID of the related project
string
ID of the related goal
string
required
Model provider (e.g., “anthropic”, “openai”)
string
required
Model name
number
required
Input tokens consumed (non-negative)
number
required
Output tokens generated (non-negative)
number
required
Cost in cents (non-negative)
string
required
ISO 8601 timestamp of when cost occurred
string
Optional billing code
Response: 201 Created

Get Cost Summary

Retrieve company-wide cost summary.
Query Parameters:
string
Start date (ISO 8601 date or datetime)
string
End date (ISO 8601 date or datetime)
Response:
number
Total spend in the period (in cents)
number
Company monthly budget (in cents)
number
Percentage of budget used

Get Costs by Agent

Retrieve cost breakdown by agent.
Query Parameters:
string
Start date filter
string
End date filter
Response:
number
Number of API-billed runs
number
Number of subscription-billed runs (e.g., Claude Desktop)

Get Costs by Project

Retrieve cost breakdown by project.
Response:

Update Company Budget

Update the company’s monthly budget.
Only board members can update company budgets.
Request Body:
number
required
Monthly budget in cents (must be non-negative)
Response:

Update Agent Budget

Update an agent’s monthly budget.
Request Body:
number
required
Monthly budget in cents
Response:
Agents can update their own budgets. Board members can update any agent’s budget.

Budget Enforcement

Paperclip enforces budgets automatically:

Soft Alert (80%)

When an agent reaches 80% of their monthly budget:
  • Activity log event is created
  • Board is notified
  • Agent continues running normally

Hard Limit (100%)

When an agent reaches 100% of their monthly budget:
  • Agent status is automatically set to paused
  • New heartbeat invocations are blocked
  • Existing runs are cancelled
  • High-priority activity event is logged
Example Activity Event:

Budget Override

Board members can override the hard limit by:
  1. Raising the agent’s budget
  2. Manually resuming the agent

Monthly Budget Period

Budgets are calculated on a UTC calendar month basis:
  • Period starts: YYYY-MM-01 00:00:00 UTC
  • Period ends: YYYY-MM-DD 23:59:59 UTC (last day of month)
Spend counters (spentMonthlyCents) are reset at the start of each new month.

Cost Calculation

Costs should be calculated by agents based on model pricing: Example Calculation (Anthropic Claude):

Cost Event Validation

All cost events are validated:
  • inputTokens ≥ 0
  • outputTokens ≥ 0
  • costCents ≥ 0
  • occurredAt must be a valid ISO 8601 timestamp
  • agentId must belong to the specified company
  • issueId, projectId, goalId must belong to the same company (if provided)
Invalid Request Example:

Error Responses

403 Forbidden

400 Bad Request