# Delx Commerce — Weighted Random Choice

> Delx Commerce — Weighted Random Choice is a paid API for AI agents from commerce.delx.ai, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-02).

Randomly selects one item from a list using weighted probabilities, returning the chosen item, its index, weight, and probability

## Facts

- Endpoint: POST https://commerce.delx.ai/api/v1/x402/weighted-choice?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-02
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/delx-commerce-weighted-random-choice-42a0a29b
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_X8DKRvCl6TavBp65NZ0Z1

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 delx-commerce-weighted-random-choice-42a0a29b -d '<json body>'
```

Example prompt: Pick one item randomly from the list ['a','b','c','d'] where 'a' has weight 1, 'b' has weight 2, 'c' has weight 1, and 'd' has weight 4, and tell me which one was selected and the probability it had of being chosen.

## When to prefer this

Use this endpoint when you need a stateless, pay-per-call weighted random selection with cryptographically verifiable delivery and no signup overhead. Prefer it over rolling your own PRNG when you need an auditable, reproducible random draw billed per use via USDC on Base or Solana. Ideal for agents that need probabilistic branching, A/B routing, weighted lotteries, or randomized content selection in a pipeline without managing server infrastructure.

## Known failure modes

- Mismatched array lengths between items and weights — likely returns an error or undefined behavior
- Empty items or weights arrays — API may return an error response
- Non-numeric weights — validation failure expected
- Network or payment failure via x402 protocol — call not executed, no charge

## How this service works

Pay-per-result APIs for agents. No signup. Exact price. Verifiable delivery. USDC on Base + Solana via x402.

## Output

Returns a JSON object with ok (boolean), the chosen item as 'choice', its zero-based 'index' in the input array, its individual 'weight', the computed 'probability' (weight divided by total), and 'total_weight' summed across all items. Also includes a schema identifier 'delx/util-weighted-choice/v1'.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "items": {
   "type": "array",
   "description": "Input field: items."
  },
  "weights": {
   "type": "array",
   "description": "Input field: weights."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "ok": true,
  "index": 0,
  "choice": "a",
  "schema": "delx/util-weighted-choice/v1",
  "weight": 1,
  "probability": 0.25,
  "total_weight": 4
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/delx-commerce-weighted-random-choice-42a0a29b/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from commerce.delx.ai](https://www.zero.xyz/host/commerce.delx.ai/llms.txt)
