---
title: "Images & Vision API (URLs and Base64) | Straitly Docs"
description: "Send image URLs and base64-encoded PNG, JPEG or WebP inputs to multimodal Claude, GPT and Gemini models via Straitly."
url: https://straitly.ai/docs/vision
updated: 2026-11-28
publisher: Straitly (https://straitly.ai)
---

Docs

API guides

# Images & vision

Copy docs

**On this page**

Send an image together with a question to a model that supports vision. Image inputs use content blocks; selecting a text-only model will not add image understanding.

### Prepare an image

Choose a vision-capable model and an image you are permitted to share with the provider. The example reads a local PNG and encodes it as a data URL, avoiding the need to publish it on a public host.

- Match the MIME type to the actual file type. This example expects image.png to be a PNG.
- Provider limits on file size, image dimensions, and image count vary. Resize large images and consult the selected model's limits.
- Avoid credentials, personal information, or confidential material in example screenshots.

[Browse model capabilities](https://straitly.ai/models)

### Send an image

Python

Copy Copied Failed

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.straitly.ai/v1",
    api_key=os.environ["STRAITLY_API_KEY"],
)

import base64
from pathlib import Path

encoded = base64.b64encode(Path("image.png").read_bytes()).decode("ascii")
response = client.chat.completions.create(
    model="claude-sonnet-5-5",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this image."},
            {"type": "image_url", "image_url": {
                "url": "data:image/png;base64," + encoded,
            }},
        ],
    }],
)
print(response.choices[0].message.content)

[SDK setup](https://straitly.ai/docs/sdks)

### URLs, costs, and results

- For models accepting remote image URLs, the URL must be reachable by the provider without your browser session cookies. Never put secrets into the URL.
- Image token accounting is model-specific. Inspect usage and the recorded charge rather than estimating from the base64 string length.
- Vision output can be wrong. Validate extracted values and use human review for consequential decisions.
- The Anthropic Messages API uses its own image source block format. Do not paste Chat Completions image\_url blocks into a Messages request.

[Endpoint formats](https://straitly.ai/docs/endpoints) [Request activity](https://straitly.ai/app/activity)

### What are the image and audio limits?

Python

Copy Copied Failed

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.straitly.ai/v1",
    api_key=os.environ["STRAITLY_API_KEY"],
)

import base64
from pathlib import Path

audio = base64.b64encode(Path("clip.mp3").read_bytes()).decode("ascii")
response = client.chat.completions.create(
    model="YOUR_GEMINI_AUDIO_MODEL_ID",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Transcribe this clip."},
            {"type": "input_audio", "input_audio": {"data": audio, "format": "mp3"}},
        ],
    }],
)
print(response.choices[0].message.content)

- Images: PNG, JPEG, GIF or WebP. Each inline image or audio clip can be up to 10 MB.
- Keep the whole request, base64 included, under 29 MB. Base64 makes each file about a third larger, so that is roughly 22 MB of inline files. A request that is too large is refused with 413 Request Entity Too Large before it reaches a model.
- A PDF sent with an image type is refused before it reaches a model. Send the PDF's text instead, or convert its pages to images.
- Audio: send an input\_audio part in wav or mp3 format to a Gemini model that supports audio. Other models refuse audio with a 400, so send a transcript to them instead.
- Each model also has its own limits on image count and dimensions. Resize large images before sending them.

Pick the audio model id from GET /v1/models or the model directory. The exact error messages for refused attachments are on the errors page.

[Attachment errors](https://straitly.ai/docs/errors#error-messages-word-for-word) [Browse models](https://straitly.ai/models)

[Reasoning controls](https://straitly.ai/docs/reasoning) [Models & pricing](https://straitly.ai/docs/models)

---
Markdown version of https://straitly.ai/docs/vision.
