ChatGPT for Developers: A Practical Guide to Building Better Workflows
From the ChatGPT app to the OpenAI Responses API: prompt patterns, structured JSON output, a small Python pipeline you can reuse, and the guardrails to keep around generated code.

This guide is for developers who use ChatGPT ad hoc and want it to pay off in real work. Most people start the same way: paste an error, get a fix, move on. It works, but it does not compound. Every session starts from zero, the quality depends on how tired you are when you write the prompt, and nothing you learn ends up in code. The shift that makes it useful is treating it as two separate tools: the ChatGPT app for thinking and exploring, and the OpenAI API for anything you want to run more than twice.
The guide covers both sides: prompt patterns that hold up for code work, the current Responses API in Python, structured JSON output, a small pipeline you can reuse, and the places where it does not belong. Model names and API details are from OpenAI's documentation as of October 30, 2026 (linked in the sources); check them again before you copy anything into production, because they change often.
Key takeaways
- Use the ChatGPT app to explore and the OpenAI API for anything you will run again. If you paste the same kind of prompt a third time, make it a script.
- State the contract: input shape, output shape, errors and constraints. For anything a program reads, use Structured Outputs instead of asking for JSON in prose.
- Keep the model id in one config value, pin a snapshot in production, and keep a small test set to rerun before you switch models.
ChatGPT app or OpenAI API?
Both run OpenAI models, but they solve different problems. The OpenAI API is the programmatic way to call those models from your own code; OpenAI's quickstart uses its Responses API (client.responses.create) for every example.
Use the ChatGPT app for exploration: understanding an unfamiliar library, sketching an approach, rubber-ducking a bug, drafting a README you will edit anyway. The conversation is the product, and you are in the loop for every step.
Use the API when the same task will run again: a code review step in CI, summarising issues every morning, generating test fixtures, triaging logs. The API gives you control over instructions, input, output format and model version, and the result lands in your code instead of a chat window.
A rule of thumb: if you catch yourself pasting the same kind of prompt into the app for the third time, turn it into a script.
Prompt patterns that hold up for code
These work the same in the app and through the API.
Give the model a role and a contract
A short set of standing instructions removes most vague answers. For code review, something like this works:
You are a senior Python reviewer. Review the code below for bugs, security issues,
performance problems and readability, in that order of priority.
For each issue give: severity (high, medium, low), the line or function, the problem,
and a concrete fix. If you are not sure something is a bug, say so. Do not rewrite
the whole file.
The last two sentences matter most. Asking the model to flag uncertainty and to stay narrow cuts down on confident, invented problems and on huge rewrites you then have to diff by hand.
Describe the data, not just the task
"Write a function to parse JSON" gets you a generic function. Describing the actual shape gets you one you can use:
Write a Python function that takes the JSON body of GET /users from our API.
The body is {"data": [{"name": str, "email": str, "role": "admin" | "member"}], "next": str | null}.
Return a list of dicts with name, email and role. Raise ValueError if "data" is missing.
Use only the standard library and add type hints.
Include the input shape, the output shape, the error behaviour and the constraints (libraries, Python version, style). The more of the contract you state, the less you rewrite.
Ask for tests next to the code
When you ask for a function, also ask for three or four pytest cases, including one edge case. Reading the tests is the fastest way to see whether the model understood the problem, and running them is the fastest way to find out whether it did not.
Keep conversations short and scoped
Long chats drift. Earlier assumptions linger, and the model starts mixing up versions of the same file. When a thread changes topic, start a new one and paste only what is relevant. Through the API this is natural: each call gets exactly the context you send.
For more on prompt structure, see Crafting effective prompts for LLM performance.
Calling the OpenAI API from Python
OpenAI's quickstart uses the Responses API. You need Python 3.10 or newer (the openai package requires it on PyPI). Install the SDK and set your key; the client reads OPENAI_API_KEY from the environment, and the examples read the model id from OPENAI_MODEL.
pip install openai pydantic
export OPENAI_API_KEY="<YOUR_OPENAI_API_KEY>"
Checked against openai@3.41.0 and pydantic@2.14.2, 2026-10-30.
import os
from openai import OpenAI
client = OpenAI() # raises an error if OPENAI_API_KEY is not set
MODEL = os.environ.get("OPENAI_MODEL", "gpt-6.1-sol")
def main() -> None:
response = client.responses.create(
model=MODEL,
instructions="You are a concise senior Python reviewer. Flag uncertainty explicitly.",
input="Review this function:\n\ndef avg(xs):\n return sum(xs) / len(xs)",
)
print(response.output_text)
if __name__ == "__main__":
main()
Which model ID?
OpenAI's models page currently lists four flagship models:
| Model | ID | OpenAI's description | Price per 1M input / output tokens |
|---|---|---|---|
| GPT-6 Astra | gpt-6-astra |
Flagship for complex reasoning and coding | $10 / $50 |
| GPT-6.1 Sol | gpt-6.1-sol |
Near-Astra performance for complex work at a lower cost | $2 / $10 |
| GPT-6.1 Terra | gpt-6.1-terra |
Fast and efficient, for visual reasoning, computer use and natural writing | $1 / $5 |
| GPT-6 Luna | gpt-6-luna |
Most efficient, for high-volume, focused tasks | $0.10 / $0.50 |
Prices are the pricing page's standard short-context rates on 2026-10-30. OpenAI recommends GPT-6 Astra if you are not sure where to start. For day-to-day developer automation, a reasonable default is to start with Sol and drop to Luna for simple, high-volume steps such as classification or short summaries. Per-token prices differ by up to 100x, so the choice is worth testing rather than defaulting to the biggest model.
A few API details that trip people up:
instructionsapplies to one request only. OpenAI's docs note that if you chain turns withprevious_response_id, the instructions from earlier turns are not carried over. Send them on every call.- Reasoning effort replaces temperature tuning. The GPT-6 models are reasoning models, controlled with
reasoning={"effort": ...}. Supported values depend on the model (for example,gpt-6.1-soldoes not accept"none"or"minimal"). Older advice to "set temperature to 0.1 for code" does not map cleanly onto reasoning models, so check the model's page before relying on sampling parameters. - Pin a snapshot in production. OpenAI recommends pinning production apps to a dated model snapshot so behaviour does not shift under you. Use the alias while experimenting and the snapshot once a workflow is live.
Structured outputs: JSON you can trust
Most automation breaks at the boundary between the model's text and your code. Structured Outputs fixes that: you give a schema and the response conforms to it. With Pydantic, the SDK's parse helper does the work:
import os
from pathlib import Path
from typing import Literal
from openai import OpenAI
from pydantic import BaseModel
client = OpenAI() # raises an error if OPENAI_API_KEY is not set
class ReviewIssue(BaseModel):
severity: Literal["high", "medium", "low"]
location: str
problem: str
fix: str
class Review(BaseModel):
issues: list[ReviewIssue]
summary: str
def main() -> None:
response = client.responses.parse(
model=os.environ.get("OPENAI_MODEL", "gpt-6.1-sol"),
instructions="You are a senior Python reviewer. Flag uncertainty explicitly.",
input=Path("app/billing.py").read_text(),
text_format=Review,
)
review = response.output_parsed
for issue in review.issues:
print(f"[{issue.severity}] {issue.location}: {issue.problem}")
if __name__ == "__main__":
main()
If you do not use Pydantic, pass a JSON Schema in text={"format": {"type": "json_schema", "name": "...", "schema": {...}, "strict": True}}. Either way, the schema guarantees shape, not truth. A well-formed issue can still be wrong, so the output is a suggestion a human or a test confirms.
A repeatable pipeline you can adapt
Here is a pattern that fits most small automations: input, model call with a fixed contract, structured output, storage. This example summarises text (an issue, a meeting note, an article) into a SQLite table.
import os
import sqlite3
from openai import OpenAI
from pydantic import BaseModel
client = OpenAI() # raises an error if OPENAI_API_KEY is not set
# Cheap, high-volume step; move up only if quality is not enough.
MODEL = os.environ.get("OPENAI_DIGEST_MODEL", "gpt-6-luna")
class Digest(BaseModel):
summary: str
key_points: list[str]
tags: list[str]
def digest(text: str) -> Digest:
response = client.responses.parse(
model=MODEL,
instructions=(
"Summarise the input for a developer in 2-3 sentences, list up to 5 key "
"points, and give 1-4 lowercase tags. Use only facts in the input."
),
input=text,
text_format=Digest,
)
return response.output_parsed
def store(db: sqlite3.Connection, source: str, d: Digest) -> None:
db.execute(
"INSERT INTO digests (source, summary, key_points, tags) VALUES (?, ?, ?, ?)",
(source, d.summary, "\n".join(d.key_points), ",".join(d.tags)),
)
db.commit()
def main() -> None:
db = sqlite3.connect("digests.db")
db.execute(
"CREATE TABLE IF NOT EXISTS digests "
"(source TEXT, summary TEXT, key_points TEXT, tags TEXT)"
)
text = "Users report a crash in checkout when the cart is empty."
store(db, "issue-123", digest(text))
if __name__ == "__main__":
main()
Swap the Digest model and the instructions and the same skeleton triages GitHub issues, drafts release notes from commit messages, or generates test case ideas from a spec. When a step needs tools and decisions rather than one call, it is time for an agent loop; Building AI agents from scratch walks through one. If you would rather wire this up visually, n8n can call the same API; the n8n automation guide is a good starting point.
Log triage and documentation
Two uses that fit this pipeline well:
Log triage. A small script takes the tail of an error log, groups repeated stack traces, and asks the model for a likely cause and a suggested fix per group, as structured output. It writes the result to a Markdown file someone reads in the morning. Stop short of letting it open pull requests on its own. The suggestions are a starting point for debugging, not a replacement for it, and a list is easier to review than an unexpected PR.
Documentation. After the code is written and tested, ask for docstrings and a README section from the actual source, with a fixed template (purpose, usage example, parameters, errors). Because the code exists first, the docs describe what it does, not what you meant it to do. Still read every line, because a confident docstring for the wrong behaviour is worse than none.
Common mistakes to avoid
- Treating output as correct by default. Generated code can look right and be wrong in subtle ways: an off-by-one, a missing
await, a deprecated API. Run it, test it, read it. - Sending too much context. Pasting a whole repository into a chat makes answers vaguer, not better. Send the function, its callers and the error.
- Not stating constraints. If you need standard library only, Python 3.11, or no new dependencies, say so up front.
- Letting the model choose the output format. For anything a program reads, use Structured Outputs instead of asking for JSON in prose.
- Hard-coding a model name everywhere. Keep it in one config value so trying a new model is a one-line change.
When not to use ChatGPT
- Hard real-time paths. A model call adds network and generation time you do not control. Keep it out of request paths with tight latency budgets; run it asynchronously instead.
- Exact, deterministic logic. Calculations, permissions, billing rules and anything that must give the same answer every time belong in normal code. The model can help you write that code; it should not be that code.
- Sensitive data without a policy. OpenAI's API docs state that data sent to the API is not used to train its models unless you opt in, and that abuse-monitoring logs are kept for up to 30 days by default. That is the API; the ChatGPT app has its own settings that depend on your plan and workspace. Know which one you are using and what your client contracts allow before you paste production data or secrets.
- Unpinned critical workflows. Models are updated. If a business process depends on a specific behaviour, pin a snapshot and keep a test set to rerun before you upgrade.
Frequently asked questions
Can ChatGPT replace a developer?
No. It speeds up boilerplate, first drafts, explanations and debugging hypotheses, but architecture, trade-offs, security and knowing what to build stay with you. The developers who get the most from it are the ones who can tell when its answer is wrong.
Which OpenAI model should I use for coding tasks?
OpenAI suggests GPT-6 Astra (gpt-6-astra) as the starting point for complex reasoning and coding. For automated, repeated steps, test GPT-6.1 Sol and GPT-6 Luna first because they cost less, and only move up when your test cases need it.
Is it safe to use the API with private code?
OpenAI states that API data is not used for training unless you opt in, with abuse-monitoring logs kept for up to 30 days by default. Whether that is acceptable depends on your employer's or client's rules. Never send secrets or credentials, and strip them from logs before sending.
How do I make the output consistent?
Use clear standing instructions, describe the input and output precisely, add one or two examples, and use Structured Outputs for anything your code reads. Pin a model snapshot for production workflows.
Can I automate ChatGPT without writing code?
Yes. Tools like n8n can call the OpenAI API from a workflow. For anything that needs validation, tests or version control, a small script like the pipeline above is easier to test and review.
Sources
Verified against the sources below on October 30, 2026. Products and docs change often: check the linked sources if something looks different.
AI Automation Engineer & Salesforce Developer
Salesforce developer since June 2018. I build AI agents, n8n workflows and Salesforce integrations, and write up what holds up in real use.



Comments
Loading comments...