How to Use Sync 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

Due to variability in Google’s underlying compute resources, inference times can fluctuate significantly.

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, even though it exists.


Common Issue: Timeout in Sync Mode

Example Scenario

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