billing

GitHub

管理LLM网关的组织、计划、积分和计费逻辑,涵盖Stripe集成、成本计算及审计通知。适用于涉及账单、订阅或组织权限的代码变更。

.agents/skills/billing/SKILL.md theopenco/llmgateway

Trigger Scenarios

修改计费或订阅逻辑 处理Stripe Webhook 调整组织计划或积分限制

Install

npx skills add theopenco/llmgateway --skill billing -g -y
More Options

Non-standard path

npx skills add https://github.com/theopenco/llmgateway/tree/main/.agents/skills/billing -g -y

Use without installing

npx skills use theopenco/llmgateway@billing

指定 Agent (Claude Code)

npx skills add theopenco/llmgateway --skill billing -a claude-code -g -y

安装 repo 全部 skill

npx skills add theopenco/llmgateway --all -g -y

预览 repo 内 skill

npx skills add theopenco/llmgateway --list

SKILL.md

Frontmatter
{
    "name": "billing",
    "description": "Organizations, plans, credits, and billing in LLM Gateway — org kinds, the Pro plan, DevPass and Chat entitlements, Stripe webhooks, end-user wallets, cost and token billing math, audit logs, and org-scoped emails and notifications. Use when changing apps\/api\/src\/stripe.ts, subscription or credit logic, cost calculation, organization.kind or plan gating, DevPass status, audit_log actions, or any email or notification sent for an organization."
}

Billing and organizations

Money

  • Do all money, credit, and usage-threshold math with Decimal from decimal.js; convert DB decimal strings with new Decimal(value ?? 0).
  • Token extraction (apps/gateway/src/chat/tools/extract-token-usage.ts) normalizes completion tokens to include reasoning; calculateCosts (packages/actions/src/costs.ts) bills the completion count and reports reasoningTokens as a detail. Verify a new reasoning provider's usage semantics live.

Organization kinds and plans

  • organization.kind (default / devpass / chat) is set at creation and never changes; DevPass and Chat signups get a separate organization (apps/api/src/utils/personal-org.ts). Joining on it for historical attribution is safe. organization.plan changes over time.
  • The Pro plan exists only on default orgs. DevPass and Chat entitlements live in devPlan / chatPlan and their *CreditsLimit / *StripeSubscriptionId columns; organization.stripeSubscriptionId is reserved for a team org's Pro subscription.
  • Every Stripe webhook that sets plan: "pro" or stamps stripeSubscriptionId first returns for non-default kinds, as checkout.session.completed, customer.subscription.created, and invoice.payment_succeeded in apps/api/src/stripe.ts do. A devpass or chat org with plan: "pro" is corrupt state; gate product behavior for those orgs on their own entitlement columns.
  • End-user wallet organizations are regular PAYG default orgs. withWalletCredits affects only downstream credit gating, never kind- or plan-gated gateway logic.
  • For "has this org ever paid for DevPass", use hasBillingHistory from GET /dev-plans/status; plan end clears every devPlan* column.

Audit log, emails, notifications

  • audit_log records actions owned by one organization. User-account events (email, password, profile) belong in a user-scoped store.
  • Send org-scoped email only when the org owner's email is verified, via isOrgOwnerEmailVerified / resolveVerifiedOrgRecipient (@llmgateway/db). Only verification and password-reset emails reach unverified users.
  • Prefix org-scoped notification event keys with the org id.

Version History

  • d41bf19 Current 2026-10-19 04:12

Same Skill Collection

.agents/skills/add-model/SKILL.md
.agents/skills/blog/SKILL.md
.agents/skills/changelog/SKILL.md
.agents/skills/core-web-vitals/SKILL.md
.agents/skills/database/SKILL.md
.agents/skills/frontend/SKILL.md
.agents/skills/gateway/SKILL.md
.agents/skills/infrastructure/SKILL.md
.agents/skills/knowledge-base/SKILL.md
.agents/skills/legal-pages/SKILL.md
.agents/skills/local-stack/SKILL.md
.agents/skills/migrations/SKILL.md
.agents/skills/model-benchmarks/SKILL.md
.agents/skills/pull-request/SKILL.md
.agents/skills/security-audit/SKILL.md
.agents/skills/skill-authoring/SKILL.md
.agents/skills/testing/SKILL.md
.agents/skills/verify/SKILL.md
.claude/skills/verify/SKILL.md

Metadata

Files
0
Version
d41bf19
Hash
3a50d487
Indexed
2026-10-19 04:12

홈 - 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-31 16:42
浙ICP备14020137号-1