OpenAI API
by OpenAI
GPT models for text, images and tools.
1. Price
“Free User must be in an allowed geography $100 / month”
No free tier on the pricing page. As reported on the official pricing page, checked Oct 22, 2026.
developers.openai.com/api/docs/pricing2. Commercial use
“You are responsible for ensuring that the content you input to our API does not violate any applicable law or our Terms of Use.”
Paid use in your product is the normal case; you own inputs and outputs, and your content must follow the law and OpenAI's Terms of Use and usage policies (the policy pages block automated readers, so read them in a browser).
developers.openai.com/api/docs/guides/embeddings.md3. Key & sign-up
“The OpenAI API accepts bearer credentials from API keys or from short-lived access tokens created with workload identity federation.”
API key sent as a Bearer header from your server (Authorization: Bearer $OPENAI_API_KEY); short-lived workload identity tokens are an option for cloud servers
developers.openai.com/api/reference/overview.md4. Agent access
“This MCP server is documentation-only. It does not call the OpenAI API on your behalf.”
Our agent check: 3 of 6 (Nov 13, 2026).
developers.openai.com/learn/docs-mcp.mdChecked against the maker's official pages, pricing on Oct 22, 2026. Tap a verdict to see its source.How we checkedReport an error
What OpenAI API does
The OpenAI API is a paid online service that lets your app use OpenAI's GPT models. Your server sends text or a picture and gets back an answer, a summary, neatly sorted data, or a request to run one of your own functions. You pay for each token, a small piece of text, at a price set per model.
- OpenAI API is one of 41 APIs in the Model hosting and inference category on AgentGid.
- It is not among the 13 that can be started for free.
- 6 of them ship an official MCP server; OpenAI API does not.
- Its official SDK is the 1st most downloaded in the category (152M a week).
What people build with it
Writing help inside your app
Draft replies, product texts or short summaries right inside your app, so people do not copy text back and forth from a chat window.
Turn messages into tidy records
Pull a name, a date and a list of people out of an email or a form message, in exactly the fields your database expects.
Answers that use your own data
Let the assistant look up an order, a booking or an account in your system before it answers, and run the action you allow, such as a refund.
Answers with today's news
Let the model search the web while it answers, for questions about prices, events or anything newer than its training.
Describe photos people upload
Read a receipt, describe a product photo or check what a screenshot shows, and get the result back as text.
Big jobs overnight at half price
Sort thousands of support tickets or product reviews in one batch that finishes within a day, when nobody waits for the answer.
OpenAI API popularity
SDK downloads from npm and PyPI, weekly. Numbers as of Nov 17, 2026.
Pricing
None
No monthly plan
Per 1M tokens: GPT-6 Luna $0.10 in / $0.50 out; GPT-6.1 Sol $2 / $10; GPT-6 Astra $10 / $50
What one action costs
| Action | Price |
|---|---|
| 1M input tokens, GPT-6 Luna (short context, standard) | $0.10 |
| 1M output tokens, GPT-6 Luna (short context, standard) | $0.50 |
| 1M input / output tokens, GPT-6.1 Sol (short context, standard) | $2.00 |
| 1M input / output tokens, GPT-6 Astra (short context, standard) | $10.00 |
| 1,000 web search tool calls (plus search content tokens at model rates) | $10.00 |
As reported on the official pricing page, checked Oct 22, 2026. Prices change: confirm before you buy. developers.openai.com/api/docs/pricing
Limits
Usage limit $100 a month; only in allowed countries
Usage limit $500 a month; 5,000 requests and 1,000,000 tokens per minute for Astra, Sol and Terra models
Usage limit $5,000 a month; 10,000 requests and 4,000,000 tokens per minute for Astra, Sol and Terra models
Usage limit $200,000 a month
From the official docs. developers.openai.com/api/docs/guides/rate-limits.md
Key and access
API key sent as a Bearer header from your server (Authorization: Bearer $OPENAI_API_KEY); short-lived workload identity tokens are an option for cloud servers
OPENAI_API_KEYNot stated on the pages we read
Steps only a person can do
- Sign in to the OpenAI platform and create an API key (a project service account key for a deployed app). Put it in .env as OPENAI_API_KEY (kept out of git) and read it on the server only.
- Add a payment method and buy prepaid credits. No code change; requests start working once credits exist.
- Set a monthly spend alert or hard spend limit for the project. Handle 429 errors with code project_spend_limit_exceeded by showing a friendly message instead of retrying.
Commercial use and your data
It is a paid online service, not open source; the official code libraries are free under the Apache-2.0 license. You own what you send and what the models return. Your content must not break the law or OpenAI's terms of use.
Paid use in your product is the normal case; you own inputs and outputs, and your content must follow the law and OpenAI's Terms of Use and usage policies (the policy pages block automated readers, so read them in a browser).
“You are responsible for ensuring that the content you input to our API does not violate any applicable law or our Terms of Use.” source
Give each client app its own project and service account key instead of a developer's personal key.
“Don't share one developer's key across a team or use that person's identity as the permanent identity of a production application.” source
The official libraries are Apache-2.0, so you may ship them in your app with their license notice; the key itself must never be bundled.
“"license":"Apache-2.0"” source
“As of March 1, 2023, data sent to the OpenAI API is not used to train or improve OpenAI models (unless you explicitly opt in to share data with us).”
Safety (abuse monitoring) logs up to 30 days; Responses API results stored at least 30 days unless store is false; Zero Data Retention only for approved customers.
“By default, abuse monitoring logs are generated for all API feature usage and retained for up to 30 days, unless longer retention is required by law, or is reasonably necessary to protect our services or any third party from harm.” source
Data residency per project for eligible customers (via sales), with a 10% price uplift for newer models.
“Data residency controls are a project configuration option that allow you to configure the location of infrastructure OpenAI uses to provide services.” source
Errors to handle
The key sent with the request is wrong or was revoked.
Check the key in .env or create a new one in the dashboard; do not retry unchanged.
Too many requests in a short time for your tier.
Slow down and retry after the Retry-After header; retry with backoff.
The organization has no prepaid credits left.
Top up credits; retrying does not help.
A problem on OpenAI's side.
Retry after a short wait and check status.openai.com if it keeps happening.
The chosen model is temporarily overloaded.
Follow Retry-After, then retry with backoff.
Use it from an agent
3 of 6: llms.txt yes, OpenAPI no, SDK yes, MCP no, status page no, AI assistants allowed yes
Checked Nov 13, 2026.
OpenAI Docs MCP (documentation only)
claude mcp add --transport http openaiDeveloperDocs https://developers.openai.com/mcp
npm install openaipip install openaiInstructions in its docs to check first
“Always use the OpenAI developer documentation MCP server if you need to work with the OpenAI API, plugins, ChatGPT, Codex,… without me having to explicitly ask.”
The docs suggest pasting this standing instruction into AGENTS.md. Ask the person before changing their project's agent instructions; using the docs server for one task needs no file change.
Alternatives
OpenAI API This page
Pick the Gemini API when you want a free tier to start, or need audio and video input as well as text and images.
Pick Mistral when you want open-weight models you could later run yourself, behind one paid API.
Pick Groq when you want fast answers from open models such as GPT-OSS and Llama, priced per 1M tokens.
Get started
Tell your AI assistant
“Add the OpenAI API to my app on the server only: read OPENAI_API_KEY from .env, call client.responses.create with a fixed model name, return response.output_text to the page, and never put the key in browser code.”
Create an API key in the OpenAI dashboard and put it in an environment variable on the server.
export OPENAI_API_KEY="your_api_key_here"Install the official package for your language (JavaScript shown; Python is pip install openai).
npm install openaiSend a first request from a server-side file and print the answer.
import OpenAI from "openai"; const client = new OpenAI(); const response = await client.responses.create({ model: "gpt-6-astra", input: "Write a one-sentence bedtime story about a unicorn.", }); console.log(response.output_text);
First request
curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-6-astra",
"input": "Tell me a three sentence bedtime story about a unicorn."
}'
{
"id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b",
"object": "response",
"status": "completed",
"model": "gpt-6-astra",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "In a peaceful grove beneath a silver moon, a unicorn named Lumina discovered a hidden pool that reflected the stars. ..."
}
]
}
],
"usage": {
"input_tokens": 36,
"output_tokens": 87,
"total_tokens": 123
}
}
Mistakes to avoid
The library blocks browsers by default because anyone can read a key shipped to the page and spend your credits.
The newest models need the Responses API for tool calling.
Dropping reasoning or tool-call items can make the next request fail.
Retries cannot fix billing, spend or quota errors.
Node.js 22 is the minimum supported version of the current library.
Questions
How is it billed?
Per token, with separate prices for input and output and for each model. Requests run on prepaid credits.
Does OpenAI train its models on what my app sends?
Not by default. Data sent to the API has not been used for training since March 1, 2023, unless you opt in.
Can I call it straight from the web page?
No. The JavaScript library refuses to run in a browser unless you switch on dangerouslyAllowBrowser, because the key would be exposed. Call it from your server.
Which model should I start with?
The models page suggests GPT-6 Astra if you are unsure, GPT-6.1 Sol to balance quality and cost, and GPT-6 Luna for cheap, high-volume work.
Who owns the text the model writes for me?
You do. The docs say customers own their input and output.