Autumn 标志

Autumn

组织热门
EpicenterHQ
autumn

Autumn billing in Epicenter: `autumn.config.ts`, `autumn-js` credit checks, `atmn` CLI, plan gates, and metered AI usage. Use when changing billing, pricing, credits, plan access, refunds, or usage events.

概览

发布者EpicenterHQ
代码仓库epicenter
技能名称autumn
星标数
4.8K
复刻数
386
附带文件
仅含指令
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 EpicenterHQ 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Autumn AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/EpicenterHQ/epicenter/tree/main/.agents/skills/autumn
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/EpicenterHQ/epicenter.git /tmp/epicenter
mkdir -p .claude/skills
cp -r /tmp/epicenter/.agents/skills/autumn .claude/skills/autumn
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Autumn,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Autumn。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Autumn 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Autumn Billing Integration Guide

Reference Repositories

Upstream Grounding

When Autumn Product, ProductItem, Feature, Entitlement, Customer, CustomerProduct, pricing, credit checks, SDK calls, CLI behavior, or usage-event semantics affect correctness, use source-backed grounding before relying on memory. If DeepWiki MCP is available, ask a narrow question against useautumn/autumn; if it is unavailable or the repo is not indexed, use upstream source or official docs directly. For autumn-js SDK or atmn CLI behavior, verify against the installed package, useautumn/typescript, or official docs. Treat DeepWiki as orientation, then verify decisive details against local billing code, installed types, source, or official docs before changing code.

Skip DeepWiki for hosted-only Epicenter billing boundaries already documented in AGENTS.md and below.


Domain Model Checks

  • Use Autumn's current nouns precisely: Feature, Entitlement, Product, ProductItem, Price, Customer, and CustomerProduct.
  • Validate ProductItem shapes before pushing config. Most failures come from invalid interval combinations, missing linked features, or price/reset variants that do not match the feature type.
  • Decide fail-open versus fail-closed behavior for check() errors at each endpoint. AI credit charging should fail closed before expensive provider calls.
  • If Stripe webhooks or CustomerProduct state transitions are touched, make the handler idempotent around retries.

Naming Conventions (CRITICAL)

All IDs use snake_case. This is Autumn's explicit convention.

Feature IDs should be descriptive (not abstract tier numbers) and ecosystem-scoped (not tied to a single app feature like "chat"). The metered features represent model cost tiers that any AI feature can consume.

typescript
// CORRECT: descriptive, ecosystem-scoped
feature({ id: 'ai_fast', ... })
feature({ id: 'ai_standard', ... })
feature({ id: 'ai_premium', ... })
plan({ id: 'pro', ... })
plan({ id: 'credit_top_up', ... })

// WRONG: tied to a single feature ("chat")
feature({ id: 'ai_chat_fast', ... })

// WRONG: abstract tier numbers (Autumn convention prefers descriptive)
feature({ id: 'ai_tier_1', ... })

// WRONG: kebab-case
feature({ id: 'ai-fast', ... })

Feature Types

TypeconsumableUse CaseExample
meteredtrueUsage that resets periodically (messages, API calls)AI model invocations
meteredfalsePersistent allocation (seats, storage)Team seats
credit_systemn/aPool that maps to metered features via creditSchemaAI credits
booleann/aFeature flag on/offAdvanced analytics

Credit systems require linked metered features with consumable: true. Each linked feature has a creditCost defining how many credits one unit consumes.

typescript
export const aiUsage = feature({
  id: 'ai_usage',
  name: 'AI Usage',
  type: 'metered',
  consumable: true,
});

export const aiCredits = feature({
  id: 'ai_credits',
  name: 'AI Credits',
  type: 'credit_system',
  creditSchema: [
    { meteredFeatureId: 'ai_usage', creditCost: 1 },
  ],
});

Proportional Billing

Instead of multiple metered features with fixed creditCost per tier, use a single metered feature with creditCost: 1 and vary the requiredBalance at runtime.

This gives per-model cost precision without cluttering the Autumn dashboard with dozens of features.

How it works: Autumn's check() with sendEvent: true uses requiredBalance as the deduction amount. With creditCost: 1, passing requiredBalance: 5 deducts exactly 5 credits from the pool.

typescript
// Runtime cost table (in worker/billing/ai-model-pricing.ts, not autumn.config.ts)
const MODEL_CREDITS: Record<string, number> = {
  'gpt-4o-mini': 1,      // cheap model = 1 credit
  'claude-sonnet-4': 5,  // mid-range = 5 credits
  'claude-opus-4': 30,   // expensive = 30 credits
};

// Dynamic deduction
const credits = MODEL_CREDITS[model];
await autumn.check({
  customerId,
  featureId: 'ai_usage',      // single feature for all models
  requiredBalance: credits,    // varies per model
  sendEvent: true,
});

Refund on error: Use track({ featureId: 'ai_usage', value: -credits }) to refund the exact amount.

Blocking expensive models: Omit them from MODEL_CREDITS. Unknown models → getModelCredits() returns undefined → 400.


Plan Structure

Groups

Plans in the same group are mutually exclusive. Subscribing to a new plan in the same group replaces the old one. Autumn handles the Stripe subscription swap automatically.

  • Upgrade (free → pro): Immediate swap with proration.
  • Downgrade (pro → free): Scheduled for end of billing cycle.

Add-ons

Plans with addOn: true stack on top of any plan. No group conflict.

autoEnable

Plans with autoEnable: true are auto-assigned when a customer is created via customers.getOrCreate(). Use for free tiers. Only allowed on plans with no price.

Plan items: reset.interval vs price.interval

The intervals are mutually exclusive, not reset and price themselves. A PlanItem is one of three variants:

PlanItemWithReset: Has reset.interval. If price is also present, it CANNOT have price.interval. Use for free allocations that reset periodically, optionally with one-time overage pricing.

PlanItemWithPriceInterval: Has price.interval. CANNOT have reset. The price.interval determines BOTH the billing cycle AND when the included balance resets for consumable features. Use for paid plans with usage-based overage.

PlanItemNoReset: No reset. Use for continuous-use features like seats, or boolean features.

typescript
// Free plan: reset only, no price
// `reset.interval` controls when the 50 included credits refresh
item({ featureId: aiCredits.id, included: 50, reset: { interval: 'month' } })

// Paid plan: price.interval handles both billing AND reset
// The 2000 included credits reset monthly via `price.interval: 'month'`
// Overage beyond 2000 billed at $1/100 credits
item({
  featureId: aiCredits.id,
  included: 2000,
  price: { amount: 1, billingUnits: 100, billingMethod: 'usage_based', interval: 'month' },
})

Key insight: For paid plans, included + price.interval implies monthly reset. The included field's Zod description: "Balance resets to this each interval for consumable features." You do NOT need a separate reset field on paid plan items.


SDK: autumn-js

Initialization

typescript
import { Autumn } from 'autumn-js';

const autumn = new Autumn({ secretKey: env.AUTUMN_SECRET_KEY });

Stateless: safe to create per-request. No connection pooling needed.

Customer Sync (MUST be blocking)

typescript
await autumn.customers.getOrCreate({
  customerId: userId,
  name: userName ?? undefined,
  email: userEmail ?? undefined,
});

This call MUST be awaited (blocking). Autumn's /check endpoint does not auto-create customers. The customer must exist before any check() call.

Credit Check

typescript
const credits = getModelCredits(data.model);
const { allowed, balance } = await autumn.check({
  customerId: userId,
  featureId: 'ai_usage',
  requiredBalance: credits,
  sendEvent: true,
  properties: { model, provider },
});

if (!allowed) {
  // Return 402 with balance info
}

featureId is always 'ai_usage'. The credit cost varies per model via the dynamic requiredBalance.

Refund on Error

typescript
await autumn.track({
  customerId: userId,
  featureId: 'ai_usage',
  value: -credits,  // Negative value = refund
});

Use when the operation fails after credits were already deducted (e.g., AI stream errors). Typically pushed to an afterResponse queue to avoid blocking the error response.


CLI: atmn

Setup

bash
bun x atmn login       # OAuth login, saves keys to .env
bun x atmn env         # Verify org and environment

Config File

autumn.config.ts at the project root. Defines features and plans using atmn builders:

typescript
import { feature, item, plan } from 'atmn';

Push/Pull

bash
bun x atmn preview     # Dry run, shows what would change
bun x atmn push        # Push to sandbox (interactive confirmation)
bun x atmn push --prod # Push to production
bun x atmn push --yes  # Auto-confirm (for CI/CD)
bun x atmn pull        # Pull remote config, generate SDK types

Data Inspection

bash
bun x atmn customers   # Browse customers
bun x atmn plans       # Browse plans
bun x atmn features    # Browse features
bun x atmn events      # Browse usage events

Environment & Secrets

KeyEnvironmentPrefix
AUTUMN_SECRET_KEYSandbox (test)am_sk_test_...
AUTUMN_SECRET_KEYProductionam_sk_prod_...

Use the same key name in both environments. Let your secrets manager (Infisical, etc.) swap the value per environment. Don't create separate key names for sandbox vs prod.

For Cloudflare Workers: wrangler secret put AUTUMN_SECRET_KEY

For local dev with Infisical: secrets are auto-injected via infisical run --env=dev --path=/api -- wrangler dev


Middleware Pattern (Cloudflare Workers + Hono)

Ensure Customer Exists

Run after authGuard, before any billing-gated routes:

typescript
app.use('/ai/*', async (c, next) => {
  const autumn = createAutumn(c.env);
  await autumn.customers.getOrCreate({
    customerId: c.var.user.id,
    name: c.var.user.name ?? undefined,
    email: c.var.user.email ?? undefined,
  });
  await next();
});

Why inline? Cloudflare Workers don't expose env at module scope. The Autumn client must be created inside the request handler.

Credit Gate in Handler

typescript
const credits = getModelCredits(data.model);
if (!credits) return c.json(error, 400);

const { allowed, balance } = await autumn.check({
  customerId: c.var.user.id,
  featureId: 'ai_usage',
  requiredBalance: credits,
  sendEvent: true,
});

if (!allowed) return c.json(error, 402);

Stripe Integration

  • Sandbox: Built-in Stripe test account. No setup needed.
  • Production: Connect via Dashboard → Integrations → Stripe (OAuth recommended).
  • Autumn creates Stripe products/prices automatically when you atmn push.
  • Autumn is the source of truth for customer state; Stripe handles payments.

Common Gotchas

  1. getOrCreate must be awaited: Fire-and-forget will cause check() to fail with "customer not found."
  2. featureId in check() is always 'ai_usage': The credit cost varies per model via dynamic requiredBalance, not featureId.
  3. reset.interval and price.interval are mutually exclusive: not reset and price themselves. A PlanItemWithReset CAN have a price, but that price cannot have an interval. For paid plans, price.interval handles both billing and balance reset.
  4. sendEvent: true deducts atomically: Don't call track() separately for the happy path. Only use track({ value: -1 }) for refunds.
  5. All IDs are snake_case: Autumn's pricing agent convention. Don't use kebab-case.
  6. autoEnable triggers on customer creation: Not on first check(). Ensure the middleware calls getOrCreate before checking.
  7. Multiple keys per environment: Autumn supports multiple active secret keys for rotation. Generate a new key, update secrets, then revoke the old key.
  8. Use proportional billing: One metered feature (ai_usage) with creditCost: 1 and dynamic requiredBalance per model. Per-model costs live in worker/billing/ai-model-pricing.ts, not autumn.config.ts. This avoids cluttering the dashboard with dozens of features.

Project Files

FilePurpose
apps/api/autumn.config.tsFeature, credit system, and plan definitions
apps/api/worker/billing/autumn.tscreateAutumnClient(env) SDK adapter and provider error mapping
apps/api/worker/billing/ai-model-pricing.tsModel string to proportional credit cost mapping
apps/api/worker/billing/service.tsBilling domain operations, reservations, dashboard DTOs, and storage sync
apps/api/worker/billing/policies.tsAI credit charging and asset storage billing policies
apps/api/worker/billing/routes.ts/api/billing/* routes and billing auth mount
apps/api/worker/index.tsCloud Worker composition and billing policy wiring

Resources

常见问题

Autumn AI 技能有什么作用?

Autumn billing in Epicenter: `autumn.config.ts`, `autumn-js` credit checks, `atmn` CLI, plan gates, and metered AI usage. Use when changing billing, pricing, credits, plan access, refunds, or usage events.

为什么在 TypingMind 中使用 Autumn?

因为您只需安装一次,就能搭配任何模型使用。Autumn 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Autumn?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/EpicenterHQ/epicenter/tree/main/.agents/skills/autumn。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Autumn?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Autumn 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Autumn 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Autumn AI 技能免费吗?

EpicenterHQ 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇