rlancemartin/doc-gpt

Hardcoding the API Key

Opened this issue · 1 comments

This is awesome. I was playing around with it to try and hardcode my API key into my own branch, I got openai.error.AuthenticationError: Incorrect API key provided, and then that key seems to die so I need to create a new one to get it to work.

I am a bit of a newbie to dev with a reasonable understanding of python.

I tried to populate the key in the text box, hard code it, and put it in a txt file, getting the same issue.

Is their a specific way of hardcoding an API key (assuming maybe having to hash it)?

Basically, I am just trying to create a project where I don't have to enter my API key in every time (I've forked to my Streamlit).

Any suggestions would be awesome.

yes, just set it as an environment variable for local testing:
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety

in the app, you can then remove the check for the user-supplied API key in this line:
https://github.com/PineappleExpress808/doc-gpt/blob/8b1ceec536c050728a0e94e242bf315377259efb/doc-gpt.py#L51