# Vercel AI SDK

Stream a server-side chat through the OpenAI-compatible provider adapter.

> Verification: source-checked; checked 2026-09-01; Vercel AI SDK OpenAI-compatible provider

## 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.

```typescript
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.

## Upstream documentation

- [Vercel AI SDK OpenAI-compatible providers](https://ai-sdk.dev/providers/openai-compatible-providers)
