Skip to content

Instantly share code, notes, and snippets.

@kxzk
Created March 29, 2023 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kxzk/d338a8383ad3017529e15e41c6f30871 to your computer and use it in GitHub Desktop.
Save kxzk/d338a8383ad3017529e15e41c6f30871 to your computer and use it in GitHub Desktop.
function img_gpt -a prompt
set create_img (curl https://api.openai.com/v1/images/generations -s \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"prompt": "'$prompt'",
"n": 1,
"size": "1024x1024"
}')
echo $create_img | jq
set url (echo $create_img | jq -r '.data[0].url')
set rand_num (random 1 1000000)
curl -s $url -o img-"$rand_num".png
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment