Guides
Image Generation API for AI Agents: Let Your Agent Create Images
A raw image generation API makes your code do the thinking. Here is how agent-native image generation moves prompt craft and quality checks to the server.
An image generation API turns a text prompt into a picture over HTTP: you POST a prompt, you get back an image URL or bytes. That part is solved and commoditized. What most APIs quietly leave to you is everything around the prompt: writing a prompt good enough to get a usable result, retrying when the first pass is wrong, checking that the output actually matches what you asked for, and keeping a consistent look across a hundred images. When a human sits in the loop, that work is invisible. When an AI agent is the caller, that work becomes code you have to write and maintain.
This post covers both. First, what the raw image APIs actually give you (OpenAI's Images API and Replicate are the honest reference points), and where they stop. Then an agent-native alternative that moves the prompt craft, retries, and quality checks to the server so your agent can call one tool and trust the result. And a straight answer on when a raw API is still the right choice, because for plenty of jobs it is.
What a raw image generation API gives you
The two APIs worth knowing are different shapes of the same idea.
OpenAI's Images API is the entrenched default and the top result for this search. It exposes a Generations endpoint and an Edits endpoint backed by the natively multimodal gpt-image-1 model (plus a cheaper gpt-image-1-mini). You send a prompt and a size (1024x1024, 1536x1024, or 1024x1536), and it returns a PNG, JPEG, or WebP. It follows instructions well and renders text better than most, and it is billed per image via tokens, not a flat free tier.
Replicate is the other common path: a run-any-model HTTP API. You pick a model version, send inputs, and it spins up the hardware and returns the output as HTTPS URLs. Image models are usually long-running, so you either use the synchronous mode for quick results or the asynchronous mode, which returns a prediction ID you poll until it settles. You pay for the seconds of compute you use, and you can run open-source models the closed APIs do not offer.
Both are excellent at the thing they do: prompt in, image out. Neither has any opinion about whether the image is good, on-brand, or what you meant. That judgment is your job.
Which OpenAI API can generate pictures?
The OpenAI image generation API is the Images API, using the gpt-image-1 model family. Older DALL-E model names still route through the same Images API surface, and OpenAI has said image support is coming to the Responses API too, but today the direct answer is: call the Images API's Generations endpoint for a new picture, or its Edits endpoint to modify an existing one. It is a paid API billed per generation, with no permanently free tier.
Why raw image APIs make your code do the thinking
A raw API is a single stateless call. Wrap an agent around it and you inherit four jobs that the API does not do:
- Prompt craft. The quality of a generation is mostly the quality of the prompt. A raw API takes whatever string you send, so your agent has to know each model's prompting quirks and assemble a good prompt every time, or accept mediocre output.
- Retries and error handling. Models refuse, time out, or return an off image. Your code owns the retry loop, the backoff, and the decision about when a result is bad enough to try again.
- Quality checks. Nothing tells you the image has six fingers, the wrong product, or text that says "PRODcT." If your agent needs to know whether the output is usable, you have to run a second model to look at it and score it, then wire that judgment back into the loop.
- Brand and consistency. Every call is a blank slate. Keeping the same style, palette, and character across images means your code carries that context and re-injects it into every prompt, and hopes the model honors it.
None of this is hard in isolation. All of it together is a real system to build and maintain, and it is the same system for every team pointing an agent at a raw image API. That duplicated work is the gap an agent-native surface is meant to close.
An agent-native AI image generation API: tools, not just an endpoint
Dream Pixel Forge exposes image and video generation to agents two ways, both over HTTP and both driven by the same set of tools: a Model Context Protocol (MCP) endpoint, and a zero-dependency command-line tool. MCP is the open standard Anthropic introduced in late 2024 that has since become the common way to connect agents to tools and data, so any MCP-capable client (Claude, Codex, ChatGPT, or your own agent) can connect to the endpoint directly. The dpf CLI wraps the identical calls for agents and scripts that would rather shell out than speak MCP.
The difference from a raw API is that the surface is a small workflow, not a single generate call. An agent runs a short, stateful loop:
- Create a run from a brief. Each run is a unit of work that tracks its plan, spend, and results.
- Store a concept plan before generating anything, so the run knows what it is trying to make.
- Generate one image per planned concept. Prompt assembly and model routing happen server-side; the agent can pass a freeform prompt or a template slug with structured inputs.
- Validate the result with a vision tool that scores the image against the brief and the brand, so the agent can decide whether to keep it or move on.
- Read the run at any point for status, credits spent, and the finished image URLs.
The three jobs your code would otherwise own move into the tools. Prompt craft lives in the templates and server-side assembly. Quality checking is a first-class tool. Brand context is loaded for you.
Self-judging output
The vision tool is the piece a raw API does not have. Called in validate mode, it takes an image the run generated and scores it on three axes: whether it adheres to the brief, whether it adheres to the brand, and whether it has obvious technical flaws, each with a pass or fail flag and a reason. Because the model doing the judging is fed the original brief, the concept description, and the brand profile, the agent gets a structured verdict instead of a raw image it has to trust blindly. That is the "check the output" loop, built in, so your agent asks "is this good?" with one call rather than a second model you host and maintain.
Brand context, loaded for you
An agent can read the brand profile as a tool: a compiled style paragraph, palette, and do and don't lists, plus brand reference images and the brand facts split into what the user has confirmed and what is only proposed. Image generations include the brand references automatically, so the same look carries across a run without your code re-describing the style every time. An agent can also propose a new brand fact it inferred, but it can only propose. Confirming a fact stays a human action in the brand settings, so the agent never quietly rewrites the brand.
Layered spend limits keep an agent from running away
Every generation debits your credit balance in a single server-side transaction, so an agent can never spend past what the account holds. On top of that, each API key has a daily limit on credit-spending calls, and each planned concept allows at most one regeneration, so a retry loop cannot grind against the same shot. This is the guardrail a raw API leaves entirely to you: a misbehaving agent on a metered API is an open tab, while here the blast radius is bounded by your balance and the key's daily limit.
How do I give my AI agent image generation?
Connecting an agent is an authentication step, not an integration project. There are two paths, and both hand the server only a hashed key.
From the command line, dpf login runs a device flow: the CLI mints an API key locally, sends only its SHA-256 hash to the server, and you approve the machine in the browser. The plaintext key never leaves your computer; it is stored at ~/.config/dpf/config.json. After that, the agent has the full tool set:
# authenticate once, then the agent drives it
dpf login
# create a run, plan a concept, generate, and validate
dpf run create "Three launch banners for our new trail shoe"
dpf run plan run_123 "hero: side profile on wet rock, dawn light"
dpf generate run_123 hero --prompt "side profile on wet rock, dawn light"
dpf vision run_123 --generation gen_456 --mode validateFor an MCP client, point it at the /api/mcp endpoint and authenticate with a key you mint yourself. In the app, the settings page has an API keys section where you create a key (shown once), and connectors that cannot send an Authorization header can carry the key in the URL path instead. Either way, the server stores only the hash of the key, so there is no plaintext secret on the server to leak. For CI or headless runs, a DPF_API_KEY environment variable overrides the stored credential.
The same run then powers image-to-video generation through a video tool, so an agent that produced an approved still can animate it in the same session under the same spend limits.
Raw API vs agent-native: an honest comparison
Neither is better in the abstract. They optimize for different callers.
| Raw image API (OpenAI, Replicate) | Agent-native surface (MCP + dpf CLI) | |
|---|---|---|
| Prompt craft | Your code writes and tunes every prompt | Templates and server-side assembly, or a freeform prompt |
| Quality checking | You host a second model to score output | Built-in vision validation against brief and brand |
| Brand and consistency | You carry and re-inject context each call | Brand profile and references loaded automatically |
| Spend control | Open-ended; you build the guardrails | Balance, per-key daily, and retry limits enforced server-side |
| Model choice | Any model the provider hosts, including open-source | A curated set the router selects across |
| Best for | One-off generation, custom pipelines, model research | Agents that need on-brand output they can trust |
When a raw image API is the right choice
Reach for OpenAI's Images API or Replicate, not an agent surface, when:
- You want one image and you will look at it. A human in the loop already does the quality check and the retry. The extra structure buys you nothing.
- You are building your own pipeline and want direct, low-level control over the model, the parameters, and the post-processing. An agent surface deliberately hides some of that.
- You need a specific open-source model or a bleeding-edge checkpoint. Replicate's catalog is the point, and a curated router will not carry everything.
- Brand consistency does not matter for the job, such as throwaway thumbnails or internal test images.
The dividing line is who does the thinking. If your code or a person is going to judge and retry, a raw API is simpler and you should use it. If an agent needs to generate on-brand images and act on the result without a human checking each one, the work of judging and staying on-brand has to live somewhere, and moving it to the server is the difference between one tool call and a system you maintain.
If that is your case, the fastest way to see it is to connect an agent you already run. The dpf CLI and MCP endpoint take a few minutes to wire up, and free credits cover a run or two so you can judge the output on your own brief before deciding anything. Credit costs are on the pricing page.






