Tcl
Tcl
AI: Set Ask Params
See more AI Examples
Demonstrates how to set the followingAsk parameters: temperature, effort, and max_output_tokens.
Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set ai [new_CkAi]
CkAi_put_VerboseLogging $ai 1
CkAi_put_Provider $ai "google"
CkAi_put_ApiKey $ai "MY_API_KEY"
CkAi_put_Model $ai "gemini-3-flash-preview"
# Note: Not all models support all params.
# Set Ask params.
set askParams [new_CkJsonObject]
CkJsonObject_UpdateNumber $askParams "temperature" "1.2"
CkJsonObject_UpdateString $askParams "effort" "low"
CkJsonObject_UpdateInt $askParams "max_output_tokens" 1024
CkJsonObject_put_EmitCompact $askParams 0
puts [CkJsonObject_emit $askParams]
CkAi_SetAskParams $ai $askParams
# Add a text input.
CkAi_InputAddText $ai "Say Hello."
# Ask the AI for text output.
set success [CkAi_Ask $ai "text"]
if {$success == 0} then {
puts [CkAi_lastErrorText $ai]
delete_CkAi $ai
delete_CkJsonObject $askParams
exit
}
# Get the text response.
set sbResponse [new_CkStringBuilder]
CkAi_GetOutputTextSb $ai $sbResponse
puts [CkStringBuilder_getAsString $sbResponse]
# Sample output:
# Hello! How can I assist you today?
# -------------------------------------------------------------
# The response is in markdown format.
# Also see Markdown to HTML Conversion Examples.
# -------------------------------------------------------------
delete_CkAi $ai
delete_CkJsonObject $askParams
delete_CkStringBuilder $sbResponse