Integrations

Use uncensored models with the Vercel AI SDK

createOpenAICompatible with the Chainless base URL. If you use @ai-sdk/openai instead, call .chat() because it defaults to the Responses API.

The AI SDK has a provider made for OpenAI-compatible APIs. It is the simplest way to use Chainless from Next.js, Node or edge runtimes.

shell
npm install ai @ai-sdk/openai-compatible
typescript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { streamText } from "ai";

const chainless = createOpenAICompatible({
  name: "chainless",
  baseURL: "https://chainless.one/v1",
  apiKey: process.env.CHAINLESS_API_KEY,
  includeUsage: true,
});

const result = streamText({
  model: chainless("kimi-k3.1-pro-uncensored"),
  prompt: "Draft a responsible disclosure email for an IDOR in a customer portal.",
});

for await (const part of result.textStream) process.stdout.write(part);
console.log(await result.usage);

The key is sent as Authorization: Bearer. includeUsage defaults to false; turn it on to get token counts from streams.

Alternative: @ai-sdk/openai with .chat()

typescript
import { createOpenAI } from "@ai-sdk/openai";

const chainless = createOpenAI({ name: "chainless", baseURL: "https://chainless.one/v1", apiKey: process.env.CHAINLESS_API_KEY });
const model = chainless.chat("glm-5.3-fast-uncensored"); // not chainless("…"): that targets /responses

createOpenAI also reads OPENAI_BASE_URL and OPENAI_API_KEY from the environment, which is easy to mix up with a real OpenAI setup. The compatible provider avoids that.

In a Next.js app

Create the provider in server code only (a route handler or server action) and stream the result to the client with the AI SDK UI helpers of your installed version. Keep the key on the server. Model ids and limits: /models; request details: /docs/api.

Sources

Checked against the official documentation on 2026-11-29. Tools change their settings often; if a field moved, the source below is the reference.

Other tools

Questions

Why does createOpenAI fail with a 404?

Since AI SDK 5, the openai provider calls the Responses API by default. Chainless serves Chat Completions only, so create models with chainless.chat('model-id') or use @ai-sdk/openai-compatible.

How do I get token usage when streaming?

Pass includeUsage: true to createOpenAICompatible. The SDK then asks for the final usage chunk, and result.usage resolves with the counts.

Do tools and generateObject work?

Tools work: every public Chainless model accepts OpenAI-format tool definitions. For structured output, prefer tool-based or JSON-mode approaches and validate the result.