IranRouter
Docs contents

Docs

Vision & images

Sending images by URL or base64, and which models accept them.

Models that accept image input take it inside the same messages array. Each model's page states whether its input modalities include image.

python
resp = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "در این تصویر چه می‌بینی؟"},
            {"type": "image_url", "image_url": {"url": "https://example.com/x.jpg"}},
        ],
    }],
)

base64

For a local file, use a data URI instead of a URL:

python
import base64
b64 = base64.b64encode(open("x.jpg", "rb").read()).decode()
image_url = {"url": f"data:image/jpeg;base64,{b64}"}
Images consume tokens, and large images consume a lot. Downscale before sending — a 4000px photo usually yields the same answer at several times the cost.