curl --request POST \
--url https://api.zerogen.com/v1/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "black-forest-labs/flux-2-pro/generate",
"prompt": "A lighthouse at dawn, fog over the water",
"output": {
"count": 1
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'black-forest-labs/flux-2-pro/generate',
prompt: 'A lighthouse at dawn, fog over the water',
output: {count: 1}
})
};
fetch('https://api.zerogen.com/v1/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.zerogen.com/v1/generations"
payload = {
"model": "black-forest-labs/flux-2-pro/generate",
"prompt": "A lighthouse at dawn, fog over the water",
"output": { "count": 1 }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"projectId": "<string>",
"model": "<string>",
"modelVersion": "<string>",
"status": "queued",
"outputs": [
{
"index": 4503599627370495,
"status": "queued",
"asset": {
"id": "<string>",
"mimeType": "<string>",
"width": 4503599627370495,
"height": 4503599627370495,
"durationMs": 4503599627370495,
"resourceUri": "<string>"
},
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
},
"warnings": [
{
"code": "<string>",
"message": "<string>"
}
],
"draft": {
"expiresAt": "2023-11-07T05:31:56Z",
"upscalable": true,
"upscale": "upscaling",
"finalResolution": "<string>",
"finalAssetId": "<string>"
}
}
],
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
},
"billing": {
"mode": "platform",
"state": "held",
"quotedMicroUsd": 4503599627370495,
"heldMicroUsd": 4503599627370495,
"chargedMicroUsd": 4503599627370495,
"hold": {
"state": "running",
"endedAt": "2023-11-07T05:31:56Z"
}
},
"createdAt": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z"
}{
"id": "<string>",
"projectId": "<string>",
"model": "<string>",
"modelVersion": "<string>",
"status": "queued",
"outputs": [
{
"index": 4503599627370495,
"status": "queued",
"asset": {
"id": "<string>",
"mimeType": "<string>",
"width": 4503599627370495,
"height": 4503599627370495,
"durationMs": 4503599627370495,
"resourceUri": "<string>"
},
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
},
"warnings": [
{
"code": "<string>",
"message": "<string>"
}
],
"draft": {
"expiresAt": "2023-11-07T05:31:56Z",
"upscalable": true,
"upscale": "upscaling",
"finalResolution": "<string>",
"finalAssetId": "<string>"
}
}
],
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
},
"billing": {
"mode": "platform",
"state": "held",
"quotedMicroUsd": 4503599627370495,
"heldMicroUsd": 4503599627370495,
"chargedMicroUsd": 4503599627370495,
"hold": {
"state": "running",
"endedAt": "2023-11-07T05:31:56Z"
}
},
"createdAt": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}Create a generation
Validates, prices, reserves and starts one generation in a single call. Send Prefer: wait=N to hold the response until it ends. Nothing is charged unless every check passes.
Needs the generations:create scope.
curl --request POST \
--url https://api.zerogen.com/v1/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "black-forest-labs/flux-2-pro/generate",
"prompt": "A lighthouse at dawn, fog over the water",
"output": {
"count": 1
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'black-forest-labs/flux-2-pro/generate',
prompt: 'A lighthouse at dawn, fog over the water',
output: {count: 1}
})
};
fetch('https://api.zerogen.com/v1/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.zerogen.com/v1/generations"
payload = {
"model": "black-forest-labs/flux-2-pro/generate",
"prompt": "A lighthouse at dawn, fog over the water",
"output": { "count": 1 }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"projectId": "<string>",
"model": "<string>",
"modelVersion": "<string>",
"status": "queued",
"outputs": [
{
"index": 4503599627370495,
"status": "queued",
"asset": {
"id": "<string>",
"mimeType": "<string>",
"width": 4503599627370495,
"height": 4503599627370495,
"durationMs": 4503599627370495,
"resourceUri": "<string>"
},
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
},
"warnings": [
{
"code": "<string>",
"message": "<string>"
}
],
"draft": {
"expiresAt": "2023-11-07T05:31:56Z",
"upscalable": true,
"upscale": "upscaling",
"finalResolution": "<string>",
"finalAssetId": "<string>"
}
}
],
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
},
"billing": {
"mode": "platform",
"state": "held",
"quotedMicroUsd": 4503599627370495,
"heldMicroUsd": 4503599627370495,
"chargedMicroUsd": 4503599627370495,
"hold": {
"state": "running",
"endedAt": "2023-11-07T05:31:56Z"
}
},
"createdAt": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z"
}{
"id": "<string>",
"projectId": "<string>",
"model": "<string>",
"modelVersion": "<string>",
"status": "queued",
"outputs": [
{
"index": 4503599627370495,
"status": "queued",
"asset": {
"id": "<string>",
"mimeType": "<string>",
"width": 4503599627370495,
"height": 4503599627370495,
"durationMs": 4503599627370495,
"resourceUri": "<string>"
},
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
},
"warnings": [
{
"code": "<string>",
"message": "<string>"
}
],
"draft": {
"expiresAt": "2023-11-07T05:31:56Z",
"upscalable": true,
"upscale": "upscaling",
"finalResolution": "<string>",
"finalAssetId": "<string>"
}
}
],
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
},
"billing": {
"mode": "platform",
"state": "held",
"quotedMicroUsd": 4503599627370495,
"heldMicroUsd": 4503599627370495,
"chargedMicroUsd": 4503599627370495,
"hold": {
"state": "running",
"endedAt": "2023-11-07T05:31:56Z"
}
},
"createdAt": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"param": "<string>",
"details": {}
}
}Authorizations
A ZeroGen API key: zg_ for a live key, zg_test_ for a test key.
Headers
Makes retries safe: a retry with the same key and body returns the first response for 24 hours instead of repeating the work. Reusing a key with a different body returns 409.
1 - 255^[\x21-\x7e]+$wait=N holds the response up to N seconds (at most 60) until the generation ends.
^wait=\d+$"wait=30"
Body
200^[a-z0-9]+(?:[.-][a-z0-9]+)*\/[a-z0-9]+(?:[.-][a-z0-9]+)*\/[a-z0-9]+(?:[.-][a-z0-9]+)*$2000050- Option 1
- Option 2
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Speech models only: the voice to read the prompt in, from the model's voices
^library:[A-Za-z0-9]{1,64}$Only the parameters the model's schema lists
Show child attributes
Show child attributes
Refuse to start when the quote exceeds this amount
0 <= x <= 9007199254740991Test keys only: rehearse each output's outcome; live keys are refused when it is present
Show child attributes
Show child attributes
The project the outputs land in; the organization's default project when omitted. Test keys use their sandbox.
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$A folder in that project to file the outputs in; null or omitted for Unfiled
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$Show child attributes
Show child attributes
Response
The generation has ended, within the requested wait.
The project that holds the outputs
200^[a-z0-9]+(?:[.-][a-z0-9]+)*\/[a-z0-9]+(?:[.-][a-z0-9]+)*\/[a-z0-9]+(?:[.-][a-z0-9]+)*$queued, running, succeeded, partial, failed, cancelled Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$