Skip to content

Commit dc521ca

Browse files
committed
register updates
1 parent 14da782 commit dc521ca

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/opengradient/client/llm.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import AsyncGenerator, Awaitable, Callable, Dict, List, Optional, TypeVar, Union
77
import httpx
88
import asyncio
9+
import os
910

1011
from eth_account import Account
1112
from eth_account.account import LocalAccount
@@ -28,6 +29,7 @@
2829
X402_PROCESSING_HASH_HEADER = "x-processing-hash"
2930
X402_PLACEHOLDER_API_KEY = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
3031
BASE_TESTNET_NETWORK = "eip155:84532"
32+
BASE_TESTNET_RPC = os.getenv("BASE_TESTNET_RPC", "https://sepolia.base.org")
3133

3234
_CHAT_ENDPOINT = "/v1/chat/completions"
3335
_COMPLETION_ENDPOINT = "/v1/completions"
@@ -84,7 +86,7 @@ def __init__(
8486
raise ValueError("A private key is required to use the LLM client. Pass a valid private_key to the constructor.")
8587
self._wallet_account: LocalAccount = Account.from_key(private_key)
8688

87-
x402_client = LLM._build_x402_client(private_key)
89+
x402_client = LLM._build_x402_client(private_key, rpc_url=BASE_TESTNET_RPC)
8890
onchain_registry = TEERegistry(rpc_url=rpc_url, registry_address=tee_registry_address)
8991
self._tee: TEEConnectionInterface = RegistryTEEConnection(x402_client=x402_client, registry=onchain_registry)
9092

@@ -114,13 +116,18 @@ def from_url(
114116
return instance
115117

116118
@staticmethod
117-
def _build_x402_client(private_key: str) -> x402Client:
119+
def _build_x402_client(private_key: str, rpc_url: str = BASE_TESTNET_RPC) -> x402Client:
118120
"""Build the x402 payment stack from a private key."""
119121
account = Account.from_key(private_key)
120122
signer = EthAccountSigner(account)
121123
client = x402Client()
122124
register_exact_evm_client(client, signer, networks=[BASE_TESTNET_NETWORK])
123-
register_upto_evm_client(client, signer, networks=[BASE_TESTNET_NETWORK])
125+
register_upto_evm_client(
126+
client,
127+
signer,
128+
networks=[BASE_TESTNET_NETWORK],
129+
rpc_url=rpc_url,
130+
)
124131
return client
125132

126133
# ── Lifecycle ───────────────────────────────────────────────────────

0 commit comments

Comments
 (0)