Skip to content

Type definitions

Inspired by Vercels AI SDK.

Conversations with LLMs consist of a series of prompts/messages. Each prompt can be of four types:

  • system: Provides context or instructions to the model.
  • user: Represents the user’s input or question.
  • assistant: Represents the model’s response.
  • tool: Represents a tool call made by the model.

Check the next section for the structure of each type.

// system
{
"role": "system",
"content": string
}
// user
{
"role": "user",
"content": [LanguageModelText | LanguageModelFile]
}
// assistant
{
"role": "assistant",
"content": [LanguageModelText | LanguageModelFile | LanguageModelReasoning | LanguageModelToolCall]
}
// tool
{
"role": "tool",
"content": [LanguageModelToolResult]
}
{
"type": "text",
"text": string,
"providerOptions": object // Optional provider-specific options
}
{
"type": "file",
"mediaType": string, // IANA media type (e.g., 'image/png', 'audio/mp3')
"data": string, // file content encoded in base64
"filename?": string, // Optional filename for the file
"providerOptions": object // Optional provider-specific options
}
{
"type": "reasoning",
"text": string,
"providerOptions": object // Optional provider-specific options
}
{
"type": "tool_call",
"toolCallId": string,
"toolName": string,
"args": string, // JSON string of arguments passed to the tool
"providerOptions" object // Optional provider-specific options
}
{
"type": "tool_result",
"toolCallId": string,
"toolName": string,
"result": string, // JSON string of the tool result
"providerOptions" object // Optional provider-specific options
}