Struct openai_req::OpenAiClient
source · pub struct OpenAiClient { /* private fields */ }
Expand description
This is main client structure required for all requests.
It is passed as a reference parameter into all API operations.
It is also holds actual reqwest::Client
http client, that performs requests.
Usage example
use openai_req::OpenAiClient;
let client = OpenAiClient::new("{YOUR_API_KEY}");
Implementations§
source§impl OpenAiClient
impl OpenAiClient
sourcepub fn new(key: &str) -> Self
pub fn new(key: &str) -> Self
simplest constructor, uses default https://api.openai.com/v1 url, and creates new default client with connection pool for connections
sourcepub fn with_client(key: &str, client: &Client) -> Self
pub fn with_client(key: &str, client: &Client) -> Self
reqwest library recommends re-using single client, so if you run access to multiple api-s, pass client into constructor. Also use this constructor if you want to customize your client (for example set different timeout, or use proxy)
sourcepub fn with_url(key: &str, url: &str) -> Self
pub fn with_url(key: &str, url: &str) -> Self
if you want to change base url from https://api.openai.com/v1 to something else - you can
sourcepub fn with_url_and_client(key: &str, url: &str, client: &Client) -> Self
pub fn with_url_and_client(key: &str, url: &str, client: &Client) -> Self
this constructor allows you to customise everything: client, key and base url for all requests
Trait Implementations§
source§impl Clone for OpenAiClient
impl Clone for OpenAiClient
source§fn clone(&self) -> OpenAiClient
fn clone(&self) -> OpenAiClient
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more