leona-client
The one Python HTTP client for Leona Quantum: the Quantum
Atlas, verified runs, and resource estimates. Used by the leona-mcp MCP server, the
%nala Jupyter magic and the leona-notebooks CLI, so there is one place that knows
how to talk to the API instead of three.
Quickstart
Requires Python 3.12 or later. Install the supported 0.3.0 release from PyPI:
python -m pip install "leona-client==0.3.0"
export LEONA_API_TOKEN=lq_pat_... # Account → Access tokens on leonaqt.com; omit for Atlas-only use
from leona_client import Client
client = Client.from_env() # reads LEONA_API_URL / LEONA_API_TOKEN
# The Atlas needs no token.
areas = client.list_problem_areas()
hits = client.search_methods("phase estimation", max_qubits=8)
record = client.get_method(hits["results"][0]["slug"])
# Runs and estimates need a token with the `run` scope (ai-ops 362 option 1: tokens
# may read and start verified runs; hardware jobs come later, under their own scope).
run = client.start_run("Build a 3-qubit GHZ state and verify it")
run = client.wait_for_run(run.id, wait_s=300)
print(run.status, run.verifier_decision, run.verification_summary)
What it is
Client(client.py) — bearer-token control-plane calls: notebooks (create,push,pull,versions,ask, ...), runs (start_run,get_run,list_runs,cancel_run,wait_for_run) and estimates (estimate_resources), plus the Atlas convenience methods below. The token comes fromLEONA_API_TOKEN— set it in your shell, never pass it as an argument or put it in a notebook cell — and every method that needs one raises a plainLeonaClientError(never an HTTP exception, never the token itself) when it is absent.catalog.py(CatalogClient) andatlas.py— the read-only Atlas: fetching the full public catalog (paged, cached, and refusing to answer from a partial read), and the site's own finder/search/verification/OpenQASM-export rules, copied fromapps/web/lib/repository/*.tsand mirror-tested against them (tests/test_mirrors.py). No token, no write, nothing that runs or costs money.Client.search_methods/get_method/list_problem_areasandleona-mcp's three read-only tools both call into this — one fetch implementation, one set of rules.
Typed responses
Run methods return leona_client.Run, Qapp calls leona_client.QappExecution and
check_circuit a leona_client.CheckVerdict (all in leona_client/models.py). Each
names the fields this client reads — a run's id, status, verifier_decision and
verification_summary, for instance — and keeps every other field the API sends,
readable as an attribute (run.task_prompt, run.created_at) and returned by
model_dump() in the order the API sent it. A field the API adds later reaches you
without upgrading this package, and a status it adds is a string, not an error.
Fields this package does not name arrive as the JSON value the API sent: a timestamp
is an ISO 8601 string, a nested object a plain dict.
Estimates and plans return the raw JSON: their response shapes are route-local, because nothing outside the web app's own planner reads them.
This package depends on httpx and pydantic and nothing else. In particular it does
not carry Leona's check engine or the contracts it validates against: check_circuit
sends the property as you wrote it, and Leona's API judges whether it is well formed
(a 422 naming the rule when it is not) as well as what the circuit does.
A check of a circuit family at several sizes sends the circuit your own code built at each size, and Leona judges each against the reference built at that size:
verdict = client.check_circuit(
None,
{"kind": "state", "reference": "ghz(n)"},
circuits={n: qiskit.qasm3.dumps(build(n)) for n in (2, 3, 4)},
)
verdict.status # "pass" only if EVERY size passed
[(row.size, row.status) for row in verdict.per_size] # one row per size, own teeth
In a notebook: leona_client.notebook
For Jupyter, VS Code or Colab, install the notebook extra (IPython) in your kernel and load the extension. Downloads retain their code, expectations and saved outputs; checks without the runtime say NOT CHECKED. Install the quantum framework/version named by your notebook's setup separately.
%pip install -q "leona-client[notebook]==0.3.0"
%load_ext leona_client.notebook # the %nala magic
%nala link <notebook id>
from leona_client.notebook import leona_check, leona_submit
Each check cell calls leona_check({...the check...}): the circuit your code holds there
is written as OpenQASM 3 in your kernel and judged by check_circuit — at several sizes,
your builder is called once per size and every circuit goes in one request. With no
token, a token Leona refuses, no network, or any error from the API, the cell says
NOT CHECKED and why; it never reports a pass Leona did not give. leona_submit prices
a hardware cell and, with a hardware-scoped token, submits it. The full walkthrough is
the repository walkthrough
(repository access required).
Never claim a run is verified unless the record says so
run.verifier_decision is one of pass/fail/inconclusive; run.status can be
succeeded while verifier_decision is not pass — a run can finish without its
generated code being verified correct. Read verifier_decision and
verification_summary, not just status, before telling anyone a result is
verified.
Install without uv
The quickstart uses plain pip; uv and Git access are not required. All dependencies
resolve from PyPI. For notebook use, install "leona-client[notebook]==0.3.0".
leona-client and leona-mcp are the two public packages. Leona's check engine,
contracts, sandbox and planner stay on the service; they are not installed in your
environment.
Commands
uv run pytest packages/py/client -q
Metadata
Release files for leona-client 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| leona_client-0.3.0.tar.gz | 56.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| leona_client-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 116.2 kB
Release files / leona_client-0.3.0.tar.gz
| Download URL | leona_client-0.3.0.tar.gz |
|---|---|
| Size | 56.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f18a6646e6dc3f98971f00b93a2631e162172552e039cc647b5b2c6187e9d6d
|
|
BLAKE2b-256 checksum How to use checksums |
9c9dae4bffb7dc521e03acd25439a99ff0f76b5c00f9b8eae266f2d7244ef231
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency logRelease files / leona_client-0.3.0-py3-none-any.whl
| Download URL | leona_client-0.3.0-py3-none-any.whl |
|---|---|
| Size | 60.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c41704c504eeb3f2bf62aa6348a4f8de1ae902128ce1f434b29fc76795437c74
|
|
BLAKE2b-256 checksum How to use checksums |
7cf2b1ae2a676f4b72e4cbea693fe8b9d3f74942d05fa84603883104530233bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency log