VectifyAI/PageIndex · error · PageIndexAPIError

The OpenAI backend is not configured: {exc}

Error message

The OpenAI backend is not configured: {exc}

What it means

When constructing the AsyncOpenAI client for the responses/chat engine, configuration errors (bad key, malformed base_url, bad proxy/type kwargs) raise openai.OpenAIError or TypeError, which the library wraps as 'The OpenAI backend is not configured: <detail>'. The original exception text identifies the misconfiguration.

Source

Thrown at pageindex/local_chat.py:205

def _openai_model(protocol: str, model_name: str, backend=None):
    """The backend protocol driver — the seam tests replace with a fake."""
    if protocol == "responses":
        model_name = model_name.removeprefix("litellm/")
        if "/" in model_name and not model_name.startswith("openai/"):
            raise PageIndexAPIError(
                f"responses() cannot drive '{model_name}': provider-prefixed "
                "models route through LiteLLM, which speaks chat.completions, "
                "not the Responses API. Use chat_completions() (or messages() "
                "for Anthropic models), or point OPENAI_BASE_URL at a "
                "Responses-capable backend and use a bare or "
                "'openai/'-prefixed model name."
            )
        import openai
        model_name = model_name.removeprefix("openai/")
        try:
            sdk_client = openai.AsyncOpenAI(**_sdk_backend(backend))
        except (openai.OpenAIError, TypeError) as exc:
            raise PageIndexAPIError(
                f"The OpenAI backend is not configured: {exc}") from exc
        # A caller-owned transport must survive the per-call close.
        sdk_client._pageindex_caller_http = "http_client" in (backend or {})
        from agents.models.openai_responses import OpenAIResponsesModel
        return OpenAIResponsesModel(model_name, openai_client=sdk_client)
    try:
        from agents.extensions.models.litellm_model import LitellmModel
        import litellm
    except ImportError:
        raise PageIndexAPIError(
            f"'{model_name}' routes through LiteLLM, but litellm is not "
            "installed. Run:  pip install 'litellm>=1.97'"
        )
    from .utils import (_litellm_model, _mute_litellm_bridge_usage_warning,
                        _repair_litellm_types)
    _repair_litellm_types()
    _mute_litellm_bridge_usage_warning()
    try:

View on GitHub (pinned to afb5e11976)

Solutions

  1. Set OPENAI_API_KEY or pass backend={"api_key": ...} explicitly
  2. Verify base_url includes scheme and is reachable; check env loading
  3. Remove unsupported keys from the backend dict — only SDK-valid kwargs pass through

Example fix

# before
client.responses(model="gpt-5", input=q, backend={"base_url":"localhost:8000/v1"})

# after
client.responses(model="gpt-5", input=q, backend={"base_url":"http://localhost:8000/v1","api_key":os.environ["OPENAI_API_KEY"]})
Defensive patterns

Strategy: try-catch

Validate before calling

assert os.environ.get('OPENAI_API_KEY'), 'OPENAI_API_KEY not set'

Type guard

null

Try / catch

try:
    client.responses(model=m, input=q, backend=backend)
except PageIndexAPIError as e:
    if str(e).startswith('The OpenAI backend is not configured'):
        # inspect original detail, fix key/base_url, retry once fixed
        ...
    raise

Prevention

When it happens

Trigger: Providing backend={"api_key": None} with no OPENAI_API_KEY env var, a malformed base_url, or unknown kwargs in the backend dict.

Common situations: Missing OPENAI_API_KEY in CI/containers, typos in base_url (missing scheme), passing engine-specific options the SDK doesn't accept, .env not loaded.

Related errors


AI-assisted analysis of VectifyAI/PageIndex@afb5e11976 (2026-08-27). Data as JSON: /api/errors/8dc17ce8ca0f2e8c. Report an issue: GitHub.