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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(proxy): declare the Moyai settings write's service target and allowlist its routes (#45220)
devin-ai-integration[bot]c912236fa55f
diff --git a/backend/routes/allowlist.py b/backend/routes/allowlist.pyindex ea56a1fd6df..44541276be0 100644--- a/backend/routes/allowlist.py+++ b/backend/routes/allowlist.py@@ -23,6 +23,7 @@ BACKEND_PATH_PREFIXES: tuple[str, ...] = ("/end_user/","/sso/","/liteadmin/slack/connect/",+ "/moyai/connect/","/login","/v2/login","/v3/login",diff --git a/litellm/proxy/moyai_endpoints.py b/litellm/proxy/moyai_endpoints.pyindex 655fc0560f4..a2335c0a49b 100644--- a/litellm/proxy/moyai_endpoints.py+++ b/litellm/proxy/moyai_endpoints.py@@ -20,6 +20,7 @@ from urllib.parse import urlencode, urlparsefrom fastapi import APIRouter, Depends, HTTPException, Request, statusfrom pydantic import BaseModel+from litellm._internal_context import with_service_targetfrom litellm.proxy._types import LitellmUserRoles, UserAPIKeyAuthfrom litellm.proxy.auth.user_api_key_auth import user_api_key_authfrom litellm.proxy.ui_crud_endpoints.proxy_setting_endpoints import (@@ -28,6 +29,7 @@ from litellm.proxy.ui_crud_endpoints.proxy_setting_endpoints import (_ui_settings_db,normalize_moyai_url,)+from litellm.proxy.utils import CONFIG_PARAMS_TARGETfrom litellm.repositories.config_repository import ConfigRepositoryfrom litellm.repositories.table_repositories import UISettingsRepository@@ -189,6 +191,7 @@ async def _moyai_key_alias(prisma_client, moyai_url: str) -> str:return alias+@with_service_target(CONFIG_PARAMS_TARGET)async def _persist_moyai_url(prisma_client, moyai_url: str) -> None:from litellm.proxy.proxy_server import user_api_key_cachediff --git a/tests/unit/proxy/test_moyai_endpoints.py b/tests/unit/proxy/test_moyai_endpoints.pyindex a0b0d56b637..92a1261d952 100644--- a/tests/unit/proxy/test_moyai_endpoints.py+++ b/tests/unit/proxy/test_moyai_endpoints.py@@ -1,10 +1,13 @@import jsonimport timefrom types import SimpleNamespace+from typing import Finalfrom unittest.mock import AsyncMock, MagicMockimport pytest+from litellm._internal_context import current_service_target+from litellm.caching.dual_cache import DualCachefrom litellm.proxy._types import LitellmUserRoles, UserAPIKeyAuth@@ -272,6 +275,37 @@ async def test_exchange_concurrent_replay_claims_nonce_once(monkeypatch: pytest.assert len(mint_calls) == 1+def _target_recording_cache(cache: DualCache) -> SimpleNamespace:+ async def _set(key: str, value: object, **kwargs: object) -> None:+ await cache.async_set_cache(key=f"{key}:service_target", value=current_service_target())+ await cache.async_set_cache(key=key, value=value, **kwargs)++ return SimpleNamespace(async_set_cache=_set)+++async def test_persist_moyai_url_writes_ui_settings_cache_under_config_params_target(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ from litellm.proxy import proxy_server+ from litellm.proxy.moyai_endpoints import _persist_moyai_url+ from litellm.proxy.ui_crud_endpoints.proxy_setting_endpoints import UI_SETTINGS_CACHE_KEY+ from litellm.proxy.utils import CONFIG_PARAMS_TARGET++ cache: Final = DualCache()+ monkeypatch.setattr(proxy_server, "user_api_key_cache", _target_recording_cache(cache))++ prisma: Final = MagicMock()+ prisma.db.litellm_uisettings.find_unique = AsyncMock(return_value=None)+ prisma.db.litellm_uisettings.upsert = AsyncMock()++ await _persist_moyai_url(prisma, "https://moyai.example.com")++ assert await cache.async_get_cache(key=f"{UI_SETTINGS_CACHE_KEY}:service_target") == CONFIG_PARAMS_TARGET+ assert await cache.async_get_cache(key=UI_SETTINGS_CACHE_KEY) == {"moyai_url": "https://moyai.example.com"}+ assert current_service_target() is None++@pytest.mark.asyncioasync def test_exchange_replay_survives_fresh_worker_cache(monkeypatch: pytest.MonkeyPatch) -> None:from fastapi import HTTPException