AI / Core OpenAI Codex Application Fundamentals Interview Questions
What is the role of system prompts (instructions) in OpenAI applications and how do you design them effectively?
The system prompt (called instructions in the Responses API, system in Chat Completions) sets the model's persona, behaviour, constraints, and context for the entire conversation. It is the primary lever for customising model behaviour without fine-tuning.
# Chat Completions system prompt: response = client.chat.completions.create( model="gpt-5.5", messages=[ { "role": "system", "content": "You are an expert Python engineer...", # system message }, {"role": "user", "content": "Write a web scraper."}, ] ) # Responses API instructions: response = client.responses.create( model="gpt-5.5", instructions="You are an expert Python engineer...", # top-level parameter input="Write a web scraper.", ) # Effective system prompt patterns: EFFECTIVE_SYSTEM_PROMPT = """ Role: You are an expert Python engineer at a fintech startup. Constraints: - Always use type hints and write Google-style docstrings - Prefer standard library over third-party when possible - Financial calculations must use Decimal, never float - Every function must have at least 2 unit tests Output format: - First, explain your approach in 2-3 sentences - Then provide the complete implementation - Finally, provide usage examples Do not: - Generate code you cannot verify is correct - Suggest experimental or deprecated libraries - Skip error handling for edge cases """
System prompt design principles:
- Be specific - vague instructions produce inconsistent results
- Include constraints - what NOT to do is as important as what to do
- Specify output format - tell the model exactly how to structure the response
- Give the model a role - "You are an expert X" sets context effectively
- Keep it stable - place system prompts at the start to maximise prompt caching
- Test iteratively - use evals to measure the impact of system prompt changes
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
