POST
/
v1
/
ai
/
image_generation
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.image_generation({
  "prompt": "A beautiful sunset over a calm ocean",
  "return_type": "url"
})
{
  "url": "https://jigsawstack-temp.b1e91a466694ad4af04df5d05ca12d93.r2.cloudflarestorage.com/temp/f86d418d-7385-4ff6-9ec7-4dbabdc2a03f.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=7b9a19349842b7b1a9e4c2e19f05b232%2F20250623%2Fauto%2Fs3%2Faws4_request&X-Amz-Date=20250623T154004Z&X-Amz-Expires=604800&X-Amz-Signature=0875f8ad8a61e078b92714cfdee4956435a34f4c82df6a68e85640af509c21d5&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject",
  "_usage": {
        "input_tokens": 11,
        "output_tokens": 75,
        "inference_time_tokens": 2577,
        "total_tokens": 2663
  }
}

Request Parameters

Body

prompt
string
required

The text prompt to generate the image from. Must be between 1-5000 characters.

aspect_ratio
string
default:"1:1"

The aspect ratio of the generated image.

  • 1:1
  • 16:9
  • 21:9
  • 3:2
  • 2:3
  • 4:5
  • 5:4
  • 3:4
  • 4:3
  • 9:16
  • 9:21
width
number

The width of the image. Must be between 256-1920 pixels.

height
number

The height of the image. Must be between 256-1920 pixels.

steps
number
default:"4"

The number of denoising steps. Must be between 1-90. Higher values produce better quality images but take more time to generate.

output_format
string
default:"png"

The output format of the generated image. Must be one of the following values:

  • png
  • svg
url
string

A valid URL where the generated image will be sent.

file_store_key
string

Key to store the generated image in file storage.

advance_config
object
return_type
string

The specified return type for the response

  • url
  • base64
  • binary
x-api-key
string
required

Your JigsawStack API key

Response

The API returns the generated image directly in the response body as binary data.

import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.image_generation({
  "prompt": "A beautiful sunset over a calm ocean",
  "return_type": "url"
})
{
  "url": "https://jigsawstack-temp.b1e91a466694ad4af04df5d05ca12d93.r2.cloudflarestorage.com/temp/f86d418d-7385-4ff6-9ec7-4dbabdc2a03f.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=7b9a19349842b7b1a9e4c2e19f05b232%2F20250623%2Fauto%2Fs3%2Faws4_request&X-Amz-Date=20250623T154004Z&X-Amz-Expires=604800&X-Amz-Signature=0875f8ad8a61e078b92714cfdee4956435a34f4c82df6a68e85640af509c21d5&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject",
  "_usage": {
        "input_tokens": 11,
        "output_tokens": 75,
        "inference_time_tokens": 2577,
        "total_tokens": 2663
  }
}