ChatGPT & OpenAI
Overview
OpenAI launched ChatGPT in November 2022 and triggered the current AI boom. They offer the most widely used AI products: ChatGPT (consumer), the OpenAI API (developer), and an expanding ecosystem of plugins, custom GPTs, and coding tools.
Model Lineup
| Model | Type | Context | Best For | Speed |
|---|---|---|---|---|
| GPT-4o | Multimodal | 128K | General-purpose, vision, code, conversation | Fast |
| GPT-4o mini | Multimodal | 128K | Budget tasks, high-volume, simple classification | Very fast |
| o1 | Reasoning | 200K | Complex math, logic, science, coding puzzles | Slow |
| o3 | Reasoning | 200K | Hardest reasoning tasks, research-grade problems | Slower |
| o3-mini | Reasoning | 200K | Reasoning at lower cost | Medium |
| o4-mini | Reasoning | 200K | Latest efficient reasoning model | Medium |
GPT-4o (The Workhorse)
The default model for most tasks. "o" stands for "omni" — it handles text, images, audio, and code in a single model.
Strengths:
- Fast and capable across all modalities
- Good at code generation and debugging
- Built-in vision (analyze screenshots, diagrams, photos)
- 128K context window (about 300 pages)
Limitations:
- Can hallucinate on niche topics
- Weaker than o1/o3 on hard reasoning
- No extended thinking (reasoning happens implicitly)
o1 / o3 (Reasoning Models)
These models think before answering. They use chain-of-thought internally (you can't see the reasoning by default) and are significantly better on hard problems.
Standard model: Reasoning model:
User → GPT-4o → Answer User → o3 → [hidden thinking] → Answer
(instant) (5-60 seconds of reasoning)
When to use o1/o3 over GPT-4o:
| Task | GPT-4o | o1/o3 |
|---|---|---|
| "Write a REST API endpoint" | Great | Overkill |
| "Debug this race condition" | Decent | Much better |
| "Prove this algorithm is O(n log n)" | Struggles | Reliable |
| "Solve this competitive programming problem" | Hit or miss | Strong |
| "Quick code review" | Perfect | Too slow |
| "Design a distributed consensus algorithm" | Surface-level | Deep analysis |
Pricing Comparison
| Model | Input (per 1M tokens) | Output (per 1M tokens) |
|---|---|---|
| GPT-4o | $2.50 | $10 |
| GPT-4o mini | $0.15 | $0.60 |
| o1 | $15 | $60 |
| o3 | $10 | $40 |
| o3-mini | $1.10 | $4.40 |
| o4-mini | $1.10 | $4.40 |
vs Claude pricing:
| Comparison | OpenAI | Anthropic |
|---|---|---|
| Main model | GPT-4o: $2.50 / $10 | Sonnet 4.6: $3 / $15 |
| Budget model | GPT-4o mini: $0.15 / $0.60 | Haiku 4.5: $0.80 / $4 |
| Reasoning | o3: $10 / $40 | Opus 4.6: $15 / $75 |
GPT-4o mini is significantly cheaper for simple tasks. Claude Sonnet and GPT-4o are close in price and capability.
Key Features
Vision
GPT-4o can analyze images natively:
pythonresponse = client.chat.completions.create( model="gpt-4o", messages=[{ "role": "user", "content": [ {"type": "text", "text": "What's in this image?"}, {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}} ] }] )
DALL-E (Image Generation)
Generate images from text descriptions. Available in ChatGPT and via API.
pythonresponse = client.images.generate( model="dall-e-3", prompt="A software engineer debugging code at 3am, pixel art style", size="1024x1024" ) image_url = response.data[0].url
Code Interpreter
ChatGPT can execute Python code in a sandboxed environment:
- Upload data files (CSV, Excel, JSON)
- Run analysis, generate charts
- Process and transform data
- Debug code by actually running it
Web Browsing
ChatGPT Plus can search the web for current information, making it useful for questions about recent events, documentation, or live data.
ChatGPT Interface
Custom GPTs
Build specialized chatbots with no code:
Custom GPT: "SQL Query Helper"
├── Instructions: "You help write PostgreSQL queries. Always use
│ parameterized queries. Explain your query logic."
├── Knowledge: uploaded schema.sql, style-guide.md
└── Actions: can call external APIs (optional)
Anyone can create and share custom GPTs. They combine a system prompt, uploaded knowledge files, and optional API integrations.
Memory
ChatGPT remembers facts about you across conversations:
- "I prefer TypeScript over JavaScript"
- "I work with PostgreSQL and Redis"
- "Explain things concisely, I'm a senior engineer"
You can view and manage memories in Settings. Useful for consistent personalized responses.
Canvas
A side panel for editing code and documents collaboratively:
- Edit specific sections without regenerating everything
- Ask for targeted improvements ("make this function async")
- Track changes visually
- Switch between code and document mode
File Uploads
Upload files directly into the conversation:
- PDFs, images, CSVs, code files
- ChatGPT can read, analyze, and reference them
- Code Interpreter can execute uploaded Python scripts
OpenAI API
Chat Completions (Basic Call)
pythonfrom openai import OpenAI client = OpenAI() # Uses OPENAI_API_KEY env var response = client.chat.completions.create( model="gpt-4o", messages=[ {"role": "system", "content": "You are a helpful coding assistant."}, {"role": "user", "content": "Write a Python function to validate email addresses."} ] ) print(response.choices[0].message.content)
Function Calling (Tool Use)
pythontools = [{ "type": "function", "function": { "name": "get_stock_price", "description": "Get the current stock price for a ticker symbol", "parameters": { "type": "object", "properties": { "ticker": {"type": "string", "description": "Stock ticker symbol (e.g., AAPL)"} }, "required": ["ticker"] } } }] response = client.chat.completions.create( model="gpt-4o", tools=tools, messages=[{"role": "user", "content": "What's Apple's stock price?"}] ) # Model returns a tool_call with arguments: {"ticker": "AAPL"}
JSON Mode / Structured Outputs
Force the model to return valid JSON:
python# Simple JSON mode response = client.chat.completions.create( model="gpt-4o", response_format={"type": "json_object"}, messages=[ {"role": "system", "content": "Respond in JSON."}, {"role": "user", "content": "List 3 programming languages with their use cases."} ] ) # Structured output (strict schema) from pydantic import BaseModel class Language(BaseModel): name: str use_case: str difficulty: str response = client.beta.chat.completions.parse( model="gpt-4o", response_format=Language, messages=[{"role": "user", "content": "Describe Python."}] ) parsed = response.choices[0].message.parsed # Language object
Streaming
pythonstream = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Explain REST APIs."}], stream=True ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="")
GitHub Copilot Connection
OpenAI's models power GitHub Copilot:
- Copilot uses GPT-4o and other OpenAI models for code suggestions
- Copilot Chat is GPT-4o in your IDE (VS Code, JetBrains)
- Copilot Workspace uses reasoning models for multi-file changes
See 12 - AI Coding Assistants for detailed Copilot coverage.
When to Use OpenAI vs Claude
| Scenario | Prefer OpenAI | Prefer Claude |
|---|---|---|
| Image generation needed | DALL-E | No native option |
| Web browsing in chat | Built-in | Needs MCP/tools |
| Budget classification | GPT-4o mini ($0.15/1M) | Haiku ($0.80/1M) |
| Long context (>128K) | Limited to 128K | Up to 1M tokens |
| Agentic coding (CLI) | Codex CLI (newer) | Claude Code (mature) |
| Strict instruction following | Good | Better |
| Code Interpreter (sandbox) | Built-in | Not available |
| Custom chatbots (no-code) | Custom GPTs | Limited |
| Hard reasoning | o1/o3 | Opus 4.6 + thinking |
The honest answer: Both are excellent. For most tasks, the difference is marginal. Pick the one that fits your workflow and ecosystem.
Quick Tips
- Use GPT-4o mini for simple tasks to save 95%+ on costs vs GPT-4o.
- Use o1/o3 only for genuinely hard reasoning. They're overkill for simple tasks.
- Use JSON mode whenever you need to parse the output programmatically.
- Custom GPTs are great for team workflows (share a specialized bot with colleagues).
- Code Interpreter is unmatched for data analysis — upload a CSV and ask questions.
- Set temperature to 0 for deterministic, reproducible outputs in production.
Resources
- 🔗 OpenAI Documentation
- 🔗 OpenAI API Reference
- 🔗 OpenAI Pricing
- 🔗 OpenAI Cookbook (examples)
- 🔗 Custom GPTs Guide
- 🔗 ChatGPT
Previous: 10 - Claude (Anthropic) | Next: 12 - AI Coding Assistants