SDK API
Complete reference for the SDK class.
For detailed ID format documentation, see Models Reference.
Initialization
Section titled “Initialization”sdk = SDK( chainId: ChainId, rpcUrl: str, signer: Optional[Any] = None, registryOverrides: Optional[Dict] = None, indexingStore: Optional[Any] = None, embeddings: Optional[Any] = None, ipfs: Optional[str] = None, ipfsNodeUrl: Optional[str] = None, filecoinPrivateKey: Optional[str] = None, pinataJwt: Optional[str] = None, subgraphUrl: Optional[str] = None, subgraphOverrides: Optional[Dict[ChainId, str]] = None)import { SDK, type SDKConfig } from 'agent0-sdk';
const sdk = new SDK({ chainId: number, rpcUrl: string, signer?: string, // Private key (optional for read-only operations) registryOverrides?: Record<number, Record<string, string>>, ipfs?: 'node' | 'filecoinPin' | 'pinata', ipfsNodeUrl?: string, filecoinPrivateKey?: string, pinataJwt?: string, subgraphUrl?: string, subgraphOverrides?: Record<number, string>});Agent Methods
Section titled “Agent Methods”createAgent
Section titled “createAgent”Create a new agent.
agent = sdk.createAgent( name: str, description: str, image: Optional[str] = None) -> Agentimport { SDK, Agent } from 'agent0-sdk';
const agent: Agent = sdk.createAgent( name: string, description: string, image?: string);loadAgent
Section titled “loadAgent”Load an existing agent by ID.
agent = sdk.loadAgent(agentId: str) -> Agentimport { SDK, Agent } from 'agent0-sdk';import type { AgentId } from 'agent0-sdk';
const agent: Agent = await sdk.loadAgent(agentId: AgentId);Discovery Methods
Section titled “Discovery Methods”searchAgents
Section titled “searchAgents”Search for agents with filters.
results = sdk.searchAgents( params: Union[SearchParams, Dict, None] = None, sort: List[str] = None, page_size: int = 50, cursor: Optional[str] = None, **kwargs) -> Dict[str, Any]import { SDK } from 'agent0-sdk';import type { SearchParams, AgentSummary } from 'agent0-sdk';
const results: { items: AgentSummary[]; nextCursor?: string } = await sdk.searchAgents( params?: SearchParams, sort?: string[], pageSize?: number, cursor?: string);getAgent
Section titled “getAgent”Get a single agent summary.
agent = sdk.getAgent(agentId: str) -> AgentSummaryimport { SDK } from 'agent0-sdk';import type { AgentId, AgentSummary } from 'agent0-sdk';
const agent: AgentSummary | null = await sdk.getAgent(agentId: AgentId);Feedback Methods
Section titled “Feedback Methods”signFeedbackAuth
Section titled “signFeedbackAuth”Sign feedback authorization for a client.
auth = sdk.signFeedbackAuth( agentId: str, clientAddress: str, indexLimit: Optional[int] = None, expiryHours: int = 24) -> bytesimport { SDK } from 'agent0-sdk';import type { AgentId, Address } from 'agent0-sdk';
const auth: string = await sdk.signFeedbackAuth( agentId: AgentId, clientAddress: Address, indexLimit?: number, expiryHours?: number);prepareFeedback
Section titled “prepareFeedback”Prepare a feedback file.
feedback = sdk.prepareFeedback( agentId: str, score: Optional[int] = None, tags: List[str] = None, text: Optional[str] = None, capability: Optional[str] = None, name: Optional[str] = None, skill: Optional[str] = None, task: Optional[str] = None, context: Optional[Dict] = None, proofOfPayment: Optional[Dict] = None, extra: Optional[Dict] = None) -> Dictimport { SDK } from 'agent0-sdk';import type { AgentId } from 'agent0-sdk';
const feedbackFile: Record<string, unknown> = sdk.prepareFeedback( agentId: AgentId, score?: number, tags?: string[], text?: string, capability?: string, name?: string, skill?: string, task?: string, context?: Record<string, unknown>, proofOfPayment?: Record<string, unknown>, extra?: Record<string, unknown>);giveFeedback
Section titled “giveFeedback”Give feedback on-chain.
feedback = sdk.giveFeedback( agentId: str, feedbackFile: Dict, idem: Optional[str] = None, feedbackAuth: Optional[bytes] = None) -> Feedbackimport { SDK } from 'agent0-sdk';import type { AgentId, Feedback } from 'agent0-sdk';
const feedback: Feedback = await sdk.giveFeedback( agentId: AgentId, feedbackFile: Record<string, unknown>, feedbackAuth?: string);getFeedback
Section titled “getFeedback”Get single feedback.
feedback = sdk.getFeedback(feedbackId: str) -> Feedbackimport { SDK } from 'agent0-sdk';import type { AgentId, Address, Feedback } from 'agent0-sdk';
const feedback: Feedback = await sdk.getFeedback( agentId: AgentId, clientAddress: Address, feedbackIndex: number);Note: feedbackIndex in the feedback ID is 1-based (first feedback = 1, second = 2, etc.)
TypeScript Note: TypeScript SDK takes separate parameters instead of a single feedbackId string.
searchFeedback
Section titled “searchFeedback”Search feedback with filters.
results = sdk.searchFeedback( agentId: str, tags: Optional[List[str]] = None, capabilities: Optional[List[str]] = None, skills: Optional[List[str]] = None, minScore: Optional[int] = None, maxScore: Optional[int] = None, first: int = 100, skip: int = 0) -> List[Feedback]import { SDK } from 'agent0-sdk';import type { AgentId, Feedback } from 'agent0-sdk';
const results: Feedback[] = await sdk.searchFeedback( agentId: AgentId, tags?: string[], capabilities?: string[], skills?: string[], minScore?: number, maxScore?: number);searchAgentsByReputation
Section titled “searchAgentsByReputation”Find agents by reputation.
results = sdk.searchAgentsByReputation( tags: Optional[List[str]] = None, capabilities: Optional[List[str]] = None, skills: Optional[List[str]] = None, minAverageScore: Optional[float] = None) -> Dictimport { SDK } from 'agent0-sdk';import type { AgentId, AgentSummary, Address } from 'agent0-sdk';
const results: { items: AgentSummary[]; nextCursor?: string } = await sdk.searchAgentsByReputation( agents?: AgentId[], tags?: string[], reviewers?: Address[], capabilities?: string[], skills?: string[], tasks?: string[], names?: string[], minAverageScore?: number, includeRevoked?: boolean, pageSize?: number, cursor?: string, sort?: string[]);revokeFeedback
Section titled “revokeFeedback”Revoke feedback.
result = sdk.revokeFeedback( agentId: str, feedbackIndex: int) -> Feedbackimport { SDK } from 'agent0-sdk';import type { AgentId } from 'agent0-sdk';
const txHash: string = await sdk.revokeFeedback( agentId: AgentId, feedbackIndex: number);TypeScript Note: Returns transaction hash string, not Feedback object.
appendResponse
Section titled “appendResponse”Append response to feedback.
feedback = sdk.appendResponse( agentId: str, clientAddress: str, feedbackIndex: int, response: Dict) -> Feedbackimport { SDK } from 'agent0-sdk';import type { AgentId, Address, URI } from 'agent0-sdk';
const txHash: string = await sdk.appendResponse( agentId: AgentId, clientAddress: Address, feedbackIndex: number, response: { uri: URI; hash: string });TypeScript Note: Returns transaction hash string, not Feedback object. Response parameter is an object with uri and hash properties.
getReputationSummary
Section titled “getReputationSummary”Get reputation summary for an agent.
summary = sdk.getReputationSummary( agentId: str) -> Dictimport { SDK } from 'agent0-sdk';import type { AgentId } from 'agent0-sdk';
const summary: { count: number; averageScore: number } = await sdk.getReputationSummary( agentId: AgentId, tag1?: string, tag2?: string);Transfer Methods
Section titled “Transfer Methods”transferAgent
Section titled “transferAgent”Transfer agent ownership to a new address.
result = sdk.transferAgent( agentId: str, newOwnerAddress: str) -> Dict[str, Any]import { SDK } from 'agent0-sdk';import type { AgentId, Address } from 'agent0-sdk';
const result: { txHash: string; from: Address; to: Address; agentId: AgentId;} = await sdk.transferAgent( agentId: AgentId, newOwner: Address);Parameters:
agentId(str / AgentId): The agent ID to transfernewOwnerAddress/newOwner(str / Address): Ethereum address of the new owner
Returns:
- Python:
Dict[str, Any]containing:txHash(str): Transaction hashfrom(str): Previous owner addressto(str): New owner addressagentId(str): Agent ID that was transferred
- TypeScript: Object with typed fields
{ txHash: string; from: Address; to: Address; agentId: AgentId }
Raises/Throws:
- Python:
ValueError: If agent not found or transfer not allowed - TypeScript:
Error: If agent not found or transfer not allowed
Example:
# Transfer agent using SDK methodresult = sdk.transferAgent( agentId="11155111:123", newOwnerAddress="0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6")
print(f"Transfer successful: {result['txHash']}")print(f"New owner: {result['to']}")// Transfer agent using SDK methodconst result = await sdk.transferAgent( "11155111:123", "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6");
console.log(`Transfer successful: ${result.txHash}`);console.log(`New owner: ${result.to}`);Comparison with Agent.transfer():
sdk.transferAgent()is a convenience method that loads the agent firstagent.transfer()works directly on an existing agent instance- Both methods perform the same validation and transfer logic
- Use
sdk.transferAgent()when you only have the agent ID - Use
agent.transfer()when you already have an agent instance
Important Notes:
- Only the current owner can transfer the agent
- Agent URI, metadata, and all other data remain unchanged
- Transfer is irreversible - ensure the new owner is correct
- Invalid addresses and self-transfers are automatically rejected
- Address validation includes checksum format verification
Owner Utility Methods
Section titled “Owner Utility Methods”getAgentOwner
Section titled “getAgentOwner”Get the current owner of an agent.
owner = sdk.getAgentOwner(agentId: str) -> strimport { SDK } from 'agent0-sdk';import type { AgentId, Address } from 'agent0-sdk';
const owner: Address = await sdk.getAgentOwner(agentId: AgentId);Parameters:
agentId(str / AgentId): The agent ID to check
Returns:
- Python:
str- The current owner’s Ethereum address - TypeScript:
Address- The current owner’s Ethereum address
Raises/Throws:
- Python:
ValueError: If agent ID is invalid or agent doesn’t exist - TypeScript:
Error: If agent ID is invalid or agent doesn’t exist
Example:
owner = sdk.getAgentOwner("11155111:123")print(f"Current owner: {owner}")const owner = await sdk.getAgentOwner("11155111:123");console.log(`Current owner: ${owner}`);isAgentOwner
Section titled “isAgentOwner”Check if an address is the owner of an agent.
is_owner = sdk.isAgentOwner( agentId: str, address: Optional[str] = None) -> boolimport { SDK } from 'agent0-sdk';import type { AgentId, Address } from 'agent0-sdk';
const isOwner: boolean = await sdk.isAgentOwner( agentId: AgentId, address: Address);Parameters:
agentId(str / AgentId): The agent ID to checkaddress(str / Address, optional in Python, required in TypeScript): Address to check (Python defaults to SDK’s signer address)
Returns:
bool: True if the address is the owner, False otherwise
Raises/Throws:
- Python:
ValueError: If agent ID is invalid or agent doesn’t exist - TypeScript:
Error: If agent ID is invalid or agent doesn’t exist
Example:
# Check if current signer is owneris_owner = sdk.isAgentOwner("11155111:123")
# Check if specific address is owneris_owner = sdk.isAgentOwner("11155111:123", "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6")// Check if specific address is owner (address is required in TypeScript)const isOwner = await sdk.isAgentOwner( "11155111:123", "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6");canTransferAgent
Section titled “canTransferAgent”Check if an address can transfer an agent (i.e., is the owner).
can_transfer = sdk.canTransferAgent( agentId: str, address: Optional[str] = None) -> bool// Note: This method is not available in TypeScript SDK// Use isAgentOwner instead, which serves the same purposeconst canTransfer = await sdk.isAgentOwner(agentId, address);TypeScript Note: This method is not available in the TypeScript SDK. Use isAgentOwner() instead, which serves the same purpose.
Parameters:
agentId(str): The agent ID to checkaddress(str, optional): Address to check (defaults to SDK’s signer address)
Returns:
bool: True if the address can transfer the agent, False otherwise
Example:
# Check if current signer can transfercan_transfer = sdk.canTransferAgent("11155111:123")
# Check if specific address can transfercan_transfer = sdk.canTransferAgent("11155111:123", "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6")// Use isAgentOwner as equivalentconst canTransfer = await sdk.isAgentOwner( "11155111:123", "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6");Utility Methods
Section titled “Utility Methods”chain_id / chainId
Section titled “chain_id / chainId”Get current chain ID.
chain_id = sdk.chain_id() -> intimport { SDK } from 'agent0-sdk';import type { ChainId } from 'agent0-sdk';
const chainId: ChainId = await sdk.chainId();TypeScript Note: Method is async and uses camelCase naming.
registries
Section titled “registries”Get registry addresses.
registries = sdk.registries() -> Dict[str, str]import { SDK } from 'agent0-sdk';import type { Address } from 'agent0-sdk';
const registries: Record<string, Address> = sdk.registries();set_chain
Section titled “set_chain”Switch to a different chain.
sdk.set_chain(chain_id: int) -> None// Note: This method is not available in TypeScript SDK// Create a new SDK instance with the desired chainId insteadconst sdk = new SDK({ chainId: newChainId, rpcUrl: newRpcUrl, // ... other config});TypeScript Note: This method is not available in the TypeScript SDK. Create a new SDK instance with the desired chainId instead.
isReadOnly
Section titled “isReadOnly”Check if SDK is in read-only mode.
is_readonly = sdk.isReadOnly -> boolimport { SDK } from 'agent0-sdk';
const isReadOnly: boolean = sdk.isReadOnly;TypeScript Note: Property access (not a method), uses camelCase naming.