Vercel AI SDK

One /v1 endpoint for every provider. Point your OpenAI client at a new base URL and key, bring your own provider keys, and pay 0% markup on tokens.

The AI SDK’s OpenAI-compatible provider talks to any chat completions endpoint. Create it once with our base URL, then name catalogue models by id.

bash
npm install ai @ai-sdk/openai-compatible
typescript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText, streamText } from "ai";

const relay = createOpenAICompatible({
  name: "autonomousrelay",
  baseURL: "https://autonomousrelay.com/v1",
  apiKey: process.env.AUTONOMOUSRELAY_API_KEY,
  includeUsage: true,
  supportsStructuredOutputs: true,
});

const { text } = await generateText({
  model: relay("anthropic/claude-sonnet-5"),
  prompt: "Say hello in one word.",
});

const result = streamText({
  model: relay("openai/gpt-5.5"),
  prompt: "Count to five.",
});
for await (const part of result.textStream) process.stdout.write(part);
  • includeUsage: true reports token usage on streams; supportsStructuredOutputs: true lets generateObject send a JSON schema.
  • Prefer this provider to @ai-sdk/openai. If you use that one with a custom baseURL, create models with openai.chat("…"): its default model calls the Responses API, and chat completions is the endpoint every model here is served on.