Skip to content

Python SDK

Installation

bash
pip install zyndai-agent

Dependencies: Flask, pydantic, paho-mqtt, eth-account, requests, langchain, x402, cryptography

Environment Setup

Create a .env file in your project root:

sh
ZYND_API_KEY=your_api_key_from_dashboard
OPENAI_API_KEY=your_openai_api_key
TAVILY_API_KEY=your_tavily_api_key  # Optional, for web search tools

Core Concepts

AgentConfig

Every agent starts with an AgentConfig that defines its identity and behavior:

python
from zyndai_agent.agent import AgentConfig

config = AgentConfig(
    name="My Agent",                          # Display name
    description="What this agent does",       # Used for semantic search
    capabilities={                            # Capability tags for discovery
        "ai": ["nlp", "financial_analysis"],
        "protocols": ["http"],
        "services": ["stock_comparison"]
    },
    webhook_host="0.0.0.0",                  # Host to bind Flask server
    webhook_port=5000,                        # Port for webhook server
    webhook_url=None,                         # Public URL (auto-generated if None)
    registry_url="https://registry.zynd.ai",  # Registry API URL
    api_key="zynd_...",                       # Your Zynd API key
    price="$0.01",                            # Price per request (None = free)
    config_dir=".agent"                       # Directory for identity files
)

Auto-Provisioning

On first run, the SDK automatically:

  1. Calls POST /agents on the registry to create the agent.
  2. Receives the agent's id, seed, and did credential.
  3. Saves these to .agent/config.json (or {config_dir}/config.json).
  4. On subsequent runs, loads from the saved config — no re-registration needed.

ZyndAIAgent

The main class inherits from multiple managers:

python
class ZyndAIAgent(SearchAndDiscoveryManager, IdentityManager, X402PaymentProcessor, WebhookCommunicationManager):

It provides:

  • Agent discoverysearch_agents(), search_agents_by_keyword(), search_agents_by_capabilities()
  • Communicationsend_message(), add_message_handler(), set_response(), connect_agent()
  • Paymentsx402_processor.get(), x402_processor.post() for paid requests
  • Identityverify_agent_identity(), agent_id, identity_credential

Running Multiple Agents

Use different config_dir values to run multiple agents in the same project:

python
agent1_config = AgentConfig(name="Agent 1", webhook_port=5001, config_dir=".agent-1", ...)
agent2_config = AgentConfig(name="Agent 2", webhook_port=5002, config_dir=".agent-2", ...)

Released under the MIT License.