BerriAI/litellm · error · ValueError

PARALLEL_API_KEY is not set. Set `PARALLEL_API_KEY` environm

Error message

PARALLEL_API_KEY is not set. Set `PARALLEL_API_KEY` environment variable.

What it means

Parallel AI's search transformation resolves credentials via resolve_server_api_key, checking the PARALLEL_AI_API_KEY and PARALLEL_API_KEY environment variables (plus caller-passed keys). If nothing resolves it raises this ValueError. The message names only PARALLEL_API_KEY, but PARALLEL_AI_API_KEY is the primary variable and works too.

Source

Thrown at litellm/llms/parallel_ai/search/transformation.py:78

    def ui_friendly_name() -> str:
        return "Parallel AI"

    def validate_environment(
        self,
        headers: dict,
        api_key: str | None = None,
        api_base: str | None = None,
        **kwargs,
    ) -> dict:
        api_key = self.resolve_server_api_key(
            caller_api_key=api_key,
            caller_api_base=api_base,
            key_env_vars=("PARALLEL_AI_API_KEY", "PARALLEL_API_KEY"),
            base_env_var="PARALLEL_AI_API_BASE",
            default_api_base=self.PARALLEL_AI_API_BASE,
        )
        if not api_key:
            raise ValueError("PARALLEL_API_KEY is not set. Set `PARALLEL_API_KEY` environment variable.")
        headers["x-api-key"] = api_key
        headers["Content-Type"] = "application/json"
        return headers

    def get_complete_url(
        self,
        api_base: str | None,
        optional_params: dict,
        data: dict | list[dict] | None = None,
        **kwargs,
    ) -> str:
        api_base = api_base or get_secret_str("PARALLEL_AI_API_BASE") or self.PARALLEL_AI_API_BASE

        api_base = api_base.rstrip("/")
        if not api_base.endswith("/v1/search"):
            api_base = f"{api_base.removesuffix('/v1')}/v1/search"

        return api_base

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. export PARALLEL_AI_API_KEY=... (or PARALLEL_API_KEY) in the environment running litellm
  2. Pass api_key explicitly in the call or deployment configuration
  3. For litellm proxy, declare the key in config.yaml rather than relying on ambient env
  4. Add a startup check asserting one of the two variables resolves

Example fix

// before
res = litellm.parallel_ai_search(query="...")  # no key anywhere

// after
import os
res = litellm.parallel_ai_search(query="...", api_key=os.environ["PARALLEL_AI_API_KEY"])
Defensive patterns

Strategy: validation

Validate before calling

import os

def parallel_key_present() -> bool:
    return bool(os.getenv("PARALLEL_AI_API_KEY") or os.getenv("PARALLEL_API_KEY"))

assert parallel_key_present(), "Set PARALLEL_AI_API_KEY (or PARALLEL_API_KEY)"  # run at startup

Try / catch

try/except ValueError around the search call can convert this deterministic config failure into an ops-facing configuration error; retrying is pointless.

Prevention

When it happens

Trigger: Invoking litellm's Parallel AI search support without an api_key argument while neither PARALLEL_AI_API_KEY nor PARALLEL_API_KEY is present in the environment.

Common situations: Env vars missing in containers/serverless deployments; misspelled variable names; key configured on a different litellm proxy deployment than the one serving the request.

Related errors


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