---
title: "What is a system prompt in LLMs?"
description: "A system prompt is the developer-written instruction block an LLM receives before user messages. How system prompts work, their priority, and their limits."
type: "glossary-term"
canonical_url: "https://theaiengineering.com/glossary/system-prompt"
markdown_url: "https://theaiengineering.com/glossary/system-prompt.md"
topic: "Prompt and context engineering"
author: "The AI Engineering Editors"
publisher: "The AI Engineering"
updated: "2026-11-06"
keywords: ["System prompt","system message","system instructions","developer message"]
citation: "The AI Engineering Editors. \"What is a system prompt in LLMs?\" The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/system-prompt"
---

# What is a system prompt in LLMs?

Also called system message, system instructions, developer message.

> **Definition of System prompt:** A system prompt is the set of developer-written instructions sent to a language model ahead of the conversation, defining its role, rules, output format, and tool use for every turn that follows.

A system prompt is the block of instructions an application places ahead of the conversation to tell a model what role it plays, what it may do, and how to respond. Developers write it once and send it with every request, while user messages change from turn to turn. A typical system prompt states the role, the scope, the constraints, the output format, and when to call tools or hand off to a person. Providers name it differently: Anthropic's Messages API takes a top-level `system` parameter, and OpenAI's Responses API takes an `instructions` parameter or messages with the `developer` role.

## How system prompts work

A system prompt sits at the start of the model's input and takes priority over user messages when the two conflict. It counts against the [context window](https://theaiengineering.com/glossary/context-window) like any other input and is billed on every request, so a long system prompt adds cost and [time to first token](https://theaiengineering.com/glossary/time-to-first-token) to each call.

OpenAI's [Model Spec](https://model-spec.openai.com/) formalizes the priority as a chain of command. Rules from the Model Spec and OpenAI come first, then developer instructions, then user instructions. Tool outputs, quoted text, file attachments, and images carry no authority by default, so instructions inside them count as information, not commands.

Whether a system prompt persists across turns depends on the API. OpenAI's [text generation guide](https://developers.openai.com/api/docs/guides/text) notes that the `instructions` parameter applies only to the current request; when a conversation continues with `previous_response_id`, earlier instructions are not carried over and must be sent again.

## System prompt vs user prompt

The system prompt carries the developer's standing rules, and the user prompt carries the request for the current turn. The system prompt is written in advance, changes only with a release, and is trusted. User prompts arrive at runtime, differ on every request, and must be treated as untrusted input.

| | System prompt | User prompt |
|---|---|---|
| Written by | The developer | The end user or upstream code |
| Changes | With a release | Every turn |
| Priority | Higher | Lower |
| Typical content | Role, rules, format, tool policy, [examples](https://theaiengineering.com/glossary/few-shot-prompting) | The question or task |

## System prompt security and caching

A system prompt is neither a secret nor a security boundary. The OWASP Top 10 for LLM Applications lists [system prompt leakage](https://genai.owasp.org/llmrisk/llm072025-system-prompt-leakage/) as LLM07:2025 and says the system prompt should not be treated as a secret or used as a security control. Attackers can often infer its rules by using the application.

Instructions in a system prompt also do not stop [prompt injection](https://theaiengineering.com/glossary/prompt-injection) on their own, because injected text reaches the model through the same token stream. Keep credentials and internal data out of the prompt, and enforce permissions in application code, for example by requiring approval before any tool call that writes data.

A stable system prompt is the main beneficiary of [prompt caching](https://theaiengineering.com/glossary/prompt-caching), which reuses work only for an identical prefix. Anthropic's [prompt caching documentation](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) builds the cache in the order tools, system, then messages, and editing the system prompt invalidates the system and message caches. Put timestamps, user names, and other per-request values in the messages that follow, not in the system prompt.

The [context engineering explainer](https://theaiengineering.com/articles/context-engineering) shows how the system prompt fits with tools, memory, and retrieved content in an agent's context window.

## Related terms

- [Prompt engineering](https://theaiengineering.com/glossary/prompt-engineering): Prompt engineering is the practice of designing the instructions, examples, and formatting given to a large language model so it produces accurate, consistent output for a task, without changing model weights.
- [Prompt injection](https://theaiengineering.com/glossary/prompt-injection): Prompt injection is an attack in which text supplied to a large language model, typed by a user or hidden in content the model reads, alters the application's intended behavior or output.
- [Prompt caching](https://theaiengineering.com/glossary/prompt-caching): Prompt caching is an LLM API and inference-server feature that stores the computed attention state for a repeated prompt prefix, so later requests sharing that prefix skip reprocessing it.
- [Context engineering](https://theaiengineering.com/glossary/context-engineering): Context engineering is the practice of selecting, structuring, and pruning all the information placed in an LLM's context window at each step, including instructions, retrieved data, tool results, and memory.
- [Few-shot prompting](https://theaiengineering.com/glossary/few-shot-prompting): Few-shot prompting is a technique that puts a few example inputs paired with desired outputs in a prompt, so a language model infers the task, format, and labels without changing its weights.
- [Context window](https://theaiengineering.com/glossary/context-window): A context window is the maximum number of tokens a language model can take into account in a single request, including the system prompt, conversation history, tool results, and the generated output.

## Guides that cover system prompt

- [What is context engineering? A practical guide for AI agents](https://theaiengineering.com/articles/context-engineering): Context engineering is the practice of choosing what fills an LLM context window. Learn its components, why context rot happens, and how to measure results.
- [How to build an AI agent: a step-by-step guide in Python](https://theaiengineering.com/articles/how-to-build-an-ai-agent): Learn how to build an AI agent from scratch in Python: when you need one, tool schemas, the agent loop, stop conditions, guardrails, evals, and tracing.
- [LLM evaluation: a practical guide to evals, metrics, and judges](https://theaiengineering.com/articles/llm-evaluation): LLM evaluation for engineers: build eval datasets, pick metrics, calibrate LLM-as-a-judge, evaluate RAG and agents, and gate every release in CI.
- [LLM routing: strategies, fallbacks, and learned routers](https://theaiengineering.com/articles/llm-routing): LLM routing guide: rule-based and cost-aware strategies, fallbacks, load balancing, semantic and learned routers like RouteLLM, router evals, and pitfalls.
- [LLM inference optimization: a practical guide for engineers](https://theaiengineering.com/articles/llm-inference-optimization): LLM inference optimization guide: prefill vs decode, TTFT, KV cache and PagedAttention, continuous batching, quantization, speculative decoding, and GPUs.
- [What is tool calling? How LLM function calling works](https://theaiengineering.com/articles/tool-calling): Tool calling lets an LLM request actions from your code through structured calls. Learn the request loop, parallel calls, structured outputs, security, and MCP.
- [vLLM vs Ollama vs llama.cpp vs SGLang: which engine to use](https://theaiengineering.com/articles/vllm-vs-ollama): vLLM vs Ollama compared with llama.cpp, SGLang, LM Studio, and TensorRT-LLM: scope, hardware, APIs, concurrency, and which engine fits local or production use.
- [What is AI engineering? The discipline, the stack, and the work](https://theaiengineering.com/articles/what-is-ai-engineering): What is AI engineering? A plain definition, how it differs from ML and software engineering, the layers of the stack, and what AI engineers do day to day.
- [AI engineer roadmap: skills, projects, and resources by stage](https://theaiengineering.com/articles/ai-engineer-roadmap): A practical AI engineer roadmap in seven stages, each with the skills to learn, a project to ship, and resources worth the time, from Python to production.

Part of the [Prompt and context engineering](https://theaiengineering.com/topics/prompt-engineering) topic hub.

## Cite this definition

The AI Engineering Editors. "What is a system prompt in LLMs?" The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/system-prompt

- Title: What is a system prompt in LLMs?
- Author: The AI Engineering Editors
- Publisher: The AI Engineering
- Updated: 2026-11-06
- URL: https://theaiengineering.com/glossary/system-prompt
- Markdown: https://theaiengineering.com/glossary/system-prompt.md
