basic_usage/
basic_usage.rs1use gpt5::{Gpt5Client, Gpt5Model};
7
8#[tokio::main]
9async fn main() -> Result<(), Box<dyn std::error::Error>> {
10 let api_key =
12 std::env::var("OPENAI_API_KEY").expect("Please set OPENAI_API_KEY environment variable");
13
14 let client = Gpt5Client::new(api_key);
15
16 println!("š¤ Asking GPT-5 Nano a simple question...");
18 let response = client
19 .simple(Gpt5Model::Gpt5Nano, "What is the capital of France?")
20 .await?;
21
22 println!("Response: {}", response);
23
24 println!("\nš¤ Asking GPT-5 Mini...");
26 let response = client
27 .simple(
28 Gpt5Model::Gpt5Mini,
29 "Explain quantum computing in simple terms",
30 )
31 .await?;
32
33 println!("Response: {}", response);
34
35 println!("\nš¤ Asking GPT-5 (main model)...");
37 let response = client
38 .simple(Gpt5Model::Gpt5, "Write a short poem about coding")
39 .await?;
40
41 println!("Response: {}", response);
42
43 Ok(())
44}