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

ModelTypeContextBest ForSpeed
GPT-4oMultimodal128KGeneral-purpose, vision, code, conversationFast
GPT-4o miniMultimodal128KBudget tasks, high-volume, simple classificationVery fast
o1Reasoning200KComplex math, logic, science, coding puzzlesSlow
o3Reasoning200KHardest reasoning tasks, research-grade problemsSlower
o3-miniReasoning200KReasoning at lower costMedium
o4-miniReasoning200KLatest efficient reasoning modelMedium

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:

TaskGPT-4oo1/o3
"Write a REST API endpoint"GreatOverkill
"Debug this race condition"DecentMuch better
"Prove this algorithm is O(n log n)"StrugglesReliable
"Solve this competitive programming problem"Hit or missStrong
"Quick code review"PerfectToo slow
"Design a distributed consensus algorithm"Surface-levelDeep analysis

Pricing Comparison

ModelInput (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:

ComparisonOpenAIAnthropic
Main modelGPT-4o: $2.50 / $10Sonnet 4.6: $3 / $15
Budget modelGPT-4o mini: $0.15 / $0.60Haiku 4.5: $0.80 / $4
Reasoningo3: $10 / $40Opus 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:

python
response = 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.

python
response = 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)

python
from 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)

python
tools = [{ "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

python
stream = 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

ScenarioPrefer OpenAIPrefer Claude
Image generation neededDALL-ENo native option
Web browsing in chatBuilt-inNeeds MCP/tools
Budget classificationGPT-4o mini ($0.15/1M)Haiku ($0.80/1M)
Long context (>128K)Limited to 128KUp to 1M tokens
Agentic coding (CLI)Codex CLI (newer)Claude Code (mature)
Strict instruction followingGoodBetter
Code Interpreter (sandbox)Built-inNot available
Custom chatbots (no-code)Custom GPTsLimited
Hard reasoningo1/o3Opus 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

  1. Use GPT-4o mini for simple tasks to save 95%+ on costs vs GPT-4o.
  2. Use o1/o3 only for genuinely hard reasoning. They're overkill for simple tasks.
  3. Use JSON mode whenever you need to parse the output programmatically.
  4. Custom GPTs are great for team workflows (share a specialized bot with colleagues).
  5. Code Interpreter is unmatched for data analysis — upload a CSV and ask questions.
  6. Set temperature to 0 for deterministic, reproducible outputs in production.

Resources


Previous: 10 - Claude (Anthropic) | Next: 12 - AI Coding Assistants