Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser
Quick Information
Runtime-focused Godot client for Quantum API v1. It supports health checks, text transform, gate execution, backend listing, transpilation, and circuit job submit/status/result for simulator and IBM workflows. Designed for shipped games with backend-proxy mode, with optional direct API-key mode for local/dev use.
Quantum API
Quantum API is a greenfield FastAPI service for quantum-inspired runtime features:
/v1/health/v1/portfolio.json/v1/echo-types/v1/gates/run/v1/circuits/run/v1/list_backends/v1/transpile/v1/qasm/import/v1/qasm/export/v1/text/transform/v1/keys/v1/ibm/profiles/v1/ibm/profiles/{profile_id}/v1/ibm/profiles/{profile_id}/verify/v1/jobs/circuits/v1/jobs/{job_id}/v1/jobs/{job_id}/result/v1/jobs/{job_id}/cancel/v1/keys/{key_id}(delete revoked key)/v1/keys/revoked(bulk delete revoked keys)/v1/keys/{key_id}/revoke/v1/keys/{key_id}/rotate/v1/optimization/qaoa/v1/optimization/vqe/v1/experiments/state_tomography/v1/experiments/randomized_benchmarking/v1/finance/portfolio_optimization/v1/ml/kernel_classifier/v1/nature/ground_state_energy/metrics(internal metrics endpoint)
This repository is intentionally not backward compatible with the previous public-facing/api/quantum/* paths.
Tech Stack
- Python 3.11+
- FastAPI + Uvicorn
- Pydantic v2
- Redis (rate limiting and quotas)
- Prometheus client metrics
- Optional qiskit/qiskit-aer runtime (with classical fallback mode)
- Optional qiskit-ibm-runtime integration for BYO IBM backend discovery and hardware jobs
- Ruff + Pytest
- Docker
- GitHub Actions CI
Quickstart (uv)
uv sync --extra dev
uv run uvicorn quantum_api.main:app --reload
Open docs at http://127.0.0.1:8000/docs.
For local development, use API key qapi_devlocal_0123456789abcdef0123456789abcdef with the default .env.example values.
Optional Phase 5 extras:
uv sync --extra phase5-optimization --extra phase5-experiments --extra phase5-finance --extra phase5-ml --extra phase5-nature --extra phase5-docs
API Contract
Authentication and Rate Limits
GET /v1/healthandGET /v1/portfolio.jsonare public.GET /v1/keys,POST /v1/keys,DELETE /v1/keys/{key_id},DELETE /v1/keys/revoked,POST /v1/keys/{key_id}/revoke,POST /v1/keys/{key_id}/rotate, and all/v1/ibm/profiles*endpoints requireAuthorization: Bearer <supabase_jwt>.- All other protected
/v1/*endpoints requireX-API-Key(DB-managed key records only; noAPI_KEYS_JSONfallback). - Successful protected responses include:
X-Request-IDRateLimit-LimitRateLimit-RemainingRateLimit-Reset
429responses includeRetry-Afterand a normalized envelope.- Error envelope shape is standardized as:
{
"error": "too_many_requests",
"message": "Rate limit or quota exceeded.",
"details": {
"policy": "key_minute",
"retry_after_seconds": 15
},
"request_id": "2e65df20-7f95-4709-bec0-69a2e4e58abf"
}
GET /v1/health
Response fields:
statusserviceversionqiskit_availableruntime_mode
GET /v1/portfolio.json
- Public metadata contract used by portfolio pages and app integrations.
- Built dynamically from the current OpenAPI surface with endpoint auth classification:
publicapi_keybearer_jwt
- When the API is mounted behind a prefix such as
/public-facing/api/quantum, each endpointpathinportfolio.jsonis emitted as a request-ready mounted path. operationPathkeeps the canonical FastAPI/OpenAPI route such as/v1/optimization/qaoa.
For a plain-English live VPS testing walkthrough, see docs/operations/phase5-beginner-testing.md.
GET /v1/echo-types
Lists canonical transformation categories and descriptions from one enum source.
Key Management Endpoints (/v1/keys*)
GET /v1/keys: list current user's keys (masked metadata only).POST /v1/keys: create a key and return the raw key exactly once.DELETE /v1/keys/{key_id}: permanently delete one revoked key from history.DELETE /v1/keys/revoked: permanently delete all revoked keys for the current user.POST /v1/keys/{key_id}/revoke: revoke an existing key.POST /v1/keys/{key_id}/rotate: atomically rotate key (old key becomes invalid, new raw key shown once).
All key-management endpoints are user-scoped to the JWT subject (sub) and require a valid Supabase bearer token.
IBM Profile Endpoints (/v1/ibm/profiles*)
GET /v1/ibm/profiles: list the current user's saved IBM credential profiles.POST /v1/ibm/profiles: save a new named IBM credential profile.PATCH /v1/ibm/profiles/{profile_id}: rename a profile, replace token/instance/channel, or switch the default profile.DELETE /v1/ibm/profiles/{profile_id}: remove one saved profile.POST /v1/ibm/profiles/{profile_id}/verify: attempt a live IBM Runtime lookup and persistverifiedorinvalid.
IBM profile rules:
- Profiles are user-scoped to the bearer JWT subject.
profile_namemust be unique per user.- Raw IBM tokens are write-only. Responses return masked token metadata only.
- Stored-profile support requires
IBM_CREDENTIAL_ENCRYPTION_KEYon the server. IBM_CHANNELdefaults toibm_quantum_platform.- Server-level
IBM_TOKENandIBM_INSTANCEremain available as a local/self-host fallback when no stored BYO profile is available.
Create request example:
{
"profile_name": "my-open-plan",
"token": "ibm_api_token_here",
"instance": "crn:v1:bluemix:public:quantum-computing:us-east:...",
"channel": "ibm_quantum_platform",
"is_default": true
}
POST /v1/gates/run
Request:
{
"gate_type": "rotation",
"rotation_angle_rad": 1.57079632679
}
Rules:
gate_typemust be one ofbit_flip,phase_flip,rotationrotation_angle_radis required only whengate_typeisrotation
Response:
{
"gate_type": "rotation",
"measurement": 1,
"superposition_strength": 1.0,
"success": false
}
POST /v1/circuits/run
Request (Bell circuit example):
{
"num_qubits": 2,
"operations": [
{ "gate": "h", "target": 0 },
{ "gate": "cx", "control": 0, "target": 1 }
],
"shots": 1024,
"include_statevector": false,
"seed": 7
}
Operation rules:
gatemust be one ofx,z,h,ry,cxtargetis required for every operationthetais required only forrycontrolis required only forcxcontrolandtargetmust be different forcx- qubit indexes must be in range
[0, num_qubits - 1]
Response:
{
"num_qubits": 2,
"shots": 1024,
"counts": {
"00": 496,
"11": 528
},
"backend_mode": "qiskit",
"statevector": null
}
Notes:
countskeys are zero-padded bitstrings from qiskit simulator output.- Use
include_statevector: trueto include serialized amplitudes (real,imag) for each basis state. - This endpoint is qiskit-dependent and returns
503if qiskit is unavailable.
GET /v1/list_backends
Query filters:
provider:aeroribmsimulator_only:true/falsemin_qubits: integer>= 1ibm_profile: optional IBM profile name whenprovider=ibm(defaults to the owner's default saved profile)
Response fields:
backends: list of backend summaries (name,provider,is_simulator,is_hardware,num_qubits,basis_gates,coupling_map_summary)totalfilters_appliedwarnings(optional, e.g. IBM provider unavailable when not explicitly requested)
Aer notes:
- The API lists modern
aer_simulator*backends. - Legacy aliases (
qasm_simulator,statevector_simulator,unitary_simulator) are intentionally not exposed.
If provider=ibm and the request owner has no usable IBM profile or fallback credentials, the API returns:
{
"error": "provider_credentials_missing",
"message": "IBM provider credentials are not configured for this user."
}
POST /v1/transpile
Request accepts exactly one input source:
circuit(JSON operation format), orqasm(source,qasm_version=auto|2|3)
Plus:
backend_name(required)provider(aer|ibm, optional)ibm_profile(optional IBM profile name whenprovider=ibm; defaults to the owner's default saved profile)optimization_level(0-3)seed_transpiler(optional)output_qasm_version(2|3, default3)
Response fields:
backend_nameproviderinput_format(circuit|qasm)num_qubits,depth,sizeoperations(normalized generic operations)qasm_versionqasm
Validation note:
- Sending both
circuitandqasmin one request returns422.
POST /v1/jobs/circuits
Submit an asynchronous hardware execution job. Phase 4 V1 supports provider: "ibm" only.
Request:
{
"provider": "ibm",
"backend_name": "ibm_kingston",
"shots": 1024,
"ibm_profile": "my-open-plan",
"circuit": {
"num_qubits": 2,
"operations": [
{ "gate": "h", "target": 0 },
{ "gate": "cx", "control": 0, "target": 1 }
]
}
}
Response fields:
job_idproviderbackend_nameibm_profilestatusremote_job_idcreated_atupdated_at
Notes:
- Jobs are scoped by the owning API key's
owner_user_id, not by bearer JWT. - Submit persists a local job row immediately, then status/result endpoints poll IBM on read and cache terminal state.
GET /v1/jobs/{job_id}
Returns the normalized job contract with local status values:
queuedrunningsucceededfailedcancellingcancelled
GET /v1/jobs/{job_id}/result
Returns the cached terminal result for successful jobs. If the job is not finished yet, the API returns:
{
"error": "result_not_ready",
"message": "Job 'job-id' has not produced a result yet.",
"details": {
"job_id": "job-id",
"status": "running"
}
}
POST /v1/jobs/{job_id}/cancel
Attempts to cancel the remote hardware job and returns the updated normalized local status contract.
POST /v1/qasm/import
Request:
{
"qasm": "OPENQASM 2.0; include \"qelib1.inc\"; qreg q[1]; h q[0];",
"qasm_version": "auto"
}
Response fields:
detected_qasm_version(2|3)num_qubits,depth,sizeoperations(normalized generic operations)
POST /v1/qasm/export
Request:
{
"circuit": {
"num_qubits": 2,
"operations": [
{ "gate": "h", "target": 0 },
{ "gate": "cx", "control": 0, "target": 1 }
]
},
"qasm_version": "3"
}
Response fields:
qasm_versionqasmnum_qubits,depth,size
Default export version:
- QASM export defaults to OpenQASM 3.
POST /v1/text/transform
Request:
{
"text": "memory signal and quantum circuit"
}
Response:
{
"original": "memory signal and quantum circuit",
"transformed": "...",
"coverage_percent": 80.0,
"quantum_words": 4,
"total_words": 5,
"category_counts": {
"scramble": 0,
"reverse": 0,
"ghost": 0,
"quantum_caps": 0,
"quantum_gates": 2,
"quantum_entanglement": 0,
"quantum_interference": 2,
"original": 1
}
}
GET /metrics (Internal)
- Exposes Prometheus metrics.
- In
stagingandproduction, requiresX-Metrics-Token.
Runtime Modes
qiskit: qiskit imports are available.classical-fallback: qiskit imports are unavailable; math-backed simulation is used.
Set REQUIRE_QISKIT=true to force 503 responses for runtime endpoints when qiskit is unavailable.
/v1/circuits/run always requires qiskit and returns 503 when qiskit is unavailable.
QASM 3 import notes:
- OpenQASM 3 import is best-effort.
- If
qiskit_qasm3_importis missing, the API returnsqasm3_dependency_missing.
Configuration
Copy .env.example to .env and adjust values as needed.
APP_ENVAPI_PREFIXMAX_TEXT_LENGTHMAX_CIRCUIT_QUBITSMAX_CIRCUIT_DEPTHMAX_CIRCUIT_SHOTSALLOW_ORIGINSDEV_CORS_ALLOW_LOCALHOSTDEV_CORS_LOCAL_ORIGINSREQUEST_TIMEOUT_SECONDSREQUIRE_QISKITIBM_TOKEN(optional local/self-host fallback)IBM_INSTANCE(optional local/self-host fallback)IBM_CHANNEL(optional, defaultibm_quantum_platform)IBM_CREDENTIAL_ENCRYPTION_KEY(required for stored BYO IBM profiles)AUTH_ENABLEDAPI_KEY_HEADERAPI_KEY_HASH_SECRETAPI_KEY_FORMAT_PREFIXAPI_KEY_PREFIX_LENGTHAPI_KEY_SECRET_LENGTHAPI_KEY_CACHE_TTL_SECONDSDEFAULT_KEY_RATE_LIMIT_PER_SECONDDEFAULT_KEY_RATE_LIMIT_PER_MINUTEDEFAULT_KEY_DAILY_QUOTAMAX_ACTIVE_API_KEYS_PER_USERMAX_TOTAL_API_KEYS_PER_USERDATABASE_URLDATABASE_AUTO_CREATESUPABASE_URLSUPABASE_JWT_AUDIENCESUPABASE_JWT_ISSUERSUPABASE_JWKS_CACHE_SECONDSDEV_BOOTSTRAP_API_KEY_ENABLEDDEV_BOOTSTRAP_API_KEYDEV_BOOTSTRAP_OWNER_IDRATE_LIMITING_ENABLEDREDIS_URLDEV_RATE_LIMIT_BYPASSIP_RATE_LIMIT_PER_SECONDIP_RATE_LIMIT_PER_MINUTEMETRICS_ENABLEDMETRICS_PATHMETRICS_TOKENMETRICS_TOKEN_HEADERREQUEST_ID_HEADER
Security defaults and guardrails:
ALLOW_ORIGINS=*is accepted only forAPP_ENV=development.- In
APP_ENV=development, localhost origins are auto-allowlisted by default whenALLOW_ORIGINSis explicit (setDEV_CORS_ALLOW_LOCALHOST=falseto disable). staging/productionrequire explicit CORS allowlists.staging/productionfail closed when Redis is unavailable for rate enforcement.staging/productionrequireMETRICS_TOKENwhen metrics are enabled.staging/productionrequireDATABASE_AUTO_CREATE=false.staging/productionrequireAPI_KEY_HASH_SECRETto be rotated from dev default.- Active API key creation is capped per owner by
MAX_ACTIVE_API_KEYS_PER_USER. - Total API key history per owner (active + revoked + rotated) is capped by
MAX_TOTAL_API_KEYS_PER_USER.
Operations and SLOs
- SLO and alert definitions:
docs/operations/slo.md - Prometheus alert rule examples:
docs/operations/alerts.prometheus.yml - Staging deployment playbook:
docs/operations/deploy-staging.md - Production deployment playbook:
docs/operations/deploy-production.md - Supabase Phase 3.5 schema script (includes
pgcrypto, RLS, and owner policies):docs/operations/phase3_5_supabase_schema.sql
Identerest Rollout (Phase 3.75)
- Point
SUPABASE_URLandDATABASE_URLat the Identerest Supabase project.- If using Supabase pooler (
*.pooler.supabase.com:6543) withasyncpg, statement cache is auto-disabled by the service bootstrap for PgBouncer compatibility.
- If using Supabase pooler (
- Apply
docs/operations/phase3_5_supabase_schema.sqlin that project. - Ensure OAuth providers and redirect URLs are configured for portfolio login.
- Keep
/v1/keys*on bearer JWT and runtime/v1/*onX-API-Key(already enforced in middleware). - Restart service and validate create/list/revoke/rotate flows.
- For BYO IBM rollout, also set
IBM_CREDENTIAL_ENCRYPTION_KEY, apply the updated Phase 3.5 schema script, and validate/v1/ibm/profiles*plus/v1/jobs*.
BYO IBM Live Verification
Use the reusable Phase 4 smoke verifier to validate the real BYO IBM flow end-to-end with a live bearer JWT and live IBM credentials.
export VERIFY_API_BASE_URL=https://davidjgrimsley.com/public-facing/api/quantum
export VERIFY_BEARER_JWT=<supabase_jwt>
export VERIFY_IBM_TOKEN=<ibm_api_token>
export VERIFY_IBM_INSTANCE=<ibm_instance_or_crn>
export VERIFY_IBM_CHANNEL=ibm_quantum_platform
uv run python scripts/verify_byo_ibm_flow.py --timeout-seconds 1800
Notes:
VERIFY_API_BASE_URLmay be the service root or the full/v1base URL. The script appends/v1when missing.IBM_CREDENTIAL_ENCRYPTION_KEYmust already be configured on the deployed server for stored-profile verification to work.- Use
--backend-name <backend>to force a specific IBM backend. - Cleanup is enabled by default. Use
--no-cleanupif you want to inspect the created verification resources afterward. - A passing run proves: IBM profile save + verify, Quantum API key creation, IBM backend listing, IBM transpile, hardware job submission, and a terminal result or structured provider error.
- Record the run date, environment, backend, terminal job status, result/error artifact, and cleanup outcome in your release notes or roadmap notes.
Docker
docker build -t quantum-api .
docker run --rm -p 8000:8000 quantum-api
Tests and Lint
uv run ruff check .
uv run pytest
Tooling note:
- This repo assumes
uvfor Python workflows. - JS SDK verification also needs Node.js, npm, and the TypeScript toolchain.
- Engine deliverables require their native toolchains for real packaging validation.
Optional performance benchmarks (non-blocking, not run in CI by default):
RUN_PERF_BENCHMARKS=true uv run pytest tests/perf -s
Repository Layout
src/quantum_api/- backend app, routers, models, servicestests/- contract, unit, determinism, and validation testssdk/js/- TypeScript SDK package-ready client worksdk/python/- Python SDK package-ready client worksdk/godot/- promoted reusable Godot addon/client for runtime/v1integrationsdk/unreal/- Unreal runtime plugin scaffold for the gameplay subsetsdk/unity/- Unity runtime helper/package scaffold for gameplay/v1integrationdocs/sdk/- SDK release governance and compatibility trackingdocs/migrations/- external client migration plans (Godot, Expo, Unreal, Unity, JS SDK, Python SDK)project/- planning, style, and implementation docs
Roadmap Status
- Phase 1 delivered: multi-qubit execution (
/v1/circuits/run) with strict limits. - Phase 2 delivered: backend discovery + transpilation + QASM interop.
- Phase 3 delivered: production auth/rate-limiting/observability hardening.
- Phase 4 delivered: BYO IBM runtime profiles and hardware-job lifecycle.
- Phase 5 delivered: expanded Qiskit domain coverage across algorithms, optimization, experiments, finance, ML, and nature.
- Current engineering focus: Phase 6 SDK productization, Godot migration, and follow-on engine integrations.
Client Packaging
sdk/js/is the package that would become the published npm package later in the roadmap.sdk/python/is the package that would become the published PyPI package later in the roadmap.sdk/godot/,sdk/unreal/, andsdk/unity/are engine-specific delivery artifacts, not npm packages.
License
Apache-2.0.
Logo
Photo by Markus Winkler: https://www.pexels.com/photo/quantum-computing-is-the-future-of-computing-18475683/
Runtime-focused Godot client for Quantum API v1. It supports health checks, text transform, gate execution, backend listing, transpilation, and circuit job submit/status/result for simulator and IBM workflows. Designed for shipped games with backend-proxy mode, with optional direct API-key mode for local/dev use.
Reviews
Quick Information
Runtime-focused Godot client for Quantum API v1. It supports health checks, text transform, gate execution, backend listing, transpilation, and circuit job submit/status/result for simulator and IBM workflows. Designed for shipped games with backend-proxy mode, with optional direct API-key mode for local/dev use.