1

when I push the code with API key from openAi , it disabled and deleted automatic from openAi , how can I solve this problem?

IM trying to add my API key to my code and push it into githup to deployed it

  • 3
    You should not check credentials in to Git. OpenAI apparently scans repositories for their API keys. Assign the key to an environment variable, use a secrets vault, write it in a configuration file on deployment. Anything but source control. – CodeCaster Apr 15 '23 at 21:19
  • I agree with @CodeCaster, sharing your API keys is a bad idea – JustSightseeing Apr 15 '23 at 21:20

1 Answers1

1

Do you use any public repo to publish the code of your app? Something like Github Pages by any chance?

Then it might be why. Github is scanning your code for API tokens; if any are detected, they report them to OpenAI to invalidate them.

Make sure your repo is private, don't hardcode API keys in your code, and use environment variables instead.

Similar question to

openai api key automatically rotating when deployed

picsoung
  • 6,314
  • 1
  • 18
  • 35
  • You are right. Just faced the same issue. The API key must be stored in environment variables. – Tahid Jun 08 '23 at 06:46