Quantum API Unity Package
The Unity package is a runtime helper for gameplay code. It uses UnityWebRequest behind coroutine and Task entry points, normalizes the Quantum API address, and starts with health, gate, and text-transform calls.
Runtime / package
Unity 2021.3+ runtime package
Version
0.1.0
What this package is
This Unity runtime package is for gameplay code, not editor tooling. It uses UnityWebRequest behind coroutine and Task entry points, with structured errors for API failures.
Install
-
Copy sdk/unity into your Unity project's Packages directory, or add it by local path in Unity Package Manager.
-
Use Unity 2021.3 or later.
-
Create QuantumApiClient with your API address and keep BackendProxyMode enabled for shipped builds.
Configure
The base URL is the web address the package sends requests to. It accepts the mounted Quantum API address with or without /v1and normalizes it before sending requests.
using QuantumApi.Unity;
var client = new QuantumApiClient(new QuantumApiClientOptions
{
BaseUrl = "https://davidjgrimsley.com/public-facing/api/quantum",
BackendProxyMode = true,
TimeoutSeconds = 15,
});
First call: Health Check
private async void Start()
{
var health = await client.HealthAsync();
Debug.Log($"Quantum API status: {health.status}");
}
Run Gate example
StartCoroutine(client.RunGateCoroutine(
new GateRunRequest
{
gate_type = "rotation",
rotation_angle_rad = Mathf.PI / 2f,
},
response => Debug.Log($"Measurement: {response.measurement}"),
error => Debug.LogWarning(error.Message)
));
Auth modes
Backend proxy mode
The default for shipped builds. Runtime calls go through your backend so the upstream key stays server-side.
Direct API key
For local development, demos, and prototypes. Protected runtime calls send X-API-Key.
Bearer override
Use a bearer token only when your own backend proxy expects it, or override a request's auth intentionally.
IBM profiles
The current package wraps gameplay endpoints only. Manage IBM credential profiles through your backend, then submit IBM jobs using the selected profile name. Do not put IBM tokens in a distributed Unity build.
IBM hardware jobs have to wait in a queue before starting; get started at quantum.cloud.ibm.com.
Available calls
-
GET /v1/health
-
GET /v1/echo-types
-
POST /v1/gates/run
-
POST /v1/text/transform
Troubleshooting
-
Call HealthAsync first to check that the API address is reachable.
-
Use BackendProxyMode for distributed builds so a runtime key is not embedded in game assets.
-
Treat the package as a runtime helper and smoke-test it inside a Unity project before relying on it in a release.
Feedback, contributions, comments, and questions
Questions, corrections, and issue reports are welcome. Email DavidJGrimsley@gmail.com or open an issue at github.com/davidjgrimsley/quantum-api/issues.
Agent version (.md)
Coding agents can use the plain Markdown companion for this guide at /public-facing/api/quantum/unity-package.md. For best results, also point the agent at /llms.txt so it can discover the core API guide, OpenAPI references, and the other integration guides.