Environment Variables

Every environment variable the Desktop app and its engine read

Environment variables move the data directory, isolate secrets, and keep the engine’s output readable on non-English locales.

python
import os
from praisonaiagents import Agent

os.environ["PRAISONAI_DESKTOP_HOME"] = "/tmp/praison-profile"
agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
)
# The app reads the same variable to pick its data directory.
agent.start("Where does my data live?")
Diagram

set

empty or unset

macOS

Windows

Linux

PRAISONAI_DESKTOP_HOME?

📁 Use it

Which OS?

Application Support/PraisonAI

APPDATA/PraisonAI

XDG_DATA_HOME or ~/.local/share

An empty value is treated as unset — PRAISONAI_DESKTOP_HOME="" no longer picks a different directory for the Rust shell than for the Python engine.

Quick Start

  1. Override the data directory

    Set PRAISONAI_DESKTOP_HOME to a folder before launching to keep a separate profile.

  2. Isolate secrets

    Set PRAISONAI_KEYCHAIN_SERVICE to keep test keys out of your real keychain entry.

  3. Leave the encoding vars alone

    PYTHONUTF8 and PYTHONIOENCODING are set by the shell for the engine. You do not need to set them yourself.


How the engine gets its environment

The Desktop shell rebuilds the engine’s environment from the resolved venv before spawning it — it does not hand the engine your shell untouched.

Diagram

strip

inject

pass through

🖥️ Your shell env

🔧 spawn-env

❌ PYTHONHOME
❌ PYTHONPATH
❌ PYTHONSTARTUP

✅ VIRTUAL_ENV
✅ PATH prepended

✅ HOME, keys, PRAISONAI_*

🧠 Engine

Most variables pass through unchanged — provider keys (OPENAI_API_KEY, TAVILY_API_KEY), Desktop vars (PRAISONAI_DESKTOP_HOME, PRAISONAI_KEYCHAIN_SERVICE, PRAISONAI_AGENTS_SOURCE, PRAISONAI_TRAIN_CMD, PRAISONAI_MODEL), and platform vars (HOME, APPDATA, XDG_DATA_HOME).

Three variables are stripped by the shell before the engine spawns: PYTHONHOME, PYTHONPATH, PYTHONSTARTUP. Setting them in your shell does nothing for the engine — they would otherwise redirect the engine’s stdlib or site-packages away from the venv the shell just resolved.

Two variables are always set by the shell: VIRTUAL_ENV (points at the resolved venv root) and PATH (the venv’s bin/Scripts prepended to whatever PATH you exported).


Reference

VariableSet byEffect
PRAISONAI_DESKTOP_HOMEUserOverride the data directory. Empty is treated as unset.
XDG_DATA_HOMEUser (Linux)Fallback data root when PRAISONAI_DESKTOP_HOME is unset. Empty is unset.
APPDATAWindowsFallback data root on Windows.
PRAISONAI_KEYCHAIN_SERVICEUser / CISecret store service name. Default ai.praison.desktop.
PRAISONAI_AGENTS_SOURCEUserPoint the engine at a local praisonai-agents checkout.
PRAISONAI_TRAIN_CMDUserOverride the fine-tune launcher; --config <path> is always appended.
PRAISONAI_MODELUserDefault model id when no setting is stored.
PYTHONUTF8Shell → engineSet to 1 so the engine decodes as UTF-8 on non-UTF-8 locales.
PYTHONIOENCODINGShell → engineSet to utf-8 for the same reason. Do not override.
PYTHONHOME(stripped)Ignored — the shell drops it before spawning the engine so the venv’s stdlib is used.
PYTHONPATH(stripped)Ignored — the shell drops it so the engine only imports from the venv’s site-packages.
PYTHONSTARTUP(stripped)Ignored — the shell drops it so a stray startup script cannot run in the engine.
VIRTUAL_ENVShell → engineSet to the resolved venv root; do not override.
PATHShell → engineVenv’s bin (POSIX) or Scripts (Windows) prepended to your exported PATH.
OPENAI_API_KEY (and peers)UserProvider key used when api_key is blank in settings. Also unlocks Sora 2 in the Video tab.
REPLICATE_API_TOKEN / REPLICATE_API_KEYUserUnlocks MiniMax video-01 in the Video tab.
GEMINI_API_KEY / GOOGLE_API_KEYUserUnlocks Veo 3.1 and Veo 3.1 Lite in the Video tab.
OPENAI_API_BASEEngineSet from the base_url setting; cleared when you clear that setting.
`

_API_BASE | Engine | Set from the base_url setting for a slashed model id; the provider is named by the id's prefix. | |

_API_KEY | Engine | Set from the api_key setting for a slashed model id, following the same naming rule. | | TAVILY_API_KEY | User | Enables the built-in web_search` tool. |


Per-provider variables the engine writes

The app does not send your credential fields to OpenAI only. It writes them to the variables named for the selected provider — the base_url field is exported as `

_API_BASE, and api_key as

_API_KEY. The provider is taken from the model id's slashed prefix; a bare id is treated as OpenAI. The specific overrides encoded in PROVIDER_ENV_OVERRIDES in the engine's server.py`:

Slashed prefixBase URL exports asapi_key exports as
ollama/, ollama_chat/OLLAMA_API_BASE(none — Ollama has no key)
lm_studio/LM_STUDIO_API_BASELM_STUDIO_API_KEY
hosted_vllm/HOSTED_VLLM_API_BASEHOSTED_VLLM_API_KEY
openai/, text-completion-openai/OPENAI_API_BASEOPENAI_API_KEY
together_ai/TOGETHERAI_API_BASETOGETHERAI_API_KEY
anything else (groq/, mistral/, …)`

_API_BASE (uppercased) |

_API_KEY (uppercased) | | bare id (gpt-4o-mini, …) | OPENAI_API_BASE | OPENAI_API_KEY` |

The OpenAI pair is always kept in step, so switching back to a bare id after using a slashed one does not leave a stale endpoint behind.


Video-tab unlocks

Each video model in the Video tab becomes selectable only when one of its keys is present. A model with no configured key shows (key needed) and stays disabled.

KeyUnlocks in Video tab
REPLICATE_API_TOKEN / REPLICATE_API_KEYMiniMax video-01
OPENAI_API_KEYSora 2
GEMINI_API_KEY / GOOGLE_API_KEYVeo 3.1, Veo 3.1 Lite

Data Directory Precedence

The data directory follows one order per platform, and both the Rust shell and the Python engine derive it the same way.

PlatformOrder
macOSPRAISONAI_DESKTOP_HOME → ~/Library/Application Support/PraisonAI
WindowsPRAISONAI_DESKTOP_HOME → %APPDATA%\PraisonAI
LinuxPRAISONAI_DESKTOP_HOME → $XDG_DATA_HOME/PraisonAI → ~/.local/share/PraisonAI

Encoding on Non-English Locales

The shell exports PYTHONUTF8=1 and PYTHONIOENCODING=utf-8 to the engine so its output decodes cleanly on CP932 (Japanese) or CP1252 (Western European) systems.

Diagram

PYTHONUTF8=1

🖥️ Shell

🧠 Engine

📜 Readable log

Setting these yourself is redundant — the shell already does it.


Best Practices

Unset rather than blank

An empty value is unset. To fall back to the platform default, remove the variable rather than setting it to "".

Isolate secrets for testing

Set PRAISONAI_KEYCHAIN_SERVICE to a distinct name so a test run never overwrites the key you actually use — PRAISONAI_DESKTOP_HOME isolates data, not the system keyring. The engine’s own redaction test suite makes this a hard rule: it refuses to run unless the service is set away from the default ai.praison.desktop, so a test can never touch your real keychain entry.

Leave a provider key in the environment

Export OPENAI_API_KEY and leave the settings api_key blank to keep the credential out of the app entirely.

Point the engine at a local checkout with PRAISONAI_AGENTS_SOURCE, not PYTHONPATH

PYTHONPATH is stripped by design before the engine spawns, so it never reaches the engine. Set PRAISONAI_AGENTS_SOURCE to your praisonaiagents checkout instead — that variable passes through unchanged.

Don't override the UTF-8 exports

The shell already sets PYTHONUTF8=1 and PYTHONIOENCODING=utf-8 so the engine starts on non-English locales. Overriding them reintroduces the startup-timeout bug they fix.


Related