Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

[Release Day] - Fixed CI/CD issues & changed processes (#19902)

Alexsander Hamir69bd4426e88d
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 77f3c2b9a7d..84b15572a66 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -715,8 +715,8 @@ jobs:
- run:
name: Rename the coverage files
command: |
- mv coverage.xml litellm_router_coverage.xml
- mv .coverage litellm_router_coverage
+ mv coverage.xml litellm_router_unit_coverage.xml
+ mv .coverage litellm_router_unit_coverage
# Store test results
- store_test_results:
path: test-results
@@ -724,8 +724,8 @@ jobs:
- persist_to_workspace:
root: .
paths:
- - litellm_router_coverage.xml
- - litellm_router_coverage
+ - litellm_router_unit_coverage.xml
+ - litellm_router_unit_coverage
litellm_security_tests:
machine:
image: ubuntu-2204:2023.10.1
@@ -3428,7 +3428,7 @@ jobs:
python -m venv venv
. venv/bin/activate
pip install coverage
- coverage combine llm_translation_coverage llm_responses_api_coverage ocr_coverage search_coverage mcp_coverage logging_coverage audio_coverage litellm_router_coverage local_testing_part1_coverage local_testing_part2_coverage litellm_assistants_api_coverage auth_ui_unit_tests_coverage langfuse_coverage caching_coverage litellm_proxy_unit_tests_part1_coverage litellm_proxy_unit_tests_part2_coverage image_gen_coverage pass_through_unit_tests_coverage batches_coverage litellm_security_tests_coverage guardrails_coverage litellm_mapped_tests_coverage
+ coverage combine llm_translation_coverage llm_responses_api_coverage ocr_coverage search_coverage mcp_coverage logging_coverage audio_coverage litellm_router_coverage litellm_router_unit_coverage local_testing_part1_coverage local_testing_part2_coverage litellm_assistants_api_coverage auth_ui_unit_tests_coverage langfuse_coverage caching_coverage litellm_proxy_unit_tests_part1_coverage litellm_proxy_unit_tests_part2_coverage image_gen_coverage pass_through_unit_tests_coverage batches_coverage litellm_security_tests_coverage guardrails_coverage litellm_mapped_tests_coverage
coverage xml
- codecov/upload:
file: ./coverage.xml
@@ -3478,8 +3478,22 @@ jobs:
ls dist/
twine upload --verbose dist/*
else
- echo "Version ${VERSION} of package is already published on PyPI. Skipping PyPI publish."
- circleci step halt
+ echo "Version ${VERSION} of package is already published on PyPI."
+
+ # Check if corresponding Docker nightly image exists
+ NIGHTLY_TAG="v${VERSION}-nightly"
+ echo "Checking for Docker nightly image: litellm/litellm:${NIGHTLY_TAG}"
+
+ # Check Docker Hub for the nightly image
+ if curl -s "https://hub.docker.com/v2/repositories/litellm/litellm/tags/${NIGHTLY_TAG}" | grep -q "name"; then
+ echo "Docker nightly image ${NIGHTLY_TAG} exists. This release was already completed successfully."
+ echo "Skipping PyPI publish and continuing to ensure Docker images are up to date."
+ circleci step halt
+ else
+ echo "ERROR: PyPI package ${VERSION} exists but Docker nightly image ${NIGHTLY_TAG} does not exist!"
+ echo "This indicates an incomplete release. Please investigate."
+ exit 1
+ fi
fi
- run:
name: Trigger Github Action for new Docker Container + Trigger Load Testing
@@ -3488,11 +3502,21 @@ jobs:
python3 -m pip install toml
VERSION=$(python3 -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")
echo "LiteLLM Version ${VERSION}"
+
+ # Determine which branch to use for Docker build
+ if [[ "$CIRCLE_BRANCH" =~ ^litellm_release_day_.* ]]; then
+ BUILD_BRANCH="$CIRCLE_BRANCH"
+ echo "Using release branch: $BUILD_BRANCH"
+ else
+ BUILD_BRANCH="main"
+ echo "Using default branch: $BUILD_BRANCH"
+ fi
+
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/BerriAI/litellm/actions/workflows/ghcr_deploy.yml/dispatches" \
- -d "{\"ref\":\"main\", \"inputs\":{\"tag\":\"v${VERSION}-nightly\", \"commit_hash\":\"$CIRCLE_SHA1\"}}"
+ -d "{\"ref\":\"${BUILD_BRANCH}\", \"inputs\":{\"tag\":\"v${VERSION}-nightly\", \"commit_hash\":\"$CIRCLE_SHA1\"}}"
echo "triggering load testing server for version ${VERSION} and commit ${CIRCLE_SHA1}"
curl -X POST "https://proxyloadtester-production.up.railway.app/start/load/test?version=${VERSION}&commit_hash=${CIRCLE_SHA1}&release_type=nightly"
@@ -4235,6 +4259,7 @@ workflows:
branches:
only:
- main
+ - /litellm_release_day_.*/
- publish_to_pypi:
requires:
- mypy_linting
diff --git a/.github/workflows/test-litellm.yml b/.github/workflows/test-litellm.yml
index ba32dc1bf54..d9cf2e74a11 100644
--- a/.github/workflows/test-litellm.yml
+++ b/.github/workflows/test-litellm.yml
@@ -34,7 +34,7 @@ jobs:
poetry run pip install "google-genai==1.22.0"
poetry run pip install "google-cloud-aiplatform>=1.38"
poetry run pip install "fastapi-offline==1.7.3"
- poetry run pip install "python-multipart==0.0.18"
+ poetry run pip install "python-multipart==0.0.22"
poetry run pip install "openapi-core"
- name: Setup litellm-enterprise as local package
run: |
diff --git a/docs/my-website/docs/proxy/config_settings.md b/docs/my-website/docs/proxy/config_settings.md
index 6d3fa206113..37e58d55407 100644
--- a/docs/my-website/docs/proxy/config_settings.md
+++ b/docs/my-website/docs/proxy/config_settings.md
@@ -462,6 +462,7 @@ router_settings:
| CHATGPT_USER_AGENT_SUFFIX | Suffix to append to the ChatGPT user agent string
| CIRCLE_OIDC_TOKEN | OpenID Connect token for CircleCI
| CIRCLE_OIDC_TOKEN_V2 | Version 2 of the OpenID Connect token for CircleCI
+| CLI_JWT_EXPIRATION_HOURS | Expiration time in hours for CLI-generated JWT tokens. Default is 24 hours. Can also be set via LITELLM_CLI_JWT_EXPIRATION_HOURS
| CLOUDZERO_API_KEY | CloudZero API key for authentication
| CLOUDZERO_CONNECTION_ID | CloudZero connection ID for data submission
| CLOUDZERO_EXPORT_INTERVAL_MINUTES | Interval in minutes for CloudZero data export operations
@@ -723,6 +724,7 @@ router_settings:
| LITERAL_API_URL | API URL for Literal service
| LITERAL_BATCH_SIZE | Batch size for Literal operations
| LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX | Disable automatic URL suffix appending for Anthropic API base URLs. When set to `true`, prevents LiteLLM from automatically adding `/v1/messages` or `/v1/complete` to custom Anthropic API endpoints
+| LITELLM_CLI_JWT_EXPIRATION_HOURS | Expiration time in hours for CLI-generated JWT tokens. Default is 24 hours
| LITELLM_DD_AGENT_HOST | Hostname or IP of DataDog agent for LiteLLM-specific logging. When set, logs are sent to agent instead of direct API
| LITELLM_DD_AGENT_PORT | Port of DataDog agent for LiteLLM-specific log intake. Default is 10518
| LITELLM_DONT_SHOW_FEEDBACK_BOX | Flag to hide feedback box in LiteLLM UI
diff --git a/litellm/constants.py b/litellm/constants.py
index 0c9d1d941ba..91cdc0ebdfc 100644
--- a/litellm/constants.py
+++ b/litellm/constants.py
@@ -1165,7 +1165,12 @@ LITELLM_CLI_SOURCE_IDENTIFIER = "litellm-cli"
LITELLM_CLI_SESSION_TOKEN_PREFIX = "litellm-session-token"
CLI_SSO_SESSION_CACHE_KEY_PREFIX = "cli_sso_session"
CLI_JWT_TOKEN_NAME = "cli-jwt-token"
-CLI_JWT_EXPIRATION_HOURS = int(os.getenv("LITELLM_CLI_JWT_EXPIRATION_HOURS", 24))
+# Support both CLI_JWT_EXPIRATION_HOURS and LITELLM_CLI_JWT_EXPIRATION_HOURS for backwards compatibility
+CLI_JWT_EXPIRATION_HOURS = int(
+ os.getenv("CLI_JWT_EXPIRATION_HOURS")
+ or os.getenv("LITELLM_CLI_JWT_EXPIRATION_HOURS")
+ or 24
+)
########################### DB CRON JOB NAMES ###########################
DB_SPEND_UPDATE_JOB_NAME = "db_spend_update_job"
diff --git a/litellm/litellm_core_utils/logging_worker.py b/litellm/litellm_core_utils/logging_worker.py
index 13a83956edd..d5eca9eeb55 100644
--- a/litellm/litellm_core_utils/logging_worker.py
+++ b/litellm/litellm_core_utils/logging_worker.py
@@ -415,6 +415,28 @@ class LoggingWorker:
"""
Safely log a message during shutdown, suppressing errors if logging is closed.
"""
+ # Check if logger has valid handlers before attempting to log
+ # During shutdown, handlers may be closed, causing ValueError when writing
+ if not hasattr(verbose_logger, 'handlers') or not verbose_logger.handlers:
+ return
+
+ # Check if any handler has a valid stream
+ has_valid_handler = False
+ for handler in verbose_logger.handlers:
+ try:
+ if hasattr(handler, 'stream') and handler.stream and not handler.stream.closed:
+ has_valid_handler = True
+ break
+ elif not hasattr(handler, 'stream'):
+ # Non-stream handlers (like NullHandler) are always valid
+ has_valid_handler = True
+ break
+ except (AttributeError, ValueError):
+ continue
+
+ if not has_valid_handler:
+ return
+
try:
if level == "debug":
verbose_logger.debug(message)
diff --git a/poetry.lock b/poetry.lock
index 462a56fe42a..9ded0c773c8 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -5719,15 +5719,15 @@ cli = ["click (>=5.0)"]
[[package]]
name = "python-multipart"
-version = "0.0.18"
+version = "0.0.22"
description = "A streaming multipart parser for Python"
optional = true
python-versions = ">=3.8"
groups = ["main"]
markers = "extra == \"proxy\""
files = [
- {file = "python_multipart-0.0.18-py3-none-any.whl", hash = "sha256:efe91480f485f6a361427a541db4796f9e1591afc0fb8e7a4ba06bfbc6708996"},
- {file = "python_multipart-0.0.18.tar.gz", hash = "sha256:7a68db60c8bfb82e460637fa4750727b45af1d5e2ed215593f917f64694d34fe"},
+ {file = "python_multipart-0.0.22-py3-none-any.whl", hash = "sha256:2b2cd894c83d21bf49d702499531c7bafd057d730c201782048f7945d82de155"},
+ {file = "python_multipart-0.0.22.tar.gz", hash = "sha256:7340bef99a7e0032613f56dc36027b959fd3b30a787ed62d310e951f7c3a3a58"},
]
[[package]]
diff --git a/pyproject.toml b/pyproject.toml
index 1e4836ed19b..6c3ab08ce02 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "litellm"
-version = "1.81.4"
+version = "1.81.5"
description = "Library to easily interface with LLM API providers"
authors = ["BerriAI"]
license = "MIT"
@@ -45,7 +45,7 @@ orjson = {version = "^3.9.7", optional = true}
apscheduler = {version = "^3.10.4", optional = true}
fastapi-sso = { version = "^0.16.0", optional = true }
PyJWT = { version = "^2.10.1", optional = true, python = ">=3.9" }
-python-multipart = { version = "^0.0.18", optional = true}
+python-multipart = { version = "^0.0.22", optional = true}
cryptography = {version = "*", optional = true}
prisma = {version = "0.11.0", optional = true}
azure-identity = {version = "^1.15.0", optional = true, python = ">=3.9"}
@@ -174,7 +174,7 @@ requires = ["poetry-core", "wheel"]
build-backend = "poetry.core.masonry.api"
[tool.commitizen]
-version = "1.81.4"
+version = "1.81.5"
version_files = [
"pyproject.toml:^version"
]
diff --git a/requirements.txt b/requirements.txt
index f250fb213ef..e40f9b9dbe4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -32,7 +32,7 @@ polars==1.31.0 # for data processing
apscheduler==3.10.4 # for resetting budget in background
fastapi-sso==0.19.0 # admin UI, SSO
pyjwt[crypto]==2.10.1 ; python_version >= "3.9"
-python-multipart==0.0.18 # admin UI
+python-multipart==0.0.22 # admin UI
Pillow==11.0.0
jaraco.context>=6.1.0
azure-ai-contentsafety==1.0.0 # for azure content safety
diff --git a/tests/code_coverage_tests/license_cache.json b/tests/code_coverage_tests/license_cache.json
index 910ec931c86..a9c7fad2b14 100644
--- a/tests/code_coverage_tests/license_cache.json
+++ b/tests/code_coverage_tests/license_cache.json
@@ -20,7 +20,7 @@
"apscheduler:3.10.4": "MIT",
"fastapi-sso:0.16.0": "MIT",
"pyjwt:2.9.0": "MIT",
- "python-multipart:0.0.18": "Apache-2.0",
+ "python-multipart:0.0.22": "Apache-2.0",
"Pillow:11.0.0": "MIT-CMU",
"azure-ai-contentsafety:1.0.0": "MIT License",
"azure-identity:1.16.1": "MIT License",
diff --git a/tests/guardrails_tests/test_lakera_v2.py b/tests/guardrails_tests/test_lakera_v2.py
index 9e0244a4819..2a8731d5ecd 100644
--- a/tests/guardrails_tests/test_lakera_v2.py
+++ b/tests/guardrails_tests/test_lakera_v2.py
@@ -22,38 +22,58 @@ async def test_lakera_pre_call_hook_for_pii_masking():
# Setup the guardrail with specific entities config
litellm._turn_on_debug()
lakera_guardrail = LakeraAIGuardrail(
- api_key=os.environ.get("LAKERA_API_KEY"),
+ api_key="test_key",
)
- # Create a sample request with PII data
- data = {
- "messages": [
- {"role": "system", "content": "You are a helpful assistant."},
- {"role": "user", "content": "My credit card is 4111-1111-1111-1111 and my email is [email protected]. My phone number is 555-123-4567"}
+ # Mock response with PII detections in payload (with start/end positions for masking)
+ mock_response = {
+ 'payload': [
+ {'detector_type': 'pii/credit_card', 'start': 18, 'end': 37, 'message_id': 1}, # "4111-1111-1111-1111"
+ {'detector_type': 'pii/email', 'start': 54, 'end': 70, 'message_id': 1}, # "[email protected]"
],
- "model": "gpt-3.5-turbo",
- "metadata": {}
+ 'flagged': True,
+ 'breakdown': [
+ {'detector_type': 'pii/credit_card', 'detected': True, 'message_id': 1},
+ {'detector_type': 'pii/email', 'detected': True, 'message_id': 1},
+ ]
}
- # Mock objects needed for the pre-call hook
- user_api_key_dict = UserAPIKeyAuth(api_key="test_key")
- cache = DualCache()
-
- # Call the pre-call hook with the specified call type
- modified_data = await lakera_guardrail.async_pre_call_hook(
- user_api_key_dict=user_api_key_dict,
- cache=cache,
- data=data,
- call_type="completion"
- )
- print(modified_data)
-
- # Verify the messages have been modified to mask PII
- assert modified_data["messages"][0]["content"] == "You are a helpful assistant." # System prompt should be unchanged
-
- user_message = modified_data["messages"][1]["content"]
- assert "4111-1111-1111-1111" not in user_message
- assert "[email protected]" not in user_message
+ with patch.object(lakera_guardrail, 'call_v2_guard', new_callable=AsyncMock) as mock_call:
+ mock_call.return_value = (mock_response, {})
+
+ # Create a sample request with PII data
+ data = {
+ "messages": [
+ {"role": "system", "content": "You are a helpful assistant."},
+ {"role": "user", "content": "My credit card is 4111-1111-1111-1111 and my email is [email protected]. My phone number is 555-123-4567"}
+ ],
+ "model": "gpt-3.5-turbo",
+ "metadata": {}
+ }
+
+ # Mock objects needed for the pre-call hook
+ user_api_key_dict = UserAPIKeyAuth(api_key="test_key")
+ cache = DualCache()
+
+ # Call the pre-call hook with the specified call type
+ modified_data = await lakera_guardrail.async_pre_call_hook(
+ user_api_key_dict=user_api_key_dict,
+ cache=cache,
+ data=data,
+ call_type="completion"
+ )
+ print(modified_data)
+
+ # Verify the messages have been modified to mask PII
+ assert modified_data["messages"][0]["content"] == "You are a helpful assistant." # System prompt should be unchanged
+
+ user_message = modified_data["messages"][1]["content"]
+ # Verify both credit card and email are masked
+ assert "4111-1111-1111-1111" not in user_message
+ assert "[email protected]" not in user_message
+ # Verify masking placeholders are present
+ assert "[MASKED CREDIT_CARD]" in user_message
+ assert "[MASKED EMAIL]" in user_message
@pytest.mark.asyncio
diff --git a/tests/local_testing/test_amazing_vertex_completion.py b/tests/local_testing/test_amazing_vertex_completion.py
index 25a85384ca1..866e2a85060 100644
--- a/tests/local_testing/test_amazing_vertex_completion.py
+++ b/tests/local_testing/test_amazing_vertex_completion.py
@@ -742,7 +742,7 @@ def test_gemini_pro_grounding(value_in_dict):
@pytest.mark.parametrize("model", ["vertex_ai_beta/gemini-2.5-flash-lite"]) # "vertex_ai",
@pytest.mark.parametrize("sync_mode", [True]) # "vertex_ai",
@pytest.mark.asyncio
[email protected](retries=3, delay=1)
[email protected](retries=6, delay=2)
async def test_gemini_pro_function_calling_httpx(model, sync_mode):
try:
load_vertex_ai_credentials()
@@ -785,6 +785,7 @@ async def test_gemini_pro_function_calling_httpx(model, sync_mode):
"messages": messages,
"tools": tools,
"tool_choice": "required",
+ "timeout": 60, # Add explicit timeout
}
print(f"Model for call - {model}")
if sync_mode:
@@ -799,12 +800,18 @@ async def test_gemini_pro_function_calling_httpx(model, sync_mode):
response.choices[0].message.tool_calls[0].function.arguments, str
)
except litellm.RateLimitError as e:
- pass
+ pytest.skip(f"Rate limit exceeded: {str(e)}")
+ except litellm.ServiceUnavailableError as e:
+ pytest.skip(f"Service unavailable: {str(e)}")
+ except litellm.Timeout as e:
+ pytest.skip(f"Request timeout: {str(e)}")
except Exception as e:
- if "429 Quota exceeded" in str(e):
- pass
+ error_msg = str(e)
+ # Skip test for known transient API issues
+ if any(x in error_msg for x in ["429 Quota exceeded", "503", "Service unavailable", "timeout", "Timeout", "UNAVAILABLE"]):
+ pytest.skip(f"Transient API error: {error_msg}")
else:
- pytest.fail("An unexpected exception occurred - {}".format(str(e)))
+ pytest.fail(f"An unexpected exception occurred - {error_msg}")
from test_completion import response_format_tests
diff --git a/tests/test_litellm/proxy/auth/test_auth_checks.py b/tests/test_litellm/proxy/auth/test_auth_checks.py
index af0591e5f51..ebcd9676129 100644
--- a/tests/test_litellm/proxy/auth/test_auth_checks.py
+++ b/tests/test_litellm/proxy/auth/test_auth_checks.py
@@ -45,6 +45,24 @@ def set_salt_key(monkeypatch):
monkeypatch.setenv("LITELLM_SALT_KEY", "sk-1234")
[email protected](autouse=True)
+def reset_constants_module():
+ """Reset constants module to ensure clean state before each test"""
+ import importlib
+ from litellm import constants
+ from litellm.proxy.auth import auth_checks
+
+ # Reload modules before test
+ importlib.reload(constants)
+ importlib.reload(auth_checks)
+
+ yield
+
+ # Reload modules after test to clean up
+ importlib.reload(constants)
+ importlib.reload(auth_checks)
+
+
@pytest.fixture
def valid_sso_user_defined_values():
return LiteLLM_UserTable(
@@ -160,16 +178,19 @@ def test_get_cli_jwt_auth_token_custom_expiration(
valid_sso_user_defined_values, monkeypatch
):
"""Test generating CLI JWT token with custom expiration via environment variable"""
+ import importlib
+ from litellm import constants
+ from litellm.proxy.auth import auth_checks
+
# Set custom expiration to 48 hours
monkeypatch.setenv("LITELLM_CLI_JWT_EXPIRATION_HOURS", "48")
# Reload the constants module to pick up the new env var
- import importlib
-
- from litellm import constants
importlib.reload(constants)
+ # Also reload auth_checks to pick up the new constant value
+ importlib.reload(auth_checks)
- token = ExperimentalUIJWTToken.get_cli_jwt_auth_token(valid_sso_user_defined_values)
+ token = auth_checks.ExperimentalUIJWTToken.get_cli_jwt_auth_token(valid_sso_user_defined_values)
# Decrypt and verify token contents
decrypted_token = decrypt_value_helper(