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,regionrequired). - 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.jsonPR. Seecheck_prices. - Unpriced work is recorded at $0. It reserves no spend and raises
unpriced, and configs naming it get a 400.free: trueis 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_tokensrate does not fall back: it is free. - Vendor cost: if the vendor's response says what it charged, put it in
VendorCostMicrossorouter prices driftcan check the rate.
Every change
- Report usage from the provider, in meters the vendor bills.
- Add the
vendor.jsonentry from the vendor's pricing page, dated in therouter.yamlcomment. Self-hosted models getlocal: trueinstead. - Run
go test ./internal/routing/ -run TestEveryRoutedModelIsPriced,router prices check, and the modality's integration suite. - After the deploy, in each environment:
router prices show --unpricedis empty, the start log has no "billable work has no price", and one real request returnsX-Stream-Cost-Microsequal to quantity × price.
By type
- LLM:
input_tokens,cached_input_tokens,cache_write_input_tokens,output_tokens. Write a long-prompt surcharge astiers(above_input_tokens) and a service tier aswhen: {service_tier}. A customer-key (BYOK) twin is generated: never write one. Seerouter-llm. - STS: split by modality (
input_audio_tokens,output_text_tokens, …), plus genericinput_tokens/output_tokensat the audio rates as a fallback for vendors that report no split. Seerouter-sts. - STT:
audio_ms(per minute isper: 3600000). Seerouter-stt. - TTS:
characters, oraudio_msif the vendor bills by duration. Seerouter-tts. - Decision model:
input_tokens, plusoutput_tokensif billed. A System One vendor reports usage for you;:freeendpoints usefree: true. Seedecision_model. - Search:
requests, or tokens for LLM-backed search. Seerouter-search. - Image, detection, OCR:
images,pages, or tokens, whichever the vendor bills. Seerouter-detection. - Memory, knowledge:
requests; knowledge also usesbytes_written,bytes_queried,bytes_returned,resultsandbyte_hours. Add new billed work tointernal/billableso--unpricedchecks it. - Sandbox:
vcpu_seconds,memory_gb_secondsanddisk_gb_seconds, withwhen: {class}, recorded by the usage jobs. Each new region or target needs entries. - Phone: per vendor,
dialandcall_minutes(call_seconds); SMS usesmessages,message_segmentsandmedia_messageswithwhenbycountry,directionorcategory. A cost the vendor quotes outright (a number's month) goes throughQuoted, with no entry. WhatsApp and iMessage are billed by the app's own account: don't price them. A new vendor goes inbillable.Items. Seetelnyx,phonecheck. - Runtime:
streamtext/voice/videobyseconds, recorded in slices byrouting.NewRecorder. These are the operator's own prices: set them by price change, not invendor.json.


