qcoscloud is one client for everything the platform sells: prepaid credits,
quantum instances, and workloads on the simulator, real QPUs (via QCOS) and
on-demand GPU/CPU — all over a single prepaid wallet. The SDK never touches a
cloud or a provider credential; it authenticates with your sq-live- key and
the platform Execution Plane authorizes, meters and
settles every call.
Install
httpx. The qcoscloud
CLI is installed as a console script by the same package.
Authenticate
QCOSCloud(api_key=None, base_url=None, timeout=60.0). A missing
key raises QCOSCloudError immediately.
Method reference
Every failed call raises
QCOSCloudError carrying .status (HTTP code) and
.reason (machine reason such as insufficient_credits) — see
error handling.
Credits and catalog
targets() also activates the workspace’s default catalog (simulator +
GPU/CPU tiers) on first call, so it is a good first request from a fresh
workspace.
Instances
An instance = pricing plan + allowed computers + access group. Passinstance= on a run to bill through it; omit it for plain
prepaid billing.
Run a circuit
run() is the general entry point: target picks the backend, the circuit is
OpenQASM 2/3 passed as qasm= (the SDK wraps it into a QUANTUM_CIRCUIT
workload for you):
simulate() is a convenience that targets the free simulator:
A circuit is required: calling
run()/simulate() without qasm= (or a
workload carrying one) submits an empty QUANTUM_CIRCUIT and the API rejects
it with 422 quantum_circuit_missing before reserving anything. Always pass
your QASM.mode="QCOS_OPTIMIZED"applies QCOS transforms and requires an active QCOS license (qcos_license_requiredotherwise). Default is"NATIVE".- Real QPU runs require the workspace to be entitled to the device and your
instance to allow it; otherwise you get
no_active_entitlement_for_offer,instance_access_deniedor (on a free instance)free_plan_simulators_only— and nothing is charged. - Every
run()sends anIdempotency-Key(a fresh UUID by default), so a network retry can never double-submit. Passidempotency_key=to control it.
GPU and CPU jobs
Both run a container command with per-minute billing and a mandatory runtime bound — the worst case is reserved up front and the machine is stopped when the reservation is exhausted, so a job can never overspend:gpu_provider_unavailable (503) and no money is held. Rates are in
Backends & pricing.
Poll, cancel, list
CREDIT_RESERVED → SUBMITTING → SUBMITTED → RUNNING → SETTLED (or FAILED / CANCELLED). On a settled job, result_verified and
usage_metrics are populated and the Evidence Bundle is
available over REST.
Error handling
e.reason is the platform’s machine reason — branch on it, never on the
message text. The full catalog is in
Errors & refusal reasons.
MCP server (for AI agents)
The same operations are exposed as MCP tools so an AI agent (Claude Desktop, Cursor, or any MCP client) can drive compute on your wallet with the same guardrails — the agent never sees a cloud or a raw credential beyond the key you configure:get_credits, list_computers, list_targets, list_instances,
create_instance, run_simulation, run_qpu_job, run_gpu_job,
run_cpu_job, get_workload, get_evidence, cancel_workload.
The circuit tools (run_simulation, run_qpu_job) take the OpenQASM source as
their qasm argument — the same 422 quantum_circuit_missing gate applies if
an agent omits it. Errors come back as values ({"error": ..., "reason": ...})
so the agent can read the machine reason and react.