> For the complete documentation index, see [llms.txt](https://agent-protocol.gitbook.io/agent-protocol-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://agent-protocol.gitbook.io/agent-protocol-docs/developers/agent-api.md).

# Agent API

These functions are intended to be invoked from within the agent.

### Creating a Keypair for your Agent

#### Generate a new keypair for a specified blockchain

```python
def gen_keypair(self, blockchain: str) -> Tuple[str, str]:
    """
    Args:
        blockchain (str): The blockchain for which to generate the keypair.

    Returns:
        Tuple[str, str]: The public key and private key.
    """
```

#### Authorize a keypair for blockchain transactions.

```python
def authorize_keypair(self, agent_id: str, blockchain: str, permissions: dict) -> Card:
    """
    Args:
        agent_id (str): The ID of the agent.
        blockchain (str): The blockchain to authorize.
        permissions (dict): The permissions and limits for the keypair.

    Returns:
        Card: The authorized keypair object.
    """
```

### Purchases

#### Retrieve cards authorized for a specific use case.

```python
def retrieve_authorized_cards(self, use_case: str) -> List[Card]:
    """
    Args:
        use_case (str): The use case for filtering the cards.

    Returns:
        List[Card]: The list of authorized cards.
    """
```

#### Describe an expense for a card

```python
def describe_expense(self, card: Card, estimated_txn_size: float, txn_description: str) -> str:
    """
    Args:
        card (Card): The card to use for the expense.
        estimated_txn_size (float): The estimated size of the transaction.
        txn_description (str): The description of the transaction.

    Returns:
        str: The transaction ID.
    """
```

#### Screen a vendor to assess the likelihood of fraud

```python
def screen_vendor(vendor_id: str, transaction_amount: int, vendor_info: dict = None) -> dict:
    """
    Returns:
        VendorScreen: The result of screening the vendor.
    """
```

#### Report an issue with a purchase.

```python
def report_purchase_issue(self, card_id: str, transaction_id: str, issue_description: str) -> IssueReport:
    """
    Args:
        card_id (str): The ID of the card.
        transaction_id (str): The ID of the transaction.
        issue_description (str): The description of the issue.

    Returns:
        IssueReport: The issue report object.
    """
```

#### Initiate a buyer dispute for a transaction

```python
def initiate_buyer_dispute(self, card_id: str, transaction_id: str, dispute_reason: str) -> DisputeResult:
    """
    Args:
        card_id (str): The ID of the card.
        transaction_id (str): The ID of the transaction.
        dispute_reason (str): The reason for the dispute.

    Returns:
        DisputeResult: The result of the dispute initiation.
    """
```
