Skip to main content

Module client

Module client 

Source
Expand description

High-level client for spawning and streaming codex executions.

CodexClient is the main entry point. Configure it once, then call exec to start an Execution that reads JSONL events from the codex subprocess.

§Example

let client = CodexClient::new();
let mut execution = client.exec("List files in the current directory", ExecOptions {
    model: Some("o4-mini".into()),
    full_auto: true,
    ..Default::default()
}).await?;

while let Some(event) = execution.next_event().await? {
    if let Event::ItemCompleted { item: Item::AgentMessage { text, .. } } = &event {
        if let Some(text) = text {
            println!("{text}");
        }
    }
}

Structs§

CodexClient
Builder / factory for codex executions.
Execution
A live execution of a codex exec --json subprocess.