# agent402.tools Random Number & Bytes Generator

> agent402.tools Random Number & Bytes Generator is a paid API for AI agents from agent402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-15).

Returns cryptographically secure random bytes as hex or a uniform random integer within a specified range, with optional batch count.

## Facts

- Endpoint: GET https://agent402.tools/api/random
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-tools-random-number-bytes-generator-1147f082
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_a_l3q2ckg7VrDFgwa2NME

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 agent402-tools-random-number-bytes-generator-1147f082
```

Example prompt: Give me 5 cryptographically secure random integers between 1 and 100, and also generate 32 random bytes as a hex string.

## When to prefer this

Use this endpoint when you need cryptographically secure randomness rather than pseudo-random values — ideal for generating tokens, nonces, salts, or unbiased integer samples. Prefer over language-runtime Math.random() when security or statistical uniformity matters.

## Known failure modes

- bytes parameter out of range (must be 1–1024) returns error
- min greater than max returns error
- count out of range (must be 1–100) returns error
- mixing bytes and min/max parameters may return error
- missing required parameters returns error
- payment not included or invalid returns 402

## How this service works

Cryptographically secure randomness. ?bytes=1..1024 returns hex; or ?min=&max= returns a uniform integer; ?count=1..100.

## Output

Returns a JSON object containing either a hex string of N random bytes, a single random integer within [min, max], or an array of up to 100 such values if count is specified.

## Example request

```json
{
 "input": {
  "type": "http",
  "method": "GET",
  "queryParams": {
   "max": "100",
   "min": "1",
   "bytes": "32",
   "count": "5"
  }
 }
}
```

## 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",
     "properties": {
      "max": {
       "type": "string",
       "description": "Integer upper bound (inclusive)"
      },
      "min": {
       "type": "string",
       "description": "Integer lower bound (inclusive)"
      },
      "bytes": {
       "type": "string",
       "description": "Return N random bytes as hex (1-1024)"
      },
      "count": {
       "type": "string",
       "description": "How many values (1-100, default 1)"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "required": [
      "integers"
     ],
     "properties": {
      "integers": {
       "type": "array",
       "items": {
        "type": "integer"
       }
      }
     }
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "integers": [
   42,
   7,
   93
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-tools-random-number-bytes-generator-1147f082/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
