Generative AI & LLMs
System Prompt
In shortA system prompt is the set of standing instructions given to a language model before a task, defining its role, tone, rules and output format.
A system prompt is the set of standing instructions given to a language model before the conversation or task starts, telling it what role to play, how to behave and which rules to follow. The application or person then sends separate user messages, and the model applies the system instructions to each one. Providers name it differently: Anthropic calls it the system prompt, Google’s Gemini API calls it system instructions, and OpenAI uses developer messages and an instructions parameter.
How it works
In an API call, the system prompt goes in its own field, apart from the user’s input:
- Anthropic’s Messages API has a system parameter. Its documentation says setting a role in the system prompt focuses Claude’s behaviour and tone, and that even a single sentence makes a difference.
- The Gemini API takes a system_instruction parameter to configure the model’s behaviour.
- OpenAI’s instructions parameter and developer messages carry the rules. OpenAI says these take priority over the prompt in the input, and compares developer messages to a function definition and user messages to its arguments.
The system prompt is still text in the model’s context window, so it uses tokens on every call and works alongside other settings such as temperature.
How it’s used in SEO and marketing
- Brand voice and style: tone, spelling conventions, banned phrases and length limits for drafted copy. Our meta description notebook uses its system prompt to keep a curiosity gap in each description.
- Classification: the allowed labels, their definitions and a strict output format live in the system prompt, and each keyword or page goes in as a user message. Add few-shot examples for tricky labels.
- AI agents: the system prompt sets working rules. In our SERP analysis agent it tells the model never to state a ranking or citation it has not looked up, and to flag weak evidence.
Example
A system prompt for intent labelling might read: “You are an SEO analyst. Classify each search query as informational, commercial, transactional or navigational. Reply with the label only. If the intent is unclear, reply unclear.” Each user message is then a single query, such as “best running shoes for flat feet”, and the model replies “commercial”. Because the rules stay fixed, the output is consistent enough to load straight into a spreadsheet.
Limitations and things to watch
- Prompt injection. OWASP ranks it first among LLM risks: text in user input, or hidden in a web page, file or email the model reads, can override your instructions. Keep permissions and spending caps in code, and treat model output as untrusted.
- Prompts can leak. Assume users can extract a system prompt, and never put API keys or private data in it.
- Scope. OpenAI notes its instructions parameter applies only to the current request, so resend it on each call.
- Long, conflicting rule lists get followed unevenly. Test your prompt on a small labelled set before running it at scale.
Learn it on MLforSEO
- 10 Ways to Automate SERP Analysis with AI, including the agent’s system prompt and guard-rails
- How to Automatically Generate Meta Descriptions with Python: From BERT to LLMs
- How to use generative AI with structured data for programmatic SEO, on reusable prompt templates
- AI Search Optimization and Agentic SEO
Where System Prompt shows up on MLforSEO
Read about it on the blog
Sources and further reading
- Anthropic: Prompting best practices (give Claude a role with a system prompt)
- OpenAI API: Text generation (message roles and instruction following)
- Gemini API: Text generation (system instructions)
- OWASP Top 10 for LLM Applications: LLM01 Prompt Injection
- 10 Ways to Automate SERP Analysis with AI MLforSEO
- How to Automatically Generate Meta Descriptions with Python: From BERT to LLMs MLforSEO
Other terms from Generative AI & LLMs
- AI GovernanceThe policies, roles and controls an organisation uses to make sure AI is used safely, legally, transparently a…
- AI GuardrailsAI guardrails are checks around an AI model that filter inputs and outputs, block harmful or invented content…
- AI HallucinationWhen a generative AI model produces content that sounds plausible but is false, unsupported by its sources, or…
- AI SlopAI slop is low-effort content mass-produced with generative AI and published with little human review, origina…
- Attention MechanismThe technique that lets a neural network weigh how much each word in a text matters to every other word, so it…
- ChatGPT (OpenAI GPT models)OpenAI's chatbot and its GPT model family: strong at summarising and rewriting, unreliable for structured anal…
- Confidence Score (Generative AI)A number, usually 0 to 1, showing how certain a model is about a label or prediction; low scores flag outputs…
- Context WindowThe maximum amount of text, measured in tokens, that a language model can consider at once, including the prom…
- DeepSeek (R1 and V-series)DeepSeek's open-weight reasoning LLM, released January 2025. MLforSEO benchmarked it for entity extraction: ge…
