Skip to content

Commit 1aa8d8e

Browse files
author
balogh.adam@icloud.com
committed
allowance
1 parent 3804a44 commit 1aa8d8e

17 files changed

Lines changed: 43 additions & 44 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ hub = og.ModelHub(email="you@example.com", password="...")
8888

8989
### OPG Token Approval
9090

91-
Before making LLM requests, your wallet must approve OPG token spending via the [Permit2](https://github.com/Uniswap/permit2) protocol. Call this once (it's idempotent — no transaction is sent if the allowance already covers the requested amount):
91+
Before making LLM requests, your wallet must approve OPG token spending via the [Permit2](https://github.com/Uniswap/permit2) protocol. This only sends an on-chain transaction when the current allowance drops below the threshold:
9292

9393
```python
94-
llm.approve_opg(opg_amount=5)
94+
llm.ensure_opg_allowance(min_allowance=5)
9595
```
9696

9797
See [Payment Settlement](#payment-settlement) for details on settlement modes.

docs/CLAUDE_SDK_USERS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import os
2121
# Create an LLM client
2222
llm = og.LLM(private_key=os.environ["OG_PRIVATE_KEY"])
2323

24-
# One-time OPG token approval (idempotent — skips if allowance already sufficient)
25-
llm.approve_opg(opg_amount=0.1)
24+
# Ensure sufficient OPG allowance (only sends tx when below threshold)
25+
llm.ensure_opg_allowance(min_allowance=0.1)
2626

2727
# LLM Chat (TEE-verified with x402 payments, async)
2828
result = await llm.chat(

docs/opengradient/client/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import opengradient as og
2424

2525
# LLM inference (Base Sepolia OPG tokens)
2626
llm = og.LLM(private_key="0x...")
27-
llm.approve_opg(opg_amount=5)
27+
llm.ensure_opg_allowance(min_allowance=5)
2828
result = await llm.chat(model=og.TEE_LLM.CLAUDE_HAIKU_4_5, messages=[...])
2929

3030
# On-chain model inference (OpenGradient testnet gas tokens)

docs/opengradient/client/llm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Supports both streaming and non-streaming responses.
2121
All request methods (``chat``, ``completion``) are async.
2222

2323
Before making LLM requests, ensure your wallet has approved sufficient
24-
OPG tokens for Permit2 spending by calling ``ensure_opg_approval``.
24+
OPG tokens for Permit2 spending by calling ``ensure_opg_allowance``.
2525
This only sends an on-chain transaction when the current allowance is
2626
below the requested amount.
2727

docs/opengradient/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import opengradient as og
3535
llm = og.LLM(private_key="0x...")
3636

3737
# One-time OPG token approval (idempotent -- skips if allowance is sufficient)
38-
llm.approve_opg(opg_amount=5)
38+
llm.ensure_opg_allowance(min_allowance=5)
3939

4040
# Chat with an LLM (TEE-verified)
4141
response = asyncio.run(llm.chat(

examples/langchain_react_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
private_key = os.environ["OG_PRIVATE_KEY"]
1919

20-
# One-time Permit2 approval for OPG spending (idempotent)
20+
# Ensure sufficient OPG allowance for Permit2 spending
2121
llm_client = og.LLM(private_key=private_key)
22-
llm_client.approve_opg(opg_amount=5)
22+
llm_client.ensure_opg_allowance(min_allowance=5)
2323

2424
# Create the OpenGradient LangChain adapter
2525
llm = og.agents.langchain_adapter(

examples/llm_chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
async def main():
1212
llm = og.LLM(private_key=os.environ.get("OG_PRIVATE_KEY"))
13-
llm.approve_opg(opg_amount=0.1)
13+
llm.ensure_opg_allowance(min_allowance=0.1)
1414

1515
messages = [
1616
{"role": "user", "content": "What is the capital of France?"},

examples/llm_chat_streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
async def main():
88
llm = og.LLM(private_key=os.environ.get("OG_PRIVATE_KEY"))
9-
llm.approve_opg(opg_amount=0.1)
9+
llm.ensure_opg_allowance(min_allowance=0.1)
1010

1111
messages = [
1212
{"role": "user", "content": "What is Python?"},

examples/llm_tool_calling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ async def main():
5050
{"role": "user", "content": "What's the weather like in Dallas, Texas? Give me the temperature in fahrenheit."},
5151
]
5252

53-
# One-time Permit2 approval for OPG spending (idempotent)
54-
llm.approve_opg(opg_amount=0.1)
53+
# Ensure sufficient OPG allowance for Permit2 spending
54+
llm.ensure_opg_allowance(min_allowance=0.1)
5555

5656
print("Testing Gemini tool calls...")
5757
print(f"Model: {og.TEE_LLM.GEMINI_2_5_FLASH_LITE}")

src/opengradient/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
llm = og.LLM(private_key="0x...")
2727
2828
# One-time OPG token approval (idempotent -- skips if allowance is sufficient)
29-
llm.approve_opg(opg_amount=5)
29+
llm.ensure_opg_allowance(min_allowance=5)
3030
3131
# Chat with an LLM (TEE-verified)
3232
response = asyncio.run(llm.chat(

0 commit comments

Comments
 (0)