use groqai::{GroqClientBuilder, BatchCreateRequest};
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = env::var("GROQ_API_KEY").expect("GROQ_API_KEY must be set");
let client = GroqClientBuilder::new(api_key)?.build()?;
let request = BatchCreateRequest {
input_file_id: "file_abc123".to_string(),
endpoint: "/chat/completions".to_string(),
completion_window: "24h".to_string(),
metadata: None,
};
match client.batches().create(request).await {
Ok(batch) => {
println!("Batch created: {}", batch.id);
match client.batches().retrieve(batch.id.clone()).await {
Ok(batch_status) => println!("Status: {}", batch_status.status),
Err(e) => println!("Failed to get batch status: {}", e),
}
}
Err(e) => println!("Failed to create batch: {}", e),
}
match client.batches().list(None, Some(10)).await {
Ok(batches) => {
println!("Found {} batches", batches.data.len());
for batch in batches.data {
println!("Batch {}: {}", batch.id, batch.status);
}
}
Err(e) => println!("Failed to list batches: {}", e),
}
Ok(())
}