Skip to content

Sync mode

The normal flow is asynchronous: submit, then poll, stream or wait for a webhook. For a model that finishes in seconds, sync mode submits and holds the connection until the prediction finishes, so the answer comes back in one call:

Terminal window
turion run acme/whisper -i audio=@clip.wav --sync
out = client.run("acme/whisper", {"audio": "clip.wav"}, sync=True)
Terminal window
curl -X POST https://api.turion.ai/v1/run/acme/whisper \
-H "Authorization: Bearer tk_…" -H "Content-Type: application/json" \
-d '{"input": {"audio": "turion://uploads/…"}}'

Sync mode creates the same prediction as POST /v1/predictions, with the same id, queueing, placement, webhook and validation. Only the waiting is different.

The server holds the connection for a limited time. If the prediction is still running when that time is up, you get 202 Accepted with the prediction (id, status, queue_position and urls), and you continue the asynchronous way:

StatusMeaning
200finished: the body is the prediction (succeeded, failed or canceled)
202still running: poll urls.get, or subscribe to urls.stream or urls.output_stream

A 202 is not an error. The prediction is running; only your wait ended. A failed prediction comes back as 200 with status: "failed": the status code describes the wait, not the outcome.

The SDK handles this for you: client.run(..., sync=True) falls back to polling on a 202 and returns the output either way. turion run --sync does the same.

Terminal window
curl -X POST "https://api.turion.ai/v1/run/acme/whisper?wait_timeout=120" …
out = client.run("acme/whisper", {"audio": "clip.wav"}, sync=True, wait_timeout=120)

?wait_timeout= (seconds, --wait-timeout on the CLI) replaces the default 60-second hold, up to 300 seconds; a larger value is treated as 300. 0 still checks the status once, so a prediction that has already finished is returned as such rather than as a 202.

The SSE response (below) ignores wait_timeout and holds for up to 600 seconds, the stream limit.

The Python SDK sets its request timeout to your hold plus 15 seconds, so the client never gives up before the server answers.

If you disconnect while the server is holding, the prediction keeps running, and GET /v1/predictions/{id} still has it.

Send Accept: text/event-stream on the same request and, instead of one answer, you get the output stream on the submit call: chunk events, the final event, then data: [DONE]:

Terminal window
curl -N -X POST https://api.turion.ai/v1/run/acme/storyteller \
-H "Authorization: Bearer tk_…" -H "Accept: text/event-stream" \
-H "Content-Type: application/json" -d '{"input": {"prompt": "…"}}'

This is the same stream as GET /v1/predictions/{id}/output/stream; see Stream a model’s output for the event shapes and behaviour.

The Python SDK’s stream=True does not use this: it submits through POST /v1/predictions and then subscribes, so you always have a prediction id. sync=True and stream=True together raise bad_request.

The route is POST /v1/run/{owner}/{model}, so it needs a namespaced model like acme/whisper. Curated models published under a bare slug (such as whisper-blackwell) cannot be run in sync mode; use POST /v1/predictions (the default turion run and client.run() path), which accepts either form. The SDK raises TurionError("bad_ref", …) for a bare slug with sync=True before making any request.

  • Use sync mode for interactive models that finish in under a minute, where one call is simpler than a submit-and-poll loop.
  • Use the asynchronous path for long jobs, batches, and anything where you would rather not hold a connection: submit, then take the result by webhook or stream.

Holding a connection does not jump the queue. Sync-mode predictions wait in the same queue as everything else in their fleet, including any concurrency limit on the version.