qBraid-CORE

Python client for developing software with qBraid cloud services

qBraid-CORE is a Python client for qBraid cloud services. The qBraid CLI, qBraid SDK, and qBraid Lab use it to access those services.

See the qBraid-CORE reference for the latest API documentation and supported services.

Getting started

You can install qbraid-core from PyPI with:

pip install qbraid-core

qbraid-core versions <0.2.0 are not compatible with qBraid API V2. See migration guide.

Use qbraid-core ≥ 0.2.0 with API V2.

Local configuration

After installing qbraid-core, you must configure your account credentials:

  1. Create a qBraid account or log in to your existing account by visiting account.qbraid.com
  2. Open API Keys and create a key. See API key management.
  3. Save your API key from step 2 in local configuration file ~/.qbraid/qbraidrc, where ~ corresponds to your home ($HOME) directory:
[default]
api-key = YOUR_KEY
url = https://api-v2.qbraid.com/api/v1

Or generate your ~/.qbraid/qbraidrc file via the qbraid-core Python interface:

>>> from qbraid_core import QbraidSessionV1
>>> session = QbraidSessionV1(api_key='API_KEY')
>>> session.save_config()

See local CLI setup for other credential configuration methods.

Verify setup

After configuring your qBraid credentials, verify your setup by running the following from a Python interpreter:

>>> from qbraid_core.services.runtime import QuantumRuntimeClient
>>> quantum_client = QuantumRuntimeClient()
>>> device_list = quantum_client.list_devices()
>>> for device in device_list:
...     print(device.qrn)

Estimate job cost

Before submitting a job, you can ask for a quote in qBraid credits for a given device and shot count:

>>> estimate = quantum_client.estimate_cost("aws:aqt:qpu:ibex-q1", shots=1000)
>>> estimate.pricingAvailable
True
>>> estimate.estimatedCost
Credits('2380')

The quote does not cap the final charge. When you submit a job, qBraid holds its estimated cost from your credit balance. When the job finishes, qBraid charges the actual cost and refunds or debits the difference. A job that runs longer than quoted is billed for what it used. QPUs are quoted from the device’s execution history, and per-minute QPUs scale with the shot count. Simulators are quoted from a fixed conservative duration, so their quote does not change with shots. Omitting shots quotes 1000.

Some devices, such as those with dynamic pricing, return a status instead of an upfront quote:

>>> estimate = quantum_client.estimate_cost("ibm:ibm:qpu:fez")
>>> estimate.pricingAvailable
False
>>> estimate.reason
'dynamic_pricing_unavailable'

A missing or retired device, or a shot count outside 1 to 100000, raises QuantumRuntimeServiceRequestError.

Community