Skip to content

Quickstart

  1. Install the package

    Terminal window
    pip install llm-parry

    The package is called llm-parry on PyPI, and you import it as parry. It has no required dependencies and hooks whichever SDKs you already have installed.

  2. Add one line at startup

    import parry
    parry.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.

  3. Make the same call twice

    import time
    import openai
    import parry
    parry.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())
    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 3
    cache 2 hits / 1 misses (67%), 46 tokens and $0.000011 saved
    spend $0.000006 this session (18 in / 5 out tokens)
    rate limiting 0 delayed, 0 rejected
    retries 0 budget stops 0
    openai:gpt-4o-mini 1 req $0.000006

    The first call went to the provider. The next two came from parry’s cache: no network, no cost, and no rate-limit capacity used.

  4. 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.BudgetExceeded before it leaves your process.

  5. Optional: keep everything across restarts

    parry.install(storage="parry.db")
    Terminal window
    parry stats --db parry.db
You wantDo
parry off for one blockwith parry.bypass(): ...
no caching at allparry.install(cache=False)
parry in one block onlywith parry.Parry() as guard: ... instead of install()
parry on one client onlyclient = parry.wrap(openai.OpenAI())
undo everythingparry.uninstall()