Moving from tokencost to Veqen

Replace string-based token estimates with the usage providers report, priced with caching, batch and tier rules.

By Keyveve, Inc. · Updated 2026-10-22

tokencost estimates cost by counting tokens in your prompt and completion strings. That works for simple chat calls, but it can't see cached input, reasoning tokens, tool definitions, images or batch discounts, so estimates drift from the bill.

Veqen prices the usage the provider actually reports for each call.

Replace the estimate

# Before
from tokencost import calculate_completion_cost, calculate_prompt_cost

cost = calculate_prompt_cost(messages, model) + calculate_completion_cost(text, model)

# After: let the wrapper price every call
import veqen
client = veqen.wrap(OpenAI())
response = client.chat.completions.create(model=model, messages=messages)  # recorded and priced in the background

If you only need a number for a call you made yourself:

usage = response.usage
cached = usage.prompt_tokens_details.cached_tokens
veqen.cost(model, usage.prompt_tokens - cached, usage.completion_tokens, cache_read_tokens=cached)

Differences you'll notice

tokencost Veqen
Token counts Estimated from text Reported by the provider
Cached input Not priced separately Cache-read and cache-write rates
Reasoning tokens Not counted Included in output
Batch, priority, flex – Their own rates
Long-context tiers, data residency – ✓
Images, video, speech, transcription, rerank, OCR – Priced per image, second, character, query or page
Attribution to customers and features – Tags
Price updates With each release Checked daily; shipped with each SDK release and cloud deploy

Both are open source; Veqen's price book is also published as prices.json if you want the rates without the SDK.

Veqen records what every AI call cost and who it was for, reconciles it to your provider bills and produces the journal entries. Start free or read the quickstart.