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
| Field | Type | Description |
|---|---|---|
prompt | string | Required. Up to 1000 characters. |
aspect_ratio | string | One of "1:1", "3:4", "4:3", "9:16", "16:9". Default "1:1". |
size | string | Alternative to aspect_ratio: "1024x1024", "768x1024", "1024x768", "576x1024", "1024x576". |
seed | integer | Optional, 0–2147483647. Reuse a seed to explore variations of the same idea. |
response_format | string | "url" (default) or "b64_json". |
model | string | Optional. 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.
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | A parameter is missing or invalid. |
| 400 | prompt_rejected | The prompt cannot be used. Try different wording. |
| 401 | invalid_api_key | The key is missing, malformed or revoked. |
| 402 | subscription_inactive | Your plan is not active. Renew in the app. |
| 429 | rate_limited | You are sending requests faster than we can serve right now. Retry after the Retry-After header. |
| 503 | busy | High demand. Retry after the Retry-After header. |
Availability and throughput are subject to system load.