# optillm

> An OpenAI-compatible proxy that boosts reasoning accuracy at inference time

- Category: Evaluation & Production Ops / Gateways & Routing
- Language: Python
- Repository: https://github.com/algorithmicsuperintelligence/optillm
- Canonical page: https://ai-tldr.dev/tools/optillm/

## In short

optillm is an OpenAI-compatible proxy that boosts reasoning accuracy at inference time. It sits in the Gateways & Routing category of the Evaluation & Production Ops tools and is open-source, written in Python. To get started: install.

## Overview

OptiLLM is an OpenAI API-compatible inference proxy that sits between your application and your language model. Instead of changing the model itself, it spends extra compute at request time, running techniques like Mixture of Agents, planning search, and multi-agent reasoning to improve answers on math, coding, and logic tasks.

It works as a drop-in replacement for any OpenAI-compatible endpoint. You point your existing OpenAI client at the local OptiLLM server and pick a technique by adding a prefix to the model name (for example 'moa-gpt-4o-mini'). Through LiteLLM it can route to OpenAI, Anthropic, Google, Cerebras, and many other models, so no fine-tuning or training is needed.

As an LLM gateway, OptiLLM fits teams that already call a chat-completions API and want better reasoning results without swapping models or retraining. You keep your client code and just route calls through the proxy.

## What it does

- OpenAI API-compatible: works as a drop-in proxy for any OpenAI-compatible client or endpoint
- Over 20 inference-time optimization techniques, from best-of-N to MCTS, planning search, and multi-agent reasoning (MARS, CePO, MOA)
- Pick a technique per request by adding a prefix to the model name (for example 'moa-' for Mixture of Agents)
- Multi-provider routing via LiteLLM, covering OpenAI, Anthropic, Google, Cerebras, and many other models
- No model training or fine-tuning required, the improvements come purely from extra compute at inference
- SSL options for self-signed certificates and corporate proxies via --ssl-cert-path or OPTILLM_SSL_CERT_PATH

## Getting started

Install OptiLLM, start the proxy server, then point any OpenAI client at it and choose a technique through the model name prefix.

1. Install

   Install the package from PyPI. A Docker image is also available at ghcr.io/algorithmicsuperintelligence/optillm.

```bash
pip install optillm
```

2. Start the server

   Set your API key and run the optillm command. The server listens on port 8000 by default.

```bash
export OPENAI_API_KEY="your-key-here"
optillm
```

3. Call it from an OpenAI client

   Point the OpenAI client at the local server and add a technique prefix (such as 'moa-') to the model name.

```python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1")

response = client.chat.completions.create(
    model="moa-gpt-4o-mini",
    messages=[{"role": "user", "content": "Solve: If 2x + 3 = 7, what is x?"}]
)
```

## When to use it

- Improving accuracy on math, coding, or logic prompts without switching to a larger model or fine-tuning
- Adding inference-time reasoning techniques to an existing app that already uses an OpenAI-compatible client
- Routing requests across OpenAI, Anthropic, Google, and other providers through one proxy via LiteLLM
- Running self-hosted via Docker behind a corporate proxy with custom CA certificates
