Artfical AI / API
Get an API key Open tAI
Request options

Images

Send an image alongside text on tai-4.1 and tai-4.2, using the same content-array shape OpenAI's vision-capable models accept.

Which models

Only tai-4.1 and tai-4.2 accept image input; see the full breakdown on the Models page. Sending an image to any other model doesn't error outright, but the image is silently ignored and only the text portion of the message is considered, so double-check the model field if image understanding isn't showing up in a response the way you expect.

The content shape

For a message with no image, content is a plain string. To attach an image, content becomes an array of typed parts instead, mixing one or more text parts with one or more image_url parts:

{
  "role": "user",
  "content": [
    {"type": "text", "text": "Bu görselde ne var?"},
    {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSU..."}}
  ]
}

image_url.url takes a base64-encoded data URI, not a plain hosted image link; the API doesn't fetch a remote URL for you. Encode the image bytes as base64, prefix them with the correct MIME type, and send the whole thing as the url value.

# Python: building the data URI from a local file
import base64

with open("photo.jpg", "rb") as f:
    b64 = base64.b64encode(f.read()).decode()
data_url = f"data:image/jpeg;base64,{b64}"

Supported formats

PNG, JPEG, and WebP are all accepted. Use the matching MIME type in the data URI prefix (image/png, image/jpeg, image/webp) so the image is decoded correctly.

Size

There's no hard document limit enforced client-side that you need to calculate against, but very large images add real latency (base64-encoding inflates size by roughly a third, and the whole request body has to be transmitted and processed before generation starts) and very large requests are more likely to be rejected by intermediate infrastructure well before they'd reach any model-side limit. Resizing an image down to whatever resolution is actually useful for the task, rather than sending a full-resolution original, is usually the right call and rarely loses anything the model would have used anyway.

Multiple images in one message

A single message's content array can include more than one image_url part, alongside as much or as little text as needed:

{
  "role": "user",
  "content": [
    {"type": "text", "text": "Bu iki görsel arasındaki fark ne?"},
    {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}},
    {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
  ]
}

Combined with tool calling

An image and tools can be present on the same request; the model can call a tool based partly on what it sees in an attached image, the same way it would based on text alone. See Tool calling for how the call-and-response cycle works.