@@ -183,6 +183,18 @@ pub enum ToolChoice {
183183 } ,
184184}
185185
186+ /// Configuration for the compression model.
187+ /// Only relevant for the `agentic` compression model.
188+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
189+ pub struct CompressionConfiguration {
190+ /// Compression rate (0.0-1.0). Defaults to 0.8 when not specified.
191+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
192+ pub rate : Option < f64 > ,
193+ /// Semantic preservation threshold (0-100).
194+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
195+ pub semantic_preservation_threshold : Option < i32 > ,
196+ }
197+
186198/// Input for the chat completion request
187199#[ derive( Debug , Clone , Serialize ) ]
188200pub struct InputObject {
@@ -193,14 +205,16 @@ pub struct InputObject {
193205 pub tool_choice : Option < serde_json:: Value > ,
194206 #[ serde( skip_serializing_if = "Option::is_none" ) ]
195207 pub tags : Option < Vec < String > > ,
196- /// Enable token compression for this request (overrides API key settings if present)
208+ /// Compression model for this request (agentic, claude, opencode, cursor, or customer).
209+ /// Only one compression model per request. Each model is a bundle of strategies.
197210 /// This is a gateway-internal field and is never sent to providers.
198211 #[ serde( default , skip_serializing) ]
199- pub enable_compression : Option < bool > ,
200- /// Compression rate for this request (0.0-1.0, overrides API key settings if present)
212+ pub compression_model : Option < String > ,
213+ /// Configuration for the compression model (rate, semantic preservation threshold).
214+ /// Only relevant for the `agentic` compression model.
201215 /// This is a gateway-internal field and is never sent to providers.
202216 #[ serde( default , skip_serializing) ]
203- pub compression_rate : Option < f64 > ,
217+ pub compression_configuration : Option < CompressionConfiguration > ,
204218}
205219
206220impl InputObject {
@@ -211,8 +225,8 @@ impl InputObject {
211225 tools : None ,
212226 tool_choice : None ,
213227 tags : None ,
214- enable_compression : None ,
215- compression_rate : None ,
228+ compression_model : None ,
229+ compression_configuration : None ,
216230 }
217231 }
218232
@@ -234,15 +248,15 @@ impl InputObject {
234248 self
235249 }
236250
237- /// Enable or disable token compression for this request
238- pub fn with_compression ( mut self , enable : bool ) -> Self {
239- self . enable_compression = Some ( enable ) ;
251+ /// Set the compression model for this request (agentic, claude, opencode, cursor, customer)
252+ pub fn with_compression_model ( mut self , model : impl Into < String > ) -> Self {
253+ self . compression_model = Some ( model . into ( ) ) ;
240254 self
241255 }
242256
243- /// Set compression rate for this request (0.0-1.0 )
244- pub fn with_compression_rate ( mut self , rate : f64 ) -> Self {
245- self . compression_rate = Some ( rate ) ;
257+ /// Set the compression configuration (only relevant for agentic model )
258+ pub fn with_compression_configuration ( mut self , config : CompressionConfiguration ) -> Self {
259+ self . compression_configuration = Some ( config ) ;
246260 self
247261 }
248262}
@@ -424,10 +438,15 @@ mod tests {
424438 #[ test]
425439 fn test_input_object_with_compression_builder ( ) {
426440 let input = InputObject :: new ( vec ! [ Message :: user( "Hello" ) ] )
427- . with_compression ( true )
428- . with_compression_rate ( 0.5 ) ;
429-
430- assert_eq ! ( input. enable_compression, Some ( true ) ) ;
431- assert_eq ! ( input. compression_rate, Some ( 0.5 ) ) ;
441+ . with_compression_model ( "agentic" )
442+ . with_compression_configuration ( CompressionConfiguration {
443+ rate : Some ( 0.5 ) ,
444+ semantic_preservation_threshold : Some ( 60 ) ,
445+ } ) ;
446+
447+ assert_eq ! ( input. compression_model, Some ( "agentic" . to_string( ) ) ) ;
448+ let config = input. compression_configuration . unwrap ( ) ;
449+ assert_eq ! ( config. rate, Some ( 0.5 ) ) ;
450+ assert_eq ! ( config. semantic_preservation_threshold, Some ( 60 ) ) ;
432451 }
433452}
0 commit comments