# algorithmicsuperintelligence/optillm architecture

> Architecture diagram of the GitHub repository algorithmicsuperintelligence/optillm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/algorithmicsuperintelligence/optillm
- Repository: https://github.com/algorithmicsuperintelligence/optillm

## Overview

OptiLLM is an OpenAI-compatible inference proxy: a client submits chat requests, the server selects an optimization approach, that approach may make one or more model calls, and the server returns an OpenAI-shaped response. Techniques span planning, voting, multi-agent reasoning, prompt learning, and long-context research; local inference and multi-provider routing are alternative serving paths. The graph emphasizes documented request routing and explicit source-index references. Several plugin internals are unsampled, so their internal links are omitted.

Main entry points: [`optillm/server.py`](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/server.py) (API server), [`optillm/mars/mars.py`](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/mars/mars.py) (MARS orchestration), [`optillm/bon.py`](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/bon.py) (Best of N), [`optillm/cepo/cepo.py`](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/cepo/cepo.py) (CePO)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_request["Request handling"]
  node_server["API server<br/>[server.py]"]
  node_router["Approach router<br/>[router_plugin.py]"]
end

subgraph group_reasoning["Reasoning techniques"]
  node_bon["Best of N<br/>[bon.py]"]
  node_cepo["CePO<br/>[cepo.py]"]
  node_mars["MARS orchestration<br/>[mars.py]"]
  node_mars_agents["MARS agents<br/>[agent.py]"]
  node_mars_workspace["MARS workspace<br/>[workspace.py]"]
  node_moa["Mixture of agents<br/>[moa.py]"]
  node_mcts["MCTS<br/>[mcts.py]"]
  node_plansearch["PlanSearch<br/>[plansearch.py]"]
  node_pvg["PVG<br/>[pvg.py]"]
  node_rstar["rStar<br/>[rstar.py]"]
  node_rto["RTO<br/>[rto.py]"]
  node_self_consistency["Self consistency"]
  node_z3["Z3 solver<br/>[z3_solver.py]"]
end

subgraph group_plugins["Specialized plugins"]
  node_longcepo["LongCePO<br/>[main.py]"]
  node_spl["Prompt learning<br/>[main.py]"]
  node_research["Deep research<br/>[research_engine.py]"]
  node_web_search["Web search"]
end

subgraph group_serving["Inference and providers"]
  node_local_inference["Local inference<br/>[inference.py]"]
  node_proxy_client["Provider proxy<br/>[client.py]"]
end

subgraph group_state["Logging and state"]
  node_conversation_log[("Conversation logger")]
end

node_client(("OpenAI client"))
node_provider["LLM provider"]

node_client -->|"sends request"| node_server
node_server -->|"selects approach"| node_router
node_server -->|"dispatches to"| node_bon
node_server -->|"dispatches to"| node_cepo
node_server -->|"dispatches to"| node_mars
node_server -->|"dispatches to"| node_moa
node_server -->|"dispatches to"| node_mcts
node_server -->|"dispatches to"| node_plansearch
node_server -->|"dispatches to"| node_pvg
node_server -->|"dispatches to"| node_rstar
node_server -->|"dispatches to"| node_rto
node_server -->|"dispatches to"| node_self_consistency
node_server -->|"dispatches to"| node_z3
node_server -->|"serves locally"| node_local_inference
node_server -.->|"uses provider proxy"| node_proxy_client
node_proxy_client -->|"forwards requests"| node_provider
node_server -.->|"dispatches to"| node_longcepo
node_server -.->|"dispatches to"| node_spl
node_server -.->|"dispatches to"| node_research
node_research -->|"searches sources"| node_web_search
node_mars -->|"runs agents"| node_mars_agents
node_mars -->|"uses workspace"| node_mars_workspace
node_server -.->|"records requests"| node_conversation_log
node_bon -.->|"generates candidates"| node_provider
node_cepo -->|"requests completions"| node_provider
node_plansearch -->|"requests completions"| node_provider
node_client -->|"receives response"| node_server

click node_server "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/server.py"
click node_router "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/router_plugin.py"
click node_bon "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/bon.py"
click node_cepo "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/cepo/cepo.py"
click node_mars "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/mars/mars.py"
click node_mars_agents "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/mars/agent.py"
click node_mars_workspace "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/mars/workspace.py"
click node_moa "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/moa.py"
click node_mcts "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/mcts.py"
click node_plansearch "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plansearch.py"
click node_pvg "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/pvg.py"
click node_rstar "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/rstar.py"
click node_rto "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/rto.py"
click node_self_consistency "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/self_consistency.py"
click node_z3 "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/z3_solver.py"
click node_longcepo "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/longcepo/main.py"
click node_spl "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/spl/main.py"
click node_research "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/deep_research/research_engine.py"
click node_web_search "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/web_search_plugin.py"
click node_local_inference "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/inference.py"
click node_proxy_client "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/proxy/client.py"
click node_conversation_log "https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/conversation_logger.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_router,node_client toneBlue
class node_bon,node_cepo,node_mars,node_mars_agents,node_mars_workspace,node_moa,node_mcts,node_plansearch,node_pvg,node_rstar,node_rto,node_self_consistency,node_z3 toneAmber
class node_longcepo,node_spl,node_research,node_web_search toneMint
class node_local_inference,node_proxy_client toneRose
class node_conversation_log,node_provider toneIndigo
```

## Components

### Request handling

- [API server](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/server.py): `optillm/server.py`
- [Approach router](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/router_plugin.py): `optillm/plugins/router_plugin.py`

### Reasoning techniques

- [Best of N](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/bon.py): `optillm/bon.py`
- [CePO](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/cepo/cepo.py): `optillm/cepo/cepo.py`
- [MARS orchestration](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/mars/mars.py): `optillm/mars/mars.py`
- [MARS agents](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/mars/agent.py): `optillm/mars/agent.py`
- [MARS workspace](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/mars/workspace.py): `optillm/mars/workspace.py`
- [Mixture of agents](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/moa.py): `optillm/moa.py`
- [MCTS](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/mcts.py): `optillm/mcts.py`
- [PlanSearch](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plansearch.py): `optillm/plansearch.py`
- [PVG](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/pvg.py): `optillm/pvg.py`
- [rStar](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/rstar.py): `optillm/rstar.py`
- [RTO](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/rto.py): `optillm/rto.py`
- [Self consistency](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/self_consistency.py): `optillm/self_consistency.py`
- [Z3 solver](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/z3_solver.py): `optillm/z3_solver.py`

### Specialized plugins

- [LongCePO](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/longcepo/main.py): `optillm/plugins/longcepo/main.py`
- [Prompt learning](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/spl/main.py): `optillm/plugins/spl/main.py`
- [Deep research](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/deep_research/research_engine.py): `optillm/plugins/deep_research/research_engine.py`
- [Web search](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/web_search_plugin.py): `optillm/plugins/web_search_plugin.py`

### Inference and providers

- [Local inference](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/inference.py): `optillm/inference.py`
- [Provider proxy](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/plugins/proxy/client.py): `optillm/plugins/proxy/client.py`

### Logging and state

- [Conversation logger](https://github.com/algorithmicsuperintelligence/optillm/blob/main/optillm/conversation_logger.py): `optillm/conversation_logger.py`

### Other components

- **OpenAI client**
- **LLM provider**

## Connections

- OpenAI client → API server: sends request (evidence: `README.md`)
- API server → Approach router: selects approach (evidence: `optillm/server.py`)
- API server → Best of N: dispatches to (evidence: `optillm/server.py`)
- API server → CePO: dispatches to (evidence: `optillm/server.py`)
- API server → MARS orchestration: dispatches to (evidence: `optillm/server.py`)
- API server → Mixture of agents: dispatches to (evidence: `optillm/server.py`)
- API server → MCTS: dispatches to (evidence: `optillm/server.py`)
- API server → PlanSearch: dispatches to (evidence: `optillm/server.py`)
- API server → PVG: dispatches to (evidence: `optillm/server.py`)
- API server → rStar: dispatches to (evidence: `optillm/server.py`)
- API server → RTO: dispatches to (evidence: `optillm/server.py`)
- API server → Self consistency: dispatches to (evidence: `optillm/server.py`)
- API server → Z3 solver: dispatches to (evidence: `optillm/server.py`)
- API server → Local inference: serves locally (evidence: `optillm/inference.py`)
- API server → Provider proxy: uses provider proxy (evidence: `optillm/server.py`)
- Provider proxy → LLM provider: forwards requests (evidence: `README.md`)
- API server → LongCePO: dispatches to
- API server → Prompt learning: dispatches to
- API server → Deep research: dispatches to
- Deep research → Web search: searches sources (evidence: `optillm/plugins/deep_research/research_engine.py`)
- MARS orchestration → MARS agents: runs agents (evidence: `optillm/mars/mars.py`)
- MARS orchestration → MARS workspace: uses workspace (evidence: `optillm/mars/mars.py`)
- API server → Conversation logger: records requests (evidence: `optillm/server.py`)
- Best of N → LLM provider: generates candidates
- CePO → LLM provider: requests completions (evidence: `optillm/cepo/cepo.py`)
- PlanSearch → LLM provider: requests completions (evidence: `optillm/plansearch.py`)
- OpenAI client → API server: receives response (evidence: `README.md`)
