fix: add OPENROUTER_API_KEY to LiteLLM container env#287
fix: add OPENROUTER_API_KEY to LiteLLM container env#287sheepdestroyer wants to merge 3 commits into
Conversation
The LiteLLM gateway container was missing OPENROUTER_API_KEY in its environment, causing all OpenRouter free model requests to fail with 'Missing Authentication header' (401). This cascaded through the fallback chain and eventually produced 429 errors for the llm-routing-auto-free routing model. Added OPENROUTER_API_KEY_PLACEHOLDER to pod.yaml LiteLLM container env and the corresponding placeholder rendering in start-stack.sh. Verified: 24/24 canonical endpoints pass in dev environment. Tested: llm-routing-auto-free chat completion succeeds (not 429).
There was a problem hiding this comment.
Sorry @sheepdestroyer, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Warning Review limit reached
Next review available in: 32 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe LiteLLM Gateway pod now declares an OpenRouter API key placeholder. ChangesOpenRouter API key configuration
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request adds support for the OPENROUTER_API_KEY environment variable across pod.yaml and start-stack.sh. The feedback suggests refactoring the extremely long export statement in start-stack.sh into multiple lines to improve readability and prevent merge conflicts.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| render_pod_yaml() { | ||
| export WORKDIR HOME LITELLM_MASTER_KEY UI_USERNAME UI_PASSWORD POSTGRES_PASSWORD NEXTAUTH_SECRET SALT ENCRYPTION_KEY LANGFUSE_INIT_USER_PASSWORD MINIO_ROOT_USER MINIO_ROOT_PASSWORD OLLAMA_API_KEY LANGFUSE_PUBLIC_KEY LANGFUSE_SECRET_KEY CLASSIFIER_INPUT_MAX_CHARS REDIS_AUTH CLICKHOUSE_PASSWORD PUBLIC_BASE_URL ROUTING_DOMAIN POD_NAME DATA_ROOT ROUTER_IMAGE ROUTER_PORT LITELLM_PORT LANGFUSE_WEB_PORT LANGFUSE_WORKER_PORT POSTGRES_PORT VALKEY_CACHE_PORT VALKEY_LF_PORT CLICKHOUSE_HTTP_PORT CLICKHOUSE_TCP_PORT CLICKHOUSE_INTERSERVER_PORT MINIO_S3_PORT MINIO_CONSOLE_PORT | ||
| export WORKDIR HOME LITELLM_MASTER_KEY UI_USERNAME UI_PASSWORD POSTGRES_PASSWORD NEXTAUTH_SECRET SALT ENCRYPTION_KEY LANGFUSE_INIT_USER_PASSWORD MINIO_ROOT_USER MINIO_ROOT_PASSWORD OLLAMA_API_KEY OPENROUTER_API_KEY LANGFUSE_PUBLIC_KEY LANGFUSE_SECRET_KEY CLASSIFIER_INPUT_MAX_CHARS REDIS_AUTH CLICKHOUSE_PASSWORD PUBLIC_BASE_URL ROUTING_DOMAIN POD_NAME DATA_ROOT ROUTER_IMAGE ROUTER_PORT LITELLM_PORT LANGFUSE_WEB_PORT LANGFUSE_WORKER_PORT POSTGRES_PORT VALKEY_CACHE_PORT VALKEY_LF_PORT CLICKHOUSE_HTTP_PORT CLICKHOUSE_TCP_PORT CLICKHOUSE_INTERSERVER_PORT MINIO_S3_PORT MINIO_CONSOLE_PORT |
There was a problem hiding this comment.
The export statement has grown extremely long (over 500 characters), making it difficult to read, maintain, and prone to merge conflicts. Consider splitting it into multiple lines using backslashes to improve readability and maintainability.
export \
WORKDIR \
HOME \
LITELLM_MASTER_KEY \
UI_USERNAME \
UI_PASSWORD \
POSTGRES_PASSWORD \
NEXTAUTH_SECRET \
SALT \
ENCRYPTION_KEY \
LANGFUSE_INIT_USER_PASSWORD \
MINIO_ROOT_USER \
MINIO_ROOT_PASSWORD \
OLLAMA_API_KEY \
OPENROUTER_API_KEY \
LANGFUSE_PUBLIC_KEY \
LANGFUSE_SECRET_KEY \
CLASSIFIER_INPUT_MAX_CHARS \
REDIS_AUTH \
CLICKHOUSE_PASSWORD \
PUBLIC_BASE_URL \
ROUTING_DOMAIN \
POD_NAME \
DATA_ROOT \
ROUTER_IMAGE \
ROUTER_PORT \
LITELLM_PORT \
LANGFUSE_WEB_PORT \
LANGFUSE_WORKER_PORT \
POSTGRES_PORT \
VALKEY_CACHE_PORT \
VALKEY_LF_PORT \
CLICKHOUSE_HTTP_PORT \
CLICKHOUSE_TCP_PORT \
CLICKHOUSE_INTERSERVER_PORT \
MINIO_S3_PORT \
MINIO_CONSOLE_PORTThere was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@start-stack.sh`:
- Line 616: Validate that OPENROUTER_API_KEY is non-empty before the export and
rendering flow in start-stack.sh, failing immediately with a clear error when it
is blank. Preserve the existing export behavior for valid values and apply the
same validation at the corresponding second occurrence.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
The 5 static entries (agent-simple-core through agent-advanced-core) were safety nets that defined hardcoded OpenRouter :free models, including 3 Google models (gemma-4-31b, gemma-4-26b) that frequently hit quota limits. The dynamic roster sync (router/main.py) already registers 31+ AA-scored free models at startup via LiteLLM's /model/new API. This is the sole source of truth for agent tier deployments now. Removing the static entries eliminates Google models that were polluting the routing pool alongside the dynamic roster. Also applies the OPENROUTER_API_KEY fix from the same branch. Tested: 101/101 pytest, 23/24 canonical endpoints (1 timeout is pre-existing — free model rate limits)
Per Gemini Code Assist review: the 500+ character export statement was hard to read and prone to merge conflicts. Split into one var per line with backslash continuations. CodeRabbit's suggestion to add OPENROUTER_API_KEY non-empty check is already handled at lines 127-152 — the script exits before reaching this function if the key is empty.
|
Closing in favor of a fresh PR with all review fixes applied and consolidated commits. |
Problem
The LiteLLM gateway container was missing
OPENROUTER_API_KEYin its environment. This caused all OpenRouter free model requests to fail withMissing Authentication header(401), which cascaded through the fallback chain and eventually produced 429 errors for thellm-routing-auto-freerouting model.Root Cause
pod.yamldefinedOLLAMA_API_KEYand other secrets for the LiteLLM container, butOPENROUTER_API_KEYwas never added. Sincestart-stack.shrequires the key and uses it for the router (via .env sourcing), the value already exists in.env— it just wasn't being rendered into the LiteLLM container's environment.Fix
OPENROUTER_API_KEY_PLACEHOLDERtopod.yamlLiteLLM container env blockOPENROUTER_API_KEYto the export list inrender_pod_yaml()start-stack.shVerification
llm-routing-auto-freechat completion test succeeds (was 429 before fix)Summary by CodeRabbit