Mozilla's any-llm Lets Developers Switch AI Providers in One Line
Mozilla.ai's open-source Python library gives you one API surface across OpenAI, Anthropic, Mistral, Ollama and dozens more, without running a proxy.
Takeaways
- Mozilla.ai's any-llm offers one Python interface for OpenAI, Anthropic, Mistral, Ollama and more.
- Wraps official provider SDKs instead of reimplementing them, unlike LiteLLM.
- No proxy server required, unlike OpenRouter or Portkey, requests go direct.
- v1.0 adds async-first APIs, connection pooling, and standardized reasoning output across providers.
- Supports streaming, tool calling from Python callables, embeddings, and the Responses API.
- A Go sibling any-llm-go extends the abstraction beyond Python.
Swapping LLM providers should be a one-line change, but in practice it rarely is. Parameter names drift, response shapes disagree, and every SDK has its own quirks. Mozilla.ai's any-llm is a Python library that papers over those differences with a single function call, and it has quietly crossed 2,000 GitHub stars while becoming the routing layer behind Mozilla's own agent stack.
any-llm gives you one completion() entry point that talks to OpenAI, Anthropic, Azure / Microsoft Foundry, Mistral, Ollama, and more without changing your code. It's Apache-2.0 licensed, requires Python 3.11+, and ships on PyPI as any-llm-sdk.
The pitch in five lines of Python
Installation is provider-scoped, so you only pull in the SDKs you actually need:
pip install 'any-llm-sdk[mistral,ollama]'
export MISTRAL_API_KEY="YOUR_KEY_HERE"
The call itself looks like the OpenAI SDK you already know:
from any_llm import completion
response = completion(
model="mistral-small-latest",
provider="mistral",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)