microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.31k stars 3.13k forks source link

Notebook 07-DALL-E-2: Access Denied #1339

Closed mhackermsft closed 1 year ago

mhackermsft commented 1 year ago

Describe the bug When following the Notebook sample 07-DALL-E-2 I am getting an Access Denied error when executing the code block under "Generate a (random) image with DALL-E 2.

I have an OpenAI key and the prior notebooks (01-06) work with no issues.

To Reproduce Steps to reproduce the behavior:

  1. Open Notebooks, dotnet, 07-DALL-E-2
  2. Run the first 2 code blocks successfully
  3. Run the 3rd code block under the heading of "Generate a (random) image with DALL-E 2. This will result in an Access Denied error shown below.

Error: Microsoft.SemanticKernel.AI.AIException: Access denied: The request is not authorized, HTTP status: Unauthorized at Microsoft.SemanticKernel.Connectors.AI.OpenAI.CustomClient.OpenAIClientBase.ExecutePostRequestAsync[T](String url, String requestBody, CancellationToken cancellationToken) at Microsoft.SemanticKernel.Connectors.AI.OpenAI.CustomClient.OpenAIClientBase.ExecuteImageGenerationRequestAsync(String url, String requestBody, Func2 extractResponseFunc, CancellationToken cancellationToken) at Microsoft.SemanticKernel.Connectors.AI.OpenAI.ImageGeneration.OpenAIImageGeneration.GenerateImageAsync(String description, Int32 width, Int32 height, String format, Func2 extractResponse, CancellationToken cancellationToken) at Submission#31.<>d__0.MoveNext()

Expected behavior Code block executes successfully and generates a random image.

craigomatic commented 1 year ago

Hmm, I'm not able to reproduce with my OpenAI key, the notebook works as expected.

Can you confirm that you have DALL-E 2 access with your API key, maybe by using postman or curl? https://platform.openai.com/docs/guides/images/usage?lang=curl

mhackermsft commented 1 year ago

Hmm, I'm not able to reproduce with my OpenAI key, the notebook works as expected.

I am using Azure OpenAI and not the public OpenAI product. In Azure OpenAI I can go into the DALL-E playground and generate images. It also shows the Python code for calling the API endpoint. Is it possible that Semantic Kernel is not yet working with Azure OpenAI?

craigomatic commented 1 year ago

Ah, with Azure OpenAI you might be blocked until this PR comes in: #1209

mhackermsft commented 1 year ago

Closing issue as it appears that the current release doesn't support DALL-E in Azure Open AI. Possible follow-up would be to update the notebook to indicate that some samples do not currently work with Azure Open AI.