optillm
CLAUDE.md4.3k starsChanged 35 days agoApache-2.0View on GitHub
OptiLLM is an OpenAI API compatible optimizing inference proxy that implements state-of-the-art techniques to improve accuracy and performance of LLMs. It focuses on reasoning improvements for coding, logical, and mathematical queries through inference-time compute optimization.
- Reads credentials
- Installs packages
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
OptiLLM is an OpenAI API compatible optimizing inference proxy that implements state-of-the-art techniques to improve accuracy and performance of LLMs. It focuses on reasoning improvements for coding, logical, and mathematical queries through inference-time compute optimization.
Core Architecture
Main Components
- Entry Points:
optillm.py- Main Flask server with inference routingoptillm/inference.py- Local inference engine with transformer models- Setup via
pyproject.tomlwith console scriptoptillm=optillm:main
- Optimization Techniques (
optillm/):- Reasoning:
cot_reflection.py,plansearch.py,leap.py,reread.py - Sampling:
bon.py(Best of N),moa.py(Mixture of Agents),self_consistency.py - Search:
mcts.py(Monte Carlo Tree Search),rstar.py(R* Algorithm) - Verification:
pvg.py(Prover-Verifier Game),z3_solver.py - Advanced:
cepo/(Cerebras Planning & Optimization),rto.py(Round Trip)
- Reasoning:
- Decoding Techniques:
cot_decoding.py- Chain-of-thought without explicit promptingentropy_decoding.py- Adaptive sampling based on token uncertaintythinkdeeper.py- Reasoning effort scalingautothink/- Query complexity classification with steering vectors
- Plugin System (
optillm/plugins/):spl/- System Prompt Learning (third paradigm learning)deepthink/- Gemini-like deep thinking with inference scalinglongcepo/- Long-context processing with divide-and-conquermcp_plugin.py- Model Context Protocol clientmemory_plugin.py- Short-term memory for unbounded contextprivacy_plugin.py- PII anonymization/deanonymizationexecutecode_plugin.py- Code interpreter integrationjson_plugin.py- Structured outputs with outlines library
Development Commands
Installation & Setup
# Development setup
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# Package installation
pip install optillmRunning the Server
# Basic server (auto approach detection)
python optillm.py
# With specific approach
python optillm.py --approach moa --model gpt-4o-mini
# With external endpoint
python optillm.py --base_url http://localhost:8080/v1
# Docker
docker compose up -dTesting
# Run all approach tests
python test.py
# Test specific approaches
python test.py --approaches moa bon mcts
# Test with specific model/endpoint
python test.py --model gpt-4o-mini --base-url http://localhost:8080/v1
# Single test case
python test.py --single-test "specific_test_name"Evaluation Scripts
# Math benchmark evaluation
python scripts/eval_math500_benchmark.py
# AIME benchmark
python scripts/eval_aime_benchmark.py
# Arena Hard Auto evaluation
python scripts/eval_arena_hard_auto_rtc.py
# FRAMES benchmark
python scripts/eval_frames_benchmark.py
# OptiLLM benchmark generation/evaluation
python scripts/gen_optillmbench.py
python scripts/eval_optillmbench.pyUsage Patterns
Approach Selection (Priority Order)
- Model prefix:
moa-gpt-4o-mini(approach slug + model name) - extra_body field:
{"optillm_approach": "bon|moa|mcts"} - Prompt tags:
<optillm_approach>re2</optillm_approach>in system/user prompt
Approach Combinations
- Pipeline (
&):cot_reflection&moa- sequential processing - Parallel (
|):bon|moa|mcts- multiple responses returned as list
Local Inference
- Set
OPTILLM_API_KEY=optillmto enable built-in transformer inference - Supports HuggingFace models with LoRA adapters:
model+lora1+lora2 - Advanced decoding:
{"decoding": "cot_decoding", "k": 10}
Plugin Configuration
- MCP:
~/.optillm/mcp_config.jsonfor Model Context Protocol servers - SPL: Built-in system prompt learning for solving strategies
- Memory: Automatic unbounded context via chunking and retrieval
- GenSelect: Quality-based selection from multiple generated candidates
Key Concepts
Inference Optimization
The proxy intercepts OpenAI API calls and applies optimization techniques before forwarding to LLM providers (OpenAI, Cerebras, Azure, LiteLLM). Each technique implements specific reasoning or sampling improvements.
Plugin Architecture
Plugins extend functionality via standardized interfaces. They can modify requests, process responses, add tools, or provide entirely new capabilities like code execution or structured outputs.
Multi-Provider Support
Automatically detects and routes to appropriate LLM provider based on environment variables (OPENAI_API_KEY, CEREBRAS_API_KEY, etc.) with fallback to LiteLLM for broader model support.
Trending
Quiet since July.thin dataabout the whole repository
Who's talking about algorithmicsuperintelligence/optillm
- A Hacker News story“OptiLLM: Accuracy improvements on reasoning tasks with zero training”Hacker News · Nov 23, 2025 · 2 points
- toejough/engram“recall: per-note usage-outcome (efficacy) tracking — record Step-3 verdicts, rank/prune by them”GitHub · Jul 30, 2026
- PyTorchKR/landscape“[Add] optillm (algorithmicsuperintelligence/optillm)”GitHub · Jun 3, 2026
- Ven0m0/gemini-web-wrapper“TODO”GitHub · Jan 27, 2026
The biggest 4 of 4 mentions linking to the repository that our crawl found. Each line is their own headline.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

