When you ask Codex for an image, why does it sometimes return a flat, SVG-like drawing instead of a real illustration?
You were expecting a photo or an illustration, but what you got was a collection of simple geometric shapes.
"Is this the limit of Codex's image generation?"
I thought so too at first. I suspected the cause was using words like "icon" or "logo," which made Codex choose to draw with SVG, HTML, or CSS instead of actual image generation.
So, I tested it by running Codex myself.
I called Codex from Claude Code and compared the following Before/After results:
- Before: Simply asked to "Create a simple cat icon."
- After: Specified the image generation tool, subject, color, texture, prohibitions, and save location.
The results confirmed my suspicions.
The short request returned a flat cat icon that was actually a rasterized SVG, even though the extension was PNG.
On the other hand, the request that explicitly stated the image generation tool and completion conditions produced a rich image featuring a cat holding a microphone, a blue circular frame, a yellow background, and even bokeh effects.
In short, this verification revealed the following:
By communicating not just the subject, but also the use of an image generation model, the avoidance of SVG alternatives, and details like color and texture, you can change the very way Codex creates images.
In this article, I will organize how to create the images you want in Codex based on official OpenAI information and actual measurement results from July 13, 2026.
Conclusion First
Here are the key points:
- Codex can generate photos and illustrations, but it can also create visuals using SVG, HTML, and CSS.
- Even if the extension is PNG, the content may be an image converted from SVG.
- When you want a photo or illustration, adding
$imagegento the prompt explicitly calls the image generation skill. - The difference in quality comes from "purpose, subject, style, composition, and constraints" rather than prompt length.
- The value of detailed specifications is making the composition easier to reproduce for its intended use, rather than just making it look fancy.
- Don't aim for perfection in one go; fix elements one by one by specifying what to change and what to keep.
If you want to try it immediately, add the following sentence to the beginning of your request:
──────── For Copy-Paste ────────
Use $imagegen to generate a raster image using the image generation model. Do not substitute with SVG, HTML, CSS, or canvas.
──────────────────────
However, it's not just this one sentence that works. By conveying "what the image is for" and "what constitutes a passing grade," Codex can finally check the image against the same standards as you.
Why Does it Output SVG Instead of an Image?
Codex is not a dedicated image generation service. It writes code, reads existing files, fixes websites, and handles SVG, HTML, CSS, and canvas as needed. This is a great strength.
For example, if a website has an existing SVG icon set and you want to add one more icon with the same line width, color, and size, editing the existing SVG is more accurate than creating a PNG with an image generation model.
On the other hand, header images for articles, photo-style visuals, textured characters, and advertising banners are better suited for image generation than code.
The current imagegen skill in Codex also distinguishes between these two:
- It uses image generation for tasks suited for bitmap images, such as photos, illustrations, textures, sprites, and mockups.
- It prioritizes editing existing SVG, vector, or code assets for tasks where that is better.
Crucially, this isn't decided mechanically just by the word "icon" or "logo."
Even for the same icon, there are two types of uses:
- Scalable vector components used in UIs.
- Decorative single images with texture and shading used on SNS.
If the request is ambiguous, Codex guesses which one you want based on existing files in the project or the surrounding context. When that guess deviates from your intention, you get the phenomenon of "getting something like an SVG when you wanted a photo."
Therefore, the essence of the problem is not that "the word icon is forbidden." It is that the format of the desired output has not been communicated to Codex.
What Can Be Confirmed from Official Information
In Codex image generation, three similar names appear, but they have different meanings:
$imagegen: The name to explicitly call Codex's image generation skill.image_gen: The name of the image generation tool built into Codex.gpt-image-2: The model ID when specifying the model directly via API or fallback CLI.- "Image 2.0" or "GPT Image 2 equivalent": Terms used to convey the quality image, not the formal model ID at runtime.
For normal image generation, the basic approach is to call the skill with $imagegen and use the built-in image_gen tool. In this path, you don't need a separate OPENAI_API_KEY.
Directly specifying gpt-image-2 as the model ID is for when you explicitly use the API or fallback CLI. This path requires an OPENAI_API_KEY.
Additionally, effective image prompts follow these principles:
- Specifically convey the purpose, subject, background, composition, style, and constraints.
- Write specific details like light direction and placement rather than abstract terms like "beautiful" or "stylish."
- When correcting, change one element at a time and repeat the conditions you want to maintain.
- Enclose text within the image in quotes and specify the typeface, color, size, and placement.
What we learn from this is that $imagegen is an officially provided explicit way to call the skill. It doesn't mean you "absolutely cannot create an image without it." However, in our "Before" case, the path to create an SVG instead of image generation was chosen. Its role is to make the intention to use image generation clear rather than leaving it to automatic judgment.
Actual Before/After
Here are the actual measurements. I called Codex from Claude Code. The Codex CLI used was version 0.144.1, executed by logging into a ChatGPT account without adding an API key.
To be clear, this is not a strict comparative experiment where only one condition was changed. In the "Before," I only briefly stated what I wanted to make. In the "After," I specified the generation tool, storage format, subject, color, composition, prohibitions, and quality.
In other words, this is a Before/After look at how much the results change when you specify the request after experiencing a failure.
Before: Asking Only for a "Simple Cat"
The initial request sent to Claude Code was just this:
──────── For Copy-Paste ────────
Create a simple cat icon
──────────────────────
I did not specify the image generation model, PNG, SVG, color, texture, background, or save location.
And here is what came back:

Examining the file revealed the following:
- Filename:
cat-icon.png - Format: PNG, RGBA
- Size: 1024x1024 pixels
- Bit depth: 16-bit
- File size: approx. 121KB
- Appearance: A flat brown tabby cat face made of overlapping simple shapes.
It's a composition with a large cat face on a light yellow circular background. The expression is cute, and it follows the request for a "simple cat icon."
In other words, Codex did not ignore the instructions. Rather, the problem was that the request was too short to convey the "finished illustration with texture by an image generation model" that I expected.
A cat-icon.svg was also created in the same folder. Furthermore, the PNG metadata contained SVG components like svg:title as "Cute brown tabby cat face icon" and svg:comment for "background," "ears," "face," "eyes," and "collar."
This means Codex interpreted the "simple icon" as a request for vector material, created an SVG, and converted it to PNG.
The "Before" wasn't a failure; it was too literal. Because I only said "simple," Codex made it simply with easy-to-edit geometric shapes.
After: Fixing the Generation Method and Final Image
Next, I called Codex from Claude Code with the following content:
──────── For Copy-Paste ────────
mkdir -p ./images
codex exec -C "$(pwd)" -s workspace-write --skip-git-repo-check \
"Use the image generation tool (image_gen / gpt-image-2) to generate a cute illustration of a cat holding a microphone in PNG and save it to ./images/cat-mic.png. Use flat and cute coloring, soft shadows and highlights, a blue circular frame, a background of #FDE68A with small stars and bokeh, an accent color of #2563EB, and the cat should be cream to orange. Create it as a single illustration and do not substitute with SVG or HTML/CSS. Do not include text or watermarks. Quality is high."
──────────────────────
This is the actual command used. However, image_gen and gpt-image-2 are not aliases for the same thing. If you are using the built-in Codex functionality, the recommended way to write it now is:
──────── For Copy-Paste ────────
mkdir -p ./images
codex exec -C "$(pwd)" -s workspace-write --skip-git-repo-check \
'$imagegen to use the built-in image_gen tool to generate a cute illustration of a cat holding a microphone as a PNG. Use flat and cute coloring, soft shadows and highlights, a blue circular frame, a background of #FDE68A with small stars and bokeh, an accent color of #2563EB, and the cat should be cream to orange. Do not substitute with SVG or HTML/CSS. Do not include text or watermarks. After completion, save the generated image to ./images/cat-mic.png. Finish with high quality.'
──────────────────────
The reason the entire prompt is enclosed in single quotes is to prevent the $ in $imagegen from being expanded as a shell variable, passing it directly to Codex.
The difference from "Before" isn't just that the text is longer:
- Explicitly states the image generation tool
- Saves as PNG
- No substitution with SVG or HTML/CSS
- Subject is a cat holding a microphone
- Flat, cute coloring with soft shadows and highlights
- Includes a blue circular frame
- Background color set to #FDE68A
- Includes stars and bokeh
- Accent color set to #2563EB
- Cat color set to cream/orange
- No text or watermarks
- Quality set to high
- Save location fixed to
./images/cat-mic.png
Here is the generated image:

The actual file was as follows:
- Filename:
cat-mic.png - Generation path: Codex built-in image generation tool
- Format: PNG, RGB
- Size: 1254x1254 pixels
- Bit depth: 8-bit
- File size: approx. 1.74MB
The image reflects the cream-to-orange cat holding a microphone, the blue circular frame, the yellow background, blue stars, and bokeh. There are soft shadows and highlights on the fur and microphone, providing much more information as a finished illustration compared to the "Before" version. No text or watermarks are present.
What I Learned Comparing the Two Results
Even with the same PNG extension, the content is completely different.
Both Before and After have the .png extension. However, Before was an image converted from SVG to PNG, while After was a raster image created directly by the image generation tool. You cannot judge if it's the expected generation method just by the fact that it was "delivered as a PNG."
The Before result was correct for the prompt.
What I asked for in Before was a "simple cat icon." What came out was indeed a simple cat icon. It wasn't that Codex's ability was low; it was that my words didn't limit the final image.
After instructed the generation path.
What worked in After wasn't a vague request like "make it prettier." It was specifying the use of the image generation tool, no SVG substitution, color, subject, background, texture, and save location.
The quality difference cannot be attributed solely to image_gen.
In After, I changed the subject, color scheme, shading, background, and quality simultaneously with the generation tool. Therefore, the visual improvement cannot be isolated as the effect of the single word image_gen. However, it at least clarified the intention to avoid the "SVG to PNG conversion path" and proceed to the image generation model.
Communicate not just what you want, but how you want it made. This is the biggest lesson learned from this Before/After.
What is the Purpose of Adding $imagegen?
Looking at these results, you might think, "If a PNG came out without it, is $imagegen unnecessary?"
It's true that if the request is clearly for a photo or illustration, Codex may automatically choose image generation. However, there are three reasons to be explicit:
- Reduce path mix-ups In projects with many existing SVG or UI assets, Codex might judge code editing to be appropriate. If you need a single image, explicitly stating image generation reduces the deviation in intent.
- Standardize requests across a team If the meanings of "image," "icon," and "banner" differ from person to person, the outputs will vary. By making
$imagegenand the purpose a common rule, it becomes easier to choose the same path even if the person making the request changes.
- Easier to isolate the cause of failure If you explicitly stated image generation but the result is poor, the next things to look at are composition, style, and constraints. If the path is unknown, you don't know if "the image generation model is bad," "it was made with SVG," or "the prompt is ambiguous."
Think of $imagegen not as a magic spell to increase image quality, but as a switch to fix the execution method.
Shortest Usable Prompt
First, please copy and paste this format:
──────── For Copy-Paste ────────
Use $imagegen to create the following image with the image generation model. Do not substitute with SVG, HTML, CSS, or canvas; generate it as a single raster image.
Purpose: X profile picture
Subject: Cat holding a microphone
Style: Friendly, 3D illustration with a sense of depth
Composition: Square, centered, subject remains intact even if cropped into a circle
Constraints: No text, logos, or watermarks
──────────────────────
You don't need to write everything in detail. OpenAI's official guide also explains that clear sentences of 1-3 sentences are often sufficient for image prompts. What's important isn't the length, but including the conditions that determine success.
5 Items to Stabilize Image Quality
If you're unsure about the prompt, just write these five things:
- Purpose Write where the image will be used. Example: X post, profile picture, blog header, LP hero image, product introduction. When you write the purpose, Codex can more easily judge the necessary composition and margins.
- Subject Write what to draw and in what state. Example: A brown tabby cat holding a microphone, a woman working on a laptop, coffee placed on a desk.
- Style Specify the desired texture, such as photo, illustration, or 3D. Example: Realistic photo with natural light, magazine-style editorial illustration, soft watercolor, 3D with depth.
- Composition Write the aspect ratio, position of the subject, and necessary margins. Example: Landscape, person on the left, leave wide margin on the right for a headline. In our After example, the "blue circular frame" instruction resulted in a composition where the cat and microphone were contained within the circle.
- Constraints Write what you don't want included and conditions to be followed. Example: No text, no logos, no watermarks, don't make the background complex.
With these five items, Codex can not only "make a picture" but also check "if it fits the purpose."
Copy-Paste Examples by Purpose
Article Header Image
──────── For Copy-Paste ────────
Use $imagegen to generate a landscape header image for a blog post. Make it a realistic photo of a laptop and coffee placed on a wooden desk, shot in soft natural morning light. Left-align the subject and leave a wide margin on the right for a headline. Do not include text, logos, or watermarks. Do not substitute with SVG, HTML, or CSS.
──────────────────────
X Post Square Image
──────── For Copy-Paste ────────
Use $imagegen to generate a square illustration for an X post. Express the scene of AI and a person collaborating at the same desk to come up with a plan using a friendly editorial illustration. Place the person and the AI device in the center, with a composition where the subject is clear even when viewed on a smartphone timeline. Use blue and orange as base colors, and do not include text, logos, or watermarks.
──────────────────────
LP Hero Image
──────── For Copy-Paste ────────
Use $imagegen to generate a hero image for an online business tool LP. Make it a natural photo of a small team talking while looking at a large screen in a bright office. Landscape orientation with people right-aligned, leaving a margin on the left for a headline and button. Do not include excessively futuristic expressions, text, corporate logos, or watermarks.
──────────────────────
Image with Japanese Text
──────── For Copy-Paste ────────
Use $imagegen to generate a square image for an X post. Place only the text "AIで仕事が変わる" (AI changes work) in a large, bold, white Gothic font at the top center. Text should be on one line, center-aligned. Do not add any other text, logos, or watermarks. The background should be a gradient from dark blue to purple, with a calm design for business.
──────────────────────
When putting text in an image, follow these three points:
- Enclose the text to be displayed in quotes.
- Specify the typeface, color, size, and position.
- Tell it not to add any other characters. After generation, check every character before publishing.
When Correcting, Write "What to Change" and "What to Keep"
When the first image is almost there, you don't need to rewrite the entire prompt from scratch. In fact, changing too much at once will change the parts you liked. Make corrections one element at a time.
- Keep the composition as is, but make the background brighter.
- Keep the person and desk, but replace the mug with a houseplant.
- Maintain the color and light, but widen the margin on the right.
- Keep the cat's expression and fur color, but make the microphone slightly smaller.
OpenAI's official guide also recommends clarifying "what to change" and "what to maintain" when editing. Here is a usable format:
──────── For Copy-Paste ────────
Please edit the attached image. Only change the background. Make the background light gray. Maintain the person, clothing, expression, composition, light, and color tone exactly as they are. Do not add text or logos.
──────────────────────
By writing "Only change this. Don't touch anything else," you can reduce the drift of the overall image.
If Writing Every Time is a Hassle, Fix the Rules
When calling Codex from Claude Code, it's a hassle to enter the same notes every time. In this operation, it's recommended to first place image generation rules in the project's CLAUDE.md. Since Claude Code reads CLAUDE.md, you fix "how to request Codex when asked for an image" here.
If it's a project where you use Codex directly, put the same idea in AGENTS.md. AGENTS.md is a project rule that the Codex side reads.
──────── For Copy-Paste ────────
Image Generation Rules
- Use
$imagegenwhen creating photos, illustrations, banners, hero images, or SNS post images. - If a raster image is requested, do not substitute with SVG, HTML, CSS, or canvas.
- Before generating, organize the purpose, subject, style, composition, and constraints.
- Only edit SVG to match the existing format when adding to an existing SVG icon set.
- Save the completed image within the project and report the storage location. ──────────────────────
The purpose of this rule is not to always ban SVG. It's to choose according to the purpose: SVG for UI components, and image generation for a finished single image.
Is it necessary to make it a Skill?
You don't need to create a new Skill just to generate images. Codex already has an imagegen skill. Creating a custom Skill becomes valuable when you want to standardize procedures across multiple projects, such as:
- Applying brand colors or art styles every time.
- Automatically choosing compositions by purpose, such as for X, articles, or LPs.
- Checking text, margins, size, and prohibitions after generation.
- Unifying filenames and save locations.
- If it fails, applying corrections based on the same standards.
The judgment is simple:
- Rules used in one project:
CLAUDE.md - Project rules for Codex to follow directly:
AGENTS.md - A mechanism to reuse "generation -> confirmation -> saving" across multiple projects: Custom Skill
You don't need to build a Skill from the start. It's enough to start with CLAUDE.md and consider making it a Skill once you find yourself repeating the same procedure three or more times.
Situations Where SVG is the Correct Answer
While I've explained how to call image generation, SVG itself is not bad. SVG is more suitable for the following uses:
- Adding a new icon to an existing UI icon set.
- Keeping lines sharp even when scaled.
- Changing colors with CSS.
- Managing shapes and line widths accurately with numerical values.
- Reviewing differences as code.
Conversely, image generation is suited for:
- Photo-style visuals.
- Illustrations requiring textures like fur, cloth, or metal.
- Eye-catchers for advertisements or articles.
- Single images with characters or storytelling.
- Visuals that convey atmosphere or emotion.
The criterion is not "SVG or PNG." It is "Is it a component to be managed deterministically, or a single image prioritizing expressiveness?" Deciding this before asking Codex will reduce path mismatches.
3 Misconceptions Corrected in This Verification
Finally, here are the points I was able to correct because I actually tried it.
Misconception 1: If it's a PNG, it's made with an image generation model.
The initial image this time was a PNG, but the metadata contained SVG titles and components. The appearance was also a combination of simple shapes, leading to the judgment that it was an image converted from SVG to PNG. What you should check is not just the extension, but what path it was created through and its actual appearance.
Misconception 2: Adding $imagegen will increase image quality.
The "After" this time had a much more informative appearance than the "Before." However, I simultaneously specified the microphone, color scheme, shading, background, composition, and quality. Explicitly stating the image generation tool fixes the generation path, but that alone doesn't guarantee a finish to your liking. You also need conditions that determine the appearance and passing conditions to judge if it fits the purpose.
Misconception 3: The longer the prompt, the better.
The reason "After" became better wasn't because the word count increased. It was because it included conditions that determine the result: image generation tool, SVG ban, subject, color scheme, background, texture, and save location. Write the conditions necessary for judgment, not length.
Summary
When Codex returns a simple image, the first thing to doubt is not the performance of the image generation model. Check if your intention is communicated: whether you want a vector component for code or a finished single image as a photo or illustration.
If you want a single image, first add this sentence:
──────── For Copy-Paste ────────
Use $imagegen to generate a raster image using the image generation model. Do not substitute with SVG, HTML, CSS, or canvas.
──────────────────────
On top of that, write the purpose, subject, style, composition, and constraints.
In this actual measurement, when I only asked Claude Code for a "simple cat icon," Codex interpreted it as a request for vector material and created a flat PNG derived from SVG. On the other hand, by calling the image generation skill with $imagegen, using the built-in image_gen tool, not substituting with SVG, and specifying the subject, color scheme, texture, background, and quality, it becomes easier to create a finished illustration that reflects those specifications.
What determines image quality is not the length of the prompt. It's whether you've shared not just what to make, but what it's for and what state constitutes a passing grade. When you communicate this much, Codex becomes more than just an image generator; it becomes a production partner that creates and checks images according to the purpose.
To start, try adding one "purpose" and one "passing condition" to your usual image requests. That alone will bring you closer from image generation that waits for a lucky hit to image production that reproduces intended results.
References:


![Yusuke Narita's Genius AI Utilization Techniques [Preservation Edition]](/cdn-cgi/image/width=1920,quality=90,format=auto,metadata=none/https%3A%2F%2Fcms-assets.youmind.com%2Fmedia%2F1784137658627_u4bwry_HNMS89bbsAAUPJI.jpg)


