Skip to main content

query_with_content

Function query_with_content 

Source
pub async fn query_with_content(
    prompt: &str,
    content: Vec<UserContent>,
) -> Result<Vec<Message>>
Expand description

Run a one-shot query with structured content, collecting all messages.

Identical to query but accepts a Vec<UserContent> instead of a plain string, allowing images and mixed content to be sent.

The prompt parameter is used only to construct the ClientConfig; the actual content sent to the session is taken from content.

§Errors

Propagates all errors from Client::new, Client::connect, Client::send_content, and Client::close.

§Example

use gemini_cli_sdk::{UserContent, query_with_content};

#[tokio::main]
async fn main() -> gemini_cli_sdk::Result<()> {
    let content = vec![
        UserContent::text("Describe this image:"),
        UserContent::image_url("https://example.com/img.png"),
    ];
    let msgs = query_with_content("Describe this image:", content).await?;
    println!("{} messages", msgs.len());
    Ok(())
}