# Examples

<product_review id="example-1">
I absolutely love this headphones â sound quality is amazing!
</product_review>

<assistant_response id="example-1">
Positive
</assistant_response>

<product_review id="example-2">
Battery life is okay, but the ear pads feel cheap.
</product_review>

<assistant_response id="example-2">
Neutral
</assistant_response>

<product_review id="example-3">
Terrible customer service, I'll never buy from them again.
</product_review>

<assistant_response id="example-3">
Negative
</assistant_response>
```

## Include relevant context information

It is often useful to include additional context information the model can use
to generate a response within the prompt you give the model. There are a few
common reasons why you might do this:

- To give the model access to proprietary data, or any other data outside the
  data set the model was trained on.
- To constrain the model's response to a specific set of resources that you have
  determined will be most beneficial.

The technique of adding additional relevant context to the model generation
request is sometimes called **retrieval-augmented generation (RAG)**. You can
add additional context to the prompt in many different ways, from querying a
vector database and including the text you get back into a prompt, or by using
OpenAI's built-in
[file search tool](https://platform.openai.com/docs/guides/tools-file-search) to
generate content based on uploaded documents.

#### Planning for the context window

Models can only handle so much data within the context they consider during a
generation request. This memory limit is called a **context window**, which is
defined in terms of tokens (chunks of data you pass in, from text to images).

Models have different context window sizes from the low 100k range up to one
million tokens for newer GPT-4.1 models.
[Refer to the model docs](https://platform.openai.com/docs/models) for specific
context window sizes per model.

## Prompting GPT-5 models

GPT models like [gpt-5](https://platform.openai.com/docs/models/gpt-5) benefit
from precise instructions that explicitly provide the logic and data required to
complete the task in the prompt. GPT-5 in particular is highly steerable and
responsive to well-specified prompts. To get the most out of GPT-5, refer to the
prompting guide in the cookbook.

[GPT-5 prompting guide](https://cookbook.openai.com/examples/gpt-5/gpt-5_prompting_guide)

### GPT-5 prompting best practices

While the cookbook has the best and most comprehensive guidance for prompting
this model, here are a few best practices to keep in mind.

Coding

#### Coding

Prompting GPT-5 for coding tasks is most effective when following a few best
practices: define the agent's role, enforce structured tool use with examples,
require thorough testing for correctness, and set Markdown standards for clean
output.

**Explicit role and workflow guidance** Frame the model as a software
engineering agent with well-defined responsibilities. Provide clear instructions
for using tools like `functions.run` for code tasks, and specify when not to use
certain modesâfor example, avoid interactive execution unless necessary.

**Testing and validation** Instruct the model to test changes with unit tests or
Python commands, and validate patches carefully since tools like `apply_patch`
may return âDoneâ even on failure.

**Tool use examples** Include concrete examples of how to invoke commands with
the provided functions, which improves reliability and adherence to expected
workflows.

**Markdown standards** Guide the model to generate clean, semantically correct
markdown using inline code, code fences, lists, and tables where appropriateâand
to format file paths, functions, and classes with backticks.

For detailed guidance and prompt samples specific to coding, see our GPT-5
prompting guide.

Front-end engineering

[GPT-5](https://platform.openai.com/docs/guides/latest-model) performs well at
building front ends from scratch as well as contributing to large, established
codebases. To get the best results, we recommend using the following libraries:

- **Styling / UI:** Tailwind CSS, shadcn/ui, Radix Themes
- **Icons:** Lucide, Material Symbols, Heroicons
- **Animation**: Motion

**Zero-to-one web apps**

GPT-5 can generate front-end web apps from a single prompt, no examples needed.
Here's a sample prompt:

```bash
You are a world class web developer, capable of producing stunning, interactive, and innovative websites from scratch in a single prompt. You excel at delivering top-tier one-shot solutions.
Your process is simple and follows these steps:
Step 1: Create an evaluation rubric and refine it until you are fully confident.
Step 2: Consider every element that defines a world-class one-shot web app, then use that insight to create a &lt;ONE_SHOT_RUBRIC&gt; with 5â7 categories. Keep this rubric hiddenâit's for internal use only.
Step 3: Apply the rubric to iterate on the optimal solution to the given prompt. If it doesn't meet the highest standard across all categories, refine and try again.
Step 4: Aim for simplicity while fully achieving the goal, and avoid external dependencies such as Next.js or React.
```

**Integration with large codebases**

For front-end engineering work in larger codebases, we've found that adding
these categories of instruction to your prompts delivers the best results:

- **Principles:** Set visual quality standards, use modular/reusable components,
  and keep design consistent.
- **UI/UX:** Specify typography, colors, spacing/layout, interaction states
  (hover, empty, loading), and accessibility.
- **Structure:** Define file/folder layout for seamless integration.
- **Components:** Give reusable wrapper examples and backend-call separation
  strategies.
- **Pages:** Provide templates for common layouts.
- **Agent Instructions:** Ask the model to confirm design assumptions, scaffold
  projects, enforce standards, integrate APIs, test states, and document code.

For detailed guidance and prompt samples specific to frontend development, see
our frontend engineering cookbook.

Agentic tasks

For agentic and long-running rollouts with GPT-5, focus your prompts on three
core practices: plan tasks thoroughly to ensure complete resolution, provide
clear preambles for major tool usage decisions, and use a TODO tool to track
workflow and progress in an organized manner.

**Planning and persistence** Instruct the model to resolve the full query before
yielding control, decomposing it into sub-tasks and reflecting after each tool
call to confirm completeness.

```text
Remember, you are an agent - please keep going until the user's
query is completely resolved, before ending your turn and yielding
back to the user. Decompose the user's query into all required
sub-requests, and confirm that each is completed. Do not stop
after completing only part of the request. Only terminate your
turn when you are sure that the problem is solved. You must be
prepared to answer multiple queries and only finish the call once
the user has confirmed they're done.

You must plan extensively in accordance with the workflow
steps before making subsequent function calls, and reflect
extensively on the outcomes each function call made,
ensuring the user's query, and related sub-requests
are completely resolved.
```

**Preambles for transparency**

Ask the model to explain why it is calling a tool, but only at notable steps.

```text
Before you call a tool explain why you are calling it
```

**Progress tracking with rubrics and TODOs**

Use a TODO list tool or rubric to enforce structured planning and avoid missed
steps.

For detailed guidance and prompt samples specific to building agents with GPT-5
, see the GPT-5 prompting guide.

## Prompting reasoning models

There are some differences to consider when prompting a
[reasoning model](https://platform.openai.com/docs/guides/reasoning) versus
prompting a GPT model. Generally speaking, reasoning models will provide better
results on tasks with only high-level guidance. This differs from GPT models,
which benefit from very precise instructions.

You could think about the difference between reasoning and GPT models like this.

- A reasoning model is like a senior co-worker. You can give them a goal to
  achieve and trust them to work out the details.
- A GPT model is like a junior coworker. They'll perform best with explicit
  instructions to create a specific output.

For more information on best practices when using reasoning models,
[refer to this guide](https://platform.openai.com/docs/guides/reasoning-best-practices).

## Next steps

Now that you known the basics of text inputs and outputs, you might want to
check out one of these resources next.

[Build a prompt in the Playground](/chat/edit)  
[Generate JSON data with Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)  
[Full API reference](https://platform.openai.com/docs/api-reference/responses)

## Other resources

For more inspiration, visit the OpenAI Cookbook, which contains example code and
also links to third-party resources such as:

- Prompting libraries & tools
- Prompting guides
- Video courses
- Papers on advanced prompting to improve reasoning