DEVSAIO

Vercel AI SDK with a custom OpenAI-compatible provider

Use @ai-sdk/openai-compatible to stream responses from any DEVSAIO model in Next.js.

DEVSAIO team · 1 min read
Share on X

The Vercel AI SDK makes streaming chat UIs in Next.js easy. Its OpenAI-compatible provider works with DEVSAIO.

Install

bash
npm install ai @ai-sdk/openai-compatible

Create the provider

ts
// lib/ai.ts
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

export const devsaio = createOpenAICompatible({
  name: "devsaio",
  baseURL: "https://devsaio.lol/v1",
  apiKey: process.env.DEVSAIO_API_KEY,
});

Generate text

ts
import { generateText } from "ai";
import { devsaio } from "@/lib/ai";

const { text } = await generateText({
  model: devsaio("claude-sonnet-4-6"),
  prompt: "Write a product tagline for a note-taking app.",
});

Stream to the browser (App Router)

ts
// app/api/chat/route.ts
import { streamText } from "ai";
import { devsaio } from "@/lib/ai";

export async function POST(req: Request) {
  const { messages } = await req.json();
  const result = streamText({ model: devsaio("claude-sonnet-4-6"), messages });
  return result.toTextStreamResponse();
}

On the client, read the stream with the SDK's React hooks or a plain fetch reader. The API key stays on the server.

Note: The AI SDK changes quickly between major versions. If a helper name differs in your version, check the SDK docs; the provider setup (name, baseURL, apiKey) stays the same.

Try it with one API key

Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.

Keep reading