DrawNew.comPOST /api/v1/generate · GET /api/v1/tasks
バッチおよびエージェント統合のための公開エンドポイント。アカウントにすでに発行されているAPIキーで認証します — 別途トークンは不要です。
AuthorizationヘッダーにAPIキーを含めてください。キーはuser_keysでアカウントに割り当てられた同じキーです(DrawNewがプランを有効化した後に提供)。不正なキーは401を返します。
Authorization: Bearer <your_api_key>{ "error": { "type": "invalid_api_key", "message": "Invalid API key" } }/api/v1/generateタスクを上流画像プロバイダーに送信し、即座にtask_idsを返します。生成された画像を取得するには、(A) 自分でGET /v1/tasks/:idをポーリングするか、(B) ウェブサイトを開くだけで、同じアカウントのImage Creationタブがタスクを自動取得し、「My Works」に結果を保存します。
curl -X POST https://www.drawnew.com/api/v1/generate \
-H "Authorization: Bearer <your_api_key>" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A serene Japanese garden in autumn",
"model": "flash",
"mode": "text",
"aspect": "16:9",
"imageSize": "2K",
"count": 1
}'{
"task_ids": ["task_abc123"],
"email": "you@example.com"
}| フィールド | 型 | 必須 | デフォルト | 説明 |
|---|---|---|---|---|
| prompt | string | ✓ | — | 生成プロンプト |
| model | string | gpt-image-2 | モデルid(下記参照) | |
| mode | text | edit | fusion | text | text=テキストから画像; edit=単一画像編集; fusion=複数画像ブレンド | |
| aspect | string | 1:1 | 比率: 1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 21:9, … | |
| imageSize | 1K | 2K | 4K | 2K | 出力解像度 | |
| count | number | 1 | 画像数(モデルごとに上限あり) | |
| imageUrls | string[] | [] | edit / fusion用の参照画像URL |
| model | 名前 | サポートされるモード |
|---|---|---|
| gpt-image-2 | GPT Image 2 | text, edit |
| pro | Nano Banana Pro | text, edit |
| flash2 | Nano Banana 2 | text, edit |
| flash | Nano Banana | text, edit |
| HTTP | error.type | 発生条件 |
|---|---|---|
| 400 | invalid_request | ボディがJSONでない、プロンプトが空、モデル不明、またはモデルがモードをサポートしていない |
| 401 | unauthorized | Authorizationヘッダーがないか、形式が間違っている |
| 401 | invalid_api_key | user_keysにAPIキーが見つからない |
| 403 | no_credits | 月間クォータを使い切りました。https://drawnew.com/pricing でプランをアップグレード |
/api/v1/tasks/{task_id}上流タスクのステータスを返します。statusはqueued / in_progress / completed / failedのいずれかです。completedにはimageUrlフィールドが追加されます。failedにはerrorフィールドが追加されます。
curl https://www.drawnew.com/api/v1/tasks/task_abc123 \
-H "Authorization: Bearer <your_api_key>"{
"task_id": "task_abc123",
"status": "completed",
"progress": 100,
"imageUrl": "https://files.example.com/generated/xxx.png"
}/api/v1/tasks?ids=t1,t2ラウンドトリップと認証ルックアップを節約するために1回の呼び出しで複数のタスクをポーリングします。結果は入力idsと同じ順序で返されます。リクエストごとに最大20件のids。
curl "https://www.drawnew.com/api/v1/tasks?ids=task_abc,task_def,task_ghi" \
-H "Authorization: Bearer <your_api_key>"{
"tasks": [
{ "task_id": "task_abc", "status": "completed", "progress": 100, "imageUrl": "https://..." },
{ "task_id": "task_def", "status": "in_progress", "progress": 60 },
{ "task_id": "task_ghi", "status": "failed", "progress": 0, "error": "model overloaded" }
]
}| HTTP | error.type | 発生条件 |
|---|---|---|
| 400 | invalid_request | idsパラメータがないか、20件以上のids |
| 401 | unauthorized | Authorizationヘッダーがないか、形式が間違っている |
| 401 | invalid_api_key | user_keysにAPIキーが見つからない |
/api/v1/uploadサーバーサイドでパブリックURLから画像を取得し、上流CDNで再ホスティングし、安定したURLを返します。generate_imageのimageUrlsに結果を渡してください。画像1枚あたり最大25MB。png / jpeg / webp / gif / bmp対応。
curl -X POST https://www.drawnew.com/api/v1/upload \
-H "Authorization: Bearer <your_api_key>" \
-H "Content-Type: application/json" \
-d '{"source_url": "https://example.com/cat.png"}'{
"url": "https://files.example.com/uploads/abc123.png",
"filename": "cat.png",
"content_type": "image/png",
"bytes": 524288
}/api/v1/history?page=1&limit=20このAPIキーに帰属する過去の生成を返します。最新が最初。page(1インデックス)とlimit(最大50)によるページネーション。
curl "https://www.drawnew.com/api/v1/history?page=1&limit=20" \
-H "Authorization: Bearer <your_api_key>"{
"items": [
{
"id": "tsk_img_xxx",
"prompt": "a cat in autumn",
"model": "flash",
"mode": "text",
"aspect": "16:9",
"imageSize": "2K",
"imageCount": 1,
"images": ["https://..."],
"refs": [],
"createdAt": 1777461252000
}
],
"total": 42,
"page": 1,
"limit": 20,
"total_pages": 3
}/api/v1/user/statusメール、ティア(trial / starter / standard / pro)、および上流キーが設定されているかどうかを返します。高コストモデルを使用できるかどうかを判断するエージェントに便利です。
curl https://www.drawnew.com/api/v1/user/status \
-H "Authorization: Bearer <your_api_key>"{
"email": "you@example.com",
"tier": "pro",
"has_key": true
}LLMエージェントにとって、DrawNewを使用する最も簡単な方法は、npmで@drawnew/mcp-serverとして公開されている公式MCPサーバーです。stdio経由で6つのツール(generate_image、get_task、batch_get_tasks、upload_reference_image、list_my_generations、get_account_status)を公開し、MCP対応クライアントと動作します。クライアントのMCP設定に以下のスニペットを追加するだけです。
パス: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) · %APPDATA%\Claude\claude_desktop_config.json (Windows)
{
"mcpServers": {
"drawnew": {
"command": "npx",
"args": ["-y", "@drawnew/mcp-server"],
"env": {
"DRAWNEW_API_KEY": "<your_api_key>"
}
}
}
}