Skip to content

feat: litellm config yaml - #369

Merged
yxtay merged 18 commits into
mainfrom
feat/litellm-config-yaml
Jul 28, 2026
Merged

feat: litellm config yaml#369
yxtay merged 18 commits into
mainfrom
feat/litellm-config-yaml

Conversation

@yxtay

@yxtay yxtay commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added LiteLLM configuration supporting multiple model providers and credentials.
    • Added smart routing with adaptive selection, complexity-based tiers, and session affinity.
    • Enabled structured logging, request timeouts, and configurable model storage.
  • Bug Fixes

    • Updated service configuration to reliably load the LiteLLM configuration from a relative path.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@yxtay, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 524dc893-7631-41dc-913d-2576ad9eb92e

📥 Commits

Reviewing files that changed from the base of the PR and between d251cd0 and ace752c.

📒 Files selected for processing (1)
  • agent/litellm/config.yaml
📝 Walkthrough

Walkthrough

LiteLLM now uses a repository-relative configuration mount and a new configuration file defining runtime settings, provider model mappings, smart routing, environment-backed credentials, and an optional guardrail example.

Changes

LiteLLM configuration

Layer / File(s) Summary
Runtime settings and compose wiring
agent/compose.yaml, agent/litellm/config.yaml
The service mounts ./litellm/config.yaml read-only, with LiteLLM runtime, database, timeout, and JSON logging settings.
Model mappings and smart routing
agent/litellm/config.yaml
Provider model mappings and a complexity-based smart-router entry are added with adaptive routing, session affinity, and a default model.
Credential providers and guardrail example
agent/litellm/config.yaml
Environment-backed credentials for three providers are added, along with a commented Headroom guardrail example.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit hops where config paths align,
Through model maps in a routing line.
Credentials whisper from env vars bright,
JSON logs sparkle through the night.
“Hop-hop!” says Bun—LiteLLM takes flight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a LiteLLM config YAML.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/litellm-config-yaml

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ BASH shfmt 11 0 0 0 0.02s
✅ JSON prettier 1 0 0 0 0.39s
✅ MARKDOWN markdownlint 5 0 0 0 0.58s
✅ MARKDOWN markdown-table-formatter 5 0 0 0 0.15s
✅ TERRAFORM terraform-fmt 7 0 0 0 0.33s
✅ YAML prettier 49 0 0 0 0.9s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters BASH_SHFMT,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,TERRAFORM_TERRAFORM_FMT,YAML_PRETTIER

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@yxtay
yxtay merged commit ed5e421 into main Jul 28, 2026
12 of 14 checks passed
@yxtay
yxtay deleted the feat/litellm-config-yaml branch July 28, 2026 03:05

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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 `@agent/compose.yaml`:
- Line 116: Update the bind-mount entry in the Compose service to use the
absolute host source path /apps/litellm/config.yaml while retaining
/app/config.yaml:ro as the container destination and read-only mode.

In `@agent/litellm/config.yaml`:
- Around line 46-57: Declare NOUS_API_KEY= in agent/.env.example, then update
the LiteLLM service environment configuration to require both NOUS_API_KEY and
OPENCODE_ZEN_API_KEY using the ${VAR:?} fail-fast syntax. Ensure the
smart-router credentials resolve through the existing litellm credential
configuration without changing routing behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a6f80e5f-4cdc-4d59-abe7-77d8c61faf00

📥 Commits

Reviewing files that changed from the base of the PR and between 414a3b8 and d251cd0.

📒 Files selected for processing (2)
  • agent/compose.yaml
  • agent/litellm/config.yaml

Comment thread agent/compose.yaml
read_only: true
volumes:
- /apps/litellm/config.yaml:/app/config.yaml:ro
- ./litellm/config.yaml:/app/config.yaml:ro

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep the bind-mount source under /apps/litellm/.

./litellm/config.yaml violates the required host bind-mount layout. Provision the repository config to /apps/litellm/config.yaml and retain that absolute source path.

Proposed fix
-      - ./litellm/config.yaml:/app/config.yaml:ro
+      - /apps/litellm/config.yaml:/app/config.yaml:ro

As per coding guidelines, Docker Compose files must “Use host bind mounts under /apps/<service-name>/ instead of named volumes.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- ./litellm/config.yaml:/app/config.yaml:ro
- /apps/litellm/config.yaml:/app/config.yaml:ro
🤖 Prompt for 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.

In `@agent/compose.yaml` at line 116, Update the bind-mount entry in the Compose
service to use the absolute host source path /apps/litellm/config.yaml while
retaining /app/config.yaml:ro as the container destination and read-only mode.

Source: Coding guidelines

Comment thread agent/litellm/config.yaml
Comment on lines +46 to +57
- model_name: smart-router
litellm_params:
model: auto_router/complexity_router
complexity_router_config:
tiers:
SIMPLE: opencode-zen/deepseek-v4-flash-free
MEDIUM: opencode-zen/deepseek-v4-flash-free
COMPLEX: nous/hy3:free
REASONING: nous/hy3:free
adaptive: true
session_affinity: true
complexity_router_default_model: nous/hy3:free

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C2 'NOUS_API_KEY|OPENCODE_ZEN_API_KEY' \
  agent/.env.example agent/compose.yaml agent/litellm/config.yaml

Repository: yxtay/docker-stacks

Length of output: 993


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files agent | sed -n '1,200p'

echo "== relevant env/compose/config excerpts =="
for f in agent/.env.example agent/compose.yaml agent/litellm/config.yaml agent/Dockerfile* Dockerfile* compose.yaml; do
  if [ -f "$f" ]; then
    echo "--- $f"
    wc -l "$f"
    sed -n '1,140p' "$f"
  fi
done

Repository: yxtay/docker-stacks

Length of output: 6835


🌐 Web query:

LiteLLM config.yaml model custom_base_url os.environ API_KEY credential_values api_key os.environ/NOUS_API_KEY

💡 Result:

In LiteLLM, you can use the os.environ/ prefix within your config.yaml to dynamically load values from environment variables [1][2][3]. This syntax is supported for various configuration fields, ensuring sensitive credentials like API keys are not hardcoded in your configuration files [4][5]. Key mechanisms for using environment variables and custom configurations include: 1. Dynamic Loading with os.environ/ You can reference any environment variable by using the prefix os.environ/ followed by the variable name [3]. When LiteLLM parses the config.yaml, it will call os.getenv() to retrieve the value [2]. Example usage in model_list: model_list: - model_name: my-model litellm_params: model: openai/gpt-4 api_key: os.environ/NOUS_API_KEY # Loads from environment variable NOUS_API_KEY api_base: os.environ/CUSTOM_API_BASE_URL # Example of using it for custom base URL 2. Centralized Credential Management To avoid duplication, you can define shared credentials using the credential_list section and reference them in your model_list using litellm_credential_name [6][7]. Example: model_list: - model_name: my-azure-model litellm_params: model: azure/gpt-4 litellm_credential_name: my_shared_creds credential_list: - credential_name: my_shared_creds credential_values: api_key: os.environ/AZURE_API_KEY api_base: os.environ/AZURE_API_BASE credential_info: description: "Shared credentials" 3. Custom API Base URL The api_base parameter within litellm_params allows you to point to non-default endpoints, such as local gateways (e.g., vLLM) or specific provider regions [8][2]. This field also supports the os.environ/ syntax, enabling flexible configuration across different environments [5]. 4. Important Note on Server Root Path If your goal is to change the base URL path of the LiteLLM Proxy service itself (e.g., serving at /api/v1 instead of the root), you should set the SERVER_ROOT_PATH environment variable in your environment, rather than modifying config.yaml [9]. Never commit your config.yaml to version control if it contains plain-text secrets [4][5]. Always prefer the os.environ/ method to keep credentials secure [4].

Citations:


Declare and fail fast on the smart-router credentials.

smart-router routes to nous/hy3:free for COMPLEX, REASONING, and fallback requests, and litellm_credential_name: nous resolves its key from NOUS_API_KEY. Add NOUS_API_KEY= to agent/.env.example and require both NOUS_API_KEY and OPENCODE_ZEN_API_KEY in the LiteLLM litellm service with ${VAR:?} so an unset credential fails startup rather than causing request failure.

🤖 Prompt for 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.

In `@agent/litellm/config.yaml` around lines 46 - 57, Declare NOUS_API_KEY= in
agent/.env.example, then update the LiteLLM service environment configuration to
require both NOUS_API_KEY and OPENCODE_ZEN_API_KEY using the ${VAR:?} fail-fast
syntax. Ensure the smart-router credentials resolve through the existing litellm
credential configuration without changing routing behavior.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant