You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: UPGRADING.md
+20-18Lines changed: 20 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,14 @@
2
2
3
3
This guide helps you migrate from the v1 Replicate Python SDK to v2. The v2 SDK is a complete rewrite generated from Replicate's OpenAPI specification, providing better type safety, more consistent error handling, and improved async support.
4
4
5
+
This doc is intended for both humans and agents.
6
+
7
+
If you're using an AI tool to assist with the upgrade process, you can provide it with this entire document as context.
8
+
5
9
## Installation
6
10
11
+
Use pip to install the latest pre-release version of the SDK:
12
+
7
13
```sh
8
14
pip install --pre replicate
9
15
```
@@ -12,7 +18,7 @@ The v2 SDK requires Python 3.8 or higher, same as v1.
12
18
13
19
## Pinning to 1.x
14
20
15
-
You are not required to upgrade to the new 2.x version. If you're already using the 1.x version and want to continue using it, pin the version number in your dependency file.
21
+
You are not required to upgrade to the new 2.x version. If you're already using the 1.x version and want to continue using it, pin the version number in your dependency files.
16
22
17
23
Here's an example `requirements.txt`:
18
24
@@ -39,38 +45,34 @@ dependencies = [
39
45
40
46
## Client initialization and authentication
41
47
42
-
The client class name and parameter names have changed.
48
+
In both the v1 and v2 SDKs, the simplest usage pattern is to import the `replicate` module and use the module-level functions like `replicate.run()`, which automatically uses the `REPLICATE_API_TOKEN` environment variable, without explicitly instantiating a client:
49
+
50
+
```python
51
+
import replicate
52
+
53
+
output = replicate.run(...)
54
+
```
55
+
56
+
For cases where you need to instantiate a client (e.g., for custom configuration or async support), the client class name and parameter names have changed in v2:
0 commit comments