BerriAI/litellm · error · ValueError

api_key is required for straiker

Error message

api_key is required for straiker

What it means

Error "api_key is required for straiker" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/guardrails/guardrail_hooks/straiker/__init__.py:40

)


def _get_config_value(litellm_params: "LitellmParams", optional_params: object, attribute_name: str) -> object:
    if optional_params is not None:
        if isinstance(optional_params, dict):
            value = optional_params.get(attribute_name)
        else:
            value = getattr(optional_params, attribute_name, None)
        if value is not None:
            return value
    return getattr(litellm_params, attribute_name, None)


def initialize_guardrail(litellm_params: "LitellmParams", guardrail: "Guardrail"):
    optional_params: Final = getattr(litellm_params, "optional_params", None)
    api_key: Final = litellm_params.api_key
    if not api_key:
        raise ValueError("api_key is required for straiker")

    api_base: Final = litellm_params.api_base or "https://api.prod.straiker.ai"
    default_app: Final = getattr(litellm_params, "default_app", None) or getattr(litellm_params, "source", None)
    source: Final = default_app if isinstance(default_app, str) and default_app else "LiteLLM Gateway"
    kwargs: Final[dict[str, object]] = {
        field: value
        for field in _OPTIONAL_INIT_FIELDS
        for value in [_get_config_value(litellm_params, optional_params, field)]
        if value is not None
    }
    _callback: Final = StraikerGuardrail(
        api_key=api_key,
        api_base=api_base if isinstance(api_base, str) else "https://api.prod.straiker.ai",
        source=source,
        guardrail_name=guardrail.get("guardrail_name", "straiker"),
        event_hook=litellm_params.mode,
        default_on=litellm_params.default_on,
        **kwargs,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass api_key in the straiker guardrail configuration.
  2. Or set the corresponding environment variable for the Straiker API key.

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/straiker/__init__.py:40 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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