Skip to content

[Bug] PageIndex long document indexing fails with custom OPENAI_API_BASE / 401 Unauthorized #219

Description

@molezz
  • Description: When configuring a custom OpenAI-compatible proxy via OPENAI_API_BASE and OPENAI_API_KEY in .env, short documents process fine, but long documents (>20 pages) fail during index_long_document with litellm.AuthenticationError: 401 Unauthorized or API key not configured.

  • Root Cause: openkb.indexer.index_long_document instantiates PageIndexClient without passing through the resolved base_url and api_key from the credential bundle, and pageindex.index.utils.llm_completion does not inject api_base/api_key into litellm.completion().

  • Expected Behavior: PageIndexClient and its internal LiteLLM calls should inherit the active KB's resolved OPENAI_API_BASE and OPENAI_API_KEY.

Steps to Reproduce

  1. Configure .env with a custom OpenAI-compatible proxy:
 
   OPENAI_API_BASE="http://your-proxy:port/v1"
   OPENAI_API_KEY="***"
  1. Set model: openai/your-model in config.yaml.
  2. Ingest a long PDF (>20 pages, e.g., 30 pages) via openkb add doc.pdf or watch service.
  3. index_long_document triggers PageIndexClient, which throws litellm.AuthenticationError: Error code: 401 - {'error': 'API key required for remote API access'} because credentials are not forwarded to LiteLLM inside pageindex.index.utils.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions