# OpenAI API — card for AI agents

GPT models for text, vision, tool calling and agents, priced per 1M tokens.

Maker: OpenAI · category: Model hosting and inference

## Price (official page)
- Free tier: none listed
- Usage price: Per 1M tokens: GPT-6 Luna $0.10 in / $0.50 out; GPT-6.1 Sol $2 / $10; GPT-6 Astra $10 / $50
- Pricing page: https://developers.openai.com/api/docs/pricing (checked 2026-10-09)

## Connect
- npm: `npm install openai`
- PyPI: `pip install openai`
- Repository: https://github.com/openai/openai-node

## For AI agents on OpenAI's own site (AgentGid check 2026-11-13: 3 of 6)
- llms.txt: https://developers.openai.com/llms.txt (full text: https://developers.openai.com/llms-full.txt)
- Docs pages as Markdown: 78% of the pages llms.txt lists
- OpenAPI description: none found at the usual places
- Official MCP server: no · official SDK: yes · status page: no
- robots.txt lets AI assistants (ChatGPT-User, Claude-User) read the site: yes

## A year of price history (Internet Archive copies of the pricing page, read by rules)
- Months read: 1 (2026-02 to 2026-02) of https://developers.openai.com/api/docs/pricing
- A figure is any "$X/month" on the page (plans, seats and add-ons alike); open the archived copy to see which plan it is.

## Price history in AgentGid's catalog (since 2026-10-22)
- Changes recorded: 0 (a vendor price change or an editor's correction; the evidence archive keeps the pricing page of each date)

## Other APIs in this category
- Gemini API: https://agentgid.com/apis/google-gemini-api/agent.md
- Mistral AI API: https://agentgid.com/apis/mistral-api/agent.md
- Groq (LLM inference): https://agentgid.com/apis/groq/agent.md
- Cohere: https://agentgid.com/apis/cohere/agent.md
- fal: https://agentgid.com/apis/fal/agent.md

## Links
- AgentGid page: https://agentgid.com/apis/openai-api/


## OpenAI API: GPT models for text, images and tools

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.

### Where to use 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.

### How to start
- 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 openai
```

- Send 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);
```


### License
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.

### Good to know
- You need an OpenAI account and a secret key. Keep the key on your server; never put it in a web page or a phone app.
- You pay in advance with credits. When they run out, requests fail until someone adds more.
- How many requests you may send per minute grows with your usage tier, which rises as you buy more credits.
- Answers can change between model versions, so name an exact version and test your prompts before switching.
- OpenAI does not train on what you send by default, but keeps safety logs of requests for up to 30 days.

Checked 2026-11-10 against: https://developers.openai.com/llms.txt, https://developers.openai.com/api/docs/llms.txt, https://developers.openai.com/api/docs/quickstart.md, https://developers.openai.com/api/docs/libraries.md, https://developers.openai.com/api/docs/models.md, https://developers.openai.com/api/docs/concepts.md, https://developers.openai.com/api/docs/guides/text.md, https://developers.openai.com/api/docs/guides/structured-outputs.md, https://developers.openai.com/api/docs/guides/function-calling.md, https://developers.openai.com/api/docs/guides/tools.md, https://developers.openai.com/api/docs/guides/batch.md, https://developers.openai.com/api/docs/guides/error-codes.md, https://developers.openai.com/api/docs/guides/rate-limits.md, https://developers.openai.com/api/docs/guides/your-data.md, https://developers.openai.com/api/docs/guides/api-keys.md, https://developers.openai.com/api/docs/guides/production-best-practices.md, https://developers.openai.com/api/docs/guides/safety-best-practices.md, https://developers.openai.com/api/docs/guides/embeddings.md, https://developers.openai.com/api/docs/pricing.md, https://developers.openai.com/api/reference/overview.md, https://developers.openai.com/api/reference/resources/responses/methods/create.md, https://developers.openai.com/learn/docs-mcp.md, https://github.com/openai/openai-node/blob/master/README.md, https://github.com/openai/openai-python/blob/main/README.md, https://registry.npmjs.org/openai/7.54.0, https://pypi.org/pypi/openai/3.48.0/json

### Mistakes to avoid
- Don't: new OpenAI({ dangerouslyAllowBrowser: true }) in a React page with the real key → Do: Call OpenAI from your own server route and send only the answer to the page (The library blocks browsers by default because anyone can read a key shipped to the page and spend your credits.)
- Don't: client.chat.completions.create(...) with tools on gpt-6-astra or gpt-6.1-sol → Do: Use client.responses.create(...) with tools for these models (The newest models need the Responses API for tool calling.)
- Don't: Keeping only the message items of response.output when you build the next turn yourself → Do: Pass previous_response_id, or replay all output items in order (toResponseInputItems() in the JavaScript library) (Dropping reasoning or tool-call items can make the next request fail.)
- Don't: Retrying in a loop on 429 credit_balance_exhausted or a spend-limit error → Do: Read error.code; retry only rate-limit and server errors with backoff, and tell the person to top up for billing errors (Retries cannot fix billing, spend or quota errors.)
- Don't: Deploying the openai package 7.x on Node.js 20 → Do: Use Node.js 22 or 24 (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.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
