Skip to main content

Messages

Message types used in chat completions.

MessageType

Messages follow a role-based structure with multi-modal content support.
import { MessageType } from "@adaline/types";

const messages: MessageType[] = [
  {
    role: "system",
    content: [{ modality: "text", value: "You are a helpful assistant." }],
  },
  {
    role: "user",
    content: [
      { modality: "text", value: "What's in this image?" },
      { modality: "image", value: "https://example.com/image.png" },
    ],
  },
];

Fields

role
string
required
The message sender role. One of:
  • "system" — System instructions
  • "user" — User input
  • "assistant" — Model response
  • "tool" — Tool call result
content
ContentType[]
required
Array of content items. Each item has a modality and value.

ContentType

Content items represent different modalities within a message.

Text Content

{ modality: "text", value: "Hello, world!" }

Image Content

{ modality: "image", value: "https://example.com/image.png" }
// or base64
{ modality: "image", value: "data:image/png;base64,..." }

Tool Call Content

Returned by the model when it wants to invoke a tool.
{
  modality: "tool_call",
  value: {
    id: "call_abc123",
    name: "get_weather",
    arguments: '{"location": "San Francisco"}',
  }
}

Tool Result Content

Sent back to the model with the tool’s response.
{
  modality: "tool_result",
  value: {
    id: "call_abc123",
    result: '{"temperature": 72, "condition": "sunny"}',
  }
}