OpenAI Platform Documentation
URL: https://platform.openai.com/docs
GPT-5.4
Flagship model (Mar 2026)
1.05M
Context window (tokens)
$2.50
Per 1M input tokens (GPT-5.4)
REST
API format
What is this resource?
The OpenAI Platform Documentation is the official, comprehensive technical reference maintained by OpenAI for developers building AI-powered applications. It covers the complete lifecycle of working with OpenAI's API — from generating your first API key and making your first request, all the way to deploying production-grade features using their most advanced models. As of 2026, the flagship model family is GPT-5.4 (released March 2026), which comes in four tiers: GPT-5.4 ($2.50/$15 per 1M input/output tokens), GPT-5.4 mini ($0.75/$4.50), GPT-5.4 nano ($0.20/$1.25), and GPT-5.4 Pro ($30/$180 for maximum capability). All tiers support a 1.05M-token context window and benefit from 50% cached input discounts. For complex reasoning tasks, OpenAI also offers reasoning-focused models that internally chain their thinking before responding. If you are integrating AI into any kind of software project, this documentation is the single most important reference you will return to repeatedly.
What makes this documentation particularly valuable is that it is written specifically for developers, not end users. It assumes you know how to write code and focuses on the mechanics of the API: how requests are structured, what parameters control model behavior, how responses are formatted, and how to handle errors. It is precise, well-organized, and regularly updated to reflect new models and features as OpenAI releases them. OpenAI introduced the Responses API as a successor to Chat Completions for agentic workflows — it natively supports web search, file reading, and computer use tools without external orchestration.
What's in it?
The documentation is organized around OpenAI's core API endpoints. The Chat Completions guide — the most critical section for most developers — explains how to structure the messages array, which holds the entire conversation history sent with every API call. Each message has a role (system, user, or assistant) and content, and understanding how this structure works is fundamental to building any chatbot or conversational feature. The guide explains how parameters like temperature (0 to 2, controlling randomness), max_tokens (limiting response length), and top_p affect model outputs. GPT-5.4 supports a 1.05-million-token context window — enough to fit an entire codebase or book-length document in a single request.
The Tool Use section (previously "function calling") lets you define functions and give the model the ability to call them by returning structured JSON. For example, you could define a get_weather(city) function, and when a user asks "what's the weather in New York?", the model responds with a structured call your app executes. Structured Outputs — fully supported across the GPT-5.4 family — go further: by passing a JSON Schema as response_format, the model is guaranteed to return valid JSON matching your exact schema — no parsing failures, no hallucinated field names. This is now the recommended approach for any structured data extraction task.
Other essential sections include the Responses API (OpenAI's new agentic endpoint with built-in web search, file reading, and code interpreter tools — no LangChain required for simple agent tasks), the Embeddings guide (converting text into vectors for search), the Models overview comparing all current models and pricing, and the Batch API reference, which lets you process large volumes of requests asynchronously at a 50% cost discount — ideal for data pipelines and bulk classification tasks.
How is it relevant to your purpose?
If you are building any kind of AI-powered feature — a chatbot, an intelligent search tool, a code assistant, or a document summarizer — you will almost certainly use the OpenAI API as your starting point. This documentation is where you will find everything you need to make it work correctly and efficiently. For a developer building something like a study app with AI-generated flashcards, a customer support bot, or a writing assistant, the Chat Completions endpoint is the core building block and this documentation explains it better than any third-party tutorial. The GPT-5.4 family gives you a clear tiered choice: use nano for high-volume simple tasks ($0.20/1M tokens), mini for general use ($0.75/1M), GPT-5.4 for production-quality work ($2.50/1M), and GPT-5.4 Pro for maximum capability on the hardest tasks ($30/1M).
Understanding the API mechanics covered here has real financial stakes: every API call costs money based on token count, and a badly structured application can easily burn through a monthly budget in a day. The docs explain exactly how tokens are counted, how conversation history accumulates costs across turns, and what strategies (like truncating old messages, using the Batch API for async work at 50% off, or enabling prompt caching) prevent runaway spending. Cached input tokens on GPT-5.4 are discounted by 50% — if your app sends the same large system prompt or document on every request, this alone can cut API costs dramatically. For a developer moving from prototype to real users, this knowledge is not optional — it directly affects whether your application is economically viable.
Key concept: Structured Outputs
OpenAI's Structured Outputs — fully supported across GPT-5.4 — lets you pass a JSON Schema in response_format and the model is guaranteed to return valid JSON matching your schema exactly. This eliminates the most common failure mode in AI-powered apps: trying to JSON.parse() a response and getting a SyntaxError because the model added a sentence before the JSON. Use response_format={"type": "json_schema", "json_schema": {...}} for any structured data extraction task.
Recommended Watch
OpenAI API Tutorial for Beginners
A hands-on walkthrough of the OpenAI API using Python — covers authentication, Chat Completions, building a basic chatbot, and handling token limits. Great companion to reading the docs.
Quick Start: Chat Completions + Structured Outputs (Python)
GPT-5.4 with Structured Outputs guarantees valid JSON matching your schema. Install with pip install openai. The second example shows the Responses API — OpenAI's agentic endpoint with built-in web search.
from openai import OpenAI
# Initialize client with your API key from platform.openai.com
client = OpenAI(api_key="sk-...")
# --- Chat Completions with Structured Outputs (GPT-5.4) ---
response = client.chat.completions.create(
model="gpt-5.4-mini", # $0.75/1M in · $4.50/1M out
messages=[
{"role": "system", "content": "Extract structured data from the user's input."},
{"role": "user", "content": "John Doe, 28, senior engineer at Acme Corp."}
],
response_format={
"type": "json_schema",
"json_schema": {
"name": "person",
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
"title": {"type": "string"},
"company": {"type": "string"}
},
"required": ["name", "age", "title", "company"]
}
}
}
)
# Guaranteed valid JSON — no try/except JSON.parse needed
data = response.choices[0].message.content
print(data) # → {"name": "John Doe", "age": 28, ...}
# Always check token usage — this is what you're billed on
print(f"Tokens used: {response.usage.total_tokens}")
print(f" Input: {response.usage.prompt_tokens}")
print(f" Output: {response.usage.completion_tokens}")
# --- Responses API (2025): agentic endpoint with built-in web search ---
r = client.responses.create(
model="gpt-5.4",
tools=[{"type": "web_search_preview"}],
input="What is the current price of GPT-5.4 per 1M tokens?"
)
print(r.output_text)