> ## Documentation Index
> Fetch the complete documentation index at: https://docs.noxus.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Text Generation

> Generate AI-powered text with LLM nodes in Noxus

Text generation is one of the most powerful capabilities in Noxus, enabling you to create content, analyze text, transform information, and build intelligent assistants using state-of-the-art language models.

## Text Generation Nodes

### Text Generation V3 (Recommended)

The most versatile text generation node with advanced features:

**Key Features**:

* Variable inputs for dynamic prompts
* Rich text prompt editor with variable insertion
* Model selection (cost/performance presets)
* Streaming support for real-time output
* Time awareness (automatic date/time injection)
* PII detection and guardrails
* Image URL reading capability

**Use Cases**:

* Content generation (articles, emails, summaries)
* Text transformation (rewriting, translation)
* Question answering
* Classification and categorization
* Extraction with flexible outputs

### OpenAI Node (Legacy)

Simple text generation for basic use cases:

**Key Features**:

* System prompt + user input
* Direct model selection
* Basic configuration

**Use Cases**:

* Simple text generation
* Legacy workflows
* Quick prototyping

**Recommendation**: Use Text Generation V3 for new workflows.

## Building Effective Prompts

### Prompt Structure

A good prompt has clear structure:

```
[Role/Context]
You are an expert marketing copywriter.

[Task]
Write a compelling product description.

[Input Data]
Product: {product_name}
Features: {features}

[Constraints]
- Keep it under 100 words
- Use persuasive language
- Highlight unique benefits

[Output Format]
Return only the description, no additional commentary.
```

### Variable Inputs

Text Generation V3 supports variable inputs for dynamic prompts:

**Add Variables**:

1. Click "+" to add input
2. Name the variable (e.g., `product_name`, `customer_email`)
3. Connect data or set default values
4. Reference in prompt using `{variable_name}`

**Example**:

```
Generate a personalized email for {customer_name}.

Customer Details:
- Company: {company}
- Industry: {industry}
- Recent Activity: {activity}

Write a brief follow-up email suggesting how our product can help.
```

### Prompt Engineering Best Practices

**Be Specific and Clear**:

```
Bad: "Write something about cats"
Good: "Write a 200-word informative paragraph about domestic cat behavior, focusing on communication methods."
```

**Provide Examples** (Few-Shot Learning):

```
Extract the key information from emails.

Example 1:
Email: "Hi, I'd like to schedule a demo for next Tuesday at 2pm."
Output: {"type": "demo_request", "date": "next Tuesday", "time": "2pm"}

Example 2:
Email: "Can you send me pricing for the enterprise plan?"
Output: {"type": "pricing_inquiry", "plan": "enterprise"}

Now extract from this email:
{email_text}
```

**Use Clear Delimiters**:

```
Summarize the text between the ### markers:

###
{long_document_text}
###

Summary:
```

**Specify Output Format**:

```
Bad: "List the main points"
Good: "List the main points as numbered items, with each point being 1-2 sentences."
```

**Set Tone and Style**:

```
Write in a [formal/casual/technical/friendly] tone.
Use [simple/advanced] language suitable for [audience].
```

## Model Selection

### Cost vs Performance Trade-offs

Different models have different characteristics:

| Model Category | Speed | Cost | Quality | Best For |
| - | - | - | - | - |
| **Fast** (GPT-3.5, Haiku) | ⚡⚡⚡ | 💰 | ⭐⭐⭐ | Simple tasks, high volume |
| **Balanced** (GPT-4o-mini, Sonnet) | ⚡⚡ | 💰💰 | ⭐⭐⭐⭐ | General purpose |
| **Quality** (GPT-4, Opus) | ⚡ | 💰💰💰 | ⭐⭐⭐⭐⭐ | Complex reasoning |

### Model Presets

Text Generation V3 offers presets:

**Fast & Cheap**:

* GPT-3.5-turbo, Claude Haiku
* 10x cheaper than GPT-4
* Great for: Simple rewrites, basic Q\&A, formatting

**Balanced**:

* GPT-4o-mini, Claude Sonnet
* 3x cheaper than GPT-4, nearly as good
* Great for: Most tasks, content generation, analysis

**Max Quality**:

* GPT-4, Claude Opus
* Most expensive but best results
* Great for: Complex reasoning, creative writing, critical analysis

### Choosing the Right Model

**Use Fast Models When**:

* Task is straightforward (reformatting, simple extraction)
* High volume processing
* Cost is a primary concern
* Speed matters

**Use Balanced Models When**:

* General-purpose text generation
* Content creation
* Moderate complexity
* Good balance needed

**Use Quality Models When**:

* Complex reasoning required
* High stakes (customer-facing content)
* Creative tasks (writing, ideation)
* Previous models struggled

**Example Strategy**:

```
Simple extraction → Fast model (GPT-3.5)
    ↓
Generate draft content → Balanced model (GPT-4o-mini)
    ↓
Final polish and review → Quality model (GPT-4)
```

## Advanced Configuration

### Temperature

Controls randomness in generation:

* **0.0**: Deterministic, consistent output
* **0.3-0.5**: Focused, predictable (recommended for data extraction)
* **0.7-0.9**: Balanced creativity (recommended for content)
* **1.0-2.0**: High creativity, more diverse outputs

**Use Cases**:

* **Low (0.0-0.3)**: Classification, extraction, technical writing
* **Medium (0.5-0.8)**: General content, emails, summaries
* **High (0.9-2.0)**: Creative writing, brainstorming, diverse ideas

### Max Output Tokens

Limits response length:

* **Short (100-300)**: Quick answers, summaries
* **Medium (500-1000)**: Paragraphs, emails, descriptions
* **Long (1500-4000)**: Articles, reports, detailed analysis

**Tip**: Set appropriate limits to control costs and ensure concise outputs.

### Time Awareness

Automatically injects current date/time into prompts:

**When enabled**, the model knows:

* Current date and time
* Day of week
* Relative dates ("yesterday", "next week")

**Use Cases**:

* Scheduling and calendar tasks
* Time-sensitive content
* Date-aware analysis

### PII Detection

Automatically detects and flags personally identifiable information:

**Detects**:

* Names, email addresses, phone numbers
* SSNs, credit cards, addresses
* Sensitive personal data

**Use Cases**:

* Compliance workflows
* Data sanitization
* Privacy protection

**Behavior**: Warns or blocks when PII detected (configurable).

## Common Patterns

### Content Generation

**Blog Post Writer**:

```
Write a blog post about {topic}.

Target Audience: {audience}
Tone: {tone}
Length: {word_count} words

Structure:
1. Engaging introduction with hook
2. 3-5 main points with examples
3. Actionable conclusion

SEO Keywords: {keywords}
```

**Email Generator**:

```
Write a professional email for the following scenario:

Recipient: {recipient_name} ({recipient_role})
Purpose: {email_purpose}
Context: {background_info}

Tone: Professional but friendly
Length: 2-3 short paragraphs
Include: Clear call-to-action
```

### Text Transformation

**Rewriting**:

```
Rewrite the following text to be more {adjective}:

Original:
{original_text}

Requirements:
- Maintain the core message
- Adjust tone to be {tone}
- Target length: Similar to original
```

**Translation** (with context):

```
Translate the following {source_language} text to {target_language}:

{text}

Context: {context}
Tone: {formal/casual}
Preserve: Technical terms, brand names
```

**Summarization**:

```
Summarize the following text in {num_sentences} sentences:

{long_text}

Focus on: Main points, key takeaways, actionable insights
Ignore: Minor details, repetitive information
```

### Analysis and Extraction

**Sentiment Analysis**:

```
Analyze the sentiment of this text:

{text}

Provide:
1. Overall sentiment (positive/negative/neutral)
2. Confidence score (0-100%)
3. Key phrases supporting the sentiment
4. Brief explanation
```

**Key Information Extraction**:

```
Extract the following information from this text:

{text}

Extract:
- Main topic
- Key people mentioned
- Important dates
- Action items
- Decisions made

Format as a bullet list.
```

**Classification**:

```
Classify this customer message into one of these categories:
- Bug Report
- Feature Request
- General Question
- Complaint
- Praise

Message:
{customer_message}

Provide:
1. Category
2. Urgency (low/medium/high)
3. Brief reasoning
```

## Streaming Outputs

Enable streaming for real-time text generation:

**Benefits**:

* See results as they're generated
* Better user experience for long outputs
* Early detection of issues

**Use Cases**:

* Interactive chatbots
* Real-time content generation
* User-facing applications

**Configuration**: Enable "Streaming" toggle in node settings.

## Error Handling

### Common Issues

**Empty Responses**:

* Prompt may be too restrictive
* Model may refuse harmful requests
* Output token limit too low

**Inconsistent Outputs**:

* Temperature too high (reduce to 0.3-0.7)
* Prompt lacks constraints
* Need more examples in prompt

**Off-Topic Responses**:

* Prompt not specific enough
* Missing context or constraints
* Try different model

### Debugging Tips

**Use Log Nodes**: Insert log nodes after text generation to inspect outputs.

**Test with Simple Inputs**: Start with basic test inputs before complex data.

**Iterate on Prompts**: Refine prompts based on actual outputs.

**Try Different Models**: Some models work better for specific tasks.

**Check Token Limits**: Ensure max tokens is sufficient for expected output.

## Optimization

### Reduce AI model cost

**Use Appropriate Models**: Don't use GPT-4 for simple tasks.

**Set Token Limits**: Avoid unnecessarily long outputs.

**Cache Results**: Use Memory nodes to store repeated generations.

**Batch When Possible**: Process multiple items in one generation (if format allows).

### Improve Quality

**Provide More Context**: More specific prompts yield better results.

**Use Examples**: Few-shot learning improves accuracy.

**Iterate on Prompts**: Refine based on real outputs.

**Choose Better Models**: Upgrade to higher-quality models for critical tasks.

### Improve Speed

**Use Faster Models**: GPT-3.5, Claude Haiku are much faster.

**Enable Streaming**: Perceived performance improvement.

**Reduce Output Length**: Shorter responses generate faster.

**Parallel Processing**: Use list iteration for batch processing.

## Examples

### Example 1: Product Description Generator

```
Workflow:
Input (Product Data) → Text Generation V3 → Output (Description)

Prompt:
Write a compelling product description for an e-commerce listing.

Product Name: {product_name}
Category: {category}
Key Features:
{features}

Price: {price}
Target Audience: {audience}

Requirements:
- 150-200 words
- Highlight unique benefits
- Include a call-to-action
- Persuasive but honest
- SEO-friendly

Format as plain text, ready to publish.
```

### Example 2: Customer Support Classifier

```
Workflow:
Customer Email → Text Generation V3 → Switch Node (by category) → Different handlers

Prompt:
Classify this customer support message:

{email_content}

Categories:
1. Technical Support - Software bugs, errors, technical issues
2. Billing - Payments, invoices, subscription questions
3. Feature Request - New feature suggestions
4. General Inquiry - Questions about product/service
5. Complaint - Negative feedback, dissatisfaction

Respond with ONLY the category number (1-5).
```

### Example 3: Meeting Notes Summarizer

```
Workflow:
Meeting Transcript → Text Generation V3 → Generate File (PDF) → Send Email

Prompt:
Summarize this meeting transcript:

{transcript}

Provide:

## Summary
Brief 2-3 sentence overview

## Key Discussion Points
- Bullet points of main topics discussed

## Decisions Made
- List of decisions and conclusions

## Action Items
- [ ] Action item 1 (Owner: Name)
- [ ] Action item 2 (Owner: Name)

## Next Steps
What happens next and when

Keep it concise and actionable.
```

## Next Steps

> **[Structured Outputs](https://docs.noxus.ai/building/ai/structured-outputs)**
>
> Generate JSON-structured data with schemas

> **[Vision & Multimodal](https://docs.noxus.ai/building/ai/vision-multimodal)**
>
> Analyze images and mixed content

> **[Model Selection Guide](https://docs.noxus.ai/building/ai/model-selection)**
>
> Deep dive into choosing the right models

> **[Text Generation Node](https://docs.noxus.ai/nodes/ai/text-generation)**
>
> Complete node reference documentation

***

Mastering text generation unlocks the full potential of AI in your workflows. Experiment with different prompts, models, and configurations to find what works best for your use cases.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.