Implementation:Openai Openai python Pyproject Config
Appearance
| Knowledge Sources | |
|---|---|
| Domains | SDK_Infrastructure, Python |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for project configuration, dependency management, and build system definition provided by the openai-python SDK.
Description
The pyproject.toml file (302 lines) is the single source of truth for the openai-python package metadata, dependencies, build configuration, and tooling. Key sections:
- Project metadata (lines 1-39):
- Package name:
openai, version:2.21.0 - License: Apache-2.0
- Author: OpenAI (
support@openai.com) - Python requirement:
>= 3.9with classifiers for Python 3.9 through 3.14 - Platforms: OS Independent (POSIX, macOS, Linux, Windows)
- Package name:
- Core dependencies (lines 11-20):
httpx>=0.23.0, <1: HTTP clientpydantic>=1.9.0, <3: Data validation (supports both v1 and v2)typing-extensions>=4.11, <5: Backported typing featuresanyio>=3.5.0, <5: Async I/O abstractiondistro>=1.7.0, <2: OS/distro detection for user-agent stringssniffio: Async library detectiontqdm > 4: Progress bars (for file uploads)jiter>=0.10.0, <1: Fast JSON parsing
- CLI entry point (line 46):
openai = "openai.cli:main"-- provides theopenaicommand-line tool
- Optional dependency groups (lines 48-53):
aiohttp:aiohttp+httpx_aiohttp>=0.1.9for aiohttp transportrealtime:websockets >= 13, < 16for realtime API supportdatalib:numpy >= 1,pandas >= 1.2.3,pandas-stubs >= 1.1.0.11for data processingvoice_helpers:sounddevice>=0.5.1,numpy>=2.0.2for audio I/O
- Build system (lines 108-133):
- Build backend:
hatchling==1.26.3withhatch-fancy-pypi-readme - Wheel package source:
src/openai - README generated from
README.mdwith relative-to-absolute link substitution
- Build backend:
- Testing configuration (lines 146-154):
- pytest with
--tb=short -n auto(parallel via pytest-xdist) asyncio_mode = "auto"for automatic async test detectionxfail_strict = trueandfilterwarnings = ["error"]for strict test hygiene
- pytest with
- Type checking (lines 159-237):
- Pyright: Strict mode, Python 3.9 target, with
reportImplicitOverride = true - Mypy: Strict settings with all
disallow_*flags enabled,strict_equality,check_untyped_defs
- Pyright: Strict mode, Python 3.9 target, with
- Linting (lines 245-301):
- Ruff: Line length 120, target Python 3.8, isort rules, bugbear rules, unused import removal,
functools.lru_cachebanned in favor of custom_utils.lru_cache
- Ruff: Line length 120, target Python 3.8, isort rules, bugbear rules, unused import removal,
Usage
This file defines how the package is built, installed, and developed. It is consumed by pip, hatch, rye, pyright, mypy, pytest, and ruff.
Code Reference
Source Location
- Repository: openai-python
- File: pyproject.toml
- Lines: 1-302
Signature
[project]
name = "openai"
version = "2.21.0"
description = "The official Python library for the openai API"
license = "Apache-2.0"
requires-python = ">= 3.9"
[project.scripts]
openai = "openai.cli:main"
[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"]
realtime = ["websockets >= 13, < 16"]
datalib = ["numpy >= 1", "pandas >= 1.2.3", "pandas-stubs >= 1.1.0.11"]
voice_helpers = ["sounddevice>=0.5.1", "numpy>=2.0.2"]
[build-system]
requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"
Import
# Not applicable -- this is a configuration file.
# Install the package with:
pip install openai
# Install with optional dependencies:
pip install 'openai[datalib]'
pip install 'openai[realtime]'
pip install 'openai[aiohttp]'
pip install 'openai[voice_helpers]'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Python version | >= 3.9 | Yes | Minimum Python interpreter version required |
| httpx | >= 0.23.0, < 1 | Yes | HTTP client library |
| pydantic | >= 1.9.0, < 3 | Yes | Data validation library (v1 or v2) |
| typing-extensions | >= 4.11, < 5 | Yes | Backported typing features |
| anyio | >= 3.5.0, < 5 | Yes | Async I/O abstraction layer |
| distro | >= 1.7.0, < 2 | Yes | Linux distribution detection |
| sniffio | any | Yes | Async library sniffing |
| tqdm | > 4 | Yes | Progress bar library |
| jiter | >= 0.10.0, < 1 | Yes | Fast JSON iterator/parser |
Outputs
| Name | Type | Description |
|---|---|---|
| openai package | Python package | Installable openai package with CLI entry point
|
| openai CLI | console_script | Command-line tool at openai.cli:main
|
Usage Examples
Installation
# Basic installation
pip install openai
# With realtime websocket support
pip install 'openai[realtime]'
# With data processing libraries
pip install 'openai[datalib]'
# With aiohttp transport
pip install 'openai[aiohttp]'
# With voice helper utilities
pip install 'openai[voice_helpers]'
CLI Usage
# The openai CLI entry point
openai --help
openai api chat.completions.create -m gpt-4o -g user "Hello"
Development Setup
# Run tests
pytest tests/ --tb=short -n auto
# Type checking
pyright
mypy .
# Linting and formatting
ruff check .
ruff format
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment