What is Qiskit?
Qiskit is an open-source Python SDK for working with quantum computers at a variety of levels—from the “metal” itself, to pulses, gates, circuits and higher-order application areas like quantum machine learning and quantum chemistry. It has “Providers” that enable support for different vendors and the various “backends” (read: quantum computers or simulators) that they offer. IonQ maintains an IonQ Provider for Qiskit that allows you to work with our trapped-ion systems and our high-performance cloud simulator, which we’ll install and use here.As of July 2025, qiskit-ionq supports Qiskit versions <=1.4. Support for Qiskit 2.0 will be available soon.
Before you begin
You’ll need an account on the IonQ Quantum Cloud, and you’ll need to create an API key. We also have a guide about setting up and managing your API keys if you need some help. You’ll also need Python 3.11 running locally on your machine.Run
python --version
from your command line if you aren’t sure which version
you have running.Set up Qiskit
First, we’ll install Qiskit and the IonQ Provider from PyPI using pip:Note: We encourage doing this inside an environment management system like
virtualenv or
conda so as to avoid this
fate, but do what makes the most sense for you.
Set up your environment
By default, Qiskit will look in your local environment for a variable namedIONQ_API_KEY
, so if you’ve already followed our guide on setting up and managing your API keys, Qiskit will automatically find it.
Alternatively, you can set an environment variable temporarily from your command line, by running:
IONQ_API_KEY
, or if you are working from a Python environment where accessing environment variables is not straightforward. You can import your key explicitly or load it from a file, and pass it into the IonQProvider()
object directly:
IonQProvider()
initialized with no arguments and assume that Qiskit will automatically find your API key, but you can always use this approach instead.
Start a script
For this exercise, we’ll create a Python file and run it as a script. If you’re comfortable and familiar with Python, you can approach this any number of ways—our getting-started repository includes Jupyter notebooks that can be downloaded or run in Google Colab. Open a file up in whatever IDE you prefer, and add the following:Submit a circuit to the simulator
Running a simple Bell state circuit
First, let’s try running a simple Bell state circuit on the ideal quantum simulator. Try running this script:While the ideal simulator creates a quantum state with a 50-50 probability of being measured as “00” or “11”, the
.get_counts()
method samples from this probability distribution, so we didn’t end up with exactly 5,000 counts for each state. You can use job.get_probabilities()
to see the calculated probabilities for a circuit that was run on the simulator.Submitting multiple circuits in a single job
To submit multiple circuits in a single job submission, pass all of the circuits to therun()
function in a list instead:
Submit a circuit to the noisy simulator
To run the circuit (or circuits) using the simulator with a noise model, add thenoise_model
like: noise_model="aria-1"
. The available noise models are harmony
(legacy), aria-1
, aria-2
, and forte-1
. You can read more about these noise models here.
noise_model="aria-1"
to the simulator backend when submitting a job, in the simulator_backend.run()
function call. This will run the job with the specified noise model and will override the backend-level settings.
However, the behavior of job.get_counts()
still depends on the backend-level settings for the backend that created the job: if the backend was an ideal simulator, .get_counts()
will always sample from the result’s stored probability distribution and can generate slightly different counts every time it’s called. If the backend itself has an assigned noise model, as in this example, .get_counts()
will reproducibly retrieve the same counts that were actually recorded (the noisy simulator runs one simulation and stores one count for every shot). We recommend using backend-level noise model settings where possible.
Submit a circuit to a QPU
To run the same circuit on IonQ’s quantum hardware (QPU), we need to define a different backend at the beginning of the script and submit the circuit to that backend. Available QPU backend options may includeionq_qpu.aria-1
, ionq_qpu.aria-2
, ionq_qpu.forte-1
, or ionq_qpu.forte-enterprise-1
. You can view which of these systems you can access in the /v0.3/backends resource in the API and on the “Backends” tab of the IonQ Cloud Console.
Before submitting to any QPU, we recommend testing your code on a simulator (including with noise model) and following the other steps on this list to confirm your access and the QPU availability.
Viewing job status and results
On the “My Jobs” tab in the IonQ Quantum Cloud application, you can always view the status of all of your jobs, and you can view and download their results.
The behavior of
job.get_counts()
is different depending on the type of backend (ideal simulator, or noisy simulator or QPU) used to retrieve the job. We recommend always retrieving a job with the same backend type and settings that were used to run the job. In particular, a job retrieved using an ideal simulator backend will get counts by sampling the stored distribution rather than reproducibly returning the counts that were actually recorded.Troubleshooting
If you encounter anIonQCredentialsError
, it’s likely that your IonQProvider did not find anything to use as an API key. You can run provider.credentials()
to print the API key (token) associated with an IonQProvider object; if the returned token is missing, this indicates that the provider did not successfully find your key. You will need to either set up an environment variable named IONQ_API_KEY
or pass the key directly into the provider as shown above.
If you encounter an IonQAPIError
mentioning “Insufficient scope” in the error message, it’s likely that your IonQProvider found something to use as a credential, but it’s not a valid API key. You may need to generate a new API key, or change your environment variable or code setup to ensure that the provider finds a valid key.
If you encounter an IonQAPIError
with a message starting with “Unable to run jobs on IonQ QPU”, your organization or project does not have permissions for this QPU backend. If you see a backend that is not listed as “Out of Plan” at cloud.ionq.com/backends, your organization owner has the option to enable that backend for your project in the IonQ Cloud Console. For backends that are listed as “Out of Plan”, your organization owner may request access from the IonQ team at [email protected].
If you encounter an IonQAPIError
with message “Not found” and error code 404 when retrieving a job, you may have tried to access a job that does not exist, or a job in a project that is not accessible to the API key being used. Check the input job ID, and confirm that the backend was set up using an IonQProvider whose API key is linked to the project where the job was run.
Please direct additional questions, support requests, and bug reports to [email protected] or the IonQ Community Slack!