Generate an image
POST
/ai/image/generate
const url = 'https://ai.work.optidata.cloud/api/ai/image/generate';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"prompt":"A minimalist illustration of a team planning on a whiteboard."}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://ai.work.optidata.cloud/api/ai/image/generate \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "prompt": "A minimalist illustration of a team planning on a whiteboard." }'Creates one image from a text description and returns it as base64 PNG. Generation can take up to a minute; use a generous client timeout.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
prompt
required
Description of the image.
string
Responses
Section titled “ Responses ”The image, base64-encoded.
Media typeapplication/json
object
id
required
Id of this request.
string
url
required
Always null; the image is returned inline.
string | null
image_base64
required
The PNG image, base64-encoded.
string
Examples
Exampleimage
{ "id": "a30508a1-7c2e-4b1d-9f3a-0e6d5c4b3a21", "url": null, "image_base64": "iVBORw0KGgoAAAANSUhEUgAA…"}No authentication key was sent.
Media typeapplication/json
Authentication failures use an error key rather than message.
object
error
required
string
Examples
Examplemissing
No bearer token sent
{ "error": "JWT passport exception: Missing bearer token in request"}The authentication key is expired or not recognised. Get a fresh one and retry.
Media typeapplication/json
Authentication failures use an error key rather than message.
object
error
required
string
Examples
Exampleexpired
{ "error": "JWT passport expired: Passport expired"}prompt was not sent.
Media typeapplication/json
object
message
required
The first validation message.
string
errors
required
Validation messages keyed by field name.
object
key
additional properties
Array<string>
Examples
ExamplemissingPrompt
{ "message": "The prompt field is required.", "errors": { "prompt": [ "The prompt field is required." ] }}