OpenAI API logo

OpenAI API

api

by openai

The developer platform for accessing GPT-5, GPT-4.1, o3, o4-mini, image generation, real time voice, embeddings, and more. Pay per token with no subscriptions required.

Key features

Chat Completions and Responses API
Function Calling and Tool Use
Structured Outputs
Reasoning Models (o3, o4-mini)
Assistants API
Image Generation (GPT Image)
Pricing

From $undefined/undefined

Best For

Developers building AI powered applications who need programmatic access to frontier models with full control over prompts, parameters, and integration logic

Verdict

The broadest model lineup of any AI provider: text, reasoning, image generation, real time voice, embeddings, speech to text, and moderation all under one platform

What it does

Chat Completions and Responses API

Send messages to any OpenAI model and receive generated text responses. The Responses API is the newest interface, combining the simplicity of Chat Completions with built in tool use capabilities.

Learn more

Function Calling and Tool Use

Models can call functions you define, enabling them to interact with external systems, databases, and APIs. Supports parallel function calls and structured JSON output for reliable integrations.

Learn more

Structured Outputs

Guarantee that model responses conform to a JSON Schema you provide. Eliminates parsing failures and ensures deterministic output structure for production applications.

Reasoning Models (o3, o4-mini)

Specialized models that use internal chain of thought reasoning before responding. Designed for complex math, science, multi step problems, and agentic workflows where deeper thinking produces better results.

Learn more

Assistants API

Build assistant like experiences with persistent threads, file storage, code interpreter, file search (vector store based RAG), and function calling, all managed server side by OpenAI.

Image Generation (GPT Image)

Generate and edit images via API using GPT Image 1.5 and GPT Image 1. Supports text prompts, image editing, and variations. Excellent text rendering in generated images.

Realtime API

Low latency, multimodal API for speech to speech, text to speech, and real time conversational experiences. Supports both text and audio input/output with sub second latency.

Fine Tuning

Train custom versions of GPT-4.1, GPT-4o, and o4-mini on your own data. Improve model performance for specific tasks and potentially reduce prompt length and cost.

Learn more

Batch API

Process large volumes of requests asynchronously within 24 hours at 50% off standard pricing. Ideal for data processing, content generation, and non time sensitive workloads.

Learn more

Embeddings

Convert text into numerical vectors for semantic search, clustering, classification, and recommendation systems. Available in small (1536 dimensions) and large (3072 dimensions) variants.

Web Search Tool

Built in tool that enables models to search the web for up to date information during API calls. Billed per tool call plus search content tokens.

Whisper (Speech to Text)

Transcribe and translate audio in 50+ languages. Available both via API and as an open source model you can self host.

Pricing

ModelInput / 1M tokensOutput / 1M tokens
GPT-5.2Latest flagship. Best for coding and agentic tasks. 400K context. Cached input: $0.175/1M$1.75$14.00
GPT-5.1Flagship model. 400K context. Cached input: $0.125/1M$1.25$10.00
GPT-5Flagship model. 400K context. Cached input: $0.125/1M$1.25$10.00
GPT-5 MiniFast, affordable GPT-5 variant. 400K context. Cached input: $0.025/1M$0.25$2.00
GPT-5 NanoMost affordable model. 400K context. Cached input: $0.005/1M$0.05$0.40
o3Reasoning model. 200K context. Internal reasoning tokens billed as output$2.00$8.00
o3 ProPremium reasoning. 200K context. Maximum accuracy on hard problems$20.00$80.00
o4-miniFast reasoning model. 200K context. Good balance of reasoning quality and cost$1.10$4.40
GPT-4.1Strong general purpose model. 1M token context window. Fine tuning available$2.00$8.00
GPT-4.1 MiniCost effective GPT-4.1 variant. 1M context. Fine tuning available$0.40$1.60
GPT-4.1 NanoBudget model with 1M context. Fine tuning available$0.10$0.40
GPT-4oMultimodal model with vision. 128K context$2.50$10.00
GPT-4o MiniFast and affordable multimodal. 128K context$0.15$0.60

Pros & Cons

Pros

  • The broadest model lineup of any AI provider: text, reasoning, image generation, real time voice, embeddings, speech to text, and moderation all under one platform
  • GPT-5 family offers excellent price to performance ratio with 90% prompt caching discounts and 50% batch processing savings
  • 1M token context window on GPT-4.1 family, the largest production context window available from a major provider
  • Structured outputs guarantee JSON Schema conformance, eliminating parsing failures in production applications
  • The most mature ecosystem: extensive documentation, client libraries in every major language, and the largest third party tooling community
  • Multiple pricing tiers (Batch, Flex, Standard, Priority) let you optimize the cost vs. speed tradeoff per request
  • Assistants API handles persistent threads, file storage, and tool orchestration server side, reducing the complexity of building agent like applications
  • $5 free credits for new users with no credit card required, making it easy to get started and prototype

Cons

  • Reasoning models (o3, o4-mini) use internal reasoning tokens billed as output but not visible in responses, which can make costs unpredictable and significantly higher than expected
  • No open source models; all models are proprietary and can only be accessed through OpenAI's API (unlike DeepSeek or Meta's Llama)
  • Rate limits on lower usage tiers can be restrictive; higher limits require accumulating significant spend ($100 to $50,000+)
  • Fine tuning costs are high (training at $5 to $100 per million tokens depending on model) and inference on fine tuned models costs 1.5 to 3x base rates
  • GPT-5 Pro and o1 Pro models are extremely expensive ($15 to $150 input, $60 to $600 output per million tokens), making them impractical for most applications
  • Writing quality on GPT models is generally considered less natural and more formulaic compared to Claude's output for long form and nuanced content
  • The API ecosystem is fragmented across Chat Completions, Responses API, and Assistants API, which can be confusing for new developers choosing between them

How to get started

1

Create an account and get your API key

Sign up at platform.openai.com. No credit card required. You receive $5 in free credits immediately. Navigate to the API Keys section and create a new secret key. Copy it immediately as it will not be shown again. Store it securely as an environment variable.

2

Install the SDK and make your first API call

Install the official OpenAI SDK for your language (Python: pip install openai, Node.js: npm install openai). Set your API key as an environment variable (OPENAI_API_KEY). Make your first Chat Completions or Responses API call with a few lines of code.

3

Choose the right model for your use case

Start with GPT-5 Nano or GPT-4o Mini for cost sensitive tasks. Use GPT-5 or GPT-5 Mini for general purpose applications. Use o3 or o4-mini when you need deep reasoning for complex problems. Use GPT-4.1 when you need the 1M token context window. Experiment in the Playground before writing code.

4

Add function calling and structured outputs

Define functions that your model can call to interact with external systems. Use structured outputs with JSON Schema to guarantee response format. These two features are the foundation of building reliable, production grade AI applications.

5

Optimize costs with caching and batching

Enable prompt caching for 50% to 90% savings on repeated prompts and system messages. Use the Batch API for non urgent workloads at 50% off. Set spending limits and budget alerts in your dashboard. Monitor usage by model to identify cost optimization opportunities.

Deep dive

Detailed guides with comparisons, tips, and visuals for each feature.

Get notified about updates

We'll email you when this tool's pricing or features change.

Last updated: 2026-02-21