Skip to main content


The strangeworks-rigetti package allows users to run construct and solve problems with the QAOA algorithm on multiple hardware providers.

📑 Package Documentation


​ This page will be describing the strangeworks rigetti sdk that allows a user to perform various Rigetti computing ( computations through the strangeworks platform. Rigetti documentation lives at


​ The user needs a strangeworks account and billing setup prior to any computations. ​


​ To get started, make sure you have Python 3.8 or above (installation) and are familiar with setting up and using virtual environments.

Install packages using pip: ​

pip install strangeworks
pip install strangeworks-rigetti

​ Import package into python: ​

import strangeworks
from strangeworks.rigetti import get_qc


Any issues authenticating, you may need to add a rigetti resource to your account through the Platform,

When running various computations one will need their api key and a resource id that you can get once you add a resource as stated above ​


​ Before running:

  1. Set up your environment and install strangeworks-rigetti and strangeworks
  2. In the portal, Activate Strangeworks Rigetti Service to create a Resource and get the resource id and replace it with resource-id below
  3. Replace your-api-key below with your key from the Portal homepage
  4. Use examples below to utilize the various functionality. See Examples section below for an example script.

Authenticate with strangeworks python sdk using users API token:


​ Get a quantum computing resource using the rigetti sdk extension by supplying a quantum computing backend name, the resource slug and a qvm setting

qc = get_qc(
"Aspen-M-3", resource_slug=resource_id, as_qvm=True
) # as_qvm=False will produce a billable transaction


​ Here is an example on how to run a simple circuit on a rigetti quantum computing resource

import os

import pyquil
from pyquil.gates import CNOT, MEASURE, H

import strangeworks
from strangeworks.rigetti import get_qc


# get rigetti resource
res = strangeworks.get_resource_for_product("rigetti")

# as_qvm=True uses the quantum virtual machine
# as_qvm=False uses an actual Rigetti machine
# as_qvm=False will produce a billable transaction
qc = get_qc(
"Aspen-M-3", resource_slug=res.slug, as_qvm=True

program = pyquil.Program()
program = program.inst(H(0))
program = program.inst(CNOT(0, 1))
ro = program.declare("ro", "BIT", 2)
program = program.inst(MEASURE(0, ro[0]))
program = program.inst(MEASURE(1, ro[1]))

res =, circuit_type="qasm")


🥳 Success! You may view your job in the portal.

😅 Something went wrong? Find us in Slack!