{"name":"random","intro":"A language model cannot produce randomness; asked for a “random” number it returns the same few. This tool draws from the operating system's entropy — or, when you pass a `seed`, from a deterministic generator, so the same seed always yields the same draw and a test can reproduce it. Tokens, passwords and UUIDs are always drawn from `secrets` and ignore the seed on purpose; that is stated in every response.","when_to_use":["UUIDs, tokens, passwords and OTPs that must be unguessable.","Sampling, shuffling, picking a winner or assigning A/B groups.","Anything that must be reproducible later: pass a `seed` and record it.","Never for cryptographic keys you intend to keep — generate those where they will live."],"network":false,"related":"[`encode`](/docs/tools/encode) to hash or encode what you generate · [`collections`](/docs/tools/collections) `chunk` for deterministic batching, when you want splitting without randomness.","docs_url":"/docs/tools/random","modes":[{"name":"uuid","purpose":"Generate UUIDs, v4 or time-ordered v7.","description":"Generates version 4 (fully random) or version 7 (time-ordered, so they sort by creation and index well as a primary key) UUIDs. `format` returns them canonical, bare hex or upper case. UUIDs are always drawn from the system entropy source and are never affected by `seed`.","parameters":[{"name":"n","type":"integer","required":false,"doc":"How many to generate, 1..10000.","default":"1"},{"name":"version","type":"integer","required":false,"doc":"4 is random; 7 is time-ordered.","default":"4"},{"name":"format","type":"string","required":false,"doc":"Output form.","default":"`canonical`"}],"examples":[{"mode":"uuid"},{"mode":"uuid","version":7,"n":3,"format":"hex"},{"mode":"uuid","version":5},{"mode":"uuid","n":0}]},{"name":"int","purpose":"Random integers in an inclusive range.","description":"Draws integers between `min` and `max`, inclusive at both ends — stated in `assumptions`, because half-open ranges are the usual bug. `unique: true` draws without replacement. With a `seed` the draw is reproducible and the response says so; without one it comes from system entropy.","parameters":[{"name":"min","type":"number","required":false,"doc":"Lower bound, inclusive.","default":"1"},{"name":"max","type":"number","required":false,"doc":"Upper bound, inclusive.","default":"100"},{"name":"n","type":"integer","required":false,"doc":"How many to draw, 1..10000.","default":"1"},{"name":"unique","type":"boolean","required":false,"doc":"Draw without replacement.","default":"`false`"},{"name":"seed","type":"string \\| integer","required":false,"doc":"Makes the draw reproducible.","default":null}],"examples":[{"mode":"int","min":1,"max":6,"n":5,"seed":"demo"},{"mode":"int","min":1,"max":49,"n":6,"unique":true,"seed":"lotto-2025"},{"mode":"int","min":1,"max":100},{"mode":"int","min":10,"max":1},{"mode":"int","min":1,"max":3,"n":5,"unique":true},{"mode":"int","min":1,"max":10,"n":999999}]},{"name":"float","purpose":"Random floats in a range.","description":"Draws uniform floats between `min` and `max`, optionally rounded to `decimals`. Seed it for reproducibility. For money, draw with `decimals` set rather than rounding afterwards.","parameters":[{"name":"min","type":"number","required":false,"doc":"Lower bound.","default":"0.0"},{"name":"max","type":"number","required":false,"doc":"Upper bound.","default":"1.0"},{"name":"n","type":"integer","required":false,"doc":"How many to draw, 1..10000.","default":"1"},{"name":"decimals","type":"integer","required":false,"doc":"Round each value to this many places.","default":null},{"name":"seed","type":"string \\| integer","required":false,"doc":"Makes the draw reproducible.","default":null}],"examples":[{"mode":"float","min":10,"max":20,"n":4,"decimals":2,"seed":"demo"},{"mode":"float","seed":"demo"},{"mode":"float","min":5,"max":1},{"mode":"float","n":0}]},{"name":"pick","purpose":"Choose from a list, with or without weights.","description":"Picks `n` items from a list. By default picks are unique (without replacement); set `unique: false` to allow repeats. `weights` makes the draw proportional — and weighted unique draws remove each chosen item and its weight before the next pick. Both the weighting and the replacement rule are reported in `assumptions`.","parameters":[{"name":"items","type":"array","required":true,"doc":"The pool to pick from.","default":null},{"name":"n","type":"integer","required":false,"doc":"How many to pick.","default":"1"},{"name":"unique","type":"boolean","required":false,"doc":"Pick without replacement.","default":"`true`"},{"name":"weights","type":"number[]","required":false,"doc":"Relative weights, one per item.","default":null},{"name":"seed","type":"string \\| integer","required":false,"doc":"Makes the pick reproducible.","default":null}],"examples":[{"mode":"pick","items":["asha","bo","chen","dev","eve"],"n":2,"seed":"raffle-1"},{"mode":"pick","items":["gold","silver","bronze"],"weights":[1,3,6],"n":5,"unique":false,"seed":"loot"},{"mode":"pick","items":["a","b","c"],"weights":[1,2]},{"mode":"pick","items":["a","b"],"n":5}]},{"name":"shuffle","purpose":"Shuffle a list, reproducibly if seeded.","description":"Returns a shuffled copy of the list; the input is not modified. With the same `seed` you get the same order every time, which is what makes a randomised experiment auditable.","parameters":[{"name":"items","type":"array","required":true,"doc":"The list to shuffle.","default":null},{"name":"seed","type":"string \\| integer","required":false,"doc":"Makes the shuffle reproducible.","default":null}],"examples":[{"mode":"shuffle","items":["a","b","c","d","e"],"seed":"demo"},{"mode":"shuffle","items":["a","b","c","d","e"],"seed":"other"},{"mode":"shuffle","items":"abcde"}]},{"name":"token","purpose":"Cryptographically secure tokens, passwords and OTPs.","description":"Generates secure random strings from the OS entropy source. `kind` picks the alphabet: `urlsafe`, `hex`, `alnum`, `alpha`, `digits`, `upper`, `lower`, `password` (mixed classes, guaranteed to contain all four), `readable` (no look-alike characters), `bytes` (hex of that many bytes) or `otp`. Seeding is deliberately ignored here — a reproducible secret is not a secret — and every response says so.","parameters":[{"name":"kind","type":"string","required":false,"doc":"Alphabet or token type.","default":"`urlsafe`"},{"name":"length","type":"integer","required":false,"doc":"Characters (or bytes for `kind: bytes`), 1..4096.","default":"32"},{"name":"n","type":"integer","required":false,"doc":"How many tokens.","default":"1"}],"examples":[{"mode":"token","kind":"urlsafe","length":32},{"mode":"token","kind":"password","length":16},{"mode":"token","kind":"otp","length":6},{"mode":"token","kind":"readable","length":8,"n":3},{"mode":"token","kind":"runes"},{"mode":"token","kind":"hex","length":0}]},{"name":"bool","purpose":"Weighted coin flips.","description":"Draws booleans that are true with probability `p`. With `n` greater than one the response includes `true_count`, which is what a simulation actually wants. Seed it for a reproducible run.","parameters":[{"name":"p","type":"number","required":false,"doc":"Probability of `true`, 0..1.","default":"0.5"},{"name":"n","type":"integer","required":false,"doc":"How many flips, 1..10000.","default":"1"},{"name":"seed","type":"string \\| integer","required":false,"doc":"Makes the run reproducible.","default":null}],"examples":[{"mode":"bool","p":0.3,"n":10,"seed":"demo"},{"mode":"bool","seed":"demo"},{"mode":"bool","p":1.5},{"mode":"bool","n":0}]},{"name":"sample","purpose":"Take a sample, or split into A/B groups.","description":"With `k`, draws a sample of that size without replacement. With `groups` — a count or a list of names — shuffles and deals the items round-robin into buckets whose sizes differ by at most one, which is what an A/B split should do. Seed it and the assignment is reproducible for anyone auditing the experiment. Asking for more groups than there are items leaves some empty, and says so in `warnings`.","parameters":[{"name":"items","type":"array","required":true,"doc":"The population.","default":null},{"name":"k","type":"integer","required":false,"doc":"Sample size, when not splitting into groups.","default":"1"},{"name":"groups","type":"integer \\| string[]","required":false,"doc":"Number of groups, or their names.","default":null},{"name":"seed","type":"string \\| integer","required":false,"doc":"Makes the assignment reproducible.","default":null}],"examples":[{"mode":"sample","items":["u1","u2","u3","u4","u5","u6","u7"],"k":3,"seed":"audit-2025"},{"mode":"sample","items":["u1","u2","u3","u4","u5","u6","u7"],"groups":["control","variant_a","variant_b"],"seed":"exp-42"},{"mode":"sample","items":["a","b"],"k":5}]}]}