sgpt icon indicating copy to clipboard operation
sgpt copied to clipboard

Support api_key and base_url in config.yaml

Open johnd0e opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

I'm aware of set OPENAI_API_KEY and OPENAI_API_BASE env vars, but I'd rather set those in config.

Describe the solution you'd like

Describe alternatives you've considered

No response

Search

  • [X] I did search for other open and closed issues before opening this

Project

  • [X] I have verified that I am using the Go implementation of SGPT (this project) and that it is not another project

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Additional context

No response

johnd0e avatar Feb 12 '24 01:02 johnd0e

I'd be nice if it also supports custom OPENAI_API_KEY and OPENAI_API_BASE (or OPENAI_BASE_URL/Host) in User environment variables in Windows. Standard OpenAI APIs work fine though. I was more thinking of these base on the request title. https://litellm.vercel.app/docs/providers/openai https://litellm.vercel.app/docs/providers/custom_openai_proxy Anyway, tinkering a bit might make sgpt work.

norrybul avatar Apr 05 '24 08:04 norrybul

Here is a workaround to avoid using an environment variable.

Add the directory with the following content into your PATH:

./
├── config.json
└── sgpt.sh
$ cat config.json
{"openai_api_key": "<value>"}

$ cat sgpt.sh
OPENAI_API_KEY=$(cat $(dirname ${BASH_SOURCE[0]})/config.json | jq -r .openai_api_key) sgpt "$@"

Now you can use sgpt.sh instead of sgpt to run your scripts/commands without exposing the API key.

ilya-bystrov avatar Oct 05 '24 02:10 ilya-bystrov