BerriAI/litellm · error · ValueError

No guardrail translation mapping found for call_type

Error message

No guardrail translation mapping found for call_type: {call_type}. Available mappings: {list(endpoint_guardrail_translation_mappings.keys())}

What it means

ValueError raised by get_guardrail_translation_mapping when the requested CallTypes value has no entry in the guardrail translation registry. The registry is discovered lazily by scanning litellm/llms/**/guardrail_translation packages (plus the MCP server mappings), so a call type is missing either because no handler ships for it or because its module failed to import during discovery (errors go to verbose_logger). The message lists the available call types.

Solutions

  1. Read the error's 'Available mappings' list and route the guardrail through one of those call types.
  2. Upgrade litellm — handlers for more call types are added over releases.
  3. Enable verbose logging and look for 'Could not import litellm.llms...' from discover_guardrail_translation_mappings; reinstall the package if files are missing.
  4. If needed immediately, add a guardrail_translation module exposing a guardrail_translation_mappings dict that maps your call type to a handler class.

Example fix

# before
handler = get_guardrail_translation_mapping(CallTypes.my_new_endpoint)
# ValueError: No guardrail translation mapping found ...

# after
from litellm.llms import load_guardrail_translation_mappings
mappings = load_guardrail_translation_mappings()
handler = mappings.get(CallTypes.my_new_endpoint) or mappings[CallTypes.acompletion]
Defensive patterns

Strategy: validation

Validate before calling

from litellm.llms import load_guardrail_translation_mappings

mappings = load_guardrail_translation_mappings()
if call_type not in mappings:
    raise ValueError(
        f"guardrails unsupported for {call_type}; supported: {sorted(str(k) for k in mappings)}"
    )
handler = mappings[call_type]

Type guard

from litellm.llms import load_guardrail_translation_mappings

def is_supported_guardrail_call_type(call_type) -> bool:
    return call_type in load_guardrail_translation_mappings()

Try / catch

try:
    handler = get_guardrail_translation_mapping(call_type)
except ValueError as e:
    logger.error("guardrail call type not supported: %s", e)
    raise HTTPException(status_code=400, detail=str(e))

Prevention

When it happens

Trigger: Applying a guardrail to an endpoint whose call type has no translation handler (compare against the error's 'Available mappings' list); a partially broken install where a guardrail_translation module raised ImportError and was skipped during discovery.

Common situations: Adding guardrails to newly introduced or non-standard endpoints; a broken pip install or vendored litellm tree missing subpackages; proxy upgrades that outpace custom guardrail code.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/29311865f6f3d30b. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/__init__.py:178

    Args:
        call_type: The type of call (e.g., completion, acompletion, anthropic_messages)

    Returns:
        The translation handler class for the given call type

    Raises:
        ValueError: If no translation mapping exists for the given call type
    """
    global endpoint_guardrail_translation_mappings

    # Lazy load the mappings on first access
    if endpoint_guardrail_translation_mappings is None:
        endpoint_guardrail_translation_mappings = discover_guardrail_translation_mappings()

    # Get the translation handler class for the call type
    if call_type not in endpoint_guardrail_translation_mappings:
        raise ValueError(
            f"No guardrail translation mapping found for call_type: {call_type}. "
            f"Available mappings: {list(endpoint_guardrail_translation_mappings.keys())}"
        )

    # Return the handler class directly
    return endpoint_guardrail_translation_mappings[call_type]

View on GitHub (pinned to 77b7c6c40c)