Version 1.5.2 of the langchain-openai package has been released, following a 1.5.2a1 pre-release, with a set of targeted improvements aimed at developers running OpenAI models through LangChain, especially in self-hosted or gateway-mediated environments.
One of the key fixes in this release addresses how reasoning item boundaries are handled. Previously, when working with OpenAI responses that include reasoning traces, the boundaries between separate reasoning items could be lost. This update preserves those boundaries, ensuring that the structured output remains intact and that downstream processing can correctly interpret each step of the model’s reasoning.
Another notable addition is the ability to extract gateway metadata from response headers when they are available. For users who route their OpenAI requests through a proxy or gateway, this means important operational information—such as request IDs, model routing details, or rate-limit data—can now be captured automatically from the headers, providing better observability and troubleshooting capabilities without requiring extra custom code.
The release also brings improved support for OpenAI’s o-series models within the get_num_tokens_from_messages utility. This change ensures that token counting works correctly for these newer models, which is especially useful for self-hosted deployments where accurate token estimation is critical for cost management and context window planning. Additionally, internal snapshot tests have been updated as part of routine maintenance.



