Images and files
Send images, PDFs and text files in a request.
Images
/v1/chat/completions accepts image_url
parts in user messages. The URL is one of:
- A base64 data URL:
data:image/png;base64,.... PNG, JPEG, GIF and WebP. - An
https:URL. The provider downloads the image itself.
detail (auto, low or high) is passed to ChatGPT candidates. Requests
with images skip Grok.
IMAGE=$(base64 < photo.png | tr -d '\n')
curl https://code.test.indicia-ai.com/v1/chat/completions \
-H "Authorization: Bearer $INDICIA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "indicia/snel",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What colour is this image? One word."},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,'"$IMAGE"'"}}
]
}]
}'When a provider cannot download an https: image, the request fails over to
the next candidate, and a candidate that rejects it ends the request with
400 upstream_rejected.
Images on private hosts
Use data URLs for images on private or rate-limited hosts.
Other URL schemes and malformed data URLs get 400 invalid_request. Images in
non-user messages, and other part types such as input_audio, get
400 unsupported_content.
/v1/messages takes Anthropic image content
blocks and passes them on.
Files
/v1/chat/completions accepts file parts in user messages. Send the file
as a base64 data URL in file_data, and optionally a filename.
| Type | What the gateway does |
|---|---|
application/pdf | Sends the PDF to the model as a document. ChatGPT and Claude candidates read it. Requests with a PDF skip Grok. |
text/plain, text/markdown, text/csv, application/json | Decodes the file as UTF-8 and adds it to the message as text, inside <document filename="..."> tags. Every provider can read it. |
PDF=$(base64 < report.pdf | tr -d '\n')
curl https://code.test.indicia-ai.com/v1/chat/completions \
-H "Authorization: Bearer $INDICIA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "indicia/snel",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Summarise this report in three bullet points."},
{"type": "file", "file": {"filename": "report.pdf", "file_data": "data:application/pdf;base64,'"$PDF"'"}}
]
}]
}'Size limits
The request body can be at most 16 MiB. Base64 makes a file a third larger, so a PDF can be about 12 MB. Providers set their own limits on top of this, such as a maximum number of pages.
These requests get 400:
| Request | code |
|---|---|
file_id instead of file_data. The gateway has no Files API. | unsupported_content |
| Any other file type, such as Word or Excel | unsupported_content |
A file in a system, assistant or tool message | unsupported_content |
file_data that is not a base64 data URL, or a text file that is not UTF-8 | invalid_request |
There is no URL form for files. Download the file and send it as file_data.
/v1/messages takes Anthropic document content blocks and passes them on:
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "JVBERi0..."}, "title": "report.pdf"}