Quickstart
-
Install the package
Terminal window pip install llm-parryThe package is called
llm-parryon PyPI, and you import it asparry. It has no required dependencies and hooks whichever SDKs you already have installed. -
Add one line at startup
import parryparry.install()Put it anywhere that runs once, such as
main(), an app factory or the top of a notebook. Clients created before and after this line are covered. -
Make the same call twice
import timeimport openaiimport parryparry.install()client = openai.OpenAI()for i in range(3):t = time.perf_counter()r = client.chat.completions.create(model="gpt-4o-mini",messages=[{"role": "user", "content": "Say hi in five words."}],)print(f"{(time.perf_counter() - t) * 1000:7.1f} ms {r.choices[0].message.content}")print(parry.stats().summary())import timeimport anthropicimport parryparry.install()client = anthropic.Anthropic()for i in range(3):t = time.perf_counter()r = client.messages.create(model="claude-haiku-5-5",max_tokens=100,messages=[{"role": "user", "content": "Say hi in five words."}],)print(f"{(time.perf_counter() - t) * 1000:7.1f} ms {r.content[0].text}")print(parry.stats().summary())output 612.4 ms Hi there, how are you?0.4 ms Hi there, how are you?0.1 ms Hi there, how are you?requests 3cache 2 hits / 1 misses (67%), 46 tokens and $0.000011 savedspend $0.000006 this session (18 in / 5 out tokens)rate limiting 0 delayed, 0 rejectedretries 0 budget stops 0openai:gpt-4o-mini 1 req $0.000006The first call went to the provider. The next two came from parry’s cache: no network, no cost, and no rate-limit capacity used.
-
Optional: set a budget
parry.install(max_cost_usd=5.00)Once this session has spent $5, every call that isn’t cached raises
parry.BudgetExceededbefore it leaves your process. -
Optional: keep everything across restarts
parry.install(storage="parry.db")Terminal window parry stats --db parry.db
Turning it off
Section titled “Turning it off”| You want | Do |
|---|---|
| parry off for one block | with parry.bypass(): ... |
| no caching at all | parry.install(cache=False) |
| parry in one block only | with parry.Parry() as guard: ... instead of install() |
| parry on one client only | client = parry.wrap(openai.OpenAI()) |
| undo everything | parry.uninstall() |