pub struct EngineApi { /* private fields */ }Expand description
Engine API facade — model catalog introspection + config writes + routing.
Holds a shared reference to the live config (behind RwLock) and the
path to config.toml so write operations can persist to disk.
Routing stats are shared with AgentRuntime via Arc<RoutingStats>.
When config writes change the model or API key, EngineApi rebuilds
OxiosEngine via [EngineHandle] so the runtime picks up the change
on the next agent execution (hot-swap, no restart required).
Implementations§
Source§impl EngineApi
impl EngineApi
Sourcepub fn new(
config: Arc<RwLock<OxiosConfig>>,
config_path: PathBuf,
routing_stats: Arc<RoutingStats>,
engine_handle: Arc<EngineHandle>,
) -> Self
pub fn new( config: Arc<RwLock<OxiosConfig>>, config_path: PathBuf, routing_stats: Arc<RoutingStats>, engine_handle: Arc<EngineHandle>, ) -> Self
Create a new EngineApi.
config— shared config store (backed by RwLock)config_path— path to config.toml for persistencerouting_stats— shared stats tracker (shared with AgentRuntime)engine_handle— hot-swap handle for live engine replacement
Sourcepub fn routing_stats(&self) -> Arc<RoutingStats> ⓘ
pub fn routing_stats(&self) -> Arc<RoutingStats> ⓘ
Get the shared RoutingStats reference (for AgentRuntime wiring).
Sourcepub fn engine_handle(&self) -> &Arc<EngineHandle> ⓘ
pub fn engine_handle(&self) -> &Arc<EngineHandle> ⓘ
Get a reference to the engine handle.
Sourcepub fn providers(&self) -> Vec<ProviderInfo>
pub fn providers(&self) -> Vec<ProviderInfo>
List all available providers from the oxi-sdk catalog.
Filters out hidden/internal providers (those flagged with
hidden: true in [PROVIDER_META]) and augments each entry
with credential status, display name, and description.
Providers without a [PROVIDER_META] entry are shown by
default — a new provider landing in oxi-sdk should be
available to users even before its metadata is added here.
Sourcepub fn models(&self, provider: &str, query: Option<&str>) -> Vec<ModelInfo>
pub fn models(&self, provider: &str, query: Option<&str>) -> Vec<ModelInfo>
List models for a given provider, optionally filtered by a query.
Sourcepub fn search_models(&self, query: &str) -> Vec<ModelInfo>
pub fn search_models(&self, query: &str) -> Vec<ModelInfo>
Search models across all providers.
Sourcepub fn config(&self) -> EngineConfigResponse
pub fn config(&self) -> EngineConfigResponse
Get the current engine configuration + credential status + routing.
Sourcepub fn routing_stats_snapshot(&self) -> RoutingStatsSnapshot
pub fn routing_stats_snapshot(&self) -> RoutingStatsSnapshot
Get routing stats snapshot (for Web dashboard).
Sourcepub fn fallback_history(&self, limit: usize) -> Vec<FallbackEvent>
pub fn fallback_history(&self, limit: usize) -> Vec<FallbackEvent>
Get recent fallback history.
Sourcepub fn set_model(&self, model_id: &str) -> Result<()>
pub fn set_model(&self, model_id: &str) -> Result<()>
Set the default model in config.toml.
Updates both the in-memory config and the on-disk file, then hot-swaps the runtime engine so the next agent execution uses the new model.
Sourcepub fn set_api_key(&self, provider: &str, key: &str) -> Result<()>
pub fn set_api_key(&self, provider: &str, key: &str) -> Result<()>
Set an API key for a provider.
Stores the key via CredentialStore (→ ~/.oxi/auth.json) and also
updates config.toml’s [engine].api_key when the provider matches
the current default model. Hot-swaps the runtime engine afterward.
Sourcepub fn set_provider_options(&self, opts: &ProviderOptions) -> Result<()>
pub fn set_provider_options(&self, opts: &ProviderOptions) -> Result<()>
Update provider options in config.toml.
Persists the options and makes them available for the next agent run.
They are passed through to AgentLoopConfig::provider_options.
Sourcepub fn set_routing(&self, update: RoutingUpdate) -> Result<()>
pub fn set_routing(&self, update: RoutingUpdate) -> Result<()>
Update routing configuration in config.toml.
Only the fields provided in update are changed; others are left untouched.
Changes are persisted to disk immediately.
Sourcepub fn validate_key(&self, provider: &str, api_key: &str) -> ValidateKeyResult
pub fn validate_key(&self, provider: &str, api_key: &str) -> ValidateKeyResult
Validate an API key by making a simple test call.
Creates a lightweight provider and attempts a minimal request. Returns the validation result.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EngineApi
impl !UnwindSafe for EngineApi
impl Freeze for EngineApi
impl Send for EngineApi
impl Sync for EngineApi
impl Unpin for EngineApi
impl UnsafeUnpin for EngineApi
Blanket Implementations§
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreimpl<T> MaybeSendSync for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.