AI SDK route handlers run fine on the edge, but the edge runtime bans Node APIs, so a route that works on nodejs can 500 on edge with a confusing error.

app/api/chat/route.ts:

export const runtime = 'edge';
export const maxDuration = 30;

export async function POST(req: Request) {
  // same streamText + createUIMessageStreamResponse wiring as nodejs
}

What to know:
1. Add export const runtime = 'edge' at the top of the route file. Without it you get the nodejs runtime, with its cold starts and regional behavior.
2. Provider keys load the same way: environment variables are available in edge. OPENAI_API_KEY and friends are read from process.env by the provider factories, no special handling needed.
3. Do not use Node-only modules in an edge route: no fs, no child_process, no node:crypto. If a tool's execute function reads files, that tool cannot run in an edge route; move it to a nodejs route or a separate service.
4. The AI SDK itself is edge-compatible: streamText, toUIMessageStream, and the provider fetch calls all run on the edge runtime.
5. Some community provider packages assume Node globals. If you see atob is not defined or ReadableStream is not defined style errors after switching to edge, the provider package is the culprit, not the AI SDK. Pin the provider or move that route back to nodejs.
6. Keep streaming responses unbuffered. On Vercel the platform handles this; behind your own proxy, disable buffering or the edge speed win disappears.