Webhooks & live status
Two ways to learn a prediction is done without polling GET /v1/predictions/{id} in a loop:
- Webhooks: pass a
webhookURL when you submit, and Turion POSTs a signed result to it when the prediction finishes. Failed deliveries are retried. - Live status stream: open an SSE connection and watch status changes as they happen.
Webhooks
Section titled “Webhooks”Create a signing secret
Section titled “Create a signing secret”Deliveries are signed with an account secret so your receiver can verify they came from Turion. Create one first:
turion webhook secret --rotate# whsec_…import turionclient = turion.Client()secret = client.rotate_webhook_secret() # whsec_… (client.webhook_secret() reads the current one)turion webhook secret without --rotate prints the current secret; rotating replaces it.
Submitting a webhook before a secret exists returns 400 no_webhook_secret.
Submit with a webhook
Section titled “Submit with a webhook”turion run acme/whisper -i audio=@meeting.wav --webhook https://your.app/turion-hookclient.run("acme/whisper", {"audio": "meeting.wav"}, webhook="https://your.app/turion-hook")The webhook must be an https URL on a public host; loopback and private addresses are rejected
with 400 invalid_webhook. The host is resolved when you submit, and a name that does not resolve
or resolves to a private address is refused the same way, with details.reason set to
dns_error or address_not_public. It is resolved again before every delivery attempt, and
Turion connects only to the public address it just checked.
Receive and verify
Section titled “Receive and verify”When the prediction reaches succeeded, failed, or canceled, Turion POSTs the full
prediction (the same shape as GET /v1/predictions/{id}) plus "event": "prediction.completed",
with these headers:
X-Turion-Event: prediction.completedX-Turion-Timestamp: 1751760000X-Turion-Signature: t=1751760000,v1=<hex hmac-sha256>The signature is HMAC-SHA256(secret, f"{timestamp}." + raw_body). Verify it before trusting the
delivery. The SDK has a helper:
import turion
@app.post("/turion-hook")def hook(request): if not turion.verify_webhook(secret, request.headers, request.body): return 400 payload = request.json() if payload["status"] == "succeeded": handle(payload["output"]) return 200verify_webhook recomputes the HMAC in constant time and rejects timestamps more than 5 minutes
off. A delivery can arrive more than once, so deduplicate on the prediction id.
Keep the secret where your other credentials live (an environment variable or a secret
manager), not in code. The whole whsec_… string is the HMAC key, used as it is.
Without the SDK: Node.js
Section titled “Without the SDK: Node.js”Any language can check the signature with its HMAC library. The check needs the body exactly as it arrived, so read it raw, before any JSON parser re-encodes it. With Express:
import crypto from "node:crypto";import express from "express";
const secret = process.env.TURION_WEBHOOK_SECRET; // whsec_…
function verifyTurion(rawBody, signature) { const parts = Object.fromEntries( (signature ?? "").split(",").map((item) => item.trim().split("=")), ); const ts = Number(parts.t); if (!parts.v1 || !Number.isInteger(ts)) return false; if (Math.abs(Date.now() / 1000 - ts) > 300) return false; // 5 minutes const expected = crypto .createHmac("sha256", secret) .update(`${ts}.`) .update(rawBody) .digest(); const given = Buffer.from(parts.v1, "hex"); if (given.length !== expected.length) return false; return crypto.timingSafeEqual(given, expected);}
const app = express();const rawJson = express.raw({ type: "application/json" });
app.post("/turion-hook", rawJson, (req, res) => { if (!verifyTurion(req.body, req.get("X-Turion-Signature"))) { return res.sendStatus(400); } const payload = JSON.parse(req.body); if (payload.status === "succeeded") handle(payload.output); res.sendStatus(200);});timingSafeEqual compares in constant time; the length check comes first because it throws on
buffers of different lengths.
Delivery and retries
Section titled “Delivery and retries”Delivery happens separately from the run and never delays it. A non-2xx response, a timeout
(10 seconds) or a connection error is retried after about 10s, 30s, 2m, 10m and 30m, six attempts
in all, after which the delivery is marked failed. Return a 2xx quickly to acknowledge.
Debug a delivery
Section titled “Debug a delivery”A webhook that never arrived is usually a delivery that was attempted and rejected. The delivery log shows what happened:
turion webhook deliveries --prediction <prediction-id># ID EVENT ATTEMPTS LAST STATUS NEXT ATTEMPT DELIVERED# 0192… prediction.completed 3 502 2026-09-09 12:40 —Each row is one prediction’s delivery: attempts so far, the HTTP status your endpoint last
returned (— if the request never completed), when the next attempt is due, and when it was
delivered. The JSON view’s last_error says why the last attempt failed: http <status> for an
answer outside 2xx, or timeout, connect_error, tls_error, protocol_error,
request_error, dns_error, address_not_public (the host resolved to a private address, so
nothing was sent) or no_webhook_secret (the account’s secret was removed).
| Option | Description |
|---|---|
--prediction | only deliveries for one prediction id |
--limit | rows per page (default 50, max 200) |
--cursor | next_cursor from a previous page |
--json | raw JSON, including url and last_error |
Once your endpoint is fixed, re-queue a delivery instead of re-running the model:
turion webhook retry 0192…# requeued 0192… attempts 3 next 2026-09-09 12:35A retry sends the delivery again now, with a fresh set of six attempts. A delivery your endpoint
already accepted answers 409 already_delivered instead of sending a duplicate; if you lost that
payload, read the prediction.
Both are also API calls,
GET /v1/webhooks/deliveries and
POST /v1/webhooks/deliveries/{id}/retry,
and SDK methods, client.webhooks.deliveries() and client.webhooks.retry(id).
Live status stream
Section titled “Live status stream”Watch a prediction move through its statuses over Server-Sent Events:
turion prediction stream <prediction-id># status=starting# status=processing# status=succeededfor event in client.predictions.stream(prediction_id): print(event["status"]) if event.get("output") is not None: print(event["output"])Over HTTP, GET /v1/predictions/{id}/stream returns text/event-stream. Each data: line is a
JSON status event, the final event carries output and error, and the stream ends with
data: [DONE]. A stream lasts at most 10 minutes; reconnect if you need longer. For the model’s
output as it is produced, see Stream a model’s output.
Queue position
Section titled “Queue position”While a prediction is starting, its queue_position (in the submit and GET responses) is the
number of predictions ahead of it in the same fleet; 0 means it is next. It is null once the
prediction is processing or finished.