Skip to content

Commit f711f0d

Browse files
author
balogh.adam@icloud.com
committed
readmes
1 parent 70eb7fc commit f711f0d

11 files changed

Lines changed: 160 additions & 153 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ See [Payment Settlement](#payment-settlement) for details on settlement modes.
9797

9898
### TEE-Secured LLM Chat
9999

100-
OpenGradient provides secure, verifiable inference through Trusted Execution Environments. All supported models include cryptographic attestation verified by the OpenGradient network:
100+
OpenGradient provides secure, verifiable inference through Trusted Execution Environments. All supported models include cryptographic attestation verified by the OpenGradient network. LLM methods are async:
101101
```python
102-
completion = client.llm.chat(
102+
completion = await client.llm.chat(
103103
model=og.TEE_LLM.GPT_5,
104104
messages=[{"role": "user", "content": "Hello!"}],
105105
)
@@ -111,14 +111,14 @@ print(f"Transaction hash: {completion.transaction_hash}")
111111

112112
For real-time generation, enable streaming:
113113
```python
114-
stream = client.llm.chat(
114+
stream = await client.llm.chat(
115115
model=og.TEE_LLM.CLAUDE_SONNET_4_6,
116116
messages=[{"role": "user", "content": "Explain quantum computing"}],
117117
max_tokens=500,
118118
stream=True,
119119
)
120120

121-
for chunk in stream:
121+
async for chunk in stream:
122122
if chunk.choices[0].delta.content:
123123
print(chunk.choices[0].delta.content, end="")
124124
```
@@ -299,7 +299,7 @@ OpenGradient supports multiple settlement modes through the x402 payment protoco
299299

300300
Specify settlement mode in your requests:
301301
```python
302-
result = client.llm.chat(
302+
result = await client.llm.chat(
303303
model=og.TEE_LLM.GPT_5,
304304
messages=[{"role": "user", "content": "Hello"}],
305305
x402_settlement_mode=og.x402SettlementMode.BATCH_HASHED,

docs/CLAUDE_SDK_USERS.md

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ client = og.Client(
2323
private_key=os.environ["OG_PRIVATE_KEY"], # Required: Ethereum private key
2424
)
2525

26-
# LLM Chat (TEE-verified with x402 payments)
27-
result = client.llm.chat(
26+
# LLM Chat (TEE-verified with x402 payments, async)
27+
result = await client.llm.chat(
2828
model=og.TEE_LLM.CLAUDE_HAIKU_4_5,
2929
messages=[{"role": "user", "content": "Hello!"}],
3030
max_tokens=100,
@@ -51,7 +51,7 @@ og.init(private_key="0x...", email="...", password="...")
5151
### LLM Chat
5252

5353
```python
54-
result = client.llm.chat(
54+
result = await client.llm.chat(
5555
model: TEE_LLM, # og.TEE_LLM enum value
5656
messages: List[Dict], # [{"role": "user", "content": "..."}]
5757
max_tokens: int = 100,
@@ -62,7 +62,7 @@ result = client.llm.chat(
6262
x402_settlement_mode: x402SettlementMode = x402SettlementMode.BATCH_HASHED,
6363
stream: bool = False, # Enable streaming responses
6464
)
65-
# Returns: TextGenerationOutput (or TextGenerationStream if stream=True)
65+
# Returns: TextGenerationOutput (or AsyncGenerator[StreamChunk] if stream=True)
6666
# - chat_output: Dict with role, content, tool_calls
6767
# - transaction_hash: str
6868
# - finish_reason: str ("stop", "tool_call")
@@ -72,7 +72,7 @@ result = client.llm.chat(
7272
### LLM Completion
7373

7474
```python
75-
result = client.llm.completion(
75+
result = await client.llm.completion(
7676
model: TEE_LLM,
7777
prompt: str,
7878
max_tokens: int = 100,
@@ -139,7 +139,7 @@ og.TEE_LLM.GROK_4_1_FAST_NON_REASONING
139139
All models are accessed through the OpenGradient TEE infrastructure with x402 payments:
140140

141141
```python
142-
result = client.llm.chat(
142+
result = await client.llm.chat(
143143
model=og.TEE_LLM.GPT_5,
144144
messages=[{"role": "user", "content": "Hello"}],
145145
)
@@ -165,7 +165,7 @@ tools = [{
165165
}
166166
}]
167167

168-
result = client.llm.chat(
168+
result = await client.llm.chat(
169169
model=og.TEE_LLM.CLAUDE_SONNET_4_6,
170170
messages=[{"role": "user", "content": "What's the weather in NYC?"}],
171171
tools=tools,
@@ -180,13 +180,13 @@ if result.chat_output.get("tool_calls"):
180180
### Streaming
181181

182182
```python
183-
stream = client.llm.chat(
183+
stream = await client.llm.chat(
184184
model=og.TEE_LLM.CLAUDE_SONNET_4_6,
185185
messages=[{"role": "user", "content": "Tell me a story"}],
186186
stream=True,
187187
)
188188

189-
for chunk in stream:
189+
async for chunk in stream:
190190
for choice in chunk.choices:
191191
if choice.delta.content:
192192
print(choice.delta.content, end="")
@@ -283,28 +283,15 @@ og.CandleOrder.ASCENDING, .DESCENDING
283283

284284
## Error Handling
285285

286-
```python
287-
from opengradient.client.exceptions import (
288-
OpenGradientError, # Base exception
289-
AuthenticationError,
290-
InferenceError,
291-
InvalidInputError,
292-
NetworkError,
293-
RateLimitError,
294-
TimeoutError,
295-
ServerError,
296-
UnsupportedModelError,
297-
InsufficientCreditsError,
298-
)
286+
LLM methods raise `RuntimeError` on failure and `ValueError` for invalid arguments:
299287

288+
```python
300289
try:
301-
result = client.llm.chat(...)
302-
except RateLimitError:
303-
# Retry with backoff
304-
except InferenceError as e:
305-
print(f"Inference failed: {e.message}")
306-
except OpenGradientError as e:
307-
print(f"Error {e.status_code}: {e.message}")
290+
result = await client.llm.chat(...)
291+
except RuntimeError as e:
292+
print(f"Inference failed: {e}")
293+
except ValueError as e:
294+
print(f"Invalid input: {e}")
308295
```
309296

310297
## Environment Variables

docs/opengradient/client/alpha.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ InferenceResult (InferenceResult): A dataclass object containing the transaction
6363

6464
**Raises**
6565

66-
* **`OpenGradientError`**: If the inference fails.
66+
* **`RuntimeError`**: If the inference fails.
6767

6868
---
6969

docs/opengradient/client/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ repo = client.model_hub.create_model("my-model", "A price prediction model")
6565

6666
* [alpha](./alpha): Alpha Testnet features for OpenGradient SDK.
6767
* [client](./client): Main Client class that unifies all OpenGradient service namespaces.
68-
* [exceptions](./exceptions): Exception types for OpenGradient SDK errors.
6968
* [llm](./llm): LLM chat and completion via TEE-verified execution with x402 payments.
7069
* [model_hub](./model_hub): Model Hub for creating, versioning, and uploading ML models.
7170
* [opg_token](./opg_token): OPG token Permit2 approval utilities for x402 payments.

docs/opengradient/client/llm.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Union[TextGenerationOutput, AsyncGenerator[StreamChunk, None]]:
9999

100100
**Raises**
101101

102-
* **`OpenGradientError`**: If the inference fails.
102+
* **`RuntimeError`**: If the inference fails.
103103

104104
---
105105

@@ -166,7 +166,7 @@ TextGenerationOutput: Generated text results including:
166166

167167
**Raises**
168168

169-
* **`OpenGradientError`**: If the inference fails.
169+
* **`RuntimeError`**: If the inference fails.
170170

171171
---
172172

@@ -201,4 +201,4 @@ Permit2ApprovalResult: Contains ``allowance_before``,
201201
**Raises**
202202

203203
* **`ValueError`**: If the OPG amount is less than 0.05.
204-
* **`OpenGradientError`**: If the approval transaction fails.
204+
* **`RuntimeError`**: If the approval transaction fails.

docs/opengradient/client/model_hub.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ List[Dict]: A list of dictionaries containing file information.
101101

102102
**Raises**
103103

104-
* **`OpenGradientError`**: If the file listing fails.
104+
* **`RuntimeError`**: If the file listing fails.
105105

106106
---
107107

@@ -129,4 +129,4 @@ dict: The processed result.
129129

130130
**Raises**
131131

132-
* **`OpenGradientError`**: If the upload fails.
132+
* **`RuntimeError`**: If the upload fails.

docs/opengradient/client/opg_token.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Permit2ApprovalResult: Contains ``allowance_before``,
4646

4747
**Raises**
4848

49-
* **`OpenGradientError`**: If the approval transaction fails.
49+
* **`RuntimeError`**: If the approval transaction fails.
5050

5151
## Classes
5252

docs/opengradient/client/twins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ TextGenerationOutput: Generated text results including chat_output and finish_re
7272

7373
**Raises**
7474

75-
* **`OpenGradientError`**: If the request fails.
75+
* **`RuntimeError`**: If the request fails.

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ print(f"Tx hash: {result.transaction_hash}")
165165

166166
### LLM Chat
167167

168-
LLM chat pattern:
168+
LLM chat methods are async:
169169

170170
```python
171-
completion = og_client.llm.chat(
171+
completion = await og_client.llm.chat(
172172
model=og.TEE_LLM.CLAUDE_HAIKU_4_5,
173173
messages=[{"role": "user", "content": "Your message"}],
174174
)

0 commit comments

Comments
 (0)