Halaman ini belum diterjemahkan. Anda sedang melihat versi asli dalam bahasa Inggris.
Save your login credentials
If you are working in a trusted Python environment (such as on a personal laptop or workstation), you can use the save_account() method to save your credentials locally, then use them to initialize the service.
- If you are using a public computer or other untrusted environment, follow the instructions in Initialize the service in an untrusted environment instead.
- Follow these instructions if you want to connect by using the REST API instead of using Qiskit.
- If necessary, use this information to configure your firewall to enable access to the IBM Quantum API endpoints.
Before you begin
- Ensure that you have an IBM Cloud account.
- Ensure you are working in an active Python environment with the Qiskit SDK and Qiskit Runtime installed.
- Activate the Python virtual environment and run Python in your virtual environment.
- Log in to IBM Quantum Platform with an IBMid or Google account.
Find your access credentials
- Make sure that the correct account and region are selected in the account switcher in the header.
- Find your API key. From the dashboard, create your API key, then copy it to a secure location so you can use it for authentication. Note that you can use the same API key to connect to any region.
- Optional: Find the instance you want to use from the Instances page. Hover over its CRN, click the icon to copy it, then save it in a secure location so you can use it to identify the instance.
Save your access credentials
Save your credentials by running the appropriate code once per account you want to save. After saving your credentials, load them by following the steps in Initialize the Qiskit Runtime service.
Save credentials that access a specific instance:
If you have multiple instances and want to easily tell Qiskit Runtime which instance to use, save credentials that include an instance CRN.
from qiskit_ibm_runtime import QiskitRuntimeService
QiskitRuntimeService.save_account(
token="<your-api-key>", # Use the 44-character API_KEY you created and saved from the IBM Quantum Platform Home dashboard
name="<account-name>", # Optional
instance="<IBM Cloud CRN or instance name>", # Optional
set_as_default=True, # Optional
overwrite=True, # Optional
)
Save credentials for automatic instance selection:
If you don't provide an instance CRN and pass these credentials to Qiskit Runtime, an appropriate instance will be chosen for you, based on the specified options.
from qiskit_ibm_runtime import QiskitRuntimeService
QiskitRuntimeService.save_account(
token="<your=api-key>", # Use the 44-character API_KEY you created and saved from the IBM Quantum Platform Home dashboard
name="<account-name>", # Optional
instance="<instance-to-use>", # Optional
plans_preference="<plan_types>", # Optional
region="<region>", # Optional
tags="<instance-tags>", # Optional
set_as_default=True, # Optional
overwrite=True, # Optional
)