autumn

Configure Autumn usage-based billing with credit checks, plan gates, and metered AI usage.

4.8k|376|Updated Mar 16, 2023
One-click install
npx skills add https://github.com/EpicenterHQ/epicenter --skill autumn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: autumn
Source: https://github.com/EpicenterHQ/epicenter/tree/main/.agents/skills/autumn
Command: npx skills add https://github.com/EpicenterHQ/epicenter --skill autumn

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires autumn-js, atmn.

What problem does it solve?

Integrating usage-based billing into an application requires correctly modeling features, credit systems, plans, and Stripe-backed subscriptions, and mistakes in configuration or SDK usage cause failed credit checks, incorrect deductions, or broken plan upgrades.

Core Features & Use Cases

  • Billing Configuration: Define features, credit systems, and plans in autumn.config.ts and push them with the atmn CLI, following Autumn's snake_case naming and PlanItem interval rules.
  • Metered AI Usage: Implement proportional credit billing where a single metered feature deducts variable amounts per AI model via dynamic requiredBalance, with refunds through negative track() values.
  • Middleware Integration: Wire customer creation and credit gates into Cloudflare Workers + Hono routes, ensuring getOrCreate is awaited before any check() call.
  • Use Case: When adding a new AI model to your API, use this Skill to map the model to a credit cost, gate the endpoint with an Autumn credit check, and refund credits automatically if the AI stream fails.

Quick Start

Ask the AI to add a credit check gate for a new AI model endpoint using the Autumn billing configuration in this project.

Frequently Asked Questions about autumn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add usage-based billing to a TypeScript API with Autumn?

Define features and plans in autumn.config.ts using the atmn builders, push the config with `bun x atmn push`, then gate endpoints with the autumn-js SDK's check() method using sendEvent: true to deduct credits atomically.

How do I charge different credit amounts per AI model with Autumn?

Use a single metered feature with creditCost: 1 and vary the requiredBalance at runtime based on a model-to-credit mapping table. Autumn's check() deducts exactly the requiredBalance amount, giving per-model pricing without creating dozens of features.

Why does Autumn check() fail with customer not found?

Autumn's /check endpoint does not auto-create customers, so customers.getOrCreate() must be awaited before any check() call. Fire-and-forget customer creation causes race conditions where the check runs before the customer exists.

Can a plan item have both reset and price intervals in Autumn?

No, reset.interval and price.interval are mutually exclusive on a PlanItem. For paid plans, price.interval controls both the billing cycle and when the included balance resets, so a separate reset field is not needed.

How do I refund credits in Autumn when an AI request fails?

Call autumn.track() with a negative value, such as track({ customerId, featureId: 'ai_usage', value: -credits }), to refund the exact deducted amount. This is typically queued in an afterResponse handler so it does not block the error response.