How to Make LLMs Generate Images: A Prompt Relay Approach

    This article explains why text-only large language models cannot produce images directly and presents a practical engineering solution called prompt relay. You will learn how to design prompt templates that convert natural language requests into structured image generation URLs, understand the key rendering parameters, integrate the workflow into chat clients or a server-side orchestration layer, and apply prompt engineering techniques for better results. The article also covers the limitations of this approach and possible optimization directions.

    1. The Problem: Why Chat Models Can Write but Not Draw

    A common question in AI development over the past two years is this: chat models excel at text comprehension, long-form writing, and code generation, yet as soon as you ask one to “draw a picture,” it only returns a text description instead of an actual image. Many users assume the model is simply missing a capability. From a system architecture perspective, however, this is an expected outcome of the design.

    Large language models are fundamentally probability predictors over token sequences. Both their input and output spaces are defined within the text domain. An image is a two-dimensional pixel matrix, which differs from text in representation, encoding, and computation. Making a text-only model output pixels directly requires attaching a diffusion model or an autoregressive visual generation module, and not every chat model includes one. So “cannot draw” is not a defect; it is an objective description of a capability boundary.

    The right approach is not to complain about that boundary but to connect the two capabilities through engineering: let the chat model handle intent understanding, description expansion, and structure, and delegate pixel rendering to a dedicated image generation service. The industry refers to this division of labor as multimodal capability orchestration. This article focuses on the simplest and easiest pattern to implement: prompt relay.

    2. Core Principle: Prompt Relay and Capability Decoupling

    Prompt relay means the chat model does not generate the image itself. Instead, it converts the user’s natural language request into a structured image generation request and outputs it; an external rendering service recognizes that request and produces the image.

    The pipeline has four stages:

    1. Intent capture: the user describes the desired scene in everyday language.
    2. Semantic enhancement: the chat model translates the description, fills in details, and adjusts composition and color to form a high-quality prompt.
    3. Request packaging: the prompt is encoded into an accessible resource URL following an agreed template.
    4. Rendering and return: the image service parses the parameters, calls the underlying generation model, and returns the image, which the interface displays.

    The value of this approach lies in three points. First, zero modification: no private API access from the model vendor is required. Second, portability: any model with text output can use the same template. Third, control: parameters, style, and dimensions can be constrained explicitly, which makes batch processing and automation easier.

    It is worth stressing that this method produces “the scene as the model understands it.” The result depends on prompt quality and the capability of the rendering service itself. It is not equivalent to the end-to-end image generation experience of a native multimodal model, and gaps remain in detail consistency, text rendering, and precise instruction following.

    3. Prompt Template Design: From “Getting an Image” to “Getting a Good Image”

    The template is the core asset of this solution. A usable template must constrain three things at once: role, task, and output format.

    The basic template is responsible for “translate + fill in + output directly,” as shown below (the rendering URL is a placeholder; replace it with your own or a compliant rendering service endpoint in practice):

    1. You are an image generation prompt expert. Complete two tasks:
    2. 1. Expand the user's Chinese scene description into a detailed English prompt with cinematic language and color direction;
    3. 2. Output exactly one image reference line using the template below. Do not wrap it in a code block and do not add explanations:
    4. ![image](<RENDER_ENDPOINT>/<ENCODED_PROMPT>?model=<MODEL>&seed=42&width=1024&height=1024&nologo=true&enhance=true)

    The advanced template makes the prompt visible: it first gives a short summary, then outputs the image reference, so users can reuse the prompt in other drawing tools for further creation:

    1. Your role is now a prompt generator.
    2. After the user describes a scene, first give a summary of no more than five words,
    3. then output one image reference line:
    4. ![image](<RENDER_ENDPOINT>/<ENCODED_PROMPT>?width=2048&height=2048&seed=100&model=<MODEL>&nologo=true)

    A few practical rules for template design are worth following:

    • Explicitly forbid code block wrapping. Many clients render code blocks as plain text, so the image will not display.
    • Enforce “output only one reference line.” Extra explanatory text breaks automated parsing.
    • Write prompts in English. Mainstream rendering models parse English semantics more reliably, and the chat model can translate Chinese directly.
    • Fix randomness with a seed. The same seed plus the same prompt produces reproducible results, which makes parameter tuning and comparison easier.

    4. Key Fields in the Parameterized Rendering URL

    The URL in the template is not assembled arbitrarily; each field has a clear meaning, and understanding them enables fine-grained control:

    • Prompt segment: must be URL-encoded. Chinese characters, spaces, and commas must be escaped, or the request will be truncated.
    • model: specifies the underlying generation model. Different models lean toward different styles such as photorealism, illustration, or anime.
    • seed: the random seed. Fixing it makes results reproducible; varying it produces batch candidates.
    • width / height: output resolution. The 1024 level suits quick previews; the 2048 level offers better detail but takes longer.
    • nologo: whether to remove the default watermark. This involves the terms of service and should be confirmed against the rules of the service you use.
    • enhance: whether the server runs another automatic enhancement pass on the prompt.
    • safe: the content safety filter switch. Keep it enabled in production.
    • private: whether to prevent generated results from appearing in a public gallery. This involves data privacy and should remain enabled.

    From an engineering standpoint, it is better to consolidate these fields into a configuration file rather than scattering them across prompts, so switching styles or resolutions does not require changing the template itself.

    5. Client Setup and Integration

    A web chat interface is the fastest way to validate the approach: just paste the template and use it, though it is often affected by queues and rate limits. A more stable option is to connect the capability to a local or self-hosted multi-model client. The general steps are:

    1. Prepare a chat client that supports a custom API endpoint.
    2. Configure the text model’s service URL and key, keeping the key only in a local environment variable.
    3. Create an assistant, put the prompt template in the system prompt area, and save it.
    4. Select an output channel with image rendering capability and send a description to verify the pipeline.

    To turn this into a product feature, the recommended approach is to add an orchestration layer on the server side: receive the business request, call the text model to generate the prompt, request the rendering service, write the binary image to object storage, and return it to the frontend through a content delivery network. Also connect logging and monitoring with alerts, and track failure rate, average latency, and cost per request.

    A schematic server-side flow looks like this:

    1. def draw(user_text: str) -> dict:
    2. prompt = llm_client.enhance(user_text) # Semantic enhancement
    3. params = build_params(prompt, seed=42) # Parameter consolidation
    4. image = render_client.fetch(params) # Request rendering
    5. key = oss_client.put(image) # Persistence
    6. return {"url": cdn_client.sign(key)}

    6. Prompt Engineering Practices

    In relay mode, prompt quality almost determines success or failure. A reusable structure is: subject + action + environment + camera + lighting + color + style + quality terms.

    For example, “a girl on an autumn street” can be expanded as follows: the subject is a short-haired girl; the action is looking back; the environment is a slope covered with fallen leaves; the camera is a 35mm medium shot with shallow depth of field; the lighting is warm dusk side-backlight; the color is a contrast of warm orange and gray-blue; the style is hand-drawn animation; and the quality terms specify high-precision detail. As you can see, once information density increases, output stability improves significantly.

    Negative prompts matter too. Common entries include low resolution, deformed limbs, extra fingers, watermarks, and cluttered text. If the rendering service supports a negative prompt field, pass it explicitly instead of relying on defaults.

    7. Limitations and Optimization Directions

    The boundaries of this approach must be acknowledged objectively. First, text rendering is weak, and Chinese characters inside the image often contain errors. Second, multi-turn revision is difficult, since every change requires running the full pipeline again. Third, adherence to precise spatial relationships (such as “three on the left, two on the right”) is limited. Fourth, it depends on an external rendering service, so availability is constrained by its quota and terms.

    Corresponding optimizations include:固化 common styles as presets and manage prompt versions; build dual quality checks combining manual scoring and automatic filtering; cache results for high-frequency requests to reduce cost; and keep a replaceable rendering adapter layer in the architecture to avoid tight coupling with a single service. If a business requires extremely high control over the output, evaluate self-hosting or private deployment of a generation model, run the inference service on a container platform, and use elastic scaling to handle peaks.

    8. Conclusion

    “A model that cannot draw” is not the end of the road but the starting point of the prompt relay engineering pattern. Assign semantic understanding to the chat model, assign pixel rendering to a dedicated service, and connect the two in a standardized way with templates and parameters—this yields usable AI drawing capability at very low cost. For developers, the real takeaway is not any mysterious piece of code but an understanding of three things: capability decoupling, prompt engineering, and pipeline observability. They apply equally to building various multimodal applications on Baidu AI Cloud.