Integrations

Next.js integration

Call abliteration.ai from a Next.js Route Handler with a minimal fetch wrapper. OpenAI-compatible /v1/chat/completions.

Updated 2026-08-04

Use a Next.js Route Handler or server action to keep your API key server-side.

Forward the incoming prompt to the OpenAI-compatible /v1/chat/completions endpoint.

import { NextResponse } from "next/server";

export async function POST(req: Request) {
  const { prompt } = await req.json();
  const res = await fetch("https://api.abliteration.ai/v1/chat/completions", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.ABLIT_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "abliterated-model",
      messages: [{ role: "user", content: prompt }],
    }),
  });

  return NextResponse.json(await res.json());
}
FAQ

Frequently asked questions.

How do I fix a 401 Unauthorized error from abliteration.ai?

Check that your API key is set and sent as a Bearer token.

How do I fix a 404 Not Found error from abliteration.ai?

Make sure the base URL ends with /v1 and you call /chat/completions.

How do I fix a 400 Bad Request error from abliteration.ai?

Verify the model id and that messages are an array of { role, content } objects.

How do I fix a 429 Rate limit error from abliteration.ai?

Back off and retry. Use the Retry-After header for pacing.