Learn
Engine Class
TextGenerator

Summary
Inherited Members
Code Samples
local Workspace = game:GetService("Workspace")
local textGenerator = Instance.new("TextGenerator")
textGenerator.Parent = Workspace
textGenerator.SystemPrompt = "You are a helpful NPC in a virtual world."
textGenerator.Temperature = 0.8
textGenerator.TopP = 0.6
textGenerator.Seed = 7
local function getResponse(userInput)
local request = {
UserPrompt = userInput,
MaxTokens = 50
}
local success, response = pcall(function()
return textGenerator:GenerateTextAsync(request)
end)
if success then
if response then
print("Generated Text: " .. response.GeneratedText)
print("Context Token: " .. response.ContextToken)
print("Model: " .. response.Model)
return response
end
else
warn("Text generation failed: " .. tostring(response))
end
return nil
end
getResponse("Tell me something cool.")

API Reference
Properties
Seed
Read Parallel
Capabilities: Basic
TextGenerator.Seed:number

SystemPrompt
Read Parallel
Capabilities: Basic
TextGenerator.SystemPrompt:string

Temperature
Read Parallel
Capabilities: Basic
TextGenerator.Temperature:number

TopP
Read Parallel
Capabilities: Basic
TextGenerator.TopP:number

Methods
GenerateTextAsync
Yields
Capabilities: Basic
TextGenerator:GenerateTextAsync(request:Dictionary):Dictionary
Parameters
request:Dictionary
Returns

©2026 Roblox Corporation. Roblox, the Roblox logo and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.