Responses

Compact conversation

Changed on

Compact a conversation. Returns a compacted response object.

Learn when and how to compact long-running conversations in the conversation state guide. For ZDR-compatible compaction details, see Compaction (advanced).

post/responses/compact

Request

  • Base URL
    https://api.openai.com/v1
  • URL
    https://api.openai.com/v1/responses/compact
  • Auth
    HTTP bearer

Request body

previous_response_idstring nullable

The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about conversation state. Cannot be used in conjunction with conversation.

instructionsstring nullable

A system (or developer) message inserted into the model's context. When used along with previous_response_id, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses.

prompt_cache_keystring nullable

A key to use when reading from or writing to the prompt cache.

prompt_cache_retention'in_memory' | '24h'
service_tier'auto' | 'default' | 'fast' | 'flex' | 'priority'

Response

Success

idstring required

The unique identifier for the compacted response.

object'response.compaction' required

The object type. Always response.compaction.

created_atinteger required

Unix timestamp (in seconds) when the compacted conversation was created.

Example response

{
  "id": "resp_001",
  "object": "response.compaction",
  "output": [
    {
      "id": "msg_001",
      "status": "completed",
      "type": "message",
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Summarize our launch checklist from last week."
        }
      ]
    },
    {
      "id": "msg_002",
      "status": "completed",
      "type": "message",
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "You are performing a CONTEXT CHECKPOINT COMPACTION..."
        }
      ]
    },
    {
      "type": "compaction",
      "id": "cmp_001",
      "encrypted_content": "encrypted-summary"
    }
  ],
  "created_at": 1731459200,
  "usage": {
    "input_tokens": 42897,
    "input_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0
    },
    "output_tokens": 12000,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 54897
  }
}

Changes

    • info

      added the new optional request property //////////

    • info

      added the new optional request property //////////

    • info

      added the new optional request property //////////

    • info

      added the new optional request property //////////

    • info

      added the new optional request property //////////

    • info

      added the new optional request property //////////

    • info

      added the new optional request property ///////////

    • info

      added the new optional request property ///////////

    • info

      added the new optional request property ///////////

    • info

      added the optional property /////// to the response with the status

    • info

      added the optional property /////// to the response with the status

    • info

      added the optional property /////// to the response with the status

    • info

      added the optional property /////// to the response with the status

    • info

      added the optional property //////// to the response with the status

    • info

      added the optional property //////// to the response with the status

    • info

      added the optional property //////// to the response with the status

    • info

      added the optional property //////// to the response with the status

    • info

      added the optional property //////// to the response with the status

    • info

      added the optional property //////// to the response with the status

    • info

      added the new gpt-6.1-terra enum value to the request property /////////