SDK MigrationUpdated 2026-01-22

Switch LlamaIndex to abliteration.ai

Switch LlamaIndex's OpenAI LLM to abliteration.ai by setting api_base. Keep your indexes, retrievers, and query engines unchanged.

LlamaIndex's OpenAI LLM class supports any OpenAI-compatible endpoint via api_base.

Your indexes, retrievers, and query engines work unchanged after the switch.

Definition

Switch LlamaIndex to abliteration.ai

Switching LlamaIndex's base URL means configuring the OpenAI LLM to route requests through an alternative OpenAI-compatible provider.

Why it matters
  • Keep your existing LlamaIndex indexes and query engines unchanged.
  • No changes to document ingestion or retrieval logic.
  • Test alternative models for RAG without rebuilding pipelines.
  • Works with all LlamaIndex query engines and chat engines.
How it works
  1. 01Import OpenAI from llama_index.llms.openai.
  2. 02Set api_base="https://api.abliteration.ai/v1" in the constructor.
  3. 03Replace your OpenAI key with your abliteration.ai API key.
  4. 04Use a supported model id like abliterated-model.
LlamaIndex base URL switch
from llama_index.llms.openai import OpenAI
from llama_index.core import Settings

# Before: OpenAI default
# llm = OpenAI(model="gpt-4")

# After: abliteration.ai
llm = OpenAI(
    model="abliterated-model",
    api_base="https://api.abliteration.ai/v1",
    api_key="YOUR_ABLIT_KEY",
)

# Set as default LLM for all LlamaIndex operations
Settings.llm = llm

# Your query engines work unchanged
response = llm.complete("Summarize this document.")
print(response.text)

# Works with RAG pipelines
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader

documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query("What is the main topic?")
FAQ

Frequently asked questions.

Do my existing indexes still work?

Yes. Indexes store embeddings and document chunks, which are independent of the LLM endpoint.

Does this work with chat engines?

Yes. Chat engines and query engines use the same LLM configuration.

Can I use different LLMs for different tasks?

Yes. Override Settings.llm or pass llm= to specific components for fine-grained control.