Text Generation

AI Dev Kit provides multiple methods for generating text content, each optimized for different use cases.

Available Methods

1. Chat Completions (.GENCompletion())

General-purpose chat and text generation:

string response = await "Explain quantum computing"
    .GENCompletion()
    .SetModel(OpenAIModel.GPT4o)
    .ExecuteAsync();

Best for:

  • ✅ Conversational AI

  • ✅ General text generation

  • ✅ Multi-turn conversations

  • ✅ Wide provider support

2. Responses API (.GENResponse())

Most capable text generation with advanced features:

string response = await "Write a technical spec"
    .GENResponse()
    .SetModel(OpenAIModel.GPT4o)
    .ExecuteAsync();

Best for:

  • ✅ Complex reasoning tasks

  • ✅ Long-form content

  • ✅ Tool calling support

  • ✅ Latest AI capabilities

3. Code Generation (.GENCode())

Specialized for code generation and refactoring:

Best for:

  • ✅ Code generation

  • ✅ Code explanation

  • ✅ Refactoring suggestions

  • ✅ Bug fixes

4. Structured Output (.GENStruct<T>())

Generate JSON mapped to strongly-typed C# classes:

Best for:

  • ✅ Parsing AI output into C# objects

  • ✅ Data extraction

  • ✅ Form filling

  • ✅ Type-safe responses

Quick Comparison

Method
Use Case
Provider Support
Complexity

GENCompletion()

General chat

Most providers

Simple

GENResponse()

Advanced features

Limited providers

Advanced

GENCode()

Code generation

Most providers

Simple

GENStruct<T>()

JSON output

Most providers

Medium

Basic Examples

Example 1: Simple Question

Example 2: Story Generation

Example 3: Code Generation

Example 4: Structured Data

Configuration Options

All text generation methods support common configuration:

Next Steps

Last updated