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
docs(sdk/python): rewrite README for 0.5.4b1 API surface
Rebuild the README around the current capability set, matching the
recently-rewritten JS README (7536c6c). Highlights:
- Installation extras table (ethereum, solana, all + aliases).
- New surface coverage: attest, sign/verify, version, is_reachable,
emit_event, cloud_vendor/cloud_product on info, not_before/not_after/
with_app_info on get_tls_key (with version-gating note).
- KMS env-encrypt section walks through the signature_v1 timestamp flow
with a legacy fallback, replacing the stub-era guidance.
- Adds a Compatibility table tying each feature to its required dstack
OS version.
Reviewed for AI slop, passive voice, redundant phrases, and sentence
length per the doc-review/copy rule set.
client.version() # VersionResponse(version, rev) — raises on OS < 0.5.7
195
+
client.is_reachable() # Quick connectivity probe; never raises
196
+
```
168
197
169
198
## Async Client
170
199
171
-
For async applications, use `AsyncDstackClient`:
200
+
For async applications, use `AsyncDstackClient`. The API surface is identical, but every method is a coroutine:
172
201
173
202
```python
174
-
from dstack_sdk import AsyncDstackClient
175
203
import asyncio
204
+
from dstack_sdk import AsyncDstackClient
176
205
177
206
asyncdefmain():
178
207
client = AsyncDstackClient()
179
208
180
209
info =await client.info()
181
210
key =await client.get_key('wallet/eth')
182
211
183
-
#Concurrent operations
212
+
#Run requests concurrently
184
213
keys =await asyncio.gather(
185
214
client.get_key('user/alice'),
186
215
client.get_key('user/bob'),
@@ -189,79 +218,80 @@ async def main():
189
218
asyncio.run(main())
190
219
```
191
220
221
+
`AsyncDstackClient` accepts the same constructor as `DstackClient` plus `use_sync_http: bool = False` for callers that need to issue sync HTTP from within an async context.
222
+
192
223
## Blockchain Integration
193
224
194
225
### Ethereum
195
226
196
227
```python
197
-
from dstack_sdk.ethereum importto_account
228
+
from dstack_sdk.ethereum importto_account_secure
198
229
199
230
key = client.get_key('wallet/ethereum')
200
-
account =to_account(key)
231
+
account =to_account_secure(key)
201
232
print(account.address)
202
233
```
203
234
235
+
`to_account_secure(key)` hashes the full key material with SHA-256 before deriving the Ethereum private key. The legacy `to_account()` is kept for backward compatibility but uses raw key bytes—prefer the secure variant for new code.
236
+
204
237
### Solana
205
238
206
239
```python
207
-
from dstack_sdk.solana importto_keypair
240
+
from dstack_sdk.solana importto_keypair_secure
208
241
209
242
key = client.get_key('wallet/solana')
210
-
keypair =to_keypair(key)
211
-
print(keypair.public_key)
243
+
keypair =to_keypair_secure(key)
244
+
print(keypair.pubkey())
212
245
```
213
246
214
-
## Development
215
-
216
-
For local development without TDX hardware, use the simulator:
Same pattern: `to_keypair_secure(key)` SHA-256-hashes the key material; `to_keypair()` is the legacy raw-bytes variant.
237
248
238
249
---
239
250
240
251
## Deployment Utilities
241
252
242
253
These utilities are for deployment scripts, not runtime SDK operations.
243
254
244
-
### Encrypt Environment Variables
255
+
### Encrypted Environment Variables
245
256
246
-
Encrypt secrets before deploying to dstack:
257
+
The KMS returns a fresh X25519 public key (with a secp256k1 signature) that you encrypt secrets against before submitting them with your deployment. Always verify the signer before trusting the key:
247
258
248
259
```python
249
-
from dstack_sdk import encrypt_env_vars, verify_env_encrypt_public_key, EnvVar
# encrypt_env_vars_sync(...) is also available for non-async callers.
263
291
```
264
292
293
+
`verify_env_encrypt_public_key` returns the recovered compressed secp256k1 signer (`0x`-prefixed hex) on success, or `None` for any failure (bad length, expired/future timestamp, malformed `app_id`, invalid signature). The default `max_age_seconds` is 300; pass a larger value if your deployment workflow legitimately holds the response longer.
0 commit comments