curl --request POST \
--url https://api.dreamto.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "An orange cat in an astronaut helmet floating in space with Earth behind it, photorealistic",
"size": "1024x1024",
"quality": "medium"
}
'
{
"created": 1794643200,
"data": [
{
"b64_json": "<BASE64_IMAGE_DATA>"
}
],
"background": "opaque",
"output_format": "png",
"quality": "medium",
"size": "1024x1024",
"usage": {
"input_tokens": 29,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 29
},
"output_tokens": 1756,
"output_tokens_details": {
"image_tokens": 1756,
"text_tokens": 0
},
"total_tokens": 1785
}
}{
"error": {
"code": "invalid_request",
"http_status": 400,
"message": "Invalid request.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "invalid_request_error"
}
}{
"error": {
"code": "unauthorized",
"http_status": 401,
"message": "Unauthorized.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "authentication_error"
}
}{
"error": {
"code": "insufficient_balance",
"http_status": 402,
"message": "Insufficient balance.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "insufficient_balance_error"
}
}{
"error": {
"code": "rate_limit_exceeded",
"http_status": 429,
"message": "Rate limit exceeded. Please try again later.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "rate_limit_error"
}
}{
"error": {
"code": "service_unavailable",
"http_status": 502,
"message": "Service temporarily unavailable. Please try again later.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "api_error"
}
}GPT Image 2
Create image
Generates images from a prompt. The request is synchronous and returns the images as Base64 when done, usually in 10–90 seconds (longer for high quality and large sizes); set the client timeout to at least 5 minutes. With stream: true the response is SSE.
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://api.dreamto.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "An orange cat in an astronaut helmet floating in space with Earth behind it, photorealistic",
"size": "1024x1024",
"quality": "medium"
}
'
{
"created": 1794643200,
"data": [
{
"b64_json": "<BASE64_IMAGE_DATA>"
}
],
"background": "opaque",
"output_format": "png",
"quality": "medium",
"size": "1024x1024",
"usage": {
"input_tokens": 29,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 29
},
"output_tokens": 1756,
"output_tokens_details": {
"image_tokens": 1756,
"text_tokens": 0
},
"total_tokens": 1785
}
}{
"error": {
"code": "invalid_request",
"http_status": 400,
"message": "Invalid request.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "invalid_request_error"
}
}{
"error": {
"code": "unauthorized",
"http_status": 401,
"message": "Unauthorized.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "authentication_error"
}
}{
"error": {
"code": "insufficient_balance",
"http_status": 402,
"message": "Insufficient balance.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "insufficient_balance_error"
}
}{
"error": {
"code": "rate_limit_exceeded",
"http_status": 429,
"message": "Rate limit exceeded. Please try again later.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "rate_limit_error"
}
}{
"error": {
"code": "service_unavailable",
"http_status": 502,
"message": "Service temporarily unavailable. Please try again later.",
"request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
"type": "api_error"
}
}Authorizations
Body
application/json
Request body of image generation.
Response
Images generated. With stream: true the body is text/event-stream.
Generation result.

