How to authenticate using an API key

Authenticate your Boulder Opal session without a browser

You can seamlessly authenticate to the Q-CTRL platform using API key-based authentication by passing an API key from your Python client environment.

In this guide, you will learn how to retrieve an API key and use it to authenticate your session.

1. Retrieve your API key

Sign in to your Q-CTRL account. Under Sign in and security, copy the pre-generated API key. You also have the ability to generate additional keys.

2. Authenticate using your API key

In your client environment, you can call boulderopal.cloud.authenticate and pass the respective API key to authenticate with the Q-CTRL platform.

import boulderopal as bo

bo.cloud.authenticate(api_key="YOUR_QCTRL_API_KEY")

3. Set an environment variable to persist authentication (optional)

To avoid re-authenticating, you may choose to simply set the QCTRL_API_KEY environment variable to your key's value. Note that if you don't set the environment variable or call boulderopal.cloud.authenticate explicitly, you will be redirected to a browser for authentication.

export QCTRL_API_KEY="YOUR_QCTRL_API_KEY"

Was this useful?

cta background

New to Boulder Opal?

Get access to everything you need to automate and optimize quantum hardware performance at scale.