Skip to main content
Prompts are instructions that you give a large language model (LLM) to tell it what to do. It’s like when you ask someone for directions; the clearer your question, the better the directions you’ll get. Many LLM providers offer complex interfaces for specifying prompts. They involve different roles and message types. While these interfaces are powerful, they can be hard to use and understand. The AI SDK simplifies prompting by supporting three types of prompts: text prompts, message prompts, and system prompts.

Text prompts

Text prompts are the simplest form - just a string. They are ideal for simple generation use cases.

Dynamic prompts

You can use template literals to provide dynamic data:

System prompts

System prompts are instructions that guide the model’s behavior and responses. They work with both text and message prompts.

Message prompts

Message prompts are arrays of messages with different roles. They’re great for chat interfaces and multi-turn conversations.

Basic messages

Multi-modal messages

Messages can include multiple content types:

Text parts

Image parts

Images can be provided as buffers, base64 strings, or URLs:
Using a URL:

File parts

Some models support file attachments like PDFs:

Message roles

User messages

User messages represent input from the user:

Assistant messages

Assistant messages represent previous responses from the model:
Assistant messages can also include tool calls:

System messages

System messages provide context and instructions:

Tool messages

Tool messages contain the results of tool executions:

Provider options

You can pass provider-specific metadata at different levels:

Function level

Message level

Message part level

Prompt conversion

The AI SDK converts prompts to the format required by each provider:
This abstraction is handled by the convertToLanguageModelPrompt function in the SDK core.