use origin_asset::{AssetClient, AsyncSubmitOptions, ImageOptions};

#[tokio::main]
async fn main() -> origin_asset::Result<()> {
    let api_key = std::env::var("ORIGIN_API_KEY").expect("set ORIGIN_API_KEY env var");
    let client = AssetClient::new(api_key);

    let ack = client
        .generate_image_async(
            "cinematic sci-fi skyline",
            Some(ImageOptions {
                size: Some("1536x1024".into()),
                ..Default::default()
            }),
            Some(AsyncSubmitOptions {
                idempotency_key: Some("example-image-001".into()),
                async_mode: true,
            }),
        )
        .await?;

    let job = client
        .job_wait_sse(&ack.job_id, |event| {
            println!("{} {}", event.kind, event.status);
        })
        .await?;

    println!("Job output: {:?}", job.output_url);
    Ok(())
}
