> ## Documentation Index
> Fetch the complete documentation index at: https://docs.linkup.so/llms.txt
> Use this file to discover all available pages before exploring further.

# x402 Payment Protocol

> Pay per request with USDC on Base. No account needed.

Linkup supports the [x402](https://x402.org) payment protocol: pay per request in USDC on the Base network, with no account or API key required. This lets AI agents use Linkup autonomously, without requiring a human to create an account.

If you already have an API key, nothing changes. x402 is an alternative way to access the API.

## Supported endpoints

All x402-enabled endpoints are billed at a flat rate of **\$0.01 per request**.

| Endpoint     |
| ------------ |
| `/v1/search` |
| `/v1/fetch`  |

## How it works

1. **Send a request without authentication.** The API responds with `402` Payment Required and a `payment-required` header containing the amount, deposit address, network, and asset.
2. **Sign a USDC transfer** (EIP-712 / EIP-3009) with your wallet, then resend the same request with the signed payload in the `payment-signature` header.
3. **The API verifies the signature**, executes the payment on-chain, and returns `200` with a `payment-response` header containing the transaction hash.

## Setting up a wallet

If you don't have a wallet yet, follow these steps to create one and fund it with USDC on Base.

<Steps>
  <Step title="Install MetaMask">
    Download and install the [MetaMask](https://metamask.io/) app on your phone or browser extension.
  </Step>

  <Step title="Create an account">
    Follow the onboarding flow to create a new wallet.
  </Step>

  <Step title="Export your private key">
    * Tap on your account name in the top left corner
    * Next to the account name, tap the **three dots** menu on the right
    * Select **Private key**
    * Copy your private key. This is what you'll use in the SDK to sign payments on **Base**
  </Step>

  <Step title="Fund your wallet with USDC on Base">
    * In MetaMask, switch to the **Base** network
    * Buy **USDC** (USD Coin). You may need to verify your identity and enter personal information
    * Complete the purchase
  </Step>
</Steps>

Once your wallet is funded, you can use your private key in the SDK to pay for Linkup API requests.

## Quickstart

<Tabs>
  <Tab title="Python">
    <Steps>
      <Step title="Install dependencies">
        ```bash theme={"system"}
        pip install 'linkup-sdk[x402]'
        ```
      </Step>

      <Step title="Send a paid request">
        ```python theme={"system"}
        from eth_account import Account
        from linkup import LinkupClient
        from linkup.x402 import create_x402_signer

        account = Account.from_key("0xYOUR_PRIVATE_KEY")
        signer = create_x402_signer(account)
        client = LinkupClient(x402_signer=signer)

        result = client.search(
            query="What is Linkup?",
            depth="standard",
            output_type="sourcedAnswer",
        )
        print(result.answer)
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="JavaScript">
    <Steps>
      <Step title="Install dependencies">
        ```bash theme={"system"}
        npm install linkup-sdk @x402/core @x402/evm viem
        ```
      </Step>

      <Step title="Send a paid request">
        ```js theme={"system"}
        import { LinkupClient } from 'linkup-sdk';
        import { createX402Signer } from 'linkup-sdk/x402';
        import { privateKeyToAccount } from 'viem/accounts';

        const account = privateKeyToAccount('0xYOUR_PRIVATE_KEY');
        const signer = createX402Signer(account);
        const client = new LinkupClient({ signer });

        const result = await client.search({
          query: 'What is Linkup?',
          depth: 'standard',
          outputType: 'sourcedAnswer',
        });
        console.log(result);
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Headers reference

| Header              | Direction        | Description                                          |
| ------------------- | ---------------- | ---------------------------------------------------- |
| `payment-required`  | Response (`402`) | Base64 JSON: amount, deposit address, network, asset |
| `payment-signature` | Request          | Base64 JSON: signed payment authorization            |
| `payment-response`  | Response (`200`) | Base64 JSON: transaction hash, success status        |

<Tip>
  For the full x402 specification, visit [x402.org](https://x402.org). The `@x402/core` and `@x402/evm` packages are open-source.
</Tip>

<Info>
  **Need help?** Email `support@linkup.so`, ping us on [Discord](https://discord.com/invite/9q9mCYJa86), or [talk to us](https://calendar.app.google/zNUZz7RxgMMk9pKW7).
</Info>
