AI API Key Generator

Generate random API keys with a custom prefix, length and character set, built on your browser's Web Crypto API.
100% client-side · No Math.random() anywhere in this tool

A recognizable, non-secret label such as sk- or myapp_. It adds no entropy. Spaces are removed.
Counts the random part only, not the prefix.
Letters and digits are safe in headers, URLs and .env files.
Format presets
Presets copy the look of each provider's keys for your own APIs, mocks and tests. They will not work with those providers.
Click "Generate key" to create one.
48
Random characters
62
Symbols in set
285
Bits of entropy

Keys exist only in this page's memory. Store one in an environment variable or secret manager, and never share it.

How These Keys Are Generated

The browser's Web Crypto API - crypto.getRandomValues() - is a cryptographically secure random number generator built into every modern browser, and it is the only source of randomness used here. Each character is chosen with rejection sampling so every symbol in the set is equally likely, and the entropy figure is simply the number of random characters times log2 of the set size. A key made here is a random token for your systems: it is not issued by, and will not authenticate with, any AI provider.

Web Crypto, Not Math.random

Every character comes from crypto.getRandomValues() - Math.random() is never used

Unbiased Selection

Rejection sampling removes the modulo bias that skews simple byte-to-character mapping

Honest Entropy

Entropy covers the random part only, and the page warns you below 128 bits

Not a Provider Key

Presets mimic key formats for your own APIs and tests; they do not unlock any provider

No Silent Downgrade

If the Web Crypto API is missing, the tool says so and refuses to generate

Privacy First

Everything runs in your browser. Nothing is uploaded or stored

How to Use Your API Key

  1. Pick a prefix, length and character set, or start from a format preset.
  2. Click Copy and put the key in your .env file or secret manager, for example API_KEY=your_generated_key.
  3. Read it in code, for example const apiKey = process.env.API_KEY;.
  4. Send it with requests, for example Authorization: Bearer YOUR_API_KEY.

Frequently Asked Questions

1. Where does the randomness in these keys come from?

From your browser's Web Crypto API, specifically crypto.getRandomValues(), a cryptographically secure random number generator (CSPRNG) built into every modern browser. Characters are picked with rejection sampling, so every character in the chosen set is equally likely and there is no modulo bias. Math.random() is never used. Nothing is sent anywhere: the page's security policy blocks network requests, and you can confirm that in your browser's developer tools.

2. Can I use a generated key with OpenAI, Google Gemini or Anthropic Claude?

No. Those providers issue their own keys from their own dashboards, and a key made here will not authenticate with them. The presets only copy the format (prefix, length, character set) so the result looks like the real thing. They are useful for your own APIs, gateways and proxies, self-hosted model servers, mock servers, test fixtures and documentation examples. Never paste a real provider key into any website, including this one.

3. How long should an API key be?

Aim for at least 128 bits of entropy; 256 bits leaves a generous margin. Entropy is the number of random characters multiplied by log2 of the character-set size, so 32 hex characters give 128 bits, 22 alphanumeric characters give about 130 bits, and the default 48 alphanumeric characters give about 285 bits. The prefix is not random, so it adds no entropy. The meter on this page shows the figure for the random part only and warns you when it falls below 128 bits.

4. Which character set should I choose?

Alphanumeric and Base64URL are safe almost everywhere: HTTP headers, URLs, JSON and .env files. Hexadecimal is the most compatible but needs more characters for the same strength. The special-character set includes $ ! & * ^ #, which many shells and .env parsers treat specially, so it must be quoted and is easy to mangle; prefer Base64URL unless you have a reason not to.

5. How should I store and handle generated keys?

Never hardcode keys in source code or client-side JavaScript. Keep them in environment variables (and keep .env out of version control) or a secret manager such as AWS Secrets Manager, HashiCorp Vault or Doppler. Use separate keys for development, staging and production, rotate them on a schedule you choose, and rotate immediately if one is ever exposed. On your server, store only a hash of each key where you can, so a database leak does not reveal usable keys.

6. Can I generate keys the same way in my own code?

Yes. This JavaScript uses the same approach, including rejection sampling to avoid modulo bias:

function generateKey(length = 48, charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
  const n = charset.length;
  const limit = 256 - (256 % n);
  const buf = new Uint8Array(length * 2);
  let out = '';
  while (out.length < length) {
    crypto.getRandomValues(buf);
    for (let i = 0; i < buf.length && out.length < length; i++) {
      if (buf[i] < limit) out += charset[buf[i] % n];
    }
  }
  return out;
}

The limit check discards bytes that would make some characters slightly more likely than others.

7. Does this tool store or send my keys anywhere?

No. Generated keys exist only in your browser's memory while the page is open, and are not written to local storage or sent to a server. The only thing the site remembers is your language choice for the menu. There are no analytics on this page, and its content security policy blocks outgoing network requests.

8. What happens if my browser doesn't support the Web Crypto API?

Key generation is disabled and the page tells you why, rather than silently falling back to Math.random() or another non-cryptographic source. Every modern browser supports it, but a security tool should never quietly produce weaker output while still calling it secure.