Skip to content

OpenGradient SDK

The OpenGradient SDK enables developers to build applications using OpenGradient's decentralized, end-to-end verified AI infrastructure. The SDK provides a simple interface to run ML and LLM inference, manage models, and deploy automated workflows—all secured by the OpenGradient network.

The SDK is currently available for Python, a TypeScript version is under development. You can directly check the Python API Reference.

In addition to the OpenGradient Python library, the SDK also includes a CLI tool called opengradient for easier access and iteration.

SDK Features

  • ML Inference & Workflows: Run ML model inference and deploy automated workflows that execute on a schedule with live oracle data
  • LLM Inference: Use large language models for completions and chat, with support for tool usage and TEE execution
  • Model Management: Upload, manage, and organize your models on the Model Hub

Installation

To install the OpenGradient Python SDK and CLI, run the following command:

bash
pip install opengradient

NOTE

Windows Users: temporarily enable WSL when installing opengradient, fix in progress.

Credentials Setup

To use Python SDK to upload or download models and run inferences, you need to create 2 accounts:

  • Model Hub account: You can create this using your email and password on the Hub Sign Up.
  • OpenGradient account: You will receive verifiable inference transactions on this blockchain account on the OpenGradient network. You can use any existing Ethereum-compatible wallet with an account (e.g., MetaMask) or create a new one using our SDK (see below).

We provide an account creation wizard in our SDK that guides you through this process. You can access it by running:

bash
opengradient config init

NOTE

The wizard will also take you to our Test Faucet, where you can fund your OpenGradient account with devnet tokens.

CLI Setup

Check that the OpenGradient client reflects your settings (private key, email, etc.)

bash
opengradient config show

NOTE

You can run opengradient config init if your configuration is not currently set up.

To ensure everything is correctly set up, run the following inference:

bash
opengradient infer -m QmbUqS93oc4JTLMHwpVxsE39mhNxy6hpf6Py3r9oANr8aZ --input '{"num_input1":[1.0, 2.0, 3.0], "num_input2":10, "str_input1":["hello", "ONNX"], "str_input2":" world"}'

More Information

To see all commands and parameters we support in the CLI, you can run:

bash
opengradient --help