OpenAI Python

OpenAI Python

★ 4.4 🔖 7000 saves 💰 Free GitHub

The OpenAI Python library is the official SDK for the OpenAI API, with 31,800+ stars on GitHub — the standard way Python applications talk to OpenAI models.

Overview

If you build with OpenAI from Python, this is the client you use. Maintained by OpenAI itself, the library provides typed, idiomatic access to the full API surface — chat completions, the Responses API, embeddings, audio, images, files, fine-tuning and more — with both synchronous and asynchronous clients. It handles the unglamorous essentials properly: automatic retries with backoff, timeouts, streaming responses, and type hints generated from the API specification so your editor catches mistakes early. Because it is generated from OpenAI’s OpenAPI spec, new API features land here first. The library is Apache-2.0 licensed and under constant development, updated in October 2026, tracking one of the most-used APIs in the world.

Because it is the reference client, its patterns define how a generation of developers thinks about LLM programming: messages in, typed responses out, streaming as a first-class mode rather than an afterthought. It is equally at home in a Jupyter notebook, a FastAPI service or a batch data pipeline, and its low-level escape hatches — raw responses, custom HTTP clients, Azure OpenAI support — keep it usable in regulated and self-hosted environments. When OpenAI ships a new capability, this repository is effectively its public interface.

Key Features

  • Full API coverage – chat, responses, embeddings, audio, images, files, fine-tuning and more.
  • Sync and async clients – the same API in blocking or asyncio styles.
  • Streaming built in – token-by-token responses with typed event handling.
  • Strong typing – generated types and Pydantic models keep requests and responses safe.
  • Production resilience – automatic retries, configurable timeouts and clear exceptions.
  • Spec-generated – built from OpenAI’s OpenAPI specification, so it stays current with the API.

💳 Pricing

The library is free and open source under the Apache License 2.0. Using it requires an OpenAI API account, and API calls are billed by OpenAI at their standard rates.

Who Is It For

Every Python developer building on OpenAI — from quick prototypes and notebooks to production services that need a reliable, typed client.

🚀 Visit OpenAI Python Official Site

🚩 Report an issue