How to authenticate using an API key

Authenticating your Q-CTRL account using an API key

You can seamlessly authenticate to the Q-CTRL platform using API key-based authentication by passing an API key from your Python client environment. Note that this is separate from your hardware provider's credentials, which are constructed via credentials functions and passed during function calls.

In this guide, you will learn how to:

  1. Retrieve your API key.
  2. Authenticate using your API key.
  3. Set an environment variable to persist authentication (optional).

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 the authenticate_qctrl_account method and pass the respective API key to authenticate with the Q-CTRL platform.

import fireopal as fo

api_key = "YOUR_QCTRL_API_KEY"
fo.authenticate_qctrl_account(api_key=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. This command should be run in a shell command line (either Terminal on Mac or Command Prompt/Windows Terminal for Windows).

Note that if you don't set the environment variable or call authenticate_qctrl_account 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 Fire Opal?

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