> ## 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

> Control model behaviour with a system prompt

## Through options

```ts theme={null}
const result = await RunAnywhere.llm.generate('How do I reverse a string?', {
  systemPrompt: 'You are a TypeScript expert. Answer with code, then one sentence.',
})
```

## Through a message

A `system` message becomes `options.systemPrompt` automatically:

```ts theme={null}
const result = await RunAnywhere.llm.generate([
  { role: 'system', content: 'You are a TypeScript expert.' },
  { role: 'user', content: 'How do I reverse a string?' },
])
```

Equivalent. When both are present, the explicit `options.systemPrompt` wins.

## Writing one that works

Even with desktop headroom, the models here are small. Short, concrete instructions land; long
personas do not.

```ts theme={null}
// Works
'You are a terse assistant. Answer in one sentence. No preamble.'

// Works less well on a 0.6B model
'You are an extremely helpful, knowledgeable, and friendly AI assistant who always strives to provide the most comprehensive and detailed responses possible…'
```

Naming the exact output shape usually holds:

```ts theme={null}
await RunAnywhere.llm.generate(review, {
  systemPrompt:
    'You are a classifier. Reply with exactly one word: positive, negative, or neutral.',
  temperature: 0.1,
})
```

For a guaranteed shape rather than a requested one, use
[structured output](/electron/structured-output).

## Reuse

```ts theme={null}
import type { LlmOptions } from '@runanywhere/electron'

export const prompts = {
  summarizer: {
    systemPrompt: 'Summarize in three bullet points. No introduction.',
    maxOutputTokens: 150,
    temperature: 0.3,
  },
  coder: {
    systemPrompt: 'You are a TypeScript expert. Answer with code first.',
    temperature: 0.2,
  },
} satisfies Record<string, LlmOptions>
```

Keeping these in the main process rather than the renderer means a settings change does not
need a window reload.
