> ## Documentation Index
> Fetch the complete documentation index at: https://docs.swarms.world/llms.txt
> Use this file to discover all available pages before exploring further.

# RouteHub overview

> A fast, lightweight LLM gateway with a litellm-compatible API, built on the official OpenAI SDK

RouteHub is the Swarms LLM gateway. It gives you one Python API for 20+ providers, including OpenAI, Anthropic, Gemini, Groq, xAI, DeepSeek, OpenRouter, Mistral, Ollama and any OpenAI-compatible server. Every response is the OpenAI SDK's own type, so the code that reads a GPT response also reads a Claude or Llama response.

RouteHub keeps litellm's function names and module paths, so moving an existing codebase is mostly a change of import. It is built for speed: `import routehub` takes 5.5 ms and the gateway adds 0.004 ms to each call.

```python theme={null}
import routehub

response = routehub.completion(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Summarize our Q3 risks in three bullets."}],
)
print(response.choices[0].message.content)
```

> **[Installation](https://docs.swarms.world/routehub/installation.md)**
>
> Install RouteHub with pip or uv

> **[Quickstart](https://docs.swarms.world/routehub/quickstart.md)**
>
> Make your first call in under a minute

> **[Providers](https://docs.swarms.world/routehub/providers.md)**
>
> Model strings and API key variables for every provider

> **[Migrating from litellm](https://docs.swarms.world/routehub/migrating-from-litellm.md)**
>
> Swap litellm for RouteHub in an existing codebase

## Why RouteHub

| Feature | What it means |
| - | - |
| **One API, every major provider** | Requests use the OpenAI chat format. Responses are `ChatCompletion`, `ChatCompletionChunk` or `CreateEmbeddingResponse`, whichever provider served them. |
| **Built on the official OpenAI SDK** | Retries, timeouts, connection pooling and response types come from OpenAI's client rather than a reimplementation. Works with openai 2.x and 3.x. |
| **First-class Claude support** | RouteHub calls Claude's native Messages API and translates both ways, so prompt caching, extended thinking, tool use, images, PDFs and cached-token usage all work. |
| **No global state** | Retries, TLS verification, timeouts and parameter dropping are arguments to each call. One agent's settings never leak into another's in the same process. |
| **Predictable errors** | Provider failures are raised as typed exceptions such as `RateLimitError` and `ContextWindowExceededError`. Each subclasses the matching OpenAI SDK exception. |
| **Usage and cost visibility** | Token usage comes back in one shape for every provider, including cached and reasoning tokens. `get_model_info` returns per-token prices. |
| **Live model catalog** | Context windows, output limits, prices and capabilities come from OpenRouter's live model list, cached for five minutes and kept on disk for offline runs. |
| **Small supply-chain surface** | Three direct dependencies, `openai`, `pydantic` and `tiktoken`, for 20 installed packages in total. |
| **Testable** | `mock_response` returns realistic responses, streams included, with no network call or API key. |
| **Async throughout** | `acompletion`, `aembedding`, async streams and async model listing, with HTTP clients cached per event loop. |

## Performance

Measured on the same machine (macOS, Python 3.12) against litellm 1.76.1.

| | litellm | RouteHub |
| - | - | - |
| `import` time | 1,027 ms | **5.5 ms** |
| Modules loaded by `import` | 2,332 | **7** |
| Gateway overhead per call | 0.74 ms | **0.004 ms** |
| Installed packages | 58 | **20** |
| Network calls at import | 1 | **none** |

* **Import time** is the median of 7 fresh processes. litellm's GitHub fetch was turned off for its measurement, so the gap is pure import cost. RouteHub loads the OpenAI SDK on the first call, which brings import plus first call to 232 ms.
* **Overhead per call** is the time each gateway adds to a bare OpenAI SDK call, measured against an instant mock server so network time is excluded. It is the median of 300 calls.

Fast startup matters most for serverless functions, CLI tools, test suites and short-lived agent processes, where an import alone can outweigh the work being done.

> [!NOTE]
>
> The full benchmark, covering cold start, per-call overhead, streaming, async throughput and connection reuse against LiteLLM, any-llm, aisuite and the bare provider SDKs, is in the [RouteHub paper](https://github.com/The-Swarm-Corporation/RouteHub/blob/main/docs/routehub.pdf).

## Resources

> **[GitHub](https://github.com/The-Swarm-Corporation/RouteHub)**
>
> Source code and issues

> **[PyPI](https://pypi.org/project/routehub/)**
>
> Released packages

> **[Paper](https://github.com/The-Swarm-Corporation/RouteHub/blob/main/docs/routehub.pdf)**
>
> Design and benchmarks


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.