Webhooks are in development. Until then, use polling via GET /api/v2/generate/{id}.
Current Approach: Polling
While webhooks are being built, poll the Generation Status endpoint:
import requests, time
def wait_for_result(gen_id: int, api_key: str, interval: int = 5) -> dict:
headers = {"Authorization": f"Bearer {api_key}"}
while True:
res = requests.get(
f"https://neuralbox.top/api/v2/generate/{gen_id}",
headers=headers
).json()
if res["status"] in ("completed", "failed"):
return res
time.sleep(interval)
async function waitForResult(genId, apiKey, intervalMs = 5000) {
while (true) {
const res = await fetch(`https://neuralbox.top/api/v2/generate/${genId}`, {
headers: { Authorization: `Bearer ${apiKey}` }
}).then(r => r.json());
if (res.status === "completed" || res.status === "failed") return res;
await new Promise(r => setTimeout(r, intervalMs));
}
}
When webhooks ship, you will register a URL and receive POST callbacks on generation events:
{
"event": "generation.completed",
"generation_id": 18502,
"status": "completed",
"model_slug": "luma-ray2",
"result_url": "https://storage.neuralbox.top/generations/18502.mp4",
"tokens_spent": 125
}
When webhooks go live, we will announce in @neuralbox_news.