|
1 | 1 | {% from "helpers.jinja" import safe_docstring %} |
2 | | -# Copyright 2026 IonQ, Inc. |
3 | | -# SPDX-License-Identifier: Apache-2.0 |
4 | | - |
5 | | -"""A Python client library for the [IonQ Cloud Platform API](https://docs.ionq.com/). |
6 | | - |
7 | | -Provides full access to IonQ's quantum computing services with typed models for all |
8 | | -request and response objects. Supports both synchronous and asynchronous usage. |
9 | | - |
10 | | -## Quick start |
11 | | - |
12 | | -```python |
13 | | -from ionq_core import IonQClient |
14 | | -from ionq_core.api.backends import get_backends |
15 | | - |
16 | | -# Authenticate with the IONQ_API_KEY environment variable |
17 | | -client = IonQClient() |
18 | | - |
19 | | -# List available quantum backends |
20 | | -for backend in get_backends.sync(client=client): |
21 | | - print(f"{backend.backend}: {backend.status}") |
22 | | -``` |
23 | | - |
24 | | -## Authentication |
25 | | - |
26 | | -Get an API key from the [IonQ Cloud Console](https://cloud.ionq.com), then |
27 | | -either set the ``IONQ_API_KEY`` environment variable or pass it directly: |
28 | | - |
29 | | -```python |
30 | | -client = IonQClient() # reads IONQ_API_KEY |
31 | | -client = IonQClient(api_key="your-key") # explicit key |
32 | | -``` |
33 | | - |
34 | | -## Submitting a job |
35 | | - |
36 | | -```python |
37 | | -from ionq_core.api.default import create_job |
38 | | -from ionq_core.models.circuit_job_creation_payload import CircuitJobCreationPayload |
39 | | - |
40 | | -job = create_job.sync( |
41 | | - client=client, |
42 | | - body=CircuitJobCreationPayload.from_dict({ |
43 | | - "type": "ionq.circuit.v1", |
44 | | - "backend": "simulator", |
45 | | - "shots": 1000, |
46 | | - "input": { |
47 | | - "gateset": "qis", |
48 | | - "circuit": [ |
49 | | - {"gate": "h", "targets": [0]}, |
50 | | - {"gate": "cnot", "targets": [0], "controls": [1]}, |
51 | | - ], |
52 | | - }, |
53 | | - }), |
54 | | -) |
55 | | -``` |
56 | | - |
57 | | -## Key features |
58 | | - |
59 | | -- **Sync and async** - every endpoint has ``.sync()`` and ``.asyncio()`` variants. |
60 | | -- **Automatic retries** - transient errors (429, 5xx) are retried with exponential |
61 | | - backoff. See `IonQClient` for configuration. |
62 | | -- **Typed exceptions** - HTTP errors are raised as `AuthenticationError`, |
63 | | - `RateLimitError`, `ServerError`, etc. See `_exceptions` for the full hierarchy. |
64 | | -- **Pagination helpers** - `iter_jobs` and `aiter_jobs` follow cursors automatically. |
65 | | -- **Job polling** - `wait_for_job` and `async_wait_for_job` poll until completion. |
66 | | -- **Session management** - `SessionManager` wraps the session lifecycle as a |
67 | | - context manager. |
68 | | -- **Native gate matrices** - `gpi_matrix`, `gpi2_matrix`, `ms_matrix`, and |
69 | | - `zz_matrix` return pure-Python unitary matrices for simulation and verification. |
70 | | -- **Extensibility** - `ClientExtension` lets downstream SDKs inject hooks, headers, |
71 | | - custom transports, and error mappers without modifying this library. |
72 | | -""" |
73 | | - |
| 2 | +{{ safe_docstring(package_description) }} |
74 | 3 | from ._exceptions import ( |
75 | 4 | APIConnectionError, |
76 | 5 | APIError, |
|
0 commit comments