Quantum Rings credentials¶
To run circuits with the Quantum Rings SDK you will need:
Your Quantum Rings token (API key)
Your Quantum Rings account name
You can store credentials locally so you do not need to pass them every time.
Recommended: save credentials using the Core SDK¶
Use the Core SDK provider to save your account locally. This creates or updates the local configuration used by the SDK.
import QuantumRingsLib
from QuantumRingsLib import QuantumRingsProvider
# Acquire the Quantum Rings Provider and your preferred backend
provider = QuantumRingsProvider(token=<YOUR_TOKEN_HERE>, name=<YOUR_ACCOUNT_NAME_HERE>)
backend = provider.get_backend("scarlet_quantum_rings")
print("Account Name: ", provider.active_account()["name"])
print("Max Qubits: ", provider.active_account()["max_qubits"])
# Save the account locally
provider.save_account(token=<YOUR_TOKEN_HERE>, name=<YOUR_ACCOUNT_NAME_HERE>)
print(provider.saved_accounts(False, "default"))
Manually create the local configuration file¶
You can also create the configuration file directly and store your credentials.
Linux / macOS (config file)¶
mkdir -p ~/.config/quantumrings
echo -e '[default]\nemail = <YOUR_ACCOUNT_ID>\nkey = <YOUR_ACCESS_KEY>\nbackend = scarlet_quantum_rings' > ~/.config/quantumrings/quantumrings.conf
Windows (config file)¶
Create a folder named quantumrings under %APPDATA%.
In that folder, create a file named quantumrings.conf with the following contents:
[default]
email = <YOUR_ACCOUNT_ID>
key = <YOUR_ACCESS_KEY>
backend = scarlet_quantum_rings
Using the toolkit for Qiskit¶
If you are using the Quantum Rings toolkit for Qiskit, you can save credentials using QrRuntimeService.save_account().
from quantumrings.toolkit.qiskit import QrRuntimeService
service = QrRuntimeService(token=<YOUR_TOKEN_HERE>, name=<YOUR_ACCOUNT_NAME_HERE>)
service.save_account(token=<YOUR_TOKEN_HERE>, name=<YOUR_ACCOUNT_NAME_HERE>, backend="scarlet_quantum_rings")
Alternative: use environment variables¶
As an alternative, store the account name and token as OS environment variables.
Windows (Command Prompt)¶
setx QR_TOKEN "<YOUR_TOKEN_HERE>"
setx QR_ACCOUNT "<YOUR_ACCOUNT_NAME_HERE>"
Linux / macOS (environment variables)¶
Add the following lines to your shell configuration (for example ~/.bashrc):
export QR_TOKEN="<YOUR_TOKEN_HERE>"
export QR_ACCOUNT="<YOUR_ACCOUNT_NAME_HERE>"
Then read the values from Python:
import os
my_token = os.environ["QR_TOKEN"]
my_name = os.environ["QR_ACCOUNT"]
Verify your credentials¶
A quick check is to create a provider or runtime service and confirm the account metadata can be read (for example, account name and max qubits).