Docs

Cloudflare Workers integration

Call abliteration.ai from a Cloudflare Worker using fetch. Store your API key in env and call /v1/chat/completions.

Updated 2025-12-24

Cloudflare Workers can call the OpenAI-compatible endpoint using fetch inside the fetch handler.

Store your API key in a Worker secret and forward requests directly to /v1/chat/completions.

export default {
  async fetch(request, env) {
    const res = await fetch("https://api.abliteration.ai/v1/chat/completions", {
      method: "POST",
      headers: {
        "Authorization": "Bearer " + env.ABLIT_KEY,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        model: "abliterated-model",
        messages: [{ role: "user", content: "Hello from Workers." }],
      }),
    });

    return new Response(await res.text(), {
      status: res.status,
      headers: { "content-type": "application/json" },
    });
  },
};