Skip to main content
The agents module handles AI agent registration, retrieval, and access token generation.

Methods

register_agent

Register a new AI agent.
result = payments.agents.register_agent(
    metadata=agent_metadata,
    api=api_config
)
agent_id = result['agentId']
Parameters:
NameTypeDescription
metadatadictAgent name, description, tags
apidictAPI endpoints and definition URL
Example:
result = payments.agents.register_agent(
    metadata={
        'name': 'My AI Assistant',
        'description': 'Helpful AI assistant',
        'tags': ['ai', 'assistant']
    },
    api={
        'endpoints': [{'POST': 'https://api.example.com/query'}],
        'agentDefinitionUrl': 'https://api.example.com/openapi.json'
    }
)
agent_id = result['agentId']

register_agent_and_plan

Register an agent and payment plan in one call.
result = payments.agents.register_agent_and_plan(
    agent_metadata,
    agent_api,
    plan_metadata,
    price_config,
    credits_config,
    access_limit
)
Example:
from payments_py.plans import get_erc20_price_config, get_fixed_credits_config

result = payments.agents.register_agent_and_plan(
    agent_metadata={'name': 'My Agent', 'tags': ['ai']},
    agent_api={'endpoints': [{'POST': 'https://api.example.com/query'}]},
    plan_metadata={'name': 'Pro Plan', 'description': '100 queries'},
    price_config=get_erc20_price_config(10_000_000, usdc_address, builder_address),
    credits_config=get_fixed_credits_config(100, 1),
    access_limit='credits'
)

agent_id = result['agentId']
plan_id = result['planId']

get_agent

Retrieve agent details by ID.
agent = payments.agents.get_agent(agent_id)
Returns:
{
    'agentId': 'did:nv:...',
    'name': 'My Agent',
    'description': '...',
    'tags': ['ai'],
    'endpoints': [...],
    'plans': [...]
}

get_agent_access_token

Get an access token for querying an agent.
credentials = payments.agents.get_agent_access_token(
    plan_id,
    agent_id
)
access_token = credentials['accessToken']
Example:
import requests

credentials = payments.agents.get_agent_access_token(
    'did:nv:plan-123',
    'did:nv:agent-456'
)

response = requests.post(
    agent_endpoint,
    headers={
        'Authorization': f"Bearer {credentials['accessToken']}"
    },
    json={'prompt': 'Hello'}
)

list_agents

List agents (optionally filtered).
agents = payments.agents.list_agents(
    owner='0x...',
    limit=10,
    offset=0
)

Types

# Agent metadata
agent_metadata = {
    'name': str,           # Required
    'description': str,    # Optional
    'tags': List[str],     # Optional
}

# API configuration
api_config = {
    'endpoints': List[Dict[str, str]],  # e.g., [{'POST': 'url'}]
    'agentDefinitionUrl': str           # Optional
}

# Access token response
{
    'accessToken': str,
    'expiresAt': str  # ISO timestamp
}

Next Steps