x402 service · $0.001 USDC / request

Reliable randomness, on demand.

Send 2–100 JSON-compatible choices. Random Choice selects one using cryptographically secure server-side randomness. Add optional positive relative weights for weighted selection.

POST /random-choice
{
  "choices": ["alpha", "beta", "gamma"],
  "weights": [7, 2, 1]
}
Simple primitive

Give an agent options. Get one selection.

Use uniform selection when every choice should be equally likely, or provide relative weights when some options should be more likely than others.

Uniform selection

Send only choices for equal-probability selection.

Weighted selection

Add one positive weight per choice. Weights are relative and do not need to total 100.

Structured result

Receive the selected value, its index, choice count, weighting details, and request ID.

Response example
{
  "selected": "alpha",
  "index": 0,
  "weighted": true,
  "choice_count": 3,
  "selected_weight": 7,
  "total_weight": 10,
  "request_id": "rc_..."
}
Boundaries

Designed for one-off agent decisions.

  • 2–100 choices per request
  • 32 KB request-body limit
  • JSON-compatible values, nested up to 32 levels
  • Server-side CSPRNG randomness
  • Retries are new random events and may be charged again
Good fits

Tie-breaking, sampling, and lightweight choice.

Tie breaking

Choose between several otherwise acceptable actions.

Weighted preference

Represent soft preferences without writing custom randomization logic.

Sampling

Select one item from a bounded set as part of a larger agent workflow.

Usage boundary: Random Choice is not intended for gambling, security tokens, consequential medical, legal, or financial decisions, or stable experiment/routing assignments. Results are cryptographically random server-side but are not independently verifiable or provably fair.