LLM API Basics: System Prompts vs User Prompts
LLM APIs separate system prompts (developer-set behavior/constraints, highest authority) from user prompts (end-user messages). System always takes precedence over user in conflicts.
In LLM APIs (such as Anthropic's Claude API), messages are structured with distinct roles: - **System prompt**: Set by the developer/operator. Defines the AI's behavior, persona, and constraints. Has the highest authority in the prompt hierarchy. - **User prompt**: Messages from the end user within the conversation. - **Assistant role**: The AI's responses, maintaining conversation history. Authority hierarchy: system > user. The system prompt shapes HOW the model behaves, while user prompts shape WHAT it responds to. When conflicts arise between system and user instructions, the system prompt takes precedence. Anthropic API structure: Requests include a `model` field, a `system` field (the system prompt), and a `messages` array containing objects with `role` (user/assistant) and `content` pairs.