groqai 0.1.9

A modern, type-safe Rust SDK for the Groq AI API with enterprise-grade features
Documentation
// examples/batch_processing.rs
// Batch processing example

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()?;
    
    // Create a batch job
    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);
            
            // Check batch status
            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),
    }
    
    // List batches
    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(())
}