Skip to main content

query_stream_from_stream

Function query_stream_from_stream 

Source
pub async fn query_stream_from_stream<S>(
    prompt: S,
    options: Option<ClaudeAgentOptions>,
    transport: Option<Box<dyn Transport>>,
) -> Result<BoxStream<'static, Result<Message>>>
where S: Stream<Item = Value> + Unpin,
Expand description

Sends a one-off query with streamed input and streamed output.

The returned stream is Send and can be consumed from any tokio task.

ยงExample

use claude_code::query_stream_from_stream;
use futures::{stream, StreamExt};
use serde_json::json;

    let mut output = query_stream_from_stream(
    stream::iter(vec![json!({"type":"user","message":{"role":"user","content":"hello"}})]),
    None,
    None,
    )
    .await?;

    let _ = output.next().await;