Skip to content

fix(replicate): poll for completion when image sync-wait times out - #16282

Open
arinsoni wants to merge 1 commit into
vercel:mainfrom
arinsoni:arinsoni/fix-replicate-image-model-polling
Open

fix(replicate): poll for completion when image sync-wait times out#16282
arinsoni wants to merge 1 commit into
vercel:mainfrom
arinsoni:arinsoni/fix-replicate-image-model-polling

Conversation

@arinsoni

Copy link
Copy Markdown

Closes #16276


When the Replicate provider's sync-wait window expires before an image generation job completes, the SDK returned an incomplete result instead of falling back to polling the prediction URL for the final output.

The fix adds a polling loop that kicks in when the sync response indicates the prediction is still in progress, retrying until the job reaches a terminal state (succeeded or failed).

This contribution was made with AI-agent assistance (Claude Code).

When Replicate's sync-wait returns status:starting or status:processing
(cold start / inference exceeds the wait window), the image model now
polls urls.get until the prediction completes — matching the existing
behavior of the video model.

Added pollIntervalMs (default 2s) and pollTimeoutMs (default 5min) to
the image provider options to control polling behavior.

Fixes vercel#16276
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ai-sdk/replicate image model fails when sync-wait returns status:starting with output:null

1 participant