跳到正文
FunCoding

pricing

How to make new billable work (a model, vendor, modality or phone feature) report usage and get priced correctly. Read before adding anything the router bills, or when work shows up unpriced.

Star
8,225
许可证
Apache-2.0
最近提交
2026年12月1日

.claude/skills/pricing/SKILL.md

在 GitHub 上查看

Pricing and usage

Providers report quantities; the price list turns them into cost. Never compute cost in a provider.

  • Meters: internal/pricing/pricing.go. List prices: acceleration/prices/vendor.json (rates only, region required).
  • The database is the source of truth. On start a router adds items the database has never priced, at rates × 1.08. It never changes an existing price, so get the rates right before the first deploy. Later changes go through a price change per environment (management API) plus a vendor.json PR. See check_prices.
  • Unpriced work is recorded at $0. It reserves no spend and raises unpriced, and configs naming it get a 400. free: true is a price; a missing entry is not.
  • Every meter the vendor bills needs a rate. Missing cached or cache-write rates fall back to input. A missing output_tokens rate does not fall back: it is free.
  • Vendor cost: if the vendor's response says what it charged, put it in VendorCostMicros so router prices drift can check the rate.

Every change

  1. Report usage from the provider, in meters the vendor bills.
  2. Add the vendor.json entry from the vendor's pricing page, dated in the router.yaml comment. Self-hosted models get local: true instead.
  3. Run go test ./internal/routing/ -run TestEveryRoutedModelIsPriced, router prices check, and the modality's integration suite.
  4. After the deploy, in each environment: router prices show --unpriced is empty, the start log has no "billable work has no price", and one real request returns X-Stream-Cost-Micros equal to quantity × price.

By type

  • LLM: input_tokens, cached_input_tokens, cache_write_input_tokens, output_tokens. Write a long-prompt surcharge as tiers (above_input_tokens) and a service tier as when: {service_tier}. A customer-key (BYOK) twin is generated: never write one. See router-llm.
  • STS: split by modality (input_audio_tokens, output_text_tokens, …), plus generic input_tokens/output_tokens at the audio rates as a fallback for vendors that report no split. See router-sts.
  • STT: audio_ms (per minute is per: 3600000). See router-stt.
  • TTS: characters, or audio_ms if the vendor bills by duration. See router-tts.
  • Decision model: input_tokens, plus output_tokens if billed. A System One vendor reports usage for you; :free endpoints use free: true. See decision_model.
  • Search: requests, or tokens for LLM-backed search. See router-search.
  • Image, detection, OCR: images, pages, or tokens, whichever the vendor bills. See router-detection.
  • Memory, knowledge: requests; knowledge also uses bytes_written, bytes_queried, bytes_returned, results and byte_hours. Add new billed work to internal/billable so --unpriced checks it.
  • Sandbox: vcpu_seconds, memory_gb_seconds and disk_gb_seconds, with when: {class}, recorded by the usage jobs. Each new region or target needs entries.
  • Phone: per vendor, dial and call_minutes (call_seconds); SMS uses messages, message_segments and media_messages with when by country, direction or category. A cost the vendor quotes outright (a number's month) goes through Quoted, with no entry. WhatsApp and iMessage are billed by the app's own account: don't price them. A new vendor goes in billable.Items. See telnyx, phonecheck.
  • Runtime: stream text/voice/video by seconds, recorded in slices by routing.NewRecorder. These are the operator's own prices: set them by price change, not in vendor.json.

相似的 Skill

rea-tool-design

MOmorluto/rea485k近 7 天新增 9,215 个 star

research

MAmattpocock/skills336k近 7 天新增 5,004 个 star

benchmark-methodology

AFaffaan-m/ECC314k近 7 天新增 4,125 个 star

brand

NEnextlevelbuilder/ui-ux-pro-max-skill156k近 7 天新增 3,077 个 star

banner-design

NEnextlevelbuilder/ui-ux-pro-max-skill156k近 7 天新增 3,077 个 star

mode-creator

THthedotmack/claude-mem121k近 7 天新增 1,594 个 star