Switching LLM providers

One of the powerful features of this project is LiteLLM support. You can switch between OpenAI, Anthropic, Google, and other providers just by changing your .env file.

Litellm provider switch

How LiteLLM abstracts multiple LLM providers behind one API

.env
bash
# OpenAI Models
DEFAULT_MODEL=gpt-4o-mini
DEFAULT_MODEL=gpt-4o
DEFAULT_MODEL=gpt-4-turbo

# Anthropic Models
DEFAULT_MODEL=claude-3-5-sonnet-20241022
DEFAULT_MODEL=claude-3-haiku-20240307

# Google Models
DEFAULT_MODEL=gemini/gemini-1.5-flash
DEFAULT_MODEL=gemini/gemini-1.5-pro

# Make sure you have the corresponding API key set!
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=...

Change DEFAULT_MODEL to switch providers. No code changes needed!

Yes! LiteLLM supports Ollama too. Set DEFAULT_MODEL=ollama/llama3 and make sure Ollama is running locally. The tradeoff is that local models are usually less capable at complex SQL generation and analysis than cloud models, so expect some quality differences.

Flashcards: Flashcards

Loading practice…

AI prompt: Try it with AI

Loading practice…

Quiz: Quiz

Loading practice…

You can now run your chatbot with any LLM provider. Next, we will explore customization challenges to make the system your own.