These examples demonstrate features that are currently only available on the OpenGradient Alpha Testnet. They are not yet supported on the official testnet.
- Alpha Testnet Access: You must be connected to the OpenGradient Alpha Testnet
- SDK Installation:
pip install opengradient - Credentials: Set up your environment variables:
OG_PRIVATE_KEY: Private key funded with OpenGradient testnet gas tokens for on-chain inference
Runs inference on a custom model using the OpenGradient network.
python examples/alpha/run_inference.pyWhat it does:
- Executes inference on a model using its CID
- Demonstrates passing structured input data (e.g., OHLC price data)
- Returns model predictions along with the transaction hash
Runs inference on an embeddings model for semantic search.
python examples/alpha/run_embeddings_model.pyWhat it does:
- Generates embeddings for queries and passages
- Demonstrates multilingual embeddings models
- Useful for semantic search, retrieval-augmented generation (RAG), etc.
Creates a new scheduled workflow for automated model inference.
python examples/alpha/create_workflow.pyWhat it does:
- Defines a workflow that runs a model on a schedule
- Configures historical data queries (e.g., cryptocurrency price data)
- Deploys the workflow as a smart contract
- Returns the contract address for the workflow
Reads results from a deployed workflow.
python examples/alpha/use_workflow.pyWhat it does:
- Retrieves the latest prediction from a workflow contract
- Fetches historical predictions from the workflow
- Demonstrates how to consume workflow outputs