Generate images in Claude Code with Driftflight's text-to-image API
Driftflight's text-to-image API returns one image per request, so Claude Code can add a README hero, docs art or a placeholder product shot with one shell command. A sketch image costs $0.01, and the storefront quotes the price in a 402 before anything is charged. Send POST https://agents.driftflight.com/zcj/klku6g33v32h/v1/images/generate with model set, through a payment client such as zero fetch with a spending cap, then download imageUrl into the repository.
At a glance
- Endpoint:
POST https://agents.driftflight.com/zcj/klku6g33v32h/v1/images/generate, one image per request - Body:
prompt(required),model(sketch,studioorgallery) and optionalpreset. A body withoutmodelis billed as studio, so set it every time. - Price per image: sketch $0.01, studio $0.06, gallery $0.14
- Payment: a 402 is the price quote, which you pay and retry. x402 and MPP are the wallet rails, both settling in USDC. No API key or Driftflight account.
- Payment client: the Zero CLI (
zero fetchwith--max-pay), installed separately, or any x402 or MPP client - Response: JSON with
imageUrl,model,preset,licenceandcredits - Limits: one image per request. Every tier lists
1408x768. - Full purchase flow: the buyer skill
Generate an image and save it into the repository
Check for a payment client and a funded wallet:
zero auth whoami --json zero wallet balance --jsonA
userobject means you are signed in. Ifzerois not found, install it. Claude Code does not include it. Use either the Claude Code plugin or npm:claude plugin marketplace add officialzeroxyz/zero-plugins && claude plugin install zero@zero-plugins npm i -g @zeroxyz/cli && zero initThen sign in with
zero auth login --start --json, or runzero auth agent register --jsonwhere no one can approve a browser sign-in. A new account has a balance of 0. Only a person can add funds: the account owner runszero wallet fund --start --jsonand finishes in a browser. The installed Zero skill is the usage guide for the CLI.Read the quote. This step is optional and free:
curl -i -X POST https://agents.driftflight.com/zcj/klku6g33v32h/v1/images/generate \ -H 'Content-Type: application/json' \ -d '{"prompt": "an editorial illustration of a paper airplane crossing a city skyline", "model": "sketch", "preset": "editorial"}'The unpaid request answers
402with a JSON body holdingpayment.amountUsd, theplan, aprotocolsblock for x402 and MPP, and thetermslinks, pluspayment-requiredandwww-authenticateheaders, in 0.3 seconds. Nothing is charged, so it is safe to stop here.Send the same request through the payment client with a cap. Set
CAPto the most you authorize for this one image, no lower than $0.01:zero fetch https://agents.driftflight.com/zcj/klku6g33v32h/v1/images/generate \ -d '{"prompt": "an editorial illustration of a paper airplane crossing a city skyline", "model": "sketch", "preset": "editorial"}' \ --max-pay "$CAP"The client pays the 402 within the cap and retries the same body. The Zero plugin does not auto-approve
zero fetch. The response is:{"imageUrl": "https://api.driftflight.com/[path]", "model": "sketch", "preset": "editorial", "licence": "commercial", "credits": "C2PA content credentials embedded"}This example paid $0.01 and took 10.8 seconds.
Download the file into the repository:
mkdir -p assets curl -sL "<imageUrl>" -o assets/readme-hero.<ext>Use the extension that matches the content type of the download. The saved file is the durable copy.
Reference the saved file from the project, not
imageUrl:The address in the response is only the way to fetch the bytes. The repository copy is the one to keep and commit.
Any HTTP client that can pay a 402 sends the same body, including @x402/fetch, @x402/axios and the x402 package on PyPI.
Choose the tier and preset
| Condition | model | Price per image |
|---|---|---|
| Lowest price, the tier these examples use | sketch | $0.01 |
The default when model is left out | studio | $0.06 |
| Highest price | gallery | $0.14 |
Every tier lists 1408x768. A README hero on sketch plus three docs images on studio costs $0.19.
preset takes editorial, product-studio, film-noir, botanical, watercolor or isometric. GET https://agents.driftflight.com/zcj/klku6g33v32h/v1/presets and GET https://agents.driftflight.com/zcj/klku6g33v32h/v1/models list them for free. Use one preset across a set of images.
Limits
- One image per request. There is no batch field and no size field.
- An unpaid 402 charges nothing. An x402 payment is charged in full when you pay and is not returned if delivery fails.
- Paying the 402 completes the purchase and accepts the terms in its
termsfield. - If a paid call times out, check the result before sending it again. Do not pay twice.
- Paid storefront renders carry a commercial licence and C2PA content credentials.
Errors
| Response | Meaning | Action |
|---|---|---|
402 payment_required | The price quote. Nothing is charged yet. | Pay within your cap and retry the same body, or stop |
settlement_failed (insufficient_funds) | The payment did not settle | Fund the wallet, then resend from the start for a fresh 402 |
payment_consumed | That payment was already settled | Check the original delivery before paying again |
401 bearer_required | A zc-mode: free call or a plan purchase was sent without an agent identity | Register at auth.md, or drop the header and pay per image |
400 invalid_request | The body is malformed | Fix the JSON |
Frequently asked questions
Can Claude Code make images without an API key?
Yes. Driftflight's storefront needs no API key, account or registration for a per-image call. The signed payment on the 402 is the only credential. The payment client is installed separately, since Claude Code does not include one, and its wallet needs USDC before a paid request.
Does Claude Code come with a payment client?
No. Install the Zero CLI through the Claude Code plugin or npm, or use another x402 or MPP client. A person funds the Zero wallet before the first paid request.
Can one image be paid by card?
No. Every tier's price is below the card rail's $0.50 floor for one call. A card buys prepaid credits instead, from $1, with a bearer credential (the agent identity the storefront issues). The buyer skill covers that route.
Are any images free?
Pay as you go includes 3 sketch images. The allowance is reserved for an agent identity that a person has claimed and verified by email. Send that credential with the zc-mode: free header.
What happens if I leave out the model field?
The request is billed as studio at $0.06. Set "model": "sketch" for $0.01 images.
Keep reading
- Buyer skill: the full purchase flow
- How to pay: the 402 flow, rails and credits
- Error reference: every code and how to react
- Identity: credentials for plans and the free allowance
