From 6ee4c8d47d21035af8850b9e50eda09d82ba2153 Mon Sep 17 00:00:00 2001 From: leauny <42369176+leauny@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:00:55 +0800 Subject: [PATCH] feat: support different api url. --- chatgpt.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/chatgpt.sh b/chatgpt.sh index 81df29a..d543acf 100755 --- a/chatgpt.sh +++ b/chatgpt.sh @@ -13,11 +13,18 @@ PROCESSING_LABEL="\n\033[90mProcessing... \033[0m\033[0K\r" OVERWRITE_PROCESSING_LINE=" \033[0K\r" if [[ -z "$OPENAI_KEY" ]]; then - echo "You need to set your OPENAI_KEY to use this script" + echo "You need to set your OPENAI_KEY and OPENAI_BASE_URL(optional) to use this script" echo "You can set it temporarily by running this on your terminal: export OPENAI_KEY=YOUR_KEY_HERE" exit 1 fi +if [[ -z "$OPENAI_BASE_URL" ]]; then + OPENAI_BASE_URL="https://api.openai.com" + echo "Use official api url." +else + echo "Use \"${OPENAI_BASE_URL}\" as api url." +fi + usage() { cat <