> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobhub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Modalities and Media

> Images, PDFs, audio and video in, and images out, as session files.

What a model takes in and gives out is a list of **modalities**: `text`, `image`, `document`, `audio` and `video`.
Media travels as [session files](https://docs.blobhub.io/blob-types/workflow/session-objects/file/introduction.md): a `file` block of a
[message](https://docs.blobhub.io/blob-types/workflow/workflows/data-types.md) names a file by alias, and an image a model draws is written back
as a session file. A model's modalities are columns of the catalog on the
[language model page](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-model-language.md#the-catalog).

## Modalities

A `file` block's modality comes from its content type:

| Content type | Modality |
| :- | :- |
| `image/*` | `image`. A session file holds only `png`, `jpeg`, `gif` or `webp`. |
| `application/pdf` | `document` |
| `audio/*` | `audio` |
| `video/*` | `video` |
| anything else | None: the call is refused with `unsupported_media`. |

A catalog model's `inputs` list the modalities it reads and its `outputs` the ones it writes; `text` is in both. Two
checks hold a flow to them:

* **The definition check** holds what a consumer asks for against the model. A `genai.chat` that lists `image` in
  `output_modalities` is an error on a catalog model whose `outputs` lack it: `model: <id> gives no image, which <consumer> asks for`. A run that names a model is held to the same rule.
* **The call** holds each `file` block against the model, before any vendor is called, and refuses it with
  `unsupported_media`, naming the file:

  | Cause | Message |
  | :- | :- |
  | A content type with no modality | `unsupported_media: <name> (<content type>) is not an image, a PDF, audio or video` |
  | A modality the model does not take | `unsupported_media: <id> does not take audio (<name>)` |
  | A modality the vendor's protocol cannot carry | `unsupported_media: anthropic cannot send audio (<name>)` |

A model the catalog does not know passes the definition check and the check on the model's inputs; a file whose content
type is no modality, or that its dialect cannot carry, is still refused.

## What each vendor takes

| Modality | In | Out |
| :- | :- | :- |
| Text | Every vendor and gateway | Every vendor and gateway |
| Image | Every vendor and gateway | OpenAI, Gemini, and gateways' image models |
| Document (PDF) | Every vendor and gateway | — |
| Audio | Gemini; gateway models that take audio, through the entry's `media_parts` | — |
| Video | Gemini; gateway models that take video, through `media_parts`; a clip within the 4 MiB file limit | — |

Neither OpenAI nor Anthropic takes audio or video on the APIs BlobHub uses, and Anthropic's models give no images. Which
of a gateway's models take what is the catalog's `inputs` and `outputs`; a model it does not list passes the check on
a model's inputs.

## Files in

A `file` block in `system`, `current` or `history` names a session file, and so does one inside a tool result. The
provider reads each distinct file once per call and sends it inline as base64 of the same bytes on every turn.

* **No vendor file APIs.** A session file holds at most 4 MiB (`workflow.session_file_bytes`, refused as
  `session_file_too_large`; see [Limits](https://docs.blobhub.io/general/limits.md)), within every vendor's inline limit, so nothing is uploaded
  to a vendor, nothing expires on its side, nothing needs deleting there, and the request stays byte-stable for
  caching.
* **A file that is not there** fails the call: `file_not_found: "<alias>" is not a file in this session`.
* **A system message's files** go at the head of the first `user` turn on every vendor, since Anthropic's and OpenAI
  Responses' instructions take text only.
* **A generated image in an assistant turn** is sent as the text `[file: <name>, <content type>]` to a protocol that
  takes no media there (Anthropic and Chat Completions). To edit such an image, put it in `current`.

How each protocol carries a file:

| Dialect | Image | PDF | Audio, video |
| :- | :- | :- | :- |
| `openai_responses` | `input_image`, a data URL | `input_file`, a data URL | Not carried. |
| `anthropic_messages` | an `image` block, base64 | a `document` block, base64 | Not carried. |
| `gemini_generate` | `inline_data` | `inline_data` | `inline_data` |
| `openai_chat` (gateways) | an `image_url` part, a data URL | a `file` part with `file_data` | The part the entry's `media_parts` names; no entry means not carried. |

A gateway's `media_parts` entry says where audio and video go: `input_audio` (the bytes and their format),
`audio_url` or `video_url` (a data URL), or `file`. The entries are on
[Vendors and Gateways](https://docs.blobhub.io/blob-types/workflow/workflows/vendors-and-gateways.md). A tool result's file goes to Chat
Completions as `[file: <name>, <content type>]`, with a warning that files are not carried there.

OpenRouter is told to let the model read a PDF itself (`engine: native`, a registry default), never through its paid
OCR.

## Images out

A `genai.chat` whose `output_modalities` list holds `image` (the default is `["text"]`) asks the model for images.
What each protocol asks for:

| Dialect | The request |
| :- | :- |
| `openai_responses` | The tool `image_generation`, with the keys of `vendor_settings.image_generation` |
| `gemini_generate` | `config.response_modalities: ["TEXT", "IMAGE"]` |
| `openai_chat` | `modalities: ["image", "text"]` |
| `anthropic_messages` | None: Anthropic's models give no images, and `output_modalities: anthropic gives no images` fails the call before it is made. |

Editing is the same call: an image in `current` with an instruction, and `image` in `output_modalities`, returns the
edited image. Image settings (size, aspect ratio, quality) are each vendor's own and go in `vendor_settings`; no shared
setting fits all three.

Each image becomes a session file, written as the call returns, through the same path as any upload: the content type,
the 4 MiB ceiling and the session's object quota hold. The answer holds a `file` block for it at its place among the
text. Its alias is

```text theme={null}
generated/<execution_id>/<component_run>-<index>.<ext>
```

where `component_run` counts the runs of components in the execution up to the leg that entered the node, `index`
counts the answer's images from 0, and `ext` is `png`, `jpg`, `webp` or `gif`. The file's name is
`image-<component_run>-<index>.<ext>`. A retried leg has the same `component_run`, so it overwrites its own files
instead of adding more; a node's second run in one execution has a different one. Images that Gemini marks as thoughts
are skipped.

An image over the 4 MiB limit fails the call: `file_too_large: image <n> of the answer is <size> bytes, over the 4 MiB
session file limit`. A session whose object quota refuses an image fails it with that limit's own message. A 1K image
is well under the limit.

Sending a generated image back to its own vendor renders it from the file's bytes, the same on every turn.

## Voice notes

The conversation widget's composer records a voice note. The browser records WebM/Opus (`audio/webm`) where it can
and MP4/AAC (`audio/mp4`) where it cannot, and stops by itself at five minutes. The recording is staged like a dropped
file, uploaded as a session file when the message is sent, and posted as an `audio` `file` block beside the text.
Gemini takes both formats. A model or gateway that does not take the recorded format refuses it at the call, with
`unsupported_media`. A voice note is a file like an image: the model answers it in text.

## Usage by modality

Where a vendor reports tokens per modality, the answer's usage carries `by_modality`, a map from modality to its
`input_tokens` and `output_tokens`. Gemini reports it, and OpenAI counts audio tokens; a vendor that reports none
leaves the field out. See [Prompt Caching and Usage](https://docs.blobhub.io/blob-types/workflow/workflows/prompt-caching-and-usage.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.