Quantum API Unity Package

v1.1.0
Unity 2021 LTS+ runtime package. Configure its scene manager in the Inspector, then start with a health check or local random integer. Gates, text transforms, and IBM jobs are available when needed.
Support the Quantum API work
These guides, SDKs, plugins, and demos take real testing time across engines and package ecosystems.
Buy me a token - Support this and other projects

What this package is

This Unity 2021.3+ runtime package handles gameplay requests. Add one QuantumApiManager to a scene to configure the connection in the Inspector. Your scripts then use its shared client, with coroutine or Task calls and structured API errors.

Install

Download the Unity v1.1.0 package archive and extract it. The source package is also available in the repository.
-
In Unity Package Manager, choose Add package from disk and select com.quantumapi.runtime/package.json from the extracted archive. For repository source, select sdk/unity/package.json instead.
-
Add QuantumApiManager to one GameObject in your first scene. Set its connection fields before entering Play Mode.
-
For a quick check in Play Mode, use the manager's Check Health context-menu action and read Unity's Console.

Configure

In the manager Inspector, choose Direct API Key and enter an existing key for a local test. Direct mode uses the hosted Quantum API address. For a distributed game, enable Backend Proxy Mode and enter your own proxy URL. The proxy must expose the compatible API and hold the upstream key on your server.
The Inspector masks the key, but a key saved in a scene or distributed build can be extracted. Leave it empty in committed scenes.

First call: Health Check

using QuantumApi.Unity; using UnityEngine; public class QuantumApiFirstCall : MonoBehaviour { private async void Start() { var client = QuantumApiManager.Instance.Client; var health = await client.HealthAsync(); Debug.Log($"Quantum API status: {health.status}"); } }
Health Check is public. A healthy response confirms connectivity; it does not confirm that a protected call or IBM hardware is ready.

Run Gate example

Use this inside a MonoBehaviour method after the manager is active.
StartCoroutine(QuantumApiManager.Instance.Client.RunGateCoroutine( new GateRunRequest { gate_type = "rotation", sendRotationAngle = true, rotation_angle_rad = Mathf.PI / 2f, }, response => Debug.Log($"Measurement: {response.measurement}"), error => Debug.LogWarning(error.Message) ));

Generate a local random integer

Use this inside an async method in the same scene.
var random = await QuantumApiManager.Instance.Client.RandomIntAsync(0, 1); Debug.Log($"Coin flip: {random.value} ({random.source})");
Both bounds are included. The result comes from the local simulator or a classical fallback. It is neither an IBM hardware job nor a cryptographic randomness guarantee.

Auth modes

Backend proxy mode
Use for shipped builds. The client sends no API key or bearer header; your backend holds the upstream key.
Direct API key
Use for local development and demos. Protected calls send X-API-Key to the hosted API.

IBM hardware jobs

The package supports random hardware jobs. Supply an existing IBM profile name and an available backend, or set their defaults on QuantumApiManager. Submit a job, keep its job_id, poll GetJobAsync, and fetch the result when status becomes succeeded.
var client = QuantumApiManager.Instance.Client; var job = await client.SubmitRandomJobAsync(new RandomJobSubmitRequest { min = 0, max = 1, provider = "ibm", backend_name = "YOUR_AVAILABLE_IBM_BACKEND", ibm_profile = "YOUR_EXISTING_PROFILE", }); // Poll client.GetJobAsync(job.job_id) before GetJobResultAsync(job.job_id).
IBM hardware jobs have to wait in a queue before starting; get started at quantum.cloud.ibm.com.

Available calls

-
HealthAsync, GetEchoTypesAsync, RunGateAsync, TransformTextAsync
-
RandomIntAsync for simulator or fallback integers
-
SubmitRandomJobAsync, GetJobAsync, GetJobResultAsync, CancelJobAsync for IBM job flows

Troubleshooting

-
Use the manager's Check Health action in Play Mode and read Unity's Console before debugging a protected call.
-
If a protected call fails, check the selected auth mode, key or proxy URL, and whether the proxy provides upstream authentication.
-
If an IBM job queues, keep gameplay responsive while polling. Handle failed and cancelled terminal states before fetching a result.

Feedback, contributions, comments, and questions

Questions, corrections, and issue reports are welcome. Email MrDJ@DavidJGrimsley.com or open an issue at github.com/davidjgrimsley/quantum-api/issues.
Install the Quantum API skill
Add the agent skill when you want coding assistants to find the Quantum API guides and integration notes quickly.

Agent version (.md)

Coding agents can use the plain Markdown companion for this guide at /public-facing/api/quantum/unity-package.md.