@@ -510,12 +510,11 @@ function _convertMessagesToOpenAIResponsesParams(
510
510
if ( role === "assistant" ) {
511
511
// if we have the original response items, just reuse them
512
512
if (
513
+ ! zdrEnabled &&
513
514
lcMsg . response_metadata . output != null &&
514
515
Array . isArray ( lcMsg . response_metadata . output ) &&
515
516
lcMsg . response_metadata . output . length > 0 &&
516
- lcMsg . response_metadata . output . every (
517
- ( item ) => "type" in item && "id" in item
518
- )
517
+ lcMsg . response_metadata . output . every ( ( item ) => "type" in item )
519
518
) {
520
519
return lcMsg . response_metadata . output ;
521
520
}
@@ -525,7 +524,7 @@ function _convertMessagesToOpenAIResponsesParams(
525
524
const input : ResponsesInputItem [ ] = [ ] ;
526
525
527
526
// reasoning items
528
- if ( lcMsg . additional_kwargs . reasoning != null ) {
527
+ if ( ! zdrEnabled && lcMsg . additional_kwargs . reasoning != null ) {
529
528
type FindType < T , TType extends string > = T extends { type : TType }
530
529
? T
531
530
: never ;
@@ -561,7 +560,7 @@ function _convertMessagesToOpenAIResponsesParams(
561
560
input . push ( {
562
561
type : "message" ,
563
562
role : "assistant" ,
564
- ...( lcMsg . id ? { id : lcMsg . id } : { } ) ,
563
+ ...( lcMsg . id && ! zdrEnabled ? { id : lcMsg . id } : { } ) ,
565
564
content :
566
565
typeof content === "string"
567
566
? content
@@ -598,7 +597,7 @@ function _convertMessagesToOpenAIResponsesParams(
598
597
name : toolCall . name ,
599
598
arguments : JSON . stringify ( toolCall . args ) ,
600
599
call_id : toolCall . id ! ,
601
- id : functionCallIds ?. [ toolCall . id ! ] ,
600
+ ... ( zdrEnabled ? { id : functionCallIds ?. [ toolCall . id ! ] } : { } ) ,
602
601
} )
603
602
)
604
603
) ;
@@ -609,7 +608,7 @@ function _convertMessagesToOpenAIResponsesParams(
609
608
type : "function_call" ,
610
609
name : toolCall . function . name ,
611
610
call_id : toolCall . id ,
612
- id : functionCallIds ?. [ toolCall . id ] ,
611
+ ... ( zdrEnabled ? { id : functionCallIds ?. [ toolCall . id ] } : { } ) ,
613
612
arguments : toolCall . function . arguments ,
614
613
} )
615
614
)
@@ -1863,7 +1862,14 @@ export class ChatOpenAI<
1863
1862
useResponsesApi = false ;
1864
1863
1865
1864
/**
1866
- * Should be set to `true` in tenancies with Zero Data Retention
1865
+ * Must be set to `true` in tenancies with Zero Data Retention. Setting to `true` will disable
1866
+ * output storage in the Responses API, but this DOES NOT enable Zero Data Retention in your
1867
+ * OpenAI organization or project. This must be configured directly with OpenAI.
1868
+ *
1869
+ * See:
1870
+ * https://help.openai.com/en/articles/10503543-data-residency-for-the-openai-api
1871
+ * https://platform.openai.com/docs/api-reference/responses/create#responses-create-store
1872
+ *
1867
1873
* @default false
1868
1874
*/
1869
1875
zdrEnabled ?: boolean | undefined ;
@@ -2110,6 +2116,7 @@ export class ChatOpenAI<
2110
2116
} ) ( ) ,
2111
2117
parallel_tool_calls : options ?. parallel_tool_calls ,
2112
2118
max_output_tokens : this . maxTokens === - 1 ? undefined : this . maxTokens ,
2119
+ ...( this . zdrEnabled ? { store : false } : { } ) ,
2113
2120
...this . modelKwargs ,
2114
2121
} ;
2115
2122
0 commit comments