Driftflight Guides

Guides

Generate an image from a text prompt with Driftflight's API

Markdown

Driftflight's text-to-image API turns one text prompt into one image, and every paid render carries a commercial licence and C2PA content credentials. A sketch image costs $0.01, a studio image $0.06 and a gallery image $0.14. Send POST https://agents.driftflight.com/zcj/jmgdqhykencp/v1/images/generate with prompt and model, pay the 402 price quote over x402 or MPP, and retry the same request to get the image URL.

At a glance

  • Endpoint: POST https://agents.driftflight.com/zcj/jmgdqhykencp/v1/images/generate, one image per request
  • Body: prompt (required), model (sketch, studio or gallery), preset (optional style). model defaults to studio, so set it on every request.
  • Price per image: sketch $0.01, studio $0.06, gallery $0.14
  • Payment: a 402, the price quote, which you pay and retry. x402 (Base USDC) and MPP (Tempo USDC) are the wallet rails. No account, registration or API key.
  • Response: JSON with imageUrl, model, preset, licence and credits
  • Limits: text to image only, one image per call, listed size 1408x768 on every tier
  • Full purchase flow: the buyer skill

Generate an image from a text prompt

  1. Send the request with no payment attached:

    curl -sS -X POST https://agents.driftflight.com/zcj/jmgdqhykencp/v1/images/generate \
      -H 'Content-Type: application/json' \
      -d '{"prompt": "an isometric illustration of a small lighthouse on a rocky island at dawn", "model": "sketch", "preset": "isometric"}'
    

    The storefront answers 402 with a JSON body that carries payment.id, payment.amountUsd, the plan and a protocols block with an x402 and an mpp challenge. The same challenges arrive in the payment-required and www-authenticate response headers. For sketch the quote is $0.01. Nothing is charged until you pay it.

  2. Pay the quote and retry the same request, with the body unchanged. On x402, sign the payment-required challenge and send the payload in x-payment:

    curl -sS -X POST https://agents.driftflight.com/zcj/jmgdqhykencp/v1/images/generate \
      -H 'Content-Type: application/json' \
      -H 'x-payment: <signed x402 payload>' \
      -d '{"prompt": "an isometric illustration of a small lighthouse on a rocky island at dawn", "model": "sketch", "preset": "isometric"}'
    

    On MPP, sign a credential for the www-authenticate challenge and send it as Authorization: Payment <credential> instead. @x402/fetch, @x402/axios, the x402 package on PyPI and the Zero CLI (zero fetch) sign and retry for you.

  3. Read the response:

    {"imageUrl": "https://api.driftflight.com/r/<id>", "model": "sketch", "preset": "isometric", "licence": "commercial", "credits": "C2PA content credentials embedded"}
    

    This sketch request returned 200, paid $0.01 and took 13.3 seconds. credits is a text statement about the embedded content credentials, not a balance. An x402 response also carries a payment-response header and an MPP response a payment-receipt header, for your spend records.

  4. Save the image by fetching imageUrl:

    curl -sL "<imageUrl from the response>" -o lighthouse
    

    The saved file is your copy. A payment alone does not complete the job, so confirm the file was written.

Choose a tier and preset

Every tier takes the same request. Only model and the price change.

modelPrice per imageListed sizeListed typical latency
sketch$0.011408x768~2s
studio (the default)$0.061408x768~5s
gallery$0.141408x768~9s

GET https://agents.driftflight.com/zcj/jmgdqhykencp/v1/models lists each tier with its maxResolution and typicalLatency for free. preset takes one of six styles: editorial, product-studio, film-noir, botanical, watercolor or isometric.

Pay by card or use the free sketch images

A single image costs less than $0.50, so a card pays for images through Prepaid credits. Buying credits needs a bearer credential, the agent identity the storefront issues, which you register through the identity guide. Then buy Prepaid credits with that bearer, an amountUsd in whole cents and "checkout": true, which returns a hosted checkout. The plan's purchase address is in the catalog.

By card, amountUsd must be at least $1. Pay the returned checkout and poll its statusUrl until it reports complete, following the card guide. Generate requests sent with Authorization: Bearer <access token> then draw down the balance. The zc-billing response header reports chargedUsd and remainingCreditUsd.

A bearer credential that a human has claimed with a verified email gets 3 free sketch images, shared across every credential the same person claims. Send a sketch request with that bearer and the zc-mode: free header.

Limits and charges

  • The body takes prompt, model and preset. There is no size, seed, reference image or editing of an existing image.
  • One request returns one image.
  • An unpaid 402 charges nothing, so it is safe to stop there.
  • Each pay-as-you-go call is charged once, through its own 402. A payment cannot be reused for a different request.
  • After a timeout on a paid retry, reconcile the payment before paying again. Do not pay twice.

Errors

ResponseMeaningAction
402 with a payment blockThe price quote for this callPay it and retry the same request, or stop
400 invalid_requestThe body is malformedFix the JSON and send again
settlement_failedThe payment did not settle. settlementReason says why, such as insufficient_funds.Fix the wallet, then start over for a fresh 402
409 payment_request_mismatchA payment was reused for a different requestRequest a fresh 402 and pay that one
payment_consumedThat payment was already settledCheck whether the image was delivered before paying again
401 bearer_requiredA credit purchase or top-up needs a bearer credentialRegister at the identity guide, then retry
403 verified_email_requiredThe free allowance needs a claimed credentialComplete the claim step in the identity guide, then retry
usage_exhaustedThe prepaid credit is used upTop up the balance, following How to pay, or pay per image

Frequently asked questions

Does Driftflight's image generation API need an API key?

No. Each image is paid for on its own through the 402 quote, over x402 or MPP. Per-image calls need no account, registration or key.

How much does one image cost?

$0.01 on sketch, $0.06 on studio and $0.14 on gallery. The 402 states the exact amount before you pay.

What does a request without model cost?

It is billed as studio, because model defaults to studio. Set model in every request body to pay the price of the tier you want.

Can I pay for a single image by card?

No. The card rail's floor for one call is $0.50 and every image costs less, so a card pays for images through Prepaid credits, with a card minimum of $1.

Can the images be used commercially?

Yes. Every image bought through the storefront comes with a commercial licence, perpetual and worldwide, and embedded C2PA content credentials.

Keep reading