Skip to content

listAgents

Enumerate every agent provisioned under your AGENSAI API key.

Signature

import type { ListAgentsOptions, AgentSummary } from "@agensai/sdk";
 
declare function listAgents(
  options: ListAgentsOptions,
): Promise<AgentSummary[]>;

Example

import { listAgents } from "@agensai/sdk";
 
const agents = await listAgents({ apiKey: process.env.AGENSAI_API_KEY! });
 
for (const a of agents) {
  console.log(a.name, a.address, a.status);
}

Returns

type AgentSummary = {
  name: string;            // "my-agent.agensai.eth"
  address: `0x${string}`;  // Smart account
  chainId: number;
  status: "active" | "revoked";
  createdAt: string;       // ISO timestamp
  policies: Array<{ type: string; summary: string }>;
};

Pagination

For accounts with hundreds of agents, pass cursor and limit:

const page = await listAgents({
  apiKey: process.env.AGENSAI_API_KEY!,
  limit: 50,
  cursor: previousCursor,
});

page.nextCursor is null when you've reached the end.