Best Practices (Help Center)
OpenAI's concise, no-nonsense best practices. Quick wins for prompt formatting, temperature tuning, few-shot examples, and avoiding common mistakes.
Official OpenAI docs →Put instructions first, context second
Always place your instruction at the start of the prompt before the context. Use ### or triple quotes to visually separate instruction from content. Be specific about the desired outcome, length, format, and style. This simple structural change consistently improves output quality because the model 'sees' what you want before processing the material.
Be specific, kill the fluff
Replace every vague word with a precise one. 'Fairly short' becomes '3 to 5 sentences.' 'A few examples' becomes 'exactly 3 examples.' 'Good quality' becomes 'professional tone, no jargon, aimed at non-technical executives.' Every vague word is a decision you're forcing the model to guess. Remove unnecessary words and be direct.
Say what to do, not what not to do
Negative instructions are surprisingly unreliable. 'Don't ask for interests' is less effective than 'Suggest available topics and ask the user to pick one.' Positive instructions give the model a clear path forward instead of a minefield to navigate. When you catch yourself writing 'don't', flip it to a 'do' statement.
Start zero-shot, then add examples
Try getting your result with no examples first. If the output isn't right, add 2-3 examples showing the exact input/output format you want (few-shot). If that still isn't working, consider fine-tuning. This progressive approach saves you tokens and time. Don't jump straight to complex prompts when a simple one might work.
Temperature and top_p
Temperature controls randomness: 0 means deterministic and focused, 1 means creative and varied. For production use cases where consistency matters (classification, extraction, analysis), use 0 to 0.3. For creative tasks (writing, brainstorming, marketing copy), use 0.7 to 1.0. Top_p works similarly but controls randomness differently. Only change one at a time, never both.
Code generation patterns
When generating code, use leading words to nudge the output. Starting your prompt with 'import' primes Python code generation. Be explicit about the language, framework, version, and coding style. Specify whether you want comments, error handling, type hints, or tests. For complex code tasks, describe the input/output contract before asking for the implementation.