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: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 themodel field. You can target Anthropic models through the same OpenAI provider: