Skip to content

Manager Server Guide

Manager Server is the backend for the full CPAMP experience. It hosts management.html, stores local SQLite data, consumes the CPA usage queue through the collector, and protects management capabilities with the CPAMP Admin Key.

When you open this entry point, you are using Manager Server mode:

text
http://<host>:18317/management.html

When CPA itself serves this entry point, you are using CPA Panel mode:

text
http://<cpa-host>:8317/management.html

CPA Panel mode does not read Manager Server SQLite and does not provide the full historical monitoring, model prices, API Key aliases, import/export, or server inspection history.

What Manager Server Does

Manager Server:

  • Serves the embedded management panel.
  • Runs first setup and stores the bound CPA connection.
  • Authenticates users with the cmp_admin_... admin key.
  • Encrypts the saved CPA Management Key with data.key.
  • Proxies CPA Management API calls after setup.
  • Consumes CPA usage events.
  • Persists usage events in SQLite.
  • Provides Dashboard, Request Monitoring, Usage Analytics, Model Pricing, API Key Alias, Usage Import/Export, and Server Codex Inspection APIs.

Architecture

text
Browser
  -> Manager Server :18317
      -> /management.html
      -> /usage-service/info
      -> /usage-service/config
      -> /v0/management/usage              from SQLite
      -> /v0/management/model-prices       from SQLite
      -> /v0/management/api-key-aliases    from SQLite
      -> /v0/management/dashboard/*        from SQLite
      -> /v0/management/monitoring/*       from SQLite
      -> /v0/management/codex-inspection/* from SQLite / background workers
      -> other /v0/management/*            proxied to CPA
      -> collector -> CPA usage queue
      -> /data/usage.sqlite

CPA still runs separately. CPAMP does not bundle CPA.

First Setup And Login

On first startup, CPAMP needs an admin key. You can provide one:

bash
CPA_MANAGER_ADMIN_KEY='replace-with-a-long-random-admin-key'

If not configured, Manager Server generates:

text
cmp_admin_...

and prints it once in the startup logs.

First setup asks for:

text
Admin Key
CPA URL
CPA Management Key
Request Monitoring
Collection Mode
Poll Interval

After setup:

  • Browser login uses the CPAMP admin key.
  • CPA Management Key is stored server-side and encrypted.
  • Manager Server uses the saved CPA Management Key when calling CPA.
  • New browsers no longer need the CPA Management Key.

CPA Prerequisites

Request monitoring requires CPA usage publishing and the CPA usage queue.

Minimum:

text
CPA v6.10.8+ for HTTP usage queue

Recommended:

text
CPA v7.1.39+

CPA Management API must be enabled:

yaml
remote-management:
  secret-key: "your CPA Management Key"
  allow-remote: true

Usage publishing can be enabled by CPAMP during setup/config save, or directly in CPA:

yaml
usage-statistics-enabled: true

Queue retention is controlled by CPA:

yaml
redis-usage-queue-retention-seconds: 60

Default retention is 60 seconds and the maximum is 3600 seconds. Keep Manager Server running continuously.

Collection Mode

Default:

text
auto

Behavior:

text
auto -> RESP Pub/Sub -> HTTP usage queue -> RESP pop fallback
ModeUse when
autoRecommended default.
subscribeForce RESP Pub/Sub for low-latency direct CPA API access.
httpForce HTTP usage queue, useful behind normal HTTP reverse proxies.
respForce legacy RESP pop; must directly reach the CPA API port.

RESP transports cannot pass through a normal HTTP reverse proxy. If you see unsupported RESP prefix 'H', the RESP client is probably connecting to an HTTP endpoint.

Configuration Boundary

Managed by Manager Server:

  • Bound CPA URL.
  • Encrypted CPA Management Key.
  • Request monitoring switch.
  • Collection mode, poll interval, batch size, and query limit.
  • SQLite usage data.
  • Model pricing data.
  • API Key aliases.
  • Server inspection history.

Still managed by CPA:

  • usage-statistics-enabled
  • redis-usage-queue-retention-seconds
  • remote-management
  • proxy and routing config
  • logging config
  • auth files
  • provider config
  • CPA config.yaml

Saving CPAMP configuration does not rewrite the full CPA config.yaml.

Environment Variables

VariableDefaultDescription
CPA_MANAGER_CONFIGemptyOptional config file path. Native packages default to config.json next to the binary.
HTTP_ADDR0.0.0.0:18317Manager Server listen address.
USAGE_DATA_DIRDocker: /data; native: ./dataBase data directory.
USAGE_DB_PATHDocker: /data/usage.sqlite; native: ./data/usage.sqliteSQLite database path.
CPA_MANAGER_ADMIN_KEYemptyOptional admin key.
CPA_MANAGER_ADMIN_KEY_FILE/run/secrets/cpa_admin_keyOptional admin key file.
CPA_MANAGER_DATA_KEYemptyOptional data encryption key.
CPA_MANAGER_DATA_KEY_FILE/run/secrets/cpa_data_keyOptional data encryption key file.
CPA_MANAGER_DATA_KEY_PATHDocker: /data/data.key; native: ./data/data.keyGenerated data key path.
CPA_UPSTREAM_URLemptyOptional environment-managed CPA URL.
CPA_MANAGEMENT_KEYemptyOptional environment-managed CPA Management Key.
CPA_MANAGEMENT_KEY_FILE/run/secrets/cpa_management_keyOptional CPA Management Key file.
USAGE_COLLECTOR_MODEautoauto, subscribe, http, or resp.
USAGE_RESP_QUEUEusageRESP key argument; normally leave unchanged.
USAGE_RESP_POP_SIDErightright uses RPOP; left uses LPOP.
USAGE_BATCH_SIZE100Max records per batch.
USAGE_POLL_INTERVAL_MS500Idle poll interval.
USAGE_QUERY_LIMIT50000Max recent usage events.
USAGE_CORS_ORIGINS*CORS origins for compatibility endpoints.
USAGE_RESP_TLS_SKIP_VERIFYfalseSkip TLS verification for RESP connection.
USAGE_QUOTA_COOLDOWN_ENABLEDfalseEnable the Codex usage-limit cooldown worker.
USAGE_ACCOUNT_ACTIONS_ENABLEDfalseEnable the account action queue for auth issues that need review.
USAGE_ACCOUNT_ACTIONS_AUTO_DISABLEfalseEnable automatic disabling for auth issues. This only takes effect when the account action queue is enabled.
PANEL_PATHemptyOptional custom management.html.

Startup precedence:

text
environment variables > config.json > defaults

When USAGE_QUOTA_COOLDOWN_ENABLED, USAGE_ACCOUNT_ACTIONS_ENABLED, or USAGE_ACCOUNT_ACTIONS_AUTO_DISABLE is set through the environment, the matching panel switch is shown as environment-sourced and locked. Remove the environment variable and restart Manager Server if you want the setting to be editable from the panel.

Runtime Endpoints

EndpointPurpose
GET /healthHealth check.
GET /statusCollector, SQLite, event count, and errors.
GET /usage-service/infoManager Server mode detection.
GET /usage-service/configRead CPAMP Manager Server config.
PUT /usage-service/configSave CPAMP config and restart collector if needed.
GET /usage-service/account-processing-policyRead quota cooldown, account action queue, and auto-disable policy.
PATCH /usage-service/account-processing-policyUpdate account processing policy. Fields locked by environment variables cannot be modified through the API.
GET /usage-service/quota-cooldownsRead active quota cooldowns so the auth files page can show recovery hints.
POST /setupFirst setup.
GET /v0/management/usageCompatible usage data.
GET /v0/management/usage/exportExport JSONL usage events.
POST /v0/management/usage/importImport JSONL or compatible legacy snapshots.
GET /v0/management/model-pricesModel pricing.
PUT /v0/management/model-pricesReplace saved model pricing.
POST /v0/management/model-prices/syncPrice sync.
GET /v0/management/api-key-aliasesAPI Key aliases.
GET /v0/management/account-action-candidatesAuth issue action queue.
POST /v0/management/account-action-candidates/{id}/ignoreIgnore an account action candidate.
POST /v0/management/account-action-candidates/{id}/resolveMark an account action candidate as resolved.
POST /v0/management/account-action-candidates/{id}/enableRe-enable the auth file linked to a candidate.
DELETE /v0/management/account-action-candidates/{id}/auth-fileDelete the auth file linked to a candidate.
GET /v0/management/dashboard/*Dashboard data.
GET /v0/management/monitoring/*Monitoring data.
GET /v0/management/codex-inspection/*Server Codex inspection.
GET /models, GET /v1/modelsProxy model-list requests to CPA after setup.
/v0/management/*Proxied to CPA unless handled by CPAMP.

After setup, Manager Server management endpoints require:

text
Authorization: Bearer <CPAMP_ADMIN_KEY>

Data And Security

Back up:

text
usage.sqlite
usage.sqlite-wal
usage.sqlite-shm
data.key

Security notes:

  • The admin key is not stored in plaintext; only a salted HMAC credential is stored.
  • The CPA Management Key is encrypted before being stored in SQLite.
  • If usage.sqlite leaks without data.key, the saved CPA Management Key is not directly readable.
  • If both usage.sqlite and data.key leak, the saved CPA Management Key can be decrypted.
  • If data.key is lost, the saved CPA Management Key cannot be recovered.
  • Request metadata may contain model names, endpoints, account labels, project snapshots, token usage, latency, and failure summaries.
  • Raw failure bodies stay local in SQLite. Normal APIs and JSONL exports expose sanitized summaries instead of raw diagnostic bodies.

Import And Export

Manager Server exports JSONL / NDJSON usage events.

It can import:

  • JSONL / NDJSON exported by Manager Server.
  • Legacy usage snapshots only when request-level details exist.

Aggregate-only legacy files cannot reconstruct request-level monitoring. Test imports against a backup or staging database when accuracy matters.

Released under the MIT License.