Skip to main content
core-ai supports multi-modal inputs, allowing you to include images, files, audio, and text in the same message.

Images in Messages

Include images in user messages:

Image Sources

Images can be provided via URL or base64:

Content Part Types

User messages can contain multiple content parts:

Multiple Images

Include multiple images in one message:

Text and Images Together

Mix text and images in any order:

Audio input

Audio parts use base64 data and a MIME type:
Google Gemini chat models accept audio through inlineData. OpenAI accepts audio only through openai.chat.chatModel() with an audio-capable Chat Completions model. Other providers reject audio with UnsupportedInputModalityError.

File Attachments

Include files in messages:
File support varies by provider and model. Check your provider’s documentation for supported file types.

Common Use Cases

Multi-Modal with Streaming

Stream responses for multi-modal inputs:

Reading Images from Disk

Load and encode local images:

Multi-Modal Conversations

Build conversations with images:

Provider Support

Multi-modal support varies by provider:

Model support

Not every model accepts every input type. Read model.capabilities.modalities.input before you build a request:
Sending image, file, or audio parts to a model that does not support them throws an UnsupportedInputModalityError (a ValidationError) before the request reaches the provider:
Provider registries generally allow image and file input for unrecognized model IDs so self-hosted and newly released models are not blocked locally. Audio remains opt-in. Vision-capable models accept both base64 and url image sources. To run the same check yourself before dispatching a request, use validateInputModalities:

Best Practices

Common formats work best:
  • JPEG: Photos, complex images
  • PNG: Screenshots, diagrams, transparency
  • WebP: Modern format, good compression
Resize large images before sending:
Tell the model what to focus on:
Read the capability instead of guessing from the model ID, and fall back to a text-only prompt when images are not available:

Next Steps

Image Generation

Generate images from text prompts

Chat Completion

Learn basic text generation

Streaming

Stream multi-modal responses

Structured Outputs

Extract structured data from images