curl --request POST \
--url https://api.opper.ai/v3/images \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>"
}
'import requests
url = "https://api.opper.ai/v3/images"
payload = {
"model": "<string>",
"prompt": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', prompt: '<string>'})
};
fetch('https://api.opper.ai/v3/images', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"created": 123,
"data": [
{
"b64_json": "<string>",
"file_id": "<string>",
"mime_type": "<string>",
"revised_prompt": "<string>",
"url": "<string>"
}
],
"id": "<string>",
"model": "<string>",
"usage": {
"cost": 123,
"images": 123,
"attempts": 123
}
}{
"id": "<string>",
"status_url": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}Generate an image
Generate one or more images. By default runs synchronously and returns them inline (200). Set async: true to run a single image on the background worker and get a 202 with a status URL to poll instead: use it for slow models (e.g. gpt-image high, imagen ultra) that can exceed the synchronous timeout. model and prompt are required; n (max 4; async is single-image), size/aspect_ratio, quality, and style are normalized, and everything in parameters is forwarded verbatim to the provider. image/mask/reference_images accept an http(s) URL, a data-URI, or a file_<id> for edit / image-to-image. response_format defaults to b64_json. Set store: true to also save the outputs to /v3/files and get a reusable file_id; nothing is stored otherwise. With async: true, set callback_url to get a signed webhook when the job ends instead of polling (see GET /v3/webhooks/secret).
curl --request POST \
--url https://api.opper.ai/v3/images \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>"
}
'import requests
url = "https://api.opper.ai/v3/images"
payload = {
"model": "<string>",
"prompt": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', prompt: '<string>'})
};
fetch('https://api.opper.ai/v3/images', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"created": 123,
"data": [
{
"b64_json": "<string>",
"file_id": "<string>",
"mime_type": "<string>",
"revised_prompt": "<string>",
"url": "<string>"
}
],
"id": "<string>",
"model": "<string>",
"usage": {
"cost": 123,
"images": 123,
"attempts": 123
}
}{
"id": "<string>",
"status_url": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}Authorizations
Body
HTTPS URL that receives a signed image.completed or image.failed webhook when the job ends, so you do not have to poll. Rules, each answered with a 400 that names it: https only, port 443 (or none), no user:password@, no #fragment, at most 2048 characters, and a host that is a public IP address or a public name resolving only to public addresses (no localhost, private, link-local, metadata or internal names). Verify the signature with the project's secret from GET /v3/webhooks/secret; see the jobCompleted webhook for the payload, headers and retries. Only with async: true; a synchronous request with callback_url answers 400.
Retries on the same endpoint when the provider rejects the call before doing any work (HTTP 429 or a gateway 502/503/504 with no result, or a connection that never reached it). Only the successful attempt is billed. Default 2 / max 3; 0 turns retries off.
0 <= x <= 3