System rules and constraints
AI Models & Assistants / Knowledge library
Prompt Engineering
Designing instructions, context, examples, and output constraints
Why learn Prompt Engineering?
Good prompts reduce ambiguity and make outputs easier to validate. Prompts cannot create missing knowledge, guarantee truth, or replace authorization and application-side controls.
Where it came from
Prompt engineering grew with general-purpose language models that could perform tasks from instructions and in-context examples. Reliable prompts specify the task, relevant context, constraints, and a checkable output contract.
Build your understanding
Work through these exercises in order. Try the task before opening a reference.
- Specify an output contract: Which prompt most clearly requests machine-readable output?
- Separate data from instructions: A prompt includes an untrusted document to summarize. What is the safest structure?
- Use few-shot examples: When are examples especially useful in a prompt?
- Evaluate prompt changes: How should two prompt versions be compared for a production extraction task?
- Recognize prompt limits: Which requirement should remain enforced outside the prompt?
Documentation and sources
- OpenAI prompt engineering guide (platform.openai.com)
Connect the ideas
Explore next
Real World Example
Automated Legal Compliance Summarization
Legal tech firms managing high volumes of regulatory filings.
The business problem
Inconsistent summarization of complex legal documents leading to manual review bottlenecks and increased operational costs.
How this topic solves it
Implementing structured prompt engineering by separating system-level instructions from user-provided document content to ensure consistent, role-based output formatting.
- Define a developer role message containing specific summarization constraints and output style guidelines.
- Inject the raw regulatory text into a user role message to isolate data from logic.
- Pin the application to a specific model snapshot to ensure consistent behavior across deployments.
- Integrate evaluation suites to measure prompt performance before pushing updates to production.
The flow shows how developer instructions and user data are combined to produce a compliant output.
Raw regulatory input
Model processing
Final structured output
- Developer Message → defines logic → Responses API
- User Message → provides data → Responses API
- Responses API → generates → Compliance Summary
Implementation example
This maps to the scenario by separating the developer's summarization instructions from the user's specific regulatory document content.
const response = await client.responses.create({
model: "gpt-6-astra",
input: [
{ role: "developer", content: "Summarize legal text into 3 bullet points." }, // Defines logic
{ role: "user", content: "[Regulatory Document Text]" } // Provides input data
],
});Expected business outcome
Standardized, predictable summaries that reduce the cognitive load on legal analysts during the review process.
Limitations and checks
Non-deterministic output generation; check this by maintaining representative fixtures and running automated evaluation suites to monitor performance as you iterate.