LlamaIndex

LlamaIndex Python with an OpenAI-compatible uncensored API

Connect LlamaIndex to Abliterator with OpenAILike: the api_base, is_chat_model and context_window settings, streaming chat, and a FunctionAgent with tools.

Reviewed LlamaIndexPython

Quick answer

Use OpenAILike(model="kimi-k3.1-pro-abliterated", api_base="https://abliterator.ai/v1", api_key=..., is_chat_model=True, is_function_calling_model=True, context_window=1048576). The plain OpenAI class rejects non-OpenAI model names.

LlamaIndex ships a wrapper for OpenAI-compatible servers, OpenAILike, in its own package. It reuses the OpenAI client but lets you declare the model's capabilities yourself. Tested with llama-index-core 0.14 and llama-index-llms-openai-like 0.9.

Install

pip install llama-index-core llama-index-llms-openai-like
export ABL_API_KEY="sk-abl-v1-..."

Configure OpenAILike

import os

from llama_index.core.llms import ChatMessage
from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="kimi-k3.1-pro-abliterated",
    api_base="https://abliterator.ai/v1",
    api_key=os.environ["ABL_API_KEY"],
    is_chat_model=True,
    is_function_calling_model=True,
    context_window=1048576,
    max_tokens=2048,
)

response = llm.chat(
    [
        ChatMessage(role="system", content="You are a digital forensics instructor."),
        ChatMessage(role="user", content="Walk through the order of volatility for evidence collection on a live Linux host."),
    ]
)
print(response.message.content)

Three flags matter:

Setting Why
is_chat_model=True Sends /chat/completions. The default False calls /completions, which Abliterator does not serve.
is_function_calling_model=True Lets agents and structured_predict use native tool calls.
context_window=1048576 Both Abliterator models take 1,048,576 tokens. The default of 3,900 makes LlamaIndex truncate retrieved context and chat memory far too early.

To make it the default for indexes and query engines, assign it once: Settings.llm = llm (from llama_index.core import Settings).

Streaming

stream_chat yields responses whose delta is the new text:

import os

from llama_index.core.llms import ChatMessage
from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="deepseek-v4.1-flash-abliterated",
    api_base="https://abliterator.ai/v1",
    api_key=os.environ["ABL_API_KEY"],
    is_chat_model=True,
    context_window=1048576,
)

for part in llm.stream_chat([ChatMessage(role="user", content="Explain how a SIEM correlation rule differs from a single-event alert.")]):
    print(part.delta, end="", flush=True)
print()

Use astream_chat with async for inside async code. Query engines stream the same way with as_query_engine(streaming=True).

A FunctionAgent with tools

FunctionAgent from the workflow agents module calls tools through the model's native function calling. Plain Python functions become tools from their signature and docstring:

import asyncio
import os

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai_like import OpenAILike


def get_open_ports(host: str) -> str:
    """Return the open ports recorded for a host in the last authorized scan."""
    return f"{host}: 22/tcp OpenSSH 8.9, 443/tcp nginx 1.24, 6379/tcp Redis (no auth)"


llm = OpenAILike(
    model="kimi-k3.1-pro-abliterated",
    api_base="https://abliterator.ai/v1",
    api_key=os.environ["ABL_API_KEY"],
    is_chat_model=True,
    is_function_calling_model=True,
    context_window=1048576,
)

agent = FunctionAgent(
    tools=[get_open_ports],
    llm=llm,
    system_prompt="You prioritize findings from authorized network scans.",
)


async def main() -> None:
    result = await agent.run(user_msg="What is the riskiest exposure on 10.0.4.12, and why?")
    print(result)


asyncio.run(main())

FunctionAgent streams by default; iterate handler.stream_events() on the object returned by agent.run(...) to show tokens and tool calls as they happen.

Troubleshooting

  • ValueError: Unknown model 'kimi-k3.1-pro-abliterated'. Please provide a valid OpenAI model name. You used llama_index.llms.openai.OpenAI. Switch to OpenAILike.
  • NotFoundError: 404 on /v1/completions. is_chat_model is missing or False.
  • Answers ignore most of your documents. context_window is still the 3,900-token default, so the prompt helper drops chunks to fit. Set it to 1048576 or to the budget you want to pay for.
  • ValueError: LLM must be a FunctionCallingLLM from FunctionAgent. Add is_function_calling_model=True.
  • Embeddings. Abliterator does not serve an embeddings endpoint. Keep a separate embedding model (local or another provider) in Settings.embed_model; only the LLM points at Abliterator.

Frequently asked questions

Why not use llama_index.llms.openai.OpenAI with api_base?

That class looks the model name up in a table of OpenAI models to find its context window, and raises ValueError: Unknown model for anything else. OpenAILike skips the lookup and takes the context window from you.

What happens if I forget is_chat_model=True?

OpenAILike defaults to the legacy completions endpoint and flattens your messages into one prompt. Abliterator has no /v1/completions route, so you get a 404. Set is_chat_model=True.

Does FunctionAgent need anything extra for Abliterator?

Only is_function_calling_model=True on the LLM. Without it LlamaIndex treats the model as unable to call tools, and FunctionAgent fails with ValueError: LLM must be a FunctionCallingLLM.