# Images and files

## Send an image with a question

Pass an array of parts in the user message. Replace the example URL with a public HTTPS image.

~~~json
{
  "model": "google/gemma-4-E2B-it",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Describe the labels in this image."},
      {"type": "image_url", "image_url": {"url": "https://your-site.example/chart.png"}}
    ]
  }],
  "max_tokens": 512
}
~~~

PNG, JPEG, WebP and GIF are supported as inputs. GIF image input uses its first frame. You can also use a base64 data URL such as `data:image/png;base64,...`.

## Send a text file or PDF

Inline UTF-8 text is useful for small files.

~~~json
{
  "model": "deepseek-v4.1-flash-1017",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Extract the meeting time."},
      {"type": "file", "file": {"filename": "meeting-notes.txt", "text": "The meeting starts at 10:30."}}
    ]
  }],
  "max_tokens": 128
}
~~~

For a PDF or encoded file, supply `file_data` as base64 or a data URL, or `file_url` as a public HTTPS URL. For Responses use `input_image` and `input_file`. Anthropic Messages uses `image` and `document` blocks; Ollama uses `images`.

PDFs need extractable text and must be unencrypted. Send scans as page images. The text reader supports UTF-8 text, code, JSON, CSV and Markdown. [Image generation and editing](#generate-an-image) uses separate API endpoints.

## Limits and metadata

Send up to 16 attachments, 4 MiB per attachment and 8 MiB per JSON request. Images are limited to 32 megapixels and PDFs to 100 pages and 262,144 extracted characters.

`input_processing` can identify how an attachment was handled, including a vision reader when a text model receives observations. Use a model with native vision when the precise details of the image matter.

## Upload a local screenshot

Use a data URL when the image is on disk. Example with the official OpenAI JavaScript SDK configured for Site6. [SDK setup](/examples/#set-up-an-sdk).

~~~javascript
import { readFile } from "node:fs/promises";
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.SITE6_API_KEY,
  baseURL: "https://site6.eokgg.win/v1",
});
const png = await readFile("screenshot.png");
const result = await client.responses.create({
  model: process.env.SITE6_MODEL ?? "google/gemma-4-E2B-it",
  input: [{
    role: "user",
    content: [
      { type: "input_text", text: "Describe the visible settings in this screenshot." },
      { type: "input_image", image_url: "data:image/png;base64," + png.toString("base64"), detail: "auto" },
    ],
  }],
  max_output_tokens: 512,
  store: false,
});
console.log(result.output_text);
~~~

Base64 adds about a third to the encoded size. Keep the original file below the per-attachment cap and the resulting JSON within the request cap. For screenshots, crop to the area the model needs to read.

## Generate an image

**POST `/v1/images/generations`** with JSON. Your key needs access to `gpt-image-2`.

~~~bash
curl --fail-with-body -sS https://site6.eokgg.win/v1/images/generations \
  -H "Authorization: Bearer $SITE6_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model":"gpt-image-2",
    "prompt":"A simple blue circle centred on white.",
    "size":"1024x1024",
    "quality":"low",
    "output_format":"png"
  }' -o image-response.json
~~~

Successful replies return a JSON object with `data[].b64_json`. Decode the base64 to recover the image bytes.

~~~python
import base64
import json
from pathlib import Path

response = json.loads(Path("image-response.json").read_text(encoding="utf-8"))
Path("circle.png").write_bytes(base64.b64decode(response["data"][0]["b64_json"]))
~~~

## Edit an uploaded image

**POST `/v1/images/edits`** with multipart form data. Let curl or your HTTP client set the multipart boundary.

~~~bash
curl --fail-with-body -sS https://site6.eokgg.win/v1/images/edits \
  -H "Authorization: Bearer $SITE6_API_KEY" \
  -F 'model=gpt-image-2' \
  -F 'prompt=Change the blue circle to red.' \
  -F 'image=@circle.png' \
  -o edit-response.json
~~~

Upload PNG, JPEG or WebP images. Repeat `image[]` for multiple images and use `mask` for an optional PNG mask. The multipart body limit is 6 MiB.

## Image options

Prompts can contain up to 32,000 characters. Use `size: "auto"` or a supported width × height string. Quality can be `low`, `medium`, `high` or `auto`. Output can be PNG, JPEG or WebP. Transparent backgrounds require PNG or WebP. Compression is available on JPEG and WebP.

Image generation and editing return one JSON response. If a large result hits the transport limit, request fewer images or use a compressed format. Use [2chat](https://2.site6.eokgg.win/) for an interactive image generation and editing interface when your key has access.
