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

# Kode Environment Variables: API Keys, Endpoints, and Paths

> All environment variables Kode reads at startup: API keys, model selection, endpoint overrides, path configuration, and server auth.

Kode reads a set of environment variables at startup to configure its LLM backend, resolve file paths, and control interactive behavior. You can set these in your shell profile, a `.env` file at your project root, or in your CI/CD pipeline. Where a variable overlaps with a field in `.kode/kode.json`, the environment variable takes precedence for API keys and endpoint overrides.

## LLM & API keys

<ParamField body="KODE_LLM_API_KEY" type="string">
  The primary API key for the configured LLM provider. This takes precedence
  over all other key variables (`OPENAI_API_KEY`, `KODE_PRO_API_KEY`). Set this
  when using the Kode Gateway or any provider that accepts a Bearer token via a
  single key.

  ```bash theme={null}
  export KODE_LLM_API_KEY=sk-...
  ```
</ParamField>

<ParamField body="OPENAI_API_KEY" type="string">
  Standard OpenAI API key. Kode uses this as a fallback when `KODE_LLM_API_KEY`
  is not set and no other key is provided. If you are already exporting this
  variable for other tools, Kode picks it up automatically.

  ```bash theme={null}
  export OPENAI_API_KEY=sk-...
  ```
</ParamField>

<ParamField body="KODE_PRO_API_KEY" type="string">
  Kode Pro API key. When this is set and no other key or endpoint overrides are
  present, Kode bypasses the public gateway and routes directly to
  `api.deepseek.com` using the `deepseek-v4-flash` model. This is the fastest
  zero-config path for Pro subscribers.

  ```bash theme={null}
  export KODE_PRO_API_KEY=kp-...
  ```
</ParamField>

<ParamField body="KODE_LLM_ENDPOINT" type="string" default="https://api.openai.com/v1">
  The LLM API endpoint Kode sends chat completion requests to. Override this to
  point at a local model server, a corporate proxy, or a self-hosted inference
  endpoint. The value must be a base URL; Kode appends `/chat/completions`
  automatically.

  ```bash theme={null}
  # Ollama running locally
  export KODE_LLM_ENDPOINT=http://localhost:11434/v1
  ```
</ParamField>

<ParamField body="KODE_LLM_MODEL" type="string" default="gpt-4o">
  Override the model Kode uses, bypassing the `model` field in `kode.json`. Use
  the same `provider/model` format as the config file, or a bare model name when
  pointing at a local endpoint.

  ```bash theme={null}
  export KODE_LLM_MODEL=anthropic/claude-sonnet-4-6
  ```
</ParamField>

## TUI & paths

<ParamField body="KODE_TUI_DIR" type="string" default="~/.kode/tui">
  Custom path for the TUI bundle directory. On first run, Kode downloads the TUI
  bundle (\~52 MB) from GitHub Releases and extracts it to `~/.kode/tui`. Set
  this variable to use a different location — useful when `~` is on a slow
  filesystem or when you want to share a pre-extracted bundle across users.

  ```bash theme={null}
  export KODE_TUI_DIR=/opt/kode/tui
  ```
</ParamField>

<ParamField body="KODE_TUI_BUNDLE_URL" type="string">
  Custom URL to download the TUI bundle archive from. When set, Kode fetches the
  `tui-bundle.tar.gz` from this URL instead of GitHub Releases. Use this to
  point at an internal mirror or a pinned artifact in air-gapped environments.

  ```bash theme={null}
  export KODE_TUI_BUNDLE_URL=https://artifacts.internal/kode/tui-bundle.tar.gz
  ```
</ParamField>

<ParamField body="KODE_DIR" type="string" default=".kode">
  Override the path Kode uses for the `.kode` config directory. By default Kode
  looks for `.kode/kode.json` in the current working directory. Set `KODE_DIR`
  to use a directory at a different absolute path — for example, a shared config
  location on a build server.

  ```bash theme={null}
  export KODE_DIR=/etc/kode
  ```
</ParamField>

<ParamField body="KODE_NO_INSTALL" type="string">
  Set to `1` to disable all automatic install prompts. When Kode detects that a
  dependency (Bun, the TUI bundle, or Sicario) is missing and this variable is
  set, it fails immediately instead of asking to install. Always set this in CI
  to prevent pipelines from hanging on interactive prompts.

  ```bash theme={null}
  export KODE_NO_INSTALL=1
  ```
</ParamField>

<ParamField body="SICARIO_PATH" type="string">
  Override the path to the Sicario SAST binary. Kode normally installs Sicario
  into your `.kode/` directory via `kode init` or `kode install sicario`. Set
  `SICARIO_PATH` to point at a pre-installed binary — useful when distributing
  a company-wide Sicario installation or when the binary lives outside the
  project tree.

  ```bash theme={null}
  export SICARIO_PATH=/usr/local/bin/sicario
  ```
</ParamField>

## Server authentication

<ParamField body="KODE_SERVER_PASSWORD" type="string">
  Password for the Kode server. Required when running `kode serve` to protect
  the HTTP API from unauthorized access. Clients must supply this password as
  a credential when connecting.

  ```bash theme={null}
  export KODE_SERVER_PASSWORD=my-secure-password
  ```
</ParamField>

<ParamField body="KODE_SERVER_USERNAME" type="string" default="kode">
  Username for the Kode server. Paired with `KODE_SERVER_PASSWORD` to form the
  basic authentication credential for the server. Defaults to `kode` if not
  set.

  ```bash theme={null}
  export KODE_SERVER_USERNAME=kode
  ```
</ParamField>

## Usage notes

<Tip>
  For CI/CD pipelines, always set `KODE_NO_INSTALL=1` alongside your
  `KODE_LLM_API_KEY`. This ensures Kode never pauses on an interactive install
  prompt and fails fast if any dependency is missing from the runner image.

  ```bash theme={null}
  export KODE_NO_INSTALL=1
  export KODE_LLM_API_KEY=<your-api-key>
  ```
</Tip>

<Note>
  Environment variables take precedence over `.kode/kode.json` settings for API
  keys and endpoints. If both `KODE_LLM_ENDPOINT` and `providers.gateway_url`
  are set, the environment variable wins. This lets you override per-project
  config at the shell level without editing committed files.
</Note>

## Zero-config mode

If none of `KODE_LLM_API_KEY`, `KODE_LLM_ENDPOINT`, `OPENAI_API_KEY`, or `KODE_LLM_MODEL` are set, Kode enters zero-config mode and routes to the public Kode Gateway at `https://api.trykode.xyz/v1` using `deepseek-v4-flash`. The public gateway is rate-limited to **20 requests per day per IP** on the free (Lite) tier.

## Related

<CardGroup cols={2}>
  <Card title="kode.json reference" href="/configuration/kode-json">
    Full reference for all fields in the project config file.
  </Card>

  <Card title="Providers" href="/configuration/providers">
    Configure AI providers, API keys, and model strings.
  </Card>
</CardGroup>
