跪拜 Guibai
← All articles
Agent

The Only Difference Between Text and Multimodal LLM Calls Is an Array

By 为你学会写情书 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The jump from text to multimodal looks intimidating but is a one-line code change: swap a string for an array. Understanding that base64 is just JSON-compatible transport, not model comprehension, prevents a common category of confusion that leads developers to overcomplicate their pipelines.

Summary

Multimodal model calls use the same API endpoint and the same model as text calls. The sole difference is that `content` becomes an array of objects keyed by `type`—text, image_url, input_audio, or video_url—with binary data encoded as base64 strings. That base64 step is purely a transport mechanism to fit binary into JSON; the model's actual understanding happens later when a Vision Encoder splits images into patches and converts them to embeddings.

TTS works in the opposite direction. The API accepts text and returns a raw binary audio stream, not JSON. Saving that stream to an `.mp3` file and handing it to the system player is the entire client-side pipeline. Internally, a text encoder produces acoustic features like a mel spectrogram, and a vocoder such as HiFi-GAN turns those into waveform audio.

GPT-4o and similar models do not natively generate pixels or waveforms. When a user asks for an image or speech, the model plans the request and dispatches it to a separate module—DALL-E for images, a TTS engine for audio—then returns the result alongside its text response.

Takeaways
Changing a Chat API call from text-only to multimodal requires only converting `content` from a string to an array of `{ type, ... }` objects.
Binary media must be base64-encoded to travel inside a JSON request body; the model decodes it server-side before inference.
base64 encoding and the Vision Encoder's patch-based understanding are entirely separate stages with no overlap.
TTS APIs return a raw binary stream, not JSON, because encoding audio as base64 would inflate payload size by roughly 33% and add parsing overhead.
GPT-4o does not generate images or audio directly; it dispatches those tasks to DALL-E or a TTS module and returns the combined result.
Conclusions

Many developers conflate base64 transport with model comprehension, which leads to unnecessary abstraction layers that re-encode or pre-process media the API already handles.

The clean separation between a reasoning model and dedicated generation modules means multimodal output is an orchestration problem, not a single-model capability, even though product branding obscures this.

TTS's binary response design is a practical reminder that not every AI API fits the familiar JSON-shaped mental model; handling raw streams is a necessary skill.

Concepts & terms
Vision Encoder (ViT)
A Vision Transformer that splits an image into a grid of fixed-size patches, flattens each into a vector, and produces visual embeddings that a language model can attend to alongside text tokens.
Mel Spectrogram
A representation of audio that maps frequency content over time, commonly used as an intermediate acoustic feature between text and raw waveform in TTS pipelines.
Vocoder
A model (e.g., HiFi-GAN) that converts acoustic features like mel spectrograms into audible waveform samples, the final step in most neural TTS systems.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗