NAME

OpenAPI::Client::OpenAI::Path::responses-compact - Documentation for the /responses/compact path.

OPERATIONS

POST /responses/compact

Compactconversation

$client->compactconversation({
    body => { ... },
});

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) .

Responses

200 - Success

Content-Type: application/json

Example:

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

SCHEMAS

CompactResource

Properties:

  • created_at (integer, required) - Unix timestamp (in seconds) when the compacted conversation was created.

  • id (string, required) - The unique identifier for the compacted response.

  • object (string, required) - The object type. Always response.compaction .

    Allowed values: response.compaction

    Default: response.compaction

  • output (array of ItemField, required) - The compacted list of output items.

  • usage (ResponseUsage, required) - Token accounting for the compaction pass, including cached, reasoning, and total tokens.

    See "ResponseUsage" below for shape.

CompactResponseMethodPublicBody

Properties:

  • input (anyOf)

  • instructions (anyOf)

  • model (ModelIdsCompaction, required)

    See "ModelIdsCompaction" below for shape.

  • previous_response_id (anyOf)

  • prompt_cache_key (anyOf)

  • prompt_cache_retention (anyOf)

  • service_tier (anyOf)

ItemField

An item representing a message, tool call, tool output, reasoning, or other response element.

ModelIdsCompaction

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 to browse and compare available models.

ResponseUsage

Properties:

  • input_tokens (integer, required) - The number of input tokens.

  • input_tokens_details (object, required) - A detailed breakdown of the input tokens.

  • output_tokens (integer, required) - The number of output tokens.

  • output_tokens_details (object, required) - A detailed breakdown of the output tokens.

  • total_tokens (integer, required) - The total number of tokens used.

SEE ALSO

OpenAPI::Client::OpenAI::Path

COPYRIGHT AND LICENSE

Copyright (C) 2023-2026 by Nelson Ferraz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.0 or, at your option, any later version of Perl 5 you may have available.