クイックスタート
数分で最初の生成を実行できます。1,496個のモデルはすべて同じ種類のリクエストを受け取り、画像、動画、音声について同じリクエストオブジェクトを返します。一度ここで学べば十分です。
1. APIキーを取得する
https://doitong.com/developers/dashboard#keys でキーを作成し、環境変数に保存してください。キーは一度しか表示されません。各キーには独自の予算を設定できるため、アカウント全体を危険にさらすことなくエージェントに渡せます。GET /account は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())
実行料金はアカウントの API残高 からAPIクレジットで支払われます:1,000 APIクレジット = $1。各モデルの料金は提供元の価格と正確に同じです。https://doitong.com/developers/dashboard#balance でチャージできます。
2. 見積もりを取得してから実行する
POST /quote/{model_id} は入力JSONを受け取り、正確な価格を返します。キーは不要で、料金もかかりません。同じ入力を実行すると、料金はその見積もりと正確に同じになります。見積もりがそのまま請求額です。(使用状況に応じて課金されるモデルは例外です。この場合、見積もりは実行にかかる可能性がある最大額で、未使用分は実行後に返金されます。)
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"
}
続いて、同じ本文を POST /run/{model_id} に送信します。接続を最大20秒保持するには ?wait=20 を追加します。高速なモデルなら、1回の往復で完了した結果が返ります。Idempotency-Key ヘッダーを送信すると、再試行によって実行や課金が二重になることを防げます。
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)
レスポンスはリクエストオブジェクトです。
{
"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見積料金を引き落としました。outputs[]に当社ストレージ上のURLが格納されていますfailed自動的に返金されます。エラーに理由が示されますcanceled結果が出る前に停止しました。返金済みです
idを使ってリクエストを再度読み取ります。ここでも ?wait=20 が使えるため、単純なループで十分です。
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)
status が succeeded の場合、outputs[].url にストレージ上のファイルへのリンクが入ります。リクエストが failed または canceled になった場合、APIクレジットは自動的に返金され、error に理由が示されます。まだ queued または running のものはキャンセルできます。
curl -X POST "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel" \
-H "Authorization: Bearer $DOITONG_API_KEY"
長時間かかる動画ジョブでは、ポーリングを省略して webhook_url を渡せます(Webhooks を参照)。
4. ファイル
入力として公開URLを渡すか、POST /files にアップロードURLを要求し、そのURLに PUT でファイルを送信して、返された file_url を使用します(ファイル を参照)。成功したリクエストの結果は outputs[] に一覧表示され、タイプ、コンテンツタイプ、判明している場合はサイズと長さが含まれます。
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}'
エラー
すべてのモデルは同じ形式で失敗します。type、正確な code、問題のある param、すべての問題を含む details を1つのエンベロープで返すため、エージェントは説明文を読まなくてもリクエストを修正できます。無効なリクエストには課金されません。
{
"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"
}
}
すべてのタイプとコードはエラーに一覧表示されています。
料金
料金はUSDとAPIクレジットで表示され、実行前にすべてのモデルページで確認できます。各リクエストには cost が含まれ、credits、usd、charged、refunded が入ります。実行は受け付けられた時点で課金され、failed と canceled のリクエストは自動的に返金されます。入力から正確に料金が決まるモデル、送信するファイルの長さやサイズで決まるモデル、実行ごとの推定料金 が課金されるモデルがありますが、いずれの場合も支払う金額は見積もりどおりです。一部のモデル(言語モデル、ビジョンモデル、音声、処理時間を使用するツール)は 使用状況に応じて課金 されます。この場合、見積もりは実行にかかる可能性がある最大額で、実際に使用されなかった分は自動的に返金されます。料金を参照してください。
MCPとAIエージェント
同じBearerキーを使って、任意のMCPクライアントを https://api.doitong.com/v1/mcp に接続できます。エージェントはカタログの検索、モデルの見積もりと実行、すべてのドキュメントページのMarkdownでの読み取りを行えます。
claude mcp add --transport http doitong-models https://api.doitong.com/v1/mcp \
--header "Authorization: Bearer YOUR_API_KEY"
次のステップ
- すべてのモデルを確認します。各ページには、コードを自動生成するリクエストビルダーがあります。
- リクエストのライフサイクルを学びます:リクエスト。
- すべてのモデルで同じパラメータ名を使用します:パラメータ。
- AIコーディングエージェントを使用していますか?https://doitong.com/developers/llms.txtを渡すか、MCPサーバーに接続してください。