pub trait Model: Send + Sync {
// Required method
fn respond<'a>(
&'a self,
request: ModelRequest<'a>,
events: ModelEventSink,
) -> BoxFuture<'a, Result<ModelOutput>>;
// Provided methods
fn info(&self) -> ModelInfo { ... }
fn supports_image_input(&self) -> bool { ... }
fn supports_tool_image_input(&self) -> bool { ... }
fn supports_realtime_voice(&self) -> bool { ... }
fn start_realtime_voice(
&self,
_request: RealtimeVoiceRequest,
) -> BoxFuture<'_, Result<RealtimeVoiceCall>> { ... }
fn prompt_cache_capability(&self) -> PromptCacheMode { ... }
fn tool_discovery(&self) -> ToolDiscoveryMode { ... }
fn pricing(&self) -> Option<ModelPricing> { ... }
fn fallback_transport<'a>(
&'a self,
_session_id: &'a str,
) -> BoxFuture<'a, Result<bool>> { ... }
fn compaction_endpoint(&self) -> bool { ... }
fn compact<'a>(
&'a self,
_request: CompactRequest<'a>,
) -> BoxFuture<'a, Result<CompactOutput>> { ... }
}Expand description
A model provider Adapter used by the agent loop.
Required Methods§
Sourcefn respond<'a>(
&'a self,
request: ModelRequest<'a>,
events: ModelEventSink,
) -> BoxFuture<'a, Result<ModelOutput>>
fn respond<'a>( &'a self, request: ModelRequest<'a>, events: ModelEventSink, ) -> BoxFuture<'a, Result<ModelOutput>>
Produces one streamed response.
Normalize provider wire data into crate::protocol::ModelEvent and
ModelOutput. Emit only immutable, fully validated
crate::protocol::ModelEvent::ToolCallReady calls, in the same order as
the final output; the agent may execute them before stream EOF, so the
final output must agree. Propagate ModelEventSink failures. The returned
future may be dropped on cancellation; implementations own cleanup of any
transport work they launch outside that future.
Provided Methods§
Sourcefn supports_image_input(&self) -> bool
fn supports_image_input(&self) -> bool
Reports whether this provider accepts native image input.
Sourcefn supports_tool_image_input(&self) -> bool
fn supports_tool_image_input(&self) -> bool
Whether images can remain associated with their originating tool call.
Sourcefn supports_realtime_voice(&self) -> bool
fn supports_realtime_voice(&self) -> bool
Reports whether this transport can negotiate a provider-owned realtime voice call.
Sourcefn start_realtime_voice(
&self,
_request: RealtimeVoiceRequest,
) -> BoxFuture<'_, Result<RealtimeVoiceCall>>
fn start_realtime_voice( &self, _request: RealtimeVoiceRequest, ) -> BoxFuture<'_, Result<RealtimeVoiceCall>>
Negotiates voice media without exposing provider credentials to the frontend.
Sourcefn prompt_cache_capability(&self) -> PromptCacheMode
fn prompt_cache_capability(&self) -> PromptCacheMode
Reports the provider’s prompt-cache mode without exposing transport details.
Sourcefn tool_discovery(&self) -> ToolDiscoveryMode
fn tool_discovery(&self) -> ToolDiscoveryMode
Reports how this route makes deferred tool schemas callable.
Sourcefn pricing(&self) -> Option<ModelPricing>
fn pricing(&self) -> Option<ModelPricing>
Returns current token pricing when this provider owns a known billing schedule.
Sourcefn fallback_transport<'a>(
&'a self,
_session_id: &'a str,
) -> BoxFuture<'a, Result<bool>>
fn fallback_transport<'a>( &'a self, _session_id: &'a str, ) -> BoxFuture<'a, Result<bool>>
Switches a session to its fallback transport once, without sending a request.
Called after retry exhaustion only when replaying the model request is safe. Returns whether a new transport was activated; providers without one return false.
Sourcefn compaction_endpoint(&self) -> bool
fn compaction_endpoint(&self) -> bool
Reports whether this provider exposes a native compaction endpoint.
Sourcefn compact<'a>(
&'a self,
_request: CompactRequest<'a>,
) -> BoxFuture<'a, Result<CompactOutput>>
fn compact<'a>( &'a self, _request: CompactRequest<'a>, ) -> BoxFuture<'a, Result<CompactOutput>>
Calls the native history-compaction endpoint when advertised.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".