validate_model

Function validate_model 

Source
pub async fn validate_model(
    provider: &dyn TokenProvider,
    provider_name: &str,
    model_id: &str,
) -> Result<bool>
Expand description

Validates if a model exists for a provider.

This function checks if a specific model identifier is available for a provider, using the cached model registry with automatic caching.

§Arguments

  • provider - Token provider for API credentials
  • provider_name - Name of the provider (e.g., “openrouter”, “gemini”)
  • model_id - Model identifier to validate

§Returns

true if the model exists, false otherwise.

§Errors

Returns an error if:

  • Provider is not found
  • API request fails
  • Response parsing fails