Guides

How to Generate Images in Claude Code

Claude Code cannot draw, but it can drive a tool that does. Here is how to make Claude Code and Cursor generate on-brand images over MCP or the dpf CLI.

6 min read

Claude Code cannot draw. The model writes text and code, so on its own it has no way to put pixels on a canvas. What it can do is call a tool that generates the image for it, then read the result back and decide whether it is good enough. That is the whole trick behind every "Claude Code made me a hero image" demo: the agent is orchestrating an image model through a tool, not painting anything itself.

This is a hands-on setup guide. By the end, Claude Code will be able to generate on-brand images from a plain-English request, check its own output, and stop when it hits a spending limit, using Dream Pixel Forge as the image backend over MCP or its command-line tool. The same steps work in Cursor and any other MCP client.

Two ways to wire it up

There are two integration paths, and they hit the same backend. Pick based on how you like to work:

  • The dpf CLI. A zero-dependency command-line tool. You authenticate once with a browser approval, and Claude Code drives it as ordinary shell commands. Nothing gets pasted into a config file. This is the simplest path and the one to start with.
  • A direct MCP connection. Register Dream Pixel Forge as a remote MCP server so its tools appear natively inside Claude Code's tool list. This is the right choice if you want the agent calling typed tools rather than shelling out, or if you are wiring it into a claude.ai connector.

Both talk to the same HTTP endpoint and spend from the same credit balance. The rest of this guide sets up each one.

Option A: the dpf command-line tool

The CLI ships on npm as dreampixel-cli and installs a dpf command. Authenticate first:

npx dreampixel-cli login

This opens a browser approval page. The key is minted on your machine and only its SHA-256 hash is sent to the server, so the plaintext key never leaves your computer. It is stored at ~/.config/dpf/config.json with 0600 permissions. For CI or a headless box, skip the browser step and set DPF_API_KEY in the environment instead; it takes precedence over the stored key.

Now teach your agent the workflow. Run this once in your project:

dpf skill install

That writes .claude/skills/dpf/SKILL.md, a skill file that tells Claude Code the create, plan, generate, validate loop, the credit costs, and how to keep a character consistent across images. With the skill in place, you can ask Claude Code for images in plain language and it knows which commands to run. Under the hood, those commands are:

dpf run create "launch sheet for the spring capsule"
dpf run plan <runId> "hero: wide shot on set" "detail: fabric close-up"
dpf generate <runId> hero --prompt "…" --ar 16:9
dpf vision <runId> --generation <id> --mode validate
dpf run status <runId> --watch

Run dpf --help to see every command. The important ones: dpf run create starts a run, dpf run plan stores the concepts before anything is generated, dpf generate renders one concept, dpf vision scores an image against your brief, and dpf run status --watch polls until the run settles. There is also dpf video for clips and dpf templates to list the built-in generation templates.

Option B: connect it as an MCP server

If you would rather have the tools appear inside Claude Code natively, add Dream Pixel Forge as a remote MCP server. The endpoint is https://www.dreampixelforge.com/api/mcp and it expects your API key as an Authorization: Bearer header. Mint a key from your account settings first (never paste a key into a chat), then run:

claude mcp add --transport http dpf https://www.dreampixelforge.com/api/mcp \
  --header "Authorization: Bearer dpf_your_key_here" --scope user

Use --scope user to make it available across all your projects, or --scope project to commit it to a single repo's config. After it connects, Claude Code lists the Dream Pixel Forge tools alongside its built-ins and can call them directly.

For Cursor, the same server goes in an MCP config file: ~/.cursor/mcp.json for a global setup, or .cursor/mcp.json in a project. Add the server under mcpServers and restart Cursor:

{
  "mcpServers": {
    "dpf": {
      "url": "https://www.dreampixelforge.com/api/mcp",
      "headers": {
        "Authorization": "Bearer dpf_your_key_here"
      }
    }
  }
}

What does the agent actually do?

However you connect, the tools Claude Code gets are the same. The workflow is deliberately a loop, not a single generate call, so the agent produces assets it can stand behind instead of firing off one prompt and hoping:

  1. Start a run. create_run takes a brief and opens a Studio run that tracks everything generated for it.
  2. Plan the concepts. update_run stores the list of images to make, a hero shot and a detail shot, say, before a single credit is spent. Every generation has to reference a planned concept.
  3. Generate. generate_image renders one concept from a freeform prompt or a template, and returns the finished image URL.
  4. Validate. vision looks at the generated image with a vision model and scores it against the brief, the concept, and your brand. This is the step that lets the agent catch a bad result and retry instead of handing you garbage.
  5. Poll. get_run reports status, credits spent, and the URLs of everything generated.

There are also read tools the agent leans on for context: get_brand_profile pulls your compiled brand block (style, palette, do and don't lists, and brand reference images), get_templates lists the generation templates, and get_influencers returns your saved AI personas so the agent can keep a face consistent. The point of routing through these rather than a raw text-to-image API is that the agent generates on brand without you re-describing your style every time.

What keeps an agent from overspending?

An autonomous agent that can spend money on image generation is exactly as scary as it sounds, so spending is bounded in layers. Your credit balance is the hard ceiling — every generation debits it in a server-side transaction, so an agent can never spend credits you do not have. Each API key also has a daily limit on credit-spending calls, which caps what an unattended loop can do in a day, and each planned concept allows at most one regeneration, so a retry loop cannot burn credits on the same shot. The agent itself is instructed to generate exactly what the plan calls for rather than batching out speculative variations.

Individual images are cheap: the baseline model runs about 2 credits per image, with higher-fidelity models costing more. That pricing is what makes the agentic loop practical. The agent can afford to generate a few options, validate them, and discard the weak ones without burning through your balance. Video costs more and is capped at two clips per run.

A real request, start to finish

With the skill installed, you do not type any of the commands above. You ask. A request like "generate a 16:9 hero image for the pricing page and a matching square thumbnail, on brand" kicks off the full loop: Claude Code creates a run, pulls your brand profile, plans the two concepts, generates each one, validates them with the vision tool, and reports back the URLs, retrying any image the validation step flagged as off-brief. You review the results and either accept them or send a note back for another pass. The agent handles the orchestration, the spend limits keep it honest, and you never hand-wrote a prompt.

If you would rather generate in a browser than from an agent, the same models are one click away in the web app. Describe what you want and it renders, no CLI required.

The bottom line

Claude Code does not generate images; it operates a tool that does. Give it that tool, either the dpf CLI with a one-time dpf login, or a remote MCP connection with a Bearer key, and it can produce on-brand hero shots, app assets, and product mockups from a plain-English brief, check its own work, and stop at a spending limit you set. Start with the CLI and dpf skill install; it is the shortest path from a fresh checkout to an agent that ships real images.

Tools for this guide

Frequently asked questions

Can Claude Code generate images on its own?
No. Claude Code is a language model: it writes text and code and has no built-in way to render pixels. It generates images by calling an external tool that runs an image model, then reading the result back. So the answer to "is there any way to generate an image from Claude Code" is yes, but only by giving it an image-generation tool over MCP or a command-line tool it can run. Dream Pixel Forge provides both.
How do I connect Dream Pixel Forge to Claude Code?
Two ways. The simplest is the dpf CLI: run "npx dreampixel-cli login" to approve your machine in the browser, then "dpf skill install" so Claude Code knows the workflow, and it drives the tool as shell commands. Alternatively, add it as a remote MCP server with "claude mcp add --transport http dpf https://www.dreampixelforge.com/api/mcp --header \"Authorization: Bearer dpf_your_key\" --scope user", which makes its tools appear natively in Claude Code. Both hit the same endpoint.
Do I need an API key, and how do I get one?
Yes, generation is tied to your account. With the CLI you never paste a key: "dpf login" mints one on your machine and sends only its SHA-256 hash to the server, storing the plaintext key locally at ~/.config/dpf/config.json. For a direct MCP connection you mint a key from your account settings and pass it as an Authorization: Bearer header. For CI, set DPF_API_KEY in the environment.
How much does it cost, and what stops an agent from overspending?
Images are priced in credits: the baseline model is about 2 credits per image, and higher-fidelity models cost more. Your credit balance is the hard ceiling — every generation debits it in a server-side transaction — and each API key has a daily limit on credit-spending calls, with at most one regeneration allowed per planned concept.
Does this work in Cursor too?
Yes. Dream Pixel Forge is a standard remote MCP server, so any MCP client works. In Cursor, add it under mcpServers in ~/.cursor/mcp.json (global) or .cursor/mcp.json (per project) with the endpoint https://www.dreampixelforge.com/api/mcp and an Authorization: Bearer header, then restart Cursor.
Can the agent keep images on-brand and characters consistent?
Yes, that is the reason to route through Dream Pixel Forge rather than a raw image API. The agent can read your compiled brand profile (style, palette, do and don't lists, brand reference images) and your saved AI personas, then generate against them, so output matches your brand without you re-describing it. It also validates each image against the brief with a vision tool and retries when a result misses.