Managing API keys
Learn how to create and manage your IonQ API keys for secure access through SDKs and APIs.
An API key is similar to a password—it’s a string of text used to authenticate (identify yourself) with to our systems and allow the system to authorize that you have access to the action you’re attempting to take. When using our APIs
IonQ uses API keys to manage access to our systems. Users must provide a valid key when using APIs both directly or through an SDK.
Creating API keys
API keys are created in the IonQ Quantum Cloud application under the API Keys page found in the top menu (pictured above.) On that page, you can also see a list of currently active keys, see when they were last used, and revoke (delete) any that are no longer needed.
IonQ Quantum Cloud - API Keys
Manage your keys from the IonQ Quantum Cloud application
Storing Keys
The value of the key is only visible at the time of creation, so we highly recommend storing it securely. One approach is to use a password manager (e.g. LastPass, 1Password, or similar) which can be useful if you find yourself moving from machine to machine often, as these tools can sync between devices.
You can also store your key locally as an environment variable, making it easy to access from software you’re running locally.
On Windows
Open the System Properties Control Panel
Press Windows + R
to open the Run prompt, type in sysdm.cpl
and click OK
.
Add your environment variable
Open the Advanced
tab and click on the Environment Variables
button in the System Properties window.
Click on the New...
button to open the New User Variable
box, where you can add your variable.
Give your variable a suitable and paste in the value provided by the IonQ application.
Using your environment variable
Once added, variables are accessible from the Windows Command Line by referencing %IONQ_API_KEY%
. In your Python code, you can use os.getenv('IONQ_API_KEY')
function to retrieve the stored value.
Alternately, variables can be set from the command line with the setx
command, like so:
On Mac or Linux
In both Mac and Linux environments, environment variables are added using the export
command in the command line, like so:
To add this variable to your environment permanently, add it to the “profile” configuration file of your shell. If you’re on a (modern) Mac, that file will be called .zshrc
(for zsh), while most Linux distributions use .bashrc
(for bash). Once added, all new shell sessions (i.e. terminal windows) will have access to these variables.
~
keyword. For example, to open a zsh
profile in the editor nano, you could run nano ~/.zshrc
.Once added, variables are accessible from the command line by referencing $IONQ_API_KEY
. In your Python code, you can use os.getenv('IONQ_API_KEY')
function to retrieve the stored value.
Best Practices
- Keys are a type of password. Keep them as safe and secure them as you would any other password.
- When presenting on a video call, be aware of what’s in your code. If you’re hardcoding your key in to a script, it will be visible. Use an environment variable instead.
- Keys are still active even if you’re no longer using them. If a key is no longer needed, delete it.
- Keys are free! If you need to delete one and replace it with a new one because you’re concerned that it was compromised, go for it.
Need help?
Having trouble? Seeing something you don’t expect? Have other questions? Reach out to [email protected] or submit a ticket on support.ionq.com.
Was this page helpful?