API reference

Generate images with chitrakar-1 from your own code. The API is included in your plan; create keys in the app after subscribing.

Authentication

Send your key as a bearer token. Keep it secret and call the API from your server, not from a browser.

Authorization: Bearer ck_YOUR_API_KEY

Create an image

POST https://chitrakar.app/v1/images/generations

FieldTypeDescription
promptstringRequired. Up to 1000 characters.
aspect_ratiostringOne of "1:1", "3:4", "4:3", "9:16", "16:9". Default "1:1".
sizestringAlternative to aspect_ratio: "1024x1024", "768x1024", "1024x768", "576x1024", "1024x576".
seedintegerOptional, 0–2147483647. Reuse a seed to explore variations of the same idea.
response_formatstring"url" (default) or "b64_json".
modelstringOptional. Must be "chitrakar-1".

Response

{
  "created": 1767225600,
  "data": [{
    "url": "https://chitrakar.app/i/3f9c…e1.jpg",
    "seed": 1234567,
    "width": 1024,
    "height": 1024
  }]
}

Requests are synchronous: the call returns when the image is ready, so allow a generous timeout (we recommend 180 seconds). Image URLs stay available for 30 days.

Examples

cURL

curl https://chitrakar.app/v1/images/generations \
  -H "Authorization: Bearer ck_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "A lighthouse above a stormy sea at dusk", "size": "1024x1024"}'

Python

import requests

r = requests.post(
    "https://chitrakar.app/v1/images/generations",
    headers={"Authorization": "Bearer ck_YOUR_API_KEY"},
    json={"prompt": "A lighthouse above a stormy sea at dusk", "aspect_ratio": "3:4"},
    timeout=180,
)
r.raise_for_status()
print(r.json()["data"][0]["url"])

JavaScript

const res = await fetch("https://chitrakar.app/v1/images/generations", {
  method: "POST",
  headers: { Authorization: "Bearer ck_YOUR_API_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({ prompt: "A lighthouse above a stormy sea at dusk", aspect_ratio: "16:9" }),
});
const { data } = await res.json();
console.log(data[0].url);

Errors

Errors return a JSON body: {"error": {"code": "…", "message": "…"}}. For 429 and 503, wait for the number of seconds in the Retry-After header, then retry.

StatusCodeMeaning
400invalid_requestA parameter is missing or invalid.
400prompt_rejectedThe prompt cannot be used. Try different wording.
401invalid_api_keyThe key is missing, malformed or revoked.
402subscription_inactiveYour plan is not active. Renew in the app.
429rate_limitedYou are sending requests faster than we can serve right now. Retry after the Retry-After header.
503busyHigh demand. Retry after the Retry-After header.

Availability and throughput are subject to system load.