videosphere
    Preparing search index...

    Function generateMetadata

    • Sends a chat completion request to OpenRouter and parses the response into a typed GeneratedMetadata object with title, description, and tags fields.

      Parameters

      • systemPrompt: string

        Instructions for the AI (platform limits, format, etc.)

      • userPrompt: string

        The user-facing content (filename, context)

      • model: string

        OpenRouter model identifier (e.g. "openai/gpt-4o")

      • OptionalfallbackModels: string[]

        Optional fallback model IDs appended after model. When provided, OpenRouter may attempt models in this order: primary model first, then each entry in fallbackModels.

      Returns Promise<GeneratedMetadata>

      Error if the API key is missing, the request fails, or the response is malformed / missing required fields.