Created
March 2, 2023 08:40
-
-
Save amn41/0b82b7e78778f3d0c7aa99869bd218f2 to your computer and use it in GitHub Desktop.
chatGPT on the command line - add to your bashrc/zshrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gpt() { | |
local url="https://api.openai.com/v1/chat/completions" | |
local model="gpt-3.5-turbo" | |
local body="{\"model\":\"$model\", \"messages\":[{\"role\": \"user\", \"content\": \"$1\"}]}" | |
local headers="Content-Type: application/json" | |
local auth="Authorization: Bearer ${OPENAI_API_KEY}" | |
curl -s -H "$headers" -H "$auth" -d "$body" "$url" \ | |
| jq -r '.choices[0].message.content' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the same problem @himalayasharma but when I debug the return I realize that I got the message:
"You exceeded your current quota, please check your plan and billing details.". Check if you have quota too. 😄