OpenAI Python SDK
Official Python SDK for the OpenAI API. As of v2.x, the Agents SDK requires openai v2. The Assistants API is deprecated and will be removed August 26, 2026. Use the Responses API for new agent builds.
Warnings
- breaking Assistants API is deprecated. Hard shutdown August 26, 2026.
- breaking Realtime API Beta deprecated. Hard shutdown March 24, 2026.
- breaking openai-agents SDK requires openai v2.x. v1.x is no longer supported.
- breaking chatgpt-4o-latest model snapshot removed February 17, 2026.
- breaking DALL-E model snapshots deprecated. Removal May 12, 2026.
- gotcha Responses API replaces Chat Completions as the recommended interface for agents.
- gotcha Model slugs like gpt-4o-mini-tts now point to dated snapshots. Behaviour can change without notice.
Install
-
pip install openai -
npm install openai
Imports
- OpenAI
from openai import OpenAI
- AsyncOpenAI
from openai import AsyncOpenAI
Quickstart
from openai import OpenAI
client = OpenAI() # reads OPENAI_API_KEY from env
response = client.responses.create(
model='gpt-4o',
input='What is the capital of France?'
)
print(response.output_text)