{"uid":"cap_2GVEbmwhe6-2sO8MVjNOg","slug":"csprng-random-number-bytes-api-63cc7878","name":"CSPRNG Random Number & Bytes API","description":"Cryptographically secure randomness for agents that are deterministic or sandboxed. Two modes: raw bytes (?bytes=1..1024, default 32, clamped) returning hex and base64url; or uniform integers (?min= and ?max= together, optional ?count=1..1000) rejection-sampled so there is no modulo bias. Errors: 400 bad_bytes for a non-integer, bad_range when max is not greater than min, range_too_large. Generated server-side, and the response says so - if nobody may have seen it, generate it yourself.","url":"https://x402.donnyautomation.com/random","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":[],"properties":{"max":{"type":"string","description":"Upper bound (inclusive) for integer mode. Must be greater than min."},"min":{"type":"string","description":"With max: return uniform integers in [min, max] inclusive instead of bytes."},"bytes":{"type":"string","description":"Random bytes to return, 1..1024 (default 32). Returned as hex and base64url."},"count":{"type":"string","description":"How many integers, 1..1000 (default 1). Integer mode only."}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object"}}}}},"responseSchema":{"type":"json","example":{"ts":"2026-08-01T00:00:00.000Z","hex":"9f86d081884c7d65…","bytes":32,"base64":"n4bQgYhMfWWa…","source":"node:crypto randomBytes (CSPRNG)"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.01","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.01/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_JySM-wZrsVYzgYZUebPBz","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.01","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Generates cryptographically secure random integers in a specified range or random bytes (hex/base64) server-side for deterministic or sandboxed AI agents","exampleAgentPrompt":"I need 5 cryptographically secure random integers between 1 and 100, rejection-sampled so there's no modulo bias — please use the server-side CSPRNG.","exampleUseCases":[{"title":"Secure nonce for session token","prompt":"Generate 32 random bytes from a server-side CSPRNG and give me both the hex and base64url encodings so I can use them as a session nonce."},{"title":"Lottery number picker","prompt":"Pick 6 unique random integers between 1 and 49 using a cryptographically secure source — I need them for a lottery draw with no bias."},{"title":"Simulation random sampling","prompt":"I need 500 random integers between 0 and 999 for a Monte Carlo simulation — make sure they're from a proper CSPRNG with no modulo bias."}],"resultDescription":"Returns random integers uniformly sampled in [min, max] (rejection-sampled, no modulo bias) with a count up to 1000, or random bytes (1–1024) encoded as both hex and base64url. The response includes metadata stating the randomness source and any applicable limits.","failureModes":["min >= max returns an error (max must be strictly greater than min)","bytes out of range 1-1024 returns a validation error","count out of range 1-1000 returns a validation error","mixing integer-mode and byte-mode parameters incorrectly may produce an error or default behavior","payment failure (x402) if USDC balance is insufficient — returns 402 Payment Required"],"whenToPreferThis":"Use this endpoint when your AI agent runs in a deterministic or sandboxed environment that cannot generate its own entropy, and you need cryptographically secure randomness. Prefer it over pseudo-random alternatives when generating nonces, session tokens, cryptographic seeds, or running unbiased lotteries and simulations. The rejection-sampling guarantee makes it superior to modulo-based random integer generation.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T18:44:52.494Z","isFirstParty":false}