All insights

Image generation

Can Claude Code Generate Images? Native Capability vs. Image APIs

Claude Code can help run an image-generation workflow, but the cited Anthropic docs don’t establish built-in photo or illustration generation. See how to use a separate image API.

Illustration for Can claude code generate images

Short answer

Claude Code can help create images through code or a connected external service, but the cited Anthropic documentation does not establish that Claude Code has a built-in model for generating photos or illustrations. Anthropic describes Claude generally as unable to generate photos or illustrations like image-generation tools. It describes HTML/SVG diagrams, charts, and interactive visuals as a beta feature on Claude web and desktop—not as a Claude Code feature. The Claude Help Center does not specifically settle Claude Code’s native capability.

In the API example below, the external image model generates the image. Claude Code can help write and run the project script; command execution may depend on your permission settings.

Use a separate image API for photos or illustrations

OpenAI documents image generation through its Responses API. Its example uses gpt-6-astra as the top-level model and configures the image_generation tool with gpt-image-2.5-sunburst. The Python example extracts the result from an image_generation_call, decodes the base64 data, and saves it as a PNG. The code below follows that documented pattern, changing only the prompt and output filename. (developers.openai.com)

Install the OpenAI Python SDK with pip install openai, and make an API key available in the environment as OPENAI_API_KEY; the SDK can read the key from there. OpenAI says organization verification may be required before using GPT Image models. (developers.openai.com)

from openai import OpenAI
import base64

client = OpenAI()

response = client.responses.create(
    model="gpt-6-astra",
    input="Generate a clean, flat illustration of a red bicycle against a pale blue background.",
    tools=[{"type": "image_generation", "model": "gpt-image-2.5-sunburst"}],
)

image_data = [
    output.result
    for output in response.output
    if output.type == "image_generation_call"
]

if image_data:
    with open("output.png", "wb") as file:
        file.write(base64.b64decode(image_data[0]))
else:
    raise RuntimeError("The response contained no generated image.")

To use this from a Claude Code project, ask it to create the script, ensure the API key is available to the process, review the file, and then ask it to run python generate_image.py. Claude Code documents reading and editing project files and running commands; whether a command runs immediately or requires approval depends on permission settings.

Which route should you choose?

  • A photo or illustration: Use a separate image-generation model or API, as in the example. The external model generates the image; Claude Code can help with the code and workflow.
  • A diagram or chart: HTML or SVG may be suitable. Anthropic documents its custom-visual feature for Claude web and desktop beta, but that does not establish availability in Claude Code.
  • A connected image service: Claude Code supports MCP connections to external tools, but check the specific image service’s current compatibility and setup instructions before relying on it.

Bottom line: Claude Code can participate in image generation through a script or appropriately configured external tool. The cited sources do not establish that Claude Code itself natively generates raster photos or illustrations.

Sources

Image generation | OpenAI API

Image generation | OpenAI API

SDKs and CLI | OpenAI API

Can Claude produce images? | Claude Help Center

Claude Code overview

Tools reference | Claude Code Docs

Connect Claude Code to tools via MCP

Contact us