pub struct OxiosEngine { /* private fields */ }Expand description
The kernel’s engine — wraps oxi-sdk’s Oxi instance.
Created via OxiosEngine::new() or OxiosEngine::builder().
Provides access to providers, models, routing, pooling, and agent construction.
§RFC-014 Phase D
authorizer / tracer / cost_tracker are optional, engine-level
observability and security handles. When set, they are propagated to
every agent built via OxiosEngine::oxi().agent() using
the new AgentBuilder::authorizer() / .tracer() / .cost_tracker()
API. All three are None by default, keeping the existing call sites
fully backward compatible.
Implementations§
Source§impl OxiosEngine
impl OxiosEngine
Sourcepub fn new(default_model_id: impl Into<String>) -> Self
pub fn new(default_model_id: impl Into<String>) -> Self
Create a new engine with the given default model.
Internally calls OxiBuilder::new().with_builtins() to load all
built-in models and providers.
Sourcepub fn from_config(
default_model_id: impl Into<String>,
config_api_key: Option<&str>,
) -> Self
pub fn from_config( default_model_id: impl Into<String>, config_api_key: Option<&str>, ) -> Self
Create a new engine with credentials from config.
Resolves API keys from CredentialStore for each known provider and injects them into the OxiBuilder. This enables the engine to create properly authenticated providers.
Resolution order (per provider): env var → config.toml → ~/.oxi/auth.json
Sourcepub fn builder() -> OxiosEngineBuilder
pub fn builder() -> OxiosEngineBuilder
Create an engine builder for advanced configuration.
Use this when you need credential injection, routing, or custom provider registration.
§RFC-014 Phase D
The builder also exposes .with_authorizer() / .with_tracer() /
.with_cost_tracker() for attaching engine-level observability
and security handles. All three are None by default.
§Example
use oxios_kernel::engine::OxiosEngine;
let engine = OxiosEngine::builder()
.default_model("anthropic/claude-sonnet-4-20250514")
.api_key("anthropic", "sk-ant-...")
.build();Sourcepub fn oxi(&self) -> &Oxi
pub fn oxi(&self) -> &Oxi
Get a reference to the underlying Oxi instance.
Use this when you need to pass the engine to oxi-sdk APIs directly
(e.g., AgentBuilder, MessageBus, AgentGroup).
RFC-014 Phase D: get the engine-level Authorizer, if any.
When Some, the authorizer is attached to every Agent built via
Oxi::agent().authorizer(...) in agent_runtime.rs::run_agent().
Sourcepub fn tracer(&self) -> Option<&Arc<Tracer>>
pub fn tracer(&self) -> Option<&Arc<Tracer>>
RFC-014 Phase D: get the engine-level Tracer, if any.
When Some, the tracer is attached to every Agent built via
Oxi::agent().tracer(...) in agent_runtime.rs::run_agent().
Sourcepub fn cost_tracker(&self) -> Option<&Arc<CostTracker>>
pub fn cost_tracker(&self) -> Option<&Arc<CostTracker>>
RFC-014 Phase D: get the engine-level CostTracker, if any.
When Some, the cost tracker is attached to every Agent built via
Oxi::agent().cost_tracker(...) in agent_runtime.rs::run_agent().
Sourcepub fn resolve_model(&self, model_id: &str) -> Result<Model>
pub fn resolve_model(&self, model_id: &str) -> Result<Model>
Resolve a model ID to a Model.
Sourcepub fn create_provider(&self, name: &str) -> Result<Arc<dyn Provider>>
pub fn create_provider(&self, name: &str) -> Result<Arc<dyn Provider>>
Create a provider for the given provider name.
Sourcepub fn default_model_id(&self) -> &str
pub fn default_model_id(&self) -> &str
Get the default model ID.
Sourcepub fn routing_control(&self) -> Option<&RoutingControl>
pub fn routing_control(&self) -> Option<&RoutingControl>
Get the routing control, if routing is enabled.
Sourcepub fn pooled_provider(&self, name: &str, rpm: u32) -> Result<Arc<dyn Provider>>
pub fn pooled_provider(&self, name: &str, rpm: u32) -> Result<Arc<dyn Provider>>
Get a rate-limited provider from the pool.
On first call for a provider name, creates a ProviderPool wrapping
the base provider with the given RPM/concurrency limits.
Subsequent calls return the same pooled instance.
If no rate limit is needed, returns the base provider directly.