| Crates.io | aidale-provider |
| lib.rs | aidale-provider |
| version | 0.1.0 |
| created_at | 2025-11-01 04:13:55.702239+00 |
| updated_at | 2025-11-01 04:13:55.702239+00 |
| description | AI provider implementations for Aidale (OpenAI, Anthropic, etc.) |
| homepage | https://github.com/hanxuanliang/aidale |
| repository | https://github.com/hanxuanliang/aidale |
| max_upload_size | |
| id | 1911678 |
| size | 84,086 |
AI provider implementations for Aidale (OpenAI, DeepSeek, etc.).
aidale-provider contains concrete implementations of the Provider trait from aidale-core:
use aidale_provider::OpenAiProvider;
// Default OpenAI API
let provider = OpenAiProvider::new("your-api-key");
// Custom base URL (for compatible APIs)
let provider = OpenAiProvider::builder()
.api_key("your-api-key")
.api_base("https://api.custom.com/v1")
.build_with_id("custom", "Custom API")?;
use aidale_provider::deepseek;
// One-liner setup with automatic configuration
let provider = deepseek("your-api-key")?;
The deepseek() helper automatically configures:
https://api.deepseek.com/v1deepseekDeepSeektokio and reqwestVia the main aidale crate:
[dependencies]
aidale = { version = "0.1", features = ["openai"] }
Directly:
[dependencies]
aidale-provider = "0.1"
aidale-core = "0.1"
use aidale_core::Provider;
use aidale_provider::OpenAiProvider;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let provider = OpenAiProvider::new("sk-...");
let params = ChatCompletionParams {
messages: vec![
Message::system("You are a helpful assistant."),
Message::user("Hello!"),
],
..Default::default()
};
let response = provider
.chat_completion("gpt-3.5-turbo", params)
.await?;
println!("{}", response.choices[0].message.content);
Ok(())
}
use futures::StreamExt;
let mut stream = provider
.stream_chat_completion("gpt-3.5-turbo", params)
.await?;
while let Some(chunk) = stream.next().await {
let chunk = chunk?;
if let Some(content) = chunk.choices[0].delta.content {
print!("{}", content);
}
}
Implement the Provider trait from aidale-core:
use aidale_core::{Provider, ChatCompletionParams, ChatCompletionResponse};
use async_trait::async_trait;
pub struct MyCustomProvider {
// Your fields
}
#[async_trait]
impl Provider for MyCustomProvider {
fn id(&self) -> &str { "custom" }
fn name(&self) -> &str { "My Custom Provider" }
async fn chat_completion(
&self,
model: &str,
params: ChatCompletionParams,
) -> Result<ChatCompletionResponse> {
// Your implementation
}
// ... other methods
}
aidale-core - Core traits and runtimeaidale-layer - Middleware layersaidale-plugin - Plugin systemMIT OR Apache-2.0