Replicate provider hard‑codes Prefer: wait (60s cap) and fails on long predictions
Description
The Replicate provider passes prefer: 'wait' to all image generations
https://github.com/vercel/ai/blob/fad04b2e4ad6f927daebb5e7e342f0a98d35c3cd/packages/replicate/src/replicate-image-model.ts#L67-L69
According to Replicate's docs here: https://replicate.com/docs/reference/http/#predictions.create
The request will wait up to 60 seconds for the model to run. If this time is exceeded the prediction will be returned in a "starting" state and need to be retrieved using the predictions.get endpoint.
And on the docs under create a prediction: https://replicate.com/docs/topics/predictions/create-a-prediction#timeout-duration
The default duration for sync mode is 60 seconds, but you can specify a different timeout duration in the header if needed. For example, Prefer: wait=5 will wait for 5 seconds.
If the model doesn’t finish within the specified duration, the request will return the incomplete prediction object with status set to starting or processing. You can then fetch the prediction again via the URL provided in the Location header, or the urls.get field as with Async mode.
So currently, any prediction that is longer than 60s just fails. This happens often with popular models like nano banana pro (in my own usage).
Suggestion: allow configuring the wait duration (e.g., Prefer: wait=n) or allow disabling sync wait entirely (no Prefer header). Alternative: detect non‑terminal prediction status and poll internally (or expose a helper to do so).
AI SDK Version
- ai: 5.0.102
- @ai-sdk/replicate version: 1.0.18
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Identify issue type
Identified as Bug
Confidence: High
Rationale
This describes a concrete failure in existing provider behavior for long-running image predictions. Although configuration and polling enhancements are suggested, they are proposed as fixes for the reported failure.
Evidence
- The Replicate image provider sends
Prefer: waitfor every image generation request. - Replicate limits synchronous waiting to 60 seconds by default and returns a non-terminal prediction when execution exceeds that limit.
- The provider reportedly fails instead of retrieving or polling predictions that remain in
startingorprocessingstatus, affecting models that commonly take longer than 60 seconds.