pub struct RequestOptions {
pub headers: Option<HeaderMap>,
pub query: Option<Vec<(String, String)>>,
pub extra_body: Option<Value>,
pub timeout: Option<Duration>,
}Expand description
Options that customize individual API requests.
Use with OpenAI::with_options() to create
a client clone that applies these options to every request:
ⓘ
use openai_oxide::RequestOptions;
let custom = client.with_options(
RequestOptions::new()
.header("X-Custom", "value")
.timeout(Duration::from_secs(30))
);
let response = custom.chat().completions().create(request).await?;Fields§
§headers: Option<HeaderMap>Extra headers to include in the request.
query: Option<Vec<(String, String)>>Extra query parameters to append to the URL.
extra_body: Option<Value>Extra JSON fields to merge into the request body (JSON requests only).
timeout: Option<Duration>Override the request timeout.
Implementations§
Source§impl RequestOptions
impl RequestOptions
Sourcepub fn header(self, name: impl AsRef<str>, value: impl AsRef<str>) -> Self
pub fn header(self, name: impl AsRef<str>, value: impl AsRef<str>) -> Self
Add a single header.
Sourcepub fn headers(self, headers: HeaderMap) -> Self
pub fn headers(self, headers: HeaderMap) -> Self
Set multiple headers at once (replaces any previously set headers).
Sourcepub fn query_param(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn query_param( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a single query parameter.
Sourcepub fn query(self, params: Vec<(String, String)>) -> Self
pub fn query(self, params: Vec<(String, String)>) -> Self
Set all query parameters (replaces any previously set).
Sourcepub fn extra_body(self, value: Value) -> Self
pub fn extra_body(self, value: Value) -> Self
Set extra JSON fields to merge into the request body.
Sourcepub fn merge(&self, other: &RequestOptions) -> RequestOptions
pub fn merge(&self, other: &RequestOptions) -> RequestOptions
Merge two options. Values from other take precedence on conflict.
Trait Implementations§
Source§impl Clone for RequestOptions
impl Clone for RequestOptions
Source§fn clone(&self) -> RequestOptions
fn clone(&self) -> RequestOptions
Returns a duplicate 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 moreSource§impl Debug for RequestOptions
impl Debug for RequestOptions
Source§impl Default for RequestOptions
impl Default for RequestOptions
Source§fn default() -> RequestOptions
fn default() -> RequestOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RequestOptions
impl RefUnwindSafe for RequestOptions
impl Send for RequestOptions
impl Sync for RequestOptions
impl Unpin for RequestOptions
impl UnsafeUnpin for RequestOptions
impl UnwindSafe for RequestOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more