@@ -30,18 +30,37 @@ Welcome to the official Python library for Runpod API & SDK.
30
30
31
31
## 💻 | Installation
32
32
33
+ ### Install from PyPI (Stable Release)
34
+
33
35
``` bash
34
- # Install the latest release version
36
+ # Install with pip
35
37
pip install runpod
36
38
37
- # Using uv (faster alternative)
39
+ # Install with uv (faster alternative)
38
40
uv add runpod
41
+ ```
42
+
43
+ ### Install from GitHub (Latest Changes)
39
44
40
- # Install the latest development version (main branch)
45
+ To get the latest changes that haven't been released to PyPI yet:
46
+
47
+ ``` bash
48
+ # Install latest development version from main branch with pip
41
49
pip install git+https://github.com/runpod/runpod-python.git
42
50
43
- # Or with uv
51
+ # Install with uv
44
52
uv add git+https://github.com/runpod/runpod-python.git
53
+
54
+ # Install a specific branch
55
+ pip install git+https://github.com/runpod/runpod-python.git@branch-name
56
+
57
+ # Install a specific tag/release
58
+ pip install git+https://github.com/runpod/
[email protected]
59
+
60
+ # Install in editable mode for development
61
+ git clone https://github.com/runpod/runpod-python.git
62
+ cd runpod-python
63
+ pip install -e .
45
64
```
46
65
47
66
* Python 3.8 or higher is required to use the latest version of this package.*
@@ -101,6 +120,8 @@ runpod.api_key = "your_runpod_api_key_found_under_settings"
101
120
102
121
You can interact with Runpod endpoints via a ` run ` or ` run_sync ` method.
103
122
123
+ #### Basic Usage
124
+
104
125
``` python
105
126
endpoint = runpod.Endpoint(" ENDPOINT_ID" )
106
127
@@ -126,6 +147,99 @@ run_request = endpoint.run_sync(
126
147
print (run_request )
127
148
```
128
149
150
+ #### API Key Management
151
+
152
+ The SDK supports multiple ways to set API keys:
153
+
154
+ ** 1. Global API Key** (Default)
155
+ ``` python
156
+ import runpod
157
+
158
+ # Set global API key
159
+ runpod.api_key = " your_runpod_api_key"
160
+
161
+ # All endpoints will use this key by default
162
+ endpoint = runpod.Endpoint(" ENDPOINT_ID" )
163
+ result = endpoint.run_sync({" input" : " data" })
164
+ ```
165
+
166
+ ** 2. Endpoint-Specific API Key**
167
+ ``` python
168
+ # Create endpoint with its own API key
169
+ endpoint = runpod.Endpoint(" ENDPOINT_ID" , api_key = " specific_api_key" )
170
+
171
+ # This endpoint will always use the provided API key
172
+ result = endpoint.run_sync({" input" : " data" })
173
+ ```
174
+
175
+ ** 3. Per-Request API Key Override**
176
+ ``` python
177
+ # Override API key for a specific request
178
+ endpoint = runpod.Endpoint(" ENDPOINT_ID" ) # Uses global key
179
+ result = endpoint.run_sync({" input" : " data" }, api_key = " override_api_key" )
180
+ ```
181
+
182
+ #### API Key Precedence
183
+
184
+ The SDK uses this precedence order (highest to lowest):
185
+ 1 . Per-request API key (if provided to ` run() ` or ` run_sync() ` )
186
+ 2 . Endpoint instance API key (if provided to ` Endpoint() ` )
187
+ 3 . Global API key (set via ` runpod.api_key ` )
188
+
189
+ ``` python
190
+ import runpod
191
+
192
+ # Example showing precedence
193
+ runpod.api_key = " GLOBAL_KEY"
194
+
195
+ # This endpoint uses GLOBAL_KEY
196
+ endpoint1 = runpod.Endpoint(" ENDPOINT_ID" )
197
+
198
+ # This endpoint uses ENDPOINT_KEY (overrides global)
199
+ endpoint2 = runpod.Endpoint(" ENDPOINT_ID" , api_key = " ENDPOINT_KEY" )
200
+
201
+ # This request uses REQUEST_KEY (overrides endpoint key)
202
+ result = endpoint2.run_sync({" input" : " data" }, api_key = " REQUEST_KEY" )
203
+ ```
204
+
205
+ #### Conflict Prevention
206
+
207
+ To prevent accidental API key misuse, the SDK will raise an error if you try to mix different keys:
208
+
209
+ ``` python
210
+ # This will raise a ValueError
211
+ endpoint = runpod.Endpoint(" ENDPOINT_ID" , api_key = " KEY_A" )
212
+ result = endpoint.run_sync({" input" : " data" }, api_key = " KEY_B" ) # Error!
213
+
214
+ # This is fine - same key used
215
+ endpoint = runpod.Endpoint(" ENDPOINT_ID" , api_key = " KEY_A" )
216
+ result = endpoint.run_sync({" input" : " data" }, api_key = " KEY_A" ) # OK
217
+ ```
218
+
219
+ #### Thread-Safe Operations
220
+
221
+ Each ` Endpoint ` instance maintains its own API key, making concurrent operations safe:
222
+
223
+ ``` python
224
+ import threading
225
+ import runpod
226
+
227
+ def process_request (api_key , endpoint_id , input_data ):
228
+ # Each thread gets its own Endpoint instance
229
+ endpoint = runpod.Endpoint(endpoint_id, api_key = api_key)
230
+ return endpoint.run_sync(input_data)
231
+
232
+ # Safe concurrent usage with different API keys
233
+ threads = []
234
+ for customer in customers:
235
+ t = threading.Thread(
236
+ target = process_request,
237
+ args = (customer[" api_key" ], customer[" endpoint_id" ], customer[" input" ])
238
+ )
239
+ threads.append(t)
240
+ t.start()
241
+ ```
242
+
129
243
### GPU Cloud (Pods)
130
244
131
245
``` python
0 commit comments