Quick Start
1
Repair a broken config
2
Provision a config from scratch
3
Detect without repairing
How It Works
Both entry points share the detect β repair β re-validate lifecycle behindpraisonai gateway doctor --fix.
When to use which
API Reference
Three symbols make up the whole public surface.repair_gateway_config
repair_gateway_config(config_path, *, fix=False, dry_run=False) -> GatewayRepairResult
Runs the same detect β repair β re-validate lifecycle as
praisonai gateway doctor --fix: forward-migrate an out-of-date config_version and mint/persist a strong gateway.auth_token when the configured one is weak or missing.
provision_gateway_config
provision_gateway_config(*, platform, token, agents=None, config_path=None) -> Path
GatewayRepairResult
@dataclass(frozen=True) β the closed result shape returned by repair_gateway_config.
.to_dict() returns a shallow JSON-safe copy of all four fields.
Precedence & Fallbacks
The auth-token repair interacts with${ENV} references and explicit YAML tokens as follows.
CLI parity
The Python API, CLI, and YAML surfaces run the same helpers.Common Patterns
CI-driven per-tenant provisioning
Post-deploy self-healing check
Testing the fixed gateway in pytest
Explicit path vs default location
Best Practices
π§ͺ Verify with the detect pass first
π§ͺ Verify with the detect pass first
Run without
fix=True, review remaining_degraded_owners, then re-run with fix=True. A detect-only pass never writes to disk.π Re-run after every deploy
π Re-run after every deploy
Config-version drift and weak tokens are silent until you check. Wire
repair_gateway_config(path, fix=False) into your post-deploy smoke test.π Never commit the token
π Never commit the token
provision_gateway_config(token=...) persists the credential to ~/.praisonai/.env (0600). Pass a ${VAR} reference in your YAML so the secret stays out of source control.π§ Keep the CLI and Python in sync
π§ Keep the CLI and Python in sync
Both surfaces run the same helpers in
admin.py β a repair from either is identical. Use the CLI interactively, the Python API in CI and tests.π Treat ValueError as fail-closed
π Treat ValueError as fail-closed
An unsupported
platform or empty token refuses to write, preventing a βstarts degradedβ outcome. Do not catch and ignore it.Related
Gateway CLI
The wrapping
gateway doctor commands.Bot Onboarding
The interactive wizard β sibling of
provision_gateway_config.Bind-Aware Auth
Weak-secret guard context.
Config Migration
Config-version migration context.

