# GET /qr: $0.001 per call

Turn text or a link into a QR code. Pass ?text=https://example.com. Returns a crisp SVG image and a data: URL you can drop into HTML or Markdown. Options: ecc (error correction L, M, Q, H), size in pixels, margin, dark and light colours (#hex). Up to 2,000 characters.

- **Price:** $0.001 in USDC, the same on Base, Solana, Polygon, Arbitrum. Failed calls are never charged.
- **Free trial:** yes, 20 free calls a day from Claude, Cursor or any MCP client ([set-up](/mcp/setup)).
- **Answers cached for:** not cached
- **Data sources:** computed locally
- **Lane:** Utilities ([OpenAPI](/openapi/utilities.json))
- **Live health:** [status page](/status)

## Free sample

See an answer for the demo input first, free (no payment, 10 a minute): [https://aayatai.com/sample/qr](/sample/qr). It is a stored real answer when we have one, otherwise an example marked `"kind": "illustrative"`.

```bash
curl "https://aayatai.com/sample/qr"
```

## 1. See the price (free)

Call it without paying: you get `402 Payment Required` and a `PAYMENT-REQUIRED` header with the exact price and where to pay.

```bash
curl -i "https://aayatai.com/qr?text=https%3A%2F%2Fx402.org&ecc=M&size=256"
```

## 2. Pay and call (TypeScript)

```bash
npm install @x402/fetch @x402/evm viem
```

```ts
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

// A wallet used only by your agent, holding a little USDC on Base.
const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const res = await pay("https://aayatai.com/qr?text=https%3A%2F%2Fx402.org&ecc=M&size=256");
console.log(await res.json());
```

## 3. Or as an MCP tool

```ts
// MCP server: https://aayatai.com/mcp (Streamable HTTP). With the x402 MCP client (see /start):
const result = await client.callTool("qr", {"text":"https://x402.org","ecc":"M","size":256});
```

## Inputs

- `text` **(required)** (string): Text or URL to encode.
- `ecc` (string; one of `L`, `M`, `Q`, `H`; default `M`): Error correction: L (7%), M (15%), Q (25%), H (30%).
- `size` (integer; default `512`): Image width/height in pixels.
- `margin` (integer; default `4`): Quiet zone around the code, in squares.
- `dark` (string; default `#000000`): Colour of the squares, #hex.
- `light` (string; default `#ffffff`): Background colour, #hex.

Bad inputs are rejected with HTTP 400 before any payment is asked for.

## Example answer

```json
{
  "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 33 33\" width=\"256\" height=\"256\">…</svg>",
  "dataUrl": "data:image/svg+xml;base64,PHN2Zy…",
  "modules": 25,
  "version": 2,
  "ecc": "M"
}
```

## Related

- [GET /dns](/services/dns) ($0.001): Look up DNS records for any domain: A, AAAA, CNAME, MX, NS, TXT, SOA, CAA, SRV, PTR, DS, DNSKEY, HTTPS, or ALL common types at once.
- [GET /email-check](/services/email-check) ($0.002): Check an email address before you use it: syntax, whether its domain has mail servers (MX, with null-MX and A-record fallback), disposable/throwaway providers, 
- [GET /rdap](/services/rdap) ($0.002): Domain registration lookup (RDAP, the modern WHOIS): registrar, abuse contact, created/updated/expiry dates, domain age, days until expiry, status codes, name s

New here? [Getting started in 60 seconds](/start). All services: [Aayat AI](/).