Metadata-Version: 2.4
Name: veqen
Version: 1.0.0
Summary: The cost ledger for AI inference: exact cost for every model call (text, embeddings, images, video, speech and transcription, across labs, open-model hosts and clouds), per customer, feature and project, with budgets.
License-Expression: MIT
Project-URL: Homepage, https://veqen-app.com
Project-URL: Documentation, https://veqen-app.com/docs
Project-URL: Source, https://github.com/Keyveve/veqen-sdks/tree/main/python
Project-URL: Issues, https://github.com/Keyveve/veqen-sdks/issues
Keywords: llm cost,token cost,openai pricing,anthropic pricing,ai cost tracking,llm budget,finops,cogs
Classifier: Programming Language :: Python :: 3
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Office/Business :: Financial :: Accounting
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.3; extra == "langchain"
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: langchain-core>=0.3; extra == "test"
Dynamic: license-file

# veqen

The cost ledger for AI inference. Usage-based cost for supported model calls (text, embeddings, images, video, speech and transcription, from about 2,000 models across labs, open-model hosts and clouds), attributed to the customer, feature, user or project that caused it, with budgets that check recorded spend before each wrapped request.

```bash
pip install veqen
```

Python 3.10+, no dependencies (LangChain support is the `veqen[langchain]` extra), works offline.

```python
import veqen
from openai import OpenAI

client = veqen.wrap(OpenAI(), feature="support-bot")

with veqen.tags(customer="acme", user="u_42"):
    client.responses.create(model="gpt-5-mini", input="Where is my order?")
```

Every call is priced from the usage the provider reports, with the rules providers bill by: cached input, 5-minute and 1-hour cache writes, batch, priority and flex tiers, long-context rates and data residency. Prompts and responses are never read.

- **Wrap** OpenAI (sync and async, streams, Responses, Chat Completions, embeddings, images and audio), Anthropic (messages and streams) and Google GenAI clients. An OpenAI client pointed at Together, Fireworks, Groq, Azure AI Foundry or another compatible host is priced as that host; name your own servers with `veqen.wrap(client, provider="self-hosted")`.
- **Tag** calls with `veqen.tags(customer=..., feature=..., user=..., project=...)`; tags follow `asyncio` code.
- **Budget**: `veqen.budget(5.00, customer="*")` raises `veqen.BudgetExceeded` before subsequent wrapped calls once recorded spend reaches the limit.
- **Record** anything else: `veqen.record("claude-sonnet-5-5", provider="anthropic", input_tokens=1200, output_tokens=300)`, or by unit for media models: `veqen.record("veo-3.1-generate-001", provider="google", units=8, variant="1080p")`.
- **Price** without recording: `veqen.cost("gpt-4o", 1000, 500)` returns `0.0075`.
- **Integrations**: `veqen.integrations.langchain`, `veqen.integrations.litellm`, `veqen.integrations.openai_agents`.

In serverless functions, call `veqen.flush()` before returning. Write a local ledger with `veqen.init(ledger_file=".veqen/ledger.jsonl")` and see cost per customer, feature and model with `npx @veqen/sdk report`. Set `VEQEN_API_KEY` to send calls to the [Veqen dashboard](https://veqen-app.com/signup?utm_source=python-sdk&utm_medium=package&utm_campaign=launch-v1) for shared budgets, reconciliation with your provider bills, custom and self-hosted prices, margin per customer and month-end journal entries. Free for 60,000 tracked calls a month.

Docs: https://veqen-app.com/docs/python · Model prices: https://veqen-app.com/models · MIT licensed.

Budgets are not guaranteed spending caps. In-flight and concurrent calls can exceed the limit. Local counters are per process and reset on restart; dashboard budgets also depend on ingestion and polling delays.
