Skip to content

Image Generation API

Generate, edit, and create variations of images. Compatible with the OpenAI Images API.

Base URL

https://api.getkawai.com/v1

Authentication

When authentication is enabled, include your token in the Authorization header:

Authorization: Bearer API_KEY

Image Generation

Generate images from text prompts.

POST /images/generations

Generates images from a text prompt.

Authentication: Required when auth is enabled. Token must have 'images-generations' endpoint access.

Headers

Header Required Description
Authorization Yes Bearer token for authentication
Content-Type Yes Must be application/json

Request Body

Content-Type: application/json

Field Type Required Description
prompt string Yes Text description of the image to generate
model string No Model ID to use
n integer No Number of images to generate (1-10, default: 1)
size string No Image size (e.g., '1024x1024')
quality string No Image quality: 'standard' or 'hd'
response_format string No Response format: 'url' or 'b64_json'

Response

Returns generated image URLs or base64-encoded images.

Content-Type: application/json

Examples

Generate a single image:

curl -X POST https://api.getkawai.com/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A serene mountain landscape at sunset",
    "n": 1,
    "size": "1024x1024"
  }'

Image Editing

Edit existing images using masks and prompts.

POST /images/edits

Edits an image based on a text prompt and optional mask.

Authentication: Required when auth is enabled. Token must have 'images-edits' endpoint access.

Headers

Header Required Description
Authorization Yes Bearer token for authentication
Content-Type Yes Must be application/json

Request Body

Content-Type: application/json

Field Type Required Description
prompt string Yes Text description of the edit
image string Yes Base64-encoded image to edit
mask string No Base64-encoded mask (white=edit, black=keep)
n integer No Number of images (1-10, default: 1)
size string No Image size
response_format string No Response format: 'url' or 'b64_json'

Response

Returns edited image URLs or base64-encoded images.

Content-Type: application/json

Examples

Edit image with mask:

curl -X POST https://api.getkawai.com/v1/images/edits \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Add a beautiful sunset sky",
    "image": "data:image/png;base64,iVBORw0KG...",
    "mask": "data:image/png;base64,iVBORw0KG...",
    "n": 1
  }'

Image Variations

Create variations of existing images.

POST /images/variations

Creates variations of an input image.

Authentication: Required when auth is enabled. Token must have 'images-variations' endpoint access.

Headers

Header Required Description
Authorization Yes Bearer token for authentication
Content-Type Yes Must be application/json

Request Body

Content-Type: application/json

Field Type Required Description
image string Yes Base64-encoded image
n integer No Number of variations (1-10)
size string No Image size
response_format string No Response format: 'url' or 'b64_json'

Response

Returns variation image URLs or base64-encoded images.

Content-Type: application/json

Examples

Generate 4 variations:

curl -X POST https://api.getkawai.com/v1/images/variations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "data:image/png;base64,iVBORw0KG...",
    "n": 4
  }'