Skip to content

Getting Started

Installation

Install PatchPal from PyPI:

pip install patchpal

Optional Features: PatchPal has optional dependencies for additional functionality:

# Browser automation (14 additional tools for interactive web tasks)
pip install patchpal[browser]
python -m playwright install chromium

See Built-In Tools for details on browser automation features.

Supported Operating Systems: Linux, MacOS, MS Windows.

Alternative: Run with Docker/Podman (no installation required)

If you prefer to use containers instead of installing PatchPal locally:

Option 1: Using patchpal-sandbox (Easiest)

After installing PatchPal (pip install patchpal), use the patchpal-sandbox command for automatic container setup:

# Interactive mode (any [LiteLLM-supported model](https://models.litellm.ai/) can be used)
patchpal-sandbox -- --model openai/gpt-5-mini

# With environment file
patchpal-sandbox --env-file .env -- --model anthropic/claude-sonnet-4-5

# Autopilot mode (for autonomous iterative development - see Autopilot docs)
patchpal-sandbox --env-file .env -- autopilot --prompt "..." --model anthropic/claude-sonnet-4-5

The patchpal-sandbox command automatically: - Auto-detects Docker/Podman - Mounts current directory and ~/.patchpal - Loads API keys from .env file or environment - Uses pre-built image (fast startup) - Default: permissions enabled for interactive mode; disabled for autopilot mode

Option 2: Manual Docker/Podman Commands

# Using Docker with pre-built image (default model)
docker run -it --rm \
  -v $(pwd):/workspace \
  -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
  ghcr.io/amaiya/patchpal-sandbox:latest \
  patchpal --model anthropic/claude-sonnet-4-5

# Or with Podman
podman run -it --rm \
  -v $(pwd):/workspace \
  -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
  ghcr.io/amaiya/patchpal-sandbox:latest \
  patchpal --model anthropic/claude-sonnet-4-5

# Specify a different model
docker run -it --rm \
  -v $(pwd):/workspace \
  -e OPENAI_API_KEY=$OPENAI_API_KEY \
  ghcr.io/amaiya/patchpal-sandbox:latest \
  patchpal --model openai/gpt-5-mini

This runs PatchPal in an isolated container with: - PatchPal pre-installed (no pip install needed) - Current directory mounted at /workspace - Your API key passed through environment variable - For other models, pass additional -e flags (e.g., -e OPENAI_API_KEY=$OPENAI_API_KEY) - Pass patchpal arguments after patchpal command (e.g., patchpal --model openai/gpt-4o-mini, patchpal --autopilot)

Setup

  1. Get an API key or a Local LLM Engine:
  2. [Cloud] For Anthropic models (default): Sign up at https://console.anthropic.com/
  3. [Cloud] For OpenAI models: Get a key from https://platform.openai.com/
  4. [Local] For vLLM: Install from https://docs.vllm.ai/ (free - no API charges)
  5. [Local] For Ollama: Install from https://ollama.com/ (⚠️ set OLLAMA_CONTEXT_LENGTH, e.g., 16384 or 32768 - see Ollama section below)
  6. [Local] Not sure which local engine to use (vLLM, Ollama, PolyStrata, llama.cpp, ...)? See Choosing an Inference Engine
  7. For other providers: Check the LiteLLM documentation

  8. Set up your API key as environment variable:

    # For Anthropic (default)
    export ANTHROPIC_API_KEY=your_api_key_here
    
    # For OpenAI
    export OPENAI_API_KEY=your_api_key_here
    
    # For vLLM - API key required only if configured
    export HOSTED_VLLM_API_BASE=http://localhost:8000 # depends on your vLLM setup
    export HOSTED_VLLM_API_KEY=token-abc123           # optional depending on your vLLM setup
    
    # No API required for Ollama.
    
    # For other providers, check LiteLLM docs
    

  9. Run PatchPal:

    # Use default model (anthropic/claude-sonnet-4-5)
    patchpal
    
    # Use a specific model via command-line argument
    patchpal --model openai/gpt-5.2-codex  # or openai/gpt-5-mini, anthropic/claude-opus-4-5, etc.
    
    # Use vLLM (local)
    # Note: vLLM server must be started with --tool-call-parser and --enable-auto-tool-choice
    export HOSTED_VLLM_API_BASE=http://localhost:8000
    export HOSTED_VLLM_API_KEY=token-abc123
    patchpal --model hosted_vllm/openai/gpt-oss-120b
    
    # Use Ollama (local - set OLLAMA_CONTEXT_LENGTH and PATCHPAL_CONTEXT_LIMIT to the same window)
    export OLLAMA_CONTEXT_LENGTH=16384 # or set the context length in the Ollama app's Settings
    PATCHPAL_CONTEXT_LIMIT=16384 patchpal --model ollama_chat/gemma4:e4b
    
    # Use any OpenAI-compatible server (e.g., PolyStrata, llama.cpp, LM Studio) - include /v1 in the URL
    # OPENAI_API_KEY can be any non-empty value if the server doesn't check keys
    OPENAI_API_BASE=http://127.0.0.1:8080/v1 OPENAI_API_KEY=dummy PATCHPAL_CONTEXT_LIMIT=32768 \
      patchpal --model openai/<served-model-name>
    
    # Or set the model via environment variable
    export PATCHPAL_MODEL=anthropic/claude-opus-4-5
    patchpal
    

Tip for Local Models: Local models (i.e., models served by Ollama or vLLM) work best with these settings:

  • Always: set PATCHPAL_CONTEXT_LIMIT to your served window (e.g., 32768 to match OLLAMA_CONTEXT_LENGTH=32768, or 16384 on resource-constrained machines). PatchPal can't detect it from the server. At 64K or less, PatchPal uses TinyAgent, which includes minimal tools plus small-window compaction and reading.
  • Model with function calling, window over 64K: PATCHPAL_MINIMAL_TOOLS=true limits tools to read_file, read_lines, write_file, edit_file, run_shell, reducing tool confusion.
  • Model without function calling: PATCHPAL_REACT_MODE=true enables text-based tool invocation (see ReAct mode docs).
  • Ollama: PATCHPAL_STREAM_OUTPUT=false was a workaround for unreliable streamed tool calls. PatchPal now handles Ollama's streamed tool calls correctly, so this may no longer be needed; try it if tool calls still fail.
  • Offline: PATCHPAL_ENABLE_WEB=false disables web tools.