Created
March 29, 2023 08:37
-
-
Save kxzk/d338a8383ad3017529e15e41c6f30871 to your computer and use it in GitHub Desktop.
This file contains 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 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