A simple Node.js script to test if an OpenAI API key is valid.
npm installRun the script by providing your OpenAI API key as a command line argument:
node test-key.js YOUR_API_KEYThe script will tell you if the API key is valid and, if it is, show you the available models.
For a valid key:
✅ API key is valid!
Available models: gpt-4, gpt-3.5-turbo, ...
For an invalid key:
❌ API key is invalid!
Error message: Invalid API key provided