---
title: "Generate an Image with the AI API | Rendley API Docs"
description: "Generate AI images from text prompts through one REST endpoint. FLUX, Imagen, Seedream, GPT Image and Nano Banana all take the same request shape."
url: https://docs.rendley.com/api/generate-image/
---

# Image generation

Generate AI images from text prompts through one REST endpoint. FLUX, Imagen, Seedream, GPT Image and Nano Banana all take the same request shape.

## Generate an image

Enqueue a job to generate an image from a text prompt, or edit an existing image.

POST`https://api.rendley.com/v1/ai/generate-image`

Body

`model_id`optionalstring

Which model to use. Changing it updates the params below.

`params`requiredjson

Model-specific parameters. The fields listed for the selected model.

`prompt`requiredstring

A text description of the image you want to generate

`image_inputs`optionalstring[]

Input images to transform or use as reference (supports multiple images)

`aspect_ratio`optionalstring

Aspect ratio of the generated image

`project_id`optionalstring

`workspace_id`optionalstring

```
const res = await fetch("https://api.rendley.com/v1/ai/generate-image", {
  method: "POST",
  headers: { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({
    "params": {
      "prompt": "A cinematic shot of a city at sunset"
    },
    "model_id": "nano-banana"
  }),
});
const { data } = await res.json();
```

```
curl -X POST "https://api.rendley.com/v1/ai/generate-image" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "params": {
      "prompt": "A cinematic shot of a city at sunset"
    },
    "model_id": "nano-banana"
  }'
```

```
import requests

res = requests.post(
    "https://api.rendley.com/v1/ai/generate-image",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "params": {
            "prompt": "A cinematic shot of a city at sunset"
        },
        "model_id": "nano-banana"
    },
)
data = res.json()["data"]
```

```
$ch = curl_init("https://api.rendley.com/v1/ai/generate-image");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer YOUR_API_KEY", "Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["params" => ["prompt" => "A cinematic shot of a city at sunset"], "model_id" => "nano-banana"]));

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true)["data"];
```

```
package main

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

func main() {
	body := bytes.NewBufferString(`{
  "params": {
    "prompt": "A cinematic shot of a city at sunset"
  },
  "model_id": "nano-banana"
}`)
	req, _ := http.NewRequest("POST", "https://api.rendley.com/v1/ai/generate-image", body)
	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")
	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	b, _ := io.ReadAll(res.Body)
	fmt.Println(string(b))
}
```

```
require "net/http"
require "json"

uri = URI("https://api.rendley.com/v1/ai/generate-image")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer YOUR_API_KEY"
req["Content-Type"] = "application/json"
req.body = { params: { prompt: "A cinematic shot of a city at sunset" }, model_id: "nano-banana" }.to_json

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)["data"]
```

Response 200

```
{
  "data": {
    "job_id": "d97241f2-e1e4-4651-b078-8663fc35c584"
  }
}
```

## Calculate image generation cost

Calculate the credit cost of generating or editing an image.

POST`https://api.rendley.com/v1/ai/generate-image/cost`

Body

`model_id`optionalstring

Which model to use. Changing it updates the params below.

`params`requiredjson

Model-specific parameters. The fields listed for the selected model.

`prompt`requiredstring

A text description of the image you want to generate

`image_inputs`optionalstring[]

Input images to transform or use as reference (supports multiple images)

`aspect_ratio`optionalstring

Aspect ratio of the generated image

`project_id`optionalstring

`workspace_id`optionalstring

```
const res = await fetch("https://api.rendley.com/v1/ai/generate-image/cost", {
  method: "POST",
  headers: { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({
    "params": {
      "prompt": "A cinematic shot of a city at sunset"
    },
    "model_id": "nano-banana"
  }),
});
const { data } = await res.json();
```

```
curl -X POST "https://api.rendley.com/v1/ai/generate-image/cost" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "params": {
      "prompt": "A cinematic shot of a city at sunset"
    },
    "model_id": "nano-banana"
  }'
```

```
import requests

res = requests.post(
    "https://api.rendley.com/v1/ai/generate-image/cost",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "params": {
            "prompt": "A cinematic shot of a city at sunset"
        },
        "model_id": "nano-banana"
    },
)
data = res.json()["data"]
```

```
$ch = curl_init("https://api.rendley.com/v1/ai/generate-image/cost");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer YOUR_API_KEY", "Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["params" => ["prompt" => "A cinematic shot of a city at sunset"], "model_id" => "nano-banana"]));

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true)["data"];
```

```
package main

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

func main() {
	body := bytes.NewBufferString(`{
  "params": {
    "prompt": "A cinematic shot of a city at sunset"
  },
  "model_id": "nano-banana"
}`)
	req, _ := http.NewRequest("POST", "https://api.rendley.com/v1/ai/generate-image/cost", body)
	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")
	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	b, _ := io.ReadAll(res.Body)
	fmt.Println(string(b))
}
```

```
require "net/http"
require "json"

uri = URI("https://api.rendley.com/v1/ai/generate-image/cost")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer YOUR_API_KEY"
req["Content-Type"] = "application/json"
req.body = { params: { prompt: "A cinematic shot of a city at sunset" }, model_id: "nano-banana" }.to_json

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)["data"]
```

Response 200

```
{
  "data": 0
}
```

Generation is asynchronous. These endpoints return a `job_id`, so poll [GET /v1/jobs/{id}](https://docs.rendley.com/api/jobs/) until the job completes and read the download URL off the finished job. [Jobs and polling](https://docs.rendley.com/api/polling/) covers the loop, and [Generate and download](https://docs.rendley.com/api/examples/generate-and-download/) is a script that runs it end to end.

[Previous pageBrand Kit](https://docs.rendley.com/api/brand-kit/) [Next pageVideo generation API](https://docs.rendley.com/api/generate-video/)
