# ai-economy-sdk reference

> Payment-gated MCP servers and paid MCP client sessions on Algorand.

Every public object of the `ai_economy_sdk` module ([`ai-economy-sdk` on PyPI](https://pypi.org/project/ai-economy-sdk/)), generated from the docstrings in [x402-avm/ai-economy-sdk](https://github.com/x402-avm/ai-economy-sdk).

## Server

| Object | Kind | Summary |
|---|---|---|
| [`PaymentGate`](https://x402-avm.github.io/reference/python/ai-economy-sdk/payment-gate) | class | Payment gate protecting FastMCP server tools with x402 on Algorand. |
| [`AIEconomySDK`](https://x402-avm.github.io/reference/python/ai-economy-sdk/ai-economy-sdk) | class | Payment-gated MCP server SDK. |
| [`DefaultAvmSigner`](https://x402-avm.github.io/reference/python/ai-economy-sdk/default-avm-signer) | class | A default implementation of AvmSigner for convenience. |
| [`ChainReader`](https://x402-avm.github.io/reference/python/ai-economy-sdk/chain-reader) | class | Reader for Algorand blockchain state via an Indexer client. |
| [`SettleOnSuccessMiddleware`](https://x402-avm.github.io/reference/python/ai-economy-sdk/settle-on-success-middleware) | class | FastMCP middleware that settles payments on chain only upon tool success. |

## Client

| Object | Kind | Summary |
|---|---|---|
| [`paid_mcp_session`](https://x402-avm.github.io/reference/python/ai-economy-sdk/paid-mcp-session) | function | Open an MCP session that pays for tool calls with x402 on Algorand. |

## Identity

| Object | Kind | Summary |
|---|---|---|
| [`make_identity_txn`](https://x402-avm.github.io/reference/python/ai-economy-sdk/make-identity-txn) | function | Create an unsigned identity proof payment transaction. |
| [`sign_identity_txn`](https://x402-avm.github.io/reference/python/ai-economy-sdk/sign-identity-txn) | function | Create and sign an identity proof transaction, returning the X-Identity-Txn header. |
| [`verify_identity_txn`](https://x402-avm.github.io/reference/python/ai-economy-sdk/verify-identity-txn) | function | Verify an X-Identity-Txn header value against timestamp skew and Algorand signature. |
| [`sign_identity`](https://x402-avm.github.io/reference/python/ai-economy-sdk/sign-identity) | function | Generate legacy identity verification headers signed with an Algorand private key. |
| [`verify_identity`](https://x402-avm.github.io/reference/python/ai-economy-sdk/verify-identity) | function | Verify identity headers against timestamp skew and Algorand signature. |

## Networks

| Object | Kind | Summary |
|---|---|---|
| [`resolve_network`](https://x402-avm.github.io/reference/python/ai-economy-sdk/resolve-network) | function | Return the CAIP-2 id for a network name or id, and register it with x402. |
| [`genesis_hash_for`](https://x402-avm.github.io/reference/python/ai-economy-sdk/genesis-hash-for) | function | Return the full 44-character base64 genesis hash for a network. |
| [`endpoints_for`](https://x402-avm.github.io/reference/python/ai-economy-sdk/endpoints-for) | function | Default algod/indexer endpoints: AlgoNode for MainNet/TestNet, LocalNet for anything else. |
| [`usdc_asset_id`](https://x402-avm.github.io/reference/python/ai-economy-sdk/usdc-asset-id) | function | Circle USDC's asset id on MainNet/TestNet; None elsewhere. |
| [`is_public`](https://x402-avm.github.io/reference/python/ai-economy-sdk/is-public) | function | Check whether a network identifier represents public MainNet or TestNet. |
| [`register_network`](https://x402-avm.github.io/reference/python/ai-economy-sdk/register-network) | function | Register an Algorand network in x402's network tables (no-op for MainNet/TestNet, which are built in). |
| [`network_from_algod`](https://x402-avm.github.io/reference/python/ai-economy-sdk/network-from-algod) | function | Derive the CAIP-2 network id from an algod client and register it. |
| [`Endpoints`](https://x402-avm.github.io/reference/python/ai-economy-sdk/endpoints) | class | Connection parameters for Algorand node services. |

## Errors

| Object | Kind | Summary |
|---|---|---|
| [`AIEconomyError`](https://x402-avm.github.io/reference/python/ai-economy-sdk/ai-economy-error) | class | Base class for every exception the SDK raises deliberately. |
| [`ConfigurationError`](https://x402-avm.github.io/reference/python/ai-economy-sdk/configuration-error) | class | Invalid arguments or configuration, detected before any payment is attempted. |
| [`UnknownNetworkError`](https://x402-avm.github.io/reference/python/ai-economy-sdk/unknown-network-error) | class | A network name or CAIP-2 identifier could not be resolved. |
| [`AlgodClientRequiredError`](https://x402-avm.github.io/reference/python/ai-economy-sdk/algod-client-required-error) | class | An operation needs an algod connection but the signer was created without one. |
| [`PaymentVerificationError`](https://x402-avm.github.io/reference/python/ai-economy-sdk/payment-verification-error) | class | A payment transaction group failed verification (for example, algod simulation). |
| [`PaymentRequiredError`](https://x402-avm.github.io/reference/python/ai-economy-sdk/payment-required-error) | class | A priced tool was invoked without a verified payment. |
| [`SettlementError`](https://x402-avm.github.io/reference/python/ai-economy-sdk/settlement-error) | class | A verified payment could not be settled on chain after the tool succeeded. |
| [`SpendLimitExceededError`](https://x402-avm.github.io/reference/python/ai-economy-sdk/spend-limit-exceeded-error) | class | The buyer's own spend controls refused a payment, so nothing was signed or sent. |

## Constants

| Object | Kind | Summary |
|---|---|---|
| [`MAINNET, TESTNET, PASS_NOTE_PREFIX, ...`](https://x402-avm.github.io/reference/python/ai-economy-sdk/constants) | constants | Network ids, the pass note prefix and the legacy identity header names exported by ai_economy_sdk. |

Source: https://x402-avm.github.io/reference/python/ai-economy-sdk/index
