@@ -64,16 +64,6 @@ impl<C: Config> Client<C> {
6464 self . http_client = http_client;
6565 self
6666 }
67-
68- /// Provide any HTTP client implementing the HttpClient trait
69- /// This allows using middleware-enabled clients for automatic instrumentation
70- pub fn with_http_client_trait < H : HttpClient + ' static > ( self , http_client : H ) -> ClientWithTrait < C > {
71- ClientWithTrait {
72- http_client : std:: sync:: Arc :: new ( http_client) ,
73- config : self . config ,
74- backoff : self . backoff ,
75- }
76- }
7767
7868 /// Exponential backoff for retrying [rate limited](https://platform.openai.com/docs/guides/rate-limits) requests.
7969 pub fn with_backoff ( mut self , backoff : backoff:: ExponentialBackoff ) -> Self {
@@ -575,3 +565,30 @@ where
575565
576566 Box :: pin ( tokio_stream:: wrappers:: UnboundedReceiverStream :: new ( rx) )
577567}
568+
569+
570+ use crate :: http_client:: { BoxedHttpClient , HttpClient } ;
571+ use std:: sync:: Arc ;
572+
573+ /// Client with HttpClient trait support
574+ pub struct ClientWithTrait < C : Config > {
575+ http_client : BoxedHttpClient ,
576+ config : C ,
577+ backoff : backoff:: ExponentialBackoff ,
578+ }
579+
580+ impl < C : Config > ClientWithTrait < C > {
581+ /// Create a new client with a custom HTTP client implementation
582+ pub fn new_with_http_client ( http_client : impl HttpClient + ' static , config : C ) -> Self {
583+ Self {
584+ http_client : Arc :: new ( http_client) ,
585+ config,
586+ backoff : Default :: default ( ) ,
587+ }
588+ }
589+
590+ /// Get the underlying configuration
591+ pub fn config ( & self ) -> & C {
592+ & self . config
593+ }
594+ }
0 commit comments