Skip to content
On this page

Integrations

Vercel AI SDK

Use RelayRouter with the AI SDK through a custom [OI] base URL.

The AI SDK's [OI] provider accepts a baseURL. That is all you need to route generations, streams, tools, and structured output through RelayRouter.

Install

npm install ai @ai-sdk/openai

Usage

import { create[OI] } from "@ai-sdk/openai";
import { streamText } from "ai";
const relay = create[OI]({
baseURL: "https://api.relayrouter.org/v1",
apiKey: process.env.RELAY_API_KEY!,
});
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: relay("deepseek-v4.1-flash"),
messages,
});
return result.toTextStreamResponse();
}

Model ids

relay("…") takes any id from the catalog. The AI SDK sends the id unchanged.