liveBook · Manning

Prompt

As explained in Build AI-Enhanced Web Apps

A basic text prompt is a single string containing instructions or questions for an AI model.

A basic text prompt is a single string containing an instruction or question for an AI model. It suits a single-turn request, such as a one-off query. In a web app, the request may start in the UI, pass through backend processing, reach a model, and return as generated content. section 5.1.2 section 1.2.2

generateText({
    prompt: 'Hello, what is your name?',
    model: model("models/gemini-2.0-flash")
});

A minimal Vercel AI SDK call passes the string through the `prompt` property of `generateText`, alongside a model. section 5.1.2

A single `prompt` is effectively a `messages` array containing one user message, but it cannot carry conversation history. Use role-labeled messages when an interaction needs earlier turns, extra context, or attachments. A separate `system` property can set behavior for the conversation. section 5.1.2

Make the instruction useful and economical:

  • Specify the requested result. “List 5 popular programming languages” constrains the answer more clearly than “List some popular programming languages.” section 5.2.1
  • Include representative input–output examples when the model must follow a pattern or adapt its tone; end by telling it how to handle the new input. section 5.2.2
  • Account for input and output tokens when estimating service costs; natural-language input is tokenized before model processing. section 5.1.1

For reusable application instructions, an MCP server can register a named prompt that returns messages, including text assembled from an argument. That server-defined prompt is a separate integration pattern from passing a one-off string to `generateText`. section 12.4.1 section 5.1.2

How Build AI-Enhanced Web Apps covers it

How deep it goes
Defines the string form, shows its `generateText` equivalent as one user message, and contrasts it with conversation-capable messages.
Examples
Shows a greeting passed to `generateText` and a programming-language request made more precise by specifying five results.
What it assumes
Introduces basic prompt types directly while assuming familiarity with JavaScript calls and web-app request flow.
What you can do after
Apply it via the Vercel AI SDK’s `generateText` for a one-off request, then switch to messages when history is needed.
How it connects
Relates prompts to message prompts, system prompts, few-shot learning, tokenization, and conversation history.

Also explained in

Compare how 50 books explain prompt →

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.