System prompts: design an AI assistant’s default behavior
A system prompt is a common name for the high-level role, goal, and rules an AI application repeatedly gives a model. Unlike the user’s question for one turn, it sets the service’s default behavior. The term does not identify one universal API field or a security boundary, so implementation depends on each provider’s documentation and instruction hierarchy.
A system prompt is a common name for the high-level role, goal, and rules an AI application repeatedly gives a model. Unlike the user’s question for one turn, it sets the service’s default behavior. The term does not identify one universal API field or a security boundary, so implementation depends on each provider’s documentation and instruction hierarchy.
What problem does it solve?
A user message contains the details of a particular request. System-level guidance holds rules that should apply across requests, such as an assistant’s scope, evidence standards, or response style. A customer-support assistant, for example, might be told to explain product policy using supplied policy materials and to ask for review when those materials do not answer a question.
This does not retrain the model or guarantee correct answers. The model still generates responses probabilistically and can misunderstand an instruction or state something false. A system prompt is one input that steers behavior; it does not replace database permissions, application logic, or code-based validation.
Where do providers put these instructions?
“System prompt” is a useful concept, but APIs expose it differently. In official documentation checked in November 2026, the mappings are:
| API | System-level instruction | Implementation note |
|---|---|---|
| OpenAI Responses API | instructions for a turn, or a developer message in input | The docs describe using the first developer message for reusable guidance across chained responses. |
| OpenAI Chat Completions | developer message | Developer instructions take priority over user input. |
| Anthropic Messages API | Top-level system parameter | The message list uses user and assistant turns; system guidance is a separate parameter. |
| Gemini API | system_instruction parameter | Use the field supported by the SDK and API surface you call. |
Do not copy one provider’s example and assume that changing the field name is enough. Message handling, persistence across turns, and supported features can vary by API version and model. Check the reference for the deployed API and verify the exact request shape.
What should you include?
Prefer a small set of clear, reusable work rules over a long declaration that tries to anticipate everything. Define the assistant’s role and users, what counts as a successful answer, which sources it may rely on, what it should do when information is missing, actions it must not take, and the output structure the application needs.
For example, these are hypothetical default rules for a customer-support drafting assistant:
Role: Draft customer-support replies.
Goal: Answer clearly and politely, with evidence a reviewer can check.
Evidence: Use only the current refund policy supplied by the application.
Uncertainty: If the policy does not answer the question, do not guess; request review.
Action limit: Do not approve refunds or change payment records.
Output: Separate the draft reply, policy evidence, and open questions.This example is invented for teaching; it is not a real policy or system. The useful part is not the role statement alone. It also defines evidence boundaries, behavior under uncertainty, prohibited actions, and a reviewable result. Put changing details, such as a particular order number or customer question, in validated request data rather than repeating them in the stable rules.
What if a user request conflicts with the instructions?
APIs define how roles are prioritized, but the model can still fail to follow instructions and input structures differ. OpenAI documents that developer instructions have higher priority than user input; Anthropic and Google expose separate system-instruction parameters. Avoid relying on a blanket claim that a system prompt “always wins.”
Write conflict rules as observable conditions. “If the supplied policy does not answer the question, ask a person to review it” is easier to test than “always be accurate.” Include ambiguous questions, missing information, conflicting source documents, and attempts to override the rules in evaluation cases.
How should you test and maintain it?
Before release, prepare examples representative of normal work and likely failures: unanswered questions, incomplete data, contradictory policy excerpts, and user text such as “ignore the previous rules.” Evaluate evidence use, required conditions, output structure, and escalation separately.
Record the model/version, system-instruction version, tool configuration, test inputs, and results. Change one important instruction at a time, compare against fixed test cases, and deploy in stages when the effect is consequential. A program can check whether output parses as JSON, but that does not prove the content is true.
A system prompt is not a security boundary
Instructions can steer the model and reduce unwanted behavior, but they cannot safely store secrets or enforce tool permissions. A user or external webpage/file may contain direct or indirect instructions that influence a model. OWASP describes prompt injection as a risk inherent in how models process input and says no foolproof prevention method is established.
Keep API keys and passwords in server-side secret storage, never in a prompt. Enforce permissions in application code and give the model only the minimum tools needed. Mark external material as untrusted, validate outputs, and require human approval for high-impact actions such as payments, account changes, or sending messages. Prompt text should complement these controls, not replace them.
References
[OpenAI API: Prompt engineering](https://developers.openai.com/api/docs/guides/prompt-engineering)
[OpenAI API reference: Create a conversation](https://developers.openai.com/api/reference/resources/conversations/methods/create)
[Anthropic API reference: Messages](https://docs.anthropic.com/en/api/messages)
[Google AI for Developers: Text generation — system instructions](https://ai.google.dev/gemini-api/docs/system-instructions)
[OWASP GenAI Security Project: LLM01:2025 Prompt Injection](https://genai.owasp.org/llmrisk/llm01-prompt-injection/)