Messages
Messages are the fundamental unit of interaction between agents and models — containing role, content, and metadata to form the complete conversation context.
Messages are the fundamental unit of model interaction in deepseek-kit. Every time you call the model, you're constructing a set of messages — the user's question, the assistant's response, the system's instructions, the tool's execution result. Understanding the structure and usage of messages is the foundation for building any AI application. deepseek-kit uses a message format compatible with the DeepSeek API while providing shorthand methods like prompt and system, enabling you to efficiently organize input in any scenario.
Prompt Methods
deepseek-kit supports three ways to pass input to the model, suitable for different scenarios:
Text Prompt
The simplest approach — pass a string directly as user input:
You can also use template literals to inject dynamic data:
System Prompt
Use the system parameter to set the model's role and behavioral guidelines. The system prompt is sent as the first system message to the model, guiding it to respond in a specific way:
The system prompt can be combined with either prompt or messages:
Message List
When you need to maintain multi-turn conversation history, use the messages array. Each message contains role and content fields:
prompt and messages are mutually exclusive input methods. prompt is suitable for single requests, while messages is for multi-turn conversations. system and fewShot can be combined with either.
Message Assembly Order
When you use system, fewShot, messages, and prompt together, deepseek-kit assembles them into the final message array in a fixed order:
system → fewShot → messages → prompt
The final message array sent to the model is:
Each parameter has a distinct role:
| Parameter | Role | Position |
|---|---|---|
system | Sets the model's role and behavioral guidelines | First, as a system message |
fewShot | Provides example conversations to guide the model's response style | After system, before messages |
messages | Carries multi-turn conversation history | After fewShot, before prompt |
prompt | The current user input as a single string | Last, as a user message |
system and fewShot are configuration-level inputs — they define how the model should behave. messages and prompt are conversation-level inputs — they define what the model should respond to. prompt and messages are mutually exclusive.
Message Types
deepseek-kit defines four message types, corresponding to different roles in a conversation:
SystemMessage
Sets the model's behavioral guidelines and role positioning, sent before the conversation begins:
Optional fields:
name— Participant name, used to distinguish different sources of system instructions
It's recommended to use the system parameter rather than manually adding system messages in messages — it's clearer and safer.
UserMessage
Represents the user's input — the most commonly used message type:
Optional fields:
name— User identifier, used in multi-user scenarios
AssistantMessage
Represents the model's response. Assistant messages can contain text content, tool calls, and reasoning content:
Plain text response:
Response with tool calls:
Response with reasoning content (thinking mode):
When the model has thinking mode enabled, the reasoning_content field contains the model's reasoning process, and content contains the final response.
ToolMessage
Represents the result of a tool execution, associated with the corresponding tool call via tool_call_id:
The tool_call_id must match the id of the corresponding item in the AssistantMessage's tool_calls array for the model to correctly associate the tool call with its result.
Multi-Turn Conversations
Use the messages array to build multi-turn conversations, where each turn contains a user message and an assistant message:
Tool Calling Message Flow
When an agent calls a tool, the message flow follows a fixed pattern:
In agent mode, you don't need to manually construct the tool calling message flow. createAgent automatically handles the generation and association of AssistantMessages and ToolMessages.
Manually Constructing Conversation History
In some scenarios, you may need to manually construct conversation history — for example, loading history from a database or simulating a specific conversation context:
Choosing Between prompt and messages
| Feature | prompt | messages |
|---|---|---|
| Input method | Single string | Message array |
| Use case | Single requests, stateless generation | Multi-turn conversations, stateful interactions |
| System prompt | Via system parameter | Via system parameter or system message |
| Few-shot examples | Via fewShot parameter | Via fewShot parameter or included in messages |
| Tool call history | Not supported | Supported |
| Conversation continuity | None | Fully preserved |
Recommendations:
- One-off generation — Use
prompt, e.g., content creation, data extraction - Chat applications — Use
messages, e.g., customer service conversations, interactive Q&A - Historical context needed — Use
messages, e.g., follow-up questions, multi-step reasoning
API Reference
ChatMessage Types
tool_call_id. ChatCompletionTool Type
'function' is supported. Input Parameters
messages. prompt or messages. system message and before messages. Used to guide the model's response style and format through demonstrations. Can be combined with prompt or messages. prompt. 
