All 8 generation endpoints
Every endpoint under the generations OpenAPI tag is strictly workspace-private and served with Cache-Control: no-store:
| Method & Path | Operation ID | Scope | Purpose |
|---|---|---|---|
POST /v1/generations | media.generate | generate | Submit one canonical generation with required Idempotency-Key (1–200 chars) and optional Prefer: wait=N (0–25s). Returns 202 Accepted (or 200 OK if ready inside Prefer: wait) with Location: /v1/generations/{id} |
GET /v1/generations | jobs.list | read | List workspace generation jobs newest-first. Returns X-Next-Cursor header for pagination; filters: modelId, providerId, deploymentId, endpointRegion, operation, keyId, status, project, since, until, limit (1–100), cursor |
GET /v1/generations/lookup | jobs.lookup | read | Read-only recovery of a job by ?idempotencyKey=<key> when the original submit response was lost. Never creates a job |
GET /v1/generations/{id} | jobs.get | read | Read full job details, billing state, structuredError, and fresh short-lived signed /media output URLs while retained |
GET /v1/generations/{id}/status | jobs.status | read | Compact status long-poll (?afterRevision=<64-hex>&waitMs=<0..25000>). Returns { job, changed, timedOut } with 64-hex revision, progress, and timings |
GET /v1/generations/{id}/events | jobs.events | read | Bounded 50-second text/event-stream SSE stream (?afterRevision= or Last-Event-ID header) with 10s heartbeats and clean reconnect cursor |
POST /v1/generations/{id}/cancel | jobs.cancel | generate | Immediately cancels a queued job (200 OK, releases hold) or requests upstream cancellation on a running job (202 Accepted, cancellationState: "requested") |
DELETE /v1/generations/{id}/outputs | jobs.purgeOutputs | generate | Permanently deletes retained private output bytes on a terminal settled job while preserving job metadata and ledger history |
Canonical request envelope
Every generation request uses one consistent envelope across all 54 models and 10 operations:
{
"modelId": "openai/gpt-image-2",
"operation": "text-to-image",
"input": {
"prompt": "Minimalist studio photo of a frosted glass carafe on travertine stone",
"resolution": "1K",
"aspectRatio": "1:1",
"quality": "low"
},
"billing": "managed",
"maxCostMicros": 50000,
"metadata": {
"project": "catalog-hero",
"tags": { "env": "staging", "batch": "dec-02" }
}
}Optional envelope fields:
billing:"managed"(default prepaid workspace credit) or"byok"(encrypted workspace provider key).routeIdorrouting: pin an exact regional route or declare routing constraints (see Regional Routing & Privacy).maxCostMicros: integer micro-USD ceiling for managed generations (1 USD = 1,000,000 micro-USD).metadata: privateproject(up to 80 chars) and up to 16tags(for filtering inGET /v1/generationsand cost attribution inGET /v1/analytics).previousJobId: owned completed job UUID for supported continuations (such as Omnivideo-extend).queueStartDeadlineAt: ISO-8601 UTC deadline after which a still-queued job fails withstart_deadline_exceededbefore dispatch.webhookUrlandwebhookEvents: per-request Ed25519-signed webhook callback (see Webhooks & Ed25519 Verification).
Job status, delivery, and cancellation states
OpenGen tracks execution status, private output delivery, and cancellation independently so callers never confuse upstream completion with downloadable media or confirmed refunds:
Execution status
| Status | Terminal? | Meaning |
|---|---|---|
queued | No | Admitted and reserved locally; waiting for worker dispatch |
submitting | No | Worker is actively submitting to the upstream provider |
running | No | Upstream provider accepted the task and is executing |
submission-unknown | Yes (reconciliation) | Upstream acceptance could not be confirmed after timeout or transport failure. Reserved funds stay held pending reconciliation — never blind-retry |
succeeded | Yes | Upstream provider reported completion; inspect deliveryStatus before downloading outputs |
failed | Yes | Upstream or admission failure recorded in structuredError |
cancelled | Yes | Cancellation confirmed |
Delivery deliveryStatus
pending: worker is downloading, verifying container signatures/SHA-256, and writing outputs into private object storage.available: all output receipts are stored privately andoutputs[]contains valid signed URLs.partial: at least one output slot succeeded while another failed (inspectdeliveryErrors[]).failed: output capture failed; inspectdeliveryErrors[]andstructuredError.expired: outputs expired or were explicitly purged viaDELETE /v1/generations/{id}/outputs.unverified: legacy/unverified delivery receipt state.
Cancellation cancellationState
none: no cancellation requested.requested: upstream cancellation was requested for arunningjob (POST /v1/generations/{id}/cancelreturned202 Accepted). Reserved credits remain held until polling confirms terminal non-billable cancellation.confirmed: cancellation confirmed (queuedjobs transition immediately tostatus: "cancelled"with200 OKand hold released).rejectedorunsupported: the upstream provider rejected or does not support mid-flight cancellation; the job may finish and settle normally.
Synchronous Prefer: wait, SSE streaming, and compact polling
Choose the waiting strategy that fits your latency profile:
- **Fast images (
Prefer: wait=20)**: Send RFC 7240Prefer: wait=20(clamped0–25s) onPOST /v1/generations. If the job reaches a terminal state with non-pending delivery inside the window, OpenGen returns200 OKwithPreference-Applied: wait=20and populatedoutputs[]. Otherwise it returns202 Acceptedcleanly so you continue asynchronously. - **Server-Sent Events (
GET /v1/generations/{id}/events)**: Streamsevent: statusframes carryingid: <64-hex-revision>,: heartbeatcomments every10seconds,event: doneonce terminal with non-pending delivery, andevent: reconnectwithretry: 1000at the bounded50-second connection ceiling soEventSourceor custom clients reconnect seamlessly usingLast-Event-ID. Re-authorizes credentials on every poll tick. - **Compact status long-poll (
GET /v1/generations/{id}/status)**: PassafterRevision=<previous-revision>&waitMs=25000to receive{ job, changed, timedOut }without resending full input payloads or re-signing media links until the job finishes.
# Stream live job status via SSE (reconnecting with Last-Event-ID if needed)
curl -N "$OPENGEN_API_URL/v1/generations/$JOB_ID/events" \
-H "Authorization: Bearer $OPENGEN_API_KEY" \
-H "Accept: text/event-stream"
# Compact status long-poll
curl --fail-with-body \
"$OPENGEN_API_URL/v1/generations/$JOB_ID/status?waitMs=20000" \
-H "Authorization: Bearer $OPENGEN_API_KEY"
# List recent succeeded video jobs with cursor pagination
curl --fail-with-body -i \
"$OPENGEN_API_URL/v1/generations?status=succeeded&operation=image-to-video&limit=20" \
-H "Authorization: Bearer $OPENGEN_API_KEY"Private media delivery, cancellation, and output purging
- **First-party
/mediaURLs**: Images<= 3.5 MiBstream directly (200 OK) from the OpenGen origin; larger images, videos, and HTTPRangerequests return302 Foundto a short-lived private storage URL (<= 300seconds) stripped of any caller tracking query parameters (such as?utm_source=...). Re-readGET /v1/generations/{id}(or MCPjob_get) to refresh an expired (410 Gone) URL while outputs remain retained. - Reusing an output: Pass
output.outputIndex(the stable receipt slot, independent of array position) toPOST /v1/assetswith{ "source": "job_output", "sourceJobId": "<jobId>", "outputIndex": 0 }to feed a generated image or video into a downstream edit or video model. - Cancelling and purging outputs:
# Request cancellation of an existing job
curl --fail-with-body -X POST "$OPENGEN_API_URL/v1/generations/$JOB_ID/cancel" \
-H "Authorization: Bearer $OPENGEN_API_KEY"
# Permanently purge retained output bytes on a terminal settled job
curl --fail-with-body -X DELETE "$OPENGEN_API_URL/v1/generations/$JOB_ID/outputs" \
-H "Authorization: Bearer $OPENGEN_API_KEY"Purging requires the job to be terminal and — for succeeded managed jobs — settled (settledMicros !== null). Active delivery leases or unsettled managed jobs return 409 (job_not_terminal, output_purge_pending_settlement, or output_delivery_in_progress). Purging is idempotent and leaves job metadata and billing history intact.