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§
Sourcefn info(&self) -> &ModelProviderInfo
fn info(&self) -> &ModelProviderInfo
Returns the configured provider metadata.
Sourcefn auth_manager(&self) -> Option<Arc<AuthManager>>
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.
Sourcefn auth(&self) -> ModelProviderFuture<'_, Option<CodexAuth>>
fn auth(&self) -> ModelProviderFuture<'_, Option<CodexAuth>>
Returns the current provider-scoped auth value, if one is configured.
Sourcefn account_state(&self) -> ProviderAccountResult
fn account_state(&self) -> ProviderAccountResult
Returns the current app-visible account state for this provider.
Sourcefn models_manager(
&self,
codex_home: PathBuf,
config_model_catalog: Option<ModelsResponse>,
) -> SharedModelsManager
fn models_manager( &self, codex_home: PathBuf, config_model_catalog: Option<ModelsResponse>, ) -> SharedModelsManager
Creates the model manager implementation appropriate for this provider.
Provided Methods§
Sourcefn capabilities(&self) -> ProviderCapabilities
fn capabilities(&self) -> ProviderCapabilities
Returns the provider-owned capability upper bounds.
Sourcefn approval_review_preferred_model(&self) -> &'static str
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.
Sourcefn memory_extraction_preferred_model(&self) -> &'static str
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.
Sourcefn memory_consolidation_preferred_model(&self) -> &'static str
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.
Sourcefn supports_attestation(&self) -> bool
fn supports_attestation(&self) -> bool
Returns whether requests made through this provider should include attestation.
Sourcefn map_api_error(&self, error: ApiError) -> CodexErr
fn map_api_error(&self, error: ApiError) -> CodexErr
Maps an API client error into the provider’s user-facing error representation.
Sourcefn api_provider(&self) -> ModelProviderFuture<'_, Result<Provider>>
fn api_provider(&self) -> ModelProviderFuture<'_, Result<Provider>>
Returns provider configuration adapted for the API client.
Sourcefn runtime_base_url(&self) -> ModelProviderFuture<'_, Result<Option<String>>>
fn runtime_base_url(&self) -> ModelProviderFuture<'_, Result<Option<String>>>
Returns the provider base URL that will be used at request time.
Sourcefn api_auth(&self) -> ModelProviderFuture<'_, Result<SharedAuthProvider>>
fn api_auth(&self) -> ModelProviderFuture<'_, Result<SharedAuthProvider>>
Returns the auth provider used to attach request credentials.
Sourcefn api_auth_for_scope(
&self,
scope: ProviderAuthScope,
) -> ModelProviderFuture<'_, Result<ResolvedProviderAuth>>
fn api_auth_for_scope( &self, scope: ProviderAuthScope, ) -> ModelProviderFuture<'_, Result<ResolvedProviderAuth>>
Returns request credentials, optionally scoped to a Codex session task.
Sourcefn models_manager_without_cache(
&self,
config_model_catalog: Option<ModelsResponse>,
) -> SharedModelsManager
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".