Skip to content

OpenGradient ML Workflows

OG-SDK ML Workflows Overview

You can use the OpenGradient SDK to create and deploy ML workflows that automatically run inference on a schedule with live oracle data. Workflows enable building decentralized applications that leverage ML predictions without having to manage the infrastructure for model execution, data collection, or scheduling.

With the OG-SDK, you can deploy model workflows that:

  • Automatically gather live price data from on-chain oracles
  • Execute ML inference on a customizable schedule
  • Store results on-chain for applications to consume
  • Maintain full verifiability and auditability of the entire process

Behind the scenes, workflows utilize on-chain contracts for orchestration, ensuring the data inputs, model execution, and outputs are fully verified and secured by the OpenGradient network.

Official OG-ML Workflows

ModelWorkflow Contract AddressModel CID
og-1hour-volatility-ethusdt10xD5629A5b95dde11e4B5772B5Ad8a13B933e33845QmRhcpDXfYCKsimTmJYrAVM4Bbvck59Zb2onj3MHv9Kw5N
og-30min-return-suiusdt0xD85BA71f5701dc4C5BDf9780189Db49C6F3708D2QmY1RjD3s4XPbSeKi5TqMwbxegumenZ49t2q7TrK7Xdga4
og-6h-return-suiusdt0x3C2E4DbD653Bd30F1333d456480c1b7aB122e946QmP4BeRjycVxfKBkFtwj5xAa7sCWyffMQznNsZnXgYHpFX

Example Deployment

Here, we will walk through the process of creating & deploying a ML workflow.

In this example, we'll be deploying the opengradient-1hour-volatility-ethusdt1 model, found here.

python
from opengradient.types import HistoricalInputQuery, CandleOrder, CandleType, SchedulerParams

input_query = HistoricalInputQuery(
    currency_pair="ETH/USD",
    total_candles=10,
    candle_duration_in_mins=30,
    order=CandleOrder.ASCENDING,
    candle_types=[
        CandleType.OPEN,
        CandleType.HIGH,
        CandleType.LOW,
        CandleType.CLOSE
    ]
)

scheduler_params = SchedulerParams(
    frequency=3600,  # Run every hour (3600 seconds)
    duration_hours=720  # Run for approximately 1 month (30 days * 24 hours)
)

# Deploy a new workflow with your model
model_cid = "QmRhcpDXfYCKsimTmJYrAVM4Bbvck59Zb2onj3MHv9Kw5N"
contract_address = og.new_workflow(
    model_cid=model_cid,
    input_query=input_query,
    input_tensor_name="open_high_low_close",
    scheduler_params=scheduler_params
)

This should output something like the following:

bash
📦 Deploying workflow contract...
 Workflow contract deployed at: 0x1624e0F90b62f15369B658D0Aed887cad808aa45

 Setting up automated execution schedule...
 Frequency: Every 3600 seconds
 Duration: 720 hours
 End Time: 2025-02-13 13:13:53
 Automated execution schedule set successfully!
   Transaction hash: a4375ed17db73baf413ba7353ac1c6387d24c8f737f271e54961fbae1b7e5fd7

Users can invoke the run_workflow function to manually run an inference with the latest live data.

python
og.run_workflow(contract_address)

At any point after the workflow has executed, view the model's latest output via the read_workflow_result function.

python
# Read the workflow result
result = og.read_workflow_result(contract_address)
print("Inference result:", result)

This will return the output of the model:

bash
Inference Result: ([('Y', [(1010655425488948822021484375, 30)], [1])], [], [], False)

When to Use Workflows

Workflows are ideal when you need a continuous, reliable stream of ML predictions that can be accessed on-chain. Consider using workflows when:

  • You need periodic model predictions without manual intervention
  • Your application requires a persistent, reliable data feed of ML predictions
  • You want to create a stream of values that can be easily consumed by:
    • Smart contracts that automate decisions based on ML predictions
    • Cross-chain applications that need access to verified ML outputs
    • Autonomous agents that integrate prediction data into their operations
    • DeFi protocols that adjust parameters based on forecasted values

Use one-off inferences when:

  • You need a single prediction at a specific moment
  • Your application handles the scheduling logic independently
  • Building user-facing applications where predictions are requested on-demand

Workflows simplify integration by handling the entire pipeline from data collection to model execution, allowing developers to focus on building applications that consume the results rather than managing infrastructure.

Use Cases

Spot Forecasting

The spot forecasting workflows can be utilized to make price projections for the designated timeframe of the model. The OG spot forecast workflows are set up to run on an hourly cadence for developers to read from & integrate into their applications.

Currently, developers can utilize the official OG SUI spot forecasting workflows for 30 minute & 6 hour horizons.

Volatility Projection

The Ethereum volatility workflow contract is set up to predict the standard deviation of 1 minute returns over the next hour for ETH/USDT.

OpenGradient 2025