Skip to content

About

CLI tool to validate API keys for AI providers (Anthropic, OpenAI, Gemini, NVIDIA, OpenRouter)

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

key-checker

CLI tool to validate API keys for AI providers. Checks whether your keys are still active and working.

Supported Providers

Provider Validation Method
Anthropic Sends a minimal 1-token completion request
OpenAI Lists available models
Gemini Lists available models
NVIDIA Lists available models
OpenRouter Queries key info and remaining credits

Installation

git clone https://github.com/skynergroup/key-checker.git
cd key-checker
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Commands

key-checker                                         # Check all keys from .env or environment
key-checker --anthropic sk-ant-xxx                  # Check a single Anthropic key
key-checker --openai sk-xxx                         # Check a single OpenAI key
key-checker --gemini AIza-xxx                       # Check a single Gemini key
key-checker --nvidia nvapi-xxx                      # Check a single NVIDIA key
key-checker --openrouter sk-or-xxx                  # Check a single OpenRouter key
key-checker --anthropic sk-ant-xxx --openai sk-xxx  # Check multiple keys at once
key-checker --json                                  # Output results as JSON
key-checker --anthropic sk-ant-xxx --json           # Combine CLI keys with JSON output
key-checker --help                                  # Show help

Usage

Pass keys directly

key-checker --anthropic sk-ant-xxx --openai sk-xxx --gemini AIza-xxx

Use environment variables

export ANTHROPIC_API_KEY=sk-ant-xxx
export OPENAI_API_KEY=sk-xxx
export GEMINI_API_KEY=AIza-xxx
export NVIDIA_API_KEY=nvapi-xxx
export OPENROUTER_API_KEY=sk-or-xxx

key-checker

Use a .env file

Create a .env file in the current directory (see .env.example):

ANTHROPIC_API_KEY=sk-ant-xxx
OPENAI_API_KEY=sk-xxx
GEMINI_API_KEY=AIza-xxx
NVIDIA_API_KEY=nvapi-xxx
OPENROUTER_API_KEY=sk-or-xxx

Then run:

key-checker

JSON output

key-checker --json
[
  {
    "provider": "Anthropic",
    "valid": true,
    "status": "Valid",
    "detail": "claude-sonnet-4-20250514"
  },
  {
    "provider": "OpenAI",
    "valid": false,
    "status": "Invalid",
    "detail": "401"
  }
]

Key Input Priority

Keys are resolved in this order (first match wins):

  1. CLI arguments (--anthropic KEY)
  2. .env file in the current directory
  3. Environment variables

Only providers with a key present are checked. The rest are skipped silently.

Status Codes

Status Meaning
Valid Key is active and working
Valid (rate limited) Key is valid but currently rate limited (429)
Invalid Key was rejected (401/403)
Unreachable Could not connect to the provider
Timeout Provider did not respond within 5 seconds

Exit Codes

  • 0 — all checked keys are valid
  • 1 — one or more keys are invalid, or no keys were found

Development

pip install -e ".[dev]"
pytest tests/ -v

About

CLI tool to validate API keys for AI providers (Anthropic, OpenAI, Gemini, NVIDIA, OpenRouter)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages