This PR introduces a new WithFileOutput() option for a new RunWithOptions method in the Go client SDK. This option abstracts away file outputs from Replicate models, making it easier to work with file outputs and allowing for future optimizations in file asset delivery.
The new option can be used as follows:
output, err := client.RunWithOptions(ctx, "black-forest-labs/flux-schnell", input, nil, WithFileOutput())
reader, ok := output.(io.ReadCloser)
if ok {
defer reader.Close()
// Read from the reader
data, err := io.ReadAll(reader)
// Or stream the data
_, err := io.Copy(destinationWriter, reader)
}
Nice! Looks great, I wonder if we should mirror the Python/JS clients and return an interface that extends ReadCloser with a URL field so we can make the URL available too.
This PR introduces a new
WithFileOutput()
option for a newRunWithOptions
method in the Go client SDK. This option abstracts away file outputs from Replicate models, making it easier to work with file outputs and allowing for future optimizations in file asset delivery.The new option can be used as follows: