integrations/sdk/LlamaIndex

LlamaIndex + AIgateway

RAG framework — point its OpenAI provider at AIgateway.

LlamaIndex's OpenAI integration accepts a custom api_base. Use it to route every embedding, completion, and chat call through AIgateway.

LlamaIndex homepage →
Setup

Three steps or fewer.

STEP 01

Python

Use OpenAILike (not the OpenAI class — it rejects provider/slug model ids against a hardcoded map). is_chat_model=True is required, or it 404s on the completions route.

# pip install llama-index-llms-openai-like
from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="anthropic/claude-sonnet-4.6",
    api_base="https://api.aigateway.sh/v1",
    api_key="sk-aig-...",
    context_window=128000,
    is_chat_model=True,
    is_function_calling_model=True,
)

resp = llm.complete("hello")
STEP 02

Embeddings

Same pattern — use OpenAILikeEmbedding with api_base set, then any embedding model from our catalog (e.g. baai/bge-m3).

# pip install llama-index-embeddings-openai-like
from llama_index.embeddings.openai_like import OpenAILikeEmbedding

embed = OpenAILikeEmbedding(
    model_name="baai/bge-m3",
    api_base="https://api.aigateway.sh/v1",
    api_key="sk-aig-...",
)
More integrations

Same key. Every other tool.