C4 Level 3 -- Cost API
Queries external usage APIs to track spending on AI and cloud services.

Clean Architecture Layers
Controllers
| Endpoint |
Purpose |
GET /usage/anthropic |
Claude API token usage and costs |
GET /usage/google |
Gemini API usage and costs |
GET /usage/cloudflare |
Worker/Pages usage and costs |
GET /usage/summary |
Aggregated spending across all services |
Domain (Entities) — No I/O
| Component |
Responsibility |
| CostCalculator |
Aggregate spending. Convert currencies (USD→NOK). Calculate burn rate. Budget vs actual. |
Adapters
| Adapter |
External System |
| AnthropicGateway |
Anthropic Admin API — token counts, costs per model |
| GoogleGateway |
GCP Billing API — Gemini usage |
| CloudflareGateway |
Cloudflare API — Worker invocations, Pages builds |