Skip to main content

nexus402

PyPI version Network Protocol Token License: MIT

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.


⚡ Installation

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

Metadata

Release files for nexus402 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nexus402 1.0.0
File Size Uploaded
nexus402-1.0.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nexus402 1.0.0
File Interpreter ABI Platform
nexus402-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / nexus402-1.0.0.tar.gz

Download URL nexus402-1.0.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1df8917d539d31248348c2dbc5eee884797f313613c21ce23e018063030217b4
BLAKE2b-256 checksum
How to use checksums
0ff3a6bfb8c65ec288c3bddcf50e92417f74e450b0224ca07ee8f0c52b7a0573
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / nexus402-1.0.0-py3-none-any.whl

Download URL nexus402-1.0.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c5c9e89363db6dc4766acca6f885a627d3df152a9d9853c338e4629dd178f34
BLAKE2b-256 checksum
How to use checksums
b456ba4ec44e1e84c3a71a0975f88dbeafcc96a83588a3488d9c4f7328e6ffe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page