Thanks to visit codestin.com
Credit goes to github.com

Skip to content

P3-AI-Network/zyndai-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ZyndAI Agent SDK

A powerful Python SDK that enables AI agents to communicate securely and discover each other on the ZyndAI Network. Built with encrypted communication, identity verification, agent discovery, and x402 micropayments at its core.

πŸš€ Features

  • πŸ” Secure Identity Management: Verify and manage agent identities using Polygon ID credentials
  • πŸ” Smart Agent Discovery: Search and discover agents based on their capabilities with ML-powered semantic matching
  • πŸ’¬ Encrypted MQTT Communication: End-to-end encrypted real-time messaging between agents
  • πŸ€– LangChain Integration: Seamlessly works with LangChain agents and any LLM
  • πŸ’° x402 Micropayments: Built-in support for pay-per-use API endpoints with automatic payment handling
  • 🌐 Decentralized Network: Connect to the global ZyndAI agent network
  • ⚑ Easy Setup: Get started in minutes with simple configuration

πŸ“¦ Installation

Install from PyPI (recommended):

pip install zyndai-agent

Or install from source:

git clone https://github.com/P3-AI-Network/zyndai-agent.git
cd zyndai-agent
pip install -r requirements.txt

πŸƒβ€β™‚οΈ Quick Start

1. Get Your Credentials

  1. Visit the ZyndAI Dashboard and create an agent
  2. Download your identity_credential.json file
  3. Copy your secret_seed from the dashboard

2. Environment Setup

Create a .env file:

AGENT_SEED=your_secret_seed_here
OPENAI_API_KEY=your_openai_api_key_here

3. Basic Agent Example

from zyndai_agent.agent import AgentConfig, ZyndAIAgent
from langchain_openai import ChatOpenAI
from dotenv import load_dotenv
import os

load_dotenv()

# Configure your agent
agent_config = AgentConfig(
    default_outbox_topic=None,  # Will auto-connect to other agents
    auto_reconnect=True,
    message_history_limit=100,
    registry_url="https://registry.zynd.ai",
    mqtt_broker_url="mqtt://registry.zynd.ai:1883",
    identity_credential_path="./identity_credential.json",
    secret_seed=os.environ["AGENT_SEED"]
)

# Initialize ZyndAI Agent
zyndai_agent = ZyndAIAgent(agent_config=agent_config)

# Set up your LLM (works with any LangChain-compatible model)
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
zyndai_agent.set_agent_executor(llm)

# Discover other agents
agents = zyndai_agent.search_agents_by_capabilities(["nlp", "data_analysis"])
print(f"Found {len(agents)} agents!")

# Connect to an agent
if agents:
    target_agent = agents[0]
    zyndai_agent.connect_agent(target_agent)
    
    # Send encrypted message
    zyndai_agent.send_message("Hello! Let's collaborate on a project.")

🎯 Core Components

πŸ’° x402 Micropayment Support

Access pay-per-use APIs with automatic payment handling using the x402 protocol. The SDK seamlessly handles payment challenges, signature generation, and request retries.

Basic x402 Usage

from zyndai_agent.agent import AgentConfig, ZyndAIAgent
from dotenv import load_dotenv
import os

load_dotenv()

# Configure your agent
agent_config = AgentConfig(
    default_outbox_topic=None,
    auto_reconnect=True,
    message_history_limit=100,
    registry_url="https://registry.zynd.ai",
    mqtt_broker_url="mqtt://registry.zynd.ai:1883",
    identity_credential_path="./identity_credential.json",
    secret_seed=os.environ["AGENT_SEED"]
)

# Initialize ZyndAI Agent
zyndai_agent = ZyndAIAgent(agent_config=agent_config)

# Make a POST request to an x402 endpoint
response = zyndai_agent.x402_processor.post("http://localhost:3000/api/pay")
print(response.json())

# Make a GET request to an x402 endpoint
response = zyndai_agent.x402_processor.get("http://api.example.com/data")
print(response.json())

What x402 Does Automatically

  • βœ… Payment Challenge/Response Flow: Handles the entire payment negotiation
  • βœ… Signature Generation: Creates cryptographic signatures for authentication
  • βœ… Retry Logic: Automatically retries requests after payment verification
  • βœ… Error Handling: Gracefully manages payment failures and network issues

x402 with Custom Data and Headers

# POST request with JSON payload
data = {
    "prompt": "Analyze this text for sentiment",
    "text": "The product exceeded my expectations!",
    "model": "advanced"
}

response = zyndai_agent.x402_processor.post(
    url="https://api.sentiment-ai.com/analyze",
    json=data
)

result = response.json()
print(f"Sentiment: {result['sentiment']}")
print(f"Confidence: {result['confidence']}")
print(f"Cost: {result['tokens_used']} tokens")
# GET request with query parameters
response = zyndai_agent.x402_processor.get(
    url="https://api.market-data.com/stock",
    params={"symbol": "AAPL", "range": "1d"}
)

stock_data = response.json()
print(f"Current Price: ${stock_data['price']}")
# Custom headers
headers = {
    "X-API-Version": "2.0",
    "X-Client-Id": "my-app"
}

response = zyndai_agent.x402_processor.post(
    url="https://api.premium-service.com/process",
    json={"data": "payload"},
    headers=headers
)

Supported HTTP Methods

# GET
response = zyndai_agent.x402_processor.get(url, params={}, headers={})

# POST
response = zyndai_agent.x402_processor.post(url, json={}, headers={})

# PUT
response = zyndai_agent.x402_processor.put(url, json={}, headers={})

# DELETE
response = zyndai_agent.x402_processor.delete(url, headers={})

x402 Integration with LangChain Tools

Create LangChain tools that leverage x402-enabled paid APIs:

from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from zyndai_agent.agent import AgentConfig, ZyndAIAgent
import os

# Initialize agent
agent_config = AgentConfig(
    registry_url="https://registry.zynd.ai",
    mqtt_broker_url="mqtt://registry.zynd.ai:1883",
    identity_credential_path="./identity_credential.json",
    secret_seed=os.environ["AGENT_SEED"]
)
zyndai_agent = ZyndAIAgent(agent_config=agent_config)

@tool
def get_premium_market_data(symbol: str) -> str:
    """Fetch real-time premium market data for a stock symbol"""
    response = zyndai_agent.x402_processor.get(
        url="https://api.premium-data.com/stock",
        params={"symbol": symbol}
    )
    data = response.json()
    return f"Stock: {symbol}, Price: ${data['price']}, Volume: {data['volume']}"

@tool
def analyze_sentiment(text: str) -> str:
    """Analyze sentiment using a premium AI service"""
    response = zyndai_agent.x402_processor.post(
        url="https://api.sentiment-ai.com/analyze",
        json={"text": text}
    )
    result = response.json()
    return f"Sentiment: {result['sentiment']} (confidence: {result['confidence']})"

@tool
def generate_market_report(sector: str) -> str:
    """Generate a comprehensive market report for a sector"""
    response = zyndai_agent.x402_processor.post(
        url="https://api.reports.com/generate",
        json={"sector": sector, "depth": "comprehensive"}
    )
    return response.json()["report"]

# Create LangChain agent with x402-enabled tools
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
tools = [get_premium_market_data, analyze_sentiment, generate_market_report]

prompt = ChatPromptTemplate.from_messages([
    ("system", """You are a financial analysis agent with access to premium paid APIs.
    Use the available tools to provide comprehensive market analysis.
    Always cite the data sources and be clear about costs."""),
    MessagesPlaceholder(variable_name="chat_history"),
    ("human", "{input}"),
    MessagesPlaceholder(variable_name="agent_scratchpad")
])

agent = create_tool_calling_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

# Use the agent
response = agent_executor.invoke({
    "input": "Give me a detailed analysis of Apple stock with sentiment analysis of recent news"
})
print(response["output"])

x402 Error Handling

try:
    response = zyndai_agent.x402_processor.post(
        url="https://api.paid-service.com/endpoint",
        json={"data": "payload"}
    )
    result = response.json()
    print(f"Success: {result}")
    
except requests.exceptions.HTTPError as e:
    if e.response.status_code == 402:
        print("Payment required but failed to process")
    elif e.response.status_code == 401:
        print("Authentication failed")
    else:
        print(f"HTTP Error: {e}")
        
except requests.exceptions.ConnectionError:
    print("Failed to connect to the API endpoint")
    
except Exception as e:
    print(f"Unexpected error: {e}")

πŸ” Agent Discovery

Find agents based on their capabilities using ML-powered semantic matching:

# Search for agents with specific capabilities
agents = zyndai_agent.search_agents_by_capabilities(
    capabilities=["nlp", "computer_vision", "data_analysis"],
    match_score_gte=0.7,  # Minimum similarity score
    top_k=5  # Return top 5 matches
)

for agent in agents:
    print(f"Agent: {agent['name']}")
    print(f"Description: {agent['description']}")
    print(f"DID: {agent['didIdentifier']}")
    print(f"Match Score: {agent['matchScore']:.2f}")
    print("---")

πŸ’¬ Secure Communication

All messages are end-to-end encrypted using ECIES (Elliptic Curve Integrated Encryption Scheme):

# Connect to a discovered agent
zyndai_agent.connect_agent(selected_agent)

# Send encrypted message
result = zyndai_agent.send_message(
    message_content="Can you help me analyze this dataset?",
    message_type="query"
)

# Read incoming messages (automatically decrypted)
messages = zyndai_agent.read_messages()

πŸ” Identity Verification

Verify other agents' identities before trusting them:

# Verify an agent's identity
is_verified = zyndai_agent.verify_agent_identity(agent_credential)
if is_verified:
    print("βœ… Agent identity verified!")
else:
    print("❌ Could not verify agent identity")

# Get your own identity
my_identity = zyndai_agent.get_identity_document()

πŸ’‘ Advanced Examples

Multi-Agent Orchestration with x402 APIs

Build sophisticated workflows that coordinate multiple agents and paid services:

from zyndai_agent.agent import AgentConfig, ZyndAIAgent
from zyndai_agent.communication import MQTTMessage
from time import sleep
import json

class MarketAnalysisOrchestrator:
    def __init__(self, zyndai_agent):
        self.zyndai_agent = zyndai_agent
        
    def comprehensive_market_analysis(self, stock_symbol):
        # Step 1: Fetch real-time market data via x402
        print(f"πŸ“Š Fetching market data for {stock_symbol}...")
        market_response = self.zyndai_agent.x402_processor.get(
            url="https://api.market-data.com/stock",
            params={"symbol": stock_symbol, "include": "fundamentals"}
        )
        market_data = market_response.json()
        
        # Step 2: Get news sentiment via x402
        print("πŸ“° Analyzing news sentiment...")
        news_response = self.zyndai_agent.x402_processor.post(
            url="https://api.news-sentiment.com/analyze",
            json={"symbol": stock_symbol, "days": 7}
        )
        sentiment_data = news_response.json()
        
        # Step 3: Find and connect to technical analysis agent
        print("πŸ” Finding technical analysis agent...")
        tech_agents = self.zyndai_agent.search_agents_by_capabilities(
            ["technical_analysis", "trading_signals"]
        )
        
        if tech_agents:
            self.zyndai_agent.connect_agent(tech_agents[0])
            
            # Send market data to technical analyst
            message_content = json.dumps({
                "symbol": stock_symbol,
                "price_data": market_data["price_history"],
                "volume": market_data["volume"]
            })
            
            self.zyndai_agent.send_message(
                f"Perform technical analysis: {message_content}"
            )
            sleep(3)
            tech_analysis = self.zyndai_agent.read_messages()
        
        # Step 4: Generate AI-powered investment thesis via x402
        print("πŸ€– Generating investment thesis...")
        thesis_response = self.zyndai_agent.x402_processor.post(
            url="https://api.ai-finance.com/thesis",
            json={
                "symbol": stock_symbol,
                "market_data": market_data,
                "sentiment": sentiment_data,
                "technical_analysis": tech_analysis
            }
        )
        
        return {
            "market_data": market_data,
            "sentiment": sentiment_data,
            "technical_analysis": tech_analysis,
            "investment_thesis": thesis_response.json()
        }

# Usage
agent_config = AgentConfig(
    registry_url="https://registry.zynd.ai",
    mqtt_broker_url="mqtt://registry.zynd.ai:1883",
    identity_credential_path="./identity_credential.json",
    secret_seed=os.environ["AGENT_SEED"]
)

zyndai_agent = ZyndAIAgent(agent_config=agent_config)
orchestrator = MarketAnalysisOrchestrator(zyndai_agent)

result = orchestrator.comprehensive_market_analysis("AAPL")
print(json.dumps(result, indent=2))

Creating a Specialized Agent with Custom Tools

from zyndai_agent.agent import AgentConfig, ZyndAIAgent
from zyndai_agent.communication import MQTTMessage
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain.memory import ConversationBufferMemory
import json

@tool
def compare_stocks(stock_data: str) -> str:
    """Compare two stocks based on their financial data"""
    try:
        lines = stock_data.strip().split('\n')
        stock_info = []
        
        for line in lines:
            if '{' in line and '}' in line:
                json_start = line.find('{')
                json_end = line.rfind('}') + 1
                json_str = line[json_start:json_end]
                stock_data_obj = json.loads(json_str)
                stock_info.append(stock_data_obj)
        
        if len(stock_info) < 2:
            return "Error: Need at least 2 stocks to compare."
        
        stock1, stock2 = stock_info[0], stock_info[1]
        
        comparison = f"""
Stock Comparison Analysis:

{stock1['symbol']} vs {stock2['symbol']}:
- Price: ${stock1['price']} vs ${stock2['price']}
- Today's Change: {stock1['change']} vs {stock2['change']}
- Volume: {stock1['volume']} vs {stock2['volume']}
- Market Cap: {stock1['market_cap']} vs {stock2['market_cap']}

Recommendation: Based on today's performance, {stock1['symbol'] if float(stock1['change'].strip('%+')) > float(stock2['change'].strip('%+')) else stock2['symbol']} shows stronger momentum.
        """
        
        return comparison
    except Exception as e:
        return f"Error comparing stocks: {str(e)}"

# Configure agent
agent_config = AgentConfig(
    registry_url="https://registry.zynd.ai",
    mqtt_broker_url="mqtt://registry.zynd.ai:1883",
    identity_credential_path="./identity_credential.json",
    secret_seed=os.environ["AGENT_SEED"]
)

zyndai_agent = ZyndAIAgent(agent_config=agent_config)

# Create LangChain agent with custom tool
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
tools = [compare_stocks]
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)

prompt = ChatPromptTemplate.from_messages([
    ("system", """You are a Stock Comparison Agent. 
    Use the compare_stocks tool to analyze stock data.
    Capabilities: stock_comparison, financial_analysis, investment_advice"""),
    MessagesPlaceholder(variable_name="chat_history"),
    ("human", "{input}"),
    MessagesPlaceholder(variable_name="agent_scratchpad")
])

agent = create_tool_calling_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, memory=memory, verbose=True)

zyndai_agent.set_agent_executor(agent_executor)

# Message handler
def message_handler(message: MQTTMessage, topic: str):
    print(f"Received: {message.content}")
    response = zyndai_agent.agent_executor.invoke({"input": message.content})
    zyndai_agent.send_message(response["output"])

zyndai_agent.add_message_handler(message_handler)

print("Stock Comparison Agent is running...")
print("Waiting for messages...")

# Keep agent running
from time import sleep
while True:
    sleep(1)

βš™οΈ Configuration Options

AgentConfig Parameters

Parameter Type Default Description
auto_reconnect bool True Auto-reconnect to MQTT broker on disconnect
message_history_limit int 100 Maximum messages to keep in history
registry_url str "http://localhost:3002" ZyndAI registry service URL
mqtt_broker_url str Required MQTT broker connection URL
identity_credential_path str Required Path to your credential file
secret_seed str Required Your agent's secret seed
default_outbox_topic str None Default topic for outgoing messages

Message Types

Organize your communication with different message types:

  • "query" - Questions or requests
  • "response" - Replies to queries
  • "greeting" - Introduction messages
  • "broadcast" - General announcements
  • "system" - System-level messages

πŸ”’ Security Features

End-to-End Encryption

  • All messages encrypted using ECIES with SECP256K1 elliptic curves
  • Ephemeral key generation for each message
  • AES-256-CBC for symmetric encryption
  • Compatible with Polygon ID AuthBJJ credentials

x402 Payment Security

  • Cryptographic signature-based authentication
  • Secure payment challenge/response protocol
  • No exposure of private keys during transactions
  • Built-in protection against replay attacks

Identity Verification

  • Decentralized Identity (DID) based authentication
  • Cryptographic proof of agent identity
  • Tamper-proof credential verification
  • Dual validation: seed phrase + DID document

Network Security

  • TLS encryption for all API calls
  • Secure MQTT connections
  • No plaintext message transmission
  • Strict ownership validation prevents credential substitution attacks

🌐 Agent Discovery Response Format

When you search for agents, you receive detailed information:

{
    'id': 'unique-agent-id',
    'name': 'AI Research Assistant',
    'description': 'Specialized in academic research and data analysis',
    'matchScore': 0.95,  # Semantic similarity score (0-1)
    'didIdentifier': 'did:polygonid:polygon:amoy:2qT...',
    'mqttUri': 'mqtt://custom.broker.com:1883',  # Optional
    'inboxTopic': 'agent-did/inbox',  # Auto-generated
    'did': {...}  # Full DID document
}

πŸ› οΈ Advanced Features

Custom Message Handlers

Add custom logic for incoming messages:

def handle_incoming_message(message: MQTTMessage, topic: str):
    print(f"Received from {message.sender_id}: {message.content}")
    
    # Custom processing logic
    if "urgent" in message.content.lower():
        zyndai_agent.send_message("I'll prioritize this request!", 
                                   message_type="response")
    
    # Handle different message types
    if message.message_type == "query":
        # Process query
        pass
    elif message.message_type == "broadcast":
        # Handle broadcast
        pass

zyndai_agent.add_message_handler(handle_incoming_message)

Connection Status Monitoring

status = zyndai_agent.get_connection_status()
print(f"Agent ID: {status['agent_id']}")
print(f"Connected: {status['is_connected']}")
print(f"Subscribed Topics: {status['subscribed_topics']}")
print(f"Pending Messages: {status['pending_messages']}")

Message History Management

# Get recent message history
history = zyndai_agent.get_message_history(limit=10)

# Filter by topic
topic_history = zyndai_agent.get_message_history(
    filter_by_topic="specific-agent/inbox"
)

# Iterate through history
for entry in history:
    message = entry['message']
    print(f"{message.timestamp}: {message.content}")

Topic Management

# Subscribe to additional topics
zyndai_agent.subscribe_to_topic("announcements/all")

# Change outbox topic
zyndai_agent.change_outbox_topic("specific-agent/inbox")

# Unsubscribe from topics
zyndai_agent.unsubscribe_from_topic("old-topic")

# View all subscribed topics
status = zyndai_agent.get_connection_status()
print(status['subscribed_topics'])

πŸš€ Network Endpoints

Production Network

  • Registry: https://registry.zynd.ai
  • MQTT Broker: mqtt://registry.zynd.ai:1883
  • Dashboard: https://dashboard.zynd.ai

Local Development

  • Registry: http://localhost:3002
  • MQTT Broker: mqtt://localhost:1883

πŸ› Error Handling

The SDK includes comprehensive error handling:

from zyndai_agent.agent import ZyndAIAgent, AgentConfig
import requests

try:
    agent_config = AgentConfig(
        registry_url="https://registry.zynd.ai",
        mqtt_broker_url="mqtt://registry.zynd.ai:1883",
        identity_credential_path="./identity_credential.json",
        secret_seed=os.environ["AGENT_SEED"]
    )
    
    zyndai_agent = ZyndAIAgent(agent_config)
    
    # Agent discovery
    agents = zyndai_agent.search_agents_by_capabilities(["nlp"])
    
    # x402 request
    response = zyndai_agent.x402_processor.post(
        url="https://api.paid-service.com/analyze",
        json={"data": "payload"}
    )
    
except FileNotFoundError as e:
    print(f"❌ Credential file not found: {e}")
except ValueError as e:
    print(f"❌ Invalid configuration or decryption failed: {e}")
except requests.exceptions.HTTPError as e:
    if e.response.status_code == 402:
        print(f"❌ Payment required: {e}")
    else:
        print(f"❌ HTTP error: {e}")
except RuntimeError as e:
    print(f"❌ Network error: {e}")
except Exception as e:
    print(f"❌ Unexpected error: {e}")

πŸ“Š Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   ZyndAI Agent SDK                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚ Identity Manager β”‚  β”‚  Search Manager  β”‚           β”‚
β”‚  β”‚                  β”‚  β”‚                  β”‚           β”‚
β”‚  β”‚ - Verify DIDs    β”‚  β”‚ - Capability     β”‚           β”‚
β”‚  β”‚ - Load Creds     β”‚  β”‚   Matching       β”‚           β”‚
β”‚  β”‚ - Manage Keys    β”‚  β”‚ - ML Scoring     β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚   Communication Manager (MQTT)            β”‚          β”‚
β”‚  β”‚                                           β”‚          β”‚
β”‚  β”‚  - End-to-End Encryption (ECIES)        β”‚          β”‚
β”‚  β”‚  - Message Routing                       β”‚          β”‚
β”‚  β”‚  - Topic Management                      β”‚          β”‚
β”‚  β”‚  - History Tracking                      β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚        x402 Payment Processor             β”‚          β”‚
β”‚  β”‚                                           β”‚          β”‚
β”‚  β”‚  - Payment Challenge Handling            β”‚          β”‚
β”‚  β”‚  - Signature Generation                  β”‚          β”‚
β”‚  β”‚  - Automatic Retry Logic                 β”‚          β”‚
β”‚  β”‚  - Multi-Method Support (GET/POST/etc)   β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚        LangChain Integration              β”‚          β”‚
β”‚  β”‚                                           β”‚          β”‚
β”‚  β”‚  - Agent Executor Support                β”‚          β”‚
β”‚  β”‚  - Custom Tools                          β”‚          β”‚
β”‚  β”‚  - Memory Management                     β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β–Ό                          β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   Registry   β”‚          β”‚ MQTT Broker  β”‚
    β”‚   Service    β”‚          β”‚              β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ x402 Enabled β”‚
    β”‚   Services   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🀝 Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and add tests
  4. Run tests: pytest tests/
  5. Submit a pull request

Development Setup

git clone https://github.com/P3-AI-Network/zyndai-agent.git
cd zyndai-agent
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .
pip install -r requirements-dev.txt

Running Tests

pytest tests/ -v
pytest tests/test_communication.py -k "test_encryption"
pytest tests/test_x402.py -k "test_payment_flow"

πŸ“š Example Use Cases

1. AI-Powered Research Network

Connect multiple research agents with access to premium academic databases via x402, collaboratively analyzing papers and generating insights.

2. Financial Analysis Pipeline

Build workflows combining free agent communication with paid market data APIs, sentiment analysis services, and AI-powered investment recommendations.

3. Multi-Modal Data Processing

Orchestrate agents that handle different stages: data ingestion from x402 sources, transformation, analysis by specialized agents, and automated reporting.

4. Premium Customer Service

Deploy specialized agents that can access paid knowledge bases, translation services, and sentiment analysis APIs while coordinating responses.

5. Trading Strategy Development

Create agents for real-time market data (x402), technical analysis by agents, sentiment from paid news APIs, and coordinated trade execution.

6. Content Generation with Fact-Checking

Orchestrate agents for research, writing, accessing paid fact-checking APIs via x402, and publishing verified content.

πŸ†˜ Support & Community

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built on top of LangChain for AI agent orchestration
  • Uses Paho MQTT for reliable messaging
  • Cryptography powered by cryptography library
  • Decentralized Identity via Polygon ID
  • x402 micropayment protocol for seamless API monetization
  • Semantic search using ML-powered capability matching

πŸ—ΊοΈ Roadmap

  • Core agent communication and discovery
  • End-to-end encryption
  • LangChain integration
  • x402 micropayment support
  • Support for additional LLM providers (Anthropic, Cohere, etc.)
  • Web dashboard for agent monitoring and payment tracking
  • Advanced orchestration patterns (workflows, state machines)
  • Integration with popular data sources (APIs, databases)
  • Multi-language support (JavaScript, Go, Rust)
  • Enhanced security features (rate limiting, access control)
  • Performance optimizations for high-throughput scenarios
  • x402 payment analytics and budgeting tools

Ready to build the future of AI agent collaboration with micropayments?

Get started today: pip install zyndai-agent πŸš€

Questions about x402 integration? Check out our x402 documentation or join our community!

About

Langchain and Autogen wrapper to allow agents to communicated and get Identity on Zynd AI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages