Responses
Compact a conversation
POST
/openai/v1/responses/compactCompacts a conversation into a response object suitable for long-running and zero-data-retention scenarios.
Request BodyContent-Type: application/json
modelOpenAI.ModelIdsResponses | string | nullrequired
Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the [model guide](/docs/models) to browse and compare available models.gpt-5.4gpt-5.4-minigpt-5.4-nanogpt-5.4-mini-2026-03-17gpt-5.4-nano-2026-03-17gpt-5.3-chat-latestgpt-5.2gpt-5.2-2025-12-11gpt-5.2-chat-latestgpt-5.2-progpt-5.2-pro-2025-12-11gpt-5.1gpt-5.1-2025-11-13gpt-5.1-codexgpt-5.1-minigpt-5.1-chat-latestgpt-5gpt-5-minigpt-5-nanogpt-5-2025-08-07gpt-5-mini-2025-08-07gpt-5-nano-2025-08-07gpt-5-chat-latestgpt-4.1gpt-4.1-minigpt-4.1-nanogpt-4.1-2025-04-14gpt-4.1-mini-2025-04-14gpt-4.1-nano-2025-04-14o4-minio4-mini-2025-04-16o3o3-2025-04-16o3-minio3-mini-2025-01-31o1o1-2024-12-17o1-previewo1-preview-2024-09-12o1-minio1-mini-2024-09-12gpt-4ogpt-4o-2024-11-20gpt-4o-2024-08-06gpt-4o-2024-05-13gpt-4o-audio-previewgpt-4o-audio-preview-2024-10-01gpt-4o-audio-preview-2024-12-17gpt-4o-audio-preview-2025-06-03gpt-4o-mini-audio-previewgpt-4o-mini-audio-preview-2024-12-17gpt-4o-search-previewgpt-4o-mini-search-previewgpt-4o-search-preview-2025-03-11gpt-4o-mini-search-preview-2025-03-11chatgpt-4o-latestcodex-mini-latestgpt-4o-minigpt-4o-mini-2024-07-18gpt-4-turbogpt-4-turbo-2024-04-09gpt-4-0125-previewgpt-4-turbo-previewgpt-4-1106-previewgpt-4-vision-previewgpt-4gpt-4-0314gpt-4-0613gpt-4-32kgpt-4-32k-0314gpt-4-32k-0613gpt-3.5-turbogpt-3.5-turbo-16kgpt-3.5-turbo-0301gpt-3.5-turbo-0613gpt-3.5-turbo-1106gpt-3.5-turbo-0125gpt-3.5-turbo-16k-0613o1-proo1-pro-2025-03-19o3-proo3-pro-2025-06-10o3-deep-researcho3-deep-research-2025-06-26o4-mini-deep-researcho4-mini-deep-research-2025-06-26computer-use-previewcomputer-use-preview-2025-03-11gpt-5-codexgpt-5-progpt-5-pro-2025-10-06gpt-5.1-codex-max
One of the following:
OpenAI.ModelIdsResponsesOpenAI.ModelIdsShared | enum
gpt-5.4gpt-5.4-minigpt-5.4-nanogpt-5.4-mini-2026-03-17gpt-5.4-nano-2026-03-17gpt-5.3-chat-latestgpt-5.2gpt-5.2-2025-12-11gpt-5.2-chat-latestgpt-5.2-progpt-5.2-pro-2025-12-11gpt-5.1gpt-5.1-2025-11-13gpt-5.1-codexgpt-5.1-minigpt-5.1-chat-latestgpt-5gpt-5-minigpt-5-nanogpt-5-2025-08-07gpt-5-mini-2025-08-07gpt-5-nano-2025-08-07gpt-5-chat-latestgpt-4.1gpt-4.1-minigpt-4.1-nanogpt-4.1-2025-04-14gpt-4.1-mini-2025-04-14gpt-4.1-nano-2025-04-14o4-minio4-mini-2025-04-16o3o3-2025-04-16o3-minio3-mini-2025-01-31o1o1-2024-12-17o1-previewo1-preview-2024-09-12o1-minio1-mini-2024-09-12gpt-4ogpt-4o-2024-11-20gpt-4o-2024-08-06gpt-4o-2024-05-13gpt-4o-audio-previewgpt-4o-audio-preview-2024-10-01gpt-4o-audio-preview-2024-12-17gpt-4o-audio-preview-2025-06-03gpt-4o-mini-audio-previewgpt-4o-mini-audio-preview-2024-12-17gpt-4o-search-previewgpt-4o-mini-search-previewgpt-4o-search-preview-2025-03-11gpt-4o-mini-search-preview-2025-03-11chatgpt-4o-latestcodex-mini-latestgpt-4o-minigpt-4o-mini-2024-07-18gpt-4-turbogpt-4-turbo-2024-04-09gpt-4-0125-previewgpt-4-turbo-previewgpt-4-1106-previewgpt-4-vision-previewgpt-4gpt-4-0314gpt-4-0613gpt-4-32kgpt-4-32k-0314gpt-4-32k-0613gpt-3.5-turbogpt-3.5-turbo-16kgpt-3.5-turbo-0301gpt-3.5-turbo-0613gpt-3.5-turbo-1106gpt-3.5-turbo-0125gpt-3.5-turbo-16k-0613o1-proo1-pro-2025-03-19o3-proo3-pro-2025-06-10o3-deep-researcho3-deep-research-2025-06-26o4-mini-deep-researcho4-mini-deep-research-2025-06-26computer-use-previewcomputer-use-preview-2025-03-11gpt-5-codexgpt-5-progpt-5-pro-2025-10-06gpt-5.1-codex-max
string
null
inputstring | (message | item_reference | output_message | file_search_call | computer_call | computer_call_output | web_search_call | function_call | function_call_output | tool_search_call | tool_search_output | reasoning | compaction | image_generation_call | code_interpreter_call | local_shell_call | local_shell_call_output | shell_call | shell_call_output | apply_patch_call | apply_patch_call_output | mcp_list_tools | mcp_approval_request | mcp_approval_response | mcp_call | custom_tool_call_output | custom_tool_call)[] | null
One of the following:
string
(message | item_reference | output_message | file_search_call | computer_call | computer_call_output | web_search_call | function_call | function_call_output | tool_search_call | tool_search_output | reasoning | compaction | image_generation_call | code_interpreter_call | local_shell_call | local_shell_call_output | shell_call | shell_call_output | apply_patch_call | apply_patch_call_output | mcp_list_tools | mcp_approval_request | mcp_approval_response | mcp_call | custom_tool_call_output | custom_tool_call)[]
null
previous_response_idstring | null
instructionsstring | null
prompt_cache_keystring | null
prompt_cache_retentionenum
in_memory24h
service_tierenum
autodefaultflexpriority
Responses
idstringrequired
The unique identifier for the compacted response.objectenumrequired
The object type. Always `response.compaction`.response.compaction
output(message | function_call | tool_search_call | tool_search_output | function_call_output | file_search_call | web_search_call | image_generation_call | computer_call | computer_call_output | reasoning | compaction | code_interpreter_call | local_shell_call | local_shell_call_output | shell_call | shell_call_output | apply_patch_call | apply_patch_call_output | mcp_list_tools | mcp_approval_request | mcp_approval_response | mcp_call | custom_tool_call | custom_tool_call_output)[]required
The compacted list of output items.One of the following:
messageOpenAI.ItemFieldMessage
A message to or from the model.function_callOpenAI.ItemFieldFunctionToolCall
A tool call to run a function. See the
[function calling guide](/docs/guides/function-calling) for more information.tool_search_callOpenAI.ItemFieldToolSearchCall
An item representing a message, tool call, tool output, reasoning, or other response element.tool_search_outputOpenAI.ItemFieldToolSearchOutput
An item representing a message, tool call, tool output, reasoning, or other response element.function_call_outputOpenAI.ItemFieldFunctionToolCallOutput
The output of a function tool call.file_search_callOpenAI.ItemFieldFileSearchToolCall
The results of a file search tool call. See the
[file search guide](/docs/guides/tools-file-search) for more information.web_search_callOpenAI.ItemFieldWebSearchToolCall
The results of a web search tool call. See the
[web search guide](/docs/guides/tools-web-search) for more information.image_generation_callOpenAI.ItemFieldImageGenToolCall
An image generation request made by the model.computer_callOpenAI.ItemFieldComputerToolCall
A tool call to a computer use tool. See the
[computer use guide](/docs/guides/tools-computer-use) for more information.computer_call_outputOpenAI.ItemFieldComputerToolCallOutput
The output of a computer tool call.reasoningOpenAI.ItemFieldReasoningItem
A description of the chain of thought used by a reasoning model while generating
a response. Be sure to include these items in your `input` to the Responses API
for subsequent turns of a conversation if you are manually
[managing context](/docs/guides/conversation-state).compactionOpenAI.ItemFieldCompactionBody
A compaction item generated by the [`v1/responses/compact` API](/docs/api-reference/responses/compact).code_interpreter_callOpenAI.ItemFieldCodeInterpreterToolCall
A tool call to run code.local_shell_callOpenAI.ItemFieldLocalShellToolCall
A tool call to run a command on the local shell.local_shell_call_outputOpenAI.ItemFieldLocalShellToolCallOutput
The output of a local shell tool call.shell_callOpenAI.ItemFieldFunctionShellCall
A tool call that executes one or more shell commands in a managed environment.shell_call_outputOpenAI.ItemFieldFunctionShellCallOutput
The output of a shell tool call that was emitted.apply_patch_callOpenAI.ItemFieldApplyPatchToolCall
A tool call that applies file diffs by creating, deleting, or updating files.apply_patch_call_outputOpenAI.ItemFieldApplyPatchToolCallOutput
The output emitted by an apply patch tool call.mcp_list_toolsOpenAI.ItemFieldMcpListTools
A list of tools available on an MCP server.mcp_approval_requestOpenAI.ItemFieldMcpApprovalRequest
A request for human approval of a tool invocation.mcp_approval_responseOpenAI.ItemFieldMcpApprovalResponseResource
A response to an MCP approval request.mcp_callOpenAI.ItemFieldMcpToolCall
An invocation of a tool on an MCP server.custom_tool_callOpenAI.ItemFieldCustomToolCall
A call to a custom tool created by the model.custom_tool_call_outputOpenAI.ItemFieldCustomToolCallOutput
The output of a custom tool call from your code, being sent back to the model.created_atintegerrequired
Unix timestamp (in seconds) when the compacted conversation was created.usageOpenAI.ResponseUsagerequired
Token accounting for the compaction pass, including cached, reasoning, and total tokens.input_tokensintegerrequired
The number of input tokens.input_tokens_detailsOpenAI.ResponseUsageInputTokensDetailsrequired
A detailed breakdown of the input tokens.output_tokensintegerrequired
The number of output tokens.output_tokens_detailsOpenAI.ResponseUsageOutputTokensDetailsrequired
A detailed breakdown of the output tokens.total_tokensintegerrequired
The total number of tokens used.