Vercel AI SDK
TypeScript toolkit for AI apps, through its OpenAI-compatible provider. Step-by-step setup with Laras Router.
This guide connects Vercel AI SDK to Laras Router. Every step was checked against the Vercel AI SDK documentation.
You need an API key (lr_live_…) and a topped-up balance. New to Laras Router? Start with the Quickstart.
Set up
Install the packages
Install the AI SDK and the OpenAI-compatible provider.
npm install ai @ai-sdk/openai-compatible
Set your API key
Put your key in an environment variable.
export LARAS_API_KEY="lr_live_your_key_here"
Generate text
Create the provider and generate text.
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";
const laras = createOpenAICompatible({
name: "larasrouter",
baseURL: "https://api.larasrouter.com/v1",
apiKey: process.env.LARAS_API_KEY,
});
const { text } = await generateText({
model: laras("deepseek-v4.1-flash"),
prompt: "Hello!",
});
console.log(text);
Good to know
- Use
@ai-sdk/openai-compatible. Since AI SDK 5, the@ai-sdk/openaiprovider calls the Responses API by default. - For streaming, use
streamText. To receive token usage while streaming, setincludeUsage: truewhen you create the provider.
Settings and screens can change between versions. If something looks different, check the Vercel AI SDK documentation. For other tools, see all integrations.
Was this page helpful?
Updated Nov 2026