✨ Key Features

🔄

Unified Interface

Single API for multiple LLM providers including OpenAI, Anthropic, Google, Groq, and more.

🔑

API Key Rotation

Automatic round-robin rotation for multiple API keys with built-in rate limit handling.

🧠

Drop-in OpenAI SDK

BorgOpenAI and BorgAsyncOpenAI duck-type the official OpenAI clients. Optional LangChain support.

🛡️

Provider Fallback

Automatic switching to alternative providers/models in case of failures or rate limits.

Zero Configuration

Works out of the box with environment variables, or configure via borg.yml for advanced features.

🔍

Virtual Providers

Create custom fallback strategies and merge multiple providers seamlessly.

🔌 Supported Providers & Models

BorgLLM supports 20+ LLM providers out of the box. Click any model to copy it to your clipboard.

Any model identifier from these providers will also work out of the box, even if it's not listed here.

Provider Model Description Copy
Showing 1-20 of 32 models

🚀 Quick Start

Installation

# Core install (OpenAI SDK integration)
pip install borgllm

# With optional LangChain support
pip install borgllm[langchain]

Basic Usage - BorgOpenAI (Drop-in OpenAI SDK)

from borgllm import BorgOpenAI

# Works with any provider - just specify provider:model
client = BorgOpenAI()

response = client.chat.completions.create(
    model="openai:gpt-5.2",
    messages=[{"role": "user", "content": "Hello! How are you?"}]
)
print(response.choices[0].message.content)

# Try different providers seamlessly
response = client.chat.completions.create(
    model="anthropic:claude-opus-4-5",  # or google:gemini-3-pro-preview
    messages=[{"role": "user", "content": "Hello!"}]
)

Advanced Features with borg.yml

# borg.yml - Advanced configuration
llm:
  providers:
    - name: "local_qwen"
      base_url: "http://localhost:1234/v1"
      model: "qwen/qwen3-8b"
      temperature: 0.7
      max_tokens: 8192

  virtual:
    - name: "smart-fallback"
      upstreams:
        # Try fast/cheap provider first
        - name: "groq:llama-3.3-70b-versatile"
        # Fall back to more capable model if needed
        - name: "openai:gpt-4o"
        # Use local model as final fallback
        - name: "local_qwen"
  
  default_model: "smart-fallback"

Using Virtual Providers

from borgllm import BorgOpenAI

# With borg.yml configuration above
client = BorgOpenAI()

# Automatically handles:
# - Rate limits (switches to next provider)
# - Context window limits (uses appropriate model)
# - Provider failures (seamless fallback)
response = client.chat.completions.create(
    model="smart-fallback",  # Uses virtual provider from borg.yml
    messages=[{"role": "user", "content": "Write a detailed analysis..."}]
)
print(response.choices[0].message.content)

Optional LangChain Integration

# Requires: pip install borgllm[langchain]
from borgllm import create_llm
from langchain_core.messages import HumanMessage

llm = create_llm("openai:gpt-5.2", temperature=0.7)
response = llm.invoke([HumanMessage(content="Hello!")])
print(response.content)
📂 See More Examples

Explore comprehensive examples including custom providers, virtual providers, API key rotation, and advanced configurations.