How to Generate Images with Claude Code (2026): 3 Methods

Claude Code can't generate images on its own. Here's how to add image generation to Claude Code — via MCP servers or one CLI. Step-by-step with examples.

by AnyCap

Abstract digital art showing a glowing pixel cursor transforming into colorful neon fragments — dark purple and blue developer aesthetic

No, Claude Code cannot generate images on its own. It's a terminal-based coding agent built for code reasoning, file manipulation, and shell execution — not pixel generation. But you have three practical options to add image generation to Claude Code: an MCP server, a capability runtime CLI, or a direct API integration.

This guide walks through all three, with real commands and output examples, so you can pick the approach that fits your workflow.


Can Claude Code Generate Images? The Short Answer

Claude Code (Anthropic's terminal-native AI coding agent) has zero built-in image generation capability. It can write the <Image> component, set up lazy loading, and optimize responsive breakpoints — but it cannot produce the actual image file.

This isn't a bug. Claude Code is designed to excel at code — planning, refactoring, debugging, shipping — and nothing else. If your task stays inside .tsx and .py files, Claude Code is unmatched. The moment you need a hero image, a diagram, or a social media graphic, you hit a wall.

Here's what that looks like in practice:

You: "Generate a hero image for our SaaS landing page."

Claude Code: I can't generate images. 
I can write the HTML/CSS for the hero section and placeholder 
components. You'll need to source the image separately.

This guide shows you how to close that gap.


Why Image Generation Matters for Claude Code Users

If you only use Claude Code for bug fixes and boilerplate, image generation isn't critical. But the most productive Claude Code workflows involve shipping complete features end-to-end — and complete features need visual assets:

  • Landing pages need hero images, logos, and section illustrations
  • Documentation needs diagrams, architecture visuals, and screenshots
  • Social media launches need graphics, banners, and thumbnail images
  • UI prototypes need mockup images to show design intent
  • Marketing sites need product shots, comparison graphics, and icon sets

Without image generation, every one of these tasks forces you out of the terminal — breaking the autonomous agent workflow that makes Claude Code powerful.


Method 1: MCP Server (Replicate, Fal.ai, or Bannerbear)

Best for: Teams already running MCP servers, developers who want model-level control.

The Model Context Protocol (MCP) is the standard way to connect external tools to Claude Code. Several MCP servers expose image generation models:

Option A: Replicate MCP Server

Replicate hosts open-source image models (Stable Diffusion, FLUX, SDXL) behind an API. Their MCP server exposes those models as Claude Code tools.

Setup:

# Install the Replicate MCP server
claude mcp add replicate -- npx -y @replicate/mcp-server \
  --env REPLICATE_API_TOKEN=r8_your_token_here

Use from Claude Code:

You: "Generate an image using the Replicate tool: 
       a modern SaaS dashboard with dark theme, blue accents, 
       using the black-forest-labs/flux-schnell model."

Claude Code: [calls Replicate MCP tool]
  Generated image: output.png (1024x1024)

Pros:

  • Access to open-source models (FLUX, SDXL)
  • Pay-per-use pricing (no monthly commitment)
  • Active community maintaining the MCP server

Cons:

  • ~15 minutes setup time (create Replicate account, get API key, configure MCP)
  • ~6,000 token overhead in Claude Code's context just for tool descriptions
  • Model selection is on you — you need to know which model ID to use
  • Output is a raw image file — no CDN URL unless you upload separately

Option B: Fal.ai MCP Server

Fal.ai specializes in fast inference for generative models. Setup is similar:

claude mcp add fal -- npx -y @fal-ai/mcp-server \
  --env FAL_KEY=your_fal_key_here

Tradeoff: Faster inference than Replicate, but fewer model options and smaller community.

Option C: Bannerbear MCP (for templated images)

If you need programmatic image generation (social media templates, OG images, dynamic banners), Bannerbear's MCP server is purpose-built for that:

claude mcp add bannerbear -- npx -y @bannerbear/mcp-server \
  --env BANNERBEAR_API_KEY=your_key_here

Method 2: AnyCap CLI (One Command, No Configuration)

Best for: Individual developers and small teams who want image generation now — not after 15 minutes of MCP setup.

AnyCap is a capability runtime that bundles image generation, video, web search, and more behind a single CLI. Claude Code invokes it directly from the terminal — one install, one command, one credential.

Setup (30 seconds)

# One command installs the skill and CLI
npx -y skills add anycap-ai/anycap -a claude-code -y
curl -fsSL https://anycap.ai/install.sh | sh
anycap login

Generate Images from Claude Code

Once installed, Claude Code can generate images through the anycap CLI directly:

Basic image generation:

anycap image generate \
  --model seedream-5 \
  --prompt "a minimal SaaS dashboard on a light background, clean UI, rounded corners, blue accent" \
  -o dashboard-hero.png

Output:

Generating image with seedream-5...
Image saved to dashboard-hero.png (1024x1024, 487KB)
CDN URL: https://cdn.anycap.ai/v1/images/abc123/dashboard-hero.png

The CDN URL is returned immediately — no separate upload step, no S3 configuration. Claude Code can embed it directly in HTML or markdown.

Advanced: Generate multiple variants:

anycap image generate \
  --model nano-banana-pro \
  --prompt "developer working in a dark terminal, ambient purple lighting, wide shot" \
  --variants 3 \
  -o dev-terminal

This produces dev-terminal-1.png, dev-terminal-2.png, and dev-terminal-3.png — three variations to choose from.

Image-to-image refinement:

anycap image generate \
  --model seedream-5 \
  --prompt "same composition but warm orange lighting instead of blue" \
  --reference dashboard-hero.png \
  -o dashboard-hero-v2.png

Models Available Through AnyCap

Model Best For Style Speed
Seedream 5 High-quality photorealistic and design Photorealistic, UI, product Medium
Nano Banana Pro Fast iteration, concepts, drafts Versatile Fast
Nano Banana 2 Landing pages, hero images, marketing Clean, commercial Fast

Claude Code doesn't need to know model IDs — the runtime selects the best model for the prompt if you don't specify one.

Pros:

  • 2-minute setup — one install, one login, one credential
  • ~2,000 token overhead — vs ~24,000 for five separate MCP servers
  • Built-in CDN — generated images get public URLs automatically
  • Multiple models — switch between Seedream 5, Nano Banana Pro, and more without reconfiguring
  • One credential for everything — same login covers image, video, search, storage, and publishing
  • Claude Code native — commands run in your terminal session, output is structured JSON

Cons:

  • Pay-as-you-go — no flat monthly rate (starts with $5 free credit)
  • Curated models — you use the models AnyCap offers, not arbitrary HuggingFace models
  • Internet required — no local-only generation

Method 3: Direct API Integration (OpenAI, Stability AI)

Best for: Developers who need maximum control and are comfortable writing their own integration code.

You can give Claude Code image generation by writing a tool that calls an image API directly:

# tools/generate_image.py
import requests
import sys

API_KEY = "your-openai-api-key"

def generate(prompt: str, output_path: str = "output.png"):
    response = requests.post(
        "https://api.openai.com/v1/images/generations",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json={"prompt": prompt, "n": 1, "size": "1024x1024"}
    )
    url = response.json()["data"][0]["url"]
    
    # Download the image
    img = requests.get(url)
    with open(output_path, "wb") as f:
        f.write(img.content)
    
    return output_path

if __name__ == "__main__":
    prompt = sys.argv[1]
    path = sys.argv[2] if len(sys.argv) > 2 else "output.png"
    result = generate(prompt, path)
    print(f"Image saved to {result}")

Then register it as a Claude Code tool via MCP. This gives you full control over the API, model, and output handling — at the cost of writing and maintaining the integration yourself.

Pros:

  • Full model selection control
  • Custom error handling
  • No external dependencies beyond the API

Cons:

  • You write and maintain the integration code
  • Manual API key management
  • No built-in CDN — you handle storage and URLs separately
  • Output format is whatever the API returns

Comparison: Which Method Should You Choose?

MCP Server AnyCap CLI Direct API
Setup time 15-30 min 2 min 30-60 min
API keys to manage 1 per server 1 total 1 per API
Context token overhead ~6,000 ~2,000 ~3,000 (your tool)
Model selection Manual (know model IDs) Curated (or auto-select) Full manual control
CDN / sharing Manual upload Built-in Manual
Multi-model switching Reconfigure MCP server Command-line flag Rewrite integration
Best for Teams already on MCP Individuals and small teams Full-stack control

Real Workflow: End-to-End with Claude Code + Image Generation

Here's what a complete landing page build looks like with image generation integrated:

You: "Build a landing page for a new AI developer tool called 'CodeLens.' 
      Include a hero section with a generated image, a three-column 
      features section, and a CTA."

Claude Code:
  1. Searches the web for similar developer tool landing pages (web search)
  2. Scaffolds a Next.js project with Tailwind CSS
  3. Writes the landing page components
  4. Calls anycap image generate for a hero image:
     "futuristic code analysis dashboard, dark theme, 
      glowing data visualization, developer tool aesthetic"
  5. Embeds the generated CDN URL in the <Image> component
  6. Generates feature icons for each section
  7. Runs the dev server for preview
  8. Commits and pushes to GitHub

You: "Deploy it."

Claude Code: 
  Builds the project, publishes the page, returns the live URL.

One session. One terminal. Zero tool switching. That's the difference between a coding assistant and a complete development agent.


FAQ

Can Claude Code generate images by itself?

No. Claude Code is a text-only coding agent. It reads, writes, and edits code and files. It has no built-in image generation model, runtime, or API. All image generation must come from external tools — MCP servers, a capability runtime like AnyCap, or direct API calls.

Why can't Claude Code just call an image API?

It can — if you set it up. Claude Code has full shell access and can execute curl commands or Python scripts. The challenge isn't that Claude Code is blocked from calling APIs; it's that setting up the tool, managing API keys, and handling output formats requires configuration that Claude Code doesn't do on its own. Methods 1 and 2 above automate that setup.

Does Anthropic plan to add image generation to Claude Code?

Anthropic has not announced any plans to add image generation to Claude Code. Claude Code is focused on code reasoning and terminal execution. Image, video, and media generation are outside its scope — which is why external capability layers exist.

What's the cheapest way to generate images from Claude Code?

AnyCap starts with $5 free credit (no payment required) and charges pay-as-you-go at model provider rates with no markup. Individual MCP servers like Replicate also offer pay-per-use pricing. For occasional use (a few images per session), either approach costs pennies per image.

Can I use Midjourney or DALL-E from Claude Code?

Directly, no — neither Midjourney nor DALL-E has an official MCP server or CLI. You can write a custom integration that calls their APIs (Method 3), but this requires writing and maintaining your own tool code. AnyCap's curated models (Seedream 5, Nano Banana Pro) provide comparable quality without the integration work.

Do I need a GPU to generate images from Claude Code?

No. All three methods use cloud APIs — the generation happens on remote servers, not your local machine. Your terminal session sends a prompt and receives a URL or file. No local GPU, no model downloads, no hardware requirements beyond a terminal.

How do I use the generated image in my project?

With Method 2 (AnyCap CLI), the image is saved locally to the path you specify AND uploaded to a CDN. Claude Code can embed the CDN URL directly:

<Image src="https://cdn.anycap.ai/v1/images/abc123/dashboard-hero.png" 
       alt="SaaS dashboard hero" width={1200} height={600} />

With Method 1 (MCP), the image is saved locally — you need to handle CDN uploads separately if you need public URLs.


Next Steps


Claude Code is an Anthropic product. AnyCap is an independent agent capability runtime.