KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Controlling AI Output Style in 4D AIKit with Temperature Parameter
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: November 6, 2025
When integrating GPT models through 4D AIKit, controlling the style and reliability of AI output is important.
The temperature parameter is the main tool for this; it determines how deterministic or creative the model’s responses will be.

  • Low temperature (0–0.3) → deterministic, consistent outputs
    Useful for tasks like structured data extraction, code generation, or reporting, where repeatability is critical.

  • High temperature (0.7–0.9) → creative, diverse outputs
    Useful for tasks like marketing content, brainstorming, or copywriting, where novelty and variation are desired.

Understanding and tuning temperature helps aligning the AI behavior with the specific business need, saving time and reducing unpredictable results.

Example 1 : Determnistic Output (Low Temperature)

var $client := cs.AIKit.OpenAI.new("YOUR_API_KEY")

// Prepare messages for deterministic output
var $messages := New collection(
{role: "system"; content: "You are a helpful assistant that gives consistent answers."}
)
$messages.push({role: "user"; content: "List 3 slogans for SCreative. Give them in a numbered list."})

// Two calls with the same parameters
var $result1 := $client.chat.completions.create($messages; {model: "gpt-4o-mini"; temperature: 0.2; max_tokens: 100})
var $result2 := $client.chat.completions.create($messages; {model: "gpt-4o-mini"; temperature: 0.2; max_tokens: 100})

// Combine both responses in a single alert
var $text := "Result 1:\r" + $result1.choices[0].message.content + \
"\r\rResult 2:\r" + $result2.choices[0].message.content

ALERT($text)


Expected Behavior:

  • Both results are nearly identical due to low temperature.

  • Perfect for tasks requiring repeatable, consistent outputs.

Result :



Example 2 : Creative Output (High Temperature)

Keep the same example as earlier, change only the prompt part and the temperature value from 0.2 to 0.8.
Here's the used prompt for this case :

var $messages := New collection(
{role: "system"; content: "You are a creative marketing assistant."}
)
$messages.push({role: "user"; content: "Suggest 3 novel slogans for SCreative."})


Expected Behavior :

  • Each run produces different outputs due to high temperature.

  • Ideal for brainstorming, marketing content, or creative tasks.


Result :



Note: Ensure the prompt aligns with the chosen temperature, because even at low temperatures, outputs can vary slightly if the prompt encourages creativity.