any-llm: a unified API to access any LLM provider using official SDKs without a proxy

any-llm: a unified API to access any LLM provider using official SDKs without a proxy

What it solves

It eliminates the fragmentation of LLM provider interfaces. Instead of writing different code for every AI provider (like OpenAI, Anthropic, or Mistral), developers can use a single, unified interface to communicate with any supported model, making it easy to switch providers without rewriting their application logic.

How it works

any-llm acts as a light wrapper that leverages official provider SDKs to ensure maximum compatibility. It provides two primary ways to interact with models:

  • Direct API Functions: A stateless completion function for quick scripts and notebooks.
  • AnyLLM Class: A stateful class that reuses clients and connection pooling, designed for production applications.

It supports standard features like streaming, tool use, and an OpenAI-compatible Responses API, and it allows users to specify models using either separate provider and model parameters or a combined provider:model string.

Who it’s for

Developers who want to build LLM-powered applications that are flexible and provider-agnostic, avoiding lock-in to a single AI vendor or the need to manage a hosted proxy server.

Highlights

  • Unified Interface: Switch between providers by changing a single string.
  • Official SDK Integration: Uses official SDKs rather than reimplementing interfaces to reduce compatibility issues.
  • Framework Agnostic: Can be integrated into any project without being tied to a specific agent framework.
  • Type-Safe: Includes full Python type hints for better IDE support.
  • No Proxy Required: Connects directly to providers without needing an intermediary server.

Sources