How Text-Only LLMs Can Understand Images: An Intercept-and-Forward Architecture
This article explains how to keep a text-only LLM as the main model while routing image inputs through a low-cost vision model. It covers the request flow, image reference and tool contracts, plugin engineering requirements, vision model selection, and cost estimation.
Text-only LLMs are stable at planning, reasoning, and function calling, but they cannot read images directly. Switching to a native multimodal model solves this problem, but it brings higher inference costs and greater migration effort. Another approach is to keep the existing text model and let a plugin send images to a low-cost vision model, then return a text description to the text model. This article describes the operating flow, interface contract, engineering requirements, and cost estimation method for this approach.
Why Add a Vision Sidecar
Developers usually encounter three problems.
First, cost and capability are hard to balance. Native multimodal models are capable but have high unit prices. Text-only models have low unit prices but cannot see images.
Second, migration costs are high. Changing the underlying model often means rewriting prompts, adjusting context management, and modifying function-calling logic.
Third, the frontend should not need to change. Business interfaces and interaction patterns need to remain unchanged, and image parsing can only be completed in the backend.
The table below compares the two approaches. The table provides qualitative judgments; specific values need to be measured using your own request data.
| Dimension | Native multimodal main model | Text-only main model plus vision sidecar |
|---|---|---|
| Inference cost | Every request is billed at multimodal prices | All requests are billed at text prices; only image requests additionally call the vision model |
| Response latency | Single model call | Image requests add one vision call and one text inference |
| Migration cost | Usually requires re-adapting prompts and tools | Existing prompts, tools, and context logic are largely preserved |
| Model replacement | Replacing the main model affects all business | The text model or vision model can be replaced independently |
End-to-End Flow: Intercept, Inject, Forward, Return
The entire flow consists of four steps.
Intercept. The plugin is deployed in the API gateway or a backend preprocessing module. It identifies images in the request, saves the images to a cache, and assigns a reference ID, such as
img_7f3a. The Base64 data or URL of the image is stored only inside the plugin.Inject. The plugin replaces the image placeholder with a short prompt, for example:
[Image received, reference ID is img_7f3a. If image content is needed, call the get_image_description tool.]
- Forward. When the text model determines that it needs to see the image, it outputs a tool call instruction. After receiving the instruction, the plugin retrieves the image from the cache by reference ID and sends it to the vision model together with the query instruction. An example model output is shown below:
{"tool_name": "get_image_description","arguments": {"image_ref": "img_7f3a","focus": "text and table data in the image"}}
- Return. After the vision model returns a description, the plugin wraps the result as a tool return value and writes it into the context. The text model continues reasoning and answering based on this description.
This flow has one hard rule: the text model only handles image_ref, not Base64 data or accessible URLs. Even if prompts or conversation logs leak, the original access method for the image is not exposed.
Before executing a call, the plugin must also check whether the image_ref belongs to the current session. Otherwise, the model may mistakenly use another user’s image.
Tool Definition and Interface Contract
All four steps must use the same set of field names. Below is the v1 tool definition, with parameter names consistent with the example in the previous section.
tools = [{"type": "function","function": {"name": "get_image_description","version": "v1","description": "Call when the user question involves image content to obtain a text description of the image.","parameters": {"type": "object","properties": {"image_ref": {"type": "string","description": "Image reference ID assigned by the plugin, for example img_7f3a"},"focus": {"type": "string","description": "Content that needs special attention, such as text, people, or charts"}},"required": ["image_ref"]}}}]
The tool return value should use a fixed structure:
{"image_ref": "img_7f3a","status": "ok","description": "The image is a sales table. The first row contains months, and the second row contains amounts..."}
The values of status include ok, timeout, failed, and forbidden. When a call fails, description should be empty, and status should indicate the reason. The plugin should not return an empty string. An empty string can easily cause the model to fabricate image content.
Engineering Requirements for the Plugin Layer
Timeouts and retries. Vision calls need a timeout. A starting value can be 8 seconds, with a maximum of 2 retries and exponential backoff. Production values should be based on the P95 latency of online requests. After a timeout, return status as timeout directly; do not wait indefinitely.
Permission checks. Before each tool call, the plugin checks three things: whether the reference ID belongs to the current session, whether the caller has access permission for that session, and whether the number of calls in the current conversation round exceeds the limit. The limit can be set to 3 calls per round to prevent the model from calling in a loop.
Image cache. The cache needs an expiration time, such as 24 hours, and should be deleted immediately after the session ends. The exact duration should be based on business compliance requirements.
Log redaction. Logs should record only image_ref, image hash, latency, status code, and model name. Logs must not contain Base64 data, presigned URLs, or image pixel content.
Sensitive image handling. Images such as ID cards, faces, and medical records should be redacted or blurred before forwarding. At the same time, confirm the data retention terms of the vision model provider, including whether images are stored and whether they are used for training.
Call auditing. Each vision call should record the time, session ID, caller, status, and latency to facilitate later troubleshooting.
Choosing a Vision Model
The vision model is only responsible for “seeing” and does not need strong reasoning ability. Its task is to accurately extract text, objects, scenes, and tables from images. When selecting a model, focus on four points:
- Recognition accuracy on the target task, especially text recognition (OCR) and table recognition. Test with real images from your own business, rather than relying only on public leaderboards.
- Per-call price and concurrency limits.
- P95 response latency.
- Data processing terms, including whether images are retained and whether they are used for training.
It is recommended to use no fewer than 200 real business images for offline evaluation and to record the error types of each model. Error types are more informative than overall accuracy. For example, an error that recognizes the digit 5 as 6 poses a much higher risk in financial scenarios than missing a decorative element.
How to Estimate Cost
The average cost per session can be estimated with the following formula:
Average cost = Text model cost per session + Image request ratio × Vision call cost
Below is a set of hypothetical numbers used to demonstrate the calculation method; they are not measured results. Assume the native multimodal main model costs 1 unit per session and the text-only main model costs 0.25 units per session.
