OpenAI Python SDK
AI & LLMsThe official Python library for the OpenAI API
Release History
v2.24.02 fixes1 featureThis release introduces support for the 'phase' field in the API and includes fixes related to its enum definition and documentation.
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 featureThis release introduces new API capabilities for container network policy and skills, alongside fixes for a memory leak in structured output parsing and webhook compatibility.
v2.20.01 featureVersion 2.20.0 introduces support for images within the batch API operations.
v2.19.01 featureThis release introduces new API capabilities for skills and hosted shell functionality. It also includes 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 calls 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. Notably, the Assistants API endpoints have been marked as deprecated.
v2.15.0v2.14.01 fix2 featuresThis release introduces support for new audio model slugs and standardizes model parameters to accept strings, alongside a fix for asynchronous file handling in patch requests.
v2.13.01 featureThis release introduces support for the gpt-image-1.5 model and includes internal client updates and CI improvements for the Agents SDK.
v2.12.03 featuresRelease 2.12.0 introduces general API updates, including support for sora-2 dated slugs and modifications to the grader input list.
v2.11.01 featureThis release introduces support for the gpt 5.2 API model.
v2.10.0Breaking1 fix1 featureRelease 2.10.0 introduces a breaking change making the 'model' parameter mandatory for the responses/compact endpoint and improves type inference for pyright users.
v2.9.03 fixes2 featuresRelease 2.9.0 introduces support for the gpt-5.1-codex-max model and includes critical bug fixes for stream management and client configuration handling.
v2.8.11 fixA patch release focused on aligning input and output item types for TypeScript compatibility.
v2.8.01 fix1 featureRelease 2.8.0 introduces support for the gpt 5.1 model and provides bug fixes for Pydantic v1 method signatures.
v2.7.2Breaking1 fixThis release drops support for Python 3.8 and introduces compatibility fixes for Python 3.14.
v2.7.11 fixThis patch release fixes a bug regarding the nullability of logprobs in the API response.
v2.7.0Breaking3 fixes3 featuresRelease 2.7.0 introduces Realtime API token limits and hybrid search ranking options, while fixing resource leaks in uploads and stream handling.
v2.6.11 fixThis is a patch release focused on documentation updates and internal code cleanup for custom translations.
v2.6.01 fix1 featureThis release introduces a new input token count field to API responses and includes internal updates to the OpenAPI specification.
v2.5.01 featureMinor release featuring an API update and a version bump for the httpx-aiohttp dependency.
v2.4.01 featureThis release introduces support for the gpt-4o-transcribe-diarize model on the audio transcriptions endpoint.
v2.3.01 featureRelease 2.3.0 introduces new comparison filters for the API and updates the jiter dependency to support Python 3.14.
v2.2.01 fix1 featureThis release introduces new API features for Dev Day 2025 and includes a bug fix to include chatkit in the beta resource.
v2.1.01 featureThis release introduces support for Realtime API calls to the OpenAI Python SDK.
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.
v1.92.11 featureThis patch release focuses on internal client synchronization for streaming and parsing methods, alongside documentation updates for Webhooks.
v1.92.01 fix2 featuresThis release introduces support for webhooks and deep research, while promoting the 'stream' and 'parse' client methods from beta to stable.
v1.91.01 featureThis release updates the API shapes for usage tracking and the code interpreter tool.
v1.90.01 featureVersion 1.90.0 updates the API to make the 'model' and 'inputs' parameters optional during response creation.
v1.89.01 fix1 featureThis release introduces support for the aiohttp library within the client and includes minor bug fixes for the test suite.
v1.88.01 featureThis release includes manual API updates and internal CI improvements.
v1.87.01 fix1 featureThis release introduces support for reusable prompt IDs and fixes an issue with service_tier updates in the beta chat completions client.
v1.86.01 featureThis release adds support for the o3-pro model IDs to the OpenAI API.
v1.85.01 fix1 featureThis release introduces support for tools and structured outputs in evaluations and fixes an issue to allow raw responses within the parse() method.
v1.84.02 featuresThis release introduces support for new Realtime and Audio models along with expanded session options and internal type name updates.
v1.83.02 fixes2 featuresThis release introduces a new follow_redirects option and binary content support for container files, while deprecating the Assistants API and fixing code interpreter interfaces.
v1.82.11 fixThis patch release fixes a bug in response re-serialization and updates internal release workflows.
v1.82.01 fix1 featureThis release introduces new streaming helpers for background API responses and fixes an issue where Azure image edit endpoints were not correctly identified as deployment endpoints.
v1.81.01 featureThis release introduces support for a new container endpoint in the OpenAI API.
v1.80.01 featureVersion 1.80.0 introduces new API tools and includes minor documentation grammar improvements.
v1.79.01 fix4 featuresThis release focuses on expanding the Evals and Assistants API schemas and includes a fix for the audio transcription endpoint.
v1.78.12 fixes1 featureThis patch release focuses on internal maintenance, fixing linting errors and enabling support for direct resource imports.
v1.78.01 fix1 featureThis release introduces support for the reinforcement fine-tuning API and optimizes performance through lazy imports for resources and module-level clients.
v1.77.02 fixes2 featuresVersion 1.77.0 introduces support for reasoning encryption and new image sizes, alongside bug fixes for whitespace parsing.
v1.76.2This patch release includes internal API specification cleanup and maintenance chores.
v1.76.11 featureThis patch release improves the handling of JSON-related content-type headers and includes internal CI updates for the repository.
v1.76.03 fixes1 featureThis release introduces support for new image models and improves compatibility with Pydantic v1 by making ModelField annotation checks more robust.
v1.75.01 featureThis release adds support for the new o3 and o4-mini model identifiers to the API.
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