Driftflight Guides

Guides

Generate images in Claude Code with Driftflight's text-to-image API

Markdown

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, studio or gallery) and optional preset. A body without model is 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 fetch with --max-pay), installed separately, or any x402 or MPP client
  • Response: JSON with imageUrl, model, preset, licence and credits
  • Limits: one image per request. Every tier lists 1408x768.
  • Full purchase flow: the buyer skill

Generate an image and save it into the repository

  1. Check for a payment client and a funded wallet:

    zero auth whoami --json
    zero wallet balance --json
    

    A user object means you are signed in. If zero is 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 init
    

    Then sign in with zero auth login --start --json, or run zero auth agent register --json where 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 runs zero wallet fund --start --json and finishes in a browser. The installed Zero skill is the usage guide for the CLI.

  2. 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 402 with a JSON body holding payment.amountUsd, the plan, a protocols block for x402 and MPP, and the terms links, plus payment-required and www-authenticate headers, in 0.3 seconds. Nothing is charged, so it is safe to stop here.

  3. Send the same request through the payment client with a cap. Set CAP to 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.

  4. 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.

  5. Reference the saved file from the project, not imageUrl:

    ![Paper airplane crossing a city skyline](assets/readme-hero.<ext>)
    

    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

ConditionmodelPrice per image
Lowest price, the tier these examples usesketch$0.01
The default when model is left outstudio$0.06
Highest pricegallery$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 terms field.
  • 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

ResponseMeaningAction
402 payment_requiredThe 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 settleFund the wallet, then resend from the start for a fresh 402
payment_consumedThat payment was already settledCheck the original delivery before paying again
401 bearer_requiredA zc-mode: free call or a plan purchase was sent without an agent identityRegister at auth.md, or drop the header and pay per image
400 invalid_requestThe body is malformedFix 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