> ## Documentation Index
> Fetch the complete documentation index at: https://www.krea.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Krea 3 API का अवलोकन

> Krea 3 API गाइड: निर्देशों का पालन करने वाला एक तेज़ इमेज एडिटिंग मॉडल। एंडपॉइंट, पैरामीटर, थिंकिंग मोड, रीजनल एडिट और कोड उदाहरण।

Krea 3 एक तेज़ इमेज एडिटिंग मॉडल है। यह सरल भाषा में लिखे निर्देशों का पालन करता है: आप बताते हैं कि क्या बदलना है और क्या वैसा ही रहना चाहिए, और Krea 3 कुछ ही सेकंड में एडिट तैयार कर देता है। आप इसका इस्तेमाल टेक्स्ट-टू-इमेज जनरेशन के लिए भी कर सकते हैं।

<Info>
  Krea 3 API अभी **अर्ली एक्सेस** में है। केवल Krea 3 बीटा में शामिल वर्कस्पेस ही इसे कॉल कर सकते हैं। एक्सेस का अनुरोध करने के लिए [sales@krea.ai](mailto:sales@krea.ai) से संपर्क करें।
</Info>

## एंडपॉइंट

| मॉडल | एंडपॉइंट |
| - | - |
| **Krea 3** | `POST /generate/image/krea/krea-3` |

यह एंडपॉइंट मानक [जॉब लाइफ़साइकिल](/docs/hi/developers/job-lifecycle) का उपयोग करता है: यह एक `job_id` लौटाता है, और जॉब पूरा होने तक आप `GET /jobs/{job_id}` को पोल करते हैं (या [वेबहुक](/docs/hi/developers/webhooks) का उपयोग करते हैं)। आउटपुट इमेज `result.urls[0]` में मिलती है।

## क्विकस्टार्ट: आपका पहला इमेज एडिट

सभी अनुरोधों के लिए Bearer token आवश्यक है। यदि आपके पास अभी तक नहीं है तो [API Keys & Billing](/docs/hi/developers/api-keys-and-billing) देखें।

<Steps>
  <Step title="रेफ़रेंस अपलोड करें">
    अपनी इनपुट इमेज के साथ `POST /assets` भेजें। रिस्पॉन्स में `image_url` मिलता है। आप `image_urls` में सीधे कोई बाहरी इमेज URL या base64 data URI भी दे सकते हैं।
  </Step>

  <Step title="एडिट बनाएं">
    अपने प्रॉम्प्ट और रेफ़रेंस के साथ `POST /generate/image/krea/krea-3` भेजें। रिस्पॉन्स से `job_id` सेव कर लें।
  </Step>

  <Step title="परिणाम प्राप्त करें">
    `GET /jobs/{job_id}` को तब तक पोल करें जब तक `status` का मान `completed` न हो जाए। आउटपुट `result.urls[0]` में मिलता है।
  </Step>
</Steps>

<CodeGroup>
  ```bash cURL theme={null}
  # Bash + curl + jq. Set KREA_API_TOKEN to your API token first.
  set -euo pipefail
  : "${KREA_API_TOKEN:?Set your Krea API token}"

  # 1. Upload a reference
  ASSET=$(curl --fail-with-body --silent --show-error --max-time 60 \
    https://api.krea.ai/assets \
    -H "Authorization: Bearer $KREA_API_TOKEN" \
    -F "file=@reference.png")

  IMAGE_URL=$(printf '%s' "$ASSET" | jq -er '.image_url')

  # 2. Create an edit
  PAYLOAD=$(jq -n --arg image "$IMAGE_URL" '{
    prompt: "Place the product on a clean studio background",
    thinking_mode: "fast",
    image_urls: [$image],
    resolution: "2k"
  }')

  JOB=$(curl --fail-with-body --silent --show-error --max-time 60 \
    https://api.krea.ai/generate/image/krea/krea-3 \
    -H "Authorization: Bearer $KREA_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d "$PAYLOAD")

  JOB_ID=$(printf '%s' "$JOB" | jq -er '.job_id')

  # 3. Get the result
  for attempt in $(seq 1 150); do
    JOB=$(curl --fail-with-body --silent --show-error --max-time 30 \
      "https://api.krea.ai/jobs/$JOB_ID" \
      -H "Authorization: Bearer $KREA_API_TOKEN")
    STATUS=$(printf '%s' "$JOB" | jq -er '.status')
    case "$STATUS" in
      completed)
        printf '%s' "$JOB" | jq -er '.result.urls[0]'
        exit 0 ;;
      failed|cancelled)
        printf 'Job ended: %s\n' "$STATUS" >&2; exit 1 ;;
      scheduled|processing|queued|backlogged|sampling|intermediate-complete)
        sleep 2 ;;
      *) printf 'Unexpected status: %s\n' "$STATUS" >&2; exit 1 ;;
    esac
  done
  printf 'Polling timed out\n' >&2
  exit 1
  ```

  ```python Python theme={null}
  # Python 3 + requests: pip install requests
  # Set KREA_API_TOKEN to your API token first.
  import os
  import time
  import requests

  api = "https://api.krea.ai"
  headers = {"Authorization": f"Bearer {os.environ['KREA_API_TOKEN']}"}

  # 1. Upload a reference
  with open("reference.png", "rb") as image:
      response = requests.post(
          f"{api}/assets", headers=headers,
          files={"file": image}, timeout=60,
      )
  response.raise_for_status()
  image_url = response.json()["image_url"]

  # 2. Create an edit
  response = requests.post(
      f"{api}/generate/image/krea/krea-3",
      headers=headers,
      json={
          "prompt": "Place the product on a clean studio background",
          "thinking_mode": "fast",
          "image_urls": [image_url],
          "resolution": "2k",
      },
      timeout=60,
  )
  response.raise_for_status()
  job_id = response.json()["job_id"]

  # 3. Get the result
  pending = {"scheduled", "processing", "queued", "backlogged",
             "sampling", "intermediate-complete"}
  deadline = time.monotonic() + 300

  while time.monotonic() < deadline:
      response = requests.get(
          f"{api}/jobs/{job_id}", headers=headers, timeout=30,
      )
      response.raise_for_status()
      job = response.json()
      if job["status"] == "completed":
          print(job["result"]["urls"][0])
          break
      if job["status"] not in pending:
          raise RuntimeError(f"Job ended: {job['status']}")
      time.sleep(2)
  else:
      raise TimeoutError("Polling timed out")
  ```

  ```javascript Node.js theme={null}
  // Node.js 22+. Save as example.mjs.
  // Set KREA_API_TOKEN to your API token first.
  import { readFile } from "node:fs/promises";

  const token = process.env.KREA_API_TOKEN;
  if (!token) throw new Error("Set your Krea API token");
  const api = "https://api.krea.ai";
  const headers = { Authorization: `Bearer ${token}` };

  async function request(path, options = {}) {
    const response = await fetch(`${api}${path}`, {
      ...options,
      headers: { ...headers, ...options.headers },
      signal: AbortSignal.timeout(60_000),
    });
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return response.json();
  }

  // 1. Upload a reference
  const form = new FormData();
  form.append("file", new Blob([await readFile("reference.png")]), "reference.png");
  const asset = await request("/assets", { method: "POST", body: form });

  // 2. Create an edit
  const job = await request("/generate/image/krea/krea-3", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      prompt: "Place the product on a clean studio background",
      thinking_mode: "fast",
      image_urls: [asset.image_url],
      resolution: "2k",
    }),
  });

  // 3. Get the result
  const pending = new Set([
    "scheduled", "processing", "queued", "backlogged",
    "sampling", "intermediate-complete",
  ]);
  const deadline = Date.now() + 300_000;
  let imageUrl;

  while (Date.now() < deadline) {
    const result = await request(`/jobs/${job.job_id}`);
    if (result.status === "completed") {
      imageUrl = result.result.urls[0];
      break;
    }
    if (!pending.has(result.status)) {
      throw new Error(`Job ended: ${result.status}`);
    }
    await new Promise((resolve) => setTimeout(resolve, 2_000));
  }
  if (!imageUrl) throw new Error("Polling timed out");
  console.log(imageUrl);
  ```
</CodeGroup>

<Tip>
  अपना API token अपने सर्वर पर ही रखें। इसे कभी भी क्लाइंट-साइड कोड में न भेजें।
</Tip>

## पैरामीटर

| फ़ील्ड | टाइप | नोट्स |
| - | - | - |
| `prompt` | string | **आवश्यक।** एडिटिंग का निर्देश। बताएं कि क्या बदलना है और क्या वैसा ही रहना चाहिए। |
| `image_urls` | array of strings | वैकल्पिक। इनपुट इमेज रेफ़रेंस, अधिकतम 8। एडिट के लिए कम से कम एक शामिल करें; टेक्स्ट-टू-इमेज जनरेशन के लिए इसे छोड़ दें। `POST /assets` से मिला `image_url`, कोई बाहरी URL या base64 data URI स्वीकार करता है। |
| `thinking_mode` | enum | वैकल्पिक। `fast` (डिफ़ॉल्ट) या `high`। [थिंकिंग मोड](#thinking-modes) देखें। |
| `resolution` | enum | `1k` या `2k`। आवश्यक, जब तक आप `width` और `height` दोनों न दें। इसे `width` और `height` के साथ न मिलाएं। |
| `aspect_ratio` | enum | वैकल्पिक। `1:1`, `4:5`, `3:4`, `2:3`, `9:16`, `5:4`, `4:3`, `3:2`, `16:9`, `21:9` में से कोई एक। इसे `resolution` के साथ इस्तेमाल करें। ऑटोमैटिक फ़्रेमिंग के लिए इसे छोड़ दें। |
| `width` / `height` | integers | वैकल्पिक। अनुरोधित डाइमेंशन, हर एक 4096 तक का धनात्मक पूर्णांक। दोनों दें, `resolution` या `aspect_ratio` के बिना। |
| `seed` | integer | वैकल्पिक। रैंडम seed चुनने के लिए इसे छोड़ दें। |
| `negative_prompt` | string | वैकल्पिक। किन चीज़ों से बचना है, अधिकतम 1,024 कैरेक्टर। |
| `regional_edit` | boolean | वैकल्पिक। ऐसे लोकल एडिट के लिए `true` सेट करें जो बाकी इमेज को बिल्कुल वैसा ही रखे। `image_urls` में कम से कम एक इमेज ज़रूरी है। [रीजनल एडिट](#regional-edits) देखें। |

<Note>
  `width` और `height` के साथ, आउटपुट को सबसे नज़दीकी समर्थित आस्पेक्ट रेशियो और 1k या 2k कैनवस पर राउंड किया जाता है। सटीक पिक्सेल डाइमेंशन की गारंटी नहीं है।

  किसी `seed` को दोबारा इस्तेमाल करने से एक जैसे परिणाम की गारंटी नहीं मिलती, क्योंकि प्रॉम्प्ट एक्सपैंशन का चरण हर रन में अलग हो सकता है।
</Note>

<h2 id="thinking-modes">
  थिंकिंग मोड
</h2>

जनरेट करने से पहले, Krea 3 आपके प्रॉम्प्ट की व्याख्या करता है। `thinking_mode` तय करता है कि यह कितनी प्लानिंग करे।

| मोड | क्या होता है | किसके लिए उपयोग करें |
| - | - | - |
| `fast` | Krea प्रॉम्प्ट को तेज़ी से विस्तार देता है, फिर जनरेट करता है। सबसे तेज़। **डिफ़ॉल्ट और अनुशंसित।** | स्पष्ट, सरल एडिट और ज़्यादातर रोज़मर्रा के अनुरोध। |
| `high` | Krea प्रॉम्प्ट और रेफ़रेंस इमेज के आधार पर ज़्यादा जटिल एडिट की योजना बनाने के लिए एक मज़बूत रीज़निंग इंजन का उपयोग करता है, फिर जनरेट करता है। धीमा। | जटिल या कई चरणों वाले एडिट, कई रेफ़रेंस को मिलाना, या जब `fast` का परिणाम आपका अनुरोध पूरा न कर पाए। |

यदि आप `thinking_mode` छोड़ देते हैं, तो API `fast` का उपयोग करता है। दोनों मोड `regional_edit` को सपोर्ट करते हैं।

<h2 id="regional-edits">
  रीजनल एडिट
</h2>

`regional_edit: true` के साथ, Krea 3 इमेज के सिर्फ़ उन्हीं हिस्सों को दोबारा जनरेट करता है जिन्हें बदलना है। बाकी सब कुछ बिल्कुल पहले जैसा रहता है, इसलिए आप क्वालिटी खोए बिना एक ही इमेज को बार-बार एडिट कर सकते हैं।

**इसे लोकल एडिट के लिए इस्तेमाल करें**, जहां बाकी इमेज पिक्सेल-दर-पिक्सेल वैसी ही रहनी चाहिए: किसी ऑब्जेक्ट का रंग बदलना या उसे बदल देना, कोई एलिमेंट जोड़ना या हटाना, किसी डिटेल को ठीक करना, या किसी साइनबोर्ड का टेक्स्ट बदलना। नवीनतम आउटपुट पर एक के बाद एक एडिट करने का यही सुरक्षित तरीका है।

**ग्लोबल एडिट के लिए इसे छोड़ दें**, जिनमें पूरी इमेज को दोबारा रेंडर होना चाहिए: स्टाइल बदलना, लाइटिंग बदलना, मौसम या दिन का समय बदलना, रीफ़्रेमिंग, या कई इमेज को मिलाकर नया सीन बनाना। सामान्य एडिट पूरी इमेज को दोबारा रेंडर करते हैं, इसलिए नवीनतम आउटपुट को बार-बार एडिट करने पर आर्टिफ़ैक्ट जमा हो सकते हैं।

रीजनल एडिट के लिए `image_urls` में कम से कम एक इमेज ज़रूरी है।

```json theme={null}
{
  "prompt": "Change the mug to red, keeping everything else the same",
  "image_urls": ["IMAGE_URL"],
  "thinking_mode": "fast",
  "resolution": "2k",
  "regional_edit": true
}
```

## प्रॉम्प्ट लिखना

Krea 3 निर्देशों का पालन करने वाला एडिटर है। एडिट को सरल भाषा में लिखें:

* बदलाव से शुरुआत करें। सिर्फ़ वही डिटेल जोड़ें जो उसे पूरा करने में मदद करें।
* जब बाकी इमेज वैसी ही रहनी चाहिए, तो अंत में एक वाक्य जोड़ें जो उसे बनाए रखने को कहे। जो कुछ भी वैसा रहना चाहिए, उसकी पूरी सूची न दें।
* जब प्रॉम्प्ट में एक से ज़्यादा इमेज हों, तो हर इमेज का ज़िक्र उसमें दिखने वाली चीज़ से करें। उदाहरण के लिए: "दूसरी इमेज वाले स्नीकर को पहली इमेज वाले व्यक्ति को पहनाएं।"

```text theme={null}
Change the mug to red, keeping everything else the same.
```

## इमेज रेफ़रेंस

* Krea 3 हर रेफ़रेंस को उसके अपलोड किए गए रेज़ोल्यूशन पर इस्तेमाल करता है। 4 MP से बड़े रेफ़रेंस को 4 MP पर रीसाइज़ कर दिया जाता है।
* ज़्यादातर एडिट के लिए लगभग 1 MP काफ़ी है। रेफ़रेंस भेजने से पहले उसे अपस्केल न करें।
* जब बारीक डिटेल मायने रखती हों (छोटा टेक्स्ट, लोगो, कपड़ा, वाइड शॉट में चेहरे), तो आपके पास मौजूद इमेज का सबसे ज़्यादा रेज़ोल्यूशन वाला वर्शन भेजें।
* एक अनुरोध में पांच या ज़्यादा रेफ़रेंस होने पर, हर रेफ़रेंस को रीसाइज़ किया जाता है ताकि उसकी सबसे लंबी साइड अधिकतम 1536 px हो। पूरी डिटेल वाले रेफ़रेंस के लिए चार या उससे कम भेजें।

## Zero Data Retention

Krea 3 एंटरप्राइज़ वर्कस्पेस के लिए [Zero Data Retention](/docs/hi/developers/zdr) को सपोर्ट करता है। `X-Api-Zero-Data-Retention: 1` हेडर भेजें। Zero Data Retention के साथ:

* `image_urls` की हर इमेज base64 data URI होनी चाहिए।
* `thinking_mode` का मान `fast` या `high` हो सकता है।
* एक अनुरोध में अधिकतम 4 इमेज रेफ़रेंस इस्तेमाल किए जा सकते हैं।

```bash theme={null}
IMAGE_DATA_URI="data:image/png;base64,$(base64 < ./reference.png | tr -d '\n')"

curl -X POST https://api.krea.ai/generate/image/krea/krea-3 \
  -H "Authorization: Bearer $KREA_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "X-Api-Zero-Data-Retention: 1" \
  -d '{
    "prompt": "Change the mug to red, keeping everything else the same",
    "image_urls": ["'"$IMAGE_DATA_URI"'"],
    "thinking_mode": "fast",
    "resolution": "2k"
  }'
```

## मूल्य निर्धारण

प्रति इमेज कीमत आउटपुट रेज़ोल्यूशन, थिंकिंग मोड और इमेज रेफ़रेंस पर निर्भर करती है।

| मूल्य घटक | 1K आउटपुट | 2K आउटपुट |
| - | - | - |
| बेस कीमत | \$0.03 | \$0.06 |
| हर 1K रेफ़रेंस इमेज | +\$0.02 | +\$0.02 |
| हर 2K रेफ़रेंस इमेज | +\$0.07 | +\$0.07 |
| `high` थिंकिंग मोड | +\$0.02 प्रति जनरेशन | +\$0.02 प्रति जनरेशन |

## संबंधित

<CardGroup cols={2}>
  <Card title="जॉब लाइफ़साइकिल" icon="arrows-rotate" href="/docs/hi/developers/job-lifecycle">
    जॉब स्टेटस, पोलिंग और परिणाम।
  </Card>

  <Card title="वेबहुक" icon="bell" href="/docs/hi/developers/webhooks">
    पोलिंग के बजाय जॉब पूरा होने पर सूचना पाएं।
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.