Skip to content

Commit

Permalink
Remove mention of returning data URLs from sync API (#330)
Browse files Browse the repository at this point in the history
This change has now been reverted while we figure out how to provide a more consistent implementation.
  • Loading branch information
aron authored Oct 30, 2024
1 parent 6a338aa commit 5a98ca7
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ console.log(output.blob()); // Blob
> of `ReadableStream` that returns the file contents. It has a `.blob()` method for accessing a
> `Blob` representation and a `.url()` method that will return the underlying data-source.
>
> **This data source can be either a remote URL or a data-uri with base64 encoded data. Check
> out the documentation on [creating a prediction](https://replicate.com/docs/topics/predictions/create-a-prediction)
> for more information.**
> We recommend accessing file data directly either as readable stream or via `.blob()` as the
> `.url()` property may not always return a HTTP URL in future.
You can also run a model in the background:

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

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

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.
Expand Down Expand Up @@ -1238,7 +1224,7 @@ const [output] = await replicate.run("black-forest-labs/flux-schnell", {
input: { prompt: "astronaut riding a rocket like a horse" }
});

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

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

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

## Troubleshooting

Expand Down

0 comments on commit 5a98ca7

Please sign in to comment.