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.

For LLM inference, the SDK provides a convenient Python wrapper around the x402 Gateway, handling HTTP requests and payment flows automatically. You can also use x402 directly from any language if you prefer more control over the integration. Beyond LLM convenience, the SDK provides additional capabilities like ML inference, automated workflows, and model management that are not available through x402 alone.

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

Installation

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

bash
pip install opengradient

You can also find the SDK on PyPI.

NOTE

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

Credentials Setup

LLM Inference (Testnet)

To run LLM inference, you need an Ethereum-compatible wallet (e.g., MetaMask) funded with $OPG testnet tokens on Base Sepolia.

PropertyValue
Payment NetworkBase Sepolia
Token$OPG (0x240b09731D96979f50B2C649C9CE10FcF9C7987F)
Chain ID84532
python
import opengradient as og

client = og.Client(private_key="0x...")

NOTE

Make sure your wallet has $OPG testnet tokens on Base Sepolia. You can get tokens from our faucet.

ML Inference & Model Management (Alpha Testnet)

To use ML inference, workflows, or model management features on the alpha testnet, you need to create 2 accounts:

  • Model Hub account: You can create this using your email and password on the Hub Sign Up.
  • OpenGradient alpha account: A blockchain account on the OpenGradient alpha testnet. You can use any existing Ethereum-compatible wallet (e.g., MetaMask) or create a new one using our SDK (see below).
python
import opengradient as og

client = og.Client(private_key="<private_key>", email="<email>", password="<password>")

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 account with testnet 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

Claude Code Plugin

The OpenGradient SDK is also available as a Claude Code plugin, letting you build with the SDK directly from your terminal using natural language.

Install the plugin

bash
claude plugin marketplace add https://github.com/OpenGradient/claude-plugins

This registers the OpenGradient marketplace and installs the plugin, making the /opengradient-sdk skill available in your Claude Code sessions.

Usage

Invoke the skill directly:

/opengradient-sdk write a streaming chat completion with tool calling

Or just describe what you want to build with OpenGradient — Claude will automatically use the skill when relevant.

NOTE

Requires Claude Code installed and a Base Sepolia wallet funded with $OPG tokens for LLM inference.

Code Examples

You can find examples using the SDK here.