Skip to main content
This guide shows you how to route the Vercel AI SDK through the to11 gateway using the OpenAI provider with a custom base URL.
These examples use the AI SDK 5+ API (inputSchema, message.parts, toUIMessageStreamResponse). On AI SDK 4 the option and method names differ.

Installation

Configuration

Create an OpenAI provider instance pointing at the to11 gateway:

Generate text

Stream text

Use with Next.js

In a Next.js route handler:
On the client side, the useChat hook posts to /api/chat by default. Manage the input yourself and send messages with sendMessage:

Cross-format routing

The to11 gateway routes based on the model field. You can target Anthropic models through the same OpenAI provider:
The gateway translates the OpenAI-format request to Anthropic format and returns the response in OpenAI format, so the Vercel AI SDK works without changes.

Tool calling