Skip to main content
POST
/
images
/
generations
Create image
curl --request POST \
  --url https://api.llmrouter.app/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "<string>",
  "model": "<string>",
  "n": 1,
  "size": "1024x1024"
}
'
import requests

url = "https://api.llmrouter.app/v1/images/generations"

payload = {
"prompt": "<string>",
"model": "<string>",
"n": 1,
"size": "1024x1024"
}
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({prompt: '<string>', model: '<string>', n: 1, size: '1024x1024'})
};

fetch('https://api.llmrouter.app/v1/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.llmrouter.app/v1/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([
'prompt' => '<string>',
'model' => '<string>',
'n' => 1,
'size' => '1024x1024'
]),
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.llmrouter.app/v1/images/generations"

payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"n\": 1,\n \"size\": \"1024x1024\"\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.llmrouter.app/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"n\": 1,\n \"size\": \"1024x1024\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.llmrouter.app/v1/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 \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"n\": 1,\n \"size\": \"1024x1024\"\n}"

response = http.request(request)
puts response.read_body
{
  "created": 1774975805,
  "id": "gen_11b25653-e44e-49ea-80ea-32fe8c5fb246",
  "model": "openai/gpt-5-image",
  "usage": {
    "input_tokens": 123,
    "total_tokens": 123,
    "output_tokens": 123,
    "cost": "<unknown>"
  },
  "data": [
    {
      "b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...",
      "url": "<string>",
      "revised_prompt": "<string>"
    }
  ]
}

Authorizations

Authorization
string
header
required

LLM Router API Key (e.g., sk-llmr-...)

Body

application/json

Accepts any additional properties supported by the upstream image model (e.g., quality, style).

prompt
string
required
model
string
required
n
integer
default:1
size
string
default:1024x1024

Response

200 - application/json

Successful image generation response

created
integer
required

Unix timestamp when the image was created

Example:

1774975805

id
string
required

Unique identifier for the generated image

Example:

"gen_11b25653-e44e-49ea-80ea-32fe8c5fb246"

model
string
required

The model used to generate the image

Example:

"openai/gpt-5-image"

usage
object
required
data
object[]
required