The new AI feature added to BBT is very convenient, bringing me great convenience, which I greatly appreciate. However, not being able to use the OpenAI API has caused significant trouble for me and my country. Our region can access the OpenAI API through Microsoft Azure, so please establish the corresponding API access. Thank you!
@channelchoi Are you referring to ChatGPT related Actions? e.g. Transform & Replace Selection With ChatGPT
.
If yes, have you tried inputting Azure endpoints in the "URL to call" field?
yep that should work, make sure to enter your API key and the full url you want to use.
E.g.
https://api.groq.com/openai/v1/chat/completions
@fortred2 @Andreas_Hegenberg Thank you very much! Initially, I couldn't find the correct URL and encountered a 404 error. After I entered the correct API and URL, the 404 error message disappeared. However, the output content is blank. Could you please help me resolve this issue?
Note: The same prompt works in GPT-3.5 and produces content.
Here is the screen recording:
did you enter your azure api key and select a model that is available on azure?
You can check the logs in ~/Library/Application Support/BetterTouchTool/Logs for any error message (go there via Finder > Go > Go to Folder, make sure to include the ~)
they say the api key is missing or incorrect. Are you sure it is entered correctly?
I'm quite sure that the API key I entered is correct. I also tested this API in other software and it is correct and functioning properly. Could it be Limited Access for Azure AI services?
Could you try whether it works with curl in your terminal?
curl https://obsidiangpt.openai.azure.com/openai/deployments/GPT4o/chat/completions?api-version=2023-03-15-preview -H "Content-Type: application/json" -H "Authorization: Bearer YOURAPIKEYHERE" -d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."
},
{
"role": "user",
"content": "Compose a poem that explains the concept of recursion in programming."
}
]
}'
replace YOURAPIKEYHERE with your key
sounds like you forgot the "curl" at the beginning
I copied your code and ran it in the terminal. I replaced my API and also confirmed that it started with "curl". I wanted to take a screenshot to show the running result, but the system prompted that I was a new user, so I can only describe it verbally.
I enabled your user for uploading screenshots.
Try to copy the code I posted via the copy function and try running it immediately without change, if it then returns a different error you might have accidentally broken something while inserting the api key:
(make sure the quotes etc. stay the same)
ah you have zsh. This is something zsh specific, apparently there is a bug in zsh that causes this (or maybe it's not a bug but a feature idk).
Try like this (prefix with noglob)
noglob curl https://obsidiangpt.openai.azure.com/openai/deployments/GPT4o/chat/completions?api-version=2023-03-15-preview -H "Content-Type: application/json" -H "Authorization: Bearer YOURAPIKEYHERE" -d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."
},
{
"role": "user",
"content": "Compose a poem that explains the concept of recursion in programming."
}
]
}'
I input the new code you provided and got a new feedback. Then I input the API and also got the same feedback.
ok in that case I'm pretty sure something is wrong with the api key :-/
I think you may be inadvertently passing the wrong OpenAI API key to the curl
command.
Here's my suggestion of steps to resolve the issue. Run each command one after another. Report back the results with screenshots please.
# save your openai key to an environment variable
export openai_key=REPLACE_THIS_TEXT_WITH_YOUR_OPENAI_KEY
# check if the environment variable was correctly saved
echo $openai_key
# clear your terminal output so you can safely take a screenshot
clear
# Enclosed the URL in single quotes to prevent Zsh from interpreting `?` as a wildcard.
# Added line breaks and indentation to the command for better readability.
curl 'https://obsidiangpt.openai.azure.com/openai/deployments/GPT4o/chat/completions?api-version=2023-03-15-preview' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $openai_key" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."
},
{
"role": "user",
"content": "Compose a poem that explains the concept of recursion in programming."
}
]
}'
# take a screenshot automatically and save it to your desktop
screencapture ~/Desktop/$(date +%y%m%d_%H_%M_%S)_screenshot.png
The following are the results of my running the code in sequence:
I have really confirmed many times that my API KEY was directly copied from the corresponding interface of Azure OpenAI @Andreas_Hegenberg . Here is the model interface I deployed: