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.
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
dpfCLI. 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 loginThis 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 installThat 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> --watchRun 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 userUse --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:
- Start a run.
create_runtakes a brief and opens a Studio run that tracks everything generated for it. - Plan the concepts.
update_runstores 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. - Generate.
generate_imagerenders one concept from a freeform prompt or a template, and returns the finished image URL. - Validate.
visionlooks 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. - Poll.
get_runreports 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.






