IBMProvider#
- class IBMProvider(token=None, url=None, name=None, instance=None, proxies=None, verify=None)[source]#
Provides access to the IBM Quantum services available to an account.
Authenticate against IBM Quantum for use from saved credentials or during session.
Credentials can be saved to disk by calling the save_account() method:
from qiskit_ibm_provider import IBMProvider IBMProvider.save_account(token=<INSERT_IBM_QUANTUM_TOKEN>)
You can set the default project using the hub, group, and project keywords in save_account(). Once credentials are saved you can simply instantiate the provider like below to load the saved account and default project:
from qiskit_ibm_provider import IBMProvider provider = IBMProvider()
Instead of saving credentials to disk, you can also set the environment variables QISKIT_IBM_TOKEN, QISKIT_IBM_URL and QISKIT_IBM_INSTANCE and then instantiate the provider as below:
from qiskit_ibm_provider import IBMProvider provider = IBMProvider()
You can also enable an account just for the current session by instantiating the provider with the API token:
from qiskit_ibm_provider import IBMProvider provider = IBMProvider(token=<INSERT_IBM_QUANTUM_TOKEN>)
token is the only required attribute that needs to be set using one of the above methods. If no url is set, it defaults to ‘https://auth.quantum-computing.ibm.com/api’.
Note
The hub/group/project is selected based on the below selection order, in decreasing order of priority.
The hub/group/project you explicity specify when calling a service. Ex: provider.get_backend(), etc.
The hub/group/project required for the service.
The default hub/group/project you set using save_account().
A premium hub/group/project in your account.
An open access hub/group/project.
The IBMProvider offers the
IBMBackendService
which gives access to the IBM Quantum devices and simulators.You can obtain an instance of the service as an attribute of the
IBMProvider
instance. For example:backend_service = provider.backend
Since
IBMBackendService
is the main service, some of the backend-related methods are available through this class for convenience.The
backends()
method returns all the backends available to this account:backends = provider.backends()
The
get_backend()
method returns a backend that matches the filters passed as argument. An example of retrieving a backend that matches a specified name:simulator_backend = provider.get_backend('ibmq_qasm_simulator')
IBMBackend’s are uniquely identified by their name. If you invoke
get_backend()
twice, you will get the same IBMBackend instance, and any previously updated options will be reset to the default values.It is also possible to use the
backend
attribute to reference a backend. As an example, to retrieve the same backend from the example above:simulator_backend = provider.backend.ibmq_qasm_simulator
Note
The
backend
attribute can be used to autocomplete the names of backends available to this account. To autocomplete, presstab
afterprovider.backend.
. This feature may not be available if an error occurs during backend discovery. Also note that this feature is only available in interactive sessions, such as in Jupyter Notebook and the Python interpreter.IBMProvider constructor
- Parameters:
token (
Optional
[str
]) – IBM Quantum API token.url (
Optional
[str
]) – The API URL. Defaults to https://auth.quantum-computing.ibm.com/api.name (
Optional
[str
]) – Name of the account to load.instance (
Optional
[str
]) – Provider in the hub/group/project format.proxies (
Optional
[dict
]) – Proxy configuration. Supported optional keys areurls
(a dictionary mapping protocol or protocol and host to the URL of the proxy, documented at https://docs.python-requests.org/en/latest/api/#requests.Session.proxies),username_ntlm
,password_ntlm
(username and password to enable NTLM user authentication)verify (
Optional
[bool
]) – Whether to verify the server’s TLS certificate.
- Returns:
An instance of IBMProvider
- Raises:
IBMInputValueError – If an input is invalid.
Attributes
Return the backend service.
Methods
Return the IBM Quantum account currently in use for the session.
IBMProvider.backends
([name, filters, ...])Return all backends accessible via this account, subject to optional filtering.
IBMProvider.delete_account
([name])Delete a saved account from disk.
IBMProvider.get_backend
([name, instance])Return a single backend matching the specified filtering.
Return the IBM Quantum instances list currently in use for the session.
IBMProvider.jobs
([limit, skip, ...])Return a list of jobs, subject to optional filtering.
IBMProvider.retrieve_job
(job_id)Return a single job.
IBMProvider.save_account
([token, url, ...])Save the account to disk for future use.
IBMProvider.saved_accounts
([default, name])List the accounts saved on disk.