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 yourself with our systems and allow the system to authorize that you have access to the action you’re attempting to take.
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. This page provides a comprehensive view of your API key management, allowing you to see a list of all your currently active keys, track their usage by viewing when they were last used, and maintain security by revoking (deleting) any keys that are no longer needed.
IonQ Quantum Cloud - API Keys
Manage your keys in 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 your 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 name 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')
as a function to retrieve the stored value.
Alternately, variables can be set from the command line with the setx
command:
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 permanently add this environment variable, you’ll need to modify your shell’s profile configuration file. This file stores settings that are loaded each time you open a new terminal session.
On a modern Mac, the profile configuration file is typically named .zshrc
(for the zsh shell). Most Linux distributions use .bashrc
(for the bash shell). Once you’ve added the variable to your profile configuration file, all new terminal sessions will have access to it.
~
keyword. For example, to open a zsh
profile in the editor nano, you could run nano ~/.zshrc
.After adding the environment variable, you can access it from the command line using $IONQ_API_KEY
. To retrieve the value in your Python code, use the os.getenv('IONQ_API_KEY')
function.
Best Practices
- Keys are a type of password. Keep them as safe and secure as you would any other password.
- When sharing your screen during a video call, be mindful of sensitive information like API keys in your code. Hardcoding your key directly in a script makes it visible to everyone on the call. Consider storing it as an environment variable and access it within your code as needed.
- 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?