openai-python
The official Python library for the OpenAI API
What is openai-python?
The official Python library for the OpenAI API
Overview of openai-python
What it is
The OpenAI Python library is the official Python library for the OpenAI API. It provides convenient access to the OpenAI REST API from any Python 3.10+ application. The library includes type definitions for all request params and response fields, and offers both synchronous and asynchronous clients powered by HTTPX2. It is generated from the OpenAI OpenAPI specification.
Key features
- Synchronous and asynchronous clients (OpenAI and AsyncOpenAI)
- Type definitions for all request parameters and response fields - Supports the Responses API and the Chat Completions API - Vision support: accepts image URLs or base64-encoded images - Workload identity authentication for Kubernetes, Azure, GCP, custom JWT, and X.509 mutual TLS - Configurable token refresh buffer for workload identity
Use cases
- Generating text from OpenAI models using the Responses API or Chat Completions API - Building coding assistants, chatbots, and other conversational AI applications - Processing images with vision-capable models - Automating secure authentication in cloud-managed environments (Kubernetes, Azure, GCP)
- Integrating OpenAI API into Python applications with type safety
Getting started
sh pip install openai For full usage examples, see the repository README and api.md.
License and pricing
Licensed under Apache-2.0. The library is open source.
Based on the project's public README and repository metadata.