OpenAI Provider for AIX
This crate provides an OpenAI provider implementation for the AIX library, supporting both regular and streaming chat completions.
Example
use ;
use ;
async
OpenAI Provider for AIX
This crate provides an OpenAI provider implementation for the AIX library, supporting both regular and streaming chat completions.
use aix_openai::{OpenAiConfig, OpenAiProvider};
use aix_core::{AiProvider, ChatRequest, ChatMessage};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = OpenAiConfig::new(std::env::var("OPENAI_API_KEY")?);
let provider = OpenAiProvider::new(config)?;
let request = ChatRequest::simple("gpt-4", "Hello, world!");
let response = provider.chat(request).await?;
println!("Response: {}", response.content);
Ok(())
}