pub struct Provider {
pub api: Api,
pub url: String,
pub key: String,
pub model: Model,
pub capability: Capability,
pub fast: String,
pub standard: String,
pub planning: String,
pub temperature: f64,
pub max_tokens: u32,
pub connection_timeout_ms: u64,
pub request_timeout_ms: u64,
}Expand description
AI inference provider configuration
Contains all the settings needed to connect to and interact with an AI inference service. This struct is serializable/deserializable for configuration storage.
Fields§
§api: ApiThe AI service API to use
url: StringBase URL for the API endpoint
Examples:
- Ollama: “http://localhost:11434”
- OpenAI: “https://api.openai.com/v1”
- OpenRouter: “https://openrouter.ai/api/v1”
key: StringAPI key for authentication (empty string for no authentication)
For OpenAI-compatible APIs, this should be a valid API key. For Ollama, this is typically empty.
model: ModelModel performance type to use
capability: CapabilityExpected capability level of the model
fast: StringModel name for fast inference tasks
standard: StringModel name for standard inference tasks
planning: StringModel name for planning/advanced reasoning tasks
temperature: f64Temperature setting for inference (0.0 to 1.0)
Controls randomness:
- Lower values (e.g., 0.2) = more focused and deterministic
- Higher values (e.g., 0.8) = more creative and random
max_tokens: u32Maximum number of tokens to generate in the response
connection_timeout_ms: u64Connection timeout in milliseconds
request_timeout_ms: u64Request timeout in milliseconds
Implementations§
Source§impl Provider
impl Provider
Sourcepub fn model(&self) -> &str
pub fn model(&self) -> &str
Get the actual model name based on the selected model type
Returns the model name string configured for the current performance type.
§Examples
use aimx::inference::provider::{Provider, Api, Model, Capability};
let provider = Provider {
api: Api::Ollama,
url: "http://localhost:11434".to_string(),
key: "".to_string(),
model: Model::Fast,
capability: Capability::Standard,
fast: "mistral:latest".to_string(),
standard: "llama2:latest".to_string(),
planning: "codellama:latest".to_string(),
temperature: 0.7,
max_tokens: 2048,
connection_timeout_ms: 30000,
request_timeout_ms: 120000,
};
assert_eq!(provider.model(), "mistral:latest");