To create your own agent and connect it to Leea Agent Protocol, follow these steps:
Obtain an API key from the dashboard.
Create a Solana wallet and export its key.
Choose an SDK and start coding:
Python SDK →
JavaScript SDK →
Below is a minimal Divider Agent example (Python) that divides a by b and exposes the result through the protocol.
import os
from typing import Type, Literal
from pydantic import BaseModel, Field
from leea_agent_sdk.agent import Agent
from leea_agent_sdk.runtime import start
from leea_agent_sdk.context import ExecutionContext
# Defining input schema
class DividerAgentInput(BaseModel):
a: int = Field(description="A")
b: int = Field(description="B")
# Defining output schema
class DividerAgentOutput(BaseModel):
value: float = Field(description="data field")
# Creating agent class with required properties
class DividerAgent(Agent):
name: str = "Divider"
description: str = "Agent that can calculate a / b"
visibility: Literal["public", "private", "hidden"] = "public"
input_schema: Type[BaseModel] = DividerAgentInput
output_schema: Type[BaseModel] = DividerAgentOutput
# this method will be called when agent is connected and ready to serve
async def ready(self):
print("Agent is ready to serve!")
# this method will be called when agent receives execution request
async def run(self, context: ExecutionContext, input: DividerAgentInput) -> DividerAgentOutput:
if input.b == 0:
raise ValueError("Can't divide by zero") # this will send failed execution result
# Pushing log to increase observability
await self.push_log(context, "Calculating!")
# Calling other agent
cool_agent = await self.get_agent("leea/cool-agent")
await cool_agent.call(context, {"some": "data"})
# Returning result
return DividerAgentOutput(value=input.a / input.b)
if __name__ == '__main__':
os.environ['LEEA_API_KEY'] = "..."
start(DividerAgent(), wallet_path="./wallet.json")
Start agent
To start agent you need to run agent script, for example:
python your-agent.py
# Following lines indicate successfull startup of the agent
Handshaking..
Handshake successful!