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

ProviderPrefixExampleLength
OpenAIsk-proj- or sk-sk-proj-abc...xyz~164 chars
Anthropicsk-ant-sk-ant-api03-abc...~108 chars
Google GeminiAIzaAIzaSyABC...xyz39 chars
DeepSeeksk-sk-abc123...xyz~35 chars
Mistral(no prefix)abc123...xyz~32 chars
Cohere(no prefix)abc123...xyz~40 chars
Groqgsk_gsk_abc123...~56 chars
xAI (Grok)xai-xai-abc123...~71 chars
OpenRoutersk-or-sk-or-v1-abc...~56 chars
Together AI(no prefix)abc123...xyz~64 chars
Perplexitypplx-pplx-abc123...~51 chars

Payment & Communication

ProviderPrefixExample
Stripe (secret)sk_live_ or sk_test_sk_live_abc123...
Stripe (publishable)pk_live_ or pk_test_pk_live_abc123...
SendGridSG.SG.abc123...xyz

Developer Tools

ProviderPrefixExample
GitHub (classic)ghp_ghp_abc123...xyz
GitHub (fine-grained)github_pat_github_pat_abc...
Hugging Facehf_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 live vs test prefix tells you immediately if it's a production key
  • Scope: GitHub's github_pat_ (fine-grained) vs ghp_ (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 the sk-ant-api03- and sk-ant-admin formats.

Related Posts