# အမြန်စတင်ခြင်း

မိနစ်အနည်းငယ်အတွင်း ပထမဆုံး ဖန်တီးမှုကို လုပ်ဆောင်ပါ။ ၁,၄၉၆ မော်ဒယ်အားလုံးသည် တူညီသော တောင်းဆိုချက်အမျိုးအစားကို လက်ခံပြီး ပုံ၊ ဗီဒီယိုနှင့် အသံများအတွက် တူညီသော တောင်းဆိုချက်အရာဝတ္ထုကို ပြန်ပေးသည် — ဤနေရာတွင် တစ်ကြိမ်လေ့လာထားရုံဖြင့် လုံလောက်ပါသည်။

> [!NOTE]
> အခြေခံ URL `https://api.doitong.com/v1` ဖြစ်သည်။ ခေါ်ဆိုမှုတိုင်းတွင် `Authorization: Bearer <your key>` ကို ပေးပို့ရပြီး တူညီသောကီးသည် HTTP
> API နှင့် MCP server နှစ်ခုလုံးတွင် အလုပ်လုပ်သည်။

## 1. API ကီး ရယူခြင်း

[https://doitong.com/developers/dashboard#keys](https://doitong.com/developers/dashboard#keys) တွင် ကီးတစ်ခုဖန်တီးပြီး environment variable တစ်ခုထဲတွင် သိမ်းထားပါ — ၎င်းကို တစ်ကြိမ်သာ ပြသသည်။ ကီးတစ်ခုစီတွင် ကိုယ်ပိုင်ဘတ်ဂျက် ထည့်သတ်မှတ်နိုင်သောကြောင့် အကောင့်တစ်ခုလုံးကို အန္တရာယ်မဖြစ်စေဘဲ အေးဂျင့်တစ်ခုထံ ပေးနိုင်သည်။ `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 ခရက်ဒစ်များဖြင့် ပေးချေသည် — ၁,၀၀၀ API ခရက်ဒစ် = ၁ $ ဖြစ်ပြီး မော်ဒယ်တိုင်း၏ ကုန်ကျစရိတ်မှာ ထုတ်လုပ်သူသတ်မှတ်ထားသော ဈေးနှုန်းအတိုင်း အတိအကျ ဖြစ်သည်။ [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"
}
```

ထို့နောက် တူညီသော body ကို `POST /run/{model_id}` သို့ ပေးပို့ပါ။ ချိတ်ဆက်မှုကို 20 စက္ကန့်အထိ ထိန်းထားရန် `?wait=20` ကို ထည့်ပါ — မြန်ဆန်သော မော်ဒယ်သည် ပြီးစီးသည့် ရလဒ်ကို အသွားအပြန်တစ်ကြိမ်တည်းဖြင့် ပြန်ပေးသည်။ ထပ်မံကြိုးစားသည့်အခါ နှစ်ကြိမ် လုပ်ဆောင်ခြင်း (သို့မဟုတ် နှစ်ကြိမ် ကောက်ခံခြင်း) မဖြစ်စေရန် `Idempotency-Key` header ကို ပေးပို့ပါ။

```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. အခြေအနေကို စောင့်ကြည့်ခြင်း

စောင့်ဆိုင်းချိန်ကုန်ဆုံးချိန်တွင် မော်ဒယ်က ဆက်လက်လုပ်ဆောင်နေပါက တောင်းဆိုချက်၏ `id` နှင့် လက်ရှိ `status` ပါသော `202 Accepted` ကို ရရှိမည်။ တောင်းဆိုချက်တိုင်းသည် တူညီသော လုပ်ဆောင်မှုအဆင့်များကို ဖြတ်သန်းသည်-

တောင်းဆိုချက် လုပ်ဆောင်မှုအဆင့်များ: `queued` → `running` → `succeeded` | `failed` | `canceled` (final; failed နှင့် canceled များကို ငွေပြန်အမ်းသည်).

၎င်း၏ id ဖြင့် တောင်းဆိုချက်ကို ထပ်မံဖတ်ပါ။ ဤနေရာတွင်လည်း `?wait=20` အလုပ်လုပ်သောကြောင့် ရိုးရှင်းသော loop တစ်ခုဖြင့် လုံလောက်သည်-

```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"
```

ကြာမြင့်သော ဗီဒီယိုလုပ်ဆောင်မှုများအတွက် polling ကို ကျော်ပြီး `webhook_url` ကို ပေးနိုင်သည် ([Webhooks](https://doitong.com/developers/docs/webhooks) ကို ကြည့်ပါ)။

## 4. ဖိုင်များ

မည်သည့် အများမြင် URL ကိုမဆို ထည့်သွင်းချက်အဖြစ် ပေးနိုင်သည်၊ သို့မဟုတ် upload URL တစ်ခုရရန် `POST /files` ကို တောင်းဆိုပြီး ထိုနေရာတွင် ဖိုင်ကို `PUT` လုပ်ကာ ပြန်ရလာသော `file_url` ကို အသုံးပြုနိုင်သည် ([Files](https://doitong.com/developers/docs/files) ကို ကြည့်ပါ)။ အောင်မြင်သော တောင်းဆိုချက်တစ်ခုသည် ၎င်း၏ ရလဒ်များကို `outputs[]` တွင် type၊ content type နှင့် သိရှိပါက အတိုင်းအတာများ၊ ကြာချိန်တို့နှင့်အတူ စာရင်းပြုစုထားသည်။

```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]
> **ဖိုင်များကို အမြဲတမ်း သိမ်းထားမည်၊ သို့မဟုတ် ၇ ရက် အခမဲ့ သိမ်းထားမည် — သင့်ရွေးချယ်မှုပါ။** တောင်းဆိုချက်တစ်ခု အောင်မြင်မီ ထွက်ရလဒ်ဖိုင်များကို ကျွန်ုပ်တို့၏
> သိုလှောင်မှုထဲသို့ ကူးယူသည်။ မူလတန်ဖိုးအရ ၎င်းတို့ကို သင်ဖျက်သည်အထိ သိမ်းထားသည် (တစ်လလျှင် GB တစ်ခုစီအတွက် ၁၀၀ API ခရက်ဒစ်)။ Dashboard တွင် "ဖိုင်များကို အမြဲတမ်း သိမ်းဆည်းထားပါ" ကို ပိတ်ပါ၊ သို့မဟုတ်
> `?storage=temporary` ကို ပေးပို့ပါက ၇ ရက် အခမဲ့ သိမ်းထားမည် ([Files](https://doitong.com/developers/docs/files#storage) ကို ကြည့်ပါ)။

## အမှားများ

မော်ဒယ်တိုင်းသည် တူညီသောနည်းဖြင့် အမှားဖြစ်သည် — `type`၊ တိကျသော `code`၊ ပြဿနာဖြစ်စေသော `param` နှင့် ပြဿနာတိုင်းကို `details` ထဲတွင် ပါဝင်သော envelope တစ်ခုတည်းဖြင့် ဖြစ်သည်။ ထို့ကြောင့် အေးဂျင့်သည် စာပိုဒ်များကို ဖတ်စရာမလိုဘဲ တောင်းဆိုချက်ကို ပြင်ဆင်နိုင်သည်။ မမှန်ကန်သော တောင်းဆိုချက်အတွက် မည်သည့်ပမာဏမျှ ကောက်ခံမည်မဟုတ်ပါ။

```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"
  }
}
```

type နှင့် code အားလုံးကို [Errors](https://doitong.com/developers/docs/errors) တွင် စာရင်းပြုစုထားသည်။

## ဈေးနှုန်းများ

ဈေးနှုန်းများကို USD နှင့် API ခရက်ဒစ်များဖြင့် ဖော်ပြထားပြီး မလုပ်ဆောင်မီ မော်ဒယ်စာမျက်နှာတိုင်းတွင် ပြသထားသည်။ တောင်းဆိုချက်တိုင်းတွင် `credits`၊ `usd`၊ `charged` နှင့် `refunded` ပါသော `cost` ပါဝင်သည်။ တောင်းဆိုချက်ကို လက်ခံသည့်အခါ လုပ်ဆောင်မှုအတွက် ကောက်ခံပြီး `failed` နှင့် `canceled` တောင်းဆိုချက်များကို အလိုအလျောက် ငွေပြန်အမ်းပေးသည်။ အချို့မော်ဒယ်များ၏ ဈေးနှုန်းကို ထည့်သွင်းချက်မှ တိတိကျကျ တွက်ချက်သည်၊ အချို့မှာ သင်ပေးပို့သည့် ဖိုင်များ၏ အရှည် သို့မဟုတ် အရွယ်အစားအပေါ် မူတည်ပြီး ကောက်ခံသည်၊ အချို့မှာ *လုပ်ဆောင်မှုတစ်ကြိမ်အတွက် ခန့်မှန်းဈေးနှုန်း* ကို ကောက်ခံသည် — မည်သည့်နည်းဖြစ်စေ ဈေးနှုန်းခန့်မှန်းချက်သည် သင်ပေးချေရမည့်ပမာဏ ဖြစ်သည်။ မော်ဒယ်အနည်းငယ် (ဘာသာစကားနှင့် ရုပ်မြင်မော်ဒယ်များ၊ အသံ၊ လုပ်ဆောင်ချိန်ကိရိယာများ) သည် *အသုံးပြုမှုအပေါ် မူတည်၍ ကောက်ခံသည်* — ဈေးနှုန်းခန့်မှန်းချက်သည် လုပ်ဆောင်မှုအတွက် ကုန်ကျနိုင်သည့် အများဆုံးပမာဏဖြစ်ပြီး လုပ်ဆောင်မှုက အသုံးမပြုသည့်ပမာဏကို အလိုအလျောက် ငွေပြန်အမ်းပေးသည်။ [Pricing](https://doitong.com/developers/docs/pricing) ကို ကြည့်ပါ။

## MCP နှင့် AI အေးဂျင့်များ

MCP client မည်သည့်အမျိုးအစားကိုမဆို တူညီသော Bearer ကီးဖြင့် `https://api.doitong.com/v1/mcp` သို့ ချိတ်ဆက်ပါ။ သင့်အေးဂျင့်သည် ကတ်တလောက်ကို ရှာဖွေခြင်း၊ မော်ဒယ်များ၏ ဈေးနှုန်းခန့်မှန်းခြင်းနှင့် လုပ်ဆောင်ခြင်း၊ စာရွက်စာတမ်းစာမျက်နှာတိုင်းကို 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) ကို ကြည့်ရှုပါ။ စာမျက်နှာတိုင်းတွင် သင့်အတွက် code ရေးပေးသည့် တောင်းဆိုချက်တည်ဆောက်ကိရိယာ ပါရှိသည်။
- တောင်းဆိုချက်၏ လုပ်ဆောင်မှုအဆင့်များကို လေ့လာပါ — [Requests](https://doitong.com/developers/docs/requests)။
- မော်ဒယ်တိုင်းတွင် တူညီသော ပါရာမီတာအမည်များကို အသုံးပြုပါ — [Parameters](https://doitong.com/developers/docs/parameters)။
- AI coding အေးဂျင့်တစ်ခုဖြင့် အလုပ်လုပ်နေပါသလား။ ၎င်းထံ [https://doitong.com/developers/llms.txt](https://doitong.com/developers/llms.txt) ကို ပေးပါ၊ သို့မဟုတ် [MCP server](https://doitong.com/developers/docs/mcp) ကို ချိတ်ဆက်ပါ။
