# Moving from tokencost to Veqen

`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

```python
# 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:

```python
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](/prices.json) if you want the rates without the SDK.
