Introduction

any-llm is a Python library providing a single interface to different LLM providers.

from any_llm import completion

# Using the messages format
response = completion(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "What is Python?"}],
    provider="openai"
)
print(response)

# Switch providers without changing your code
response = completion(
    model="claude-sonnet-4-5-20250929",
    messages=[{"role": "user", "content": "What is Python?"}],
    provider="anthropic"
)
print(response)

Get Started | View on GitHub

Why any-llm

API Documentation

any-llm provides two main interfaces:

Direct API Functions (recommended for simple use cases):

AnyLLM Class (recommended for advanced use cases):

  • Provider API - Lower-level provider interface with metadata access and reusability

For AI Systems

This documentation is available in an AI-friendly format via the unified Mozilla.ai llms.txt:

  • llms.txt - Structured overview of all Mozilla.ai documentation for AI systems

  • llms-full.txt - Complete Mozilla.ai documentation concatenated into a single file

Last updated