mirror of
https://github.com/pocketpaw/pocketpaw.git
synced 2026-05-21 09:14:59 +00:00
* feat: add LiteLLM provider support and unified env resolution Add LiteLLM as a provider option for all backends (Claude SDK, OpenAI Agents, Google ADK, Copilot SDK), enabling access to 100+ LLM providers including HuggingFace, Ollama, vLLM, Together AI, Groq, Mistral, and more through a single proxy or direct SDK integration. Key changes: - New config fields: litellm_api_base, litellm_api_key, litellm_model - OpenAI Agents: native LitellmModel extension with proxy fallback - Google ADK: LiteLlm model wrapper for cross-provider support - Claude SDK: routes through LiteLLM proxy via ANTHROPIC_BASE_URL - Copilot SDK: LiteLLM via OpenAI-compatible BYOK config - resolve_backend_env() pushes unified POCKETPAW_* keys to env vars each SDK expects, fixing the issue where switching backends required manually reconfiguring environment variables * fix: complete LiteLLM integration across dashboard, health checks, and WS - Fix health check false warning: add 'litellm' to provider skip list in check_api_key_primary() for Claude SDK, OpenAI Agents, and Google ADK backends - Add google_adk_provider to WS settings handler and broadcast - Add litellm_api_base, litellm_api_key, litellm_model to WS handler - Add 'LiteLLM (100+ Providers)' option to provider dropdowns in settings UI for Claude SDK and OpenAI Agents backends - Add LiteLLM config fields (proxy URL, API key, model) shown when litellm provider is selected in the settings modal * fix: add LiteLLM provider to Copilot SDK and Google ADK settings UI - Add LiteLLM option to Copilot SDK provider dropdown - Add provider dropdown to Google ADK settings (was missing entirely) - Add LiteLLM config fields (proxy URL, API key, model) for Google ADK when litellm provider is selected * fix: sync env vars at runtime when API keys change via dashboard resolve_backend_env() now accepts force=True to overwrite existing env vars. Called after every settings/API-key save so backends immediately see updated keys without a restart. Codex CLI subprocess gets an explicit env snapshot via env=os.environ.copy(). * refactor: provider adapter pattern for LLM providers Extract provider-specific logic (config resolution, client creation, env var setup, error formatting) into adapter classes under llm/providers/. Six adapters: Anthropic, Ollama, OpenAICompatible, OpenRouter, Gemini, LiteLLM. LLMClient delegates to adapters internally while keeping its public API stable. Backends (OpenAI Agents, Google ADK, Copilot SDK) now use adapters directly, replacing 70+ line if/elif chains with ~5 line adapter calls. Adding a new provider means adding one adapter file and registering it, no backend changes needed. 30 new tests for adapters, registry, model resolution, and LLMClient delegation. * fix: _stderr_lines UnboundLocalError and test_fast_path failures Move _stderr_lines initialization before the try block so the except handler can always access it. Add missing _HookMatcher and is_litellm to test mocks. * style: format test files and fix UP038 lint * docs: add Discord deployment config with multi-provider support Add Docker Compose, Dockerfile, env example, and identity files for headless Discord bot deployment. Supports direct Anthropic, LiteLLM proxy, OpenAI-compatible, and OpenAI Agents backends out of the box. * chore: remove Discord deploy files (moved to separate PR #597) Deploy config now lives under deploy/discord/ in the deploy/discord-docker branch to keep this PR focused on the provider adapter pattern and LiteLLM integration. * fix: LiteLLM max_tokens setting, config persistence, and health recheck - Add litellm_max_tokens config option so users can cap output tokens for models like DeepSeek (8192 limit) - Fix LiteLLM settings not persisting on reload: litellmApiBase, litellmModel, litellmMaxTokens were missing from SETTINGS_MAP in app.js, so the frontend never loaded them back from the server - Also add 13 other missing backend settings to SETTINGS_MAP (openaiAgentsModel, googleAdkProvider, codexCliModel, etc.) - Re-run health checks after settings save so switching to LiteLLM immediately clears the "no Anthropic API key" degraded warning - Claude SDK fast-path respects provider max_tokens instead of hardcoding 1024 * fix: LiteLLM proxy routing, adapter bugs, and remove plan docs - Fix LiteLLM + OpenAI Agents: use OpenAI-compat proxy path when base_url is set instead of native LitellmModel which tried to route directly (causing Vertex AI credential errors) - Fix operator precedence in _to_provider_config() base_url resolution - Fix dashboard unable to clear LiteLLM API key (falsy vs None check) - Fix fragile hasattr duck-typing in openai_agents, add explicit provider == "litellm" guard - Replace unnecessary getattr() with direct attribute access in google_adk now that the field exists in Settings - Pass api_key and base_url to ADK LiteLlm wrapper explicitly - Remove plan design doc * docs: add OpenRouter and LiteLLM provider documentation - Add dedicated OpenRouter and LiteLLM sections to LLM providers guide with configuration examples for proxy vs direct SDK mode - Update backend compatibility matrix to include both new providers - Update per-backend provider tables (Claude SDK, OpenAI Agents, Google ADK, Copilot SDK) with LiteLLM and OpenRouter support - Add OpenRouter and LiteLLM config fields to configuration reference - Update getting-started configuration with OpenRouter and LiteLLM environment variable examples - Replace OpenRouter-only section in backends index with combined OpenRouter + LiteLLM section
194 lines
6.2 KiB
Plaintext
194 lines
6.2 KiB
Plaintext
---
|
|
title: "Configure PocketPaw: Env Variables, API Keys & Settings"
|
|
description: "Complete guide to configuring PocketPaw: environment variables with POCKETPAW_ prefix, JSON config file, API keys, channel tokens, tool profiles, and memory settings."
|
|
section: Getting Started
|
|
ogType: article
|
|
keywords: ["environment variables", "config file", "settings", "api keys", "pocketpaw prefix"]
|
|
tags: ["configuration", "settings"]
|
|
---
|
|
|
|
# Configure PocketPaw: Env Variables, API Keys & Settings
|
|
|
|
PocketPaw uses a layered configuration system built on Pydantic Settings.
|
|
|
|
## Configuration Sources
|
|
|
|
Configuration is loaded from these sources (in order of precedence):
|
|
|
|
1. **Environment variables** — Prefixed with `POCKETPAW_`
|
|
2. **Config file** — `~/.pocketpaw/config.json`
|
|
3. **Web dashboard** — Settings saved through the UI
|
|
|
|
## API Key Requirement
|
|
|
|
<Callout type="warning">
|
|
**Anthropic API key required for Claude SDK backend.** Anthropic's [authentication policy](https://code.claude.com/docs/en/legal-and-compliance#authentication-and-credential-use) prohibits third-party applications from using OAuth tokens from Free/Pro/Max plans. PocketPaw requires an API key from [console.anthropic.com](https://console.anthropic.com/settings/keys). This does not apply when using Ollama or other local providers.
|
|
</Callout>
|
|
|
|
## Environment Variables
|
|
|
|
All settings use the `POCKETPAW_` prefix:
|
|
|
|
```bash
|
|
# Core
|
|
export POCKETPAW_ANTHROPIC_API_KEY="sk-ant-..." # Required for Claude SDK backend
|
|
export POCKETPAW_OPENAI_API_KEY="sk-..."
|
|
export POCKETPAW_AGENT_BACKEND="claude_agent_sdk" # or openai_agents, google_adk, codex_cli, opencode, copilot_sdk
|
|
|
|
# Claude SDK settings (only when agent_backend=claude_agent_sdk)
|
|
export POCKETPAW_CLAUDE_SDK_MODEL="" # empty = auto (recommended)
|
|
export POCKETPAW_CLAUDE_SDK_MAX_TURNS=25 # max tool-use loops per query
|
|
|
|
# Ollama (local models, no API key needed)
|
|
export POCKETPAW_LLM_PROVIDER="ollama" # auto, anthropic, openai, ollama, openrouter, litellm
|
|
export POCKETPAW_OLLAMA_HOST="http://localhost:11434"
|
|
export POCKETPAW_OLLAMA_MODEL="qwen2.5:7b"
|
|
|
|
# OpenRouter (100+ models, pay-per-token)
|
|
export POCKETPAW_LLM_PROVIDER="openrouter"
|
|
export POCKETPAW_OPENROUTER_API_KEY="sk-or-v1-..."
|
|
export POCKETPAW_OPENROUTER_MODEL="anthropic/claude-sonnet-4-6"
|
|
|
|
# LiteLLM (100+ providers via proxy)
|
|
export POCKETPAW_LLM_PROVIDER="litellm"
|
|
export POCKETPAW_LITELLM_API_BASE="http://localhost:4000"
|
|
export POCKETPAW_LITELLM_API_KEY="sk-..."
|
|
export POCKETPAW_LITELLM_MODEL="gpt-4o"
|
|
|
|
# Web Dashboard
|
|
export POCKETPAW_WEB_PORT=8888
|
|
export POCKETPAW_WEB_HOST="0.0.0.0"
|
|
|
|
# Telegram
|
|
export POCKETPAW_TELEGRAM_TOKEN="your-bot-token"
|
|
export POCKETPAW_ALLOWED_TELEGRAM_IDS="123456,789012"
|
|
|
|
# Discord
|
|
export POCKETPAW_DISCORD_BOT_TOKEN="your-discord-token"
|
|
export POCKETPAW_DISCORD_ALLOWED_GUILD_IDS="111,222"
|
|
export POCKETPAW_DISCORD_ALLOWED_USER_IDS="333,444"
|
|
|
|
# Slack
|
|
export POCKETPAW_SLACK_BOT_TOKEN="xoxb-..."
|
|
export POCKETPAW_SLACK_APP_TOKEN="xapp-..."
|
|
export POCKETPAW_SLACK_ALLOWED_CHANNEL_IDS="C01,C02"
|
|
|
|
# WhatsApp Business
|
|
export POCKETPAW_WHATSAPP_ACCESS_TOKEN="your-token"
|
|
export POCKETPAW_WHATSAPP_PHONE_NUMBER_ID="123456"
|
|
export POCKETPAW_WHATSAPP_VERIFY_TOKEN="your-verify-token"
|
|
export POCKETPAW_WHATSAPP_ALLOWED_PHONE_NUMBERS="+1234567890"
|
|
|
|
# WhatsApp Personal
|
|
export POCKETPAW_WHATSAPP_MODE="personal" # or "business"
|
|
|
|
# Signal
|
|
export POCKETPAW_SIGNAL_API_URL="http://localhost:8080"
|
|
export POCKETPAW_SIGNAL_PHONE_NUMBER="+1234567890"
|
|
|
|
# Matrix
|
|
export POCKETPAW_MATRIX_HOMESERVER="https://matrix.org"
|
|
export POCKETPAW_MATRIX_USER_ID="@bot:matrix.org"
|
|
export POCKETPAW_MATRIX_ACCESS_TOKEN="your-token"
|
|
|
|
# Microsoft Teams
|
|
export POCKETPAW_TEAMS_APP_ID="your-app-id"
|
|
export POCKETPAW_TEAMS_APP_PASSWORD="your-password"
|
|
|
|
# Google Chat
|
|
export POCKETPAW_GCHAT_PROJECT_ID="your-project-id"
|
|
export POCKETPAW_GCHAT_SERVICE_ACCOUNT_KEY="/path/to/key.json"
|
|
```
|
|
|
|
## Config File
|
|
|
|
The JSON config file at `~/.pocketpaw/config.json` stores all settings:
|
|
|
|
```json
|
|
{
|
|
"anthropic_api_key": "sk-ant-...",
|
|
"agent_backend": "claude_agent_sdk",
|
|
"claude_sdk_model": "",
|
|
"claude_sdk_max_turns": 25,
|
|
"llm_provider": "auto",
|
|
"ollama_host": "http://localhost:11434",
|
|
"ollama_model": "llama3.2",
|
|
"tool_profile": "coding",
|
|
"tools_allow": [],
|
|
"tools_deny": [],
|
|
"smart_routing_enabled": false,
|
|
"web_search_provider": "tavily",
|
|
"tavily_api_key": "tvly-...",
|
|
"mem0_auto_learn": true,
|
|
"mem0_llm_provider": "ollama",
|
|
"mem0_llm_model": "llama3.2"
|
|
}
|
|
```
|
|
|
|
<Callout type="info">
|
|
**`claude_sdk_model`**: Leave empty (default) to let Claude Code auto-select the best model. Only set this if you want to force a specific model.
|
|
</Callout>
|
|
|
|
## Tool Policy Configuration
|
|
|
|
Control which tools are available via profiles and allow/deny lists:
|
|
|
|
```bash
|
|
# Profile: minimal, coding, or full
|
|
export POCKETPAW_TOOL_PROFILE="coding"
|
|
|
|
# Allow specific tools (comma-separated)
|
|
export POCKETPAW_TOOLS_ALLOW="web_search,image_gen"
|
|
|
|
# Deny specific tools (takes precedence over allow)
|
|
export POCKETPAW_TOOLS_DENY="shell,write_file"
|
|
```
|
|
|
|
See [Tool Policy](/tools/tool-policy) for detailed documentation.
|
|
|
|
## Memory Configuration
|
|
|
|
```bash
|
|
# Mem0 semantic memory
|
|
export POCKETPAW_MEM0_AUTO_LEARN=true
|
|
export POCKETPAW_MEM0_LLM_PROVIDER="ollama" # or anthropic, openai
|
|
export POCKETPAW_MEM0_LLM_MODEL="llama3.2"
|
|
export POCKETPAW_MEM0_EMBEDDER_PROVIDER="ollama" # or openai
|
|
export POCKETPAW_MEM0_EMBEDDER_MODEL="nomic-embed-text"
|
|
export POCKETPAW_MEM0_VECTOR_STORE="qdrant"
|
|
```
|
|
|
|
## Google Integration
|
|
|
|
For Gmail, Calendar, Drive, and Docs:
|
|
|
|
```bash
|
|
export POCKETPAW_GOOGLE_CLIENT_ID="your-client-id"
|
|
export POCKETPAW_GOOGLE_CLIENT_SECRET="your-secret"
|
|
```
|
|
|
|
OAuth tokens are stored in `~/.pocketpaw/tokens/`.
|
|
|
|
## Spotify Integration
|
|
|
|
```bash
|
|
export POCKETPAW_SPOTIFY_CLIENT_ID="your-client-id"
|
|
export POCKETPAW_SPOTIFY_CLIENT_SECRET="your-secret"
|
|
```
|
|
|
|
## Data Directory
|
|
|
|
PocketPaw stores all data in `~/.pocketpaw/`:
|
|
|
|
```
|
|
~/.pocketpaw/
|
|
├── config.json # Configuration file
|
|
├── memory/ # Session history and facts
|
|
├── identity/
|
|
│ └── USER.md # User profile (auto-created)
|
|
├── skills/ # Custom skill definitions
|
|
├── tokens/ # OAuth tokens
|
|
├── audit.jsonl # Security audit log
|
|
└── mcp.json # MCP server configuration
|
|
```
|