Skill for adding feature gating and usage tracking using Autumn.
Always consult docs.useautumn.com for code examples and latest API.
Autumn tracks feature usage and enforces limits. Backend checks required for security.
check → work → track
| Field | Description |
|-------|-------------|
| allowed | Can customer proceed |
| balance | Units remaining |
| included_usage | Total usage included in plan |
| unlimited | No limit enforced |
| Type | Behavior |
|------|----------|
| boolean | Access granted or denied |
| metered | Usage tracked against limit |
| credit_system | Pool for multiple features |
| Layer | Purpose | Trust | |-------|---------|-------| | Frontend | UX (show/hide UI) | Untrusted | | Backend | Enforcement | Required |
import { Autumn } from "autumn-js";
const autumn = new Autumn({ secretKey: process.env.AUTUMN_SECRET_KEY });
// 1. Check
const { data } = await autumn.check({ customer_id, feature_id: "api_calls" });
if (!data.allowed) return { error: "Limit reached" };
// 2. Work
const result = await doWork();
// 3. Track
await autumn.track({ customer_id, feature_id: "api_calls", value: 1 });
return result;
from autumn import Autumn
autumn = Autumn('am_sk_test_xxx')
response = await autumn.check(customer_id="user_123", feature_id="api_calls")
if not response.allowed:
raise HTTPException(403, "Limit reached")
result = await do_work()
await autumn.track(customer_id="user_123", feature_id="api_calls", value=1)
import { useCustomer } from "autumn-js/react";
const { check, refetch } = useCustomer();
const handleAction = async () => {
const { data } = await check({ featureId: "messages" });
if (!data?.allowed) {
showUpgradePrompt();
return;
}
await performAction();
await refetch();
};
const { customer } = useCustomer();
const feature = customer?.features?.api_calls;
<p>{feature?.balance} / {feature?.included_usage}</p>
Track the underlying metered feature, not the credit system:
// Config: credits → api_calls (1), image_gen (10)
// Wrong
await autumn.track({ customer_id, feature_id: "credits", value: 10 });
// Right - Autumn deducts 10 credits automatically
await autumn.track({ customer_id, feature_id: "image_gen", value: 1 });
idempotency_key to prevent double-countingvalue for bulk operationsnpx skills add usenotra/autumn-add-usage-tracking下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer