Skip to main content

query_stream_with_content

Function query_stream_with_content 

Source
pub async fn query_stream_with_content(
    prompt: &str,
    content: Vec<UserContent>,
) -> impl Stream<Item = Result<Message>>
Expand description

Run a one-shot query with structured content, yielding messages as a stream as they arrive.

Each message is forwarded to the caller immediately via an internal channel, providing true streaming backpressure rather than buffering the full response.

Equivalent to query_stream but accepts a Vec<UserContent> for mixed text/image inputs.

§Errors

Any connection or streaming error is emitted as the first Err item in the returned stream.

§Example

use gemini_cli_sdk::{UserContent, query_stream_with_content};
use tokio_stream::StreamExt as _;

#[tokio::main]
async fn main() -> gemini_cli_sdk::Result<()> {
    let content = vec![UserContent::text("Hello!")];
    let stream = query_stream_with_content("Hello!", content).await;
    tokio::pin!(stream);
    while let Some(item) = stream.next().await {
        println!("{:?}", item?);
    }
    Ok(())
}