Skip to main content

Environment Variables

Dorgu recognizes several environment variables for configuring LLM providers, Kubernetes access, and runtime behavior. Environment variables sit at priority level 5 in the configuration hierarchy — above built-in defaults but below config files and CLI flags.

Variables Reference

VariablePurposeExample
OPENAI_API_KEYOpenAI API accesssk-proj-...
ANTHROPIC_API_KEYAnthropic Claude API accesssk-ant-...
GEMINI_API_KEYGoogle Gemini API accessAIza...
GOOGLE_API_KEYAlternative Gemini API keyAIza...
OLLAMA_HOSTCustom Ollama endpoint URLhttp://localhost:11434
KUBECONFIGPath to kubeconfig file~/.kube/config

Precedence

For API keys, environment variables take precedence over the global config file (~/.config/dorgu/config.yaml). This makes it easy to override keys per-session or in CI pipelines:
# Override the configured API key for this session
export OPENAI_API_KEY="sk-proj-different-key..."
dorgu generate .
For other settings, the standard priority order applies: CLI flags and config files override environment variables.

DORGU_* Prefix

Dorgu uses Viper for configuration management with AutomaticEnv() enabled. This means any configuration key can be overridden via an environment variable with the DORGU_ prefix, using underscores for nested keys:
# Override llm.provider via environment
export DORGU_LLM_PROVIDER="anthropic"

# Override defaults.namespace via environment
export DORGU_DEFAULTS_NAMESPACE="staging"
The DORGU_* prefix variables follow the same naming convention as the config file keys, with dots replaced by underscores and the DORGU_ prefix added. For example, llm.model becomes DORGU_LLM_MODEL.

Usage in CI/CD

Environment variables are the recommended way to configure Dorgu in CI/CD pipelines. Store API keys as secrets and export them before running Dorgu:
# GitHub Actions example
steps:
  - name: Generate manifests
    env:
      OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
    run: dorgu generate . --output manifests/
# GitLab CI example
generate:
  script:
    - dorgu generate . --output manifests/
  variables:
    OPENAI_API_KEY: $OPENAI_API_KEY
When running in CI without a TTY, Dorgu will not prompt for missing API keys. Make sure to set the appropriate environment variable or use the --llm-provider flag to explicitly disable LLM enhancement if no key is available.