Getting "Resource Not Found" while using OpenAIClient.

Alex Mirzayanov 25 Reputation points
2023-06-27T18:21:15.0033333+00:00

I'm having trouble using C# API. Details below.

API request - OpenAIClient client = new OpenAIClient(
 new Uri('https://srch.openai.azure.com/openai/deployments/SRCH/completions?api-version=2022-12-01

'),
 new AzureKeyCredential('xxx'));
 
Response<Completions> completionsResponse = client.GetCompletions(
 deploymentOrModelName: 'SRCH',
 new CompletionsOptions()
 {
 Prompts =
 {
 /* prompt removed */
 },
 Temperature = (float)0,
 MaxTokens = 262,
 StopSequences = { '###', '##'},
 NucleusSamplingFactor = (float)0.5,
 FrequencyPenalty = (float)0,
 PresencePenalty = (float)0,
 });

 Completions completions = completionsResponse.Value;

Question: What model or model are you using?
Answer:
gpt-35-turbo

Question: Details
Answer: I used 'View Code'-'Sample code' (c#) from the 'Completions Playground'
The error I recieve is:

Azure.RequestFailedException: Resource not found
Status: 404 (Resource Not Found)
ErrorCode: 404

Content:
{'error':{'code':'404','message': 'Resource not found'}}

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,132 questions
{count} votes

Accepted answer
  1. romungi-MSFT 46,476 Reputation points Microsoft Employee
    2023-06-28T06:19:10.4433333+00:00

    @Alex Mirzayanov I think the endpoint should only be https://<resource_name>.openai.azure.com instead of the endpoint of completions. Please see this sample for an example.

                string key = "YOUR_AZURE_OPENAI_KEY";
                string endpoint = "https://myaccount.openai.azure.com/";
                var client = new OpenAIClient(new Uri(endpoint), new AzureKeyCredential(key));
    
                List<string> examplePrompts = new(){
                    "How are you today?",
                    "What is Azure OpenAI?",
                    "Why do children love dinosaurs?",
                    "Generate a proof of Euler's identity",
                    "Describe in single words only the good things that come into your mind about your mother.",
                };
    
                string deploymentName = "text-davinci-003";
    
                foreach (string prompt in examplePrompts)
                {
                    Console.Write($"Input: {prompt}");
                    CompletionsOptions completionsOptions = new CompletionsOptions();
                    completionsOptions.Prompts.Add(prompt);
    
                    Response<Completions> completionsResponse = client.GetCompletions(deploymentName, completionsOptions);
                    string completion = completionsResponse.Value.Choices[0].Text;
                    Console.WriteLine($"Chatbot: {completion}");
                }
    
    

    I hope this helps!!

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.