Qiskit Plugin Getting Started¶
Install¶
This installs the Qiskit plugin along with openquantum-sdk (Core SDK) and qiskit>=2.0.0.
Create a Service¶
With Credentials¶
from openquantum_sdk.auth import ClientCredentials
from openquantum_sdk_qiskit import OpenQuantumService
service = OpenQuantumService(
creds=ClientCredentials(
client_id="s_your_client_id",
client_secret="your_client_secret",
),
)
With a Saved Account¶
If you have previously saved credentials (see Authentication):
from openquantum_sdk_qiskit import OpenQuantumService
service = OpenQuantumService.from_saved_account(name="default")
With a JWT Token¶
from openquantum_sdk_qiskit import OpenQuantumService
service = OpenQuantumService(token="your_jwt_token")
Auto-Load¶
If you have a saved account named "default", the service loads it automatically:
When that account is missing or cannot be loaded, the same constructor falls back to environment credentials: OPENQUANTUM_TOKEN, an SDK-key file at OPENQUANTUM_SDK_KEY, or OPENQUANTUM_CLIENT_ID + OPENQUANTUM_CLIENT_SECRET. An explicit token or creds argument still wins, and a saved account still wins over the environment.
Tip
Set OPENQUANTUM_NO_AUTOLOAD=1 to skip the saved account and use only the environment credentials.
Service URLs from the environment¶
OpenQuantumService() does not read the playbook URL variables. Use from_env() when you want OPENQUANTUM_SCHEDULER_URL, OPENQUANTUM_MANAGEMENT_URL, OPENQUANTUM_KEYCLOAK_BASE, and OPENQUANTUM_KEYCLOAK_REALM. That call does not autoload a saved account, and it raises AuthenticationError when no credential resolves:
Run a Simple Circuit¶
from qiskit.circuit import QuantumCircuit
# Get a backend
backend = service.return_backend("rigetti:cepheus-1-108q")
# Build a Bell state circuit
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
# Run on Open Quantum
job = backend.run(qc, shots=128)
result = job.result()
counts = result.get_counts()
print(counts)
Expected output:
Note
Counts use bitstring keys, zero-padded to the circuit's classical register width and ordered most-significant-bit first (matching Qiskit's convention).
Get Results¶
The backend.run() method returns an immediate result job. Call .result() to access the Qiskit Result object:
job = backend.run(qc, shots=128)
result = job.result()
# Get counts
counts = result.get_counts()
# Get memory (individual shot results)
memory = result.get_memory()
Clean Up¶
Close the service when done to release HTTP connections:
Or use the context manager:
with OpenQuantumService(creds=creds) as service:
backend = service.return_backend("rigetti:cepheus-1-108q")
job = backend.run(qc, shots=128)
result = job.result()
Next Steps¶
- Backends & Targets -- Backend capabilities and filtering.
- Sampler & Estimator -- Use SamplerV2 and EstimatorV2.
- Examples -- More Qiskit workflows.