model changes.
Choose a model
All of these models are usage-billed in thedefault group. Prices are in the model catalog.
Qwen VL models such as
qwen3-vl-plus also accept image_url requests, but the image URL must return a Content-Length header; otherwise the request fails with a 400, Missing Content-Length of multimodal url. The screenshot URL in these examples does not, so send it as Base64 when you use Qwen.
Each input type goes through a specific endpoint:
Before you start
Create an API key in Token management with its billing mode set to Usage first (recommended) or Usage-based, export it in your terminal, and install the OpenAI SDK for the Python examples:Send an image URL
The example image is a screenshot of the LaoZhang API console’s token page. The prompt asks the model which buttons are outlined in red.- cURL
- Python
gemini-3.8-flash, change only model.
The model service downloads the image itself, so your own URLs must open on the public internet without a login or cookies.
Send a local image as Base64
For a file on your machine, encode it as a data URL,data:<MIME type>;base64,<data>, and send it in the same image_url.url field. This example reads photo.jpg from the current directory.
- cURL
- Python
A Base64 image is too long for the command line, so write the request body to a file first and send that file:
image/jpeg for a JPEG or image/png for a PNG.
Compare several images
Add oneimage_url part per image in the same message. The model reads them in order, so you can compare two versions or combine information across images. Refer to the images by position in your prompt (“the first image”, “the second image”) for more reliable answers.
Trade detail for tokens
OpenAI models accept adetail setting on each image_url:
detail; their token usage does not change.
Read a PDF
OpenAI models read PDFs directly; you do not need to convert pages to images. Encode the PDF as a Base64 data URL and send it in afile part with a filename:
Use the Responses API
OpenAI models also accept images and PDFs through the Responses API, asinput_image and input_file parts:
input_image, image_url is a plain string: a public URL or a Base64 data URL. Gemini models do not support the Responses API; call them with Chat Completions or the native Gemini API.
Read the answer
The answer is plain text inchoices[0].message.content, and the response has the same shape as any Chat Completions reply. Add "stream": true to stream the answer; image requests stream the same way as text.
usage.prompt_tokens includes the tokens for images and files. Check call logs for the actual charge.
Vision models can misread details, such as a digit in a similar-looking number. Review the output before you rely on it for amounts, IDs, or legal, medical, financial, or identity decisions.
Use Gemini’s native format
In Gemini’s nativegenerateContent format, Gemini models accept PDFs, audio, and video as well as images:
- Images: Include an image
- PDFs and audio: Send a PDF or audio file
- MP4 video, frames and audio: Video understanding API
FAQ
Which model reads images most accurately?
For complex interfaces, small text, and multi-image comparisons, start withgpt-6-sol or gpt-6-astra. For simple, high-volume recognition, gpt-6-luna or gemini-3.5-flash-lite costs less. Before you go live, compare candidate models on your own images for accuracy and token usage.
Can I send a PDF directly?
Yes. With OpenAI models, use afile part in Chat Completions or input_file in Responses; see Read a PDF. With Gemini models, use the native Gemini API, because Chat Completions drops the PDF.
Can I send audio to the model?
GPT-6 and GPT-5.6 do not accept audio input; aninput_audio part returns a 400. If you only need a transcript, use the audio API. If the model needs to listen and answer questions, use a Gemini model through the native Gemini API.
Can I send video?
OpenAI models do not accept video. Gemini models analyze the frames and audio of an MP4 through the native API, or through a Base64 data URL in avideo_url part in Chat Completions; see the Video understanding API.
The model says it received no image or file. What now?
Checkusage.prompt_tokens first. A few dozen tokens means the attachment was not read. Common causes:
- The image URL needs a login or no longer works.
- The data URL’s MIME type does not match the file, or the Base64 is incomplete.
- A Gemini model received a
fileorinput_audiopart, which Chat Completions drops for Gemini.
How are images billed?
Images and PDFs are converted to input tokens and billed with your text at the model’s price. For OpenAI models,"detail": "low" cuts image tokens substantially; Gemini models ignore detail. See call logs for the tokens and cost of each request.