Margin & StackLedger
Map customer MRR to LLM cost and export for accounting
Understand margin = customer revenue − LLM spend for each customer_id.
Prerequisites
- Pro or Team plan (customer cost / margin feature)
- Events that include
customer_id
await sg.record({
feature_id: "chat",
model: "gpt-4o-mini",
input_tokens: 100,
output_tokens: 40,
customer_id: "cus_123",
});
Margin view
- Open Project → Margin.
- Map each
customer_idto monthly MRR (USD), or sync from Stripe when configured. - Inspect gross margin on a rolling window (typically 30 days).
StackLedger
For indie operators linking LLM burn into bookkeeping:
- Settings → Integrations → set StackLedger project id.
- Ensure server env
STACKLEDGER_API_URL+STACKLEDGER_API_KEY(hosted stack handles this for you when bundled). - Export Schedule C–friendly CSV via the Margin export control, or:
GET /api/projects/{projectId}/export?type=stackledger
Team RBAC note
On Team plans, member roles are read-mostly on dashboards; admin manages billing, invites, and integrations.