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

# System Prompts

> Configure model behavior and personality

System prompts define how the model should behave, respond, and what role it should assume.

## Basic Usage

```kotlin theme={null}
val options = LLMGenerationOptions(
    maxTokens = 200,
    systemPrompt = """
        You are a senior Kotlin developer.
        Answer questions with code examples.
        Use modern Kotlin conventions and coroutines.
    """.trimIndent()
)

val result = RunAnywhere.generate(
    prompt = "How do I make an HTTP request?",
    options = options
)
```

## Example: Code Assistant

```kotlin theme={null}
val codeAssistant = LLMGenerationOptions(
    maxTokens = 500,
    temperature = 0.3f,  // Lower for more precise code
    systemPrompt = """
        You are an expert Android developer assistant.
        - Always provide working Kotlin code examples
        - Use Jetpack libraries when appropriate
        - Follow Material Design guidelines for UI code
        - Include error handling in your examples
        - Keep explanations concise
    """.trimIndent()
)

val result = RunAnywhere.generate(
    prompt = "How do I implement a RecyclerView with DiffUtil?",
    options = codeAssistant
)
```

## Example: Customer Support Bot

```kotlin theme={null}
val supportBot = LLMGenerationOptions(
    maxTokens = 300,
    temperature = 0.7f,
    systemPrompt = """
        You are a friendly customer support assistant for TechCorp.

        Guidelines:
        - Be helpful, patient, and empathetic
        - Keep responses under 3 paragraphs
        - If you don't know something, say so
        - Never make up product features
        - End with asking if there's anything else you can help with
    """.trimIndent()
)
```

## Example: Creative Writer

```kotlin theme={null}
val creativeWriter = LLMGenerationOptions(
    maxTokens = 1000,
    temperature = 1.2f,  // Higher for creativity
    topP = 0.95f,
    systemPrompt = """
        You are a creative fiction writer with a vivid imagination.
        Write engaging stories with:
        - Rich character development
        - Descriptive settings
        - Unexpected plot twists
        - Emotional depth
    """.trimIndent()
)
```

## Example: JSON Output

```kotlin theme={null}
val jsonFormatter = LLMGenerationOptions(
    maxTokens = 500,
    temperature = 0.1f,  // Very low for consistent structure
    systemPrompt = """
        You are a data extraction assistant.
        Always respond with valid JSON only.
        Do not include any text outside the JSON object.
        Use this schema: {"name": string, "category": string, "confidence": number}
    """.trimIndent()
)

val result = RunAnywhere.generate(
    prompt = "Extract product info: 'iPhone 15 Pro Max 256GB Space Black'",
    options = jsonFormatter
)
// Result: {"name": "iPhone 15 Pro Max", "category": "smartphone", "confidence": 0.95}
```

## Best Practices

<Tip>
  **Keep system prompts focused and specific:** - Define the role clearly - Set boundaries on what
  the model should/shouldn't do - Specify output format if needed - Include examples for complex
  tasks
</Tip>

| Goal             | Temperature | System Prompt Style                     |
| ---------------- | ----------- | --------------------------------------- |
| Code generation  | 0.1-0.4     | Precise, technical instructions         |
| Creative writing | 0.9-1.3     | Open-ended, encourage creativity        |
| Factual Q\&A     | 0.2-0.5     | Focus on accuracy, cite limitations     |
| Conversation     | 0.6-0.8     | Personality traits, response guidelines |
