Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
#Include <JSON>
http := WinHttpRequest()
url := "http://localhost:1234/v1/chat/completions"
body := {}
body.messages := [{"role":"user", "content":"Hello There"}]
body.max_tokens := -1
headers := {"Content-Type": "application/json"}
response := http.POST(url, JSON.Dump(body), headers, {Object:true})
obj := JSON.Load(response.Text)
text := obj.choices[1].message.content
msgbox, % text
ExitApp