@@ -51,18 +51,18 @@ opengradient config init
5151import os
5252import opengradient as og
5353
54- og_client = og.new_client(
54+ client = og.init(
55+ private_key = os.environ.get(" OG_PRIVATE_KEY" ),
5556 email = None , # Optional: only needed for model uploads
5657 password = None ,
57- private_key = os.environ.get(" OG_PRIVATE_KEY" ),
5858)
5959```
6060
6161### 3. Basic Usage
6262
6363#### LLM Chat
6464``` python
65- completion = og_client.llm_chat (
65+ completion = client.llm.chat (
6666 model = og.TEE_LLM .GPT_4O ,
6767 messages = [{" role" : " user" , " content" : " Hello!" }],
6868)
@@ -73,7 +73,7 @@ print(f"Tx hash: {completion.transaction_hash}")
7373#### Custom Model Inference
7474Browse models on our [ Model Hub] ( https://hub.opengradient.ai/ ) or upload your own:
7575``` python
76- result = og_client .infer(
76+ result = client.inference .infer(
7777 model_cid = " your-model-cid" ,
7878 model_input = {" input" : [1.0 , 2.0 , 3.0 ]},
7979 inference_mode = og.InferenceMode.VANILLA ,
@@ -86,7 +86,7 @@ print(f"Output: {result.model_output}")
8686OpenGradient supports secure, verifiable inference through TEE for leading LLM providers. Access models from OpenAI, Anthropic, Google, and xAI with cryptographic attestation:
8787``` python
8888# Use TEE mode for verifiable AI execution
89- completion = og_client.llm_chat (
89+ completion = client.llm.chat (
9090 model = og.TEE_LLM .CLAUDE_3_7_SONNET ,
9191 messages = [{" role" : " user" , " content" : " Your message here" }],
9292)
@@ -112,10 +112,10 @@ The Alpha Testnet provides access to experimental features, including **workflow
112112``` python
113113import opengradient as og
114114
115- og.init(
115+ client = og.init(
116+ private_key = " your-private-key" ,
116117 email = " your-email" ,
117118 password = " your-password" ,
118- private_key = " your-private-key" ,
119119)
120120
121121# Define input query for historical price data
@@ -129,7 +129,7 @@ input_query = og.HistoricalInputQuery(
129129)
130130
131131# Deploy a workflow (optionally with scheduling)
132- contract_address = og .alpha.new_workflow(
132+ contract_address = client .alpha.new_workflow(
133133 model_cid = " your-model-cid" ,
134134 input_query = input_query,
135135 input_tensor_name = " input" ,
@@ -141,14 +141,14 @@ print(f"Workflow deployed at: {contract_address}")
141141#### Execute and Read Results
142142``` python
143143# Manually trigger workflow execution
144- result = og .alpha.run_workflow(contract_address)
144+ result = client .alpha.run_workflow(contract_address)
145145print (f " Inference output: { result} " )
146146
147147# Read the latest result
148- latest = og .alpha.read_workflow_result(contract_address)
148+ latest = client .alpha.read_workflow_result(contract_address)
149149
150150# Get historical results
151- history = og .alpha.read_workflow_history(contract_address, num_results = 5 )
151+ history = client .alpha.read_workflow_history(contract_address, num_results = 5 )
152152```
153153
154154### 6. Examples
0 commit comments