Tīmatanga tere
Whakahaerehia tō whakaputanga tuatahi i roto i ētahi meneti. He momo tono ōrite te whakamahi a ngā tauira 1,496 katoa, ā, ka whakahoki i te ahanoa tono ōrite mō ngā atahanga, ataata me te ororongo: akona kotahi ki konei.
1. Tikina he kī API
Waihangahia he kī ki https://doitong.com/developers/dashboard#keys, ka puritia ki tētahi taurangi
ā-taiao: kotahi anake te wā ka whakaaturia. Ka taea e ia kī tōna ake pūtea, nō reira ka taea e koe te tuku ki tētahi āpiha
me te kore e mōrearea te pūkete katoa. Ka whakahokia e GET /account tō toenga API.
export DOITONG_API_KEY="doitong_..."
curl "https://api.doitong.com/v1/account" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const res = await fetch("https://api.doitong.com/v1/account", {
headers: { Authorization: `Bearer ${process.env.DOITONG_API_KEY}` },
});
console.log(await res.json());
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())
Ka utua ngā whakahaere mai i te toenga API o tō pūkete, i roto i ngā whiwhinga API: 1,000 whiwhinga API = $ 1, ā, ka rite tonu te utu o ia tauira ki te utu a tōna kaihanga. Tāpirihia he pūtea ki https://doitong.com/developers/dashboard#balance.
2. Tautuhia te utu, kātahi ka whakahaere
Ka tango a POST /quote/{model_id} i te JSON tāuru, ka whakahoki i te utu tika. Kāore he kī, kāore hoki he utu. Ko te whakahaere i taua tāuru anō ka utu tika i taua moni: ko te utu kua whakatauria te utu. (Ko te tauira e utu ana mā te whakamahinga te mea rerekē: ko tana utu kua whakatauria te mōrahi o te utu whakahaere, ā, ka whakahokia te wāhanga kāore i whakamahia i muri i te whakahaere.)
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}'
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"
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
{
"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"
}
Kātahi ka tuku i taua tinana anō ki POST /run/{model_id}. Tāpirihia ?wait=20 hei pupuri i te hononga mō te 20 hēkona: ka whakahoki te tauira tere i te putanga oti i roto i te huringa kotahi. Tukua he pane Idempotency-Key kia kore ai te ngana anō e whakahaere, e utu rānei, kia rua.
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"}'
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);
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)
He ahanoa tono te whakautu:
{
"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. Aroturukihia te tūnga
Mēnā kei te mahi tonu te tauira ina mutu te tatari, ka whiwhi koe i 202 Accepted me te id o te tono me tōna status o nāianei. Ka whai ia tono i te huringa ora ōrite:
-
queuedKua whakaaetia, kua utua, e tatari ana ki tētahi kaimahi -
runningE whakaputa ana te tauira -
Ngā tūnga whakamutunga:
succeededKua utua te utu kua whakahuahia; kei outputs[] ngā URL ki tō mātou pūmaharafailedKua whakahokia aunoatia; mā te hapa e whakamārama te takecanceledKua whakamutua i mua i te hua; kua whakahokia te utu
Pānuihia anō te tono mā tōna id. Ka mahi hoki ?wait=20 i konei, nō reira he koropiko māmā noa iho:
curl "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
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);
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)
Ina succeeded te status, kei outputs[].url ngā hononga ki ngā kōnae kei tō mātou rokiroki. Mēnā i failed, i canceled rānei te tono, ka whakahokia aunoa ngā whiwhinga API, ā, ka whakamārama a error i te take. Whakakorehia ngā mea kei queued, kei running rānei:
curl -X POST "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel" \
-H "Authorization: Bearer $DOITONG_API_KEY"
Mō ngā mahi ataata roa, ka taea te peke i te pōti me te tuku i webhook_url kē (tirohia Webhooks).
4. Kōnae
Tukua he URL tūmatanui hei tāuru, tonoa rānei he URL tukuake mā POST /files, ka PUT i te kōnae ki reira, ka whakamahi i te file_url kua whakahokia (tirohia Kōnae). Ka whakarārangi te tono kua succeeded i ōna putanga ki outputs[], me te momo, te momo ihirangi, ā, mēnā e mōhiotia ana, ngā rahinga me te roanga.
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}'
Hapa
He ōrite te ara hē o ia tauira: kotahi te pūhera me type, he code tika, te param i hapa, me ngā raruraru katoa i details, kia taea ai e tētahi āpiha te whakatika i te tono me te kore pānui i ngā kōrero. Kāore he utu mō tētahi tono muhu.
{
"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"
}
}
Ka whakarārangihia ia momo me ia waehere ki Hapa.
Utu
Kei roto ngā utu i te USD me ngā whiwhinga API, ā, ka whakaaturia ki ia whārangi tauira i mua i te whakahaere. Kei ia tono te cost me credits, usd, charged me refunded. Ka utua te whakahaere ina whakaaetia; ka whakahokia aunoa ngā tono failed me canceled. Ko ētahi tauira ka whakatauria tikatia te utu mai i te tāuru, ko ētahi mā te roa, mā te rahi rānei o ngā kōnae ka tukuna e koe, ā, ko ētahi ka utu i tētahi estimated price per run: ahakoa pēhea, ko te whakataunga utu te moni ka utua e koe. Ko ētahi tauira (ngā tauira reo me te tirohanga, te reo, ngā taputapu wā-tukatuka) charged by whakamahinga: ko te whakataunga utu te mōrahi, ā, ka whakahokia aunoa te wāhanga kāore i whakamahia. Tirohia Utu.
MCP me ngā āpiha AI
Honoa he kiritaki MCP ki https://api.doitong.com/v1/mcp me taua kī Bearer anō. Ka taea e tō āpiha te rapu i te rārangi, te whakataunga utu me te whakahaere tauira, me te pānui i ia whārangi tuhinga hei Markdown.
claude mcp add --transport http doitong-models https://api.doitong.com/v1/mcp \
--header "Authorization: Bearer YOUR_API_KEY"
Ngā mahi whai ake
- Tirotirohia ngā tauira katoa. Kei ia whārangi he kaihanga tono hei tuhi i te waehere māu.
- Akona te huringa ora o te tono: Ngā tono.
- Whakamahia ngā ingoa tawhā ōrite ki ia tauira: Ngā tawhā.
- Kei te mahi tahi me tētahi āpiha AI whakawaehere? Hoatu ki a ia https://doitong.com/developers/llms.txt, honoa rānei te tūmau MCP.