fix: remove mandatory API key check and add LLM gateway support#16
Conversation
Closes #13, Closes #15 - Change API key validation from hard error to warning (fixes #13) - Add LLM_API_KEY, OPENROUTER_API_KEY, OPENAI_BASE_URL support - Add LLM Gateway configuration docs for OpenRouter, LiteLLM, Together AI, NVIDIA NIM, Ollama (fixes #15) - Add OPENAI_BASE_URL to workflow templates - Update help output with new environment variables - Add packages/ to .gitignore
There was a problem hiding this comment.
Pull request overview
This PR updates the Docker entrypoint and documentation to make LLM API keys optional (warning-only) and to document/configure OpenAI-compatible “LLM gateway” usage via OPENAI_BASE_URL, addressing requests to support free/local models and gateway providers.
Changes:
- Downgrade Docker-mode LLM API key validation from a hard error to a warning; expand help text to mention gateway/key env vars.
- Add “Using LLM Gateways” documentation (EN + ZH) with example
OPENAI_BASE_URLvalues for common gateways. - Update workflow templates to include commented
OPENAI_BASE_URLand ignorepackages/in git.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
entrypoint.sh |
Removes mandatory LLM key check; adds warning + help output for gateway-related env vars. |
README.md |
Adds LLM gateway usage section and updates secrets table. |
README_zh.md |
Adds Chinese LLM gateway docs and updates secrets table. |
templates/workflow-docker.yaml |
Documents optional OPENAI_BASE_URL in the Docker workflow template. |
templates/workflow-source.yaml |
Documents optional OPENAI_BASE_URL in the source workflow template. |
.gitignore |
Ignores packages/ directory. |
| # Warn if no LLM API key is set (not fatal - some providers don't need one) | ||
| if [ -z "$DEEPSEEK_API_KEY" ] && [ -z "$ANTHROPIC_API_KEY" ] && \ | ||
| [ -z "$OPENAI_API_KEY" ] && [ -z "$LLM_API_KEY" ] && \ | ||
| [ -z "$OPENROUTER_API_KEY" ] && [ -z "$OPENAI_BASE_URL" ]; then | ||
| log_warn "No LLM API key detected (DEEPSEEK_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY, LLM_API_KEY, OPENROUTER_API_KEY)" | ||
| log_warn "If you are using a local model or custom gateway, you can ignore this warning" | ||
| log_warn "Set OPENAI_BASE_URL to use an OpenAI-compatible gateway (LiteLLM, OpenRouter, etc.)" |
There was a problem hiding this comment.
The warning message can be misleading when no keys are set because the script will still default to MODEL=deepseek/deepseek-chat (see print_config) which typically requires DEEPSEEK_API_KEY. Consider adjusting the warning to explicitly say that if you keep the default model you still need the corresponding provider key, otherwise set MODEL to a local/gateway-backed provider and/or OPENAI_BASE_URL.
| # Warn if no LLM API key is set (not fatal - some providers don't need one) | |
| if [ -z "$DEEPSEEK_API_KEY" ] && [ -z "$ANTHROPIC_API_KEY" ] && \ | |
| [ -z "$OPENAI_API_KEY" ] && [ -z "$LLM_API_KEY" ] && \ | |
| [ -z "$OPENROUTER_API_KEY" ] && [ -z "$OPENAI_BASE_URL" ]; then | |
| log_warn "No LLM API key detected (DEEPSEEK_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY, LLM_API_KEY, OPENROUTER_API_KEY)" | |
| log_warn "If you are using a local model or custom gateway, you can ignore this warning" | |
| log_warn "Set OPENAI_BASE_URL to use an OpenAI-compatible gateway (LiteLLM, OpenRouter, etc.)" | |
| # Warn if no LLM API key or OpenAI-compatible base URL is set | |
| if [ -z "$DEEPSEEK_API_KEY" ] && [ -z "$ANTHROPIC_API_KEY" ] && \ | |
| [ -z "$OPENAI_API_KEY" ] && [ -z "$LLM_API_KEY" ] && \ | |
| [ -z "$OPENROUTER_API_KEY" ] && [ -z "$OPENAI_BASE_URL" ]; then | |
| log_warn "No LLM API key or OPENAI_BASE_URL detected (DEEPSEEK_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY, LLM_API_KEY, OPENROUTER_API_KEY)" | |
| log_warn "If you keep the default MODEL=deepseek/deepseek-chat, you still need the corresponding provider key (typically DEEPSEEK_API_KEY)" | |
| log_warn "Only ignore this warning if you set MODEL to a local/gateway-backed provider and/or set OPENAI_BASE_URL for an OpenAI-compatible gateway (LiteLLM, OpenRouter, etc.)" |
| # Point MODEL to an OpenAI-compatible provider | ||
| MODEL: openai/your-model-name | ||
| OPENAI_API_KEY: ${{ secrets.YOUR_API_KEY }} | ||
| # Set the gateway URL | ||
| OPENAI_BASE_URL: "https://openrouter.ai/api/v1" # OpenRouter | ||
| # OPENAI_BASE_URL: "http://localhost:4000/v1" # LiteLLM |
There was a problem hiding this comment.
In the gateway example, the snippet uses OPENAI_API_KEY, but the OpenRouter row below says to use OPENROUTER_API_KEY. This is inconsistent and may confuse users (and the default workflow templates only pass OPENAI_API_KEY). Please align the docs to one env var scheme (either document OpenRouter as OPENAI_API_KEY with OPENAI_BASE_URL, or add OPENROUTER_API_KEY consistently to secrets/workflow examples if it’s actually supported).
| | `OPENCODE_GIT_TOKEN` | Gitea API Token (requires repo permissions) | | ||
| | `DEEPSEEK_API_KEY` | DeepSeek API Key (default model) | | ||
| | `ANTHROPIC_API_KEY` | Anthropic API Key (optional) | | ||
| | `OPENAI_API_KEY` | OpenAI API Key (optional) | |
There was a problem hiding this comment.
The secrets table doesn’t mention OPENROUTER_API_KEY (or other gateway-specific keys), but the new gateway section later instructs users to use OPENROUTER_API_KEY. Either add the referenced secret(s) here or update the later section to use the keys that are already documented.
| | `OPENAI_API_KEY` | OpenAI API Key (optional) | | |
| | `OPENAI_API_KEY` | OpenAI API Key (optional) | | |
| | `OPENROUTER_API_KEY` | OpenRouter API Key (optional, for LLM gateway usage) | |
| # 将 MODEL 指向 OpenAI 兼容的 provider | ||
| MODEL: openai/your-model-name | ||
| OPENAI_API_KEY: ${{ secrets.YOUR_API_KEY }} | ||
| # 设置网关 URL | ||
| OPENAI_BASE_URL: "https://openrouter.ai/api/v1" # OpenRouter | ||
| # OPENAI_BASE_URL: "http://localhost:4000/v1" # LiteLLM |
There was a problem hiding this comment.
在网关示例中,代码块里使用的是 OPENAI_API_KEY,但下面 OpenRouter 的备注却写的是使用 OPENROUTER_API_KEY。这两处不一致容易让用户配置错(而默认 workflow 模板也只传了 OPENAI_API_KEY)。建议统一文档:要么说明 OpenRouter 也用 OPENAI_API_KEY + OPENAI_BASE_URL,要么在 secrets / workflow 示例中一致地加入 OPENROUTER_API_KEY(如果确实被支持)。
| | `OPENCODE_GIT_TOKEN` | Gitea API Token(需要 repo 权限) | | ||
| | `DEEPSEEK_API_KEY` | DeepSeek API Key(默认模型) | | ||
| | `ANTHROPIC_API_KEY` | Anthropic API Key(可选) | | ||
| | `OPENAI_API_KEY` | OpenAI API Key(可选) | |
There was a problem hiding this comment.
Secrets 表里没有列出 OPENROUTER_API_KEY(或其他网关相关的 key),但后面的网关章节又要求使用 OPENROUTER_API_KEY。建议要么在这里补充对应的 secret,要么把后面章节改成使用这里已说明的 key。
| | `OPENAI_API_KEY` | OpenAI API Key(可选) | | |
| | `OPENAI_API_KEY` | OpenAI API Key(可选) | | |
| | `OPENROUTER_API_KEY` | OpenRouter API Key(使用 LLM 网关时可选) | |
Summary
OPENAI_BASE_URLenvironment variable.Changes
entrypoint.shLLM_API_KEY,OPENROUTER_API_KEY,OPENAI_BASE_URLrecognition; update help textREADME.mdREADME_zh.mdtemplates/workflow-docker.yamlOPENAI_BASE_URLenv vartemplates/workflow-source.yamlOPENAI_BASE_URLenv var.gitignorepackages/directory