Skip to main content

gproxy_protocol/wire/openai/
compact.rs

1//! Public Responses compaction body; source: Compact a response.md.
2//! Model is required-nullable, input optional-nullable; output is the same 28-item
3//! response union, with required usage accounting. Model resources remain open strings.
4use super::responses::{input::Input, response::ResponseOutputItem};
5use crate::Rest;
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
9#[serde(rename_all = "snake_case")]
10#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
11#[derive(gproxy_protocol_macros::DeclaredFields)]
12#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
13pub struct CompactRequestBody {
14    #[serde(
15        default,
16        deserialize_with = "super::responses::input::present_nullable",
17        skip_serializing_if = "Option::is_none"
18    )]
19    pub prompt_cache_options: Option<Option<super::responses::generate::PromptCacheOptions>>,
20    #[serde(
21        default,
22        deserialize_with = "super::responses::input::present_nullable",
23        skip_serializing_if = "Option::is_none"
24    )]
25    pub prompt_cache_retention: Option<Option<super::responses::generate::PromptCacheRetention>>,
26    #[wire(required)]
27    #[cfg_attr(feature = "schema", schemars(extend("x-gproxy-required" = true)))]
28    #[serde(deserialize_with = "super::responses::input::required_nullable")]
29    pub model: Option<String>,
30    #[serde(
31        default,
32        deserialize_with = "super::responses::input::present_nullable",
33        skip_serializing_if = "Option::is_none"
34    )]
35    pub input: Option<Option<Input>>,
36    #[serde(
37        default,
38        deserialize_with = "super::responses::input::present_nullable",
39        skip_serializing_if = "Option::is_none"
40    )]
41    pub instructions: Option<Option<String>>,
42    #[serde(
43        default,
44        deserialize_with = "super::responses::input::present_nullable",
45        skip_serializing_if = "Option::is_none"
46    )]
47    pub previous_response_id: Option<Option<String>>,
48    #[serde(
49        default,
50        deserialize_with = "super::responses::input::present_nullable",
51        skip_serializing_if = "Option::is_none"
52    )]
53    pub prompt_cache_key: Option<Option<String>>,
54    #[serde(
55        default,
56        deserialize_with = "super::responses::input::present_nullable",
57        skip_serializing_if = "Option::is_none"
58    )]
59    pub service_tier: Option<Option<ServiceTier>>,
60    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
61    pub rest: Rest,
62}
63pub type CompactRequest = crate::WireRequest<CompactRequestBody>;
64#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
65#[serde(rename_all = "snake_case")]
66#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
67#[derive(gproxy_protocol_macros::DeclaredFields)]
68#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
69pub enum ServiceTier {
70    Auto,
71    Default,
72    Fast,
73    Flex,
74    Priority,
75}
76#[derive(
77    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
78)]
79#[serde(rename_all = "snake_case")]
80#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
81#[derive(gproxy_protocol_macros::DeclaredFields)]
82#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
83pub struct CompactResponseBody {
84    pub usage: super::responses::response::ResponseUsage,
85    pub id: String,
86    pub created_at: i64,
87    pub object: CompactObject,
88    pub output: Vec<ResponseOutputItem>,
89    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
90    pub rest: Rest,
91}
92pub type CompactResponse = crate::WireResponse<CompactResponseBody>;
93#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
94#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
95#[derive(gproxy_protocol_macros::DeclaredFields)]
96#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
97pub enum CompactObject {
98    #[serde(rename = "response.compaction")]
99    ResponseCompaction,
100}
101
102/// Codex client compaction request from codex-api CompactionInput. This is
103/// distinct from the public /responses/compact resource schema above.
104#[derive(
105    Debug,
106    Clone,
107    PartialEq,
108    Serialize,
109    Deserialize,
110    gproxy_protocol_macros::WireBuilder,
111    gproxy_protocol_macros::DeclaredFields,
112)]
113#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
114#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
115pub struct ClientCompactRequestBody {
116    pub model: String,
117    pub input: Vec<super::codex::ClientResponseItem>,
118    #[serde(default, skip_serializing_if = "String::is_empty")]
119    pub instructions: String,
120    #[serde(skip_serializing_if = "Option::is_none")]
121    pub tools: Option<serde_json::Value>,
122    pub parallel_tool_calls: bool,
123    #[serde(skip_serializing_if = "Option::is_none")]
124    pub reasoning: Option<super::codex::Reasoning>,
125    #[serde(skip_serializing_if = "Option::is_none")]
126    pub service_tier: Option<String>,
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub prompt_cache_key: Option<String>,
129    #[serde(skip_serializing_if = "Option::is_none")]
130    pub text: Option<super::codex::ClientTextControls>,
131    #[serde(skip_serializing_if = "Option::is_none")]
132    pub access_programs: Option<super::codex::AccessPrograms>,
133    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
134    pub rest: Rest,
135}
136/// The client consumes this complete replacement array verbatim; no invented
137/// usage, timestamp, response ID or foreign ciphertext is required.
138#[derive(
139    Debug,
140    Clone,
141    PartialEq,
142    Serialize,
143    Deserialize,
144    gproxy_protocol_macros::WireBuilder,
145    gproxy_protocol_macros::DeclaredFields,
146)]
147#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
148#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
149pub struct ClientCompactResponseBody {
150    pub output: Vec<super::codex::ClientResponseItem>,
151    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
152    pub rest: Rest,
153}
154pub type ClientCompactRequest = crate::WireRequest<ClientCompactRequestBody>;
155pub type ClientCompactResponse = crate::WireResponse<ClientCompactResponseBody>;