Ever had the issue that you hit the timeout of the OpenAI client and could not find any quick resolution? Well, don’t worry - Here you go! // Used NuGet: Azure.AI.OpenAI@2.0.0 using OpenAI; using OpenAI.Chat; // ... var config = sp.GetRequiredService<IOptions<AIConfiguration>>().Value; var apiKey = config.ApiKey; var client = new OpenAIClient(new(config.ApiKey), new OpenAIClientOptions { NetworkTimeout = TimeSpan.FromMinutes(3) // Specify your timeout here }); ...
February 12, 2025