← Blog

How to Prompt Engineer ChatGPT: A Working Guide

2026-09-19 · 5 min read · SubToAPI Team

Prompt engineering ChatGPT means structuring your input so the model has enough context, constraints, and format guidance to produce the output you actually want on the first try. It's not about magic phrases — it's about being explicit where you'd normally rely on a human's shared context, and giving the model a clear job description instead of a vague request.

The short answer: tell ChatGPT who it should act as, what the task is, what the output should look like, and what "good" means for your specific case. The rest of this article breaks that down into steps you can apply immediately, whether you're using ChatGPT in the browser or calling a model through an API.

Start With Role and Task, Not Just the Question

A common mistake is asking ChatGPT a bare question and expecting a tailored answer. Instead, open with role and task framing:

You are a senior backend engineer reviewing a pull request.
Task: identify security issues in the code below.
Ignore style issues unless they cause bugs.

This does two things: it narrows the model's "persona" so its vocabulary and priorities match the task, and it tells it explicitly what to ignore. Without that second part, ChatGPT often pads its answer with generic advice you didn't ask for.

Specify the Output Format Explicitly

ChatGPT will default to prose unless you tell it otherwise. If you need structured output — JSON, a table, a numbered list, a specific schema — say so directly and show an example:

Return your answer as JSON with this exact shape:
{
  "issues": [{"line": number, "severity": "low"|"medium"|"high", "description": string}]
}
Do not include any text outside the JSON object.

This is the single highest-leverage change most people can make to their prompts. Vague format requests ("give me a list") produce inconsistent results across runs; a schema with types produces near-identical structure every time, which matters if you're parsing the response programmatically.

Give It Examples (Few-Shot Prompting)

When the task has a "shape" you can demonstrate, show one or two examples before asking for the real one:

Convert customer feedback into a one-line summary.

Feedback: "The app crashed twice today when I tried to upload a photo."
Summary: App crash on photo upload.

Feedback: "Support took 3 days to respond and didn't solve my billing issue."
Summary: Slow support, unresolved billing issue.

Feedback: "Love the new dashboard, much faster than before."
Summary:

Few-shot examples work better than long written instructions because the model pattern-matches on structure rather than trying to interpret abstract rules.

Break Complex Tasks Into Steps

For multi-part tasks, ask ChatGPT to work through them in order rather than jumping straight to a final answer. This reduces errors on anything involving reasoning, math, or multi-file code changes:

1. List the functions in this file and what each one does.
2. Identify which functions have no test coverage.
3. Write tests only for the functions from step 2.

This is sometimes called chain-of-thought prompting, but you don't need the term — you just need to stop asking for the end result in one shot when the task actually has several dependent parts.

Set Constraints Up Front

Constraints prevent ChatGPT from over-delivering or under-delivering. Common ones worth stating explicitly:

Without constraints, the model guesses at your intent, and its guess is usually more verbose and more generic than what you needed.

Iterate Instead of Rewriting From Scratch

If the first response is close but not right, don't restart the conversation — correct it directly:

Good structure, but remove the introduction paragraph and
start directly with the first bullet point.

ChatGPT retains conversation context, so targeted corrections are faster and more reliable than re-explaining the whole task with a new prompt.

Moving From Prompting to Production

Prompting well in the ChatGPT interface is one skill; running the same prompts reliably inside an application is another. Once you're sending prompts programmatically — for a support bot, a content pipeline, or an internal tool — you need consistent message formatting, streaming support, and usage visibility, not just a good prompt.

If you're already comfortable using Claude through a subscription and want to reuse that same access as an API instead of paying for a second provider, SubToAPI turns your existing Claude plan into an HTTPS API with sub_live_... application keys, streaming responses, tool use, and per-key usage metadata. The prompting techniques above — explicit roles, output schemas, few-shot examples, step-by-step instructions — carry over directly; you're just sending them through /docs/messages instead of a chat window. Check the quickstart if you want to see the request format, and pricing for plan details starting at Solo for individuals up to Scale for teams needing more seats.

Putting It Together

A well-engineered ChatGPT prompt usually has four parts in this order: role and task, constraints, examples if applicable, and output format. Skipping any one of these is where most vague or inconsistent outputs come from. Test your prompts more than once — small wording changes can shift output quality, so if a prompt matters (production, repeated use, customer-facing), run it a handful of times before trusting the pattern.

Questions

Does prompt engineering ChatGPT require special tools or a paid course? No. It's a skill you build by writing clear, structured prompts and testing them. Tools help with organizing prompts at scale, but the core technique — role, constraints, examples, format — works in the free ChatGPT interface.

Why does ChatGPT give different answers to the same prompt? Language models sample from probability distributions, so some variation is expected even with identical prompts. Adding explicit output formats and constraints reduces variation significantly, but it won't eliminate it entirely.

Can I use the same prompting techniques with other models like Claude? Yes. Role framing, output schemas, few-shot examples, and step-by-step breakdowns are model-agnostic techniques. If you're calling Claude via an API such as SubToAPI, the same prompt structures apply — see /docs/tools for tool-use specific patterns.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →