DrawNew.comPOST /api/v1/generate · GET /api/v1/tasks
Endpoint pubblici per integrazioni batch e agent. Autenticati con la chiave API già assegnata al tuo account — non è necessario un token separato.
Includi la tua chiave API nell'intestazione Authorization. La chiave è la stessa assegnata al tuo account in user_keys (fornita da DrawNew dopo l'attivazione del tuo piano). Una chiave errata restituisce 401.
Authorization: Bearer <your_api_key>{ "error": { "type": "invalid_api_key", "message": "Invalid API key" } }/api/v1/generateInvia il task al fornitore di immagini a monte e restituisce immediatamente i task_ids. Per ottenere l'immagine risultante puoi (A) interrogare direttamente GET /v1/tasks/:id, oppure (B) aprire semplicemente il sito web — la stessa scheda Creazione immagini dell'account recupererà automaticamente il task e persisterà i risultati in "Le mie opere".
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"
}| Campo | Tipo | Obbligatorio | Predefinito | Descrizione |
|---|---|---|---|---|
| prompt | string | ✓ | — | Prompt di generazione |
| model | string | gpt-image-2 | ID del modello (vedi sotto) | |
| mode | text | edit | fusion | text | text=testo in immagine; edit=modifica immagine singola; fusion=fusione multi-immagine | |
| aspect | string | 1:1 | Rapporto: 1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 21:9, … | |
| imageSize | 1K | 2K | 4K | 2K | Risoluzione di output | |
| count | number | 1 | Numero di immagini (limitato per modello) | |
| imageUrls | string[] | [] | URL di immagini di riferimento per edit / fusion |
| model | Nome | Modalità supportate |
|---|---|---|
| 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 | Quando |
|---|---|---|
| 400 | invalid_request | Il body non è JSON, il prompt è vuoto, modello sconosciuto o il modello non supporta la modalità |
| 401 | unauthorized | Intestazione Authorization mancante o formato errato |
| 401 | invalid_api_key | Chiave API non trovata in user_keys |
| 403 | no_credits | Quota mensile esaurita. Aggiorna il tuo piano su https://drawnew.com/pricing |
/api/v1/tasks/{task_id}Restituisce lo stato del task a monte. status è uno tra queued / in_progress / completed / failed. completed aggiunge un campo imageUrl; failed aggiunge un campo 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,t2Interroga più task in una chiamata per risparmiare round-trip e ricerche di autenticazione. I risultati vengono restituiti nello stesso ordine degli id in input. Massimo 20 id per richiesta.
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 | Quando |
|---|---|---|
| 400 | invalid_request | Parametro ids mancante, o più di 20 id |
| 401 | unauthorized | Intestazione Authorization mancante o formato errato |
| 401 | invalid_api_key | Chiave API non trovata in user_keys |
/api/v1/uploadIl server recupera un'immagine da un URL pubblico e la riospita sul CDN a monte, restituendo un URL stabile. Passa il risultato a generate_image's imageUrls. Massimo 25 MB per immagine; png / jpeg / webp / gif / bmp accettati.
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=20Restituisce le generazioni passate attribuite a questa chiave API, le più recenti per prime. Paginazione tramite page (indicizzata da 1) e limit (massimo 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/statusRestituisce l'e-mail, il livello (trial / starter / standard / pro) e se la chiave a monte è configurata. Utile per gli agent per decidere se possono permettersi un modello ad alto costo.
curl https://www.drawnew.com/api/v1/user/status \
-H "Authorization: Bearer <your_api_key>"{
"email": "you@example.com",
"tier": "pro",
"has_key": true
}Per gli agent LLM, il modo più semplice di utilizzare DrawNew è tramite il server MCP ufficiale pubblicato come @drawnew/mcp-server su npm espone 6 strumenti (generate_image, get_task, batch_get_tasks, upload_reference_image, list_my_generations, get_account_status) tramite stdio e funziona con qualsiasi client compatibile con MCP. Aggiungi lo snippet qui sotto alla configurazione MCP del tuo client — ecco fatto.
Percorso: ~/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>"
}
}
}
}