This commit is contained in:
devin-ai-integration[bot] 2026-08-27 18:55:20 -05:00 committed by GitHub
commit b534e9c3b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 0 deletions

View file

@ -108,6 +108,20 @@ class GenericGuardrailAPIConfigModel(
):
"""Configuration parameters for the Generic Guardrail API guardrail"""
api_base: str | None = Field(
default=None,
description=(
"Base URL of the guardrail service implementing the LiteLLM Basic Guardrail API spec; "
"LiteLLM appends /beta/litellm_basic_guardrail_api to it. Falls back to the "
"GENERIC_GUARDRAIL_API_BASE environment variable, and initialization fails when neither is set."
),
)
api_key: str | None = Field(
default=None,
description="API key for the guardrail service, sent as the x-api-key header.",
)
optional_params: GenericGuardrailAPIOptionalParams | None = Field(
default_factory=GenericGuardrailAPIOptionalParams,
description="Optional parameters for the Generic Guardrail API guardrail",

View file

@ -1150,6 +1150,26 @@ class TestGenericGuardrailAPIStreamingConfig:
assert GenericGuardrailAPI.get_config_model() is GenericGuardrailAPIConfigModel
def test_config_model_exposes_api_base_and_api_key(self):
from litellm.types.proxy.guardrails.guardrail_hooks.generic_guardrail_api import (
GenericGuardrailAPIConfigModel,
)
assert set(GenericGuardrailAPIConfigModel.model_fields) >= {"api_base", "api_key"}
@pytest.mark.asyncio
async def test_ui_provider_specific_params_expose_connection_fields(self):
from litellm.proxy.guardrails.guardrail_endpoints import (
get_provider_specific_params,
)
provider_params = await get_provider_specific_params()
generic_params = provider_params["generic_guardrail_api"]
assert generic_params["api_base"]["type"] == "string"
assert generic_params["api_key"]["type"] == "string"
assert generic_params["optional_params"]["type"] == "nested"
def test_streaming_transform_mode_defaults_block_only(self):
guardrail = GenericGuardrailAPI(
api_base="https://api.test.guardrail.com",