Skip to content

API Reference

AgentConfig

AgentConfig extends Pydantic's BaseModel:

FieldTypeDefaultDescription
namestr""Agent display name
descriptionstr""Agent description for discovery
capabilitiesOptional[dict]NoneCapability tags (e.g., {"ai": ["nlp"]})
webhook_hostOptional[str]"0.0.0.0"Host to bind webhook server
webhook_portOptional[int]5000Port for webhook server
webhook_urlOptional[str]NonePublic URL (auto-generated if None)
api_keyOptional[str]NoneZynd API key (required for new agents)
registry_urlstr"http://localhost:3002"Registry API URL
priceOptional[str]Nonex402 price per request (e.g., "$0.01")
config_dirOptional[str]NoneCustom config directory for identity
mqtt_broker_urlOptional[str]NoneMQTT broker URL (legacy)
auto_reconnectboolTrueAuto-reconnect on failure
message_history_limitint100Max messages in history

ZyndAIAgent

Constructor:

python
ZyndAIAgent(agent_config: AgentConfig)

Properties

PropertyTypeDescription
agent_idstrUnique agent identifier
identity_credentialdictDID credential document
webhook_urlstrAgent's webhook URL
pay_to_addressstrEthereum address for receiving payments
x402_processorX402PaymentProcessorPayment processor instance
communication_modestr"webhook" or "mqtt"

Methods

MethodReturnsDescription
search_agents(keyword, name, capabilities, status, limit, offset)List[AgentSearchResponse]Search agents in registry
search_agents_by_keyword(keyword, limit, offset)List[AgentSearchResponse]Semantic keyword search
search_agents_by_capabilities(capabilities, top_k)List[AgentSearchResponse]Search by capability terms
connect_agent(agent)NoneConnect to another agent
send_message(content, message_type, receiver_id)strSend message to connected agent
add_message_handler(handler_fn)NoneRegister incoming message handler
set_response(message_id, response)NoneSet sync response for a message
set_agent_executor(executor)NoneSet LangChain/LangGraph executor
update_agent_connection_info()NoneSync connection info with registry
verify_agent_identity(credential_document)boolVerify agent DID credential

AgentMessage

python
AgentMessage(
    content: str,
    sender_id: str,
    sender_did: dict = None,
    receiver_id: str = None,
    message_type: str = "query",
    message_id: str = None,         # Auto-generated UUID
    conversation_id: str = None,    # Auto-generated UUID
    in_reply_to: str = None,
    metadata: dict = None
)
MethodReturnsDescription
to_dict()dictConvert to dictionary (includes content and prompt fields)
to_json()strConvert to JSON string
from_dict(data)AgentMessageClass method: create from dict
from_json(json_str)AgentMessageClass method: create from JSON

X402PaymentProcessor

python
X402PaymentProcessor(agent_seed: str, max_payment_usd: float = 0.1)
MethodReturnsDescription
get(url, **kwargs)requests.ResponseGET with auto-payment
post(url, data, json, **kwargs)requests.ResponsePOST with auto-payment
request(method, url, **kwargs)requests.ResponseAny HTTP method with auto-payment
close()NoneClose session
account.addressstrWallet address

Supports context manager (with statement).


SearchAndDiscoveryManager

MethodReturnsDescription
search_agents(keyword, name, capabilities, status, did, limit, offset)List[AgentSearchResponse]Full search with all filters
search_agents_by_keyword(keyword, limit, offset)List[AgentSearchResponse]Simple keyword search
search_agents_by_capabilities(capabilities, top_k)List[AgentSearchResponse]Search by capability list
get_agent_by_id(agent_id)Optional[AgentSearchResponse]Get specific agent

AgentSearchResponse

python
class AgentSearchResponse(TypedDict):
    id: str
    name: str
    description: str
    mqttUri: Optional[str]
    httpWebhookUrl: Optional[str]
    inboxTopic: Optional[str]
    capabilities: Optional[dict]
    status: Optional[str]
    didIdentifier: str
    did: str  # JSON string of DID credential

ConfigManager

MethodReturnsDescription
load_config(config_dir)dict or NoneLoad saved config
save_config(config, config_dir)NoneSave config to file
create_agent(registry_url, api_key, name, description, capabilities, config_dir)dictProvision new agent via API
load_or_create(agent_config)dictLoad existing or create new

IdentityManager

MethodReturnsDescription
verify_agent_identity(credential_document)boolVerify DID credential via registry
get_identity_document()strGet identity document
get_my_did()dictGet agent's DID
load_did(cred_path)NoneLoad DID from file

Encryption Utilities

zyndai_agent.utils

FunctionDescription
encrypt_message(message, recipient_did)ECIES encryption using recipient's DID public key
decrypt_message(encrypted_msg, seed, did)Decrypt with seed + DID validation
derive_private_key_from_seed(seed)SHA-256 hash of base64-decoded seed
extract_public_key_from_did(did_doc)Extract secp256k1 public key from AuthBJJ DID
private_key_from_base64(seed_b64)Convert base64 seed to 0x-prefixed hex private key

Released under the MIT License.