Env Config Injection

Supply the full PraisonAI CLI config from the environment โ€” no config.yaml on disk

Supply the whole user-config layer from a single environment variable โ€” no config.yaml is read or written to disk. Pairs with PRAISONAI_AUTH_CONTENT so one CI secret set provides auth and config for a stateless run.

Diagram

Zero-Disk Config

๐ŸŒฑ PRAISONAI_CONFIG_CONTENT

๐Ÿง  Resolver

๐Ÿ“„ PRAISONAI_CONFIG

โš™๏ธ User-config layer

๐Ÿค– Agent runs

Quick Start

  1. Inline (YAML)
    bash
    export PRAISONAI_CONFIG_CONTENT='agent:
      model: gpt-4o-mini
    permissions:
      deny:
        - "rm -rf /"'
    
    praisonai run "Summarise this repo"
    python
    from praisonaiagents import Agent
    
    # Model + permissions come from PRAISONAI_CONFIG_CONTENT โ€” no ~/.praisonai/config.yaml
    agent = Agent(name="assistant", instructions="Be helpful.")
    agent.start("What model am I using?")
  2. Inline (JSON)
    bash
    export PRAISONAI_CONFIG_CONTENT='{"agent":{"model":"gpt-4o-mini"},"mcp":{"srv":{"url":"https://mcp.example.com"}}}'
    praisonai run "List MCP tools"
  3. Explicit path (PRAISONAI_CONFIG)
    bash
    export PRAISONAI_CONFIG=/etc/praisonai/prod.yaml
    praisonai run "Ship it"
  4. Auth + config in one env set (zero-disk CI)
    bash
    export PRAISONAI_AUTH_CONTENT='{"openai":{"api_key":"sk-...","auth_method":"apikey"}}'
    export PRAISONAI_CONFIG_CONTENT='agent:
      model: gpt-4o-mini'
    praisonai run "Run my CI task"
    # Nothing is written to ~/.praisonai โ€” both auth and config live in memory only.

Which one should I use?

Pick the source that matches where your config already lives.

Diagram

In an env secret

On a mounted path

On disk, discovered

Just one setting

Where does
the config live?

PRAISONAI_CONFIG_CONTENT
inline JSON/YAML

PRAISONAI_CONFIG
explicit file path

Global / project
config.yaml

Per-key env var
PRAISONAI_MODEL, …


Precedence

The env-config layer occupies the same slot as the discovered global/project files, so higher layers still win.

Diagram

โšก CLI flags

๐ŸŒฑ Per-key env vars
PRAISONAI_MODEL, …

๐Ÿ“ฆ Env config
PRAISONAI_CONFIG_CONTENT
or PRAISONAI_CONFIG

๐Ÿ“ Project config.yaml

๐Ÿ  Global config.yaml

๐Ÿข Managed defaults

๐Ÿ“‹ Built-in defaults

Key rules:

  • PRAISONAI_CONFIG_CONTENT (inline) wins over PRAISONAI_CONFIG (path) โ€” inline replaces the path layer entirely.
  • When either is set, no global/project config.yaml on disk is read for the user-config layer.
  • Per-key env vars (PRAISONAI_MODEL, OPENAI_API_BASE, โ€ฆ) and CLI flags still override the env blob.
  • Managed policy (permissions, model_allowlist) is still enforced on top.

Configuration Options

VariableTypeDefaultDescription
PRAISONAI_CONFIG_CONTENTinline JSON or YAML blobunsetParsed in memory as the user-config layer. Supports ${VAR} / {env:VAR} / {file:...} interpolation, same as an on-disk file.
PRAISONAI_CONFIGfile pathunsetExplicit config file loaded in place of global/project discovery. Ignored when PRAISONAI_CONFIG_CONTENT is set.

Provenance

See which layer supplied each key with the env-config: label.

bash
praisonai config show --sources
# agent.model            env-config:env:PRAISONAI_CONFIG_CONTENT
# permissions.deny       env-config:env:PRAISONAI_CONFIG_CONTENT
python
from praisonai_code.cli.configuration.resolver import ConfigResolver

prov = ConfigResolver().resolve_with_provenance()
print(prov["agent.model"]["layer"])   # -> "env-config"

Fallback & Warning Behaviour

SituationBehaviour
PRAISONAI_CONFIG_CONTENT is not valid JSON/YAMLUserWarning (Ignoring PRAISONAI_CONFIG_CONTENT: value is not valid JSON/YAML.), fall back to file discovery
PRAISONAI_CONFIG_CONTENT parses to a list/scalar (not a mapping)UserWarning (value must be a mapping.), fall back to file discovery
PRAISONAI_CONFIG_CONTENT is {} (empty mapping)Authoritative โ€” file discovery is not re-enabled
PRAISONAI_CONFIG points at a missing fileUserWarning, fall back to file discovery
PRAISONAI_CONFIG points at a valid but non-mapping fileUserWarning, fall back to file discovery
PRAISONAI_CONFIG points at an empty (valid-YAML) fileAuthoritative โ€” file discovery is not re-enabled

Best Practices

๐Ÿ”’ Treat the blob as a secret

It can contain provider URLs, tenant IDs, and deny rules. Inject only from a secrets manager; never commit it.

๐Ÿ“ฆ Compose with PRAISONAI_AUTH_CONTENT

An auth blob plus a config blob together give a true zero-disk run โ€” nothing touches ~/.praisonai.

๐Ÿงญ Use PRAISONAI_CONFIG for mounted volumes

Kubernetes ConfigMaps mounted as files pair naturally with the explicit path variable.

๐Ÿงช Verify with praisonai config show –sources

The env-config: label confirms the env layer won for each key.


Related