pub async fn query(prompt: &str) -> Result<Vec<Message>>Expand description
Run a one-shot query with a plain-text prompt, collecting all messages.
Creates a temporary Client with default configuration, connects it,
sends the prompt, collects the full response into a Vec, and closes
the session. Equivalent to calling query_with_content with a single
UserContent::text block.
§Errors
Propagates all errors from Client::new, Client::connect,
Client::send, and Client::close.
§Example
#[tokio::main]
async fn main() -> gemini_cli_sdk::Result<()> {
let msgs = gemini_cli_sdk::query("What is 2+2?").await?;
for m in msgs {
if let Some(t) = m.assistant_text() {
println!("{t}");
}
}
Ok(())
}