Switch providers in one line
Change from OpenAI to Anthropic, Mistral, or any other provider with a single parameter change.
from any_llm import completion
# Using the messages formatresponse = completion( model="gpt-4o-mini", messages=[{"role": "user", "content": "What is Python?"}], provider="openai")print(response)
# Switch providers without changing your coderesponse = completion( model="claude-sonnet-4-5-20250929", messages=[{"role": "user", "content": "What is Python?"}], provider="anthropic")print(response)Switch providers in one line
Change from OpenAI to Anthropic, Mistral, or any other provider with a single parameter change.
Unified exception handling
Consistent error handling across all providers with a unified exception hierarchy.
Simple API, powerful features
Streaming, tool calling, embeddings, reasoning, and more — all through one interface.
any-llm provides two main interfaces:
Direct API Functions (recommended for simple use cases):
AnyLLM Class (recommended for advanced use cases):
This documentation is available in two AI-friendly formats: