Integrations

Vercel AI SDK

TypeScript toolkit for AI apps, through its OpenAI-compatible provider. Step-by-step setup with Laras Router.

On this page

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.

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

Set your API key

Put your key in an environment variable.

Shell
export LARAS_API_KEY="lr_live_your_key_here"

Generate text

Create the provider and generate text.

TypeScript
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-flash"),
  prompt: "Hello!",
});
console.log(text);

Good to know

  • Use @ai-sdk/openai-compatible. Since AI SDK 5, the @ai-sdk/openai provider calls the Responses API by default.
  • For streaming, use streamText. To receive token usage while streaming, set includeUsage: true when 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.