Tasks
Queue a prompt on ChatGPT, Google AI Overviews, Google AI Mode and more, poll it or get a webhook, retry safely with an idempotency key, and list or cancel tasks.
A task is one engine run. POST /v1/tasks queues it and returns at once; you read the result later by polling or by webhook.
Create a task
POST /v1/tasks checks the request, holds the task price from your balance and answers 201 with the task in status QUEUED. Its URL is in the Location header.
curl
curl -X POST https://promptgale.com/v1/tasks \
-H "Authorization: Bearer $PROMPTGALE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: run-2026-11-21-001" \
-d '{
"taskType": "PERPLEXITY",
"payload": {
"prompt": "Which project management tools are best for agencies?",
"country": "US",
"brand": "Acme",
"competitors": ["Globex", "Initech"]
},
"webhookUrl": "https://example.com/hooks/promptgale"
}'Python
import os
import requests
res = requests.post(
"https://promptgale.com/v1/tasks",
headers={
"Authorization": f"Bearer {os.environ['PROMPTGALE_API_KEY']}",
"Idempotency-Key": "run-2026-11-21-001",
},
json={
"taskType": "PERPLEXITY",
"payload": {
"prompt": "Which project management tools are best for agencies?",
"country": "US",
"brand": "Acme",
"competitors": ["Globex", "Initech"],
},
},
)
task_id = res.json()["data"]["id"]Response, 201
{
"success": true,
"data": {
"id": "tsk_8Jx0c2...",
"taskType": "PERPLEXITY",
"status": "QUEUED",
"country": "US",
"credits": 1,
"result": null,
"error": null,
"createdAt": "2026-11-21T12:00:00.000Z"
}
}The body fields are in Request fields.
Task status
| Status | Meaning |
|---|---|
QUEUED | Accepted, waiting for a free slot. Credits are held. |
PROCESSING | A browser is asking the engine. |
COMPLETED | Done. result is set and the credits are charged. |
FAILED | Did not finish. error is set and the credits are refunded in full. |
Temporary engine errors are retried automatically before a task fails.
On the task, credits is its price and creditsCharged is what it cost in the end: the same number once
COMPLETED, 0 once FAILED, null until then. durationMs is the engine time of the last attempt; a task
that was retried took longer end to end, so use completedAt minus startedAt for the wall time.
Read a task
Poll GET /v1/tasks/{id} until the status is COMPLETED or FAILED. Every two seconds is enough.
curl
curl https://promptgale.com/v1/tasks/tsk_8Jx0c2... \
-H "Authorization: Bearer $PROMPTGALE_API_KEY"Python
import os
import time
import requests
API = "https://promptgale.com"
HEADERS = {"Authorization": f"Bearer {os.environ['PROMPTGALE_API_KEY']}"}
def wait_for(task_id):
while True:
task = requests.get(f"{API}/v1/tasks/{task_id}", headers=HEADERS).json()["data"]
if task["status"] in ("COMPLETED", "FAILED"):
return task
time.sleep(2)Node.js
const API = 'https://promptgale.com';
const headers = { Authorization: `Bearer ${process.env.PROMPTGALE_API_KEY}` };
async function waitFor(id) {
for (;;) {
const res = await fetch(`${API}/v1/tasks/${id}`, { headers });
const { data } = await res.json();
if (data.status === 'COMPLETED' || data.status === 'FAILED') return data;
await new Promise((r) => setTimeout(r, 2000));
}
}To be called instead of polling, pass webhookUrl: see Webhooks. To wait inside one request, use Sync tasks.
Retry safely with an idempotency key
Send the same Idempotency-Key header (or idempotencyKey field, up to 256 characters) when you retry a submit.
- Same key, same body: the original task is returned with
200andIdempotent-Replayed: true. Nothing runs twice. - Same key, different body (engine, payload, priority or webhookUrl):
409RESOURCE_ALREADY_EXISTSwithdetails.reasonidempotency_mismatch.
Keys are kept at least 30 days. The same rule holds on every create endpoint.
Create up to 500 tasks at once
POST /v1/tasks/bulk takes { "tasks": [...] }. The tasks are accepted or rejected as a whole, and every invalid item is listed in error.details.items. A request-level idempotency key gives items without their own key <key>:<index>.
curl -X POST https://promptgale.com/v1/tasks/bulk \
-H "Authorization: Bearer $PROMPTGALE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"tasks":[
{"taskType":"CHATGPT","payload":{"prompt":"best crm","country":"US"}},
{"taskType":"GEMINI","payload":{"prompt":"best crm","country":"US"}}
]}'For more than 500, use Batches.
List, cancel and inspect
| Action | Request |
|---|---|
| List tasks, newest first | GET /v1/tasks?limit=50&engine=CHATGPT&status=completed&createdAfter=2026-11-01 |
| Cancel a queued task | DELETE /v1/tasks/{id} |
| Read a task's timeline | GET /v1/tasks/{id}/events |
| Read your balance | GET /v1/credits |
| Read daily usage | GET /v1/usage?from=2026-11-01&to=2026-11-30 |
- Lists answer
{ items, nextCursor, hasMore }. PassnextCursorascursorto get the next page.include=resultadds the results. - Cancelling releases the held credits. Once a task runs it cannot be cancelled:
409INVALID_STATE.
Last updated