Documentation Index
Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
MessageContent
Multi-modal content types for messages and variables in the Adaline SDK.
Overview
Content types support text, images, PDFs, tool calls/responses, reasoning, errors, and search results. All content uses the modality field as a discriminator.
MessageContent (Union Type)
Polymorphic content type supporting multiple modalities.
type MessageContent =
| TextContent
| ImageContent
| PdfContent
| ReasoningContent
| ToolCallContent
| ToolResponseContent
| ErrorContent
| SearchResultContent;
Type Narrowing:
function processContent(content: MessageContent) {
switch (content.modality) {
case 'text':
console.log('Text:', content.value);
break;
case 'image':
console.log('Image:', content.value.type);
break;
case 'pdf':
console.log('PDF:', content.file.name);
break;
case 'tool-call':
console.log('Tool call:', content.name);
break;
case 'tool-response':
console.log('Tool response:', content.name);
break;
case 'reasoning':
console.log('Reasoning...');
break;
case 'error':
console.log('Error:', content.value);
break;
case 'search-result':
console.log('Search result:', content.value);
break;
}
}
Text Content
TextContent
See the dedicated TextContent page for full documentation.
Plain text content for messages.
interface TextContent {
modality: 'text';
value: string;
}
Example:
const text: TextContent = {
modality: 'text',
value: 'Hello, how are you?'
};
const message: PromptMessage = {
role: 'user',
content: [text]
};
JSON:
{
"modality": "text",
"value": "Hello, how are you?"
}
Image Content
Base64ImageContentValue
Base64-encoded image data with media type.
interface Base64ImageContentValue {
type: 'base64';
base64: string;
mediaType: 'png' | 'jpeg' | 'webp' | 'gif';
}
Example:
const base64Image: Base64ImageContentValue = {
type: 'base64',
base64: 'iVBORw0KGgoAAAANSUhEUgA...',
mediaType: 'png'
};
UrlImageContentValue
URL reference to an externally hosted image.
interface UrlImageContentValue {
type: 'url';
url: string;
}
Example:
const urlImage: UrlImageContentValue = {
type: 'url',
url: 'https://example.com/image.jpg'
};
ImageContentValue
Union of base64 or URL image content.
type ImageContentValue = Base64ImageContentValue | UrlImageContentValue;
Example:
// URL variant
const urlValue: ImageContentValue = {
type: 'url',
url: 'https://example.com/photo.jpg'
};
// Base64 variant
const base64Value: ImageContentValue = {
type: 'base64',
base64: 'iVBORw0KG...',
mediaType: 'png'
};
ImageContent
See the dedicated ImageContent page for full documentation.
Image content with detail level specification.
interface ImageContent {
modality: 'image';
detail: 'low' | 'medium' | 'high' | 'auto';
value: ImageContentValue;
}
Example:
// With URL
const image: ImageContent = {
modality: 'image',
detail: 'high',
value: {
type: 'url',
url: 'https://example.com/chart.png'
}
};
// With base64
const base64Image: ImageContent = {
modality: 'image',
detail: 'auto',
value: {
type: 'base64',
base64: 'iVBORw0KGgoAAAANSUhEUgA...',
mediaType: 'jpeg'
}
};
// In message
const message: PromptMessage = {
role: 'user',
content: [
{ modality: 'text', value: 'Describe this' },
image
]
};
JSON:
{
"modality": "image",
"detail": "high",
"value": {
"type": "url",
"url": "https://example.com/image.jpg"
}
}
PDF Content
Base64PdfContentValue
Base64-encoded PDF document.
interface Base64PdfContentValue {
type: 'base64';
base64: string;
}
Example:
const pdfValue: Base64PdfContentValue = {
type: 'base64',
base64: 'JVBERi0xLjcKCjEgMCBvYmo...'
};
UrlPdfContentValue
URL reference to a PDF document.
interface UrlPdfContentValue {
type: 'url';
url: string;
}
Example:
const pdfValue: UrlPdfContentValue = {
type: 'url',
url: 'https://example.com/document.pdf'
};
PdfContentValue
Union of base64 or URL PDF content.
type PdfContentValue = Base64PdfContentValue | UrlPdfContentValue;
PdfContent
See the dedicated PdfContent page for full documentation.
PDF document content with file metadata.
interface PdfContent {
modality: 'pdf';
value: PdfContentValue;
file: {
name: string;
id: string;
size?: number | null;
};
}
Example:
const pdf: PdfContent = {
modality: 'pdf',
value: {
type: 'url',
url: 'https://example.com/report.pdf'
},
file: {
name: 'Q4_Report.pdf',
id: 'file_abc123',
size: 1024000
}
};
const message: PromptMessage = {
role: 'user',
content: [
{ modality: 'text', value: 'Summarize this document' },
pdf
]
};
JSON:
{
"modality": "pdf",
"value": {
"type": "url",
"url": "https://example.com/report.pdf"
},
"file": {
"name": "report.pdf",
"id": "file_123",
"size": 1024000
}
}
Tool Content
ToolCallContent
See the dedicated ToolCallContent page for full documentation.
Tool/function call request from LLM.
interface ToolCallContent {
modality: 'tool-call';
index: number; // minimum: 0
id: string;
name: string;
arguments: string;
serverName?: string | null;
}
Example:
const toolCall: ToolCallContent = {
modality: 'tool-call',
index: 0,
id: 'call_abc123',
name: 'get_weather',
arguments: JSON.stringify({
city: 'San Francisco',
units: 'fahrenheit'
}),
serverName: 'weather-api'
};
// In assistant message
const assistantMessage: PromptMessage = {
role: 'assistant',
content: [toolCall]
};
JSON:
{
"modality": "tool-call",
"index": 0,
"id": "call_abc123",
"name": "get_weather",
"arguments": "{\"city\":\"San Francisco\"}"
}
ToolResponseContent
See the dedicated ToolResponseContent page for full documentation.
Tool/function execution response.
interface ToolResponseContent {
modality: 'tool-response';
index: number; // minimum: 0
id: string;
name: string;
data: string;
apiResponse?: {
statusCode?: number;
} | null;
}
Example:
const toolResponse: ToolResponseContent = {
modality: 'tool-response',
index: 0,
id: 'call_abc123',
name: 'get_weather',
data: JSON.stringify({
temperature: 72,
conditions: 'sunny',
humidity: 65
}),
apiResponse: {
statusCode: 200
}
};
// In tool message
const toolMessage: PromptMessage = {
role: 'tool',
content: [toolResponse]
};
JSON:
{
"modality": "tool-response",
"index": 0,
"id": "call_abc123",
"name": "get_weather",
"data": "{\"temperature\":72,\"conditions\":\"sunny\"}",
"apiResponse": {
"statusCode": 200
}
}
Reasoning Content
ReasoningContentValue
LLM reasoning/thinking content with signature.
interface ReasoningContentValue {
type: 'thinking';
thinking: string;
signature: string;
}
RedactedReasoningContentValue
Redacted reasoning content for privacy.
interface RedactedReasoningContentValue {
type: 'redacted';
data: string;
}
ReasoningContentValueUnion
Union of reasoning content types.
type ReasoningContentValueUnion =
| ReasoningContentValue
| RedactedReasoningContentValue;
ReasoningContent
See the dedicated ReasoningContent page for full documentation.
Reasoning content for chain-of-thought responses.
interface ReasoningContent {
modality: 'reasoning';
value: ReasoningContentValueUnion;
}
Example:
const reasoning: ReasoningContent = {
modality: 'reasoning',
value: {
type: 'thinking',
thinking: 'Let me analyze this step by step...',
signature: 'sig_abc123'
}
};
// Redacted version
const redacted: ReasoningContent = {
modality: 'reasoning',
value: {
type: 'redacted',
data: '[REDACTED]'
}
};
Error Content
ErrorContent
See the dedicated ErrorContent page for full documentation.
Error content type for LLM safety and content filtering errors.
interface ErrorContent {
modality: 'error';
value: SafetyErrorContentValue;
}
Example:
const error: ErrorContent = {
modality: 'error',
value: {
type: 'safety',
value: 'Content filtered due to safety policy.'
}
};
Search Result Content
SearchResultContent
See the dedicated SearchResultContent page for full documentation.
Search result content type for grounding LLM responses with web search data.
interface SearchResultContent {
modality: 'search-result';
value: SearchResultGoogleContentValue;
}
Example:
const searchResult: SearchResultContent = {
modality: 'search-result',
value: {
type: 'google',
references: [{ title: 'Example', url: 'https://example.com', snippet: '...' }],
responses: [{ text: 'Search grounding result...' }]
}
};
Complete Examples
Multi-Modal Message
import type { PromptMessage, MessageContent } from '@adaline/api';
const message: PromptMessage = {
role: 'user',
content: [
{
modality: 'text',
value: 'Analyze this image and document'
},
{
modality: 'image',
detail: 'high',
value: {
type: 'url',
url: 'https://example.com/image.jpg'
}
},
{
modality: 'pdf',
value: {
type: 'url',
url: 'https://example.com/report.pdf'
},
file: {
name: 'report.pdf',
id: 'file_123'
}
}
]
};
// 1. Assistant makes tool call
const assistantWithTool: PromptMessage = {
role: 'assistant',
content: [
{
modality: 'tool-call',
index: 0,
id: 'call_123',
name: 'get_weather',
arguments: JSON.stringify({ city: 'Paris' })
}
]
};
// 2. Tool responds
const toolResult: PromptMessage = {
role: 'tool',
content: [
{
modality: 'tool-response',
index: 0,
id: 'call_123',
name: 'get_weather',
data: JSON.stringify({ temp: 24, conditions: 'sunny' })
}
]
};
// 3. Assistant uses tool result
const finalResponse: PromptMessage = {
role: 'assistant',
content: [
{
modality: 'text',
value: 'The weather in Paris is sunny with a temperature of 24°C.'
}
]
};
Helper Functions
// Create text content
function createText(value: string): TextContent {
return { modality: 'text', value };
}
// Create image content
function createImage(url: string, detail: 'low' | 'medium' | 'high' | 'auto' = 'auto'): ImageContent {
return {
modality: 'image',
detail,
value: { type: 'url', url }
};
}
// Create PDF content
function createPdf(url: string, name: string): PdfContent {
return {
modality: 'pdf',
value: { type: 'url', url },
file: { name, id: `file_${Date.now()}` }
};
}
// Usage
const message: PromptMessage = {
role: 'user',
content: [
createText('Analyze these'),
createImage('https://example.com/chart.png', 'high'),
createPdf('https://example.com/report.pdf', 'Q4 Report')
]
};
Content Filtering
const message: PromptMessage = {
role: 'user',
content: [/* mixed content */]
};
// Get all text content
const textItems = message.content.filter(
(c): c is TextContent => c.modality === 'text'
);
// Get all images
const images = message.content.filter(
(c): c is ImageContent => c.modality === 'image'
);
// Get tool calls
const toolCalls = message.content.filter(
(c): c is ToolCallContent => c.modality === 'tool-call'
);
// Extract text values
const textValues = textItems.map(t => t.value).join(' ');