Skip to main content

openai_oxide/
lib.rs

1//! # openai-oxide
2//!
3//! Idiomatic Rust client for the OpenAI API — 1:1 parity with the official Python SDK.
4//!
5//! ## Quick Start
6//!
7//! ```no_run
8//! use openai_oxide::{OpenAI, types::chat::*};
9//!
10//! #[tokio::main]
11//! async fn main() -> Result<(), openai_oxide::OpenAIError> {
12//!     let client = OpenAI::from_env()?;
13//!
14//!     let request = ChatCompletionRequest::new(
15//!         "gpt-4o-mini",
16//!         vec![
17//!             ChatCompletionMessageParam::System {
18//!                 content: "You are a helpful assistant.".into(),
19//!                 name: None,
20//!             },
21//!             ChatCompletionMessageParam::User {
22//!                 content: UserContent::Text("Hello!".into()),
23//!                 name: None,
24//!             },
25//!         ],
26//!     );
27//!
28//!     let response = client.chat().completions().create(request).await?;
29//!     println!("{}", response.choices[0].message.content.as_deref().unwrap_or(""));
30//!     Ok(())
31//! }
32//! ```
33
34pub mod client;
35pub mod config;
36pub mod error;
37pub mod resources;
38pub mod streaming;
39pub mod types;
40
41pub use client::OpenAI;
42pub use config::ClientConfig;
43pub use error::OpenAIError;
44pub use streaming::SseStream;