Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Pyproject Config

From Leeroopedia
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:

  1. Project metadata (lines 1-39):
    • Package name: openai, version: 2.21.0
    • License: Apache-2.0
    • Author: OpenAI (support@openai.com)
    • Python requirement: >= 3.9 with classifiers for Python 3.9 through 3.14
    • Platforms: OS Independent (POSIX, macOS, Linux, Windows)
  1. Core dependencies (lines 11-20):
    • httpx>=0.23.0, <1: HTTP client
    • pydantic>=1.9.0, <3: Data validation (supports both v1 and v2)
    • typing-extensions>=4.11, <5: Backported typing features
    • anyio>=3.5.0, <5: Async I/O abstraction
    • distro>=1.7.0, <2: OS/distro detection for user-agent strings
    • sniffio: Async library detection
    • tqdm > 4: Progress bars (for file uploads)
    • jiter>=0.10.0, <1: Fast JSON parsing
  1. CLI entry point (line 46):
    • openai = "openai.cli:main" -- provides the openai command-line tool
  1. Optional dependency groups (lines 48-53):
    • aiohttp: aiohttp + httpx_aiohttp>=0.1.9 for aiohttp transport
    • realtime: websockets >= 13, < 16 for realtime API support
    • datalib: numpy >= 1, pandas >= 1.2.3, pandas-stubs >= 1.1.0.11 for data processing
    • voice_helpers: sounddevice>=0.5.1, numpy>=2.0.2 for audio I/O
  1. Build system (lines 108-133):
    • Build backend: hatchling==1.26.3 with hatch-fancy-pypi-readme
    • Wheel package source: src/openai
    • README generated from README.md with relative-to-absolute link substitution
  1. Testing configuration (lines 146-154):
    • pytest with --tb=short -n auto (parallel via pytest-xdist)
    • asyncio_mode = "auto" for automatic async test detection
    • xfail_strict = true and filterwarnings = ["error"] for strict test hygiene
  1. 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
  1. Linting (lines 245-301):
    • Ruff: Line length 120, target Python 3.8, isort rules, bugbear rules, unused import removal, functools.lru_cache banned in favor of custom _utils.lru_cache

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

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