liveBook · Manning

Multimedia prompt

As explained in Build AI-Enhanced Web Apps

A multimedia prompt is an instruction to a generative AI system that combines text with one or more media inputs such as images.

A multimedia prompt combines a text instruction with media, such as an image, so a generative AI system can analyze both inputs. In a web application, the feature spans an upload interface, request transformation, and a vision-capable model. section 3.4.2

A practical implementation follows this flow:

  • Accept an image upload and retain its preview data in the chat component. section 3.4.2
  • Attach the image URL to the request alongside the user's text. section 3.4.2
  • Convert the final message into text and image parts before passing it to streamText. section 3.4.2
  • Send the enriched messages to a Gemini vision model and stream its response. section 3.4.2
Listing 3.14 processIncomingMessages function in route.js
async function processRequestMessages(req) {
  const { messages, data } = await req.json();    #1
  if (!data?.imageUrl) return messages;    #2

  const initialMessages = messages.slice(0, -1);
  const lastMessage = messages[messages.length - 1];    #3

  return [
    ...initialMessages,
    {
      ... lastMessage,
      content: [    #4
        { type: "text", text: lastMessage.content },
        {
          type: "image",
          image: data.imageUrl,
        },
      ],
    },
  ];
};

Use the route transformation to see how a text-only message becomes a multimedia prompt with separate text and image parts. section 3.4.2

How Build AI-Enhanced Web Apps covers it

How deep it goes
Explains the upload-to-model data path and provides JavaScript snippets, while deferring complete uploader implementation.
Examples
Demonstrates an uploaded image receiving an accurate AI-generated description.
What it assumes
Assumes basic chat-message handling and introduces image upload, preview, and multipart message construction.
What you can do after
Build it with React, JavaScript, Vercel AI SDK, and Gemini vision model integration.
How it connects
Connects image upload, multimodal input, Gemini vision, Vercel AI SDK, React state, and streamed responses.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI-Enhanced Web Apps. The section links point to the parts of the book it draws on.