pub struct ModelProviderInfo {
pub name: String,
pub base_url: Option<String>,
pub env_key: Option<String>,
pub env_key_instructions: Option<String>,
pub wire_api: WireApi,
pub query_params: Option<HashMap<String, String>>,
pub http_headers: Option<HashMap<String, String>>,
pub env_http_headers: Option<HashMap<String, String>>,
pub request_max_retries: Option<u64>,
pub stream_max_retries: Option<u64>,
pub stream_idle_timeout_ms: Option<u64>,
pub requires_openai_auth: bool,
}Expand description
Serializable representation of a provider definition.
Fields§
§name: StringFriendly display name.
base_url: Option<String>Base URL for the provider’s OpenAI-compatible API.
env_key: Option<String>Environment variable that stores the user’s API key for this provider.
env_key_instructions: Option<String>Optional instructions to help the user get a valid value for the variable and set it.
wire_api: WireApiWhich wire protocol this provider expects.
query_params: Option<HashMap<String, String>>Optional query parameters to append to the base URL.
http_headers: Option<HashMap<String, String>>Additional HTTP headers to include in requests to this provider where the (key, value) pairs are the header name and value.
env_http_headers: Option<HashMap<String, String>>Optional HTTP headers to include in requests to this provider where the (key, value) pairs are the header name and environment variable whose value should be used. If the environment variable is not set, or the value is empty, the header will not be included in the request.
request_max_retries: Option<u64>Maximum number of times to retry a failed HTTP request to this provider.
stream_max_retries: Option<u64>Number of times to retry reconnecting a dropped streaming response before failing.
stream_idle_timeout_ms: Option<u64>Idle timeout (in milliseconds) to wait for activity on a streaming response before treating the connection as lost.
requires_openai_auth: boolWhether this provider requires some form of standard authentication (API key, ChatGPT token).
Implementations§
Source§impl ModelProviderInfo
impl ModelProviderInfo
Sourcepub async fn create_request_builder<'a>(
&'a self,
client: &'a Client,
auth: &Option<CodexAuth>,
) -> Result<RequestBuilder>
pub async fn create_request_builder<'a>( &'a self, client: &'a Client, auth: &Option<CodexAuth>, ) -> Result<RequestBuilder>
Construct a POST RequestBuilder for the given URL using the provided
reqwest Client applying:
• provider-specific headers (static + env based)
• Bearer auth header when an API key is available.
• Auth token for OAuth.
If the provider declares an env_key but the variable is missing/empty, returns an Err identical to the
one produced by ModelProviderInfo::api_key.
Sourcepub fn api_key(&self) -> Result<Option<String>>
pub fn api_key(&self) -> Result<Option<String>>
If env_key is Some, returns the API key for this provider if present
(and non-empty) in the environment. If env_key is required but
cannot be found, returns an error.
Sourcepub fn request_max_retries(&self) -> u64
pub fn request_max_retries(&self) -> u64
Effective maximum number of request retries for this provider.
Sourcepub fn stream_max_retries(&self) -> u64
pub fn stream_max_retries(&self) -> u64
Effective maximum number of stream reconnection attempts for this provider.
Sourcepub fn stream_idle_timeout(&self) -> Duration
pub fn stream_idle_timeout(&self) -> Duration
Effective idle timeout for streaming responses.
Trait Implementations§
Source§impl Clone for ModelProviderInfo
impl Clone for ModelProviderInfo
Source§fn clone(&self) -> ModelProviderInfo
fn clone(&self) -> ModelProviderInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModelProviderInfo
impl Debug for ModelProviderInfo
Source§impl<'de> Deserialize<'de> for ModelProviderInfo
impl<'de> Deserialize<'de> for ModelProviderInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ModelProviderInfo
impl PartialEq for ModelProviderInfo
Source§impl Serialize for ModelProviderInfo
impl Serialize for ModelProviderInfo
impl StructuralPartialEq for ModelProviderInfo
Auto Trait Implementations§
impl Freeze for ModelProviderInfo
impl RefUnwindSafe for ModelProviderInfo
impl Send for ModelProviderInfo
impl Sync for ModelProviderInfo
impl Unpin for ModelProviderInfo
impl UnwindSafe for ModelProviderInfo
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more