videosphere
    Preparing search index...

    Function streamMetadata

    • Opens a streaming chat completion request to OpenRouter and returns the raw upstream Response object whose body is an SSE text/event-stream.

      The caller is responsible for piping response.body to the client. The request is aborted when signal fires (i.e. client disconnect).

      Parameters

      • systemPrompt: string

        Instructions for the AI

      • userPrompt: string

        The user-facing content

      • model: string

        OpenRouter model identifier

      • Optionalsignal: AbortSignal

        Optional 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.

      Returns Promise<Response>

      RateLimitError on HTTP 429

      Error on any other non-2xx or network failure