Back to directory

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.

OpenAI Python API library

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.

More in Libraries

See all 292
  • OpenDecision

    deepanwadhwa.github.io

    An open-source Python package that answers typed questions about application state or documents using a local natural-language-inference model, returning structured choice, score, yes/no or evidence-relation values instead of free text.

  • TradeCanvas

    bonguynvan.github.io

    A zero-dependency canvas charting engine for building TradingView-style trading charts in JavaScript, with 66 technical indicators, 24 drawing tools, 17 chart types, and real-time streaming.

  • 3d retro graphics

    3d-retro.com

    A free, CC0-licensed library of copy-paste retro 3D and demoscene graphics effects, such as plasma, raytracing, and voxel terrain, runnable as WebGL 1 or plain 2D canvas.