Synchronous Mode

Sync Mode (enable_sync_mode)

This document describes the behavior, limitations, and best practices for using synchronous mode in API requests.

Parameter Definition

FieldTypeRequiredDefaultDescription
enable_sync_modebooleanNofalseIf set to true, the request waits until the result is generated and uploaded before returning the response. This allows you to receive outputs directly in the response. This option is only available via the API.

How It Works

When enable_sync_mode = true:

  • The API blocks the request until the task is completed
  • The response directly includes output URLs or results
  • No additional polling is required

When enable_sync_mode = false (default):

  • The API returns immediately with a task ID
  • Results must be retrieved via polling or callback

Limitations

Inference times can fluctuate significantly depending on model, queue depth, and upstream compute availability.

As a result:

  • Synchronous requests may exceed gateway time limits
  • This can lead to 504 Gateway Timeout errors
  • The task may still be successfully completed on the server
  • Outputs (e.g., images) may still be generated and stored

⚠️ In such cases, the client may not receive the result in the sync response, even though it exists. Retrieve it via GET /api/v3/predictions/:id using the prediction ID.


Common Issue: Timeout in Sync Mode

Example Scenario

HTTP 504 Gateway Timeout
© 2025 WaveSpeedAI. All rights reserved.