LlamaIndex
LlamaIndex can use OdiRouter through OpenAI-compatible LLM clients. Set the API key, API base, and OdiRouter model ID.
Requirements
Section titled “Requirements”| Requirement | Value |
|---|---|
| Python | 3.10+ |
| Package | LlamaIndex OpenAI LLM integration |
| API base | https://www.odirouter.ai/v1 |
| API Key | OdiRouter API key |
| Model | An OdiRouter LLM model ID |
Install
Section titled “Install”pip install llama-index llama-index-llms-openaiConfigure LLM
Section titled “Configure LLM”import os
from llama_index.llms.openai import OpenAI
llm = OpenAI( model="gpt-5.5", api_key=os.environ["ODIROUTER_API_KEY"], api_base="https://www.odirouter.ai/v1",)Complete Text
Section titled “Complete Text”response = llm.complete("Reply with a one-line LlamaIndex integration test.")
print(response.text)Use With Settings
Section titled “Use With Settings”from llama_index.core import Settings
Settings.llm = llmUse separate embedding settings unless your selected OdiRouter model and LlamaIndex integration explicitly support embeddings.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Fix |
|---|---|
| Requests go to OpenAI | Confirm api_base is set to https://www.odirouter.ai/v1 |
401 response | Set ODIROUTER_API_KEY in the server environment |
| Model not found | Use an exact model ID from /models |
| RAG app fails during embedding | Configure embeddings separately from the OdiRouter LLM client |