diff --git a/.circleci/config.yml b/.circleci/config.yml
index 95ee0a6412c..cf1a7b94fe5 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1099,7 +1099,7 @@ jobs:
docker build \
--label org.opencontainers.image.revision="$(git rev-parse HEAD)" \
-t litellm-docker-database:ci \
- -f docker/Dockerfile.database .
+ -f Dockerfile .
fi
python3 .circleci/scripts/run_migration_tests.py record-image
diff --git a/.dockerignore b/.dockerignore
index f3a80fee3e4..8459d0cd482 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -7,7 +7,6 @@ tests
.devcontainer
*.tgz
log.txt
-docker/Dockerfile.*
# Claude Flow generated files (must be excluded from Docker build)
.claude/
diff --git a/.github/PULL_REQUEST_TEMPLATE/general.md b/.github/PULL_REQUEST_TEMPLATE/general.md
index aafd968ee0f..f815601a29c 100644
--- a/.github/PULL_REQUEST_TEMPLATE/general.md
+++ b/.github/PULL_REQUEST_TEMPLATE/general.md
@@ -6,18 +6,12 @@
## Handwritten 1-3 sentence description
-
-``
-
-``
+[insert handwritten description here]
Details
@@ -99,6 +93,7 @@ If you're seeing a delay in your PR being merged, ping the LiteLLM Team on [Slac
Otherwise proof must be fully e2e, no mocks, with real provider calls where applicable. Pytest alone is insufficient. The following format applies to live proof
Show only the latest proof. Before uses the merge base and After the tested tip. Rerun affected QA after behavior changes. Verified neutral diffs may carry proof with the tested SHA, current tip, equivalence reason and focused checks, following AGENTS.md and /qa
Use matching Before/After case headings with numbered commands and observed output. Put shared setup above them. For one case, omit case headings
+ A reviewer must be able to rerun every case from the body alone, so the shared setup gives the proxy start command, the config.yaml, env var names (never values) and the client code or curl used, all exactly as run. Wrap any block longer than about 20 lines in a collapsed with a one-line summary
### Before ()
diff --git a/.github/ci-coverage-allowlist.yml b/.github/ci-coverage-allowlist.yml
index 5dffa78776d..76f8e3ef7e7 100644
--- a/.github/ci-coverage-allowlist.yml
+++ b/.github/ci-coverage-allowlist.yml
@@ -57,15 +57,6 @@ test_paths:
- tests/integration/test_oci_proxy_integration.py
dockerfiles:
- - reason: >-
- The dashboard container is a static Next.js export served by nginx, and the dashboard build
- and lint workflows already exercise that output, so building the image adds no signal about it
- paths:
- - ui/Dockerfile
- - reason: >-
- An example image under cookbook/ that is documentation rather than a shipped artifact
- paths:
- - cookbook/litellm-ollama-docker-image/Dockerfile
- reason: >-
The Rust gateway image compiles the whole workspace in release mode, which is too slow for
a per-pull-request job while the gateway binary is still being assembled; the Rust lint,
diff --git a/.github/scripts/verify_linux_native_wheel.py b/.github/scripts/verify_linux_native_wheel.py
index 4c4cb399dce..571092263ed 100644
--- a/.github/scripts/verify_linux_native_wheel.py
+++ b/.github/scripts/verify_linux_native_wheel.py
@@ -214,7 +214,7 @@ def main(
native_module: Final = load_native_module(native_path)
native_module_loads: Final = native_module is not None
panic_test_hook_absent: Final = native_module is not None and not hasattr(native_module, "_panic_for_test")
- native_size_limit: Final = 48_000_000
+ native_size_limit: Final = 55_000_000
native_size_within_limit: Final = native_member.file_size <= native_size_limit
validations: Final = (
(f"Python tag is {EXPECTED_PYTHON_TAG}", python_tag == EXPECTED_PYTHON_TAG),
diff --git a/.github/workflows/compat-matrix-image.yml b/.github/workflows/compat-matrix-image.yml
index ddd2aa1a50b..73a77c1e861 100644
--- a/.github/workflows/compat-matrix-image.yml
+++ b/.github/workflows/compat-matrix-image.yml
@@ -26,17 +26,24 @@ jobs:
with:
persist-credentials: false
- - name: Build the Render cron image
- run: docker build -f tests/e2e/claude_code/cron_vm/Dockerfile -t compat-matrix:${{ github.sha }} tests/e2e
-
- - name: Resolve and install the Claude Code CLI as the cron user
+ - name: Install the pinned uv the cron image ships
+ env:
+ UV_VERSION: 0.10.9
+ UV_SHA256: 20d79708222611fa540b5c9ed84f352bcd3937740e51aacc0f8b15b271c57594
run: |
- docker run --rm compat-matrix:${{ github.sha }} bash -c '
- set -euo pipefail
- whoami
- gh --version
- uv --version
- version="$(uv run --no-project --python 3.12 python /opt/litellm/tests/e2e/cli_harness/npm_version_resolver.py @anthropic-ai/claude-code)"
- /opt/litellm/tests/e2e/claude_code/cron_vm/install_claude_code.sh "${version}" /tmp/claude-cli
- /tmp/claude-cli/claude --version
- '
+ set -euo pipefail
+ curl -fsSLo "$RUNNER_TEMP/uv.tar.gz" "https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-x86_64-unknown-linux-gnu.tar.gz"
+ echo "${UV_SHA256} $RUNNER_TEMP/uv.tar.gz" | sha256sum -c -
+ mkdir -p "$RUNNER_TEMP/bin"
+ tar -xzf "$RUNNER_TEMP/uv.tar.gz" -C "$RUNNER_TEMP/bin" --strip-components=1 uv-x86_64-unknown-linux-gnu/uv
+ echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
+
+ - name: Resolve and install the Claude Code CLI as an unprivileged user
+ run: |
+ set -euo pipefail
+ whoami
+ gh --version
+ uv --version
+ version="$(uv run --no-project --python 3.12 python tests/e2e/cli_harness/npm_version_resolver.py @anthropic-ai/claude-code)"
+ tests/e2e/claude_code/cron_vm/install_claude_code.sh "${version}" "$RUNNER_TEMP/claude-cli"
+ "$RUNNER_TEMP/claude-cli/claude" --version
diff --git a/.github/workflows/image-scan.yml b/.github/workflows/image-scan.yml
index 3e2bca8779d..6e13b49eb15 100644
--- a/.github/workflows/image-scan.yml
+++ b/.github/workflows/image-scan.yml
@@ -8,31 +8,25 @@ on:
- "litellm_**"
paths:
- Dockerfile
- - docker/Dockerfile.non_root
- - docker/Dockerfile.database
- - migrations/Dockerfile
+ - .dockerignore
+ - docker-entrypoint.sh
- migrations/run.py
- - gateway/Dockerfile
- - gateway/launch.py
- gateway/main.py
+ - gateway/launch.py
- gateway/routes/allowlist.py
- litellm_cli/**
- - backend/Dockerfile
- backend/main.py
+ - backend/routes/allowlist.py
- litellm-rust/**
- litellm/proxy/lens/**
- - docker/component_entrypoint.sh
- - docker/entrypoint.sh
- litellm/proxy/prisma_migration.py
- litellm/proxy/admin_mcp.py
- litellm/proxy/proxy_server.py
- - backend/routes/allowlist.py
- pyproject.toml
- litellm-proxy-extras/**
- tests/integration/database/image/**
- uv.lock
- ui/litellm-dashboard/package-lock.json
- - ui/Dockerfile
- ui/nginx.conf
- .github/workflows/image-scan.yml
- .grype.yaml
@@ -46,14 +40,18 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
+env:
+ IMAGE: litellm-image-scan:${{ github.sha }}
+ ADMIN_MCP_SCHEMA_IMAGE: litellm-admin-mcp-schema:${{ github.sha }}
+
jobs:
- image-scan:
- name: image-scan
+ build:
+ name: build
runs-on: ubuntu-latest
if: >-
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
- timeout-minutes: 30
+ timeout-minutes: 60
permissions:
contents: read
steps:
@@ -61,7 +59,129 @@ jobs:
with:
persist-credentials: false
+ - name: Build the image
+ run: docker build --build-arg LITELLM_RELEASE_TAG=v0.0.0-lens-ci -t "$IMAGE" .
+
+ - name: Save the image for the verify matrix
+ run: docker save "$IMAGE" | zstd -T0 -3 -o "$RUNNER_TEMP/litellm-image.tar.zst"
+
+ - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
+ with:
+ name: litellm-image
+ path: ${{ runner.temp }}/litellm-image.tar.zst
+ retention-days: 1
+ compression-level: 0
+
+ - name: Build the Admin MCP schema image
+ run: docker build --build-arg LITELLM_RELEASE_TAG=v0.0.0-lens-ci --target builder -t "$ADMIN_MCP_SCHEMA_IMAGE" .
+
+ - name: Save the Admin MCP schema image for the verify matrix
+ run: docker save "$ADMIN_MCP_SCHEMA_IMAGE" | zstd -T0 -3 -o "$RUNNER_TEMP/litellm-admin-mcp-schema.tar.zst"
+
+ - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
+ with:
+ name: litellm-admin-mcp-schema
+ path: ${{ runner.temp }}/litellm-admin-mcp-schema.tar.zst
+ retention-days: 1
+ compression-level: 0
+
+ verify:
+ name: verify (${{ matrix.check }})
+ needs: build
+ runs-on: ubuntu-latest
+ timeout-minutes: 45
+ permissions:
+ contents: read
+ strategy:
+ fail-fast: false
+ matrix:
+ check: [scan, migrations, gateway, backend, ui, collector]
+ steps:
+ - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
+ with:
+ persist-credentials: false
+
+ - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
+ with:
+ name: litellm-image
+ path: ${{ runner.temp }}
+
+ - name: Load the image
+ run: zstd -d --stdout "$RUNNER_TEMP/litellm-image.tar.zst" | docker load
+
+ - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
+ if: matrix.check == 'migrations' || matrix.check == 'backend'
+ with:
+ name: litellm-admin-mcp-schema
+ path: ${{ runner.temp }}
+
+ - name: Load the Admin MCP schema image
+ if: matrix.check == 'migrations' || matrix.check == 'backend'
+ run: zstd -d --stdout "$RUNNER_TEMP/litellm-admin-mcp-schema.tar.zst" | docker load
+
+ - name: Set up Python
+ if: matrix.check != 'scan'
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
+ with:
+ python-version: "3.12"
+
+ - name: Install pytest
+ if: matrix.check != 'scan'
+ run: python -m pip install "pytest==9.0.3"
+
+ # The prisma bake must migrate a fresh DB with no egress as an arbitrary
+ # non-root uid (OpenShift restricted-v2 / air-gapped / readOnlyFilesystem).
+ # `docker run` as the default uid with network hides a broken bake because
+ # the migration entrypoint exits 0 even when it applied nothing; asserting
+ # the schema was created is what catches it.
+ - name: Verify offline migration as a non-root uid
+ if: matrix.check == 'migrations'
+ env:
+ LITELLM_IMAGE: ${{ env.IMAGE }}
+ LITELLM_ADMIN_MCP_SCHEMA_IMAGE: ${{ env.ADMIN_MCP_SCHEMA_IMAGE }}
+ run: |
+ python -m pytest --noconftest -v \
+ tests/integration/database/image/test_offline_image_migration.py \
+ tests/integration/database/image/test_image_bedrock_realtime_extra.py \
+ tests/integration/database/image/test_image_admin_mcp.py
+
+ - name: Verify the gateway component serves offline as a non-root uid
+ if: matrix.check == 'gateway'
+ env:
+ LITELLM_IMAGE: ${{ env.IMAGE }}
+ LITELLM_COMPONENT: gateway
+ LITELLM_IMAGE_COMPONENT: gateway
+ run: |
+ python -m pytest --noconftest -v \
+ tests/integration/database/image/test_component_image_serves_offline.py \
+ tests/integration/database/image/test_image_admin_mcp.py
+
+ - name: Verify the backend component serves offline as a non-root uid
+ if: matrix.check == 'backend'
+ env:
+ LITELLM_IMAGE: ${{ env.IMAGE }}
+ LITELLM_COMPONENT: backend
+ LITELLM_IMAGE_COMPONENT: backend
+ LITELLM_ADMIN_MCP_SCHEMA_IMAGE: ${{ env.ADMIN_MCP_SCHEMA_IMAGE }}
+ run: |
+ python -m pytest --noconftest -v \
+ tests/integration/database/image/test_component_image_serves_offline.py \
+ tests/integration/database/image/test_image_admin_mcp.py
+
+ - name: Verify the ui component serves as an arbitrary uid with a read-only root fs
+ if: matrix.check == 'ui'
+ env:
+ LITELLM_IMAGE: ${{ env.IMAGE }}
+ run: python -m pytest --noconftest -v tests/integration/database/image/test_ui_image_serves_offline.py
+
+ - name: Verify the collector creates its socket as the image user
+ if: matrix.check == 'collector'
+ env:
+ LITELLM_IMAGE: ${{ env.IMAGE }}
+ run: python -m pytest --noconftest -v tests/integration/database/image/test_collector_image_serves_socket.py
+
- name: Download Grype v0.114.0
+ if: matrix.check == 'scan'
run: |
curl -fsSL --retry 3 -o "$RUNNER_TEMP/grype.tar.gz" \
https://github.com/anchore/grype/releases/download/v0.114.0/grype_0.114.0_linux_amd64.tar.gz
@@ -69,33 +189,6 @@ jobs:
tar xzf "$RUNNER_TEMP/grype.tar.gz" -C "$RUNNER_TEMP" grype
chmod +x "$RUNNER_TEMP/grype"
- # Dockerfile.non_root is the rootless variant we ship. The other
- # Dockerfiles share the same wolfi base and apk set, so OS-layer coverage
- # is the same; matrix-scan if those variants ever diverge.
- - name: Build runtime image
- run: docker build -f docker/Dockerfile.non_root -t litellm-image-scan:${{ github.sha }} .
-
- - name: Tag the cached builder for Admin MCP schema setup
- run: docker build --target builder -f docker/Dockerfile.non_root -t litellm-admin-mcp-schema:${{ github.sha }} .
-
- # The prisma bake must migrate a fresh DB with no egress as an arbitrary
- # non-root uid (OpenShift restricted-v2 / air-gapped / readOnlyRootFilesystem).
- # `docker run` as the default uid with network hides a broken bake because
- # the migration entrypoint exits 0 even when it applied nothing; asserting
- # the schema was created is what catches it.
- - name: Set up Python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- with:
- python-version: "3.12"
-
- - name: Verify offline migration as a non-root uid
- env:
- LITELLM_IMAGE: litellm-image-scan:${{ github.sha }}
- LITELLM_ADMIN_MCP_SCHEMA_IMAGE: litellm-admin-mcp-schema:${{ github.sha }}
- run: |
- python -m pip install "pytest==9.0.3"
- python -m pytest --noconftest tests/integration/database/image/test_offline_image_migration.py tests/integration/database/image/test_image_bedrock_realtime_extra.py tests/integration/database/image/test_image_admin_mcp.py -v
-
# Scans the whole shipped artifact: OS/apk plus every language package
# baked into the image, including ones no lockfile declares (e.g. prisma's
# vendored node engine) that osv-scan cannot see. osv-scan stays the fast
@@ -103,175 +196,12 @@ jobs:
# free OSS, run as a pinned, checksum-verified binary; no GitHub Action
# dependency and no vendor SaaS callout.
- name: Scan image for fixable HIGH/CRITICAL CVEs
+ if: matrix.check == 'scan'
env:
GRYPE_MATCH_PYTHON_USING_CPES: "true"
run: |
- "$RUNNER_TEMP/grype" litellm-image-scan:${{ github.sha }} \
+ "$RUNNER_TEMP/grype" "$IMAGE" \
--config .grype.yaml \
--only-fixed \
--fail-on high \
--output table
-
- runtime-image:
- name: runtime-image (${{ matrix.dockerfile }})
- runs-on: ubuntu-latest
- if: >-
- github.event_name != 'pull_request' ||
- github.event.pull_request.head.repo.full_name == github.repository
- timeout-minutes: 45
- permissions:
- contents: read
- strategy:
- fail-fast: false
- matrix:
- dockerfile: [Dockerfile, docker/Dockerfile.database]
- steps:
- - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- with:
- persist-credentials: false
-
- - name: Build runtime image
- run: docker build --build-arg LITELLM_RELEASE_TAG=v0.0.0-lens-ci -f "${{ matrix.dockerfile }}" -t litellm-runtime-scan:${{ github.sha }} .
-
- - name: Tag the cached builder for Admin MCP schema setup
- run: docker build --target builder -f "${{ matrix.dockerfile }}" -t litellm-admin-mcp-schema:${{ github.sha }} .
-
- - name: Set up Python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- with:
- python-version: "3.12"
-
- - name: Verify offline migration as a non-root uid
- env:
- LITELLM_IMAGE: litellm-runtime-scan:${{ github.sha }}
- LITELLM_ADMIN_MCP_SCHEMA_IMAGE: litellm-admin-mcp-schema:${{ github.sha }}
- run: |
- python -m pip install "pytest==9.0.3"
- python -m pytest --noconftest tests/integration/database/image/test_offline_image_migration.py tests/integration/database/image/test_image_bedrock_realtime_extra.py tests/integration/database/image/test_image_admin_mcp.py -v
-
-
- migrations-image:
- name: migrations-image
- runs-on: ubuntu-latest
- if: >-
- github.event_name != 'pull_request' ||
- github.event.pull_request.head.repo.full_name == github.repository
- timeout-minutes: 30
- permissions:
- contents: read
- steps:
- - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- with:
- persist-credentials: false
-
- - name: Build migrations image
- run: docker build -f migrations/Dockerfile -t litellm-migrations-scan:${{ github.sha }} .
-
- - name: Set up Python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- with:
- python-version: "3.12"
-
- - name: Verify offline migration as a non-root uid
- env:
- LITELLM_IMAGE: litellm-migrations-scan:${{ github.sha }}
- LITELLM_MIGRATION_INTERPRETER: python3
- LITELLM_MIGRATION_SCRIPT: /app/run.py
- run: |
- python -m pip install "pytest==9.0.3"
- python -m pytest --noconftest tests/integration/database/image/test_offline_image_migration.py -v
-
- gateway-image:
- name: gateway-image
- runs-on: ubuntu-latest
- if: >-
- github.event_name != 'pull_request' ||
- github.event.pull_request.head.repo.full_name == github.repository
- timeout-minutes: 30
- permissions:
- contents: read
- steps:
- - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- with:
- persist-credentials: false
-
- - name: Build gateway image
- run: docker build -f gateway/Dockerfile -t litellm-gateway-scan:${{ github.sha }} .
-
- - name: Set up Python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- with:
- python-version: "3.12"
-
- - name: Verify the gateway serves offline as a non-root uid
- env:
- LITELLM_IMAGE: litellm-gateway-scan:${{ github.sha }}
- LITELLM_COMPONENT_PORT: "4000"
- LITELLM_IMAGE_COMPONENT: gateway
- run: |
- python -m pip install "pytest==9.0.3"
- python -m pytest --noconftest tests/integration/database/image/test_component_image_serves_offline.py tests/integration/database/image/test_image_bedrock_realtime_extra.py tests/integration/database/image/test_image_admin_mcp.py -v
-
- ui-image:
- name: ui-image
- runs-on: ubuntu-latest
- if: >-
- github.event_name != 'pull_request' ||
- github.event.pull_request.head.repo.full_name == github.repository
- timeout-minutes: 30
- permissions:
- contents: read
- steps:
- - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- with:
- persist-credentials: false
-
- - name: Build UI image
- run: docker build -f ui/Dockerfile -t litellm-ui-scan:${{ github.sha }} .
-
- - name: Set up Python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- with:
- python-version: "3.12"
-
- - name: Verify the UI serves offline as an arbitrary uid with a read-only root fs
- env:
- LITELLM_IMAGE: litellm-ui-scan:${{ github.sha }}
- run: |
- python -m pip install "pytest==9.0.3"
- python -m pytest --noconftest tests/integration/database/image/test_ui_image_serves_offline.py -v
-
- backend-image:
- name: backend-image
- runs-on: ubuntu-latest
- if: >-
- github.event_name != 'pull_request' ||
- github.event.pull_request.head.repo.full_name == github.repository
- timeout-minutes: 30
- permissions:
- contents: read
- steps:
- - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- with:
- persist-credentials: false
-
- - name: Build backend image
- run: docker build -f backend/Dockerfile -t litellm-backend-scan:${{ github.sha }} .
-
- - name: Tag the cached builder for Admin MCP schema setup
- run: docker build --target builder -f backend/Dockerfile -t litellm-admin-mcp-schema:${{ github.sha }} .
-
- - name: Set up Python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- with:
- python-version: "3.12"
-
- - name: Verify the backend serves offline as a non-root uid
- env:
- LITELLM_IMAGE: litellm-backend-scan:${{ github.sha }}
- LITELLM_ADMIN_MCP_SCHEMA_IMAGE: litellm-admin-mcp-schema:${{ github.sha }}
- LITELLM_COMPONENT_PORT: "4001"
- LITELLM_IMAGE_COMPONENT: backend
- run: |
- python -m pip install "pytest==9.0.3"
- python -m pytest --noconftest tests/integration/database/image/test_component_image_serves_offline.py tests/integration/database/image/test_image_admin_mcp.py -v
diff --git a/.github/workflows/interactions-spec-canary.yml b/.github/workflows/interactions-spec-canary.yml
index a2e4646dce5..89ebdd87a7c 100644
--- a/.github/workflows/interactions-spec-canary.yml
+++ b/.github/workflows/interactions-spec-canary.yml
@@ -49,9 +49,9 @@ jobs:
id: compliance
run: |
uv run --no-sync pytest tests/unit/interactions/test_openapi_compliance.py \
- --interactions-spec-url=https://ai.google.dev/static/api/interactions.openapi.json \
+ --interactions-spec-url=https://aistudio.google.com/api-reference/interactions.openapi.json \
--tb=short -vv -p no:rerunfailures -p no:pytest-retry \
- --allow-hosts=127.0.0.1,::1,localhost,ai.google.dev
+ --allow-hosts=127.0.0.1,::1,localhost,ai.google.dev,aistudio.google.com
tracking-issue:
name: tracking-issue
diff --git a/.github/workflows/osv-scan.yml b/.github/workflows/osv-scan.yml
index 1c7e8b2841a..5016957bd6f 100644
--- a/.github/workflows/osv-scan.yml
+++ b/.github/workflows/osv-scan.yml
@@ -5,6 +5,9 @@ on:
branches:
- main
- "litellm_**"
+ - "rc/**"
+ - "stable/**"
+ - "lts/**"
schedule:
- cron: "23 6 * * *"
workflow_dispatch:
diff --git a/.github/workflows/test-linting.yml b/.github/workflows/test-linting.yml
index cbeea71ad0f..fd1d2973951 100644
--- a/.github/workflows/test-linting.yml
+++ b/.github/workflows/test-linting.yml
@@ -21,7 +21,7 @@ jobs:
pull-requests: read
actions: read
runs-on: ubuntu-latest
- timeout-minutes: 20
+ timeout-minutes: 30
services:
redis:
image: redis@sha256:e2debfb7956fa12c7ddc79d7e645c8cf26b30c99a6e9161ea9bf4171e1668a5f
diff --git a/.github/workflows/test-merge-smoke.yml b/.github/workflows/test-merge-smoke.yml
index 99dbd1c101b..912fc90fbe5 100644
--- a/.github/workflows/test-merge-smoke.yml
+++ b/.github/workflows/test-merge-smoke.yml
@@ -200,8 +200,36 @@ jobs:
- name: Install the test client dependencies
run: .github/scripts/uv_sync_with_retries.sh --frozen --no-install-workspace --extra proxy --group dev --python 3.12
- - name: Build the image from the published package
- run: docker build -t litellm-build-from-pip:smoke -f docker/build_from_pip/Dockerfile.build_from_pip .
+ - name: Cache Prisma binaries
+ timeout-minutes: 3
+ uses: ./.github/actions/cache-prisma-binaries
+
+ - name: Install the published proxy into its own venv
+ run: |
+ uv --no-config venv --python 3.13 /tmp/litellm-pip
+ uv --no-config pip install --python /tmp/litellm-pip/bin/python \
+ "litellm[proxy,proxy-runtime]==1.83.0" \
+ "google-cloud-aiplatform==1.133.0" \
+ "google-genai==1.37.0" \
+ "anthropic[vertex]==0.84.0" \
+ "grpcio==1.78.0" \
+ "prometheus-client==0.20.0" \
+ "langfuse==2.59.7" \
+ "opentelemetry-api==1.28.0" \
+ "opentelemetry-sdk==1.28.0" \
+ "opentelemetry-exporter-otlp==1.28.0" \
+ "ddtrace==4.11.0" \
+ "sentry-sdk==2.21.0" \
+ "mangum==0.17.0" \
+ "azure-ai-contentsafety==1.0.0" \
+ "azure-storage-file-datalake==12.20.0" \
+ "pypdf==6.7.5" \
+ "llm-sandbox==0.3.31" \
+ "detect-secrets==1.5.0" \
+ "prisma==0.11.0" \
+ "openai==2.24.0"
+ export PATH="/tmp/litellm-pip/bin:$PATH"
+ /tmp/litellm-pip/bin/prisma generate --schema=schema.prisma
- name: Start the fake OpenAI endpoint
run: |
@@ -219,23 +247,21 @@ jobs:
echo "::add-mask::${key}"
echo "LITELLM_MASTER_KEY=${key}" >> "${GITHUB_ENV}"
- - name: Start the proxy container
+ - name: Start the published proxy
+ env:
+ DATABASE_URL: postgresql://postgres:postgres@localhost:5432/circle_test
+ LITELLM_LICENSE: bad-license
+ FAKE_OPENAI_API_BASE: http://localhost:8190
+ OTEL_EXPORTER: in_memory
+ USE_DDTRACE: "True"
+ DD_TRACE_OPENAI_ENABLED: "False"
+ GCS_FLUSH_INTERVAL: "1"
+ LITELLM_LOG: ERROR
run: |
- docker run -d \
- -p 4000:4000 \
- -e DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:5432/circle_test \
- -e LITELLM_MASTER_KEY \
- -e FAKE_OPENAI_API_BASE=http://host.docker.internal:8190 \
- -e OTEL_EXPORTER=in_memory \
- -e USE_DDTRACE=True \
- -e GCS_FLUSH_INTERVAL=1 \
- -e LITELLM_LOG=ERROR \
- --add-host host.docker.internal:host-gateway \
- --name litellm-build-from-pip \
- -v "${GITHUB_WORKSPACE}/docker/build_from_pip/litellm_config.yaml:/app/config.yaml" \
- litellm-build-from-pip:smoke \
- --config /app/config.yaml \
- --port 4000
+ cd /tmp/litellm-pip
+ nohup /tmp/litellm-pip/bin/ddtrace-run /tmp/litellm-pip/bin/litellm \
+ --config "${GITHUB_WORKSPACE}/tests/basic_proxy_startup_tests/build_from_pip_config.yaml" \
+ --port 4000 > /tmp/litellm-pip.log 2>&1 &
for _ in $(seq 1 150); do
curl -sf --max-time 5 -o /dev/null http://localhost:4000 && exit 0
sleep 2
@@ -270,7 +296,7 @@ jobs:
- name: Show the proxy logs
if: always()
- run: docker logs litellm-build-from-pip || true
+ run: cat /tmp/litellm-pip.log || true
smoke-passed:
name: smoke passed
diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml
index 2c05ee827a3..d3f4821a05b 100644
--- a/.github/workflows/test-unit.yml
+++ b/.github/workflows/test-unit.yml
@@ -5,6 +5,9 @@ on:
branches:
- main
- "litellm_**"
+ - "rc/**"
+ - "stable/**"
+ - "lts/**"
push:
branches:
- main
@@ -42,7 +45,7 @@ jobs:
id: rust-bridge-key
if: steps.changes.outputs.decision != 'skip'
env:
- RUST_BRIDGE_CACHE_KEY: ${{ runner.os }}-rust-bridge-editable-${{ hashFiles('litellm-rust/Cargo.lock', 'litellm-rust/Cargo.toml', 'litellm-rust/crates/**', 'model_prices_and_context_window.json', 'pyproject.toml') }}
+ RUST_BRIDGE_CACHE_KEY: ${{ runner.os }}-rust-bridge-editable-${{ hashFiles('litellm-rust/Cargo.lock', 'litellm-rust/Cargo.toml', 'litellm-rust/crates/**', 'model_prices_and_context_window.json', 'pyproject.toml', 'packaging/litellm-proxy/pyproject.toml') }}
run: echo "key=$RUST_BRIDGE_CACHE_KEY" >> "$GITHUB_OUTPUT"
- name: Set up Python
@@ -95,6 +98,18 @@ jobs:
mkdir -p rust-bridge-dist/litellm/rust_bridge
cp litellm/rust_bridge/_native.abi3.so rust-bridge-dist/litellm/rust_bridge/_native.abi3.so
+ - name: Build the gateway wheel once for test shards
+ if: steps.changes.outputs.decision != 'skip' && steps.rust-bridge-cache.outputs.cache-hit != 'true'
+ timeout-minutes: 15
+ working-directory: packaging/litellm-proxy
+ env:
+ RUSTC_WRAPPER: sccache
+ SCCACHE_GHA_ENABLED: "true"
+ SCCACHE_GHA_VERSION: litellm-ci-v1
+ SCCACHE_GHA_RW_MODE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'READ_WRITE' || 'READ_ONLY' }}
+ CARGO_INCREMENTAL: "0"
+ run: uv run --no-project --with maturin==1.15.0 maturin build --profile dev --strip --out ../../rust-bridge-dist
+
- name: Upload Rust bridge artifact
if: steps.changes.outputs.decision != 'skip'
timeout-minutes: 10
@@ -167,6 +182,7 @@ jobs:
tests/unit/google_genai
tests/unit/router_strategy
tests/unit/router_utils
+ tests/unit/redis
tests/unit/proxy/common_utils/test_cache_aware_routing.py
tests/unit/enterprise/enterprise_callbacks/send_emails
tests/unit/enterprise/proxy/test_afile_retrieve_returns_unified_id.py
@@ -280,6 +296,7 @@ jobs:
tests/unit/llms/e2b
tests/unit/llms/edenai
tests/unit/llms/elevenlabs
+ tests/unit/llms/empiriolabs
tests/unit/llms/exa_ai
tests/unit/llms/fal_ai
tests/unit/llms/fastcrw
@@ -380,6 +397,7 @@ jobs:
tests/unit/llms/voyage
tests/unit/llms/wandb
tests/unit/llms/watsonx
+ tests/unit/llms/webiq
tests/unit/llms/xai
tests/unit/llms/xinference
tests/unit/llms/you_com
@@ -415,6 +433,7 @@ jobs:
- shard: router
test-path: >-
+ tests/unit/router_rust
tests/unit/test_router
python-version: "3.12"
workers: 4
@@ -441,6 +460,7 @@ jobs:
tests/unit/ocr
tests/unit/passthrough
tests/unit/rag
+ tests/unit/cookbook
tests/unit/realtime_api
tests/unit/rerank_api
tests/unit/search
@@ -972,10 +992,10 @@ jobs:
dist: loadscope
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- timeout-minutes: ${{ matrix.shard == 'db-and-spend' && 10 || 3 }}
+ timeout-minutes: 3
with:
persist-credentials: false
- fetch-depth: ${{ matrix.shard == 'db-and-spend' && '0' || '1' }}
+ fetch-depth: 1
- name: Detect relevant changes
id: changes
@@ -1008,27 +1028,37 @@ jobs:
with:
artifact: ${{ needs.rust-bridge.outputs.artifact }}
- - name: Install dependencies and check schema
+ - name: Install dependencies
if: steps.changes.outputs.decision != 'skip'
- timeout-minutes: 8
+ timeout-minutes: 5
env:
RUST_BRIDGE_ARTIFACT: ${{ needs.rust-bridge.outputs.artifact }}
- UNIT_SHARD: ${{ matrix.shard }}
- SCHEMA_BASE_REF: origin/${{ github.event.repository.default_branch }}
run: |
diff -u model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json
if [ -z "$RUST_BRIDGE_ARTIFACT" ]; then
- .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra saml --extra extra_proxy --extra proxy-runtime --extra utils
+ .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra switchyard --extra saml --extra extra_proxy --extra proxy-runtime --extra utils
else
- .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra saml --extra extra_proxy --extra proxy-runtime --extra utils --no-install-project
+ .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra switchyard --extra saml --extra extra_proxy --extra proxy-runtime --extra utils --no-install-project --no-install-package litellm-proxy
uv pip install --no-deps --python .venv/bin/python rust-bridge-dist/*.whl
cp rust-bridge-dist/litellm/rust_bridge/_native.abi3.so litellm/rust_bridge/_native.abi3.so
uv run --no-sync python -c "import importlib.metadata; import litellm.rust_bridge._native; print(importlib.metadata.version('litellm'))"
fi
uv run --no-sync python -c 'import os, sys; print(sys.version); assert f"{sys.version_info.major}.{sys.version_info.minor}" == os.environ["UV_PYTHON"]'
- if [ "$UNIT_SHARD" = "db-and-spend" ]; then
- uv run --no-sync python scripts/check_schema_compatibility.py --base-ref "$SCHEMA_BASE_REF"
- fi
+
+ - name: Check schema.prisma against the merge base
+ if: steps.changes.outputs.decision != 'skip' && matrix.shard == 'db-and-spend' && github.event_name == 'pull_request'
+ timeout-minutes: 3
+ env:
+ GH_TOKEN: ${{ github.token }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ EVENT_BASE_REF: ${{ github.event.pull_request.base.ref }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ run: |
+ base_ref=$(gh api "repos/${GITHUB_REPOSITORY}/branches/${EVENT_BASE_REF}" --jq .name) || base_ref=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq .base.ref)
+ merge_base=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${base_ref}...${HEAD_SHA}?per_page=1" --jq '.merge_base_commit.sha')
+ test -n "$merge_base"
+ git fetch --no-tags --depth=1 origin "$merge_base"
+ uv run --no-sync python scripts/check_schema_compatibility.py --base-commit "$merge_base"
- name: Cache Prisma binaries
if: steps.changes.outputs.decision != 'skip'
@@ -1265,7 +1295,7 @@ jobs:
- name: Install dependencies
if: steps.changes.outputs.decision != 'skip'
run: |
- .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router
+ .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra switchyard
- name: Cache Prisma binaries
if: steps.changes.outputs.decision != 'skip'
@@ -1468,9 +1498,9 @@ jobs:
RUST_BRIDGE_ARTIFACT: ${{ needs.rust-bridge.outputs.artifact }}
run: |
if [ -z "$RUST_BRIDGE_ARTIFACT" ]; then
- .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra saml --extra extra_proxy --extra proxy-runtime --extra utils
+ .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra switchyard --extra saml --extra extra_proxy --extra proxy-runtime --extra utils
else
- .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra saml --extra extra_proxy --extra proxy-runtime --extra utils --no-install-project
+ .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra switchyard --extra saml --extra extra_proxy --extra proxy-runtime --extra utils --no-install-project --no-install-package litellm-proxy
uv pip install --no-deps --python .venv/bin/python rust-bridge-dist/*.whl
cp rust-bridge-dist/litellm/rust_bridge/_native.abi3.so litellm/rust_bridge/_native.abi3.so
fi
diff --git a/AGENTS.md b/AGENTS.md
index 9aa9ab32528..d8de447be90 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -45,14 +45,13 @@ Run QA proxies with `python litellm/proxy/proxy_cli.py --config litellm/proxy/de
Simple PRs may skip before/after e2e when the full diff is mechanical and focused checks completely prove it, such as #49030 restoring an existing helper name. Trace affected callers and run relevant tests/static checks at the tip. For a bug fix, establish that the regression catches the original defect. Size alone never qualifies. New behavior, API/provider semantics, auth, billing, persistence, concurrency or uncertain integration risk need live e2e. In Screenshots / Proof of Fix, record `E2E exception at `, scope, rationale, commands and results. Tests count as proof only for this exception. Reassess changed diffs, retain CI/bot gates, and honor explicit e2e requests (2026-10-28, unnecessary live QA for #49030)
-For other PRs, proof must show the end user's real flow before and after, with commands and output against a live proxy and real provider calls where applicable. Pytest alone is insufficient. For UI or interactive coding-tool flows, drive that surface and embed before/after screenshots, with URLs, clicks and input fields a reviewer can reproduce
+For other PRs, proof must show the end user's real flow before and after, with commands and output against a live proxy and real provider calls where applicable. The body alone must let a reviewer rerun it, with the proxy command, config, env var names and client code exactly as run, and long blocks collapsed in . Pytest alone is insufficient. For UI or interactive coding-tool flows, drive that surface and embed before/after screenshots, with URLs, clicks and input fields a reviewer can reproduce
If you ever write any human-facing text (pull requests, issues, commit messages, discussion posts, github comments, release notes, docs, etc.), always follow these guidelines to sound less AI-y:
- don't use emojis
- don't use "—". Don't use ";" or ":" unless it would be nonsensical not to. Instead, reach for ",", ".", conjunction words, etc. in descending order of preference: vary among them, weighted toward the front of the list, and skip "," where it would cause a comma splice or the sentence is getting long. Overusing any one of them also feels AI-y. A word cap does not penalize you for adding more sentences
- don't use the pattern "It's not X, it's Y", "You're not X, you're Y", etc.
- unless explicitly asked, don't use bulleted or numbered lists unless it would be nonsensical not to. Instead, prefer prose
-- don't add a trailing "." at the end of paragraphs (just like this file). That means every paragraph, not just the last one (of the markdown file, PR description, GitHub comment, etc.). Rule of thumb: if you're adding new line(s) before the next sentence, don't add a ".". Exception is that docs (i.e., litellm-docs) should have trailing "."
- don't use →. Instead, prefer not to use arrows, and if need be, use -> instead
- use plain, simple, everyday engineering language: the common phrase engineers actually say over rare compact phrasing, in grammatically complete sentences. When explicitly asked to use bullets or ordered lists and structure legitimately helps the reader, prefer nested bullets (any depth is fine) over dense lines in a flat structure
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e956b27d5da..426cf986d4c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -305,8 +305,8 @@ uv run litellm --config your_config.yaml
If you want to build the Docker image yourself:
```bash
-# Build using the non-root Dockerfile
-docker build -f docker/Dockerfile.non_root -t litellm_dev .
+# Build the image (runs as a non-root user by default)
+docker build -t litellm_dev .
# Generate a master key. Requests send it as the bearer token
export LITELLM_MASTER_KEY="sk-$(openssl rand -hex 32)"
diff --git a/Dockerfile b/Dockerfile
index 4cef63c8d71..205f0cc981d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -76,6 +76,7 @@ ENV UV_PROJECT_ENVIRONMENT=/app/.venv \
COPY pyproject.toml uv.lock ./
COPY enterprise/pyproject.toml enterprise/
COPY litellm-proxy-extras/pyproject.toml litellm-proxy-extras/
+COPY packaging/litellm-proxy/pyproject.toml packaging/litellm-proxy/
# Install third-party dependencies (cached unless pyproject.toml/uv.lock change)
RUN uv sync --frozen --no-install-project --no-install-workspace --no-default-groups --no-editable \
@@ -101,7 +102,8 @@ COPY --from=ui-builder /ui/out/. litellm/proxy/_experimental/out/
RUN sed -i 's/\r$//' docker/build_admin_ui.sh && chmod +x docker/build_admin_ui.sh && ./docker/build_admin_ui.sh
# Install project and workspace packages (fast - deps already cached)
-RUN uv sync --frozen --no-default-groups --no-editable \
+RUN uv build --package litellm-proxy --wheel --out-dir /wheels
+RUN uv sync --frozen --no-install-package litellm-proxy --no-default-groups --no-editable \
--extra proxy \
--extra proxy-runtime \
--group admin-mcp \
@@ -111,12 +113,18 @@ RUN uv sync --frozen --no-default-groups --no-editable \
--extra bedrock-realtime \
--python python3.13
+RUN uv pip install --python /app/.venv/bin/python --no-deps /wheels/litellm_proxy-*.whl
+
RUN HOME=/opt/prisma XDG_CACHE_HOME=/opt/prisma/.cache PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries \
npm_config_cache=/root/.npm \
prisma generate --schema=./schema.prisma
-RUN sed -i 's/\r$//' docker/entrypoint.sh && chmod +x docker/entrypoint.sh && \
- sed -i 's/\r$//' docker/prod_entrypoint.sh && chmod +x docker/prod_entrypoint.sh
+RUN sed -i 's/\r$//' docker-entrypoint.sh && chmod +x docker-entrypoint.sh
+
+RUN mkdir -p /var/lib/litellm/ui /var/lib/litellm/assets && \
+ cp -r litellm/proxy/_experimental/out/. /var/lib/litellm/ui/ && \
+ cp litellm/proxy/logo.png /var/lib/litellm/assets/logo.png && \
+ touch /var/lib/litellm/ui/.litellm_ui_ready
FROM $LITELLM_BUILD_IMAGE AS liteadmin-builder
COPY --from=uvbin /uv /usr/local/bin/uv
@@ -141,24 +149,35 @@ USER root
# https://github.com/BerriAI/litellm/issues/33518
RUN echo "https://packages.wolfi.dev/os" >> /etc/apk/repositories
-# node (without npm) is required by the prisma CLI at runtime
-RUN apk add --no-cache bash openssl libssl3 tzdata nodejs python-3.13 libsndfile libevent
+RUN for i in 1 2 3; do \
+ apk add --no-cache bash openssl libssl3 tzdata nodejs python-3.13 libsndfile libatomic libevent nginx && break; \
+ [ "$i" = 3 ] && { echo "apk add failed after 3 retries" >&2; exit 1; }; \
+ sleep 5; \
+ done
COPY --from=pgbouncer-builder /usr/local/bin/pgbouncer /usr/local/bin/pgbouncer
WORKDIR /app
+
ENV PATH="/app/.venv/bin:${PATH}" \
+ PYTHONPATH="/app" \
+ PYTHONDONTWRITEBYTECODE=1 \
+ PYTHONUNBUFFERED=1 \
+ HOME=/app \
+ LITELLM_NON_ROOT=true \
PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries \
PRISMA_CLI_PATH=/opt/prisma/binaries/node_modules/.bin/prisma \
PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
+ PRISMA_SKIP_POSTINSTALL_GENERATE=1 \
+ PRISMA_HIDE_UPDATE_MESSAGE=1 \
+ PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING=1 \
PRISMA_OFFLINE_MODE=true
# Copy only what runtime needs. The application is installed inside the venv;
# the rest of the builder's /app is source and build metadata that must not
# ship (manifest-scanning tools attribute everything in it to this image).
-# entrypoint.sh invokes litellm/proxy/prisma_migration.py by source path.
COPY --from=builder /app/.venv /app/.venv
COPY --from=liteadmin-builder /opt/liteadmin /opt/liteadmin
-COPY --from=builder /app/docker /app/docker
+COPY --from=builder /app/docker-entrypoint.sh /app/docker-entrypoint.sh
COPY --from=builder /app/schema.prisma /app/schema.prisma
COPY --from=builder /app/litellm/proxy/prisma_migration.py /app/litellm/proxy/prisma_migration.py
# enterprise/ is imported by source path at runtime (proxy_cli puts the
@@ -166,21 +185,33 @@ COPY --from=builder /app/litellm/proxy/prisma_migration.py /app/litellm/proxy/pr
# enterprise.enterprise_hooks from it)
COPY --from=builder /app/enterprise /app/enterprise
COPY --from=builder /app/litellm-proxy-extras /app/litellm-proxy-extras
-# Prisma CLI + engines are baked under /opt/prisma, a fixed path every
-# runtime uid can read and that no cache volume mount shadows. The paths are
-# pinned via PRISMA_BINARY_CACHE_DIR / PRISMA_CLI_PATH and recorded into the
-# generated client at build time, so `prisma migrate deploy` on a fresh
-# database needs no npm and no network access (#33650, #24554).
+COPY --from=builder /app/gateway /app/gateway
+COPY --from=builder /app/backend /app/backend
+COPY --from=builder /app/migrations /app/migrations
COPY --from=builder /opt/prisma /opt/prisma
+COPY --from=builder /var/lib/litellm /var/lib/litellm
+COPY ui/nginx.conf /etc/nginx/nginx.conf
+COPY ui/docker-entrypoint.d/40-litellm-runtime-config.sh /app/ui/docker-entrypoint.d/40-litellm-runtime-config.sh
-RUN find /app/.venv -type f -path "*/tornado/test/*" -delete && \
- find /app/.venv -type d -path "*/tornado/test" -delete && \
+RUN find /app/.venv -depth -type d -path "*/tornado/test" -exec rm -rf {} + && \
+ mkdir -p /app/.cache /var/run/litellm && \
+ chown -R 65532:0 /app /var/lib/litellm /var/run/litellm && \
+ chmod -R g=u,g+w /app/.cache /var/lib/litellm /var/run/litellm && \
+ PRISMA_PATH="$(python -c 'import os, prisma; print(os.path.dirname(prisma.__file__))')" && \
+ PROXY_EXTRAS_PATH="$(python -c 'import os, litellm_proxy_extras; print(os.path.dirname(litellm_proxy_extras.__file__))')" && \
+ chmod -R g=u,g+w "$PRISMA_PATH" "$PROXY_EXTRAS_PATH" && \
chmod -R a+rX /opt/prisma && \
test -x /opt/prisma/binaries/node_modules/.bin/prisma && \
test -f /opt/prisma/binaries/node_modules/prisma/build/index.js && \
- python -c "from prisma.client import BINARY_PATHS; paths = list(BINARY_PATHS.query_engine.values()); assert paths and all(p.startswith('/opt/prisma/') for p in paths), paths"
+ ls /opt/prisma/binaries/node_modules/@prisma/engines/query-engine-* >/dev/null && \
+ python -c "from prisma.client import BINARY_PATHS; paths = list(BINARY_PATHS.query_engine.values()); assert paths and all(p.startswith('/opt/prisma/') for p in paths), paths" && \
+ python -c "from litellm.rust_bridge import _native" && \
+ python -c "import gateway.launch, backend.main"
-EXPOSE 4000/tcp
+USER 65532:65532
-ENTRYPOINT ["docker/prod_entrypoint.sh"]
-CMD ["--port", "4000"]
+RUN nginx -t
+
+EXPOSE 4000/tcp 4001/tcp 3000/tcp
+
+ENTRYPOINT ["/app/docker-entrypoint.sh"]
diff --git a/README.md b/README.md
index 3b5710fa0c5..31a93bf8c67 100644
--- a/README.md
+++ b/README.md
@@ -398,6 +398,7 @@ Set `LITELLM_PROXY_API_BASE` and `LITELLM_PROXY_API_KEY` and every model call th
| [Deepseek (`deepseek`)](https://docs.litellm.ai/docs/providers/deepseek) | ✅ | ✅ | ✅ | | | | | | | |
| [Eden AI (`edenai`)](https://docs.litellm.ai/docs/providers/edenai) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | |
| [ElevenLabs (`elevenlabs`)](https://docs.litellm.ai/docs/providers/elevenlabs) | ✅ | ✅ | ✅ | | | ✅ | ✅ | | | |
+| [EmpirioLabs AI (`empiriolabs`)](https://docs.litellm.ai/docs/providers/empiriolabs) | ✅ | | ✅ | | | | | | | |
| [Empower (`empower`)](https://docs.litellm.ai/docs/providers/empower) | ✅ | ✅ | ✅ | | | | | | | |
| [eu/jev Decisions API (`eu_jev`)](https://docs.litellm.ai/docs/pass_through/eu_jev) | | | | | | | | | | |
| [Fal AI (`fal_ai`)](https://docs.litellm.ai/docs/providers/fal_ai) | ✅ | ✅ | ✅ | | ✅ | | | | | |
@@ -444,6 +445,7 @@ Set `LITELLM_PROXY_API_BASE` and `LITELLM_PROXY_API_KEY` and every model call th
| [OpenAI-like (`openai_like`)](https://docs.litellm.ai/docs/providers/openai_compatible) | | | | ✅ | | | | | | |
| [OpenRouter (`openrouter`)](https://docs.litellm.ai/docs/providers/openrouter) | ✅ | ✅ | ✅ | | | | | | | |
| [OVHCloud AI Endpoints (`ovhcloud`)](https://docs.litellm.ai/docs/providers/ovhcloud) | ✅ | ✅ | ✅ | | | | | | | |
+| [Parallel AI (`parallel_ai`)](https://docs.litellm.ai/docs/search/parallel_ai) | | | | | | | | | | |
| [Perplexity AI (`perplexity`)](https://docs.litellm.ai/docs/providers/perplexity) | ✅ | ✅ | ✅ | | | | | | | |
| [Petals (`petals`)](https://docs.litellm.ai/docs/providers/petals) | ✅ | ✅ | ✅ | | | | | | | |
| [Pinstripes (`pinstripes`)](https://docs.litellm.ai/docs/providers/pinstripes) | ✅ | ✅ | ✅ | | | | | | | |
diff --git a/backend/Dockerfile b/backend/Dockerfile
deleted file mode 100644
index aad59ba17c6..00000000000
--- a/backend/Dockerfile
+++ /dev/null
@@ -1,146 +0,0 @@
-ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:360896efb0753a5701c48f860e17130c205eae5a264797aa3e7ea126ee2923a7
-ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:360896efb0753a5701c48f860e17130c205eae5a264797aa3e7ea126ee2923a7
-ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a
-
-FROM $UV_IMAGE AS uvbin
-
-# ---------- Rust extension ----------
-# Copies only the native build's inputs, so the fat-LTO compile stays cached across Python-only changes
-FROM $LITELLM_BUILD_IMAGE AS rust-native
-
-WORKDIR /app
-USER root
-
-COPY --from=uvbin /uv /uvx /usr/local/bin/
-
-RUN for i in 1 2 3; do \
- apk add --no-cache bash gcc python-3.13 python-3.13-dev openssl openssl-dev && break; \
- [ $i = 3 ] && { echo "apk add failed after 3 retries" >&2; exit 1; }; \
- sleep 5; \
- done
-
-ENV UV_PYTHON_DOWNLOADS=0
-
-COPY pyproject.toml README.md rust-toolchain.toml ./
-COPY .cargo ./.cargo
-COPY litellm-rust ./litellm-rust
-COPY model_prices_and_context_window.json ./
-
-RUN --mount=type=cache,target=/root/.cache/uv \
- mkdir -p litellm/rust_bridge /wheels && \
- touch litellm/__init__.py litellm/rust_bridge/__init__.py && \
- uvx --python python3.13 --from maturin==1.15.0 --with puccinialin==0.1.14 \
- python -c "import maturin; maturin.build_wheel('/wheels')"
-
-# ---------- Builder ----------
-FROM $LITELLM_BUILD_IMAGE AS builder
-
-WORKDIR /app
-USER root
-
-COPY --from=uvbin /uv /uvx /usr/local/bin/
-
-# nodejs/npm so `prisma generate` uses Wolfi's Node via PRISMA_USE_GLOBAL_NODE
-# instead of nodeenv downloading one whose dynamic deps may not be in Wolfi
-# (e.g. Node 26.2.0 needs libatomic). Retry for transient apk.cgr.dev flakes.
-RUN for i in 1 2 3; do \
- apk add --no-cache bash gcc python-3.13 python-3.13-dev openssl libssl3 openssl-dev libsndfile nodejs npm && break; \
- [ $i = 3 ] && { echo "apk add failed after 3 retries" >&2; exit 1; }; \
- sleep 5; \
- done
-
-# UV_COMPILE_BYTECODE=1 precompiles .pyc at install time → faster cold start.
-# UV_LINK_MODE=copy avoids hardlink warnings when uv installs from a
-# BuildKit cache mount (different filesystem).
-# UV_PYTHON_DOWNLOADS=0 force uv to use the apk-installed CPython instead of
-# silently pulling a managed interpreter.
-# PRISMA_USE_GLOBAL_NODE explicit (matches default) so an env override can't
-# silently re-enable nodeenv's Node download.
-ENV UV_PROJECT_ENVIRONMENT=/app/.venv \
- UV_LINK_MODE=copy \
- UV_COMPILE_BYTECODE=1 \
- UV_PYTHON_DOWNLOADS=0 \
- PRISMA_USE_GLOBAL_NODE=true \
- PATH="/app/.venv/bin:${PATH}"
-
-# Stage 1 — install dependencies only.
-RUN --mount=type=cache,target=/root/.cache/uv \
- --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
- --mount=type=bind,source=uv.lock,target=uv.lock \
- --mount=type=bind,source=enterprise/pyproject.toml,target=enterprise/pyproject.toml \
- --mount=type=bind,source=litellm-proxy-extras/pyproject.toml,target=litellm-proxy-extras/pyproject.toml \
- uv sync --frozen --no-install-project --no-install-workspace --no-default-groups --no-editable \
- --extra proxy \
- --extra proxy-runtime \
- --group admin-mcp \
- --extra extra_proxy \
- --extra semantic-router \
- --extra saml \
- --python python3.13
-
-# Stage 2 — copy source and install the project + workspace members.
-COPY . .
-
-RUN --mount=type=cache,target=/root/.cache/uv \
- uv sync --frozen --no-install-project --no-default-groups --no-editable \
- --extra proxy \
- --extra proxy-runtime \
- --group admin-mcp \
- --extra extra_proxy \
- --extra semantic-router \
- --extra saml \
- --python python3.13
-
-RUN --mount=type=bind,from=rust-native,source=/wheels,target=/wheels \
- uv pip install --python /app/.venv/bin/python --no-deps /wheels/litellm-*.whl
-
-RUN cp "$(python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')"/litellm/rust_bridge/_native*.so litellm/rust_bridge/
-
-RUN HOME=/opt/prisma XDG_CACHE_HOME=/opt/prisma/.cache PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries \
- npm_config_cache=/root/.npm \
- prisma generate --schema=./schema.prisma
-
-RUN sed -i 's/\r$//' docker/component_entrypoint.sh && chmod +x docker/component_entrypoint.sh
-
-# ---------- Runtime ----------
-FROM $LITELLM_RUNTIME_IMAGE AS runtime
-ARG LITELLM_RELEASE_TAG=""
-ENV LITELLM_RELEASE_TAG=${LITELLM_RELEASE_TAG}
-
-USER root
-
-RUN for i in 1 2 3; do \
- apk add --no-cache bash openssl libssl3 tzdata python-3.13 libsndfile libatomic && break; \
- [ $i = 3 ] && { echo "apk add failed after 3 retries" >&2; exit 1; }; \
- sleep 5; \
- done
-
-# wolfi-base ships an unprivileged `nonroot` account (UID/GID 65532) with
-# /home/nonroot. We run the backend as that user
-WORKDIR /app
-ENV HOME=/home/nonroot \
- PATH="/app/.venv/bin:${PATH}" \
- PYTHONPATH="/app" \
- PYTHONDONTWRITEBYTECODE=1 \
- PYTHONUNBUFFERED=1 \
- PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries
-
-COPY --from=builder --chown=nonroot:nonroot /app/.venv /app/.venv
-COPY --from=builder --chown=nonroot:nonroot /app/litellm /app/litellm
-COPY --from=builder --chown=nonroot:nonroot /app/enterprise /app/enterprise
-COPY --from=builder --chown=nonroot:nonroot /app/backend /app/backend
-COPY --from=builder --chown=nonroot:nonroot /app/docker/component_entrypoint.sh /app/docker/component_entrypoint.sh
-COPY --from=builder --chown=nonroot:nonroot /app/schema.prisma /app/schema.prisma
-COPY --from=builder /opt/prisma /opt/prisma
-
-RUN find /app/.venv -type f -path "*/tornado/test/*" -delete && \
- find /app/.venv -type d -path "*/tornado/test" -delete && \
- chmod -R a+rX /opt/prisma && \
- python -c "from prisma.client import BINARY_PATHS; paths = list(BINARY_PATHS.query_engine.values()); assert paths and all(p.startswith('/opt/prisma/') for p in paths), paths"
-
-USER nonroot
-
-EXPOSE 4001/tcp
-
-ENTRYPOINT ["/app/docker/component_entrypoint.sh", "uvicorn", "backend.main:app"]
-CMD ["--host", "0.0.0.0", "--port", "4001"]
diff --git a/ci_cd/security_scans_readme.md b/ci_cd/security_scans_readme.md
index dd64b01c296..3003ea1d105 100644
--- a/ci_cd/security_scans_readme.md
+++ b/ci_cd/security_scans_readme.md
@@ -4,6 +4,5 @@
- Trivy scan on `./docs/` (HIGH/CRITICAL/MEDIUM)
- Trivy scan on `./ui/` (HIGH/CRITICAL/MEDIUM)
-- Grype scan on `Dockerfile.database` (fails on CRITICAL)
- Grype scan on main `Dockerfile` (fails on CRITICAL)
- Grype CVSS ≥ 4.0 scan on main `Dockerfile` (fails any vulnerabilities with CVSS ≥ 4.0)
diff --git a/cookbook/ai_coding_tool_guides/chatgpt_subscription_passthrough.md b/cookbook/ai_coding_tool_guides/chatgpt_subscription_passthrough.md
index e1f606a2eb7..538a5f8a404 100644
--- a/cookbook/ai_coding_tool_guides/chatgpt_subscription_passthrough.md
+++ b/cookbook/ai_coding_tool_guides/chatgpt_subscription_passthrough.md
@@ -46,7 +46,43 @@ For a managed workspace rollout, use OpenAI's [gateway configuration guide](http
## Native compatibility and Pi
-For a native Codex model catalog and request format, change Codex's `base_url` to `https://litellm.example.com/backend-api/codex`. This route uses the same credentials but does not need a model deployment or resolve model aliases. Restricted keys must allow the upstream model name.
+For a native Codex model catalog and request format, change Codex's `base_url` to `https://litellm.example.com/backend-api/codex`. This route uses the same credentials. A ChatGPT model keeps its upstream name and needs no deployment of its own.
+
+### Mix ChatGPT and LiteLLM models
+
+On the native route, Codex's model picker shows OpenAI's catalog first and then the other chat and responses models the virtual key can use. Pick one of those and Codex's requests go through LiteLLM's `/v1/responses` with the key's usual routing, budgets, guardrails, and logging. The proxy removes the ChatGPT bearer and account header from that request, so the other provider and your callbacks never receive them. A name is routed this way when another provider serves it as an exact `model_name`, through a router `model_group_alias`, or as a team's public model name. A ChatGPT model, a name that only a wildcard deployment matches, or a name OpenAI's catalog lists for the caller's ChatGPT account keeps the passthrough, so a model OpenAI adds later still uses the subscription even when a deployment of another provider has the same name. The proxy learns the account's list from the catalog Codex fetches, or asks OpenAI with the caller's login. When it cannot get the list, for example because OpenAI is down, the request times out, or the client is not Codex, every request keeps the passthrough for the next minute, as it did before LiteLLM models were added to the picker. When the key can use many models, the picker lists the ones that fit in Codex's catalog size limit, and the proxy logs a warning with how many it left out.
+
+Codex's picker sends a `none` reasoning effort for a LiteLLM model whose catalog entry lists no effort levels. With `litellm_settings: drop_params: true`, the proxy drops it for a model that does not support `none`, and the provider applies its own default. A model whose cost map entry or `model_info` sets `supports_none_reasoning_effort: true` keeps it. Without `drop_params`, the effort reaches the provider unchanged.
+
+Codex also sends its ChatGPT app tools with every turn, which on a LiteLLM model adds a few hundred thousand prompt tokens to each turn. Set `apps = false` under `[features]` in Codex's `config.toml` to turn them off.
+
+Only a key that may call `/v1/responses` gets these models. A key whose `allowed_routes` covers only the native routes sees OpenAI's catalog unchanged, and every request it sends uses the subscription.
+
+Codex sends earlier reasoning items back with each turn. The proxy tags the reasoning that a LiteLLM model returns on this route, OpenAI and Azure deployments included. When a session switches to a ChatGPT model, the proxy drops those items before forwarding the request to OpenAI, which would reject them. Messages, tool calls, and ChatGPT's own reasoning are kept, and a LiteLLM model still gets its own reasoning back.
+
+When the catalog adds LiteLLM models for a key, its `ETag` is a digest of OpenAI's ETag and those models, and that key's responses carry the same value in `X-Models-Etag`. Codex keeps its cached catalog while the two match and fetches it again when OpenAI's catalog or the key's models change. A key whose catalog adds no LiteLLM models keeps OpenAI's ETags.
+
+### Restrict native models with an access group
+
+A key with a model allowlist needs a rule for ChatGPT names that OpenAI adds over time. Put the subscription wildcards in an access group under `chatgpt/` names:
+
+```yaml
+model_list:
+ - model_name: chatgpt/gpt-*
+ litellm_params:
+ model: chatgpt/gpt-*
+ model_info:
+ access_groups: ["chatgpt-native"]
+ - model_name: chatgpt/codex-*
+ litellm_params:
+ model: chatgpt/codex-*
+ model_info:
+ access_groups: ["chatgpt-native"]
+```
+
+Then add `chatgpt-native` to the key's models, next to any other model names it should reach. On the native route, a key that holds only the `chatgpt/` form of a name is checked as that form, so a request for `gpt-5.6-sol` is allowed when the key may call `chatgpt/gpt-5.6-sol`. The key can call every ChatGPT model that matches the wildcards, including ones the proxy configuration does not name.
+
+On `/v1` these wildcards match only a request that asks for a `chatgpt/` name, so a request for a plain `gpt-` or `codex-` name still goes where it went before, such as a `*` catch-all deployment. A `/v1` request for a `chatgpt/` name without a ChatGPT login falls back to the proxy's own saved login if it has one, so keep that login unset as described above.
### Configure Pi
@@ -71,7 +107,7 @@ Keep Pi's subscription login as the provider credential. The header value names
Send a prompt and check the completed request in LiteLLM's Logs page. Its gateway user/key and token counts should match the caller. Give each person their own LiteLLM virtual key for separate attribution. The gateway credential and ChatGPT login are independently authenticated; LiteLLM does not establish that both identities belong to the same person.
-The native routes are `GET /backend-api/codex/models` and `POST /backend-api/codex/responses`. Model requests use the upstream model name, so a restricted LiteLLM key must allow that name. OpenAI's model catalog is returned in its native format; seeing a model there does not override gateway permissions.
+The native routes are `GET /backend-api/codex/models` and `POST /backend-api/codex/responses`. Model requests use the upstream model name, so a restricted LiteLLM key needs the `chatgpt-native` access group above or that exact name. OpenAI's model catalog is returned in its native format; seeing a model there does not override gateway permissions.
The proxy forwards the ChatGPT bearer and account header to the fixed OpenAI Codex endpoint. It removes gateway credentials and cookies from the upstream request and redacts credential headers in logging callbacks. The client remains responsible for refresh and reauthentication. Native passthrough returns authentication and quota errors without switching subscriptions. Standard model routes retain the caller login across ChatGPT retries; explicitly configured cross-provider fallbacks use their own credentials. An explicit workspace header is preserved for OpenAI to validate.
diff --git a/cookbook/gpt_realtime_translate.py b/cookbook/gpt_realtime_translate.py
new file mode 100644
index 00000000000..827c65cdbfe
--- /dev/null
+++ b/cookbook/gpt_realtime_translate.py
@@ -0,0 +1,245 @@
+#!/usr/bin/env python3
+
+import argparse
+import asyncio
+import base64
+import json
+import os
+import sys
+import wave
+from collections.abc import Iterator, Sequence
+from dataclasses import dataclass
+from pathlib import Path
+from urllib.parse import urlencode, urlsplit, urlunsplit
+
+import websockets
+from websockets.asyncio.client import ClientConnection
+
+SAMPLE_RATE = 24_000
+CHANNELS = 1
+SAMPLE_WIDTH = 2
+CHUNK_DURATION_SECONDS = 0.1
+CHUNK_BYTES = int(SAMPLE_RATE * CHANNELS * SAMPLE_WIDTH * CHUNK_DURATION_SECONDS)
+RESPONSE_TIMEOUT_SECONDS = 30.0
+AUDIO_EVENT_TYPES = frozenset(
+ {
+ "session.output_audio.delta",
+ "response.audio.delta",
+ "response.output_audio.delta",
+ }
+)
+TRANSCRIPT_EVENT_TYPES = frozenset(
+ {
+ "session.output_transcript.delta",
+ "response.text.delta",
+ "response.output_audio_transcript.delta",
+ }
+)
+
+
+@dataclass(frozen=True, slots=True)
+class Settings:
+ input_wav: Path
+ output_wav: Path
+ base_url: str
+ model: str
+ target_language: str
+ trailing_silence_seconds: float
+ api_key: str
+
+
+def write_stdout(message: str = "", *, end: str = "\n", flush: bool = False) -> None:
+ sys.stdout.write(f"{message}{end}")
+ if flush:
+ sys.stdout.flush()
+
+
+def write_stderr(message: str) -> None:
+ sys.stderr.write(f"{message}\n")
+
+
+def parse_args(argv: Sequence[str] | None = None) -> Settings | str:
+ parser = argparse.ArgumentParser(
+ description="Stream a 24 kHz PCM16 WAV through gpt-realtime-translate and save the translated audio",
+ )
+ parser.add_argument("input_wav", type=Path)
+ parser.add_argument("--output", type=Path, default=Path("translated.wav"))
+ parser.add_argument("--base-url", default=os.getenv("LITELLM_BASE_URL", "http://localhost:4000"))
+ parser.add_argument("--model", default=os.getenv("REALTIME_TRANSLATE_MODEL", "gpt-realtime-translate"))
+ parser.add_argument("--target-language", default="fr")
+ parser.add_argument("--trailing-silence", type=float, default=1.5)
+ parsed = parser.parse_args(argv)
+ api_key = os.getenv("LITELLM_API_KEY") or os.getenv("OPENAI_API_KEY")
+ if not api_key:
+ return "Set LITELLM_API_KEY or OPENAI_API_KEY before running the script"
+ if parsed.trailing_silence < 0:
+ return "--trailing-silence must be zero or greater"
+ return Settings(
+ input_wav=parsed.input_wav,
+ output_wav=parsed.output,
+ base_url=parsed.base_url,
+ model=parsed.model,
+ target_language=parsed.target_language,
+ trailing_silence_seconds=parsed.trailing_silence,
+ api_key=api_key,
+ )
+
+
+def translation_url(base_url: str, model: str) -> str | None:
+ parsed = urlsplit(base_url.rstrip("/"))
+ scheme = {"http": "ws", "https": "wss", "ws": "ws", "wss": "wss"}.get(parsed.scheme)
+ if not scheme or not parsed.netloc:
+ return None
+ base_path = parsed.path.rstrip("/")
+ realtime_path = (
+ f"{base_path}/realtime/translations" if base_path.endswith("/v1") else f"{base_path}/v1/realtime/translations"
+ )
+ return urlunsplit((scheme, parsed.netloc, realtime_path, urlencode({"model": model}), ""))
+
+
+def read_pcm16_wav(path: Path) -> bytes | str:
+ try:
+ with wave.open(str(path), "rb") as source:
+ actual_format = (
+ source.getnchannels(),
+ source.getsampwidth(),
+ source.getframerate(),
+ source.getcomptype(),
+ )
+ expected_format = (CHANNELS, SAMPLE_WIDTH, SAMPLE_RATE, "NONE")
+ if actual_format != expected_format:
+ return (
+ f"{path} must be mono, 16-bit PCM, 24 kHz WAV; received "
+ f"channels={actual_format[0]}, sample_width={actual_format[1]}, "
+ f"sample_rate={actual_format[2]}, compression={actual_format[3]}"
+ )
+ return source.readframes(source.getnframes())
+ except (OSError, EOFError, wave.Error) as exc:
+ return f"Unable to read {path}: {exc}"
+
+
+def audio_chunks(audio: bytes) -> Iterator[bytes]:
+ return (audio[offset : offset + CHUNK_BYTES] for offset in range(0, len(audio), CHUNK_BYTES))
+
+
+def audio_message(audio: bytes) -> str:
+ return json.dumps(
+ {
+ "type": "session.input_audio_buffer.append",
+ "audio": base64.b64encode(audio).decode("ascii"),
+ }
+ )
+
+
+async def configure_session(connection: ClientConnection, target_language: str) -> str | None:
+ await connection.send(
+ json.dumps(
+ {
+ "type": "session.update",
+ "session": {"audio": {"output": {"language": target_language}}},
+ }
+ )
+ )
+ while True:
+ raw_event = await asyncio.wait_for(connection.recv(), timeout=20)
+ event = json.loads(raw_event)
+ event_type = event.get("type")
+ if event_type == "session.created":
+ write_stdout(f"Session: {event.get('session', {}).get('id', 'created')}")
+ if event_type == "session.updated":
+ return None
+ if event_type == "error":
+ return f"Realtime API error: {json.dumps(event.get('error', event), ensure_ascii=False)}"
+
+
+async def send_audio(
+ connection: ClientConnection, pcm: bytes, trailing_silence_seconds: float, finished: asyncio.Event
+) -> None:
+ silence = bytes(round(trailing_silence_seconds * SAMPLE_RATE * CHANNELS * SAMPLE_WIDTH))
+ try:
+ for chunk in audio_chunks(pcm + silence):
+ await connection.send(audio_message(chunk))
+ await asyncio.sleep(len(chunk) / (SAMPLE_RATE * CHANNELS * SAMPLE_WIDTH))
+ await connection.send(json.dumps({"type": "session.close"}))
+ finally:
+ finished.set()
+
+
+async def receive_translation(
+ connection: ClientConnection, output_path: Path, sender_finished: asyncio.Event
+) -> str | None:
+ audio_received = asyncio.Event()
+ try:
+ with wave.open(str(output_path), "wb") as output:
+ output.setnchannels(CHANNELS)
+ output.setsampwidth(SAMPLE_WIDTH)
+ output.setframerate(SAMPLE_RATE)
+ write_stdout("Translation: ", end="", flush=True)
+ while True:
+ try:
+ raw_event = await asyncio.wait_for(connection.recv(), timeout=RESPONSE_TIMEOUT_SECONDS)
+ except TimeoutError:
+ if not sender_finished.is_set():
+ continue
+ return (
+ f"The translation stream went quiet for {RESPONSE_TIMEOUT_SECONDS:g} s without closing the session"
+ )
+ event = json.loads(raw_event)
+ event_type = event.get("type")
+ if event_type in AUDIO_EVENT_TYPES:
+ output.writeframes(base64.b64decode(event.get("delta", ""), validate=True))
+ audio_received.set()
+ elif event_type in TRANSCRIPT_EVENT_TYPES:
+ write_stdout(event.get("delta", event.get("text", "")), end="", flush=True)
+ elif event_type == "error":
+ return f"Realtime API error: {json.dumps(event.get('error', event), ensure_ascii=False)}"
+ elif event_type == "session.closed":
+ write_stdout()
+ return None if audio_received.is_set() else "The translation stream ended without translated audio"
+ except (OSError, wave.Error) as exc:
+ return f"Unable to write {output_path}: {exc}"
+
+
+async def translate(settings: Settings, pcm: bytes) -> str | None:
+ url = translation_url(settings.base_url, settings.model)
+ if not url:
+ return f"Invalid --base-url: {settings.base_url}"
+ sender_finished = asyncio.Event()
+ try:
+ async with websockets.connect(
+ url,
+ additional_headers={"Authorization": f"Bearer {settings.api_key}"},
+ proxy=None,
+ open_timeout=20,
+ close_timeout=5,
+ ) as connection:
+ configuration_error = await configure_session(connection, settings.target_language)
+ if configuration_error:
+ return configuration_error
+ async with asyncio.TaskGroup() as tasks:
+ receiver = tasks.create_task(receive_translation(connection, settings.output_wav, sender_finished))
+ tasks.create_task(send_audio(connection, pcm, settings.trailing_silence_seconds, sender_finished))
+ return receiver.result()
+ except Exception as exc:
+ return f"Translation failed: {type(exc).__name__}: {exc}"
+
+
+def main(argv: Sequence[str] | None = None) -> int:
+ settings = parse_args(argv)
+ if isinstance(settings, str):
+ write_stderr(settings)
+ return 2
+ pcm = read_pcm16_wav(settings.input_wav)
+ if isinstance(pcm, str):
+ write_stderr(pcm)
+ return 2
+ error = asyncio.run(translate(settings, pcm))
+ if error:
+ write_stderr(error)
+ return 1
+ write_stdout(f"Translated audio: {settings.output_wav}")
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/cookbook/litellm-ollama-docker-image/Dockerfile b/cookbook/litellm-ollama-docker-image/Dockerfile
deleted file mode 100644
index be237a4df77..00000000000
--- a/cookbook/litellm-ollama-docker-image/Dockerfile
+++ /dev/null
@@ -1,25 +0,0 @@
-FROM ollama/ollama as ollama
-
-RUN echo "auto installing llama2"
-
-# auto install ollama/llama2
-RUN ollama serve & sleep 2 && ollama pull llama2
-
-RUN echo "installing litellm"
-
-RUN apt-get update
-
-# Install Python
-RUN apt-get install -y python3 python3-pip
-
-# Set the working directory in the container
-WORKDIR /app
-
-# Copy the current directory contents into the container at /app
-COPY . /app
-
-# Install any needed packages specified in requirements.txt
-
-RUN python3 -m pip install litellm
-COPY start.sh /start.sh
-ENTRYPOINT [ "/bin/bash", "/start.sh" ]
diff --git a/cookbook/litellm-ollama-docker-image/requirements.txt b/cookbook/litellm-ollama-docker-image/requirements.txt
deleted file mode 100644
index 9b9181b2360..00000000000
--- a/cookbook/litellm-ollama-docker-image/requirements.txt
+++ /dev/null
@@ -1 +0,0 @@
-litellm==1.83.14
diff --git a/cookbook/litellm-ollama-docker-image/start.sh b/cookbook/litellm-ollama-docker-image/start.sh
deleted file mode 100644
index ecc03ce73c5..00000000000
--- a/cookbook/litellm-ollama-docker-image/start.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-ollama serve &
-litellm
\ No newline at end of file
diff --git a/cookbook/litellm-ollama-docker-image/test.py b/cookbook/litellm-ollama-docker-image/test.py
deleted file mode 100644
index 93b9c6ac4a7..00000000000
--- a/cookbook/litellm-ollama-docker-image/test.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import openai
-
-api_base = "http://0.0.0.0:8000"
-
-openai.api_base = api_base
-openai.api_key = "temp-key"
-print(openai.api_base)
-
-
-print("LiteLLM: response from proxy with streaming")
-response = openai.ChatCompletion.create(
- model="ollama/llama2",
- messages=[
- {
- "role": "user",
- "content": "this is a test request, acknowledge that you got it",
- }
- ],
- stream=True,
-)
-
-for chunk in response:
- print(f"LiteLLM: streaming response from proxy {chunk}")
-
-response = openai.ChatCompletion.create(
- model="ollama/llama2",
- messages=[
- {
- "role": "user",
- "content": "this is a test request, acknowledge that you got it",
- }
- ],
-)
-
-print(f"LiteLLM: response from proxy {response}")
diff --git a/cookbook/skill_scanner/README.md b/cookbook/skill_scanner/README.md
new file mode 100644
index 00000000000..2a68e116002
--- /dev/null
+++ b/cookbook/skill_scanner/README.md
@@ -0,0 +1,60 @@
+# Manual skill security scans
+
+This standalone adapter runs NVIDIA SkillSpector on a separate machine. It is not installed in the LiteLLM proxy and does not require a shared Helm or Compose deployment
+
+Start it with Python 3.12 or newer and uv. The script pins SkillSpector and its HTTP dependencies
+
+```sh
+export SKILL_SCANNER_API_KEY="$(openssl rand -hex 32)"
+uv run server.py
+```
+
+For another host, place the loopback service behind an HTTPS reverse proxy that forwards the Authorization header and enforces a 65 MiB request limit. Run it under an unprivileged account with a writable temporary directory and no production files or credentials. The scanner host needs Git and network access to requested sources and optional model providers. Apply network egress restrictions suitable for those sources
+
+Configure the same scanner secret in the gateway's environment, then add this to LiteLLM's configuration
+
+```yaml
+general_settings:
+ skill_scanner:
+ endpoint: https://scanner.example.com/scan
+ api_key_env: SKILL_SCANNER_API_KEY
+ use_llm: false
+ timeout_seconds: 180
+```
+
+The endpoint must be reachable from the gateway. A customer's laptop works while it is reachable through their network, VPN or authenticated HTTPS tunnel. `localhost` refers to the gateway machine, not the admin's browser. HTTP is accepted only for loopback development
+
+Open Skills, Submissions, and Review as a proxy admin. Click **Scan for threats**, inspect the report, then independently approve or reject the proposal. Scanning is optional and never changes approval permissions or blocks publication. The report shows findings, locations, remediation, risk score, scanner version and whether semantic analysis actually ran. Incomplete reports do not establish safety
+
+Uploaded ZIPs are sent privately to the scanner with their exact stored bytes. Metadata-only edits reuse the matching stored archive. If that archive is missing or changed, submit a new ZIP before scanning. The displayed SHA-256 identifies that archive, and the scan examines its files rather than proposed catalog metadata. Remote URL reports describe the source at scan time and do not freeze its contents. GitHub branch/tag refs and explicit-ref subdirectories are supported. Other ref/subdirectory combinations require a ZIP so the adapter does not silently scan the wrong revision
+
+The latest scan result is retained with the submission. Running scans have a deadline. If a gateway restarts or the scanner becomes unavailable, the attempt expires and an admin can retry. Retries replace the latest report. Approving or rejecting during a scan does not cancel it or change the decision
+
+Set `use_llm: true` to request semantic analysis and configure the provider on the scanner machine using [SkillSpector's provider instructions](https://github.com/NVIDIA/skillspector#llm-analysis). Provider credentials stay on that machine. Static analysis can also call OSV for dependency checks
+
+## HTTP contract
+
+The gateway sends an authenticated `POST` to the configured endpoint. The body contains form fields `source` (JSON source descriptor), `use_llm` (boolean), and `expires_at` (timezone-aware ISO timestamp), plus `file` (ZIP) when bytes are available. The service returns HTTP 200 with this JSON shape
+
+```json
+{
+ "scanner_version": "2.12.0",
+ "complete": true,
+ "scan_mode": "static-only",
+ "risk_score": 70,
+ "findings": [{
+ "rule_id": "example-rule",
+ "severity": "HIGH",
+ "message": "Potential data exfiltration",
+ "file": "SKILL.md",
+ "start_line": 8,
+ "explanation": "Instructions request sending local files to an external host",
+ "remediation": "Remove the external upload instruction"
+ }],
+ "limitations": []
+}
+```
+
+Reports are limited to 1 MiB and 500 findings. Scanner uploads allow 64 MiB because the gateway can expand compressed skill uploads into stored compatibility ZIPs. The gateway rejects malformed reports, refuses redirects and verifies TLS. Only the configured scanner credential is sent. A timeout, HTTP error or incomplete report remains visible to the reviewer
+
+The bundled adapter runs at most two child scans concurrently. Each child and its descendants are terminated at the gateway deadline, capped at 570 seconds. Keep the gateway and scanner clocks synchronized. Direct adapter clients may omit `expires_at` to use the cap. Child processes never execute submitted skill scripts. Raise the gateway deadline up to 600 seconds when needed for semantic analysis and configure the reverse proxy timeout to match
diff --git a/cookbook/skill_scanner/server.py b/cookbook/skill_scanner/server.py
new file mode 100644
index 00000000000..44a1cecb00f
--- /dev/null
+++ b/cookbook/skill_scanner/server.py
@@ -0,0 +1,172 @@
+# /// script
+# requires-python = ">=3.12"
+# dependencies = [
+# "fastapi==0.162.0", "uvicorn==0.54.0", "python-multipart==0.0.33",
+# "skillspector @ git+https://github.com/NVIDIA/skillspector.git@62c2fe8622f580ac292d4078c3b71f790194dbbd",
+# ]
+# ///
+import asyncio
+import hmac
+import json
+import os
+import signal
+import sys
+import tempfile
+from contextlib import suppress
+from datetime import datetime, timezone
+from pathlib import Path
+from typing import Annotated, Final
+from urllib.parse import quote, urlsplit
+
+from fastapi import Depends, FastAPI, File, Form, HTTPException, UploadFile
+from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
+from pydantic import AwareDatetime, TypeAdapter, ValidationError
+
+MAX_UPLOAD: Final = 64 * 1024 * 1024
+MAX_REPORT: Final = 1024 * 1024
+SCAN_TIMEOUT: Final = 570
+SOURCE: Final = TypeAdapter(dict[str, str])
+SLOTS: Final = asyncio.Semaphore(2)
+app: Final = FastAPI(title="SkillSpector adapter", docs_url=None, redoc_url=None, openapi_url=None)
+
+
+def authenticate(credentials: Annotated[HTTPAuthorizationCredentials, Depends(HTTPBearer())]) -> None:
+ token: Final = os.environ.get("SKILL_SCANNER_API_KEY", "")
+ if not token or not hmac.compare_digest(credentials.credentials, token):
+ raise HTTPException(401, "Invalid scanner credentials")
+
+
+def source_target(source: dict[str, str]) -> str:
+ target: Final = (
+ "https://github.com/" + source.get("repo", "") if source.get("source") == "github" else source.get("url", "")
+ )
+ parsed: Final = urlsplit(target)
+ if parsed.scheme != "https" or not parsed.hostname or parsed.username or parsed.password or parsed.fragment:
+ raise HTTPException(400, "Remote sources require an HTTPS URL without credentials or a fragment")
+ ref: Final = source.get("ref")
+ subdir: Final = source.get("path")
+ if ref or subdir:
+ if parsed.hostname != "github.com" or len(parsed.path.strip("/").split("/")) != 2 or not ref:
+ raise HTTPException(400, "Upload a ZIP to scan this source's exact ref and subdirectory")
+ suffix: Final = "/" + quote(subdir, safe="/") if subdir else ""
+ return target.removesuffix(".git").rstrip("/") + "/tree/" + quote(ref, safe="/") + suffix
+ return target
+
+
+async def worker(target: str, output: Path, use_llm: bool) -> None:
+ from skillspector.mcp_server import run_scan
+
+ result: Final = await run_scan(target, use_llm=use_llm, allow_local_targets=not target.startswith("https://"))
+ coverage: Final = result.get("analysis_completeness", {})
+ findings: Final = result["findings"]
+ complete: Final = (
+ result.get("execution_successful") is True
+ and coverage.get("is_complete") is True
+ and (not use_llm or (result.get("llm_available") is True and result.get("llm_used") is True))
+ and len(findings) <= 500
+ )
+ limitations: Final = tuple(str(value)[:2000] for value in coverage.get("limitations", ()))
+ report: Final = {
+ "scanner_version": result["version"],
+ "complete": complete,
+ "scan_mode": result["scan_mode"],
+ "risk_score": result["risk_score"],
+ "findings": [
+ {
+ "rule_id": finding["id"],
+ "severity": finding["severity"],
+ "message": finding.get("pattern") or finding.get("finding") or "Security finding",
+ "file": finding["location"]["file"],
+ "start_line": finding["location"].get("start_line"),
+ "explanation": finding.get("explanation"),
+ "remediation": finding.get("remediation"),
+ }
+ for finding in findings[:500]
+ ],
+ "limitations": (
+ *limitations,
+ *(("Only the first 500 findings are displayed.",) if len(findings) > 500 else ()),
+ ),
+ }
+ encoded: Final = json.dumps(report).encode()
+ if len(encoded) > MAX_REPORT:
+ raise ValueError("Scanner report exceeded the response limit")
+ output.write_bytes(encoded)
+
+
+async def run_worker(target: str, output: Path, use_llm: bool, expires_at: datetime | None = None) -> dict[str, object]:
+ timeout: Final = (
+ SCAN_TIMEOUT
+ if expires_at is None
+ else min(SCAN_TIMEOUT, (expires_at - datetime.now(timezone.utc)).total_seconds())
+ )
+ if timeout <= 0:
+ raise HTTPException(504, "SkillSpector scan deadline expired")
+ process: Final = await asyncio.create_subprocess_exec(
+ sys.executable,
+ str(Path(__file__).resolve()),
+ "--scan",
+ target,
+ str(output),
+ str(use_llm).lower(),
+ stdout=asyncio.subprocess.DEVNULL,
+ stderr=asyncio.subprocess.DEVNULL,
+ start_new_session=True,
+ env={
+ **os.environ,
+ "HOME": str(output.parent),
+ "TMPDIR": str(output.parent),
+ "GIT_CONFIG_GLOBAL": os.devnull,
+ "GIT_CONFIG_NOSYSTEM": "1",
+ "GIT_TERMINAL_PROMPT": "0",
+ "GIT_ALLOW_PROTOCOL": "https",
+ },
+ )
+ try:
+ code: Final = await asyncio.wait_for(process.wait(), timeout)
+ if code != 0 or not output.is_file() or output.stat().st_size > MAX_REPORT:
+ raise HTTPException(502, "SkillSpector could not produce a report for this source")
+ return TypeAdapter(dict[str, object]).validate_json(output.read_bytes())
+ except TimeoutError:
+ raise HTTPException(504, "SkillSpector scan timed out") from None
+ finally:
+ with suppress(ProcessLookupError):
+ os.killpg(process.pid, signal.SIGKILL)
+ await process.wait()
+
+
+@app.post("/scan", dependencies=[Depends(authenticate)])
+async def scan(
+ source: Annotated[str, Form(max_length=16384)],
+ use_llm: Annotated[bool, Form()] = False,
+ expires_at: Annotated[AwareDatetime | None, Form()] = None,
+ file: Annotated[UploadFile | None, File()] = None,
+) -> dict[str, object]:
+ if SLOTS.locked():
+ raise HTTPException(429, "Scanner is busy; try again shortly")
+ try:
+ parsed: Final = SOURCE.validate_json(source)
+ except ValidationError:
+ raise HTTPException(400, "Invalid source metadata") from None
+ async with SLOTS:
+ with tempfile.TemporaryDirectory(prefix="skill-scan-") as directory:
+ root: Final = Path(directory)
+ if file is not None:
+ content: Final = await file.read(MAX_UPLOAD + 1)
+ if len(content) > MAX_UPLOAD:
+ raise HTTPException(413, "Upload exceeds 64 MiB")
+ archive: Final = root / "skill.zip"
+ archive.write_bytes(content)
+ return await run_worker(str(archive), root / "report.json", use_llm, expires_at)
+ return await run_worker(source_target(parsed), root / "report.json", use_llm, expires_at)
+
+
+if __name__ == "__main__":
+ if len(sys.argv) > 1 and sys.argv[1] == "--scan":
+ asyncio.run(worker(sys.argv[2], Path(sys.argv[3]), sys.argv[4] == "true"))
+ else:
+ import uvicorn
+
+ if not os.environ.get("SKILL_SCANNER_API_KEY"):
+ raise SystemExit("Set SKILL_SCANNER_API_KEY before starting the scanner")
+ uvicorn.run(app, host="127.0.0.1", port=int(os.environ.get("PORT", "8099")))
diff --git a/docker-compose.hardened.yml b/docker-compose.hardened.yml
deleted file mode 100644
index 84a23faa054..00000000000
--- a/docker-compose.hardened.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-services:
- # Hardened stack: for testing the proxy under non-root, read-only, proxy-enforced constraints.
- # Keep this file focused on hardening/QA scenarios; leave the main docker-compose.yml for default dev usage.
- litellm:
- build:
- context: .
- dockerfile: docker/Dockerfile.non_root
- target: runtime
- depends_on:
- - squid
- user: "101:101"
- group_add:
- - "2345"
- read_only: true
- cap_drop:
- - ALL
- security_opt:
- - no-new-privileges:true
- tmpfs:
- - /app/cache:rw,noexec,nosuid,nodev,size=128m,uid=101,gid=101,mode=1777
- - /app/migrations:rw,noexec,nosuid,nodev,size=64m,uid=101,gid=101,mode=1777
- volumes:
- - ./proxy_server_config.yaml:/app/config.yaml:ro
- environment:
- LITELLM_NON_ROOT: "true"
- PRISMA_BINARY_CACHE_DIR: "/app/cache/prisma-python/binaries"
- XDG_CACHE_HOME: "/app/cache"
- LITELLM_MIGRATION_DIR: "/app/migrations"
- HTTP_PROXY: "http://squid:3128"
- HTTPS_PROXY: "http://squid:3128"
- NO_PROXY: "localhost,127.0.0.1,db"
- command:
- - "--port"
- - "4000"
- - "--config"
- - "/app/config.yaml"
- squid:
- image: sameersbn/squid:3.5.27-2
- restart: unless-stopped
- ports:
- - "3128:3128"
- tmpfs:
- - /var/spool/squid:rw,noexec,nosuid,nodev,size=64m
- - /var/log/squid:rw,noexec,nosuid,nodev,size=16m
diff --git a/docker-compose.yml b/docker-compose.yml
index 80e1f289aad..b012c3763de 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,52 +1,71 @@
+# LiteLLM plus a Postgres database that stores models, virtual keys and spend
+# logs. Used by https://docs.litellm.ai/docs/proxy/docker_quick_start
+#
+# curl -sSLO https://github.com/BerriAI/litellm/raw/main/docker-compose.yml
+# printf 'LITELLM_MASTER_KEY=sk-%s\nLITELLM_SALT_KEY=sk-%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
+# docker compose up -d
+#
+# `docker compose up` runs the published image. From a checkout of the repo,
+# `docker compose up --build` builds the Dockerfile next to this file instead.
+# `docker compose --profile monitoring up -d` also starts Prometheus on 9090.
+#
+# Compose reads .env from this directory. Keep it: regenerating LITELLM_SALT_KEY
+# makes credentials already stored in the database unreadable. A database
+# created without LITELLM_SALT_KEY encrypted them with the master key, so when
+# upgrading one, write only LITELLM_MASTER_KEY (the existing one) to .env. For anything
+# beyond local evaluation, pin the image to a specific release tag.
services:
litellm:
+ image: docker.litellm.ai/berriai/litellm:main-stable
build:
context: .
- args:
- target: runtime
- image: docker.litellm.ai/berriai/litellm:main-stable
- #########################################
- ## Uncomment these lines to start proxy with a config.yaml file ##
- # volumes:
- # - ./config.yaml:/app/config.yaml
- # command:
- # - "--config=/app/config.yaml"
- ##############################################
+ target: runtime
+ pull_policy: missing
ports:
- - "4000:4000" # Map the container port to the host, change the host port if necessary
+ - "4000:4000"
+ # The same image runs every component. The first word of `command` picks
+ # it: proxy (default), gateway, backend, ui, migrations, metrics,
+ # collector. See docker/README.md
+ # command: ["--config", "/app/config.yaml"]
+ # volumes:
+ # - ./config.yaml:/app/config.yaml:ro
environment:
- DATABASE_URL: "postgresql://llmproxy:dbpassword9090@db:5432/litellm"
- # Optional: route read-only queries (find_*, count, group_by, query_raw/_first)
- # to a separate reader endpoint, e.g. an Aurora reader. Leave unset for
- # single-DB deployments. With IAM_TOKEN_DB_AUTH enabled, the reader URL
- # is auto-refreshed alongside the writer.
- # DATABASE_URL_READ_REPLICA: "postgresql://llmproxy:dbpassword9090@db-reader:5432/litellm"
- STORE_MODEL_IN_DB: "True" # allows adding models to proxy via UI
+ LITELLM_MASTER_KEY: ${LITELLM_MASTER_KEY:?set it in .env, see the header of this file}
+ LITELLM_MIGRATION_DIR: /tmp/litellm-migrations
+ DATABASE_URL: postgresql://llmproxy:dbpassword9090@db:5432/litellm
+ STORE_MODEL_IN_DB: "True"
env_file:
- - .env # Load local .env file
+ - path: .env
+ required: false
+ read_only: true
+ cap_drop:
+ - ALL
+ security_opt:
+ - no-new-privileges:true
+ tmpfs:
+ - /tmp:rw,noexec,nosuid,nodev,size=64m,mode=1777
+ - /app/.cache:rw,noexec,nosuid,nodev,size=128m,mode=1777
depends_on:
- - db # Indicates that this service depends on the 'db' service, ensuring 'db' starts first
- healthcheck: # Defines the health check configuration for the container
+ db:
+ condition: service_healthy
+ healthcheck:
test:
- CMD-SHELL
- - python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:4000/health/liveliness')" # Command to execute for health check
- interval: 30s # Perform health check every 30 seconds
- timeout: 10s # Health check command times out after 10 seconds
- retries: 3 # Retry up to 3 times if health check fails
- start_period: 40s # Wait 40 seconds after container start before beginning health checks
+ - python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:4000/health/liveliness')"
+ interval: 30s
+ timeout: 10s
+ retries: 3
+ start_period: 40s
db:
image: postgres:16
restart: always
- container_name: litellm_db
environment:
POSTGRES_DB: litellm
POSTGRES_USER: llmproxy
POSTGRES_PASSWORD: dbpassword9090
- ports:
- - "5432:5432"
volumes:
- - postgres_data:/var/lib/postgresql/data # Persists Postgres data across container restarts
+ - postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -d litellm -U llmproxy"]
interval: 1s
@@ -55,6 +74,8 @@ services:
prometheus:
image: prom/prometheus
+ profiles:
+ - monitoring
volumes:
- prometheus_data:/prometheus
- ./prometheus.yml:/etc/prometheus/prometheus.yml
@@ -68,6 +89,5 @@ services:
volumes:
prometheus_data:
- driver: local
postgres_data:
- name: litellm_postgres_data # Named volume for Postgres data persistence
+ name: litellm_postgres_data
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
new file mode 100755
index 00000000000..7bcb62253a7
--- /dev/null
+++ b/docker-entrypoint.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+# LiteLLM image entrypoint: docker-entrypoint.sh [COMPONENT] [ARGS...]
+#
+# COMPONENT selects the process this container runs; it can also be given as
+# LITELLM_COMPONENT when the command carries no component. Anything after it is
+# passed to that process. A first argument starting with "-" (or no argument at
+# all) keeps the historical behaviour of running the monolithic proxy.
+#
+# proxy litellm ARGS everything in one process (default)
+# gateway python -m gateway.launch ARGS inference routes, 0.0.0.0:4000
+# backend uvicorn backend.main:app ARGS management routes, 0.0.0.0:4001
+# ui nginx serving the admin UI port 3000
+# migrations python migrations/run.py prisma migrate deploy, then exit
+# metrics python -m litellm.proxy.prometheus_metrics_server ARGS
+# collector python -m litellm.proxy.collector ARGS
+# --admin-agent the bundled LiteAdmin Slack agent (litellm-admin-agent --web ARGS)
+#
+# gateway and backend get their host and port defaults first, so ARGS such as
+# --port 8080 override them. An unknown first word is executed as-is (docker run
+# sh), through ddtrace-run like every component when USE_DDTRACE=true. PgBouncer is not a component: LITELLM_PGBOUNCER_ENABLED=true
+# starts it inside proxy and gateway. Components that write Prometheus samples
+# start with an empty PROMETHEUS_MULTIPROC_DIR; metrics, collector and raw
+# readers keep the workers' files, other raw commands clear stale samples.
+set -eu
+
+usage() {
+ awk 'NR == 1 { next } /^#/ { sub(/^# ?/, ""); print; next } { exit }' "$0" >&2
+}
+
+component="${LITELLM_COMPONENT:-proxy}"
+case "${1:-}" in
+ proxy|gateway|backend|ui|migrations|metrics|collector)
+ component="$1"
+ shift
+ ;;
+ --admin-agent)
+ shift
+ export CONNECTION_AUTH_MODE=native
+ exec /opt/liteadmin/bin/litellm-admin-agent --web "$@"
+ ;;
+ ""|-*)
+ ;;
+ help)
+ usage
+ exit 0
+ ;;
+ *)
+ if [ -n "${PROMETHEUS_MULTIPROC_DIR:-}" ]; then
+ mkdir -p "$PROMETHEUS_MULTIPROC_DIR"
+ case "$*" in
+ *litellm.proxy.prometheus_metrics_server*|*litellm.proxy.collector*) ;;
+ *) rm -f "$PROMETHEUS_MULTIPROC_DIR"/*.db "$PROMETHEUS_MULTIPROC_DIR"/litellm_admitted_series_* ;;
+ esac
+ fi
+ component=raw
+ ;;
+esac
+
+case "$component" in
+ raw)
+ ;;
+ proxy)
+ set -- litellm "$@"
+ ;;
+ gateway)
+ set -- python -m gateway.launch --workers "${NUM_WORKERS:-1}" --host 0.0.0.0 --port 4000 "$@"
+ ;;
+ backend)
+ set -- uvicorn backend.main:app --host 0.0.0.0 --port 4001 "$@"
+ ;;
+ ui)
+ sh "$(dirname "$0")/ui/docker-entrypoint.d/40-litellm-runtime-config.sh"
+ exec nginx -g 'daemon off;' "$@"
+ ;;
+ migrations)
+ set -- python /app/migrations/run.py "$@"
+ ;;
+ metrics)
+ set -- python -m litellm.proxy.prometheus_metrics_server "$@"
+ ;;
+ collector)
+ set -- python -m litellm.proxy.collector "$@"
+ ;;
+ *)
+ echo "docker-entrypoint.sh: unknown LITELLM_COMPONENT '$component'" >&2
+ usage
+ exit 64
+ ;;
+esac
+
+if [ -n "${PROMETHEUS_MULTIPROC_DIR:-}" ]; then
+ case "$component" in
+ raw) ;;
+ metrics|collector) mkdir -p "$PROMETHEUS_MULTIPROC_DIR" ;;
+ *)
+ mkdir -p "$PROMETHEUS_MULTIPROC_DIR"
+ rm -f "$PROMETHEUS_MULTIPROC_DIR"/*.db "$PROMETHEUS_MULTIPROC_DIR"/litellm_admitted_series_*
+ ;;
+ esac
+fi
+
+case "${USE_DDTRACE:-}" in
+ [Tt][Rr][Uu][Ee])
+ export DD_TRACE_OPENAI_ENABLED="False"
+ exec ddtrace-run "$@"
+ ;;
+esac
+
+exec "$@"
diff --git a/docker/Dockerfile.database b/docker/Dockerfile.database
deleted file mode 100644
index 20f810686a3..00000000000
--- a/docker/Dockerfile.database
+++ /dev/null
@@ -1,168 +0,0 @@
-# syntax=docker/dockerfile:1.7
-
-# Base image for building
-ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:360896efb0753a5701c48f860e17130c205eae5a264797aa3e7ea126ee2923a7
-
-# Runtime image
-ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:360896efb0753a5701c48f860e17130c205eae5a264797aa3e7ea126ee2923a7
-ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a
-# Pinned by digest like the other base images; bump explicitly on Node upgrades.
-ARG UI_BUILD_IMAGE=node:24.19-alpine3.24@sha256:d32cdf619f63fe0471182d08996dd516c6275bb5fd31ae06e55a570bd9e1ad43
-# Checksum from https://www.pgbouncer.org/downloads/ (the Wolfi repo only carries 1.24.x)
-ARG PGBOUNCER_VERSION=1.26.0
-ARG PGBOUNCER_SHA256=afd25dd61ee6775d37b40629b87ce08736b3e6955f3057bb212e410fbf21c71d
-
-FROM $UV_IMAGE AS uvbin
-
-FROM $LITELLM_BUILD_IMAGE AS pgbouncer-builder
-ARG PGBOUNCER_VERSION
-ARG PGBOUNCER_SHA256
-USER root
-RUN apk add --no-cache build-base pkgconf libevent-dev openssl-dev curl
-WORKDIR /build
-RUN curl -fsSL -o pgbouncer.tar.gz "https://www.pgbouncer.org/downloads/files/${PGBOUNCER_VERSION}/pgbouncer-${PGBOUNCER_VERSION}.tar.gz" && \
- echo "${PGBOUNCER_SHA256} pgbouncer.tar.gz" | sha256sum -c - && \
- tar xzf pgbouncer.tar.gz --strip-components=1 && \
- ./configure --prefix=/usr/local --with-openssl=/usr && \
- make -j"$(nproc)" pgbouncer && \
- install -m 0755 pgbouncer /usr/local/bin/pgbouncer
-
-# Admin UI builder. Pinned to the build platform so the architecture-independent
-# Next.js static export compiles once natively even in a multi-arch build,
-# instead of once per target arch under QEMU.
-FROM --platform=$BUILDPLATFORM $UI_BUILD_IMAGE AS ui-builder
-
-ENV NEXT_TELEMETRY_DISABLED=1 \
- npm_config_fund=false \
- npm_config_audit=false
-
-WORKDIR /ui
-
-COPY ui/litellm-dashboard/package.json ui/litellm-dashboard/package-lock.json ./
-COPY ui/litellm-dashboard/vendor/ ./vendor/
-RUN --mount=type=cache,target=/root/.npm npm ci --prefer-offline
-
-COPY ui/litellm-dashboard/ ./
-RUN npm run build
-
-FROM $LITELLM_BUILD_IMAGE AS builder
-
-WORKDIR /app
-USER root
-
-COPY --from=uvbin /uv /usr/local/bin/uv
-COPY --from=uvbin /uvx /usr/local/bin/uvx
-
-RUN apk add --no-cache \
- bash \
- gcc \
- python-3.13 \
- python-3.13-dev \
- openssl \
- libssl3 \
- openssl-dev \
- nodejs \
- npm \
- libsndfile
-
-ENV UV_PROJECT_ENVIRONMENT=/app/.venv \
- UV_LINK_MODE=copy \
- UV_PYTHON_DOWNLOADS=0 \
- PATH="/app/.venv/bin:${PATH}"
-
-# Copy dependency metadata first for layer caching
-COPY pyproject.toml uv.lock ./
-COPY enterprise/pyproject.toml enterprise/
-COPY litellm-proxy-extras/pyproject.toml litellm-proxy-extras/
-
-# Install third-party dependencies (cached unless pyproject.toml/uv.lock change)
-RUN uv sync --frozen --no-install-project --no-install-workspace --no-default-groups --no-editable \
- --extra proxy \
- --extra proxy-runtime \
- --group admin-mcp \
- --extra extra_proxy \
- --extra semantic-router \
- --extra saml \
- --extra bedrock-realtime \
- --python python3.13
-
-# Copy full source tree
-COPY . .
-
-# Replace the committed UI bundle with the one built from this exact source.
-# Clearing first drops the committed bundle's content-hashed chunks that COPY
-# would otherwise leave behind alongside the fresh ones.
-RUN rm -rf litellm/proxy/_experimental/out
-COPY --from=ui-builder /ui/out/. litellm/proxy/_experimental/out/
-
-# Build Admin UI before final sync (applies the enterprise color override when present)
-RUN sed -i 's/\r$//' docker/build_admin_ui.sh && chmod +x docker/build_admin_ui.sh && ./docker/build_admin_ui.sh
-
-# Install project and workspace packages (fast - deps already cached)
-RUN uv sync --frozen --no-default-groups --no-editable \
- --extra proxy \
- --extra proxy-runtime \
- --group admin-mcp \
- --extra extra_proxy \
- --extra semantic-router \
- --extra saml \
- --extra bedrock-realtime \
- --python python3.13
-
-RUN HOME=/opt/prisma XDG_CACHE_HOME=/opt/prisma/.cache PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries \
- npm_config_cache=/root/.npm \
- prisma generate --schema=./schema.prisma
-
-RUN sed -i 's/\r$//' docker/entrypoint.sh && chmod +x docker/entrypoint.sh && \
- sed -i 's/\r$//' docker/prod_entrypoint.sh && chmod +x docker/prod_entrypoint.sh
-
-FROM $LITELLM_RUNTIME_IMAGE AS runtime
-ARG LITELLM_RELEASE_TAG=""
-ENV LITELLM_RELEASE_TAG=${LITELLM_RELEASE_TAG}
-
-USER root
-
-# node (without npm) is required by the prisma CLI at runtime
-RUN apk add --no-cache bash openssl libssl3 tzdata nodejs python-3.13 libsndfile libevent
-COPY --from=pgbouncer-builder /usr/local/bin/pgbouncer /usr/local/bin/pgbouncer
-
-WORKDIR /app
-ENV PATH="/app/.venv/bin:${PATH}" \
- PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries \
- PRISMA_CLI_PATH=/opt/prisma/binaries/node_modules/.bin/prisma \
- PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
- PRISMA_OFFLINE_MODE=true
-
-# Copy only what runtime needs. The application is installed inside the venv;
-# the rest of the builder's /app is source and build metadata that must not
-# ship (manifest-scanning tools attribute everything in it to this image).
-# entrypoint.sh invokes litellm/proxy/prisma_migration.py by source path.
-COPY --from=builder /app/.venv /app/.venv
-COPY --from=builder /app/docker /app/docker
-COPY --from=builder /app/schema.prisma /app/schema.prisma
-COPY --from=builder /app/litellm/proxy/prisma_migration.py /app/litellm/proxy/prisma_migration.py
-# enterprise/ is imported by source path at runtime (proxy_cli puts the
-# working directory on sys.path; litellm/proxy/hooks resolves
-# enterprise.enterprise_hooks from it)
-COPY --from=builder /app/enterprise /app/enterprise
-COPY --from=builder /app/litellm-proxy-extras /app/litellm-proxy-extras
-# Prisma CLI + engines are baked under /opt/prisma, a fixed path every
-# runtime uid can read and that no cache volume mount shadows (unlike
-# /app/.cache or $HOME/.cache in readOnlyRootFilesystem + emptyDir setups).
-# The paths are pinned via PRISMA_BINARY_CACHE_DIR / PRISMA_CLI_PATH and
-# recorded into the generated client at build time, so `prisma migrate
-# deploy` on a fresh database needs no npm and no network access
-# (#33650, #24554).
-COPY --from=builder /opt/prisma /opt/prisma
-
-RUN find /app/.venv -type f -path "*/tornado/test/*" -delete && \
- find /app/.venv -type d -path "*/tornado/test" -delete && \
- chmod -R a+rX /opt/prisma && \
- test -x /opt/prisma/binaries/node_modules/.bin/prisma && \
- test -f /opt/prisma/binaries/node_modules/prisma/build/index.js && \
- python -c "from prisma.client import BINARY_PATHS; paths = list(BINARY_PATHS.query_engine.values()); assert paths and all(p.startswith('/opt/prisma/') for p in paths), paths"
-
-EXPOSE 4000/tcp
-
-ENTRYPOINT ["docker/prod_entrypoint.sh"]
-CMD ["--port", "4000"]
diff --git a/docker/Dockerfile.non_root b/docker/Dockerfile.non_root
deleted file mode 100644
index 90bcc523d9e..00000000000
--- a/docker/Dockerfile.non_root
+++ /dev/null
@@ -1,208 +0,0 @@
-# syntax=docker/dockerfile:1.7
-
-# Base images
-ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:360896efb0753a5701c48f860e17130c205eae5a264797aa3e7ea126ee2923a7
-ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:360896efb0753a5701c48f860e17130c205eae5a264797aa3e7ea126ee2923a7
-ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a
-# Pinned by digest like the other base images; bump explicitly on Node upgrades.
-ARG UI_BUILD_IMAGE=node:24.19-alpine3.24@sha256:d32cdf619f63fe0471182d08996dd516c6275bb5fd31ae06e55a570bd9e1ad43
-# Checksum from https://www.pgbouncer.org/downloads/ (the Wolfi repo only carries 1.24.x)
-ARG PGBOUNCER_VERSION=1.26.0
-ARG PGBOUNCER_SHA256=afd25dd61ee6775d37b40629b87ce08736b3e6955f3057bb212e410fbf21c71d
-
-FROM $UV_IMAGE AS uvbin
-
-FROM $LITELLM_BUILD_IMAGE AS pgbouncer-builder
-ARG PGBOUNCER_VERSION
-ARG PGBOUNCER_SHA256
-USER root
-RUN apk add --no-cache build-base pkgconf libevent-dev openssl-dev curl
-WORKDIR /build
-RUN curl -fsSL -o pgbouncer.tar.gz "https://www.pgbouncer.org/downloads/files/${PGBOUNCER_VERSION}/pgbouncer-${PGBOUNCER_VERSION}.tar.gz" && \
- echo "${PGBOUNCER_SHA256} pgbouncer.tar.gz" | sha256sum -c - && \
- tar xzf pgbouncer.tar.gz --strip-components=1 && \
- ./configure --prefix=/usr/local --with-openssl=/usr && \
- make -j"$(nproc)" pgbouncer && \
- install -m 0755 pgbouncer /usr/local/bin/pgbouncer
-
-# Admin UI builder. Pinned to the build platform so the architecture-independent
-# Next.js static export compiles once natively even in a multi-arch build,
-# instead of once per target arch under QEMU.
-FROM --platform=$BUILDPLATFORM $UI_BUILD_IMAGE AS ui-builder
-
-ENV NEXT_TELEMETRY_DISABLED=1 \
- npm_config_fund=false \
- npm_config_audit=false
-
-WORKDIR /ui
-
-COPY ui/litellm-dashboard/package.json ui/litellm-dashboard/package-lock.json ./
-COPY ui/litellm-dashboard/vendor/ ./vendor/
-RUN --mount=type=cache,target=/root/.npm npm ci --prefer-offline
-
-COPY ui/litellm-dashboard/ ./
-RUN npm run build
-
-FROM $LITELLM_BUILD_IMAGE AS builder
-WORKDIR /app
-USER root
-
-COPY --from=uvbin /uv /usr/local/bin/uv
-COPY --from=uvbin /uvx /usr/local/bin/uvx
-
-RUN for i in 1 2 3; do \
- apk add --no-cache \
- python-3.13 \
- python-3.13-dev \
- gcc \
- rust \
- bash \
- coreutils \
- curl \
- openssl \
- libssl3 \
- libsndfile \
- nodejs \
- npm && break || sleep 5; \
- done
-
-ENV UV_PROJECT_ENVIRONMENT=/app/.venv \
- UV_LINK_MODE=copy \
- UV_PYTHON_DOWNLOADS=0 \
- PATH="/app/.venv/bin:${PATH}" \
- LITELLM_NON_ROOT=true \
- XDG_CACHE_HOME=/app/.cache
-
-# Copy dependency metadata first for layer caching
-COPY pyproject.toml uv.lock ./
-COPY enterprise/pyproject.toml enterprise/
-COPY litellm-proxy-extras/pyproject.toml litellm-proxy-extras/
-
-# Install third-party dependencies (cached unless pyproject.toml/uv.lock change)
-RUN --mount=type=cache,target=/app/.cache/uv,id=litellm-uv-cache \
- uv sync --frozen --no-install-project --no-install-workspace --no-default-groups --no-editable \
- --extra proxy \
- --extra proxy-runtime \
- --group admin-mcp \
- --extra extra_proxy \
- --extra semantic-router \
- --extra saml \
- --extra bedrock-realtime \
- --python python3.13
-
-# Copy full source tree
-COPY . .
-
-# Replace the committed UI bundle with the one built from this exact source.
-# Clearing first drops the committed bundle's content-hashed chunks that COPY
-# would otherwise leave behind alongside the fresh ones.
-RUN rm -rf litellm/proxy/_experimental/out
-COPY --from=ui-builder /ui/out/. litellm/proxy/_experimental/out/
-
-# Set non-root flag for build time consistency
-ENV LITELLM_NON_ROOT=true
-
-RUN mkdir -p /var/lib/litellm/ui /var/lib/litellm/assets && \
- cp -r /app/litellm/proxy/_experimental/out/. /var/lib/litellm/ui/ && \
- cp /app/litellm/proxy/logo.png /var/lib/litellm/assets/logo.png && \
- touch /var/lib/litellm/ui/.litellm_ui_ready
-
-RUN --mount=type=cache,target=/app/.cache/uv,id=litellm-uv-cache \
- uv sync --frozen --no-default-groups --no-editable \
- --extra proxy \
- --extra proxy-runtime \
- --group admin-mcp \
- --extra extra_proxy \
- --extra semantic-router \
- --extra saml \
- --extra bedrock-realtime \
- --python python3.13
-
-RUN HOME=/opt/prisma XDG_CACHE_HOME=/opt/prisma/.cache PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries \
- npm_config_cache=/root/.npm \
- prisma generate --schema=./schema.prisma
-
-RUN sed -i 's/\r$//' docker/entrypoint.sh && chmod +x docker/entrypoint.sh && \
- sed -i 's/\r$//' docker/prod_entrypoint.sh && chmod +x docker/prod_entrypoint.sh
-
-FROM $LITELLM_RUNTIME_IMAGE AS runtime
-ARG LITELLM_RELEASE_TAG=""
-ENV LITELLM_RELEASE_TAG=${LITELLM_RELEASE_TAG}
-WORKDIR /app
-USER root
-
-RUN for i in 1 2 3; do \
- apk upgrade --no-cache && break || sleep 5; \
- done && \
- for i in 1 2 3; do \
- apk add --no-cache python-3.13 bash openssl libssl3 tzdata libsndfile nodejs libevent && break || sleep 5; \
- done
-COPY --from=pgbouncer-builder /usr/local/bin/pgbouncer /usr/local/bin/pgbouncer
-
-# Copy only what runtime needs. The application is installed inside the venv;
-# the rest of the builder's /app is source and build metadata that must not
-# ship (manifest-scanning tools attribute everything in it to this image).
-# entrypoint.sh invokes litellm/proxy/prisma_migration.py by source path.
-COPY --from=builder /app/.venv /app/.venv
-COPY --from=builder /app/docker /app/docker
-COPY --from=builder /app/schema.prisma /app/schema.prisma
-COPY --from=builder /app/litellm/proxy/prisma_migration.py /app/litellm/proxy/prisma_migration.py
-# enterprise/ is imported by source path at runtime (proxy_cli puts the
-# working directory on sys.path; litellm/proxy/hooks resolves
-# enterprise.enterprise_hooks from it)
-COPY --from=builder /app/enterprise /app/enterprise
-COPY --from=builder /app/litellm-proxy-extras /app/litellm-proxy-extras
-# Prisma CLI + engines are baked under /opt/prisma, a fixed path every runtime
-# uid can read and that no cache volume mount shadows (unlike /app/.cache or
-# $HOME/.cache under readOnlyRootFilesystem + emptyDir or arbitrary-uid setups).
-# PRISMA_CLI_QUERY_ENGINE_TYPE=binary makes the CLI use the baked binary query
-# engine directly, so `prisma migrate deploy` on a fresh database needs no npm
-# and no network access; without it the CLI looks for the library engine, which
-# prisma stopped baking, and falls back to a download that fails offline or as a
-# non-writable uid (#33650, #24554).
-COPY --from=builder /opt/prisma /opt/prisma
-COPY --from=builder /var/lib/litellm/ui /var/lib/litellm/ui
-COPY --from=builder /var/lib/litellm/assets /var/lib/litellm/assets
-
-# XDG_CACHE_HOME is intentionally left unset so it falls back to $HOME/.cache
-# (/app/.cache, writable by the runtime uid). The prisma bake at the read-only
-# /opt/prisma is anchored by PRISMA_BINARY_CACHE_DIR / PRISMA_CLI_PATH, so
-# nothing needs XDG to point there; pointing it at the read-only bake would
-# deny any XDG-aware library that writes a cache at runtime.
-ENV PATH="/app/.venv/bin:${PATH}" \
- PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries \
- PRISMA_CLI_PATH=/opt/prisma/binaries/node_modules/.bin/prisma \
- PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
- HOME=/app \
- LITELLM_NON_ROOT=true \
- PRISMA_SKIP_POSTINSTALL_GENERATE=1 \
- PRISMA_HIDE_UPDATE_MESSAGE=1 \
- PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING=1 \
- PRISMA_OFFLINE_MODE=true
-
-RUN mkdir -p /nonexistent /app/.cache /var/lib/litellm/assets /var/lib/litellm/ui && \
- chown -R nobody:nogroup /app /var/lib/litellm/ui /var/lib/litellm/assets /nonexistent && \
- PRISMA_PATH=$(python -c "import os, prisma; print(os.path.dirname(prisma.__file__))") && \
- chown -R nobody:nogroup "$PRISMA_PATH" && \
- LITELLM_PKG_MIGRATIONS_PATH="$(python -c 'import os, litellm_proxy_extras; print(os.path.dirname(litellm_proxy_extras.__file__))' 2>/dev/null || echo '')/migrations" && \
- [ -n "$LITELLM_PKG_MIGRATIONS_PATH" ] && chown -R nobody:nogroup "$LITELLM_PKG_MIGRATIONS_PATH" || true && \
- LITELLM_PROXY_EXTRAS_PATH=$(python -c "import os, litellm_proxy_extras; print(os.path.dirname(litellm_proxy_extras.__file__))" 2>/dev/null || echo "") && \
- chgrp -R 0 "$PRISMA_PATH" /var/lib/litellm/ui /var/lib/litellm/assets && \
- [ -n "$LITELLM_PROXY_EXTRAS_PATH" ] && chgrp -R 0 "$LITELLM_PROXY_EXTRAS_PATH" || true && \
- chmod -R g=u "$PRISMA_PATH" /var/lib/litellm/ui /var/lib/litellm/assets && \
- [ -n "$LITELLM_PROXY_EXTRAS_PATH" ] && chmod -R g=u "$LITELLM_PROXY_EXTRAS_PATH" || true && \
- chmod -R g+w "$PRISMA_PATH" /var/lib/litellm/ui /var/lib/litellm/assets && \
- [ -n "$LITELLM_PROXY_EXTRAS_PATH" ] && chmod -R g+w "$LITELLM_PROXY_EXTRAS_PATH" || true && \
- chmod -R g+rX "$PRISMA_PATH" /var/lib/litellm/ui /var/lib/litellm/assets && \
- chmod -R a+rX /opt/prisma && \
- test -x /opt/prisma/binaries/node_modules/.bin/prisma && \
- test -f /opt/prisma/binaries/node_modules/prisma/build/index.js && \
- ls /opt/prisma/binaries/node_modules/@prisma/engines/query-engine-* >/dev/null 2>&1 && \
- python -c "from prisma.client import BINARY_PATHS; paths = list(BINARY_PATHS.query_engine.values()); assert paths and all(p.startswith('/opt/prisma/') for p in paths), paths"
-
-USER 65534
-
-EXPOSE 4000/tcp
-
-ENTRYPOINT ["/app/docker/prod_entrypoint.sh"]
-CMD ["--port", "4000"]
diff --git a/docker/README.md b/docker/README.md
index ac82c6caebf..3ec26219420 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -2,15 +2,15 @@
This guide provides instructions for building and running the LiteLLM application using Docker and Docker Compose.
-> **Just want to run LiteLLM?** This guide builds from source. To run the published
-> image instead, use `docker-compose.quickstart.yml` in this directory — the
-> two-service stack (gateway + Postgres) that the
-> [Docker quickstart](https://docs.litellm.ai/docs/proxy/docker_quick_start) documents:
+> **Just want to run LiteLLM?** `docker-compose.yml` in the repository root runs
+> the published image with a Postgres database, the stack the
+> [Docker quickstart](https://docs.litellm.ai/docs/proxy/docker_quick_start) documents,
+> and it works on its own outside a checkout:
>
> ```bash
-> curl -sSLO https://github.com/BerriAI/litellm/raw/main/docker/docker-compose.quickstart.yml
+> curl -sSLO https://github.com/BerriAI/litellm/raw/main/docker-compose.yml
> printf 'LITELLM_MASTER_KEY=sk-%s\nLITELLM_SALT_KEY=sk-%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
-> docker compose -f docker-compose.quickstart.yml up -d
+> docker compose up -d
> ```
## Prerequisites
@@ -20,33 +20,52 @@ This guide provides instructions for building and running the LiteLLM applicatio
## Building and Running the Application
-To build and run the application, you will use the `docker-compose.yml` file located in the root of the project. This file is configured to use the `Dockerfile.non_root` for a secure, non-root container environment.
+The same `docker-compose.yml` builds from source when you pass `--build`: it builds the `Dockerfile` in the repository root, the one image LiteLLM ships. `docker-entrypoint.sh` next to it is the only entrypoint script; every container starts through it
-### 1. Set the Master Key
+## One image, many components
-The application requires a `LITELLM_MASTER_KEY` for signing and validating tokens. You must set this key as an environment variable before running the application.
+Every LiteLLM container runs the same image. The first word of the container command (or the `LITELLM_COMPONENT` environment variable when the command carries only flags) picks the process the container runs, and everything after it is handed to that process unchanged:
-Create a `.env` file in the root of the project and add the following line:
+| Component | Runs | Port |
+|--------------|-----------------------------------------------------|------|
+| `proxy` | `litellm ...` (everything in one process, default) | 4000 |
+| `gateway` | `python -m gateway.launch ...` (inference routes) | 4000 |
+| `backend` | `uvicorn backend.main:app ...` (management routes) | 4001 |
+| `ui` | nginx serving the static admin UI | 3000 |
+| `migrations` | `python migrations/run.py`, `prisma migrate deploy` then exit | |
+| `metrics` | `python -m litellm.proxy.prometheus_metrics_server ...` | `--port` |
+| `collector` | `python -m litellm.proxy.collector ...` | |
-```
-LITELLM_MASTER_KEY=your-secret-key
+```bash
+docker run -p 4000:4000 litellm --config /app/config.yaml # proxy, exactly as before
+docker run -p 4000:4000 litellm gateway --port 4000 # componentized data plane
+docker run -p 4001:4001 -e LITELLM_COMPONENT=backend litellm # same, chosen through the env
+docker run -p 3000:3000 --read-only --tmpfs /tmp litellm ui # admin UI behind nginx
+docker run -e DATABASE_URL=... litellm migrations # one-off schema migration job
+docker run -it litellm sh # anything else runs verbatim
```
-Replace `your-secret-key` with a strong, randomly generated secret.
+PgBouncer is not a separate component: `LITELLM_PGBOUNCER_ENABLED=true` starts an in-container PgBouncer in front of `DATABASE_URL` inside `proxy` and `gateway`. `USE_DDTRACE=true` wraps whichever component runs with `ddtrace-run`, and `PROMETHEUS_MULTIPROC_DIR` is emptied of stale samples before any workers fork (the `metrics` and `collector` sidecars only read it, so their restart keeps the live samples)
+
+The image runs as uid `65532` (`nonroot` in the Wolfi base) and also works as an arbitrary uid in gid 0, the shape OpenShift `restricted-v2` assigns, because everything it writes at runtime lives under `/app/.cache`, `/var/lib/litellm` and `/tmp`. Mount those (or set `readOnlyRootFilesystem` with emptyDirs there) for a read-only root filesystem. Prisma's CLI and engines are baked under `/opt/prisma`, so migrations need neither network nor a writable home
+
+### 1. Set the Master and Salt Keys
+
+The proxy signs virtual keys with `LITELLM_MASTER_KEY` and encrypts stored provider credentials with `LITELLM_SALT_KEY`. Compose reads both from a `.env` file in the directory you run it from, so generate them once:
+
+```bash
+printf 'LITELLM_MASTER_KEY=sk-%s\nLITELLM_SALT_KEY=sk-%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
+```
+
+Keep the file: regenerating `LITELLM_SALT_KEY` makes credentials already stored in the database unreadable. A database created without `LITELLM_SALT_KEY` encrypted them with the master key, so when upgrading one, write only the existing `LITELLM_MASTER_KEY` to `.env` and leave `LITELLM_SALT_KEY` out. Provider keys such as `OPENAI_API_KEY` go in the same file, and the whole file is passed to the container
### 2. Build and Run the Containers
-Once you have set the `LITELLM_MASTER_KEY`, you can build and run the containers using the following command:
-
```bash
docker compose up -d --build
```
-This command will:
-
-- Build the Docker image using `Dockerfile.non_root`.
-- Start the `litellm`, `litellm_db`, and `prometheus` services in detached mode (`-d`).
-- The `--build` flag ensures that the image is rebuilt if there are any changes to the Dockerfile or the application code.
+This command builds the image from the root `Dockerfile` and starts the `litellm` and `db` services in detached mode. Without `--build`, `docker compose up` pulls the published `main-stable` image instead. Add `--profile monitoring` to also start Prometheus on port 9090, scraping the proxy with the root `prometheus.yml`
### 3. Verifying the Application is Running
@@ -80,13 +99,13 @@ LITELLM_LICENSE="your-enterprise-license"
PROXY_BASE_URL=https://gateway.example.com
```
-For the unified source deployment described above, put them in its `.env` file and rebuild:
+For the compose deployment described above, put them in its `.env` file and rebuild:
```bash
docker compose up -d --build
```
-In componentized deployments, set the flag and license on the backend container and route `/admin/mcp` to the backend service. The gateway component excludes this endpoint. The unified, database, non-root, and backend image builds bundle the connector
+In componentized deployments, set the flag and license on the `backend` component and route `/admin/mcp` to it. The `gateway` component excludes this endpoint. The image bundles the connector for every component
Hosting is disabled by default. Opting in requires a valid base Enterprise license; an unlicensed opt-in or invalid flag value prevents startup. Enabling it reserves `/admin`, so rename any MCP server alias called `admin` first
@@ -96,34 +115,18 @@ Embedded responses default to `full`; selecting `LITELLM_ADMIN_RESPONSE_VIEW=com
See the [LiteAdmin MCP guide](https://docs.litellm.ai/docs/proxy/liteadmin_mcp#run-liteadmin-mcp-inside-litellm) for client configuration, tool restrictions, and verification
-## Hardened / Offline Testing
+## Hardening
-To ensure changes are safe for non-root, read-only root filesystems and restricted egress, always validate with the hardened compose file:
+The compose file runs the proxy the way a locked-down cluster would: as the image's non-root user with a read-only root filesystem, every capability dropped, `no-new-privileges` set, and tmpfs mounts only at `/tmp` and `/app/.cache`. The image is built for that, so a change that makes the proxy write anywhere else fails here before it fails in Kubernetes. To try an arbitrary uid in gid 0, the shape OpenShift `restricted-v2` assigns, add `user: "101:0"` to the `litellm` service
+
+Prisma's CLI and engines are baked under `/opt/prisma`, so migrations run without network access. Verify with:
```bash
-docker compose -f docker-compose.yml -f docker-compose.hardened.yml build --no-cache
-docker compose -f docker-compose.yml -f docker-compose.hardened.yml up -d
+docker run --rm --network none --entrypoint prisma docker.litellm.ai/berriai/litellm:main-stable --version
```
-This setup:
-- Builds from `docker/Dockerfile.non_root` with Prisma engines and Node toolchain baked into the image.
-- Runs the proxy as a non-root user with a read-only rootfs and only writable tmpfs mounts:
- - `/app/cache` (Prisma/NPM cache; backing `PRISMA_BINARY_CACHE_DIR`, `NPM_CONFIG_CACHE`, `XDG_CACHE_HOME`)
- - `/app/migrations` (Prisma migration workspace; backing `LITELLM_MIGRATION_DIR`)
-- Pre-builds and serves the admin UI from read-only paths:
- - `/var/lib/litellm/ui` (pre-restructured Next.js UI with `.litellm_ui_ready` marker)
- - `/var/lib/litellm/assets` (UI logos and assets)
-- Routes all outbound traffic through a local Squid proxy that denies egress, so Prisma migrations must use the cached CLI and engines.
-
-You should also verify offline Prisma behaviour with:
-
-```bash
-docker run --rm --network none --entrypoint prisma ghcr.io/berriai/litellm:main-stable --version
-```
-
-This command should succeed (showing engine versions) even with `--network none`, confirming that Prisma binaries are available without network access.
-
## Troubleshooting
-- **`build_admin_ui.sh: not found`**: This error can occur if the Docker build context is not set correctly. Ensure that you are running the `docker-compose` command from the root of the project.
-- **`Master key is not initialized`**: This error means the `LITELLM_MASTER_KEY` environment variable is not set. Make sure you have created a `.env` file in the project root with the `LITELLM_MASTER_KEY` defined.
+- **`required variable LITELLM_MASTER_KEY is missing a value`**: Compose did not find a `.env` file with `LITELLM_MASTER_KEY` in the directory you ran it from. Generate one as shown above.
+- **`password authentication failed for user "llmproxy"`**: the `litellm_postgres_data` volume was initialised by an older compose file with different credentials. `docker compose down -v` drops it and the next `up` recreates the database.
+- **`build_admin_ui.sh: not found`**: the build context is wrong. Run `docker compose` from the root of the repository.
diff --git a/docker/build_from_pip/Dockerfile.build_from_pip b/docker/build_from_pip/Dockerfile.build_from_pip
deleted file mode 100644
index 25a7ed2fa97..00000000000
--- a/docker/build_from_pip/Dockerfile.build_from_pip
+++ /dev/null
@@ -1,64 +0,0 @@
-ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.10.9@sha256:10902f58a1606787602f303954cea099626a4adb02acbac4c69920fe9d278f82
-FROM $UV_IMAGE AS uvbin
-
-FROM python:3.13-slim@sha256:739e7213785e88c0f702dcdc12c0973afcbd606dbf021a589cab77d6b00b579d
-
-ARG LITELLM_VERSION=1.83.0
-
-WORKDIR /app
-
-COPY --from=uvbin /uv /usr/local/bin/uv
-COPY --from=uvbin /uvx /usr/local/bin/uvx
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends gcc libffi-dev nodejs npm && \
- rm -rf /var/lib/apt/lists/*
-
-ENV UV_PROJECT_ENVIRONMENT=/app/.venv \
- UV_LINK_MODE=copy \
- PATH="/app/.venv/bin:${PATH}"
-
-COPY schema.prisma .
-
-# This image is specifically for validating/installing the published PyPI
-# artifact, not the checked-out source tree.
-# Keep the moved proxy-runtime packages explicit until the published PyPI
-# artifact includes that extra; newer releases will simply dedupe these.
-RUN uv venv --python python && \
- uv pip install --python /app/.venv/bin/python \
- "litellm[proxy,proxy-runtime]==${LITELLM_VERSION}" \
- "google-cloud-aiplatform==1.133.0" \
- "google-genai==1.37.0" \
- "anthropic[vertex]==0.84.0" \
- "grpcio==1.84.1" \
- "prometheus-client==0.20.0" \
- "langfuse==2.59.7" \
- "opentelemetry-api==1.28.0" \
- "opentelemetry-sdk==1.28.0" \
- "opentelemetry-exporter-otlp==1.28.0" \
- "ddtrace==4.11.0" \
- "sentry-sdk==2.21.0" \
- "mangum==0.17.0" \
- "azure-ai-contentsafety==1.0.0" \
- "azure-storage-file-datalake==12.20.0" \
- "pypdf==6.7.5" \
- "llm-sandbox==0.3.31" \
- "detect-secrets==1.5.0" \
- "prisma==0.11.0" \
- "openai==2.24.0"
-
-RUN HOME=/opt/prisma XDG_CACHE_HOME=/opt/prisma/.cache PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries \
- npm_config_cache=/root/.npm \
- prisma generate --schema=./schema.prisma && \
- chmod -R a+rX /opt/prisma && \
- python -c "import sys; from prisma.client import BINARY_PATHS; bad = sorted(p for group in BINARY_PATHS.model_dump().values() for p in group.values() if not p.startswith('/opt/prisma/')); sys.exit('prisma engines baked outside /opt/prisma: %r' % bad) if bad else None"
-
-ENV PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries
-
-COPY docker/prod_entrypoint.sh /app/docker/prod_entrypoint.sh
-RUN sed -i 's/\r$//' /app/docker/prod_entrypoint.sh && chmod +x /app/docker/prod_entrypoint.sh
-
-EXPOSE 4000/tcp
-
-ENTRYPOINT ["/app/docker/prod_entrypoint.sh"]
-CMD ["--port", "4000"]
diff --git a/docker/build_from_pip/Readme.md b/docker/build_from_pip/Readme.md
deleted file mode 100644
index ad043588f33..00000000000
--- a/docker/build_from_pip/Readme.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Docker to build LiteLLM Proxy from litellm pip package
-
-### When to use this ?
-
-If you need to build LiteLLM Proxy from litellm pip package, you can use this Dockerfile as a reference.
-
-### Why build from pip package ?
-
-- If your company has a strict requirement around security / building images you can follow steps outlined here
\ No newline at end of file
diff --git a/docker/component_entrypoint.sh b/docker/component_entrypoint.sh
deleted file mode 100755
index 3cd530e3009..00000000000
--- a/docker/component_entrypoint.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-# stale samples from a previous container incarnation would be summed into the aggregate
-if [ -n "$PROMETHEUS_MULTIPROC_DIR" ]; then
- mkdir -p "$PROMETHEUS_MULTIPROC_DIR"
- rm -f "$PROMETHEUS_MULTIPROC_DIR"/*.db "$PROMETHEUS_MULTIPROC_DIR"/litellm_admitted_series_*
-fi
-
-case "$USE_DDTRACE" in
- [Tt][Rr][Uu][Ee])
- export DD_TRACE_OPENAI_ENABLED="False"
- exec ddtrace-run "$@"
- ;;
-esac
-
-exec "$@"
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
deleted file mode 100755
index 003d9b21db8..00000000000
--- a/docker/entrypoint.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-
-REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
-VENV_PYTHON="$REPO_ROOT/.venv/bin/python"
-MIGRATION_SCRIPT="$REPO_ROOT/litellm/proxy/prisma_migration.py"
-
-if [ -x "$VENV_PYTHON" ]; then
- "$VENV_PYTHON" "$MIGRATION_SCRIPT"
-elif command -v uv >/dev/null 2>&1; then
- (cd "$REPO_ROOT" && uv run --no-sync python "$MIGRATION_SCRIPT")
-else
- python3 "$MIGRATION_SCRIPT"
-fi
-
-echo "Migration script ran successfully!"
diff --git a/docker/install_auto_router.sh b/docker/install_auto_router.sh
deleted file mode 100755
index 4fedf201b41..00000000000
--- a/docker/install_auto_router.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-
-# semantic-router dependencies are installed via `uv sync`.
diff --git a/docker/prod_entrypoint.sh b/docker/prod_entrypoint.sh
deleted file mode 100644
index 4386be65a32..00000000000
--- a/docker/prod_entrypoint.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = "--admin-agent" ]; then
- shift
- export CONNECTION_AUTH_MODE=native
- exec /opt/liteadmin/bin/litellm-admin-agent --web "$@"
-fi
-
-case "$USE_DDTRACE" in
- [Tt][Rr][Uu][Ee])
- export DD_TRACE_OPENAI_ENABLED="False"
- exec ddtrace-run litellm "$@"
- ;;
-esac
-
-exec litellm "$@"
diff --git a/docker/tests/nonroot.yaml b/docker/tests/nonroot.yaml
deleted file mode 100644
index 36118ca8c59..00000000000
--- a/docker/tests/nonroot.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-schemaVersion: 2.0.0
-
-metadataTest:
- entrypoint: ["docker/prod_entrypoint.sh"]
- user: "65534"
- workdir: "/app"
-
-fileExistenceTests:
- - name: "Prisma Folder"
- path: "/usr/local/lib/python3.13/site-packages/prisma/"
- shouldExist: true
- uid: 65534
- gid: 65534
- - name: "Prisma Schema"
- path: "/usr/local/lib/python3.13/site-packages/prisma/schema.prisma"
- shouldExist: true
- uid: 65534
- gid: 65534
diff --git a/enterprise/litellm_enterprise/proxy/common_utils/check_batch_cost.py b/enterprise/litellm_enterprise/proxy/common_utils/check_batch_cost.py
index a31e926256a..abc2487a4a5 100644
--- a/enterprise/litellm_enterprise/proxy/common_utils/check_batch_cost.py
+++ b/enterprise/litellm_enterprise/proxy/common_utils/check_batch_cost.py
@@ -8,7 +8,6 @@ import re
from collections.abc import Callable, Mapping, Sequence
from dataclasses import replace as dataclasses_replace
from datetime import datetime, timedelta
-from types import MappingProxyType
from typing import TYPE_CHECKING, Final, List, Literal, Optional, Protocol, Tuple, cast
from pydantic import TypeAdapter, ValidationError
@@ -21,6 +20,7 @@ from litellm_enterprise.proxy.common_utils.managed_object_attribution import (
import litellm
from litellm._logging import verbose_proxy_logger
from litellm._uuid import uuid
+from litellm.litellm_core_utils.cloud_storage_security import stored_s3_bucket_kwargs
from litellm.constants import (
BATCH_LINE_ITEMS_MAX_PART_BYTES,
MANAGED_OBJECT_STALENESS_CUTOFF_DAYS,
@@ -766,8 +766,7 @@ class CheckBatchCost:
credentials: Final = self.llm_router.registry().credentials(model_id, form="with_provider") or {}
_file_content = await afile_content(
file_id=cast(str, raw_output_file_id),
- _litellm_internal_model_credentials=MappingProxyType(dict(credentials)),
- **cast(FileContentCallOptions, credentials),
+ **cast(FileContentCallOptions, {**credentials, **stored_s3_bucket_kwargs(cast(str, raw_output_file_id))}),
)
content_bytes: Final = await _file_content_bytes(_file_content)
@@ -867,10 +866,7 @@ class CheckBatchCost:
error_file_failed_requests: Final = await count_error_file_failed_requests(
response,
custom_llm_provider=batch_file_provider,
- litellm_params={
- **credentials,
- "_litellm_internal_model_credentials": MappingProxyType(dict(credentials)),
- },
+ litellm_params=credentials,
)
batch_result: Final = (
output_file_result
@@ -1029,11 +1025,7 @@ class CheckBatchCost:
custom_llm_provider=deployment_info.litellm_params.custom_llm_provider,
)
cost_provider: Final = cast(BatchFileProvider, llm_provider)
- credentials: Final = self.llm_router.registry().credentials(model_id, form="with_provider") or {}
- file_access: Final = {
- **credentials,
- "_litellm_internal_model_credentials": MappingProxyType(dict(credentials)),
- }
+ file_access: Final = self.llm_router.registry().credentials(model_id, form="with_provider") or {}
output_content: Final = (
await fetch_batch_managed_file_content(
response.output_file_id, custom_llm_provider=cost_provider, litellm_params=file_access
diff --git a/enterprise/litellm_enterprise/proxy/common_utils/check_responses_cost.py b/enterprise/litellm_enterprise/proxy/common_utils/check_responses_cost.py
index cfe4ca98145..69e36a0c076 100644
--- a/enterprise/litellm_enterprise/proxy/common_utils/check_responses_cost.py
+++ b/enterprise/litellm_enterprise/proxy/common_utils/check_responses_cost.py
@@ -200,7 +200,6 @@ async def log_billed_background_response(billed: BilledBackgroundResponse) -> Bi
unpriced: Final = _without_read_price(billed.response)
cost: Final = logging_obj.response_cost_calculator(result=unpriced)
end_time: Final = datetime.now()
- logging_obj.capture_usage_before_logging(unpriced, logging_obj.start_time, end_time)
GLOBAL_LOGGING_WORKER.ensure_initialized_and_enqueue(
async_coroutine=logging_obj.async_success_handler(
result=unpriced, start_time=logging_obj.start_time, end_time=end_time
diff --git a/enterprise/litellm_enterprise/proxy/common_utils/managed_object_attribution.py b/enterprise/litellm_enterprise/proxy/common_utils/managed_object_attribution.py
index a4a40a7a3d7..1c433d04819 100644
--- a/enterprise/litellm_enterprise/proxy/common_utils/managed_object_attribution.py
+++ b/enterprise/litellm_enterprise/proxy/common_utils/managed_object_attribution.py
@@ -182,7 +182,7 @@ class ManagedObjectCreatorAttribution:
team_id: Final = getattr(job, "team_id", None)
rows: Final = _CreatorRows(
key=await self._live_key_row(api_key, job.created_by),
- team=await self._live_team_row(team_id),
+ team=await self._live_team_row(team_id, job.created_at),
user=await self._user_row(object_id, _creator_user_id(job.created_by)),
)
return ResponseCreator(
@@ -269,10 +269,15 @@ class ManagedObjectCreatorAttribution:
verbose_proxy_logger.error(f"{self._poller_name}: could not look up team {team_id} for {object_id}: {e}")
return None
- async def _live_team_row(self, team_id: str | None) -> prisma_models.LiteLLM_TeamTable | None:
+ async def _live_team_row(
+ self, team_id: str | None, created_before: datetime | None = None
+ ) -> prisma_models.LiteLLM_TeamTable | None:
if not team_id:
return None
- return await _team_table(self._prisma_client).find_unique(where={"team_id": team_id})
+ team: Final = await _team_table(self._prisma_client).find_unique(where={"team_id": team_id})
+ if team is not None and created_before is not None and team.created_at > created_before:
+ return None
+ return team
def _response_creator_metadata(job: ManagedObjectRow, rows: _CreatorRows) -> Mapping[str, object]:
diff --git a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py
index 91c5e2c5f39..bbb09e75b47 100644
--- a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py
+++ b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py
@@ -49,6 +49,7 @@ from litellm.constants import (
)
from litellm.files.types import FileRetrieveCallOptions, FileRetrieveProvider
from litellm.integrations.custom_logger import CustomLogger
+from litellm.litellm_core_utils.cloud_storage_security import stored_s3_bucket_kwargs
from litellm.litellm_core_utils.core_helpers import require_attributes
from litellm.litellm_core_utils.hidden_params import HIDDEN_PARAMS_ATTR
from litellm.litellm_core_utils.internal_call_metadata import requests_background
@@ -78,6 +79,7 @@ from litellm.proxy.litellm_pre_call_utils import (
from litellm.proxy.openai_files_endpoints.common_utils import (
BATCH_CREATE_HIDDEN_PARAM,
FILE_LIST_CONTINUATION_CHUNK_SIZE,
+ TeamProviderDeployment,
_is_base64_encoded_unified_file_id,
apply_unified_file_ids,
decode_model_from_file_id,
@@ -127,7 +129,6 @@ class _ManagedFileRetrieve(Protocol):
self,
*,
file_id: str,
- _litellm_internal_model_credentials: Mapping[str, object] | None = None,
**kwargs: Unpack[FileRetrieveCallOptions],
) -> OpenAIFileObject: ...
@@ -396,11 +397,12 @@ class _CursorPageArgs(TypedDict, total=False):
class _RouterFileCallKwargs(TypedDict, total=False):
client: ReadOnly[AsyncOpenAI | None]
custom_llm_provider: ReadOnly[str | None]
+ stored_s3_bucket_name: ReadOnly[str]
_MODEL_FILE_ID_MAPPING: Final = TypeAdapter(dict[str, str])
_FILE_UPLOAD_ONLY_FIELDS: Final = frozenset({"file", "purpose", "expires_after", "extra_body"})
-_FILE_DELETE_RESERVED_FIELDS: Final = frozenset({"model", "file_id", "_litellm_internal_model_credentials"})
+_FILE_DELETE_RESERVED_FIELDS: Final = frozenset({"model", "file_id"})
@dataclass(frozen=True, slots=True)
@@ -459,19 +461,11 @@ async def _delete_provider_file(
provider_file_id: str,
request_data: Mapping[str, object],
) -> None:
- credentials: Final = llm_router.registry().credentials(model_id, form="with_provider")
- delete_data: Final = {
- **{k: v for k, v in request_data.items() if k not in _FILE_DELETE_RESERVED_FIELDS},
- **(
- {"_litellm_internal_model_credentials": MappingProxyType(dict(credentials))}
- if credentials is not None
- else {}
- ),
- }
+ delete_data: Final = {k: v for k, v in request_data.items() if k not in _FILE_DELETE_RESERVED_FIELDS}
await llm_router.afile_delete(
model=model_id,
file_id=provider_file_id,
- **cast(_RouterFileCallKwargs, delete_data),
+ **cast(_RouterFileCallKwargs, {**delete_data, **stored_s3_bucket_kwargs(provider_file_id)}),
)
@@ -1160,26 +1154,19 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints):
*,
provider_file_id: str,
call_options: Mapping[str, object],
- internal_model_credentials: Mapping[str, object] | None = None,
) -> OpenAIFileObject:
"""Retrieve provider file details with transient retries and SDK retries disabled."""
retrieve_file: Final = cast(_ManagedFileRetrieve, litellm.afile_retrieve)
retrieve_options: Final = cast(
FileRetrieveCallOptions,
- {**call_options, "max_retries": 0},
+ {**call_options, **stored_s3_bucket_kwargs(provider_file_id), "max_retries": 0},
)
for attempt in range(len(_PROVIDER_FILE_RETRIEVE_RETRY_DELAYS_SECONDS) + 1):
if attempt > 0:
await self._sleep(_PROVIDER_FILE_RETRIEVE_RETRY_DELAYS_SECONDS[attempt - 1])
try:
- if internal_model_credentials is None:
- return await retrieve_file(
- file_id=provider_file_id,
- **retrieve_options,
- )
return await retrieve_file(
file_id=provider_file_id,
- _litellm_internal_model_credentials=MappingProxyType(dict(internal_model_credentials)),
**retrieve_options,
)
except Exception as error:
@@ -1221,7 +1208,6 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints):
self._afile_retrieve_with_retries(
provider_file_id=provider_file_id,
call_options=router_credentials,
- internal_model_credentials=router_credentials,
),
timeout=BATCH_OUTPUT_FILE_LOOKUP_TIMEOUT_SECONDS,
)
@@ -1443,6 +1429,43 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints):
user_api_key_dict=owner,
)
+ async def register_provider_file(
+ self,
+ *,
+ provider_file_id: str,
+ content_type: str,
+ deployment: TeamProviderDeployment,
+ owner: UserAPIKeyAuth,
+ llm_router: Router | None,
+ ) -> str | None:
+ unified_file_id: Final = self.get_unified_output_file_id(
+ provider_file_id, deployment.deployment_id, deployment.public_model_name, file_type=content_type
+ )
+ provider_file_object, _ = await self._fetch_provider_file_object(
+ unified_file_id=unified_file_id,
+ provider_file_id=provider_file_id,
+ model_id=deployment.deployment_id,
+ model_name=None,
+ llm_router=llm_router,
+ )
+ if provider_file_object is None:
+ return None
+ try:
+ await self.store_unified_file_id(
+ file_id=unified_file_id,
+ file_object=provider_file_object,
+ litellm_parent_otel_span=None,
+ model_mappings={deployment.deployment_id: provider_file_id},
+ user_api_key_dict=owner,
+ )
+ except Exception as error: # noqa: BLE001 # the upload succeeded, so the caller keeps the provider id
+ verbose_logger.warning(
+ f"Failed to register provider_file_id={sanitize_for_log(provider_file_id)} as a managed file: "
+ f"{type(error).__name__} {sanitize_for_log(error)}"
+ )
+ return None
+ return unified_file_id
+
async def list_user_batches(
self,
user_api_key_dict: UserAPIKeyAuth,
@@ -1774,8 +1797,10 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints):
if potential_file_id and "llm_output_file_id," in potential_file_id:
model_id = self.get_model_id_from_unified_file_id(potential_file_id)
if model_id:
+ provider_file_id: Final = self.get_output_file_id_from_unified_file_id(potential_file_id)
data["model"] = model_id
- data["file_id"] = self.get_output_file_id_from_unified_file_id(potential_file_id)
+ data["file_id"] = provider_file_id
+ data.update(stored_s3_bucket_kwargs(provider_file_id))
elif call_type == CallTypes.acreate_batch.value:
input_file_id = cast(Optional[str], data.get("input_file_id"))
if input_file_id:
@@ -2270,10 +2295,12 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints):
unified_batch_id = SpecialEnums.LITELLM_MANAGED_BATCH_COMPLETE_STR.value.format(model_id, batch_id)
return base64.urlsafe_b64encode(unified_batch_id.encode()).decode().rstrip("=")
- def get_unified_output_file_id(self, output_file_id: str, model_id: str, model_name: Optional[str]) -> str:
+ def get_unified_output_file_id(
+ self, output_file_id: str, model_id: str, model_name: Optional[str], file_type: str = "application/json"
+ ) -> str:
deterministic_uuid: Final = uuid5(uuid5(NAMESPACE_URL, model_id), output_file_id)
unified_output_file_id = SpecialEnums.LITELLM_MANAGED_FILE_COMPLETE_STR.value.format(
- "application/json",
+ file_type,
str(deterministic_uuid),
model_name or "",
output_file_id,
@@ -2866,21 +2893,22 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints):
exception_dict = {}
for model_id, provider_file_id in specific_model_file_id_mapping.items():
try:
- # Cloud-storage providers (e.g. Bedrock S3) validate file ids
- # against the deployment's configured bucket, which they only
- # trust from this immutable server-side snapshot, never from
- # request params.
- credentials = llm_router.registry().credentials(model_id, form="with_provider")
- if credentials is not None:
- data["_litellm_internal_model_credentials"] = cast(Dict, MappingProxyType(dict(credentials)))
- else:
- data.pop("_litellm_internal_model_credentials", None)
return cast(
HttpxBinaryResponseContent,
await llm_router.afile_content(
model=model_id,
file_id=provider_file_id,
- **cast(_RouterFileCallKwargs, data),
+ **cast(
+ _RouterFileCallKwargs,
+ {
+ **data,
+ **(
+ stored_s3_bucket_kwargs(provider_file_id)
+ if isinstance(provider_file_id, str)
+ else {}
+ ),
+ },
+ ),
),
)
except Exception as e:
diff --git a/enterprise/litellm_enterprise/types/enterprise_callbacks/send_emails.py b/enterprise/litellm_enterprise/types/enterprise_callbacks/send_emails.py
index a2322d7f650..bb3b712d50b 100644
--- a/enterprise/litellm_enterprise/types/enterprise_callbacks/send_emails.py
+++ b/enterprise/litellm_enterprise/types/enterprise_callbacks/send_emails.py
@@ -1,9 +1,9 @@
import enum
-from typing import Dict, List, Optional
from pydantic import Field
from litellm.proxy._types import WebhookEvent
+from litellm.types.integrations.model_deprecation_email import MODEL_DEPRECATION_EMAIL_EVENT
from litellm.types.llms.base import LiteLLMBaseModel
@@ -26,7 +26,7 @@ class SendKeyCreatedEmailEvent(WebhookEvent):
class SendKeyRotatedEmailEvent(WebhookEvent):
virtual_key: str
- key_alias: Optional[str] = None
+ key_alias: str | None = None
"""
The virtual key that was rotated
this will be sk-123xxx, since we will be emailing this to the user to start using the new key
@@ -34,23 +34,33 @@ class SendKeyRotatedEmailEvent(WebhookEvent):
class EmailEvent(str, enum.Enum):
+ model_deprecations = MODEL_DEPRECATION_EMAIL_EVENT
virtual_key_created = "Virtual Key Created"
new_user_invitation = "New User Invitation"
virtual_key_rotated = "Virtual Key Rotated"
soft_budget_crossed = "Soft Budget Crossed"
max_budget_alert = "Max Budget Alert"
+
class EmailEventSettings(LiteLLMBaseModel):
event: EmailEvent
enabled: bool
+
+
class EmailEventSettingsUpdateRequest(LiteLLMBaseModel):
- settings: List[EmailEventSettings]
+ settings: list[EmailEventSettings]
+
+
class EmailEventSettingsResponse(LiteLLMBaseModel):
- settings: List[EmailEventSettings]
+ settings: list[EmailEventSettings]
+
+
class DefaultEmailSettings(LiteLLMBaseModel):
"""Default settings for email events"""
- settings: Dict[EmailEvent, bool] = Field(
+
+ settings: dict[EmailEvent, bool] = Field(
default_factory=lambda: {
+ EmailEvent.model_deprecations: False, # Explicit opt-in for owner retirement reminders.
EmailEvent.virtual_key_created: True, # On by default
EmailEvent.new_user_invitation: True, # On by default
EmailEvent.virtual_key_rotated: True, # On by default
@@ -58,10 +68,12 @@ class DefaultEmailSettings(LiteLLMBaseModel):
EmailEvent.max_budget_alert: True, # On by default
}
)
- def to_dict(self) -> Dict[str, bool]:
+
+ def to_dict(self) -> dict[str, bool]:
"""Convert to dictionary with string keys for storage"""
return {event.value: enabled for event, enabled in self.settings.items()}
+
@classmethod
- def get_defaults(cls) -> Dict[str, bool]:
+ def get_defaults(cls) -> dict[str, bool]:
"""Get the default settings as a dictionary with string keys"""
- return cls().to_dict()
\ No newline at end of file
+ return cls().to_dict()
diff --git a/enterprise/pyproject.toml b/enterprise/pyproject.toml
index 7db2de1f874..64fe03769b8 100644
--- a/enterprise/pyproject.toml
+++ b/enterprise/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "litellm-enterprise"
-version = "0.1.81"
+version = "0.1.83"
description = "Package for LiteLLM Enterprise features"
readme = "README.md"
requires-python = ">=3.9"
@@ -26,7 +26,7 @@ required-version = ">=0.10.9"
module-root = ""
[tool.commitizen]
-version = "0.1.81"
+version = "0.1.83"
version_files = [
"pyproject.toml:^version",
"../pyproject.toml:litellm-enterprise==",
diff --git a/gateway/Dockerfile b/gateway/Dockerfile
deleted file mode 100644
index 658bed831ba..00000000000
--- a/gateway/Dockerfile
+++ /dev/null
@@ -1,165 +0,0 @@
-ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:360896efb0753a5701c48f860e17130c205eae5a264797aa3e7ea126ee2923a7
-ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:360896efb0753a5701c48f860e17130c205eae5a264797aa3e7ea126ee2923a7
-ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a
-# Checksum from https://www.pgbouncer.org/downloads/ (the Wolfi repo only carries 1.24.x)
-ARG PGBOUNCER_VERSION=1.26.0
-ARG PGBOUNCER_SHA256=afd25dd61ee6775d37b40629b87ce08736b3e6955f3057bb212e410fbf21c71d
-
-FROM $UV_IMAGE AS uvbin
-
-FROM $LITELLM_BUILD_IMAGE AS pgbouncer-builder
-ARG PGBOUNCER_VERSION
-ARG PGBOUNCER_SHA256
-USER root
-RUN apk add --no-cache build-base pkgconf libevent-dev openssl-dev curl
-WORKDIR /build
-RUN curl -fsSL -o pgbouncer.tar.gz "https://www.pgbouncer.org/downloads/files/${PGBOUNCER_VERSION}/pgbouncer-${PGBOUNCER_VERSION}.tar.gz" && \
- echo "${PGBOUNCER_SHA256} pgbouncer.tar.gz" | sha256sum -c - && \
- tar xzf pgbouncer.tar.gz --strip-components=1 && \
- ./configure --prefix=/usr/local --with-openssl=/usr && \
- make -j"$(nproc)" pgbouncer && \
- install -m 0755 pgbouncer /usr/local/bin/pgbouncer
-
-# ---------- Rust extension ----------
-# Copies only the native build's inputs, so the fat-LTO compile stays cached across Python-only changes
-FROM $LITELLM_BUILD_IMAGE AS rust-native
-
-WORKDIR /app
-USER root
-
-COPY --from=uvbin /uv /uvx /usr/local/bin/
-
-RUN for i in 1 2 3; do \
- apk add --no-cache bash gcc python-3.13 python-3.13-dev openssl openssl-dev && break; \
- [ $i = 3 ] && { echo "apk add failed after 3 retries" >&2; exit 1; }; \
- sleep 5; \
- done
-
-ENV UV_PYTHON_DOWNLOADS=0
-
-COPY pyproject.toml README.md rust-toolchain.toml ./
-COPY .cargo ./.cargo
-COPY litellm-rust ./litellm-rust
-COPY model_prices_and_context_window.json ./
-
-RUN --mount=type=cache,target=/root/.cache/uv \
- mkdir -p litellm/rust_bridge /wheels && \
- touch litellm/__init__.py litellm/rust_bridge/__init__.py && \
- uvx --python python3.13 --from maturin==1.15.0 --with puccinialin==0.1.14 \
- python -c "import maturin; maturin.build_wheel('/wheels')"
-
-# ---------- Builder ----------
-FROM $LITELLM_BUILD_IMAGE AS builder
-
-WORKDIR /app
-USER root
-
-COPY --from=uvbin /uv /uvx /usr/local/bin/
-
-# nodejs/npm so `prisma generate` uses Wolfi's Node via PRISMA_USE_GLOBAL_NODE
-# instead of nodeenv downloading one whose dynamic deps may not be in Wolfi
-# (e.g. Node 26.2.0 needs libatomic). Retry for transient apk.cgr.dev flakes.
-RUN for i in 1 2 3; do \
- apk add --no-cache bash gcc python-3.13 python-3.13-dev openssl libssl3 openssl-dev libsndfile nodejs npm && break; \
- [ $i = 3 ] && { echo "apk add failed after 3 retries" >&2; exit 1; }; \
- sleep 5; \
- done
-
-# UV_COMPILE_BYTECODE=1 precompiles .pyc at install time → faster cold start.
-# UV_LINK_MODE=copy avoids hardlink warnings when uv installs from a
-# BuildKit cache mount (different filesystem).
-# UV_PYTHON_DOWNLOADS=0 force uv to use the apk-installed CPython instead of
-# silently pulling a managed interpreter.
-# PRISMA_USE_GLOBAL_NODE explicit (matches default) so an env override can't
-# silently re-enable nodeenv's Node download.
-ENV UV_PROJECT_ENVIRONMENT=/app/.venv \
- UV_LINK_MODE=copy \
- UV_COMPILE_BYTECODE=1 \
- UV_PYTHON_DOWNLOADS=0 \
- PRISMA_USE_GLOBAL_NODE=true \
- PATH="/app/.venv/bin:${PATH}"
-
-# Stage 1 — install dependencies only.
-RUN --mount=type=cache,target=/root/.cache/uv \
- --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
- --mount=type=bind,source=uv.lock,target=uv.lock \
- --mount=type=bind,source=enterprise/pyproject.toml,target=enterprise/pyproject.toml \
- --mount=type=bind,source=litellm-proxy-extras/pyproject.toml,target=litellm-proxy-extras/pyproject.toml \
- uv sync --frozen --no-install-project --no-install-workspace --no-default-groups --no-editable \
- --extra proxy \
- --extra proxy-runtime \
- --group admin-mcp \
- --extra extra_proxy \
- --extra semantic-router \
- --extra bedrock-realtime \
- --python python3.13
-
-# Stage 2 — copy source and install the workspace members.
-COPY . .
-
-RUN --mount=type=cache,target=/root/.cache/uv \
- uv sync --frozen --no-install-project --no-default-groups --no-editable \
- --extra proxy \
- --extra proxy-runtime \
- --group admin-mcp \
- --extra extra_proxy \
- --extra semantic-router \
- --extra bedrock-realtime \
- --python python3.13
-
-RUN --mount=type=bind,from=rust-native,source=/wheels,target=/wheels \
- uv pip install --python /app/.venv/bin/python --no-deps /wheels/litellm-*.whl
-
-# PYTHONPATH=/app makes the source tree shadow the installed package, so the
-# compiled Rust extension must live next to the source or it is never imported.
-RUN cp "$(python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')"/litellm/rust_bridge/_native*.so litellm/rust_bridge/
-
-RUN HOME=/opt/prisma XDG_CACHE_HOME=/opt/prisma/.cache PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries \
- npm_config_cache=/root/.npm \
- prisma generate --schema=./schema.prisma
-
-RUN sed -i 's/\r$//' docker/component_entrypoint.sh && chmod +x docker/component_entrypoint.sh
-
-# ---------- Runtime ----------
-FROM $LITELLM_RUNTIME_IMAGE AS runtime
-
-USER root
-
-RUN for i in 1 2 3; do \
- apk add --no-cache bash openssl libssl3 tzdata python-3.13 libsndfile libatomic libevent && break; \
- [ $i = 3 ] && { echo "apk add failed after 3 retries" >&2; exit 1; }; \
- sleep 5; \
- done
-
-# wolfi-base ships an unprivileged `nonroot` account (UID/GID 65532) with
-# /home/nonroot. We run the proxy as that user.
-WORKDIR /app
-ENV HOME=/home/nonroot \
- PATH="/app/.venv/bin:${PATH}" \
- PYTHONPATH="/app" \
- PYTHONDONTWRITEBYTECODE=1 \
- PYTHONUNBUFFERED=1 \
- PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries
-
-COPY --from=builder --chown=nonroot:nonroot /app/.venv /app/.venv
-COPY --from=builder --chown=nonroot:nonroot /app/litellm /app/litellm
-COPY --from=builder --chown=nonroot:nonroot /app/enterprise /app/enterprise
-COPY --from=builder --chown=nonroot:nonroot /app/gateway /app/gateway
-COPY --from=builder --chown=nonroot:nonroot /app/litellm_cli /app/litellm_cli
-COPY --from=builder --chown=nonroot:nonroot /app/docker/component_entrypoint.sh /app/docker/component_entrypoint.sh
-COPY --from=builder --chown=nonroot:nonroot /app/schema.prisma /app/schema.prisma
-COPY --from=builder /opt/prisma /opt/prisma
-COPY --from=pgbouncer-builder /usr/local/bin/pgbouncer /usr/local/bin/pgbouncer
-
-RUN find /app/.venv -type f -path "*/tornado/test/*" -delete && \
- find /app/.venv -type d -path "*/tornado/test" -delete && \
- chmod -R a+rX /opt/prisma && \
- python -c "from prisma.client import BINARY_PATHS; paths = list(BINARY_PATHS.query_engine.values()); assert paths and all(p.startswith('/opt/prisma/') for p in paths), paths" && \
- python -c "import litellm, litellm.rust_bridge._native; assert litellm.__file__ == '/app/litellm/__init__.py', litellm.__file__"
-
-USER nonroot
-
-EXPOSE 4000/tcp
-
-ENTRYPOINT ["sh", "-c", "exec /app/docker/component_entrypoint.sh python -m gateway.launch --workers \"${NUM_WORKERS:-1}\" \"$@\"", "--"]
-CMD ["--host", "0.0.0.0", "--port", "4000"]
diff --git a/helm/litellm-helm/Chart.yaml b/helm/litellm-helm/Chart.yaml
index a3cb388ffc6..059889cb667 100644
--- a/helm/litellm-helm/Chart.yaml
+++ b/helm/litellm-helm/Chart.yaml
@@ -18,7 +18,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
-version: 1.1.3
+version: 1.1.4
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
diff --git a/helm/litellm-helm/README.md b/helm/litellm-helm/README.md
index 694cca05b52..bc6e29632f1 100644
--- a/helm/litellm-helm/README.md
+++ b/helm/litellm-helm/README.md
@@ -56,8 +56,8 @@ If `db.useStackgresOperator` is used (not yet implemented):
| `billingMetrics.enabled` | Enable enterprise billable-request metering. Requires an enterprise license. | `false` |
| `billingMetrics.endpoint` | Collector that the billable-request counter is pushed to. | `https://telemetry.litellm.ai` |
-| `billingMetrics.secretName` | Name of an existing Secret holding the mTLS client certificate, under the keys `tls.crt` and `tls.key`. | `litellm-billing-metrics-mtls` |
-| `billingMetrics.caSecretName` | Name of an existing Secret holding a CA bundle under the key `ca.crt`. Only needed for a private or test collector whose server certificate is not on the public web PKI. | `""` |
+| `billingMetrics.tokenUrl` | Cognito OAuth2 client-credentials token endpoint. | `https://litellm-prod.auth.us-west-1.amazoncognito.com/oauth2/token` |
+| `billingMetrics.secretName` | Name of an existing Secret with `client-id` and `client-secret` keys. | `litellm-billing-metrics` |
| `billingMetrics.exportIntervalMs` | How often the counter is pushed, in milliseconds. The proxy defaults to `60000` when unset. | `""` |
#### Example `proxy_config` ConfigMap from values (default):
@@ -109,10 +109,10 @@ type: Opaque
#### Enterprise billable-request metering
-Enterprise licenses meter billable requests by pushing a counter to LiteLLM's collector over mutual TLS. The chart does not create the client certificate; it mounts one you already hold, read-only, so the private key is never exposed through the environment. Create the Secret under the name the chart expects, then turn the block on:
+Enterprise licenses meter billable requests by pushing a counter to LiteLLM's collector with Cognito bearer authentication. Create a Secret with `client-id` and `client-secret` keys, then enable the chart values:
```
-kubectl create secret tls litellm-billing-metrics-mtls --cert=client.crt --key=client.key
+kubectl create secret generic litellm-billing-metrics --from-literal=client-id=... --from-literal=client-secret=...
```
```
@@ -120,7 +120,8 @@ billingMetrics:
enabled: true
```
-Set `billingMetrics.caSecretName` only when the collector is a private or test one whose server certificate is not on the public web PKI; the production collector needs no CA override. The chart fails the render rather than deploying a proxy that silently never exports, so a missing `secretName` or an emptied `endpoint` surfaces at `helm install` time.
+The endpoint and token URL must use HTTPS. The chart requires both URLs and
+the Secret name when billing metrics are enabled
### Database Settings
diff --git a/helm/litellm-helm/templates/_helpers.tpl b/helm/litellm-helm/templates/_helpers.tpl
index 929fc415163..230d2acaeef 100644
--- a/helm/litellm-helm/templates/_helpers.tpl
+++ b/helm/litellm-helm/templates/_helpers.tpl
@@ -50,53 +50,27 @@ app.kubernetes.io/name: {{ include "litellm.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
-{{/*
-Enterprise billable-request metering. The client certificate identifies the
-deployment to LiteLLM's collector, so it is mounted read-only from an existing
-Secret rather than passed through the environment.
-*/}}
-{{- define "litellm.billingMetrics.certDir" -}}/etc/litellm/billing-mtls{{- end -}}
-{{- define "litellm.billingMetrics.caDir" -}}/etc/litellm/billing-mtls-ca{{- end -}}
-
{{- define "litellm.billingMetricsEnv" -}}
- name: LITELLM_BILLING_METRICS_ENDPOINT
value: {{ required "billingMetrics.endpoint is required when billingMetrics.enabled is true" .Values.billingMetrics.endpoint | quote }}
-- name: LITELLM_BILLING_METRICS_CLIENT_CERT
- value: {{ printf "%s/tls.crt" (include "litellm.billingMetrics.certDir" .) | quote }}
-- name: LITELLM_BILLING_METRICS_CLIENT_KEY
- value: {{ printf "%s/tls.key" (include "litellm.billingMetrics.certDir" .) | quote }}
-{{- if .Values.billingMetrics.caSecretName }}
-- name: LITELLM_BILLING_METRICS_CA_CERT
- value: {{ printf "%s/ca.crt" (include "litellm.billingMetrics.caDir" .) | quote }}
-{{- end }}
+- name: LITELLM_BILLING_METRICS_TOKEN_URL
+ value: {{ required "billingMetrics.tokenUrl is required when billingMetrics.enabled is true" .Values.billingMetrics.tokenUrl | quote }}
+- name: LITELLM_BILLING_METRICS_CLIENT_ID
+ valueFrom:
+ secretKeyRef:
+ name: {{ required "billingMetrics.secretName is required when billingMetrics.enabled is true" .Values.billingMetrics.secretName }}
+ key: client-id
+- name: LITELLM_BILLING_METRICS_CLIENT_SECRET
+ valueFrom:
+ secretKeyRef:
+ name: {{ required "billingMetrics.secretName is required when billingMetrics.enabled is true" .Values.billingMetrics.secretName }}
+ key: client-secret
{{- with .Values.billingMetrics.exportIntervalMs }}
- name: LITELLM_BILLING_METRICS_EXPORT_INTERVAL_MS
value: {{ . | quote }}
{{- end }}
{{- end -}}
-{{- define "litellm.billingMetricsVolumes" -}}
-- name: billing-metrics-mtls
- secret:
- secretName: {{ required "billingMetrics.secretName is required when billingMetrics.enabled is true (an existing Secret with tls.crt and tls.key)" .Values.billingMetrics.secretName }}
-{{- if .Values.billingMetrics.caSecretName }}
-- name: billing-metrics-mtls-ca
- secret:
- secretName: {{ .Values.billingMetrics.caSecretName }}
-{{- end }}
-{{- end -}}
-
-{{- define "litellm.billingMetricsVolumeMounts" -}}
-- name: billing-metrics-mtls
- mountPath: {{ include "litellm.billingMetrics.certDir" . }}
- readOnly: true
-{{- if .Values.billingMetrics.caSecretName }}
-- name: billing-metrics-mtls-ca
- mountPath: {{ include "litellm.billingMetrics.caDir" . }}
- readOnly: true
-{{- end }}
-{{- end -}}
-
{{/*
Create the name of the service account to use
*/}}
diff --git a/helm/litellm-helm/templates/deployment.yaml b/helm/litellm-helm/templates/deployment.yaml
index 37e7eaec9e9..a37193f0efa 100644
--- a/helm/litellm-helm/templates/deployment.yaml
+++ b/helm/litellm-helm/templates/deployment.yaml
@@ -148,9 +148,6 @@ spec:
- name: npm
mountPath: /.npm
{{- end }}
- {{- if .Values.billingMetrics.enabled }}
- {{- include "litellm.billingMetricsVolumeMounts" . | nindent 12 }}
- {{- end }}
{{- if include "litellm.collector.socketDir" . }}
- name: collector-socket
mountPath: {{ include "litellm.collector.socketDir" . }}
@@ -234,9 +231,6 @@ spec:
items:
- key: {{ .Values.proxyConfigMap.key | default "config.yaml" }}
path: "config.yaml"
- {{- if .Values.billingMetrics.enabled }}
- {{- include "litellm.billingMetricsVolumes" . | nindent 8 }}
- {{- end }}
{{- if include "litellm.collector.socketDir" . }}
- name: collector-socket
emptyDir:
diff --git a/helm/litellm-helm/tests/billing_metrics_tests.yaml b/helm/litellm-helm/tests/billing_metrics_tests.yaml
index 71803df378c..52185c8dd9d 100644
--- a/helm/litellm-helm/tests/billing_metrics_tests.yaml
+++ b/helm/litellm-helm/tests/billing_metrics_tests.yaml
@@ -1,31 +1,21 @@
-suite: test billingMetrics wiring on the proxy deployment
+suite: test bearer-only billingMetrics wiring
templates:
- deployment.yaml
- configmap-litellm.yaml
- - migrations-job.yaml
tests:
- - it: is off by default, adding no env, volume, or mount
+ - it: is disabled by default
template: deployment.yaml
asserts:
- - notContains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls
- secret:
- secretName: litellm-billing-metrics-mtls
- - notContains:
- path: spec.template.spec.containers[0].volumeMounts
- content:
- name: billing-metrics-mtls
- mountPath: /etc/litellm/billing-mtls
- readOnly: true
- notContains:
path: spec.template.spec.containers[0].env
content:
name: LITELLM_BILLING_METRICS_ENDPOINT
- value: https://telemetry.litellm.ai
+ - notContains:
+ path: spec.template.spec.volumes
+ content:
+ name: billing-metrics
- - it: renders the endpoint and the mounted cert paths when enabled
+ - it: renders required URLs and Cognito secret references when enabled
template: deployment.yaml
set:
billingMetrics:
@@ -39,119 +29,34 @@ tests:
- contains:
path: spec.template.spec.containers[0].env
content:
- name: LITELLM_BILLING_METRICS_CLIENT_CERT
- value: /etc/litellm/billing-mtls/tls.crt
+ name: LITELLM_BILLING_METRICS_TOKEN_URL
+ value: https://litellm-prod.auth.us-west-1.amazoncognito.com/oauth2/token
- contains:
path: spec.template.spec.containers[0].env
content:
- name: LITELLM_BILLING_METRICS_CLIENT_KEY
- value: /etc/litellm/billing-mtls/tls.key
-
- # The conventional Secret name is the default, so enabling the block is enough.
- - it: mounts the default cert secret read-only alongside the config volume
- template: deployment.yaml
- set:
- billingMetrics:
- enabled: true
- asserts:
- - contains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls
- secret:
- secretName: litellm-billing-metrics-mtls
- - contains:
- path: spec.template.spec.containers[0].volumeMounts
- content:
- name: billing-metrics-mtls
- mountPath: /etc/litellm/billing-mtls
- readOnly: true
-
- - it: honours a secretName override
- template: deployment.yaml
- set:
- billingMetrics:
- enabled: true
- secretName: my-billing-mtls
- asserts:
- - contains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls
- secret:
- secretName: my-billing-mtls
- - notContains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls
- secret:
- secretName: litellm-billing-metrics-mtls
-
- - it: honours an endpoint override
- template: deployment.yaml
- set:
- billingMetrics:
- enabled: true
- endpoint: https://collector.internal:4318
- asserts:
+ name: LITELLM_BILLING_METRICS_CLIENT_ID
+ valueFrom:
+ secretKeyRef:
+ name: litellm-billing-metrics
+ key: client-id
- contains:
path: spec.template.spec.containers[0].env
content:
- name: LITELLM_BILLING_METRICS_ENDPOINT
- value: https://collector.internal:4318
-
- # The production collector presents a public web-PKI certificate, so the CA
- # override must stay absent unless a private collector is configured.
- - it: omits the CA env, volume, and mount when no caSecretName is set
- template: deployment.yaml
- set:
- billingMetrics:
- enabled: true
- asserts:
+ name: LITELLM_BILLING_METRICS_CLIENT_SECRET
+ valueFrom:
+ secretKeyRef:
+ name: litellm-billing-metrics
+ key: client-secret
- notContains:
path: spec.template.spec.volumes
content:
- name: billing-metrics-mtls-ca
- secret:
- secretName: billing-ca
+ name: billing-metrics
- notContains:
path: spec.template.spec.containers[0].volumeMounts
content:
- name: billing-metrics-mtls-ca
- mountPath: /etc/litellm/billing-mtls-ca
- readOnly: true
- - notContains:
- path: spec.template.spec.containers[0].env
- content:
- name: LITELLM_BILLING_METRICS_CA_CERT
- value: /etc/litellm/billing-mtls-ca/ca.crt
+ name: billing-metrics
- - it: mounts the CA secret when caSecretName is set
- template: deployment.yaml
- set:
- billingMetrics:
- enabled: true
- caSecretName: billing-ca
- asserts:
- - contains:
- path: spec.template.spec.containers[0].env
- content:
- name: LITELLM_BILLING_METRICS_CA_CERT
- value: /etc/litellm/billing-mtls-ca/ca.crt
- - contains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls-ca
- secret:
- secretName: billing-ca
- - contains:
- path: spec.template.spec.containers[0].volumeMounts
- content:
- name: billing-metrics-mtls-ca
- mountPath: /etc/litellm/billing-mtls-ca
- readOnly: true
-
- - it: passes the export interval through only when set
+ - it: renders the export interval only when set
template: deployment.yaml
set:
billingMetrics:
@@ -164,129 +69,7 @@ tests:
name: LITELLM_BILLING_METRICS_EXPORT_INTERVAL_MS
value: "5000"
- - it: omits the export interval when unset
- template: deployment.yaml
- set:
- billingMetrics:
- enabled: true
- asserts:
- - notContains:
- path: spec.template.spec.containers[0].env
- content:
- name: LITELLM_BILLING_METRICS_EXPORT_INTERVAL_MS
- value: "60000"
-
- # Kubernetes resolves duplicate env names last-wins, so the chart-owned billing
- # entries must render after .Values.envVars or a user could silently redirect
- # the metering export. The three billing entries are the last ones emitted here
- # (migrationJob, which appends DISABLE_SCHEMA_UPDATE, is off for this case).
- - it: renders the billing endpoint after envVars so it cannot be shadowed
- template: deployment.yaml
- set:
- migrationJob:
- enabled: false
- billingMetrics:
- enabled: true
- envVars:
- LITELLM_BILLING_METRICS_ENDPOINT: https://shadowed.example
- asserts:
- - contains:
- path: spec.template.spec.containers[0].env
- content:
- name: LITELLM_BILLING_METRICS_ENDPOINT
- value: https://shadowed.example
- - equal:
- path: spec.template.spec.containers[0].env[-3]
- value:
- name: LITELLM_BILLING_METRICS_ENDPOINT
- value: https://telemetry.litellm.ai
- - equal:
- path: spec.template.spec.containers[0].env[-2].name
- value: LITELLM_BILLING_METRICS_CLIENT_CERT
- - equal:
- path: spec.template.spec.containers[0].env[-1].name
- value: LITELLM_BILLING_METRICS_CLIENT_KEY
-
- - it: keeps user-supplied volumes and mounts alongside the billing secret
- template: deployment.yaml
- set:
- billingMetrics:
- enabled: true
- volumes:
- - name: custom-callbacks
- configMap:
- name: my-callbacks
- volumeMounts:
- - name: custom-callbacks
- mountPath: /app/callbacks
- asserts:
- - contains:
- path: spec.template.spec.volumes
- content:
- name: custom-callbacks
- configMap:
- name: my-callbacks
- - contains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls
- secret:
- secretName: litellm-billing-metrics-mtls
- - contains:
- path: spec.template.spec.containers[0].volumeMounts
- content:
- name: custom-callbacks
- mountPath: /app/callbacks
- - contains:
- path: spec.template.spec.containers[0].volumeMounts
- content:
- name: billing-metrics-mtls
- mountPath: /etc/litellm/billing-mtls
- readOnly: true
-
- - it: still mounts the proxy config when enabled
- template: deployment.yaml
- set:
- billingMetrics:
- enabled: true
- asserts:
- - contains:
- path: spec.template.spec.containers[0].volumeMounts
- content:
- name: litellm-config
- mountPath: /etc/litellm/config.yaml
- subPath: config.yaml
-
- # Only the proxy serves billable traffic. The migrations Job must never mount
- # the client certificate, and it renders its own env and volumes, so nothing
- # stops a future edit from wiring the billing include into it by mistake.
- - it: does not touch the migrations job when enabled
- template: migrations-job.yaml
- set:
- billingMetrics:
- enabled: true
- asserts:
- - notContains:
- path: spec.template.spec.containers[0].env
- content:
- name: LITELLM_BILLING_METRICS_ENDPOINT
- value: https://telemetry.litellm.ai
- - notExists:
- path: spec.template.spec.containers[0].volumeMounts
- - notExists:
- path: spec.template.spec.volumes
-
- - it: fails loudly when enabled with an emptied secretName
- template: deployment.yaml
- set:
- billingMetrics:
- enabled: true
- secretName: ""
- asserts:
- - failedTemplate:
- errorMessage: billingMetrics.secretName is required when billingMetrics.enabled is true (an existing Secret with tls.crt and tls.key)
-
- - it: fails loudly when enabled without an endpoint
+ - it: requires the endpoint when enabled
template: deployment.yaml
set:
billingMetrics:
@@ -295,3 +78,23 @@ tests:
asserts:
- failedTemplate:
errorMessage: billingMetrics.endpoint is required when billingMetrics.enabled is true
+
+ - it: requires the token URL when enabled
+ template: deployment.yaml
+ set:
+ billingMetrics:
+ enabled: true
+ tokenUrl: ""
+ asserts:
+ - failedTemplate:
+ errorMessage: billingMetrics.tokenUrl is required when billingMetrics.enabled is true
+
+ - it: requires the secret name when enabled
+ template: deployment.yaml
+ set:
+ billingMetrics:
+ enabled: true
+ secretName: ""
+ asserts:
+ - failedTemplate:
+ errorMessage: billingMetrics.secretName is required when billingMetrics.enabled is true
diff --git a/helm/litellm-helm/tests/collector_tests.yaml b/helm/litellm-helm/tests/collector_tests.yaml
index 0340b1161b7..1365290e16c 100644
--- a/helm/litellm-helm/tests/collector_tests.yaml
+++ b/helm/litellm-helm/tests/collector_tests.yaml
@@ -191,7 +191,7 @@ tests:
metricsServer.port: 9090
billingMetrics.enabled: true
billingMetrics.endpoint: https://metering.example.com
- billingMetrics.secretName: billing-mtls
+ billingMetrics.secretName: billing-metrics
asserts:
- contains:
path: spec.template.spec.containers[0].env
@@ -214,9 +214,9 @@ tests:
name: LITELLM_BILLING_METRICS_ENDPOINT
any: true
- notContains:
- path: spec.template.spec.containers[1].volumeMounts
+ path: spec.template.spec.containers[1].env
content:
- name: billing-metrics-mtls
+ name: LITELLM_BILLING_METRICS_CLIENT_SECRET
any: true
- it: should give the sidecar the same scratch mounts as the proxy on a read-only root
diff --git a/helm/litellm-helm/values.yaml b/helm/litellm-helm/values.yaml
index f51f8bdd173..9afce050261 100644
--- a/helm/litellm-helm/values.yaml
+++ b/helm/litellm-helm/values.yaml
@@ -154,19 +154,13 @@ masterkeySecretName: ""
# if set, use this secret key for the master key; otherwise, use the default key
masterkeySecretKey: ""
-# Optional: enterprise billable-request metering. When enabled, the proxy counts
-# successful requests to inference, MCP, and A2A endpoints and pushes them to
-# LiteLLM's collector over mutual TLS. Requires an enterprise license.
-# The client certificate identifies the deployment, so it is mounted read-only
-# from an existing Secret and never passed through the environment.
+# Optional: enterprise billable-request metering. Requires an enterprise license.
billingMetrics:
enabled: false
- endpoint: https://telemetry.litellm.ai # collector to push the counter to
- secretName: litellm-billing-metrics-mtls # existing Secret holding tls.crt and tls.key
- # Only for private or test collectors whose server certificate is not on the
- # public web PKI. The production collector needs no CA override.
- caSecretName: "" # existing Secret holding ca.crt
- exportIntervalMs: "" # push cadence; the proxy defaults to 60000
+ endpoint: https://telemetry.litellm.ai
+ tokenUrl: https://litellm-prod.auth.us-west-1.amazoncognito.com/oauth2/token
+ secretName: litellm-billing-metrics
+ exportIntervalMs: ""
proxyConfigMap:
# when true, creates a new configmap
diff --git a/helm/litellm/Chart.yaml b/helm/litellm/Chart.yaml
index e67f5790c7e..341172da925 100644
--- a/helm/litellm/Chart.yaml
+++ b/helm/litellm/Chart.yaml
@@ -2,7 +2,7 @@ apiVersion: v2
name: litellm
description: LiteLLM componentized — gateway, UI backend, and UI as separate services
type: application
-version: 0.1.0
+version: 0.1.1
appVersion: "0.1.0"
annotations:
org.opencontainers.image.source: "https://github.com/BerriAI/litellm"
diff --git a/helm/litellm/README.md b/helm/litellm/README.md
index 97b94754402..d66bb3284bf 100644
--- a/helm/litellm/README.md
+++ b/helm/litellm/README.md
@@ -22,6 +22,23 @@ backend:
gatewayUrl: https://gateway.example.com
```
+## Enterprise billing metrics
+
+Billing metrics use Cognito bearer authentication. Create the Secret with
+`client-id` and `client-secret` keys, then enable billing metrics:
+
+```bash
+kubectl create secret generic litellm-billing-metrics --from-literal=client-id=... --from-literal=client-secret=...
+```
+
+```yaml
+billingMetrics:
+ enabled: true
+```
+
+The chart requires an HTTPS endpoint, an HTTPS token URL, and the Secret name
+when billing metrics are enabled
+
## Routes to another Service
For a shared hostname, `ingress.extraPaths` can route to a Service in the same namespace using `serviceName` and `servicePort`. The port can be a number or a named Service port. Omit `service` when using these fields
diff --git a/helm/litellm/templates/_helpers.tpl b/helm/litellm/templates/_helpers.tpl
index 18e938564e9..b704782f5d1 100644
--- a/helm/litellm/templates/_helpers.tpl
+++ b/helm/litellm/templates/_helpers.tpl
@@ -58,56 +58,27 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }}
{{- end -}}
-{{/*
-Enterprise billable-request metering. Wired into gateway and backend, not the
-migrations job. The gateway serves nearly all billable traffic, but the backend
-keeps the named-server MCP transport (/{mcp_server_name}/mcp), which writes a
-SpendLogs row, so metering only the gateway would silently drop that traffic.
-The client certificate identifies the deployment to LiteLLM's collector, so it is
-mounted read-only from an existing Secret rather than passed through the
-environment.
-*/}}
-{{- define "litellm.billingMetrics.certDir" -}}/etc/litellm/billing-mtls{{- end -}}
-{{- define "litellm.billingMetrics.caDir" -}}/etc/litellm/billing-mtls-ca{{- end -}}
-
{{- define "litellm.billingMetricsEnv" -}}
- name: LITELLM_BILLING_METRICS_ENDPOINT
value: {{ required "billingMetrics.endpoint is required when billingMetrics.enabled is true" .Values.billingMetrics.endpoint | quote }}
-- name: LITELLM_BILLING_METRICS_CLIENT_CERT
- value: {{ printf "%s/tls.crt" (include "litellm.billingMetrics.certDir" .) | quote }}
-- name: LITELLM_BILLING_METRICS_CLIENT_KEY
- value: {{ printf "%s/tls.key" (include "litellm.billingMetrics.certDir" .) | quote }}
-{{- if .Values.billingMetrics.caSecretName }}
-- name: LITELLM_BILLING_METRICS_CA_CERT
- value: {{ printf "%s/ca.crt" (include "litellm.billingMetrics.caDir" .) | quote }}
-{{- end }}
+- name: LITELLM_BILLING_METRICS_TOKEN_URL
+ value: {{ required "billingMetrics.tokenUrl is required when billingMetrics.enabled is true" .Values.billingMetrics.tokenUrl | quote }}
+- name: LITELLM_BILLING_METRICS_CLIENT_ID
+ valueFrom:
+ secretKeyRef:
+ name: {{ required "billingMetrics.secretName is required when billingMetrics.enabled is true" .Values.billingMetrics.secretName }}
+ key: client-id
+- name: LITELLM_BILLING_METRICS_CLIENT_SECRET
+ valueFrom:
+ secretKeyRef:
+ name: {{ required "billingMetrics.secretName is required when billingMetrics.enabled is true" .Values.billingMetrics.secretName }}
+ key: client-secret
{{- with .Values.billingMetrics.exportIntervalMs }}
- name: LITELLM_BILLING_METRICS_EXPORT_INTERVAL_MS
value: {{ . | quote }}
{{- end }}
{{- end -}}
-{{- define "litellm.billingMetricsVolumes" -}}
-- name: billing-metrics-mtls
- secret:
- secretName: {{ required "billingMetrics.secretName is required when billingMetrics.enabled is true (an existing Secret with tls.crt and tls.key)" .Values.billingMetrics.secretName }}
-{{- if .Values.billingMetrics.caSecretName }}
-- name: billing-metrics-mtls-ca
- secret:
- secretName: {{ .Values.billingMetrics.caSecretName }}
-{{- end }}
-{{- end -}}
-
-{{- define "litellm.billingMetricsVolumeMounts" -}}
-- name: billing-metrics-mtls
- mountPath: {{ include "litellm.billingMetrics.certDir" . }}
- readOnly: true
-{{- if .Values.billingMetrics.caSecretName }}
-- name: billing-metrics-mtls-ca
- mountPath: {{ include "litellm.billingMetrics.caDir" . }}
- readOnly: true
-{{- end }}
-{{- end -}}
{{/*
Per-component selector labels — used in both Service selectors and Deployment matchLabels.
diff --git a/helm/litellm/templates/backend/deployment.yaml b/helm/litellm/templates/backend/deployment.yaml
index 7360261dab1..7db14ad87a5 100644
--- a/helm/litellm/templates/backend/deployment.yaml
+++ b/helm/litellm/templates/backend/deployment.yaml
@@ -79,16 +79,13 @@ spec:
{{- include "litellm.billingMetricsEnv" . | nindent 12 }}
{{- end }}
{{- include "litellm.envFrom" .Values.backend | nindent 10 }}
- {{- if or .Values.gateway.config.create .Values.backend.volumeMounts .Values.billingMetrics.enabled }}
+ {{- if or .Values.gateway.config.create .Values.backend.volumeMounts }}
volumeMounts:
{{- if .Values.gateway.config.create }}
- name: gateway-config
mountPath: /app/config/config.yaml
subPath: config.yaml
{{- end }}
- {{- if .Values.billingMetrics.enabled }}
- {{- include "litellm.billingMetricsVolumeMounts" . | nindent 12 }}
- {{- end }}
{{- with .Values.backend.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
@@ -114,16 +111,13 @@ spec:
{{- with .Values.backend.extraContainers }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
- {{- if or .Values.gateway.config.create .Values.backend.volumes .Values.billingMetrics.enabled }}
+ {{- if or .Values.gateway.config.create .Values.backend.volumes }}
volumes:
{{- if .Values.gateway.config.create }}
- name: gateway-config
configMap:
name: {{ include "litellm.gateway.fullname" . }}-config
{{- end }}
- {{- if .Values.billingMetrics.enabled }}
- {{- include "litellm.billingMetricsVolumes" . | nindent 8 }}
- {{- end }}
{{- with .Values.backend.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
diff --git a/helm/litellm/templates/gateway/deployment.yaml b/helm/litellm/templates/gateway/deployment.yaml
index b0e7f0dcebb..987109e361e 100644
--- a/helm/litellm/templates/gateway/deployment.yaml
+++ b/helm/litellm/templates/gateway/deployment.yaml
@@ -86,7 +86,7 @@ spec:
{{- include "litellm.gateway.collectorEnv" . | nindent 12 }}
{{- end }}
{{- include "litellm.envFrom" .Values.gateway | nindent 10 }}
- {{- if or .Values.gateway.config.create .Values.gateway.volumeMounts .Values.billingMetrics.enabled .Values.gateway.metricsServer.enabled (include "litellm.gateway.collectorSocketDir" .) }}
+ {{- if or .Values.gateway.config.create .Values.gateway.volumeMounts .Values.gateway.metricsServer.enabled (include "litellm.gateway.collectorSocketDir" .) }}
volumeMounts:
{{- if .Values.gateway.config.create }}
- name: gateway-config
@@ -101,9 +101,6 @@ spec:
- name: collector-socket
mountPath: {{ include "litellm.gateway.collectorSocketDir" . }}
{{- end }}
- {{- if .Values.billingMetrics.enabled }}
- {{- include "litellm.billingMetricsVolumeMounts" . | nindent 12 }}
- {{- end }}
{{- with .Values.gateway.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
@@ -206,7 +203,7 @@ spec:
{{- with .Values.gateway.extraContainers }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
- {{- if or .Values.gateway.config.create .Values.gateway.volumes .Values.billingMetrics.enabled .Values.gateway.metricsServer.enabled (include "litellm.gateway.collectorSocketDir" .) }}
+ {{- if or .Values.gateway.config.create .Values.gateway.volumes .Values.gateway.metricsServer.enabled (include "litellm.gateway.collectorSocketDir" .) }}
volumes:
{{- if .Values.gateway.config.create }}
- name: gateway-config
@@ -222,9 +219,6 @@ spec:
emptyDir:
sizeLimit: 1Mi
{{- end }}
- {{- if .Values.billingMetrics.enabled }}
- {{- include "litellm.billingMetricsVolumes" . | nindent 8 }}
- {{- end }}
{{- with .Values.gateway.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
diff --git a/helm/litellm/tests/billing_metrics_tests.yaml b/helm/litellm/tests/billing_metrics_tests.yaml
index ceba0bd1430..d17b8192fce 100644
--- a/helm/litellm/tests/billing_metrics_tests.yaml
+++ b/helm/litellm/tests/billing_metrics_tests.yaml
@@ -1,39 +1,30 @@
-suite: test billingMetrics wiring on gateway and backend
+suite: test bearer-only billingMetrics wiring
templates:
- gateway/deployment.yaml
- gateway/configmap.yaml
- backend/deployment.yaml
+ - backend/configmap.yaml
- migrations-job.yaml
values:
- ./values/required.yaml
tests:
- - it: is off by default, adding no env, volume, or mount
+ - it: is disabled by default
template: gateway/deployment.yaml
asserts:
- - notContains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls
- secret:
- secretName: billing-mtls
- - equal:
- path: spec.template.spec.containers[0].volumeMounts
- value:
- - name: gateway-config
- mountPath: /app/config/config.yaml
- subPath: config.yaml
- notContains:
path: spec.template.spec.containers[0].env
content:
name: LITELLM_BILLING_METRICS_ENDPOINT
- value: https://telemetry.litellm.ai
+ - notContains:
+ path: spec.template.spec.volumes
+ content:
+ name: billing-metrics
- - it: renders the endpoint and the mounted cert paths when enabled
+ - it: wires gateway URLs and bearer credentials from Secret keys
template: gateway/deployment.yaml
set:
billingMetrics:
enabled: true
- secretName: billing-mtls
asserts:
- contains:
path: spec.template.spec.containers[0].env
@@ -43,87 +34,68 @@ tests:
- contains:
path: spec.template.spec.containers[0].env
content:
- name: LITELLM_BILLING_METRICS_CLIENT_CERT
- value: /etc/litellm/billing-mtls/tls.crt
+ name: LITELLM_BILLING_METRICS_TOKEN_URL
+ value: https://litellm-prod.auth.us-west-1.amazoncognito.com/oauth2/token
- contains:
path: spec.template.spec.containers[0].env
content:
- name: LITELLM_BILLING_METRICS_CLIENT_KEY
- value: /etc/litellm/billing-mtls/tls.key
-
- - it: mounts the cert secret read-only alongside the config volume
- template: gateway/deployment.yaml
- set:
- billingMetrics:
- enabled: true
- secretName: billing-mtls
- asserts:
+ name: LITELLM_BILLING_METRICS_CLIENT_ID
+ valueFrom:
+ secretKeyRef:
+ name: litellm-billing-metrics
+ key: client-id
- contains:
- path: spec.template.spec.volumes
+ path: spec.template.spec.containers[0].env
content:
- name: billing-metrics-mtls
- secret:
- secretName: billing-mtls
- - contains:
- path: spec.template.spec.containers[0].volumeMounts
- content:
- name: billing-metrics-mtls
- mountPath: /etc/litellm/billing-mtls
- readOnly: true
-
- # The production collector presents a public web-PKI certificate, so the CA
- # override must stay absent unless a private collector is configured.
- - it: omits the CA env, volume, and mount when no caSecretName is set
- template: gateway/deployment.yaml
- set:
- billingMetrics:
- enabled: true
- secretName: billing-mtls
- asserts:
+ name: LITELLM_BILLING_METRICS_CLIENT_SECRET
+ valueFrom:
+ secretKeyRef:
+ name: litellm-billing-metrics
+ key: client-secret
- notContains:
path: spec.template.spec.volumes
content:
- name: billing-metrics-mtls-ca
- secret:
- secretName: billing-ca
+ name: billing-metrics
- notContains:
- path: spec.template.spec.containers[0].env
+ path: spec.template.spec.containers[0].volumeMounts
content:
- name: LITELLM_BILLING_METRICS_CA_CERT
- value: /etc/litellm/billing-mtls-ca/ca.crt
+ name: billing-metrics
- - it: mounts the CA secret when caSecretName is set
- template: gateway/deployment.yaml
+ - it: wires billing metrics on the backend without volumes
+ template: backend/deployment.yaml
set:
billingMetrics:
enabled: true
- secretName: billing-mtls
- caSecretName: billing-ca
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
- name: LITELLM_BILLING_METRICS_CA_CERT
- value: /etc/litellm/billing-mtls-ca/ca.crt
- - contains:
+ name: LITELLM_BILLING_METRICS_CLIENT_SECRET
+ valueFrom:
+ secretKeyRef:
+ name: litellm-billing-metrics
+ key: client-secret
+ - notContains:
path: spec.template.spec.volumes
content:
- name: billing-metrics-mtls-ca
- secret:
- secretName: billing-ca
- - contains:
- path: spec.template.spec.containers[0].volumeMounts
- content:
- name: billing-metrics-mtls-ca
- mountPath: /etc/litellm/billing-mtls-ca
- readOnly: true
+ name: billing-metrics
- - it: passes the export interval through only when set
+ - it: does not add billing metrics to migrations
+ template: migrations-job.yaml
+ set:
+ billingMetrics:
+ enabled: true
+ asserts:
+ - notContains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: LITELLM_BILLING_METRICS_ENDPOINT
+
+ - it: renders an optional export interval
template: gateway/deployment.yaml
set:
billingMetrics:
enabled: true
- secretName: billing-mtls
exportIntervalMs: 5000
asserts:
- contains:
@@ -132,102 +104,27 @@ tests:
name: LITELLM_BILLING_METRICS_EXPORT_INTERVAL_MS
value: "5000"
- - it: keeps user-supplied gateway volumes alongside the billing secret
+ - it: requires the endpoint when enabled
template: gateway/deployment.yaml
set:
billingMetrics:
enabled: true
- secretName: billing-mtls
- gateway.volumes:
- - name: custom-callbacks
- configMap:
- name: my-callbacks
- gateway.volumeMounts:
- - name: custom-callbacks
- mountPath: /app/callbacks
+ endpoint: ""
asserts:
- - contains:
- path: spec.template.spec.volumes
- content:
- name: custom-callbacks
- configMap:
- name: my-callbacks
- - contains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls
- secret:
- secretName: billing-mtls
+ - failedTemplate:
+ errorMessage: billingMetrics.endpoint is required when billingMetrics.enabled is true
- # The backend keeps the named-server MCP transport (/{mcp_server_name}/mcp),
- # which writes a SpendLogs row, so it must meter too or that traffic is lost.
- - it: meters the backend as well, since it serves the MCP transport
- template: backend/deployment.yaml
- set:
- billingMetrics:
- enabled: true
- secretName: billing-mtls
- asserts:
- - contains:
- path: spec.template.spec.containers[0].env
- content:
- name: LITELLM_BILLING_METRICS_ENDPOINT
- value: https://telemetry.litellm.ai
- - contains:
- path: spec.template.spec.containers[0].volumeMounts
- content:
- name: billing-metrics-mtls
- mountPath: /etc/litellm/billing-mtls
- readOnly: true
- - contains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls
- secret:
- secretName: billing-mtls
-
- - it: leaves the backend alone when metering is off
- template: backend/deployment.yaml
- asserts:
- - notContains:
- path: spec.template.spec.containers[0].env
- content:
- name: LITELLM_BILLING_METRICS_ENDPOINT
- value: https://telemetry.litellm.ai
-
- # The migrations job runs prisma and serves no traffic; it must never receive
- # the client key.
- - it: never mounts the billing cert on the migrations job
- template: migrations-job.yaml
- set:
- billingMetrics:
- enabled: true
- secretName: billing-mtls
- asserts:
- - notContains:
- path: spec.template.spec.containers[0].env
- content:
- name: LITELLM_BILLING_METRICS_ENDPOINT
- value: https://telemetry.litellm.ai
- - isNull:
- path: spec.template.spec.volumes
-
- # The conventional Secret name is the default, so enabling metering needs no
- # secretName at all; the guard below only fires on an explicitly blanked one.
- - it: uses the conventional secret name by default
+ - it: requires the token URL when enabled
template: gateway/deployment.yaml
set:
billingMetrics:
enabled: true
+ tokenUrl: ""
asserts:
- - contains:
- path: spec.template.spec.volumes
- content:
- name: billing-metrics-mtls
- secret:
- secretName: litellm-billing-metrics-mtls
+ - failedTemplate:
+ errorMessage: billingMetrics.tokenUrl is required when billingMetrics.enabled is true
- - it: fails loudly when the secretName is explicitly blanked
+ - it: requires the secret name when enabled
template: gateway/deployment.yaml
set:
billingMetrics:
@@ -235,15 +132,4 @@ tests:
secretName: ""
asserts:
- failedTemplate:
- errorMessage: billingMetrics.secretName is required when billingMetrics.enabled is true (an existing Secret with tls.crt and tls.key)
-
- - it: fails loudly when enabled without an endpoint
- template: gateway/deployment.yaml
- set:
- billingMetrics:
- enabled: true
- endpoint: ""
- secretName: billing-mtls
- asserts:
- - failedTemplate:
- errorMessage: billingMetrics.endpoint is required when billingMetrics.enabled is true
+ errorMessage: billingMetrics.secretName is required when billingMetrics.enabled is true
diff --git a/helm/litellm/tests/migration_job_tests.yaml b/helm/litellm/tests/migration_job_tests.yaml
index 2ebb1b44926..b9e52ba7123 100644
--- a/helm/litellm/tests/migration_job_tests.yaml
+++ b/helm/litellm/tests/migration_job_tests.yaml
@@ -91,7 +91,7 @@ tests:
app.kubernetes.io/name: litellm
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
- helm.sh/chart: litellm-0.1.0
+ helm.sh/chart: litellm-0.1.1
app.kubernetes.io/component: migrations
- it: renders pod-level and container-level securityContext in their own scopes
diff --git a/helm/litellm/values.yaml b/helm/litellm/values.yaml
index 92a48153c5a..cb37656cb77 100644
--- a/helm/litellm/values.yaml
+++ b/helm/litellm/values.yaml
@@ -180,23 +180,14 @@ masterKey:
secretKey: master-key
# Optional: enterprise billable-request metering. When enabled, the gateway and
-# backend count successful requests to inference, MCP, and A2A endpoints and push
-# them to LiteLLM's collector over mutual TLS. Both components serve billable
-# routes: the backend keeps the named-server MCP transport. Requires an
-# enterprise license. The client certificate identifies the deployment, so it is
-# mounted read-only from an existing Secret and never passed through the env.
+# backend count successful requests to inference, MCP, and A2A endpoints. Requires
+# an enterprise license.
billingMetrics:
enabled: false
- endpoint: https://telemetry.litellm.ai # collector to push the counter to
- # An existing Secret holding the client certificate under tls.crt and its key
- # under tls.key, usually created from the onboarding artifact. The default is
- # the conventional name, so the common path is to create that Secret and set
- # enabled: true. Override only if yours is named differently.
- secretName: litellm-billing-metrics-mtls
- # Only for private or test collectors whose server certificate is not on the
- # public web PKI. The production collector needs no CA override.
- caSecretName: "" # existing Secret holding ca.crt
- exportIntervalMs: "" # push cadence; the proxy defaults to 60000
+ endpoint: https://telemetry.litellm.ai
+ tokenUrl: https://litellm-prod.auth.us-west-1.amazoncognito.com/oauth2/token
+ secretName: litellm-billing-metrics
+ exportIntervalMs: ""
# External Postgres connection.
database:
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261029000000_add_background_response_settlement/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261029000000_add_background_response_settlement/migration.sql
new file mode 100644
index 00000000000..4965ed3cfc4
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261029000000_add_background_response_settlement/migration.sql
@@ -0,0 +1,9 @@
+SET LOCAL lock_timeout = '10s';
+
+-- CreateTable
+CREATE TABLE IF NOT EXISTS "LiteLLM_BackgroundResponseSettlement" (
+ "response_id" TEXT NOT NULL,
+ "settled_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+
+ CONSTRAINT "LiteLLM_BackgroundResponseSettlement_pkey" PRIMARY KEY ("response_id")
+);
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261103010000_spendlogs_accounting_delivery/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261103010000_spendlogs_accounting_delivery/migration.sql
new file mode 100644
index 00000000000..b00cf892b68
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261103010000_spendlogs_accounting_delivery/migration.sql
@@ -0,0 +1,19 @@
+SET LOCAL lock_timeout = '10s';
+CREATE TABLE IF NOT EXISTS "LiteLLM_SpendLogDelivery" (
+ "delivery_id" TEXT PRIMARY KEY DEFAULT gen_random_uuid()::text,
+ "request_id" TEXT NOT NULL,
+ "state" "AccountingDeliveryState" NOT NULL DEFAULT 'pending',
+ "attempts" INTEGER NOT NULL DEFAULT 0,
+ "next_attempt_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "applied_at" TIMESTAMP(3),
+ "last_error" TEXT,
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "accounting_payload" JSONB NOT NULL,
+ "is_batch" BOOLEAN NOT NULL
+);
+CREATE INDEX IF NOT EXISTS "LiteLLM_SpendLogDelivery_state_next_attempt_at_idx"
+ ON "LiteLLM_SpendLogDelivery" ("state", "next_attempt_at");
+CREATE INDEX IF NOT EXISTS "LiteLLM_SpendLogDelivery_state_applied_at_idx"
+ ON "LiteLLM_SpendLogDelivery" ("state", "applied_at");
+CREATE INDEX IF NOT EXISTS "LiteLLM_SpendLogDelivery_request_id_idx"
+ ON "LiteLLM_SpendLogDelivery" ("request_id");
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261104000000_skill_zip_upload/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261104000000_skill_zip_upload/migration.sql
new file mode 100644
index 00000000000..acbe87515d9
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261104000000_skill_zip_upload/migration.sql
@@ -0,0 +1,9 @@
+SET LOCAL lock_timeout = '10s';
+
+CREATE TABLE IF NOT EXISTS "LiteLLM_ClaudeCodePluginUpload" (
+ "plugin_name" TEXT NOT NULL,
+ "content" BYTEA NOT NULL,
+ CONSTRAINT "LiteLLM_ClaudeCodePluginUpload_pkey" PRIMARY KEY ("plugin_name"),
+ CONSTRAINT "LiteLLM_ClaudeCodePluginUpload_plugin_name_fkey" FOREIGN KEY ("plugin_name")
+ REFERENCES "LiteLLM_ClaudeCodePluginTable"("name") ON DELETE CASCADE ON UPDATE CASCADE
+);
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261104010000_drop_accounting_event_tables/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261104010000_drop_accounting_event_tables/migration.sql
new file mode 100644
index 00000000000..cba6a18368f
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261104010000_drop_accounting_event_tables/migration.sql
@@ -0,0 +1,5 @@
+SET LOCAL lock_timeout = '10s';
+DROP TABLE IF EXISTS "LiteLLM_AccountingDelivery";
+DROP TABLE IF EXISTS "LiteLLM_AccountingEvent";
+DROP TYPE IF EXISTS "AccountingDeliveryTarget";
+DROP TYPE IF EXISTS "AccountingEventKind";
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105000000_skill_version_history/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105000000_skill_version_history/migration.sql
new file mode 100644
index 00000000000..ecfa7321d87
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105000000_skill_version_history/migration.sql
@@ -0,0 +1,16 @@
+SET LOCAL lock_timeout = '10s';
+CREATE TABLE IF NOT EXISTS "LiteLLM_ClaudeCodePluginVersion" (
+ "id" TEXT NOT NULL,
+ "plugin_id" TEXT NOT NULL,
+ "version" TEXT,
+ "description" TEXT,
+ "manifest_json" TEXT,
+ "published_at" TIMESTAMP(3),
+ "published_by" TEXT,
+ "archive_available" BOOLEAN NOT NULL DEFAULT false,
+ "content" BYTEA,
+ CONSTRAINT "LiteLLM_ClaudeCodePluginVersion_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "LiteLLM_ClaudeCodePluginVersion_plugin_id_fkey" FOREIGN KEY ("plugin_id") REFERENCES "LiteLLM_ClaudeCodePluginTable"("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+CREATE UNIQUE INDEX IF NOT EXISTS "LiteLLM_ClaudeCodePluginVersion_plugin_id_version_key" ON "LiteLLM_ClaudeCodePluginVersion"("plugin_id", "version");
+CREATE INDEX IF NOT EXISTS "LiteLLM_ClaudeCodePluginVersion_plugin_id_published_at_idx" ON "LiteLLM_ClaudeCodePluginVersion"("plugin_id", "published_at");
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105010000_skill_submissions/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105010000_skill_submissions/migration.sql
new file mode 100644
index 00000000000..e7975258ca9
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105010000_skill_submissions/migration.sql
@@ -0,0 +1,27 @@
+SET LOCAL lock_timeout = '10s';
+
+CREATE TABLE IF NOT EXISTS "LiteLLM_SkillSubmission" (
+ "id" TEXT NOT NULL,
+ "plugin_name" TEXT NOT NULL,
+ "operation" TEXT NOT NULL,
+ "status" TEXT NOT NULL DEFAULT 'pending_review',
+ "proposal_json" TEXT NOT NULL,
+ "archive_content" BYTEA,
+ "submitted_by" TEXT NOT NULL,
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "base_plugin_id" TEXT,
+ "base_updated_at" TIMESTAMP(3),
+ "reviewed_by" TEXT,
+ "reviewed_at" TIMESTAMP(3),
+ "rejection_reason" TEXT,
+ CONSTRAINT "LiteLLM_SkillSubmission_pkey" PRIMARY KEY ("id")
+);
+
+CREATE INDEX IF NOT EXISTS "LiteLLM_SkillSubmission_submitted_by_created_at_id_idx"
+ ON "LiteLLM_SkillSubmission"("submitted_by", "created_at" DESC, "id" DESC);
+CREATE INDEX IF NOT EXISTS "LiteLLM_SkillSubmission_submitted_by_status_created_at_id_idx"
+ ON "LiteLLM_SkillSubmission"("submitted_by", "status", "created_at" DESC, "id" DESC);
+CREATE INDEX IF NOT EXISTS "LiteLLM_SkillSubmission_status_created_at_id_idx"
+ ON "LiteLLM_SkillSubmission"("status", "created_at" DESC, "id" DESC);
+CREATE INDEX IF NOT EXISTS "LiteLLM_SkillSubmission_created_at_id_idx"
+ ON "LiteLLM_SkillSubmission"("created_at" DESC, "id" DESC);
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105020000_skill_scanning/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105020000_skill_scanning/migration.sql
new file mode 100644
index 00000000000..6b70cca4a9a
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105020000_skill_scanning/migration.sql
@@ -0,0 +1,3 @@
+SET LOCAL lock_timeout = '10s';
+
+ALTER TABLE "LiteLLM_SkillSubmission" ADD COLUMN IF NOT EXISTS "scan_json" TEXT;
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105094500_add_skill_download_history/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105094500_add_skill_download_history/migration.sql
new file mode 100644
index 00000000000..43e26b324a0
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261105094500_add_skill_download_history/migration.sql
@@ -0,0 +1,37 @@
+SET LOCAL lock_timeout = '10s';
+
+DO $$
+BEGIN
+ IF NOT EXISTS (
+ SELECT 1 FROM pg_attribute
+ WHERE attrelid = to_regclass('"LiteLLM_ClaudeCodePluginTable"')
+ AND attname = 'anonymous_download_count' AND NOT attisdropped
+ ) THEN
+ ALTER TABLE "LiteLLM_ClaudeCodePluginTable"
+ ADD COLUMN IF NOT EXISTS "anonymous_download_count" BIGINT NOT NULL DEFAULT 0;
+ END IF;
+
+ IF to_regclass('"LiteLLM_ClaudeCodePluginDownload"') IS NULL THEN
+ CREATE TABLE IF NOT EXISTS "LiteLLM_ClaudeCodePluginDownload" (
+ "id" BIGSERIAL NOT NULL,
+ "plugin_id" TEXT NOT NULL,
+ "downloaded_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "version" TEXT,
+ "digest" TEXT NOT NULL,
+ "authenticated" BOOLEAN NOT NULL,
+ "user_id" TEXT,
+ "user_email" TEXT,
+ "key_alias" TEXT,
+ "team_id" TEXT,
+ "team_alias" TEXT,
+ CONSTRAINT "LiteLLM_ClaudeCodePluginDownload_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "LiteLLM_ClaudeCodePluginDownload_plugin_id_fkey" FOREIGN KEY ("plugin_id")
+ REFERENCES "LiteLLM_ClaudeCodePluginTable"("id") ON DELETE CASCADE ON UPDATE CASCADE
+ );
+ END IF;
+
+ IF to_regclass('"LiteLLM_ClaudeCodePluginDownload_plugin_id_id_idx"') IS NULL THEN
+ CREATE INDEX IF NOT EXISTS "LiteLLM_ClaudeCodePluginDownload_plugin_id_id_idx"
+ ON "LiteLLM_ClaudeCodePluginDownload"("plugin_id", "id");
+ END IF;
+END $$;
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261110000000_add_budget_model_tpm_rpm_limit/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261110000000_add_budget_model_tpm_rpm_limit/migration.sql
new file mode 100644
index 00000000000..6b77194e3b4
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261110000000_add_budget_model_tpm_rpm_limit/migration.sql
@@ -0,0 +1,7 @@
+SET LOCAL lock_timeout = '10s';
+
+-- AlterTable
+ALTER TABLE "LiteLLM_BudgetTable" ADD COLUMN IF NOT EXISTS "model_tpm_limit" JSONB;
+
+-- AlterTable
+ALTER TABLE "LiteLLM_BudgetTable" ADD COLUMN IF NOT EXISTS "model_rpm_limit" JSONB;
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20261110120000_add_daily_spend_guardrail_spend/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261110120000_add_daily_spend_guardrail_spend/migration.sql
new file mode 100644
index 00000000000..c2c264325a6
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20261110120000_add_daily_spend_guardrail_spend/migration.sql
@@ -0,0 +1,22 @@
+SET LOCAL lock_timeout = '10s';
+
+-- AlterTable
+ALTER TABLE "LiteLLM_DailyUserSpend" ADD COLUMN IF NOT EXISTS "guardrail_spend" DOUBLE PRECISION NOT NULL DEFAULT 0.0;
+
+-- AlterTable
+ALTER TABLE "LiteLLM_DailyTeamSpend" ADD COLUMN IF NOT EXISTS "guardrail_spend" DOUBLE PRECISION NOT NULL DEFAULT 0.0;
+
+-- AlterTable
+ALTER TABLE "LiteLLM_DailyOrganizationSpend" ADD COLUMN IF NOT EXISTS "guardrail_spend" DOUBLE PRECISION NOT NULL DEFAULT 0.0;
+
+-- AlterTable
+ALTER TABLE "LiteLLM_DailyEndUserSpend" ADD COLUMN IF NOT EXISTS "guardrail_spend" DOUBLE PRECISION NOT NULL DEFAULT 0.0;
+
+-- AlterTable
+ALTER TABLE "LiteLLM_DailyAgentSpend" ADD COLUMN IF NOT EXISTS "guardrail_spend" DOUBLE PRECISION NOT NULL DEFAULT 0.0;
+
+-- AlterTable
+ALTER TABLE "LiteLLM_DailyTagSpend" ADD COLUMN IF NOT EXISTS "guardrail_spend" DOUBLE PRECISION NOT NULL DEFAULT 0.0;
+
+-- AlterTable
+ALTER TABLE "LiteLLM_DailyGlobalSpend" ADD COLUMN IF NOT EXISTS "guardrail_spend" DOUBLE PRECISION NOT NULL DEFAULT 0.0;
diff --git a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
index 179b741fe7c..5a5d56cc6e2 100644
--- a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
+++ b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
@@ -19,6 +19,8 @@ model LiteLLM_BudgetTable {
rpm_limit BigInt?
tpd_limit BigInt?
model_max_budget Json?
+ model_tpm_limit Json?
+ model_rpm_limit Json?
budget_duration String?
budget_reset_at DateTime?
allowed_models String[] @default([]) // per-member model scope; empty = inherit team models
@@ -881,6 +883,7 @@ model LiteLLM_DailyUserSpend {
prompt_caching_savings_spend Float @default(0.0)
gateway_injected_caching_savings_spend Float @default(0.0)
autorouter_savings_spend Float @default(0.0)
+ guardrail_spend Float @default(0.0)
spend Float @default(0.0)
api_requests BigInt @default(0)
successful_requests BigInt @default(0)
@@ -917,6 +920,7 @@ model LiteLLM_DailyGlobalSpend {
prompt_caching_savings_spend Float @default(0.0)
gateway_injected_caching_savings_spend Float @default(0.0)
autorouter_savings_spend Float @default(0.0)
+ guardrail_spend Float @default(0.0)
spend Float @default(0.0)
api_requests BigInt @default(0)
successful_requests BigInt @default(0)
@@ -950,6 +954,7 @@ model LiteLLM_DailyOrganizationSpend {
prompt_caching_savings_spend Float @default(0.0)
gateway_injected_caching_savings_spend Float @default(0.0)
autorouter_savings_spend Float @default(0.0)
+ guardrail_spend Float @default(0.0)
spend Float @default(0.0)
api_requests BigInt @default(0)
successful_requests BigInt @default(0)
@@ -988,6 +993,7 @@ model LiteLLM_DailyEndUserSpend {
prompt_caching_savings_spend Float @default(0.0)
gateway_injected_caching_savings_spend Float @default(0.0)
autorouter_savings_spend Float @default(0.0)
+ guardrail_spend Float @default(0.0)
spend Float @default(0.0)
api_requests BigInt @default(0)
successful_requests BigInt @default(0)
@@ -1025,6 +1031,7 @@ model LiteLLM_DailyAgentSpend {
prompt_caching_savings_spend Float @default(0.0)
gateway_injected_caching_savings_spend Float @default(0.0)
autorouter_savings_spend Float @default(0.0)
+ guardrail_spend Float @default(0.0)
spend Float @default(0.0)
api_requests BigInt @default(0)
successful_requests BigInt @default(0)
@@ -1062,6 +1069,7 @@ model LiteLLM_DailyTeamSpend {
prompt_caching_savings_spend Float @default(0.0)
gateway_injected_caching_savings_spend Float @default(0.0)
autorouter_savings_spend Float @default(0.0)
+ guardrail_spend Float @default(0.0)
spend Float @default(0.0)
api_requests BigInt @default(0)
successful_requests BigInt @default(0)
@@ -1102,6 +1110,7 @@ model LiteLLM_DailyTagSpend {
prompt_caching_savings_spend Float @default(0.0)
gateway_injected_caching_savings_spend Float @default(0.0)
autorouter_savings_spend Float @default(0.0)
+ guardrail_spend Float @default(0.0)
spend Float @default(0.0)
api_requests BigInt @default(0)
successful_requests BigInt @default(0)
@@ -1615,9 +1624,77 @@ model LiteLLM_ClaudeCodePluginTable {
updated_at DateTime? @default(now()) @updatedAt
created_by String?
+ uploaded_archive LiteLLM_ClaudeCodePluginUpload?
+ versions LiteLLM_ClaudeCodePluginVersion[]
+ downloads LiteLLM_ClaudeCodePluginDownload[]
+ anonymous_download_count BigInt @default(0)
+
@@map("LiteLLM_ClaudeCodePluginTable")
}
+model LiteLLM_ClaudeCodePluginVersion {
+ id String @id @default(uuid())
+ plugin_id String
+ version String?
+ description String?
+ manifest_json String?
+ published_at DateTime?
+ published_by String?
+ archive_available Boolean @default(false)
+ content Bytes?
+ plugin LiteLLM_ClaudeCodePluginTable @relation(fields: [plugin_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
+
+ @@unique([plugin_id, version])
+ @@index([plugin_id, published_at])
+}
+
+
+model LiteLLM_SkillSubmission {
+ id String @id @default(uuid())
+ plugin_name String
+ operation String
+ status String @default("pending_review")
+ proposal_json String
+ archive_content Bytes?
+ submitted_by String
+ created_at DateTime @default(now())
+ base_plugin_id String?
+ base_updated_at DateTime?
+ reviewed_by String?
+ reviewed_at DateTime?
+ rejection_reason String?
+ scan_json String?
+
+ @@index([submitted_by, created_at(sort: Desc), id(sort: Desc)])
+ @@index([submitted_by, status, created_at(sort: Desc), id(sort: Desc)])
+ @@index([status, created_at(sort: Desc), id(sort: Desc)])
+ @@index([created_at(sort: Desc), id(sort: Desc)])
+}
+
+model LiteLLM_ClaudeCodePluginDownload {
+ id BigInt @id @default(autoincrement())
+ plugin_id String
+ downloaded_at DateTime @default(now())
+ version String?
+ digest String
+ authenticated Boolean
+ user_id String?
+ user_email String?
+ key_alias String?
+ team_id String?
+ team_alias String?
+ plugin LiteLLM_ClaudeCodePluginTable @relation(fields: [plugin_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
+
+ @@index([plugin_id, id])
+}
+
+model LiteLLM_ClaudeCodePluginUpload {
+ plugin_name String @id
+ content Bytes
+ plugin LiteLLM_ClaudeCodePluginTable @relation(fields: [plugin_name], references: [name], onDelete: Cascade, onUpdate: Cascade)
+}
+
+
// User/team-scoped memory store with a GLOBAL unique key.
// `value` is a string (typically markdown/text meant for LLM context);
// `metadata` is an optional JSON envelope for structured tags without schema changes.
@@ -1985,6 +2062,11 @@ model LiteLLM_BackgroundInteractionSettlement {
@@index([settled_at], map: "idx_background_interaction_settlement_settled_at")
}
+model LiteLLM_BackgroundResponseSettlement {
+ response_id String @id
+ settled_at DateTime @default(now())
+}
+
model LiteLLM_Lens {
reviews LiteLLM_LensReview[]
id String @id
@@ -2062,74 +2144,27 @@ model LiteLLM_TelemetryReport {
@@index([created_at])
}
-enum AccountingEventKind {
- inbound_usage
- outbound_usage
- cost
-}
-
enum AccountingDeliveryState {
pending
applied
parked
}
-enum AccountingDeliveryTarget {
- LiteLLM_VerificationToken
- LiteLLM_UserTable
- LiteLLM_TeamTable
- LiteLLM_TeamMembership
- LiteLLM_OrganizationTable
- LiteLLM_OrganizationMembership
- LiteLLM_EndUserTable
- LiteLLM_AgentsTable
- LiteLLM_TagTable
- LiteLLM_ProjectTable
- LiteLLM_ModelAccessGroupBudgetTable
- LiteLLM_BudgetTable
- LiteLLM_BudgetWindowSpend
- LiteLLM_DailyUserSpend
- LiteLLM_DailyTeamSpend
- LiteLLM_DailyOrganizationSpend
- LiteLLM_DailyEndUserSpend
- LiteLLM_DailyAgentSpend
- LiteLLM_DailyTagSpend
- LiteLLM_DailyModelUsage
- LiteLLM_DailyToolSpend
- LiteLLM_AutoRouterDailySpend
-}
+model LiteLLM_SpendLogDelivery {
+ delivery_id String @id @default(dbgenerated("(gen_random_uuid())::text"))
+ request_id String
+ state AccountingDeliveryState @default(pending)
+ accounting_payload Json
+ is_batch Boolean
+ attempts Int @default(0)
+ next_attempt_at DateTime @default(now())
+ applied_at DateTime?
+ last_error String?
+ created_at DateTime @default(now())
-// Durable accounting ledger. One row per usage or cost event; payload holds the
-// private event envelope versioned by schema_version. Usage rows retain request-scoped
-// pricing context; cost rows include resolved rates and the finalized pricing snapshot.
-model LiteLLM_AccountingEvent {
- event_id String @id
- kind AccountingEventKind
- source_event_id String?
- schema_version Int
- payload_hash String
- occurred_at DateTime
- recorded_at DateTime @default(now())
- payload Json
-
- @@index([recorded_at])
- @@index([kind, source_event_id])
-}
-
-// One row per (event, target table, version): pending work for the projector and,
-// once applied in the same transaction as the target write, the receipt that stops a retry.
-model LiteLLM_AccountingDelivery {
- event_id String
- target AccountingDeliveryTarget
- version Int
- state AccountingDeliveryState @default(pending)
- attempts Int @default(0)
- next_attempt_at DateTime @default(now())
- applied_at DateTime?
- last_error String?
-
- @@id([event_id, target, version])
- @@index([target, state, next_attempt_at])
+ @@index([state, next_attempt_at])
+ @@index([state, applied_at])
+ @@index([request_id])
}
model LiteLLM_SubscriptionAccountTable {
diff --git a/litellm-proxy-extras/pyproject.toml b/litellm-proxy-extras/pyproject.toml
index a12e1e27cfc..1c0c708ae7a 100644
--- a/litellm-proxy-extras/pyproject.toml
+++ b/litellm-proxy-extras/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "litellm-proxy-extras"
-version = "0.4.112"
+version = "0.4.114"
description = "Additional files for the LiteLLM Proxy. Reduces the size of the main litellm package."
readme = "README.md"
requires-python = ">=3.9"
@@ -30,7 +30,7 @@ required-version = ">=0.10.9"
module-root = ""
[tool.commitizen]
-version = "0.4.112"
+version = "0.4.114"
version_files = [
"pyproject.toml:^version",
"../pyproject.toml:litellm-proxy-extras==",
diff --git a/litellm-rust/.agents/skills/rust-gateway/SKILL.md b/litellm-rust/.agents/skills/rust-gateway/SKILL.md
index 4fee0b54a68..923c9bf5ab6 100644
--- a/litellm-rust/.agents/skills/rust-gateway/SKILL.md
+++ b/litellm-rust/.agents/skills/rust-gateway/SKILL.md
@@ -7,7 +7,7 @@ metadata:
# Rust gateway
-`crates/gateway` mounts endpoint routers and serves the listener. `crates/gateway-inference`, `gateway-mcp` and `gateway-ui` own their endpoints, `gateway-auth` is the inbound authentication middleware and `gateway-management` holds management logic that has no router yet. A crate's `AGENTS.md`, where it has one, says what belongs in it. Read the reference for the part you are touching
+`crates/gateway` mounts endpoint routers and serves the listener. `crates/gateway-inference`, `gateway-mcp` and `gateway-ui` own their endpoints, `gateway-auth` is the inbound authentication middleware and `gateway-management` holds management logic that has no router yet. `gateway-forward` is the reverse proxy that relays every request to the Python proxy and has no routes of its own. A crate's `AGENTS.md`, where it has one, says what belongs in it. Read the reference for the part you are touching
- [surfaces](references/surfaces.md)
- Each API surface mirrors the envelope the Python proxy returns there, so the shapes differ on purpose
diff --git a/litellm-rust/.agents/skills/rust-python-boundary/SKILL.md b/litellm-rust/.agents/skills/rust-python-boundary/SKILL.md
new file mode 100644
index 00000000000..5ead8f287ab
--- /dev/null
+++ b/litellm-rust/.agents/skills/rust-python-boundary/SKILL.md
@@ -0,0 +1,53 @@
+---
+name: rust-python-boundary
+description: Decide where Python-shaped input becomes typed Rust in litellm-rust. Use when reading config.yaml values, os.environ/ references, REDIS_* or other environment layering, get_secret fallbacks, or kwargs and objects handed over from Python, when coercing text to a bool, int or float the way Python does, or when adding a dependency on litellm-python-compat
+metadata:
+ internal: true
+---
+
+# Python boundary
+
+Python-shaped input becomes typed Rust in exactly two crates. Every crate past them handles typed values, so no crate re-guesses how Python would have read a value
+
+## The two boundaries
+
+- `crates/config` reads config.yaml, which is Python-shaped: `os.environ/` references, scalars that Helm or the environment turned into text, raw kwargs maps. It also owns the environment layering and `get_secret` fallbacks Python applies while it loads that config. It has no Python runtime, so it reproduces Python value semantics with `litellm-python-compat`
+- `crates/python-bridge` receives live Python objects, such as `RedisCache.redis_kwargs`. It reads them through PyO3 with the real protocol (`is_truthy()`, `str()`, `extract`), so it never imitates Python
+- Both produce the same typed input, defined in the data crate the consumer already depends on (`redis-types` for Redis), so a downstream crate cannot tell which host it runs under
+
+## Python value semantics
+
+Reading a value the way Python itself reads it. This lives only at the two boundaries
+
+- Truthiness and `x or fallback`, `str(x)`, `int(text)` and `float(text)`
+- Each surface's true and false text: `_str_to_bool`, pydantic's lax bool, `get_secret`'s `true` and `false`
+- `os.environ/` references and `REDIS_` style environment layering
+
+A boundary knows which surface a value came from. `general_settings.coordination_redis` is a pydantic model and `cache_params` goes through `_str_to_bool`, so the boundary applies that surface's rule exactly instead of refusing the text two surfaces disagree on
+
+Each typed field keeps where its value came from (the key, `REDIS_` or the fallback name), so an error or warning downstream still names it
+
+## What stays downstream
+
+A crate that stands in for a Python library keeps that library's semantics, because they are its compatibility contract and not value coercion. `redis-resolve` stands in for redis-py, so it keeps
+
+- Which target wins, and the defaults redis-py applies
+- How `parse_url` reads a url, including `int()` on `?db=` and redis-py's `to_bool` on the TLS query parameters
+- Which kwargs redis-py accepts, and whether the Rust client reads, warns about or refuses each one
+
+Its input is typed. A rule it applies reads typed fields, never a `serde_json::Value` it has to coerce first. A value it only carries back to Python untouched, like `passthrough`, may stay untyped
+
+## litellm-python-compat
+
+The rule is about where config and kwargs get coerced, not about who may depend on the crate
+
+- Its data formats (`pickle`, `json.dumps`, `repr`) are fine anywhere Rust reads or writes state Python also reads or writes, such as cache values in a shared Redis
+- Its coercions (`truthy`, `number`) belong at the two boundaries, and in a crate that stands in for a Python library when that library calls them itself
+
+## Existing code
+
+Some code still coerces Python-shaped values past the boundary, for example the `REDIS_*` merge in `gateway/src/redis/layers.rs` and the flag and number readers in `redis-resolve/src/options.rs`. Do not add more. When you change one, move the coercion to its boundary instead of extending it in place
+
+## Tests
+
+Pin a boundary's coercion with named cases next to the Python function it mirrors, in the Rust test and in its Python twin, like the Redis contract cases in `redis-resolve/tests/interpret.rs` and `tests/unit/test_redis.py`. A downstream crate's tests build its typed input directly and never feed it raw text to coerce
diff --git a/litellm-rust/AGENTS.md b/litellm-rust/AGENTS.md
index 5eaf876e3b2..5fcf05f61f7 100644
--- a/litellm-rust/AGENTS.md
+++ b/litellm-rust/AGENTS.md
@@ -8,6 +8,10 @@ For string-valued enums and their Serde conversions, follow [.agents/skills/rust
For error types, error variants and conversions between crate errors, follow [.agents/skills/rust-error/SKILL.md](.agents/skills/rust-error/SKILL.md)
+For where config.yaml values, environment layering and kwargs from Python become typed Rust, follow [.agents/skills/rust-python-boundary/SKILL.md](.agents/skills/rust-python-boundary/SKILL.md)
+
+The process-wide rustls `CryptoProvider` (ring) is installed once by the host. rust-proxy does it at the top of `main` through `litellm_gateway::install_crypto_provider`, and python-bridge must do the same in its module init before it builds any rustls config. Library crates never install it. The AWS SDK links aws-lc-rs next to ring, so without an installed default the first rustls config a library builds, such as redis-rs TLS, panics
+
For fieldless enums, derive `strum::VariantArray` and use `VARIANTS` instead of a hand-listed `ALL` array. Derive Strum string conversions instead of hand-written variant-to-string matches
Use the derived conversions directly (`<&'static str>::from(x)` / `.into()`, `str::parse`) with no `as_str`/`parse` wrapper that only delegates, and spell each variant with explicit `#[strum(serialize = "...")]` instead of `serialize_all`
diff --git a/litellm-rust/Cargo.lock b/litellm-rust/Cargo.lock
index f91deaaa401..ed658e074ee 100644
--- a/litellm-rust/Cargo.lock
+++ b/litellm-rust/Cargo.lock
@@ -8,6 +8,17 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
+[[package]]
+name = "aes"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures 0.2.17",
+]
+
[[package]]
name = "ahash"
version = "0.8.12"
@@ -547,7 +558,7 @@ dependencies = [
"http 1.4.2",
"http-body 0.4.6",
"hyper 0.14.32",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-rustls 0.24.2",
"hyper-rustls 0.27.9",
"hyper-util",
@@ -736,7 +747,7 @@ dependencies = [
"http 1.4.2",
"http-body 1.1.0",
"http-body-util",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-util",
"itoa",
"matchit",
@@ -883,6 +894,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cffb0e931875b666fc4fcb20fee52e9bbd1ef836fd9e9e04ec21555f9f85f7ef"
dependencies = [
"fastrand",
+ "tokio",
]
[[package]]
@@ -982,6 +994,15 @@ dependencies = [
"hybrid-array",
]
+[[package]]
+name = "block-padding"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
+dependencies = [
+ "generic-array",
+]
+
[[package]]
name = "bollard"
version = "0.20.2"
@@ -1000,7 +1021,7 @@ dependencies = [
"home",
"http 1.4.2",
"http-body-util",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-named-pipe",
"hyper-rustls 0.27.9",
"hyper-util",
@@ -1134,6 +1155,15 @@ dependencies = [
"rustversion",
]
+[[package]]
+name = "cbc"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "cc"
version = "1.3.0"
@@ -1210,6 +1240,16 @@ dependencies = [
"half",
]
+[[package]]
+name = "cipher"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
+dependencies = [
+ "crypto-common 0.1.7",
+ "inout",
+]
+
[[package]]
name = "clap"
version = "4.6.7"
@@ -1774,6 +1814,15 @@ dependencies = [
"syn 2.0.119",
]
+[[package]]
+name = "des"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ffdd80ce8ce993de27e9f063a444a4d53ce8e8db4c1f00cc03af5ad5a9867a1e"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "digest"
version = "0.10.7"
@@ -2255,7 +2304,7 @@ dependencies = [
"chrono",
"http 1.4.2",
"http-body-util",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-rustls 0.27.9",
"hyper-util",
"ring",
@@ -2391,7 +2440,7 @@ dependencies = [
"http 1.4.2",
"http-body 1.1.0",
"http-body-util",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"lazy_static",
"opentelemetry",
"opentelemetry-semantic-conventions",
@@ -2833,9 +2882,9 @@ dependencies = [
[[package]]
name = "hyper"
-version = "1.10.1"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "55281c53a1894c864990125767da440a4e630446785086f52523b20033b74498"
+checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c"
dependencies = [
"atomic-waker",
"bytes",
@@ -2860,7 +2909,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fab3637d6b04a8037af8a266fdf6cf92ea957e8c53981a2bf6136572531025bf"
dependencies = [
"hex",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-util",
"pin-project-lite",
"tokio",
@@ -2889,7 +2938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f"
dependencies = [
"http 1.4.2",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-util",
"rustls 0.23.42",
"rustls-native-certs",
@@ -2904,7 +2953,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0"
dependencies = [
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-util",
"pin-project-lite",
"tokio",
@@ -2923,7 +2972,7 @@ dependencies = [
"futures-util",
"http 1.4.2",
"http-body 1.1.0",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"ipnet",
"libc",
"percent-encoding",
@@ -2942,7 +2991,7 @@ checksum = "986c5ce3b994526b3cd75578e62554abd09f0899d6206de48b3e96ab34ccc8c7"
dependencies = [
"hex",
"http-body-util",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-util",
"pin-project-lite",
"tokio",
@@ -3105,6 +3154,16 @@ dependencies = [
"serde_core",
]
+[[package]]
+name = "inout"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
+dependencies = [
+ "block-padding",
+ "generic-array",
+]
+
[[package]]
name = "ipnet"
version = "2.12.0"
@@ -3389,15 +3448,19 @@ version = "0.1.0"
dependencies = [
"aws-config",
"aws-credential-types",
+ "aws-runtime",
"aws-sdk-sts",
"aws-sigv4",
"aws-smithy-runtime-api",
+ "aws-smithy-types",
"aws-types",
"bytes",
"futures-util",
"litellm-auth-types",
"litellm-error",
"litellm-http",
+ "litellm-secret-value",
+ "litellm-secrets",
"moka",
"reqwest",
"rstest",
@@ -3406,6 +3469,7 @@ dependencies = [
"sha2 0.10.9",
"thiserror 2.0.19",
"tokio",
+ "url",
"veil",
]
@@ -3418,6 +3482,7 @@ dependencies = [
"litellm-auth-types",
"litellm-error",
"litellm-secret-value",
+ "litellm-secrets",
"moka",
"rstest",
"serde_json",
@@ -3431,6 +3496,7 @@ dependencies = [
name = "litellm-auth-gcp"
version = "0.1.0"
dependencies = [
+ "axum",
"base64 0.22.1",
"gcp_auth",
"google-cloud-auth",
@@ -3440,10 +3506,12 @@ dependencies = [
"litellm-secret-value",
"moka",
"rstest",
+ "rustls 0.23.42",
"serde",
"serde_json",
"sha2 0.10.9",
"tempfile",
+ "time",
"tokio",
"veil",
]
@@ -3569,37 +3637,6 @@ dependencies = [
"uuid",
]
-[[package]]
-name = "litellm-cache-redis"
-version = "0.1.0"
-dependencies = [
- "litellm-cache",
- "litellm-cache-testing",
- "litellm-error",
- "r2d2",
- "redis",
- "redis-test",
- "rstest",
- "serde_json",
- "thiserror 2.0.19",
- "tokio",
-]
-
-[[package]]
-name = "litellm-cache-redis-semantic"
-version = "0.1.0"
-dependencies = [
- "litellm-cache",
- "litellm-cache-redis",
- "litellm-cache-testing",
- "redis",
- "redis-test",
- "rstest",
- "serde_json",
- "sha2 0.10.9",
- "tokio",
-]
-
[[package]]
name = "litellm-cache-response"
version = "0.1.0"
@@ -3607,11 +3644,8 @@ dependencies = [
"litellm-cache",
"litellm-cache-gcs",
"litellm-cache-memory",
- "litellm-cache-redis",
"litellm-http",
"py_literal",
- "redis",
- "redis-test",
"rstest",
"serde",
"serde_json",
@@ -3624,19 +3658,15 @@ dependencies = [
name = "litellm-cache-s3"
version = "0.1.0"
dependencies = [
- "aws-credential-types",
"aws-sdk-s3",
- "aws-smithy-runtime-api",
"aws-smithy-types",
- "aws-types",
"futures-util",
- "http 1.4.2",
"litellm-auth-aws",
"litellm-cache",
"litellm-cache-testing",
"litellm-error",
"litellm-http",
- "reqwest",
+ "litellm-s3",
"rstest",
"serde_json",
"tokio",
@@ -3650,24 +3680,6 @@ dependencies = [
"litellm-cache",
]
-[[package]]
-name = "litellm-cache-valkey-semantic"
-version = "0.1.0"
-dependencies = [
- "litellm-cache",
- "litellm-cache-redis",
- "litellm-cache-testing",
- "litellm-error",
- "redis",
- "redis-test",
- "rstest",
- "serde_json",
- "sha2 0.10.9",
- "thiserror 2.0.19",
- "tokio",
- "uuid",
-]
-
[[package]]
name = "litellm-callbacks-legacy-python"
version = "0.1.0"
@@ -3706,8 +3718,7 @@ dependencies = [
"strum",
"tempfile",
"thiserror 2.0.19",
- "tracing",
- "tracing-subscriber",
+ "veil",
]
[[package]]
@@ -3810,8 +3821,10 @@ dependencies = [
"http-body-util",
"litellm-circuit-breaker",
"litellm-config",
+ "litellm-core-utils",
"litellm-error",
"litellm-gateway-auth",
+ "litellm-gateway-forward",
"litellm-gateway-inference",
"litellm-gateway-mcp",
"litellm-gateway-ui",
@@ -3819,11 +3832,15 @@ dependencies = [
"litellm-inference",
"litellm-llms",
"litellm-redis-client",
+ "litellm-redis-connect",
+ "litellm-redis-resolve",
"litellm-redis-testing",
+ "litellm-redis-types",
"litellm-secret-value",
"litellm-secrets",
"litellm-tracing",
"rstest",
+ "rustls 0.23.42",
"serde",
"serde_json",
"tempfile",
@@ -3834,6 +3851,7 @@ dependencies = [
"tower-sessions-moka-store",
"tracing",
"uuid",
+ "veil",
]
[[package]]
@@ -3858,6 +3876,29 @@ dependencies = [
"veil",
]
+[[package]]
+name = "litellm-gateway-forward"
+version = "0.1.0"
+dependencies = [
+ "axum",
+ "bytes",
+ "envy",
+ "futures-util",
+ "http-body-util",
+ "httparse",
+ "hyper 1.12.0",
+ "hyper-util",
+ "proptest",
+ "rstest",
+ "serde",
+ "thiserror 2.0.19",
+ "tokio",
+ "tokio-tungstenite",
+ "tokio-util",
+ "tower-service",
+ "tracing",
+]
+
[[package]]
name = "litellm-gateway-inference"
version = "0.1.0"
@@ -4302,12 +4343,14 @@ dependencies = [
"jsonschema",
"litellm-cost",
"litellm-error",
+ "litellm-tracing",
"macro_rules_attribute",
"rstest",
"schemars 1.2.2",
"serde",
"serde_json",
"serde_with",
+ "sha1 0.10.7",
"strum",
"thiserror 2.0.19",
"time",
@@ -4317,9 +4360,13 @@ dependencies = [
name = "litellm-model-catalog-refresh"
version = "0.1.0"
dependencies = [
+ "aws-credential-types",
+ "backon",
+ "bytes",
"litellm-error",
"litellm-http",
- "litellm-model-catalog",
+ "litellm-s3",
+ "litellm-tracing",
"reqwest",
"rstest",
"thiserror 2.0.19",
@@ -4331,18 +4378,19 @@ dependencies = [
name = "litellm-python-bridge"
version = "0.1.0"
dependencies = [
+ "async-trait",
"aws-sdk-secretsmanager",
"bytes",
"criterion",
"fancy-regex 0.19.2",
"futures-util",
+ "indexmap 2.14.0",
"litellm-auth",
"litellm-auth-aws",
"litellm-cache",
- "litellm-cache-memory",
- "litellm-cache-redis",
"litellm-cache-response",
"litellm-callbacks-legacy-python",
+ "litellm-circuit-breaker",
"litellm-core-utils",
"litellm-error",
"litellm-host",
@@ -4357,6 +4405,14 @@ dependencies = [
"litellm-llms",
"litellm-llms-types",
"litellm-model-catalog",
+ "litellm-model-catalog-refresh",
+ "litellm-python-compat",
+ "litellm-redis-client",
+ "litellm-redis-connect",
+ "litellm-redis-resolve",
+ "litellm-redis-store",
+ "litellm-redis-types",
+ "litellm-router-core",
"litellm-router-types",
"litellm-secret-value",
"litellm-secrets",
@@ -4369,9 +4425,9 @@ dependencies = [
"prost",
"pyo3",
"pyo3-async-runtimes",
- "redis",
"reqwest",
"rstest",
+ "rustls 0.23.42",
"serde",
"serde_json",
"serde_with",
@@ -4407,23 +4463,110 @@ version = "0.1.0"
dependencies = [
"futures-util",
"litellm-circuit-breaker",
+ "litellm-python-compat",
"litellm-redis-testing",
+ "litellm-redis-types",
"litellm-secret-value",
+ "pem",
+ "pkcs8",
"redis",
"rstest",
+ "rustls 0.23.42",
+ "rustls-native-certs",
+ "socket2 0.6.5",
"thiserror 2.0.19",
"tokio",
+ "tracing",
+]
+
+[[package]]
+name = "litellm-redis-connect"
+version = "0.1.0"
+dependencies = [
+ "futures-util",
+ "litellm-auth-aws",
+ "litellm-auth-azure",
+ "litellm-auth-gcp",
+ "litellm-auth-types",
+ "litellm-circuit-breaker",
+ "litellm-core-utils",
+ "litellm-error",
+ "litellm-http",
+ "litellm-redis-client",
+ "litellm-redis-resolve",
+ "litellm-redis-testing",
+ "litellm-redis-types",
+ "litellm-secret-value",
+ "rstest",
+ "rustls 0.23.42",
+ "serde",
+ "serde_json",
+ "strum",
+ "thiserror 2.0.19",
+ "time",
+ "tokio",
+ "tracing",
+ "url",
+ "veil",
+]
+
+[[package]]
+name = "litellm-redis-resolve"
+version = "0.1.0"
+dependencies = [
+ "litellm-python-compat",
+ "litellm-redis-types",
+ "litellm-secret-value",
+ "rstest",
+ "serde",
+ "serde_json",
+ "strum",
+ "thiserror 2.0.19",
+ "tracing",
+ "url",
+]
+
+[[package]]
+name = "litellm-redis-store"
+version = "0.1.0"
+dependencies = [
+ "futures-util",
+ "litellm-cache",
+ "litellm-cache-memory",
+ "litellm-circuit-breaker",
+ "litellm-python-compat",
+ "litellm-redis-client",
+ "litellm-redis-testing",
+ "litellm-secret-value",
+ "litellm-tracing",
+ "rstest",
+ "strum",
+ "thiserror 2.0.19",
+ "tokio",
+ "tracing",
]
[[package]]
name = "litellm-redis-testing"
version = "0.1.0"
dependencies = [
+ "pkcs8",
+ "rcgen",
+ "tempfile",
"testcontainers-modules",
"thiserror 2.0.19",
"tokio",
]
+[[package]]
+name = "litellm-redis-types"
+version = "0.1.0"
+dependencies = [
+ "litellm-secret-value",
+ "rstest",
+ "url",
+]
+
[[package]]
name = "litellm-router"
version = "0.1.0"
@@ -4439,6 +4582,24 @@ dependencies = [
[[package]]
name = "litellm-router-core"
version = "0.1.0"
+dependencies = [
+ "arc-swap",
+ "async-trait",
+ "jiff",
+ "litellm-cache",
+ "litellm-router-types",
+ "parking_lot",
+ "rand 0.8.7",
+ "rstest",
+ "serde",
+ "serde_json",
+ "serde_with",
+ "sha2 0.10.9",
+ "strum",
+ "thiserror 2.0.19",
+ "tokio",
+ "tracing",
+]
[[package]]
name = "litellm-router-types"
@@ -4452,6 +4613,23 @@ dependencies = [
"serde_with",
]
+[[package]]
+name = "litellm-s3"
+version = "0.1.0"
+dependencies = [
+ "aws-config",
+ "aws-credential-types",
+ "aws-sdk-s3",
+ "aws-smithy-runtime-api",
+ "aws-smithy-types",
+ "aws-types",
+ "http 1.4.2",
+ "litellm-http",
+ "reqwest",
+ "rstest",
+ "thiserror 2.0.19",
+]
+
[[package]]
name = "litellm-secret-value"
version = "0.1.0"
@@ -5288,6 +5466,16 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
+[[package]]
+name = "pbkdf2"
+version = "0.12.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
+dependencies = [
+ "digest 0.10.7",
+ "hmac 0.12.1",
+]
+
[[package]]
name = "pem"
version = "4.0.0"
@@ -5398,6 +5586,22 @@ dependencies = [
"spki",
]
+[[package]]
+name = "pkcs5"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e847e2c91a18bfa887dd028ec33f2fe6f25db77db3619024764914affe8b69a6"
+dependencies = [
+ "aes",
+ "cbc",
+ "der",
+ "des",
+ "pbkdf2",
+ "scrypt",
+ "sha2 0.10.9",
+ "spki",
+]
+
[[package]]
name = "pkcs8"
version = "0.10.2"
@@ -5405,6 +5609,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
dependencies = [
"der",
+ "pkcs5",
+ "rand_core 0.6.4",
"spki",
]
@@ -5592,6 +5798,7 @@ version = "0.29.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4688ddedf473e32662b9b067670129a8afb8c18e351482c70d62ba4a88171e8b"
dependencies = [
+ "indexmap 2.14.0",
"libc",
"once_cell",
"portable-atomic",
@@ -5782,17 +5989,6 @@ version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
-[[package]]
-name = "r2d2"
-version = "0.8.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93"
-dependencies = [
- "log",
- "parking_lot",
- "scheduled-thread-pool",
-]
-
[[package]]
name = "rand"
version = "0.8.7"
@@ -5966,18 +6162,6 @@ dependencies = [
"xxhash-rust",
]
-[[package]]
-name = "redis-test"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "804d36862e4323b69f96440cbb13c9894fc90176abdeaf91264e21d5d77f6aca"
-dependencies = [
- "rand 0.9.5",
- "redis",
- "socket2 0.6.5",
- "tempfile",
-]
-
[[package]]
name = "redox_syscall"
version = "0.5.18"
@@ -6080,7 +6264,7 @@ dependencies = [
"http 1.4.2",
"http-body 1.1.0",
"http-body-util",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-rustls 0.27.9",
"hyper-util",
"js-sys",
@@ -6436,6 +6620,15 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
+[[package]]
+name = "salsa20"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "same-file"
version = "1.0.6"
@@ -6454,15 +6647,6 @@ dependencies = [
"windows-sys 0.61.2",
]
-[[package]]
-name = "scheduled-thread-pool"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3cbc66816425a074528352f5789333ecff06ca41b36b0b0efdfbb29edc391a19"
-dependencies = [
- "parking_lot",
-]
-
[[package]]
name = "schemars"
version = "0.9.0"
@@ -6508,6 +6692,17 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+[[package]]
+name = "scrypt"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f"
+dependencies = [
+ "pbkdf2",
+ "salsa20",
+ "sha2 0.10.9",
+]
+
[[package]]
name = "sct"
version = "0.7.1"
@@ -7570,6 +7765,7 @@ dependencies = [
"bytes",
"futures-core",
"futures-sink",
+ "futures-util",
"pin-project-lite",
"tokio",
]
@@ -7649,7 +7845,7 @@ dependencies = [
"http 1.4.2",
"http-body 1.1.0",
"http-body-util",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-timeout",
"hyper-util",
"percent-encoding",
@@ -8225,9 +8421,9 @@ dependencies = [
[[package]]
name = "want"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
+checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b"
dependencies = [
"try-lock",
]
@@ -8609,7 +8805,7 @@ dependencies = [
"futures",
"http 1.4.2",
"http-body-util",
- "hyper 1.10.1",
+ "hyper 1.12.0",
"hyper-util",
"log",
"once_cell",
diff --git a/litellm-rust/Cargo.toml b/litellm-rust/Cargo.toml
index 75cac2a5d63..cc72cd01dc0 100644
--- a/litellm-rust/Cargo.toml
+++ b/litellm-rust/Cargo.toml
@@ -13,6 +13,7 @@ litellm-config = { path = "crates/config" }
litellm-error = { path = "crates/error" }
litellm-router = { path = "crates/router" }
litellm-router-types = { path = "crates/router-types" }
+litellm-router-core = { path = "crates/router-core" }
litellm-tracing = { path = "crates/tracing" }
litellm-spend-clickhouse = { path = "crates/spend-clickhouse" }
litellm-storage-clickhouse = { path = "crates/storage-clickhouse" }
@@ -25,6 +26,7 @@ litellm-inference-ocr = { path = "crates/inference-ocr" }
litellm-inference-testing = { path = "crates/inference-testing" }
litellm-gateway-mcp = { path = "crates/gateway-mcp" }
litellm-gateway = { path = "crates/gateway" }
+litellm-gateway-forward = { path = "crates/gateway-forward" }
litellm-gateway-inference = { path = "crates/gateway-inference" }
litellm-gateway-auth = { path = "crates/gateway-auth" }
litellm-gateway-management = { path = "crates/gateway-management" }
@@ -57,11 +59,10 @@ litellm-db-testing = { path = "crates/db-testing" }
litellm-cache = { path = "crates/cache" }
litellm-cache-azure-blob = { path = "crates/cache-azure-blob" }
litellm-cache-memory = { path = "crates/cache-memory" }
-litellm-cache-redis = { path = "crates/cache-redis" }
litellm-cache-s3 = { path = "crates/cache-s3" }
+litellm-s3 = { path = "crates/s3" }
litellm-cache-gcs = { path = "crates/cache-gcs" }
litellm-cache-disk = { path = "crates/cache-disk" }
-litellm-cache-redis-semantic = { path = "crates/cache-redis-semantic" }
litellm-cache-response = { path = "crates/cache-response" }
litellm-cache-qdrant-semantic = { path = "crates/cache-qdrant-semantic" }
litellm-cache-testing = { path = "crates/cache-testing" }
@@ -73,17 +74,25 @@ litellm-host-python = { path = "crates/host-python" }
litellm-python-compat = { path = "crates/python-compat" }
litellm-circuit-breaker = { path = "crates/circuit-breaker" }
litellm-redis-client = { path = "crates/redis-client" }
+litellm-redis-connect = { path = "crates/redis-connect" }
+litellm-redis-store = { path = "crates/redis-store" }
litellm-redis-testing = { path = "crates/redis-testing" }
+litellm-redis-resolve = { path = "crates/redis-resolve" }
+litellm-redis-types = { path = "crates/redis-types" }
litellm-cost = { path = "crates/cost" }
litellm-model-catalog = { path = "crates/model-catalog" }
litellm-model-catalog-refresh = { path = "crates/model-catalog-refresh" }
+arc-swap = "1.9.2"
+async-trait = "0.1.91"
askama = { version = "0.16.1", default-features = false, features = ["derive", "std"] }
tracing = "0.1"
axum = { version = "0.8.9", default-features = false, features = ["http1", "tokio", "multipart"] }
axum-login = "0.18.0"
tower-sessions = { version = "0.14.0", features = ["memory-store"] }
bytes = "1"
+backon = { version = "1.6.0", default-features = false, features = ["std", "tokio-sleep"] }
+aws-sdk-s3 = { version = "1.146.1", default-features = false, features = ["rt-tokio"] }
http = "1"
google-cloud-auth = { version = "1.16.0", default-features = false }
jsonwebtoken = { version = "11.1.0", default-features = false }
@@ -97,7 +106,6 @@ macro_rules_attribute = "0.2.3"
schemars = "1"
reqwest = { version = "0.13", default-features = false, features = ["json", "multipart", "rustls", "http2", "stream", "query"] }
redis = "1.8.0"
-redis-test = "1.0.4"
testcontainers-modules = "0.15.0"
qdrant-client = { version = "1.19.0", default-features = false }
uuid = { version = "1", features = ["v4"] }
diff --git a/litellm-rust/crates/auth-aws/Cargo.toml b/litellm-rust/crates/auth-aws/Cargo.toml
index e4578777a08..c8ed7bb0f14 100644
--- a/litellm-rust/crates/auth-aws/Cargo.toml
+++ b/litellm-rust/crates/auth-aws/Cargo.toml
@@ -11,14 +11,16 @@ litellm-error.workspace = true
litellm-http.workspace = true
reqwest.workspace = true
-moka = { workspace = true, features = ["sync"] }
+moka.workspace = true
+litellm-secret-value.workspace = true
serde.workspace = true
serde_json = { workspace = true, features = ["preserve_order"] }
sha2.workspace = true
thiserror.workspace = true
+url.workspace = true
veil.workspace = true
-aws-config = { version = "1.9.0", default-features = false, features = ["rustls", "rt-tokio"] }
+aws-config = { version = "1.9.0", default-features = false, features = ["rustls", "rt-tokio", "credentials-process"] }
aws-credential-types = { version = "1.3.0", features = ["hardcoded-credentials"] }
aws-sdk-sts = { version = "1.108.0", default-features = false, features = ["rustls", "rt-tokio"] }
aws-sigv4 = "1.5.1"
@@ -26,6 +28,9 @@ aws-types = "1.4.0"
aws-smithy-runtime-api = "1.13.0"
[dev-dependencies]
+litellm-secrets.workspace = true
+aws-smithy-types = "1.6.4"
+aws-runtime = { version = "1.9.4", default-features = false }
rstest.workspace = true
litellm-http = { workspace = true, features = ["test-support"] }
bytes.workspace = true
diff --git a/litellm-rust/crates/auth-aws/src/aws.rs b/litellm-rust/crates/auth-aws/src/aws.rs
index 81aa4b068bc..e6e32754b4f 100644
--- a/litellm-rust/crates/auth-aws/src/aws.rs
+++ b/litellm-rust/crates/auth-aws/src/aws.rs
@@ -1,13 +1,16 @@
use std::time::Duration;
use std::time::{SystemTime, UNIX_EPOCH};
-use moka::sync::Cache;
-use sha2::{Digest, Sha256};
+use aws_credential_types::provider::{SharedCredentialsProvider, error::CredentialsError};
+use litellm_secret_value::SecretValue;
+use moka::{Expiry, future::Cache};
+use std::{future::Future, pin::Pin, sync::Arc};
use aws_credential_types::Credentials;
use aws_credential_types::provider::ProvideCredentials;
use aws_sigv4::http_request::{
- SignableBody, SignableRequest, SigningParams, SigningSettings, sign,
+ SignableBody, SignableRequest, SignatureLocation, SigningInstructions, SigningParams,
+ SigningSettings, sign,
};
use aws_sigv4::sign::v4;
use aws_smithy_runtime_api::client::identity::Identity;
@@ -23,72 +26,106 @@ use super::constants::{
};
use crate::error::{CredentialFlow, Error, SigningStage};
-const STATIC_CREDENTIALS_TTL: Duration = Duration::from_secs(3600 - 60);
-const AMBIENT_CREDENTIALS_TTL: Duration = Duration::from_secs(600);
+const CREDENTIAL_CACHE_TTL: Duration = Duration::from_secs(600);
+const EXPIRY_BUFFER: Duration = Duration::from_secs(60);
#[derive(Clone)]
pub struct AwsAuthService {
- static_credentials: Cache,
- ambient_credentials: Cache,
+ providers: Cache,
+ credentials: Cache,
+ loader: Arc,
}
impl Default for AwsAuthService {
fn default() -> Self {
+ Self::new(Arc::new(NativeProviderLoader))
+ }
+}
+
+impl AwsAuthService {
+ fn new(loader: Arc) -> Self {
Self {
- static_credentials: Cache::builder()
+ providers: Cache::builder().max_capacity(200).build(),
+ credentials: Cache::builder()
.max_capacity(200)
- .time_to_live(STATIC_CREDENTIALS_TTL)
- .build(),
- ambient_credentials: Cache::builder()
- .max_capacity(200)
- .time_to_live(AMBIENT_CREDENTIALS_TTL)
+ .expire_after(CredentialExpiry)
.build(),
+ loader,
}
}
}
-fn credential_cache_ttl(flow: &AwsAuthFlow) -> Option {
- match flow {
- AwsAuthFlow::StaticKeys { .. } => Some(STATIC_CREDENTIALS_TTL),
- AwsAuthFlow::DefaultChain => Some(AMBIENT_CREDENTIALS_TTL),
- AwsAuthFlow::WebIdentity { .. }
- | AwsAuthFlow::AssumeRole { .. }
- | AwsAuthFlow::Profile { .. }
- | AwsAuthFlow::SessionToken { .. } => None,
+struct CredentialExpiry;
+
+impl Expiry for CredentialExpiry {
+ fn expire_after_create(
+ &self,
+ _: &AwsAuthConfig,
+ credentials: &Credentials,
+ _: std::time::Instant,
+ ) -> Option {
+ Some(credentials.expiry().map_or(CREDENTIAL_CACHE_TTL, |expiry| {
+ expiry
+ .duration_since(SystemTime::now())
+ .unwrap_or_default()
+ .saturating_sub(EXPIRY_BUFFER)
+ .min(CREDENTIAL_CACHE_TTL)
+ }))
}
}
-#[derive(Clone, Debug, Default, PartialEq, Eq)]
+type ProviderFuture<'a> =
+ Pin> + Send + 'a>>;
+
+trait ProviderLoader: Send + Sync {
+ fn load(&self, config: AwsAuthConfig, flow: AwsAuthFlow) -> ProviderFuture<'_>;
+}
+
+struct NativeProviderLoader;
+
+impl ProviderLoader for NativeProviderLoader {
+ fn load(&self, config: AwsAuthConfig, flow: AwsAuthFlow) -> ProviderFuture<'_> {
+ Box::pin(build_provider(config, flow))
+ }
+}
+
+#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct AwsAuthConfig {
- pub access_key_id: Option,
- pub secret_access_key: Option,
- pub session_token: Option,
+ pub access_key_id: Option,
+ pub secret_access_key: Option,
+ pub session_token: Option,
pub region_name: Option,
pub session_name: Option,
pub profile_name: Option,
pub role_name: Option,
- pub web_identity_token: Option,
+ pub web_identity_token: Option,
pub sts_endpoint: Option,
- pub external_id: Option,
+ pub external_id: Option,
}
impl AwsAuthConfig {
fn with_environment(self, env_lookup: &(dyn Fn(&str) -> Option + Sync)) -> Self {
Self {
- access_key_id: self.access_key_id.or_else(|| env_lookup(AWS_ACCESS_KEY_ID)),
+ access_key_id: self
+ .access_key_id
+ .or_else(|| env_lookup(AWS_ACCESS_KEY_ID).map(SecretValue::new)),
secret_access_key: self
.secret_access_key
- .or_else(|| env_lookup(AWS_SECRET_ACCESS_KEY)),
- session_token: self.session_token.or_else(|| env_lookup(AWS_SESSION_TOKEN)),
+ .or_else(|| env_lookup(AWS_SECRET_ACCESS_KEY).map(SecretValue::new)),
+ session_token: self
+ .session_token
+ .or_else(|| env_lookup(AWS_SESSION_TOKEN).map(SecretValue::new)),
region_name: self.region_name.or_else(|| env_lookup(AWS_REGION_NAME)),
session_name: self.session_name.or_else(|| env_lookup(AWS_SESSION_NAME)),
profile_name: self.profile_name.or_else(|| env_lookup(AWS_PROFILE_NAME)),
role_name: self.role_name.or_else(|| env_lookup(AWS_ROLE_NAME)),
web_identity_token: self
.web_identity_token
- .or_else(|| env_lookup(AWS_WEB_IDENTITY_TOKEN)),
+ .or_else(|| env_lookup(AWS_WEB_IDENTITY_TOKEN).map(SecretValue::new)),
sts_endpoint: self.sts_endpoint.or_else(|| env_lookup(AWS_STS_ENDPOINT)),
- external_id: self.external_id.or_else(|| env_lookup(AWS_EXTERNAL_ID)),
+ external_id: self
+ .external_id
+ .or_else(|| env_lookup(AWS_EXTERNAL_ID).map(SecretValue::new)),
}
}
}
@@ -96,52 +133,31 @@ impl AwsAuthConfig {
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum AwsAuthFlow {
WebIdentity {
- token: String,
+ token: SecretValue,
role: String,
session_name: String,
},
AssumeRole {
role: String,
session_name: Option,
+ web_identity_role: Option,
},
Profile {
name: String,
},
SessionToken {
- access_key_id: String,
- secret_access_key: String,
- session_token: String,
+ access_key_id: SecretValue,
+ secret_access_key: SecretValue,
+ session_token: SecretValue,
},
StaticKeys {
- access_key_id: String,
- secret_access_key: String,
+ access_key_id: SecretValue,
+ secret_access_key: SecretValue,
region_name: String,
},
DefaultChain,
}
-fn cache_key(config: &AwsAuthConfig, flow: &AwsAuthFlow) -> String {
- let mut hasher = Sha256::new();
- hasher.update(format!("{config:?}:{flow:?}"));
- format!("{:x}", hasher.finalize())
-}
-
-impl AwsAuthService {
- fn get_cached_credentials(&self, key: &str) -> Option {
- self.static_credentials
- .get(key)
- .or_else(|| self.ambient_credentials.get(key))
- }
-
- fn set_cached_credentials(&self, key: String, credentials: Credentials, ttl: Duration) {
- if ttl == STATIC_CREDENTIALS_TTL {
- self.static_credentials.insert(key, credentials);
- } else {
- self.ambient_credentials.insert(key, credentials);
- }
- }
-}
-
fn role_identity(arn: &str) -> Option<(&str, &str, &str)> {
let mut parts = arn.splitn(6, ':');
let ("arn", partition, _, _, account, resource) = (
@@ -170,6 +186,9 @@ pub fn classify_auth(
config: AwsAuthConfig,
env_lookup: &(dyn Fn(&str) -> Option + Sync),
) -> AwsAuthFlow {
+ let web_identity_role = env_lookup(AWS_WEB_IDENTITY_TOKEN_FILE)
+ .filter(|token_file| !token_file.is_empty())
+ .and_then(|_| env_lookup(AWS_ROLE_ARN));
let config = config.with_environment(env_lookup);
if let (Some(token), Some(role), Some(session_name)) = (
config.web_identity_token.clone(),
@@ -186,6 +205,7 @@ pub fn classify_auth(
return AwsAuthFlow::AssumeRole {
role,
session_name: config.session_name.clone(),
+ web_identity_role,
};
}
if let Some(name) = config.profile_name {
@@ -216,6 +236,30 @@ pub fn classify_auth(
AwsAuthFlow::DefaultChain
}
+async fn profile_provider(
+ name: &str,
+ region: Option,
+ config: aws_config::provider_config::ProviderConfig,
+ builder: aws_config::profile::credentials::Builder,
+) -> Result {
+ let region = match region {
+ Some(region) => Some(aws_types::region::Region::new(region)),
+ None => {
+ aws_config::default_provider::region::DefaultRegionChain::builder()
+ .profile_name(name)
+ .build()
+ .region()
+ .await
+ }
+ };
+ Ok(SharedCredentialsProvider::new(
+ builder
+ .configure(&config.with_region(region))
+ .profile_name(name)
+ .build(),
+ ))
+}
+
impl AwsAuthService {
pub async fn resolve_credentials(
&self,
@@ -224,183 +268,240 @@ impl AwsAuthService {
) -> Result {
let resolved = config.clone().with_environment(env_lookup);
let flow = classify_auth(config, env_lookup);
- match flow {
- AwsAuthFlow::SessionToken {
- access_key_id,
- secret_access_key,
- session_token,
- } => Ok(Credentials::new(
- access_key_id,
- secret_access_key,
- Some(session_token),
- None,
- "litellm-static-session",
- )),
- AwsAuthFlow::StaticKeys {
- access_key_id,
- secret_access_key,
- region_name,
- } => {
- let flow = AwsAuthFlow::StaticKeys {
- access_key_id: access_key_id.clone(),
- secret_access_key: secret_access_key.clone(),
- region_name,
- };
- let key = cache_key(&resolved, &flow);
- if let Some(credentials) = self.get_cached_credentials(&key) {
- return Ok(credentials);
- }
- let credentials = Credentials::new(
- access_key_id,
- secret_access_key,
- None,
- None,
- "litellm-static",
- );
- self.set_cached_credentials(
- key,
- credentials.clone(),
- credential_cache_ttl(&flow).unwrap_or(STATIC_CREDENTIALS_TTL),
- );
- Ok(credentials)
- }
- AwsAuthFlow::Profile { name } => {
- let provider = aws_config::profile::ProfileFileCredentialsProvider::builder()
- .profile_name(name)
- .build();
+ self.fresh_credentials(&resolved, &flow).await
+ }
+
+ /// The credentials botocore's default chain finds in `region`, without LiteLLM's Bedrock settings
+ /// (`AWS_ROLE_NAME`, `AWS_PROFILE_NAME`, `AWS_SESSION_NAME`) that `resolve_credentials` also reads.
+ pub async fn default_chain_credentials(&self, region: &str) -> Result {
+ let config = AwsAuthConfig {
+ region_name: Some(region.to_owned()),
+ ..Default::default()
+ };
+ self.fresh_credentials(&config, &AwsAuthFlow::DefaultChain)
+ .await
+ }
+
+ async fn fresh_credentials(
+ &self,
+ resolved: &AwsAuthConfig,
+ flow: &AwsAuthFlow,
+ ) -> Result {
+ let cached = self.cached_credentials(resolved, flow).await?;
+ if fresh(&cached) {
+ return Ok(cached);
+ }
+ self.credentials.invalidate(resolved).await;
+ let refetched = self.cached_credentials(resolved, flow).await?;
+ if fresh(&refetched) {
+ return Ok(refetched);
+ }
+ self.credentials.invalidate(resolved).await;
+ Err(Error::ExpiredCredentials)
+ }
+
+ async fn cached_credentials(
+ &self,
+ resolved: &AwsAuthConfig,
+ flow: &AwsAuthFlow,
+ ) -> Result {
+ self.credentials
+ .try_get_with(resolved.clone(), async {
+ let provider = self
+ .providers
+ .try_get_with(
+ resolved.clone(),
+ self.loader.load(resolved.clone(), flow.clone()),
+ )
+ .await
+ .map_err(|error| (*error).clone())?;
provider
.provide_credentials()
.await
- .map_err(Error::credentials(CredentialFlow::Profile))
- }
- AwsAuthFlow::AssumeRole { role, session_name } => {
- if is_already_running_as_role(&role, &resolved).await? {
- let ambient_flow = AwsAuthFlow::DefaultChain;
- let key = cache_key(&resolved, &ambient_flow);
- if let Some(credentials) = self.get_cached_credentials(&key) {
- return Ok(credentials);
- }
- let provider =
- aws_config::default_provider::credentials::DefaultCredentialsChain::builder()
- .build()
- .await;
- let credentials = provider
- .provide_credentials()
- .await
- .map_err(Error::credentials(CredentialFlow::DefaultChain))?;
- self.set_cached_credentials(
- key,
- credentials.clone(),
- credential_cache_ttl(&ambient_flow).unwrap_or(AMBIENT_CREDENTIALS_TTL),
- );
- return Ok(credentials);
- }
- let mut loader = aws_config::defaults(aws_config::BehaviorVersion::latest());
- if let Some(region) = resolved.region_name.clone() {
- loader = loader.region(aws_types::region::Region::new(region));
- }
- if let Some(endpoint) = resolved.sts_endpoint.clone() {
- loader = loader.endpoint_url(endpoint);
- }
- if let (Some(access_key_id), Some(secret_access_key)) =
- (resolved.access_key_id, resolved.secret_access_key)
- {
- loader = loader.credentials_provider(Credentials::new(
- access_key_id,
- secret_access_key,
- resolved.session_token,
- None,
- "litellm-role-source",
- ));
- }
- let sdk_config = loader.load().await;
- let builder = aws_config::sts::AssumeRoleProvider::builder(role);
- let builder = match session_name {
- Some(name) => builder.session_name(name),
- None => builder.session_name(default_session_name()),
- };
- let builder = match resolved.external_id {
- Some(id) => builder.external_id(id),
- None => builder,
- };
- let provider = builder.configure(&sdk_config).build().await;
- provider
- .provide_credentials()
- .await
- .map_err(Error::credentials(CredentialFlow::AssumeRole))
- }
- AwsAuthFlow::WebIdentity {
- token,
- role,
- session_name,
- } => {
- let mut loader = aws_config::defaults(aws_config::BehaviorVersion::latest());
- if let Some(region) = resolved.region_name {
- loader = loader.region(aws_types::region::Region::new(region));
- }
- if let Some(endpoint) = resolved.sts_endpoint {
- loader = loader.endpoint_url(endpoint);
- }
- let sdk_config = loader.load().await;
- let client = aws_sdk_sts::Client::new(&sdk_config);
- let response = client
- .assume_role_with_web_identity()
- .role_arn(role)
- .role_session_name(session_name)
- .web_identity_token(token)
- .send()
- .await
- .map_err(Error::credentials(CredentialFlow::WebIdentity))?;
- let credentials = response
- .credentials()
- .ok_or(Error::MissingWebIdentityCredentials)?;
- let expiration =
- SystemTime::try_from(*credentials.expiration()).map_err(|source| {
- Error::WebIdentityExpiration(litellm_error::Source::new(source))
- })?;
- Ok(Credentials::new(
- credentials.access_key_id(),
- credentials.secret_access_key(),
- Some(credentials.session_token().to_string()),
- Some(expiration),
- "litellm-web-identity",
- ))
- }
- AwsAuthFlow::DefaultChain => {
- let key = cache_key(&resolved, &AwsAuthFlow::DefaultChain);
- if let Some(credentials) = self.get_cached_credentials(&key) {
- return Ok(credentials);
- }
- let provider =
- aws_config::default_provider::credentials::DefaultCredentialsChain::builder()
- .build()
- .await;
- let credentials = provider
- .provide_credentials()
- .await
- .map_err(Error::credentials(CredentialFlow::DefaultChain))?;
- self.set_cached_credentials(
- key,
- credentials.clone(),
- credential_cache_ttl(&AwsAuthFlow::DefaultChain)
- .unwrap_or(AMBIENT_CREDENTIALS_TTL),
- );
- Ok(credentials)
+ .map_err(Error::credentials(flow.credential_flow()))
+ })
+ .await
+ .map_err(|error| (*error).clone())
+ }
+}
+
+fn fresh(credentials: &Credentials) -> bool {
+ credentials
+ .expiry()
+ .is_none_or(|expiry| expiry > SystemTime::now() + EXPIRY_BUFFER)
+}
+
+impl AwsAuthFlow {
+ fn credential_flow(&self) -> CredentialFlow {
+ match self {
+ Self::Profile { .. } => CredentialFlow::Profile,
+ Self::AssumeRole { .. } => CredentialFlow::AssumeRole,
+ Self::WebIdentity { .. } => CredentialFlow::WebIdentity,
+ Self::DefaultChain | Self::StaticKeys { .. } | Self::SessionToken { .. } => {
+ CredentialFlow::DefaultChain
}
}
}
}
-async fn is_already_running_as_role(role: &str, config: &AwsAuthConfig) -> Result {
+async fn build_provider(
+ resolved: AwsAuthConfig,
+ flow: AwsAuthFlow,
+) -> Result {
+ match flow {
+ AwsAuthFlow::SessionToken {
+ access_key_id,
+ secret_access_key,
+ session_token,
+ } => Ok(SharedCredentialsProvider::new(Credentials::new(
+ access_key_id.expose(),
+ secret_access_key.expose(),
+ Some(session_token.expose().to_owned()),
+ None,
+ "litellm-static-session",
+ ))),
+ AwsAuthFlow::StaticKeys {
+ access_key_id,
+ secret_access_key,
+ ..
+ } => Ok(SharedCredentialsProvider::new(Credentials::new(
+ access_key_id.expose(),
+ secret_access_key.expose(),
+ None,
+ None,
+ "litellm-static",
+ ))),
+ AwsAuthFlow::Profile { name } => {
+ profile_provider(
+ &name,
+ resolved.region_name,
+ aws_config::provider_config::ProviderConfig::without_region(),
+ aws_config::profile::ProfileFileCredentialsProvider::builder(),
+ )
+ .await
+ }
+ AwsAuthFlow::DefaultChain => {
+ let builder =
+ aws_config::default_provider::credentials::DefaultCredentialsChain::builder();
+ let builder = match resolved.region_name {
+ Some(region) => builder.region(aws_types::region::Region::new(region)),
+ None => builder,
+ };
+ Ok(SharedCredentialsProvider::new(builder.build().await))
+ }
+ AwsAuthFlow::AssumeRole {
+ role,
+ session_name,
+ web_identity_role,
+ } => {
+ if is_already_running_as_role(&role, web_identity_role.as_deref(), &resolved).await? {
+ return Ok(SharedCredentialsProvider::new(
+ aws_config::default_provider::credentials::DefaultCredentialsChain::builder()
+ .build()
+ .await,
+ ));
+ }
+ let sdk_config = sdk_config(resolved.clone()).await;
+ let builder = aws_config::sts::AssumeRoleProvider::builder(role)
+ .session_name(session_name.unwrap_or_else(default_session_name));
+ let builder = match resolved.external_id {
+ Some(id) => builder.external_id(id.expose()),
+ None => builder,
+ };
+ Ok(SharedCredentialsProvider::new(
+ builder.configure(&sdk_config).build().await,
+ ))
+ }
+ AwsAuthFlow::WebIdentity {
+ token,
+ role,
+ session_name,
+ } => Ok(SharedCredentialsProvider::new(WebIdentityProvider {
+ client: aws_sdk_sts::Client::new(&sdk_config(resolved).await),
+ token,
+ role,
+ session_name,
+ })),
+ }
+}
+
+async fn sdk_config(config: AwsAuthConfig) -> aws_types::SdkConfig {
+ let loader = aws_config::defaults(aws_config::BehaviorVersion::latest());
+ let loader = match config.region_name {
+ Some(region) => loader.region(aws_types::region::Region::new(region)),
+ None => loader,
+ };
+ let loader = match config.sts_endpoint {
+ Some(endpoint) => loader.endpoint_url(endpoint),
+ None => loader,
+ };
+ let loader = match (config.access_key_id, config.secret_access_key) {
+ (Some(key), Some(secret)) => loader.credentials_provider(Credentials::new(
+ key.expose(),
+ secret.expose(),
+ config.session_token.map(|token| token.expose().to_owned()),
+ None,
+ "litellm-role-source",
+ )),
+ _ => loader,
+ };
+ loader.load().await
+}
+
+#[derive(Debug)]
+struct WebIdentityProvider {
+ client: aws_sdk_sts::Client,
+ token: SecretValue,
+ role: String,
+ session_name: String,
+}
+
+impl ProvideCredentials for WebIdentityProvider {
+ fn provide_credentials<'a>(
+ &'a self,
+ ) -> aws_credential_types::provider::future::ProvideCredentials<'a>
+ where
+ Self: 'a,
+ {
+ aws_credential_types::provider::future::ProvideCredentials::new(async {
+ let response = self
+ .client
+ .assume_role_with_web_identity()
+ .role_arn(&self.role)
+ .role_session_name(&self.session_name)
+ .web_identity_token(self.token.expose())
+ .send()
+ .await
+ .map_err(CredentialsError::provider_error)?;
+ let credentials = response.credentials().ok_or_else(|| {
+ CredentialsError::provider_error(Error::MissingWebIdentityCredentials)
+ })?;
+ let expiration = SystemTime::try_from(*credentials.expiration())
+ .map_err(CredentialsError::provider_error)?;
+ Ok(Credentials::new(
+ credentials.access_key_id(),
+ credentials.secret_access_key(),
+ Some(credentials.session_token().to_owned()),
+ Some(expiration),
+ "litellm-web-identity",
+ ))
+ })
+ }
+}
+
+async fn is_already_running_as_role(
+ role: &str,
+ web_identity_role: Option<&str>,
+ config: &AwsAuthConfig,
+) -> Result {
+ if config.access_key_id.is_some() || config.secret_access_key.is_some() {
+ return Ok(false);
+ }
if role_identity(role).is_none() {
return Ok(false);
}
- if let (Ok(current_role), Ok(token_file)) = (
- std::env::var(AWS_ROLE_ARN),
- std::env::var(AWS_WEB_IDENTITY_TOKEN_FILE),
- ) && !token_file.is_empty()
- {
- return Ok(same_role_arns(role, ¤t_role));
+ if let Some(current_role) = web_identity_role {
+ return Ok(same_role_arns(role, current_role));
}
let mut loader = aws_config::defaults(aws_config::BehaviorVersion::latest());
@@ -473,16 +574,6 @@ pub fn sign_headers(
headers: &HeaderMap,
scope: SigningScope<'_>,
) -> Result {
- let identity: Identity = scope.credentials.clone().into();
- let params = v4::SigningParams::builder()
- .identity(&identity)
- .region(scope.region)
- .name(scope.service)
- .time(scope.time)
- .settings(SigningSettings::default())
- .build()
- .map(SigningParams::from)
- .map_err(Error::signing(SigningStage::Parameters))?;
let header_refs = headers
.iter()
.map(|(name, value)| {
@@ -494,16 +585,14 @@ pub fn sign_headers(
})
})
.collect::, _>>()?;
- let request = SignableRequest::new(
+ let instructions = sign_request(
method,
url,
header_refs.into_iter(),
- SignableBody::Bytes(body),
- )
- .map_err(Error::signing(SigningStage::Request))?;
- let (instructions, _) = sign(request, ¶ms)
- .map_err(Error::signing(SigningStage::Signature))?
- .into_parts();
+ body,
+ SigningSettings::default(),
+ scope,
+ )?;
instructions
.headers()
.map(|(name, value)| {
@@ -516,6 +605,60 @@ pub fn sign_headers(
.collect()
}
+pub fn presign_url(
+ url: &str,
+ expires_in: Duration,
+ scope: SigningScope<'_>,
+) -> Result {
+ let mut signed = url::Url::parse(url).map_err(Error::signing(SigningStage::Request))?;
+ let mut settings = SigningSettings::default();
+ settings.signature_location = SignatureLocation::QueryParams;
+ settings.expires_in = Some(expires_in);
+ let instructions = sign_request(
+ "GET",
+ signed.as_str(),
+ std::iter::empty(),
+ &[],
+ settings,
+ scope,
+ )?;
+ let (signature, auth): (Vec<_>, Vec<_>) = instructions
+ .params()
+ .iter()
+ .map(|(name, value)| (*name, value.as_ref()))
+ .partition(|(name, _)| *name == "X-Amz-Signature");
+ signed
+ .query_pairs_mut()
+ .extend_pairs(auth.into_iter().chain(signature));
+ Ok(signed.into())
+}
+
+fn sign_request<'a>(
+ method: &'a str,
+ url: &'a str,
+ headers: impl Iterator- ,
+ body: &'a [u8],
+ settings: SigningSettings,
+ scope: SigningScope<'_>,
+) -> Result {
+ let identity: Identity = scope.credentials.clone().into();
+ let params = v4::SigningParams::builder()
+ .identity(&identity)
+ .region(scope.region)
+ .name(scope.service)
+ .time(scope.time)
+ .settings(settings)
+ .build()
+ .map(SigningParams::from)
+ .map_err(Error::signing(SigningStage::Parameters))?;
+ let request = SignableRequest::new(method, url, headers, SignableBody::Bytes(body))
+ .map_err(Error::signing(SigningStage::Request))?;
+ let (instructions, _) = sign(request, ¶ms)
+ .map_err(Error::signing(SigningStage::Signature))?
+ .into_parts();
+ Ok(instructions)
+}
+
/// Model-id and region parsing shared by every Bedrock route.
pub fn bedrock_model_id_and_region(model: &str) -> (String, Option) {
let mut stripped = model;
@@ -586,16 +729,26 @@ pub fn aws_auth_config(
env_lookup: &dyn Fn(&str) -> Option,
) -> AwsAuthConfig {
AwsAuthConfig {
- access_key_id: params.resolve(&AwsParams::ACCESS_KEY_ID, env_lookup),
- secret_access_key: params.resolve(&AwsParams::SECRET_ACCESS_KEY, env_lookup),
- session_token: params.resolve(&AwsParams::SESSION_TOKEN, env_lookup),
+ access_key_id: params
+ .resolve(&AwsParams::ACCESS_KEY_ID, env_lookup)
+ .map(SecretValue::new),
+ secret_access_key: params
+ .resolve(&AwsParams::SECRET_ACCESS_KEY, env_lookup)
+ .map(SecretValue::new),
+ session_token: params
+ .resolve(&AwsParams::SESSION_TOKEN, env_lookup)
+ .map(SecretValue::new),
region_name: params.resolve(&AwsParams::REGION, env_lookup),
session_name: params.resolve(&AwsParams::SESSION_NAME, env_lookup),
profile_name: params.resolve(&AwsParams::PROFILE_NAME, env_lookup),
role_name: params.resolve(&AwsParams::ROLE_NAME, env_lookup),
- web_identity_token: params.resolve(&AwsParams::WEB_IDENTITY_TOKEN, env_lookup),
+ web_identity_token: params
+ .resolve(&AwsParams::WEB_IDENTITY_TOKEN, env_lookup)
+ .map(SecretValue::new),
sts_endpoint: params.resolve(&AwsParams::STS_ENDPOINT, env_lookup),
- external_id: params.resolve(&AwsParams::EXTERNAL_ID, env_lookup),
+ external_id: params
+ .resolve(&AwsParams::EXTERNAL_ID, env_lookup)
+ .map(SecretValue::new),
}
}
@@ -660,10 +813,133 @@ mod tests {
use crate::constants::{AWS_REGION, BEDROCK_SERVICE};
use reqwest::header::CONTENT_TYPE;
+ #[cfg(unix)]
+ #[rstest::fixture]
+ fn process_profile() -> aws_runtime::env_config::file::EnvConfigFiles {
+ let credentials = serde_json::json!({
+ "Version": 1,
+ "AccessKeyId": "process-access",
+ "SecretAccessKey": "process-secret",
+ "SessionToken": "process-session",
+ });
+ aws_runtime::env_config::file::EnvConfigFiles::builder()
+ .include_default_config_file(false)
+ .include_default_credentials_file(false)
+ .with_contents(
+ aws_runtime::env_config::file::EnvConfigFileKind::Config,
+ format!(
+ "[profile smoke]\ncredential_process = /usr/bin/printf '%s' '{credentials}'\n"
+ ),
+ )
+ .build()
+ }
+
+ #[cfg(unix)]
+ #[rstest::rstest]
+ #[tokio::test]
+ async fn profile_process_credentials_can_be_loaded(
+ process_profile: aws_runtime::env_config::file::EnvConfigFiles,
+ ) {
+ let provider = profile_provider(
+ "smoke",
+ Some("us-west-2".into()),
+ aws_config::provider_config::ProviderConfig::without_region(),
+ aws_config::profile::ProfileFileCredentialsProvider::builder()
+ .profile_files(process_profile),
+ )
+ .await
+ .unwrap();
+ let credentials = provider.provide_credentials().await.unwrap();
+
+ assert_eq!(credentials.access_key_id(), "process-access");
+ assert_eq!(credentials.secret_access_key(), "process-secret");
+ assert_eq!(credentials.session_token(), Some("process-session"));
+ }
+
+ #[derive(Debug)]
+ struct StsConnector;
+
+ impl aws_smithy_runtime_api::client::http::HttpConnector for StsConnector {
+ fn call(
+ &self,
+ request: aws_smithy_runtime_api::client::orchestrator::HttpRequest,
+ ) -> aws_smithy_runtime_api::client::http::HttpConnectorFuture {
+ assert!(request.uri().contains("sts.us-west-2."));
+ aws_smithy_runtime_api::client::http::HttpConnectorFuture::new(async {
+ Ok(
+ aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
+ 200_u16.try_into().unwrap(),
+ aws_smithy_types::body::SdkBody::from(
+ r#"
+
+ role-accessrole-secret
+ role-session2100-01-01T00:00:00Z
+ arn:aws:sts::123456789012:assumed-role/smoke/session
+ smoke:session
+ smoke"#,
+ ),
+ ),
+ )
+ })
+ }
+ }
+
+ #[rstest::rstest]
+ #[tokio::test]
+ async fn role_profile_uses_region_when_acquiring_sts_credentials() {
+ use aws_smithy_runtime_api::client::http::{SharedHttpConnector, http_client_fn};
+ let files = aws_runtime::env_config::file::EnvConfigFiles::builder()
+ .include_default_config_file(false)
+ .include_default_credentials_file(false)
+ .with_contents(
+ aws_runtime::env_config::file::EnvConfigFileKind::Config,
+ "[profile smoke]\nrole_arn = arn:aws:iam::123456789012:role/smoke\nsource_profile = source\n\n[profile source]\naws_access_key_id = source-access\naws_secret_access_key = source-secret\n",
+ ).build();
+ let config = aws_config::provider_config::ProviderConfig::without_region()
+ .with_http_client(http_client_fn(|_, _| {
+ SharedHttpConnector::new(StsConnector)
+ }));
+ let credentials = profile_provider(
+ "smoke",
+ Some("us-west-2".into()),
+ config,
+ aws_config::profile::ProfileFileCredentialsProvider::builder().profile_files(files),
+ )
+ .await
+ .unwrap();
+ let credentials = credentials.provide_credentials().await.unwrap();
+ assert_eq!(credentials.access_key_id(), "role-access");
+ assert_eq!(credentials.secret_access_key(), "role-secret");
+ assert_eq!(credentials.session_token(), Some("role-session"));
+ assert!(credentials.expiry().is_some());
+ }
+
fn no_env(_: &str) -> Option {
None
}
+ #[rstest::rstest]
+ #[case::access_key(Some("source-access"), None)]
+ #[case::secret_key(None, Some("source-secret"))]
+ #[case::source_pair(Some("source-access"), Some("source-secret"))]
+ #[tokio::test]
+ async fn explicit_source_keys_cannot_reuse_an_ambient_role(
+ #[case] access_key: Option<&str>,
+ #[case] secret_key: Option<&str>,
+ ) {
+ let role = "arn:aws:iam::123456789012:role/target";
+ let config = AwsAuthConfig {
+ access_key_id: access_key.map(SecretValue::new),
+ secret_access_key: secret_key.map(SecretValue::new),
+ ..Default::default()
+ };
+ assert!(
+ !is_already_running_as_role(role, Some(role), &config)
+ .await
+ .unwrap()
+ );
+ }
+
#[test]
fn secret_names_cover_environment_reads() {
let seen = std::sync::Arc::new(std::sync::Mutex::new(
@@ -706,7 +982,10 @@ mod tests {
};
assert_eq!(
- aws_auth_config(¶ms, &env).secret_access_key.as_deref(),
+ aws_auth_config(¶ms, &env)
+ .secret_access_key
+ .as_ref()
+ .map(SecretValue::expose),
expected
);
assert_eq!(
@@ -831,6 +1110,53 @@ mod tests {
);
}
+ #[rstest::rstest]
+ #[case::running_with_web_identity("/var/run/token", Some("arn:aws:iam::1:role/current"))]
+ #[case::empty_token_file("", None)]
+ #[tokio::test]
+ async fn assume_role_reads_the_ambient_role_from_the_secret_snapshot(
+ #[case] token_file: &str,
+ #[case] expected: Option<&str>,
+ ) {
+ use litellm_secrets::source::SecretSource;
+
+ struct WebIdentitySecrets<'a>(&'a str);
+
+ impl SecretSource for WebIdentitySecrets<'_> {
+ fn get_secret_str<'a>(
+ &'a self,
+ name: &'a str,
+ ) -> futures_util::future::BoxFuture<
+ 'a,
+ Result