Source: https://ailoot.ai/docs/hi/api/images/
Canonical: https://ailoot.ai/docs/hi/api/images/
Language: hi

[API](https://ailoot.ai/docs/hi/) 

# चित्र/छवियाँ

[मार्कआउट फॉर्मेट।](https://ailoot.ai/docs/hi/api/images/index.md)

OpenAI फॉर्मेट में छवियों को生成 एवं संपादित करना संभव है।

पोस्ट`https://api.ailoot.ai/v1/images/generations`

चित्र/छवियाँ

```bash
curl https://api.ailoot.ai/v1/images/generations \
  -H "Authorization: Bearer $AILOOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.5",
    "prompt": "Watercolor painting: a lighthouse on a cliff at dawn",
    "size": "1024x1024"
  }' 
```

```python
img = client.images.generate(
    model="gpt-image-2.5",
    prompt="Watercolor painting: a lighthouse on a cliff at dawn",
    size="1024x1024",
)
print(img.data[0].url or "base64:", (img.data[0].b64_json or "")[:40])
```

200 ठीक है.

```json
{
  "created": 1790812800,
  "data": [
    { "url": "https://…/content" }
  ],
  "usage": { "input_tokens": 18, "output_tokens": 1056 }
}
```

## प्रमाणीकरण।

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `Authorization` | हेडर | आवश्यक है। | फॉर्मेट में कुंजी/महत्वपूर्ण भाग। `Bearer sk-…`। निम्नलिखित हेडर भी कार्य करते हैं: `x-api-key` या `x-goog-api-key`. |

## अनुरोध शरीर/डेटा

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `मॉडल।` | स्ट्रिंग। | आवश्यक है। | – छवि मॉडल: `gpt-image-2.5-sunburst`, `gemini-3.1-flash-image`, `grok-imagine-image-2.0`, `qwen-image-3.0-pro`, `image-01`, `gpt-image-2`, `gemini-3.1-flash-lite-image`, `grok-imagine-image`, `wan2.7-image`, `gpt-image-2.5-sunburst-2026-09-08`, `gemini-3-pro-image`, `grok-imagine-image-quality` एवं अन्य… [4](https://ailoot.ai/models/hi/?format=images). |
| `– प्रॉम्प्ट…` | स्ट्रिंग। | आवश्यक है। | – छवि का विवरण… |
| `n` | पूर्णांक/इंटीजर | वैकल्पिक/ऐच्छिक | – उत्पन्न होने वाली छवियों की संख्या… प्रत्येक पूरी हुई छवि के लिए शुल्क लिया जाता है… |
| `– आकार…` | स्ट्रिंग। | वैकल्पिक/ऐच्छिक | – आकार… उदाहरण के लिए… `1024x1024`– समर्थित आकार… यह मॉडल पर निर्भर है… |
| `– गुणवत्ता…` | स्ट्रिंग। | वैकल्पिक/ऐच्छिक | – गुणवत्ता… यदि मॉडल द्वारा समर्थित है… `low`, `medium`, `high`). |
| `उत्तर-प्रारूप/रूप` | स्ट्रिंग। | वैकल्पिक/ऐच्छिक | `url` या `b64_json` – यदि मॉडल, फॉर्मेट चुनने का समर्थन करता है। |

## – संपादन।

पोस्ट`https://api.ailoot.ai/v1/images/edits`

– अनुरोध। `multipart/form-data`– फील्ड। `image` – एक या अधिक छवियाँ। `prompt`, `model`– वैकल्पिक रूप से। `mask`.

## प्रतिक्रिया/उत्तर:

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `– डेटा।` | सरणी |  | – पूरी हुई छवियाँ: यूआरएल, या डेटा। `url` – या डेटा। `b64_json`– मॉडल के आधार पर। |

प्रजनन से पहले, Ailoot आउटपुट की पूरी लागत को अपने पास रखता है। छवियों की लागत, टेक्स्ट की लागत से अधिक होती है; इसलिए अपने बैलेंस में अतिरिक्त धन रखें। प्रति छवि या प्रति छवि टोकन की कीमतें दी गई हैं। [कैटलॉग/सूची](https://ailoot.ai/models/hi/?kind=image).

## संपादन – मल्टीपार्ट/फॉर्म-डेटा

```bash
: "${AILOOT_IMAGE_EDIT_MODEL:?Select a model whose actual card or GET /v1/models method supports /v1/images/edits}"
curl --fail-with-body --max-time 300 \
  -D image-edit-headers.txt -o image-edit.json \
  https://api.ailoot.ai/v1/images/edits \
  -H "Authorization: Bearer $AILOOT_API_KEY" \
  -F "model=$AILOOT_IMAGE_EDIT_MODEL" \
  -F 'prompt=Keep the subject and replace the background with a sunset' \
  -F 'image=@input.png'
```

`input.png` → `image-edit.json` → `data[]` → `url | b64_json`

```python
import base64
import json
import mimetypes
import os
from pathlib import Path
import time
from urllib.parse import urljoin, urlsplit
from urllib.request import Request, urlopen

origin = "https://api.ailoot.ai"
out = Path("image-edit-results")
out.mkdir(exist_ok=True)

def save_all(data):
    rows = data.get("data", [])
    if not rows:
        raise RuntimeError("No completed image data; keep the original response")
    for index, row in enumerate(rows, 1):
        if row.get("b64_json"):
            content = base64.b64decode(row["b64_json"], validate=True)
            suffix = ".png" if content.startswith(b"\x89PNG") else ".bin"
        elif row.get("url"):
            url = row["url"]
            if urlsplit(url).scheme != "https":
                raise ValueError("Expected the exact returned HTTPS image URL")
            # Signed result URLs are downloaded without sending the API key to another host.
            with urlopen(url, timeout=300) as response:
                content = response.read()
                suffix = mimetypes.guess_extension(response.headers.get_content_type()) or ".bin"
        else:
            raise RuntimeError("Image has neither url nor b64_json")
        (out / ("image-%03d" % index + suffix)).write_bytes(content)


with open("image-edit.json", encoding="utf-8") as response:
    save_all(json.load(response))
```

## छवियाँ · असीमित/अनियमित

OpenAI एवं Anthropic SDK, आम तौर पर नेटवर्क समस्याओं एवं 5xx प्रतिक्रियाओं को पुनरावृत्त करते हैं। जेनरेशन अनुरोधों के लिए इस व्यवस्था को अक्षम कर दें।`max_retries=0`और जाँच करें। `X-Should-Retry` नए प्रयास से पहले… एक असफल प्रयास का मतलब यह नहीं है कि अनुरोध निष्पादित नहीं हुआ।

```python
import base64
import json
import mimetypes
import os
from pathlib import Path
import time
from urllib.parse import urljoin, urlsplit
from urllib.request import Request, urlopen

origin = "https://api.ailoot.ai"
key = os.environ["AILOOT_API_KEY"]
out = Path("image-results")
out.mkdir(exist_ok=True)

def api(url, payload=None):
    url = urljoin(origin, url)
    if urlsplit(url).scheme != "https" or urlsplit(url).netloc != "api.ailoot.ai":
        raise ValueError("Unexpected API origin")
    request = Request(url, data=None if payload is None else json.dumps(payload).encode(),
                      headers={"Authorization": "Bearer " + key, "Content-Type": "application/json"})
    with urlopen(request, timeout=300) as response:
        headers = dict(response.headers)
        data = json.load(response)
    (out / "response-headers.json").write_text(json.dumps(headers, indent=2))
    return data, headers

def save_all(data):
    rows = data.get("data", [])
    if not rows:
        raise RuntimeError("No completed image data; keep the original response")
    for index, row in enumerate(rows, 1):
        if row.get("b64_json"):
            content = base64.b64decode(row["b64_json"], validate=True)
            suffix = ".png" if content.startswith(b"\x89PNG") else ".bin"
        elif row.get("url"):
            url = row["url"]
            if urlsplit(url).scheme != "https":
                raise ValueError("Expected the exact returned HTTPS image URL")
            # Signed result URLs are downloaded without sending the API key to another host.
            with urlopen(url, timeout=300) as response:
                content = response.read()
                suffix = mimetypes.guess_extension(response.headers.get_content_type()) or ".bin"
        else:
            raise RuntimeError("Image has neither url nor b64_json")
        (out / ("image-%03d" % index + suffix)).write_bytes(content)

# One POST. If its result is unknown, preserve it and check history; do not rerun creation.
task, headers = api("/v1/images/generations/async", {
    "model": "gpt-image-2.5", "prompt": "Watercolor lighthouse at dawn", "size": "1024x1024"})
(out / "created-task.json").write_text(json.dumps(task, indent=2))
task_id = task.get("task_id") or task.get("id")
poll_url = task.get("poll_url") or headers.get("Location") or headers.get("location")
if not task_id or not poll_url:
    raise RuntimeError("Keep the create response and Request ID; do not submit again")

for poll in range(60):
    task, headers = api(poll_url)  # Read the original task with the same key.
    (out / "task-status.json").write_text(json.dumps(task, indent=2))
    if task.get("status") == "completed":
        result = task["result"]
        (out / "image-response.json").write_text(json.dumps(result, indent=2))
        save_all(result)
        break
    if task.get("status") == "failed":
        raise RuntimeError(json.dumps(task.get("error")))
    if task.get("status") != "processing" or task.get("result_pending_check"):
        raise RuntimeError("Keep the original task ID and check it later; no new POST")
    time.sleep(min(60, max(1, int(headers.get("Retry-After", headers.get("retry-after", "3"))))))
else:
    raise TimeoutError("Polling stopped; resume GET reads using created-task.json, never repeat POST")
```

अभी भी कुछ सवाल हैं? अपनी विंडो में अनुरोध का नाम एवं विवरण भेजें… हम आपको मदद करेंगे।[सहायता हेतु संपर्क करें.](mailto:support@ailoot.ai)

## Ailoot · कंपनी एवं उसका प्रोजेक्ट पोर्टफोलियो





Ailoot में व्यापक अनुभव, विशाल क्लाइंट बेस, स्थिर सेवाएँ, एवं लगातार KPI नियंत्रण शामिल है।





कंपनी एवं उसकी परियोजनाओं के बारे में: लाखों ग्राहक; मासिक बिक्री राशि अरबों में है।





Ailoot उस कार्यान्वयन अनुभव को API तक लाता है; ताकि कस्टमर उत्पादों, एजेंटों, एप्लिकेशनों एवं ऑटोमेशनों में एआई सुविधाओं का लाभ उठाया जा सके।
