Skip to content

Commit 5a98ca7

Browse files
authored
Remove mention of returning data URLs from sync API (#330)
This change has now been reverted while we figure out how to provide a more consistent implementation.
1 parent 6a338aa commit 5a98ca7

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

README.md

+4-18
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ console.log(output.blob()); // Blob
6969
> of `ReadableStream` that returns the file contents. It has a `.blob()` method for accessing a
7070
> `Blob` representation and a `.url()` method that will return the underlying data-source.
7171
>
72-
> **This data source can be either a remote URL or a data-uri with base64 encoded data. Check
73-
> out the documentation on [creating a prediction](https://replicate.com/docs/topics/predictions/create-a-prediction)
74-
> for more information.**
72+
> We recommend accessing file data directly either as readable stream or via `.blob()` as the
73+
> `.url()` property may not always return a HTTP URL in future.
7574
7675
You can also run a model in the background:
7776

@@ -388,19 +387,6 @@ which is optimized for low latency requests to file models like `black-forest-la
388387
`black-forest-labs/flux-schnell`. When creating a prediction this will hold a connection open to the
389388
server and return a `FileObject` containing the generated file as quickly as possible.
390389

391-
> [!NOTE]
392-
> In this mode the `url()` method on the `FileObject` may refer to either a remote URL or
393-
> base64 encoded data-uri. The latter is an optimization we make on certain models to deliver
394-
> the files faster to the client.
395-
>
396-
> If you need the prediction URLs for whatever reason you can opt out of the sync mode by
397-
> passing `wait: { "type": "poll" }` to the `run()` method.
398-
>
399-
> ```js
400-
> const output = await replicate.run(model, { input, wait: { type: "poll" } });
401-
> output.url() // URL<https://...>
402-
> ```
403-
404390
### `replicate.stream`
405391

406392
Run a model and stream its output. Unlike [`replicate.prediction.create`](#replicatepredictionscreate), this method returns only the prediction output rather than the entire prediction object.
@@ -1238,7 +1224,7 @@ const [output] = await replicate.run("black-forest-labs/flux-schnell", {
12381224
input: { prompt: "astronaut riding a rocket like a horse" }
12391225
});
12401226

1241-
// To access the file URL (or data-uri):
1227+
// To access the file URL:
12421228
console.log(output.url()); //=> "http://example.com"
12431229

12441230
// To write the file to disk:
@@ -1261,8 +1247,8 @@ const replicate = new Replicate({ useFileOutput: false });
12611247

12621248
| method | returns | description |
12631249
| -------------------- | ------ | ------------------------------------------------------------ |
1264-
| `url()` | string | A `URL` object representing the HTTP URL or data-uri |
12651250
| `blob()` | object | A `Blob` instance containing the binary file |
1251+
| `url()` | string | A `URL` object pointing to the underlying data source. Please note that this may not always be an HTTP URL in future. |
12661252

12671253
## Troubleshooting
12681254

0 commit comments

Comments
 (0)