Skip to content

Async Mode

Async mode returns a task ID immediately. You then poll for the result when it's ready. This is the default behavior when calling the API without any query parameters.

Prerequisites

Make sure you have an API key. See Get Started with API for setup instructions.

Step 1: Submit a Task

Send a POST request to start a generation task:

bash
curl -X POST "https://api.get3w.com/v1/google/nano-banana-pro/text-to-image" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A sunset over mountains",
    "aspect_ratio": "16:9",
    "resolution": "1k",
    "output_format": "png",
    "channel": "stable"
  }'
python
import requests

response = requests.post(
    "https://api.get3w.com/v1/google/nano-banana-pro/text-to-image",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "A sunset over mountains",
        "aspect_ratio": "16:9",
        "resolution": "1k",
        "output_format": "png",
        "channel": "stable"
    }
)

task = response.json()
print(task["id"])  # Save this for polling
javascript
const apiKey = "YOUR_API_KEY";

const response = await fetch(
    "https://api.get3w.com/v1/google/nano-banana-pro/text-to-image",
    {
        method: "POST",
        headers: {
            "Authorization": `Bearer ${apiKey}`,
            "Content-Type": "application/json"
        },
        body: JSON.stringify({
            prompt: "A sunset over mountains",
            aspect_ratio: "16:9",
            resolution: "1k",
            output_format: "png",
            channel: "stable"
        })
    }
);

const task = await response.json();
console.log(task.id);  // Save this for polling

Response:

json
{
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "status": "created",
  "estimated_duration": 52
}

Save the id — you'll need it to retrieve your result.

Step 2: Poll for the Result

Use the task ID to check the status until it reaches a terminal state (completed or failed):

bash
curl "https://api.get3w.com/v1/requests/${request_id}" \
  -H "Authorization: Bearer YOUR_API_KEY"
python
import time
import requests

task_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"  # From Step 1 response

while True:
    response = requests.get(
        f"https://api.get3w.com/v1/requests/{task_id}",
        headers={"Authorization": "Bearer YOUR_API_KEY"}
    )
    data = response.json()

    if data["status"] == "completed":
        print("Done!", data["outputs"])
        break
    elif data["status"] == "failed":
        print("Failed:", data["error"])
        break

    time.sleep(3)
javascript
const apiKey = "YOUR_API_KEY";
const taskId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; // From Step 1

async function pollResult() {
    while (true) {
        const response = await fetch(
            `https://api.get3w.com/v1/requests/${taskId}`,
            { headers: { "Authorization": `Bearer ${apiKey}` } }
        );
        const data = await response.json();

        if (data.status === "completed") {
            console.log("Done!", data.outputs);
            return data;
        } else if (data.status === "failed") {
            console.error("Failed:", data.error);
            throw new Error(data.error);
        }

        await new Promise(r => setTimeout(r, 3000));
    }
}

pollResult();

Response (completed):

json
{
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "model": "google/nano-banana-pro/text-to-image",
  "status": "completed",
  "code": 0,
  "outputs": [
    "https://storage.example.com/output.png"
  ],
  "timings": {
    "queue_wait": 427,
    "celery_init": 2429,
    "api_call": 21392,
    "save": 1781,
    "run_overhead": 679,
    "total": 26709
  },
  "error": null,
  "created_at": "2026-03-28T07:51:34"
}

When to Use Async Mode

  • Long-running tasks — Video generation can take minutes; avoid blocking the connection
  • Batch processing — Submit many tasks at once, then collect results later
  • Resilient integrations — If your client disconnects, the task keeps running and the result stays available

Polling Tips

  • Use estimated_duration from the submit response to set an initial wait before the first poll
  • Poll every 3–5 seconds for most tasks
  • Use exponential backoff for tasks that take longer than expected

Next Steps

  • Sync Mode — Simpler approach for quick tasks
  • Webhook Mode — Receive results via callback instead of polling

Released under the MIT License.