{"uid":"cap_0-kXdDVZoTt-GqefRpAwQ","slug":"weighted-random-choice-selector-89e06a8d","name":"Weighted Random Choice Selector","description":"Choose among options using caller-supplied probability weights for routing, games and simulations.","url":"https://x402-zoo.lolagent.workers.dev/api/weighted-choice","method":"GET","headers":{},"bodySchema":{"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":["items","weights"],"properties":{"items":{"type":"string"},"weights":{"type":"string"}}}},"additionalProperties":false}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_OwTZrnvEUGa76aDUKyNTD","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Randomly selects one item from a caller-supplied list using provided probability weights, useful for routing, games, and simulations.","exampleAgentPrompt":"Pick one option from [red, blue, green] using weights [0.5, 0.3, 0.2] — red should be chosen half the time, blue 30%, and green 20%.","exampleUseCases":[{"title":"A/B test traffic routing","prompt":"Route this user to one of three variants — control, variant-A, or variant-B — with weights 60, 25, and 15 respectively, so control gets the majority of traffic."},{"title":"Weighted loot drop in a game","prompt":"I'm building a game loot system — randomly pick one item from [common, uncommon, rare, legendary] with probabilities [0.6, 0.25, 0.1, 0.05]."},{"title":"Random daily challenge selector","prompt":"Pick today's challenge from [easy, medium, hard] where easy should come up 50% of the time, medium 35%, and hard 15%."}],"resultDescription":"Returns the single selected item from the provided list, chosen according to the caller-supplied probability weights. The selection is non-deterministic across calls but statistically conforms to the given weights over many calls.","failureModes":["Mismatched lengths between items and weights arrays returns an error","Weights that don't sum to a valid distribution may cause undefined behavior","Malformed query parameters (non-numeric weights, empty items list) return a 4xx error","Network timeout or Cloudflare Worker cold start on rare occasions"],"whenToPreferThis":"Use this endpoint when you need a lightweight, stateless, pay-per-call weighted random selection without maintaining local randomization logic. Ideal for routing decisions, game mechanics, simulation steps, or any scenario where options have unequal probabilities and you want a remote, reproducible API call rather than client-side RNG.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T12:54:47.425Z","isFirstParty":false}