ApiClientConstructors

Trait ApiClientConstructors 

Source
pub trait ApiClientConstructors: Sized {
    // Required method
    fn from_http_client(http_client: HttpClient) -> Self;

    // Provided methods
    fn new<S: Into<String>>(api_key: S) -> Result<Self> { ... }
    fn new_with_base_url<S: Into<String>>(
        api_key: S,
        base_url: S,
    ) -> Result<Self> { ... }
}
Expand description

Common trait for API clients with standard constructors

Required Methods§

Source

fn from_http_client(http_client: HttpClient) -> Self

Create a new instance with the HTTP client

Provided Methods§

Source

fn new<S: Into<String>>(api_key: S) -> Result<Self>

Creates a new API client

§Arguments
  • api_key - Your OpenAI API key
§Errors

Returns an error if the API key is empty or invalid

Source

fn new_with_base_url<S: Into<String>>(api_key: S, base_url: S) -> Result<Self>

Creates a new API client with custom base URL

§Arguments
  • api_key - Your OpenAI API key
  • base_url - Custom base URL for the API
§Errors

Returns an error if the API key is empty or invalid

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§