Sample code for 30+ languages & platforms
AutoIt

AI: Set Ask Params

See more AI Examples

Demonstrates how to set the following Ask parameters: temperature, effort, and max_output_tokens.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oAi = ObjCreate("Chilkat.Ai")

$oAi.VerboseLogging = True

$oAi.Provider = "google"
$oAi.ApiKey = "MY_API_KEY"
$oAi.Model = "gemini-3-flash-preview"

; Note: Not all models support all params.

; Set Ask params.
$oAskParams = ObjCreate("Chilkat.JsonObject")
$oAskParams.UpdateNumber("temperature","1.2")
$oAskParams.UpdateString("effort","low")
$oAskParams.UpdateInt("max_output_tokens",1024)

$oAskParams.EmitCompact = False
ConsoleWrite($oAskParams.Emit() & @CRLF)

$oAi.SetAskParams($oAskParams)

; Add a text input.
$oAi.InputAddText("Say Hello.")

; Ask the AI for text output.
$bSuccess = $oAi.Ask("text")
If ($bSuccess = False) Then
    ConsoleWrite($oAi.LastErrorText & @CRLF)
    Exit
EndIf

; Get the text response.
$oSbResponse = ObjCreate("Chilkat.StringBuilder")
$oAi.GetOutputTextSb($oSbResponse)
ConsoleWrite($oSbResponse.GetAsString() & @CRLF)

; Sample output:
; Hello! How can I assist you today?

; -------------------------------------------------------------
; The response is in markdown format.
; Also see Markdown to HTML Conversion Examples.
; -------------------------------------------------------------