Quickstart Guide
Get Spectral running locally and run your first autonomous AI optimization scan in under 10 minutes.
Prerequisites
- Python 3.10 or higher
- PostgreSQL 17
- Anthropic API key (for Claude-powered evaluation)
Installation
-
Clone the repository
bashgit clone https://github.com/your-org/spectral.git cd spectral -
Install Python dependencies
bashpip install fastapi uvicorn psycopg2-binary anthropic -
Start PostgreSQL 17
bashsudo pg_ctlcluster 17 main start -
Create the Spectral database
bashcreatedb spectral -
Set your Anthropic API key
bashexport ANTHROPIC_API_KEY=sk-ant-... -
Start the FastAPI server (runs on port 8000)
bashcd spectral && python api_server.py -
Open the dashboard in your browser
urlhttp://localhost:8000/index.html
Your First Workflow
Follow these API calls in order to set up your first AI optimization workflow:
-
Create a workflow
POST /api/workflowscurl -X POST http://localhost:8000/api/workflows \ -H "Content-Type: application/json" \ -d '{"name": "Prior Authorization", "agent_name": "pa_agent", "description": "Automate prior auth decisions"}' -
Upload traces — use JSON ingestion or CSV upload
POST /api/ingest-tracescurl -X POST http://localhost:8000/api/ingest-traces \ -H "Content-Type: application/json" \ -d '{"workflow_id": 1, "traces": [ {"input": "Patient needs MRI...", "output": "Approved", "latency_ms": 340} ]}' -
Create evaluation rubrics for your agents
POST /api/rubricscurl -X POST http://localhost:8000/api/rubrics \ -H "Content-Type: application/json" \ -d '{"agent_name": "pa_agent", "name": "PA Rubric v1", "dimensions": [{"name": "accuracy", "weight": 0.5}, {"name": "completeness", "weight": 0.3}, {"name": "safety", "weight": 0.2}]}' -
Run your first Spectral Scan — the autonomous optimization loop
POST /api/spectral-scancurl -X POST http://localhost:8000/api/spectral-scan \ -H "Content-Type: application/json" \ -d '{"workflow_id": 1, "sample_size": 50}' -
Poll for results using the returned scan_id
GET /api/scans/{scan_id}curl http://localhost:8000/api/scans/1The scan returns a
verdictfield:GO(safe to promote) orNO-GO(regression detected).
How a Scan Works
Every Spectral Scan runs a closed-loop, autonomous evaluation and optimization cycle:
POST /api/spectral-scan, Spectral will observe, evaluate, diagnose, generate candidate patches, run tournaments, and issue a GO/NO-GO verdict — no manual steps required.
Key Concepts
A named AI agent pipeline (e.g., "Prior Authorization"). The top-level container for cases, configs, and scans.
A single test input with optional expected output. Cases belong to eval pools: working, holdout, adversarial, or business_critical.
A recorded agent execution: input, output, latency, and token usage. The raw signal that gets evaluated.
A versioned set of agent hyperparameters (system prompt, model, temperature). Configs are mutated and tested.
An evaluation specification with weighted dimensions (accuracy, safety, completeness). Used by LLM-as-judge.
One complete run of the Observe→Gate loop. Produces a champion config and a GO/NO-GO verdict.
A reserved set of cases never seen during optimization. Used for unbiased final validation in the Gate step.
The binary promotion decision. GO means the challenger outperforms champion on the holdout set without regression.
API Reference
All 109 endpoints exposed by the Spectral FastAPI server. The server runs at http://localhost:8000 by default.
endpoints
Workflows
5 endpoints/api/workflows
List all workflows with case/config/scan counts.
list_workflowsList all workflows with case/config/scan counts.
curl http://localhost:8000/api/workflows
/api/workflows
Create a new workflow.
create_workflowCreate a new workflow.
curl -X POST http://localhost:8000/api/workflows \
-H "Content-Type: application/json" \
-d '{...}'
/api/workflows/{workflow_id}/economics
Get the business economics parameters for a workflow.
get_workflow_economicsGet the business economics parameters for a workflow. Returns the workflow-specific cost model used in report generation. Falls back to system defaults if not configured.
curl http://localhost:8000/api/workflows/{workflow_id}/economics
/api/workflows/{workflow_id}/economics
Set or update the business economics parameters for a workflow.
update_workflow_economicsSet or update the business economics parameters for a workflow. Partial updates are supported — omit any field to keep its current value. All values fall back to system defaults if not previo
curl -X PUT http://localhost:8000/api/workflows/{workflow_id}/economics \
-H "Content-Type: application/json" \
-d '{...}'
/api/workflows/{workflow_id}/sample-recommendation
Recommend sample size for a workflow based on historical failure rates.
workflow_sample_recommendationRecommend sample size for a workflow based on historical failure rates.
curl http://localhost:8000/api/workflows/{workflow_id}/sample-recommendation
Ingestion
6 endpoints/api/cases/bulk-pool
Set eval_pool for multiple cases at once.
bulk_pool_assignmentSet eval_pool for multiple cases at once.
curl -X POST http://localhost:8000/api/cases/bulk-pool \
-H "Content-Type: application/json" \
-d '{...}'
/api/ingest-cases
Import test cases from a CSV file.
ingest_casesImport test cases from a CSV file. Supports flexible column mapping: Required: input_text (or input or patient_summary) Optional: external_case_id, workflow_id, expected_output,
curl -X POST http://localhost:8000/api/ingest-cases \
-H "Content-Type: application/json" \
-d '{...}'
/api/ingest-csv
Ingest traces from a CSV file upload (multipart) or raw CSV body.
ingest_csvIngest traces from a CSV file upload (multipart) or raw CSV body.
curl -X POST http://localhost:8000/api/ingest-csv \
-H "Content-Type: application/json" \
-d '{...}'
/api/ingest-jsonl
Ingest traces from a JSONL body.
ingest_jsonlIngest traces from a JSONL body.
curl -X POST http://localhost:8000/api/ingest-jsonl \
-H "Content-Type: application/json" \
-d '{...}'
/api/ingest-traces
Ingest traces from an external pipeline into Spectral.
ingest_tracesIngest traces from an external pipeline into Spectral.
curl -X POST http://localhost:8000/api/ingest-traces \
-H "Content-Type: application/json" \
-d '{...}'
/api/webhooks/traces
Webhook endpoint for external systems to push trace data.
webhook_tracesWebhook endpoint for external systems to push trace data.
curl -X POST http://localhost:8000/api/webhooks/traces \
-H "Content-Type: application/json" \
-d '{...}'
Cases & Configs
8 endpoints/api/cases
List all test cases. Optional ?workflow_id=X filter.
list_casesList all test cases. Optional ?workflow_id=X filter.
curl http://localhost:8000/api/cases
/api/cases/pool-stats
Return case counts per eval_pool.
get_pool_statsReturn case counts per eval_pool. Optional ?workflow_id=X filter.
curl http://localhost:8000/api/cases/pool-stats
/api/cases/{case_id}/pool
Set the eval_pool for a case.
set_case_poolSet the eval_pool for a case. Valid values: working, holdout, adversarial, business_critical.
curl -X POST http://localhost:8000/api/cases/{case_id}/pool \
-H "Content-Type: application/json" \
-d '{...}'
/api/configs
List all configurations. Optional ?workflow_id=X filter.
list_configsList all configurations. Optional ?workflow_id=X filter.
curl http://localhost:8000/api/configs
/api/configs
Create a new configuration.
create_configCreate a new configuration.
curl -X POST http://localhost:8000/api/configs \
-H "Content-Type: application/json" \
-d '{...}'
/api/configs/{config_id}
Get a single configuration with full details.
get_configGet a single configuration with full details.
curl http://localhost:8000/api/configs/{config_id}
/api/traces
List traces with optional filters.
list_tracesList traces with optional filters.
curl http://localhost:8000/api/traces
/api/traces/{trace_id}
Single trace with its eval_results.
get_traceSingle trace with its eval_results.
curl http://localhost:8000/api/traces/{trace_id}
Rubrics
9 endpoints/api/rubric-library
Return the built-in rubric template library.
get_rubric_libraryReturn the built-in rubric template library.
curl http://localhost:8000/api/rubric-library
/api/rubrics
List all rubrics, optionally filtered by agent.
list_rubricsList all rubrics, optionally filtered by agent.
curl http://localhost:8000/api/rubrics
/api/rubrics
Create a new rubric with dimensions.
create_rubricCreate a new rubric with dimensions.
curl -X POST http://localhost:8000/api/rubrics \
-H "Content-Type: application/json" \
-d '{...}'
/api/rubrics/active
Get all active rubrics (one per agent).
get_active_rubricsGet all active rubrics (one per agent).
curl http://localhost:8000/api/rubrics/active
/api/rubrics/agent/{agent_name}
Get the active rubric for a specific agent.
get_agent_rubricGet the active rubric for a specific agent.
curl http://localhost:8000/api/rubrics/agent/{agent_name}
/api/rubrics/{rubric_id}
Delete a rubric.
delete_rubricDelete a rubric.
curl -X DELETE http://localhost:8000/api/rubrics/{rubric_id}
/api/rubrics/{rubric_id}
Get a single rubric with dimensions.
get_rubricGet a single rubric with dimensions.
curl http://localhost:8000/api/rubrics/{rubric_id}
/api/rubrics/{rubric_id}
Update a rubric and optionally its dimensions.
update_rubricUpdate a rubric and optionally its dimensions.
curl -X PUT http://localhost:8000/api/rubrics/{rubric_id} \
-H "Content-Type: application/json" \
-d '{...}'
/api/rubrics/{rubric_id}/activate
Set a rubric as the active rubric for its agent.
activate_rubricSet a rubric as the active rubric for its agent.
curl -X POST http://localhost:8000/api/rubrics/{rubric_id}/activate \
-H "Content-Type: application/json" \
-d '{...}'
Evaluation
5 endpoints/api/eval-agent-report
Return eval agent health metrics derived from eval_traces.
eval_agent_reportReturn eval agent health metrics derived from eval_traces.
curl http://localhost:8000/api/eval-agent-report
/api/eval-consistency-check
Cross-evaluator consensus check — re-score a sample of traces with strict/lenient variants.
eval_consistency_checkCross-evaluator consensus check — re-score a sample of traces with strict/lenient variants.
curl -X POST http://localhost:8000/api/eval-consistency-check \
-H "Content-Type: application/json" \
-d '{...}'
/api/eval-results
List eval results with optional config filter.
list_eval_resultsList eval results with optional config filter.
curl http://localhost:8000/api/eval-results
/api/evaluate
Run LLM-as-judge evaluation on traces using per-agent rubrics.
evaluate_tracesRun LLM-as-judge evaluation on traces using per-agent rubrics.
curl -X POST http://localhost:8000/api/evaluate \
-H "Content-Type: application/json" \
-d '{...}'
/api/run
Execute the 3-agent pipeline on cases using LLM with full hyperparameter support.
run_pipelineExecute the 3-agent pipeline on cases using LLM with full hyperparameter support.
curl -X POST http://localhost:8000/api/run \
-H "Content-Type: application/json" \
-d '{...}'
Scans
4 endpoints/api/eval-scan
Start an evaluate-only scan for externally ingested traces. No agent re-execution.
start_eval_scanStart an evaluate-only scan for externally ingested traces. No agent re-execution.
curl -X POST http://localhost:8000/api/eval-scan \
-H "Content-Type: application/json" \
-d '{...}'
/api/scans
List all scans. Optional ?workflow_id=X filter.
list_scansList all scans. Optional ?workflow_id=X filter.
curl http://localhost:8000/api/scans
/api/scans/{scan_id}
Get scan detail with full results.
get_scanGet scan detail with full results.
curl http://localhost:8000/api/scans/{scan_id}
/api/spectral-scan
Start a Spectral Scan — full autonomous Observe->Evaluate->Diagnose->Optimize loop.
start_spectral_scanStart a Spectral Scan — full autonomous Observe->Evaluate->Diagnose->Optimize loop.
curl -X POST http://localhost:8000/api/spectral-scan \
-H "Content-Type: application/json" \
-d '{...}'
Reports
2 endpoints/api/scan-report/{scan_id}
Enhanced scan report with dynamically generated finding narrative.
get_scan_reportEnhanced scan report with dynamically generated finding narrative.
curl http://localhost:8000/api/scan-report/{scan_id}
/api/scan-report/{scan_id}/pdf
Generate and return a PDF scan report with Spectral branding.
get_scan_report_pdfGenerate and return a PDF scan report with Spectral branding.
curl http://localhost:8000/api/scan-report/{scan_id}/pdf
Failure Analysis
3 endpoints/api/analyze
Run LLM failure analysis on eval results for a config.
analyze_failuresRun LLM failure analysis on eval results for a config.
curl -X POST http://localhost:8000/api/analyze \
-H "Content-Type: application/json" \
-d '{...}'
/api/compositional/{config_id}
Gap 5: Returns multiplicative system reliability breakdown.
get_compositional_reliabilityGap 5: Returns multiplicative system reliability breakdown.
curl http://localhost:8000/api/compositional/{config_id}
/api/failures/{config_id}
Get failure clusters for a config.
get_failuresGet failure clusters for a config.
curl http://localhost:8000/api/failures/{config_id}
Experiments
3 endpoints/api/experiments
List experiments.
list_experimentsList experiments.
curl http://localhost:8000/api/experiments
/api/experiments
Create an experiment and record initial results.
create_experimentCreate an experiment and record initial results.
curl -X POST http://localhost:8000/api/experiments \
-H "Content-Type: application/json" \
-d '{...}'
/api/experiments/{experiment_id}
Experiment detail with leaderboard.
get_experimentExperiment detail with leaderboard.
curl http://localhost:8000/api/experiments/{experiment_id}
Promotion
8 endpoints/api/promote-auto
Auto-promote the patch config from a GO scan to champion.
promote_autoAuto-promote the patch config from a GO scan to champion.
curl -X POST http://localhost:8000/api/promote-auto \
-H "Content-Type: application/json" \
-d '{...}'
/api/promote/{config_id}
Promote a config to champion.
promote_configPromote a config to champion.
curl -X POST http://localhost:8000/api/promote/{config_id} \
-H "Content-Type: application/json" \
-d '{...}'
/api/promotion
Champion vs challenger comparison data.
get_promotionChampion vs challenger comparison data.
curl http://localhost:8000/api/promotion
/api/v2/promotion-stages
Create a promotion stage pipeline for a candidate config.
create_v2_promotion_stagesCreate a promotion stage pipeline for a candidate config.
curl -X POST http://localhost:8000/api/v2/promotion-stages \
-H "Content-Type: application/json" \
-d '{...}'
/api/v2/promotion-stages/{candidate_id}
Get promotion stage status for a candidate config.
get_v2_promotion_stagesGet promotion stage status for a candidate config.
curl http://localhost:8000/api/v2/promotion-stages/{candidate_id}
/api/v2/promotion-stages/{candidate_id}/advance
Advance to the next promotion stage.
advance_v2_promotion_stageAdvance to the next promotion stage.
curl -X POST http://localhost:8000/api/v2/promotion-stages/{candidate_id}/advance \
-H "Content-Type: application/json" \
-d '{...}'
/api/v2/promotion-stages/{candidate_id}/approve
Approve the current promotion stage (requires human sign-off).
approve_v2_promotion_stageApprove the current promotion stage (requires human sign-off).
curl -X POST http://localhost:8000/api/v2/promotion-stages/{candidate_id}/approve \
-H "Content-Type: application/json" \
-d '{...}'
/api/v2/promotion-stages/{candidate_id}/rollback
Rollback all promotion stages for a candidate.
rollback_v2_promotion_stageRollback all promotion stages for a candidate.
curl -X POST http://localhost:8000/api/v2/promotion-stages/{candidate_id}/rollback \
-H "Content-Type: application/json" \
-d '{...}'
Dashboard
3 endpoints/api/control-plane
Cross-workflow summary for the Control Plane screen.
get_control_planeCross-workflow summary for the Control Plane screen.
curl http://localhost:8000/api/control-plane
/api/dashboard
Returns KPIs computed from the database.
get_dashboardReturns KPIs computed from the database.
curl http://localhost:8000/api/dashboard
/api/workflow-overview
Workflow-level KPIs, activity feed, and accuracy trend for Prior Authorization.
get_workflow_overviewWorkflow-level KPIs, activity feed, and accuracy trend for Prior Authorization.
curl http://localhost:8000/api/workflow-overview
Meta-Improvement
22 endpoints/api/meta/convergence
Champion score trajectory over scans (convergence analysis).
get_convergence_dataChampion score trajectory over scans (convergence analysis).
curl http://localhost:8000/api/meta/convergence
/api/meta/dashboard
Full meta-improvement system dashboard.
meta_dashboardFull meta-improvement system dashboard.
curl http://localhost:8000/api/meta/dashboard
/api/meta/experiments
List meta-improvement experiments.
list_meta_experimentsList meta-improvement experiments.
curl http://localhost:8000/api/meta/experiments
/api/meta/improvement-log
Return recent events from the meta_improvement_log table.
get_improvement_logReturn recent events from the meta_improvement_log table.
curl http://localhost:8000/api/meta/improvement-log
/api/meta/rubric-audit
Layer 1: Audit rubrics against outcome data and propose mutations.
meta_rubric_auditLayer 1: Audit rubrics against outcome data and propose mutations.
curl -X POST http://localhost:8000/api/meta/rubric-audit \
-H "Content-Type: application/json" \
-d '{...}'
/api/meta/rubric-mutations
List all rubric mutations with optional filters.
list_rubric_mutationsList all rubric mutations with optional filters.
curl http://localhost:8000/api/meta/rubric-mutations
/api/meta/rubric-mutations/{mutation_id}/apply
Apply a specific proposed rubric mutation.
apply_rubric_mutationApply a specific proposed rubric mutation.
curl -X POST http://localhost:8000/api/meta/rubric-mutations/{mutation_id}/apply \
-H "Content-Type: application/json" \
-d '{...}'
/api/meta/rubric-mutations/{mutation_id}/reject
Reject a proposed rubric mutation.
reject_rubric_mutationReject a proposed rubric mutation.
curl -X POST http://localhost:8000/api/meta/rubric-mutations/{mutation_id}/reject \
-H "Content-Type: application/json" \
-d '{...}'
/api/meta/strategies
List optimization strategies with ELO ratings.
list_strategiesList optimization strategies with ELO ratings.
curl http://localhost:8000/api/meta/strategies
/api/meta/strategies/{strategy_name}/record
Record a win/loss for a strategy to update ELO ratings.
record_strategyRecord a win/loss for a strategy to update ELO ratings.
curl -X POST http://localhost:8000/api/meta/strategies/{strategy_name}/record \
-H "Content-Type: application/json" \
-d '{...}'
/api/meta/tune
Layer 3: Recommend optimal meta-hyperparameters (sample_size, num_candidates, promotion_threshold).
meta_tuneLayer 3: Recommend optimal meta-hyperparameters (sample_size, num_candidates, promotion_threshold).
curl -X POST http://localhost:8000/api/meta/tune \
-H "Content-Type: application/json" \
-d '{...}'
/api/v2/intervention-memory
List past intervention records.
list_intervention_memoryList past intervention records.
curl http://localhost:8000/api/v2/intervention-memory
/api/v2/intervention-memory/effectiveness
Summarize intervention effectiveness.
get_intervention_effectivenessSummarize intervention effectiveness.
curl http://localhost:8000/api/v2/intervention-memory/effectiveness
/api/v2/intervention-memory/similar
Retrieve historically similar interventions for a cluster.
get_similar_interventionsRetrieve historically similar interventions for a cluster.
curl http://localhost:8000/api/v2/intervention-memory/similar
/api/v2/mutations
List mutation types from the type registry.
list_v2_mutationsList mutation types from the type registry.
curl http://localhost:8000/api/v2/mutations
/api/v2/mutations/recommend
Recommend mutation types based on recent failure attributions.
recommend_mutationsRecommend mutation types based on recent failure attributions.
curl http://localhost:8000/api/v2/mutations/recommend
/api/v2/mutations/{mutation_id}
Get a specific mutation type by ID.
get_v2_mutationGet a specific mutation type by ID.
curl http://localhost:8000/api/v2/mutations/{mutation_id}
/api/v2/objective-functions
List all objective functions. Optional ?workflow_id=X filter.
list_objective_functionsList all objective functions. Optional ?workflow_id=X filter.
curl http://localhost:8000/api/v2/objective-functions
/api/v2/objective-functions
Create a new objective function for a workflow.
create_objective_functionCreate a new objective function for a workflow.
curl -X POST http://localhost:8000/api/v2/objective-functions \
-H "Content-Type: application/json" \
-d '{...}'
/api/v2/objective-functions/{obj_id}
Delete an objective function.
delete_objective_functionDelete an objective function.
curl -X DELETE http://localhost:8000/api/v2/objective-functions/{obj_id}
/api/v2/objective-functions/{obj_id}
Get a single objective function by ID.
get_objective_functionGet a single objective function by ID.
curl http://localhost:8000/api/v2/objective-functions/{obj_id}
/api/v2/objective-functions/{obj_id}
Update an existing objective function.
update_objective_functionUpdate an existing objective function.
curl -X PUT http://localhost:8000/api/v2/objective-functions/{obj_id} \
-H "Content-Type: application/json" \
-d '{...}'
Outcomes
6 endpoints/api/outcomes
List outcome signals with optional type filter.
list_outcome_signalsList outcome signals with optional type filter.
curl http://localhost:8000/api/outcomes
/api/outcomes
Ingest a single real-world outcome signal and correlate to traces.
ingest_outcome_signalIngest a single real-world outcome signal and correlate to traces.
curl -X POST http://localhost:8000/api/outcomes \
-H "Content-Type: application/json" \
-d '{...}'
/api/outcomes/batch
Batch ingest outcome signals.
ingest_outcome_batchBatch ingest outcome signals.
curl -X POST http://localhost:8000/api/outcomes/batch \
-H "Content-Type: application/json" \
-d '{...}'
/api/outcomes/correlation
Compute correlation between rubric eval scores and real-world outcomes.
outcome_rubric_correlationCompute correlation between rubric eval scores and real-world outcomes.
curl http://localhost:8000/api/outcomes/correlation
/api/v2/outcome-correlations
Compute enhanced outcome correlations for v2.
v2_outcome_correlationsCompute enhanced outcome correlations for v2.
curl http://localhost:8000/api/v2/outcome-correlations
/api/v2/outcomes/enhanced
Ingest enhanced outcome signal with business metrics.
ingest_enhanced_outcomeIngest enhanced outcome signal with business metrics.
curl -X POST http://localhost:8000/api/v2/outcomes/enhanced \
-H "Content-Type: application/json" \
-d '{...}'
Safety
4 endpoints/api/intervention-log
Gap 3: Returns the cross-workflow intervention history.
get_intervention_logGap 3: Returns the cross-workflow intervention history.
curl http://localhost:8000/api/intervention-log
/api/safety-report/{scan_id}
Gap 8: Returns safety check summary for all traces in a scan.
get_safety_reportGap 8: Returns safety check summary for all traces in a scan.
curl http://localhost:8000/api/safety-report/{scan_id}
/api/v2/anti-deception/check
Run anti-deception suite for a candidate config and scan.
anti_deception_checkRun anti-deception suite for a candidate config and scan.
curl -X POST http://localhost:8000/api/v2/anti-deception/check \
-H "Content-Type: application/json" \
-d '{...}'
/api/v2/anti-deception/drift
Detect score drift in recent scans.
anti_deception_driftDetect score drift in recent scans.
curl http://localhost:8000/api/v2/anti-deception/drift
Scheduling
5 endpoints/api/scan-schedules
List all scan schedules.
list_scan_schedulesList all scan schedules.
curl http://localhost:8000/api/scan-schedules
/api/scan-schedules
Create a scheduled scan.
create_scan_scheduleCreate a scheduled scan.
curl -X POST http://localhost:8000/api/scan-schedules \
-H "Content-Type: application/json" \
-d '{...}'
/api/scan-schedules/{schedule_id}
Delete a scan schedule.
delete_scan_scheduleDelete a scan schedule.
curl -X DELETE http://localhost:8000/api/scan-schedules/{schedule_id}
/api/scan-schedules/{schedule_id}/toggle
Enable/disable a scan schedule.
toggle_scan_scheduleEnable/disable a scan schedule.
curl -X POST http://localhost:8000/api/scan-schedules/{schedule_id}/toggle \
-H "Content-Type: application/json" \
-d '{...}'
/api/scan-trigger-on-ingest
Auto-trigger a scan if >= 50 new traces since last scan.
scan_trigger_on_ingestAuto-trigger a scan if >= 50 new traces since last scan.
curl -X POST http://localhost:8000/api/scan-trigger-on-ingest \
-H "Content-Type: application/json" \
-d '{...}'
Settings & Notifications
6 endpoints/api/digest/weekly
Weekly summary of scan activity, verdicts, and top failure clusters.
weekly_digestWeekly summary of scan activity, verdicts, and top failure clusters.
curl http://localhost:8000/api/digest/weekly
/api/notifications
List recent scan notifications.
list_notificationsList recent scan notifications.
curl http://localhost:8000/api/notifications
/api/settings
Get all settings key-value pairs.
get_settingsGet all settings key-value pairs.
curl http://localhost:8000/api/settings
/api/settings
Upsert one or more settings. Body: {key: value, ...}.
upsert_settingsUpsert one or more settings. Body: {key: value, ...}.
curl -X POST http://localhost:8000/api/settings \
-H "Content-Type: application/json" \
-d '{...}'
/api/settings/webhook
Get current webhook URL.
get_webhook_urlGet current webhook URL.
curl http://localhost:8000/api/settings/webhook
/api/settings/webhook
Configure webhook URL for scan notifications.
set_webhook_urlConfigure webhook URL for scan notifications.
curl -X POST http://localhost:8000/api/settings/webhook \
-H "Content-Type: application/json" \
-d '{...}'
Validation
3 endpoints/api/validate/run
Kick off a new validation analysis (analyzes recent scans for proof pack patterns).
run_validationKick off a new validation analysis (analyzes recent scans for proof pack patterns).
curl -X POST http://localhost:8000/api/validate/run \
-H "Content-Type: application/json" \
-d '{...}'
/api/validate/status
Return status of all validation runs.
get_validation_statusReturn status of all validation runs.
curl http://localhost:8000/api/validate/status
/api/validate/{run_id}
Get status/results of a specific validation run.
get_validation_runGet status/results of a specific validation run.
curl http://localhost:8000/api/validate/{run_id}
Integration
2 endpoints/api/generate-api-key
Generate a new API key stub for the demo.
generate_api_keyGenerate a new API key stub for the demo.
curl -X POST http://localhost:8000/api/generate-api-key \
-H "Content-Type: application/json" \
-d '{...}'
/api/integration-status
Returns integration health metrics.
integration_statusReturns integration health metrics.
curl http://localhost:8000/api/integration-status
Autonomy
5 endpoints/api/v2/autonomy
List all autonomy settings.
list_autonomy_settingsList all autonomy settings.
curl http://localhost:8000/api/v2/autonomy
/api/v2/autonomy
Create autonomy settings for a workflow.
create_autonomy_settingsCreate autonomy settings for a workflow.
curl -X POST http://localhost:8000/api/v2/autonomy \
-H "Content-Type: application/json" \
-d '{...}'
/api/v2/autonomy/{workflow_id}
Get autonomy settings for a workflow.
get_autonomy_settingsGet autonomy settings for a workflow.
curl http://localhost:8000/api/v2/autonomy/{workflow_id}
/api/v2/autonomy/{workflow_id}
Update autonomy settings for a workflow.
update_autonomy_settingsUpdate autonomy settings for a workflow.
curl -X PUT http://localhost:8000/api/v2/autonomy/{workflow_id} \
-H "Content-Type: application/json" \
-d '{...}'
/api/v2/workflow-graph
Return workflow graph structure.
get_workflow_graphReturn workflow graph structure.
curl http://localhost:8000/api/v2/workflow-graph
Architecture
Spectral is a FastAPI-backed control plane that orchestrates an autonomous AI evaluation and optimization loop backed by PostgreSQL and Claude.
System Diagram
Database Tables
Spectral uses 31 PostgreSQL tables to store all state across the optimization lifecycle:
Key Services
The Scan Loop
The full Spectral Scan runs six sequential phases. Each phase is autonomous — no human input is required between steps:
n cases from the working pool. Execute the agent pipeline on each input using the current champion config. Record traces — input, output, latency, tokens.POST /api/promote-auto or the Promotion Gate screen to deploy it.
anti_deception.py run alongside every phase. Any detected score drift or evaluator gaming will block promotion and log an intervention event regardless of the GO/NO-GO verdict.