← All news

News / Learn / Multimodal AI

How do you use vision models in an app?

You'll be able to send an image to a vision model, get useful output back, and build that call into an app safely.

A vision model reads images as well as text. You send it a picture and a question, and it sends back an answer. It does not see the image the way a person does. It turns the image into tokens, then reasons over those tokens with your text.

Many useful product features depend on images: receipts, screenshots, product photos, scanned forms, charts. A vision model can read these without custom code for each case. Knowing how the input is handled helps you control cost, speed, and accuracy.

Most vision APIs accept an image in one of two ways. You can send a URL that points to a publicly reachable image, or you can send the image bytes encoded as base64 inside the request. Either way, the image travels with your text prompt in a single message. The message usually has a list of content parts, where each part is either text or an image.

Inside the model, the image is split into patches. Each patch becomes a set of vector values, and those values are converted into tokens that the model can attend to, the same way it handles words. Larger images create more tokens. More tokens mean more cost and slower responses. Many providers resize or compress images before processing, so very large inputs often add cost without adding accuracy.

The model does not store a perfect copy of what it saw. It produces a best reading of the image, which can be wrong. Small text, dense tables, unusual handwriting, and fine detail are common failure points. Ask the model to quote text it reads, and check important values against the source when accuracy matters.

For structured results, ask for JSON with a defined shape and validate it in your code. Treat the model's output as untrusted input until you have checked it.

A minimal request that sends an image URL with a question, using the OpenAI-style chat format. Adapt the field names to your provider's current docs.

import base64
from openai import OpenAI

client = OpenAI()

with open("receipt.jpg", "rb") as f:
    image_b64 = base64.b64encode(f.read()).decode("utf-8")

response = client.chat.completions.create(
    model="your-vision-model",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text",
                 "text": "Extract the store name, date, and total. Reply as JSON with keys store, date, total. Use null if unreadable."},
                {"type": "image_url",
                 "image_url": {"url": f"data:image/jpeg;base64,{image_b64}"}},
            ],
        }
    ],
)

print(response.choices[0].message.content)

A short sketch to show the idea. Check the official docs of the tool you use.

  • Trusting the output without checks Parse the JSON in code, check types and ranges, and handle null or missing fields. Flag low-confidence results for review.
  • Sending huge images Resize or compress images before upload. Test the accuracy at the size you send, since more pixels do not always help.
  • Asking vague questions State exactly what to extract and the output format. A specific prompt gives more consistent results.
  • Ignoring image content as an attack path Text inside an image can contain instructions. Treat image text as data, not commands, and keep tool permissions narrow.

Read about structured output and JSON modes, then about evals that measure extraction accuracy on your own sample images. Learn how multimodal inputs are priced and batched by your provider.

Can a vision model read any image?

It can read many images, but accuracy drops with small text, low resolution, dense tables, and unusual handwriting. Test on samples that look like your real inputs.

Should I send a URL or base64 data?

Use a URL when the image is publicly reachable and stable. Use base64 for private files or images that are not hosted. Check your provider's size limits for each.

Does the model remember images I sent earlier?

Not by default. Each request is independent unless you resend the image or your app keeps conversation state.

How do I know if the answer is correct?

Build a small labeled test set of images with known answers, run the model on it, and measure the error rate. Repeat this when you change prompts or models.

Written with AI by CapyLaunch. Spotted a mistake? Email hello@capylaunch.com.