The System One EventUtahGo To Event Page →

Docs

Set up Midium, use every part of it, run it for your team, and build on it.

Images & vision

Send images to a vision model in the OpenAI or Anthropic format — as base64 data URLs or public links.

For developers

Vision models (Gemma 4, Qwen vision models and others) take images in the OpenAI format: an image_url part inside a message's content. You don't need a public link — send the image itself, base64-encoded, as a data URL. The same images work on Anthropic Messages.

Request#

IMG=$(base64 < photo.jpg | tr -d '\n')
curl http://127.0.0.1:9100/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL",
    "messages": [{"role": "user", "content": [
      {"type": "text", "text": "What is in this image?"},
      {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,'"$IMG"'"}}
    ]}]
  }'

YOUR_MODEL must be a model that can see. GET /v1/models marks those with capabilities.vision: true.

Image parts#

FieldTypeDescription
typestringimage_url. Midium: image and input_image work too.
image_url.urlstringA base64 data URL (data:image/png;base64,…), an http(s) link, or Midium: bare base64 with no data: prefix.
  • Base64 data URL — the image goes straight to the model. Best for private or local files.
  • Public link — Midium downloads it (30-second timeout). Links to localhost, .local names, or private, loopback, link-local, reserved or multicast addresses are refused (the host name is resolved and every address checked), so send internal images as base64.
  • Put several image parts in one message to send more than one image.

On Anthropic Messages, send an image block with a base64 or url source.

Response#

A normal chat completion: the model's description is in choices[0].message.content. See Chat completions.

Notes#

If Midium can't read an image — a refused link, a download that fails, bad base64 — the request still runs, but without any of that request's images, and the model answers from the text alone. The engine log (Settings → Logs) records Media extraction failed. If a reply ignores your image, check there first.

  • Models that can't see. A text-only model gets only the text parts; images are dropped without an error.
  • Tools work with images. Vision models call tools the same way text models do. See Tool calling.
  • Context. Images take up context. A prompt longer than the model's context window fails with 400 "Prompt too long".

Errors#

StatusWhen
400{"error": "Prompt too long: …"} — the prompt is longer than the model's context window.
404model_not_found — no model by that name.

See Errors & limits.

Something here wrong or out of date? Tell us.