Skip to main content
Use these guidelines to write prompts for Agent Studio. Test your prompts on examples in the Response Playground in the Algolia dashboard.

Write effective prompts

A prompt gives instructions to a large language model (LLM), an AI system that generates responses. Prompt engineering means writing and refining these instructions. Write an initial prompt, test it with sample questions or content, review unexpected responses, and refine it. Start by defining the task you want the model to perform. For example:
  • Summarize this user review.
  • Describe who this product is for.
  • Translate this product’s description into Spanish.

Make instructions explicit

Develop the task into a full prompt with detailed, explicit instructions. Include relevant background information and requirements, such as who the response is for and how long it should be. Focus on the information you need. For example, ask for a summary of a company’s financial performance rather than a general description of the company. When asking the model to describe who a product is for, specify which user groups to consider. For example:

Specify the output

Specify the response format and length. If the response must use specific answers or labels, list them in the prompt. For example, when you need product questions in XML, name the format in the prompt:

Include example responses

Few-shot prompting uses examples of expected responses in the prompt to show the model how to answer. Pair each example question or piece of content with the response you want. You can also include examples of responses the model shouldn’t produce. Use “Expected response:” to identify a response to follow and “Response to avoid:” to identify an unwanted response. For example, this prompt includes two reviews and their expected responses.
Prompt

Keep prompts simple and concise

Use plain language and remove repetition or irrelevant details. Break complex tasks into smaller tasks. Keep explicit requirements and short examples that clarify the expected output. Use prompts for similar tasks as a starting point.

Keep instructions consistent

Use the same terms throughout the prompt. Make sure examples of expected responses match your instructions. Remove conflicting requirements or state which one takes priority.

Provide fallback options

Specify what to do when the information supplied to the model isn’t enough to answer. Don’t require an answer when information is missing. For example, when answers must come from the supplied product information:

Security and compliance guidance

Don’t paste secrets, personally identifiable information (PII), or internal URLs into prompt templates. Don’t add company policies or other sensitive information to your prompt templates. Test some generated answers for policy compliance.

Test and refine prompts

During testing, try shorter versions of the prompt to find unnecessary details. You can also use an LLM to rephrase the prompt, then test the revised version.

Example prompt

This prompt helps engineers learn Kubernetes concepts before migrating their applications. It includes instructions and examples of expected and unwanted responses.
Prompt

See also

Last modified on September 23, 2026