Integrations

AWS Lambda integration

Call abliteration.ai from AWS Lambda with a minimal handler and fetch.

Updated 2026-01-03

Use a Lambda handler to receive an API Gateway payload and forward it.

Return the JSON from abliteration.ai with the status code preserved.

export const handler = async (event) => {
  const { prompt = "Hello from Lambda." } = JSON.parse(event.body || "{}");
  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 }],
    }),
  });

  const data = await res.json();
  return { statusCode: res.status, body: JSON.stringify(data) };
};