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 default model (grok-4-1-fast-reasoning) ──");
let response = client
.chat(
"What is the Rust programming language in two sentences?",
None,
)
.await?;
println!("Response:\n{}\n", response);
println!("── Using grok-4.20-0309-non-reasoning (flagship fast) ──");
let response = client
.chat(
"Name three reasons Rust is memory-safe.",
Some("grok-4.20-0309-non-reasoning"),
)
.await?;
println!("Response:\n{}\n", response);
println!("── Using grok-code-fast-1 (code-optimised) ──");
let response = client
.chat(
"Write a one-liner Rust function that returns the factorial of n using recursion.",
Some("grok-code-fast-1"),
)
.await?;
println!("Response:\n{}\n", response);
println!("✨ Done!");
Ok(())
}