AI DevKit
Glitch9 Inc.Glitch9 DocsDiscordIssues
  • Introduction
    • AI DevKit 3.0
    • Update Logs
    • Troubleshooting
      • ❗Issues After Updating AIDevKit?
      • ❗The type or namespace name 'Newtonsoft' could not be found
      • ❗Build Error: The name 'UnityMenu' does not exist in the current context
      • ❗Model 'modelName' not found
      • ❗The model `model name` does not exist or you do not have access to it
      • ❗The type or namespace name 'AndroidJavaObject' could not be found
      • ❗The type or namaspace name 'Plastic' does not exist
      • ❗Build Error: The name 'Asset Database' does not exist in the current context
      • ❗'ModelData.Create(Provider, string, UnixTime?, string)': not all code paths return a value
      • ⚠️ Timeout Issues
      • ⚠️ Receiving a “HTTP/1.1 400 Bad Request” Error?
    • FAQ
      • My OpenAI API free trial has ended or is inactive.
  • Quick Start
    • Get API Keys
      • OpenAI API Key Guide
      • Google API Key Guide
      • ElevenLabs API Key Guide
    • Text Generation
    • C# Object Generation
    • Image Generation
    • Sound Effect Generation
    • Text to Speech (TTS)
    • Speech to Text (STT)
    • Voice Changer
    • Audio Isolation
  • Pro Features
    • Generation Menu
      • Code Generators
        • C# Script Generator
        • Unity Component Generator
    • Editor Chat
    • Editor Vision (TTI, ITI)
    • Editor Speech (TTS)
    • Management Tools
      • Prompt History Viewer
      • AI Model Manager
      • TTS Voice Manager
      • OpenAI File Manager
      • OpenAI Assistant Manager
      • ElevenLabs Voice Library
  • Assistants API (OpenAI)
    • How it works
    • Creating custom functions
    • Creating assistants API
  • Advanced API Supports
    • OpenAI API
      • 💬Chat completions
      • 🖼️Image operations
      • 🗣️Text to speech
      • 🎙️Speech to text
        • Recording real-time in Unity
      • 💾Files
      • 🔎Embeddings
      • 🛡️Moderations
      • ⚙️Fine-tuning
    • Google API
      • 📝System instructions
      • 💬Text generation
      • ⚙️Fine-tuning
      • ▶️Fucntion calling
      • 🔎Embeddings
      • 🛡️Safety
      • 💻Code execution
    • ElevenLabs API
  • Legacy Documents
    • AI DevKit 1.0 - 2.0
      • AI DevKit 2.0
      • AI DevKit 1.0
      • Preperation
      • Event Handlers
      • Scriptable Toolkits
        • Chat Streamer
        • Image Generator
        • Voice Transcriber
        • Voice Generator
      • Editor Tools
Powered by GitBook
On this page
  1. Quick Start

Text Generation

Text generation allows you to create natural language output from a prompt using powerful large language models (LLMs) like GPT-4o, Gemini, and more.

This is commonly used for answering questions, summarizing content, writing marketing copy, or even creative writing.

✅ Basic Usage

Use the Fluent API to quickly create and execute a text generation task.

string prompt = "Explain quantum computing in simple terms.";

string result = await prompt
    .GENText()
    .SetModel(GPTModel.GPT4o)
    .SetTemperature(0.7f)
    .ExecuteAsync();

Debug.Log(result);

💡 GENText() is an extension method for string, turning your prompt into a text generation task.


⚙️ Available Configuration

You can customize the task using the following fluent methods:

Method
Description

SetModel(model)

Choose the model to use (e.g., GPTModel.GPT4o, GeminiModel.Gemini1_5Pro).

SetInstruction(text)

Set a system-level instruction (defines tone/role).

SetStartingMessage(text)

Set the first assistant message to guide the response.

SetMaxOutputTokens(int)

Limit the maximum output length (in tokens).

SetTemperature(float)

Control randomness: 0.0 is focused, 1.0 is creative.

SetTopP(float)

Nucleus sampling: limit token selection to top probability P.

SetTopK(float)

Limit selection to the top K tokens (used by Gemini).

SetSeed(int)

Use a fixed seed for consistent output.

SetPresencePenalty(float)

Discourage repeated ideas.

SetFrequencyPenalty(float)

Discourage repeated words.


🚀 Streaming Output

For real-time applications like chat or narration, you can stream the output word-by-word:

await prompt
    .GENText()
    .SetModel(GPTModel.GPT4o)
    .StreamAsync(
        onTextReceived: chunk => Debug.Log(chunk),
        onStreamStart: () => Debug.Log("Started..."),
        onStreamEnd: () => Debug.Log("Finished.")
    );

✅ Supported only on models that support streaming (e.g., OpenAI GPT family).


📦 Example Result

Quantum computing is a type of computing that uses quantum bits, or qubits, which can represent both 0 and 1 at the same time...

🧠 Tips

  • You don’t need to manually handle UniTask cancellation unless you want to cancel early.

  • The default model is defined in your project settings (AIDevKitSettings.DefaultTextModel).

  • You can safely combine this with object generation if you want to extract structured data — see C# Object Generation.

PreviousElevenLabs API Key GuideNextC# Object Generation

Last updated 18 days ago