AI / Google Antigravity Gemini Fundamentals Interview Questions
What is the Gemini API's system instruction and how does it differ from a user prompt?
The system instruction (equivalent to a system prompt) sets the model's persona, behaviour, constraints, and context before any user interaction begins. It differs from a user prompt in that it is processed separately and takes precedence in shaping the model's overall behaviour.
from google import genai from google.genai import types client = genai.Client() # generateContent with system instruction: response = client.models.generate_content( model="gemini-3.5-flash", contents="Explain recursion.", # user input config=types.GenerateContentConfig( system_instruction="You are a Python tutor for beginners. Always give examples in Python. Keep explanations under 200 words. Never use jargon without explaining it first.", ) ) print(response.text) # Interactions API with system instruction: interaction = client.interactions.create( model="gemini-3.5-flash", input="Explain recursion.", system_instruction="You are a Python tutor for beginners...", ) # Effective system instruction principles: EFFECTIVE_SYSTEM_INSTRUCTION = """ Role: You are a senior Python code reviewer at a fintech company. Constraints: - Always check for security vulnerabilities first - Flag any use of eval() or exec() as critical risk - Use Decimal for financial calculations, never float - Output in this format: Risk Level, Issues, Recommendations Tone: Professional, direct, constructive """ # System instruction vs user prompt: # System instruction: stable per session; shapes all responses; cached efficiently # User prompt: changes per turn; the actual task or question
Caching system instructions: since system instructions are typically long and repeated across many requests, they are the primary candidate for context caching. A well-structured system instruction placed in a cache can reduce per-request costs significantly for production deployments with high request volumes.
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...
