OkGoDoIt / OpenAI-API-dotnet

An unofficial C#/.NET SDK for accessing the OpenAI GPT-3 API

Home Page:https://www.nuget.org/packages/OpenAI/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure - HTTP status code: NotFound. Content: {"error":{"code":"404","message": "Resource not found"}})'

AlexGrossi opened this issue · comments

I am trying to connect to Azure using OpenAIAPI. However, despite my deployment ID and resourcename being correct, I am encountering the following error:

System.AggregateException
'One or more errors occurred. (Error at images/generations (https://LSopenAIUS.openai.azure.com/openai/deployments/lasetestai/images/generations?api-version=2022-12-01) with HTTP status code: NotFound. Content: {"error":{"code":"404","message": "Resource not found"}})'

Inner Exception:
HttpRequestException: Error at images/generations (https://LSopenAIUS.openai.azure.com/openai/deployments/lasetestai/images/generations?api-version=2022-12-01) with HTTP status code: NotFound. Content: {"error":{"code":"404","message": "Resource not found"}}

The code

public void CreateImageWithUrl(string query)
        {
            OpenAIAPI api = OpenAIAPI.ForAzure(deployment, deploymentID, key);
            //OpenAIAPI api = new OpenAIAPI(testkey2);
            var results = api.ImageGenerations.CreateImageAsync(new ImageGenerationRequest(query, 1, ImageSize._256)).Result;

            Assert.That(results.Data.First().Url.Length > 0);
            Assert.That(results.Data.First().Url.StartsWith("https://"));
            Console.WriteLine(results.Data[0].Url);
        }

What I tried
I can confirm that deployment and deployment ID are correct. However, not much more testing can be conducted further until I understand what is causing this issue.

I think you need to specify a more up to date Azure API version using api.ApiVersion = "2023-03-15-preview";, although as I don't have access to the Azure API it's hard for me to debug.
See https://github.com/OkGoDoIt/OpenAI-API-dotnet#azure for Azure details.