use grok_api::{GrokClient, Result};
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let api_key = std::env::var("GROK_API_KEY").expect("GROK_API_KEY environment variable not set");
let client = GrokClient::new(&api_key)?;
println!("🤖 Grok API — Simple Chat\n");
println!("── Using grok-4.3 (new flagship, recommended default) ──");
let response = client
.chat(
"What is the Rust programming language in two sentences?",
Some("grok-4.3"),
)
.await?;
println!("Response:\n{}\n", response);
println!("── Using grok-4.20-non-reasoning (fast, high-throughput) ──");
let response = client
.chat(
"Name three reasons Rust is memory-safe.",
Some("grok-4.20-non-reasoning"),
)
.await?;
println!("Response:\n{}\n", response);
println!("── Using grok-4.3 for code (replaces retired grok-code-fast-1) ──");
let response = client
.chat(
"Write a one-liner Rust function that returns the factorial of n using recursion.",
Some("grok-4.3"),
)
.await?;
println!("Response:\n{}\n", response);
println!("✨ Done!");
Ok(())
}