Integrations

FastAPI integration

Proxy abliteration.ai through FastAPI with an async httpx client. OpenAI-compatible chat completions.

Updated 2026-08-04

Create a small FastAPI endpoint that forwards prompts to abliteration.ai.

Keep your ABLIT_KEY in an environment variable and return the JSON response.

from fastapi import FastAPI
from pydantic import BaseModel
import httpx
import os

app = FastAPI()

class ChatIn(BaseModel):
    prompt: str

@app.post("/chat")
async def chat(payload: ChatIn):
    async with httpx.AsyncClient() as client:
        res = await client.post(
            "https://api.abliteration.ai/v1/chat/completions",
            headers={
                "Authorization": f"Bearer {os.environ['ABLIT_KEY']}",
                "Content-Type": "application/json",
            },
            json={
                "model": "abliterated-model",
                "messages": [{"role": "user", "content": payload.prompt}],
            },
        )
    return 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.