pub struct ModelClient { /* private fields */ }Expand description
A session-scoped client for model-provider API calls.
This holds configuration and state that should be shared across turns within a Codex session (auth, provider selection, thread id, and transport fallback state).
WebSocket fallback is session-scoped: once a turn activates the HTTP fallback, subsequent turns will also use HTTP for the remainder of the session.
Turn-scoped settings (model selection, reasoning controls, telemetry context, and turn metadata) are passed explicitly to the relevant methods to keep turn lifetime visible at the call site.
Implementations§
Source§impl ModelClient
impl ModelClient
Sourcepub fn new(
auth_manager: Option<Arc<AuthManager>>,
agent_identity_policy: AgentIdentityAuthPolicy,
thread_id: ThreadId,
provider_info: ModelProviderInfo,
session_source: SessionSource,
originator: String,
model_verbosity: Option<VerbosityConfig>,
enable_request_compression: bool,
include_timing_metrics: bool,
beta_features_header: Option<String>,
concurrent_reasoning_summaries_enabled: bool,
attestation_provider: Option<Arc<dyn AttestationProvider>>,
http_client_factory: HttpClientFactory,
) -> Self
pub fn new( auth_manager: Option<Arc<AuthManager>>, agent_identity_policy: AgentIdentityAuthPolicy, thread_id: ThreadId, provider_info: ModelProviderInfo, session_source: SessionSource, originator: String, model_verbosity: Option<VerbosityConfig>, enable_request_compression: bool, include_timing_metrics: bool, beta_features_header: Option<String>, concurrent_reasoning_summaries_enabled: bool, attestation_provider: Option<Arc<dyn AttestationProvider>>, http_client_factory: HttpClientFactory, ) -> Self
Creates a new session-scoped ModelClient.
All arguments are expected to be stable for the lifetime of a Codex session. Per-turn values
are passed to ModelClientSession::stream (and other turn-scoped methods) explicitly. The
HTTP client factory must come from the effective session configuration so every transport
observes the resolved outbound proxy policy.
Sourcepub fn new_session(&self) -> ModelClientSession
pub fn new_session(&self) -> ModelClientSession
Creates a fresh turn-scoped streaming session.
This constructor does not perform network I/O itself; the session opens a websocket lazily when the first stream request is issued.
Sourcepub async fn summarize_memories(
&self,
raw_memories: Vec<ApiRawMemory>,
model_info: &ModelInfo,
effort: Option<ReasoningEffortConfig>,
session_telemetry: &SessionTelemetry,
) -> Result<Vec<ApiMemorySummarizeOutput>>
pub async fn summarize_memories( &self, raw_memories: Vec<ApiRawMemory>, model_info: &ModelInfo, effort: Option<ReasoningEffortConfig>, session_telemetry: &SessionTelemetry, ) -> Result<Vec<ApiMemorySummarizeOutput>>
Builds memory summaries for each provided normalized raw memory.
This is a unary call (no streaming) to /v1/memories/trace_summarize.
The model selection, reasoning effort, and telemetry context are passed explicitly to keep
ModelClient session-scoped.
Sourcepub fn responses_websocket_enabled(&self) -> bool
pub fn responses_websocket_enabled(&self) -> bool
Returns whether the Responses-over-WebSocket transport is active for this session.
WebSocket use is controlled by provider capability and session-scoped fallback state.
Trait Implementations§
Source§impl Clone for ModelClient
impl Clone for ModelClient
Source§fn clone(&self) -> ModelClient
fn clone(&self) -> ModelClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ModelClient
impl !UnwindSafe for ModelClient
impl Freeze for ModelClient
impl Send for ModelClient
impl Sync for ModelClient
impl Unpin for ModelClient
impl UnsafeUnpin for ModelClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<T> AsTypeStaticRegistered for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
impl<T> HasTyVTable for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request