> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fortytwo.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Image input

> Send images in a chat completion, by HTTPS URL or base64 data URL.

A `user` message can carry images as content parts of type `image_url`. [Models](https://docs.fortytwo.network/docs/models.md) lists which models accept images.

## Send an image

Add an image part to the `content` array, next to the text:

```json theme={null}
{
  "type": "image_url",
  "image_url": { "url": "https://example.com/chart.png" }
}
```

**image\_url.url** `string` *required*

An absolute `https://` URL, or a data URL such as `data:image/png;base64,<data>`. The media type in a data URL must match the image data.

**image\_url.detail** `string`

`auto`, `low` or `high`. Optional.

```python HTTPS URL theme={null}
import os

import requests

BASE_URL = "https://api.fortytwo.network/v1"
MODEL = "qwen/qwen3.8-27b"
IMAGE_URL = "https://example.com/chart.png"

response = requests.post(
    f"{BASE_URL}/chat/completions",
    headers={
        "Authorization": f"Bearer {os.environ['FORTYTWO_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": MODEL,
        "messages": [
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "What does this chart show?"},
                    {"type": "image_url", "image_url": {"url": IMAGE_URL}},
                ],
            }
        ],
    },
)

print(response.json()["choices"][0]["message"]["content"])
```

```python Base64 data URL theme={null}
import base64
import os

import requests

BASE_URL = "https://api.fortytwo.network/v1"
MODEL = "qwen/qwen3.8-27b"
IMAGE_PATH = "chart.png"

with open(IMAGE_PATH, "rb") as handle:
    encoded = base64.b64encode(handle.read()).decode()

response = requests.post(
    f"{BASE_URL}/chat/completions",
    headers={
        "Authorization": f"Bearer {os.environ['FORTYTWO_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": MODEL,
        "messages": [
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "What does this chart show?"},
                    {
                        "type": "image_url",
                        "image_url": {"url": f"data:image/png;base64,{encoded}"},
                    },
                ],
            }
        ],
    },
)

print(response.json()["choices"][0]["message"]["content"])
```

## Accepted images

| | |
| - | - |
| Formats | PNG, JPEG, WebP |
| Sources | Absolute `https://` URL, or base64 data URL |
| Size of one image | 48 MiB: the downloaded file, or the decoded data of a data URL |
| Pixels in one image | 40 million (width × height) |
| Images per request | No fixed limit. The request body size and the model's context window apply |

* A request over a limit fails with `413 request_too_large`.
* A data URL of another type, a URL that is not `https://`, or an image outside a `user` message fails with `400 unsupported_content_type`. An image that can't be downloaded or decoded fails with `400 invalid_request`.
* A data URL is part of the request body, so it counts towards the [request body limit](https://docs.fortytwo.network/docs/limits.md#request-size).
* Each image also uses input tokens.

### Images sent by URL

The API downloads the image. The URL must:

* resolve to a public address;
* contain no credentials;
* use at most 3 redirects;
* connect within 10 seconds and finish within 30 seconds;
* return a `2xx` status with a `Content-Type` of `image/png`, `image/jpeg` or `image/webp`. A generic type such as `application/octet-stream` is rejected;
* return the image uncompressed, without `Content-Encoding`.

The image data itself must also be PNG, JPEG or WebP.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.