Instructions for the AI
The user-facing content
OpenRouter model identifier
Optionalsignal: AbortSignalOptional AbortSignal (e.g. from the Next.js request)
OptionalfallbackModels: string[]Optional ordered fallback model identifiers. When
passed, OpenRouter receives models: [model, ...fallbackModels] so it can
route to the first available model for the streaming request.
Opens a streaming chat completion request to OpenRouter and returns the raw upstream
Responseobject whose body is an SSEtext/event-stream.The caller is responsible for piping
response.bodyto the client. The request is aborted whensignalfires (i.e. client disconnect).