1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! # OpenAI4RS: An Asynchronous Rust Client for OpenAI-Compatible APIs
//!
//! `openai4rs` is an unofficial Rust crate designed for seamless interaction with
//! OpenAI-compatible APIs, offering a robust and fluent asynchronous experience.
//!
//! This library is built with ease of use, thread safety, and high configurability in mind,
//! making it suitable for a wide range of applications from simple scripts to complex,
//! high-performance services.
//!
//! ## Key Features
//!
//! - **Async-First**: Built on `tokio` and `reqwest` for non-blocking I/O operations.
//! - **Chat Completions**: Full support for the Chat Completions API, including streaming and tool calling.
//! - **Legacy Completions**: Support for legacy text completion models.
//! - **Model Management**: List and retrieve information about available models.
//! - **Configurable HTTP Client**: Customize timeouts, retries, proxies, and user agents.
//! - **Thread Safety**: The client can be safely shared across multiple threads.
//! - **Reasoning Support**: Special support for reasoning-based models.
//!
//! ## Quick Start
//!
//! First, add `openai4rs` to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! openai4rs = "0.1.8"
//! tokio = { version = "1", features = ["full"] }
//! dotenvy = "0.15"
//! ```
//!
//! Then, configure the client using environment variables and make your first API call.
//!
//! ```rust
//! use openai4rs::*;
//! use dotenvy::dotenv;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Load .env file
//! dotenv().ok();
//!
//! // Create client from environment variables
//! let client = OpenAI::from_env()?;
//!
//! // Create a chat request
//! let messages = vec![user!("What is the capital of France?")];
//! let request = chat_request("Qwen/Qwen3-235B-A22B-Instruct-2507", &messages);
//!
//! // Get the response
//! let response = client.chat().create(request).await?;
//! println!("Response: {:#?}", response);
//!
//! Ok(())
//! }
//! ```
//!
//! For more examples and detailed usage, refer to the documentation of each module.
/// API modules for different OpenAI functionality.
/// Contains chat, completions, and models modules for interacting with various API endpoints.
/// Core client implementation and entry point for the OpenAI API.
/// Provides the main OpenAI struct for interacting with OpenAI-compatible APIs.
/// Configuration for the OpenAI client.
/// Handles API keys, base URLs, timeouts, and other client settings.
/// Common types and utilities shared within the library.
/// Contains shared data structures and utility functions used across modules.
/// Error handling and custom error types.
/// Defines the error hierarchy and error handling utilities for the library.
/// Interceptor functionality for modifying requests and responses.
/// Allows middleware-style processing of API requests and responses.
/// HTTP service layer with retry logic, error handling, and flexible request processing.
///
/// This module provides a robust HTTP transport layer for making requests to OpenAI-compatible APIs.
/// It features configurable timeouts, proxy support, automatic retry logic with exponential backoff,
/// and support for both regular JSON responses and streaming Server-Sent Events (SSE).
///
/// The service module includes components for request execution, transport handling, and response processing.
/// Utility functions and traits.
/// Contains helper functions and common traits used throughout the library.
// Re-export core types and functions
pub use OpenAI;
pub use ;
pub use OpenAIError;
pub use *;
pub use *;
pub use serde_json;
pub use ;
pub use Apply;
// Import and re-export the new procedural macros
pub use *;