Skip to content
API Reference
SDKs

Agents

Agent-to-agent delegation using the A2A protocol.

The Agents package enables agent-to-agent (A2A) delegation — allowing one AI agent to securely delegate tasks to another while maintaining the user’s identity and authorization context.

  • Building agents that delegate work to other specialized agents
  • Exposing an agent as a service that other agents can call
  • Integrating with CrewAI or other agent frameworks
  • Implementing the A2A protocol with Keycard authentication
Terminal window
pip install keycardai-agents
ExportDescription
AgentServiceConfigConfiguration for an agent service (name, URL, capabilities)
AgentServerHost an agent as an A2A-compatible service
AgentClientCall remote agents via A2A protocol
DelegationClientHandle delegated OAuth token exchange between agents
ServiceDiscoveryDiscover available agent services
serve_agentConvenience function to start an agent server
crewaiOptional CrewAI framework integration
from keycardai.agents import AgentServiceConfig, AgentServer, serve_agent
config = AgentServiceConfig(
name="Research Agent",
description="Searches the web and summarizes findings",
url="http://localhost:9000",
)
async def handle_task(task):
# Process the delegated task
return {"result": "Research complete"}
server = AgentServer(config=config, handler=handle_task)
serve_agent(server)
from keycardai.agents import AgentClient, ServiceDiscovery
# Discover available agents
discovery = ServiceDiscovery(zone_url="https://your-zone.keycard.ai")
agents = await discovery.list_agents()
# Call a remote agent
client = AgentClient(agent_url="http://localhost:9000")
result = await client.send_task(
task="Summarize the latest news on AI agents",
)