# Environment Variables

## Runtime Selection

| Variable | Meaning |
| --- | --- |
| `KEDI_ADAPTER` | Default framework adapter for the Python API/CLI |
| `KEDI_AGENT` | Default harness for the Python API |
| `KEDI_ADAPTER_MODEL` | Default model for the selected backend |
| `MODEL_NAME` | CLI fallback model and codegen fallback |
| `KEDI_PARALLEL` | Enable/size default parallel execution |

`KEDI_ADAPTER` and `KEDI_AGENT` are mutually exclusive. Python `configure()`,
decorator arguments, source directives, and CLI options can provide more local
selection. `KEDI_PARALLEL` accepts `0/1`, `true/false`, `on/off`, or a positive
worker count; invalid values fail rather than silently selecting a mode.

## Code Generation

| Variable | CLI equivalent |
| --- | --- |
| `KEDI_CODEGEN_AGENT` | `--codegen-agent` |
| `KEDI_CODEGEN_MODEL` | `--codegen-model` |
| `KEDI_CODEGEN_RETRIES` | `--codegen-retries` |

`MODEL_NAME` is also consulted by the Pydantic codegen service when no explicit
codegen model is supplied.

## Optimization

| Variable | CLI equivalent |
| --- | --- |
| `KEDI_OPTIMIZER` | `--optimizer` |
| `KEDI_OPTIMIZER_MODEL` | `--optimizer-model` |
| `KEDI_OPTIMIZER_REFLECTION_MODEL` | `--optimizer-reflection-model` |
| `KEDI_OPTIMIZER_MAX_METRIC_CALLS` | `--optimizer-max-metric-calls` |
| `KEDI_OPTIMIZER_MODEL_MAX_TOKENS` | `--optimizer-model-max-tokens` |
| `KEDI_OPTIMIZER_REFLECTION_MODEL_MAX_TOKENS` | `--optimizer-reflection-model-max-tokens` |
| `KEDI_OPTIMIZER_REFLECTION_MINIBATCH_SIZE` | `--optimizer-reflection-minibatch-size` |
| `KEDI_OPTIMIZER_MAX_VALIDATION_EXAMPLES` | `--optimizer-max-validation-examples` |
| `KEDI_DEBUG_OPTIMIZED=1` | Print optimized prompt-loading diagnostics |

The debug variable is for diagnosis and may reveal prompt content; do not leave
it enabled in normal production logs.

## Packages

| Variable | Contract |
| --- | --- |
| `KEDI_HOME` | Absolute Kedi state root; relative paths are rejected |
| `KEDI_REGISTRY_MOCK_ROOT` | Local mock registry root until the public registry exists |

Installed packages live beneath `$KEDI_HOME/registry` or the platform default
Kedi home. Git package operations set `GIT_TERMINAL_PROMPT=0` so unattended
installs fail instead of waiting for credentials.

## Provider Credentials

Provider SDKs read their own variables, such as `GROQ_API_KEY`,
`OPENAI_API_KEY`, `OPENROUTER_API_KEY`, or `ANTHROPIC_API_KEY`. Kedi forwards
selection and settings but does not rename provider credentials. The exact
required variable depends on the model string and adapter.

ACP, Claude, and Codex process settings can also supply an explicit `env`
mapping. It is merged with the current process environment where that adapter
documents process spawning.

## `.env` Loading and Security

The Python API's default configuration loads `.env` through its environment
setup. Explicit arguments and scoped configuration take precedence. Do not
depend on `.env` loading inside a separately spawned harness unless that process
also loads or receives the values.

Never put secrets in `.kedi` source, optimizer datasets, debug exports, or
committed environment files. `MarkdownDebugExporter` does not redact values.
Bundled filesystem tools treat `.env` names as sensitive, but arbitrary Python
code is not intercepted by the approval layer.
