Skip to content

Installation

The Qedma client library provides a convenient way to interact with the Quantinuum QESEM API.

Installation

$ pip install "qedma-api[quantinuum]" qnexus

Then import the client in your environment:

import qedma_api

Client Configuration

Initialize the client with your Qedma API token:

qedma_client = qedma_api.Client(api_token="<Qedma API token>")

Alternatively, store the token once per machine and load it by default:

qedma_api.save_token(api_token="<Qedma API token>")

qedma_client = qedma_api.Client()

Note

Your Qedma API token grants access to your Qedma account. Do not share it with unauthorized parties. If it is compromised, contact [email protected] immediately.

Register Your Quantinuum Refresh Token

QESEM executes jobs through your Quantinuum account. Register your Quantinuum refresh token before submitting a job:

import getpass

import qnexus


def get_quantinuum_refresh_token():
    qnexus.logout()
    response = qnexus.client.get_nexus_client().post(
        "https://nexus.quantinuum.com/auth/login",
        json={
            "email": input("Quantinuum email: "),
            "password": getpass.getpass("Quantinuum password: "),
        },
    )
    response.raise_for_status()

    refresh_token = response.cookies.get("myqos_oat")
    if refresh_token is None:
        raise RuntimeError("Quantinuum did not return a refresh token.")
    return refresh_token


qedma_client.register_qpu_token(token=get_quantinuum_refresh_token())

The refresh token is stored for your Qedma account. To replace it later, call qedma_client.unregister_qpu_token() and register a new refresh token. Do not save your Quantinuum password or refresh token in source code.

Note

Quantinuum refresh tokens expire after 30 days. Because a Quantinuum execution can take several days, register a refresh token with at least two weeks remaining before expiry. If the token does not have sufficient time remaining, QESEM returns an error prompting you to register a new refresh token.

Set the Provider

Configure the Quantinuum provider before creating QESEM jobs:

provider = qedma_api.QuantinuumProvider()
qedma_client.set_provider(provider)

Upgrading

$ pip install --upgrade "qedma-api[quantinuum]"

Next Steps

  • Use the quick start notebook to create your first Quantinuum QESEM job.
  • Review the reference page for the staged estimation and execution flow.