Skip to main content

Configuration Overview

DocuGen AI supports multiple configuration methods with a clear precedence order. This allows you to set defaults globally while overriding them per-project or per-command.

Configuration Precedence

Configuration values are resolved in the following order (highest to lowest priority):
  1. CLI arguments - Direct command-line options
  2. TOML configuration files - Project or user config files
  3. Default values - Built-in defaults

Configuration Methods

Command-Line Options

The most direct way to configure DocuGen is via CLI arguments. These always take precedence over other configuration methods.
docugen generate . \
  --output DOCS.md \
  --model gemini-pro \
  --prompt "Focus on API documentation"
Available CLI options:
  • --output, -o - Output file path
  • --model - Gemini model name
  • --prompt, -p - Additional AI instructions
  • --config - Path to TOML config file
See CLI Reference for complete details.

Configuration Parameters

API Key

api_key
string
required
Source: GEMINI_API_KEY environment variable or .env fileYour Google Gemini API key. Obtain one from Google AI Studio.Resolution order:
  1. GEMINI_API_KEY environment variable
  2. GEMINI_API_KEY in .env file (current directory)
  3. GEMINI_API_KEY in .env file (DocuGen installation directory)

Model

model
string
default:"gemini-3.1-flash-lite-preview"
Sources: CLI --model, TOML model keyThe Gemini model to use for generating documentation.Popular options:
  • gemini-3.1-flash-lite-preview - Fastest, recommended for most projects
  • gemini-pro - Balanced performance and quality
  • gemini-ultra - Highest quality, slower
Resolution order:
  1. --model CLI argument
  2. model in TOML config file
  3. Default: "gemini-3.1-flash-lite-preview"

Output Path

output
string
default:"README.md"
Sources: CLI --output, TOML output keyPath where the generated documentation will be written.
  • Relative paths are resolved from the project directory
  • Absolute paths are used as-is
  • Parent directories are created automatically
Resolution order:
  1. --output (or -o) CLI argument
  2. output in TOML config file
  3. Default: "README.md"

Custom Prompt

prompt
string
Source: CLI --prompt onlyAdditional instructions for the AI to customize the generated documentation.This parameter is only available via CLI (not TOML) as it’s typically unique per-generation.

Complete Configuration Examples

Example 1: Personal Development Setup

~/.config/docugen/config.toml:
[docugen]
model = "gemini-pro"
output = "README.md"
~/.zshrc or ~/.bashrc:
export GEMINI_API_KEY="your-api-key-here"
Usage:
# Uses your personal config and API key
docugen generate .

Example 2: Project-Specific Configuration

Project structure:
my_project/
├── .env
├── .docugen.toml
├── .gitignore
└── src/
.env:
GEMINI_API_KEY=project-specific-key
.docugen.toml:
model = "gemini-ultra"
output = "docs/API_REFERENCE.md"
.gitignore:
.env
Usage:
cd my_project
docugen generate ./src
# Generates: my_project/docs/API_REFERENCE.md
# Uses: gemini-ultra model and project-specific API key

Example 3: Team Shared Configuration

Committed to repository: .docugen.toml:
# Team defaults
model = "gemini-pro"
output = "docs/README.md"
.env.example:
# Copy to .env and add your key
GEMINI_API_KEY=your-key-here
.gitignore:
.env
Each developer creates their own .env:
cp .env.example .env
# Edit .env with your personal API key

Example 4: Override Everything via CLI

# CLI arguments override all configuration files
docugen generate ./src \
  --config /custom/config.toml \
  --model gemini-pro \
  --output /tmp/docs.md \
  --prompt "Focus on async patterns"

Troubleshooting

Error: Missing GEMINI_API_KEY (set it in environment or .env).Solutions:
  1. Set the environment variable:
    export GEMINI_API_KEY="your-key"
    
  2. Create a .env file in your project directory:
    echo 'GEMINI_API_KEY=your-key' > .env
    
  3. Verify the variable is set:
    echo $GEMINI_API_KEY
    
Issue: DocuGen isn’t using your TOML configuration.Check:
  1. Verify the file exists in one of the search locations:
    ls -la .docugen.toml
    ls -la ~/.config/docugen/config.toml
    ls -la ~/.docugen.toml
    
  2. Check for TOML syntax errors:
    # Invalid TOML will be silently ignored
    # Verify syntax at: https://www.toml-lint.com/
    
  3. Specify explicitly:
    docugen generate . --config ./path/to/config.toml
    
Issue: Environment variables from .env aren’t being used.Solutions:
  1. Verify file location:
    ls -la .env
    
  2. Check file format (no spaces around =):
    cat .env
    # Correct: GEMINI_API_KEY=value
    # Wrong:   GEMINI_API_KEY = value
    
  3. Specify explicitly:
    export DOCUGEN_DOTENV="./path/to/.env"
    

Best Practices

Use .env for Secrets

Store API keys in .env files and add them to .gitignore. Never commit secrets to version control.

Use TOML for Defaults

Set project or user defaults in TOML files. Commit project configs (without secrets) to share with team.

Use CLI for Overrides

Override defaults with CLI arguments for one-off customizations or testing.

Document for Teams

Include .env.example and .docugen.toml in your repository to help team members get started quickly.

Build docs developers (and LLMs) love