Introduction

OpenAI just added a first‑party Prompt Optimizer to the Playground. It rewrites any prompt to match GPT‑5 best practices. The tool removes contradictions, fixes format specifications, and tunes the prompt for the model’s agentic capabilities. Pair the optimizer with a small dataset and an evaluation flywheel and you get a fully automated migration pipeline. No more manual trial‑and‑error edits.

Why Optimizing for GPT‑5 matters

GPT‑5 is the smartest model OpenAI has released. It excels at agentic tasks, coding, and multi‑modal reasoning. The model also expects stricter prompt hygiene than its predecessors. Small ambiguities that were harmless for GPT‑4 can hurt GPT‑5’s performance, leading to hallucinations or wasted compute. An optimized prompt gives you:

  • Higher success rates on complex tool use.
  • Lower latency because the model spends less time resolving contradictory instructions.
  • Better alignment with the model’s built‑in agentic tuning.

The Prompt Optimizer at a glance

The optimizer lives at https://platform.openai.com/chat/edit?models=gpt-5&optimize=true [1]. You paste a prompt into the Developer Message field and click Optimize. The service analyses the prompt, runs a few internal evaluations, and returns a revised version. It also highlights the changes it made and why they matter.

Key capabilities:

  • Contradiction removal – Detects and resolves opposing directives.
  • Format spec repair – Ensures JSON, CSV, or custom schemas are well‑formed.
  • Agentic tuning – Adds or re‑weights instructions that help the model behave like an autonomous assistant.
  • Iterative improvement – You can run the optimizer repeatedly on the new prompt to squeeze out further gains.

Step‑by‑step migration cookbook

Below is a reproducible workflow you can drop into a notebook or CI job.

1. Create a dataset of prompt‑output pairs

import os

# Must be available as OPENAI_API_KEY
dataset = [
    {"prompt": "<your original prompt>", "expected": "<desired behavior>"},
    # Add at least three rows with real model outputs
]
# Write to JSONL for the API
with open("gpt5_opt_dataset.jsonl", "w") as f:
    for row in dataset:
        f.write(json.dumps(row) + "\n")

2. Add annotations and graders

  • Add a Good/Bad column that marks whether the output met the task.
  • Add a free‑form critique column with specific feedback (e.g., “missing JSON key temperature”).
  • Write a simple grader that checks for those keys. The grader should return a numeric score; higher scores indicate better alignment.

3. Launch the optimization

  1. Open the Prompt Optimizer UI.
  2. Upload your dataset via the Datasets tab.
  3. Paste the original prompt in the Developer Message field.
  4. Click Optimize.

The UI will generate a new prompt and a Prompt Object you can reuse via its prompt_id.

4. Test the optimized prompt

import openai

optim_prompt_id = "<prompt_id_from_ui>"
response = openai.ChatCompletion.create(
    model="gpt-5",
    prompt=optim_prompt_id,
    # Optional: supply your test inputs here
)
print(response)

If the result still falls short, repeat step 3. Each iteration typically yields diminishing returns, so two or three passes are enough for most tasks.

5. Hook into an evaluation flywheel

OpenAI’s eval API lets you run the same dataset against the new prompt automatically [2]. Store the scores, compare to the baseline, and trigger another optimizer run if the improvement drops below a threshold.

from openai import Evaluations

baseline = Evaluations.run(dataset="gpt5_opt_dataset.jsonl", prompt=original_prompt_id)
optimized = Evaluations.run(dataset="gpt5_opt_dataset.jsonl", prompt=optim_prompt_id)

# Simple improvement metric
delta = optimized.mean_score - baseline.mean_score
print(f"Improvement: {delta:.2f}")

Best‑practice checklist

  • Use at least three dataset rows – the optimizer needs a minimal signal.
  • Provide clear Good/Bad labels – vague ratings reduce the quality of the learned edits.
  • Add concrete critiques – the optimizer relies on textual feedback to rewrite ambiguous sections.
  • Run the optimizer on a copy of the prompt – never edit the original in place.
  • Validate before production – manually review a few optimized prompts; edge cases sometimes slip through.

When to skip the optimizer

  • The prompt already follows the official GPT‑5 prompting guide [3].
  • Your task is extremely sensitive to wording and you have a proven manual prompt that works.
  • You lack a dataset or can’t generate enough graded examples.

Conclusion

The Prompt Optimizer turns a tedious manual migration into a repeatable pipeline. By coupling a tiny dataset, clear annotations, and the evaluation flywheel you can push any legacy prompt to GPT‑5 with measurable gains in correctness and speed. The next time you ship a new LLM‑powered feature, start with the optimizer – it saves hours of trial‑and‑error and gives you a reusable prompt object for future experiments.


Citations

  1. OpenAI Prompt Optimizer UI – <https://platform.openai.com/docs/guides/prompt-optimizer>
  2. OpenAI Evaluation API – <https://platform.openai.com/docs/guides/evaluations>
  3. GPT‑5 Prompting Guide – <https://developers.openai.com/cookbook/examples/gpt-5/gpt-5promptingguide/>

Suggested title

OpenAI Prompt Optimizer + GPT‑5 Migration Cookbook

Word count

748

Fact‑check notes

  • Verify that the Prompt Optimizer URL still points to the optimizer page (it may change with future UI updates).
  • Confirm that the evaluation API endpoints and parameter names match the current OpenAI docs.
  • Ensure the dataset JSONL format aligns with the latest OpenAI spec (field names prompt and expected).