OpenAI Python SDK
AI & LLMsThe official Python library for the OpenAI API
Release History
v2.45.0v2.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.
v2.39.03 featuresThis release introduces new features related to audit logs, response structures, and optional query parameters in ActionSearch.
v2.38.03 featuresThis release primarily focuses on updating the underlying API specifications and configurations. It includes several minor API updates and associated chore work.
v2.37.01 fix3 featuresRelease 2.37.0 introduces API enhancements like the service_tier parameter and internal validation improvements, alongside removing an unnecessary client ID for workload identity authentication.
v2.36.02 featuresThis release introduces manual API updates and new Realtime 2 API capabilities.
v2.35.11 fixVersion 2.35.1 addresses a specific bug fix related to the image generation API size enumeration.
v2.35.02 featuresThis release introduces updates to the image API and includes chores related to removing and renaming the legacy Python CLI entrypoint. Documentation for top_logprobs has also been updated.
v2.34.011 fixes5 featuresThis release introduces support for setting headers via environment variables and adds functionality for Admin API Keys per endpoint. It also includes numerous bug fixes related to authentication handling and type corrections in response models.
v2.33.01 fix1 featureThis release includes an API update and fixes a bug related to the prompt_cache_retention enum value.
v2.32.01 fix5 featuresThis release introduces significant enhancements to websocket handling, including event handlers, reconnection support, and the ability to enqueue messages when disconnected. It also adds detail to InputFileContent and the OAuthErrorCode type.
v2.31.02 fixes5 featuresThis release introduces support for short-lived tokens, raw websocket data transmission, and updates API message structures, while also correcting an inconsistency regarding the 'web_search_call.results' field in ResponseIncludable.
v2.30.03 fixes1 featureVersion 2.30.0 introduces new fields for computer actions and includes several bug fixes related to API response types and input validation.
v2.29.02 fixes4 featuresThis release introduces new model slugs, adds video batch creation support, and includes several API enhancements along with minor dependency and serialization fixes.
v2.28.01 featureThis release introduces support for custom voices via the API.
v2.27.01 fix2 featuresThis release introduces significant updates to the API, including enhancements for Sora video capabilities, and resolves a bug in the merged videos resource.
v2.26.0Breaking1 featureThis release updates the GA ComputerTool to use the ComputerTool class and moves the 'computer_use_preview' tool to 'ComputerUsePreview'.
v2.25.03 fixes2 featuresThis release introduces support for new models and tools, while simultaneously removing the `prompt_cache_key` parameter and the `phase` field from message types.
v2.24.02 fixes1 featureThis release introduces API support for the 'phase' field and includes related bug fixes and documentation updates.
v2.23.01 featureVersion 2.23.0 introduces new model options for realtime API interactions, specifically gpt-realtime-1.5 and gpt-audio-1.5.
v2.22.01 featureThis release introduces websocket support for the responses API and includes various documentation enhancements across several API endpoints.
v2.21.02 fixes1 featureVersion 2.21.0 introduces new API capabilities for container network policy and skills, alongside fixes for memory leaks in structured output parsing.
v2.20.01 featureVersion 2.20.0 introduces support for images within the batch API operations.
v2.19.01 featureVersion 2.19.0 introduces new API capabilities for skills and hosted shell support, along with internal dependency bumps.
v2.18.01 featureThis release introduces the addition of the context_management field to API responses.
v2.17.02 fixes3 featuresRelease 2.17.0 introduces new API fields for shell output and image generation actions, alongside client improvements for JSON encoding. Several minor client-side bug fixes related to web search actions were also addressed.
v2.16.02 featuresThis release introduces support for binary request streaming and includes general API updates. Additionally, the Assistants API endpoints have been marked as deprecated.
v2.15.01 featureThis release introduces a new `completed_at` property on the Response object for API interactions and includes internal code generation updates.
v2.14.01 fix2 featuresThis release introduces support for new audio model slugs and allows all model parameters to accept string inputs, alongside a fix for the patch method using async file handling.
v2.13.01 featureThis release introduces support for the new gpt-image-1.5 model and includes internal CI/chore updates.
v2.12.02 featuresThis release includes general API updates and specific fixes related to grader input lists and sora-2 dated slugs.
v2.11.01 featureThis release introduces support for the new gpt 5.2 model via the API.
v2.10.01 fix1 featureVersion 2.10.0 makes the model parameter mandatory for the responses/compact endpoint and fixes a type inference issue for pyright.
v2.9.03 fixes1 featureThis release introduces support for the new gpt-5.1-codex-max model and includes several bug fixes related to stream closing and client configuration mutation. A temporary pin on mypy was also introduced due to a regression in version 1.18.1.
v2.8.11 fixVersion 2.8.1 primarily addresses a bug fix related to aligning input and output item types for better TypeScript compatibility within the API.
v2.8.01 fix1 featureThis release introduces support for the gpt 5.1 model and includes a bug fix related to Pydantic v1 compatibility for model serialization methods.
v2.7.2Breaking1 fixThis patch release fixes Python 3.14 compatibility and officially drops support for Python 3.8.
v2.7.11 fixVersion 2.7.1 is a patch release primarily focused on fixing a bug concerning the nullability of logprobs in API responses.
v2.7.03 fixes3 featuresThis release introduces support for Realtime API token limits and new hybrid search ranking options. It also includes several bug fixes, notably ensuring streams are properly closed and preventing file handle leaks.
v2.6.11 fixVersion 2.6.1 primarily contains minor bug fixes, specifically updating API documentation, alongside internal code cleanup.
v2.6.01 fix1 featureVersion 2.6.0 introduces a new field for token counts in API responses and incorporates internal OpenAPI specification updates.
v2.5.01 featureThis release introduces an API update and bumps the dependency version for httpx-aiohttp.
v2.4.01 featureVersion 2.4.0 introduces support for the gpt-4o-transcribe-diarize model on the audio transcription endpoint and includes minor internal chore updates.
v2.3.01 featureThis release introduces new comparison filter capabilities for the API and updates dependencies to ensure compatibility with Python 3.14.
v2.2.01 fix1 featureVersion 2.2.0 introduces support for new API features from dev day 2025 and includes a minor bug fix related to beta resources.
v2.1.01 featureVersion 2.1.0 introduces support for realtime API calls. This release focuses on expanding real-time interaction capabilities.
v2.0.11 fixThis patch release includes a bug fix for MCP tool calls, adding missing status and approval request ID fields.
v2.0.0Breaking2 featuresThis major release introduces support for multi-modal function call outputs (images and files) and BatchUsage, while changing the output type of tool call response items from string to a union type.
v1.109.11 fixThis patch release addresses a compatibility bug with older versions of Pydantic when handling additional fields.
v1.109.01 featureThis release introduces support for the gpt-5-codex model to the OpenAI Python SDK.
v1.108.21 fix1 featureThis patch release focuses on fixing MCP tool naming and updating OpenAPI definitions for conversations, alongside minor internal script improvements.
v1.108.1Breaking1 featureThis release introduces the reasoning_text field to the API and updates internal type handling for optional parameters from NotGiven to Omit.
v1.108.01 featureThis release introduces type updates for conversations and reasoning effort in evaluations, alongside internal Pydantic dependency maintenance.
v1.107.3This is a maintenance release focused on internal API documentation refactoring, specification updates, and test simplification.
v1.107.2This patch release includes minor documentation and type updates for the realtime API, along with internal test simplifications.
v1.107.11 fixThis patch release focuses on correcting type definitions for the Realtime API following its General Availability.
v1.107.01 featureThis release introduces the API shape for RealtimeGA and includes internal codegen updates.
v1.106.1This patch release focuses on internal maintenance by moving mypy configurations to the pyproject.toml file.
v1.106.02 featuresThis release introduces support for dynamic API keys via callables and enhances forward compatibility with Pydantic v3.
v1.105.01 featureThis release introduces support for the new gpt-realtime models in the OpenAI API.
v1.104.21 fixVersion 1.104.2 is a maintenance patch that restores type aliases for web search tools to fix potential type-checking regressions.
v1.104.11 featureThis patch release includes manual updates to the ResponseInputAudio API components.
v1.104.01 fix1 featureThis release focuses on internal type safety improvements by replacing List[str] with SequenceNotStr in various parameter definitions.
v1.103.01 fix1 featureThis release introduces updates to the Realtime API and fixes a bug where parameters were missing from the stream() method.
v1.102.01 fix1 featureThis release introduces web search filters to the API and fixes a bug related to modern type syntax usage.
v1.101.02 featuresThis release introduces support for the /v1/conversations endpoint and adds connector support for MCP tools.
v1.100.3This is a maintenance release focused on internal CI improvements, specifically setting up breaking change detection.
v1.100.21 fixThis patch release updates the internal API representation for the verbosity parameter in Chat Completions to ensure accurate data shaping.
v1.100.11 fixThis patch release reverts an accidental deletion of response text configuration types to ensure type consistency.
v1.100.01 featureThis release introduces new text parameters and expiration options to the API.
v1.99.91 fixThis patch release specifically addresses a typing issue within the ChatCompletionMessageToolCall class.
v1.99.82 fixesRelease 1.99.8 focuses on internal test improvements and reverts a breaking change to the ChatCompletionMessageToolCallUnion type.
v1.99.7Breaking2 fixesRelease 1.99.7 focuses on fixing type definitions by reverting ChatCompletionMessageToolCallParam to a TypedDict.
v1.99.61 fixThis release focuses on improving type exports for tool calls and internal maintenance updates.
v1.99.51 fixThis patch release fixes a bug regarding the location of the verbosity parameter within the Responses class.
v1.99.4Breaking2 fixesThis patch release focuses on type definition fixes, specifically reverting ChatCompletionToolParam to a TypedDict and renaming internal chat completion tool types.
v1.99.31 fixThis patch release restores the missing 'output_text' field to response objects.
v1.99.21 fix1 featureThis release introduces support for GPT-5 and associated API features, alongside a fix for tool-related type definitions.
v1.99.11 fixThis patch release addresses a bug regarding internal event imports.
v1.99.01 fix2 featuresThis release introduces support for file upload requests and adds missing prompt cache parameters to the client.
v1.98.01 featureThis release includes manual updates to the API.
v1.97.2This patch release includes internal refactoring of the streaming client for future-proofing and adds VS Code project settings.
v1.97.12 fixesThis patch release focuses on improving parsing logic for metadata and extra field types, alongside internal API event shape refinements.
v1.97.01 featureThis release includes manual updates to the API definitions.
v1.96.11 featureThis patch release updates the internal Realtime API specifications.
v1.96.02 featuresThis release focuses on internal maintenance, including environment call-out cleanup and updates to the Realtime API specifications.
v1.95.11 fixThis patch release fixes a bug in the client where Content-Type headers were incorrectly being sent during GET requests.
v1.95.01 fix2 featuresThis release introduces file_url support to the API and includes minor fixes for event IDs and README rendering on PyPI.
v1.94.01 featureRelease 1.94.0 improves API error messaging specifically for missing embeddings.
v1.93.31 fixThis patch release addresses a bug in the parsing logic to correctly handle nested discriminated unions.
v1.93.21 featureThis maintenance release adds official support for Python 3.13 and updates the internal h11 dependency constraint.
v1.93.14 fixesThis patch release focuses on fixing missing arguments in vector store file polling methods and response parsing, alongside CI improvements.
v1.93.01 featureThis release introduces CLI support for managing fine-tuning jobs.
v1.92.31 fixThis patch release fixes an encoding error triggered by empty API keys and updates documentation regarding macOS requirements for realtime examples.
v1.92.2BreakingThis maintenance release removes an unsupported 'api' property from the library.
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.
InternalServerError3 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.
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.
ImportError1 reportThis 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.
JSONDecodeError1 reportJSONDecodeError often arises when the response from the OpenAI API is malformed JSON or contains non-JSON data (e.g., SSE retry events). Implement robust error handling by checking if the response line is valid JSON before attempting to parse it; you may need to skip lines that are not JSON objects (e.g., retry events) or use a try-except block to catch and handle JSONDecodeError exceptions, logging the error and potentially retrying the request. Specifically, handle the case where the data field might be missing.
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