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

# LlamaIndex

> Route + trace LlamaIndex LLM calls through Orbitrage.

LlamaIndex's built-in `OpenAI` LLM validates model names against OpenAI's
catalog, so for gateway models (`minimax-m3`, `glm-5.2`, `auto`) use
**`OpenAILike`** — it skips that validation and speaks the same OpenAI API.

## Install

```bash theme={null}
pip install -U orbitrage llama-index-core llama-index-llms-openai-like
```

## Setup

```python theme={null}
import os, orbitrage
orbitrage.init(os.environ["ORBITRAGE_API_KEY"], user_id="customer_42")

from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="minimax-m3",                             # direct model — or "glm-5.2"; "auto" to route
    api_base="https://api.orbitrage.ai/v1",
    api_key=os.environ["ORBITRAGE_API_KEY"],
    default_headers={"x-orbitrage-end-user-id": "customer_42"},
    is_chat_model=True,
    context_window=8000,
    max_tokens=512,
)

print(llm.complete("Summarize what an LLM router does, in one sentence."))
```

Use it anywhere LlamaIndex takes an LLM — `Settings.llm = llm`, query engines,
chat engines, agents — and every call is routed and traced.

## Managed tools (server-side, no keys)

Pass [managed tools](/concepts/tools-gateway) by name as a `tools` kwarg to
`chat()` — Orbitrage runs them server-side and returns the final answer.

```python theme={null}
from llama_index.core.llms import ChatMessage

resp = llm.chat(
    [ChatMessage(role="user", content="Use the calculator to compute 1234*5678. Only the number.")],
    tools=["calculator_orbitrage", "tavily_orbitrage"],
)
print(resp)   # assistant: 7006652
```

<Note>
  If you use the standard `llama_index.llms.openai.OpenAI` class, it only accepts
  OpenAI model ids (e.g. `gpt-oss-20b`) — those still route through the gateway,
  but for open-weight ids like `minimax-m3` / `glm-5.2`, or for `auto`, prefer
  `OpenAILike` as shown above.
</Note>
