0

I am trying steps from this tutorial - https://github.com/Azure-Samples/openai/blob/cf0f19f36a30925e3891137b0bc2539e25687cac/Basic_Samples/AAD_Integration/setup_aad.md

I tried to run the completion from Azure CLI, which worked fine. However, it didn't work when I use powershell on local computer

on Azure CLI, I run the curl api,

curl https://aoai-try-mc.openai.azure.com/openai/deployments/try-davinci/completions?api-version=2022-12-01 -H "Content-Type:application/json" -H "api-key:keygoeshere" -d '{"prompt":"Tell me a funny story"}'

on powershell on desktop, I get error when I run the following command (I know that curl is different on Windows so I have made changes based on my search on how to create similar curl command

curl https://aoai-try-mc.openai.azure.com/openai/deployments/try-davinci/completions?api-version=2022-12-01 -H @{"Content-Type"="application/json" ; "api-key"="keygoeshere"} -Body @{"prompt"="Tell me a funny story"}
curl : {"error":{"code":"404","message": "Resource not found"}}
At line:1 char:1
+ curl https://aoai-try-mc.openai.azure.com/openai/deployments/try-davi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

How do I solve the issues?

Manu Chadha
  • 15,555
  • 19
  • 91
  • 184
  • Without additional content, it's hard to tell. Have you sucessfully created an Azure OpenAI resource on Azure and set properly your `OPENAI_API_BASE` value? Does your `accessToken` value is not empty? – Nicolas R May 31 '23 at 10:41
  • I have updated the question. I was able to run the API in Azure CLI but still can't do it on desktop. I think the issue with azure clli was I had to use `api-key` and not `authorisation` header though I don't know what difference it makes. – Manu Chadha Jun 01 '23 at 06:57
  • You don't pass the same things to api-key or authorization headers: one is to provide the endpoint key, the other one is to provide an AAD token – Nicolas R Jun 01 '23 at 12:43

0 Answers0