Skip to content

Instantly share code, notes, and snippets.

@amn41
Created March 2, 2023 08:40
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amn41/0b82b7e78778f3d0c7aa99869bd218f2 to your computer and use it in GitHub Desktop.
Save amn41/0b82b7e78778f3d0c7aa99869bd218f2 to your computer and use it in GitHub Desktop.
chatGPT on the command line - add to your bashrc/zshrc
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'
}
@JuanBarros2
Copy link

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. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment