Skip to main content

ImageContent

Image content with detail level specification for multi-modal LLM messages.

Import

import type { ImageContent } from '@adaline/api';

Type Definition

interface ImageContent {
  modality: 'image';
  detail: 'low' | 'medium' | 'high' | 'auto';
  value: ImageContentValue;
}

type ImageContentValue = Base64ImageContentValue | UrlImageContentValue;

interface UrlImageContentValue {
  type: 'url';
  url: string;
}

interface Base64ImageContentValue {
  type: 'base64';
  base64: string;
  mediaType: 'png' | 'jpeg' | 'webp' | 'gif';
}

Fields

modality
string
required
Must be "image".
detail
string
required
Detail level for image processing. One of: "low", "medium", "high", "auto".
value
ImageContentValue
required
Image data — either a URL reference or base64-encoded content with media type.

Example

import type { ImageContent, PromptMessage } from '@adaline/api';

const image: ImageContent = {
  modality: 'image',
  detail: 'high',
  value: {
    type: 'url',
    url: 'https://example.com/chart.png'
  }
};

const base64Image: ImageContent = {
  modality: 'image',
  detail: 'auto',
  value: {
    type: 'base64',
    base64: 'iVBORw0KGgoAAAANSUhEUgA...',
    mediaType: 'jpeg'
  }
};

const message: PromptMessage = {
  role: 'user',
  content: [
    { modality: 'text', value: 'Describe this image' },
    image
  ]
};
JSON:
{
  "modality": "image",
  "detail": "high",
  "value": {
    "type": "url",
    "url": "https://example.com/image.jpg"
  }
}