Skip to main content

Nexus6 AI Identity SDK — universal identity verification for AI agents

Project description

Nexus6 Python SDK

PyPI Python License: MIT

Installation

pip install nexus6-sdk

Quick Start — Register a new AI agent

from nexus6_sdk import Nexus6Client

client = Nexus6Client()

# Register — you get an identity + RSA key pair
result = client.register(name="My AI Agent")
print(result["api_key"])      # nxs6_xxx — your identifier
print(result["public_key"])   # RSA public key (stored on Nexus6)
print(result["private_key"])  # RSA private key — save securely!

Quick Start — Sign and verify (5 lines)

import time
from nexus6_sdk import Nexus6Client

client = Nexus6Client()

# 1. Sign a request with your private key
message = f"POST:/api/v1/tools:{int(time.time())}"
signature = client.sign_request(private_key_pem, message)

# 2. Verify on the other side
result = client.verify(
    api_key="nxs6_xxx",
    signature=signature,
    timestamp=str(int(time.time())),
    method="POST",
    path="/api/v1/tools"
)
print(result["verified"])  # True

How It Works

AI Agent                          Platform
    │                                 │
    ├─ Register → get RSA keys        │
    │                                 │
    ├─ sign_request(private_key,      │
    │   "GET:/api/data:ts")           │
    │                                 │
    ├─ Send headers:                  │
    │   X-API-Key: nxs6_xxx           │
    │   X-Agent-Signature: <base64>   │
    │   X-Agent-Timestamp: <ts>       │
    │                       ─────►    │
    │                                 ├─ Lookup public key by api_key
    │                                 ├─ Verify RSA signature locally
    │                                 ├─ ✅ Identity verified (under 100ms)
    │                                 └─ Process request

Platform Integration (FastAPI)

One line of middleware. Every incoming request is verified automatically.

from fastapi import FastAPI, Request
from nexus6_sdk.middleware import Nexus6Middleware

app = FastAPI()
app.add_middleware(Nexus6Middleware)

@app.post("/api/chat")
async def chat(request: Request):
    identity = request.state.ai_identity
    return {"message": f"Verified AI: {identity['identity']['api_key']}"}

Expected Headers

Header Value Required
X-API-Key nxs6_xxx Yes
X-Agent-Signature base64(RSA-SHA256) Yes
X-Agent-Timestamp Unix timestamp Yes

Custom Configuration

app.add_middleware(
    Nexus6Middleware,
    base_url="https://your-nexus6-instance.com",
    exclude_paths=["/health", "/docs"],
    signature_max_age_seconds=60,  # default: 300
)

API Reference

Nexus6Client

Method Returns Description
register(name, **kwargs) {success, agent_id, api_key, private_key, public_key} Register new AI agent with RSA keys
verify(api_key, signature, timestamp, method, path) {verified, id, name, ...} Verify RSA signature against Nexus6
sign_request(private_key_pem, message) str Sign a message with RSA private key
build_auth_headers(private_key_pem, method, path) {X-Agent-Signature, X-Agent-Timestamp} Build signature headers
generate_keys(ai_id, x_api_key) {success, public_key, private_key} Generate RSA key pair and upload public key
fetch_public_key(ai_id) str or None Fetch public key by agent ID
fetch_public_key_by_api_key(api_key) str or None Fetch public key by API key
verify_signature_offline(public_key_pem, message, signature) bool Verify RSA signature locally

Register Parameters

Parameter Required Description
name Yes AI agent name
title No Display title
ai_type No Type: assistant, coding, customer_service, etc.
description No What the AI does
developer_email No Developer contact

Middleware Options

Option Default Description
base_url https://nexus-7xp6n.ondigitalocean.app Nexus6 API endpoint
mode "signature" Verification mode (signature or legacy)
exclude_paths ["/health", "/docs", ...] Paths to skip
signature_max_age_seconds 300 Max signature age (5 min)
on_verified None Callback(request, identity)

Requirements

  • Python 3.9+
  • httpx
  • starlette (for middleware)
  • cryptography (for RSA signing/verification)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexus6_sdk-0.2.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexus6_sdk-0.2.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file nexus6_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: nexus6_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for nexus6_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 87b236052867526791e75e7932d755ba73c8070dd5111036ca83432636cdf719
MD5 6546d77f0f507db348f9f115ce6eb6b3
BLAKE2b-256 281be9eef001b5d0483abd0037a74096d6640c5c789e93fb486448b9810839c7

See more details on using hashes here.

File details

Details for the file nexus6_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: nexus6_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for nexus6_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e558f7906197300dbca5b2990c6ab9d31ba56528669c50747faa605d326a770
MD5 383687a3c26bf23eef857d45db5b8a7f
BLAKE2b-256 c6ac49f4f946c5cebd0f0ef74d7a151687fbdb038abd13f3d7575da4cbb6d81b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page