Examples: cost and cache¶
Ledgers, prices, budgets, caches, embeddings. Back to the Examples gallery. Files here: 7.
| File | Shows | Install | Run | Docs |
|---|---|---|---|---|
examples/cache.py |
Cache backends, the LLM response cache, a stable prompt layout and a prompt-cache plug-in. | pip install agent-adapter |
python examples/cache.py |
Cache |
examples/cost.py |
Price LLM and paid-API calls with a ledger; override prices; summarise a run. | pip install agent-adapter |
python examples/cost.py |
Cost: prices and the ledger |
examples/cost_own_models.py |
Price your own models: pattern keys, free local models, per-call and per-second prices. | pip install agent-adapter |
python examples/cost_own_models.py |
Cost: prices and the ledger |
examples/embeddings.py |
Embeddings: wrap your own embedding function, then batch, cache and bill it. | pip install agent-adapter |
python examples/embeddings.py |
Embeddings |
examples/howto_budgets.py |
Budgets: price every call in a ledger, cap spend per run or per thread, cap call counts. | pip install agent-adapter |
python examples/howto_budgets.py |
Budgets |
examples/howto_caching.py |
Caching: tool results per run, thread or globally; LLM responses; what a hit costs. | pip install agent-adapter |
python examples/howto_caching.py |
Caching |
examples/howto_team_budgets.py |
Team budgets: cap spend per user and per team per UTC day, shared by every worker. | pip install agent-adapter |
python examples/howto_team_budgets.py |
Team budgets |