# OpenAI Python API library

The official Python client library for the OpenAI REST API, with typed request and response models and both synchronous and asynchronous clients.

The library provides type definitions for all request parameters and response fields, generated from OpenAI's OpenAPI specification, and offers synchronous and asynchronous clients built on HTTPX. It supports the Responses API, described as the primary interface for generating model output, as well as the previously standard Chat Completions API, which remains supported.

Besides a static API key, it supports workload identity authentication using short-lived tokens from cloud identity providers instead of long-lived API keys, with built-in providers for Kubernetes service account tokens, Azure managed identity and Google Cloud Platform compute engine metadata, plus a way to supply a custom token provider; the token refresh buffer is configurable and defaults to 20 minutes before expiration.

It requires Python 3.10 or newer, installs from PyPI, and is licensed under Apache-2.0.

Website: https://github.com/openai/openai-python
