Published

Multimodal AI for Business: Working with Documents, Images and Audio

How vision-language and speech models read scanned documents, photos and calls: architecture, pipeline code and ways to keep image and audio costs down.

Written by
Ali ÖzdurmuşFounder, Veni AI
Updated
Reading time
6 min read

Multimodal AI systems understand more than text: scanned invoices, product photos, technical drawings, recorded calls and video. Current frontier chat models from OpenAI, Anthropic and Google accept images as input, and dedicated speech models handle transcription and voice. For companies, this unlocks the large share of information that never lived in a database.

Code samples are illustrative Python. client is an initialized SDK client; MODEL, TRANSCRIBE_MODEL, TTS_MODEL and VOICE are placeholders for the models you choose.

Multimodal AI Fundamentals

Modality Types

  1. Text: Natural language, code, structured data
  2. Vision: Photo, diagram, screenshot
  3. Audio: Speech, music, environmental sounds
  4. Video: Combination of moving image + audio

Why Multimodal?

  • Human communication is inherently multimodal
  • Context information missed with single modality
  • Richer meaning extraction
  • Suitability for real-world applications

Vision-Language Models

Architectural Approaches

1. Contrastive Learning (CLIP style)

Image Encoder → Image Embedding
Text Encoder → Text Embedding
Contrastive Loss: Match(image, text)

2. Generative (vision-language model style)

Image → Vision Encoder → Visual Tokens
Visual Tokens + Text Tokens → LLM → Response

3. Cross-Attention Fusion

Image Features ←Cross-Attention→ Text Features

Vision Encoder Types

EncoderArchitectureResolutionFeature
ViTTransformer224-1024Patch-based
CLIP ViTTransformer336Contrastive
SigLIPTransformer384Sigmoid loss
ConvNeXtCNNFlexibleEfficient

Image Tokenization

Patch Embedding:

224×224 image → 14×14 patch grid → 196 visual tokens
Each patch: 16×16 pixel → Linear projection → Embedding

Variable Resolution:

Anyres approach:
1. Divide image into tiles
2. Encode each tile separately
3. Add global thumbnail
4. Concatenate all tokens

Multimodal LLM Implementation

Image Input (OpenAI-style API)

python
from openai import OpenAI
import base64

client = OpenAI()
MODEL = "your-model-id"

def encode_image(image_path):
    with open(image_path, "rb") as f:
        return base64.b64encode(f.read()).decode('utf-8')

response = client.chat.completions.create(
    model=MODEL,
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Analyze this image"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": f"data:image/jpeg;base64,{encode_image('image.webp')}",
                        "detail": "high"  # low, high, auto
                    }
                }
            ]
        }
    ],
    max_tokens=1000
)

Image Input (Anthropic API)

python
from anthropic import Anthropic
import base64

client = Anthropic()

with open("image.webp", "rb") as f:
    image_data = base64.standard_b64encode(f.read()).decode("utf-8")

message = client.messages.create(
    model=MODEL,
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image",
                    "source": {
                        "type": "base64",
                        "media_type": "image/jpeg",
                        "data": image_data
                    }
                },
                {"type": "text", "text": "What is in this image?"}
            ]
        }
    ]
)

Audio Processing

Speech-to-Text (STT)

Hosted transcription API:

python
from openai import OpenAI

client = OpenAI()

with open("audio.mp3", "rb") as audio_file:
    transcript = client.audio.transcriptions.create(
        model=TRANSCRIBE_MODEL,
        file=audio_file,
        language="tr"
    )
    
print(transcript.text)

Current speech-to-text options include GPT-Transcribe, ElevenLabs Scribe v2, Mistral Voxtral Mini Transcribe V2 and the open-weights Qwen3-ASR, which you can run on your own servers when recordings must stay in-house.

Text-to-Speech (TTS)

python
response = client.audio.speech.create(
    model=TTS_MODEL,
    voice=VOICE,
    input="Hello, I am an AI assistant."
)

response.stream_to_file("output.mp3")

Current text-to-speech options include Eleven v4, Gemini 3.8 Flash TTS, Voxtral TTS and the open-weights Qwen3-TTS.

Real-time Audio Pipeline

Microphone → VAD → Chunking → STT → LLM → TTS → Speaker
             ↓
        Voice Activity
        Detection

Video Understanding

Frame Sampling Strategies

1. Uniform Sampling:

python
def uniform_sample(video_path, num_frames=8):
    cap = cv2.VideoCapture(video_path)
    total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
    indices = np.linspace(0, total_frames-1, num_frames, dtype=int)
    
    frames = []
    for idx in indices:
        cap.set(cv2.CAP_PROP_POS_FRAMES, idx)
        ret, frame = cap.read()
        if ret:
            frames.append(frame)
    
    return frames

2. Keyframe Extraction:

python
def extract_keyframes(video_path, threshold=30):
    # Finding keyframes with Scene change detection
    pass

Video-LLM Pipeline

Video → Frame Sampling → Per-frame Encoding → Temporal Aggregation → LLM
                              ↓
                        Audio Extraction → STT → Text

Modality Fusion

Early Fusion

Combining modalities at model input:

[CLS] [IMG_1] ... [IMG_N] [SEP] [TXT_1] ... [TXT_M] [SEP]

Late Fusion

Processing each modality separately and combining results:

Image → Image Model → Image Features ─┐
                                       ├→ Fusion Layer → Output
Text → Text Model → Text Features ────┘

Cross-Modal Attention

Attention between modalities:

Q = Text Features
K, V = Image Features
Cross_Attention(Q, K, V) = softmax(QK^T/√d)V

OCR and Document Understanding

Document AI Pipeline

python
def process_document(image_path):
    # 1. Layout Detection
    layout = detect_layout(image)  # Headings, paragraphs, tables
    
    # 2. OCR
    text_regions = ocr_extract(image)
    
    # 3. Structure Understanding
    structured_doc = parse_structure(layout, text_regions)
    
    # 4. LLM Analysis
    analysis = llm_analyze(structured_doc)
    
    return analysis

Table Extraction

python
response = client.chat.completions.create(
    model=MODEL,
    messages=[{
        "role": "user",
        "content": [
            {"type": "image_url", "image_url": {"url": table_image_url}},
            {"type": "text", "text": "Extract this table in JSON format"}
        ]
    }]
)

Enterprise Multimodal Applications

1. Document Processing

  • Invoice/receipt OCR
  • Contract analysis
  • Form data extraction
  • Search from product image
  • Similar image finding
  • Visual Q&A

3. Content Moderation

  • Inappropriate image detection
  • Brand logo check
  • Text + image consistency

4. Customer Support

  • Screenshot analysis
  • Visual troubleshooting
  • Voice support

Performance Optimization

Image Preprocessing

python
def optimize_image(image_path, max_size=1024, quality=85):
    img = Image.open(image_path)
    
    # Resize
    if max(img.size) > max_size:
        ratio = max_size / max(img.size)
        new_size = tuple(int(d * ratio) for d in img.size)
        img = img.resize(new_size, Image.LANCZOS)
    
    # Compress
    buffer = io.BytesIO()
    img.save(buffer, format="JPEG", quality=quality)
    
    return buffer.getvalue()

Batch Processing

python
async def batch_image_analysis(images, batch_size=5):
    results = []
    for i in range(0, len(images), batch_size):
        batch = images[i:i+batch_size]
        tasks = [analyze_image(img) for img in batch]
        batch_results = await asyncio.gather(*tasks)
        results.extend(batch_results)
    return results

Cost Management

Token Calculation (Vision)

Images are converted into tokens before the model reads them. Each provider documents its own formula, and the count grows with resolution and detail level. Measure the token usage of your typical documents (a one-page invoice, a multi-page contract scan) before you estimate volume costs.

Optimization Strategies

  1. Adjust detail level: Do not use "high" unless necessary
  2. Reduce image size: Reduces token count
  3. Caching: Do not re-analyze the same image
  4. Batch operations: Reduce API call count

Conclusion

Much of a company's knowledge sits in scans, photos, drawings and recordings. Multimodal models make that content searchable and usable, as long as the pipeline is sound: good preprocessing, the right model per modality, validation of extracted data and cost control on image and audio tokens.

Veni AI builds document, image and audio pipelines that feed directly into companies' existing systems. See our services or talk to us about your documents.

Keep reading

Have a process that should run on AI?

Describe one process as it runs today, and we'll show you which repetitive steps an AI application or agent could handle.