Deno
Deno 2 and Deno Deploy with an OpenAI-compatible uncensored API
Call Abliterator from Deno 2 with npm:openai and narrow permissions, stream tokens from Deno.serve, and run a deno serve app with --parallel workers.
Import OpenAI from "npm:openai", construct it with baseURL "https://abliterator.ai/v1" and apiKey Deno.env.get("ABL_API_KEY"), and run with --allow-net and --allow-env=ABL_API_KEY.
Deno 2 runs npm packages directly, so the official openai package works with an npm: import, and Deno.serve handles HTTP. Deno was not installed on the machine used to check this page, so the code was type-checked with tsc --strict against the Deno 2.7 type definitions and run under Node with a small Deno stand-in.
Setup
export ABL_API_KEY="sk-abl-v1-..."
deno add npm:openai
deno add records the dependency in deno.json, so code can import "openai" or "npm:openai".
A script with narrow permissions
import OpenAI from "npm:openai";
const abliterator = new OpenAI({
baseURL: "https://abliterator.ai/v1",
apiKey: Deno.env.get("ABL_API_KEY"),
});
const completion = await abliterator.chat.completions.create({
model: "kimi-k3.1-pro-abliterated",
messages: [
{ role: "system", content: "You are an OSINT analyst who explains methods and their limits." },
{ role: "user", content: "How do analysts attribute a phishing domain to earlier campaigns using passive DNS?" },
],
});
console.log(completion.choices[0].message.content);
deno run --allow-net --allow-env=ABL_API_KEY ask.ts
Narrow --allow-net to the host name in https://abliterator.ai/v1 (for example --allow-net=api.example.com) so the script cannot reach anything else.
Stream from Deno.serve
Return a ReadableStream in the Response and enqueue text as it arrives. req.signal aborts the upstream call when the client disconnects:
import OpenAI from "npm:openai";
const abliterator = new OpenAI({ baseURL: "https://abliterator.ai/v1", apiKey: Deno.env.get("ABL_API_KEY") });
const encoder = new TextEncoder();
Deno.serve({ port: 8000 }, async (req) => {
if (req.method !== "POST") return new Response("POST a JSON body with a prompt", { status: 405 });
const { prompt } = (await req.json()) as { prompt: string };
const stream = await abliterator.chat.completions.create(
{ model: "deepseek-v4.1-flash-abliterated", messages: [{ role: "user", content: prompt }], stream: true },
{ signal: req.signal },
);
const body = new ReadableStream<Uint8Array>({
async start(controller) {
try {
for await (const chunk of stream) {
const text = chunk.choices[0]?.delta?.content;
if (text) controller.enqueue(encoder.encode(`data: ${JSON.stringify(text)}\n\n`));
}
controller.enqueue(encoder.encode("data: [DONE]\n\n"));
} catch {
// client went away or upstream failed; end the response
}
controller.close();
},
});
return new Response(body, { headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache" } });
});
Passing { signal: req.signal } as the request option ties the Abliterator request to the incoming one.
deno serve with parallel workers
Deno 2 can serve a module whose default export has a fetch handler. deno serve --parallel starts one worker per CPU core, each with its own client:
import OpenAI from "npm:openai";
const abliterator = new OpenAI({ baseURL: "https://abliterator.ai/v1", apiKey: Deno.env.get("ABL_API_KEY") });
export default {
async fetch(req) {
const url = new URL(req.url);
if (url.pathname !== "/classify") return new Response("not found", { status: 404 });
const text = await req.text();
const r = await abliterator.chat.completions.create({
model: "deepseek-v4.1-flash-abliterated",
messages: [
{ role: "system", content: "Label the message for a moderation dataset: spam, scam, harassment or ok. Reply with the label only." },
{ role: "user", content: text },
],
max_tokens: 5,
});
const cost = (r.usage as { cost?: number } | undefined)?.cost;
return Response.json({ label: r.choices[0].message.content?.trim(), cost });
},
} satisfies Deno.ServeDefaultExport;
deno serve --parallel --allow-net --allow-env=ABL_API_KEY classify.ts
satisfies Deno.ServeDefaultExport gives the handler its types. The cast on usage is needed because Abliterator's cost field is not in the SDK's types. Keep total concurrency within your plan's limit (/pricing); more workers do not raise it.
Troubleshooting
NotCapable: Requires env access to "ABL_API_KEY". Add--allow-env=ABL_API_KEY. Prompts forOPENAI_*variables come from the SDK probing defaults; answer no, or add--no-promptto deny them silently.NotCapable: Requires net access. The--allow-netlist does not include Abliterator's host. Check the host inhttps://abliterator.ai/v1.deno checkfails onusage.cost. Cast as in the example, or read theX-Abl-Cost-Usdheader with.withResponse().- 404 on
/v1/responses. Usechat.completions; Abliterator does not serve the Responses API. - Old
deno.land/xOpenAI ports. Unofficial ports lag behind. Usenpm:openai.
Frequently asked questions
Which permissions does an Abliterator client need in Deno?
Network access to Abliterator's host and read access to one environment variable: --allow-net=<Abliterator host> --allow-env=ABL_API_KEY. The SDK also probes a few OPENAI_* variables; denying them is safe because it treats unreadable variables as unset.
Should I import openai from npm: or JSR?
npm:openai is the official package and works unchanged in Deno 2. Pin a major version in deno.json imports so updates are deliberate.
Does this work on Deno Deploy?
Yes. Set ABL_API_KEY in the project's environment variables; Deno.env.get reads it, and Deno.serve or a default export with fetch handles requests the same way.