Agent API
Complete reference for the Agent class.
Properties
Section titled “Properties”All properties are read-only. Use setter methods to modify values.
# Identityagent.agentId # Optional[str]agent.agentURI # Optional[str]agent.name # stragent.description # stragent.image # Optional[str]
# Statusagent.active # boolagent.x402support # boolagent.updatedAt # int
# Walletagent.walletAddress # Optional[str]agent.walletChainId # Optional[int]
# Endpointsagent.mcpEndpoint # Optional[str]agent.a2aEndpoint # Optional[str]agent.ensEndpoint # Optional[str]
# Capabilitiesagent.mcpTools # Optional[List[str]]agent.mcpPrompts # Optional[List[str]]agent.mcpResources # Optional[List[str]]agent.a2aSkills # Optional[List[str]]
# Listsagent.endpoints # List[Endpoint]agent.trustModels # List[TrustModel]agent.metadata # Dict[str, Any]agent.owners # List[str]agent.operators # List[str]import { Agent } from 'agent0-sdk';import type { AgentId, Address, URI } from 'agent0-sdk';
// Identityagent.agentId // AgentId | undefinedagent.agentURI // URI | undefinedagent.name // stringagent.description // stringagent.image // URI | undefined
// Statusagent.active // booleanagent.x402support // boolean// Note: updatedAt is in registrationFile.updatedAt
// Walletagent.walletAddress // Address | undefinedagent.walletChainId // number | undefined
// Endpointsagent.mcpEndpoint // string | undefinedagent.a2aEndpoint // string | undefinedagent.ensEndpoint // string | undefined
// Capabilitiesagent.mcpTools // string[] | undefinedagent.mcpPrompts // string[] | undefinedagent.mcpResources // string[] | undefinedagent.a2aSkills // string[] | undefined
// Access via getRegistrationFile()const regFile = agent.getRegistrationFile();regFile.endpoints // Endpoint[]regFile.trustModels // (TrustModel | string)[]regFile.metadata // Record<string, unknown>regFile.owners // Address[]regFile.operators // Address[]Endpoint Methods
Section titled “Endpoint Methods”setMCP
Section titled “setMCP”Set MCP endpoint.
agent = agent.setMCP( endpoint: str, version: str = "2025-06-18", auto_fetch: bool = True) -> Agentimport { Agent } from 'agent0-sdk';
const agent: Agent = await agent.setMCP( endpoint: string, version?: string, autoFetch?: boolean);TypeScript Note: Method is async and returns Promise<this> for chaining.
setA2A
Section titled “setA2A”Set A2A endpoint.
agent = agent.setA2A( agentcard: str, version: str = "0.30", auto_fetch: bool = True) -> Agentimport { Agent } from 'agent0-sdk';
const agent: Agent = await agent.setA2A( agentcard: string, version?: string, autoFetch?: boolean);TypeScript Note: Method is async and returns Promise<this> for chaining.
setENS
Section titled “setENS”Set ENS endpoint.
agent = agent.setENS(name: str, version: str = "1.0") -> Agentimport { Agent } from 'agent0-sdk';
const agent: Agent = agent.setENS( name: string, version?: string);TypeScript Note: Method is synchronous and returns this for chaining.
removeEndpoint
Section titled “removeEndpoint”Remove endpoint(s).
agent = agent.removeEndpoint( type: Optional[EndpointType] = None, value: Optional[str] = None) -> Agent// Note: This method is not available in TypeScript SDK// Manually filter endpoints from registrationFile instead:const regFile = agent.getRegistrationFile();regFile.endpoints = regFile.endpoints.filter( ep => !(ep.type === endpointType && ep.value === value));TypeScript Note: This method is not available in the TypeScript SDK. Manually filter endpoints from the registration file instead.
removeEndpoints
Section titled “removeEndpoints”Remove all endpoints.
agent = agent.removeEndpoints() -> Agent// Note: This method is not available in TypeScript SDK// Manually clear endpoints from registrationFile instead:const regFile = agent.getRegistrationFile();regFile.endpoints = [];TypeScript Note: This method is not available in the TypeScript SDK. Manually clear endpoints from the registration file instead.
Trust Model Methods
Section titled “Trust Model Methods”setTrust
Section titled “setTrust”Set trust models using keywords.
agent = agent.setTrust( reputation: bool = False, cryptoEconomic: bool = False, teeAttestation: bool = False) -> Agentimport { Agent } from 'agent0-sdk';
const agent: Agent = agent.setTrust( reputation?: boolean, cryptoEconomic?: boolean, teeAttestation?: boolean);TypeScript Note: Method is synchronous and returns this for chaining.
trustModels
Section titled “trustModels”Set trust models directly.
agent = agent.trustModels( models: List[Union[TrustModel, str]]) -> Agent// Note: This method is not available in TypeScript SDK// Manually set trustModels on registrationFile instead:import type { TrustModel } from 'agent0-sdk';
const regFile = agent.getRegistrationFile();regFile.trustModels = models; // (TrustModel | string)[]TypeScript Note: This method is not available in the TypeScript SDK. Manually set trustModels on the registration file instead.
Info Methods
Section titled “Info Methods”updateInfo
Section titled “updateInfo”Update basic agent information.
agent = agent.updateInfo( name: Optional[str] = None, description: Optional[str] = None, image: Optional[str] = None) -> Agentimport { Agent } from 'agent0-sdk';import type { URI } from 'agent0-sdk';
const agent: Agent = agent.updateInfo( name?: string, description?: string, image?: URI);TypeScript Note: Method is synchronous and returns this for chaining.
setAgentWallet
Section titled “setAgentWallet”Set agent wallet.
agent = agent.setAgentWallet( addr: Optional[str], chainId: Optional[int] = None) -> Agentimport { Agent } from 'agent0-sdk';import type { Address } from 'agent0-sdk';
const agent: Agent = agent.setAgentWallet( address: Address, chainId: number);TypeScript Note: Method is synchronous, both parameters are required (not optional), and returns this for chaining.
setActive
Section titled “setActive”Set active status.
agent = agent.setActive(active: bool) -> Agentimport { Agent } from 'agent0-sdk';
const agent: Agent = agent.setActive(active: boolean);TypeScript Note: Method is synchronous and returns this for chaining.
setX402Support
Section titled “setX402Support”Set x402 support.
agent = agent.setX402Support(x402Support: bool) -> Agentimport { Agent } from 'agent0-sdk';
const agent: Agent = agent.setX402Support(x402Support: boolean);TypeScript Note: Method is synchronous and returns this for chaining.
Metadata Methods
Section titled “Metadata Methods”setMetadata
Section titled “setMetadata”Set metadata.
agent = agent.setMetadata(kv: Dict[str, Any]) -> Agentimport { Agent } from 'agent0-sdk';
const agent: Agent = agent.setMetadata( kv: Record<string, unknown>);TypeScript Note: Method is synchronous and returns this for chaining.
getMetadata
Section titled “getMetadata”Get metadata.
metadata = agent.getMetadata() -> Dict[str, Any]import { Agent } from 'agent0-sdk';
const metadata: Record<string, unknown> = agent.getMetadata();delMetadata
Section titled “delMetadata”Delete a metadata key.
agent = agent.delMetadata(key: str) -> Agentimport { Agent } from 'agent0-sdk';
const agent: Agent = agent.delMetadata(key: string);TypeScript Note: Method is synchronous and returns this for chaining.
Registration Methods
Section titled “Registration Methods”registerIPFS
Section titled “registerIPFS”Register with IPFS (recommended).
reg_file = agent.registerIPFS() -> RegistrationFileimport { Agent } from 'agent0-sdk';import type { RegistrationFile } from 'agent0-sdk';
const regFile: RegistrationFile = await agent.registerIPFS();TypeScript Note: Method is async and returns Promise<RegistrationFile>.
register
Section titled “register”Register with direct URI.
reg_file = agent.register(agentUri: str) -> RegistrationFileimport { Agent } from 'agent0-sdk';import type { RegistrationFile, URI } from 'agent0-sdk';
const regFile: RegistrationFile = await agent.registerHTTP( agentUri: URI);TypeScript Note: Method is named registerHTTP in TypeScript SDK and is async.
updateRegistration
Section titled “updateRegistration”Update registration after edits.
reg_file = agent.updateRegistration( agentURI: Optional[str] = None, idem: Optional[str] = None) -> RegistrationFile// Note: This method is not available in TypeScript SDK// Use registerIPFS() again to update existing registration:const regFile = await agent.registerIPFS();// Or use setAgentUri() to update URI:await agent.setAgentUri(newUri);TypeScript Note: This method is not available in the TypeScript SDK. Use registerIPFS() again to update an existing registration, or setAgentUri() to update the URI.
setAgentUri
Section titled “setAgentUri”Set agent URI locally.
agent = agent.setAgentUri(uri: str) -> Agentimport { Agent } from 'agent0-sdk';import type { URI } from 'agent0-sdk';
await agent.setAgentUri(uri: URI);TypeScript Note: Method is async and updates the URI on-chain (not just locally).
Ownership Methods
Section titled “Ownership Methods”transfer
Section titled “transfer”Transfer ownership.
result = agent.transfer( to: str, approve_operator: bool = False, idem: Optional[str] = None) -> Dictimport { Agent } from 'agent0-sdk';import type { Address, AgentId } from 'agent0-sdk';
const result: { txHash: string; from: Address; to: Address; agentId: AgentId;} = await agent.transfer( newOwner: Address);TypeScript Note: Method is async, only takes newOwner parameter (no approve_operator or idem), and returns typed object.
Parameters:
to/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 is not registered, address is invalid, or caller is not the owner - TypeScript:
Error: If agent is not registered, address is invalid, or caller is not the owner
Example:
# Transfer agent to new ownernew_owner = "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6"result = agent.transfer(new_owner)
print(f"Transfer successful: {result['txHash']}")print(f"New owner: {result['to']}")// Transfer agent to new ownerconst newOwner = "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6";const result = await agent.transfer(newOwner);
console.log(`Transfer successful: ${result.txHash}`);console.log(`New owner: ${result.to}`);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
addOperator
Section titled “addOperator”Add operator.
result = agent.addOperator( operator: str, idem: Optional[str] = None) -> Dict// Note: This method is not available in TypeScript SDK// Use SDK's web3Client to interact with Identity Registry directlyTypeScript Note: This method is not available in the TypeScript SDK. Use the SDK’s web3Client to interact with the Identity Registry directly.
removeOperator
Section titled “removeOperator”Remove operator.
result = agent.removeOperator( operator: str, idem: Optional[str] = None) -> Dict// Note: This method is not available in TypeScript SDK// Use SDK's web3Client to interact with Identity Registry directlyTypeScript Note: This method is not available in the TypeScript SDK. Use the SDK’s web3Client to interact with the Identity Registry directly.
activate
Section titled “activate”Activate agent.
reg_file = agent.activate(idem: Optional[str] = None) -> RegistrationFile// Note: This method is not available in TypeScript SDK// Use setActive(true) and registerIPFS() instead:agent.setActive(true);const regFile = await agent.registerIPFS();TypeScript Note: This method is not available in the TypeScript SDK. Use setActive(true) and registerIPFS() instead.
deactivate
Section titled “deactivate”Deactivate agent.
reg_file = agent.deactivate(idem: Optional[str] = None) -> RegistrationFile// Note: This method is not available in TypeScript SDK// Use setActive(false) and registerIPFS() instead:agent.setActive(false);const regFile = await agent.registerIPFS();TypeScript Note: This method is not available in the TypeScript SDK. Use setActive(false) and registerIPFS() instead.
Utility Methods
Section titled “Utility Methods”getRegistrationFile
Section titled “getRegistrationFile”Get registration file.
reg_file = agent.getRegistrationFile() -> RegistrationFileimport { Agent } from 'agent0-sdk';import type { RegistrationFile } from 'agent0-sdk';
const regFile: RegistrationFile = agent.getRegistrationFile();toJson
Section titled “toJson”Convert to JSON.
json_str = agent.toJson() -> str// Note: This method is not available in TypeScript SDK// Use JSON.stringify() on registrationFile instead:const regFile = agent.getRegistrationFile();const jsonStr = JSON.stringify(regFile, null, 2);TypeScript Note: This method is not available in the TypeScript SDK. Use JSON.stringify() on the registration file instead.
saveToFile
Section titled “saveToFile”Save to file.
agent.saveToFile(filePath: str) -> None// Note: This method is not available in TypeScript SDK// Use Node.js fs module instead:import * as fs from 'fs';const regFile = agent.getRegistrationFile();fs.writeFileSync(filePath, JSON.stringify(regFile, null, 2));TypeScript Note: This method is not available in the TypeScript SDK. Use Node.js fs module to write the registration file to disk.