codex-cli-sdk 0.0.1

Rust SDK for the OpenAI Codex CLI
Documentation
//! Basic one-shot query.
//!
//! Sends a prompt and collects the full response into a `Turn`.
//! Prints the final response text and token usage.
//!
//! ```bash
//! cargo run --example 01_basic_query
//! ```

use codex_cli_sdk::{Codex, CodexConfig, ThreadOptions};

#[tokio::main]
async fn main() -> codex_cli_sdk::Result<()> {
    let codex = Codex::new(CodexConfig::default())?;
    let mut thread = codex.start_thread(ThreadOptions::builder().model("o4-mini").build());

    let turn = thread
        .run(
            "What files are in the current directory?",
            Default::default(),
        )
        .await?;

    println!("Response:\n{}", turn.final_response);

    if let Some(usage) = turn.usage {
        println!(
            "\nTokens: {} in / {} out",
            usage.input_tokens, usage.output_tokens
        );
    }

    Ok(())
}