Quantum API Python SDK

v0.1.0
Python package. Use this synchronous client in scripts, CLIs, services, and backend automation. It handles the API's /v1 address and returns structured errors when a request fails.
Support the Quantum API work
These guides, SDKs, plugins, and demos take real testing time across engines and package ecosystems.
Buy me a token - Support this and other projects

What this SDK is

quantum-api-sdk is a synchronous Python client for scripts, command-line tools, service integrations, and backend automation. It uses httpx and works as a context manager.

Install

pip install quantum-api-sdk
Install the published package from PyPI. It requires Python 3.11 or later.

Configure

The published SDK requires a base_url when creating the client. Use the Quantum API address shown below; the SDK adds /v1 for you.
import os from quantum_api_sdk import QuantumApiClient client = QuantumApiClient( base_url="https://davidjgrimsley.com/public-facing/api/quantum", api_key=os.environ.get("QUANTUM_API_KEY"), )
Use an existing key in a trusted script or backend. The public Health Check below works without a key.

First call: Health Check

from quantum_api_sdk import QuantumApiClient, QuantumApiError with QuantumApiClient( base_url="https://davidjgrimsley.com/public-facing/api/quantum" ) as client: try: health = client.health() print(health["status"]) except QuantumApiError as error: print(error.status_code, error.code, error.request_id)

Run Gate example

import os with QuantumApiClient( base_url="https://davidjgrimsley.com/public-facing/api/quantum", api_key=os.environ["QUANTUM_API_KEY"], ) as client: gate = client.run_gate({ "gate_type": "rotation", "rotation_angle_rad": 1.57079632679, }) print(gate["measurement"])

Auth modes

auto
The default. Health and portfolio are public; protected runtime methods use your supplied API key.
api_key
Use X-API-Key for protected runtime methods.
none
Use only for public calls such as health.

IBM profiles and jobs

Use an existing ibm_profile name supplied by the owner, or the account default. Choose an available backend before submitting a job. Poll its status and fetch the result after success; submission alone does not show that hardware ran.
IBM hardware jobs have to wait in a queue before starting; get started at quantum.cloud.ibm.com.

Useful methods

-
health, portfolio, echo_types, run_gate, run_circuit, transform_text
-
list_backends, transpile, import_qasm, export_qasm, run_qasm
-
submit_circuit_job, submit_qasm_job, get_circuit_job, get_circuit_job_result, cancel_circuit_job

Troubleshooting

-
Catch QuantumApiError so failures preserve a status code, normalized code, request ID, and details.
-
Use API-key auth for protected runtime calls.
-
Keep credentials in environment variables or server-side secret storage, not in a shipped client.

Feedback, contributions, comments, and questions

Questions, corrections, and issue reports are welcome. Email MrDJ@DavidJGrimsley.com or open an issue at github.com/davidjgrimsley/quantum-api/issues.
Install the Quantum API skill
Add the agent skill when you want coding assistants to find the Quantum API guides and integration notes quickly.

Agent version (.md)

Coding agents can use the plain Markdown companion for this guide at /public-facing/api/quantum/python-sdk.md.