OpenAI API Platform Guide: Models, APIs, and Agents
OpenAI's official docs describe the development flow as "from prompt to product." Following the GPT-5.6 release, the platform's models, APIs, and tools now cover text generation, images, speech, realtime conversation, and agent orchestration. For developers wiring AI into websites, SaaS products, or internal tools, the key is understanding model selection, API usage, and cost control.
1. The Model Matrix: Balancing Capability and Cost
OpenAI organizes its models into several families, and the official docs stress "think about the task first, then pick a model."
- Flagship and reasoning models: GPT-5.6 (including the sol/terra/luna variants) and GPT-5.5 target complex reasoning and long-running agent tasks, with context windows on the order of one million tokens. The o-series (for example o3, o4-mini) excels at science, math, and coding that require deep deliberation.
- Cost-efficiency and low latency: GPT-5.4 mini/nano and GPT-4o mini fit high-frequency, budget-sensitive workloads such as support, summarization, and classification.
- Multimodal and creative models: GPT-4o accepts text and image input, alongside dedicated image generation (gpt-image), audio, and realtime speech (gpt-realtime, whisper transcription) models.
- Embedding models: The text-embedding-3 family maps text into vectors, the foundation for RAG retrieval. See the RAG implementation guide for practical usage.
Pricing varies widely between models. Billing is per input/output token, and reasoning tokens are billed separately. When running several models in parallel without centralized governance, bills can spiral; the AI gateway spend limits guide shows how to set budgets at a gateway layer.
2. Core APIs: Chat Completions and Responses API
API choice is the most common point of confusion for beginners.
- Chat Completions API: The classic
POST /v1/chat/completionsendpoint, which organizes conversation as a messages array. It is simple, has the widest ecosystem compatibility, and most third-party compatible APIs align with it. - Responses API: The newer recommended interface that folds tool calling, file search, web search, and computer use into a unified response object. It fits agent-style applications, and OpenAI recommends it for new projects.
In practice: use Chat Completions for simple Q&A or migration-sensitive projects; prefer Responses API for multi-step tool calling, state management, and built-in tools such as Web Search and File Search.
The two APIs are called in very similar ways; the real difference is in the response structure. Below are minimal examples for each using the official Python SDK (see the API Reference for the full parameter set):
# Option 1: Chat Completions, single-turn Q&A
import openai
client = openai.Client(api_key="sk-...")
resp = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[
{"role": "system", "content": "You are an e-commerce agent. Be concise and polite."},
{"role": "user", "content": "When will my order ship?"},
],
temperature=0.3,
)
print(resp.choices[0].message.content)
# Option 2: Responses API with built-in Web Search
resp = client.responses.create(
model="gpt-5.6",
tools=[{"type": "web_search_preview"}],
input="Check OpenAI platform status today and summarize it",
)
print(resp.output_text)
Notice that the Responses API folds tool declarations into a unified object, and the input field no longer distinguishes system/user roles. The whole flow maps more closely to "one request, one task."
3. Tool Calling and Structured Outputs
Letting the model "call functions" is the key capability for building real AI applications: you declare tools (each with a name and a JSON Schema of parameters), the model returns tool_calls, your code executes the tool and returns results, and the model produces the final answer.
- Parallel tool calling: Multiple tool calls can be issued in a single request, cutting round trips.
- Structured Outputs: Constrain the model to emit valid JSON via an output schema, so results plug directly into forms, database writes, and downstream systems.
- Strict mode: The docs recommend disabling additional properties and requiring all fields, which measurably raises JSON compliance.
4. Assistants and the Agents SDK
Moving from "single-shot Q&A" to "autonomously executing tasks" is a meaningful step up.
- Assistants API: Packages instructions, tools, file search, and conversation state into a reusable assistant object, ideal for quickly building support or shopping assistants.
- Agents SDK: A production-grade multi-agent orchestration framework. Its core primitives are Agent (instructions + tools + guardrails), Handoff (delegating work to another agent), Guardrails (input/output validation), and built-in tracing. Paired with the Responses API, it suits complex multi-step business workflows. For fundamentals, see AI agent development basics.
5. Pricing and Cost Governance
OpenAI bills input, output, and cached tokens at different rates, with reasoning tokens charged separately. Practical tips:
- Estimate before integrating: Use the official pricing page and a tokenizer (such as tiktoken) to estimate per-call cost, then multiply by daily call volume.
- Leverage caching: Enable prompt caching for system prompts and fixed context to cut input costs substantially.
- Use the Batch API: For non-realtime jobs, batch processing is typically 50% cheaper and suits offline workloads.
- Set budget guardrails: Centralized budgets matter most when running multiple models, preventing runaway costs from abnormal traffic.
- Evaluate continuously: After swapping models or prompts, use the AI model evaluation guide to build regression tests so you do not "save money and lose quality."
A Concrete Cost Estimate
Let us work through a real example. Suppose you are building a consumer-facing support agent on GPT-5.4 mini, averaging 600 input tokens and 150 output tokens per conversation:
| Item | Value |
|---|---|
| Input price | $1.25 / million tokens |
| Output price | $10 / million tokens |
| Daily conversations | 20,000 |
| Cost per conversation | ~$0.0023 |
| Monthly cost (unoptimized) | ~$1,400 |
Enabling prompt caching for system prompts and fixed scripts (around a 60% hit rate) can cut input costs by roughly another 40%; moving non-realtime work to the Batch API can halve the total bill again. Conversely, if you always reach for the most expensive flagship model, the same conversation volume could cost 5-10x more with GPT-5.6. Modeling your real traffic first, then choosing the model tier, usually matters more than agonizing over which API to use.
FAQ
- Will the Responses API replace Chat Completions? OpenAI is pushing the new interface as its preferred direction, but both will coexist for a long time, and most existing ecosystems (third-party SDKs, compatibility layers) still align with Chat Completions. New projects with low migration cost should adopt Responses directly; legacy projects do not need a rushed rewrite.
- How do I handle images and speech? Pass image input as an
image_urlinside the content array of a message; use the Realtime API for live voice conversations and Whisper for offline transcription. They share the same key and quota system as the text models. - What if I hit token limits? The most common solution is chunking documents, embedding them for vector retrieval, and sending only relevant fragments into context (RAG) instead of blindly expanding the model's context window.
6. 16IDC Takeaways
If you are wiring OpenAI into your website or business, start by placing a model gateway in front of all vendors to consolidate keys, budgets, and logs into one layer; move non-realtime workloads (summaries, transcription, batch processing) to the Batch API; and validate outputs with fallback strategies. Also reserve enough compute and bandwidth for your server selection: although API calls run in the cloud, local embedding, reranking, logging, and vector retrieval still need stable infrastructure.
References: Overview https://platform.openai.com/docs/overview; Pricing https://platform.openai.com/docs/pricing; API Reference https://platform.openai.com/docs/api-reference; Structured Outputs guide https://platform.openai.com/docs/guides/structured-outputs