Skip to content

Batches

Track thousands of prompts across engines and countries in one call, follow progress and credits, and read each answer as soon as it finishes.

View as Markdown

A batch queues up to 10,000 tasks in one call. Use it to ask many prompts on many engines and read the items as they finish.

Create a batch

POST /v1/batches takes a list of items. Each item is one task.

Shell
curl -X POST https://promptgale.com/v1/batches \
  -H "Authorization: Bearer $PROMPTGALE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      { "customId": "q1-chatgpt", "taskType": "CHATGPT", "payload": { "prompt": "best crm", "country": "US" } },
      { "customId": "q1-gemini", "taskType": "GEMINI", "payload": { "prompt": "best crm", "country": "US" } }
    ],
    "webhookUrl": "https://example.com/hooks/promptgale",
    "idempotencyKey": "run-2026-11-21"
  }'
FieldTypeDescription
itemsarrayUp to 10,000. Each: customId?, taskType, payload, idempotencyKey?, webhookUrl?.
webhookUrlstringCalled once with batch.completed, and for each item without its own webhookUrl.
idempotencyKeystringThe same key and body within 30 days returns the first batch (200). A different body under the key is 409.
metadataobjectYour own data, returned with the batch.

Every item is checked first. One bad item refuses the whole batch and names the failing indexes.

How a batch runs

  • Items enter the queue as room frees up. Each account keeps at most twice its concurrency limit of batch tasks queued or running.
  • Accounts and batches take turns. Your single tasks go before queued batch tasks of the same priority.
  • Credits are held per item when it is queued. An item you cannot pay for at that moment ends rejected with INSUFFICIENT_CREDITS.

Follow a batch

ActionRequest
Counts, percent done, credits held and chargedGET /v1/batches/{id}
Read the items, with resultsGET /v1/batches/{id}/items?include=result
List your batchesGET /v1/batches?status=OPEN
Stop a batchPOST /v1/batches/{id}/cancel

Cancelling rejects the pending items and cancels the queued tasks, releasing their credits. Tasks that are already running finish.

When it ends

When every item has finished, webhookUrl receives {"event":"batch.completed","data":<batch>}. It is signed like a task webhook, over ${batchId}.${timestamp}.${rawBody}. See Webhooks.

Last updated