VectifyAI/PageIndex · error · PageIndexAPIError

messages drives your own chat model and requires the Anthrop

Error message

messages drives your own chat model and requires the Anthropic SDK — pip install anthropic (or pip install 'pageindex[anthropic]').

What it means

The messages() API runs on your own Anthropic chat model, so pageindex needs the Anthropic Python SDK at runtime. _require_anthropic() probes for the anthropic package before starting the tool runner and raises PageIndexAPIError when the import fails. This is purely an environment/dependency issue, not a request problem.

Source

Thrown at pageindex/local_chat.py:871

        transcript = streamed.to_input_list()[len(items):]
        sequence += 1
        status = recorded.get("status") or "completed"
        terminal = {"incomplete": "response.incomplete",
                    "failed": "response.failed"}.get(status,
                                                     "response.completed")
        yield {"type": terminal, "sequence_number": sequence,
               "response": envelope(transcript, streamed.raw_responses)}

    return _stream_sync(agen)


# ── Anthropic engine (messages) ──

def _require_anthropic() -> None:
    try:
        import anthropic  # noqa: F401
    except ImportError as exc:
        raise PageIndexAPIError(
            "messages drives your own chat model and requires the "
            "Anthropic SDK — "
            "pip install anthropic (or pip install 'pageindex[anthropic]')."
        ) from exc
    try:
        from anthropic import beta_tool  # noqa: F401
        from anthropic.lib.tools import ToolError  # noqa: F401
    except ImportError as exc:
        raise PageIndexAPIError(
            "messages requires anthropic >= 0.108.0 (the tool "
            "runner with ToolError) — pip install -U anthropic."
        ) from exc


_ANTHROPIC_CLIENTS: dict = {}  # backend key -> client, kept open for reuse


def _anthropic_client(backend=None):

View on GitHub (pinned to afb5e11976)

Solutions

  1. pip install anthropic (or pip install 'pageindex[anthropic]' to get the pinned extra)
  2. Verify the import works in the target environment: python -c "import anthropic"
  3. If deploying, add anthropic to your requirements.txt/lockfile alongside pageindex

Example fix

# before
resp = client.messages("summarize this doc")  # PageIndexAPIError
# after
# pip install 'pageindex[anthropic]'
resp = client.messages("summarize this doc")
Defensive patterns

Strategy: validation

Validate before calling

try:
    import anthropic  # noqa
except ImportError:
    raise SystemExit("Install first: pip install 'pageindex[anthropic]'")

Try / catch

try:
    resp = client.messages("hi")
except PageIndexAPIError as e:
    if "requires the Anthropic SDK" in str(e):
        subprocess.check_call([sys.executable, "-m", "pip", "install", "anthropic"])
        resp = client.messages("hi")
    else:
        raise

Prevention

When it happens

Trigger: Calling client.messages(...) (which delegates to run_messages) in an environment where `import anthropic` raises ImportError — e.g. pageindex installed without the [anthropic] extra, or a fresh venv/CI image that never installed the SDK.

Common situations: Installing pageindex via `pip install pageindex` (without the [anthropic] extra) and then calling the messages door; deploying to a slim Docker image or CI runner that strips optional dependencies; a different library shadowing the anthropic module name.

Related errors


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