pub struct OpenAiConfig {
pub base_url: String,
pub api_key: Option<String>,
pub auth: AuthStyle,
pub headers: Vec<(String, String)>,
pub query: Vec<(String, String)>,
pub include_usage: bool,
pub use_max_completion_tokens: bool,
pub connect_timeout: Duration,
pub credentials: Option<Arc<dyn CredentialSource>>,
pub credential_name: String,
}Expand description
Configuration of an OpenAI-compatible endpoint.
Fields§
§base_url: StringBase URL without the /chat/completions suffix, e.g. https://api.openai.com/v1.
api_key: Option<String>§auth: AuthStyle§headers: Vec<(String, String)>Extra headers sent with every request.
query: Vec<(String, String)>Extra query parameters (e.g. api-version).
include_usage: boolAsk for a final usage chunk (stream_options.include_usage). Disable for
endpoints that reject the field.
use_max_completion_tokens: boolSend max_completion_tokens instead of max_tokens (required by some newer models).
connect_timeout: Duration§credentials: Option<Arc<dyn CredentialSource>>Per-request credential source. When set it replaces api_key; its headers are
appended and its base_url, if any, overrides base_url. A 401/403 response
invalidates the credential and the request is retried once.
credential_name: StringProvider name passed to the credential source (default openai).
Implementations§
Source§impl OpenAiConfig
impl OpenAiConfig
pub fn new(base_url: impl Into<String>, api_key: Option<String>) -> Self
Sourcepub fn with_credentials(self, source: Arc<dyn CredentialSource>) -> Self
pub fn with_credentials(self, source: Arc<dyn CredentialSource>) -> Self
Ask source for a credential before every request (see crate::credentials).
Sourcepub fn credential_name(self, name: impl Into<String>) -> Self
pub fn credential_name(self, name: impl Into<String>) -> Self
Provider name passed to the credential source.