OpenAI-API-dotnet icon indicating copy to clipboard operation
OpenAI-API-dotnet copied to clipboard

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

Open AlexGrossi opened this issue 1 year ago • 1 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.

AlexGrossi avatar Nov 07 '23 13:11 AlexGrossi

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.

OkGoDoIt avatar Dec 07 '23 00:12 OkGoDoIt