MyRelay

← नोटबुक पर वापस जाएँ

Send Images to Vision Models, Step by Step

Start your first vision API experiment with one screenshot and one question. This walkthrough uses extracting an error message as the example. Keep the first test small: you want to confirm that the image arrives, the model reads it, and the result is useful before building a larger workflow.

Choose a model that accepts image inputs

First, check image-input support rather than assuming every chat model can see pictures. Gemini 2.5 Flash, for example, accepts images and produces text. Confirm its current availability through your chosen relay, then copy the exact API model identifier rather than guessing it from the display name. ([ai.google.dev](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash?authuser=3&hl=en&utm_source=openai))

If you are starting with MyRelay, create an account and use its connection instructions to connect your OpenAI-compatible SDK with your relay key. Keep that key on your server, not inside a browser application or shared notebook output. MyRelay documents a Chat Completions connection, which is the request style used here. ([myapirelay.com](https://myapirelay.com/how-to-connect?hl=en))

Prepare a screenshot with readable text

Next, choose a screenshot whose answer you already know. Crop away unrelated windows, hide personal information, and keep the error message large enough to read comfortably. Avoid making the crop so tight that it removes the application name or other context needed to understand the message.

Check orientation and readability before sending anything. Small text and rotated images are documented sources of vision mistakes. For this test, prefer a clean, upright screenshot over a complicated photograph of your screen. ([platform.openai.com](https://platform.openai.com/docs/guides/images-vision))

Decide how the request will carry the image

For an OpenAI-style vision request, two common choices are an accessible image URL and a Base64-encoded data URL. The first points to an image hosted elsewhere; the second carries encoded image data inside the request. These are image inputs, not ordinary text descriptions of where an image lives. ([platform.openai.com](https://platform.openai.com/docs/guides/images-vision))

For your first test, consider the encoded approach so you do not need to arrange image hosting. Use your application's encoding library and declare the image's actual media type. Google's OpenAI-compatible image example demonstrates this approach with an encoded JPEG. Encoding is a transport choice, not a reason to skip redaction or review how your provider handles data. ([ai.google.dev](https://ai.google.dev/gemini-api/docs/openai))

Combine the question and image in one message

Now build a Chat Completions request with your selected model and a user message whose content is a list of parts. Include a text part containing your question and a separate image part carrying the image URL or encoded data URL. Google's compatibility documentation demonstrates this mixed-content message structure. Do not paste the encoded image into the question itself. ([ai.google.dev](https://ai.google.dev/gemini-api/docs/openai))

Ask the model to transcribe the visible error message, explain it in two sentences, and identify any unreadable words. This gives you a concrete result to inspect. Avoid asking for a complete diagnosis in the same first request; establish that the screenshot is readable before expanding the task.

Send one request and inspect the answer

Send the request once, then compare the transcription against the screenshot yourself. Check numbers, punctuation, and error identifiers carefully. Treat an answer that admits uncertainty as something to investigate, not something to replace automatically with a confident guess.

If the request fails, read the returned error before retrying. Check the model identifier, message structure, image encoding, and documented input limits. If it succeeds but the answer is poor, change one thing, such as the crop or question, so the next test tells you something useful.

Measure spending before processing more images

Record the cost alongside whether the answer was correct. Images contribute to billable input usage, so a short question does not necessarily mean a small request. Check the selected model's image accounting rather than estimating from the text alone. ([platform.openai.com](https://platform.openai.com/docs/guides/images-vision))

Use MyRelay's per-request token and cost view to compare your tests. Set yourself a small experimental budget and stop when you reach it. Once one screenshot works reliably, try a handful of varied examples before adding automatic processing. Aim for the least expensive setup that consistently solves your actual task, not the most elaborate setup you can assemble.

और पढ़ें