Integration guide
Vercel AI SDK
Stream a server-side chat through the OpenAI-compatible provider adapter.
Create the provider
Keep this code in a server route or server action. Never expose a Laminarity key through a browser bundle or a NEXT_PUBLIC_* variable.
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { streamText } from "ai";
const laminarity = createOpenAICompatible({
name: "laminarity",
apiKey: process.env.LAMINARITY_API_KEY!,
baseURL: "https://api.laminarity.ai/v1",
includeUsage: true,
});
export async function POST(request: Request) {
const { messages } = await request.json();
const result = streamText({
model: laminarity("auto"),
messages,
});
return result.toUIMessageStreamResponse();
}Model choice
Use laminarity("auto") for routing and fallback. Use a concrete id returned by /v1/models only when the application intentionally pins a provider model.