OpenAI API

Access GPT-4o, o1, embeddings, and assistants via API.

Developer API

Overview

The OpenAI API is the developer-facing product behind ChatGPT — the same GPT-5 family of models, exposed as HTTPS endpoints with per-token pricing, first-party SDKs in eight languages, and a batteries-included platform for embeddings, image generation, speech, moderation, and agentic tool use. If you have shipped anything with a generative feature in the last three years, there is a good chance the first line of production code you wrote called openai.chat.completions.create().

OpenAI built the API before it built ChatGPT — the /v1/completions endpoint predates the consumer chatbot by two years — and that lineage still shows in how the platform is priced, documented, and versioned. The pricing philosophy is "cheap enough to prototype, priced to scale": GPT-5 nano exists precisely so a hackathon project doesn't burn through a $50 credit in an afternoon, and GPT-5 flagship exists so the same project can graduate to production without switching providers.

The one-line positioning: the OpenAI API is the safest first pick for any team shipping a generative feature in 2026 — the widest model catalog, the most mature SDK ecosystem, the deepest documentation, and the tightest integration with the tools and habits developers already have. It is not always the cheapest per-token option and not always the fastest per-request, but the ratio of engineering hours saved to dollars spent is still the best in the category for most teams.

Under the hood the API surface splits into six product lines: chat completions (the workhorse), the Responses API (the newer agentic surface with built-in state and tools), embeddings, image generation (DALL-E 3 and gpt-image-1), Realtime (streaming voice), and Batch (asynchronous jobs at half price). If you learn one of them well, the others feel familiar within an afternoon.

Key Features

The OpenAI API's feature set in 2026 is enormous. The parts that matter for most integrations:

  • GPT-5, GPT-5 mini, and GPT-5 nano. The current generation of general-purpose models, priced across roughly two orders of magnitude. GPT-5 is the frontier chat and reasoning model; mini is the cost-optimized default for most production traffic; nano is the classifier-cheap tier for high-volume, low-stakes calls. All three share the same API surface, so switching between them is a one-line change.
  • o-series reasoning models. The o3 and o3-mini lineage — trained to think longer before answering — remains the pick for math, code, and multi-step planning where a five-second wait for a correct answer beats a one-second wait for a wrong one. Pricing per token is higher and latency is measured in seconds, not milliseconds.
  • Responses API with built-in tools. The successor to the Assistants API. First-class support for web search, code interpreter, file search over your vector stores, and computer use, all callable as tool types without wiring them yourself. Threads and stateful conversations are handled server-side, which eliminates a lot of the boilerplate that made the old Assistants API awkward.
  • Function calling with strict JSON mode. Pass a JSON Schema, get back tokens guaranteed to conform. This one feature alone rewrote how production systems talk to LLMs — no more regex-parsing hallucinated JSON, no more retry loops on malformed output. The strict mode adds a small latency cost and is worth it every time.
  • Structured Outputs and JSON Schema enforcement. Beyond function calling, you can pin any response to a schema. Combine with Pydantic or Zod on the client side and you get end-to-end typed contracts between your LLM and your application.
  • Streaming everywhere. Server-Sent Events on chat, deltas on Responses, and the Realtime API for full-duplex audio. Time-to-first-token on GPT-5 hovers around 400-600 ms in typical regions, and streamed output makes almost any UX feel responsive.
  • Embeddings v3. text-embedding-3-large at 3072 dimensions and text-embedding-3-small at 1536 dimensions, with configurable output size via the dimensions parameter — useful for cutting vector-store costs when you don't need the full space. These embeddings still trade wins with Cohere and Voyage on public benchmarks but win on ecosystem support.
  • DALL-E 3 and gpt-image-1. Native image generation via the same key. gpt-image-1 is the newer multimodal image model with better prompt fidelity and reference-image support. Prices are per image and per resolution tier.
  • Realtime API for voice. Full-duplex speech-to-speech with sub-second latency, interruption handling, and function calling inside the voice loop. This is the API surface behind Advanced Voice in ChatGPT, and it is genuinely different from stitching together Whisper plus a chat call plus TTS.
  • Batch API at 50% off. Submit a JSONL file of requests, get results within 24 hours, pay half the sync-endpoint price. The right tool for backfills, evaluation runs, and any workload where latency doesn't matter.
  • SDKs in Python, Node, .NET, Java, Go, Ruby, Kotlin, and PHP. All first-party, all versioned in lockstep with the API. The Python and Node SDKs are the most feature-complete and get new capabilities the day they ship.

Pricing

OpenAI API pricing is per token, tiered by model, with a Batch discount and prompt caching layered on top. Approximate per-million-token prices in mid-2026:

Model Input ($/M) Output ($/M) Cached input ($/M)
GPT-5 $5.00 $15.00 $2.50
GPT-5 mini $0.30 $1.20 $0.15
GPT-5 nano $0.05 $0.20 $0.025
o3 $15.00 $60.00 $7.50
o3-mini $1.10 $4.40 $0.55
text-embedding-3-large $0.13
text-embedding-3-small $0.02

Image generation prices per image, roughly $0.04 (low) to $0.19 (high) for gpt-image-1 depending on resolution and quality. Realtime audio bills separately per audio-minute in and out, currently around $6/M audio-input tokens and $24/M audio-output tokens. Whisper transcription is $0.006 per audio-minute. Batch API is a flat 50% discount off sync-endpoint prices.

The pricing that actually matters for most projects: GPT-5 mini at $0.30/$1.20 is where you should route the majority of production traffic. It is roughly 90% of the quality of full GPT-5 for typical instruction-following, classification, extraction, and summarization tasks, at one-sixteenth the price. Reserve full GPT-5 for the calls where quality visibly drops on mini — usually long-form writing, nuanced reasoning, and multi-hop tool use.

Prompt caching gives you a 50% discount on any tokens that hit a cached prefix. For RAG systems, agent loops, and any workload with a long stable system prompt, this alone can cut effective bills by 30-40% with no code changes beyond ordering your messages correctly.

Pros and Cons

Pros

  • The most complete model catalog in the industry — frontier chat, reasoning, embeddings, images, audio, and moderation from one key
  • SDKs in every serious language, updated same-day with API releases
  • Best-in-class documentation and a genuinely useful playground for prototyping
  • Structured Outputs and strict JSON mode eliminate an entire class of production bugs
  • Prompt caching and Batch API give real cost levers without changing model choice
  • The Responses API with built-in tools removes the boilerplate that made agentic apps painful in 2023-2024
  • Global rate limits are generous by default and scale quickly once you have billing history

Cons

  • Not the cheapest per-token option — Groq, DeepSeek, and open-model hosts undercut GPT-5 mini for many workloads
  • Latency on GPT-5 flagship is respectable but not exceptional; if sub-100 ms time-to-first-token matters, look at Groq or Cerebras
  • No open weights — you cannot self-host, fine-tune the base model on your own hardware, or air-gap deployments
  • Fine-tuning is available but pricing and quality gains are modest compared to using a better base model
  • Data residency is limited compared to Azure OpenAI, which is why many enterprise buyers route the same models through Azure instead
  • API surface is large and evolving — old endpoints get deprecated on 12-month timelines and migrations are on you

Best Use Cases

  • Startups shipping their first generative feature. The combination of docs, SDK maturity, and model breadth means you can prototype on GPT-5 mini in an afternoon and ship without swapping infrastructure. Almost every YC batch since 2023 has been dominated by OpenAI-API-backed products for a reason.
  • Production RAG systems. Embeddings v3, function calling, structured outputs, and prompt caching combine into one of the smoothest RAG stacks available. Pair with a vector database of your choice and you have a working retrieval pipeline in a few hundred lines.
  • Agentic applications. The Responses API with built-in web search, code interpreter, file search, and computer use is the most complete agentic surface any provider ships. Building the same functionality on top of raw chat completions is possible but adds weeks of work.
  • Voice-first products. The Realtime API is the only production-grade speech-to-speech surface with sub-second latency and function calling inside the loop. If you are building a voice agent, phone bot, or in-app voice assistant, this is the shortest path to a demo that doesn't feel like Siri circa 2015.
  • Batch analytical workloads. Overnight classification of a million support tickets, embedding backfills, evaluation runs — the Batch API at half price makes these workloads economically sensible.

Alternatives

The OpenAI API has real competition in 2026, and the right pick depends on which axis matters most:

  • Anthropic API — Claude Sonnet 4.5 and Opus 4.7 win on long-form writing and hard coding, with a 1M-token context window on Sonnet. Pick this if your workload is writing-quality-sensitive or leans on very long context. Pricing sits in the same range as GPT-5.
  • Groq — the same open-weight models (Llama 4, Qwen, Mixtral) served at 500+ tokens per second on custom LPU hardware. Pick this if latency dominates your UX budget and you can live with open-weight quality instead of GPT-5.
  • Together AI — cost-optimized hosting of open-weight models with fine-tuning and dedicated endpoints. Roughly one-third the token price of GPT-5 mini for Llama 3.3 70B-class quality.
  • Hugging Face — inference endpoints, spaces, and the model hub. Pick this if you need to run a specific open-weight model that no closed-provider hosts, or if you want to fine-tune and serve on your own dedicated infra.
  • Azure OpenAI — the same OpenAI models, hosted by Microsoft with enterprise-grade compliance, regional deployments, and BAA/HIPAA coverage. Pick this if procurement requires Azure or if data residency is non-negotiable.

For the consumer product on top of this API, see ChatGPT. For head-to-head model comparisons in production settings, artificialanalysis.ai publishes updated latency and quality benchmarks weekly.

Getting Started

  1. Create an OpenAI account at platform.openai.com and generate an API key. New accounts get $5 in free credits, which is enough to run a few hundred thousand tokens through GPT-5 mini and get a real feel for quality.
  2. Install the official SDK. pip install openai for Python, npm install openai for Node. The five-line quickstart in the docs will get you your first response.
  3. Start on GPT-5 mini, not flagship. Route everything at mini first and only upgrade the calls where quality visibly drops. Most teams over-provision on model choice for months before figuring out that mini would have been fine.

Set a hard monthly spending limit in the dashboard on day one. Enable usage tracking. If you are building a customer-facing product, use per-user rate limiting on your side before you hit OpenAI's — the platform will happily let you burn a $10,000 bill overnight if a bot loops on your endpoint.

FAQ

Is the OpenAI API the same models as ChatGPT? Roughly, yes — the GPT-5 family is shared. ChatGPT Plus applies additional product-layer features (Memory, Custom GPTs, browsing) that are not part of the raw API. The models themselves are the same.

How much does GPT-5 cost per real conversation? A typical multi-turn support conversation of ~5,000 input tokens and 500 output tokens costs about $0.033 on GPT-5, $0.002 on GPT-5 mini, and $0.0003 on GPT-5 nano. At scale, the model-choice decision matters more than any other cost lever.

Does OpenAI train on my API traffic? No. API traffic is not used to train models by default, and has not been since 2023. This is different from ChatGPT free/Plus, where consumer chats may be used for training unless you opt out.

What's the largest context window? GPT-5 supports 400K tokens of input and 128K tokens of output as of mid-2026. o3 supports 200K. That is smaller than Claude Sonnet's 1M context, and large enough for the vast majority of production RAG and agent workloads.

Can I fine-tune GPT-5? Fine-tuning is available on GPT-5 mini and nano. Flagship GPT-5 is not fine-tunable directly. For most use cases, prompt engineering and structured outputs get you further than fine-tuning at a fraction of the cost.

Verdict

The OpenAI API is the default first pick for shipping any generative feature in 2026. The combination of model catalog breadth, SDK maturity, documentation depth, and mature agentic surface means you spend less engineering time fighting infrastructure and more time on your actual product. For teams new to LLM development, this is the platform where the tutorials assume the least about what you already know.

Where OpenAI stops being the obvious choice is on the two edges the platform doesn't optimize for: raw per-token cost and raw per-request latency. Open-weight hosts on Together AI or Groq will be cheaper and faster for workloads that don't need frontier reasoning, and Anthropic's Claude will out-write GPT-5 on long-form prose. Mature teams end up multi-provider: OpenAI for the agentic and image work, Anthropic for the writing-quality calls, Groq for the latency-sensitive interactive UX.

The honest recommendation for most teams shipping in 2026: start on the OpenAI API, route the majority of traffic to GPT-5 mini with prompt caching enabled, reserve GPT-5 flagship for the calls where quality visibly matters, and add a second provider only when you have measured a specific reason to. Most projects never need the second provider, and the ones that do usually know exactly which calls to route where by the time they add it.

Explore more in the Developer API category, or read The Economics of AI Inference at Scale for the broader token-pricing landscape.