API Key Formats: How to Identify Keys by Their Prefix
2026-07-13·
ReferenceAPI KeysSecurity
Why Key Formats Matter
Knowing what a key looks like helps you:
- Quickly identify which service a leaked key belongs to
- Verify you're using the right key in the right environment
- Spot misconfigured keys before they cause failures
- Understand key scopes and permissions from format alone
Complete API Key Format Reference
AI / LLM Providers
| Provider | Prefix | Example | Length |
|---|---|---|---|
| OpenAI | sk-proj- or sk- | sk-proj-abc...xyz | ~164 chars |
| Anthropic | sk-ant- | sk-ant-api03-abc... | ~108 chars |
| Google Gemini | AIza | AIzaSyABC...xyz | 39 chars |
| DeepSeek | sk- | sk-abc123...xyz | ~35 chars |
| Mistral | (no prefix) | abc123...xyz | ~32 chars |
| Cohere | (no prefix) | abc123...xyz | ~40 chars |
| Groq | gsk_ | gsk_abc123... | ~56 chars |
| xAI (Grok) | xai- | xai-abc123... | ~71 chars |
| OpenRouter | sk-or- | sk-or-v1-abc... | ~56 chars |
| Together AI | (no prefix) | abc123...xyz | ~64 chars |
| Perplexity | pplx- | pplx-abc123... | ~51 chars |
Payment & Communication
| Provider | Prefix | Example |
|---|---|---|
| Stripe (secret) | sk_live_ or sk_test_ | sk_live_abc123... |
| Stripe (publishable) | pk_live_ or pk_test_ | pk_live_abc123... |
| SendGrid | SG. | SG.abc123...xyz |
Developer Tools
| Provider | Prefix | Example |
|---|---|---|
| GitHub (classic) | ghp_ | ghp_abc123...xyz |
| GitHub (fine-grained) | github_pat_ | github_pat_abc... |
| Hugging Face | hf_ | hf_abc123...xyz |
How Auto-Detection Works
Api Key Chain uses prefix matching + regex patterns to identify keys:
// Simplified detection logic
function detectProvider(key: string): string | null {
if (key.startsWith('sk-proj-') || key.match(/^sk-[A-Za-z0-9]{48}/))
return 'openai'
if (key.startsWith('sk-ant-'))
return 'anthropic'
if (key.startsWith('AIza'))
return 'gemini'
if (key.startsWith('sk_live_') || key.startsWith('sk_test_'))
return 'stripe'
if (key.startsWith('SG.'))
return 'sendgrid'
if (key.startsWith('ghp_') || key.startsWith('github_pat_'))
return 'github'
// ... 13+ more patterns
}
Security Implications of Key Formats
What Prefixes Reveal
- Environment: Stripe's
livevstestprefix tells you immediately if it's a production key - Scope: GitHub's
github_pat_(fine-grained) vsghp_(classic) indicates permission granularity - Project: OpenAI's
sk-proj-prefix ties the key to a specific project
What Prefixes Don't Reveal
- Whether the key has been revoked
- The actual permissions or rate limits
- The associated billing plan
⚠️ Remember: Seeing a key's format tells you what service it's for, but not if it's still active. Always validate before relying on a key.
Using the Reference
Bookmark this page and use it next time you need to:
- Audit which keys you have across services
- Identify a key found in old code or config files
- Verify you haven't mixed up test and live keys
🔍 Try it: Paste any API key on the homepage and see the auto-detection in action across every supported provider. For Claude keys, the Anthropic (Claude) API key checker explains thesk-ant-api03-andsk-ant-adminformats.
Related Posts
How to Share API Keys With Your Team Securely
Stop pasting API keys into chat. Share them through an encrypted folder where every person has their own login and PIN, and access can be removed in one click.
Get an Email When Your API Key Stops Working
API keys get revoked, expire or run out of credit without warning. Here is how to watch a key and get an email when it fails, and again when it works.
Never Miss an API Key Expiry Date Again
Many API keys and tokens expire on a fixed date. Record the date once and get reminder emails 30, 7 and 1 day before, and on the day it expires.