Introduction
The Management API provides programmatic control over switchAILocal’s configuration, monitoring, and intelligent systems. Use it to automate operations, build management dashboards, or integrate with DevOps tools.
Base URL
http://localhost:18080/v0/management
All management endpoints use the /v0/management prefix.
Authentication
Management endpoints require a secret key for authentication:
curl http://localhost:18080/v0/management/config \
-H "X-Management-Key: your-secret-key"
Initialize Secret
On first run, initialize your management secret:
curl -X POST http://localhost:18080/v0/management/initialize \
-H "Content-Type: application/json" \
-d '{
"password": "your-secure-password"
}'
See Authentication for details.
Endpoint Categories
Configuration Manage server configuration and settings
Get/update config.yaml
Manage API keys
Configure providers
Monitoring Track usage and performance
Usage statistics
Provider health
Request logs
Intelligent Systems Access advanced AI capabilities
Memory statistics
Steering rules
Hook status
Analytics
Provider Management Control AI providers
Test connectivity
Discover models
Manage credentials
Quick Examples
Get Server Configuration
curl http://localhost:18080/v0/management/config \
-H "X-Management-Key: your-secret-key"
Update Configuration
curl -X PUT http://localhost:18080/v0/management/config.yaml \
-H "X-Management-Key: your-secret-key" \
-H "Content-Type: application/yaml" \
--data-binary @config.yaml
Get Usage Statistics
curl http://localhost:18080/v0/management/usage \
-H "X-Management-Key: your-secret-key"
Test Provider
curl -X POST http://localhost:18080/v0/management/providers/test \
-H "X-Management-Key: your-secret-key" \
-H "Content-Type: application/json" \
-d '{
"provider": "geminicli",
"model": "gemini-2.5-pro"
}'
Setup Workflow
New installations can use the setup flow:
1. Check Setup Status
curl http://localhost:18080/v0/management/setup-status
Response :
{
"initialized" : false ,
"skipped" : false ,
"allow_remote" : false
}
2. Initialize or Skip
# Option A: Initialize with secret
curl -X POST http://localhost:18080/v0/management/initialize \
-H "Content-Type: application/json" \
-d '{"password": "secure-password"}'
# Option B: Skip setup (localhost-only access)
curl -X POST http://localhost:18080/v0/management/skip
3. Access Management Endpoints
After initialization, use the secret key:
curl http://localhost:18080/v0/management/config \
-H "X-Management-Key: your-secret-key"
Localhost Bypass
When accessing from localhost and remote management is disabled:
remote_management :
allow_remote : false # Default
Management endpoints allow unauthenticated access from localhost for better UX.
Only enable allow_remote: true when you need external access. Always use strong secret keys for remote access.
Remote Access
To enable remote management:
remote_management :
allow_remote : true
secret_key : "<bcrypt-hashed-password>" # Set via initialize endpoint
Or use environment variable:
export MANAGEMENT_PASSWORD = "your-password"
./switchAILocal
Security Features
Rate Limiting
Failed authentication attempts trigger temporary IP bans:
Max failures : 5 attempts
Ban duration : 30 minutes
Scope : Per remote IP
CORS Disabled
Management endpoints disable CORS to prevent browser-based attacks.
Localhost Restriction
Optionally restrict management to localhost only:
ampcode :
restrict_management_to_localhost : true
All management endpoints return JSON:
Success Response
{
"success" : true ,
"data" : { ... }
}
Error Response
{
"error" : "Invalid management key"
}
Header Required Description X-Management-KeyYes Management secret key Content-TypeVaries application/json or application/yamlAuthorizationNo Alternative to X-Management-Key: Bearer <key>
All responses include version headers:
X-CPA-VERSION: 1.0.0
X-CPA-COMMIT: abc123def
X-CPA-BUILD-DATE: 2026-03-09T10:00:00Z
Available Endpoints
Configuration Management
Endpoint Method Description /configGET Get JSON configuration /config.yamlGET Get YAML configuration /config.yamlPUT Update configuration /debugGET/PUT Get/set debug mode /logging-to-fileGET/PUT Get/set file logging /usage-statistics-enabledGET/PUT Get/set usage tracking /proxy-urlGET/PUT/DELETE Manage proxy settings
Provider Management
Endpoint Method Description /providers/testPOST Test provider connectivity /providers/discover-modelsPOST Discover available models /gemini-api-keyGET/PUT/PATCH/DELETE Manage Gemini keys /claude-api-keyGET/PUT/PATCH/DELETE Manage Claude keys /switchai-api-keyGET/PUT/PATCH/DELETE Manage switchAI keys /codex-api-keyGET/PUT/PATCH/DELETE Manage Codex keys
Monitoring
Endpoint Method Description /usageGET Usage statistics /metricsGET Superbrain metrics /logsGET Server logs /request-error-logsGET Error logs /request-log-by-id/:idGET Specific request log
Intelligent Systems
Endpoint Method Description /memory/statsGET Memory system statistics /heartbeat/statusGET Provider health status /steering/rulesGET Loaded steering rules /steering/reloadPOST Reload steering rules /hooks/statusGET Hook execution status /hooks/reloadPOST Reload hooks /analyticsGET Computed analytics
Advanced
Endpoint Method Description /cache/metricsGET Cache statistics /cache/clearPOST Clear semantic cache /state-box/statusGET State directory info /latest-versionGET Check for updates
Python Client Example
import requests
class ManagementClient :
def __init__ ( self , base_url = "http://localhost:18080" , secret_key = None ):
self .base_url = base_url
self .headers = {}
if secret_key:
self .headers[ "X-Management-Key" ] = secret_key
def get_config ( self ):
response = requests.get(
f " { self .base_url } /v0/management/config" ,
headers = self .headers
)
response.raise_for_status()
return response.json()
def get_usage ( self ):
response = requests.get(
f " { self .base_url } /v0/management/usage" ,
headers = self .headers
)
response.raise_for_status()
return response.json()
def test_provider ( self , provider , model ):
response = requests.post(
f " { self .base_url } /v0/management/providers/test" ,
headers = self .headers,
json = { "provider" : provider, "model" : model}
)
response.raise_for_status()
return response.json()
# Usage
client = ManagementClient( secret_key = "your-secret-key" )
config = client.get_config()
print ( f "Debug mode: { config[ 'debug' ] } " )
usage = client.get_usage()
print ( f "Total requests: { usage[ 'total_requests' ] } " )
JavaScript Client Example
class ManagementClient {
constructor ( baseURL = 'http://localhost:18080' , secretKey = null ) {
this . baseURL = baseURL ;
this . headers = secretKey ? { 'X-Management-Key' : secretKey } : {};
}
async getConfig () {
const response = await fetch (
` ${ this . baseURL } /v0/management/config` ,
{ headers: this . headers }
);
if ( ! response . ok ) throw new Error ( 'Failed to get config' );
return response . json ();
}
async getUsage () {
const response = await fetch (
` ${ this . baseURL } /v0/management/usage` ,
{ headers: this . headers }
);
if ( ! response . ok ) throw new Error ( 'Failed to get usage' );
return response . json ();
}
async testProvider ( provider , model ) {
const response = await fetch (
` ${ this . baseURL } /v0/management/providers/test` ,
{
method: 'POST' ,
headers: { ... this . headers , 'Content-Type' : 'application/json' },
body: JSON . stringify ({ provider , model })
}
);
if ( ! response . ok ) throw new Error ( 'Failed to test provider' );
return response . json ();
}
}
// Usage
const client = new ManagementClient (
'http://localhost:18080' ,
'your-secret-key'
);
const config = await client . getConfig ();
console . log ( `Debug mode: ${ config . debug } ` );
const usage = await client . getUsage ();
console . log ( `Total requests: ${ usage . total_requests } ` );
Next Steps