Skip to main content

QNN API — Quantum Neural Network

The QNN (Quantum Neural Network) API lets you train, deploy, and run inference on quantum-enhanced ML models. Use it to predict code quality, optimize energy grids, benchmark quantum vs classical models, and monitor quantum circuit executions.

Base URL: https://qnn.ainative.studio/api/v1

Authentication: All endpoints require an AINative API key.

Authorization: Bearer <your-ainative-api-key>

Quick Start

import requests

headers = {"Authorization": "Bearer <your-api-key>"}

# Predict code quality
resp = requests.post(
"https://qnn.ainative.studio/api/v1/predictions/predict",
headers=headers,
json={
"code": "def add(a, b):\n return a + b",
"model_id": "your-model-id",
"mode": "quantum",
"optimization_level": 1,
"domain": "code_quality"
}
)
print(resp.json())
# { "quality_score": 0.94, "recommendations": [...], "entropy": 0.12 }
const res = await fetch('https://qnn.ainative.studio/api/v1/predictions/predict', {
method: 'POST',
headers: {
'Authorization': 'Bearer <your-api-key>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
code: 'def add(a, b):\n return a + b',
model_id: 'your-model-id',
mode: 'quantum',
}),
});
const { quality_score, recommendations } = await res.json();

Health

GET /health/simple

Simple health check — no database dependencies.

Response

{ "status": "ok" }

GET /health/

Full health check including database and settings.


Models

POST /models/

Create a new quantum model.

Body

FieldTypeRequiredDescription
namestringModel name
descriptionstringModel description
n_qubitsintegerNumber of qubits
circuit_depthintegerQuantum circuit depth
quantum_devicestringTarget device (e.g. aws-braket-sv1)

ResponseModelResponse

{
"id": "mdl_abc123",
"name": "code-quality-v1",
"n_qubits": 4,
"circuit_depth": 12,
"status": "draft",
"created_at": "2026-04-25T00:00:00Z"
}

GET /models/

List all models with optional filtering and pagination.

Query params: limit, offset, status, quantum_device

GET /models/{model_id}

Get a specific model by ID.

PATCH /models/{model_id}

Update a model's metadata.

DELETE /models/{model_id}

Delete a model.

GET /models/{model_id}/info

Get detailed metadata — architecture, training history, performance metrics.


Model Versions

POST /models/{model_id}/versions

Create a new version of a model.

GET /models/{model_id}/versions

List all versions for a model.

POST /models/{model_id}/versions/{version_id}/training

Create a training run for a specific model version.


Predictions

POST /predictions/predict

Run inference on a trained QNN model.

Body

FieldTypeRequiredDescription
codestringCode to analyze
model_idstringModel ID to use for prediction
modebasic | llm | quantumPrediction mode (default: basic)
optimization_level0–3Circuit optimization level
domainstringProblem domain: code_quality, energy_grid

Response

{
"model_id": "mdl_abc123",
"quality_score": 0.94,
"recommendations": ["Add type hints", "Reduce cyclomatic complexity"],
"entropy": 0.12,
"execution_time": 0.043,
"domain": "code_quality",
"interpretation": "High quality — production ready"
}

Training

POST /training/train

Train a new QNN model on code examples.

Body

FieldTypeDescription
examplesarrayCode snippets with quality labels
model_configobjectQubit count, circuit depth, device
epochsintegerTraining epochs

Response — returns model_id and initial metrics.


Feature Extraction

POST /features/extract-from-code

Extract code quality features directly from a code string.

Body

FieldTypeDescription
codestringSource code
languagestringOverride language detection

GET /features/extract

Extract features from a specific file path.

POST /features/extract/batch

Extract features from multiple files in one call.


Quantum Signing

Cryptographically sign and verify QNN models with quantum signatures.

POST /signing/sign

Sign a model — produces a quantum signature bound to the model weights.

Body: { "model_id": "mdl_abc123" }

POST /signing/verify

Verify a model's quantum signature hasn't been tampered with.

POST /signing/apply

Apply an existing signature to a model.


Repositories

GET /repositories/

List popular GitHub repositories for analysis.

Query params

ParamDefaultDescription
min_stars100Minimum GitHub stars
limit50Results per page (max 100)
languageFilter by language
sort_bystarsstars, updated, relevance

GET /repositories/search / POST /repositories/search

Search repositories by quality criteria or query string.

POST /repositories/clone

Clone a GitHub repository for analysis.

POST /repositories/analyze

Start an async analysis job on a cloned repository.

Response: { "analysis_id": "..." }

GET /repositories/analyze/{analysis_id}

Poll the status of a repository analysis job.


Monitoring

GET /monitoring/models/{model_id}/logs

Get training logs for a specific model.

GET /monitoring/models/{model_id}/training-summary

Get aggregated training metrics summary.

Quantum Metrics

EndpointDescription
GET /monitoring/quantum/metricsSummary metrics for all quantum executions
GET /monitoring/quantum/executionsRecent executions (limit 1–100)
GET /monitoring/quantum/devicesAvailable quantum devices with usage stats

Anomaly Detection

MethodEndpointDescription
GET/monitoring/anomalies/List training anomalies (filter by severity, status)
GET/monitoring/anomalies/{id}Get anomaly details
POST/monitoring/anomalies/{id}/resolveMark anomaly resolved
GET/monitoring/anomalies/thresholdsGet detection thresholds
POST/monitoring/anomalies/thresholdsUpdate thresholds

Anomaly severities: low, medium, high


Alerts

GET /alerts/

Get alerts with optional filtering.

Query params: alert_type, severity, status

Alert types: stalled_training, accuracy_drop, abnormal_execution_time

Severities: info, warning, error, critical

Statuses: new, acknowledged, resolved, ignored

GET /alerts/{alert_id} · PATCH /alerts/{alert_id}

Get or update a specific alert.

GET /alerts/model/{model_id}

Get all alerts for a model.


Circuit Profiler

Profile quantum circuits across devices before committing to paid runs.

POST /circuit-profiler/analyze/

Profile a quantum circuit on a specific device.

Body

FieldTypeRequiredDescription
devicestringTarget quantum device
n_qubitsinteger (1–100)Number of qubits
circuit_depthinteger (1–1000)Circuit depth
shotsintegerMeasurement shots (default: 1000)
circuit_typestringqnn (default), etc.
optimization_level0–3Default: 1

Response — CircuitProfileResults

{
"device": "aws-braket-sv1",
"n_qubits": 4,
"circuit_depth": 12,
"execution_time_ms": 42.3,
"success_rate": 0.98,
"cost_usd": 0.0035,
"gate_counts": { "cnot": 8, "h": 4, "rx": 12 }
}

POST /circuit-profiler/compare/

Compare circuit performance across multiple devices simultaneously.

GET /circuit-profiler/optimize/

Get optimization suggestions to reduce gate count or execution time.

GET /circuit-profiler/devices/

List all available quantum devices for profiling.


Cost Estimation

Estimate and compare costs before running on real quantum hardware.

GET /cost-estimation/devices

List available quantum devices with pricing information.

GET /cost-estimation/estimate

Estimate cost for a circuit run.

Query params

ParamRequiredDescription
deviceAWS Braket device
shotsNumber of measurement shots
n_qubitsNumber of qubits
n_layersNumber of circuit layers

POST /cost-estimation/compare

Compare costs across multiple AWS Braket devices for the same circuit.


Cost Tracking & Budgets

GET /cost-tracking/budget-limits

Get current budget limits.

POST /cost-tracking/budget-limits

Set a budget limit for quantum spending.

Body

FieldTypeDescription
amountnumberBudget limit in USD
timeframestringdaily, weekly, monthly, quarterly, yearly
user_idstringScope to a specific user
model_idstringScope to a specific model

POST /cost-tracking/track

Track cost of a completed quantum execution.

GET /cost-tracking/current-costs

Get current costs for all configured timeframes.

GET /cost-tracking/alerts · POST /cost-tracking/resolve-alert/{alert_id}

List and resolve cost budget alerts.

POST /cost-tracking/reports

Generate a detailed cost report for a time range.


Benchmarking

Compare QNN models against classical ML baselines.

POST /benchmarking/models/compare

Run a comparison between a QNN model and classical models.

Body

FieldTypeDefaultDescription
model_idstringQNN model ID
dataset_idstringDataset to benchmark on
include_scaling_analysisbooleantrueInclude scaling metrics
classical_modelsarray[RandomForest, SVM, GradientBoosting]Models to compare against

Response — BenchmarkReport

{
"report_id": "rpt_xyz",
"qnn_model_id": "mdl_abc123",
"timestamp": "2026-04-25T00:00:00Z",
"model_comparison": { "qnn": 0.94, "RandomForest": 0.87, "SVM": 0.82 },
"scaling_analysis": { ... },
"recommendations": ["QNN shows 8% improvement on sparse feature sets"]
}

GET /benchmarking/reports

List all benchmark reports.

GET /benchmarking/reports/{report_id}

Get a full benchmark report with visualizations.

POST /benchmarking/scaling-analysis

Run a dedicated scaling analysis for QNN vs classical.


EnergyGrid Demo

Real-world quantum optimization for energy systems.

GET /energygrid/status

Check EnergyGrid integration status.

POST /energygrid/optimize/forecast

Predict energy demand using a QNN forecasting model.

POST /energygrid/optimize/storage

Optimize battery storage scheduling with quantum optimization.

POST /energygrid/optimize/grid-switch

Configure grid node switching with QNN optimization.


Data Pipelines & Datasets

POST /data/pipeline/run

Run the complete data collection pipeline.

GET /data/pipeline/{pipeline_id}

Get pipeline status.

GET /data/datasets

List available datasets.

Query params: limit (max 100), offset, format (csv, json, parquet)

GET /data/datasets/{dataset_id}

Get dataset details.

GET /data/datasets/{dataset_id}/download

Download a dataset in the requested format.


Model Lifecycle

draft → training → trained → validating → validated → signed → deployed

Use the /models/{id} PATCH endpoint to transition states, and /signing/sign to produce a cryptographic quantum signature before deployment.