OpenAI Python SDK
AI & LLMsThe official Python library for the OpenAI API
Release History
View all versions →v3.6.01 fix1 featureThis release introduces compute_units to API responses and enhances the X.509 workload identity integration. Several development and build system dependencies have also been updated.
v3.5.01 featureThis release introduces a change to function call outputs, making call IDs optional. This aims to provide more flexibility in how function call results are handled.
v3.4.012 fixes2 featuresThis release introduces new features like obfuscation in ChatCompletionChunk and project residency configuration. It also includes numerous bug fixes across API, Azure, and WebSocket handling, along with documentation updates and internal refactors.
v3.3.11 fixThis release addresses security vulnerabilities by updating dependencies and includes several build and dependency management improvements, such as migrating to uv and removing unused packages.
v3.3.01 fix1 featureThis release introduces support for named data-residency endpoints and ensures patched optional networking dependencies are required. It also includes updates to dependency management and documentation.
v3.2.02 featuresThis release introduces support for Bedrock Runtime endpoints and adds new features for shell call streaming events and service/image types.
v3.1.03 featuresThis release introduces several API enhancements including WebSocket stream IDs, workload identity access token events, and the Ultrafast tier. Sora video APIs have been deprecated.
v3.0.0Breaking1 featureThis release upgrades the default HTTP client to HTTPX2, requiring migration for applications with custom HTTPX configurations. The `httpx` package is no longer installed automatically.
v2.54.01 fix1 featureThis release adds new model identifiers for Responses and clarifies audio upload metadata requirements.
v2.53.02 fixes2 featuresThis release introduces support for the gpt-5.5 model and enhances Response types with tool name and namespace information. It also includes CI improvements to avoid NumPy source builds and duplicate HTTPX coverage.
v2.52.1This release is a patch version (2.52.1) that primarily focuses on CI improvements by pinning the setup-uv action to a specific commit for better reproducibility.
v2.52.01 fix1 featureThis release introduces content provenance checks for the API and improves the client's handling of retry delays. It also includes documentation updates for mTLS HTTP client recipes.
v2.51.01 fix1 featureThis release introduces a new 'fast tier' for API usage and includes bug fixes to integrate this feature into helper methods.
v2.50.01 fix1 featureThis release includes updates to transcription models for the API and restores a keyword overload for audio transcriptions.
v2.49.01 featureThis release introduces a new minimum Python version requirement of 3.10 and includes automation for version reviews.
v2.48.02 featuresThis release introduces the ability to accept `None` for `prompt_cache_key`/`safety_identifier` and adds support for `spend_limit` admin APIs.
v2.47.01 fix2 featuresThis release introduces experimental support for HTTPX2 clients and enhances CI workflow templates. It also addresses a dependency issue by requiring a patched aiohttp version for Python 3.10 and above.
v2.46.02 fixes4 featuresThis release introduces a new endpoint for managing API keys within projects and adds support for owner project access. It also includes bug fixes for type compatibility and the removal of beta annotation aliases.
v2.45.01 fix1 featureThis release introduces support for gpt-5.6-sol model updates and fixes an issue with beta resource access.
v2.44.01 fixRelease 2.44.0 primarily addresses a bug in authentication header prioritization.
v2.43.01 featureRelease 2.43.0 primarily updates the underlying OpenAPI specification or Stainless configuration.
v2.42.03 featuresThis release introduces new API features including admin spend alerts, manual updates, and OpenAPI spec configuration updates.
v2.41.1This patch release primarily addresses internal build system maintenance by removing a scheduled release workflow trigger.
v2.41.01 featureThis release introduces new features allowing direct access to moderation results on API responses for both general responses and chat completions.
v2.40.01 fix1 featureThis release introduces support for Amazon Bedrock Responses and fixes an issue allowing Bedrock API keys to be set directly on the client.
Common Errors
BadRequestError24 reportsBadRequestError in openai-python-sdk usually arises from malformed requests sent to the OpenAI API. This can happen due to incorrect data types, missing required parameters, or invalid values in your API request. To fix, carefully validate your request data against the OpenAI API documentation for the specific endpoint you are using, paying close attention to the expected schema and data types; also, ensure your pydantic models correctly reflect the expected schema if using them.
NotFoundError8 reportsThe "NotFoundError" in the openai-python-sdk often arises from using an incorrect or unsupported API endpoint, particularly with Azure OpenAI or preview API versions. To resolve this, double-check that the API endpoint, deployment name, and API version are accurate and supported by your Azure OpenAI service and model. Ensure that the requested functionality (e.g., edits, tools) is available for the specific model and API version you're using.
InternalServerError4 reports"InternalServerError" errors in the OpenAI Python SDK often indicate a problem on OpenAI's server-side, or issues in the request that the server cannot properly process. To fix it, first, ensure your request data is correctly formatted and validated against the API documentation, especially for complex types like `decimal.Decimal` fields or file content requests. If the issue persists, consider implementing retry logic with exponential backoff to handle temporary server hiccups and report the issue to OpenAI support if it continues.
RemoteProtocolError3 reportsThis error usually indicates network instability or the server closing the connection prematurely, often due to timeouts. Implement retry logic with exponential backoff using libraries like `tenacity` around your OpenAI API calls to gracefully handle transient network issues and server-side hiccups. Additionally, consider increasing the timeout settings in your `openai` client configuration to allow more time for the server to respond.
LengthFinishReasonError2 reportsLengthFinishReasonError usually means the OpenAI API stopped generating tokens because it hit the `max_tokens` limit you specified in your request. Increase the `max_tokens` parameter in your API call to allow the model to complete its response, or consider streaming the response to handle potentially long outputs.
ImportError2 reportsThis ImportError often arises due to inconsistencies between the openai package version and its dependencies, particularly when dealing with streaming functionality. To resolve this, upgrade the `openai` package and its dependencies, especially `requests` and `urllib3`, using pip: `pip install --upgrade openai requests urllib3`. If the error persists, try creating a new virtual environment to ensure a clean installation.
Related AI & LLMs Packages
AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Get up and running with OpenAI gpt-oss, DeepSeek-R1, Gemma 3 and other models.
🦜🔗 The platform for reliable agents.
The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
LLM inference in C/C++
GPT4All: Run Local LLMs on Any Device. Open-source and available for commercial use.
Subscribe to Updates
Get notified when new versions are released