ERROR: "An error occurred in the secure channel support" Word VBA

I have a program in Word VBA that has been running fine for over a year or more. I am using model gpt-4o-mini and verified the end points. I have tried pretty much every possible solution regarding registry entries and resetting network settings, but I still haven’t had any luck.

Here is a sample of the code I am using which errors out on the send line.
Set httpRequest = CreateObject(“WinHttp.WinHttpRequest.5.1”)
'Set httpRequest = CreateObject(“MSXML2.ServerXMLHTTP.6.0”)

            httpRequest.setTimeouts 120000, 120000, 120000, 120000 ' This sets all timeout values to 60 second
            Dim messages As String
            messages = """messages"": [" & _
                    "{""role"": ""system"", ""content"": ""You are a highly skilled RFP specialist.""}," & _
                    "{""role"": ""user"", ""content"": """ & Prompt & """}" & _
                    "]"
            
            
            requestBody = "{" & _
                            """model"": ""gpt-4o-mini""," & _
                            messages & "," & _
                            """max_tokens"": " & maxTokensToUse & "," & _
                            """temperature"": 0.0" & _
                          "}"
            With httpRequest
                .Open "POST", API_ENDPOINT, False
                .setRequestHeader "Content-Type", "application/json"
                .setRequestHeader "Authorization", "Bearer API KEY HERE-NOT ENTERING HERE FOR OBVIOUS REASONS"
                .Send (requestBody)
            End With
1 Like

Hi and welcome to the community!

You can take a look if the suggested solution in this topic will work for you:

1 Like

I have tried pretty much everything I can and still nothing is working. I have reinstalled Office and still nothing fixed it. On my server running Windows server 2019 it seems to be running fine, so I think this is a Microsoft thing, possible with .NET?
I am sure there will be a lot more people in this boat and this needs to have a resolution that does not require us to rewrite stuff. I am thinking Microsoft in their latest update to Edge that more or less turns on CoPilot is the cause.