> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Zero-Disk Config"
        Env[🌱 PRAISONAI_CONFIG_CONTENT] --> Parser[🧠 Resolver]
        File[📄 PRAISONAI_CONFIG] --> Parser
        Parser --> Config[⚙️ User-config layer]
        Config --> Agent[🤖 Agent runs]
    end

    classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef process fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef output fill:#10B981,stroke:#7C90A0,color:#fff
    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff

    class Env,File input
    class Parser process
    class Config output
    class Agent agent
```

## Quick Start

**1. Inline (YAML)**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export PRAISONAI_CONFIG_CONTENT='agent:
  model: gpt-4o-mini
permissions:
  deny:
    - "rm -rf /"'

praisonai run "Summarise this repo"
```

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export PRAISONAI_CONFIG=/etc/praisonai/prod.yaml
praisonai run "Ship it"
```

**4. Auth + config in one env set (zero-disk CI)**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    Start{Where does<br/>the config live?} -->|In an env secret| A[PRAISONAI_CONFIG_CONTENT<br/>inline JSON/YAML]
    Start -->|On a mounted path| B[PRAISONAI_CONFIG<br/>explicit file path]
    Start -->|On disk, discovered| C[Global / project<br/>config.yaml]
    Start -->|Just one setting| D[Per-key env var<br/>PRAISONAI_MODEL, ...]

    classDef pick fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef opt fill:#6366F1,stroke:#7C90A0,color:#fff
    class Start pick
    class A,B,C,D opt
```

***

## Precedence

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

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    CLI[⚡ CLI flags] --> ENV[🌱 Per-key env vars<br/>PRAISONAI_MODEL, ...]
    ENV --> EnvBlob[📦 Env config<br/>PRAISONAI_CONFIG_CONTENT<br/>or PRAISONAI_CONFIG]
    EnvBlob --> PROJ[📁 Project config.yaml]
    PROJ --> GLOB[🏠 Global config.yaml]
    GLOB --> MANAGED[🏢 Managed defaults]
    MANAGED --> DEF[📋 Built-in defaults]

    classDef high fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef mid fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef low fill:#6366F1,stroke:#7C90A0,color:#fff

    class CLI,ENV high
    class EnvBlob,PROJ,GLOB mid
    class MANAGED,DEF low
```

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.

> [!WARNING]
>
> A valid empty mapping (`{}`) is **authoritative** — it suppresses file discovery instead of falling back. Only invalid blobs (non-mapping / unparseable) warn and fall back to discovery.

***

## Configuration Options

| Variable | Type | Default | Description |
| - | - | - | - |
| `PRAISONAI_CONFIG_CONTENT` | inline JSON or YAML blob | unset | Parsed in memory as the user-config layer. Supports `${VAR}` / `{env:VAR}` / `{file:...}` interpolation, same as an on-disk file. |
| `PRAISONAI_CONFIG` | file path | unset | Explicit 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai config show --sources
# agent.model            env-config:env:PRAISONAI_CONFIG_CONTENT
# permissions.deny       env-config:env:PRAISONAI_CONFIG_CONTENT
```

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai_code.cli.configuration.resolver import ConfigResolver

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

***

## Fallback & Warning Behaviour

| Situation | Behaviour |
| - | - |
| `PRAISONAI_CONFIG_CONTENT` is not valid JSON/YAML | `UserWarning` (`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 file | `UserWarning`, fall back to file discovery |
| `PRAISONAI_CONFIG` points at a valid but non-mapping file | `UserWarning`, fall back to file discovery |
| `PRAISONAI_CONFIG` points at an empty (valid-YAML) file | Authoritative — file discovery is **not** re-enabled |

***

## Best Practices

> [accordion] 🔒 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.

> [accordion] 📦 Compose with PRAISONAI\_AUTH\_CONTENT
>
> An auth blob plus a config blob together give a true zero-disk run — nothing touches `~/.praisonai`.

> [accordion] 🧭 Use PRAISONAI\_CONFIG for mounted volumes
>
> Kubernetes ConfigMaps mounted as files pair naturally with the explicit path variable.

> [accordion] 🧪 Verify with praisonai config show --sources
>
> The `env-config:` label confirms the env layer won for each key.

***

## Related

> [card] [CLI Configuration](https://praison.ai/docs/features/cli-configuration.md)
>
> The full layered precedence hierarchy.

> [card] [Security Environment Variables](https://praison.ai/docs/features/security-environment-variables.md)
>
> `PRAISONAI_AUTH_CONTENT` and other security env vars.

> [card] [Managed Config Layer](https://praison.ai/docs/features/managed-config.md)
>
> Org-enforced policy on top of every layer.

> [card] [XDG Base Directories](https://praison.ai/docs/features/xdg-base-directories.md)
>
> Where PraisonAI writes its persistent state.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.