Back to Prompts
🔵Google AIBeginner

Google Gemini Prompt Engineering Guide

Best practices for prompting Google's Gemini models, including Gemini 2.5 Pro and multimodal capabilities

View Official Documentation

TL;DR

  • Be precise and direct - state your goal clearly
  • Use consistent structure with clear delimiters
  • Leverage few-shot prompting with 3-5 examples
  • Keep temperature at 1.0 for best reasoning performance
  • Use system instructions for consistent behavior
  • Take advantage of multimodal capabilities

Key Principles

1State your goal clearly and concisely
2Use XML-style tags or Markdown headers as delimiters
3Provide 3-5 examples for pattern-based tasks
4Explicitly request detailed responses if needed (default is concise)
5Keep temperature at 1.0 to avoid unexpected behavior
6Prompt for self-critique before final response on complex tasks

Be Precise and Direct

Gemini models respond best to prompts that are direct, well-structured, and clearly define the task and constraints. By default, Gemini 3 provides direct and efficient answers - if you need more detail, you must explicitly request it.

Examples

Specify output requirements
Bad:
Write about dogs
Good:
Write a 150-word blog post about the benefits of adopting rescue dogs.
- Target audience: First-time dog owners
- Tone: Warm and encouraging
- Include: 3 specific benefits with brief explanations

Specific parameters ensure the output matches your exact needs.

Use Consistent Structure

Employ clear delimiters to separate different parts of your prompt. XML-style tags (e.g., <context>, <task>) or Markdown headings are both effective approaches.

Examples

Structure with XML tags
Good:
<context>
You are a technical documentation writer.
</context>

<task>
Write API documentation for a user registration endpoint.
</task>

<requirements>
- Include request/response examples
- Document error codes
- Keep it concise
</requirements>

Clear structure helps Gemini understand and organize its response accordingly.

Few-Shot Prompting

Gemini can pick up on patterns using a few examples. Experiment with the number - too few may not establish the pattern, too many may cause overfitting. Show patterns to follow rather than anti-patterns to avoid.

Examples

Establish output pattern with examples
Good:
Convert product descriptions to tags.

Example 1:
Input: "Warm wool sweater perfect for winter, available in red and blue"
Output: [clothing, sweater, wool, winter, red, blue]

Example 2:
Input: "Stainless steel water bottle, 32oz, keeps drinks cold"
Output: [drinkware, bottle, steel, 32oz, insulated]

Now convert:
Input: "Leather messenger bag with laptop compartment, brown"

Two clear examples establish the tagging pattern for Gemini to follow.

Temperature Settings

For Gemini 3 models, keep temperature at its default value of 1.0. Setting it lower may lead to unexpected behavior like looping or degraded performance, especially in complex reasoning tasks.

Advanced Reasoning with Self-Critique

For complex tasks, leverage Gemini's thinking capabilities by prompting it to plan or self-critique before the final response. This includes parsing goals into sub-tasks, checking if input is complete, and creating structured outlines.

Examples

Self-critique before answering
Good:
Before answering, please:
1. Identify the key components of this question
2. Consider what information you need
3. Note any assumptions you're making
4. Then provide your answer

Question: Should our startup expand to the European market this year?

Prompting for self-reflection improves response quality for complex decisions.

Multimodal Prompting

Gemini excels at multimodal tasks. When working with images, videos, or audio, be specific about what aspects you want analyzed and how they relate to any text instructions.

Examples

Image analysis with specific focus
Good:
[Attach image]

Analyze this product photo for our e-commerce listing:
1. Describe the main product features visible
2. Suggest 3 improvements to the photo composition
3. Write a 2-sentence product description based on what you see

Specific instructions about what to analyze in the image yield more useful results.

#prompt-engineering#gemini#google-ai#multimodal#few-shot#temperature#system-instructions
Last updated: December 1, 2024