# Repository Briefing: openai/openai-python
> Source: https://repoforai.com/repo/openai/openai-python (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/openai/openai-python
- **Official Docs / Website**: https://pypi.org/project/openai/
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: A+ (100/100 · Maintenance 35/35 · Adoption 25/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v3.63.0 (2026-12-03) — https://github.com/openai/openai-python/releases
- **Review Snapshot**: 2026-12-02 (Note: v3.63.0 on 2026-12-03 shipped after this review; verify latest release notes)
- **Deployment / Stack Signals**: API
- **Momentum**: 32,302 ★ total (+0 24h / +58 7d) · 5,782 forks
- **Topics**: `openai`, `python`
- **When to Use**: 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.

## Overview
```text
### 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.
```

## Key Capabilities
```text
- 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.
```

## Quick Start / Clone
```bash
# install from PyPI
pip install openai
```
