Image Generation with Text-Only LLMs: A Practical Guide
This article explores a practical method for enabling text-only Large Language Models (LLMs) to generate images. By leveraging Markdown syntax and public text-to-image APIs, text models can "draw" by acting as prompt engineers and formatting image links. The guide covers the underlying principles, prompt template design, parameter tuning, troubleshooting, and engineering considerations for this workflow.
1. Background: Why Text-Only Models Cannot Draw Natively
Current mainstream LLMs fall into two categories: multimodal models with built-in image understanding and generation capabilities, and text-only models restricted to text input and output. While the latter excel at code generation, copywriting, and logical reasoning, they can only output text descriptions when asked to “draw an image.”
However, text-only models have a natural advantage: they output structured Markdown text, which supports image syntax:

If the rendering client (chat UI, note-taking app, Markdown-supported client) can render this syntax, and the image URL points to a service that dynamically generates images based on parameters, the text model can indirectly fulfill the drawing request. This is the core concept of the approach discussed in this article.
2. Principle: Teaching Models to Assemble Image Links
The workflow breaks down into three steps:
- Semantic Translation: Translate the user’s description into high-quality, detailed English prompts. Image generation models typically respond more stably to English prompts, a task at which text-only LLMs excel.
- Template Filling: Insert the generated English prompt into a predefined URL template to construct the complete image link.
- Markdown Output: The model outputs the link using Markdown image syntax, allowing the frontend to render the image for the user.
The essence is a division of labor: the text model handles creativity and formatting, while the image service handles rendering. Note that the image service refers to common public text-to-image APIs. Readers can choose any service that supports generating images via URL parameters; this article does not endorse any specific vendor.
3. Prompt Template Design
To ensure the model works stably, the prompt must define the role, task, and output format. A reusable template is as follows:
You are a world-class image generation master with outstanding visual perception and artistic intuition for translating text into images. Please complete the following tasks:1. Translate the user's image description into a delicate, vivid, and visually striking English prompt. Expand on details, atmosphere, composition, and color to make it suitable for generating high-quality images.2. Fill the translated English prompt (URL encoded) into the {prompt} section of the following template, and output it in Markdown image syntax:Important: Output the Markdown URL directly. Do not put it in a code block.
Design Notes:
- Role Setting: Giving the model the identity of a “prompt expert” significantly improves the detail of the description.
- Clear Output Format: Emphasizing “do not put it in a code block” is critical because Markdown inside a code block will not be rendered; users would only see a string of link text.
- One-Step vs. Two-Step: The template above completes “translation + image generation” in one step. If you desire better controllability, you can use a two-stage prompt. The first stage only outputs the English prompt, which you manually review before assembling the URL. This approach makes it easier to adjust details and migrate the prompt to other drawing tools.
Two-stage template example:
Now, you will act as a prompt generator. I will describe an image, and you will:1. Provide a summary of no more than 5 words;2. Output a detailed English prompt suitable for image generation, covering subject, environment, lighting, composition, color, and artistic style.
After obtaining the reviewed prompt, manually replace it into the URL template.
4. Key Parameter Tuning
The parameters in the URL template significantly impact the output. Common parameters and their functions are as follows:
| Parameter | Function | Tuning Suggestions |
|---|---|---|
| width / height | Output dimensions | Use 768×1024 for portrait, 1280×768 for landscape, and 1024×1024 for square images |
| seed | Random seed | Fixing the seed reproduces the same image; change the value to alter the style |
| model | Underlying model | Different models have distinct styles; switch as needed |
| nologo | Remove watermark | Availability depends on the service’s rules |
| enhance | Auto-enhance | When enabled, the service will expand the prompt. Effects can be impressive or sometimes deviate from intent |
5. Common Issues and Troubleshooting
- Only link text visible, no image: This is usually because the output is wrapped in a code block, or your client does not support Markdown image rendering. Switch to a chat interface that supports Markdown rendering.
- Image fails to load: Check if the URL contains non-English or special characters; the prompt section must be URL encoded. It could also be temporary rate limiting from the service; retry later.
- Image deviates significantly from expectations: Prioritize enriching the subject description and style keywords (e.g., “flat illustration,” “watercolor,” “cyberpunk”) in the prompt. Then, adjust the seed and enhance parameters.
- Service instability during peak hours: If you are using a conversational service that requires online calls, consider integrating a stable and reliable inference platform. For example, accessing via Baidu AI Cloud’s large model service provides a stable API experience and monitoring alerts, significantly reducing peak-time call failures and facilitating the encapsulation of the entire drawing workflow into your own application.
6. Engineering Tips and Capability Boundaries
- Understand capability boundaries: The image quality of this solution depends on the backend image service. The text model only processes the prompt, so do not expect it to match the native effects of top-tier drawing products. It is more like giving text-only models the wings to draw.
- Official capability evolution: Many text-only models are evolving toward multimodality, and official native drawing capabilities may be launched at any time. This “external workaround” is more suitable as a lightweight transitional feature or a personal creative tool.
- Content safety: Public APIs called via URL parameters typically lack a strict content moderation pipeline. When using them in a production environment, be sure to add your own prompt filtering and result review to avoid compliance risks.
- Transferability: This prompt engineering concept (role setting + format constraints + template filling) is not bound to a specific model. Almost any LLM with instruction-following capabilities can apply it, which is its greatest value.
Conclusion
In summary, drawing with text-only models is essentially a combined application of “prompt engineering + Markdown rendering + public text-to-image APIs.” Once you understand the principle, you can not only replicate this approach but also extend it to more practical automated workflows, such as batch illustration and stylized poster generation.
