Images & vision
Vision models take images inside an ordinary chat message: the content becomes an array of
parts mixing text and images. Send the image as a base64 data URL, or name it by an https: URL
and the gateway reads it for you. Either way the endpoint receives the bytes inside the request:
no provider is ever sent a URL to fetch.
Finding a vision model
A model that accepts images lists image in its input modalities:
"architecture": { "modality": "text+image->text", "input_modalities": ["text", "image"], ... }
Filter the model list by input, or check architecture.input_modalities in the
catalogue.
Sending an image
Encode the file, build a data: URL with its media type, and put it in an image_url part:
import base64, os
from openai import OpenAI
client = OpenAI(base_url=BASE_URL, api_key=os.environ["HEIMDALL_API_KEY"])
with open("chart.png", "rb") as f:
data_url = "data:image/png;base64," + base64.b64encode(f.read()).decode()
completion = client.chat.completions.create(
model="huggingfacetb/smolvlm2-2.2b",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What does this chart show?"},
{"type": "image_url", "image_url": {"url": data_url}},
],
}
],
)
print(completion.choices[0].message.content)
The same request as raw JSON:
{
"model": "huggingfacetb/smolvlm2-2.2b",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "What does this chart show?" },
{
"type": "image_url",
"image_url": { "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...", "detail": "auto" }
}
]
}
]
}
| Field | Type | Meaning |
|---|---|---|
image_url.url | string | A data:<media type>;base64,<data> URL carrying the image bytes, or an https: URL. |
image_url.detail | string | auto (default), low or high — processing detail, where the endpoint distinguishes. |
A message may carry several images, interleaved with text parts, up to the model's context. Images sent as data URLs count against the 8 MB request body limit, which is the practical ceiling on their size, since base64 grows the bytes by about a third.
Images by URL
An https: URL in image_url.url is read by the gateway before the request is routed, and the
endpoint is sent the picture as a data URL in its place, typed by what the bytes are rather than by
what the origin says they are. The read is bounded: at most 16 distinct URLs and 32 MiB per request,
an answer within 10 seconds, and public addresses only. A URL that cannot be read within those
bounds, or that holds no PNG, JPEG, WebP or GIF picture, is answered 400 naming the part before any
provider is called; the full list of bounds is under
Media named by URL. Nothing read from a URL is logged, stored or
cached.
Pricing
Image inputs are tokenized by the serving model and billed as prompt tokens at the endpoint's
prompt price, and nothing else. There is no per-input-image price on this marketplace: the only
per-picture meter is image_megapixel, which is charged on the pixels an endpoint RENDERS. As
everywhere, an undeclared unit is never silently billed (see Pricing & billing).