# CSPRNG Random Number & Bytes API

> CSPRNG Random Number & Bytes API is a paid API for AI agents from x402.donnyautomation.com, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-14).

Generates cryptographically secure random integers in a specified range or random bytes (hex/base64) server-side for deterministic or sandboxed AI agents

## Facts

- Endpoint: GET https://x402.donnyautomation.com/random
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/csprng-random-number-bytes-api-63cc7878
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_2GVEbmwhe6-2sO8MVjNOg

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability csprng-random-number-bytes-api-63cc7878
```

Example prompt: I need 5 cryptographically secure random integers between 1 and 100, rejection-sampled so there's no modulo bias — please use the server-side CSPRNG.

## When to prefer this

Use this endpoint when your AI agent runs in a deterministic or sandboxed environment that cannot generate its own entropy, and you need cryptographically secure randomness. Prefer it over pseudo-random alternatives when generating nonces, session tokens, cryptographic seeds, or running unbiased lotteries and simulations. The rejection-sampling guarantee makes it superior to modulo-based random integer generation.

## Known failure modes

- min >= max returns an error (max must be strictly greater than min)
- bytes out of range 1-1024 returns a validation error
- count out of range 1-1000 returns a validation error
- mixing integer-mode and byte-mode parameters incorrectly may produce an error or default behavior
- payment failure (x402) if USDC balance is insufficient — returns 402 Payment Required

## How this service works

Cryptographically secure randomness for agents that are deterministic or sandboxed. Two modes: raw bytes (?bytes=1..1024, default 32, clamped) returning hex and base64url; or uniform integers (?min= and ?max= together, optional ?count=1..1000) rejection-sampled so there is no modulo bias. Errors: 400 bad_bytes for a non-integer, bad_range when max is not greater than min, range_too_large. Generated server-side, and the response says so - if nobody may have seen it, generate it yourself.

## Output

Returns random integers uniformly sampled in [min, max] (rejection-sampled, no modulo bias) with a count up to 1000, or random bytes (1–1024) encoded as both hex and base64url. The response includes metadata stating the randomness source and any applicable limits.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [],
     "properties": {
      "max": {
       "type": "string",
       "description": "Upper bound (inclusive) for integer mode. Must be greater than min."
      },
      "min": {
       "type": "string",
       "description": "With max: return uniform integers in [min, max] inclusive instead of bytes."
      },
      "bytes": {
       "type": "string",
       "description": "Random bytes to return, 1..1024 (default 32). Returned as hex and base64url."
      },
      "count": {
       "type": "string",
       "description": "How many integers, 1..1000 (default 1). Integer mode only."
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "ts": "2026-08-01T00:00:00.000Z",
  "hex": "9f86d081884c7d65…",
  "bytes": 32,
  "base64": "n4bQgYhMfWWa…",
  "source": "node:crypto randomBytes (CSPRNG)"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/csprng-random-number-bytes-api-63cc7878/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.donnyautomation.com](https://www.zero.xyz/host/x402.donnyautomation.com/llms.txt)
