How to Generate Unlimited AI Images for Free With Claude Code + Cloudflare

By Hasan Aboul Hasan Published 2026-07-07 Updated 2026-07-09
TL;DR

I taught Claude Code to generate AI images through Cloudflare Workers AI (the flux-1-schnell model). I describe the picture in plain English, Claude writes the detailed Flux prompt, runs one small script, and the JPG lands in my project folder. The free tier covers about 170 images a day, and it resets every day, forever. Setup is two credentials and about ten minutes.

What you'll have at the end
  • A working cf-image skill inside Claude Code: describe a picture, get a JPG
  • Free Cloudflare credentials wired into a .env file the right way
  • The exact math on your daily allowance, so you know what "free" really means
  • Prompt patterns tuned for flux-schnell, including the one thing it cannot do

Every image in this guide came out of my terminal while I was writing it. My total bill: $0.

The engine is Cloudflare Workers AI, which gives every account a free daily allowance. The brain is a tiny Claude Code skill that does the prompt engineering for you. No subscription, no GPU in my machine, no trial countdown.

One honest note before we start, because "unlimited" is doing some work in that title. There is a daily cap. But it resets every day, with no end date, and at default settings you'd need to generate an image every 8 minutes, around the clock, to hit it. For a solo builder, that's unlimited.

Connecting Claude Code to an outside API with a skill is also one of the most useful patterns you can learn right now. It's the same move I use across my own products, and the one I teach start to finish in Build With AI 1.0.

The free-forever promise

The whole pipeline is this:

your idea  →  Claude writes an optimized prompt  →  Cloudflare Flux API  →  saved JPG

Three pieces make it work:

  • FLUX.1 schnell is an open-weight image model by Black Forest Labs. "Schnell" is German for "fast": it's the speed-tuned member of the FLUX.1 family, built to produce a good image in very few passes.
  • Cloudflare Workers AI runs that model on Cloudflare's GPUs and exposes it as a plain HTTPS endpoint. You never touch a server. And every account gets a free daily allocation of compute.
  • A Claude Code skill: one 64-line Python script plus one instructions file. Claude reads the instructions, writes a proper Flux prompt from your rough idea, runs the script, and reports the saved file.

Why would Cloudflare give this away? Because the free allocation is worth about 11 cents a day at their paid rates, and it pulls developers onto their platform. Their marketing budget, your image pipeline. I did the exact math below.


Step 1: Get your Cloudflare credentials

You need two values: your Account ID and an API token that's allowed to run Workers AI. Both come from one screen, and a free account is enough:

  1. Sign up (or log in) at dash.cloudflare.com. The free plan works.
  2. In the left sidebar, open AI → Workers AI.
  3. Click Use REST API.
  4. Click Create a Workers AI API Token. Cloudflare prefills a token template with exactly the right permission. Review it and hit Create API Token.
  5. Click Copy API Token and keep it somewhere safe for the next step. This is the only time it's shown in full.
  6. On the same screen, find Get Account ID and copy that value too.

Prefer to build the token by hand? Go to My Profile → API Tokens → Create Token and give it the Workers AI: Read and Workers AI: Edit permissions. Same result.

Treat the token like a password. It can spend your Cloudflare account's AI allowance. It goes in a .env file that stays out of git (the repo below ships a .gitignore that handles it). If a token ever lands in a commit, revoke it in the dashboard and make a new one. Deleting the commit is not enough; git history remembers.


Step 2: Wire it into Claude Code

A Claude Code skill is just a folder with a SKILL.md file in it. Think of it as a sticky note on Claude's monitor: "when the user asks for an image, here's how you do it." The cf-image skill folder holds that note plus the script it points to:

.claude/skills/level-3-image-generator/
├── SKILL.md      ← when to trigger + how to write a good Flux prompt
└── generate.py   ← calls Cloudflare, decodes the image, saves the JPG

The script's core is one HTTP request. This is the whole trick, no framework, no SDK:

MODEL = "@cf/black-forest-labs/flux-1-schnell"

url = f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{MODEL}"
resp = requests.post(
    url,
    headers={"Authorization": f"Bearer {api_token}"},
    json={"prompt": args.prompt, "steps": args.steps},
)

image_b64 = resp.json().get("result", {}).get("image")
with open(args.output, "wb") as f:
    f.write(base64.b64decode(image_b64))

To set it up, grab the ready-made skill folder from the free toolkit below (or hand-build it from this page, it's small on purpose), drop it into your project, and install the two dependencies:

pip install requests python-dotenv

Then copy the env template and paste in the two values from Step 1:

cp .env.example .env

Your .env ends up with exactly two lines:

CF_ACCOUNT_ID=your_cloudflare_account_id
CF_API_TOKEN=your_cloudflare_api_token

That's the setup. Done.

🧭 New to Claude Code? Skills are the feature that turns it from a code assistant into a worker you can hand your own playbooks to. If you want to go from "I installed it" to shipping a real product with it, Build With AI 1.0 is the zero-to-shipped path.


Step 3: The cf-image skill in action

Open Claude Code in the project and ask for a picture the way you'd ask a person:

make me a picture of a cyberpunk cat coding at night

Here's what happens. Claude matches your request against the skill's description, reads the sticky note, and does the one job the raw API can't do for you: it expands your six words into a real Flux prompt. Subject, style, framing, lighting, mood. This is the prompt it actually sent when I ran exactly that request:

a cyberpunk cat coding at night, close-up of a fluffy tabby cat wearing tiny neon-rimmed glasses in front of a glowing laptop, dark room lit by pink and cyan neon signs, rain-streaked window in the background, cinematic photo, shallow depth of field, moody high-contrast lighting

Then it runs the script. Real terminal, real output:

Terminal: generate.py called with the detailed cyberpunk-cat Flux prompt, printing 'Saved cyberpunk-cat.jpg' with the full prompt and 4 steps.

And this is the image that came back, a few seconds later, for zero dollars:

AI-generated photo of a fluffy tabby cat wearing glowing neon-rimmed glasses at a laptop, lit by pink and cyan neon signs; the neon sign text behind it is illegible gibberish.
Generated live on the free tier while writing this guide. Keep an eye on that neon sign; we'll come back to it.

The same prompt engineering is what turns vague business asks into usable assets. Ask for "a logo for a coffee shop" and Claude sends something like:

minimalist logo of a steaming coffee cup, flat vector illustration, warm brown and cream palette, centered on a clean off-white background, simple bold shapes, modern branding
AI-generated minimalist flat-vector logo of a steaming brown coffee cup centered on a cream background.
Six words in, a brand-ready concept out. Also generated on the free tier for this guide.

After every run, Claude tells you the filename and the exact prompt it used. Want a variation? Say what to change and it re-runs with a tweaked prompt and a new filename. That loop, describe, look, adjust, is the entire workflow.


How many free images per day? (the Neuron math)

Cloudflare bills AI work in Neurons. Think of a prepaid electricity meter that refills to 10,000 units every day. Every image draws a little power. The meter never sends you a bill; when it's empty, the lights go off until tomorrow's refill.

Here are the live numbers from Cloudflare's pricing page, verified the day I published this:

What Cost
Free daily allocation (every account) 10,000 Neurons/day
One diffusion step (a refinement pass of the model) 9.6 Neurons
One 512×512 tile of output 4.8 Neurons
One default image (1024×1024 = 4 tiles, 4 steps) 57.6 Neurons
Images per day, default settings ≈173
Images per day at --steps 8 ≈104

I checked the output size against a live run: the script's images come back at 1024×1024, which is four 512×512 tiles. So the default image costs 4 × 9.6 + 4 × 4.8 = 57.6 Neurons, and 10,000 ÷ 57.6 ≈ 173 images.

What happens when the meter runs out? On the free plan, the API starts returning errors until the daily reset. Nothing upgrades itself, nothing charges you. Pricing drifts, though. If you're reading this long after July 2026, check the pricing page before you plan around the numbers.

💻 Free on GitHub

Want the ready-made skill?

The full cf-image skill, plus every other image skill I've built for Claude Code, is one open repo. Clone it and drop the skills into .claude/skills/.

Get it on GitHub →


Flux-schnell prompt tips

The skill handles this for you, but knowing the rules makes you better at directing it:

  • 4 steps is the sweet spot. Schnell is distilled to converge fast; that's the whole point of the model. The script defaults to --steps 4, and 4 to 8 covers everything. More steps means a slower image and a bigger Neuron bill, not necessarily a better picture.
  • It cannot render legible text. Scroll back to the cat. Flux tried to write something on that neon sign and produced "Rattiy". Don't ask it for words, logos with lettering, or UI mockups with labels. Generate the visual, add real text yourself afterward with code or a design tool.
  • Name five things in every prompt: the subject (concretely), the style or medium (photo, flat vector, watercolor, isometric), the composition (close-up, wide shot, centered), the lighting and mood (golden hour, neon, soft studio light), and the palette or detail cues.
  • One or two sentences is enough. A wall of comma-separated keywords doesn't help schnell; a short, vivid description does.

Or skip the checklist entirely and let Claude apply it. That's the point of the skill: the rules live in SKILL.md once, and every future request gets them for free. Teaching your tools your standards once, instead of retyping them forever, is a core move I keep coming back to in Build With AI 1.0.


Get the skill (free)

Everything in this guide comes from my claude-image-generation toolkit, and I'm giving away the whole thing, not just this one skill. One opt-in gets you:

  • The cf-image skill from this guide: free Flux images via Cloudflare Workers AI
  • Two "no AI model" image skills: a code-based design engine for quote cards, posters, and carousel slides, plus a Three.js renderer for real 3D shots, both running on pure code with zero API cost
  • The full story pipeline: skills that split a story into scenes, illustrate them with consistent characters, narrate them with AI voices, and package everything into an interactive HTML player
💻 Free on GitHub

The Claude Code image-generation toolkit

Every skill above, ready to drop into .claude/skills/. Describe an image in the chat, get the file on disk. It is one open repo, so clone it and go.

Open the repo on GitHub →

I'm publishing separate guides for the other pieces, and both are live now: how I make Claude Code draw real graphics with no AI model at all, pure code, perfect text, and the advanced payoff, keeping one character consistent across a whole illustrated, narrated story.


FAQ

Is this really free, or free-trial free?

Really free. Cloudflare's Workers AI free allocation gives every account 10,000 Neurons per day at no charge, and it resets daily with no end date. There is no trial clock. At Cloudflare's paid rate the whole daily allowance is worth about 11 cents, which is why they can afford to give it away. If you use up the allowance on the free plan, requests return an error until the next reset; nothing gets charged behind your back.

How many free images do I get per day?

About 170 at the default settings. A default flux-1-schnell image is 1024×1024 at 4 diffusion steps, which costs 57.6 Neurons: 4 steps at 9.6 Neurons each plus four 512×512 tiles at 4.8 Neurons each. Divide the daily 10,000 Neuron allowance by 57.6 and you get roughly 173 images. If you raise the steps to 8, it drops to about 104 a day. Full math above.

Can I use the images commercially?

The model, FLUX.1 schnell by Black Forest Labs, is released under the Apache 2.0 license, which puts no restriction on what you do with generated outputs. So blog heroes, thumbnails, and product mockups are fine. The usual common-sense limits still apply: don't generate someone's trademark or a real person's likeness and expect a license to save you.

Do I need to deploy a Cloudflare Worker?

No. Despite the name, Workers AI is reachable as a plain REST API. The script sends one HTTPS request with your token and gets the image back as base64. There is nothing to deploy, host, or keep running.

How good is flux-1-schnell compared to paid models?

Very good for scenes, concepts, thumbnails, and stylized art, which covers most of what a builder needs day to day. Schnell is the fast, distilled member of the FLUX.1 family, so it gives up some fine detail and it cannot render legible text. Premium models also beat it when you need the same character to stay consistent across many images; that needs reference-image support, which is a different workflow I cover separately.

Does the script work without Claude Code?

Yes. generate.py is a normal command-line script: pass it a prompt and an output filename and it saves the image. Claude Code adds the layer that makes it pleasant, turning a six-word idea into a detailed, well-structured Flux prompt before calling the script.


What this is part of

This guide gave you one pattern: teach Claude Code a skill, point it at an outside API, get a capability for free. A real product is that pattern applied twenty times, wrapped in a codebase, auth, payments, and users.

That's what I cover in Build With AI 1.0. The full course is 38 lessons that walk through:

  • Building a full AI SaaS with Python and Django, from empty folder to deployed product
  • Wiring LLMs and AI APIs into real features, the same pattern this guide used, at product scale
  • The engineering thinking to direct AI tools instead of copy-pasting and praying
  • Auth, payments, and shipping to real users

🚀 Want the full system?

The course is here: Build With AI 1.0 →


  • Updated July 2026
  • Model flux-1-schnell
  • Cost $0 (free tier)
  • Time ~10 minutes
  • Difficulty Beginner
Last verified: July 9, 2026 against Cloudflare's live pricing page (10,000 free Neurons/day, 9.6 per step, 4.8 per tile) and a real generation run.


Hasan Aboul Hasan builds open-source tools and teaches solo developers how to build, host, and sell AI-powered products. Founder of LearnWithHasan.com, creator of SimplerLLM and PyRunner.

Last verified: July 9, 2026 (Cloudflare Workers AI pricing re-checked live, both demo images generated on the free tier while writing).

Ship it.

Vibe Engineering Blocks — free guide
Free guide

Get the free Vibe Engineering Blocks guide

The exact building blocks I use to ship real products with AI — yours as a free PDF.

Free PDF · double opt-in · unsubscribe anytime.