Jump to content

Recommended Posts

The code below to call the ChatGPT API was generated completely by ChatGPT itself. Enjoy.

 It's able to write code in autoit, at least at a beginner level pretty darn well. Took some poking but it works.  Also a word of warning, my API key took a few minutes to start working after being generated if you want to use the API. Seems like we're well on our way to being replaced lol.

; Store your API key in a variable
Local $api_key = "yourkey"

; Create the WinHttpRequest object
Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")

; Open a POST request to the OpenAI API
$oHTTP.Open("POST", "https://api.openai.com/v1/engines/davinci-codex/completions", False)

; Set the headers for the request
$oHTTP.SetRequestHeader("Content-Type", "application/json")
$oHTTP.SetRequestHeader("Authorization", "Bearer " & $api_key)

; Send the request with the prompt and temperature
$oHTTP.Send('{"prompt": "What is an atom made of?", "temperature": 0.7}')

; Get the response text
Local $response = $oHTTP.ResponseText
ConsoleWrite("Generated text: " & $response & @CRLF)
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...