Skip to main content

openresponses_rust/
lib.rs

1//! # Open Responses
2//!
3//! A Rust client library for the Open Responses API specification.
4//!
5//! Open Responses is an open-source specification for building multi-provider,
6//! interoperable LLM interfaces based on the OpenAI Responses API.
7//!
8//! ## Quick Start
9//!
10//! ```rust,no_run
11//! use openresponses_rust::{Client, CreateResponseBody, Input, Item};
12//!
13//! #[tokio::main]
14//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
15//!     let client = Client::new("your-api-key");
16//!     
17//!     let request = CreateResponseBody {
18//!         model: Some("gpt-4o".to_string()),
19//!         input: Some(Input::Items(vec![
20//!             Item::user_message("Hello, how are you?")
21//!         ])),
22//!         ..Default::default()
23//!     };
24//!     
25//!     let response = client.create_response(request).await?;
26//!     println!("Response: {:?}", response);
27//!     
28//!     Ok(())
29//! }
30//! ```
31
32pub mod client;
33pub mod streaming;
34pub mod types;
35
36pub use client::{Client, ClientError};
37pub use streaming::{StreamingClient, StreamingError};
38pub use types::*;
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_item_creation() {
46        let item = Item::user_message("Hello");
47        assert!(matches!(item, Item::Message { .. }));
48    }
49}