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
1
Open the System Properties Control Panel
Press
Windows + R
to open the Run prompt, type in sysdm.cpl
and click OK
.2
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.3
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.setx
command:
Note: You’ll need to restart the Command Prompt for the changes to take effect, as it reads the local environment variables into memory when opened.
On Mac or Linux
In both Mac and Linux environments, environment variables are added using theexport
command in the command line, like so:
.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.
You’ll find your profile in the user directory, which can be referenced with the
~
keyword. For example, to open a zsh
profile in the editor nano, you could run nano ~/.zshrc
.$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.