Generator Utilities

Pick Random

Randomly selects one or more items from a provided list with true randomness. Use via MCP in Cursor or Windsurf, or call GET /v1/generate/pick directly. Perfect for A/B testing scenarios, random sampling, or when AI agents need unbiased selection from options. Returns deterministic results with optional seed values for reproducible randomness.

API Endpoint

GET /v1/generate/pick

Code Examples

curl "https://tinyfn.io/v1/generate/pick" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/generate/pick', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/generate/pick',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's generator tools:

{
  "mcpServers": {
    "tinyfn-generator": {
      "url": "https://tinyfn.io/mcp/generator",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I pick multiple random items without duplicates?

Set the count parameter to your desired number and ensure it doesn't exceed your list length. The tool automatically prevents duplicates in a single selection.

Can I get reproducible random results for testing?

Yes, provide a seed parameter to get consistent results across runs. Same seed + same list = same random selection every time.

What happens if I request more items than exist in my list?

The API returns an error. You can't pick 10 items from a 5-item list, even with replacement disabled by default.

How does this compare to using Math.random() in my code?

TinyFn provides cryptographically secure randomness and handles edge cases like empty lists. Plus MCP integration means AI agents get true randomness instead of hallucinated selections.

Can I pick random items with replacement enabled?

Check the API documentation for replacement options. Some implementations allow sampling with replacement for statistical use cases.

Try Pick Random Now

Get your free API key and start using Pick Random in seconds.

Get Free API Key