LlamaIndex.TS
LlamaIndex.TS with an OpenAI-compatible uncensored API
Point LlamaIndex.TS at Abliterator with the @llamaindex/openai OpenAI class and baseURL, stream chat, fix the 1,024-token context default and run a tool agent.
Set Settings.llm = new OpenAI({ model: "kimi-k3.1-pro-abliterated", baseURL: "https://abliterator.ai/v1", apiKey: process.env.ABL_API_KEY }) from @llamaindex/openai, and override metadata.contextWindow so memory is not cut to 1,024 tokens.
LlamaIndex.TS reaches OpenAI-compatible servers through the OpenAI class in @llamaindex/openai, which takes a baseURL option as shown in the LlamaIndex.TS OpenAI guide. Examples were type-checked with tsc --strict and run on Node 22 with llamaindex 0.12, @llamaindex/openai 0.4 and @llamaindex/workflow 1.1.
Install
npm install llamaindex @llamaindex/openai @llamaindex/workflow zod
export ABL_API_KEY="sk-abl-v1-..."
Configure the LLM
import { OpenAI } from "@llamaindex/openai";
import { Settings } from "llamaindex";
class AblOpenAI extends OpenAI {
get metadata() {
return { ...super.metadata, contextWindow: 1_048_576 };
}
}
Settings.llm = new AblOpenAI({
model: "kimi-k3.1-pro-abliterated",
baseURL: "https://abliterator.ai/v1",
apiKey: process.env.ABL_API_KEY,
maxTokens: 2048,
});
const response = await Settings.llm.chat({
messages: [
{ role: "system", content: "You are a cloud security reviewer." },
{ role: "user", content: "List the IAM misconfigurations you would check first in an AWS account audit." },
],
});
console.log(response.message.content);
Why the subclass: for model names it does not know, the OpenAI class reports contextWindow: 1024. Memory sizes itself at 75% of that, so an agent forgets everything past about 768 tokens of history. Both Abliterator models accept 1,048,576 tokens, and overriding metadata fixes every component that reads it.
Streaming
Pass stream: true to chat() and iterate. Each chunk's delta is the new text:
import { OpenAI } from "@llamaindex/openai";
const llm = new OpenAI({
model: "deepseek-v4.1-flash-abliterated",
baseURL: "https://abliterator.ai/v1",
apiKey: process.env.ABL_API_KEY,
});
const stream = await llm.chat({
messages: [{ role: "user", content: "Explain what a canary token is and where to plant them in a network." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.delta);
}
process.stdout.write("\n");
A tool agent with @llamaindex/workflow
agent() builds a single-agent workflow that calls tools through native function calling. tool() takes a Zod schema for the arguments:
import { OpenAI } from "@llamaindex/openai";
import { agent, agentStreamEvent, agentToolCallEvent } from "@llamaindex/workflow";
import { tool } from "llamaindex";
import { z } from "zod";
class AblOpenAI extends OpenAI {
get metadata() {
return { ...super.metadata, contextWindow: 1_048_576 };
}
}
const llm = new AblOpenAI({ model: "kimi-k3.1-pro-abliterated", baseURL: "https://abliterator.ai/v1", apiKey: process.env.ABL_API_KEY });
const findSecrets = tool({
name: "scan_repo_for_secrets",
description: "Return findings from the last secret-scanning run on a repository.",
parameters: z.object({ repo: z.string() }),
execute: ({ repo }) => `${repo}: 2 AWS access keys in config/old.env (commit 4f2a9c1), 1 Slack webhook in README`,
});
const reviewer = agent({
llm,
tools: [findSecrets],
systemPrompt: "You triage secret-scanning results and recommend rotation steps.",
});
const events = reviewer.runStream("Check acme/payments-api and tell me what to rotate first.");
for await (const event of events) {
if (agentToolCallEvent.include(event)) console.log(`\n[tool] ${event.data.toolName}`);
if (agentStreamEvent.include(event)) process.stdout.write(event.data.delta);
}
process.stdout.write("\n");
Use await reviewer.run(...) instead of runStream when you only need the final answer; it resolves to an event whose data.result holds the reply.
Troubleshooting
- Agent loses earlier turns. The context window override is missing, so memory is capped near 768 tokens. Use the
AblOpenAIsubclass or setSettings.llmto an instance of it. - 404 on
/v1/responses. You usedopenaiResponses(). Switch tonew OpenAI(...). baseURLignored. It must be a top-level option on theOpenAIclass (unlike LangChain.js, which nests it underconfiguration).OPENAI_BASE_URLin the environment is used only when the option is absent.- Embeddings fail. Abliterator has no embeddings endpoint. Set
Settings.embedModelto a separate embedding provider and keepSettings.llmon Abliterator. reasoningEfforttype errors. The class types it as"low" | "medium" | "high" | "minimal". See /docs/reasoning for how Abliterator handles reasoning effort.
Frequently asked questions
Does LlamaIndex.TS need an OpenAILike class like Python?
No. The TypeScript OpenAI class accepts any model string and a baseURL. It only uses its built-in model table for metadata, which is why the context window needs the override shown on this page.
Will agents use native tool calling with Abliterator models?
Yes. supportToolCall is true for any model name that is not an old OpenAI snapshot or o1, so agent() sends tools through Chat Completions function calling.
Can I use openaiResponses() from @llamaindex/openai?
No. openaiResponses targets the OpenAI Responses API, which Abliterator does not serve. Use the OpenAI class, which calls Chat Completions.