openai/openai-python
The official Python library for the OpenAI API
What it solves
This library provides a streamlined, type-safe way for Python developers to interact with the OpenAI REST API, eliminating the need to manually handle raw HTTP requests to access OpenAI's models and services.
How it works
It acts as a Python wrapper around the OpenAI REST API, generated from an OpenAPI specification. It uses HTTPX2 for synchronous and asynchronous communication and provides Pydantic models for response fields and TypedDicts for request parameters to ensure type safety and and autocomplete in editors.
Who it’s for
Python developers building applications that integrate OpenAI's AI models, including those requiring high-concurrency asynchronous requests or secure enterprise-grade authentication.
Highlights
- Multi-modal Support: Access to text generation, vision (image input), and a Realtime API for low-latency audio and text conversations via WebSockets.
- Flexible Authentication: Supports standard API keys, workload identity authentication for cloud providers (Kubernetes, Azure, GCP), and X.509 mutual TLS.
- Developer Experience: Includes auto-paginating iterators for list methods and built-in webhook verification tools.
- Async Capabilities: Full support for asynchronous requests using
AsyncOpenAI, with an optionalaiohttptransport for improved performance. - Streaming: Support for Server-Sent Events (SSE) to stream model responses in real time.
Related
- Project
- Project
- Project
- Dispatch
- Project