Documentation

chatular-image-api

Two calls for making pictures: text to image and image to image. The answer holds the finished picture. They need the same API key.

How it works

1
Send your words to POST /api/image/text-to-image, or your words and a picture to POST /api/image/image-to-image.
2
Keep the connection open. The answer arrives when the pictures are ready, usually in under a minute.
3
Download each picture from its file address, with your key.

Text to image

POST /api/image/text-to-image. Makes a new picture from your words.

FieldTypeWhat it is
promptstringWhat to create, in any language, up to 2,500 characters. Required.
shapestringsquare, portrait, tall or wide. Leave it out and the words decide, else square.
countnumberHow many pictures, 1 to 4. The default is 1.
curl https://api.chatular.ai/api/image/text-to-image \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"A perfume poster, Velvet Night, new scent","shape":"tall"}'

In JavaScript:

import { writeFile } from 'node:fs/promises';

const res = await fetch('https://api.chatular.ai/api/image/text-to-image', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ prompt: 'A perfume poster, Velvet Night, new scent', shape: 'tall' }),
});
const { pictures } = await res.json();

// Download the first picture
const file = await fetch('https://api.chatular.ai' + pictures[0].file, {
  headers: { Authorization: 'Bearer YOUR_API_KEY' },
});
await writeFile('poster.png', Buffer.from(await file.arrayBuffer()));

In Python:

import requests

API = "https://api.chatular.ai"
headers = {"Authorization": "Bearer YOUR_API_KEY"}

res = requests.post(
    API + "/api/image/text-to-image",
    headers=headers,
    json={"prompt": "A perfume poster, Velvet Night, new scent", "shape": "tall"},
)
pictures = res.json()["pictures"]

# Download the first picture
file = requests.get(API + pictures[0]["file"], headers=headers)
with open("poster.png", "wb") as f:
    f.write(file.content)

Image to image

POST /api/image/image-to-image. Changes the picture you send, as your words say. A picture you send is kept in your account for later, as one added in the app is.

FieldTypeWhat it is
promptstringWhat to change, in any language, up to 2,500 characters. Required.
imageobjectThe picture to change, { base64 }: PNG, JPEG or WebP under 10 MB. Required.
shapestringsquare, portrait, tall or wide. Leave it out and the picture keeps its own shape. Another shape can crop it.
countnumberHow many pictures, 1 to 4. The default is 1.
curl https://api.chatular.ai/api/image/image-to-image \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"Make the sneakers white","image":{"base64":"iVBORw0KGgo…"}}'

In Python, from a file:

import base64, requests

API = "https://api.chatular.ai"
headers = {"Authorization": "Bearer YOUR_API_KEY"}

with open("photo.png", "rb") as f:
    photo = base64.b64encode(f.read()).decode()

res = requests.post(
    API + "/api/image/image-to-image",
    headers=headers,
    json={"prompt": "Make the sneakers white", "image": {"base64": photo}},
)
pictures = res.json()["pictures"]

The answer

Both calls answer the same way:

{
  "pictures": [
    {
      "id": "k3J9…",
      "prompt": "A perfume poster, Velvet Night, new scent",
      "shape": "tall",
      "width": 576,
      "height": 1024,
      "createdAt": 1793491200000,
      "file": "/api/image/k3J9…/file"
    }
  ],
  "failed": 0
}
FieldWhat it is
idThe picture's id.
promptThe words you sent.
shapeThe shape it was created in.
width, heightIts size in pixels.
createdAtWhen it was made, in milliseconds since 1970.
fileWhere to download it. Add it to https://api.chatular.ai.
failedHow many of the pictures you asked for could not be created.
limitedPresent when your daily limit allowed fewer than you asked for; dailyLimit says what it is.

Download the picture

GET /api/image/:id/file sends the picture itself, as PNG, JPEG or WebP (see its Content-Type). It needs the key of the account that made it.

curl https://api.chatular.ai/api/image/k3J9…/file \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --output poster.png

Limits

Each picture counts against your plan's pictures per day, which reset at midnight UTC. A picture that fails does not count. Pictures are kept in your account and also appear in My paints.

Errors

StatuscodeWhat it means
400empty, too_long, bad_shape, bad_count, bad_input, needs_image, image_not_allowedThe words are missing or too long, the shape or the count is wrong, the picture can't be read or is missing, or text to image was sent a picture.
401The key is missing, wrong or revoked.
422blockedThese words can't be used. Try different ones.
429photo_limitYou have made all your pictures for today.
502failedThe picture could not be created. Try again.
503unavailableCreating pictures is not available right now.