Skip to content

feat: Add multi-provider LLM support via LiteLLM integration - #110

Closed
joeVenner wants to merge 3 commits into
VectifyAI:mainfrom
joeVenner:feat/Add_multi_provider_LLM_support_including_local_ollama
Closed

feat: Add multi-provider LLM support via LiteLLM integration#110
joeVenner wants to merge 3 commits into
VectifyAI:mainfrom
joeVenner:feat/Add_multi_provider_LLM_support_including_local_ollama

Conversation

@joeVenner

Copy link
Copy Markdown

🌟 Add Multi-Provider LLM Support - Use Any LLM with PageIndex!

Summary

This PR transforms PageIndex from an OpenAI-only tool into a universal LLM-powered document indexing solution. By integrating LiteLLM, users can now choose from 100+ LLM providers including:

Provider Models Setup
🟢 OpenAI GPT-4o, GPT-4 Turbo OPENAI_API_KEY
🟣 Anthropic Claude 3 Opus, Sonnet, Haiku ANTHROPIC_API_KEY
🔵 Google Gemini Pro, Gemini 1.5 GEMINI_API_KEY
🟦 Azure Azure OpenAI deployments AZURE_API_KEY + base
🟠 AWS Bedrock Claude, Llama on Bedrock AWS credentials
Groq Llama 3.1, Mixtral GROQ_API_KEY
🦙 Ollama (Local) Llama3, Mistral, Qwen No API key!

🚀 Key Features

  • Zero Breaking Changes: Fully backward compatible with existing setups
  • Local Model Support: Run completely offline with Ollama
  • Flexible Token Counting: Automatic tokenizer selection per provider
  • Simple Migration: Just change the model string!

📝 Usage Examples

# OpenAI (default - no changes needed)
python3 run_pageindex.py --pdf_path doc.pdf

# Claude 3 Opus
export ANTHROPIC_API_KEY=your_key
python3 run_pageindex.py --pdf_path doc.pdf --model claude-3-opus-20240229

# Local Ollama (no API key!)
ollama serve
python3 run_pageindex.py --pdf_path doc.pdf --model ollama/llama3

@jdiaz-elyndra

jdiaz-elyndra commented Feb 14, 2026 via email

Copy link
Copy Markdown

@joeVenner

Copy link
Copy Markdown
Author

@zmtomorrow Can you check please ?

@hoangvantuan

Copy link
Copy Markdown

I really need this pull request.

@joeVenner

Copy link
Copy Markdown
Author

@rejojer can you check ?

Comment thread pageindex/utils.py Outdated
else:
# Use LiteLLM's token counter for other providers
try:
return litellm.token_counter(model=model, text=text)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use directly litellm.token_counter? Why is this needed: if is_openai_model:

Joevenner and others added 3 commits March 22, 2026 14:23
Replace OpenAI-only implementation with LiteLLM to support 100+ LLM providers
including Anthropic Claude, Google Gemini, Azure OpenAI, AWS Bedrock, Groq,
and local Ollama models.

Changes:
- Add litellm>=1.0.0 dependency
- Refactor ChatGPT_API functions to use litellm.completion()
- Enhance count_tokens() for multi-provider token counting
- Update config.yaml with provider-specific model examples
- Update README.md with multi-provider setup instructions

Backward compatible: Existing OPENAI_API_KEY and CHATGPT_API_KEY still work.
Default model remains gpt-4o-2024-11-20.
…removing reliance on direct tiktoken and hardcoded models, while cleaning up tokenization logic to prevent crashes
Accept upstream's LiteLLM implementation (llm_completion/llm_acompletion,
pinned litellm==1.82.0, ConfigLoader, drop_params) which supersedes
our parallel implementation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joeVenner
joeVenner force-pushed the feat/Add_multi_provider_LLM_support_including_local_ollama branch from acc22f7 to 7d63209 Compare March 22, 2026 13:24
@joeVenner
joeVenner requested a review from ClimenteA March 22, 2026 23:37
@joeVenner

Copy link
Copy Markdown
Author

@ClimenteA Can you please check this PR when you have time ?

@KylinMountain

Copy link
Copy Markdown
Collaborator

Thanks @joeVenner! This is exactly the direction we took — multi-provider support via LiteLLM landed in #168 (merged), so llm_completion now routes through litellm.completion and works with any LiteLLM-supported provider by model name. Closing as already implemented; your PR helped validate the approach. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants