> ## 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](/docs/models) 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" }
}
```

<ParamField body="image_url.url" type="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.
</ParamField>

<ParamField body="image_url.detail" type="string">
  `auto`, `low` or `high`. Optional.
</ParamField>

<CodeGroup>
  ```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"])
  ```
</CodeGroup>

## Accepted images

| | |
| - | - |
| Formats | PNG, JPEG, WebP |
| Sources | Absolute `https://` URL, or base64 data URL |
| Size of one image | 48 MiB, after decoding |
| 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`. An image in another format or from another source is rejected.
* A data URL is part of the request body, so it counts toward the [request body limit](/docs/limits#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.