OpenAI API
The OpenAI API lets programs call OpenAI's models (GPT-6 Astra, GPT-6.1 Sol, GPT-6.1 Terra, GPT-6 Luna, image, voice and transcription models) with an API key, billed per token. New projects use the Responses API through the official SDKs, with documentation at developers.openai.com.
The OpenAI API is the paid developer service for calling OpenAI's models from your own code: you create an API key in the dashboard, install an official SDK (pip install openai or npm install openai), and send a request to the Responses API, paying per token rather than a monthly fee. It is separate from a ChatGPT subscription, with its own billing, usage tiers and rate limits; ChatGPT Plus includes no API usage, though ChatGPT Pro and paid Business seats now come with monthly API credits (below). As of Nov 6, 2026 the flagship models are GPT-6 Astra, GPT-6.1 Sol, GPT-6.1 Terra and GPT-6 Luna, and OpenAI's developer documentation lives at developers.openai.com.
Quick facts
| What it is | Pay-as-you-go access to OpenAI models over HTTPS, with official SDKs |
| Documentation | developers.openai.com/api/docs |
| Dashboard and keys | platform.openai.com (keys, billing, limits) |
| Recommended endpoint | Responses API ("recommended for all new projects") |
| Flagship models | gpt-6-astra, gpt-6.1-sol, gpt-6.1-terra, gpt-6-luna, as of Nov 6, 2026 |
| Cheapest flagship | GPT-6 Luna, $0.10 in and $0.50 out per 1M tokens, as of Nov 6, 2026 |
| Most capable | GPT-6 Astra, $10 in and $50 out per 1M tokens, as of Nov 6, 2026 |
| Context window | 1,050,000 tokens on all four flagships |
| Official SDKs | Python, JavaScript, .NET, Ruby; Java and Go in beta |
| Usage tiers | Free, Build, Launch, Grow |
How do you start using the OpenAI API?
The quickstart takes five steps. Each SDK reads the key from the environment, so you never paste it into code (OpenAI quickstart).
- Sign in to the OpenAI developer dashboard (platform.openai.com) and add a payment method or credits. A first purchase of $5 in credits moves an organization from the Free tier to Build.
- Select Create an API Key in the dashboard and copy the key once; it is not shown again.
- Store it as the environment variable
OPENAI_API_KEY:export OPENAI_API_KEY="your_api_key_here"on macOS or Linux, orsetx OPENAI_API_KEY "your_api_key_here"in Windows PowerShell. - Install an SDK:
pip install openaifor Python,npm install openaifor JavaScript,dotnet add package OpenAIfor .NET, orgem "openai"in a Ruby Gemfile. - Call
responses.createwith a model and an input. OpenAI's own example asksgpt-6-astrafor a one-sentence bedtime story about a unicorn.
from openai import OpenAI
client = OpenAI() # reads OPENAI_API_KEY
response = client.responses.create(
model="gpt-6-luna",
input="Write a one-sentence bedtime story about a unicorn.",
)
print(response)
The example above swaps in GPT-6 Luna, the cheapest flagship, which is a sensible default while testing. The Java SDK (com.openai:openai-java) and the Go SDK (github.com/openai/openai-go/v3) are both labeled beta on the quickstart as of Nov 6, 2026. For trying prompts without code, the quickstart links the Chat Playground at platform.openai.com/chat.
Is the OpenAI API free?
Not in practice. The Free usage tier exists for accounts in an "allowed geography" and carries a $100 monthly usage limit, but every token is still billed at the published prices. A few things cost nothing: the moderation model omni-moderation-latest is free, and the first 1 GB of file search storage is free. For the full price list, see OpenAI API Pricing.
Some ChatGPT plans now pay for part of it. Since Oct 28, 2026, ChatGPT Pro adds $100, $200 or $500 of API credits a month on its $100, $200 and $500 tiers, and paid Business seats add $20 (Standard) or $100 (Premium) each, pooled up to $500 a month per workspace. You link one API organization under Billing in ChatGPT; unused credits expire at the end of the billing period, and they do not raise ChatGPT or Codex limits. Plus, Enterprise and Edu are not eligible (OpenAI Help Center).
Which models can you call?
OpenAI's models page splits the catalog into flagship and specialized models, as of Nov 6, 2026.
| Model | API id | What OpenAI says it is for | Price per 1M tokens (in / out) |
|---|---|---|---|
| GPT-6 Astra | gpt-6-astra |
The most demanding work | $10.00 / $50.00 |
| GPT-6.1 Sol | gpt-6.1-sol |
Near-Astra performance at lower cost | $2.00 / $10.00 |
| GPT-6.1 Terra | gpt-6.1-terra |
Visual reasoning, computer use and writing, fast | $1.00 / $5.00 |
| GPT-6 Luna | gpt-6-luna |
Focused, high-volume tasks | $0.10 / $0.50 |
Source: OpenAI models and OpenAI API pricing, read Nov 6, 2026. Short-context prices (up to 272K input tokens).
All four take text and images in and give text out, with a 1,050,000-token context window and 128,000 tokens of output. Astra and Sol do not accept reasoning effort none; Terra and Luna do (latest model guide).
The specialized models cover other jobs: GPT Image (gpt-image-2.6-sunburst and gpt-image-2.6-flare, released Nov 4, 2026), voice for the Realtime API (gpt-realtime-2.1, gpt-live-1), speech to text (gpt-transcribe and gpt-live-transcribe), embeddings (text-embedding-3-small and -large), and gated models for security and life sciences (GPT-Rosalind and Cyber Models). The open-weight gpt-oss models are listed on their own pages but not on the main models page. Older models such as GPT-5.5, GPT-5.4, GPT-4.1 and GPT-4o still have prices, but many have shutdown dates; see Retired ChatGPT Models and the deprecations page.
The main APIs
Responses API. The core endpoint since Mar 11, 2025: one request can call built-in tools (web search, file search, code interpreter, remote MCP servers, computer use, image generation), keep state with previous_response_id or the Conversations API, and return a typed list of output items. OpenAI calls it "recommended for all new projects" (migration guide). See Responses API.
Chat Completions. The older message-list endpoint "is still supported" (migration guide), but the GPT-6 models accept tool calls only through Responses; Chat Completions works with them without tools (latest model guide).
Realtime API and GPT-Live. Low-latency speech in and speech out over WebRTC in the browser or WebSocket on a server (Realtime guide). GPT-Live 1, a full-duplex voice model, costs $0.05 a minute. See Realtime API.
Audio. Transcription with GPT-Transcribe at an estimated $0.0045 a minute, plus text to speech models that shut down Jan 6, 2027. See Whisper and Audio Models.
Images. Generation and editing at v1/images/generations and v1/images/edits, or as a tool inside Responses. See GPT Image.
Batch API. Upload a file of up to 50,000 requests and get results within 24 hours at 50% lower cost. Flex processing gives the same discount on ordinary calls that can wait. See Batch API.
Embeddings and moderation. text-embedding-3-small costs $0.02 per 1M tokens and returns 1,536 dimensions (embeddings guide); the moderation endpoint checks text and images against 13 categories at no charge.
Agents. The Agents API (a hosted agent harness, public beta since Sep 10, 2026) and the open-source Agents SDK for Python and TypeScript. See Agents SDK.
Fine-tuning. Being wound down: no new users, and existing customers lose job creation on Jan 6, 2027. See Fine-Tuning.
What has been retired
Several API products ended in 2026, and code written against them needs to move.
- Assistants API: shut down Aug 26, 2026; move to the Responses API and Conversations API.
- Sora video API: the Sora 2 models and the Videos API shut down Sep 24, 2026 with no replacement, so the API has no video model today (see Sora).
- DALL-E 2 and DALL-E 3: shut down May 12, 2026 (see DALL-E).
- Agent Builder, the Evals platform and reusable prompts (
v1/prompts): all shut down Nov 30, 2026. ChatKit stays. - GPT-4o, GPT-4o mini, GPT-4.1 and GPT-4.1 mini: shut down Jan 14, 2027, with
gpt-6-lunaas the named replacement.
Prices, limits and speed
Prices are per 1M tokens and split into input, cached input and output. Four processing tiers change the price: Standard; Batch and Flex at half price; Fast (called Priority until Jul 30, 2026) at double; and Ultrafast for Astra and Sol only, at six times Standard (pricing). Prompts over 272K input tokens pay long-context rates. Repeated prompt prefixes are cached: on GPT-6.1 Sol and Terra a cache hit costs 5% of the input price. Full tables are on OpenAI API Pricing.
Rate limits are set per organization and project, by tier. An organization moves up automatically as its total credit purchases grow: Build at $5, Launch at $100, Grow at $500, with monthly usage caps of $500, $5,000 and $200,000 (rate limits guide). See API Rate Limits.
Where else the models run
OpenAI models are also sold through Microsoft Azure and Amazon Bedrock, billed by those clouds rather than by OpenAI (pricing); GPT-5.4 and GPT-5.5 reached Bedrock on Jun 1, 2026, and OpenAI's GPT-6 Astra announcement named both Azure and AWS Bedrock (OpenAI). Regional processing (data residency) adds 10% for models released on or after Mar 5, 2026.
How the API compares
The closest rival is Anthropic's Claude API, which prices its own models in the same ranges and also offers batch and caching discounts. OpenAI API vs Claude API sets them side by side. For coding agents built on these APIs, see Codex and the Codex SDK.
Frequently asked questions
How do I get an OpenAI API key? Sign in to the OpenAI developer dashboard at platform.openai.com, select Create an API Key, and save it as the environment variable OPENAI_API_KEY, which every official SDK reads automatically. Add credits first, since API calls are billed per token.
Is the OpenAI API included in ChatGPT Plus? No. ChatGPT Plus and the OpenAI API are billed separately, and Plus gives no API credits. ChatGPT Pro and paid Business seats do include monthly API credits as of Nov 6, 2026, from $20 per Business Standard seat to $500 on Pro $500; beyond those, API usage is paid per token.
Which OpenAI API model should I use? As of Nov 6, 2026, OpenAI points to GPT-6 Astra for the hardest work, GPT-6.1 Sol for near-Astra quality at one-fifth the price, GPT-6.1 Terra for visual reasoning and computer use, and GPT-6 Luna for cheap high-volume tasks at $0.10 per 1M input tokens.
Should I use the Responses API or Chat Completions? OpenAI recommends the Responses API for all new projects. Chat Completions is still supported, but GPT-6 models need Responses for tool calls, and the built-in tools live only there.
Where are the OpenAI API docs now? The OpenAI API documentation is at developers.openai.com/api/docs, while the dashboard for keys, billing and limits stays at platform.openai.com.
Can I still use the Assistants API? No. OpenAI shut the Assistants API down on Aug 26, 2026; its replacement is the Responses API with the Conversations API for stored threads.
Sources
- Developer quickstart, OpenAI, read Nov 6, 2026
- Models, OpenAI, read Nov 6, 2026
- GPT-6 Astra model page, OpenAI, read Nov 6, 2026
- Pricing, OpenAI, read Nov 6, 2026
- Rate limits, OpenAI, read Nov 6, 2026
- Migrate to the Responses API, OpenAI, read Nov 6, 2026
- Using the latest model, OpenAI, read Nov 6, 2026
- Realtime API, OpenAI, read Nov 6, 2026
- Batch API, OpenAI, read Nov 6, 2026
- Prompt caching, OpenAI, read Nov 6, 2026
- Embeddings, OpenAI, read Nov 6, 2026
- Moderation, OpenAI, read Nov 6, 2026
- Changelog, OpenAI, read Nov 6, 2026
- Deprecations, OpenAI, read Nov 6, 2026
- Introducing GPT-6 Astra, OpenAI, Sep 3, 2026
- API credits benefit for eligible ChatGPT subscriptions, OpenAI Help Center, read Nov 6, 2026
- API credits, now in ChatGPT Pro and Business plans, OpenAI, Oct 28, 2026 (video)
- GPT-Live-1 is now in the API, OpenAI, Sep 11, 2026 (video)
- Introducing gpt-transcribe and gpt-live-transcribe, OpenAI, Jul 28, 2026 (video)
- Introducing the Agents API, OpenAI, Sep 10, 2026 (video)
- Build faster with Ultrafast, OpenAI, Sep 29, 2026 (video)
Moments
API credits, now in ChatGPT Pro and Business plans
OpenAI
GPT-Live-1 is now in the API
OpenAI
Introducing gpt-transcribe and gpt-live-transcribe
OpenAI
Introducing the Agents API
OpenAI
Build faster with Ultrafast
OpenAI
See also
-
Responses APIThe Responses API is OpenAI's recommended endpoint for new projects, combining model calls, built-in tools, structured outputs and conversation state in one request. Chat Completions is still supported, and the Assistants API it replaced shut down on Aug 26, 2026.
-
ChatGPTChatGPT is OpenAI's AI assistant, and as of Nov 6, 2026 it is one app with three modes: Chat for questions, Work for longer tasks and Codex for software. It is free to use, with paid plans from $8 to $500 a month. -
GPT-6 AstraGPT-6 Astra is OpenAI's most capable model, released Sep 3, 2026, priced at $10 per million input tokens and $50 per million output tokens in the API, with a 1.05 million token context. In ChatGPT it powers GPT-6 Pro and is in ChatGPT Work and Codex. -
GPT-6.1 SolGPT-6.1 Sol is OpenAI's mid-priced GPT-6 model, released Sep 29, 2026 at $2 per million input tokens and $10 output, which OpenAI says nearly matches GPT-6 Astra on agentic work. In ChatGPT it is only in Work and Codex; the Chat tab uses the earlier GPT-6 Sol. -
GPT-6.1 TerraGPT-6.1 Terra is OpenAI's fast, low-cost GPT-6 model for visual reasoning, computer use and writing, released Oct 26, 2026 at $1 per million input tokens and $5 output. In ChatGPT it is in Work and Codex on Plus and higher plans, not in the Chat tab. - GPT-6 LunaGPT-6 Luna is OpenAI's cheapest and fastest GPT-6 model, released Sep 22, 2026 at $0.10 per million input tokens and $0.50 output. OpenAI's pricing page and Oct 7 release note name it as ChatGPT's model for Free and Go, though its help articles say GPT-5.6 Luna.