Skip to Content
Launching the open-source gateway

Vision and files

Send images and documents to chat models as URLs or base64 data.

Chat models that read images or documents take them as content parts in a user message. You write the parts in OpenAI’s format, and the gateway translates them into each provider’s format, so the same request works for OpenAI, Anthropic and Gemini models. Every call is logged as a chat row with its cost.

Pick a model: filter by input type image or file on the model catalog , or read Models.

URL or base64

Every media part carries its content in one of two forms:

FormExampleUse when
Public URLhttps://example.com/receipt.pngThe file is already hosted and reachable from the internet. The provider fetches it.
Base64 data URLdata:image/png;base64,iVBORw0...The file is local or private. The bytes travel in the request body.

Which form each part takes:

PartURLBase64 data URL
image_url (images)YesYes
file (PDF, plain text)NoYes, in file_data
input_audio (audio)NoYes, raw base64 in data

Base64 makes the request body about a third larger than the file, and every body counts against the gateway’s request size budget, so prefer URLs for large images. To turn a local file into a data URL:

Python
import base64 with open("receipt.png", "rb") as f: data = base64.b64encode(f.read()).decode() url = f"data:image/png;base64,{data}"

Images

Add image_url parts to a user message. Send several images by adding more parts to the same message.

Terminal
curl https://gateway.respan.ai/v1/chat/completions \ -H "Authorization: Bearer $RESPAN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.5", "messages": [{ "role": "user", "content": [ {"type": "text", "text": "What is the total on this receipt?"}, {"type": "image_url", "image_url": {"url": "https://example.com/receipt.png"}} ] }] }'

Files

Add a file part to send a PDF (application/pdf) or plain text (text/plain) as a base64 data URL.

Python
with open("contract.pdf", "rb") as f: data = base64.b64encode(f.read()).decode() response = client.chat.completions.create( model="gpt-5.5", messages=[{ "role": "user", "content": [ {"type": "text", "text": "Summarize this contract in three bullets."}, {"type": "file", "file": { "filename": "contract.pdf", "file_data": f"data:application/pdf;base64,{data}", }}, ], }], )
FieldTypeDescription
file.file_datastringThe document as a data URL: data:application/pdf;base64,... or data:text/plain;base64,....
file.filenamestringOptional file name, passed to providers that take one.

The gateway translates file_data. An uploaded file id (file.file_id) works only on the provider that issued it; it is not translated to other providers.

Provider support

ProviderImagesFiles
OpenAIYes, nativelyYes, natively
AnthropicYes, mapped to image blocksYes, mapped to document blocks
GeminiYes, mapped to inline dataYes, mapped to inline data in Gemini’s own format

A given model may still not read images or files. Check its input types (next section).

Model input types

Every model in the catalog lists what it accepts in input_modalities and what it returns in output_modalities:

FieldValues
input_modalitiestext, image, audio, video, file
output_modalitiestext, image, audio, video, embeddings, speech, transcription, rerank, decisions, realtime

A model that reads images lists image in input_modalities; one that reads PDFs lists file. Filter on these fields on the model catalog , or in the models list API (List models).

Routing

When a request can go to several models, such as through a route with fallbacks or load balancing, the gateway drops the candidates whose input_modalities don’t include image when the messages carry an image. The first model is always tried as you named it.

Respan parameters

Respan parameters work as on any chat request: in the body (or extra_body) or the X-Data-Respan-Params header. See Respan parameters.

Pricing and logs

  • Images and documents are billed as part of the chat call, from the input tokens the provider reports, at the model’s catalog price.
  • The trace’s chat row keeps the request’s messages, including the media parts.

Next steps