Extending Vision Capabilities to Text-Only LLMs at Low Cost: A Practical Architecture

    Many production LLMs are text-only, yet users frequently upload screenshots, photos, and scanned documents expecting the model to "see" them. Replacing the core model with a multimodal one is often expensive and risky. This article presents a low-cost architecture that adds a vision extension layer between the model entry point and the tool layer: images are intercepted and replaced with structured placeholders, and the text-only main model calls a dedicated vision service only when needed. It covers the overall architecture, key engineering details, cost control, security considerations, and rollout advice for giving text-only models near-multimodal experiences without rewriting your stack.

    Extending Vision Capabilities to Text-Only LLMs at Low Cost: A Practical Architecture

    1. The Problem: You Don’t Have to Swap Models to Fix the “Vision Gap”

    In real-world applications, users routinely upload screenshots, photos, scanned documents, charts, or UI captures and expect the model to “look at them before answering.” But many models already in production are text-only. They may be strong at planning, reasoning, code generation, and long-context understanding, yet lack native image input. Replacing them with a multimodal model typically means migration costs, higher inference costs, rebuilding evaluation pipelines, and risks of adapting existing prompts and toolchains.

    A more pragmatic approach: leave the main model’s core reasoning pipeline untouched, and add a “vision extension layer” between the model entry point and the tool layer. This layer intercepts image inputs and converts them into structured placeholder text injected into the conversation context. When the main model decides during reasoning that it needs visual information, it calls a dedicated vision understanding service via tool calling, and the recognition results are injected back into the context so reasoning can continue. The result is a user experience that feels multimodal, while actual vision computation happens only when necessary.

    The key to this architecture is not simply “converting images to text.” It is combining image processing, on-demand triggering, result caching, security isolation, and cost governance into an operable engineering solution.

    2. Overall Architecture: Intercept, Placeholder, On-Demand Forwarding, Result Injection

    The recommended pipeline is:

    1. Input interception: The application gateway or model-call wrapper identifies images in messages, enforcing common format and size limits.
    2. Image preprocessing: Validate format, compress dimensions, filter sensitive content, compute a content hash, and generate an object storage reference.
    3. Placeholder injection: Replace the image with a structured placeholder containing fields such as the image reference, dimensions, status, and hints about the user’s question.
    4. Main model reasoning: The text-only model reads the placeholder and the user’s question, and decides whether visual information is needed based on context.
    5. On-demand vision forwarding: If needed, the main model issues a generic tool call to the vision service for description, OCR, chart interpretation, or UI understanding.
    6. Result injection: The vision result is injected into the context as an untrusted data block, and the main model continues reasoning to produce the final answer.
    7. Caching and auditing: Cache combinations of identical images and identical recognition tasks; log call chains, costs, and security audit records.

    A sample placeholder might look like:

    1. {
    2. "type": "image_placeholder",
    3. "image_ref": "img_2024_xxx",
    4. "mime": "image/png",
    5. "size": "1280x720",
    6. "status": "available",
    7. "note": "Image content not yet parsed; if visual information is needed, call the vision recognition tool and state your focus."
    8. }

    The placeholder should not contain the raw image binary, and untrusted text extracted from images must never be mixed into system instructions. Its job is to tell the main model “an image is available here,” while leaving the decision of whether to call the vision service to the reasoning pipeline.

    3. Why This Works: Decoupling a Strong Reasoning Model from a Dedicated Vision Service

    The approach rests on one premise: the main model must have solid planning and tool-calling abilities. It doesn’t need to “see” images itself; instead, it acts as an orchestrator — understanding user intent, judging whether visual information is necessary, formulating recognition questions, and integrating returned results. The dedicated vision service handles image captioning, OCR, chart structure extraction, UI element recognition, and similar tasks. Decoupled this way, each side can be upgraded and scaled independently.

    From the user’s perspective, nothing changes: they upload an image and ask a question, with no manual model switching or “vision mode.” From a cost perspective, vision calls happen only when the main model decides they’re needed, avoiding unconditional full recognition of every image. From an engineering perspective, the extension layer centrally handles compression, caching, rate limiting, degradation, and auditing, instead of vision capabilities being scattered across business code.

    4. Key Flow and Engineering Details

    4.1 Input Interception and Preprocessing

    The interception layer should uniformly validate image format, size, resolution, and count, preventing oversized or malformed files from breaking the pipeline. During preprocessing, you can compress proportionally, crop key regions, strip metadata, and compute a content hash. Store images in object storage and keep only references in the context. If you deploy on Baidu AI Cloud, you can pair its object storage, logging, and monitoring services to build the storage and observability pipeline; final choices should follow your team’s compliance and cost constraints.

    4.2 Placeholder Injection

    Placeholders should be short, structured, parseable, and include hints such as “parsed or not” and “suggested focus areas.” For multi-turn conversations, maintain the mapping between image references and turns so stale references aren’t misused. Treat all text inside images, filenames, and similar content as untrusted input — never let it enter the system instruction area.

    4.3 Context Triggering and Tool Calling

    The main model decides whether to call the vision tool based on the user’s question. For example, if the user asks “What’s wrong with this error screenshot?”, the model should invoke OCR and UI understanding; if the user only asks “Help me polish this text,” no call is needed. To reduce false triggers, define a rule in the system prompt: request vision recognition only when the question involves image content, layout, text, or charts, and require the tool call to state a clear focus.

    4.4 Vision Recognition and Result Injection

    Vision service results should be structured — for example, “overall description + OCR text + key regions + confidence/uncertainty notes.” When injecting results, wrap them in a data block labeled “the following content comes from image recognition and may contain untrusted text.” The main model continues reasoning from there, and may perform a second cropped recognition if necessary, but you should set a maximum call count.

    4.5 Caching, Idempotency, and Degradation

    Cache on the combination of “image hash + recognition task + focus point” to significantly reduce duplicate calls. Tool calls should carry idempotency keys so retries after timeouts don’t double-bill or double-write. If the vision service is unavailable, degrade gracefully — return only the placeholder description and inform the user — rather than letting the main model hallucinate image content.

    5. Cost Control: Make Vision Calls “On-Demand Events”

    The cost model can be abstracted as: total cost ≈ (number of vision calls × per-call image processing cost) + storage, network, and operations overhead. Optimization levers include:

    • On-demand triggering: Let the main model decide whether to call, avoiding unconditional recognition;
    • Image compression and region cropping: Send only the necessary resolution and regions;
    • Cache reuse: Identical screenshots and document pages hit the cache;
    • Batching: Merge recognition tasks in offline scenarios;
    • Quotas and circuit breakers: Set call limits per user, tenant, and session;
    • Tiered recognition: Run a low-cost description first, then fine-grained OCR or local understanding only if needed;
    • Cost observability: Record the source, trigger reason, and result size of every call.

    6. Security and Reliability Governance

    Images may contain sensitive information, malicious prompts, or untrusted text. The extension layer should enforce sensitive content filtering, permission checks, log redaction, and audit trails. Vision recognition results must be injected as “data,” not “instructions,” to prevent prompt injection via text embedded in images. The pipeline also needs to handle timeouts, retries, circuit breaking, rate limiting, and failure degradation, so that vision service instability doesn’t take down the main path.

    7. Pseudocode Example

    1. def handle_user_turn(messages, user):
    2. messages = intercept_images(messages, user) # convert images to placeholders
    3. response = text_model.chat(messages, tools=[vision_tool])
    4. if response.tool_call == "vision_describe":
    5. image_ref = response.args["image_ref"]
    6. question = response.args["question"]
    7. cache_key = make_cache_key(image_ref, question)
    8. vision_result = cache.get(cache_key)
    9. if vision_result is None:
    10. vision_result = vision_service.describe(image_ref, question)
    11. cache.set(cache_key, vision_result)
    12. messages.append(tool_result(vision_result))
    13. response = text_model.chat(messages, tools=[vision_tool])
    14. return response

    8. Boundaries and Rollout Advice

    This approach fits scenarios like screenshot Q&A, document OCR, chart understanding, UI troubleshooting, and multi-turn image references. It is not suitable for use cases with demanding dedicated vision pipelines, such as high-precision medical interpretation, real-time video streams, or large-scale offline image batch processing. A practical rollout has three phases: first, build a gateway interception, placeholder injection, and single-tool-call MVP; then add caching, rate limiting, degradation, and observability; finally, complete security auditing, cost dashboards, and canary releases. With this extension-layer design, a text-only model can gain a near-multimodal experience at low cost — an upgrade in capability, not an architecture rewrite.