Token导航 LogoToken导航TokenDH.com
开发敏感数据github未标认证来源可访问许可证需确认审计提醒

ai-billingAI 计费

Agent Skill

ai-billing 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

416

周安装

17

GitHub Stars

3

下载量

133
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:ai-billing(AI 计费)
来源仓库:https://github.com/commet-labs/commet-skills
仓库路径:skills/ai-billing
安装命令:
npx skills add https://github.com/commet-labs/commet-skills --skill ai-billing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/commet-labs/commet-skills --skill ai-billing

简介

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理。
  • 可结合来源仓库、安装命令和原始 README 继续核验具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • ai-billing 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

AI Billing

Quick Start

Wrap any Vercel AI SDK model with tracked() to automatically bill for token usage:

import { Commet } from "@commet/node";
import { tracked } from "@commet/ai-sdk";
import { anthropic } from "@ai-sdk/anthropic";
import { generateText } from "ai";

const commet = new Commet({ apiKey: process.env.COMMET_API_KEY! });

const result = await generateText({
  model: tracked(anthropic("claude-sonnet-4-20250514"), {
    commet,
    feature: "ai_generation",
    customerId: "user_123",
  }),
  prompt: "Explain quantum computing",
});
// Tokens tracked, cost calculated, balance deducted. Done.

That's it. tracked() intercepts the model response, reports inputTokens, outputTokens, cacheReadTokens, and cacheWriteTokens to Commet, which calculates cost from the AI model catalog and deducts from the customer's balance.

How It Works

Your app                    Commet                         AI Provider
   |                          |                                |
   |-- tracked(model) ------->|                                |
   |                          |                                |
   |-- generateText() --------|-------- API call ------------->|
   |                          |                                |
   |<-- tokens + response ----|<------- response --------------|
   |                          |                                |
   |                          |-- resolve model price          |
   |                          |-- apply margin                 |
   |                          |-- deduct from balance          |
   |                          |-- record ledger entry          |
   |                          |                                |
   |<-- result (unchanged) ---|                                |

Balance Model Overview

AI billing uses the balance consumption model. Customers get a dollar balance (e.g., $10.00/month) that depletes as they use AI features. When the balance reaches zero, behavior depends on configuration:

  • blockOnExhaustion = true: API returns 402, customer must top up or wait for renewal
  • blockOnExhaustion = false: Usage continues, overage charged at period end

Balance resets to includedBalance at each billing period renewal.

Cost Formula

All values use rate scale (10000 = $1.00) for sub-cent precision:

inputCost    = ceil(inputTokens    x inputPricePerMillionTokens    / 1,000,000)
outputCost   = ceil(outputTokens   x outputPricePerMillionTokens   / 1,000,000)
subtotal     = inputCost + outputCost + cacheReadCost + cacheWriteCost
marginAmount = ceil(subtotal x margin / 10000)
total        = subtotal + marginAmount

Margin is configured per feature per plan in basis points (2000 = 20% markup). All costs use Math.ceil() to prevent underbilling.

Key Gotchas

#GotchaDetail
1Feature must be pricingMode: "ai_model"Configure this in the Commet dashboard before tracking works
2Model must exist in the catalogCommet syncs models from AI Gateway automatically, but verify your model is listed
3Tracking is non-blockingIf token reporting fails, the AI response still returns. Use onTrackingError to catch failures
4Balance deduction is real-timeCost is deducted immediately, not at period end
5Rate scale, not centsToken prices and costs use rate scale (10000 = $1.00), not settlement scale (100 = $1.00)
6Margin is per feature per planDifferent plans can have different markups on the same AI feature

What Do You Need?

TaskReference
Set up tracked() middlewaretracked-middleware.md -- installation, streaming, multiple models, error handling
Understand cost calculationcost-calculation.md -- AI model catalog, pricing, margins, multi-currency
Configure balance modelbalance-model.md -- how balance works, exhaustion, top-ups, choosing the right model

Prerequisites

  1. Feature configured with pricingMode: "ai_model" in the Commet dashboard
  2. Plan using the balance consumption model
  3. Margin configured on the plan feature (0 basis points = pass-through cost)
  4. Customer with an active subscription to that plan

Common Setup

API Key

Store in environment variable:

export COMMET_API_KEY=ck_xxxxxxxxx

Install

npm install @commet/node @commet/ai-sdk

Error Handling Quick Reference

CodeConditionAction
402Insufficient balanceCustomer needs to top up or upgrade plan
403Feature not in planCheck customer's subscription includes the AI feature
404Model not in catalogVerify the model ID matches the catalog (e.g., claude-sonnet-4-20250514)
422Missing required fieldsinputTokens is required when model is provided

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.94%
按下载量换算46

Claude

28.19%
按下载量换算37

Cursor

20.25%
按下载量换算27

Gemini CLI

10.09%
按下载量换算13

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills