{"record":{"id":"12c394b092ec0287","repo":"VectifyAI/PageIndex","slug":"method-with-your-own-chat-model-requires-the-ope","errorCode":null,"errorMessage":"{method} with your own chat model requires the OpenAI Agents SDK — pip install openai-agents. messages() runs on the anthropic extra instead.","messagePattern":"(.+?) with your own chat model requires the OpenAI Agents SDK — pip install openai-agents\\. messages\\(\\) runs on the anthropic extra instead\\.","errorType":"exception","errorClass":"PageIndexAPIError","httpStatus":null,"severity":"error","filePath":"pageindex/local_chat.py","lineNumber":172,"sourceCode":"    try:\n        while True:\n            item = items.get()\n            if item is _SENTINEL:\n                return\n            if isinstance(item, BaseException):\n                raise item\n            yield item\n    finally:\n        cancelled.set()\n\n\n# ── OpenAI engine (chat_completions / responses) ──\n\ndef _require_openai_agents(method: str) -> None:\n    try:\n        import agents  # noqa: F401\n    except ImportError as exc:\n        raise PageIndexAPIError(\n            f\"{method} with your own chat model requires the OpenAI \"\n            \"Agents SDK — \"\n            \"pip install openai-agents. \"\n            \"messages() runs on the anthropic extra instead.\"\n        ) from exc\n\n\ndef _sdk_backend(backend) -> dict:\n    \"\"\"chat_backend for an SDK constructor: LiteLLM takes either endpoint\n    spelling, the openai and anthropic SDKs only ``base_url``.\"\"\"\n    return {(\"base_url\" if key == \"api_base\" else key): value\n            for key, value in (backend or {}).items()}\n\n\ndef _openai_model(protocol: str, model_name: str, backend=None):\n    \"\"\"The backend protocol driver — the seam tests replace with a fake.\"\"\"\n    if protocol == \"responses\":\n        model_name = model_name.removeprefix(\"litellm/\")","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/VectifyAI/PageIndex/blob/afb5e119766630af6014b04fe8b53357527bc05e/pageindex/local_chat.py#L154-L190","documentation":"chat_completions() and responses() with your own chat model are implemented on top of the OpenAI Agents SDK; if `import agents` fails, this error tells you to install it. messages() does not need it (it uses the anthropic extra).","triggerScenarios":"Installing only the base pageindex package (no chat extras) then calling client.chat_completions(model=..., ...) or client.responses(...).","commonSituations":"Minimal install in CI, slim Docker images, upgrading and losing the extras, assuming the SDK is a transitive dependency.","solutions":["pip install 'pageindex[chat]' (or pip install openai-agents)","If you only need Anthropic models, use messages() instead — it runs on the anthropic extra","Pin openai-agents in requirements to avoid environment drift"],"exampleFix":"# before\npip install pageindex\n\n# after\npip install 'pageindex[chat]'","handlingStrategy":"fallback","validationCode":"try:\n    import agents  # noqa\n    HAS_AGENTS = True\nexcept ImportError:\n    HAS_AGENTS = False\nif not HAS_AGENTS:\n    raise RuntimeError('install pageindex[chat] or use messages()')","typeGuard":"null","tryCatchPattern":"try:\n    client.chat_completions(...)\nexcept PageIndexAPIError as e:\n    if 'pip install openai-agents' in str(e):\n        # fall back to messages() or install and retry\n        ...","preventionTips":["Install 'pageindex[chat]' in images that call chat_completions/responses","Add an import agents probe at startup with a clear failure","Use messages() when only Anthropic models are needed"],"tags":["pageindex","chat","missing-dependency","openai-agents","pip"],"backgroundTag":"missing-dependency","analyzedSha":"afb5e119766630af6014b04fe8b53357527bc05e","analyzedAt":"2026-08-27T11:20:48.519Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}