An AI Agent Skill that makes integrating the OpenGradient SDK safe, fast, and always up-to-date.
opengradient-connect is a modular AI Agent Skill that turns any AI coding agent into a senior OpenGradient integration engineer. Instead of hallucinating API calls or generating outdated boilerplate, the agent follows a strict Safety-First & Fetch protocol:
- 🩺 Diagnose first — audits your project before writing a single line of code.
- 📥 Fetch, don't invent — pulls live, verified templates from the official Cookbook.
- 🔒 Enforce Golden Rules — ensures
Permit2approval and TEE proof extraction are present every time. - 🛡️ Guard the network — prevents accidental Mainnet deployments before you're ready.
| Feature | Description |
|---|---|
| Hybrid Architecture | The skill acts as a rule engine and fetches live code from the Cookbook. No stale boilerplate. |
| Environment Diagnostics | Dual-mode audit: manual file analysis + automated og_diagnostics.py JSON report. |
| TEE Proof Enforcement | Every inference call is checked for payment_hash — the cryptographic proof of TEE execution. |
| Permit2 Golden Rule | ensure_opg_approval() is enforced at startup — the most common integration bug, automatically caught. |
| Network Context Guard | The agent always asks Testnet or Mainnet? before generating constants or config. |
| Mainnet Migration Checklist | An interactive 8-step safety protocol for moving from Sepolia to Mainnet — requires manual confirmation at each step. |
| PyPI Freshness Check | Compares installed SDK version with latest on PyPI and warns if stale. |
| Troubleshooting Database | Top 10 TEE / Gateway / x402 Gateway Gateway errors with exact diagnostic commands and fixes. |
┌─────────────────────────────────────────────────────────────────┐
│ AI Agent (You) │
│ │
│ User: "Help me build a verifiable FastAPI backend with OG" │
└────────────────────────────┬────────────────────────────────────┘
│ triggers skill
▼
┌─────────────────────────────────────────────────────────────────┐
│ opengradient-connect (SKILL.md) │
│ │
│ Step 0: Network Context Guard ──► Testnet or Mainnet? │
│ Step 1: Environment Diagnostics ─► Read .env + run og_diag.py │
│ Step 2: Template Fetching ───────► GET from Cookbook GitHub │
│ Step 3: Golden Rules Check ──────► Permit2 + payment_hash │
│ Step 4: Network Guard ───────────► Warn if Mainnet │
│ Step 5: Hybrid Updater ──────────► Check PyPI freshness │
└────────────────────────────┬────────────────────────────────────┘
│ fetches live code
▼
┌─────────────────────────────────────────────────────────────────┐
│ OpenGradient Developer Cookbook (GitHub) │
│ │
│ snippets/01_llm_completion_basic.py │
│ snippets/02_llm_chat_with_tools.py │
│ snippets/11_langchain_agent.py │
│ boilerplates/fastapi-verifiable-backend/main.py │
└─────────────────────────────────────────────────────────────────┘
opengradient-connect-skill/
│
├── SKILL.md # 🧠 Core agent instructions & trigger conditions
│
├── scripts/
│ ├── og_diagnostics.py # 🩺 Full environment auditor (JSON output)
│ └── og_pypi_check.sh # 📦 Quick SDK version checker (PyPI vs installed)
│
└── references/
├── troubleshooting.md # 🔧 Top-10 TEE/Gateway error database
└── mainnet_checklist.md # 🚀 Interactive 8-step Mainnet migration protocol
Drop the skill folder directly into your agent's skills directory:
# Clone the repository
git clone https://github.com/Floyd11/opengradient-connect-skill.git
# Copy into your agent's skills folder
cp -r opengradient-connect-skill/ /path/to/your/project/.agent/skills/05-opengradient-connect/Your agent will auto-discover SKILL.md at startup due to the keywords in its description field.
Expected directory after setup:
your-project/
└── .agent/
└── skills/
└── 05-opengradient-connect/
├── SKILL.md
├── scripts/
└── references/
Claude Code supports loading custom skill context via its --add-dir flag or by pointing to the skill folder in your project.
# Install claude CLI (if not yet installed)
npm install -g @anthropic-ai/claude-code
# Start a session with the skill in context
claude --add-dir .agent/skills/05-opengradient-connect/
# Or, add it permanently to your project's allowed paths
# in .claude/settings.json:{
"allowedDirectories": [
".",
".agent/skills/05-opengradient-connect"
]
}The agent will load
SKILL.mdwhen it detects OpenGradient-related keywords in your request.
These editors support injecting context via .cursorrules or a system prompt file.
Step 1: Create or append to .cursorrules at your project root:
# OpenGradient SDK Integration Rules
# Auto-loaded from: .agent/skills/05-opengradient-connect/SKILL.md
@.agent/skills/05-opengradient-connect/SKILL.md
Step 2: Windsurf users — add to .windsurfrules:
@.agent/skills/05-opengradient-connect/SKILL.md
Step 3 (Optional): For Cursor's AI Pane, manually paste the contents of SKILL.md into the System Prompt section under Cursor Settings → AI → Rules for AI.
Tip for Cursor / Windsurf: The
og_diagnostics.pyscript always exits with code0regardless of findings, so it won't break your agent's tool-calling chain. The agent reads the JSON output and decides what to do.
If your agent platform supports a skills package manager:
# Install via skills CLI (if supported by your platform)
skills add opengradient-connect
# Or install from GitHub directly
skills install github:Floyd11/opengradient-connect-skillOnce installed, trigger the skill naturally. Here are example prompts:
"Integrate OpenGradient into my project. Check my environment first."
"Help me deploy a verifiable FastAPI backend using OpenGradient with TEE inference on Base Sepolia."
"Build a LangGraph agent that uses OpenGradient for verifiable LLM calls and logs the TEE proof to my database."
"Replace my existing ChatOpenAI usage with OpenGradient's TEE-verified LLM. Use LangChain integration."
"Run a full OpenGradient environment diagnostic on my project and tell me what's missing."
"I'm ready to migrate my OpenGradient integration to Mainnet. Guide me through the checklist."
The skill will check for the following in your .env:
| Variable | Required | Description |
|---|---|---|
OG_PRIVATE_KEY |
✅ Yes | Your Ethereum-compatible wallet private key (hex, 64 chars, optionally 0x-prefixed). Used to authenticate with the x402 Gateway. |
Example .env:
# OpenGradient SDK Configuration
OG_PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
⚠️ Security: Always add.envto.gitignore. Never commit your private key.
| Network | Chain ID | RPC URL | Status |
|---|---|---|---|
| Base Sepolia (Testnet) | 84532 |
https://sepolia.base.org |
✅ Active |
| OpenGradient Mainnet | TBD | TBD | 🔜 Coming Soon |
To get testnet $OPG tokens: join the OpenGradient Discord or use the OpenGradient Faucet.
Every piece of code this skill generates or reviews enforces these two rules without exception:
# Called ONCE at application startup — never inside a loop.
# Grants the x402 Gateway permission to spend $OPG on behalf of the user.
llm.ensure_opg_approval(min_allowance=5.0)If missing → flagged as a critical bug.
result = llm.chat(messages=[{"role": "user", "content": "your prompt"}])
# Every inference call must surface the cryptographic proof of TEE execution.
payment_hash = result.payment_hash
print(f"[TEE PROOF] {payment_hash}") # verifiable on-chainIf payment_hash is None → treated as a silent data-loss failure.
Run the bundled auditor from your project root to get a full JSON health report:
python .agent/skills/05-opengradient-connect/scripts/og_diagnostics.pyExample output:
{
"project_root": "/your/project",
"package_manager": "pip",
"sdk": {
"installed": true,
"installed_version": "0.9.9",
"latest_pypi_version": "0.9.9",
"update_needed": false
},
"env_vars": {
"env_file_exists": true,
"vars": { "OG_PRIVATE_KEY": true },
"all_present": true
},
"network_config": {
"detected_chain_id": null,
"is_testnet": null
},
"detected_integrations": ["langchain", "langgraph", "fastapi"],
"ready_to_integrate": true
}When you're ready to go live, the skill will guide you through an 8-step interactive checklist (references/mainnet_checklist.md):
- ✅ Confirm Mainnet is officially launched
- 💾 Backup your Testnet
.env - 💰 Validate Mainnet wallet and
$OPGbalance (min. 10 OPG) - ✏️ Update
.envmanually (agent never auto-writes keys) - 🩺 Re-run diagnostics on Mainnet config
- 🤝 Permit2 re-approval on Mainnet (irreversible — requires explicit YES)
- 🔬 Smoke test with minimal inference + TEE proof verification
- 🔍 Grep codebase for hardcoded Testnet constants
⚠️ Every step requires explicit user confirmation. The agent will HALT if any validation fails.
The skill never generates boilerplate from memory. It fetches from:
| Recipe | Description | Source |
|---|---|---|
| Basic LLM Completion | Simple TEE chat inference | 01_llm_completion_basic.py |
| Tool Calling Agent | Multi-turn chat with function calling | 02_llm_chat_with_tools.py |
| LangChain Integration | Drop-in for ChatOpenAI |
11_langchain_agent.py |
| FastAPI Backend | Async REST endpoint with TEE verification | fastapi-verifiable-backend/main.py |
Quick reference for the most common errors. The full database is in references/troubleshooting.md.
| Error | Cause | Quick Fix |
|---|---|---|
InsufficientFundsError |
No $OPG on Sepolia |
Get tokens from Discord faucet |
GatewayTimeoutError |
x402 Gateway overloaded | Add retry with exponential backoff |
payment_hash is None |
Not using a TEE model | Use og.TEE_LLM enum, not string names |
PermissionError on inference |
Permit2 not approved | Call ensure_opg_approval() at startup |
ModuleNotFoundError |
SDK not installed | pip install opengradient |
InvalidPrivateKeyError |
Malformed OG_PRIVATE_KEY |
Must be 64-char hex, optionally 0x-prefixed |
- 📘 OpenGradient Documentation
- 🍳 Developer Cookbook
- 💬 OpenGradient Discord
- 🔗 OpenGradient Faucet
- 📦 opengradient on PyPI
MIT — see LICENSE for details.
Built for the OpenGradient ecosystem · Safety-First · Verifiable AI