Prerequisite: Complete the Quickstart to get an access key. All requests go to
https://gateway.ngrok.ai.Installation
Basic usage
Point the OpenAI provider at your AI Gateway endpoint:Streaming responses
The AI Gateway supports streaming. UsestreamText for real-time responses:
Chat interface
Build chat applications with theuseChat hook:
app/page.tsx
app/api/chat/route.ts
Using different providers
The AI Gateway routes based on the model name. Use provider prefixes to be explicit:Model failover
List fallback models in the request. See Configure fallback models.Environment variables
Set up your environment:.env.local
Tool calling
The AI Gateway supports function/tool calling:Error handling
Handle errors gracefully:Next steps
- Vercel AI SDK Documentation - Full SDK reference
- Choose a model: Model IDs and provider prefixes
- Configure fallback models: Try another model when the first one fails
- Choose how to reach providers: Credits, provider keys, and self-run models