Skip to main content

ModelProvider

Trait ModelProvider 

Source
pub trait ModelProvider:
    Debug
    + Send
    + Sync {
Show 16 methods // Required methods fn info(&self) -> &ModelProviderInfo; fn auth_manager(&self) -> Option<Arc<AuthManager>>; fn auth(&self) -> ModelProviderFuture<'_, Option<CodexAuth>>; fn account_state(&self) -> ProviderAccountResult; fn models_manager( &self, codex_home: PathBuf, config_model_catalog: Option<ModelsResponse>, ) -> SharedModelsManager; // Provided methods fn capabilities(&self) -> ProviderCapabilities { ... } fn approval_review_preferred_model(&self) -> &'static str { ... } fn memory_extraction_preferred_model(&self) -> &'static str { ... } fn memory_consolidation_preferred_model(&self) -> &'static str { ... } fn supports_attestation(&self) -> bool { ... } fn map_api_error(&self, error: ApiError) -> CodexErr { ... } fn api_provider(&self) -> ModelProviderFuture<'_, Result<Provider>> { ... } fn runtime_base_url( &self, ) -> ModelProviderFuture<'_, Result<Option<String>>> { ... } fn api_auth(&self) -> ModelProviderFuture<'_, Result<SharedAuthProvider>> { ... } fn api_auth_for_scope( &self, scope: ProviderAuthScope, ) -> ModelProviderFuture<'_, Result<ResolvedProviderAuth>> { ... } fn models_manager_without_cache( &self, config_model_catalog: Option<ModelsResponse>, ) -> SharedModelsManager { ... }
}
Expand description

Runtime provider abstraction used by model execution.

Implementations own provider-specific behavior for a model backend. The ModelProviderInfo returned by info is the serialized/configured provider metadata used by the default OpenAI-compatible implementation.

Required Methods§

Source

fn info(&self) -> &ModelProviderInfo

Returns the configured provider metadata.

Source

fn auth_manager(&self) -> Option<Arc<AuthManager>>

Returns the provider-scoped auth manager, when this provider uses one.

TODO(celia-oai): Make auth manager access internal to this crate so callers resolve provider-specific auth only through ModelProvider. We first need to think through whether Codex should have a unified provider-specific auth manager throughout the codebase; that is a larger refactor than this change.

Source

fn auth(&self) -> ModelProviderFuture<'_, Option<CodexAuth>>

Returns the current provider-scoped auth value, if one is configured.

Source

fn account_state(&self) -> ProviderAccountResult

Returns the current app-visible account state for this provider.

Source

fn models_manager( &self, codex_home: PathBuf, config_model_catalog: Option<ModelsResponse>, ) -> SharedModelsManager

Creates the model manager implementation appropriate for this provider.

Provided Methods§

Source

fn capabilities(&self) -> ProviderCapabilities

Returns the provider-owned capability upper bounds.

Source

fn approval_review_preferred_model(&self) -> &'static str

Returns the preferred model used for automatic approval review.

Providers that require backend-specific model IDs should override this.

Source

fn memory_extraction_preferred_model(&self) -> &'static str

Returns the preferred model used for memory extraction.

Providers that require backend-specific model IDs should override this.

Source

fn memory_consolidation_preferred_model(&self) -> &'static str

Returns the preferred model used for memory consolidation.

Providers that require backend-specific model IDs should override this.

Source

fn supports_attestation(&self) -> bool

Returns whether requests made through this provider should include attestation.

Source

fn map_api_error(&self, error: ApiError) -> CodexErr

Maps an API client error into the provider’s user-facing error representation.

Source

fn api_provider(&self) -> ModelProviderFuture<'_, Result<Provider>>

Returns provider configuration adapted for the API client.

Source

fn runtime_base_url(&self) -> ModelProviderFuture<'_, Result<Option<String>>>

Returns the provider base URL that will be used at request time.

Source

fn api_auth(&self) -> ModelProviderFuture<'_, Result<SharedAuthProvider>>

Returns the auth provider used to attach request credentials.

Source

fn api_auth_for_scope( &self, scope: ProviderAuthScope, ) -> ModelProviderFuture<'_, Result<ResolvedProviderAuth>>

Returns request credentials, optionally scoped to a Codex session task.

Source

fn models_manager_without_cache( &self, config_model_catalog: Option<ModelsResponse>, ) -> SharedModelsManager

Creates a model manager with caching disabled.

Providers that fetch model catalogs should override this method. The default uses an authoritative in-memory catalog so hosted callers cannot accidentally write to disk.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§