← Back to Leaderboard
Oopenai

openai/openai-python

Typed sync and async Python SDK for OpenAI API calls, streaming, and Realtime.

AI FrameworkQuickstart ↓
Engineering Health (Methodology)
A+ · 100/100
Maintenance Activity
● Updated yesterday
Latest Release
v3.63.0
Commercial License Check
Apache-2.0 · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance35/35
Fork Adoption25/25
Release Cadence20/20
License Clarity20/20
API
Total Stars
★ 32,302
24h Growth
+0
7d Growth
+58
Forks
5,782

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

openai/openai-python Star History (2020-10-25 - 2026-12-03) ALL-TIME STAR HISTORY (2020-10 – 2026-12) +32.3k in 2230d · avg +14/day 34.1k 17.1k 0 2020-10-25: ★ 52021-03-13: ★ 742021-07-31: ★ 1732021-12-18: ★ 2812022-05-07: ★ 4732022-09-24: ★ 6802023-02-11: ★ 2,5592023-07-01: ★ 9,2842023-11-18: ★ 14,3382024-04-06: ★ 18,4752024-08-24: ★ 20,8272025-01-11: ★ 23,0512025-05-31: ★ 26,0852025-10-18: ★ 28,2832026-03-07: ★ 29,5782026-07-25: ★ 30,9882026-12-03: ★ 32,302 ★ 32.3k 2020-10 2023-11 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

openai-python is a generated client for the OpenAI REST API, not a model runtime. Its OpenAPI-derived resource methods expose nested request parameters as TypedDicts and return Pydantic models. OpenAI and AsyncOpenAI expose the same resource surface for blocking and awaitable code. The package requires HTTPX2 2.12 or later in the 2.x line, AnyIO 4.10 or later in the 4.x line, jiter, and Pydantic 1.10.13 or later below 3, excluding versions 2.0 through 2.3.

The HTTP client is replaceable, allowing applications to set proxies, custom transports, authentication, and event hooks without changing resource calls. The async client can use aiohttp as its HTTPX2 transport. Request-level overrides such as with_options(max_retries=5) keep policy changes local to an individual call. Realtime is a separate protocol path built on the websockets library rather than the ordinary HTTP transport.

Key Capabilities & Differentiators

The primary entry point, client.responses.create, handles text input and supports vision requests with either an image URL or a base64 data URL. Server-Sent Events (SSE) deliver incremental responses through synchronous or asynchronous iteration. List methods expose auto-paginating iterators. Realtime instead keeps a bidirectional WebSocket session open for text, audio, and function calling; an incoming error event is delivered to application code rather than raised as an SDK exception, and the connection remains usable.

Beyond API keys, workload identity can use Kubernetes service account tokens, Azure managed identity, Google Cloud ID tokens, or a custom subject-token provider. X.509 workload identity uses the configured HTTP client's certificate for both the token exchange and API calls, with lazy token exchange, caching, and refresh. API requests must stay on the configured HTTPS origin. X.509 is not supported by Azure clients or by Realtime. The retained beta Realtime interface does not exchange workload-identity tokens or sign Bedrock requests; where allowed, callers must supply their own Authorization header.

Trade-offs & Limitations

Against direct REST calls, the SDK removes maintenance work around typed payloads, pagination, and event handling. A small integration with only a few endpoints might prefer direct HTTP for tighter dependency and transport control. Compared with a provider-neutral wrapper, the SDK gives direct access to OpenAI-specific request fields and events, but callers still own portability across providers. Neither approach turns a remote API into offline inference: availability, latency, rate limits, and usage charges still depend on the service.

Transport customization is useful when production networking is constrained, but the move to HTTPX2 warrants regression tests for custom clients, timeouts, auth handlers, hooks, and request mocks. Set a retry budget against the application's request deadline rather than increasing it blindly; max_retries=0 is available when an upstream layer owns retries. Apache-2.0 covers the SDK code, not the API service or any right to run the models locally.

Hardware & Deployment Guide

Install openai from PyPI in the application's Python 3.10+ environment, configure OPENAI_API_KEY or a supported workload identity, and provide network access to the chosen API endpoint. Allow WebSocket connections through any outbound proxy if you use Realtime. For X.509, configure the certificate chain, private key, and server trust on the HTTPX2 client; the application remains responsible for secure provisioning and rotation.

The SDK needs no model weights, CUDA, or inference server on the application host. Size the process for open connections, concurrent requests, and payload work such as encoding images, rather than for model VRAM. In the supplied release history, v3.62.0 added health alert rules and notification retrieval, while v3.62.2 added support for websockets 17 in the Realtime extra. Pin and test the optional dependencies you deploy alongside the SDK, especially if HTTP calls and Realtime sessions have separate production paths.

Typed API surface: OpenAPI generation pairs TypedDict request parameters with Pydantic response models.
Transport control: Sync and async clients use HTTPX2; async callers can opt into aiohttp via the openai[aiohttp] extra.
Streaming protocols: Responses uses SSE for incremental output; Realtime uses WebSocket for bidirectional text, audio, and function calling.
Workload identity: Kubernetes, Azure managed identity, Google Cloud, and custom token providers can supply short-lived credentials; X.509 is HTTP-only.
Request policy: Retry budgets can be set on the client or overridden per request with with_options; zero disables retries.
Pagination: List responses provide auto-paginating iterators for both sync and async code.
Best For

Python services and tools that call OpenAI APIs and need typed responses, SSE streaming, or bidirectional Realtime sessions.

Skip If

You need offline inference, self-hosted model weights, or a provider-neutral interface as the primary integration contract.

Reviewed on 2026-12-02 · Grounded in GitHub README, root file tree & releases · Newer release v3.63.0 (2026-12-03) shipped after this reviewMethodology

Quick Start & Installation

API
# install from PyPI
pip install openai

Comparison vs. Top LLMs & Inference Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
openai-python ★32.3k+58PythonApache-2.0Typed sync and async Python SDK for OpenAI API calls, streaming, and Realtime.
transformers169.6k+337PythonApache-2.0A PyTorch model-definition SDK for unified inference and training across modalit
pytorch105.9k+299Python—Python-first tensor SDK for GPU-accelerated training and inference
qlib50.8k+197PythonMITModular Python framework for quant research, from market data to backtests

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/openai/openai-python.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

openai/openai-python Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about openai-python

Which client and streaming protocol should I integrate?

Use OpenAI for synchronous code or AsyncOpenAI for an async service. Call responses.create for model requests and enable stream=True when you want incremental SSE events. For bidirectional text or audio, use a separate Realtime WebSocket session and handle incoming error events explicitly.

Does the SDK need a GPU, and what should I size for?

No GPU, CUDA, or model VRAM is needed by the SDK itself: inference runs at the API endpoint. Size the client process for concurrent requests, open streams, and payload processing. Large base64 image inputs and many simultaneous audio sessions are useful cases to include in load tests.

Can I use the SDK commercially or self-host it for compliance?

Apache-2.0 permits commercial use of the SDK, subject to its conditions, including applicable redistribution notices. You can run the client in your own environment, but the package does not include model weights or a serving runtime. Evaluate API terms and data-handling requirements separately from the SDK license.

When is this SDK preferable to direct REST or a multi-provider wrapper?

Choose it when you want typed OpenAI resources, automatic pagination, and streaming helpers without maintaining those layers yourself. Direct REST calls can be a better fit for a handful of endpoints or a tightly controlled HTTP stack. A provider-neutral wrapper is worth considering if switching vendors matters more than direct access to OpenAI-specific features; a local inference engine solves a different problem.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining openai/openai-python? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature openai/openai-python on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare