---
title: "Pay for one generation with this request (Machine Payments Protocol, HTTP 402) — no credits"
method: POST
path: "/v1/pay/generate"
---

# Pay for one generation with this request (Machine Payments Protocol, HTTP 402) — no credits

`POST /v1/pay/generate`

## Request

- Base URL: `https://varosity.ai/api`
- URL: `https://varosity.ai/api/v1/pay/generate`
- Auth: API key in header `X-API-Key`

The first call quotes one job and returns 402: the body names job_id, model and amount; WWW-Authenticate: Payment carries a challenge bound to that job. Pay it (card through a Stripe Link agent wallet; USDC is accepted for credit top-ups, not here yet) and send the same request again with Authorization: Payment <credential>; that runs exactly that job. An image is returned in the response; a video starts and is polled at GET /v1/jobs/{job_id} (the same id). Price: the credits price for the job, at least $0.50 (card minimum), at most $50. A job that fails after payment is refunded. Send the Varosity key as X-API-Key. Media-driven models (length set by supplied audio/video) are not offered here.

## Request body

- object
  - `type` 'image' | 'video', required
  - `model` string, required
  - `prompt` string, required
  - `aspectRatio` '16:9' | '9:16' | '1:1' | '4:5' | '21:9'
  - `durationSec` integer
  - `referenceImageUrl` string, uri

## Response `200`

Paid: { job_id, status (succeeded | running), output_url, poll_url (video), amount_cents, payment_reference } plus a Payment-Receipt header

## Other responses

- `400`: Invalid body, unknown model, unsupported job, or a credential not for a job on this account
- `401`: Missing or invalid key — send it as X-API-Key
- `402`: Payment required: { job_id, model, amount_usd, expires_at } and the challenge in WWW-Authenticate
- `403`: Key lacks generate:image / generate:video
- `409`: already_paid (another payment already paid for this job) or payment_not_applied (the payment could not be applied); either way this payment is refunded. Body: { job_id, code, error, refund, payment_reference }
- `410`: The quote expired (30 minutes); request a new one
- `429`: Too many quotes or payment attempts this hour
- `502`: Payment could not be processed (nothing charged), or the paid job failed and was refunded

## Changes

- **2026-10-20** `81d0169a4897`: 2 info
  - the endpoint scheme security `apiKeyHeader` was added to the API
  - added the non-success response with the status `409`

[Operation history](https://skmtc.dev/varosity/apis/varosity-ai-api/changes/v1/pay/generate/post.md)

---

[API](https://skmtc.dev/varosity/apis/varosity-ai-api.md) · [All operations](https://skmtc.dev/varosity/apis/varosity-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/varosity/apis/varosity-ai-api/revisions/81d0169a4897?raw)
