npm / @langchain/openai
@langchain/openai
What changed in @langchain/openai 0.1 to 1, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
6 breaking3 security59 new APIs and options1 performance10 behavior and defaults45 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@langchain/openai 1105 changes
Breaking changes 6
Installed dependencies must use Zod 4.6.6 or newer to exclude versions affected by GHSA-mrhx-c7xc-m3w5; Zod v3 schemas remain supported through the bundled zod/v3 entry point.
With jsonSchema, structured output throws ModelRefusalError when the model refuses.
Binary Uint8Array data in image, audio, and file content blocks sent through the Chat Completions API is now Base64-encoded instead of sent as comma-separated decimal bytes.
Removed the model profile after OpenAI shut down the model on Aug 10, 2026.
Tool-call and server-tool-call args stream as new-slice tool-call-delta events instead of block-delta snapshots; read tool-call-delta in raw-event consumers and stream transformers.
Applies per-call options before modelKwargs, then the constructor field; on Chat Completions, modelKwargs values are no longer dropped and take precedence over the constructor field.
Security 2
LangChain: MongoDBChatMessageHistory query injection can allow cross-session access
Encrypted reasoning is now included in the input for zero-data-retention (ZDR) responses.
New APIs and options 41
Adds model-routing agent middleware.
Adds a beta runnable with typed predicate, choice and score questions.
Adds tool-risk agent middleware.
Added a model profile for GPT-6.1 Terra.
GPT-6 Luna is added to the regenerated model profiles.
GPT-6 Sol is added to the regenerated model profiles.
GPT-6.1 Sol is added to the regenerated model profiles.
GPT-4.1, GPT-5.x, GPT-6.x and o3 model profiles declare mid-conversation system-message support.
GPT-4.1, GPT-5.x, GPT-6.x and o3 model profiles declare mid-conversation tool support; ChatOpenAI reports it only when routing to the Responses API.
Responses API accepts an additional_tools block on a SystemMessage and sends it as a top-level input item preceding the message. It throws if used with Chat Completions or on a non-SystemMessage, except assistant messages.
ModelProfile now includes fileMimeTypes so models can advertise accepted MIME types for generic file inputs; OpenAI Responses API models report the types supported by input_file.
Adds support for content-block breakpoints.
Supports explicit prompt cache options.
Supports configuration_update content blocks for changing reasoning effort mid-conversation without invalidating the cached prompt prefix.
OpenAI chat models can now use LangSmith Gateway environment configuration.
Adds native event converters for streamEvents.
Responses API messages now support phase on text content blocks, including streaming events, and round-trip it through raw provider and standard content paths.
Propagates defer_loading from LangChain tool extras through bindTools() into the Responses API payload, enabling on-demand tool discovery.
Adds a factory for the OpenAI Responses API tool_search built-in tool, supporting server-executed and client-executed modes.
Added gpt-5.4 to profiles, making it available to developers using the package.
Structured output now supports Standard Schema, allowing developers to use Standard Schema schemas for structured output.
File input conversion supports docx, pptx, xlsx, and csv document types.
OpenAI now raises ContextOverflowError for context overflow, giving callers a specific error to handle.
Adds support for codex 5.3.
The image generation tool accepts an action option with generate, edit, and auto choices.
Adds local_shell_call support to the streaming converter and input reconstruction.
Adds shell_call support to the streaming converter and input reconstruction.
Adds a deprecated call-option shorthand for reasoning.effort; reasoning.effort takes precedence when both are provided.
Adds support for the apply patch tool.
Adds support for the code interpreter tool.
Adds support for the computer use tool.
Adds support for the file search tool.
Adds support for the image generation tool.
Adds support for the local shell tool.
Adds support for the MCP connector tool.
Adds moderateContent to ChatOpenAI for content moderation.
Adds support for prompt cache retention.
Adds support for the shell tool.
Adds support for the web search tool.
apiKey now supports a callable function.
A new property provides unified, provider-agnostic access to modern LLM features; @langchain/openai supports standard content blocks.
Performance 1
Stream chunk aggregation was optimized and redundant sorting was removed.
Behavior and default changes 10
The v0 default replay path reuses response_metadata.output directly, preserving every reasoning item's id and encrypted_content in original order under Zero Data Retention.
Timeouts and rate limits are marked retryable; aborts, context overflow, invalid tool results, bad credentials, and unknown models are marked non-retryable. Other errors remain unmarked and retry as before.
Strict tools are decoupled from strict structured output responses, so their behavior is no longer tied together.
Built-in tool progress events are now streamed.
Standard URL file blocks are now routed to native input_file in the Responses API.
Runnable traces now include package version metadata, making version information available in LangSmith trace metadata.
Stores response.output in response_metadata to support reasoning model round-trips.
Codex models, including codex-mini-latest and gpt-5-codex variants, are automatically routed to the Responses API.
OpenAI image generation outputs are now returned as proper image content blocks.
Prefers the Responses API for 5.2 pro.
Fixes and other changes 45
Refusals are sent back natively on assistant messages, including v1 messages.
Chat Completions keeps refusal information from responses, so applications can access it.
Messages streamed from the Responses API through the chat model event stream now set response_metadata.model_name, matching the Chat Completions stream and non-streaming Responses path.
Wrapped configuration_update and mcp_approval_response blocks are now hoisted as Responses API input items, including blocks on messages built with contentBlocks. Chat Completions sends a non_standard block's payload rather than its wrapper.
Sends the in-memory retention value as in_memory because the API rejects the hyphenated value.
The v1 contentBlocks replay path preserves every reasoning item's id and encrypted_content in original order under Zero Data Retention.
Fixes base URL deserialization.
Routes gpt-5.6-sol to the Responses API so function tools work with reasoning.
Streaming now resolves encrypted_content from the canonical payload on the final done event, and it propagates without needing an include call option.
Tool-call-only v1 assistant messages now send content as null instead of an empty array.
OpenAI cache_write_tokens are mapped to cache_creation in usage_metadata.input_token_details instead of being silently dropped.
Gemini-native functionCall content blocks are dropped when converting messages to Chat Completions API params, preventing requests from failing during cross-provider handoffs.
A per-call maxRetries is forwarded to the retry loop so a surrounding retry loop can take over instead of multiplying retries.
Includes usage in response_metadata when system_fingerprint is absent.
Content blocks rejected by the chat completions API are filtered out of input.
tool_call content blocks are dropped from chat completions input.
Assistant content in responses input now emits output_text.
The converter no longer forwards content on reasoning input items, which only carry summary, avoiding a Responses API error.
When replaying reasoning items as Responses API input, the converter now omits id when it is absent, avoiding an OpenAI 400 error.
Responses API stream iteration errors are now wrapped with existing OpenAI client error handling.
AI messages preserve top-level Responses API ids.
Custom tool calls are streamed through Responses API chunks.
Handles JSON parsing failures caused by trailing non-whitespace characters without terminating the streaming response; the structured-output pipeline handles the typed failure.
Preserves v1 assistant tool calls.
Adds an index to streaming reasoning content blocks so chunks merge properly.
Preserves plain string responses content.
Placeholder filenames are supplied for OpenAI file inputs.
Preserves reasoning_content in ChatOpenAICompletions.
DeepSeek 400 errors containing maximum context length are now recognized as ContextOverflowError, allowing downstream code to handle context overflow correctly.
Guard JSON.parse in streaming json_schema when the text is empty.
Streaming and non-streaming converters handle tool_search_call and tool_search_output response items; core block translation maps them to server_tool_call and server_tool_call_result.
Fixes type narrowing for the new union type.
The Completions API streaming path now calls the callback for the final usage chunk, so callback-based consumers receive the usage_metadata chunk.
Passes service_tier to the API when using the Responses API.
Chat model invoke and streaming operations now check and propagate abort signals, enabling cancellation and allowing fallback chains to proceed after an abort.
Validation now allows file_url and file_id without filename metadata and avoids sending filename when it is not allowed.
ChatOpenAI now passes runManager to responses._generate.
A fix was made to OpenAI reasoning.
Reasoning tokens are now properly elevated.
The responses API now passes runManager to _streamResponseChunks.
Provider-native content in ToolMessage is passed through without stringification, preserving its original form.
Fixes content in AIMessage for tool and function calls.
Fixes filename and base64 conversions in OpenAI completions converters.
Allows setting the strict tag manually in providerStrategy.
Fix missing and inconsistent user agent headers.
@langchain/openai 0.31 changes
Security 1
Fixes CVE 2025 12735.
@langchain/openai 0.118 changes
New APIs and options 18
Adds an API endpoint to delete a custom model price from a workspace. Default entries cannot be deleted, and existing run costs are not recomputed.
Adds an endpoint to create organization-wide teams. Requests require a name and organization team-management permission; successful responses return the created team.
Adds an endpoint to attach an existing access policy to a team. The request requires access_policy_id and optionally accepts workspace_id; it returns 201 when attached or 200 when already attached.
Adds an endpoint to list workspace identities for a workspace-scoped team's members, with cursor pagination and workspace team-read permission requirements.
Adds an endpoint to grant an organization-wide team a role in a workspace; it requires organization:teams:manage-grants.
Adds an endpoint to remove an organization-wide team's access to a workspace, requiring organization:teams:manage-grants.
Adds an endpoint to list organization teams, with workspace, parent-team, and identity filters, pagination, and workspace-scoped role details.
Adds an endpoint that resolves an AGENT, EXPERIMENT, or EVALUATOR address to its tracing project session ID.
Adds a beta API endpoint to attach a sandbox to a browser, or open a browser window for the caller, and return attachment details.
Adds a beta endpoint to open a tab in a browser window, optionally at a specified URL; without a URL, the tab opens at about:blank.
Adds a beta endpoint that creates a copy-on-write copy of an existing volume. The source cannot be attached read-write to a sandbox that is not stopped.
Adds a beta API endpoint to close a tab in a browser window.
Lists access policies attached to a team, with paginated results. Organization-scoped teams require organization:teams:read; workspace-scoped teams require workspaces:teams:read in their workspace.
Adds a query parameter for resuming from the previous page; the response's next_cursor is null after the last page.
Adds a query parameter to control the number of access policies per page; it defaults to 20 and accepts values from 1 to 100.
Creates an organization tracing key. The request requires workspaces and can include a description and expiration time.
Replaces every field of a custom model price entry in a workspace. The request body is a full replacement; omitted optional fields reset to defaults.
When share_localhost is enabled, returns the sandbox's localhost address as seen by the browser.