Metadata-Version: 2.4
Name: opengradient
Version: 0.5.12
Summary: Python SDK for OpenGradient decentralized model management & inference services
Author-email: OpenGradient <kyle@vannalabs.ai>
License-Expression: MIT
Project-URL: Homepage, https://opengradient.ai
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: eth-account>=0.13.4
Requires-Dist: web3>=7.3.0
Requires-Dist: click>=8.1.7
Requires-Dist: firebase-rest-api>=1.11.0
Requires-Dist: grpcio>=1.66.2
Requires-Dist: numpy>=1.26.4
Requires-Dist: requests>=2.32.3
Requires-Dist: langchain>=0.3.7
Requires-Dist: openai>=1.58.1
Requires-Dist: pydantic>=2.9.2
Requires-Dist: og-test-x402==0.0.9
Requires-Dist: x402==0.2.1
Dynamic: license-file

# OpenGradient Python SDK

A Python SDK for decentralized model management and inference services on the OpenGradient platform. The SDK enables programmatic access to our model repository and decentralized AI infrastructure.

## Key Features

- Model management and versioning
- Decentralized model inference
- Support for LLM inference with various models
- **Trusted Execution Environment (TEE) inference** with cryptographic attestation
- End-to-end verified AI execution
- Command-line interface (CLI) for direct access

## Model Hub

Browse and discover AI models on our [Model Hub](https://hub.opengradient.ai/). The Hub provides:
- Registry of models and LLMs
- Easy model discovery and deployment
- Direct integration with the SDK

## Installation
```bash
pip install opengradient
```

Note: Windows users should temporarily enable WSL when installing `opengradient` (fix in progress).

## Getting Started

### 1. Account Setup

You'll need two accounts to use the SDK:
- **Model Hub account**: Create one at [Hub Sign Up](https://hub.opengradient.ai/signup)
- **OpenGradient account**: Use an existing Ethereum-compatible wallet or create a new one via SDK

The easiest way to set up your accounts is through our configuration wizard:
```bash
opengradient config init
```

This wizard will:
- Guide you through account creation
- Help you set up credentials
- Direct you to our Test Faucet for devnet tokens

### 2. Initialize the SDK
```python
import opengradient as og
og.init(private_key="<private_key>", email="<email>", password="<password>")
```

### 3. Basic Usage

Browse available models on our [Model Hub](https://hub.opengradient.ai/) or create and upload your own:
```python
# Create and upload a model
og.create_model(
    model_name="my-model",
    model_desc="Model description",
    model_path="/path/to/model"
)

# Run inference
inference_mode = og.InferenceMode.VANILLA
result = og.infer(
    model_cid="your-model-cid",
    model_inputs={"input": "value"},
    inference_mode=inference_mode
)
```

### 4. TEE (Trusted Execution Environment) Inference

OpenGradient supports secure, verifiable inference through TEE for leading LLM providers. Access models from OpenAI, Anthropic, Google, and xAI with cryptographic attestation:
```python
from opengradient import TEE_LLM

# Use TEE-enabled models for verifiable AI execution
result = og.infer(
    model_cid=TEE_LLM.CLAUDE_3_7_SONNET,  # or any other TEE_LLM model
    model_inputs={"prompt": "Your prompt here"},
    inference_mode=og.InferenceMode.TEE
)
```

**Available TEE Models:**
The SDK includes models from multiple providers accessible via the `TEE_LLM` enum:
- **OpenAI**: GPT-4.1, GPT-4o, o4-mini
- **Anthropic**: Claude 3.7 Sonnet, Claude 3.5 Haiku, Claude 4.0 Sonnet
- **Google**: Gemini 2.5 Flash, Gemini 2.5 Pro, and more
- **xAI**: Grok 3 Beta, Grok 4.1 Fast, and other Grok variants

For the complete list of available models, check the `TEE_LLM` enum in your IDE autocomplete or see the [API documentation](https://docs.opengradient.ai/).

### 5. Examples

See code examples under [examples](./examples).

## CLI Usage

The SDK includes a command-line interface for quick operations. First, verify your configuration:
```bash
opengradient config show
```

Run a test inference:
```bash
opengradient infer -m QmbUqS93oc4JTLMHwpVxsE39mhNxy6hpf6Py3r9oANr8aZ \
    --input '{"num_input1":[1.0, 2.0, 3.0], "num_input2":10}'
```

## Use Cases

1. **Off-chain Applications**: Use OpenGradient as a decentralized alternative to centralized AI providers like HuggingFace and OpenAI.

2. **Verifiable AI Execution**: Leverage TEE inference for cryptographically attested AI outputs, enabling trustless AI applications.

3. **Model Development**: Manage models on the Model Hub and integrate directly into your development workflow.

## Documentation

For comprehensive documentation, API reference, and examples, visit:
- [OpenGradient Documentation](https://docs.opengradient.ai/)
- [API Reference](https://docs.opengradient.ai/api_reference/python_sdk/)

### Claude Code Users

If you use [Claude Code](https://claude.ai/code), copy [docs/CLAUDE_SDK_USERS.md](docs/CLAUDE_SDK_USERS.md) to your project's `CLAUDE.md` to help Claude assist you with OpenGradient SDK development.

## Support

- Run `opengradient --help` for CLI command reference
- Visit our [documentation](https://docs.opengradient.ai/) for detailed guides
- Join our [community](https://opengradient.ai/) for support
