Skip to main content
POST
/
v3
/
images
/
generations
Image Generations
curl --request POST \
  --url https://api.edenai.run/v3/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "prompt": "<string>",
  "n": 5,
  "size": "<string>",
  "user": "<string>",
  "metadata": {},
  "extra_headers": {},
  "quality": "<string>",
  "response_format": "<string>"
}
'
import requests

url = "https://api.edenai.run/v3/images/generations"

payload = {
"model": "<string>",
"prompt": "<string>",
"n": 5,
"size": "<string>",
"user": "<string>",
"metadata": {},
"extra_headers": {},
"quality": "<string>",
"response_format": "<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>',
n: 5,
size: '<string>',
user: '<string>',
metadata: {},
extra_headers: {},
quality: '<string>',
response_format: '<string>'
})
};

fetch('https://api.edenai.run/v3/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.edenai.run/v3/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'prompt' => '<string>',
'n' => 5,
'size' => '<string>',
'user' => '<string>',
'metadata' => [

],
'extra_headers' => [

],
'quality' => '<string>',
'response_format' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.edenai.run/v3/images/generations"

payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 5,\n \"size\": \"<string>\",\n \"user\": \"<string>\",\n \"metadata\": {},\n \"extra_headers\": {},\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.edenai.run/v3/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 5,\n \"size\": \"<string>\",\n \"user\": \"<string>\",\n \"metadata\": {},\n \"extra_headers\": {},\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.edenai.run/v3/images/generations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 5,\n \"size\": \"<string>\",\n \"user\": \"<string>\",\n \"metadata\": {},\n \"extra_headers\": {},\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "cost": 123,
  "provider": "<string>",
  "created": 123,
  "data": [
    {
      "url": "<string>",
      "b64_json": "<string>",
      "revised_prompt": "<string>"
    }
  ],
  "usage": {}
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

OpenAI-compatible POST /v1/images/generations request body.

model
string
required

provider/model, e.g. 'openai/gpt-image-2'

prompt
string
required
Required string length: 1 - 32000
n
integer | null
Required range: 1 <= x <= 10
size
string | null

Provider-specific size string. OpenAI accepts '1024x1024', '1536x1024', '1024x1536', 'auto'. Vertex Imagen accepts square or aspect-ratio strings. Validation is delegated to the provider.

user
string | null

End-user identifier for abuse tracking.

metadata
Metadata · object | null

Arbitrary metadata attached to the request.

extra_headers
Extra Headers · object | null

Additional HTTP headers forwarded to the provider API. Credential headers (Authorization, x-api-key, ...) are rejected.

quality
string | null

Provider-specific quality string (e.g. 'low', 'medium', 'high', 'standard', 'hd', 'auto'). Accepted values depend on the model.

response_format
string | null

Legacy DALL-E parameter. Ignored by gpt-image-* and forwarded to the provider for any model that still honors it.

Response

Successful Response

OpenAI-compatible image response + Eden cost / provider fields.

Shared by POST /v3/images/generations and POST /v3/images/edits — the wire shape is identical.

cost
number | null
provider
string | null
created
integer | null
data
ImageDataItem · object[]
usage
Usage · object | null