Media generation

Media runs as asynchronous jobs: submit, poll, download. Output is copied into platform storage as soon as the job finishes, so it does not expire with the provider.

Endpoints

EndpointProduces
POST /v1/images/generationsImages
POST /v1/videosVideo
POST /v1/audio/speechSpeech audio
POST /v1/audio/transcriptionsText from uploaded audio
POST /v1/music/generationsMusic
POST /v1/workflowsWhatever the workflow graph produces

Submit a job

curl https://api.openmayhem.ai/v1/images/generations \
  -H "Authorization: Bearer $OPENMAYHEM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tongyi/z-image-turbo",
    "prompt": "A lighthouse on a cliff at dusk",
    "size": "1024x1024"
  }'

# → { "id": "JOB_ID", "status": "running", "polling_url": "/v1/jobs/JOB_ID" }

Poll it

curl https://api.openmayhem.ai/v1/jobs/JOB_ID \
  -H "Authorization: Bearer $OPENMAYHEM_API_KEY"

# When completed, the job lists artifacts and the final cost:
# { "status": "completed", "cost": "0.002500",
#   "artifacts": [{ "id": "ARTIFACT_ID", "content_type": "image/png", ... }] }

GET /v1/jobs lists your recent jobs; DELETE /v1/jobs/JOB_ID cancels a running one. A cancelled job is charged exactly for the work its receipt records, never the full estimate.

Download artifacts

curl -L https://api.openmayhem.ai/v1/artifacts/ARTIFACT_ID \
  -H "Authorization: Bearer $OPENMAYHEM_API_KEY" -o image.png

The artifact route checks ownership and redirects to a signed URL valid for a few minutes. Artifacts are retained for 30 days.

Billing holds a worst-case estimate at submission and settles to the receipted amount at completion. A job that fails without producing work charges nothing; a partial failure charges only what the provider’s receipt records.