Vercel's AI SDK has a first-class OpenAI provider that accepts a baseURL. Configure it for AIgateway and every AI SDK feature — streamText, generateObject, tool calling — works against any of our 100+ models.
Create a custom OpenAI client pointed at AIgateway and use it everywhere.
import { createOpenAI } from "@ai-sdk/openai";
import { streamText } from "ai";
const ai = createOpenAI({
baseURL: "https://api.aigateway.sh/v1",
apiKey: process.env.AIGATEWAY_API_KEY,
});
const result = await streamText({
model: ai("anthropic/claude-opus-4.7"),
prompt: "hello",
});