# שנעלע אָנהייב

לויפֿט אײַער ערשטע גענערירונג אין עטלעכע מינוטן. אַלע 1,496 מאָדעלן נעמען דעם זעלבן סאָרט בקשה און געבן צוריק דעם זעלבן בקשה־אָביעקט, פֿאַר בילדער, ווידעא און אַודיאָ: לערנט עס דאָ אַמאָל.

> [!NOTE]
> באַזע URL `https://api.doitong.com/v1`. יעדע רוף שיקט `Authorization: Bearer <your key>`, און דער זעלבער שליסל אַרבעט פֿאַר דעם HTTP
> API און דעם MCP סערווער.

## 1. באַקומען אַן API שליסל

שאַפֿט אַ שליסל בײַ [https://doitong.com/developers/dashboard#keys](https://doitong.com/developers/dashboard#keys) און היט אים אין אַן
ענוויראָנמענט־וואַריאַבל: ער ווערט געוויזן נאָר איין מאָל. יעדע שליסל קען האָבן זײַן אייגענעם בודזשעט, דערפֿאַר קענט איר אים געבן אַן אַגענט אָן צו ריזיקירן דעם גאַנצן חשבון. `GET /account` גיט צוריק אײַער API באַלאַנס.

```bash
export DOITONG_API_KEY="doitong_..."

curl "https://api.doitong.com/v1/account" \
  -H "Authorization: Bearer $DOITONG_API_KEY"
```
```javascript
const res = await fetch("https://api.doitong.com/v1/account", {
  headers: { Authorization: `Bearer ${process.env.DOITONG_API_KEY}` },
});

console.log(await res.json());
```
```python
import os
import requests

r = requests.get(
    "https://api.doitong.com/v1/account",
    headers={"Authorization": f"Bearer {os.environ['DOITONG_API_KEY']}"},
)
print(r.json())
```

לויפֿן ווערן באַצאָלט פֿון אײַער חשבוןס **API באַלאַנס** אין API קרעדיטן: 1,000 API־קרעדיטן = ⁨$ 1⁩, און יעדע מאָדעל קאָסט פּינקטלעך דעם פּרײַז פֿון זײַן שאַפֿער. לאָדט אײַף בײַ [https://doitong.com/developers/dashboard#balance](https://doitong.com/developers/dashboard#balance).

## 2. קוואָטירן, דערנאָך לויפֿן

`POST /quote/{model_id}` נעמט דעם אַרײַנגעבונג־JSON און גיט צוריק דעם פּינקטלעכן פּרײַז. עס דאַרף נישט קיין שליסל און קאָסט גאָרנישט. דאָס זעלבע אַרײַנגעבונג צו לויפֿן קאָסט פּינקטלעך דאָס: דער קוואָט איז דער אָפּצאָל. (א מאָדעל וואָס ווערט באַצאָלט לויט באַניץ איז די אויסנאַם: זײַן קוואָט איז דאָס מערסטע וואָס דער לויפֿ קען קאָסטן, און דער נישט־געניצטער טייל ווערט צוריקגעצאָלט נאָך דעם לויפֿ.)

```bash
curl -X POST "https://api.doitong.com/v1/quote/kling-video/v3/pro/image-to-video" \
  -H "Content-Type: application/json" \
  -d '{"image": "https://example.com/fox.jpg", "duration": 5, "generate_audio": true}'
```
```javascript
const res = await fetch("https://api.doitong.com/v1/quote/kling-video/v3/pro/image-to-video", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ image: "https://example.com/fox.jpg", duration: 5, generate_audio: true }),
});

const quote = await res.json();
console.log(quote.credits, quote.usd); // 840 "0.84"
```
```python
import requests

r = requests.post(
    "https://api.doitong.com/v1/quote/kling-video/v3/pro/image-to-video",
    json={"image": "https://example.com/fox.jpg", "duration": 5, "generate_audio": True},
)
print(r.json()["credits"], r.json()["usd"])  # 840 0.84
```

```json 200 OK · קוואָט
{
  "object": "quote",
  "model": "kling-video/v3/pro/image-to-video",
  "credits": 840,
  "usd": "0.84",
  "unit": "second",
  "quantity": 5,
  "unit_credits": 168,
  "mode": "exact",
  "breakdown": "5 s × 168 API credits"
}
```

דערנאָך שיקט דעם זעלבן גוף צו `POST /run/{model_id}`. לייגט צו `?wait=20` צו האַלטן די פֿאַרבינדונג ביז צו 20 סעקונדעס: אַ שנעלער מאָדעל גיט צוריק דעם פֿאַרטיקן רעזולטאַט אין איין רונדע. שיקט אַן `Idempotency-Key` קעפּל, כּדי אַ ווידער־פּרוּוו זאָל קיינמאָל לויפֿן (אָדער באַצאָלן) צוויי מאָל.

```bash
curl -X POST "https://api.doitong.com/v1/run/flux/schnell?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: lighthouse-001" \
  -d '{"prompt": "A lighthouse on a rocky coast at dusk, warm light in the window"}'
```
```javascript
const res = await fetch("https://api.doitong.com/v1/run/flux/schnell?wait=20", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.DOITONG_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "lighthouse-001",
  },
  body: JSON.stringify({ prompt: "A lighthouse on a rocky coast at dusk, warm light in the window" }),
});

const request = await res.json();
console.log(request.status, request.outputs[0]?.url);
```
```python
import os
import requests

r = requests.post(
    "https://api.doitong.com/v1/run/flux/schnell",
    params={"wait": 20},
    headers={
        "Authorization": f"Bearer {os.environ['DOITONG_API_KEY']}",
        "Idempotency-Key": "lighthouse-001",
    },
    json={"prompt": "A lighthouse on a rocky coast at dusk, warm light in the window"},
)
request = r.json()
print(request["status"], request["outputs"][0]["url"] if request["outputs"] else None)
```

דער ענטפֿער איז אַ בקשה־אָביעקט:

```json 200 OK · בקשה
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "flux/schnell",
  "status": "succeeded",
  "cost": { "credits": 3, "usd": "0.003", "charged": 3, "refunded": 0 },
  "outputs": [
    { "type": "image", "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg", "width": 1024, "height": 768, "stored": true }
  ],
  "error": null
}
```

## 3. נאָכגיין דעם סטאַטוס

אויב דער מאָדעל אַרבעט נאָך ווען די וואַרט־צײַט ענדיקט זיך, באַקומט איר `202 Accepted` מיט דער בקשהס `id` און איר איצטיקן `status`. יעדע בקשה גייט דורך דעם זעלבן לעבן־ציקל:

ריקוועסט־לעבנסציקל: `queued` → `running` → `succeeded` | `failed` | `canceled` (ענדגילטיק; פֿאַר דורכגעפאַלענע און קאַנסאַלירטע ווערט צוריקגעצאָלט).

לייענט די בקשה ווידער מיט איר id. `?wait=20` אַרבעט אויך דאָ, דערפֿאַר איז אַ פּשוטער שלייף גענוג:

```bash
curl "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"
```
```javascript
const headers = { Authorization: `Bearer ${process.env.DOITONG_API_KEY}` };
let request = await (await fetch("https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t?wait=20", { headers })).json();

while (request.status === "queued" || request.status === "running") {
  const res = await fetch(`https://api.doitong.com/v1/requests/${request.id}?wait=20`, { headers });
  request = await res.json();
}

console.log(request.status, request.outputs[0]?.url);
```
```python
import os
import requests

headers = {"Authorization": f"Bearer {os.environ['DOITONG_API_KEY']}"}
request = {"id": "req_8k2m4q7x1z9c3v5b6n0p2r4t", "status": "queued"}

while request["status"] in ("queued", "running"):
    request = requests.get(
        f"https://api.doitong.com/v1/requests/{request['id']}",
        params={"wait": 20},
        headers=headers,
    ).json()

print(request["status"], request["outputs"][0]["url"] if request["outputs"] else None)
```

ווען `status` איז `succeeded`, האַלט `outputs[].url` לינקס צו די פֿײַלן אין אונדזער סטאָרידזש. אויב די בקשה `failed` אָדער איז `canceled`, ווערן אירע API קרעדיטן אויטאָמאַטיש צוריקגעצאָלט און `error` זאָגט פֿאַרוואָס. קענסלט יעדע זאַך וואָס איז נאָך `queued` אָדער `running`:

```bash
curl -X POST "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel" \
  -H "Authorization: Bearer $DOITONG_API_KEY"
```

פֿאַר לאַנגע ווידעא־דזשאָבס קענט איר אויסלאָזן פּאָלינג און אַנשטאָט איבערגעבן אַ `webhook_url` (זעט [וועבהוקס](https://doitong.com/developers/docs/webhooks)).

## 4. פֿײַלן

גיט איבער יעדע פּובליקע URL ווי אַרײַנגעבונג, אָדער בעט `POST /files` פֿאַר אַן אײַפלאָד־URL, `PUT` דעם פֿײַל דאָרט און נוצט דעם צוריקגעגעבן `file_url` (זעט [פֿײַלן](https://doitong.com/developers/docs/files)). אַ מצליחע בקשה ליסטירט אירע רעזולטאַטן אין `outputs[]` מיט טיפּ, אינהאַלט־טיפּ און, ווען באַקאַנט, דימענסיעס און געדויער.

```bash
curl -X POST "https://api.doitong.com/v1/files" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filename": "fox.jpg", "content_type": "image/jpeg", "size": 482113}'
```

> [!TIP]
> **פֿײַלן געהאַלטן אויף אייביק, אָדער 7 טעג פֿרײַ: אײַער ברירה.** רעזולטאַט־פֿײַלן ווערן קאַפּירט אין אונדזער
> סטאָרידזש איידער אַ בקשה ווערט מצליח. לויטן סטאַנדאַרט בלײַבן זיי ביז איר מעקט זיי אויס (100 API קרעדיטן
> פּער GB פּער חודש); שאַלט "האַלטן טעקעס אויף אייביק" אויס אין דאַשבאָרד, אָדער גיט איבער `?storage=temporary`, צו האַלטן זיי
> 7 טעג פֿרײַ (זעט [פֿײַלן](https://doitong.com/developers/docs/files#storage)).

## ערראָרס

יעדע מאָדעל פֿאַלט אויס אויפֿן זעלבן אופֿן: איין ענוועלאָפּ מיט אַ `type`, אַן גענויעם `code`, דעם פּראָבלעמאַטישן `param` און יעדן פּראָבלעם אין `details`, כּדי אַן אַגענט זאָל קענען פֿאַרריכטן די בקשה אָן לייענען פּראָזע. פֿאַר אַן אומגילטיקער בקשה ווערט גאָרנישט אָפּגעלאָדן.

```json 422 Unprocessable Entity
{
  "error": {
    "type": "invalid_request",
    "code": "invalid_input",
    "message": "duration must be one of 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15.",
    "param": "duration",
    "details": [ { "param": "duration", "message": "duration must be one of 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15." } ],
    "request_id": null,
    "doc_url": "https://doitong.com/developers/docs/errors#invalid_input"
  }
}
```

יעדער טיפּ און קאָד איז אויסגערעכנט אין [ערראָרס](https://doitong.com/developers/docs/errors).

## פּרײַזן

פּרײַזן זענען אין USD און API קרעדיטן און ווערן געוויזן אויף יעדן מאָדעל־בלאַט איידער איר לויפֿט. יעדע בקשה טראָגט `cost` מיט `credits`, `usd`, `charged` און `refunded`. אַ לויפֿ ווערט אָפּגעלאָדן ווען ער ווערט אָנגענומען; `failed` און `canceled` בקשות ווערן אויטאָמאַטיש צוריקגעצאָלט. געוויסע מאָדעלן ווערן פּרײַזירט פּינקטלעך לויטן אַרײַנגעבונג, געוויסע לויט דער לענג אָדער גרייס פֿון די פֿײַלן וואָס איר שיקט, און אַנדערע נעמען אַן *אָפּגעשאַצטן פּרײַז פּער לויפֿ*: בכל אופֿן איז דער קוואָט וואָס איר צאָלט. אַ פּאָר מאָדעלן (שפּראַך־ און זעאונג־מאָדעלן, קול, פּראַסעסינג־צײַט־מכשירים) ווערן *אָפּגעלאָדן לויט באַניץ*: דער קוואָט איז דאָס מערסטע וואָס דער לויפֿ קען קאָסטן, און דער טייל וואָס דער לויפֿ האָט נישט גענוצט ווערט אויטאָמאַטיש צוריקגעצאָלט. זעט [פּרײַזן](https://doitong.com/developers/docs/pricing).

## MCP און AI אַגענטן

פֿאַרבינדט יעדן MCP קליענט צו `https://api.doitong.com/v1/mcp` מיט דעם זעלבן Bearer שליסל. אײַער אַגענט קען זוכן אין קאַטאַלאָג, קוואָטירן און לויפֿן מאָדעלן, און לייענען יעדן דאָקומענטאַציע־בלאַט ווי Markdown.

```bash Claude Code
claude mcp add --transport http doitong-models https://api.doitong.com/v1/mcp \
  --header "Authorization: Bearer YOUR_API_KEY"
```

## קומענדיקע טריט

- בלעטערט [אַלע מאָדעלן](https://doitong.com/developers/models). יעדן בלאַט האָט אַ בקשה־בויער וואָס שרײַבט דעם קאָד פֿאַר אײַך.
- לערנט דעם בקשה־לעבן־ציקל: [בקשות](https://doitong.com/developers/docs/requests).
- נוצט די זעלבע פּאַראַמעטער־נעמען אויף יעדן מאָדעל: [פּאַראַמעטערס](https://doitong.com/developers/docs/parameters).
- אַרבעט איר מיט אַן AI קאָדירונג־אַגענט? גיט אים [https://doitong.com/developers/llms.txt](https://doitong.com/developers/llms.txt) אָדער פֿאַרבינדט דעם [MCP סערווער](https://doitong.com/developers/docs/mcp).
