콘텐츠로 이동

Prompting Strategies#

Skip to main content

/

  • English
  • Deutsch
  • Español – América Latina
  • Français
  • Indonesia
  • Italiano
  • Polski
  • Português – Brasil
  • Shqip
  • Tiếng Việt
  • Türkçe
  • Русский
  • עברית
  • العربيّة
  • فارسی
  • हिंदी
  • বাংলা
  • ภาษาไทย
  • 中文 – 简体
  • 中文 – 繁體
  • 日本語
  • 한국어

Get API key Cookbook Community Sign in

Docs API reference

The Interactions API is now generally available. We recommend using this API for access to all the latest features and models.

Send feedback

Prompt design strategies#

Prompt design is the process of creating prompts, or natural language requests, that elicit accurate, high quality responses from a language model.

This page introduces basic concepts, strategies, and best practices to get you started designing prompts to get the most out of Gemini AI models.

Note: Prompt engineering is iterative. These guidelines and templates are starting points. Experiment and refine based on your specific use cases and observed model responses.

Topic-specific prompt guides#

Looking for more specific prompt strategies? Check out our other prompting guides on:

You can find other sample prompts in the prompt gallery meant to interactively showcase many of the concepts shared in this guide.

Clear and specific instructions#

An effective and efficient way to customize model behavior is to provide it with clear and specific instructions. Instructions can be in the form of a question, step-by-step tasks, or as complex as mapping out a user's experience and mindset.

Input#

Input is the required text in the prompt that you want the model to provide a response to. Inputs can be a question that the model answers (question input), a task the model performs (task input), an entity the model operates on (entity input), or partial input that the model completes or continues (completion input).

Input type Prompt Generated output
Question
    What's a good name for a flower shop that specializes in selling bouquets of
    dried flowers? Create a list of 5 options with just the names.

|

    Here are 5 names for a flower shop specializing in dried flowers:

    1. Everlasting Blooms
    2. Dried & Delightful
    3. The Petal Preserve
    4. Whispers of Wildflowers
    5. Forever Blooms

Task |

    Give me a simple list of just the things that I must bring on a camping trip. The list should have 5 items.

|

    1. **Tent:** Your shelter from the elements.
    2. **Sleeping Bag:** Stay warm and comfortable.
    3. **Sleeping Pad:** Insulation and cushioning for a good night's sleep.
    4. **Headlamp or Flashlight:** Light for nighttime activities.
    5. **First Aid Kit:** Be prepared for minor injuries.

Entity |

    Classify the following items as [large, small]:
Elephant
Mouse
Snail

|

Here's the classification:

* **Elephant:** Large
* **Mouse:** Small
* **Snail:** Small

Partial input completion#

Generative language models work like an advanced auto completion tool. When you provide partial content, the model can provide the rest of the content or what it thinks is a continuation of that content as a response. When doing so, if you include any examples or context, the model can take those examples or context into account.

The following example provides a prompt with an instruction and an entity input:

Prompt:

For the given order, return a JSON object that has the fields cheeseburger, hamburger, fries, or
drink, with the value being the quantity.

Order: A burger and a drink.

Response:

{
  "cheeseburger": 0,
  "hamburger": 1,
  "fries": 0,
  "drink": 1
}

(gemini-2.5-flash)#

While the model did as prompted, writing out the instructions in natural language can sometimes be challenging and it leaves a lot to the model's interpretation. For example, a restaurants menu might contain many items. To reduce the size of the JSON response, you probably want to omit the items that weren't ordered. In this case, you can give an example and a response prefix and let the model complete it:

Prompt:

Valid fields are cheeseburger, hamburger, fries, and drink.
Order: Give me a cheeseburger and fries
Output:
```
{
  "cheeseburger": 1,
  "fries": 1
}
```
Order: I want two burgers, a drink, and fries.
Output:

Response:

```
{
  "hamburger": 2,
  "drink": 1,
  "fries": 1
}
```

(gemini-2.5-flash)#

Notice how "cheeseburger" was excluded from the output because it wasn't a part of the order.

While you can specify the format of simple JSON response objects using prompts, we recommend using Gemini API's structured output feature when specifying a more complex JSON Schema for the response.

Constraints#

Specify any constraints on reading the prompt or generating a response. You can tell the model what to do and not to do. For example, you can specify a constraint in the prompt on how long you want a summary to be:

Prompt:

**Summarize this text in one sentence:**
Text: A quantum computer exploits quantum mechanical phenomena to perform calculations exponentially
faster than any modern traditional computer. At very tiny scales, physical matter acts as both
particles and as waves, and quantum computing uses specialized hardware to leverage this behavior.
The operating principles of quantum devices is beyond the scope of classical physics. When deployed
at scale, quantum computers could be used in a wide variety of applications such as: in
cybersecurity to break existing encryption methods while helping researchers create new ones, in
meteorology to develop better weather forecasting etc. However, the current state of the art quantum
computers are still largely experimental and impractical.

Response:

      Exploiting quantum mechanical phenomena, quantum computers can perform calculations exponentially faster than traditional computers for potential applications like cybersecurity and meteorology, although they are currently largely experimental and impractical.

(gemini-2.5-flash)#

Response format#

You can give instructions that specify the format of the response. For example, you can ask for the response to be formatted as a table, bulleted list, elevator pitch, keywords, sentence, or paragraph. The following system instruction tells the model to be more conversational in its response:

System instruction

    All questions should be answered comprehensively with details, unless the user requests a concise response specifically.

Prompt

    What is a smart way to make a business that sells DVD's in 2026?

Response:

Starting a business selling DVDs in 2026 presents significant challenges due to the overwhelming domin