Machine-Native Compute & Sentinel-Shield Pre-Flight Security SDK for Autonomous AI Agents on Base L2 (x402 Protocol)
Turnkey Machine-Native Compute & Sentinel-Shield Pre-Flight Security SDK for Autonomous AI Agents on Base L2.
Autonomous AI agents shouldn't need human credit cards or KYC API keys to think, trade, and protect their treasuries. nexus402 provides a drop-in replacement for the official OpenAI Python SDK that automatically negotiates Coinbase x402 v2.0 payment challenges on Base, signing sub-cent native USDC micropayment vouchers directly from your agent's EVM key.
pip install nexus402 🚀 30-Second Quickstart (Drop-in OpenAI Replacement) from nexus402 import Nexus402Client import os # Initialize with your agent's Base L2 wallet private key client = Nexus402Client( base_url="https://gateway.nexus402.org/v1", # or "http://127.0.0.1:4020/v1" private_key=os.environ.get("AGENT_PRIVATE_KEY") ) # 1. Autonomous Chat Completion with automated x402 micro-settlement response = client.chat.completions.create( model="openai/gpt-4o-mini", # or "deepseek/deepseek-r1", "openai/gpt-oss-120b" messages=[ {"role": "system", "content": "You are an autonomous DeFi security agent."}, {"role": "user", "content": "Verify reentrancy invariant on contract 0x8335...2913."} ] ) print("Agent Thought:", response["choices"][0]["message"]["content"]) print("Proof-of-Inference:", response.get("proof_of_inference", {}).get("output_hash")) 🛡️ Sentinel-Shield Smart Contract Pre-Flight Audit Before your agent interacts with an unfamiliar token or pool, run an automated pre-flight audit ($0.10 USDC) to prevent getting drained:
from nexus402 import Nexus402Client client = Nexus402Client() def pre_flight_check(token_address: str): audit = client.shield.inspect(token_address) print(f"Contract: {audit['targetContract']}") print(f"Risk Score: {audit['riskScore']} / 100 ({audit['verdict']})") print(f"Honeypot: {audit['honeypot']}") print(f"Sell Tax: {audit['sellTaxBps'] / 100}% | Buy Tax: {audit['buyTaxBps'] / 100}%") if audit['riskScore'] >= 70 or audit['honeypot']: raise RuntimeError("🚨 ABORT TRADE: Malicious contract detected by Sentinel-Shield!") print("✅ Verified Safe. Proceeding with swap.") pre_flight_check("0x833589fcd6edb6e08f4c7c32d4f71b54bda02913") 🌊 SSE Token Streaming Example stream = client.chat.completions.create( model="openai/gpt-oss-120b", # Groq LPU (280 TPS) messages=[{"role": "user", "content": "Analyze slippage curve on Uniswap V3 pool."}], stream=True ) for chunk in stream: delta = chunk.get("choices", [{}])[0].get("delta", {}).get("content", "") print(delta, end="", flush=True) print() 📄 License MIT © Nexus-402 Protocol Working Group & BluSky Contributors
Author: Nexus-402 Protocol Working Group & BluSky Contributors
nexus402 x402 ai-agents base usdc micropayments openai smart-contract-audit sentinel-shield deepseek-r1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




