DrawNew.comPOST /api/v1/generate · GET /api/v1/tasks
Mga pampublikong endpoint para sa batch at agent integration. Mag-authenticate gamit ang API key na inilabas na sa iyong account — hindi na kailangan ng hiwalay na token.
Isama ang iyong API key sa Authorization header. Ang key ay pareho sa itinalaga sa iyong account sa user_keys (ibinigay ng DrawNew pagkatapos ma-activate ang iyong plan). Ang maling key ay nagbabalik ng 401.
Authorization: Bearer <your_api_key>{ "error": { "type": "invalid_api_key", "message": "Invalid API key" } }/api/v1/generateInihaharap ang task sa upstream image provider at agad na nagbabalik ng mga task_id. Upang makuha ang resultang larawan maaari kang (A) mag-poll ng GET /v1/tasks/:id mismo, o (B) buksan lamang ang website — ang Image Creation tab ng parehong account ay awtomatikong kukuha ng task at itatabi ang mga resulta sa "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"
}| Field | Uri | Required | Default | Paglalarawan |
|---|---|---|---|---|
| prompt | string | ✓ | — | Generation prompt |
| model | string | gpt-image-2 | Model id (tingnan sa ibaba) | |
| mode | text | edit | fusion | text | text=text-to-image; edit=single-image edit; fusion=multi-image blend | |
| aspect | string | 1:1 | Ratio: 1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 21:9, … | |
| imageSize | 1K | 2K | 4K | 2K | Output resolution | |
| count | number | 1 | Bilang ng larawan (capped per model) | |
| imageUrls | string[] | [] | Mga reference image URL para sa edit / fusion |
| model | Pangalan | Mga suportadong mode |
|---|---|---|
| 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 | Kailan |
|---|---|---|
| 400 | invalid_request | Ang body ay hindi JSON, walang laman ang prompt, hindi kilala ang model, o hindi sinusuportahan ng model ang mode |
| 401 | unauthorized | Walang Authorization header o mali ang format |
| 401 | invalid_api_key | Hindi nahanap ang API key sa user_keys |
| 403 | no_credits | Naubos na ang buwanang quota. I-upgrade ang iyong plan sa https://drawnew.com/pricing |
/api/v1/tasks/{task_id}Nagbabalik ng status ng upstream task. Ang status ay isa sa queued / in_progress / completed / failed. Nagdadagdag ng imageUrl field ang completed; nagdadagdag ng error field ang failed.
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,t2Nagpo-poll ng maraming task sa isang tawag upang makatipid ng round-trip at authentication lookup. Ang mga resulta ay ibinabalik sa parehong pagkakasunod-sunod ng input na mga id. Hanggang 20 id bawat kahilingan.
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 | Kailan |
|---|---|---|
| 400 | invalid_request | Walang ids param, o mahigit sa 20 na id |
| 401 | unauthorized | Walang Authorization header o mali ang format |
| 401 | invalid_api_key | Hindi nahanap ang API key sa user_keys |
/api/v1/uploadSa server-side kumukuha ng larawan mula sa isang pampublikong URL at nagho-host muli sa upstream CDN, nagbabalik ng matatag na URL. Ipass ang resulta sa imageUrls ng generate_image. Hanggang 25 MB bawat larawan; tinatanggap ang 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=20Nagbabalik ng mga nakaraang paglikha na naka-attribute sa API key na ito, ang pinakabago muna. Paginasyon sa pamamagitan ng page (1-indexed) at limit (hanggang 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/statusNagbabalik ng email, tier (trial / starter / standard / pro), at kung ang upstream key ay naka-configure. Kapaki-pakinabang para sa mga agent upang magpasya kung kaya nila ang isang high-cost model.
curl https://www.drawnew.com/api/v1/user/status \
-H "Authorization: Bearer <your_api_key>"{
"email": "you@example.com",
"tier": "pro",
"has_key": true
}Para sa mga LLM agent, ang pinakamadaling paraan upang gamitin ang DrawNew ay sa pamamagitan ng opisyal na MCP server na inilathala bilang @drawnew/mcp-server sa npm. Inilalantad nito ang 6 na tool (generate_image, get_task, batch_get_tasks, upload_reference_image, list_my_generations, get_account_status) sa pamamagitan ng stdio at gumagana sa anumang MCP-compatible na client. Magdagdag ng snippet sa ibaba sa MCP config ng iyong client — iyon lang.
Path: ~/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>"
}
}
}
}