pub struct ClientBuilder { /* private fields */ }Expand description
Client 的构建器。
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn http_client(self, client: Client) -> Self
pub fn http_client(self, client: Client) -> Self
注入一个自定义 reqwest::Client。
Sourcepub fn api_key_provider<F>(self, provider: F) -> Self
pub fn api_key_provider<F>(self, provider: F) -> Self
设置动态 API Key 回调。
Sourcepub fn api_key_async_provider<F, Fut>(self, provider: F) -> Self
pub fn api_key_async_provider<F, Fut>(self, provider: F) -> Self
设置异步 API Key 回调。
Sourcepub fn disable_proxy_for_local_base_url(self, disable: bool) -> Self
pub fn disable_proxy_for_local_base_url(self, disable: bool) -> Self
控制当 base_url 指向本机地址时,是否显式关闭系统代理。
该开关默认关闭。
Sourcepub fn azure_endpoint<T>(self, endpoint: T) -> Self
pub fn azure_endpoint<T>(self, endpoint: T) -> Self
设置 Azure 资源级 endpoint。
该值应类似 https://example-resource.openai.azure.com,
SDK 会在发送请求时自动补上 /openai。
Sourcepub fn azure_api_version<T>(self, api_version: T) -> Self
pub fn azure_api_version<T>(self, api_version: T) -> Self
设置 Azure api-version。
Sourcepub fn azure_deployment<T>(self, deployment: T) -> Self
pub fn azure_deployment<T>(self, deployment: T) -> Self
设置 Azure 默认 deployment。
Sourcepub fn azure_bearer_auth(self) -> Self
pub fn azure_bearer_auth(self) -> Self
切换 Azure 为 Bearer Token 认证。
Sourcepub fn azure_ad_token<T>(self, token: T) -> Self
pub fn azure_ad_token<T>(self, token: T) -> Self
设置 Azure AD Bearer Token。
Sourcepub fn azure_ad_token_provider<F, Fut>(self, provider: F) -> Self
pub fn azure_ad_token_provider<F, Fut>(self, provider: F) -> Self
设置 Azure AD Bearer Token 异步提供器。
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
覆盖默认最大重试次数。
Sourcepub fn default_header<T, U>(self, key: T, value: U) -> Self
pub fn default_header<T, U>(self, key: T, value: U) -> Self
添加默认请求头。
Sourcepub fn default_headers(self, headers: BTreeMap<String, String>) -> Self
pub fn default_headers(self, headers: BTreeMap<String, String>) -> Self
批量设置默认请求头。
Sourcepub fn default_query<T, U>(self, key: T, value: U) -> Self
pub fn default_query<T, U>(self, key: T, value: U) -> Self
添加默认查询参数。
Sourcepub fn default_query_map(self, query: BTreeMap<String, String>) -> Self
pub fn default_query_map(self, query: BTreeMap<String, String>) -> Self
批量设置默认查询参数。
Sourcepub fn webhook_secret<T>(self, secret: T) -> Self
pub fn webhook_secret<T>(self, secret: T) -> Self
设置 Webhook 密钥。
Sourcepub fn compatibility_mode(self, mode: CompatibilityMode) -> Self
pub fn compatibility_mode(self, mode: CompatibilityMode) -> Self
设置兼容性模式。
Trait Implementations§
Source§impl Clone for ClientBuilder
impl Clone for ClientBuilder
Source§fn clone(&self) -> ClientBuilder
fn clone(&self) -> ClientBuilder
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 ClientBuilder
impl Debug for ClientBuilder
Source§impl Default for ClientBuilder
impl Default for ClientBuilder
Source§fn default() -> ClientBuilder
fn default() -> ClientBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ClientBuilder
impl !RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnsafeUnpin for ClientBuilder
impl !UnwindSafe for ClientBuilder
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