Integration guide

How to use Vercel AI SDK with an OpenAI-compatible endpoint (TypeScript)

Vercel AI SDK integration guide for TypeScript. Connect to an OpenAI-compatible endpoint with a base URL swap and keep the same request schema.

Updated 2026-01-06

Vercel AI SDK works with OpenAI-compatible APIs by switching the base URL and API key.

This guide shows a TypeScript example plus a test vector you can run to validate responses.

const payload = {
  model: "abliterated-model",
  messages: [{ role: "user", content: "Respond with: Vercel AI SDK TypeScript ready." }],
  temperature: 0.2,
};

const response: Response = 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(payload),
});

if (!response.ok) throw new Error(await response.text());
const data = await response.json();
console.log(data.choices[0].message.content);

Configure Vercel AI SDK

Follow this checklist to point your integration at the OpenAI-compatible endpoint.

OpenAI-compatible payload

Use this request body as a known-good payload before customizing parameters.

{
  "model": "abliterated-model",
  "messages": [
    { "role": "user", "content": "Respond with: Vercel AI SDK TypeScript ready." }
  ],
  "temperature": 0.2
}

Streaming and tool calling readiness

If you stream responses or send tool definitions, keep the OpenAI-compatible schema and validate against the OpenAPI spec.