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

# Code Examples

> Copy-paste x402 endpoint patterns.

## Basic — 0.001 USDC per request

```typescript theme={null}
import { withPayment } from "@ace_won/x402";
import { NextRequest, NextResponse } from "next/server";

export const GET = withPayment({ amount: "0.001" }, async (req: NextRequest) => {
  return NextResponse.json({ data: "basic content" });
});
```

## Pay directly to your wallet

```typescript theme={null}
export const GET = withPayment({
  amount: "0.01",
  payTo: "0xYourWalletAddress",
  description: "Premium analytics data",
}, async (req: NextRequest) => {
  const data = await getPremiumData();
  return NextResponse.json({ data });
});
```

## POST endpoint — AI inference

```typescript theme={null}
export const POST = withPayment({
  amount: "0.005",
  description: "AI inference — pay per request",
}, async (req: NextRequest) => {
  const { prompt } = await req.json();
  const result = await runInference(prompt);
  return NextResponse.json({ result });
});
```

## Multiple price tiers

```typescript theme={null}
// app/api/basic/route.ts — 0.001 USDC
export const GET = withPayment(
  { amount: "0.001", description: "Basic data" },
  basicHandler
);

// app/api/premium/route.ts — 0.01 USDC
export const GET = withPayment({
  amount: "0.01",
  payTo: "0xYourWallet",
  description: "Premium tier with full dataset",
}, premiumHandler);
```

## Access payer address in your handler

```typescript theme={null}
export const GET = withPayment({ amount: "0.001" }, async (req: NextRequest) => {
  const payerAddress = req.headers.get("x-payment-payer");
  return NextResponse.json({ data: "your content", paidBy: payerAddress });
});
```

<Tip>
  The full source for `/api/arc-stats` is in the [GitHub repo](https://github.com/ace-coderr/conduit). Use it as a working reference.
</Tip>
